Jump to content

TheTrollguy_

Forge Modder
  • Posts

    71
  • Joined

  • Last visited

Everything posted by TheTrollguy_

  1. Welp thanks for that, will edit my code. At this momment I'm focused on making this mod actually work, I will focus on bugs later on. (Also I didn't bump the thread after an hour, I waited ~2 days.
  2. Long story short, I wanted to change my blocks' collision box, but it seems that it gets sets inappropriately - whatever the state of the block is, every entity stands ~1 block higher than it should be. Also, whenever I pick-block my block, I get the wrong 'meta'. Let's say I pick-block on my block with meta 8 and I have the block in inventory with meta 13, it'll just select the block with meta 13 that is already in the inventory, instead of giving me a new item stack with the appropriate meta. THE PROBLEMS: - weird collision box - wrong meta returned on pick-block Here's the whole block class BlockSidewalk.class package tt.trafficstuffmod.sidewalks; import java.util.List; import java.util.Random; import javax.annotation.Nullable; import org.apache.commons.lang3.StringUtils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import tt.trafficstuffmod.main.TrafficStuffMod; public class BlockSidewalk extends Block { public static final PropertyInteger HEIGHT = PropertyInteger.create("height", 1, 16); private static final double pixel = 0.0625; protected boolean isSpecial = false; public BlockSidewalk(String name, Block oppositeBlock) { super(Material.ROCK); GameRegistry.register(this.setRegistryName(name).setUnlocalizedName(name)); loadProperties(); registerItemBlocks(oppositeBlock, name); } public BlockSidewalk(String name) { super(Material.ROCK); this.isSpecial = true; GameRegistry.register(this.setRegistryName(name).setUnlocalizedName(name)); loadProperties(); } /* PROPERTIES CODE */ private void loadProperties() { setCreativeTab(TrafficStuffMod.tsm_tabSidewalk); setDefaultState(blockState.getBaseState().withProperty(HEIGHT, 16)); } private void registerItemBlocks(Block oppositeBlock, String name) { GameRegistry.register(new ItemBlockSidewalk(this, oppositeBlock).setRegistryName(this.getRegistryName())); TrafficStuffMod.registerItemModelsForBlockWith16Metadata(this, name); } @Override public boolean canSilkHarvest(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer entityPlayer) { return false; } @Override public boolean isOpaqueCube(IBlockState blockState) { return blockState.getValue(HEIGHT) == 16; } @Override public boolean isFullCube(IBlockState blockState) { return isOpaqueCube(blockState); } @Override public boolean isSideSolid(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos, EnumFacing facing) { if (isSpecial && facing == EnumFacing.UP) { return true; } if (!isSpecial && facing == EnumFacing.DOWN) { return true; } if (blockState.getValue(HEIGHT) == 16) { return true; } else { return false; } } /* BOUNDING AND COLLISION BOX CODE */ @Override public AxisAlignedBB getBoundingBox(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos) { return isSpecial ? new AxisAlignedBB(0.0, 1 - blockState.getValue(HEIGHT)*pixel, 0.0, 1.0, 1.0, 1.0) : new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, blockState.getValue(HEIGHT)*pixel, 1.0); } @Override public void addCollisionBoxToList(IBlockState blockState, World world, BlockPos blockPos, AxisAlignedBB axisAlignedBB, List<AxisAlignedBB> list, @Nullable Entity entity) { list.add(isSpecial ? new AxisAlignedBB(0.0, 1 - blockState.getValue(HEIGHT)*pixel, 0.0, 1.0, 1.0, 1.0) : new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, blockState.getValue(HEIGHT)*pixel, 1.0)); } /* BLOCK STATE CODE */ @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {HEIGHT}); } @Override public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(HEIGHT, meta + 1); } @Override public int getMetaFromState(IBlockState blockState) { return blockState.getValue(HEIGHT) - 1; } @Override public IBlockState getActualState(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPosition) { return blockState.withProperty(HEIGHT, blockState.getValue(HEIGHT)); } /* DROP, PICK AND TAB CODE */ @Override public Item getItemDropped(IBlockState blockState, Random random, int fortune) { return Item.getItemFromBlock(Block.getBlockFromName(TrafficStuffMod.MODID + ":sidewalk_normal_" + StringUtils.substringAfterLast(getUnlocalizedName(), "_"))); } @Override public int damageDropped(IBlockState blockState) { return getMetaFromState(blockState); } @Override public ItemStack getPickBlock(IBlockState blockState, RayTraceResult rayTraceResult, World world, BlockPos blockPos, EntityPlayer entityPlayer) { return new ItemStack(Block.getBlockFromName("trafficstuffmod:sidewalk_normal_" + StringUtils.substringAfterLast(getUnlocalizedName(), "_")), 1, blockState.getValue(HEIGHT) - 1); } @SideOnly(Side.CLIENT) @Override public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { if (!isSpecial) { for (int meta = 15; meta >=0; meta --) { list.add(new ItemStack(this, 1, meta)); } } } } So can anyone tell me what would be the cause of these 2 problems?
  3. WOW, how did I not notice that, thank you Anyway, after changing the order to: 1) pushing Matrix 2) translation to the middle of the block 3) rotation on all axes 4) translation back to the original point 5) setting block bounds and textures (my customized code that does nothing special) 6) popping matrix the part of it doesn't rotate at all...
  4. I've been stuck on this problem for a while now and I can't figure it out. Probs this will have and awfully easy solution, but I'm in a hurry now and I need help. What I'm trying to do is render a pole block. For the sake of getting help and not confusing you let's say it contains two parts: 1) pole part on Y axis (is basically looks like a fence post) 2) a tiny chunk facing north The problem is, when I render it just on the whole axis or just the chunk, it's normally rendered, but if I try both, the rotations get messed up and basically both parts are rotated the way and then they overlap. I'm using a rendering helper I made myself and here are a lot of custom methods, booleans, etc, so here it is with what it looks like *places inside renderTileEntityAt* vertexBuffer.begin(7, DefaultVertexFormats.POSITION_TEX); GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); renderPoleOnAxis(EnumAxis.Yaxis); **** renderPolePart(EnumDirection.NORTH); **** Tessellator.getInstance().draw(); GlStateManager.popMatrix(); **** methods contain following: 1) translation to the middle of the block 2) rotation on all axes 3) translation back to the original point 4) pushing Matrix 5) setting block bounds and textures (my customized code that does nothing special) 6) popping matrix
  5. Okay, I've got everything I need, now I'm using TESR for something else. I found tutorials for 1.8.9 and they use WorldRenderer, but I can't find that class in 1.9.4, with what class has it been replaced?
  6. So with the introduction of the new block model rendering system in 1.8, ISBRH has been removed. I've made a block that uses Minecraft's new system, but the thing is the block has over 4000 states, which is absurd and the best way to render that block wouldn't be through Minecraft's rendering system, but rather through a hardcoded render in java. So is there a replacement for ISBRH and if there is are there any tutorials for it. BTW: Using TESR would be a horrible choice since the block I'm making would be placed a lot around the world.
  7. I kinda feel like an idiot right now. Thank you, but here's the thing: the colour doesnt have to be saved since it is determined by the time in the world. I'm really confused now since this should kinda work like redstone dust, one block and hundreds of states. Now that I'm writing this, maybe I should look its code....
  8. I'm sorry for the misunderstanding. I was walking and talking at the same time while I was writing that. What I meant was: how do I change the "colour" state/property/whateverItIs called and if there is a method to change it since I'm not home ATM and I can't get to MC's code. I'm still not home though EDIT: Looks like I'm not that good at expressing my thoughts...
  9. Well after thinking about it I'll have to use TE, don't ask why. Just a stupid question: I'm not home atm so I can't look at MC's code, but is there a method for chaning a block's property?
  10. I was thinking about how this should actually work. If I need the exact tick to switch its state, does that mean that I also need a tile entity since from what I've seen they "tick every game tick"?
  11. Welp, I don't know what to do anymore, I tried my best, but I can't get this to work. What I'm trying to do is switch my block's property "colour" if the tick is under specified conditions as seen in the code, but all I get is the block that does change the "facing" property, but the "colour" property is always "green". Here's the code, what am I doing wrong? package tt.trafficStuffMod.trafficLights; import java.util.List; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.IStringSerializable; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockTrafficLights extends Block { public static final PropertyEnum COLOUR = PropertyEnum.create("colour", BlockTrafficLights.EnumColour.class); public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public enum EnumColour implements IStringSerializable { ON(0, "off"), OFF(1, "on"), RED(2, "red"), YELLOW(3, "yellow"), GREEN(4, "green"); private int colour_value; private String colour_name; private EnumColour(int value, String name) { this.colour_value = value; this.colour_name = name; } public String getName() { return colour_name; } public int getValue() { return colour_value; } } private EnumColour[] colours = {EnumColour.OFF, EnumColour.ON, EnumColour.RED, EnumColour.YELLOW, EnumColour.GREEN}; public BlockTrafficLights() { super(Material.iron); this.setUnlocalizedName("trafficLights"); this.setCreativeTab(CreativeTabs.tabBlock); this.setLightLevel(0.9F); this.setTickRandomly(true); this.setDefaultState(blockState.getBaseState().withProperty(COLOUR, EnumColour.ON).withProperty(FACING, EnumFacing.NORTH)); } @Override public boolean isOpaqueCube() { return false; } @Override public boolean isFullCube() { return false; } @SideOnly(Side.CLIENT) public EnumWorldBlockLayer getBlockLayer() { return EnumWorldBlockLayer.SOLID; } @Override protected BlockState createBlockState() { return new BlockState(this, new IProperty[] {COLOUR, FACING}); } @Override public int getMetaFromState(IBlockState blockState) { return ((EnumFacing) blockState.getValue(FACING)).getHorizontalIndex(); } public IBlockState getActualState(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPosition) { return blockState.withProperty(FACING, blockState.getValue(FACING)).withProperty(COLOUR, blockState.getValue(COLOUR)); } @Override public int damageDropped(IBlockState blockState) { return getMetaFromState(blockState); } @Override public void getSubBlocks(Item item, CreativeTabs creativeTab, List list) { for (int i = 0; i < 4; i++) list.add(new ItemStack(item, 1, i)); } @Override public ItemStack getPickBlock(MovingObjectPosition movingObjectPosition, World world, BlockPos blockPosition) { return new ItemStack(this, 1, this.getMetaFromState(world.getBlockState(blockPosition))); } @Override public boolean getTickRandomly() { return true; } public void updateTick(World world, BlockPos blockPosition, IBlockState blockState, Random random) { super.updateTick(world, blockPosition, blockState, random); long tick = world.getWorldTime()%1000; System.out.println(tick); if (tick >= 0 && tick < 350 ) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[4]), 4); } if (tick >= 350 && tick < 370) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[1]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 370 && tick < 390) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[4]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 390 && tick < 410) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[1]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 410 && tick < 430) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[4]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 430 && tick < 450) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[1]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 450 && tick < 500) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[3]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 500 && tick < 850) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[2]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 850 && tick < 870) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[1]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 870 && tick < 890) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[2]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 890 && tick < 910) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[1]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 910 && tick < 930) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[2]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 930 && tick < 950) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[1]).withProperty(FACING, blockState.getValue(FACING)), 4); } if (tick >= 950 && tick < 1000) { world.setBlockState(blockPosition, blockState.withProperty(COLOUR, colours[3]), 4); } } public IBlockState onBlockPlaced(World world, BlockPos blockPos, EnumFacing facing, float X, float Y, float Z, int integer, EntityLivingBase entityLivingBase) { if (entityLivingBase.isSneaking()) { return getDefaultState().withProperty(FACING, entityLivingBase.getHorizontalFacing().getOpposite()); } else { return getDefaultState().withProperty(FACING, entityLivingBase.getHorizontalFacing()); } } }
  12. So recently I've been kinda playing with what Minecraft 1.8 has to offer and I've encountered some problems. The thing is I'm trying to make a block that has two properties: facing and colour. Now the only property that needs to be saved is the facing one - I save it using metadata, the colour property is determined by the tick in the world. I don't really have time to lose, so can anyone tell me what I need to do to: 1) save the first property ; 2) to determine depending on the world tick what the second property is?
  13. Well looks like the universe hates me and trolls me all the time, it's appearing now but in some chunks it doesn't
  14. When I do that the texture doesn't show up from the behind I'm going to try this again but it just doesn't work, I don't know why
  15. Hi, I have 2 things that I just don't get. The first one is how can I make a block face visible from it's behind, just one face! And I know I should disable the culling with GL11, but that just doesn't work for if I don't do tessellator.draw(); which I can't use if using ISBRH. So how do I do that? And the next problem if I flip my texture using tessellator (you know how that is done) why do I have to disable culling? If I do that everything becomes messed up (glass block becomes strange - you can see it's faces from it's behind). So can someone explain me how to do these things?
  16. I just tested it without tessellator.startDrawingQuads() and tessellator.draw() and it works fine. And it doesn't call these methods in the renderInvetnoryBlock method either. Anyway thanks for the help; PROBLEM SOLVED!
  17. So Minecraft works something like this: 1. tessellator.startDrawingQuads(); // done by Minecraft 2. rendering my block 3. tessellator.draw(); // done by Minecraft so I should just throw them away from my code, right?
  18. Hey guys. So recently I've started playing with the Tessellator and it's going really good actually. I used it for my item renderer because I have some weird shapes. But then I tried to use it in my custom block renderer and it got bad. So usually one will start with the tessellator by this: tessellator.startDrawingQuads(); and then you'll add vertices and then one will use tessellator.draw(); (with some translations and other lighting stuff which I'm capable of fixing). But there's one thing which bugs me the most. If I don't use the tessellator.startDrawingQuads(); it'll give me a crash report saying: "Not tessellating!" and if I use it it will say "Already tessellating!". Here's what I use for my code: AsphaltRenderer_0.java (ISBRH) - renderWorldBlock method. @Override public boolean renderWorldBlock(IBlockAccess iBlockAccess, int X, int Y, int Z, Block block, int modelID, RenderBlocks renderer) { Tessellator tessellator = Tessellator.instance; int metadata = iBlockAccess.getBlockMetadata(X, Y, Z); int lightValue = block.getMixedBrightnessForBlock(iBlockAccess, X, Y, Z); double blockHeight = 0.75D; tessellator.addTranslation(-0.5F, -0.5F, -0.5F); tessellator.startDrawingQuads(); // Imagine if this was just adding vertices for the block's bottom face RenderingHelper.renderBlockBottomFace(tessellator, X, Y, Z, X + 1.0D, Y+ blockHeight, Z + 1.0D, AsphaltSet_0.mainTextures[0], 0, false); tessellator.Draw(); tessellator.addTranslation(0.5F, 0.5F, 0.5F); return true; } Can someone tell me why is this happening?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.