
TheTrollingTrollguy
Forge Modder-
Posts
64 -
Joined
-
Last visited
Everything posted by TheTrollingTrollguy
-
Hi guys, it's me again. I have a blocks that has one asphalt texture and it says here. In my renderer I "stick" some texture on it's top face, but they don't render and by the way how can I make them able to rotate only themselves, not touching the base texture? Here's the code: RenderBlocksOfAsphalt_Yellow_0 package trafficStuffMod.client; import org.lwjgl.opengl.GL11; import trafficStuffMod.common.*; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class RenderBlocksOfAsphalt_Yellow_0 implements ISimpleBlockRenderingHandler { public static int blocksOfAsphalt_Yellow_0_renderID; public RenderBlocksOfAsphalt_Yellow_0() { RenderBlocksOfAsphalt_Yellow_0.blocksOfAsphalt_Yellow_0_renderID = RenderingRegistry.getNextAvailableRenderId(); } @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderBlocks) { /** Tessellator tessellator = Tessellator.instance; GL11.glTranslatef(-0.5F, -0.5F, -0.5F); tessellator.startDrawingQuads(); renderBlocksOfAsphalt_Yellow_0(0, 0, 0, renderBlocks); tessellator.draw(); GL11.glTranslatef(0.5F, 0.5F, 0.5F); */ } @Override public boolean renderWorldBlock(IBlockAccess IBlockAccess, int X, int Y, int Z, Block block, int modelID, RenderBlocks renderBlocks) { Tessellator tessellator = Tessellator.instance; TileEntityBlocksOfAsphalt_Yellow_0 BOA_Yellow_0 = (TileEntityBlocksOfAsphalt_Yellow_0) IBlockAccess.getBlockTileEntity(X, Y, Z); BlocksOfAsphalt_Yellow_0 blocksOfAsphalt_Yellow_0 = (BlocksOfAsphalt_Yellow_0) TrafficStuffMod.blocksOfAsphalt_Yellow_0; int subtype = BOA_Yellow_0.getSubtype(); int age = BOA_Yellow_0.getAge(); switch (subtype) { case 1: renderBlocks.renderFaceYPos(blocksOfAsphalt_Yellow_0, X, Y, Z, BlocksOfAsphalt_Yellow_0.AY_1); renderBlocks.uvRotateTop = 0; break; case 2: renderBlocks.renderFaceYPos(blocksOfAsphalt_Yellow_0, X, Y, Z, BlocksOfAsphalt_Yellow_0.AY_2); renderBlocks.uvRotateTop = 0; break; case 3: renderBlocks.renderFaceYPos(blocksOfAsphalt_Yellow_0, X, Y, Z, BlocksOfAsphalt_Yellow_0.AY_1); renderBlocks.uvRotateTop = 1; break; case 4: renderBlocks.renderFaceYPos(blocksOfAsphalt_Yellow_0, X, Y, Z, BlocksOfAsphalt_Yellow_0.AY_2); renderBlocks.uvRotateTop = 1; break; case 5: renderBlocks.renderFaceYPos(blocksOfAsphalt_Yellow_0, X, Y, Z, BlocksOfAsphalt_Yellow_0.AY_1); renderBlocks.uvRotateTop = 3; break; case 6: renderBlocks.renderFaceYPos(blocksOfAsphalt_Yellow_0, X, Y, Z, BlocksOfAsphalt_Yellow_0.AY_2); renderBlocks.uvRotateTop = 3; break; case 7: renderBlocks.renderFaceYPos(blocksOfAsphalt_Yellow_0, X, Y, Z, BlocksOfAsphalt_Yellow_0.AY_1); renderBlocks.uvRotateTop = 2; break; case 8: renderBlocks.renderFaceYPos(blocksOfAsphalt_Yellow_0, X, Y, Z, BlocksOfAsphalt_Yellow_0.AY_2); renderBlocks.uvRotateTop = 2; break; } boolean flag = renderBlocks.renderStandardBlock(blocksOfAsphalt_Yellow_0, X, Y, Z); renderBlocks.uvRotateSouth = 0; renderBlocks.uvRotateEast = 0; renderBlocks.uvRotateWest = 0; renderBlocks.uvRotateNorth = 0; renderBlocks.uvRotateTop = 0; renderBlocks.uvRotateBottom = 0; return flag; } @Override public boolean shouldRender3DInInventory() { return true; } @Override public int getRenderId() { return ClientProxy.BOA_Yellow_0_renderID; } private void renderBlocksOfAsphalt_Yellow_0(int X, int Y, int Z, RenderBlocks renderBlocks) { } }
-
Nah, It looks like I'm just going to do textures that already have arrows on them, because of the lighting. Reasons why I wanted to have them separate is because I'm already using the arrow texture on a block so I wanted just to "stick" it to another block and to have less textures in my mod file after I release the new update. Since I can't really make any progress because of the lighting I'm switching back to my old system. Thanks for the help!
-
Hey guys, it's me again with another crazy idea. How can I make my block have multiple texture layers like the grass block has. What I want to do is to have a base texture on all sides, then have transparent textures on all sides(which in my case will be an arrow) and then the last layer for textures is on that kinda adds some "shadows" on the block, it is transparent too(it will represend the block age, which I have with my tile entity). So I have 3 layers: 1. base texture 2. arrow or line texture(transparent) 3. "shadows" texture(transparent) So what do I need to do? Add some methods to my block class, or make a renderer for my block? Tell me.
-
[SOLVED] TileEntity problem
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
Yes! It worked! Thank you Mazetar!!! -
[SOLVED] TileEntity problem
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
I really don't know what I'm doing right now, can you help me a little bit what should I do in that method, because I'm tired as f@ck so I don't know where my head is right now. -
[SOLVED] TileEntity problem
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
oh, it's nice to know that there will be no big changes that will be drama for me, anyway... yes, I've been looking on the Minecraft Forge Modding Tutorials Wiki and I saw that I'm missing the onDataPacket method, I'm adding it, let's see if it works! -
[SOLVED] TileEntity problem
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
here is a funny thing, I will have to rewrite everything, right? I'm talking about the packets because as I heard Minecraft now uses Netty for packet handling, right? -
[SOLVED] TileEntity problem
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
I did and it sets the correct subtype, but it doesn't when the world unloads/when you exit it -
Hello. I have a problem with my tile entity. When I place it in the world is has correct textures, but when I exit the world and enter it again, the textures reset. Basically I have a tile entity just to save what subtype my block has and based on that give it textures for all sides, but they reset and the subtype isn't saved after exiting the world. So can anyone help me? Code: BlocksOfAsphalt_White_0: package trafficStuffMod.common; import java.util.List; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlocksOfAsphalt_White_0 extends BlockContainer { public static final String[] subTypes = new String[] {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"}; @SideOnly(Side.CLIENT) private Icon ATW_0; @SideOnly(Side.CLIENT) private Icon ATW_1; @SideOnly(Side.CLIENT) private Icon ATW_2; @SideOnly(Side.CLIENT) private Icon ATW_3; @SideOnly(Side.CLIENT) private Icon ATW_4; @SideOnly(Side.CLIENT) private Icon ATW_5; @SideOnly(Side.CLIENT) private Icon ATW_6; @SideOnly(Side.CLIENT) private Icon ATW_7; @SideOnly(Side.CLIENT) private Icon ATW_8; @SideOnly(Side.CLIENT) private Icon ATW_9; @SideOnly(Side.CLIENT) private Icon ATW_10; @SideOnly(Side.CLIENT) private Icon ATW_11; @SideOnly(Side.CLIENT) private Icon ATW_12; @SideOnly(Side.CLIENT) private Icon ATW_13; @SideOnly(Side.CLIENT) private Icon ATW_14; @SideOnly(Side.CLIENT) private Icon ATW_15; @SideOnly(Side.CLIENT) private Icon ATW_16; @SideOnly(Side.CLIENT) private Icon ATW_17; @SideOnly(Side.CLIENT) private Icon ATW_18; @SideOnly(Side.CLIENT) private Icon ATW_19; @SideOnly(Side.CLIENT) private Icon ATW_20; @SideOnly(Side.CLIENT) private Icon ATW_21; @SideOnly(Side.CLIENT) private Icon ATW_22; @SideOnly(Side.CLIENT) private Icon ATW_23; @SideOnly(Side.CLIENT) private Icon ATW_24; public BlocksOfAsphalt_White_0(int ID, Material material) { super(ID, material); this.setCreativeTab(TrafficStuffMod.tabBlocksOfAsphalt); this.setStepSound(Block.soundStoneFootstep); } public TileEntity createNewTileEntity(World world) { return new TileEntityBlocksOfAsphalt_White_0(); } @Override public boolean hasTileEntity(int metadata) { return true; } @Override public void breakBlock(World world, int X, int Y, int Z, int ID, int metadata) { super.breakBlock(world, X, Y, Z, ID, metadata); world.removeBlockTileEntity(X, Y, Z); } @SideOnly(Side.CLIENT) public Icon getBlockTexture(IBlockAccess IBlockAccess, int X, int Y, int Z, int side) { TileEntityBlocksOfAsphalt_White_0 tileEntityBlocksOfAsphalt_White_0 = (TileEntityBlocksOfAsphalt_White_0) IBlockAccess.getBlockTileEntity(X, Y, Z); return this.getIcon(side, tileEntityBlocksOfAsphalt_White_0.getSubType()); } public Icon getIcon(int side, int meta) { if(meta == 0) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_0; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 1) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_1; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 2) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_2; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 3) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_3; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 4) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_4; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 5) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_5; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 6) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_6; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 7) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_7; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_8; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 9) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_9; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 10) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_10; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 11) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_11; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 12) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_12; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 13) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_13; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 14) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_14; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 15) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_15; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 16) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_16; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} if(meta == 17) {switch(side) {case 0: return this.ATW_0; case 1: return this.ATW_17; case 2: return this.ATW_0; case 3: return this.ATW_0; case 4: return this.ATW_0; case 5: return this.ATW_0;}} return this.blockIcon; } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { this.ATW_0 = iconRegister.registerIcon("asphaltTop"); this.ATW_1 = iconRegister.registerIcon("asphaltTop_white_1"); this.ATW_2 = iconRegister.registerIcon("asphaltTop_white_2"); this.ATW_3 = iconRegister.registerIcon("asphaltTop_white_3"); this.ATW_4 = iconRegister.registerIcon("asphaltTop_white_4"); this.ATW_5 = iconRegister.registerIcon("asphaltTop_white_5"); this.ATW_6 = iconRegister.registerIcon("asphaltTop_white_6"); this.ATW_7 = iconRegister.registerIcon("asphaltTop_white_7"); this.ATW_8 = iconRegister.registerIcon("asphaltTop_white_8"); this.ATW_9 = iconRegister.registerIcon("asphaltTop_white_9"); this.ATW_10 = iconRegister.registerIcon("asphaltTop_white_10"); this.ATW_11 = iconRegister.registerIcon("asphaltTop_white_11"); this.ATW_12 = iconRegister.registerIcon("asphaltTop_white_12"); this.ATW_13 = iconRegister.registerIcon("asphaltTop_white_13"); this.ATW_14 = iconRegister.registerIcon("asphaltTop_white_14"); this.ATW_15 = iconRegister.registerIcon("asphaltTop_white_15"); this.ATW_16 = iconRegister.registerIcon("asphaltTop_white_16"); this.ATW_17 = iconRegister.registerIcon("asphaltTop_white_17"); this.ATW_18 = iconRegister.registerIcon("asphaltTop_white_18"); this.ATW_19 = iconRegister.registerIcon("asphaltTop_white_19"); this.ATW_20 = iconRegister.registerIcon("asphaltTop_white_20"); this.ATW_21 = iconRegister.registerIcon("asphaltTop_white_21"); this.ATW_22 = iconRegister.registerIcon("asphaltTop_white_22"); this.ATW_23 = iconRegister.registerIcon("asphaltTop_white_23"); this.ATW_24 = iconRegister.registerIcon("asphaltTop_white_24"); } protected boolean canSilkHarvest() { return false; } @SideOnly(Side.CLIENT) public void getSubBlocks(int ID, CreativeTabs creativeTabs, List list) { for(int i = 0; i < this.subTypes.length; i++) { list.add(new ItemStack(ID, 1, i)); } } } ItemBlocksOfAsphalt_White_0: package trafficStuffMod.common; import java.util.Iterator; import java.util.List; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockSkull; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityEggInfo; import net.minecraft.entity.EntityList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntitySkull; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; public class ItemBlocksOfAsphalt_White_0 extends ItemBlock { static int blockID = TrafficStuffMod.blocksOfAsphalt_White_0.blockID; public static final String[] subTypes = new String[] {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39"}; public ItemBlocksOfAsphalt_White_0(int ID) { super(ID); this.setHasSubtypes(true); } public boolean shouldRotateAroundWhenRendering() { return true; } public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean something) { int subType = itemStack.getItemDamage(); if (subType == 0) { list.add("Plain"); } } @Override public boolean onItemUse(ItemStack itemStack, EntityPlayer entityPlayer, World world, int X, int Y, int Z, int side, float hitX, float hitY, float hitZ) { if (side == 0) { --Y; } if (side == 1) { ++Y; } if (side == 2) { --Z; } if (side == 3) { ++Z; } if (side == 4) { --X; } if (side == 5) { ++X; } if(itemStack.stackSize == 0) { return false; } else if (!entityPlayer.canPlayerEdit(X, Y, Z, side, itemStack)) { return false; } else if (Y == 255 && Block.blocksList[this.itemID].blockMaterial.isSolid()) { return false; } else { world.setBlock(X, Y, Z, this.blockID); int i1 = 0; TileEntity tileentity = world.getBlockTileEntity(X, Y, Z); if (tileentity != null && tileentity instanceof TileEntityBlocksOfAsphalt_White_0) { ((TileEntityBlocksOfAsphalt_White_0)tileentity).setSubType(itemStack.getItemDamage()); } --itemStack.stackSize; return true; } } public String getUnlocalizedName(ItemStack itemStack) { return "blocksOfAsphalt_White_0" + "." + itemStack.getItemDamage(); } } TileEntityBlocksOfAsphalt_White_0: package trafficStuffMod.common; import java.util.logging.Level; import cpw.mods.fml.common.FMLLog; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; public class TileEntityBlocksOfAsphalt_White_0 extends TileEntity { public int subType; public TileEntityBlocksOfAsphalt_White_0() {} public int getSubType() { return subType; } public void setSubType(int subTypes) { this.subType = subTypes; } @Override public void onChunkUnload() { NBTTagCompound NBT = new NBTTagCompound(); this.writeToNBT(NBT); } @Override public void readFromNBT(NBTTagCompound NBT) { super.readFromNBT(NBT); this.subType = NBT.getInteger("subType"); } @Override public void writeToNBT(NBTTagCompound NBT) { super.writeToNBT(NBT); NBT.setInteger("subType", subType); } @Override public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 4, nbttagcompound); } } and in my main class I have this: public static Block blocksOfAsphalt_White_0; public static int blocksOfAsphalt_White_0ID; public static TileEntity BOA_white_0 = new TileEntityBlocksOfAsphalt_White_0(); blocksOfAsphalt_White_0 = new BlocksOfAsphalt_White_0(blocksOfAsphalt_White_0ID, Material.rock).setHardness(15.0F).setResistance(20.0F).setUnlocalizedName("blocksOfAsphalt_0_white_0"); GameRegistry.registerBlock(blocksOfAsphalt_White_0, ItemBlocksOfAsphalt_White_0.class, "blocksOfAsphalt_White_0"); GameRegistry.registerTileEntity(TileEntityBlocksOfAsphalt_White_0.class, "tileEntityBlocksOfAsphalt_White_0");
-
Block with 100 metadatas problems
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
well I do get now why were you talking like this: delete this shit in your code I do have a little bit of java knowledge but I have so much to learn about anyway, thank you guys now Moritz, what did you mean with itemNBTData? -
Custom Chests Connecting to each other?
TheTrollingTrollguy replied to TLHPoE's topic in Modder Support
look at BlockChest.java, there are some methods that may help you -
Block with 100 metadatas problems
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
well, I'm speechless... -
Block with 100 metadatas problems
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
thanks Moritz! see I've been looking for someone that will help me like you without telling me to learn java or writing a text with rage. thank you very much! -
Block with 100 metadatas problems
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
so really, nothing else but learn java, I already know that, I came here because of something I don't know -
Block with 100 metadatas problems
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
well like other people say: I a Java noob.. -
Block with 100 metadatas problems
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
ok I found this code on a post on these forums and I just edited some things that I had to and I really didn't care for some things. and like you I do think that I need to read more about classes that Minecraft uses. -
OK, so I've been playing with tile entities for a week and I actually learned a lot, well kinda. But anyway. I wanted to make a block with more than 100 metadatas/subtypes and I already knew that I need tile entities. I was looking on the forums if anyone ever actually needed help with this and I found one but it helped me partially. What I did make is 100 blocks to appear in one creative tab and I learned how to put textures on those block that are actually tile entities. Now I've got problems that I can't solve and I need your help. The problems are: 1. Blocks don't have textures when placed on the world but they do have in the creative tab. 2. When I drop the block with metadata 1 and 0, they both make a single stack and after I pick it up, the stack will be blocks wit metadata 0. 3. A weird problem with names. This is actually the fist time I'm "playing" with tile entities, because I was stuck with blocks that have metadatas, so if there are some silly parts of my code feel free to laugh 'till you die. Here it is ItemBlockMegaBlock package asphaltMod.common; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.World; public class ItemBlockMegaBlock extends ItemBlock { private static final TileEntity TE = new TileEntityMegaBlock(); public ItemBlockMegaBlock(int ID) { super(ID); setHasSubtypes(true); this.setCreativeTab(CreativeTabs.tabBlock); } @SideOnly(Side.CLIENT) public Icon getIconFromDamage(int metadata) { TE.blockMetadata = metadata; return AsphaltMod.tileEntityTest.getIcon(2, this.TE.blockMetadata); } public int getMetadata(int metadata) { return this.TE.blockMetadata; } public int damageDropped(int par1) { return this.TE.blockMetadata; } public String getItemNameIS(ItemStack is) { this.TE.blockMetadata = is.getItemDamage(); return "asphaltBlocks_" + this.TE.blockMetadata; } public String getUnlocalizedName(ItemStack itemstack) { return getUnlocalizedName() + "." + itemstack.getItemDamage(); } } BlockMegaBlock package asphaltMod.common; import java.util.List; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockMegaBlock extends BlockContainer { private static TileEntity TE = new TileEntityMegaBlock(); @SideOnly(Side.CLIENT) private Icon AT_0; @SideOnly(Side.CLIENT) private Icon AT_1; @SideOnly(Side.CLIENT) private Icon[][] iconBuffer; public BlockMegaBlock(int par1, Material material) { super(par1, material); } public boolean hasTileEntity(int meta) { return true; } public TileEntity createNewTileEntity(World world) { this.TE.blockMetadata = 100; return new TileEntityMegaBlock(); } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister iconRegister) { this.AT_0 = iconRegister.registerIcon("asphalt_0"); this.AT_1 = iconRegister.registerIcon("asphalt_1"); } public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int side) { return this.getIcon(side, TE.blockMetadata); } public Icon getIcon(int side, int meta) { return meta == 0 ? (side == 0 ? this.AT_0 : (side == 1 ? this.AT_0 : (side == 2 ? this.AT_0 : (side == 3 ? this.AT_0 : (side == 4 ? this.AT_0 : (side == 5 ? this.AT_0 : this.blockIcon)))))) : (meta == 1 ? (side == 0 ? this.AT_0 : (side == 1 ? this.AT_1 : (side == 2 ? this.AT_0 : (side == 3 ? this.AT_0 : (side == 4 ? this.AT_0 : (side == 5 ? this.AT_0 : this.blockIcon)))))) : this.blockIcon); } public int idDropped(int ID, Random par2Random, int par3) { return this.blockID; } protected ItemStack createStackedBlock(int par1) { return new ItemStack(AsphaltMod.tileEntityTest.blockID, 1, par1); } public int damageDropped(int metadata) { return TE.blockMetadata; } @SideOnly(Side.CLIENT) public void getSubBlocks(int ID, CreativeTabs creativeTabs, List list) { int metadata = TE.blockMetadata; for(metadata = 0; metadata <= 100; metadata++) { list.add(new ItemStack(ID, 1, metadata)); } } } TileEntityMegaBlock package asphaltMod.common; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.tileentity.TileEntity; public class TileEntityMegaBlock extends TileEntity { public static int blockMetadata; public TileEntityMegaBlock() { } @Override public void writeToNBT(NBTTagCompound nbt) { nbt.setInteger("metadata", blockMetadata); super.writeToNBT(nbt); } @Override public void readFromNBT(NBTTagCompound nbt) { blockMetadata = nbt.getInteger("metadata"); super.readFromNBT(nbt); } public int getBlockMetadata() { return this.blockMetadata; } public void setMeta(int metadata) { this.blockMetadata = metadata; } public TileEntity returnTE() { return this; } } And things in my mods' main class: public static Block tileEntityTest; tileEntityTest = new BlockMegaBlock(700, Material.rock).setCreativeTab(CreativeTabs.tabTransport); GameRegistry.registerBlock(tileEntityTest, ItemBlockMegaBlock.class, "TET"); GameRegistry.registerTileEntity(TileEntityMegaBlock.class, "watafak"); Note: This is only just a test for me to see how to make blocks with more than 16 metadatas. This isn't the final code. So can anyone help me?
-
How to make a block with more than 16 metadatas?
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
I did but can someone help me? -
How to make a block with more than 16 metadatas?
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
Well it did help a little bit, but what I really wanna do is to make a block with around 100 subtypes. I only want to change textures, that's all. So maybe some code will be helpfull. -
Asphalt Mod [1.2.0] for Minecraft 1.6.4
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Mods
Go to my FB page to get the latest new about the Asphalt Mod -
Here is the link for the mod, it's on Minecraft Forums: http://www.minecraftforum.net/topic/1892017-asphalt-mod-110-for-minecraft-162/#entry23364297
-
Loading a block ID from a .txt file
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
nonono, in what folder? -
Loading a block ID from a .txt file
TheTrollingTrollguy replied to TheTrollingTrollguy's topic in Modder Support
P.S. where is the config file location?