Posted July 22, 201510 yr Hi there. I have made a new torch class in my mod and would like to add a fire animation to a torch. I don't know where to start. I have tried to find the torch class but can't.. Any tips? Zen
July 22, 201510 yr Hi Depends what you mean by animation. Torch in your hand, or in the world (as a block)? BlockTorch is the vanilla torch. But BlockFire might be more interesting. Best way for block animation is by animated textures. You can do that with mcmeta textures, for example see fire_layer_0.png and fire_layer_0.png.mcmeta. A google on animated textures will also bring up a relevant tutorial or two. -TGG
July 29, 201510 yr Author Hi Depends what you mean by animation. Torch in your hand, or in the world (as a block)? BlockTorch is the vanilla torch. But BlockFire might be more interesting. Best way for block animation is by animated textures. You can do that with mcmeta textures, for example see fire_layer_0.png and fire_layer_0.png.mcmeta. A google on animated textures will also bring up a relevant tutorial or two. -TGG Thanks so much for your reply it got me on the right track. I cant believe I could not find the BlockTorch it was so simple.. to tired I am guessing. For those how are trying to do the same thing here the code in my class that i made. I didn't use the smoke in the end so just deleted those lines. @Override public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); double d0 = (double)pos.getX() + 0.5D; double d1 = (double)pos.getY() + 0.55D; double d2 = (double)pos.getZ() + 0.5D; double d3 = 0.18D; double d4 = 0.20D; double d5 = (double)pos.getX() + 0.5D; double d6 = (double)pos.getY() + 0.6D; double d7 = (double)pos.getZ() + 0.5D; if (enumfacing.getAxis().isHorizontal()) { EnumFacing enumfacing1 = enumfacing.getOpposite(); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4 * (double)enumfacing1.getFrontOffsetX(), d1 + d3, d2 + d4 * (double)enumfacing1.getFrontOffsetZ(), 0.0D, 0.0D, 0.0D, new int[0]); } else { worldIn.spawnParticle(EnumParticleTypes.FLAME, d5, d6, d7, 0.0D, 0.0D, 0.0D, new int[0]); } } The full class. public class CustomLight extends BlockTorch { private Item dropsOnHarvest; private int dropamountmax = 1; private int maxharvestEXP = 0; public CustomLight(Material material, String name, float hardness, float resistance, CreativeTabs zentab, HarvestToolEnum harvesttool, HarvestLevelEnum harvestlevel) { super(); this.setUnlocalizedName(name); this.setHardness(hardness); this.setResistance(resistance); this.setStepSound(soundTypePiston); this.setCreativeTab(Main.zentab); this.setLightLevel(1.0f); this.setLightOpacity(0); this.setHarvestLevel(harvesttool, harvestlevel); this.useNeighborBrightness = true; GameRegistry.registerBlock(this, name); this.dropsOnHarvest = Item.getItemFromBlock(this); } @Override public boolean isOpaqueCube() { return false; } @SideOnly(Side.CLIENT) public EnumWorldBlockLayer getBlockLayer() { return EnumWorldBlockLayer.CUTOUT; } @Override public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); double d0 = (double)pos.getX() + 0.5D; double d1 = (double)pos.getY() + 0.55D; double d2 = (double)pos.getZ() + 0.5D; double d3 = 0.18D; double d4 = 0.20D; double d5 = (double)pos.getX() + 0.5D; double d6 = (double)pos.getY() + 0.6D; double d7 = (double)pos.getZ() + 0.5D; if (enumfacing.getAxis().isHorizontal()) { EnumFacing enumfacing1 = enumfacing.getOpposite(); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4 * (double)enumfacing1.getFrontOffsetX(), d1 + d3, d2 + d4 * (double)enumfacing1.getFrontOffsetZ(), 0.0D, 0.0D, 0.0D, new int[0]); } else { worldIn.spawnParticle(EnumParticleTypes.FLAME, d5, d6, d7, 0.0D, 0.0D, 0.0D, new int[0]); } } public void RegisterRenderer(String modelName) { System.out.println("REGISTERING BLOCK RENDERER: " + modelName); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(this), 0, new ModelResourceLocation(Main.MODID+":"+modelName, "inventory")); } public void setHarvestLevel(HarvestToolEnum harvesttool, HarvestLevelEnum harvestlevel) { int level; String tool; switch(harvesttool) { case PICKAXE: tool = "pickaxe"; break; case SHOVEL: tool = "shovel"; break; case AXE: tool = "axe"; break; default: tool = "pickaxe"; } switch(harvestlevel) { case WOOD: level = 0; break; case STONE: level = 1; break; case IRON: level = 2; break; case DIAMOND: level = 3; break; case GOLD: level = 0; break; default: level = 0; } super.setHarvestLevel(tool, level); } public static enum HarvestToolEnum { PICKAXE, SHOVEL, AXE; } public static enum HarvestLevelEnum { WOOD, STONE, IRON, DIAMOND, GOLD; } public void setMaxHarvestEXP(int expAmount) { maxharvestEXP = expAmount; } public void setDrops(Item drops) { this.dropsOnHarvest = drops; } public void setDrops(Block drops) { this.dropsOnHarvest = Item.getItemFromBlock(drops); } public void setDropMaxAmount(int dropamount) { this.dropamountmax = dropamount; } public Item getItemDropped(IBlockState state, Random rand, int fortune) { return this.dropsOnHarvest; } public int quantityDropped(Random random) { int amount = random.nextInt(this.dropamountmax)+1; return amount; } public int getExpDrop(IBlockAccess world, BlockPos pos, int fortune) { IBlockState state = world.getBlockState(pos); Random rand = world instanceof World ? ((World)world).rand : new Random(); if (this.getItemDropped(state, rand, fortune) != Item.getItemFromBlock(this)) { return MathHelper.getRandomIntegerInRange(rand, 0, maxharvestEXP); } return 0; } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.