From 5a54630291bf7a0f38afc713d533454a3096e138 Mon Sep 17 00:00:00 2001 From: Ruling-0 <47913168+Ruling-0@users.noreply.github.com> Date: Thu, 16 Jan 2025 03:08:59 -0600 Subject: [PATCH] Slab Refactor and Everything Burns --- .../java/mods/natura/blocks/GrassSlab.java | 33 ++++- .../java/mods/natura/blocks/NSlabBase.java | 124 ++++++++++-------- .../blocks/overrides/AlternateBookshelf.java | 23 +++- .../blocks/overrides/AlternateFence.java | 24 ++++ .../natura/blocks/trees/DarkTreeBlock.java | 26 +--- .../natura/blocks/trees/FruitTreeBlock.java | 47 ------- .../mods/natura/blocks/trees/LogTwoxTwo.java | 15 +-- .../mods/natura/blocks/trees/NLeaves.java | 44 +------ .../natura/blocks/trees/NLeavesNocolor.java | 23 ++++ .../blocks/trees/OverworldTreeBlock.java | 7 - .../java/mods/natura/blocks/trees/Planks.java | 24 ++-- .../mods/natura/blocks/trees/SimpleLog.java | 10 +- .../mods/natura/blocks/trees/TreeBlock.java | 24 +++- .../mods/natura/blocks/trees/WillowBlock.java | 8 -- .../java/mods/natura/common/NContent.java | 100 +++++++------- .../natura/items/blocks/GrassSlabItem.java | 20 +-- .../natura/items/blocks/NSlabBaseItem.java | 13 ++ .../natura/items/blocks/PlankSlab1Item.java | 89 ------------- .../natura/items/blocks/PlankSlab2Item.java | 87 ------------ 19 files changed, 289 insertions(+), 452 deletions(-) delete mode 100644 src/main/java/mods/natura/blocks/trees/FruitTreeBlock.java create mode 100644 src/main/java/mods/natura/items/blocks/NSlabBaseItem.java delete mode 100644 src/main/java/mods/natura/items/blocks/PlankSlab1Item.java delete mode 100644 src/main/java/mods/natura/items/blocks/PlankSlab2Item.java diff --git a/src/main/java/mods/natura/blocks/GrassSlab.java b/src/main/java/mods/natura/blocks/GrassSlab.java index 42e3a23f..7a0704b3 100644 --- a/src/main/java/mods/natura/blocks/GrassSlab.java +++ b/src/main/java/mods/natura/blocks/GrassSlab.java @@ -1,7 +1,11 @@ package mods.natura.blocks; import java.util.List; +import java.util.Random; +import mods.natura.common.NContent; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSlab; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -18,12 +22,17 @@ import mods.natura.client.GrassColorizerAlternate; import mods.natura.common.NaturaTab; -public class GrassSlab extends NSlabBase { +public class GrassSlab extends BlockSlab { - public GrassSlab() { - super(Material.ground); - setHardness(0.6F); - this.setCreativeTab(NaturaTab.tab); + public static final String blockType[] = { "grass", "bluegrass", "autumngrass" }; + + public GrassSlab(boolean isDoubleSlab) { + super(isDoubleSlab, Material.ground); + this.setHardness(0.6F); + this.setStepSound(Block.soundTypeGrass); + if (!isDoubleSlab) { + this.setCreativeTab(NaturaTab.tab); + } } @Override @@ -32,12 +41,26 @@ public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon("natura:grass_top"); } + @Override + public String func_150002_b(int meta) + { + if (meta < 0 || meta >= blockType.length) meta = 0; + return "block.soil." + blockType[meta] + ".slab"; + } + @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { return this.blockIcon; } + @Override + public Item getItemDropped(int meta, Random random, int fortune) { + // if double slab + if (field_150004_a) return Item.getItemFromBlock(NContent.grassSlab); + return Item.getItemFromBlock(this); + } + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item id, CreativeTabs tab, List list) { diff --git a/src/main/java/mods/natura/blocks/NSlabBase.java b/src/main/java/mods/natura/blocks/NSlabBase.java index 5211823c..878163ff 100644 --- a/src/main/java/mods/natura/blocks/NSlabBase.java +++ b/src/main/java/mods/natura/blocks/NSlabBase.java @@ -1,102 +1,114 @@ package mods.natura.blocks; import java.util.List; +import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; +import mods.natura.common.NContent; +import net.minecraft.block.BlockWoodSlab; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mods.natura.common.NaturaTab; +import net.minecraftforge.common.util.ForgeDirection; -public class NSlabBase extends Block { +public class NSlabBase extends BlockWoodSlab { - Block modelBlock; - int startingMeta; - int totalSize; + public static String[] woodNames = new String[] { "eucalyptus", "sakura", "ghost", "redwood", "blood", + "bush", "maple", "silverbell", "purpleheart", "tiger", "willow", "darkwood", "fusewood" }; + private final int group; - public NSlabBase(Material material) { - super(material); - this.setCreativeTab(NaturaTab.tab); - } - - public NSlabBase(Material material, Block model, int meta, int totalSize) { - super(material); - this.setCreativeTab(NaturaTab.tab); - this.modelBlock = model; - this.startingMeta = meta; - this.totalSize = totalSize; + public NSlabBase(boolean isDoubleSlab, int grp) { + super(isDoubleSlab); + this.setHardness(2.0F); + this.setResistance(5.0F); + if (!isDoubleSlab) { + this.setCreativeTab(NaturaTab.tab); + } + group = grp; } @Override - public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, - Entity entity) { - setBlockBoundsBasedOnState(world, x, y, z); - super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity); + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return NContent.planks.getIcon(side, getWoodMeta(meta)); } @Override - public void setBlockBoundsForItemRender() { - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + public Item getItemDropped(int meta, Random random, int fortune) { + // if double slab + if (field_150004_a) { + if (this == NContent.plankSlab1Double) return Item.getItemFromBlock(NContent.plankSlab1); + else return Item.getItemFromBlock(NContent.plankSlab2); + } + else return Item.getItemFromBlock(this); } @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z) / 8; - float minY = meta == 1 ? 0.5F : 0.0F; - float maxY = meta == 1 ? 1.0F : 0.5F; - setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F); + public String func_150002_b(int meta) + { + return "block.wood." + woodNames[getWoodMeta(meta)] + ".slab"; } @Override - public int onBlockPlaced(World par1World, int blockX, int blockY, int blockZ, int side, float clickX, float clickY, - float clickZ, int metadata) { - if (side == 1) return metadata; - if (side == 0 || clickY >= 0.5F) return metadata | 8; - - return metadata; + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = getWoodMeta(world.getBlockMetadata(x, y, z)); + if (metadata == 2 || metadata == 4 || metadata > 10) return 0; + return Blocks.fire.getFlammability(this); } @Override - public boolean isOpaqueCube() { - return false; + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = getWoodMeta(world.getBlockMetadata(x, y, z)); + if (metadata == 2 || metadata == 4 || metadata > 10) return 0; + return Blocks.fire.getEncouragement(this); } @Override - public boolean renderAsNormalBlock() { - return false; + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = getWoodMeta(world.getBlockMetadata(x, y, z)); + if (metadata == 2 || metadata == 4 || metadata > 10) return false; + return getFlammability(world, x, y, z, face) > 0; } @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) {} - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) { - meta = meta % 8 + startingMeta; - return modelBlock.getIcon(side, meta); + public void getSubBlocks(Item id, CreativeTabs tab, List list) { + if (group == 1) { + if (id != Item.getItemFromBlock(NContent.plankSlab1Double)) { + for (int iter = 0; iter < 8; iter++) { + list.add(new ItemStack(id, 1, iter)); + } + } + } + else { + if (id != Item.getItemFromBlock(NContent.plankSlab2Double)) { + for (int iter = 0; iter < 5; iter++) { + list.add(new ItemStack(id, 1, iter)); + } + } + } } @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item id, CreativeTabs tab, List list) { - for (int iter = 0; iter < totalSize; iter++) { - list.add(new ItemStack(id, 1, iter)); + protected ItemStack createStackedBlock(int meta) + { + if (group == 1) { + return new ItemStack(Item.getItemFromBlock(NContent.plankSlab1), 2, meta & 7); + } + else { + return new ItemStack(Item.getItemFromBlock(NContent.plankSlab2), 2, meta & 7); } } - @Override - public int damageDropped(int meta) { - return meta % 8; + private int getWoodMeta(int meta) { + meta = (meta & 7) + (group-1) * 8; + if (meta < 0 || meta >= woodNames.length) meta = 0; + return meta; } } diff --git a/src/main/java/mods/natura/blocks/overrides/AlternateBookshelf.java b/src/main/java/mods/natura/blocks/overrides/AlternateBookshelf.java index 6c034b2a..140de9e1 100644 --- a/src/main/java/mods/natura/blocks/overrides/AlternateBookshelf.java +++ b/src/main/java/mods/natura/blocks/overrides/AlternateBookshelf.java @@ -5,14 +5,17 @@ import net.minecraft.block.BlockBookshelf; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mods.natura.common.NContent; +import net.minecraftforge.common.util.ForgeDirection; public class AlternateBookshelf extends BlockBookshelf { @@ -41,8 +44,24 @@ public void registerBlockIcons(IIconRegister iconRegister) { } @Override - public int damageDropped(int meta) { - return 0; + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 2 || metadata == 4 || metadata > 10) return 0; + return Blocks.fire.getFlammability(this); + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 2 || metadata == 4 || metadata > 10) return 0; + return Blocks.fire.getEncouragement(this); + } + + @Override + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 2 || metadata == 4 || metadata > 10) return false; + return getFlammability(world, x, y, z, face) > 0; } @Override diff --git a/src/main/java/mods/natura/blocks/overrides/AlternateFence.java b/src/main/java/mods/natura/blocks/overrides/AlternateFence.java index ccbcc3de..cb9b35fb 100644 --- a/src/main/java/mods/natura/blocks/overrides/AlternateFence.java +++ b/src/main/java/mods/natura/blocks/overrides/AlternateFence.java @@ -6,15 +6,18 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mods.natura.client.FenceRender; import mods.natura.common.NContent; +import net.minecraftforge.common.util.ForgeDirection; public class AlternateFence extends BlockFence { @@ -43,6 +46,27 @@ public void getSubBlocks(Item item, CreativeTabs tabs, List list) { for (int i = 0; i < NContent.woodTextureNames.length; i++) list.add(new ItemStack(item, 1, i)); } + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 2 || metadata == 4 || metadata > 10) return 0; + return Blocks.fire.getFlammability(this); + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 2 || metadata == 4 || metadata > 10) return 0; + return Blocks.fire.getEncouragement(this); + } + + @Override + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 2 || metadata == 4 || metadata > 10) return false; + return getFlammability(world, x, y, z, face) > 0; + } + @Override public boolean canPlaceTorchOnTop(World world, int x, int y, int z) { return true; diff --git a/src/main/java/mods/natura/blocks/trees/DarkTreeBlock.java b/src/main/java/mods/natura/blocks/trees/DarkTreeBlock.java index c17c666e..6e1251cb 100644 --- a/src/main/java/mods/natura/blocks/trees/DarkTreeBlock.java +++ b/src/main/java/mods/natura/blocks/trees/DarkTreeBlock.java @@ -30,7 +30,6 @@ public DarkTreeBlock() { this.setHardness(3.5F); this.setResistance(40F); this.setStepSound(Block.soundTypeWood); - // setBurnProperties(this.blockID, 5, 20); this.setCreativeTab(NaturaTab.tab); } @@ -74,25 +73,18 @@ public void registerBlockIcons(IIconRegister iconRegister) { } @Override - public Item getItemDropped(int par1, Random par2Random, int par3) { - return Item.getItemFromBlock(this); - } - - /** - * ejects contained items into the world, and notifies neighbours of an update, as appropriate - */ - public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { + public void breakBlock(World worldIn, int x, int y, int z, Block blockBroken, int meta) { byte b0 = 4; int j1 = b0 + 1; - if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1)) { + if (worldIn.checkChunksExist(x - j1, y - j1, z - j1, x + j1, y + j1, z + j1)) { for (int k1 = -b0; k1 <= b0; ++k1) { for (int l1 = -b0; l1 <= b0; ++l1) { for (int i2 = -b0; i2 <= b0; ++i2) { - Block j2 = par1World.getBlock(par2 + k1, par3 + l1, par4 + i2); + Block j2 = worldIn.getBlock(x + k1, y + l1, z + i2); if (j2 != null) { - j2.beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2); + j2.beginLeavesDecay(worldIn, x + k1, y + l1, z + i2); } } } @@ -100,9 +92,6 @@ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, } } - /** - * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata - */ @Override public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) { @@ -126,9 +115,6 @@ public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5 return j1 | b0; } - /** - * Determines the damage on the item the block drops. Used in cloth and wood. - */ @Override public int damageDropped(int par1) { return par1 & 3; @@ -146,10 +132,6 @@ protected ItemStack createStackedBlock(int par1) { return new ItemStack(this, 1, limitToValidMetadata(par1)); } - public boolean isBlockReplaceable(World world, int x, int y, int z) { - return false; - } - @Override public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) { if (meta % 4 == 1) { diff --git a/src/main/java/mods/natura/blocks/trees/FruitTreeBlock.java b/src/main/java/mods/natura/blocks/trees/FruitTreeBlock.java deleted file mode 100644 index adf88704..00000000 --- a/src/main/java/mods/natura/blocks/trees/FruitTreeBlock.java +++ /dev/null @@ -1,47 +0,0 @@ -package mods.natura.blocks.trees; - -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockLog; -import net.minecraft.item.Item; - -import mods.natura.common.NaturaTab; - -public class FruitTreeBlock extends BlockLog { - - public FruitTreeBlock() { - super(); - this.setHardness(1.5F); - this.setResistance(5F); - this.setStepSound(Block.soundTypeWood); - // TODO 1.7 Where the heck did this go? setBurnProperties(this, 5, 20); - this.setCreativeTab(NaturaTab.tab); - } - - /* - * public int getIcon(int side, int metadata) { int tex = blockIndexInTexture + (metadata % 4); int orientation = - * metadata / 4; switch (orientation) //Ends of logs { case 0: if (side == 0 || side == 1) return tex + 16; break; - * case 1: if (side == 4 || side == 5) return tex + 16; break; case 2: if (side == 2 || side == 3) return tex + 16; - * break; } return tex; } - */ - - @Override - public Item getItemDropped(int par1, Random par2Random, int par3) { - return Item.getItemFromBlock(this); - } - - @Override - public int damageDropped(int meta) { - return meta % 4; - } - - /* - * public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) { return - * metadata % 4 != 2 ? blockFlammability[blockID] : 0; } public int getFireSpreadSpeed(World world, int x, int y, - * int z, int metadata, ForgeDirection face) { return metadata % 4 != 2 ? blockFireSpreadSpeed[blockID] : 0; } - * @SideOnly(Side.CLIENT) - * @Override public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { for (int i = 0; i < - * 4; i++) par3List.add(new ItemStack(par1, 1, i)); } - */ -} diff --git a/src/main/java/mods/natura/blocks/trees/LogTwoxTwo.java b/src/main/java/mods/natura/blocks/trees/LogTwoxTwo.java index 8ce3be5d..35397dc1 100644 --- a/src/main/java/mods/natura/blocks/trees/LogTwoxTwo.java +++ b/src/main/java/mods/natura/blocks/trees/LogTwoxTwo.java @@ -61,21 +61,19 @@ public boolean isBlockReplaceable(World world, int x, int y, int z) { return false; } - /** - * ejects contained items into the world, and notifies neighbours of an update, as appropriate - */ - public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { + @Override + public void breakBlock(World worldIn, int x, int y, int z, Block blockBroken, int meta) { byte b0 = 4; int j1 = b0 + 1; - if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1)) { + if (worldIn.checkChunksExist(x - j1, y - j1, z - j1, x + j1, y + j1, z + j1)) { for (int k1 = -b0; k1 <= b0; ++k1) { for (int l1 = -b0; l1 <= b0; ++l1) { for (int i2 = -b0; i2 <= b0; ++i2) { - Block j2 = par1World.getBlock(par2 + k1, par3 + l1, par4 + i2); + Block j2 = worldIn.getBlock(x + k1, y + l1, z + i2); if (j2 != null) { - j2.beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2); + j2.beginLeavesDecay(worldIn, x + k1, y + l1, z + i2); } } } @@ -83,9 +81,6 @@ public void breakBlock(World par1World, int par2, int par3, int par4, int par5, } } - /** - * The type of render function that is called for this block - */ @Override public int getRenderType() { return 31; diff --git a/src/main/java/mods/natura/blocks/trees/NLeaves.java b/src/main/java/mods/natura/blocks/trees/NLeaves.java index 8ca84020..2fa9351d 100644 --- a/src/main/java/mods/natura/blocks/trees/NLeaves.java +++ b/src/main/java/mods/natura/blocks/trees/NLeaves.java @@ -5,6 +5,7 @@ import java.util.Random; import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.block.BlockLeaves; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -20,14 +21,13 @@ import cpw.mods.fml.relauncher.SideOnly; import mods.natura.common.NContent; import mods.natura.common.NaturaTab; +import net.minecraftforge.common.util.ForgeDirection; public class NLeaves extends BlockLeaves { public NLeaves() { - super(); - setBlockName("floraLeaves"); - setCreativeTab(NaturaTab.tab); - // Blocks.fire.setFireInfo(this, 30, 60); + this.setBlockName("floraLeaves"); + this.setCreativeTab(NaturaTab.tab); } @Override @@ -62,42 +62,6 @@ public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_1497 return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255; } - @Override - public void updateTick(World world, int x, int y, int z, Random random) { - if (!world.isRemote) { - int meta = world.getBlockMetadata(x, y, z); - - if ((meta & 4) == 0) { - int range = 4; - if (world.checkChunksExist(x - range, y - range, z - range, x + range, y + range, z + range)) { - // Do not decay leaves if can't check every possible support - boolean nearbyTree = false; - - for (int posX = x - range; posX <= x + range; posX++) { - for (int posY = y - range; posY <= y + range; posY++) { - for (int posZ = z - range; posZ <= z + range; posZ++) { - Block block = world.getBlock(posX, posY, posZ); - if (block != null && block.canSustainLeaves(world, posX, posY, posZ)) nearbyTree = true; - } - } - } - - if (!nearbyTree) { - this.removeLeaves(world, x, y, z); - } - } - } - } - } - - public void removeLeaves(World world, int x, int y, int z) { - this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); - world.setBlock(x, y, z, Blocks.air, 0, 7); - } - - /** - * Returns the ID of the items to drop on destruction. - */ @Override public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return Item.getItemFromBlock(NContent.floraSapling); diff --git a/src/main/java/mods/natura/blocks/trees/NLeavesNocolor.java b/src/main/java/mods/natura/blocks/trees/NLeavesNocolor.java index 4aab6a78..7eabe047 100644 --- a/src/main/java/mods/natura/blocks/trees/NLeavesNocolor.java +++ b/src/main/java/mods/natura/blocks/trees/NLeavesNocolor.java @@ -6,6 +6,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -17,6 +18,7 @@ import cpw.mods.fml.relauncher.SideOnly; import mods.natura.Natura; import mods.natura.common.NContent; +import net.minecraftforge.common.util.ForgeDirection; public class NLeavesNocolor extends NLeaves { @@ -73,6 +75,27 @@ public ArrayList getDrops(World world, int x, int y, int z, int metad return ret; } + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 1 || metadata == 2) return 0; + return Blocks.fire.getFlammability(this); + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 1 || metadata == 2) return 0; + return Blocks.fire.getEncouragement(this); + } + + @Override + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 1 || metadata == 2) return false; + return getFlammability(world, x, y, z, face) > 0; + } + @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { diff --git a/src/main/java/mods/natura/blocks/trees/OverworldTreeBlock.java b/src/main/java/mods/natura/blocks/trees/OverworldTreeBlock.java index 61ac2274..edfcda4b 100644 --- a/src/main/java/mods/natura/blocks/trees/OverworldTreeBlock.java +++ b/src/main/java/mods/natura/blocks/trees/OverworldTreeBlock.java @@ -29,7 +29,6 @@ public OverworldTreeBlock() { super(); this.setHardness(2.0F); this.setStepSound(Block.soundTypeWood); - // TODO 1.7 Where the heck did this go? setBurnProperties(this, 5, 20); this.setCreativeTab(NaturaTab.tab); } @@ -84,12 +83,6 @@ public int damageDropped(int meta) { return meta % 4; } - /* - * public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) { return - * metadata % 4 != 2 ? blockFlammability[blockID] : 0; } public int getFireSpreadSpeed(World world, int x, int y, - * int z, int metadata, ForgeDirection face) { return metadata % 4 != 2 ? blockFireSpreadSpeed[blockID] : 0; } - */ - @SideOnly(Side.CLIENT) @Override public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { diff --git a/src/main/java/mods/natura/blocks/trees/Planks.java b/src/main/java/mods/natura/blocks/trees/Planks.java index f9e45257..84878802 100644 --- a/src/main/java/mods/natura/blocks/trees/Planks.java +++ b/src/main/java/mods/natura/blocks/trees/Planks.java @@ -26,7 +26,6 @@ public class Planks extends Block { public Planks() { super(Material.wood); - // TODO 1.7 Where the heck did this go? setBurnProperties(this, 5, 20); this.setHardness(2.0f); this.setCreativeTab(NaturaTab.tab); this.setStepSound(Block.soundTypeWood); @@ -49,18 +48,25 @@ public void registerBlockIcons(IIconRegister iconRegister) { } } - /* - * public boolean renderAsNormalBlock() { return false; } - */ - - public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) { + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); if (metadata == 2 || metadata == 4 || metadata > 10) return 0; - return this.getFlammability(world, x, y, z, face); + return Blocks.fire.getFlammability(this); } - public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face) { + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); if (metadata == 2 || metadata == 4 || metadata > 10) return 0; - return this.getFireSpreadSpeed(world, x, y, z, face); + return Blocks.fire.getEncouragement(this); + } + + @Override + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata == 2 || metadata == 4 || metadata > 10) return false; + return getFlammability(world, x, y, z, face) > 0; } @Override diff --git a/src/main/java/mods/natura/blocks/trees/SimpleLog.java b/src/main/java/mods/natura/blocks/trees/SimpleLog.java index 155f784c..1eb5f8a9 100644 --- a/src/main/java/mods/natura/blocks/trees/SimpleLog.java +++ b/src/main/java/mods/natura/blocks/trees/SimpleLog.java @@ -4,6 +4,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; @@ -20,7 +21,6 @@ public class SimpleLog extends Planks { public String[] textureNames = new String[] { "redwood_bark", "redwood_heart", "redwood_root" }; public SimpleLog() { - super(); this.setCreativeTab(NaturaTab.tab); } @@ -45,13 +45,13 @@ public boolean isWood(IBlockAccess world, int x, int y, int z) { } @Override - public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) { - return this.getFlammability(world, x, y, z, face); + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return Blocks.fire.getFlammability(this); } @Override - public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face) { - return this.getFireSpreadSpeed(world, x, y, z, face); + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + return Blocks.fire.getEncouragement(this); } @Override diff --git a/src/main/java/mods/natura/blocks/trees/TreeBlock.java b/src/main/java/mods/natura/blocks/trees/TreeBlock.java index c624d6c3..e64d23d8 100644 --- a/src/main/java/mods/natura/blocks/trees/TreeBlock.java +++ b/src/main/java/mods/natura/blocks/trees/TreeBlock.java @@ -7,11 +7,11 @@ import net.minecraft.block.BlockLog; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; @@ -30,7 +30,6 @@ public TreeBlock() { this.setHardness(1.5F); this.setResistance(5F); this.setStepSound(Block.soundTypeWood); - // TODO 1.7 Where the heck did this go? setBurnProperties(this, 5, 20); this.setCreativeTab(NaturaTab.tab); } @@ -83,12 +82,25 @@ public int damageDropped(int meta) { return meta % 4; } - public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) { - return metadata % 4 != 2 ? this.getFlammability(world, x, y, z, face) : 0; + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata % 4 == 2) return 0; + return Blocks.fire.getFlammability(this); } - public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face) { - return metadata % 4 != 2 ? this.getFireSpreadSpeed(world, x, y, z, face) : 0; + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata % 4 == 2) return 0; + return Blocks.fire.getEncouragement(this); + } + + @Override + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int metadata = world.getBlockMetadata(x, y, z); + if (metadata % 4 == 2) return false; + return getFlammability(world, x, y, z, face) > 0; } @SideOnly(Side.CLIENT) diff --git a/src/main/java/mods/natura/blocks/trees/WillowBlock.java b/src/main/java/mods/natura/blocks/trees/WillowBlock.java index 28cdd0d1..964e3b09 100644 --- a/src/main/java/mods/natura/blocks/trees/WillowBlock.java +++ b/src/main/java/mods/natura/blocks/trees/WillowBlock.java @@ -28,7 +28,6 @@ public WillowBlock() { super(); this.setHardness(2.0F); this.setStepSound(Block.soundTypeWood); - // TODO 1.7 Where the heck did this go? setBurnProperties(this, 5, 20); this.setCreativeTab(NaturaTab.tab); } @@ -78,13 +77,6 @@ public ArrayList getDrops(World world, int x, int y, int z, int metad return i; } - /* - * @Override public int damageDropped(int meta) { return meta % 4; } public int getFlammability(IBlockAccess world, - * int x, int y, int z, int metadata, ForgeDirection face) { return metadata % 4 != 2 ? blockFlammability[blockID] : - * 0; } public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face) { return - * metadata % 4 != 2 ? blockFireSpreadSpeed[blockID] : 0; } - */ - @SideOnly(Side.CLIENT) @Override public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { diff --git a/src/main/java/mods/natura/common/NContent.java b/src/main/java/mods/natura/common/NContent.java index ae8b9a2a..816ec287 100644 --- a/src/main/java/mods/natura/common/NContent.java +++ b/src/main/java/mods/natura/common/NContent.java @@ -4,6 +4,8 @@ import java.util.HashMap; import java.util.List; +import mods.natura.blocks.*; +import mods.natura.items.blocks.*; import net.minecraft.block.Block; import net.minecraft.block.BlockDispenser; import net.minecraft.block.BlockPressurePlate.Sensitivity; @@ -35,15 +37,6 @@ import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import mods.natura.Natura; -import mods.natura.blocks.CloudBlock; -import mods.natura.blocks.GrassBlock; -import mods.natura.blocks.GrassSlab; -import mods.natura.blocks.NButton; -import mods.natura.blocks.NFenceGate; -import mods.natura.blocks.NPressurePlate; -import mods.natura.blocks.NSlabBase; -import mods.natura.blocks.NStairs; -import mods.natura.blocks.NTrapdoor; import mods.natura.blocks.crops.BerryBush; import mods.natura.blocks.crops.CropBlock; import mods.natura.blocks.crops.FlowerBlock; @@ -104,32 +97,6 @@ import mods.natura.items.SeedFood; import mods.natura.items.SpawnEgg; import mods.natura.items.StickItem; -import mods.natura.items.blocks.BerryBushItem; -import mods.natura.items.blocks.CloudItem; -import mods.natura.items.blocks.DarkTreeItem; -import mods.natura.items.blocks.FenceItem; -import mods.natura.items.blocks.GlowshroomItem; -import mods.natura.items.blocks.GrassBlockItem; -import mods.natura.items.blocks.GrassSlabItem; -import mods.natura.items.blocks.LogTwoxTwoItem; -import mods.natura.items.blocks.NAlternateItem; -import mods.natura.items.blocks.NDoorItem; -import mods.natura.items.blocks.NLeavesDarkItem; -import mods.natura.items.blocks.NLeavesItem; -import mods.natura.items.blocks.NSaplingItem; -import mods.natura.items.blocks.NetherBerryBushItem; -import mods.natura.items.blocks.NetherGlassItem; -import mods.natura.items.blocks.NoColorLeavesItem; -import mods.natura.items.blocks.OverworldLeavesItem; -import mods.natura.items.blocks.OverworldSaplingItem; -import mods.natura.items.blocks.OverworldTreeItem; -import mods.natura.items.blocks.PlankSlab1Item; -import mods.natura.items.blocks.PlankSlab2Item; -import mods.natura.items.blocks.PlanksItem; -import mods.natura.items.blocks.RedwoodItem; -import mods.natura.items.blocks.SaguaroItem; -import mods.natura.items.blocks.TreeItem; -import mods.natura.items.blocks.WillowItem; import mods.natura.items.tools.FlintAndBlaze; import mods.natura.items.tools.NaturaArmor; import mods.natura.items.tools.NaturaBow; @@ -223,6 +190,7 @@ public void preInit() { // Nether plants thornVines = new ThornVines().setBlockName("Thornvines").setLightLevel(0.625f); GameRegistry.registerBlock(thornVines, "Thornvines"); + Blocks.fire.setFireInfo(thornVines, 5, 100); glowshroom = (Glowshroom) new Glowshroom().setBlockName("Glowshroom").setLightLevel(0.625f); GameRegistry.registerBlock(glowshroom, GlowshroomItem.class, "Glowshroom"); glowshroomGreen = new LargeGlowshroom(Material.wood, "green").setBlockName("greenGlowshroom") @@ -243,6 +211,7 @@ public void preInit() { if (PHNatura.enableBerryBushes) { berryBush = new BerryBush(); GameRegistry.registerBlock(berryBush, BerryBushItem.class, "BerryBush"); + Blocks.fire.setFireInfo(berryBush, 60, 100); } // Overworld plants @@ -252,6 +221,7 @@ public void preInit() { GameRegistry.registerBlock(saguaro, SaguaroItem.class, "Saguaro"); bluebells = (FlowerBlock) new FlowerBlock().setBlockName("bluebells"); GameRegistry.registerBlock(bluebells, "Bluebells"); + Blocks.fire.setFireInfo(bluebells, 60, 100); // TODO 1.7 apparently this isn't so simple anymore // MinecraftForge.addGrassPlant(bluebells, 0, 18); @@ -259,9 +229,10 @@ public void preInit() { grassBlock = new GrassBlock().setBlockName("GrassBlock"); grassBlock.stepSound = Block.soundTypeGrass; GameRegistry.registerBlock(grassBlock, GrassBlockItem.class, "GrassBlock"); - grassSlab = new GrassSlab().setBlockName("GrassSlab"); - grassSlab.stepSound = Block.soundTypeGrass; - GameRegistry.registerBlock(grassSlab, GrassSlabItem.class, "GrassSlab"); + GrassSlab sGSlab = (GrassSlab) new GrassSlab(false).setBlockName("GrassSlab"); + GrassSlab dGSlab = (GrassSlab) new GrassSlab(true).setBlockName("GrassSlabDouble"); + grassSlab = GameRegistry.registerBlock(sGSlab, GrassSlabItem.class, "GrassSlab", sGSlab, dGSlab); + grassSlabDouble = GameRegistry.registerBlock(dGSlab, GrassSlabItem.class, "GrassSlabDouble", sGSlab, dGSlab); // Clouds cloud = new CloudBlock(); @@ -276,16 +247,22 @@ public void preInit() { // Logs tree = new TreeBlock().setBlockName("natura.treeblock"); GameRegistry.registerBlock(tree, TreeItem.class, "tree"); + Blocks.fire.setFireInfo(tree, 5, 5); redwood = new SimpleLog().setBlockName("natura.redwood"); GameRegistry.registerBlock(redwood, RedwoodItem.class, "redwood"); + // Redwood just a bit more flammable, because it is massive + Blocks.fire.setFireInfo(redwood, 40, 10); willow = new WillowBlock().setBlockName("willow"); GameRegistry.registerBlock(willow, WillowItem.class, "willow"); + Blocks.fire.setFireInfo(willow, 5, 5); bloodwood = new LogTwoxTwo(8f, Material.wood).setBlockName("bloodwood"); GameRegistry.registerBlock(bloodwood, LogTwoxTwoItem.class, "bloodwood"); rareTree = new OverworldTreeBlock().setBlockName("RareTree"); GameRegistry.registerBlock(rareTree, OverworldTreeItem.class, "Rare Tree"); + Blocks.fire.setFireInfo(rareTree, 5, 5); darkTree = new DarkTreeBlock().setBlockName("Darktree"); GameRegistry.registerBlock(darkTree, DarkTreeItem.class, "Dark Tree"); + // Nether trees shouldn't be burnable tree.setHarvestLevel("axe", -1); redwood.setHarvestLevel("axe", -1); bloodwood.setHarvestLevel("axe", 2); @@ -295,16 +272,21 @@ public void preInit() { // Leaves floraLeaves = (NLeaves) new NLeaves().setBlockName("natura.leaves"); GameRegistry.registerBlock(floraLeaves, NLeavesItem.class, "floraleaves"); + Blocks.fire.setFireInfo(floraLeaves, 30, 60); floraLeavesNoColor = (NLeaves) new NLeavesNocolor().setBlockName("natura.leavesnocolor"); GameRegistry.registerBlock(floraLeavesNoColor, NoColorLeavesItem.class, "floraleavesnocolor"); + Blocks.fire.setFireInfo(floraLeavesNoColor, 30, 60); rareLeaves = (NLeaves) new OverworldLeaves().setBlockName("RareLeaves"); GameRegistry.registerBlock(rareLeaves, OverworldLeavesItem.class, "Rare Leaves"); + Blocks.fire.setFireInfo(rareLeaves, 30, 60); darkLeaves = (NLeaves) new NLeavesDark().setBlockName("Darkleaves"); GameRegistry.registerBlock(darkLeaves, NLeavesDarkItem.class, "Dark Leaves"); + // Nether trees shouldn't be burnable // Wooden Planks planks = new Planks().setBlockName("natura.planks"); GameRegistry.registerBlock(planks, PlanksItem.class, "planks"); + Blocks.fire.setFireInfo(planks, 5, 20); // Wooden Workbenches if (PHNatura.enableWoodenWorkbenches) { @@ -318,6 +300,7 @@ public void preInit() { alternateBookshelf = new AlternateBookshelf().setHardness(1.5F).setStepSound(Block.soundTypeWood) .setBlockName("bookshelf").setCreativeTab(NaturaTab.tab); GameRegistry.registerBlock(alternateBookshelf, NAlternateItem.class, "Natura.bookshelf"); + Blocks.fire.setFireInfo(alternateBookshelf, 30, 20); } // Wooden Stairs @@ -326,10 +309,12 @@ public void preInit() { stairEucalyptus = new NStairs(planks, 0).setBlockName("stair.eucalyptus"); stairEucalyptus.stepSound = Block.soundTypeWood; GameRegistry.registerBlock(stairEucalyptus, "stair.eucalyptus"); + Blocks.fire.setFireInfo(stairEucalyptus, 5, 20); // Sakura stairSakura = new NStairs(planks, 1).setBlockName("stair.sakura"); stairSakura.stepSound = Block.soundTypeWood; GameRegistry.registerBlock(stairSakura, "stair.sakura"); + Blocks.fire.setFireInfo(stairSakura, 5, 20); // Ghostwood stairGhostwood = new NStairs(planks, 2).setBlockName("stair.ghostwood"); stairGhostwood.stepSound = Block.soundTypeWood; @@ -338,6 +323,7 @@ public void preInit() { stairRedwood = new NStairs(planks, 3).setBlockName("stair.redwood"); stairRedwood.stepSound = Block.soundTypeWood; GameRegistry.registerBlock(stairRedwood, "stair.redwood"); + Blocks.fire.setFireInfo(stairRedwood, 5, 20); // Bloodwood stairBloodwood = new NStairs(planks, 4).setBlockName("stair.bloodwood"); stairBloodwood.stepSound = Block.soundTypeWood; @@ -346,26 +332,32 @@ public void preInit() { stairHopseed = new NStairs(planks, 5).setBlockName("stair.hopseed"); stairHopseed.stepSound = Block.soundTypeWood; GameRegistry.registerBlock(stairHopseed, "stair.hopseed"); + Blocks.fire.setFireInfo(stairHopseed, 5, 20); // Maple stairMaple = new NStairs(planks, 6).setBlockName("stair.maple"); stairMaple.stepSound = Block.soundTypeWood; GameRegistry.registerBlock(stairMaple, "stair.maple"); + Blocks.fire.setFireInfo(stairMaple, 5, 20); // Silverbell stairSilverbell = new NStairs(planks, 7).setBlockName("stair.silverbell"); stairSilverbell.stepSound = Block.soundTypeWood; GameRegistry.registerBlock(stairSilverbell, "stair.silverbell"); + Blocks.fire.setFireInfo(stairSilverbell, 5, 20); // Amaranth stairAmaranth = new NStairs(planks, 8).setBlockName("stair.amaranth"); stairAmaranth.stepSound = Block.soundTypeWood; GameRegistry.registerBlock(stairAmaranth, "stair.amaranth"); + Blocks.fire.setFireInfo(stairAmaranth, 5, 20); // Tiger stairTiger = new NStairs(planks, 9).setBlockName("stair.tiger"); stairTiger.stepSound = Block.soundTypeWood; GameRegistry.registerBlock(stairTiger, "stair.tiger"); + Blocks.fire.setFireInfo(stairTiger, 5, 20); // Willow stairWillow = new NStairs(planks, 10).setBlockName("stair.willow"); stairWillow.stepSound = Block.soundTypeWood; GameRegistry.registerBlock(stairWillow, "stair.willow"); + Blocks.fire.setFireInfo(stairWillow, 5, 20); // Darkwood stairDarkwood = new NStairs(planks, 11).setBlockName("stair.darkwood"); stairDarkwood.stepSound = Block.soundTypeWood; @@ -378,12 +370,19 @@ public void preInit() { // Wooden Slabs if (PHNatura.enableWoodenSlabs) { - plankSlab1 = new NSlabBase(Material.wood, planks, 0, 8).setHardness(2.0f).setBlockName("plankSlab1"); - plankSlab1.stepSound = Block.soundTypeWood; - GameRegistry.registerBlock(plankSlab1, PlankSlab1Item.class, "plankSlab1"); - plankSlab2 = new NSlabBase(Material.wood, planks, 8, 5).setHardness(2.0f).setBlockName("plankSlab2"); - plankSlab2.stepSound = Block.soundTypeWood; - GameRegistry.registerBlock(plankSlab2, PlankSlab2Item.class, "plankSlab2"); + NSlabBase sSlab = (NSlabBase) new NSlabBase(false, 1).setBlockName("plankSlab1"); + NSlabBase dslab = (NSlabBase) new NSlabBase(true, 1).setBlockName("plankSlab1Double"); + plankSlab1 = GameRegistry.registerBlock(sSlab, NSlabBaseItem.class, "plankSlab1", sSlab, dslab); + Blocks.fire.setFireInfo(plankSlab1, 5, 20); + plankSlab1Double = GameRegistry.registerBlock(dslab, NSlabBaseItem.class, "plankSlab1Double", sSlab, dslab); + Blocks.fire.setFireInfo(plankSlab1Double, 5, 20); + + sSlab = (NSlabBase) new NSlabBase(false, 2).setBlockName("plankSlab2"); + dslab = (NSlabBase) new NSlabBase(true, 2).setBlockName("plankSlab2Double"); + plankSlab2 = GameRegistry.registerBlock(sSlab, NSlabBaseItem.class, "plankSlab2", sSlab, dslab); + Blocks.fire.setFireInfo(plankSlab2, 5, 20); + plankSlab2Double = GameRegistry.registerBlock(dslab, NSlabBaseItem.class, "plankSlab2Double", sSlab, dslab); + Blocks.fire.setFireInfo(plankSlab2Double, 5, 20); } // Wooden Trapdoors @@ -447,6 +446,7 @@ public void preInit() { alternateFence = new AlternateFence(Material.wood).setHardness(2.0F).setResistance(5.0F) .setStepSound(Block.soundTypeWood).setBlockName("fence").setCreativeTab(NaturaTab.tab); GameRegistry.registerBlock(alternateFence, FenceItem.class, "Natura.fence"); + Blocks.fire.setFireInfo(alternateFence, 5, 20); } // Wooden Fence Gates @@ -456,11 +456,13 @@ public void preInit() { fenceGateEucalyptus.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) .setBlockName("fenceGate.eucalyptus"); GameRegistry.registerBlock(fenceGateEucalyptus, "fenceGate.eucalyptus"); + Blocks.fire.setFireInfo(fenceGateEucalyptus, 5, 20); // Sakura fenceGateSakura = new NFenceGate(planks, 1); fenceGateSakura.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) .setBlockName("fenceGate.sakura"); GameRegistry.registerBlock(fenceGateSakura, "fenceGate.sakura"); + Blocks.fire.setFireInfo(fenceGateSakura, 5, 20); // Ghostwood fenceGateGhostwood = new NFenceGate(planks, 2); fenceGateGhostwood.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) @@ -471,6 +473,7 @@ public void preInit() { fenceGateRedwood.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) .setBlockName("fenceGate.redwood"); GameRegistry.registerBlock(fenceGateRedwood, "fenceGate.redwood"); + Blocks.fire.setFireInfo(fenceGateRedwood, 5, 20); // Bloodwood fenceGateBloodwood = new NFenceGate(planks, 4); fenceGateBloodwood.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) @@ -481,31 +484,37 @@ public void preInit() { fenceGateHopseed.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) .setBlockName("fenceGate.hopseed"); GameRegistry.registerBlock(fenceGateHopseed, "fenceGate.hopseed"); + Blocks.fire.setFireInfo(fenceGateHopseed, 5, 20); // Maple fenceGateMaple = new NFenceGate(planks, 6); fenceGateMaple.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) .setBlockName("fenceGate.maple"); GameRegistry.registerBlock(fenceGateMaple, "fenceGate.maple"); + Blocks.fire.setFireInfo(fenceGateMaple, 5, 20); // Amaranth fenceGateAmaranth = new NFenceGate(planks, 8); fenceGateAmaranth.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) .setBlockName("fenceGate.amaranth"); GameRegistry.registerBlock(fenceGateAmaranth, "fenceGate.amaranth"); + Blocks.fire.setFireInfo(fenceGateAmaranth, 5, 20); // Silverbell fenceGateSilverbell = new NFenceGate(planks, 7); fenceGateSilverbell.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) .setBlockName("fenceGate.silverbell"); GameRegistry.registerBlock(fenceGateSilverbell, "fenceGate.silverbell"); + Blocks.fire.setFireInfo(fenceGateSilverbell, 5, 20); // Tigerwood fenceGateTiger = new NFenceGate(planks, 9); fenceGateTiger.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) .setBlockName("fenceGate.tiger"); GameRegistry.registerBlock(fenceGateTiger, "fenceGate.tiger"); + Blocks.fire.setFireInfo(fenceGateTiger, 5, 20); // Willow fenceGateWillow = new NFenceGate(planks, 10); fenceGateWillow.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) .setBlockName("fenceGate.willow"); GameRegistry.registerBlock(fenceGateWillow, "fenceGate.willow"); + Blocks.fire.setFireInfo(fenceGateWillow, 5, 20); // Darkwood fenceGateDarkwood = new NFenceGate(planks, 11); fenceGateDarkwood.setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeWood) @@ -2016,6 +2025,7 @@ public int getBurnTime(ItemStack fuel) { // Full grass blocks and slabs public static Block grassBlock; public static Block grassSlab; + public static Block grassSlabDouble; // Clouds public static Block cloud; @@ -2063,6 +2073,8 @@ public int getBurnTime(ItemStack fuel) { // Wooden Slabs public static Block plankSlab1; public static Block plankSlab2; + public static Block plankSlab1Double; + public static Block plankSlab2Double; // Wooden Trapdoors public static Block trapdoorEucalyptus; diff --git a/src/main/java/mods/natura/items/blocks/GrassSlabItem.java b/src/main/java/mods/natura/items/blocks/GrassSlabItem.java index 5cb78500..0626e17f 100644 --- a/src/main/java/mods/natura/items/blocks/GrassSlabItem.java +++ b/src/main/java/mods/natura/items/blocks/GrassSlabItem.java @@ -1,22 +1,12 @@ package mods.natura.items.blocks; +import mods.natura.blocks.GrassSlab; import net.minecraft.block.Block; +import net.minecraft.item.ItemSlab; -import mantle.blocks.abstracts.MultiItemBlock; +public class GrassSlabItem extends ItemSlab { -public class GrassSlabItem extends MultiItemBlock { - - public static final String blockType[] = { "grass", "bluegrass", "autumngrass" }; - - public GrassSlabItem(Block id) { - super(id, "block.soil", "slab", blockType); - setMaxDamage(0); - setHasSubtypes(true); + public GrassSlabItem(Block block, GrassSlab singleSlab, GrassSlab doubleSlab) { + super(block, singleSlab, doubleSlab, block == doubleSlab); } - - /* - * @Override public String getUnlocalizedName (ItemStack itemstack) { int pos = - * MathHelper.clamp_int(itemstack.getItemDamage(), 0, blockType.length - 1); return (new - * StringBuilder()).append("block.soil.").append(blockType[pos]).append(".slab").toString(); } - */ } diff --git a/src/main/java/mods/natura/items/blocks/NSlabBaseItem.java b/src/main/java/mods/natura/items/blocks/NSlabBaseItem.java new file mode 100644 index 00000000..7a0302ef --- /dev/null +++ b/src/main/java/mods/natura/items/blocks/NSlabBaseItem.java @@ -0,0 +1,13 @@ +package mods.natura.items.blocks; + +import mods.natura.blocks.NSlabBase; +import net.minecraft.block.Block; +import net.minecraft.item.ItemSlab; +import net.minecraft.item.ItemStack; + +public class NSlabBaseItem extends ItemSlab { + + public NSlabBaseItem(Block block, NSlabBase singleSlab, NSlabBase doubleSlab) { + super(block, singleSlab, doubleSlab, block == doubleSlab); + } +} diff --git a/src/main/java/mods/natura/items/blocks/PlankSlab1Item.java b/src/main/java/mods/natura/items/blocks/PlankSlab1Item.java deleted file mode 100644 index 8be246cb..00000000 --- a/src/main/java/mods/natura/items/blocks/PlankSlab1Item.java +++ /dev/null @@ -1,89 +0,0 @@ -package mods.natura.items.blocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import mantle.blocks.abstracts.MultiItemBlock; -import mods.natura.common.NContent; - -public class PlankSlab1Item extends MultiItemBlock { - - public static final String blockType[] = { "eucalyptus", "sakura", "ghost", "redwood", "blood", "bush", "maple", - "silverbell" }; - Block block; - - public PlankSlab1Item(Block id) { - super(id, "block.wood", "slab", blockType); - this.block = id; - setMaxDamage(0); - setHasSubtypes(true); - } - - /* - * @Override public String getUnlocalizedName (ItemStack itemstack) { int damage = itemstack.getItemDamage(); if - * (damage >= blockType.length) { if (blockType.length == 0) { return ""; } damage %= blockType.length; } return - * (new StringBuilder()).append("block.wood.").append(blockType[damage]).append(".slab").toString(); } - */ - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { - switch (stack.getItemDamage()) { - case 0: - list.add(StatCollector.translateToLocal("tooltip.tree1")); - break; - case 1: - list.add(StatCollector.translateToLocal("tooltip.tree2")); - break; - case 2: - list.add(StatCollector.translateToLocal("tooltip.tree3")); - break; - case 3: - list.add(StatCollector.translateToLocal("tooltip.tree4")); - break; - case 4: - list.add(StatCollector.translateToLocal("tooltip.tree5")); - break; - case 5: - list.add(StatCollector.translateToLocal("tooltip.tree6")); - break; - case 6: - list.add(StatCollector.translateToLocal("tooltip.tree7")); - break; - case 7: - list.add(StatCollector.translateToLocal("tooltip.tree8")); - break; - } - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, - float hitX, float hitY, float hitZ) { - Block id = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - int trueMeta = meta % 8; - boolean flag = id != null; - - if ((side == 1 && !flag || side == 0 && flag) && id == this.block && trueMeta == stack.getItemDamage()) { - if (world.setBlock(x, y, z, NContent.planks, trueMeta, 3)) { - world.playSoundEffect( - x + 0.5F, - y + 0.5F, - z + 0.5F, - this.block.stepSound.getBreakSound(), - (this.block.stepSound.getVolume() + 1.0F) / 2.0F, - this.block.stepSound.getPitch() * 0.8F); - --stack.stackSize; - return true; - } - } - return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); - } -} diff --git a/src/main/java/mods/natura/items/blocks/PlankSlab2Item.java b/src/main/java/mods/natura/items/blocks/PlankSlab2Item.java deleted file mode 100644 index 2011c68a..00000000 --- a/src/main/java/mods/natura/items/blocks/PlankSlab2Item.java +++ /dev/null @@ -1,87 +0,0 @@ -package mods.natura.items.blocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import mantle.blocks.abstracts.MultiItemBlock; -import mods.natura.common.NContent; - -public class PlankSlab2Item extends MultiItemBlock { - - public static final String blockType[] = { "purpleheart", "tiger", "willow", "darkwood", "fusewood", "", "", "" }; - Block block; - - public PlankSlab2Item(Block id) { - super(id, "block.wood", "slab", blockType); - this.block = id; - setMaxDamage(0); - setHasSubtypes(true); - } - - @Override - public String getUnlocalizedName(ItemStack itemstack) { - int damage = itemstack.getItemDamage(); - if (damage >= blockType.length) { - if (blockType.length == 0) { - return ""; - } - damage %= blockType.length; - } - - return (new StringBuilder()).append("block.wood.").append(blockType[damage]).append(".slab").toString(); - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { - switch (stack.getItemDamage()) { - case 0: - list.add(StatCollector.translateToLocal("tooltip.tree9")); - break; - case 1: - list.add(StatCollector.translateToLocal("tooltip.tree10")); - break; - case 2: - list.add(StatCollector.translateToLocal("tooltip.tree11")); - break; - case 3: - list.add(StatCollector.translateToLocal("tooltip.nethertree")); - break; - case 4: - list.add(StatCollector.translateToLocal("tooltip.nethertree")); - list.add(StatCollector.translateToLocal("tooltip.fusewood.log")); - break; - } - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, - float hitX, float hitY, float hitZ) { - Block id = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - int trueMeta = meta % 8; - boolean flag = id != null; - - if ((side == 1 && !flag || side == 0 && flag) && id == this.block && trueMeta == stack.getItemDamage()) { - if (world.setBlock(x, y, z, NContent.planks, trueMeta + 8, 3)) { - world.playSoundEffect( - x + 0.5F, - y + 0.5F, - z + 0.5F, - this.block.stepSound.getBreakSound(), - (this.block.stepSound.getVolume() + 1.0F) / 2.0F, - this.block.stepSound.getPitch() * 0.8F); - --stack.stackSize; - return true; - } - } - return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); - } -}