From 21965a44c32d0bec460e799bebeaed38c19c878f Mon Sep 17 00:00:00 2001 From: Ruling-0 <47913168+Ruling-0@users.noreply.github.com> Date: Mon, 20 Jan 2025 09:55:27 -0600 Subject: [PATCH] Slab Refactor, Leaf Refactor, and Everything Burns (#29) --- .../java/mods/natura/blocks/GrassSlab.java | 40 +++++- .../java/mods/natura/blocks/NSlabBase.java | 117 ++++++------------ .../java/mods/natura/blocks/PlankSlab1.java | 45 +++++++ .../java/mods/natura/blocks/PlankSlab2.java | 45 +++++++ .../blocks/overrides/AlternateBookshelf.java | 14 ++- .../blocks/overrides/AlternateFence.java | 15 +++ .../natura/blocks/trees/DarkTreeBlock.java | 27 +--- .../natura/blocks/trees/FruitTreeBlock.java | 47 ------- .../mods/natura/blocks/trees/LogTwoxTwo.java | 15 +-- .../java/mods/natura/blocks/trees/NDoor.java | 8 +- .../mods/natura/blocks/trees/NLeaves.java | 54 ++------ .../mods/natura/blocks/trees/NLeavesDark.java | 20 +-- .../natura/blocks/trees/NLeavesNocolor.java | 35 ++++-- .../blocks/trees/OverworldTreeBlock.java | 7 -- .../java/mods/natura/blocks/trees/Planks.java | 28 +++-- .../mods/natura/blocks/trees/SimpleLog.java | 11 +- .../mods/natura/blocks/trees/TreeBlock.java | 24 +++- .../mods/natura/blocks/trees/WillowBlock.java | 8 -- .../java/mods/natura/common/NContent.java | 68 ++++++++-- .../natura/items/blocks/GrassSlabItem.java | 19 +-- .../items/blocks/OverworldLeavesItem.java | 9 +- .../natura/items/blocks/PlankSlab1Item.java | 50 ++------ .../natura/items/blocks/PlankSlab2Item.java | 54 +------- 23 files changed, 368 insertions(+), 392 deletions(-) create mode 100644 src/main/java/mods/natura/blocks/PlankSlab1.java create mode 100644 src/main/java/mods/natura/blocks/PlankSlab2.java delete mode 100644 src/main/java/mods/natura/blocks/trees/FruitTreeBlock.java diff --git a/src/main/java/mods/natura/blocks/GrassSlab.java b/src/main/java/mods/natura/blocks/GrassSlab.java index 42e3a23f..1839eba3 100644 --- a/src/main/java/mods/natura/blocks/GrassSlab.java +++ b/src/main/java/mods/natura/blocks/GrassSlab.java @@ -1,7 +1,10 @@ package mods.natura.blocks; import java.util.List; +import java.util.Random; +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; @@ -11,19 +14,27 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.ColorizerGrass; import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mods.natura.client.GrassColorizerAlternate; +import mods.natura.common.NContent; 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); + this.useNeighborBrightness = true; + if (!isDoubleSlab) { + this.setCreativeTab(NaturaTab.tab); + } } @Override @@ -32,12 +43,25 @@ 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) { @@ -46,6 +70,12 @@ public void getSubBlocks(Item id, CreativeTabs tab, List list) { } } + @Override + @SideOnly(Side.CLIENT) + public Item getItem(World worldIn, int x, int y, int z) { + return Item.getItemFromBlock(NContent.grassSlab); + } + @Override @SideOnly(Side.CLIENT) public int getBlockColor() { diff --git a/src/main/java/mods/natura/blocks/NSlabBase.java b/src/main/java/mods/natura/blocks/NSlabBase.java index 5211823c..dd0b30b9 100644 --- a/src/main/java/mods/natura/blocks/NSlabBase.java +++ b/src/main/java/mods/natura/blocks/NSlabBase.java @@ -1,102 +1,63 @@ package mods.natura.blocks; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.AxisAlignedBB; +import net.minecraft.block.BlockWoodSlab; 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; import cpw.mods.fml.relauncher.SideOnly; +import mods.natura.blocks.trees.Planks; +import mods.natura.common.NContent; import mods.natura.common.NaturaTab; - -public class NSlabBase extends Block { - - Block modelBlock; - int startingMeta; - int totalSize; - - 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; - } - - @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); - } - - @Override - public void setBlockBoundsForItemRender() { - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); - } - - @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); +import mods.natura.items.blocks.PlanksItem; + +public abstract class NSlabBase extends BlockWoodSlab { + + // metaGroup 1 is the first 8 types, metaGroup 2 is the next 8, etc. + // slabs are max of 8 per group due to vanilla use of metadata, so this variable maps + // wooden slabs to the overall wood metadata used elsewhere, such as for textures and flammability + private final int metaGroup; + + public NSlabBase(boolean isDoubleSlab, int grp) { + super(isDoubleSlab); + this.setHardness(2.0F); + this.setResistance(5.0F); + this.useNeighborBrightness = true; + if (!isDoubleSlab) { + this.setCreativeTab(NaturaTab.tab); + } + metaGroup = grp; } @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; + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return NContent.planks.getIcon(side, getWoodMeta(meta)); } @Override - public boolean isOpaqueCube() { - return false; + public String func_150002_b(int meta) { + // unlocalized name + meta = getWoodMeta(meta); + return "block.wood." + PlanksItem.blockType[meta] + ".slab"; } @Override - public boolean renderAsNormalBlock() { - return false; + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int meta = getWoodMeta(world.getBlockMetadata(x, y, z)); + return Planks.getPlankFlammability(this, meta); } @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 int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int meta = getWoodMeta(world.getBlockMetadata(x, y, z)); + return Planks.getPlankFireSpreadSpeed(this, meta); } - @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)); - } - } - - @Override - public int damageDropped(int meta) { - return meta % 8; + private int getWoodMeta(int meta) { + meta = (meta & 7) + (metaGroup - 1) * 8; + if (meta < 0 || meta >= PlanksItem.blockType.length) meta = 0; + return meta; } } diff --git a/src/main/java/mods/natura/blocks/PlankSlab1.java b/src/main/java/mods/natura/blocks/PlankSlab1.java new file mode 100644 index 00000000..0363adbc --- /dev/null +++ b/src/main/java/mods/natura/blocks/PlankSlab1.java @@ -0,0 +1,45 @@ +package mods.natura.blocks; + +import java.util.List; +import java.util.Random; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import mods.natura.common.NContent; + +public class PlankSlab1 extends NSlabBase { + + public PlankSlab1(boolean isDoubleSlab) { + super(isDoubleSlab, 1); + } + + @Override + public Item getItemDropped(int meta, Random random, int fortune) { + // handles so both double and single drop the single slab version + return Item.getItemFromBlock(NContent.plankSlab1); + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item id, CreativeTabs tab, List list) { + for (int iter = 0; iter < 8; iter++) { + list.add(new ItemStack(id, 1, iter)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public Item getItem(World worldIn, int x, int y, int z) { + return Item.getItemFromBlock(NContent.plankSlab1); + } + + @Override + protected ItemStack createStackedBlock(int meta) { + return new ItemStack(Item.getItemFromBlock(NContent.plankSlab1), 2, meta & 7); + } +} diff --git a/src/main/java/mods/natura/blocks/PlankSlab2.java b/src/main/java/mods/natura/blocks/PlankSlab2.java new file mode 100644 index 00000000..a4ee5cb4 --- /dev/null +++ b/src/main/java/mods/natura/blocks/PlankSlab2.java @@ -0,0 +1,45 @@ +package mods.natura.blocks; + +import java.util.List; +import java.util.Random; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import mods.natura.common.NContent; + +public class PlankSlab2 extends NSlabBase { + + public PlankSlab2(boolean isDoubleSlab) { + super(isDoubleSlab, 2); + } + + @Override + public Item getItemDropped(int meta, Random random, int fortune) { + // handles so both double and single drop the single slab version + return Item.getItemFromBlock(NContent.plankSlab2); + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item id, CreativeTabs tab, List list) { + for (int iter = 0; iter < 5; iter++) { + list.add(new ItemStack(id, 1, iter)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public Item getItem(World worldIn, int x, int y, int z) { + return Item.getItemFromBlock(NContent.plankSlab2); + } + + @Override + protected ItemStack createStackedBlock(int meta) { + return new ItemStack(Item.getItemFromBlock(NContent.plankSlab2), 2, meta & 7); + } +} diff --git a/src/main/java/mods/natura/blocks/overrides/AlternateBookshelf.java b/src/main/java/mods/natura/blocks/overrides/AlternateBookshelf.java index 6c034b2a..4ce5b54f 100644 --- a/src/main/java/mods/natura/blocks/overrides/AlternateBookshelf.java +++ b/src/main/java/mods/natura/blocks/overrides/AlternateBookshelf.java @@ -8,10 +8,13 @@ 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; import cpw.mods.fml.relauncher.SideOnly; +import mods.natura.blocks.trees.Planks; import mods.natura.common.NContent; public class AlternateBookshelf extends BlockBookshelf { @@ -41,8 +44,15 @@ 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 meta = world.getBlockMetadata(x, y, z); + return Planks.getPlankFlammability(this, meta); + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int meta = world.getBlockMetadata(x, y, z); + return Planks.getPlankFireSpreadSpeed(this, meta); } @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..880f2f79 100644 --- a/src/main/java/mods/natura/blocks/overrides/AlternateFence.java +++ b/src/main/java/mods/natura/blocks/overrides/AlternateFence.java @@ -9,10 +9,13 @@ 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; import cpw.mods.fml.relauncher.SideOnly; +import mods.natura.blocks.trees.Planks; import mods.natura.client.FenceRender; import mods.natura.common.NContent; @@ -43,6 +46,18 @@ 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 meta = world.getBlockMetadata(x, y, z); + return Planks.getPlankFlammability(this, meta); + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int meta = world.getBlockMetadata(x, y, z); + return Planks.getPlankFireSpreadSpeed(this, meta); + } + @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..bccb4eae 100644 --- a/src/main/java/mods/natura/blocks/trees/DarkTreeBlock.java +++ b/src/main/java/mods/natura/blocks/trees/DarkTreeBlock.java @@ -1,7 +1,6 @@ package mods.natura.blocks.trees; import java.util.List; -import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -30,7 +29,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 +72,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 +91,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 +114,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 +131,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/NDoor.java b/src/main/java/mods/natura/blocks/trees/NDoor.java index 59e8952f..c40c44b2 100644 --- a/src/main/java/mods/natura/blocks/trees/NDoor.java +++ b/src/main/java/mods/natura/blocks/trees/NDoor.java @@ -7,6 +7,7 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.IconFlipped; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -114,12 +115,7 @@ public IIcon getIcon(int par1, int par2) { } @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { return new ItemStack(NContent.doorItem, 1, meta); } - - @Override - public int getRenderType() { - return 7; - } } diff --git a/src/main/java/mods/natura/blocks/trees/NLeaves.java b/src/main/java/mods/natura/blocks/trees/NLeaves.java index 8ca84020..46d48021 100644 --- a/src/main/java/mods/natura/blocks/trees/NLeaves.java +++ b/src/main/java/mods/natura/blocks/trees/NLeaves.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.Random; -import net.minecraft.block.Block; import net.minecraft.block.BlockLeaves; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -24,10 +23,8 @@ 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 +59,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); @@ -140,6 +101,11 @@ public void registerBlockIcons(IIconRegister iconRegister) { } } + @Override + public int getDamageValue(World worldIn, int x, int y, int z) { + return worldIn.getBlockMetadata(x, y, z) & 3; + } + /** * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given * coordinates. Args: blockAccess, x, y, z, side @@ -161,13 +127,9 @@ public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List par3List.add(new ItemStack(par1, 1, 2)); } - public int getDamageValue(World par1World, int par2, int par3, int par4) { - return this.damageDropped(par1World.getBlockMetadata(par2, par3, par4)) % 3; - } - @Override public int getLightOpacity(IBlockAccess world, int x, int y, int z) { - if (world.getBlockMetadata(x, y, z) % 4 == 0) { + if ((world.getBlockMetadata(x, y, z) & 3) == 0) { return 255; } return super.getLightOpacity(world, x, y, z); diff --git a/src/main/java/mods/natura/blocks/trees/NLeavesDark.java b/src/main/java/mods/natura/blocks/trees/NLeavesDark.java index 20a07088..990f544f 100644 --- a/src/main/java/mods/natura/blocks/trees/NLeavesDark.java +++ b/src/main/java/mods/natura/blocks/trees/NLeavesDark.java @@ -58,21 +58,27 @@ public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, in } @Override - public Item getItemDropped(int metadata, Random random, int fortune) { - if (metadata % 4 == 2) return NContent.potashApple; + public Item getItemDropped(int meta, Random random, int fortune) { + if ((meta & 3) == 2) return NContent.potashApple; return Item.getItemFromBlock(NContent.floraSapling); } @Override - public int damageDropped(int par1) { - if (par1 % 4 == 2) return 0; - if (par1 % 4 == 3) return 7; - return 6; + public int damageDropped(int meta) { + meta = meta & 3; + switch (meta) { + case 2: + return 0; + case 3: + return 7; + default: + return 6; + } } @Override public int quantityDropped(int meta, int fortune, Random random) { - if (meta % 4 == 2) return 1; + if ((meta & 3) == 2) return 1; return quantityDroppedWithBonus(fortune, random); } diff --git a/src/main/java/mods/natura/blocks/trees/NLeavesNocolor.java b/src/main/java/mods/natura/blocks/trees/NLeavesNocolor.java index 4aab6a78..727517f8 100644 --- a/src/main/java/mods/natura/blocks/trees/NLeavesNocolor.java +++ b/src/main/java/mods/natura/blocks/trees/NLeavesNocolor.java @@ -6,12 +6,14 @@ 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; 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; import cpw.mods.fml.relauncher.SideOnly; @@ -49,22 +51,17 @@ public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, in return 16777215; } - public int damageDropped(int meta) { - if (meta % 4 == 3) return 4; - return (meta & 3) + 3; - } - @Override public Item getItemDropped(int meta, Random random, int fortune) { - if (meta % 4 == 3) return Item.getItemFromBlock(NContent.rareSapling); + if ((meta & 3) == 3) return Item.getItemFromBlock(NContent.rareSapling); return Item.getItemFromBlock(NContent.floraSapling); } @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - ArrayList ret = super.getDrops(world, x, y, z, metadata, fortune); + public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { + ArrayList ret = super.getDrops(world, x, y, z, meta, fortune); - if (metadata % 4 == 2) { + if ((meta & 3) == 2) { if (fortune > 3 || Natura.random.nextInt(40 - fortune * 10) == 0) { ret.add(new ItemStack(Items.redstone)); } @@ -73,6 +70,26 @@ public ArrayList getDrops(World world, int x, int y, int z, int metad return ret; } + @Override + public int damageDropped(int meta) { + if ((meta & 3) == 3) return 4; + return super.damageDropped(meta) + 3; + } + + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int meta = world.getBlockMetadata(x, y, z) & 3; + if (meta == 1 || meta == 2) return 0; + return Blocks.fire.getFlammability(this); + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int meta = world.getBlockMetadata(x, y, z) & 3; + if (meta == 1 || meta == 2) return 0; + return Blocks.fire.getEncouragement(this); + } + @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..e9049144 100644 --- a/src/main/java/mods/natura/blocks/trees/Planks.java +++ b/src/main/java/mods/natura/blocks/trees/Planks.java @@ -11,7 +11,6 @@ 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; @@ -26,7 +25,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 +47,26 @@ public void registerBlockIcons(IIconRegister iconRegister) { } } - /* - * public boolean renderAsNormalBlock() { return false; } - */ + @Override + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int meta = world.getBlockMetadata(x, y, z); + return getPlankFlammability(this, meta); + } - public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) { - if (metadata == 2 || metadata == 4 || metadata > 10) return 0; - return this.getFlammability(world, x, y, z, face); + public static int getPlankFlammability(Block block, int meta) { + if (meta == 2 || meta == 4 || meta > 10) return 0; + return Blocks.fire.getFlammability(block); + } + + @Override + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { + int meta = world.getBlockMetadata(x, y, z); + return getPlankFireSpreadSpeed(this, meta); } - public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face) { - if (metadata == 2 || metadata == 4 || metadata > 10) return 0; - return this.getFireSpreadSpeed(world, x, y, z, face); + public static int getPlankFireSpreadSpeed(Block block, int meta) { + if (meta == 2 || meta == 4 || meta > 10) return 0; + return Blocks.fire.getEncouragement(block); } @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..9c53e557 100644 --- a/src/main/java/mods/natura/blocks/trees/SimpleLog.java +++ b/src/main/java/mods/natura/blocks/trees/SimpleLog.java @@ -4,11 +4,11 @@ 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; @@ -20,7 +20,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 +44,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..72faf944 100644 --- a/src/main/java/mods/natura/common/NContent.java +++ b/src/main/java/mods/natura/common/NContent.java @@ -41,9 +41,10 @@ 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.PlankSlab1; +import mods.natura.blocks.PlankSlab2; import mods.natura.blocks.crops.BerryBush; import mods.natura.blocks.crops.CropBlock; import mods.natura.blocks.crops.FlowerBlock; @@ -223,6 +224,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 +245,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 +255,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 +263,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 +281,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 +306,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 +334,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 +343,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 +357,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 +366,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 +404,21 @@ 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"); + PlankSlab1 dslab1 = (PlankSlab1) new PlankSlab1(true).setBlockName("plankSlab1Double"); + PlankSlab1 sSlab1 = (PlankSlab1) new PlankSlab1(false).setBlockName("plankSlab1"); + plankSlab1Double = GameRegistry + .registerBlock(dslab1, PlankSlab1Item.class, "plankSlab1Double", sSlab1, dslab1); + plankSlab1 = GameRegistry.registerBlock(sSlab1, PlankSlab1Item.class, "plankSlab1", sSlab1, dslab1); + Blocks.fire.setFireInfo(plankSlab1, 5, 20); + Blocks.fire.setFireInfo(plankSlab1Double, 5, 20); + + PlankSlab2 dslab2 = (PlankSlab2) new PlankSlab2(true).setBlockName("plankSlab2Double"); + PlankSlab2 sSlab2 = (PlankSlab2) new PlankSlab2(false).setBlockName("plankSlab2"); + plankSlab2Double = GameRegistry + .registerBlock(dslab2, PlankSlab2Item.class, "plankSlab2Double", sSlab2, dslab2); + plankSlab2 = GameRegistry.registerBlock(sSlab2, PlankSlab2Item.class, "plankSlab2", sSlab2, dslab2); + Blocks.fire.setFireInfo(plankSlab2, 5, 20); + Blocks.fire.setFireInfo(plankSlab2Double, 5, 20); } // Wooden Trapdoors @@ -447,6 +482,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 +492,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 +509,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 +520,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 +2061,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 +2109,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..15de443a 100644 --- a/src/main/java/mods/natura/items/blocks/GrassSlabItem.java +++ b/src/main/java/mods/natura/items/blocks/GrassSlabItem.java @@ -1,22 +1,13 @@ package mods.natura.items.blocks; import net.minecraft.block.Block; +import net.minecraft.item.ItemSlab; -import mantle.blocks.abstracts.MultiItemBlock; +import mods.natura.blocks.GrassSlab; -public class GrassSlabItem extends MultiItemBlock { +public class GrassSlabItem extends ItemSlab { - 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/OverworldLeavesItem.java b/src/main/java/mods/natura/items/blocks/OverworldLeavesItem.java index 96eee0b5..9f3dd39f 100644 --- a/src/main/java/mods/natura/items/blocks/OverworldLeavesItem.java +++ b/src/main/java/mods/natura/items/blocks/OverworldLeavesItem.java @@ -21,11 +21,10 @@ public OverworldLeavesItem(Block i) { setHasSubtypes(true); } - /* - * @Override public String getUnlocalizedName (ItemStack itemstack) { int i = - * MathHelper.clamp_int(itemstack.getItemDamage(), 0, 3); return (new - * StringBuilder()).append("block.leaves.").append(blockType[i]).toString(); } - */ + @Override + public int getMetadata(int meta) { + return meta | 4; + } @Override @SideOnly(Side.CLIENT) diff --git a/src/main/java/mods/natura/items/blocks/PlankSlab1Item.java b/src/main/java/mods/natura/items/blocks/PlankSlab1Item.java index 8be246cb..6692ba6b 100644 --- a/src/main/java/mods/natura/items/blocks/PlankSlab1Item.java +++ b/src/main/java/mods/natura/items/blocks/PlankSlab1Item.java @@ -4,34 +4,20 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemSlab; 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; +import mods.natura.blocks.PlankSlab1; -public class PlankSlab1Item extends MultiItemBlock { +public class PlankSlab1Item extends ItemSlab { - 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); + public PlankSlab1Item(Block block, PlankSlab1 singleSlab, PlankSlab1 doubleSlab) { + super(block, singleSlab, doubleSlab, block == doubleSlab); } - /* - * @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) { @@ -43,12 +29,14 @@ public void addInformation(ItemStack stack, EntityPlayer player, List list, bool list.add(StatCollector.translateToLocal("tooltip.tree2")); break; case 2: + list.add(StatCollector.translateToLocal("tooltip.nethertree")); list.add(StatCollector.translateToLocal("tooltip.tree3")); break; case 3: list.add(StatCollector.translateToLocal("tooltip.tree4")); break; case 4: + list.add(StatCollector.translateToLocal("tooltip.nethertree")); list.add(StatCollector.translateToLocal("tooltip.tree5")); break; case 5: @@ -62,28 +50,4 @@ public void addInformation(ItemStack stack, EntityPlayer player, List list, bool 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 index 2011c68a..1551363c 100644 --- a/src/main/java/mods/natura/items/blocks/PlankSlab2Item.java +++ b/src/main/java/mods/natura/items/blocks/PlankSlab2Item.java @@ -4,38 +4,18 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemSlab; 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; +import mods.natura.blocks.PlankSlab2; -public class PlankSlab2Item extends MultiItemBlock { +public class PlankSlab2Item extends ItemSlab { - 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(); + public PlankSlab2Item(Block block, PlankSlab2 singleSlab, PlankSlab2 doubleSlab) { + super(block, singleSlab, doubleSlab, block == doubleSlab); } @Override @@ -60,28 +40,4 @@ public void addInformation(ItemStack stack, EntityPlayer player, List list, bool 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); - } }