diff --git a/.gitignore b/.gitignore index f16ba47..c194f50 100644 --- a/.gitignore +++ b/.gitignore @@ -21,21 +21,5 @@ build eclipse run -CREDITS-fml.txt -Paulscode SoundSystem CodecIBXM License.txt -LICENSE-new.txt -forge-1.10.2-12.18.3.2221-changelog.txt -Paulscode IBXM Library License.txt -MinecraftForge-Credits.txt -.gradle.zip -shoots.png -dates.1.png -dates.0.png -palm.png -palette.png -dates.2.png -forge-1.10.2-12.18.3.2281-changelog.txt -README.txt -src/main/resources/mcmod.info secret.json -secret.txt +secret.txt \ No newline at end of file diff --git a/LICENSE b/LICENSE.md similarity index 100% rename from LICENSE rename to LICENSE.md diff --git a/build.gradle b/build.gradle index 024e629..eb5a2b0 100644 --- a/build.gradle +++ b/build.gradle @@ -59,9 +59,9 @@ if (secretFile.exists()) { } minecraft { - version = "1.12-14.21.1.2443" + version = "1.12.2-14.23.5.2836" runDir = "run" - mappings = "snapshot_20180709" + mappings = "stable_39" // makeObfSourceJar = false } diff --git a/src/main/java/panda/gotwood/GotWood.java b/src/main/java/panda/gotwood/GotWood.java index 06ecbf3..7d97175 100644 --- a/src/main/java/panda/gotwood/GotWood.java +++ b/src/main/java/panda/gotwood/GotWood.java @@ -9,70 +9,65 @@ import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; - import panda.gotwood.block.entity.TileEntityTreeTap; import panda.gotwood.events.ConfigurationHandler; import panda.gotwood.generation.WorldGenerator; -import panda.gotwood.proxy.CommonProxy; import panda.gotwood.registry.BlockRegistry; import panda.gotwood.registry.ItemRegistry; import panda.gotwood.registry.MasterRegistrar; -@Mod(modid = GotWood.MODID, name = GotWood.NAME, version = GotWood.VERSION) - -public class GotWood -{ - public static final String MODID = "gotwood"; - public static final String ID = MODID; // lots of use of "GotWood.ID" still in the code-base, Panda - public static final String VERSION = "0.26.0"; - - public static final String NAME = "Got Wood?"; +@Mod( + modid = GotWood.MODID, + name = GotWood.NAME, + version = GotWood.VERSION) +public class GotWood { - @SidedProxy(clientSide = "panda.gotwood.proxy.ClientProxy", serverSide = "panda.gotwood.proxy.ServerProxy") - public static CommonProxy proxy; + //TODO Setup new gradle scripts and mod info -ProxyNeko + public static final String MODID = "gotwood"; + public static final String VERSION = "0.26.0"; + public static final String NAME = "Got Wood?"; - @SubscribeEvent - public void registerSpecialRecipes(RegistryEvent.Register event) { - if (ConfigurationHandler.retrieveSaplingsMode == 2) { - ResourceLocation group = new ResourceLocation(GotWood.ID); - GameRegistry.addShapelessRecipe(new ResourceLocation("oak_seed"), group, new ItemStack(Blocks.SAPLING, 1, 0), Ingredient.fromStacks(new ItemStack(ItemRegistry.oak_seed))); - GameRegistry.addShapelessRecipe(new ResourceLocation("spruce_seed"), group, new ItemStack(Blocks.SAPLING, 1, 1), Ingredient.fromStacks(new ItemStack(ItemRegistry.spruce_seed))); - GameRegistry.addShapelessRecipe(new ResourceLocation("birch_seed"), group, new ItemStack(Blocks.SAPLING, 1, 2), Ingredient.fromStacks(new ItemStack(ItemRegistry.birch_seed))); - GameRegistry.addShapelessRecipe(new ResourceLocation("jungle_seed"), group, new ItemStack(Blocks.SAPLING, 1, 3), Ingredient.fromStacks(new ItemStack(ItemRegistry.jungle_seed))); - GameRegistry.addShapelessRecipe(new ResourceLocation("acacia_seed"), group, new ItemStack(Blocks.SAPLING, 1, 4), Ingredient.fromStacks(new ItemStack(ItemRegistry.acacia_seed))); - GameRegistry.addShapelessRecipe(new ResourceLocation("dark_oak_seed"), group, new ItemStack(Blocks.SAPLING, 1, 5), Ingredient.fromStacks(new ItemStack(ItemRegistry.dark_oak_seed))); + public static final CreativeTabs TREE_TAB = new CreativeTabs(GotWood.MODID) { + @Override + public ItemStack createIcon() { + return new ItemStack(ItemRegistry.oak_seed); + } + }; - GameRegistry.addShapelessRecipe(new ResourceLocation("apple_seed"), group, new ItemStack(BlockRegistry.apple_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.apple_seed))); - GameRegistry.addShapelessRecipe(new ResourceLocation("maple_seed"), group, new ItemStack(BlockRegistry.maple_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.maple_seed))); - GameRegistry.addShapelessRecipe(new ResourceLocation("pine_seed"), group, new ItemStack(BlockRegistry.pine_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.pine_seed))); - GameRegistry.addShapelessRecipe(new ResourceLocation("willow_seed"), group, new ItemStack(BlockRegistry.willow_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.willow_seed))); - GameRegistry.addShapelessRecipe(new ResourceLocation("yew_seed"), group, new ItemStack(BlockRegistry.yew_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.yew_seed))); - GameRegistry.addShapelessRecipe(new ResourceLocation("ebony_seed"), group, new ItemStack(BlockRegistry.ebony_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.ebony_seed))); - GameRegistry.addShapelessRecipe(new ResourceLocation("fir_seed"), group, new ItemStack(BlockRegistry.fir_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.fir_seed))); - } - } + @SubscribeEvent + public void registerSpecialRecipes(RegistryEvent.Register event) { + if (ConfigurationHandler.retrieveSaplingsMode == 2) { + ResourceLocation group = new ResourceLocation(GotWood.MODID); + GameRegistry.addShapelessRecipe(new ResourceLocation("oak_seed"), group, new ItemStack(Blocks.SAPLING, 1, 0), Ingredient.fromStacks(new ItemStack(ItemRegistry.oak_seed))); + GameRegistry.addShapelessRecipe(new ResourceLocation("spruce_seed"), group, new ItemStack(Blocks.SAPLING, 1, 1), Ingredient.fromStacks(new ItemStack(ItemRegistry.spruce_seed))); + GameRegistry.addShapelessRecipe(new ResourceLocation("birch_seed"), group, new ItemStack(Blocks.SAPLING, 1, 2), Ingredient.fromStacks(new ItemStack(ItemRegistry.birch_seed))); + GameRegistry.addShapelessRecipe(new ResourceLocation("jungle_seed"), group, new ItemStack(Blocks.SAPLING, 1, 3), Ingredient.fromStacks(new ItemStack(ItemRegistry.jungle_seed))); + GameRegistry.addShapelessRecipe(new ResourceLocation("acacia_seed"), group, new ItemStack(Blocks.SAPLING, 1, 4), Ingredient.fromStacks(new ItemStack(ItemRegistry.acacia_seed))); + GameRegistry.addShapelessRecipe(new ResourceLocation("dark_oak_seed"), group, new ItemStack(Blocks.SAPLING, 1, 5), Ingredient.fromStacks(new ItemStack(ItemRegistry.dark_oak_seed))); - @EventHandler - public void preinit(FMLPreInitializationEvent event) { - MasterRegistrar.callRegistry(event); - } + GameRegistry.addShapelessRecipe(new ResourceLocation("apple_seed"), group, new ItemStack(BlockRegistry.apple_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.apple_seed))); + GameRegistry.addShapelessRecipe(new ResourceLocation("maple_seed"), group, new ItemStack(BlockRegistry.maple_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.maple_seed))); + GameRegistry.addShapelessRecipe(new ResourceLocation("pine_seed"), group, new ItemStack(BlockRegistry.pine_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.pine_seed))); + GameRegistry.addShapelessRecipe(new ResourceLocation("willow_seed"), group, new ItemStack(BlockRegistry.willow_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.willow_seed))); + GameRegistry.addShapelessRecipe(new ResourceLocation("yew_seed"), group, new ItemStack(BlockRegistry.yew_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.yew_seed))); + GameRegistry.addShapelessRecipe(new ResourceLocation("ebony_seed"), group, new ItemStack(BlockRegistry.ebony_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.ebony_seed))); + GameRegistry.addShapelessRecipe(new ResourceLocation("fir_seed"), group, new ItemStack(BlockRegistry.fir_sapling), Ingredient.fromStacks(new ItemStack(ItemRegistry.fir_seed))); + } + } - @EventHandler - public void init(FMLInitializationEvent event) { - GameRegistry.registerWorldGenerator(new WorldGenerator(), 0); - BlockRegistry.specialfire.initInfo(); - GameRegistry.registerTileEntity(TileEntityTreeTap.class, "gotwood:tree_tap"); - } + @EventHandler + public void preinit(FMLPreInitializationEvent event) { + MasterRegistrar.callRegistry(event); + } - public static final CreativeTabs TREE_TAB = new CreativeTabs(GotWood.ID) { - @Override - public ItemStack getTabIconItem() { - return new ItemStack(ItemRegistry.oak_seed); - } - }; + @EventHandler + public void init(FMLInitializationEvent event) { + GameRegistry.registerWorldGenerator(new WorldGenerator(), 0); + BlockRegistry.specialfire.initInfo(); + GameRegistry.registerTileEntity(TileEntityTreeTap.class, "gotwood:tree_tap"); + } } diff --git a/src/main/java/panda/gotwood/block/BlockBambooFence.java b/src/main/java/panda/gotwood/block/BlockBambooFence.java index 27c3b81..42c5521 100644 --- a/src/main/java/panda/gotwood/block/BlockBambooFence.java +++ b/src/main/java/panda/gotwood/block/BlockBambooFence.java @@ -1,8 +1,5 @@ package panda.gotwood.block; -import java.util.List; -import javax.annotation.Nullable; - import net.minecraft.block.BlockFence; import net.minecraft.block.BlockPlanks; import net.minecraft.block.SoundType; @@ -15,107 +12,106 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; +import javax.annotation.Nullable; +import java.util.List; + public final class BlockBambooFence extends BlockFence implements IOreDictionaryEntry { - private final WoodMaterial wood; - - private static final AxisAlignedBB[] BOUNDING_BOXES = new AxisAlignedBB[] { - new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D), - new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 1.0D), - new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D), - new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.625D, 1.0D, 1.0D), - new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 0.625D), - new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D), - new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.625D, 1.0D, 0.625D), - new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D), - new AxisAlignedBB(0.375D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D), - new AxisAlignedBB(0.375D, 0.0D, 0.375D, 1.0D, 1.0D, 1.0D), - new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D), - new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 1.0D), - new AxisAlignedBB(0.375D, 0.0D, 0.0D, 1.0D, 1.0D, 0.625D), - new AxisAlignedBB(0.375D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), - new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.625D), - new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D) - }; - - public static final AxisAlignedBB PILLAR_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.5D, 0.625D); - - public static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.625D, 0.625D, 1.5D, 1.0D); - - public static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.375D, 1.5D, 0.625D); - - public static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.5D, 0.375D); - - public static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.625D, 0.0D, 0.375D, 1.0D, 1.5D, 0.625D); - - public BlockBambooFence(WoodMaterial wood) { - super(Material.WOOD, BlockPlanks.EnumType.OAK.getMapColor()); - this.setSoundType(SoundType.WOOD); - this.wood = wood; - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - Blocks.FIRE.setFireInfo(this, 5, 20); - this.setRegistryName(wood.getName() + "_fence"); - } - - public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn) { - IBlockState actualstate = state.getActualState(worldIn, pos); - addCollisionBoxToList(pos, entityBox, collidingBoxes, PILLAR_AABB); - - if (actualstate.getValue(NORTH)) { - addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB); - } - - if (actualstate.getValue(EAST)) { - addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB); - } - - if (actualstate.getValue(SOUTH)) { - addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB); - } - - if (actualstate.getValue(WEST)) { - addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB); - } - } - - @Deprecated - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return BOUNDING_BOXES[getBoundingBoxIdx(this.getActualState(state, source, pos))]; - } - - private static int getBoundingBoxIdx(IBlockState state) { - int i = 0; - - if (state.getValue(NORTH)) { - i |= 1 << EnumFacing.NORTH.getHorizontalIndex(); - } - - if (state.getValue(EAST)) { - i |= 1 << EnumFacing.EAST.getHorizontalIndex(); - } - - if (state.getValue(SOUTH)) { - i |= 1 << EnumFacing.SOUTH.getHorizontalIndex(); - } - - if (state.getValue(WEST)) { - i |= 1 << EnumFacing.WEST.getHorizontalIndex(); - } - - return i; - } - - public WoodMaterial getWoodMaterial() { - return this.wood; - } - - @Override - public String getOreDictionaryName() { - return "fence" + this.wood.getCapitalizedName(); - } + + private final WoodMaterial wood; + + private static final AxisAlignedBB[] BOUNDING_BOXES = new AxisAlignedBB[]{ + new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D), + new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 1.0D), + new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D), + new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.625D, 1.0D, 1.0D), + new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 0.625D), + new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D), + new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.625D, 1.0D, 0.625D), + new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D), + new AxisAlignedBB(0.375D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D), + new AxisAlignedBB(0.375D, 0.0D, 0.375D, 1.0D, 1.0D, 1.0D), + new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D), + new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 1.0D), + new AxisAlignedBB(0.375D, 0.0D, 0.0D, 1.0D, 1.0D, 0.625D), + new AxisAlignedBB(0.375D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), + new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.625D), + new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D) + }; + + public static final AxisAlignedBB PILLAR_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.5D, 0.625D); + public static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.625D, 0.625D, 1.5D, 1.0D); + public static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.375D, 1.5D, 0.625D); + public static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.5D, 0.375D); + public static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.625D, 0.0D, 0.375D, 1.0D, 1.5D, 0.625D); + + public BlockBambooFence(WoodMaterial wood) { + super(Material.WOOD, BlockPlanks.EnumType.OAK.getMapColor()); + this.setSoundType(SoundType.WOOD); + this.wood = wood; + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + Blocks.FIRE.setFireInfo(this, 5, 20); + this.setRegistryName(wood.getName() + "_fence"); + } + + public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn) { + IBlockState actualstate = state.getActualState(worldIn, pos); + addCollisionBoxToList(pos, entityBox, collidingBoxes, PILLAR_AABB); + + if (actualstate.getValue(NORTH)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB); + } + + if (actualstate.getValue(EAST)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB); + } + + if (actualstate.getValue(SOUTH)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB); + } + + if (actualstate.getValue(WEST)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB); + } + } + + @Deprecated + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return BOUNDING_BOXES[getBoundingBoxIdx(this.getActualState(state, source, pos))]; + } + + private static int getBoundingBoxIdx(IBlockState state) { + int i = 0; + + if (state.getValue(NORTH)) { + i |= 1 << EnumFacing.NORTH.getHorizontalIndex(); + } + + if (state.getValue(EAST)) { + i |= 1 << EnumFacing.EAST.getHorizontalIndex(); + } + + if (state.getValue(SOUTH)) { + i |= 1 << EnumFacing.SOUTH.getHorizontalIndex(); + } + + if (state.getValue(WEST)) { + i |= 1 << EnumFacing.WEST.getHorizontalIndex(); + } + + return i; + } + + public WoodMaterial getWoodMaterial() { + return this.wood; + } + + @Override + public String getOreDictionaryName() { + return "fence" + this.wood.getCapitalizedName(); + } } diff --git a/src/main/java/panda/gotwood/block/BlockBambooLog.java b/src/main/java/panda/gotwood/block/BlockBambooLog.java index ceb3aba..fd2d39d 100644 --- a/src/main/java/panda/gotwood/block/BlockBambooLog.java +++ b/src/main/java/panda/gotwood/block/BlockBambooLog.java @@ -1,9 +1,5 @@ package panda.gotwood.block; -import java.util.List; -import java.util.Random; -import javax.annotation.Nullable; - import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.block.material.Material; @@ -20,7 +16,6 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import panda.gotwood.registry.BlockRegistry; import panda.gotwood.registry.ItemRegistry; import panda.gotwood.util.IFireDrops; @@ -28,152 +23,157 @@ import panda.gotwood.util.WoodMaterial; import panda.gotwood.util.WoodMaterials; +import javax.annotation.Nullable; +import java.util.List; +import java.util.Random; + public final class BlockBambooLog extends Block implements IOreDictionaryEntry, IGrowable, IFireDrops { - public static final PropertyBool LEAVES = PropertyBool.create("leaves"); - - public BlockBambooLog(WoodMaterial wood) { - super(Material.WOOD); - this.setDefaultState(this.blockState.getBaseState().withProperty(LEAVES, false)); - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - this.setRegistryName(wood.getName() + "_log"); - - } - - @SideOnly(Side.CLIENT) - @Override - public BlockRenderLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT_MIPPED; - } - - @Override - public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity) { - return true; - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return state == this.getDefaultState() ? new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D) : new AxisAlignedBB(0D, 0D, 0D, 1D, 1.0D, 1D); - } - - @Nullable - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { - return blockState == this.getDefaultState() ? new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D) : new AxisAlignedBB(0D, 0D, 0D, 1D, 1.0D, 1D); - } - - @Override - public boolean canSustainLeaves(IBlockState state, IBlockAccess world, BlockPos pos) { - return true; - } - - public boolean isFullCube(IBlockState state) { - return false; - } - - public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { - return false; - } - - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - List ret = new java.util.ArrayList<>(); - ret.add(new ItemStack(ItemRegistry.bamboo_pole)); - return ret; - } - - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { - return side != EnumFacing.DOWN || super.shouldSideBeRendered(blockState, blockAccess, pos, side); - } - - @Override - public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) { - return false; - } - - @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos frompos) { - if (world.getBlockState(pos.north()).getBlock() == BlockRegistry.bamboo_leaves || world.getBlockState(pos.west()).getBlock() == BlockRegistry.bamboo_leaves || world.getBlockState(pos.east()).getBlock() == BlockRegistry.bamboo_leaves || world.getBlockState(pos.south()).getBlock() == BlockRegistry.bamboo_leaves) { - world.setBlockState(pos, this.getDefaultState().withProperty(LEAVES, true), 2); - } else { - world.setBlockState(pos, this.getDefaultState().withProperty(LEAVES, false), 2); - } - this.checkAndDropBlock(world, pos, state); - - } - - protected final void checkAndDropBlock(World world, BlockPos pos, IBlockState state) { - boolean drop = world.getBlockState(pos.down()).getBlock() != this && !world.getBlockState(pos.down()).isNormalCube(); - if (drop && !world.isRemote) { - world.destroyBlock(pos, true); - breakBlock(world, pos, state); - } - } - - public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { - int k = pos.getX(); - int l = pos.getY(); - int i1 = pos.getZ(); - if (worldIn.isAreaLoaded(new BlockPos(k - 2, l - 2, i1 - 2), new BlockPos(k + 2, l + 2, i1 + 2))) { - for (int j1 = -1; j1 <= 1; ++j1) { - for (int k1 = -1; k1 <= 1; ++k1) { - for (int l1 = -1; l1 <= 1; ++l1) { - BlockPos blockpos = pos.add(j1, k1, l1); - IBlockState iblockstate = worldIn.getBlockState(blockpos); - if (iblockstate.getBlock().isLeaves(iblockstate, worldIn, blockpos)) { - iblockstate.getBlock().beginLeavesDecay(iblockstate, worldIn, blockpos); - } - } - } - } - } - } - - @Override - public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) { - return false; - } - - @Override - public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) {} - - @Override - public String getOreDictionaryName() { - return "log" + WoodMaterials.bamboo.getCapitalizedName(); - } - - @Override - public boolean hasFireDrops() { - return true; - } - - @Override - public List addFireDrops(List drops, Random random) { - if (random.nextBoolean()) { - drops.add(new ItemStack(ItemRegistry.ash)); - } else { - drops.add(new ItemStack(ItemRegistry.bamboo_charcoal)); - } - return drops; - } - - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(LEAVES, meta == 1); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(LEAVES) ? 1 : 0; - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, LEAVES); - } + public static final PropertyBool LEAVES = PropertyBool.create("leaves"); + + public BlockBambooLog(WoodMaterial wood) { + super(Material.WOOD); + this.setDefaultState(this.blockState.getBaseState().withProperty(LEAVES, false)); + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + this.setRegistryName(wood.getName() + "_log"); + + } + + @SideOnly(Side.CLIENT) + @Override + public BlockRenderLayer getRenderLayer() { + return BlockRenderLayer.CUTOUT_MIPPED; + } + + @Override + public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity) { + return true; + } + + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return state == this.getDefaultState() ? new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D) : new AxisAlignedBB(0D, 0D, 0D, 1D, 1.0D, 1D); + } + + @Nullable + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { + return blockState == this.getDefaultState() ? new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D) : new AxisAlignedBB(0D, 0D, 0D, 1D, 1.0D, 1D); + } + + @Override + public boolean canSustainLeaves(IBlockState state, IBlockAccess world, BlockPos pos) { + return true; + } + + public boolean isFullCube(IBlockState state) { + return false; + } + + public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { + return false; + } + + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @Override + public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + List ret = new java.util.ArrayList<>(); + ret.add(new ItemStack(ItemRegistry.bamboo_pole)); + return ret; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { + return side != EnumFacing.DOWN || super.shouldSideBeRendered(blockState, blockAccess, pos, side); + } + + @Override + public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) { + return false; + } + + @Override + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos frompos) { + if (world.getBlockState(pos.north()).getBlock() == BlockRegistry.bamboo_leaves || world.getBlockState(pos.west()).getBlock() == BlockRegistry.bamboo_leaves || world.getBlockState(pos.east()).getBlock() == BlockRegistry.bamboo_leaves || world.getBlockState(pos.south()).getBlock() == BlockRegistry.bamboo_leaves) { + world.setBlockState(pos, this.getDefaultState().withProperty(LEAVES, true), 2); + } else { + world.setBlockState(pos, this.getDefaultState().withProperty(LEAVES, false), 2); + } + this.checkAndDropBlock(world, pos, state); + + } + + protected final void checkAndDropBlock(World world, BlockPos pos, IBlockState state) { + boolean drop = world.getBlockState(pos.down()).getBlock() != this && !world.getBlockState(pos.down()).isNormalCube(); + if (drop && !world.isRemote) { + world.destroyBlock(pos, true); + breakBlock(world, pos, state); + } + } + + public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { + int k = pos.getX(); + int l = pos.getY(); + int i1 = pos.getZ(); + if (worldIn.isAreaLoaded(new BlockPos(k - 2, l - 2, i1 - 2), new BlockPos(k + 2, l + 2, i1 + 2))) { + for (int j1 = -1; j1 <= 1; ++j1) { + for (int k1 = -1; k1 <= 1; ++k1) { + for (int l1 = -1; l1 <= 1; ++l1) { + BlockPos blockpos = pos.add(j1, k1, l1); + IBlockState iblockstate = worldIn.getBlockState(blockpos); + if (iblockstate.getBlock().isLeaves(iblockstate, worldIn, blockpos)) { + iblockstate.getBlock().beginLeavesDecay(iblockstate, worldIn, blockpos); + } + } + } + } + } + } + + @Override + public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) { + return false; + } + + @Override + public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { + } + + @Override + public String getOreDictionaryName() { + return "log" + WoodMaterials.bamboo.getCapitalizedName(); + } + + @Override + public boolean hasFireDrops() { + return true; + } + + @Override + public List addFireDrops(List drops, Random random) { + if (random.nextBoolean()) { + drops.add(new ItemStack(ItemRegistry.ash)); + } else { + drops.add(new ItemStack(ItemRegistry.bamboo_charcoal)); + } + return drops; + } + + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(LEAVES, meta == 1); + } + + @Override + public int getMetaFromState(IBlockState state) { + return state.getValue(LEAVES) ? 1 : 0; + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, LEAVES); + } } diff --git a/src/main/java/panda/gotwood/block/BlockBerryBush.java b/src/main/java/panda/gotwood/block/BlockBerryBush.java index 52bc127..f5fdbf1 100644 --- a/src/main/java/panda/gotwood/block/BlockBerryBush.java +++ b/src/main/java/panda/gotwood/block/BlockBerryBush.java @@ -1,8 +1,5 @@ package panda.gotwood.block; -import java.util.Random; -import javax.annotation.Nullable; - import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.properties.PropertyInteger; @@ -15,73 +12,77 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import javax.annotation.Nullable; +import java.util.Random; + public final class BlockBerryBush extends BlockBush { - public static final PropertyInteger GROWTH = PropertyInteger.create("growth", 0, 1); - - public BlockBerryBush() { - this.setDefaultState(this.blockState.getBaseState().withProperty(GROWTH, Integer.valueOf(0))); - this.setTickRandomly(true); - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { - super.neighborChanged(state, worldIn, pos, blockIn, fromPos); - this.checkAndDropBlock(worldIn, pos, state); - } - - @Override - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { - this.checkAndDropBlock(worldIn, pos, state); - } - - @Override - protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state) { - if (!this.canBlockStay(worldIn, pos, state) || areaCleared(worldIn, pos)) { - if (areaCleared(worldIn, pos)) { - this.dropBlockAsItem(worldIn, pos, state, 0); - } - worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 3); - } - } - - public boolean areaCleared(World world, BlockPos pos) { - return (world.getBlockState(pos.down(2)).getBlock() == Blocks.AIR) && (world.getBlockState(pos.east()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.east().down()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.west()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.west().down()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.north()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.north().down()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.south()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.south().down()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.down()).getBlock() != Blocks.AIR); - } - - @Override - public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) { - return this.canSustainBush(worldIn.getBlockState(pos.down())); - - } - - @Override - public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack) { - super.harvestBlock(worldIn, player, pos, state, te, stack); - worldIn.setBlockToAir(pos); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(GROWTH, Integer.valueOf(meta)); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(GROWTH).intValue(); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, GROWTH); - } + + public static final PropertyInteger GROWTH = PropertyInteger.create("growth", 0, 1); + + public BlockBerryBush() { + this.setDefaultState(this.blockState.getBaseState().withProperty(GROWTH, 0)); + this.setTickRandomly(true); + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @Override + public boolean isFullCube(IBlockState state) { + return false; + } + + @Override + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { + super.neighborChanged(state, worldIn, pos, blockIn, fromPos); + this.checkAndDropBlock(worldIn, pos, state); + } + + @Override + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + this.checkAndDropBlock(worldIn, pos, state); + } + + @Override + protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state) { + if (!this.canBlockStay(worldIn, pos, state) || areaCleared(worldIn, pos)) { + if (areaCleared(worldIn, pos)) { + this.dropBlockAsItem(worldIn, pos, state, 0); + } + worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 3); + } + } + + public boolean areaCleared(World world, BlockPos pos) { + return (world.getBlockState(pos.down(2)).getBlock() == Blocks.AIR) && (world.getBlockState(pos.east()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.east().down()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.west()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.west().down()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.north()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.north().down()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.south()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.south().down()).getBlock() == Blocks.AIR) && (world.getBlockState(pos.down()).getBlock() != Blocks.AIR); + } + + @Override + public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) { + return this.canSustainBush(worldIn.getBlockState(pos.down())); + + } + + @Override + public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack) { + super.harvestBlock(worldIn, player, pos, state, te, stack); + worldIn.setBlockToAir(pos); + } + + @Override + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(GROWTH, meta); + } + + @Override + public int getMetaFromState(IBlockState state) { + return state.getValue(GROWTH); + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, GROWTH); + } } diff --git a/src/main/java/panda/gotwood/block/BlockDates.java b/src/main/java/panda/gotwood/block/BlockDates.java index 117f7a1..29c5e27 100644 --- a/src/main/java/panda/gotwood/block/BlockDates.java +++ b/src/main/java/panda/gotwood/block/BlockDates.java @@ -1,8 +1,5 @@ package panda.gotwood.block; -import java.util.Random; -import javax.annotation.Nullable; - import net.minecraft.block.Block; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.IGrowable; @@ -26,163 +23,166 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import panda.gotwood.registry.BlockRegistry; import panda.gotwood.registry.ItemRegistry; +import javax.annotation.Nullable; +import java.util.Random; + public final class BlockDates extends BlockHorizontal implements IGrowable { - public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 2); - - public BlockDates() { - super(Material.PLANTS); - this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(AGE, 0)); - this.setTickRandomly(true); - this.setRegistryName("block_dates"); - } - - @Override - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { - if (!this.canBlockStay(worldIn, pos, state)) { - this.dropBlock(worldIn, pos, state); - } else { - int i = state.getValue(AGE); - if (i < 2 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, pos, state, rand.nextInt(5) == 0)) { - worldIn.setBlockState(pos, state.withProperty(AGE, i + 1), 2); - net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos)); - } - } - } - - public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) { - BlockPos offset = pos.offset(state.getValue(FACING)); - IBlockState iblockstate = worldIn.getBlockState(offset); - return iblockstate.getBlock() == BlockRegistry.palm_log || worldIn.getBlockState(offset.up()) == BlockRegistry.palm_log; - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return new AxisAlignedBB(0, 0, 0, 1, 1, 1); - } - - @Override - public IBlockState withRotation(IBlockState state, Rotation rot) { - return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); - } - - @Override - public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { - return state.withRotation(mirrorIn.toRotation(state.getValue(FACING))); - } - - @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { - EnumFacing enumfacing = EnumFacing.fromAngle((double) placer.rotationYaw); - worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); - } - - public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { - if (!facing.getAxis().isHorizontal()) { - facing = EnumFacing.NORTH; - } - - return this.getDefaultState().withProperty(FACING, facing.getOpposite()).withProperty(AGE, Integer.valueOf(0)); - } - - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { - if (!this.canBlockStay(worldIn, pos, state)) { - this.dropBlock(worldIn, pos, state); - } - } - - private void dropBlock(World worldIn, BlockPos pos, IBlockState state) { - worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 3); - } - - @Nullable - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { - return null; - } - - @Override - public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) { - super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune); - } - - @Override - public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - java.util.List dropped = super.getDrops(world, pos, state, fortune); - int i = state.getValue(AGE); - if (i == 2) { - Random rand = world instanceof World ? ((World) world).rand : RANDOM; - dropped.add(new ItemStack(ItemRegistry.dates, rand.nextInt(2) + 2)); - } - return dropped; - } - - @Override - public boolean canDropFromExplosion(Explosion explosionIn) { - return false; - } - - @Override - public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) { - return false; - } - - @Override - public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { - return new ItemStack(ItemRegistry.dates); - } - - public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) { - return state.getValue(AGE) < 2; - } - - public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) { - return true; - } - - public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { - worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(state.getValue(AGE) + 1)), 2); - } - - @SideOnly(Side.CLIENT) - @Override - public BlockRenderLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT; - } - - @Nullable - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) { - return null; - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)).withProperty(AGE, Integer.valueOf((meta & 15) >> 2)); - } - - @Override - public int getMetaFromState(IBlockState state) { - int i = 0; - i = i | state.getValue(FACING).getHorizontalIndex(); - i = i | state.getValue(AGE) << 2; - return i; - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, FACING, AGE); - } + + public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 2); + + public BlockDates() { + super(Material.PLANTS); + this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(AGE, 0)); + this.setTickRandomly(true); + this.setRegistryName("block_dates"); + } + + @Override + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (!this.canBlockStay(worldIn, pos, state)) { + this.dropBlock(worldIn, pos, state); + } else { + int i = state.getValue(AGE); + if (i < 2 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, pos, state, rand.nextInt(5) == 0)) { + worldIn.setBlockState(pos, state.withProperty(AGE, i + 1), 2); + net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos)); + } + } + } + + public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) { + BlockPos offset = pos.offset(state.getValue(FACING)); + IBlockState iblockstate = worldIn.getBlockState(offset); + return iblockstate.getBlock() == BlockRegistry.palm_log || worldIn.getBlockState(offset.up()) == BlockRegistry.palm_log; + } + + @Override + public boolean isFullCube(IBlockState state) { + return false; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return new AxisAlignedBB(0, 0, 0, 1, 1, 1); + } + + @Override + public IBlockState withRotation(IBlockState state, Rotation rot) { + return state.withProperty(FACING, rot.rotate(state.getValue(FACING))); + } + + @Override + public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { + return state.withRotation(mirrorIn.toRotation(state.getValue(FACING))); + } + + @Override + public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { + EnumFacing enumfacing = EnumFacing.fromAngle((double) placer.rotationYaw); + worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); + } + + public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { + if (!facing.getAxis().isHorizontal()) { + facing = EnumFacing.NORTH; + } + + return this.getDefaultState().withProperty(FACING, facing.getOpposite()).withProperty(AGE, 0); + } + + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { + if (!this.canBlockStay(worldIn, pos, state)) { + this.dropBlock(worldIn, pos, state); + } + } + + private void dropBlock(World worldIn, BlockPos pos, IBlockState state) { + worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 3); + } + + @Nullable + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { + return null; + } + + @Override + public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) { + super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune); + } + + @Override + public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + java.util.List dropped = super.getDrops(world, pos, state, fortune); + int i = state.getValue(AGE); + if (i == 2) { + Random rand = world instanceof World ? ((World) world).rand : RANDOM; + dropped.add(new ItemStack(ItemRegistry.dates, rand.nextInt(2) + 2)); + } + return dropped; + } + + @Override + public boolean canDropFromExplosion(Explosion explosionIn) { + return false; + } + + @Override + public boolean canSilkHarvest(World world, BlockPos pos, IBlockState state, EntityPlayer player) { + return false; + } + + @Override + public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { + return new ItemStack(ItemRegistry.dates); + } + + public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) { + return state.getValue(AGE) < 2; + } + + public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) { + return true; + } + + public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { + worldIn.setBlockState(pos, state.withProperty(AGE, state.getValue(AGE) + 1), 2); + } + + @SideOnly(Side.CLIENT) + @Override + public BlockRenderLayer getRenderLayer() { + return BlockRenderLayer.CUTOUT; + } + + @Nullable + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return null; + } + + @Override + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(FACING, EnumFacing.byHorizontalIndex(meta)).withProperty(AGE, (meta & 15) >> 2); + } + + @Override + public int getMetaFromState(IBlockState state) { + int i = 0; + i = i | state.getValue(FACING).getHorizontalIndex(); + i = i | state.getValue(AGE) << 2; + return i; + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, FACING, AGE); + } } diff --git a/src/main/java/panda/gotwood/block/BlockDoubleSlab.java b/src/main/java/panda/gotwood/block/BlockDoubleSlab.java index 4d7841f..d6f5477 100644 --- a/src/main/java/panda/gotwood/block/BlockDoubleSlab.java +++ b/src/main/java/panda/gotwood/block/BlockDoubleSlab.java @@ -3,13 +3,14 @@ import panda.gotwood.util.WoodMaterial; public final class BlockDoubleSlab extends BlockWoodSlab { - public BlockDoubleSlab(WoodMaterial wood) { - super(wood); - this.setRegistryName("double_" + wood.getName() + "_slab"); - } - - @Override - public boolean isDouble() { - return true; - } + + public BlockDoubleSlab(WoodMaterial wood) { + super(wood); + this.setRegistryName("double_" + wood.getName() + "_slab"); + } + + @Override + public boolean isDouble() { + return true; + } } diff --git a/src/main/java/panda/gotwood/block/BlockFruitSapling.java b/src/main/java/panda/gotwood/block/BlockFruitSapling.java index 2620840..303356a 100644 --- a/src/main/java/panda/gotwood/block/BlockFruitSapling.java +++ b/src/main/java/panda/gotwood/block/BlockFruitSapling.java @@ -1,7 +1,5 @@ package panda.gotwood.block; -import java.util.Random; - import net.minecraft.block.BlockBush; import net.minecraft.block.IGrowable; import net.minecraft.block.SoundType; @@ -21,167 +19,143 @@ import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; -public class BlockFruitSapling extends BlockBush implements IOreDictionaryEntry, IGrowable, IPlantable{ +import java.util.Random; + +public class BlockFruitSapling extends BlockBush implements IOreDictionaryEntry, IGrowable, IPlantable { public static final PropertyInteger AGE = PropertyInteger.create("stage", 0, 4); protected static final AxisAlignedBB SAPLING_AABB = new AxisAlignedBB(0.1, 0.0D, 0.1, 0.9, 0.8, 0.9D); protected final WoodMaterial wood; - - public BlockFruitSapling(WoodMaterial wood) - { - this.wood = wood; - this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, 0)); - this.setTickRandomly(true); - this.setHardness(0.0F); - this.setSoundType(SoundType.PLANT); - this.setRegistryName(wood.getName() + "_sapling"); - } - + + public BlockFruitSapling(WoodMaterial wood) { + this.wood = wood; + this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, 0)); + this.setTickRandomly(true); + this.setHardness(0.0F); + this.setSoundType(SoundType.PLANT); + this.setRegistryName(wood.getName() + "_sapling"); + } + @Override - protected boolean canSustainBush(IBlockState state) - { + protected boolean canSustainBush(IBlockState state) { return state.getBlock() == this; } - + @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return SAPLING_AABB; } @Override - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) - { - if (!worldIn.isRemote) - { + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (!worldIn.isRemote) { super.updateTick(worldIn, pos, state, rand); - if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) - { - this.grow(worldIn,rand, pos, state); + if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) { + this.grow(worldIn, rand, pos, state); } } } - + @Override - public void breakBlock(World world, BlockPos pos, IBlockState state) - { - if(world.getBlockState(pos.up()).getBlock() == this){ - world.setBlockToAir(pos.up()); - return; - } - if(world.getBlockState(pos.down()).getBlock() == this){ - world.setBlockToAir(pos.down()); - return; - } - - } - - + public void breakBlock(World world, BlockPos pos, IBlockState state) { + if (world.getBlockState(pos.up()).getBlock() == this) { + world.setBlockToAir(pos.up()); + return; + } + if (world.getBlockState(pos.down()).getBlock() == this) { + world.setBlockToAir(pos.down()); + return; + } + + } + @Override - public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) { - return super.canBlockStay(worldIn, pos, state)||worldIn.getBlockState(pos.down()).getBlock() == this; - } + public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) { + return super.canBlockStay(worldIn, pos, state) || worldIn.getBlockState(pos.down()).getBlock() == this; + } - @Override - public boolean canPlaceBlockAt(World worldIn, BlockPos pos) - { + @Override + public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { return super.canPlaceBlockAt(worldIn, pos) && worldIn.isAirBlock(pos.up()); } - + @Override - public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) - { - int s = state.getValue(AGE); - if (s < 2) - { + public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { + int s = state.getValue(AGE); + if (s < 2) { worldIn.setBlockState(pos, state.cycleProperty(AGE)); - } - else if(s == 2) - { - if(worldIn.getBlockState(pos.up()).getMaterial().isReplaceable()){ - worldIn.setBlockState(pos, state.cycleProperty(AGE)); - worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(AGE, 4)); - } - } - else - { - if(s==4){ - pos = pos.down(); - } - this.generateTree(worldIn, pos, state, rand); + } else if (s == 2) { + if (worldIn.getBlockState(pos.up()).getMaterial().isReplaceable()) { + worldIn.setBlockState(pos, state.cycleProperty(AGE)); + worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(AGE, 4)); + } + } else { + if (s == 4) { + pos = pos.down(); + } + this.generateTree(worldIn, pos, state, rand); } } - - public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) - { + public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos)) return; - - WorldGenerator worldgenerator; + switch (wood.getName()) { + case "banana": + default: + worldgenerator = new WorldGenApple(true); + } - switch (wood.getName()) { - case "banana": - default: - worldgenerator = new WorldGenApple(true); - } - - worldIn.setBlockToAir(pos); - worldIn.setBlockToAir(pos.up()); - - if (!worldgenerator.generate(worldIn, rand, pos)) { - worldIn.setBlockState(pos, state, 4); - } - } - - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) { - return state==this.getStateFromMeta(3)?null:Items.STICK; - } + worldIn.setBlockToAir(pos); + worldIn.setBlockToAir(pos.up()); + if (!worldgenerator.generate(worldIn, rand, pos)) { + worldIn.setBlockState(pos, state, 4); + } + } - @Override - public int quantityDropped(Random random) { - return random.nextBoolean() ? 2 : 1; - } + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return state == this.getStateFromMeta(3) ? null : Items.STICK; + } + @Override + public int quantityDropped(Random random) { + return random.nextBoolean() ? 2 : 1; + } @Override - public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) - { + public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) { return true; } - + @Override - public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) - { - return ConfigurationHandler.allowBonemealFruitSaplings?(double)worldIn.rand.nextFloat() < 0.40D : false; + public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) { + return ConfigurationHandler.allowBonemealFruitSaplings && (double) worldIn.rand.nextFloat() < 0.40D; } @Override - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(AGE, meta); + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(AGE, meta); } @Override - public int getMetaFromState(IBlockState state) - { - return state.getValue(AGE); + public int getMetaFromState(IBlockState state) { + return state.getValue(AGE); } @Override - protected BlockStateContainer createBlockState() - { - return new BlockStateContainer(this,AGE); + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, AGE); } + public WoodMaterial getWoodMaterial() { - return this.wood; - } + return this.wood; + } - @Override - public String getOreDictionaryName() { - return "saplingFruit"; - } + @Override + public String getOreDictionaryName() { + return "saplingFruit"; + } } diff --git a/src/main/java/panda/gotwood/block/BlockFruitingLeaves.java b/src/main/java/panda/gotwood/block/BlockFruitingLeaves.java index d0fd31e..cf8832d 100644 --- a/src/main/java/panda/gotwood/block/BlockFruitingLeaves.java +++ b/src/main/java/panda/gotwood/block/BlockFruitingLeaves.java @@ -1,18 +1,11 @@ package panda.gotwood.block; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Random; - -import net.minecraft.block.Block; import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockPlanks.EnumType; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -30,233 +23,223 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import panda.gotwood.events.ConfigurationHandler; import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; import panda.gotwood.util.WoodMaterials; +import java.util.Arrays; +import java.util.List; +import java.util.Random; public class BlockFruitingLeaves extends BlockLeaves implements IOreDictionaryEntry { - - - public static final PropertyBool DECAYABLE = PropertyBool.create("decayable"); - - public static final PropertyBool CHECK_DECAY = PropertyBool.create("check_decay"); - - public static final PropertyInteger FRUITING = PropertyInteger.create("fruit",0,2); - - final WoodMaterial wood; - - public BlockFruitingLeaves(WoodMaterial wood) { - this.wood = wood; - Blocks.FIRE.setFireInfo(this, 30, 60); - this.setDefaultState(this.blockState.getBaseState().withProperty(DECAYABLE, false).withProperty(CHECK_DECAY, false).withProperty(FRUITING, 0)); - this.setRegistryName(wood.getName() + "_leaves"); - this.setTickRandomly(true); - } - - - - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) { - return Items.AIR; - } - - @Override - public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, - float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { - return this.getDefaultState(); - } - - @Override - public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random) { - super.randomTick(worldIn, pos, state, random); - if (state.getValue(FRUITING) == 2) { - return; - } - - if (state.getValue(FRUITING) == 1) { - worldIn.setBlockState(pos, state.cycleProperty(FRUITING), 2); - } - - if (state.getValue(DECAYABLE) && random.nextInt(ConfigurationHandler.appleFruitingChance) == 0) { - - - - int adjacent = 0; - if (worldIn.getBlockState(pos.up()).getBlock() == this) { - if (worldIn.getBlockState(pos.up()).getValue(FRUITING) >0) { - adjacent++; - } - } - if (worldIn.getBlockState(pos.down()).getBlock() == this) { - if (worldIn.getBlockState(pos.down()).getValue(FRUITING)>0) { - adjacent++; - } - } - if (worldIn.getBlockState(pos.east()).getBlock() == this) { - if (worldIn.getBlockState(pos.east()).getValue(FRUITING)>0) { - adjacent++; - } - } - if (worldIn.getBlockState(pos.south()).getBlock() == this) { - if (worldIn.getBlockState(pos.south()).getValue(FRUITING)>0) { - adjacent++; - } - } - if (worldIn.getBlockState(pos.north()).getBlock() == this) { - if (worldIn.getBlockState(pos.north()).getValue(FRUITING)>0) { - adjacent++; - } - } - if (worldIn.getBlockState(pos.west()).getBlock() == this) { - if (worldIn.getBlockState(pos.west()).getValue(FRUITING)>0) { - adjacent++; - } - } - - if (adjacent <= 1) { - worldIn.setBlockState(pos, state.withProperty(FRUITING, 1), 2); - } - } - - } - - @Override - public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - java.util.List ret = new java.util.ArrayList<>(); - Random rand = world instanceof World ? ((World) world).rand : new Random(); - int chance = -1; - if (state.getValue(FRUITING) == 2) { - if (wood == WoodMaterials.apple) {//Allow for other fruit trees later - chance = getModifiedChance(ConfigurationHandler.appleChance, fortune, ConfigurationHandler.appleDropFortuneDecrement, ConfigurationHandler.appleDropMinChance); - - ret.add(new ItemStack(Items.APPLE)); - - if (rand.nextInt(chance) == 0) { - ret.add(new ItemStack(Items.APPLE)); - } - - chance = getModifiedChance(ConfigurationHandler.goldenDropChance, fortune, ConfigurationHandler.goldenDropFortuneDecrement, ConfigurationHandler.goldenDropMinChance); - if (rand.nextInt(chance) == 0) { - ret.add(new ItemStack(Items.GOLDEN_APPLE)); - } - } - } - - this.captureDrops(true); - - ret.addAll(this.captureDrops(false)); - return ret; - } - - @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - - if (!worldIn.isRemote ) { - if( state.getValue(FRUITING) == 2){ - for (ItemStack item : this.getDrops(worldIn, pos, state, 0)) { - worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.6F, 0.8F / (worldIn.rand.nextFloat() * 0.4F + 0.8F)); - EntityItem entityitem = new EntityItem(worldIn, pos.getX() + 0.5 + facing.getFrontOffsetX() * 0.7, pos.getY() + 0.5 + facing.getFrontOffsetY() * 0.7, pos.getZ() + 0.5 + facing.getFrontOffsetZ() * 0.7, item); - entityitem.motionX *= 0.2; - entityitem.motionY = 0; - entityitem.motionZ *= 0.2; - worldIn.spawnEntity(entityitem); - worldIn.setBlockState(pos, state.withProperty(FRUITING, 0), 2); - } - } - - } - - return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); - } - - private int getModifiedChance(int chance, int fortune, int decrement, int minchance) { - - int modifiedchance = chance; - if (fortune > 0) { - modifiedchance -= decrement << fortune; - if (modifiedchance < minchance) { - modifiedchance = minchance; - } - } - return modifiedchance; - } - - @SideOnly(Side.CLIENT) - public int getBlockColor() { - return 16777215; - } - - @SideOnly(Side.CLIENT) - public int getRenderColor(IBlockState state) { - return 16777215; - } - - @SideOnly(Side.CLIENT) - public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { - return 16777215; - } - - @SideOnly(Side.CLIENT) - @Override - public BlockRenderLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT_MIPPED; - } - - @Override - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { - return true; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public boolean isFoliage(IBlockAccess world, BlockPos pos) { - return true; - } - - @Override - public EnumType getWoodType(int meta) { - return null; - } - - public WoodMaterial getWoodMaterial() { - return this.wood; - } - - @Override - public String getOreDictionaryName() { - return "leavesFruit" + this.wood.getCapitalizedName(); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(DECAYABLE, meta % 2 == 1).withProperty(CHECK_DECAY, meta<6).withProperty(FRUITING, Arrays.asList(0,1,10,11).contains(meta)?Arrays.asList(2,3,8,9).contains(meta)?2:1:0); - } - - @Override - public int getMetaFromState(IBlockState state) { - int i = 0; - i += state.getValue(DECAYABLE)?1:0; - i += state.getValue(CHECK_DECAY) ? 0 : 6; - i += state.getValue(FRUITING)*2; - return i; - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, CHECK_DECAY, DECAYABLE, FRUITING); - } - - @Override - public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) { - return java.util.Arrays.asList(new ItemStack(this, 1)); - } - + public static final PropertyBool DECAYABLE = PropertyBool.create("decayable"); + public static final PropertyBool CHECK_DECAY = PropertyBool.create("check_decay"); + public static final PropertyInteger FRUITING = PropertyInteger.create("fruit", 0, 2); + final WoodMaterial wood; + + public BlockFruitingLeaves(WoodMaterial wood) { + this.wood = wood; + Blocks.FIRE.setFireInfo(this, 30, 60); + this.setDefaultState(this.blockState.getBaseState().withProperty(DECAYABLE, false).withProperty(CHECK_DECAY, false).withProperty(FRUITING, 0)); + this.setRegistryName(wood.getName() + "_leaves"); + this.setTickRandomly(true); + } + + + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return Items.AIR; + } + + @Override + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, + float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { + return this.getDefaultState(); + } + + @Override + public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random) { + super.randomTick(worldIn, pos, state, random); + if (state.getValue(FRUITING) == 2) { + return; + } + + if (state.getValue(FRUITING) == 1) { + worldIn.setBlockState(pos, state.cycleProperty(FRUITING), 2); + } + + if (state.getValue(DECAYABLE) && random.nextInt(ConfigurationHandler.appleFruitingChance) == 0) { + int adjacent = 0; + if (worldIn.getBlockState(pos.up()).getBlock() == this) { + if (worldIn.getBlockState(pos.up()).getValue(FRUITING) > 0) { + adjacent++; + } + } + + if (worldIn.getBlockState(pos.down()).getBlock() == this) { + if (worldIn.getBlockState(pos.down()).getValue(FRUITING) > 0) { + adjacent++; + } + } + + if (worldIn.getBlockState(pos.east()).getBlock() == this) { + if (worldIn.getBlockState(pos.east()).getValue(FRUITING) > 0) { + adjacent++; + } + } + + if (worldIn.getBlockState(pos.south()).getBlock() == this) { + if (worldIn.getBlockState(pos.south()).getValue(FRUITING) > 0) { + adjacent++; + } + } + + if (worldIn.getBlockState(pos.north()).getBlock() == this) { + if (worldIn.getBlockState(pos.north()).getValue(FRUITING) > 0) { + adjacent++; + } + } + + if (worldIn.getBlockState(pos.west()).getBlock() == this) { + if (worldIn.getBlockState(pos.west()).getValue(FRUITING) > 0) { + adjacent++; + } + } + + if (adjacent <= 1) { + worldIn.setBlockState(pos, state.withProperty(FRUITING, 1), 2); + } + } + } + + @Override + public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + java.util.List ret = new java.util.ArrayList<>(); + Random rand = world instanceof World ? ((World) world).rand : new Random(); + int chance = -1; + if (state.getValue(FRUITING) == 2) { + if (wood == WoodMaterials.apple) {//Allow for other fruit trees later + chance = getModifiedChance(ConfigurationHandler.appleChance, fortune, ConfigurationHandler.appleDropFortuneDecrement, ConfigurationHandler.appleDropMinChance); + ret.add(new ItemStack(Items.APPLE)); + if (rand.nextInt(chance) == 0) { + ret.add(new ItemStack(Items.APPLE)); + } + + chance = getModifiedChance(ConfigurationHandler.goldenDropChance, fortune, ConfigurationHandler.goldenDropFortuneDecrement, ConfigurationHandler.goldenDropMinChance); + if (rand.nextInt(chance) == 0) { + ret.add(new ItemStack(Items.GOLDEN_APPLE)); + } + } + } + + this.captureDrops(true); + ret.addAll(this.captureDrops(false)); + return ret; + } + + @Override + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + if (!worldIn.isRemote) { + if (state.getValue(FRUITING) == 2) { + for (ItemStack item : this.getDrops(worldIn, pos, state, 0)) { + worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.6F, 0.8F / (worldIn.rand.nextFloat() * 0.4F + 0.8F)); + EntityItem entityitem = new EntityItem(worldIn, pos.getX() + 0.5 + facing.getXOffset() * 0.7, pos.getY() + 0.5 + facing.getYOffset() * 0.7, pos.getZ() + 0.5 + facing.getZOffset() * 0.7, item); + entityitem.motionX *= 0.2; + entityitem.motionY = 0; + entityitem.motionZ *= 0.2; + worldIn.spawnEntity(entityitem); + worldIn.setBlockState(pos, state.withProperty(FRUITING, 0), 2); + } + } + + } + return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); + } + + private int getModifiedChance(int chance, int fortune, int decrement, int minchance) { + int modifiedchance = chance; + if (fortune > 0) { + modifiedchance -= decrement << fortune; + if (modifiedchance < minchance) { + modifiedchance = minchance; + } + } + return modifiedchance; + } + + @SideOnly(Side.CLIENT) + public int getBlockColor() { + return 16777215; + } + + @SideOnly(Side.CLIENT) + public int getRenderColor(IBlockState state) { + return 16777215; + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { + return 16777215; + } + + @SideOnly(Side.CLIENT) + @Override + public BlockRenderLayer getRenderLayer() { + return BlockRenderLayer.CUTOUT_MIPPED; + } + + @Override + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { + return true; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @Override + public boolean isFoliage(IBlockAccess world, BlockPos pos) { + return true; + } + + @Override + public EnumType getWoodType(int meta) { + return null; + } + + public WoodMaterial getWoodMaterial() { + return this.wood; + } + + @Override + public String getOreDictionaryName() { + return "leavesFruit" + this.wood.getCapitalizedName(); + } + + @Override + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(DECAYABLE, meta % 2 == 1).withProperty(CHECK_DECAY, meta < 6).withProperty(FRUITING, Arrays.asList(0, 1, 10, 11).contains(meta) ? Arrays.asList(2, 3, 8, 9).contains(meta) ? 2 : 1 : 0); + } + + @Override + public int getMetaFromState(IBlockState state) { + int i = 0; + i += state.getValue(DECAYABLE) ? 1 : 0; + i += state.getValue(CHECK_DECAY) ? 0 : 6; + i += state.getValue(FRUITING) * 2; + return i; + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, CHECK_DECAY, DECAYABLE, FRUITING); + } + + @Override + public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) { + return java.util.Arrays.asList(new ItemStack(this, 1)); + } } diff --git a/src/main/java/panda/gotwood/block/BlockHalfSlab.java b/src/main/java/panda/gotwood/block/BlockHalfSlab.java index 3976aeb..c56fb27 100644 --- a/src/main/java/panda/gotwood/block/BlockHalfSlab.java +++ b/src/main/java/panda/gotwood/block/BlockHalfSlab.java @@ -3,13 +3,14 @@ import panda.gotwood.util.WoodMaterial; public final class BlockHalfSlab extends BlockWoodSlab { - public BlockHalfSlab(WoodMaterial wood) { - super(wood); - this.setRegistryName(wood.getName() + "_slab"); - } - - @Override - public boolean isDouble() { - return false; - } + + public BlockHalfSlab(WoodMaterial wood) { + super(wood); + this.setRegistryName(wood.getName() + "_slab"); + } + + @Override + public boolean isDouble() { + return false; + } } diff --git a/src/main/java/panda/gotwood/block/BlockPalmLeaves.java b/src/main/java/panda/gotwood/block/BlockPalmLeaves.java index 97a416a..cf140af 100644 --- a/src/main/java/panda/gotwood/block/BlockPalmLeaves.java +++ b/src/main/java/panda/gotwood/block/BlockPalmLeaves.java @@ -1,8 +1,5 @@ package panda.gotwood.block; -import java.util.List; -import java.util.Random; - import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockPlanks.EnumType; import net.minecraft.block.properties.PropertyBool; @@ -22,136 +19,135 @@ import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import panda.gotwood.GotWood; import panda.gotwood.registry.BlockRegistry; import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; +import java.util.List; +import java.util.Random; + public final class BlockPalmLeaves extends BlockLeaves implements IOreDictionaryEntry { - public static final PropertyBool DECAYABLE = PropertyBool.create("decayable"); - - public static final PropertyBool CHECK_DECAY = PropertyBool.create("check_decay"); - - private final WoodMaterial wood; - - public BlockPalmLeaves(WoodMaterial wood) { - this.wood = wood; - Blocks.FIRE.setFireInfo(this, 30, 60); - this.setDefaultState(this.blockState.getBaseState().withProperty(DECAYABLE, false).withProperty(CHECK_DECAY, false)); - this.setRegistryName(wood.getName() + "_leaves"); - } - - @Override - public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, - float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { - return this.getDefaultState(); - } - - @Override - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { - if (!worldIn.isRemote && state.getValue(CHECK_DECAY) && state.getValue(DECAYABLE)) { - int i = pos.getX(); - int j = pos.getY(); - int k = pos.getZ(); - int r = 10; - if (worldIn.isAreaLoaded(new BlockPos(i - r, j - r, k - r), new BlockPos(i + r, j + r, k + r))) { - for (BlockPos blockpos : BlockPos.getAllInBox(new BlockPos(i - r, j - r, k - r), new BlockPos(i + r, j + r, k + r))) { - if (worldIn.getBlockState(blockpos).getBlock() == BlockRegistry.palm_log) { - return; - } - } - this.destroyBlock(worldIn, pos); - } - } - } - - private void destroyBlock(World worldIn, BlockPos pos) { - this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0); - worldIn.setBlockToAir(pos); - } - - //Should never be called for apple trees - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) { - return ForgeRegistries.ITEMS.getValue(new ResourceLocation(GotWood.ID, wood + "_seed")); - } - - @SideOnly(Side.CLIENT) - public int getBlockColor() { - return 16777215; - } - - @SideOnly(Side.CLIENT) - public int getRenderColor(IBlockState state) { - return 16777215; - } - - @SideOnly(Side.CLIENT) - public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { - return 16777215; - } - - @SideOnly(Side.CLIENT) - @Override - public BlockRenderLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT_MIPPED; - } - - @Override - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { - return true; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public boolean isFoliage(IBlockAccess world, BlockPos pos) { - return true; - } - - @Override - public EnumType getWoodType(int meta) { - return null; - } - - public WoodMaterial getWoodMaterial() { - return this.wood; - } - - @Override - public String getOreDictionaryName() { - return "leaves" + this.wood.getCapitalizedName(); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(DECAYABLE, Boolean.valueOf((meta) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf(meta > 0)); - } - - @Override - public int getMetaFromState(IBlockState state) { - int i = 0; - if (!state.getValue(DECAYABLE)) { - i |= 1; - } - if (state.getValue(CHECK_DECAY)) { - i |= 2; - } - return i; - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, CHECK_DECAY, DECAYABLE); - } - - @Override - public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) { - return java.util.Arrays.asList(new ItemStack(this, 1)); - } + public static final PropertyBool DECAYABLE = PropertyBool.create("decayable"); + public static final PropertyBool CHECK_DECAY = PropertyBool.create("check_decay"); + private final WoodMaterial wood; + + public BlockPalmLeaves(WoodMaterial wood) { + this.wood = wood; + Blocks.FIRE.setFireInfo(this, 30, 60); + this.setDefaultState(this.blockState.getBaseState().withProperty(DECAYABLE, false).withProperty(CHECK_DECAY, false)); + this.setRegistryName(wood.getName() + "_leaves"); + } + + @Override + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { + return this.getDefaultState(); + } + + @Override + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (!worldIn.isRemote && state.getValue(CHECK_DECAY) && state.getValue(DECAYABLE)) { + int i = pos.getX(); + int j = pos.getY(); + int k = pos.getZ(); + int r = 10; + if (worldIn.isAreaLoaded(new BlockPos(i - r, j - r, k - r), new BlockPos(i + r, j + r, k + r))) { + for (BlockPos blockpos : BlockPos.getAllInBox(new BlockPos(i - r, j - r, k - r), new BlockPos(i + r, j + r, k + r))) { + if (worldIn.getBlockState(blockpos).getBlock() == BlockRegistry.palm_log) { + return; + } + } + this.destroyBlock(worldIn, pos); + } + } + } + + private void destroyBlock(World worldIn, BlockPos pos) { + this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0); + worldIn.setBlockToAir(pos); + } + + //Should never be called for apple trees + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return ForgeRegistries.ITEMS.getValue(new ResourceLocation(GotWood.MODID, wood + "_seed")); + } + + @SideOnly(Side.CLIENT) + public int getBlockColor() { + return 16777215; + } + + @SideOnly(Side.CLIENT) + public int getRenderColor(IBlockState state) { + return 16777215; + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { + return 16777215; + } + + @SideOnly(Side.CLIENT) + @Override + public BlockRenderLayer getRenderLayer() { + return BlockRenderLayer.CUTOUT_MIPPED; + } + + @Override + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { + return true; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @Override + public boolean isFoliage(IBlockAccess world, BlockPos pos) { + return true; + } + + @Override + public EnumType getWoodType(int meta) { + return null; + } + + public WoodMaterial getWoodMaterial() { + return this.wood; + } + + @Override + public String getOreDictionaryName() { + return "leaves" + this.wood.getCapitalizedName(); + } + + @Override + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(DECAYABLE, (meta) == 0).withProperty(CHECK_DECAY, meta > 0); + } + + @Override + public int getMetaFromState(IBlockState state) { + int i = 0; + if (!state.getValue(DECAYABLE)) { + i |= 1; + } + if (state.getValue(CHECK_DECAY)) { + i |= 2; + } + return i; + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, CHECK_DECAY, DECAYABLE); + } + + @Override + public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) { + return java.util.Arrays.asList(new ItemStack(this, 1)); + } } diff --git a/src/main/java/panda/gotwood/block/BlockPlanks.java b/src/main/java/panda/gotwood/block/BlockPlanks.java index 3fd107f..ba4c52b 100644 --- a/src/main/java/panda/gotwood/block/BlockPlanks.java +++ b/src/main/java/panda/gotwood/block/BlockPlanks.java @@ -8,81 +8,77 @@ import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; - import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; -/** - * Metal Block - */ public final class BlockPlanks extends Block implements IOreDictionaryEntry { - private final WoodMaterial wood; - - private final String oreDict; - - public BlockPlanks(WoodMaterial wood) { - super(Material.WOOD); - this.setSoundType(SoundType.WOOD); - this.fullBlock = true; - this.lightOpacity = 255; - this.translucent = false; - this.wood = wood; - this.oreDict = "plank" + wood.getCapitalizedName(); - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - this.setDefaultState(this.blockState.getBaseState()); - Blocks.FIRE.setFireInfo(this, 5, 20); - this.setRegistryName(wood.getName() + "_planks"); - - } - - @Override - public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - return MapColor.WOOD; - } - - @Override - public boolean isFullBlock(IBlockState bs) { - return true; - } - - @Override - public boolean isNormalCube(IBlockState bs) { - return true; - } - - @Override - public boolean isVisuallyOpaque() { - return true; - } - - @Override - public boolean isFullCube(IBlockState bs) { - return true; - } - - @Override - public boolean isPassable(final IBlockAccess world, final BlockPos pos) { - return false; - } - - @Override - public boolean isReplaceable(final IBlockAccess w, final BlockPos p) { - return false; - } - - @Override - public boolean isNormalCube(final IBlockState bs, final IBlockAccess w, final BlockPos coord) { - return this.isNormalCube(bs); - } - - @Override - public String getOreDictionaryName() { - return this.oreDict; - } - public WoodMaterial getWoodMaterial() { - return this.wood; - } + private final WoodMaterial wood; + private final String oreDict; + + public BlockPlanks(WoodMaterial wood) { + super(Material.WOOD); + this.setSoundType(SoundType.WOOD); + this.fullBlock = true; + this.lightOpacity = 255; + this.translucent = false; + this.wood = wood; + this.oreDict = "plank" + wood.getCapitalizedName(); + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + this.setDefaultState(this.blockState.getBaseState()); + Blocks.FIRE.setFireInfo(this, 5, 20); + this.setRegistryName(wood.getName() + "_planks"); + + } + + @Override + public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos) { + return MapColor.WOOD; + } + + @Override + public boolean isFullBlock(IBlockState state) { + return true; + } + + @Override + public boolean isNormalCube(IBlockState bs) { + return true; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return true; + } + + @Override + public boolean isFullCube(IBlockState bs) { + return true; + } + + @Override + public boolean isPassable(final IBlockAccess world, final BlockPos pos) { + return false; + } + + @Override + public boolean isReplaceable(final IBlockAccess w, final BlockPos p) { + return false; + } + + @Override + public boolean isNormalCube(final IBlockState bs, final IBlockAccess w, final BlockPos coord) { + return this.isNormalCube(bs); + } + + @Override + public String getOreDictionaryName() { + return this.oreDict; + } + + public WoodMaterial getWoodMaterial() { + return this.wood; + } } diff --git a/src/main/java/panda/gotwood/block/BlockSappyLog.java b/src/main/java/panda/gotwood/block/BlockSappyLog.java index 6d71e42..6a4a35e 100644 --- a/src/main/java/panda/gotwood/block/BlockSappyLog.java +++ b/src/main/java/panda/gotwood/block/BlockSappyLog.java @@ -11,98 +11,88 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; - import panda.gotwood.registry.ItemRegistry; import panda.gotwood.util.WoodMaterial; public class BlockSappyLog extends BlockWoodLog { - public static final PropertyInteger GENERATED = PropertyInteger.create("generated", 0, 1); - - public BlockSappyLog(WoodMaterial wood) { - super(wood); - this.setDefaultState(this.blockState.getBaseState().withProperty(GENERATED, 0).withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); - - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, LOG_AXIS, GENERATED); - } - - public IBlockState getStateFromMeta(int meta) { - IBlockState iblockstate = this.getDefaultState(); - - switch (meta) { - case 0: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y).withProperty(GENERATED, 0); - break; - case 1: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X).withProperty(GENERATED, 0); - break; - case 2: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z).withProperty(GENERATED, 0); - break; - case 3: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y).withProperty(GENERATED, 1); - break; - case 4: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X).withProperty(GENERATED, 1); - break; - case 5: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z).withProperty(GENERATED, 1); - break; - default: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE).withProperty(GENERATED, 0); - } - - return iblockstate; - } - - /** - * Convert the BlockState into the correct metadata value - */ - @Override - public int getMetaFromState(IBlockState state) { - int i = 0; - - switch (state.getValue(LOG_AXIS)) { - case X: - i = 0; - break; - case Z: - i |= 1; - break; - default: - i |= 2; - } - - int j = state.getValue(GENERATED); - i += j * 3; - - return i; - } - - @Override //&& state.getValue(GENERATED)==1 - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - ItemStack heldItem = playerIn.getHeldItem(hand); - - if (heldItem.isEmpty()) { - return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); - } - - if (!worldIn.isRemote && heldItem.getItem() == Items.BOWL && facing != EnumFacing.UP && facing != EnumFacing.DOWN) { - - ItemStack itemstack1 = new ItemStack(ItemRegistry.rubber_sap); - - heldItem.shrink(1); - if (heldItem.isEmpty()) { - playerIn.setHeldItem(hand, itemstack1); - } else if (!playerIn.inventory.addItemStackToInventory(itemstack1)) { - playerIn.dropItem(itemstack1, false); - } - } - return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); - - } + public static final PropertyInteger GENERATED = PropertyInteger.create("generated", 0, 1); + + public BlockSappyLog(WoodMaterial wood) { + super(wood); + this.setDefaultState(this.blockState.getBaseState().withProperty(GENERATED, 0).withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); + + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, LOG_AXIS, GENERATED); + } + + public IBlockState getStateFromMeta(int meta) { + IBlockState iblockstate = this.getDefaultState(); + switch (meta) { + case 0: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y).withProperty(GENERATED, 0); + break; + case 1: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X).withProperty(GENERATED, 0); + break; + case 2: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z).withProperty(GENERATED, 0); + break; + case 3: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y).withProperty(GENERATED, 1); + break; + case 4: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X).withProperty(GENERATED, 1); + break; + case 5: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z).withProperty(GENERATED, 1); + break; + default: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE).withProperty(GENERATED, 0); + } + return iblockstate; + } + + /** + * Convert the BlockState into the correct metadata value + */ + @Override + public int getMetaFromState(IBlockState state) { + int i = 0; + switch (state.getValue(LOG_AXIS)) { + case X: + i = 0; + break; + case Z: + i |= 1; + break; + default: + i |= 2; + } + int j = state.getValue(GENERATED); + i += j * 3; + return i; + } + + @Override //&& state.getValue(GENERATED)==1 + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack heldItem = playerIn.getHeldItem(hand); + if (heldItem.isEmpty()) { + return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); + } + + if (!worldIn.isRemote && heldItem.getItem() == Items.BOWL && facing != EnumFacing.UP && facing != EnumFacing.DOWN) { + ItemStack itemstack1 = new ItemStack(ItemRegistry.rubber_sap); + heldItem.shrink(1); + if (heldItem.isEmpty()) { + playerIn.setHeldItem(hand, itemstack1); + } else if (!playerIn.inventory.addItemStackToInventory(itemstack1)) { + playerIn.dropItem(itemstack1, false); + } + } + return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); + } } diff --git a/src/main/java/panda/gotwood/block/BlockSpecialFire.java b/src/main/java/panda/gotwood/block/BlockSpecialFire.java index 084654c..4e04d3b 100644 --- a/src/main/java/panda/gotwood/block/BlockSpecialFire.java +++ b/src/main/java/panda/gotwood/block/BlockSpecialFire.java @@ -1,16 +1,7 @@ package panda.gotwood.block; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Random; -import javax.annotation.Nullable; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockFire; -import net.minecraft.block.BlockLog; -import net.minecraft.block.BlockTNT; -import net.minecraft.block.SoundType; +import com.google.common.collect.Maps; +import net.minecraft.block.*; import net.minecraft.block.material.MapColor; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyInteger; @@ -23,423 +14,430 @@ import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.SoundCategory; +import net.minecraft.util.*; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - -import com.google.common.collect.Maps; import panda.gotwood.registry.ItemRegistry; import panda.gotwood.util.IFireDrops; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Random; + public final class BlockSpecialFire extends BlockFire { - public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15); - - public static final PropertyBool NORTH = PropertyBool.create("north"); - - public static final PropertyBool EAST = PropertyBool.create("east"); - - public static final PropertyBool SOUTH = PropertyBool.create("south"); - - public static final PropertyBool WEST = PropertyBool.create("west"); - - public static final PropertyBool UPPER = PropertyBool.create("up"); - - private final Map encouragements = Maps.newIdentityHashMap(); - - private final Map flammabilities = Maps.newIdentityHashMap(); - - @Override - public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) && !canCatchFire(worldIn, pos.down(), EnumFacing.UP)) { - return state.withProperty(NORTH, this.canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH)).withProperty(EAST, this.canCatchFire(worldIn, pos.east(), EnumFacing.WEST)).withProperty(SOUTH, this.canCatchFire(worldIn, pos.south(), EnumFacing.NORTH)).withProperty(WEST, this.canCatchFire(worldIn, pos.west(), EnumFacing.EAST)).withProperty(UPPER, this.canCatchFire(worldIn, pos.up(), EnumFacing.DOWN)); - } - return this.getDefaultState(); - } - - public BlockSpecialFire() { - this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, 0).withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false).withProperty(UPPER, false)); - this.setTickRandomly(true); - this.setHardness(0.0F); - this.setLightLevel(1.0F); - this.setSoundType(SoundType.CLOTH); - this.disableStats(); - this.setRegistryName("fire"); - - } - - @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - worldIn.setBlockState(pos.up(), Blocks.AIR.getDefaultState(), 2); - System.out.println("doot"); - return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); - } - - @Override - public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { - System.out.println("doot"); - worldIn.setBlockState(pos.up(), Blocks.AIR.getDefaultState(), 2); - super.onBlockClicked(worldIn, pos, playerIn); - } - - @Override - public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { - super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn); - if (!entityIn.isWet()) { - entityIn.setFire(8); - } - } - - public void initInfo() { - setFireInfo(Blocks.PLANKS, 5, 20); - setFireInfo(Blocks.DOUBLE_WOODEN_SLAB, 5, 20); - setFireInfo(Blocks.WOODEN_SLAB, 5, 20); - setFireInfo(Blocks.OAK_FENCE_GATE, 5, 20); - setFireInfo(Blocks.SPRUCE_FENCE_GATE, 5, 20); - setFireInfo(Blocks.BIRCH_FENCE_GATE, 5, 20); - setFireInfo(Blocks.JUNGLE_FENCE_GATE, 5, 20); - setFireInfo(Blocks.DARK_OAK_FENCE_GATE, 5, 20); - setFireInfo(Blocks.ACACIA_FENCE_GATE, 5, 20); - setFireInfo(Blocks.OAK_FENCE, 5, 20); - setFireInfo(Blocks.SPRUCE_FENCE, 5, 20); - setFireInfo(Blocks.BIRCH_FENCE, 5, 20); - setFireInfo(Blocks.JUNGLE_FENCE, 5, 20); - setFireInfo(Blocks.DARK_OAK_FENCE, 5, 20); - setFireInfo(Blocks.ACACIA_FENCE, 5, 20); - setFireInfo(Blocks.OAK_STAIRS, 5, 20); - setFireInfo(Blocks.BIRCH_STAIRS, 5, 20); - setFireInfo(Blocks.SPRUCE_STAIRS, 5, 20); - setFireInfo(Blocks.JUNGLE_STAIRS, 5, 20); - setFireInfo(Blocks.ACACIA_STAIRS, 5, 20); - setFireInfo(Blocks.DARK_OAK_STAIRS, 5, 20); - setFireInfo(Blocks.LOG, 5, 5); - setFireInfo(Blocks.LOG2, 5, 5); - setFireInfo(Blocks.LEAVES, 30, 60); - setFireInfo(Blocks.LEAVES2, 30, 60); - setFireInfo(Blocks.BOOKSHELF, 30, 20); - setFireInfo(Blocks.TNT, 15, 100); - setFireInfo(Blocks.TALLGRASS, 60, 100); - setFireInfo(Blocks.DOUBLE_PLANT, 60, 100); - setFireInfo(Blocks.YELLOW_FLOWER, 60, 100); - setFireInfo(Blocks.RED_FLOWER, 60, 100); - setFireInfo(Blocks.DEADBUSH, 60, 100); - setFireInfo(Blocks.WOOL, 30, 60); - setFireInfo(Blocks.VINE, 15, 100); - setFireInfo(Blocks.COAL_BLOCK, 5, 5); - setFireInfo(Blocks.HAY_BLOCK, 60, 20); - setFireInfo(Blocks.CARPET, 60, 20); - } - - @Override - public void setFireInfo(Block blockIn, int encouragement, int flammability) { - if (blockIn == Blocks.AIR) - throw new IllegalArgumentException("Tried to set air on fire... This is bad."); - this.encouragements.put(blockIn, encouragement); - this.flammabilities.put(blockIn, flammability); - } - - @Nullable - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { - return FULL_BLOCK_AABB; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public int quantityDropped(Random random) { - return 0; - } - - @Override - public int tickRate(World worldIn) { - return 30; - } - - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { - if (worldIn.getGameRules().getBoolean("doFireTick")) { - if (!this.canPlaceBlockAt(worldIn, pos)) { - worldIn.setBlockToAir(pos); - } - Block block = worldIn.getBlockState(pos.down()).getBlock(); - boolean flag = block.isFireSource(worldIn, pos.down(), EnumFacing.UP); - int i = state.getValue(AGE); - if (!flag && worldIn.isRaining() && this.canDie(worldIn, pos) && rand.nextFloat() < 0.2F + (float) i * 0.03F) { - worldIn.setBlockToAir(pos); - } else { - if (i < 15) { - state = state.withProperty(AGE, i + rand.nextInt(3) / 2); - worldIn.setBlockState(pos, state, 4); - } - worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + rand.nextInt(10)); - if (!flag) { - if (!this.canNeighborCatchFire(worldIn, pos)) { - if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) || i > 3) { - worldIn.setBlockToAir(pos); - } - return; - } - if (!this.canCatchFire(worldIn, pos.down(), EnumFacing.UP) && i == 15 && rand.nextInt(4) == 0) { - worldIn.setBlockToAir(pos); - return; - } - } - boolean flag1 = worldIn.isBlockinHighHumidity(pos); - int j = 0; - if (flag1) { - j = -50; - } - this.tryCatchFire(worldIn, pos.east(), 300 + j, rand, i, EnumFacing.WEST); - this.tryCatchFire(worldIn, pos.west(), 300 + j, rand, i, EnumFacing.EAST); - this.tryCatchFire(worldIn, pos.down(), 250 + j, rand, i, EnumFacing.UP); - this.tryCatchFire(worldIn, pos.up(), 250 + j, rand, i, EnumFacing.DOWN); - this.tryCatchFire(worldIn, pos.north(), 300 + j, rand, i, EnumFacing.SOUTH); - this.tryCatchFire(worldIn, pos.south(), 300 + j, rand, i, EnumFacing.NORTH); - for (int k = -1; k <= 1; ++k) { - for (int l = -1; l <= 1; ++l) { - for (int i1 = -1; i1 <= 4; ++i1) { - if (k != 0 || i1 != 0 || l != 0) { - int j1 = 100; - if (i1 > 1) { - j1 += (i1 - 1) * 100; - } - BlockPos blockpos = pos.add(k, i1, l); - int k1 = this.getNeighborEncouragement(worldIn, blockpos); - if (k1 > 0) { - int l1 = (k1 + 40 + worldIn.getDifficulty().getDifficultyId() * 7) / (i + 30); - if (flag1) { - l1 /= 2; - } - if (l1 > 0 && rand.nextInt(j1) <= l1 && (!worldIn.isRaining() || !this.canDie(worldIn, blockpos))) { - int i2 = i + rand.nextInt(5) / 4; - if (i2 > 15) { - i2 = 15; - } - worldIn.setBlockState(blockpos, state.withProperty(AGE, i2), 3); - } - } - } - } - } - } - } - } - } - - @Override - protected boolean canDie(World worldIn, BlockPos pos) { - return worldIn.isRainingAt(pos) || worldIn.isRainingAt(pos.west()) || worldIn.isRainingAt(pos.east()) || worldIn.isRainingAt(pos.north()) || worldIn.isRainingAt(pos.south()); - } - - @Override - public boolean requiresUpdates() { - return false; - } - - @Deprecated // Use Block.getFlammability - public int getFlammability(Block block) { - Integer integer = this.flammabilities.get(block); - return integer == null ? 0 : integer; - } - - @Deprecated // Use Block.getFlammability - public int getEncouragement(Block block) { - Integer integer = this.encouragements.get(block); - return integer == null ? 0 : integer; - } - - @Deprecated // Use tryCatchFire with face below - private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age) { - this.tryCatchFire(worldIn, pos, chance, random, age, EnumFacing.UP); - } - - private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face) { - int i = worldIn.getBlockState(pos).getBlock().getFlammability(worldIn, pos, face); - if (random.nextInt(chance) < i) { - IBlockState iblockstate = worldIn.getBlockState(pos); - if (random.nextInt(age + 10) < 5 && !worldIn.isRainingAt(pos)) { - int j = age + random.nextInt(5) / 4; - if (j > 15) { - j = 15; - } - worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, j), 3); - } else { - worldIn.setBlockToAir(pos); - Block block = iblockstate.getBlock(); - if (block instanceof BlockLog && !(block instanceof IFireDrops)) { - ItemStack burnitem = worldIn.rand.nextBoolean() ? new ItemStack(ItemRegistry.ash) : new ItemStack(Items.COAL, 1, 1); - EntityItem entityitem = new EntityItem(worldIn, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, burnitem); - worldIn.spawnEntity(entityitem); - } else if (block instanceof IFireDrops) { - IFireDrops fireDrops = (IFireDrops) block; - if (fireDrops.hasFireDrops()) { - ///use NonNullList for 1.11 - //also add an event that allows the modification of that same list. - List drops = new ArrayList<>(); - fireDrops.addFireDrops(drops, random); - for (ItemStack drop : drops) { - EntityItem entityitem = new EntityItem(worldIn, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, drop); - worldIn.spawnEntity(entityitem); - } - - } - } - } - if (iblockstate.getBlock() == Blocks.TNT) { - Blocks.TNT.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, true)); - } - } - } - - private boolean canNeighborCatchFire(World worldIn, BlockPos pos) { - for (EnumFacing enumfacing : EnumFacing.values()) { - if (this.canCatchFire(worldIn, pos.offset(enumfacing), enumfacing.getOpposite())) { - return true; - } - } - - return false; - } - - private int getNeighborEncouragement(World worldIn, BlockPos pos) { - if (!worldIn.isAirBlock(pos)) { - return 0; - } - int i = 0; - for (EnumFacing enumfacing : EnumFacing.values()) { - i = Math.max(worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getFireSpreadSpeed(worldIn, pos.offset(enumfacing), enumfacing.getOpposite()), i); - } - return i; - } - - @Override - public boolean isCollidable() { - return false; - } - - @Override - public boolean canCatchFire(IBlockAccess worldIn, BlockPos pos) { - return canCatchFire(worldIn, pos, EnumFacing.UP); - } - - public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { - return worldIn.getBlockState(pos.down()).isTopSolid() || this.canNeighborCatchFire(worldIn, pos); - } - - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { - if (!worldIn.getBlockState(pos.down()).isTopSolid() && !this.canNeighborCatchFire(worldIn, pos)) { - worldIn.setBlockToAir(pos); - } - } - - @Override - public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { - if (worldIn.provider.getDimensionType().getId() > 0 || !Blocks.PORTAL.trySpawnPortal(worldIn, pos)) { - if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos, EnumFacing.UP) && !this.canNeighborCatchFire(worldIn, pos)) { - worldIn.setBlockToAir(pos); - } else { - worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + worldIn.rand.nextInt(10)); - } - } - } - - @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { - if (rand.nextInt(24) == 0) { - worldIn.playSound((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY() + 0.5F), (double) ((float) pos.getZ() + 0.5F), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F + rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false); - } - if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) && !canCatchFire(worldIn, pos.down(), EnumFacing.UP)) { - if (canCatchFire(worldIn, pos.west(), EnumFacing.EAST)) { - for (int j = 0; j < 2; ++j) { - double d3 = (double) pos.getX() + rand.nextDouble() * 0.10000000149011612D; - double d8 = (double) pos.getY() + rand.nextDouble(); - double d13 = (double) pos.getZ() + rand.nextDouble(); - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d3, d8, d13, 0.0D, 0.0D, 0.0D, 0); - } - } - if (canCatchFire(worldIn, pos.east(), EnumFacing.WEST)) { - for (int k = 0; k < 2; ++k) { - double d4 = (double) (pos.getX() + 1) - rand.nextDouble() * 0.10000000149011612D; - double d9 = (double) pos.getY() + rand.nextDouble(); - double d14 = (double) pos.getZ() + rand.nextDouble(); - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d4, d9, d14, 0.0D, 0.0D, 0.0D, 0); - } - } - if (canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH)) { - for (int l = 0; l < 2; ++l) { - double d5 = (double) pos.getX() + rand.nextDouble(); - double d10 = (double) pos.getY() + rand.nextDouble(); - double d15 = (double) pos.getZ() + rand.nextDouble() * 0.10000000149011612D; - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d5, d10, d15, 0.0D, 0.0D, 0.0D, 0); - } - } - if (canCatchFire(worldIn, pos.south(), EnumFacing.NORTH)) { - for (int i1 = 0; i1 < 2; ++i1) { - double d6 = (double) pos.getX() + rand.nextDouble(); - double d11 = (double) pos.getY() + rand.nextDouble(); - double d16 = (double) (pos.getZ() + 1) - rand.nextDouble() * 0.10000000149011612D; - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d6, d11, d16, 0.0D, 0.0D, 0.0D, 0); - } - } - if (canCatchFire(worldIn, pos.up(), EnumFacing.DOWN)) { - for (int j1 = 0; j1 < 2; ++j1) { - double d7 = (double) pos.getX() + rand.nextDouble(); - double d12 = (double) (pos.getY() + 1) - rand.nextDouble() * 0.10000000149011612D; - double d17 = (double) pos.getZ() + rand.nextDouble(); - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d7, d12, d17, 0.0D, 0.0D, 0.0D, 0); - } - } - } else { - for (int i = 0; i < 3; ++i) { - double d0 = (double) pos.getX() + rand.nextDouble(); - double d1 = (double) pos.getY() + rand.nextDouble() * 0.5D + 0.5D; - double d2 = (double) pos.getZ() + rand.nextDouble(); - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, 0); - } - } - } - - public MapColor getMapColor(IBlockState state) { - return MapColor.TNT; - } - - @Override - @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT; - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(AGE, meta); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(AGE); - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, AGE, NORTH, EAST, SOUTH, WEST, UPPER); - } - - @Override - public boolean canCatchFire(IBlockAccess world, BlockPos pos, EnumFacing face) { - return world.getBlockState(pos).getBlock().isFlammable(world, pos, face); - } + + public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15); + public static final PropertyBool NORTH = PropertyBool.create("north"); + public static final PropertyBool EAST = PropertyBool.create("east"); + public static final PropertyBool SOUTH = PropertyBool.create("south"); + public static final PropertyBool WEST = PropertyBool.create("west"); + public static final PropertyBool UPPER = PropertyBool.create("up"); + private final Map encouragements = Maps.newIdentityHashMap(); + private final Map flammabilities = Maps.newIdentityHashMap(); + + public BlockSpecialFire() { + this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, 0).withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false).withProperty(UPPER, false)); + this.setTickRandomly(true); + this.setHardness(0.0F); + this.setLightLevel(1.0F); + this.setSoundType(SoundType.CLOTH); + this.disableStats(); + this.setRegistryName("fire"); + + } + + @Override + public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { + if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) && !canCatchFire(worldIn, pos.down(), EnumFacing.UP)) { + return state.withProperty(NORTH, this.canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH)).withProperty(EAST, this.canCatchFire(worldIn, pos.east(), EnumFacing.WEST)).withProperty(SOUTH, this.canCatchFire(worldIn, pos.south(), EnumFacing.NORTH)).withProperty(WEST, this.canCatchFire(worldIn, pos.west(), EnumFacing.EAST)).withProperty(UPPER, this.canCatchFire(worldIn, pos.up(), EnumFacing.DOWN)); + } + return this.getDefaultState(); + } + + @Override + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + worldIn.setBlockState(pos.up(), Blocks.AIR.getDefaultState(), 2); + System.out.println("doot"); + return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); + } + + @Override + public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { + System.out.println("doot"); + worldIn.setBlockState(pos.up(), Blocks.AIR.getDefaultState(), 2); + super.onBlockClicked(worldIn, pos, playerIn); + } + + @Override + public void onEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { + super.onEntityCollision(worldIn, pos, state, entityIn); + if (!entityIn.isWet()) { + entityIn.setFire(8); + } + } + + public void initInfo() { + setFireInfo(Blocks.PLANKS, 5, 20); + setFireInfo(Blocks.DOUBLE_WOODEN_SLAB, 5, 20); + setFireInfo(Blocks.WOODEN_SLAB, 5, 20); + setFireInfo(Blocks.OAK_FENCE_GATE, 5, 20); + setFireInfo(Blocks.SPRUCE_FENCE_GATE, 5, 20); + setFireInfo(Blocks.BIRCH_FENCE_GATE, 5, 20); + setFireInfo(Blocks.JUNGLE_FENCE_GATE, 5, 20); + setFireInfo(Blocks.DARK_OAK_FENCE_GATE, 5, 20); + setFireInfo(Blocks.ACACIA_FENCE_GATE, 5, 20); + setFireInfo(Blocks.OAK_FENCE, 5, 20); + setFireInfo(Blocks.SPRUCE_FENCE, 5, 20); + setFireInfo(Blocks.BIRCH_FENCE, 5, 20); + setFireInfo(Blocks.JUNGLE_FENCE, 5, 20); + setFireInfo(Blocks.DARK_OAK_FENCE, 5, 20); + setFireInfo(Blocks.ACACIA_FENCE, 5, 20); + setFireInfo(Blocks.OAK_STAIRS, 5, 20); + setFireInfo(Blocks.BIRCH_STAIRS, 5, 20); + setFireInfo(Blocks.SPRUCE_STAIRS, 5, 20); + setFireInfo(Blocks.JUNGLE_STAIRS, 5, 20); + setFireInfo(Blocks.ACACIA_STAIRS, 5, 20); + setFireInfo(Blocks.DARK_OAK_STAIRS, 5, 20); + setFireInfo(Blocks.LOG, 5, 5); + setFireInfo(Blocks.LOG2, 5, 5); + setFireInfo(Blocks.LEAVES, 30, 60); + setFireInfo(Blocks.LEAVES2, 30, 60); + setFireInfo(Blocks.BOOKSHELF, 30, 20); + setFireInfo(Blocks.TNT, 15, 100); + setFireInfo(Blocks.TALLGRASS, 60, 100); + setFireInfo(Blocks.DOUBLE_PLANT, 60, 100); + setFireInfo(Blocks.YELLOW_FLOWER, 60, 100); + setFireInfo(Blocks.RED_FLOWER, 60, 100); + setFireInfo(Blocks.DEADBUSH, 60, 100); + setFireInfo(Blocks.WOOL, 30, 60); + setFireInfo(Blocks.VINE, 15, 100); + setFireInfo(Blocks.COAL_BLOCK, 5, 5); + setFireInfo(Blocks.HAY_BLOCK, 60, 20); + setFireInfo(Blocks.CARPET, 60, 20); + } + + @Override + public void setFireInfo(Block blockIn, int encouragement, int flammability) { + if (blockIn == Blocks.AIR) { + throw new IllegalArgumentException("Tried to set air on fire... This is bad."); + } + this.encouragements.put(blockIn, encouragement); + this.flammabilities.put(blockIn, flammability); + } + + @Nullable + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { + return FULL_BLOCK_AABB; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @Override + public boolean isFullCube(IBlockState state) { + return false; + } + + @Override + public int quantityDropped(Random random) { + return 0; + } + + @Override + public int tickRate(World worldIn) { + return 30; + } + + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (worldIn.getGameRules().getBoolean("doFireTick")) { + if (!this.canPlaceBlockAt(worldIn, pos)) { + worldIn.setBlockToAir(pos); + } + + Block block = worldIn.getBlockState(pos.down()).getBlock(); + boolean flag = block.isFireSource(worldIn, pos.down(), EnumFacing.UP); + int i = state.getValue(AGE); + if (!flag && worldIn.isRaining() && this.canDie(worldIn, pos) && rand.nextFloat() < 0.2F + (float) i * 0.03F) { + worldIn.setBlockToAir(pos); + } else { + if (i < 15) { + state = state.withProperty(AGE, i + rand.nextInt(3) / 2); + worldIn.setBlockState(pos, state, 4); + } + + worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + rand.nextInt(10)); + if (!flag) { + if (!this.canNeighborCatchFire(worldIn, pos)) { + if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) || i > 3) { + worldIn.setBlockToAir(pos); + } + return; + } + + if (!this.canCatchFire(worldIn, pos.down(), EnumFacing.UP) && i == 15 && rand.nextInt(4) == 0) { + worldIn.setBlockToAir(pos); + return; + } + } + + boolean flag1 = worldIn.isBlockinHighHumidity(pos); + int j = 0; + if (flag1) { + j = -50; + } + + this.tryCatchFire(worldIn, pos.east(), 300 + j, rand, i, EnumFacing.WEST); + this.tryCatchFire(worldIn, pos.west(), 300 + j, rand, i, EnumFacing.EAST); + this.tryCatchFire(worldIn, pos.down(), 250 + j, rand, i, EnumFacing.UP); + this.tryCatchFire(worldIn, pos.up(), 250 + j, rand, i, EnumFacing.DOWN); + this.tryCatchFire(worldIn, pos.north(), 300 + j, rand, i, EnumFacing.SOUTH); + this.tryCatchFire(worldIn, pos.south(), 300 + j, rand, i, EnumFacing.NORTH); + for (int k = -1; k <= 1; ++k) { + for (int l = -1; l <= 1; ++l) { + for (int i1 = -1; i1 <= 4; ++i1) { + if (k != 0 || i1 != 0 || l != 0) { + int j1 = 100; + if (i1 > 1) { + j1 += (i1 - 1) * 100; + } + + BlockPos blockpos = pos.add(k, i1, l); + int k1 = this.getNeighborEncouragement(worldIn, blockpos); + if (k1 > 0) { + int l1 = (k1 + 40 + worldIn.getDifficulty().getId() * 7) / (i + 30); + if (flag1) { + l1 /= 2; + } + + if (l1 > 0 && rand.nextInt(j1) <= l1 && (!worldIn.isRaining() || !this.canDie(worldIn, blockpos))) { + int i2 = i + rand.nextInt(5) / 4; + if (i2 > 15) { + i2 = 15; + } + worldIn.setBlockState(blockpos, state.withProperty(AGE, i2), 3); + } + } + } + } + } + } + } + } + } + + @Override + protected boolean canDie(World worldIn, BlockPos pos) { + return worldIn.isRainingAt(pos) || worldIn.isRainingAt(pos.west()) || worldIn.isRainingAt(pos.east()) || worldIn.isRainingAt(pos.north()) || worldIn.isRainingAt(pos.south()); + } + + @Override + public boolean requiresUpdates() { + return false; + } + + @Deprecated // Use Block.getFlammability + public int getFlammability(Block block) { + Integer integer = this.flammabilities.get(block); + return integer == null ? 0 : integer; + } + + @Deprecated // Use Block.getFlammability + public int getEncouragement(Block block) { + Integer integer = this.encouragements.get(block); + return integer == null ? 0 : integer; + } + + @Deprecated // Use tryCatchFire with face below + private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age) { + this.tryCatchFire(worldIn, pos, chance, random, age, EnumFacing.UP); + } + + private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face) { + int i = worldIn.getBlockState(pos).getBlock().getFlammability(worldIn, pos, face); + if (random.nextInt(chance) < i) { + IBlockState iblockstate = worldIn.getBlockState(pos); + if (random.nextInt(age + 10) < 5 && !worldIn.isRainingAt(pos)) { + int j = age + random.nextInt(5) / 4; + if (j > 15) { + j = 15; + } + worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, j), 3); + } else { + worldIn.setBlockToAir(pos); + Block block = iblockstate.getBlock(); + if (block instanceof BlockLog && !(block instanceof IFireDrops)) { + ItemStack burnitem = worldIn.rand.nextBoolean() ? new ItemStack(ItemRegistry.ash) : new ItemStack(Items.COAL, 1, 1); + EntityItem entityitem = new EntityItem(worldIn, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, burnitem); + worldIn.spawnEntity(entityitem); + } else if (block instanceof IFireDrops) { + IFireDrops fireDrops = (IFireDrops) block; + if (fireDrops.hasFireDrops()) { + ///use NonNullList for 1.11 + //also add an event that allows the modification of that same list. + List drops = new ArrayList<>(); + fireDrops.addFireDrops(drops, random); + for (ItemStack drop : drops) { + EntityItem entityitem = new EntityItem(worldIn, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, drop); + worldIn.spawnEntity(entityitem); + } + } + } + } + + if (iblockstate.getBlock() == Blocks.TNT) { + Blocks.TNT.onPlayerDestroy(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, true)); + } + } + } + + private boolean canNeighborCatchFire(World worldIn, BlockPos pos) { + for (EnumFacing enumfacing : EnumFacing.values()) { + if (this.canCatchFire(worldIn, pos.offset(enumfacing), enumfacing.getOpposite())) { + return true; + } + } + return false; + } + + private int getNeighborEncouragement(World worldIn, BlockPos pos) { + if (!worldIn.isAirBlock(pos)) { + return 0; + } + + int i = 0; + for (EnumFacing enumfacing : EnumFacing.values()) { + i = Math.max(worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getFireSpreadSpeed(worldIn, pos.offset(enumfacing), enumfacing.getOpposite()), i); + } + return i; + } + + @Override + public boolean isCollidable() { + return false; + } + + @Override + public boolean canCatchFire(IBlockAccess worldIn, BlockPos pos) { + return canCatchFire(worldIn, pos, EnumFacing.UP); + } + + public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { + return worldIn.getBlockState(pos.down()).isTopSolid() || this.canNeighborCatchFire(worldIn, pos); + } + + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { + if (!worldIn.getBlockState(pos.down()).isTopSolid() && !this.canNeighborCatchFire(worldIn, pos)) { + worldIn.setBlockToAir(pos); + } + } + + @Override + public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { + if (worldIn.provider.getDimensionType().getId() > 0 || !Blocks.PORTAL.trySpawnPortal(worldIn, pos)) { + if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos, EnumFacing.UP) && !this.canNeighborCatchFire(worldIn, pos)) { + worldIn.setBlockToAir(pos); + } else { + worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + worldIn.rand.nextInt(10)); + } + } + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { + if (rand.nextInt(24) == 0) { + worldIn.playSound(((float) pos.getX() + 0.5F), ((float) pos.getY() + 0.5F), ((float) pos.getZ() + 0.5F), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F + rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false); + } + + if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) && !canCatchFire(worldIn, pos.down(), EnumFacing.UP)) { + if (canCatchFire(worldIn, pos.west(), EnumFacing.EAST)) { + for (int j = 0; j < 2; ++j) { + double d3 = (double) pos.getX() + rand.nextDouble() * 0.10000000149011612D; + double d8 = (double) pos.getY() + rand.nextDouble(); + double d13 = (double) pos.getZ() + rand.nextDouble(); + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d3, d8, d13, 0.0D, 0.0D, 0.0D, 0); + } + } + + if (canCatchFire(worldIn, pos.east(), EnumFacing.WEST)) { + for (int k = 0; k < 2; ++k) { + double d4 = (double) (pos.getX() + 1) - rand.nextDouble() * 0.10000000149011612D; + double d9 = (double) pos.getY() + rand.nextDouble(); + double d14 = (double) pos.getZ() + rand.nextDouble(); + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d4, d9, d14, 0.0D, 0.0D, 0.0D, 0); + } + } + + if (canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH)) { + for (int l = 0; l < 2; ++l) { + double d5 = (double) pos.getX() + rand.nextDouble(); + double d10 = (double) pos.getY() + rand.nextDouble(); + double d15 = (double) pos.getZ() + rand.nextDouble() * 0.10000000149011612D; + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d5, d10, d15, 0.0D, 0.0D, 0.0D, 0); + } + } + + if (canCatchFire(worldIn, pos.south(), EnumFacing.NORTH)) { + for (int i1 = 0; i1 < 2; ++i1) { + double d6 = (double) pos.getX() + rand.nextDouble(); + double d11 = (double) pos.getY() + rand.nextDouble(); + double d16 = (double) (pos.getZ() + 1) - rand.nextDouble() * 0.10000000149011612D; + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d6, d11, d16, 0.0D, 0.0D, 0.0D, 0); + } + } + + if (canCatchFire(worldIn, pos.up(), EnumFacing.DOWN)) { + for (int j1 = 0; j1 < 2; ++j1) { + double d7 = (double) pos.getX() + rand.nextDouble(); + double d12 = (double) (pos.getY() + 1) - rand.nextDouble() * 0.10000000149011612D; + double d17 = (double) pos.getZ() + rand.nextDouble(); + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d7, d12, d17, 0.0D, 0.0D, 0.0D, 0); + } + } + } else { + for (int i = 0; i < 3; ++i) { + double d0 = (double) pos.getX() + rand.nextDouble(); + double d1 = (double) pos.getY() + rand.nextDouble() * 0.5D + 0.5D; + double d2 = (double) pos.getZ() + rand.nextDouble(); + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, 0); + } + } + } + + public MapColor getMapColor(IBlockState state) { + return MapColor.TNT; + } + + @Override + @SideOnly(Side.CLIENT) + public BlockRenderLayer getRenderLayer() { + return BlockRenderLayer.CUTOUT; + } + + @Override + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(AGE, meta); + } + + @Override + public int getMetaFromState(IBlockState state) { + return state.getValue(AGE); + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, AGE, NORTH, EAST, SOUTH, WEST, UPPER); + } + + @Override + public boolean canCatchFire(IBlockAccess world, BlockPos pos, EnumFacing face) { + return world.getBlockState(pos).getBlock().isFlammable(world, pos, face); + } } diff --git a/src/main/java/panda/gotwood/block/BlockTreeTap.java b/src/main/java/panda/gotwood/block/BlockTreeTap.java index d66c2a7..1ca1e97 100644 --- a/src/main/java/panda/gotwood/block/BlockTreeTap.java +++ b/src/main/java/panda/gotwood/block/BlockTreeTap.java @@ -1,12 +1,7 @@ package panda.gotwood.block; -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.BlockLog; -import net.minecraft.block.SoundType; +import com.google.common.collect.ImmutableMap; +import net.minecraft.block.*; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; @@ -25,155 +20,156 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - -import com.google.common.collect.ImmutableMap; import panda.gotwood.block.entity.TileEntityTreeTap; +import javax.annotation.Nonnull; + public final class BlockTreeTap extends BlockContainer { - private static int FLUIDPERTICK = 0; - - public static final PropertyBool HASBUCKET = PropertyBool.create("hasbucket"); - - public static final PropertyDirection FACING = BlockHorizontal.FACING; - - private static final ImmutableMap BOUNDS = ImmutableMap.builder() - .put(EnumFacing.UP, FULL_BLOCK_AABB) - .put(EnumFacing.NORTH, new AxisAlignedBB(0.25, 0.25, 0, 0.75, 0.625, 0.375)) - .put(EnumFacing.SOUTH, new AxisAlignedBB(0.25, 0.25, 0.625, 0.75, 0.625, 1.0)) - .put(EnumFacing.EAST, new AxisAlignedBB(0.625, 0.25, 0.25, 1, 0.625, 0.75)) - .put(EnumFacing.WEST, new AxisAlignedBB(0, 0.25, 0.25, 0.375, 0.625, 0.75)) - .put(EnumFacing.DOWN, FULL_BLOCK_AABB) - .build(); - - public BlockTreeTap() { - super(Material.WOOD); - this.setHardness(3F); - this.setResistance(2F); - this.setSoundType(SoundType.WOOD); - this.setRegistryName("tree_tap"); - this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(HASBUCKET, false)); - } - - @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); - if (worldIn.isRemote) { - return false; - } - if (this.hasTileEntity(this.getDefaultState())) { - ItemStack stack = playerIn.getHeldItem(hand); - if (!stack.isEmpty()) { - System.out.println("yep"); - if (stack.getItem() == Items.BUCKET && !stack.isEmpty()) { - stack.shrink(1); - TileEntity te = worldIn.getTileEntity(pos); - if (te instanceof TileEntityTreeTap) { - ((TileEntityTreeTap) te).hasBucket = true; - worldIn.setBlockState(pos, worldIn.getBlockState(pos).withProperty(HASBUCKET, true), 3); - return true; - } - } - } - - } - return false; - } - - @Override - public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) {} - - @Nonnull - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, FACING, HASBUCKET); - } - - @Nonnull - @Override - public IBlockState getStateFromMeta(int meta) { - if (meta >= EnumFacing.HORIZONTALS.length) { - meta = 1; - } - EnumFacing face = EnumFacing.values()[meta >> 1]; - if (face == EnumFacing.DOWN || face == EnumFacing.UP) { - face = EnumFacing.NORTH; - } - return this.getDefaultState().withProperty(FACING, face); - } - - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(FACING).ordinal() << 1 - 1 + (state.getValue(HASBUCKET) ? 1 : 0); - } - - @Override - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos frompos) { - if (worldIn.isRemote) { - return; - } - Block block = worldIn.getBlockState(pos).getBlock(); - if (block instanceof BlockTreeTap) { - this.breakBlock(worldIn, pos, state); - } - } - - @Nonnull - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return BOUNDS.get(state.getValue(FACING)); - } - - @Nonnull - @Override - public EnumBlockRenderType getRenderType(IBlockState state) { - return EnumBlockRenderType.MODEL; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, @Nonnull IBlockAccess blockAccess, @Nonnull BlockPos pos, EnumFacing side) { - return true; - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Nonnull - @Override - public TileEntity createNewTileEntity(@Nonnull World worldIn, int meta) { - System.out.println(FLUIDPERTICK); - return new TileEntityTreeTap().setLiquidAmount(FLUIDPERTICK); - } - - //gets the amount of sap transfered to the bucket per tick, determined by the number of log blocks and the tree type - public int getAmountPerTick(World world, BlockPos pos, EnumFacing facing) { - int amtPerBlock = 2; //mb - BlockPos start = pos.offset(facing); - int totalAmount = 0; - if (world.getBlockState(start) instanceof BlockLog) { - for (int k = -1; k < 14; k++) { - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (world.getBlockState(start.add(i, j, k)) instanceof BlockLog) { - totalAmount += amtPerBlock; - } - } - } - } - } - return totalAmount; - } - - @Override - public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { - FLUIDPERTICK = getAmountPerTick(worldIn, pos, state.getValue(FACING)); - super.onBlockAdded(worldIn, pos, state); - } + + public static final PropertyBool HASBUCKET = PropertyBool.create("hasbucket"); + public static final PropertyDirection FACING = BlockHorizontal.FACING; + private static final ImmutableMap BOUNDS = ImmutableMap.builder() + .put(EnumFacing.UP, FULL_BLOCK_AABB) + .put(EnumFacing.NORTH, new AxisAlignedBB(0.25, 0.25, 0, 0.75, 0.625, 0.375)) + .put(EnumFacing.SOUTH, new AxisAlignedBB(0.25, 0.25, 0.625, 0.75, 0.625, 1.0)) + .put(EnumFacing.EAST, new AxisAlignedBB(0.625, 0.25, 0.25, 1, 0.625, 0.75)) + .put(EnumFacing.WEST, new AxisAlignedBB(0, 0.25, 0.25, 0.375, 0.625, 0.75)) + .put(EnumFacing.DOWN, FULL_BLOCK_AABB) + .build(); + private static int FLUIDPERTICK = 0; + + public BlockTreeTap() { + super(Material.WOOD); + this.setHardness(3F); + this.setResistance(2F); + this.setSoundType(SoundType.WOOD); + this.setRegistryName("tree_tap"); + this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(HASBUCKET, false)); + } + + @Override + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ); + if (worldIn.isRemote) { + return false; + } + + if (this.hasTileEntity(this.getDefaultState())) { + ItemStack stack = playerIn.getHeldItem(hand); + if (!stack.isEmpty()) { + System.out.println("yep"); + if (stack.getItem() == Items.BUCKET && !stack.isEmpty()) { + stack.shrink(1); + TileEntity te = worldIn.getTileEntity(pos); + if (te instanceof TileEntityTreeTap) { + ((TileEntityTreeTap) te).hasBucket = true; + worldIn.setBlockState(pos, worldIn.getBlockState(pos).withProperty(HASBUCKET, true), 3); + return true; + } + } + } + + } + return false; + } + + @Override + public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { + } + + @Nonnull + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, FACING, HASBUCKET); + } + + @Nonnull + @Override + public IBlockState getStateFromMeta(int meta) { + if (meta >= EnumFacing.HORIZONTALS.length) { + meta = 1; + } + EnumFacing face = EnumFacing.values()[meta >> 1]; + if (face == EnumFacing.DOWN || face == EnumFacing.UP) { + face = EnumFacing.NORTH; + } + return this.getDefaultState().withProperty(FACING, face); + } + + @Override + public int getMetaFromState(IBlockState state) { + return state.getValue(FACING).ordinal() << (state.getValue(HASBUCKET) ? 1 : 0); + } + + @Override + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos frompos) { + if (worldIn.isRemote) { + return; + } + + Block block = worldIn.getBlockState(pos).getBlock(); + if (block instanceof BlockTreeTap) { + this.breakBlock(worldIn, pos, state); + } + } + + @Nonnull + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return BOUNDS.get(state.getValue(FACING)); + } + + @Nonnull + @Override + public EnumBlockRenderType getRenderType(IBlockState state) { + return EnumBlockRenderType.MODEL; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockState blockState, @Nonnull IBlockAccess blockAccess, @Nonnull BlockPos pos, EnumFacing side) { + return true; + } + + @Override + public boolean isFullCube(IBlockState state) { + return false; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @Nonnull + @Override + public TileEntity createNewTileEntity(@Nonnull World worldIn, int meta) { + System.out.println(FLUIDPERTICK); + return new TileEntityTreeTap().setLiquidAmount(FLUIDPERTICK); + } + + //gets the amount of sap transfered to the bucket per tick, determined by the number of log blocks and the tree type + public int getAmountPerTick(World world, BlockPos pos, EnumFacing facing) { + int amtPerBlock = 2; //mb + BlockPos start = pos.offset(facing); + int totalAmount = 0; + if (world.getBlockState(start) instanceof BlockLog) { + for (int k = -1; k < 14; k++) { + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (world.getBlockState(start.add(i, j, k)) instanceof BlockLog) { + totalAmount += amtPerBlock; + } + } + } + } + } + return totalAmount; + } + + @Override + public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { + FLUIDPERTICK = getAmountPerTick(worldIn, pos, state.getValue(FACING)); + super.onBlockAdded(worldIn, pos, state); + } } diff --git a/src/main/java/panda/gotwood/block/BlockWoodDoor.java b/src/main/java/panda/gotwood/block/BlockWoodDoor.java index 243064c..627ad61 100644 --- a/src/main/java/panda/gotwood/block/BlockWoodDoor.java +++ b/src/main/java/panda/gotwood/block/BlockWoodDoor.java @@ -1,7 +1,5 @@ package panda.gotwood.block; -import java.util.Random; - import net.minecraft.block.BlockDoor; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; @@ -15,67 +13,67 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; -import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import panda.gotwood.util.WoodMaterial; +import java.util.Random; + public final class BlockWoodDoor extends BlockDoor { - private final WoodMaterial wood; - private Item doorItem; + private final WoodMaterial wood; + private Item doorItem; - public BlockWoodDoor(WoodMaterial wood) { - super(Material.WOOD); - this.setSoundType(SoundType.WOOD); - this.wood = wood; - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - this.disableStats(); - this.setRegistryName(wood.getName() + "_door"); - } + public BlockWoodDoor(WoodMaterial wood) { + super(Material.WOOD); + this.setSoundType(SoundType.WOOD); + this.wood = wood; + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + this.disableStats(); + this.setRegistryName(wood.getName() + "_door"); + } - @Override - public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { - return new ItemStack(getDoorItem()); - } + @Override + public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { + return new ItemStack(getDoorItem()); + } - private Item getDoorItem() { - if (this.doorItem == null) { - this.doorItem = Item.REGISTRY.getObject(new ResourceLocation(this.getRegistryName().getResourceDomain(), this.wood.getName() + "_door_item")); - } - return this.doorItem; - } + private Item getDoorItem() { + if (this.doorItem == null) { + this.doorItem = Item.REGISTRY.getObject(new ResourceLocation(this.getRegistryName().getNamespace(), this.wood.getName() + "_door_item")); + } + return this.doorItem; + } - @SideOnly(Side.CLIENT) - @Override - public ItemStack getItem(final World w, final BlockPos c, final IBlockState bs) { - return new ItemStack(this.getDoorItem()); - } + @SideOnly(Side.CLIENT) + @Override + public ItemStack getItem(final World w, final BlockPos c, final IBlockState bs) { + return new ItemStack(this.getDoorItem()); + } - @Override - public Item getItemDropped(final IBlockState state, final Random rand, final int fortune) { - return (state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) ? null : this.getDoorItem(); - } + @Override + public Item getItemDropped(final IBlockState state, final Random rand, final int fortune) { + return (state.getValue(BlockDoor.HALF) == EnumDoorHalf.UPPER) ? null : this.getDoorItem(); + } - @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down(); - IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos); - if (iblockstate.getBlock() != this) { - return false; - } - IBlockState checkstate = iblockstate.cycleProperty(OPEN); - worldIn.setBlockState(blockpos, checkstate, 10); - worldIn.markBlockRangeForRenderUpdate(blockpos, pos); - worldIn.playEvent(playerIn, checkstate.getValue(OPEN) ? 1012 : 1006, pos, 0); - return true; + @Override + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down(); + IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos); + if (iblockstate.getBlock() != this) { + return false; + } - } + IBlockState checkstate = iblockstate.cycleProperty(OPEN); + worldIn.setBlockState(blockpos, checkstate, 10); + worldIn.markBlockRangeForRenderUpdate(blockpos, pos); + worldIn.playEvent(playerIn, checkstate.getValue(OPEN) ? 1012 : 1006, pos, 0); + return true; + } - public WoodMaterial getWoodMaterial() { - return this.wood; - } + public WoodMaterial getWoodMaterial() { + return this.wood; + } } diff --git a/src/main/java/panda/gotwood/block/BlockWoodFence.java b/src/main/java/panda/gotwood/block/BlockWoodFence.java index 1d8c85b..e6bf308 100644 --- a/src/main/java/panda/gotwood/block/BlockWoodFence.java +++ b/src/main/java/panda/gotwood/block/BlockWoodFence.java @@ -5,30 +5,30 @@ import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; - import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; public final class BlockWoodFence extends BlockFence implements IOreDictionaryEntry { - private final WoodMaterial wood; - public BlockWoodFence(WoodMaterial wood) { - super(Material.WOOD, BlockPlanks.EnumType.OAK.getMapColor()); - this.setSoundType(SoundType.WOOD); - this.wood = wood; - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - Blocks.FIRE.setFireInfo(this, 5, 20); - this.setRegistryName(wood.getName() + "_fence"); - } + private final WoodMaterial wood; + + public BlockWoodFence(WoodMaterial wood) { + super(Material.WOOD, BlockPlanks.EnumType.OAK.getMapColor()); + this.setSoundType(SoundType.WOOD); + this.wood = wood; + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + Blocks.FIRE.setFireInfo(this, 5, 20); + this.setRegistryName(wood.getName() + "_fence"); + } - public WoodMaterial getWoodMaterial() { - return this.wood; - } + public WoodMaterial getWoodMaterial() { + return this.wood; + } - @Override - public String getOreDictionaryName() { - return "fence" + this.wood.getCapitalizedName(); - } + @Override + public String getOreDictionaryName() { + return "fence" + this.wood.getCapitalizedName(); + } } diff --git a/src/main/java/panda/gotwood/block/BlockWoodFenceGate.java b/src/main/java/panda/gotwood/block/BlockWoodFenceGate.java index 961cf01..5a83f2c 100644 --- a/src/main/java/panda/gotwood/block/BlockWoodFenceGate.java +++ b/src/main/java/panda/gotwood/block/BlockWoodFenceGate.java @@ -4,31 +4,30 @@ import net.minecraft.block.BlockPlanks; import net.minecraft.block.SoundType; import net.minecraft.init.Blocks; - import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; public class BlockWoodFenceGate extends BlockFenceGate implements IOreDictionaryEntry { - final WoodMaterial wood; + final WoodMaterial wood; - public BlockWoodFenceGate(WoodMaterial wood) { - super(BlockPlanks.EnumType.OAK); - this.setSoundType(SoundType.WOOD); - this.wood = wood; - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - Blocks.FIRE.setFireInfo(this, 5, 20); - this.setRegistryName(wood.getName() + "_fence_gate"); - } + public BlockWoodFenceGate(WoodMaterial wood) { + super(BlockPlanks.EnumType.OAK); + this.setSoundType(SoundType.WOOD); + this.wood = wood; + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + Blocks.FIRE.setFireInfo(this, 5, 20); + this.setRegistryName(wood.getName() + "_fence_gate"); + } - public WoodMaterial getWoodMaterial() { - return this.wood; - } + public WoodMaterial getWoodMaterial() { + return this.wood; + } - @Override - public String getOreDictionaryName() { - return "gate" + this.wood.getCapitalizedName(); - } + @Override + public String getOreDictionaryName() { + return "gate" + this.wood.getCapitalizedName(); + } } diff --git a/src/main/java/panda/gotwood/block/BlockWoodLeaves.java b/src/main/java/panda/gotwood/block/BlockWoodLeaves.java index f7554e4..f8a5dc6 100644 --- a/src/main/java/panda/gotwood/block/BlockWoodLeaves.java +++ b/src/main/java/panda/gotwood/block/BlockWoodLeaves.java @@ -1,8 +1,5 @@ package panda.gotwood.block; -import java.util.List; -import java.util.Random; - import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockPlanks.EnumType; import net.minecraft.block.properties.PropertyBool; @@ -22,181 +19,177 @@ import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import panda.gotwood.GotWood; import panda.gotwood.events.ConfigurationHandler; import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; +import java.util.List; +import java.util.Random; + public final class BlockWoodLeaves extends BlockLeaves implements IOreDictionaryEntry { - public static final PropertyBool DECAYABLE = PropertyBool.create("decayable"); - - public static final PropertyBool CHECK_DECAY = PropertyBool.create("check_decay"); - - private final WoodMaterial wood; - - public BlockWoodLeaves(WoodMaterial wood) { - this.wood = wood; - Blocks.FIRE.setFireInfo(this, 30, 60); - this.setDefaultState(this.blockState.getBaseState().withProperty(DECAYABLE, false).withProperty(CHECK_DECAY, false)); - this.setRegistryName(wood.getName() + "_leaves"); - } - - //Should never be called for apple trees - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) { - return ForgeRegistries.ITEMS.getValue(new ResourceLocation(GotWood.ID, wood + "_seed")); - } - - @Override - public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - java.util.List ret = new java.util.ArrayList<>(); - Random rand = world instanceof World ? ((World) world).rand : new Random(); - int chance = -1; - //20,2,10 - chance = getModifiedSeedChance(this.wood, fortune); - if (rand.nextInt(chance) == 0) { - ret.add(new ItemStack(getItemDropped(state, rand, fortune), 1, damageDropped(state))); - } - this.captureDrops(true); - - ret.addAll(this.captureDrops(false)); - return ret; - } - - private int getModifiedSeedChance(WoodMaterial wood, int fortune) { - //should never happen but fall back to vanilla if so. - - int dec = ConfigurationHandler.seedDropFortuneDecrement; - int min = ConfigurationHandler.mapleChance; - int ch; - - switch (wood.getName()) { - case "maple": - ch = ConfigurationHandler.mapleChance; - break; - case "pine": - ch = ConfigurationHandler.pineChance; - break; - case "willow": - ch = ConfigurationHandler.willowChance; - break; - case "yew": - ch = ConfigurationHandler.yewChance; - break; - case "ebony": - ch = ConfigurationHandler.ebonyChance; - break; - case "fir": - ch = ConfigurationHandler.firChance; - break; - case "bamboo": - ch = ConfigurationHandler.bambooChance; - break; - case "rubber": - ch = ConfigurationHandler.rubberChance; - break; - default: - ch = 20; - } - return getModifiedChance(ch, fortune, dec, min); - } - - private int getModifiedChance(int chance, int fortune, int decrement, int minchance) { - int modifiedchance = chance; - if (fortune > 0) { - modifiedchance -= decrement << fortune; - if (modifiedchance < minchance) { - modifiedchance = minchance; - } - } - return modifiedchance; - } - - @SideOnly(Side.CLIENT) - public int getBlockColor() { - return 16777215; - } - - @SideOnly(Side.CLIENT) - public int getRenderColor(IBlockState state) { - return 16777215; - } - - @SideOnly(Side.CLIENT) - public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { - return 16777215; - } - - @SideOnly(Side.CLIENT) - @Override - public BlockRenderLayer getBlockLayer() { - return BlockRenderLayer.CUTOUT_MIPPED; - } - - @Override - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { - return true; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Override - public boolean isFoliage(IBlockAccess world, BlockPos pos) { - return true; - } - - @Override - public EnumType getWoodType(int meta) { - return null; - } - - public WoodMaterial getWoodMaterial() { - return this.wood; - } - - @Override - public String getOreDictionaryName() { - return "leaves" + this.wood.getCapitalizedName(); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(DECAYABLE, Boolean.valueOf((meta) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf(meta > 0)); - } - - @Override - public int getMetaFromState(IBlockState state) { - int i = 0; - - if (!state.getValue(DECAYABLE)) { - i |= 1; - } - - if (state.getValue(CHECK_DECAY)) { - i |= 2; - } - - return i; - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, CHECK_DECAY, DECAYABLE); - } - - @Override - public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) { - return java.util.Arrays.asList(new ItemStack(this, 1)); - } - - @Override - public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, - float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { - return this.getDefaultState(); - } + public static final PropertyBool DECAYABLE = PropertyBool.create("decayable"); + public static final PropertyBool CHECK_DECAY = PropertyBool.create("check_decay"); + private final WoodMaterial wood; + + public BlockWoodLeaves(WoodMaterial wood) { + this.wood = wood; + Blocks.FIRE.setFireInfo(this, 30, 60); + this.setDefaultState(this.blockState.getBaseState().withProperty(DECAYABLE, false).withProperty(CHECK_DECAY, false)); + this.setRegistryName(wood.getName() + "_leaves"); + } + + //Should never be called for apple trees + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return ForgeRegistries.ITEMS.getValue(new ResourceLocation(GotWood.MODID, wood + "_seed")); + } + + @Override + public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + java.util.List ret = new java.util.ArrayList<>(); + Random rand = world instanceof World ? ((World) world).rand : new Random(); + int chance = -1; + //20,2,10 + chance = getModifiedSeedChance(this.wood, fortune); + if (rand.nextInt(chance) == 0) { + ret.add(new ItemStack(getItemDropped(state, rand, fortune), 1, damageDropped(state))); + } + + this.captureDrops(true); + ret.addAll(this.captureDrops(false)); + return ret; + } + + private int getModifiedSeedChance(WoodMaterial wood, int fortune) { + //should never happen but fall back to vanilla if so. + int dec = ConfigurationHandler.seedDropFortuneDecrement; + int min = ConfigurationHandler.mapleChance; + int ch; + + switch (wood.getName()) { + case "maple": + ch = ConfigurationHandler.mapleChance; + break; + case "pine": + ch = ConfigurationHandler.pineChance; + break; + case "willow": + ch = ConfigurationHandler.willowChance; + break; + case "yew": + ch = ConfigurationHandler.yewChance; + break; + case "ebony": + ch = ConfigurationHandler.ebonyChance; + break; + case "fir": + ch = ConfigurationHandler.firChance; + break; + case "bamboo": + ch = ConfigurationHandler.bambooChance; + break; + case "rubber": + ch = ConfigurationHandler.rubberChance; + break; + default: + ch = 20; + } + return getModifiedChance(ch, fortune, dec, min); + } + + private int getModifiedChance(int chance, int fortune, int decrement, int minchance) { + int modifiedchance = chance; + if (fortune > 0) { + modifiedchance -= decrement << fortune; + if (modifiedchance < minchance) { + modifiedchance = minchance; + } + } + return modifiedchance; + } + + @SideOnly(Side.CLIENT) + public int getBlockColor() { + return 16777215; + } + + @SideOnly(Side.CLIENT) + public int getRenderColor(IBlockState state) { + return 16777215; + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { + return 16777215; + } + + @SideOnly(Side.CLIENT) + @Override + public BlockRenderLayer getRenderLayer() { + return BlockRenderLayer.CUTOUT_MIPPED; + } + + @Override + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { + return true; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @Override + public boolean isFoliage(IBlockAccess world, BlockPos pos) { + return true; + } + + @Override + public EnumType getWoodType(int meta) { + return null; + } + + public WoodMaterial getWoodMaterial() { + return this.wood; + } + + @Override + public String getOreDictionaryName() { + return "leaves" + this.wood.getCapitalizedName(); + } + + @Override + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(DECAYABLE, (meta) == 0).withProperty(CHECK_DECAY, meta > 0); + } + + @Override + public int getMetaFromState(IBlockState state) { + int i = 0; + if (!state.getValue(DECAYABLE)) { + i |= 1; + } + + if (state.getValue(CHECK_DECAY)) { + i |= 2; + } + return i; + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, CHECK_DECAY, DECAYABLE); + } + + @Override + public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) { + return java.util.Arrays.asList(new ItemStack(this, 1)); + } + + @Override + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { + return this.getDefaultState(); + } } diff --git a/src/main/java/panda/gotwood/block/BlockWoodLog.java b/src/main/java/panda/gotwood/block/BlockWoodLog.java index 3f498ef..2c4d09d 100644 --- a/src/main/java/panda/gotwood/block/BlockWoodLog.java +++ b/src/main/java/panda/gotwood/block/BlockWoodLog.java @@ -7,87 +7,79 @@ import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; - import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; public class BlockWoodLog extends BlockLog implements IOreDictionaryEntry { - public static final PropertyEnum LOG_AXIS = PropertyEnum.create("axis", BlockLog.EnumAxis.class); - - private final WoodMaterial wood; - - public BlockWoodLog(WoodMaterial wood) { - this.setDefaultState(this.blockState.getBaseState().withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); - Blocks.FIRE.setFireInfo(this, 5, 5); - this.wood = wood; - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - this.setRegistryName(wood.getName() + "_log"); - - } - - @Override - public boolean isWood(IBlockAccess world, BlockPos pos) { - return true; - } - - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, LOG_AXIS); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - IBlockState iblockstate = this.getDefaultState(); - - switch (meta) { - case 0: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); - break; - case 1: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); - break; - case 2: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); - break; - default: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); - } - - return iblockstate; - } - - @Override - public int getMetaFromState(IBlockState state) { - int i = 0; - - switch (state.getValue(LOG_AXIS)) { - case X: - i = 0; - break; - case Z: - i |= 1; - break; - case NONE: - i |= 2; - break; - default: - i = 0; - break; - } - - return i; - } - - public WoodMaterial getWoodMaterial() { - return this.wood; - } - - @Override - public String getOreDictionaryName() { - return "log" + this.wood.getCapitalizedName(); - } + public static final PropertyEnum LOG_AXIS = PropertyEnum.create("axis", BlockLog.EnumAxis.class); + private final WoodMaterial wood; + + public BlockWoodLog(WoodMaterial wood) { + this.setDefaultState(this.blockState.getBaseState().withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); + Blocks.FIRE.setFireInfo(this, 5, 5); + this.wood = wood; + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + this.setRegistryName(wood.getName() + "_log"); + } + + @Override + public boolean isWood(IBlockAccess world, BlockPos pos) { + return true; + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, LOG_AXIS); + } + + @Override + public IBlockState getStateFromMeta(int meta) { + IBlockState iblockstate = this.getDefaultState(); + switch (meta) { + case 0: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); + break; + case 1: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); + break; + case 2: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); + break; + default: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); + } + return iblockstate; + } + + @Override + public int getMetaFromState(IBlockState state) { + int i = 0; + switch (state.getValue(LOG_AXIS)) { + case X: + i = 0; + break; + case Z: + i |= 1; + break; + case NONE: + i |= 2; + break; + default: + i = 0; + break; + } + return i; + } + + public WoodMaterial getWoodMaterial() { + return this.wood; + } + + @Override + public String getOreDictionaryName() { + return "log" + this.wood.getCapitalizedName(); + } } - diff --git a/src/main/java/panda/gotwood/block/BlockWoodSapling.java b/src/main/java/panda/gotwood/block/BlockWoodSapling.java index b59f212..2e79c5f 100644 --- a/src/main/java/panda/gotwood/block/BlockWoodSapling.java +++ b/src/main/java/panda/gotwood/block/BlockWoodSapling.java @@ -1,7 +1,5 @@ package panda.gotwood.block; -import java.util.Random; - import net.minecraft.block.BlockBush; import net.minecraft.block.IGrowable; import net.minecraft.block.SoundType; @@ -18,197 +16,179 @@ import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.IPlantable; - -import panda.gotwood.generation.WorldGenApple; -import panda.gotwood.generation.WorldGenBamboo; -import panda.gotwood.generation.WorldGenEbony; -import panda.gotwood.generation.WorldGenFir; -import panda.gotwood.generation.WorldGenMaple; -import panda.gotwood.generation.WorldGenPalm; -import panda.gotwood.generation.WorldGenPine; -import panda.gotwood.generation.WorldGenRubber; -import panda.gotwood.generation.WorldGenWillow; -import panda.gotwood.generation.WorldGenYew; +import panda.gotwood.generation.*; import panda.gotwood.registry.BlockRegistry; import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; import panda.gotwood.util.WoodMaterials; +import java.util.Random; + public class BlockWoodSapling extends BlockBush implements IOreDictionaryEntry, IGrowable, IPlantable { - public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 1); - - protected static final AxisAlignedBB SAPLING_AABB = new AxisAlignedBB(0.1, 0.0D, 0.1, 0.9, 0.8, 0.9D); - - protected final WoodMaterial wood; - - public BlockWoodSapling(WoodMaterial wood) { - this.wood = wood; - this.setDefaultState(this.blockState.getBaseState().withProperty(STAGE, 0)); - this.setTickRandomly(true); - this.setHardness(0.0F); - this.setSoundType(SoundType.PLANT); - this.setRegistryName(wood.getName() + "_sapling"); - - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return SAPLING_AABB; - } - - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) { - return wood == WoodMaterials.bamboo ? Item.getItemFromBlock(BlockRegistry.bamboo_sapling) : Items.STICK; - } - - @Override - public int quantityDropped(Random random) { - return random.nextBoolean() ? 2 : 1; - } - - @Override - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { - if (!worldIn.isRemote) { - super.updateTick(worldIn, pos, state, rand); - - if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) { - this.grow(worldIn, pos, state, rand); - } - } - } - - public void grow(World worldIn, BlockPos pos, IBlockState state, Random rand) { - if (state.getValue(STAGE) == 0) { - worldIn.setBlockState(pos, this.getStateFromMeta(1), 4); - } else { - this.generateTree(worldIn, pos, state, rand); - } - } - - public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) { - - if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos)) - return; - - WorldGenerator worldgenerator; - int i = 0; - int j = 0; - boolean flag = false; // for bamboo spreading - - switch (wood.getName()) { - case "willow": - worldgenerator = new WorldGenWillow(); - break; - case "yew": - worldgenerator = new WorldGenYew(); - break; - case "ebony": - worldgenerator = new WorldGenEbony(true); - break; - case "fir": - worldgenerator = new WorldGenFir(true); - break; - case "pine": - worldgenerator = new WorldGenPine(true); - break; - case "bamboo": - worldgenerator = new WorldGenBamboo(true); - break; - case "palm": - worldgenerator = new WorldGenPalm(true); - break; - case "rubber": - worldgenerator = new WorldGenRubber(true); - break; - default: - worldgenerator = new WorldGenMaple(true); - } - - IBlockState iblockstate2 = Blocks.AIR.getDefaultState(); - - if (flag) { - worldIn.setBlockState(pos.add(i, 0, j), iblockstate2, 4); - worldIn.setBlockState(pos.add(i + 1, 0, j), iblockstate2, 4); - worldIn.setBlockState(pos.add(i, 0, j + 1), iblockstate2, 4); - worldIn.setBlockState(pos.add(i + 1, 0, j + 1), iblockstate2, 4); - } else { - - worldIn.setBlockToAir(pos); - } - - if (!worldgenerator.generate(worldIn, rand, pos.add(i, 0, j))) { - - if (flag) { - worldIn.setBlockState(pos.add(i, 0, j), state, 4); - worldIn.setBlockState(pos.add(i + 1, 0, j), state, 4); - worldIn.setBlockState(pos.add(i, 0, j + 1), state, 4); - worldIn.setBlockState(pos.add(i + 1, 0, j + 1), state, 4); - } else { - worldIn.setBlockState(pos, state, 4); - } - } - } - - @Override - public int damageDropped(IBlockState state) { - return 0; - } - - @Override - public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { - - return wood.getName().equals("palm") ? EnumPlantType.Desert : EnumPlantType.Plains; - } - - @Override - public IBlockState getPlant(IBlockAccess world, BlockPos pos) { - IBlockState state = world.getBlockState(pos); - if (state.getBlock() != this) { - return getDefaultState(); - } - return state; - } - - public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) { - return true; - } - - public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) { - return (double)worldIn.rand.nextFloat() < 0.45D;// - } - - public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { - this.grow(worldIn, pos, state, rand); - } - - @Override - protected boolean canSustainBush(IBlockState state) - { - return false; + + public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 1); + protected static final AxisAlignedBB SAPLING_AABB = new AxisAlignedBB(0.1, 0.0D, 0.1, 0.9, 0.8, 0.9D); + protected final WoodMaterial wood; + + public BlockWoodSapling(WoodMaterial wood) { + this.wood = wood; + this.setDefaultState(this.blockState.getBaseState().withProperty(STAGE, 0)); + this.setTickRandomly(true); + this.setHardness(0.0F); + this.setSoundType(SoundType.PLANT); + this.setRegistryName(wood.getName() + "_sapling"); + } + + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return SAPLING_AABB; + } + + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return wood == WoodMaterials.bamboo ? Item.getItemFromBlock(BlockRegistry.bamboo_sapling) : Items.STICK; + } + + @Override + public int quantityDropped(Random random) { + return random.nextBoolean() ? 2 : 1; + } + + @Override + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (!worldIn.isRemote) { + super.updateTick(worldIn, pos, state, rand); + if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) { + this.grow(worldIn, pos, state, rand); + } + } + } + + public void grow(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (state.getValue(STAGE) == 0) { + worldIn.setBlockState(pos, this.getStateFromMeta(1), 4); + } else { + this.generateTree(worldIn, pos, state, rand); + } + } + + public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos)) { + return; + } + + WorldGenerator worldgenerator; + int i = 0; + int j = 0; + boolean flag = false; // for bamboo spreading + switch (wood.getName()) { + case "willow": + worldgenerator = new WorldGenWillow(); + break; + case "yew": + worldgenerator = new WorldGenYew(); + break; + case "ebony": + worldgenerator = new WorldGenEbony(true); + break; + case "fir": + worldgenerator = new WorldGenFir(true); + break; + case "pine": + worldgenerator = new WorldGenPine(true); + break; + case "bamboo": + worldgenerator = new WorldGenBamboo(true); + break; + case "palm": + worldgenerator = new WorldGenPalm(true); + break; + case "rubber": + worldgenerator = new WorldGenRubber(true); + break; + default: + worldgenerator = new WorldGenMaple(true); + } + + IBlockState iblockstate2 = Blocks.AIR.getDefaultState(); + if (flag) { + worldIn.setBlockState(pos.add(i, 0, j), iblockstate2, 4); + worldIn.setBlockState(pos.add(i + 1, 0, j), iblockstate2, 4); + worldIn.setBlockState(pos.add(i, 0, j + 1), iblockstate2, 4); + worldIn.setBlockState(pos.add(i + 1, 0, j + 1), iblockstate2, 4); + } else { + worldIn.setBlockToAir(pos); + } + + if (!worldgenerator.generate(worldIn, rand, pos.add(i, 0, j))) { + if (flag) { + worldIn.setBlockState(pos.add(i, 0, j), state, 4); + worldIn.setBlockState(pos.add(i + 1, 0, j), state, 4); + worldIn.setBlockState(pos.add(i, 0, j + 1), state, 4); + worldIn.setBlockState(pos.add(i + 1, 0, j + 1), state, 4); + } else { + worldIn.setBlockState(pos, state, 4); + } + } } - @Override - public IBlockState getStateFromMeta(int meta) { - return this.getDefaultState().withProperty(STAGE, meta); - } + @Override + public int damageDropped(IBlockState state) { + return 0; + } + + @Override + public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { + return wood.getName().equals("palm") ? EnumPlantType.Desert : EnumPlantType.Plains; + } + + @Override + public IBlockState getPlant(IBlockAccess world, BlockPos pos) { + IBlockState state = world.getBlockState(pos); + if (state.getBlock() != this) { + return getDefaultState(); + } + return state; + } - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(STAGE); - } + public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) { + return true; + } - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, STAGE); - } + public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) { + return (double) worldIn.rand.nextFloat() < 0.45D;// + } - public WoodMaterial getWoodMaterial() { - return this.wood; - } + public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { + this.grow(worldIn, pos, state, rand); + } - @Override - public String getOreDictionaryName() { - return "sapling" + this.wood.getCapitalizedName(); - } + @Override + protected boolean canSustainBush(IBlockState state) { + return false; + } + @Override + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(STAGE, meta); + } + + @Override + public int getMetaFromState(IBlockState state) { + return state.getValue(STAGE); + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, STAGE); + } + + public WoodMaterial getWoodMaterial() { + return this.wood; + } + + @Override + public String getOreDictionaryName() { + return "sapling" + this.wood.getCapitalizedName(); + } } diff --git a/src/main/java/panda/gotwood/block/BlockWoodSlab.java b/src/main/java/panda/gotwood/block/BlockWoodSlab.java index 52153bd..a8ac8f8 100644 --- a/src/main/java/panda/gotwood/block/BlockWoodSlab.java +++ b/src/main/java/panda/gotwood/block/BlockWoodSlab.java @@ -1,7 +1,5 @@ package panda.gotwood.block; -import java.util.Random; - import net.minecraft.block.BlockSlab; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; @@ -17,99 +15,99 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLLog; - import panda.gotwood.util.WoodMaterial; +import java.util.Random; + public abstract class BlockWoodSlab extends BlockSlab { - public static final PropertyEnum VARIANT = PropertyEnum.create("variant", BlockWoodSlab.Variant.class); - - private final WoodMaterial wood; - - private Item slabItem; - - public BlockWoodSlab(WoodMaterial wd) { - super(Material.WOOD); - this.setSoundType(SoundType.WOOD); - this.wood = wd; - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - Blocks.FIRE.setFireInfo(this, 5, 20); - IBlockState iblockstate = this.blockState.getBaseState(); - if (!this.isDouble()) { - iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM); - } - this.setDefaultState(iblockstate.withProperty(VARIANT, BlockWoodSlab.Variant.DEFAULT)); - this.useNeighborBrightness = !this.isDouble(); - } - - @Override - public IBlockState getStateFromMeta(int meta) { - IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, BlockWoodSlab.Variant.DEFAULT); - if (!this.isDouble()) { - iblockstate = iblockstate.withProperty(HALF, (meta & 8) == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP); - } - return iblockstate; - } - - @Override - public int getMetaFromState(IBlockState state) { - return !this.isDouble() && state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP ? 8 : 0; - } - - @Override - protected BlockStateContainer createBlockState() { - return this.isDouble() ? new BlockStateContainer(this, VARIANT) : new BlockStateContainer(this, HALF, VARIANT); - } - - @Override - public String getUnlocalizedName(int meta) { - return super.getUnlocalizedName(); - } - - @Override - public boolean isDouble() { - return false; - } - - @Override - public IProperty getVariantProperty() { - return VARIANT; - } - - @Override - public Comparable getTypeForItem(ItemStack stack) { - return BlockWoodSlab.Variant.DEFAULT; - } - - private Item getSlabItem() { - if (this.slabItem == null) { - FMLLog.severe("getting item for slab: %s, %s", this.getRegistryName().getResourceDomain(), this.wood.getName() + "_slab"); - this.slabItem = Item.REGISTRY.getObject(new ResourceLocation(this.getRegistryName().getResourceDomain(), this.wood.getName() + "_slab")); - } - return this.slabItem; - } - - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) { - return this.getSlabItem(); - } - - @Override - public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { - return new ItemStack(this.getSlabItem()); - } - - public WoodMaterial getWoodMaterial() { - return this.wood; - } - - public enum Variant implements IStringSerializable { - DEFAULT; - - @Override - public String getName() { - return "default"; - } - } + + public static final PropertyEnum VARIANT = PropertyEnum.create("variant", BlockWoodSlab.Variant.class); + private final WoodMaterial wood; + private Item slabItem; + + public BlockWoodSlab(WoodMaterial wd) { + super(Material.WOOD); + this.setSoundType(SoundType.WOOD); + this.wood = wd; + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + Blocks.FIRE.setFireInfo(this, 5, 20); + IBlockState iblockstate = this.blockState.getBaseState(); + if (!this.isDouble()) { + iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM); + } + this.setDefaultState(iblockstate.withProperty(VARIANT, BlockWoodSlab.Variant.DEFAULT)); + this.useNeighborBrightness = !this.isDouble(); + } + + @Override + public IBlockState getStateFromMeta(int meta) { + IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, BlockWoodSlab.Variant.DEFAULT); + if (!this.isDouble()) { + iblockstate = iblockstate.withProperty(HALF, (meta & 8) == 0 ? BlockSlab.EnumBlockHalf.BOTTOM : BlockSlab.EnumBlockHalf.TOP); + } + return iblockstate; + } + + @Override + public int getMetaFromState(IBlockState state) { + return !this.isDouble() && state.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP ? 8 : 0; + } + + @Override + protected BlockStateContainer createBlockState() { + return this.isDouble() ? new BlockStateContainer(this, VARIANT) : new BlockStateContainer(this, HALF, VARIANT); + } + + @Override + public String getTranslationKey(int meta) { + return super.getTranslationKey(); + } + + @Override + public boolean isDouble() { + return false; + } + + @Override + public IProperty getVariantProperty() { + return VARIANT; + } + + @Override + public Comparable getTypeForItem(ItemStack stack) { + return BlockWoodSlab.Variant.DEFAULT; + } + + private Item getSlabItem() { + if (this.slabItem == null) { + FMLLog.severe("getting item for slab: %s, %s", this.getRegistryName().getNamespace(), this.wood.getName() + "_slab"); + this.slabItem = Item.REGISTRY.getObject(new ResourceLocation(this.getRegistryName().getNamespace(), this.wood.getName() + "_slab")); + } + return this.slabItem; + } + + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return this.getSlabItem(); + } + + @Override + public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { + return new ItemStack(this.getSlabItem()); + } + + public WoodMaterial getWoodMaterial() { + return this.wood; + } + + public enum Variant implements IStringSerializable { + DEFAULT; + + @Override + public String getName() { + return "default"; + } + } } diff --git a/src/main/java/panda/gotwood/block/BlockWoodStairs.java b/src/main/java/panda/gotwood/block/BlockWoodStairs.java index acf92b7..c9928b6 100644 --- a/src/main/java/panda/gotwood/block/BlockWoodStairs.java +++ b/src/main/java/panda/gotwood/block/BlockWoodStairs.java @@ -4,31 +4,31 @@ import net.minecraft.block.BlockStairs; import net.minecraft.block.SoundType; import net.minecraft.init.Blocks; - import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; public final class BlockWoodStairs extends BlockStairs implements IOreDictionaryEntry { - private final WoodMaterial wood; - public BlockWoodStairs(WoodMaterial wood, Block modelBlock) { - super(modelBlock.getDefaultState()); - this.setSoundType(SoundType.WOOD); - this.wood = wood; - this.useNeighborBrightness = true; - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - Blocks.FIRE.setFireInfo(this, 5, 20); - this.setRegistryName(wood.getName() + "_stairs"); - } + private final WoodMaterial wood; + + public BlockWoodStairs(WoodMaterial wood, Block modelBlock) { + super(modelBlock.getDefaultState()); + this.setSoundType(SoundType.WOOD); + this.wood = wood; + this.useNeighborBrightness = true; + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + Blocks.FIRE.setFireInfo(this, 5, 20); + this.setRegistryName(wood.getName() + "_stairs"); + } - public WoodMaterial getWoodMaterial() { - return this.wood; - } + public WoodMaterial getWoodMaterial() { + return this.wood; + } - @Override - public String getOreDictionaryName() { - return "stairs" + this.wood.getCapitalizedName(); - } + @Override + public String getOreDictionaryName() { + return "stairs" + this.wood.getCapitalizedName(); + } } diff --git a/src/main/java/panda/gotwood/block/BlockWoodTrapdoor.java b/src/main/java/panda/gotwood/block/BlockWoodTrapdoor.java index d52d33e..6e3f8ad 100644 --- a/src/main/java/panda/gotwood/block/BlockWoodTrapdoor.java +++ b/src/main/java/panda/gotwood/block/BlockWoodTrapdoor.java @@ -9,47 +9,44 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraft.item.ItemStack; - import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; public final class BlockWoodTrapdoor extends BlockTrapDoor implements IOreDictionaryEntry { - private final WoodMaterial wood; - - private final String oreDict; - - public BlockWoodTrapdoor(WoodMaterial wood) { - super(Material.WOOD); - this.wood = wood; - this.oreDict = "trapdoor" + wood.getCapitalizedName(); - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.blockSoundType = SoundType.WOOD; - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - this.disableStats(); - this.setRegistryName(wood.getName() + "_trapdoor"); - } - - @Override - public boolean onBlockActivated(final World world, final BlockPos coord, IBlockState state, - final EntityPlayer player, EnumHand hand, ItemStack heldItem, final EnumFacing facing, - final float partialX, final float partialY, final float partialZ) { - if (this.wood.getToolHarvestLevel() > 1) - return true; - - IBlockState newState = state.cycleProperty(BlockTrapDoor.OPEN); - worldIn.setBlockState(pos, newState, 2); - worldIn.playEvent(playerIn, newState.getValue(BlockTrapDoor.OPEN) ? 1012 : 1006, pos, 0); - return true; - } - - @Override - public String getOreDictionaryName() { - return this.oreDict; - } - - public WoodMaterial getWoodMaterial() { - return this.wood; - } + + private final WoodMaterial wood; + private final String oreDict; + + public BlockWoodTrapdoor(WoodMaterial wood) { + super(Material.WOOD); + this.wood = wood; + this.oreDict = "trapdoor" + wood.getCapitalizedName(); + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.blockSoundType = SoundType.WOOD; + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + this.disableStats(); + this.setRegistryName(wood.getName() + "_trapdoor"); + } + + @Override + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + if (this.wood.getToolHarvestLevel() > 1) { + return true; + } + + IBlockState newState = state.cycleProperty(BlockTrapDoor.OPEN); + world.setBlockState(pos, newState, 2); + world.playEvent(player, newState.getValue(BlockTrapDoor.OPEN) ? 1012 : 1006, pos, 0); + return true; + } + + @Override + public String getOreDictionaryName() { + return this.oreDict; + } + + public WoodMaterial getWoodMaterial() { + return this.wood; + } } diff --git a/src/main/java/panda/gotwood/block/entity/TileEntityTreeTap.java b/src/main/java/panda/gotwood/block/entity/TileEntityTreeTap.java index aca3d61..098bad4 100644 --- a/src/main/java/panda/gotwood/block/entity/TileEntityTreeTap.java +++ b/src/main/java/panda/gotwood/block/entity/TileEntityTreeTap.java @@ -1,104 +1,104 @@ package panda.gotwood.block.entity; -import javax.annotation.Nonnull; - import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraftforge.fluids.FluidStack; - import panda.gotwood.block.BlockTreeTap; import panda.gotwood.util.TapRegistry; +import javax.annotation.Nonnull; + public final class TileEntityTreeTap extends TileEntity implements ITickable { - private static int LIQUID_AMOUNT = 0; - - private EnumFacing direction; - - public boolean hasBucket; - - private FluidStack sapInBucket; //fluid In bucket - - public TileEntityTreeTap() { - reset(); - } - - @Override - public void update() { - if (getWorld().isRemote) { - return; - } - if (!hasBucket) { - return; - } - System.out.println(sapInBucket); - if (LIQUID_AMOUNT == 0 || sapInBucket == null) { - return; - } - if (sapInBucket.amount < 1000) { - addToBucket(); - } - } - - protected void addToBucket() { - sapInBucket.amount += LIQUID_AMOUNT; - System.out.println("Adding " + LIQUID_AMOUNT + " mb"); - if (sapInBucket.amount > 1000) { - sapInBucket.amount = 1000; - } - } - - protected void reset() { - hasBucket = false; - sapInBucket = null; - direction = EnumFacing.DOWN; // invalid direction - } - - @Nonnull - @Override - public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound = super.writeToNBT(compound); - if (sapInBucket != null) { - sapInBucket.writeToNBT(compound); - compound.setInteger("direction", direction.getIndex()); - compound.setInteger("sappertick", LIQUID_AMOUNT); - } - return compound; - } - - @Override - public void readFromNBT(NBTTagCompound compound) { - super.readFromNBT(compound); - sapInBucket = FluidStack.loadFluidStackFromNBT(compound); - if (sapInBucket != null) { - direction = EnumFacing.values()[compound.getInteger("direction")]; - LIQUID_AMOUNT = compound.getInteger("sappertick"); - hasBucket = true; - } else { - reset(); - } - } - - @Override - public void handleUpdateTag(@Nonnull NBTTagCompound tag) { - readFromNBT(tag); - } - - @Nonnull - @Override - public NBTTagCompound getUpdateTag() { - return writeToNBT(new NBTTagCompound()); - } - - @Override - public void onLoad() { - sapInBucket = TapRegistry.find(getWorld().getBlockState(pos).getBlock()); - direction = getWorld().getBlockState(pos).getValue(BlockTreeTap.FACING); - } - - public TileEntity setLiquidAmount(int amountPerTick) { - LIQUID_AMOUNT = amountPerTick; - return this; - } + + private static int LIQUID_AMOUNT = 0; + public boolean hasBucket; + public EnumFacing direction; + public FluidStack sapInBucket; //fluid In bucket + + public TileEntityTreeTap() { + reset(); + } + + @Override + public void update() { + if (getWorld().isRemote) { + return; + } + + if (!hasBucket) { + return; + } + + System.out.println(sapInBucket); + if (LIQUID_AMOUNT == 0 || sapInBucket == null) { + return; + } + + if (sapInBucket.amount < 1000) { + addToBucket(); + } + } + + protected void addToBucket() { + sapInBucket.amount += LIQUID_AMOUNT; + System.out.println("Adding " + LIQUID_AMOUNT + " mb"); + if (sapInBucket.amount > 1000) { + sapInBucket.amount = 1000; + } + } + + protected void reset() { + hasBucket = false; + sapInBucket = null; + direction = EnumFacing.DOWN; // invalid direction + } + + @Nonnull + @Override + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound = super.writeToNBT(compound); + if (sapInBucket != null) { + sapInBucket.writeToNBT(compound); + compound.setInteger("direction", direction.getIndex()); + compound.setInteger("sappertick", LIQUID_AMOUNT); + } + return compound; + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + sapInBucket = FluidStack.loadFluidStackFromNBT(compound); + if (sapInBucket != null) { + direction = EnumFacing.values()[compound.getInteger("direction")]; + LIQUID_AMOUNT = compound.getInteger("sappertick"); + hasBucket = true; + } else { + reset(); + } + } + + @Override + public void handleUpdateTag(@Nonnull NBTTagCompound tag) { + readFromNBT(tag); + } + + @Nonnull + @Override + public NBTTagCompound getUpdateTag() { + return writeToNBT(new NBTTagCompound()); + } + + @Override + public void onLoad() { + sapInBucket = TapRegistry.find(getWorld().getBlockState(pos).getBlock()); + direction = getWorld().getBlockState(pos).getValue(BlockTreeTap.FACING); + } + + public TileEntity setLiquidAmount(int amountPerTick) { + LIQUID_AMOUNT = amountPerTick; + return this; + } } diff --git a/src/main/java/panda/gotwood/blocks/BlockBambooFence.java b/src/main/java/panda/gotwood/blocks/BlockBambooFence.java index 64600e5..5c385c3 100644 --- a/src/main/java/panda/gotwood/blocks/BlockBambooFence.java +++ b/src/main/java/panda/gotwood/blocks/BlockBambooFence.java @@ -1,121 +1,97 @@ package panda.gotwood.blocks; -import java.util.List; - -import javax.annotation.Nullable; - -import panda.gotwood.util.IOreDictionaryEntry; -import panda.gotwood.util.WoodMaterial; -import net.minecraft.block.Block; import net.minecraft.block.BlockFence; import net.minecraft.block.BlockPlanks; -import net.minecraft.block.BlockWall; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; -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.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import panda.gotwood.util.IOreDictionaryEntry; +import panda.gotwood.util.WoodMaterial; + +import javax.annotation.Nullable; +import java.util.List; /** - * * @author Jasmine Iwanek - * */ -public class BlockBambooFence extends BlockFence implements IOreDictionaryEntry{ +public class BlockBambooFence extends BlockFence implements IOreDictionaryEntry { - final WoodMaterial wood; - - protected static final AxisAlignedBB[] BOUNDING_BOXES = new AxisAlignedBB[] {new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D), new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D), new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.625D, 1.0D, 1.0D), new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 0.625D), new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.625D, 1.0D, 0.625D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D), new AxisAlignedBB(0.375D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D), new AxisAlignedBB(0.375D, 0.0D, 0.375D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D), new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.375D, 0.0D, 0.0D, 1.0D, 1.0D, 0.625D), new AxisAlignedBB(0.375D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.625D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D)}; public static final AxisAlignedBB PILLAR_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.5D, 0.625D); public static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.625D, 0.625D, 1.5D, 1.0D); public static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.375D, 1.5D, 0.625D); public static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.5D, 0.375D); public static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.625D, 0.0D, 0.375D, 1.0D, 1.5D, 0.625D); - - public BlockBambooFence(WoodMaterial wood) { - //TODO maptypes - super(Material.WOOD,BlockPlanks.EnumType.OAK.getMapColor()); - this.setSoundType(SoundType.WOOD); - this.wood = wood; - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - Blocks.FIRE.setFireInfo(this, 5, 20); - this.setRegistryName(wood.getName()+"_fence"); - } - - - public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn) - { - state = state.getActualState(worldIn, pos); - addCollisionBoxToList(pos, entityBox, collidingBoxes, PILLAR_AABB); - - if (((Boolean)state.getValue(NORTH)).booleanValue()) - { - addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB); - } - - if (((Boolean)state.getValue(EAST)).booleanValue()) - { - addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB); - } - - if (((Boolean)state.getValue(SOUTH)).booleanValue()) - { - addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB); - } - - if (((Boolean)state.getValue(WEST)).booleanValue()) - { - addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB); - } - } - - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { - state = this.getActualState(state, source, pos); - return BOUNDING_BOXES[getBoundingBoxIdx(state)]; - } - - /** - * Returns the correct index into boundingBoxes, based on what the fence is connected to. - */ - private static int getBoundingBoxIdx(IBlockState state) - { - int i = 0; - - if (((Boolean)state.getValue(NORTH)).booleanValue()) - { - i |= 1 << EnumFacing.NORTH.getHorizontalIndex(); - } - - if (((Boolean)state.getValue(EAST)).booleanValue()) - { - i |= 1 << EnumFacing.EAST.getHorizontalIndex(); - } - - if (((Boolean)state.getValue(SOUTH)).booleanValue()) - { - i |= 1 << EnumFacing.SOUTH.getHorizontalIndex(); - } - - if (((Boolean)state.getValue(WEST)).booleanValue()) - { - i |= 1 << EnumFacing.WEST.getHorizontalIndex(); - } - - return i; - } + protected static final AxisAlignedBB[] BOUNDING_BOXES = new AxisAlignedBB[]{new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D), new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D), new AxisAlignedBB(0.0D, 0.0D, 0.375D, 0.625D, 1.0D, 1.0D), new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 0.625D), new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.625D, 1.0D, 0.625D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D), new AxisAlignedBB(0.375D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D), new AxisAlignedBB(0.375D, 0.0D, 0.375D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D), new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.375D, 0.0D, 0.0D, 1.0D, 1.0D, 0.625D), new AxisAlignedBB(0.375D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.625D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D)}; + final WoodMaterial wood; + + public BlockBambooFence(WoodMaterial wood) { + //TODO maptypes + super(Material.WOOD, BlockPlanks.EnumType.OAK.getMapColor()); + this.setSoundType(SoundType.WOOD); + this.wood = wood; + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + Blocks.FIRE.setFireInfo(this, 5, 20); + this.setRegistryName(wood.getName() + "_fence"); + } + + /** + * Returns the correct index into boundingBoxes, based on what the fence is connected to. + */ + private static int getBoundingBoxIdx(IBlockState state) { + int i = 0; + + if ((Boolean) state.getValue(NORTH)) { + i |= 1 << EnumFacing.NORTH.getHorizontalIndex(); + } + + if (state.getValue(EAST)) { + i |= 1 << EnumFacing.EAST.getHorizontalIndex(); + } + + if (state.getValue(SOUTH)) { + i |= 1 << EnumFacing.SOUTH.getHorizontalIndex(); + } + + if (state.getValue(WEST)) { + i |= 1 << EnumFacing.WEST.getHorizontalIndex(); + } + return i; + } + + public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn) { + state = state.getActualState(worldIn, pos); + addCollisionBoxToList(pos, entityBox, collidingBoxes, PILLAR_AABB); + + if (state.getValue(NORTH)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB); + } + + if (state.getValue(EAST)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB); + } + + if (state.getValue(SOUTH)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB); + } + + if (state.getValue(WEST)) { + addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB); + } + } + + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + state = this.getActualState(state, source, pos); + return BOUNDING_BOXES[getBoundingBoxIdx(state)]; + } /*@Override @SideOnly(Side.CLIENT) @@ -123,13 +99,12 @@ public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { list.add(new ItemStack(itemIn, 1, BlockFence..EnumType.NORMAL.getMetadata())); }*/ + public WoodMaterial getWoodMaterial() { + return this.wood; + } - public WoodMaterial getWoodMaterial() { - return this.wood; - } - -@Override - public String getOreDictionaryName() { - return "fence" + this.wood.getCapitalizedName(); - } + @Override + public String getOreDictionaryName() { + return "fence" + this.wood.getCapitalizedName(); + } } \ No newline at end of file diff --git a/src/main/java/panda/gotwood/blocks/BlockBambooLog.java b/src/main/java/panda/gotwood/blocks/BlockBambooLog.java index 29b3d61..d044778 100644 --- a/src/main/java/panda/gotwood/blocks/BlockBambooLog.java +++ b/src/main/java/panda/gotwood/blocks/BlockBambooLog.java @@ -1,31 +1,17 @@ package panda.gotwood.blocks; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import javax.annotation.Nullable; - import net.minecraft.block.Block; -import net.minecraft.block.BlockFenceGate; -import net.minecraft.block.BlockWall; import net.minecraft.block.IGrowable; import net.minecraft.block.material.Material; -import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.translation.I18n; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -36,133 +22,116 @@ import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; -public class BlockBambooLog extends Block implements IOreDictionaryEntry, IGrowable,IFireDrops{ - - public static final PropertyBool LEAVES = PropertyBool.create("leaves"); - - public BlockBambooLog(WoodMaterial wood) { - super(Material.WOOD); - this.setDefaultState(this.blockState.getBaseState().withProperty(LEAVES, Boolean.valueOf(false))); - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - this.setRegistryName(wood.getName()+"_log"); - - } - - @SideOnly(Side.CLIENT) +import javax.annotation.Nullable; +import java.util.List; +import java.util.Random; + +public class BlockBambooLog extends Block implements IOreDictionaryEntry, IGrowable, IFireDrops { + + public static final PropertyBool LEAVES = PropertyBool.create("leaves"); + + public BlockBambooLog(WoodMaterial wood) { + super(Material.WOOD); + this.setDefaultState(this.blockState.getBaseState().withProperty(LEAVES, false)); + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + this.setRegistryName(wood.getName() + "_log"); + } + + @SideOnly(Side.CLIENT) @Override - public BlockRenderLayer getBlockLayer() - { - return BlockRenderLayer.CUTOUT_MIPPED ; + public BlockRenderLayer getRenderLayer() { + return BlockRenderLayer.CUTOUT_MIPPED; } - - @Override public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity) - { return true; } - - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { - return state == this.getDefaultState()? new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D):new AxisAlignedBB(0D, 0D, 0D, 1D, 1.0D, 1D); + + @Override + public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity) { + return true; + } + + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return state == this.getDefaultState() ? new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D) : new AxisAlignedBB(0D, 0D, 0D, 1D, 1.0D, 1D); } @Nullable - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) - { - return blockState == this.getDefaultState()? new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D):new AxisAlignedBB(0D, 0D, 0D, 1D, 1.0D, 1D); + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { + return blockState == this.getDefaultState() ? new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D) : new AxisAlignedBB(0D, 0D, 0D, 1D, 1.0D, 1D); } @Override - public boolean canSustainLeaves(IBlockState state, IBlockAccess world, - BlockPos pos) { - return true; - } - public boolean isFullCube(IBlockState state) - { + public boolean canSustainLeaves(IBlockState state, IBlockAccess world, BlockPos pos) { + return true; + } + + public boolean isFullCube(IBlockState state) { return false; } - public boolean isPassable(IBlockAccess worldIn, BlockPos pos) - { + public boolean isPassable(IBlockAccess worldIn, BlockPos pos) { return false; } /** * Used to determine ambient occlusion and culling when rebuilding chunks for render */ - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } + @Override + public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + List ret = new java.util.ArrayList(); + ret.add(new ItemStack(ItemRegistry.bamboo_pole)); + return ret; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { + return side != EnumFacing.DOWN || super.shouldSideBeRendered(blockState, blockAccess, pos, side); + } + @Override + public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) { + // TODO Auto-generated method stub + return false; + } @Override - public List getDrops(IBlockAccess world, BlockPos pos, - IBlockState state, int fortune) { - List ret = new java.util.ArrayList(); - ret.add(new ItemStack(ItemRegistry.bamboo_pole)); - return ret; - } - - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) - { - return side == EnumFacing.DOWN ? super.shouldSideBeRendered(blockState, blockAccess, pos, side) : true; - } - - @Override - public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, - boolean isClient) { - // TODO Auto-generated method stub - return false; - } - - @Override - public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block) { - - - if(world.getBlockState(pos.north()).getBlock() == BlockRegistry.bamboo_leaves ||world.getBlockState(pos.west()).getBlock() == BlockRegistry.bamboo_leaves||world.getBlockState(pos.east()).getBlock() == BlockRegistry.bamboo_leaves|| world.getBlockState(pos.south()).getBlock() == BlockRegistry.bamboo_leaves){ - world.setBlockState(pos, this.getDefaultState().withProperty(LEAVES, true),2); - }else{ - world.setBlockState(pos, this.getDefaultState().withProperty(LEAVES, false),2); - } - - this.checkAndDropBlock(world, pos, state); - - } - - protected final void checkAndDropBlock(World world, BlockPos pos, IBlockState state) { - boolean flag = true; - if (world.getBlockState(pos.down()).getBlock() == this || world.getBlockState(pos.down()).isNormalCube()) - flag = false; - else if (flag && !world.isRemote){ - world.destroyBlock(pos, true); - breakBlock(world,pos,state); - } - - } - - public void breakBlock(World worldIn, BlockPos pos, IBlockState state) - { + public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) { + if (world.getBlockState(pos.north()).getBlock() == BlockRegistry.bamboo_leaves || world.getBlockState(pos.west()).getBlock() == BlockRegistry.bamboo_leaves || world.getBlockState(pos.east()).getBlock() == BlockRegistry.bamboo_leaves || world.getBlockState(pos.south()).getBlock() == BlockRegistry.bamboo_leaves) { + world.setBlockState(pos, this.getDefaultState().withProperty(LEAVES, true), 2); + } else { + world.setBlockState(pos, this.getDefaultState().withProperty(LEAVES, false), 2); + } + this.checkAndDropBlock(world, pos, state); + } + + protected final void checkAndDropBlock(World world, BlockPos pos, IBlockState state) { + boolean flag = true; + if (world.getBlockState(pos.down()).getBlock() == this || world.getBlockState(pos.down()).isNormalCube()) { + flag = false; + } else if (flag && !world.isRemote) { + world.destroyBlock(pos, true); + breakBlock(world, pos, state); + } + } + + public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { int i = 1; int j = 2; int k = pos.getX(); int l = pos.getY(); int i1 = pos.getZ(); - if (worldIn.isAreaLoaded(new BlockPos(k - 2, l - 2, i1 - 2), new BlockPos(k + 2, l + 2, i1 + 2))) - { - for (int j1 = -1; j1 <= 1; ++j1) - { - for (int k1 = -1; k1 <= 1; ++k1) - { - for (int l1 = -1; l1 <= 1; ++l1) - { + if (worldIn.isAreaLoaded(new BlockPos(k - 2, l - 2, i1 - 2), new BlockPos(k + 2, l + 2, i1 + 2))) { + for (int j1 = -1; j1 <= 1; ++j1) { + for (int k1 = -1; k1 <= 1; ++k1) { + for (int l1 = -1; l1 <= 1; ++l1) { BlockPos blockpos = pos.add(j1, k1, l1); IBlockState iblockstate = worldIn.getBlockState(blockpos); - if (iblockstate.getBlock().isLeaves(iblockstate, worldIn, blockpos)) - { + if (iblockstate.getBlock().isLeaves(iblockstate, worldIn, blockpos)) { iblockstate.getBlock().beginLeavesDecay(iblockstate, worldIn, blockpos); } } @@ -171,61 +140,54 @@ public void breakBlock(World worldIn, BlockPos pos, IBlockState state) } } - @Override - public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, - IBlockState state) { - // TODO Auto-generated method stub - return false; - } - - @Override - public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { - // TODO Auto-generated method stub - - } - @Override - public boolean isBlockSolid(IBlockAccess worldIn, BlockPos pos, EnumFacing side) - { + @Override + public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) { + return false; + } + + @Override + public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { + // TODO Auto-generated method stub + } + + @Override + public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { + return true; + } + + @Override + public String getOreDictionaryName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean hasFireDrops() { return true; } - @Override - public String getOreDictionaryName() { - // TODO Auto-generated method stub - return null; - } - @Override - public boolean hasFireDrops() { - return true; - } - @Override - public List addFireDrops(List drops,Random random) { - - if(random.nextBoolean()){ - drops.add(new ItemStack(ItemRegistry.ash)); - }else{ - drops.add(new ItemStack(ItemRegistry.bamboo_charcoal)); - } - - return drops; - } - - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(LEAVES, Boolean.valueOf(meta == 1)); - } - + @Override + public List addFireDrops(List drops, Random random) { + if (random.nextBoolean()) { + drops.add(new ItemStack(ItemRegistry.ash)); + } else { + drops.add(new ItemStack(ItemRegistry.bamboo_charcoal)); + } + return drops; + } + + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(LEAVES, meta == 1); + } + /** * Convert the BlockState into the correct metadata value */ - public int getMetaFromState(IBlockState state) - { - return state.getValue(LEAVES)==true?1:0; - } - - protected BlockStateContainer createBlockState() - { - return new BlockStateContainer(this, new IProperty[] {LEAVES}); + public int getMetaFromState(IBlockState state) { + return state.getValue(LEAVES) ? 1 : 0; } + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, LEAVES); + } } diff --git a/src/main/java/panda/gotwood/blocks/BlockBerryBush.java b/src/main/java/panda/gotwood/blocks/BlockBerryBush.java index ccd5fbb..8cef0a6 100644 --- a/src/main/java/panda/gotwood/blocks/BlockBerryBush.java +++ b/src/main/java/panda/gotwood/blocks/BlockBerryBush.java @@ -1,13 +1,7 @@ package panda.gotwood.blocks; -import java.util.Random; - -import javax.annotation.Nullable; - import net.minecraft.block.Block; import net.minecraft.block.BlockBush; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; @@ -18,91 +12,82 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class BlockBerryBush extends BlockBush{ +import javax.annotation.Nullable; +import java.util.Random; + +public class BlockBerryBush extends BlockBush { - public static final PropertyInteger GROWTH = PropertyInteger.create("growth", 0, 1); - - public BlockBerryBush(){ - this.setDefaultState(this.blockState.getBaseState().withProperty(GROWTH, Integer.valueOf(0))); + public static final PropertyInteger GROWTH = PropertyInteger.create("growth", 0, 1); + + public BlockBerryBush() { + this.setDefaultState(this.blockState.getBaseState().withProperty(GROWTH, 0)); this.setTickRandomly(true); - } - - public boolean isOpaqueCube(IBlockState state) - { + } + + public boolean isOpaqueCube(IBlockState state) { return false; } - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } - - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) - { - super.neighborChanged(state, worldIn, pos, blockIn); + + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { + super.neighborChanged(state, worldIn, pos, blockIn, fromPos); this.checkAndDropBlock(worldIn, pos, state); } - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) - { + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { this.checkAndDropBlock(worldIn, pos, state); } - protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state) - { - if (!this.canBlockStay(worldIn, pos, state)|| areaCleared( worldIn,pos)) - { - if(areaCleared(worldIn,pos)){ - this.dropBlockAsItem(worldIn, pos, state, 0); + protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state) { + if (!this.canBlockStay(worldIn, pos, state) || areaCleared(worldIn, pos)) { + if (areaCleared(worldIn, pos)) { + this.dropBlockAsItem(worldIn, pos, state, 0); } worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 3); } } - - public boolean areaCleared(World world, BlockPos pos){ - if((world.getBlockState(pos.down(2)).getBlock() == Blocks.AIR)&& - (world.getBlockState(pos.east()).getBlock() == Blocks.AIR)&& - (world.getBlockState(pos.east().down()).getBlock() == Blocks.AIR)&& - (world.getBlockState(pos.west()).getBlock() == Blocks.AIR)&& - (world.getBlockState(pos.west().down()).getBlock() == Blocks.AIR)&& - (world.getBlockState(pos.north()).getBlock() == Blocks.AIR)&& - (world.getBlockState(pos.north().down()).getBlock() == Blocks.AIR)&& - (world.getBlockState(pos.south()).getBlock() == Blocks.AIR)&& - (world.getBlockState(pos.south().down()).getBlock() == Blocks.AIR)&& - (world.getBlockState(pos.down()).getBlock() != Blocks.AIR)){ - return true; - } - return false; + + public boolean areaCleared(World world, BlockPos pos) { + if ((world.getBlockState(pos.down(2)).getBlock() == Blocks.AIR) && + (world.getBlockState(pos.east()).getBlock() == Blocks.AIR) && + (world.getBlockState(pos.east().down()).getBlock() == Blocks.AIR) && + (world.getBlockState(pos.west()).getBlock() == Blocks.AIR) && + (world.getBlockState(pos.west().down()).getBlock() == Blocks.AIR) && + (world.getBlockState(pos.north()).getBlock() == Blocks.AIR) && + (world.getBlockState(pos.north().down()).getBlock() == Blocks.AIR) && + (world.getBlockState(pos.south()).getBlock() == Blocks.AIR) && + (world.getBlockState(pos.south().down()).getBlock() == Blocks.AIR) && + (world.getBlockState(pos.down()).getBlock() != Blocks.AIR)) { + return true; + } + return false; } - public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) - { + public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state) { return this.canSustainBush(worldIn.getBlockState(pos.down())); - } - public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack) - { + public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack) { super.harvestBlock(worldIn, player, pos, state, te, stack); worldIn.setBlockToAir(pos); } - - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(GROWTH, Integer.valueOf(meta)); + + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(GROWTH, meta); } - + /** * Convert the BlockState into the correct metadata value */ - public int getMetaFromState(IBlockState state) - { - return ((Integer)state.getValue(GROWTH)).intValue(); + public int getMetaFromState(IBlockState state) { + return state.getValue(GROWTH); } - - protected BlockStateContainer createBlockState() - { - return new BlockStateContainer(this, new IProperty[] {GROWTH}); + + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, GROWTH); } } diff --git a/src/main/java/panda/gotwood/blocks/BlockPalmLeaves.java b/src/main/java/panda/gotwood/blocks/BlockPalmLeaves.java index d49af8f..c64acfd 100644 --- a/src/main/java/panda/gotwood/blocks/BlockPalmLeaves.java +++ b/src/main/java/panda/gotwood/blocks/BlockPalmLeaves.java @@ -1,205 +1,165 @@ package panda.gotwood.blocks; -import java.util.List; -import java.util.Random; - -import javax.annotation.Nullable; - -import panda.gotwood.events.ConfigurationHandler; -import panda.gotwood.registry.BlockRegistry; -import panda.gotwood.util.IOreDictionaryEntry; -import panda.gotwood.util.WoodMaterial; -import panda.gotwood.util.WoodMaterials; - -import com.google.common.base.Predicate; - -import net.minecraft.block.Block; import net.minecraft.block.BlockLeaves; -import net.minecraft.block.BlockLog; -import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockPlanks.EnumType; -import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.stats.StatList; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import panda.gotwood.registry.BlockRegistry; +import panda.gotwood.util.IOreDictionaryEntry; +import panda.gotwood.util.WoodMaterial; + +import java.util.Arrays; +import java.util.List; +import java.util.Random; -public class BlockPalmLeaves extends BlockLeaves implements IOreDictionaryEntry{ - public static final PropertyBool DECAYABLE = PropertyBool.create("decayable"); +public class BlockPalmLeaves extends BlockLeaves implements IOreDictionaryEntry { + + public static final PropertyBool DECAYABLE = PropertyBool.create("decayable"); public static final PropertyBool CHECK_DECAY = PropertyBool.create("check_decay"); - final WoodMaterial wood; - int[] surroundings; - - public BlockPalmLeaves( WoodMaterial wood){ - this.wood = wood; - Blocks.FIRE.setFireInfo(this, 30, 60); - this.setDefaultState(this.blockState.getBaseState().withProperty(DECAYABLE, false).withProperty(CHECK_DECAY, false)); - this.setRegistryName(wood.getName()+"_leaves"); - } - - //protected int getSaplingDropChance(IBlockState state) + final WoodMaterial wood; + int[] surroundings; + + public BlockPalmLeaves(WoodMaterial wood) { + this.wood = wood; + Blocks.FIRE.setFireInfo(this, 30, 60); + this.setDefaultState(this.blockState.getBaseState().withProperty(DECAYABLE, false).withProperty(CHECK_DECAY, false)); + this.setRegistryName(wood.getName() + "_leaves"); + } + + //protected int getSaplingDropChance(IBlockState state) //{ // return state.getValue(VARIANT) == BlockPlanks.EnumType.JUNGLE ? 40 : super.getSaplingDropChance(state); //} - - - - @Override - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) - { - if (!worldIn.isRemote) - { - if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue() && ((Boolean)state.getValue(DECAYABLE)).booleanValue()) - { + + @Override + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (!worldIn.isRemote) { + if (state.getValue(CHECK_DECAY) && state.getValue(DECAYABLE)) { int i = pos.getX(); int j = pos.getY(); int k = pos.getZ(); int r = 10; - if (worldIn.isAreaLoaded(new BlockPos(i - r, j - r, k - r), new BlockPos(i + r, j + r, k + r))) - { - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); - for(BlockPos blockpos:BlockPos.getAllInBox(new BlockPos(i - r, j - r, k - r), new BlockPos(i + r, j + r, k + r))){ - if(worldIn.getBlockState(blockpos).getBlock() == BlockRegistry.palm_log){ - return; - } + if (worldIn.isAreaLoaded(new BlockPos(i - r, j - r, k - r), new BlockPos(i + r, j + r, k + r))) { + for (BlockPos blockpos : BlockPos.getAllInBox(new BlockPos(i - r, j - r, k - r), new BlockPos(i + r, j + r, k + r))) { + if (worldIn.getBlockState(blockpos).getBlock() == BlockRegistry.palm_log) { + return; + } } - - this.destroy(worldIn, pos); - } - else - { + this.destroy(worldIn, pos); + } else { this.destroy(worldIn, pos); } } } } - - private void destroy(World worldIn, BlockPos pos) - { + + private void destroy(World worldIn, BlockPos pos) { this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0); worldIn.setBlockToAir(pos); } - - //Should never be called for apple trees - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) - { - return GameRegistry.findItem("varietytrees", wood+"_seed"); + + //Should never be called for apple trees + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + //return GameRegistry.findItem("varietytrees", wood + "_seed"); + return ForgeRegistries.ITEMS.getValue(new ResourceLocation("varietytrees", wood + "_seed")); } - - + @SideOnly(Side.CLIENT) - public int getBlockColor() - { + public int getBlockColor() { return 16777215; } @SideOnly(Side.CLIENT) - public int getRenderColor(IBlockState state) - { + public int getRenderColor(IBlockState state) { return 16777215; } @SideOnly(Side.CLIENT) - public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) - { + public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { return 16777215; } - + @SideOnly(Side.CLIENT) @Override - public BlockRenderLayer getBlockLayer() - { - return BlockRenderLayer.CUTOUT_MIPPED ; + public BlockRenderLayer getRenderLayer() { + return BlockRenderLayer.CUTOUT_MIPPED; } - @Override - public boolean shouldSideBeRendered(IBlockState blockState, - IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { - return true; - } + @Override + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { + return true; + } - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } - @Override - public boolean isFoliage(IBlockAccess world, BlockPos pos) - { + @Override + public boolean isFoliage(IBlockAccess world, BlockPos pos) { return true; } - @Override - public EnumType getWoodType(int meta) { - return null; - } - - public WoodMaterial getWoodMaterial() { - return this.wood; - } - -@Override - public String getOreDictionaryName() { - return "leaves" + this.wood.getCapitalizedName(); - } -@Override -public IBlockState getStateFromMeta(int meta) -{ - return this.getDefaultState().withProperty(DECAYABLE, Boolean.valueOf((meta) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf(meta > 0)); -} + @Override + public EnumType getWoodType(int meta) { + return null; + } -/** - * Convert the BlockState into the correct metadata value - */ -@Override -public int getMetaFromState(IBlockState state) -{ - int i = 0; + public WoodMaterial getWoodMaterial() { + return this.wood; + } - if (!((Boolean)state.getValue(DECAYABLE)).booleanValue()) - { - i |= 1; + @Override + public String getOreDictionaryName() { + return "leaves" + this.wood.getCapitalizedName(); } - if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue()) - { - i |= 2; + @Override + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(DECAYABLE, meta == 0).withProperty(CHECK_DECAY, meta > 0); } - return i; -} -@Override -protected BlockStateContainer createBlockState() -{ - return new BlockStateContainer(this, new IProperty[] {CHECK_DECAY, DECAYABLE}); -} + /** + * Convert the BlockState into the correct metadata value + */ + @Override + public int getMetaFromState(IBlockState state) { + int i = 0; -@Override -public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) -{ - return java.util.Arrays.asList(new ItemStack(this, 1)); -} + if (!state.getValue(DECAYABLE)) { + i |= 1; + } + if (state.getValue(CHECK_DECAY)) { + i |= 2; + } + return i; + } + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, CHECK_DECAY, DECAYABLE); + } + @Override + public List onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { + return Arrays.asList(new ItemStack(this, 1)); + } } diff --git a/src/main/java/panda/gotwood/blocks/BlockTreeTap.java b/src/main/java/panda/gotwood/blocks/BlockTreeTap.java index ff8e068..e808f90 100644 --- a/src/main/java/panda/gotwood/blocks/BlockTreeTap.java +++ b/src/main/java/panda/gotwood/blocks/BlockTreeTap.java @@ -3,13 +3,11 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; - import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockLog; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.BlockStateContainer; @@ -28,199 +26,187 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import panda.gotwood.block.entity.TileEntityTreeTap; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import panda.gotwood.block.entity.TileEntityTreeTap; -import panda.gotwood.registry.BlockRegistry; +public class BlockTreeTap extends BlockContainer { + public static final PropertyBool HASBUCKET = PropertyBool.create("hasbucket"); + public static final PropertyDirection FACING = PropertyDirection.create("facing", new Predicate() { + @Override + public boolean apply(@Nullable EnumFacing input) { + return input != EnumFacing.DOWN && input != EnumFacing.UP; + } + }); + private static final ImmutableMap BOUNDS; + public static int FLUIDPERTICK = 0; + + static { + ImmutableMap.Builder builder = ImmutableMap.builder(); + builder.put(EnumFacing.UP, FULL_BLOCK_AABB); + builder.put(EnumFacing.NORTH, new AxisAlignedBB(0.25, 0.25, 0, 0.75, 0.625, 0.375)); + builder.put(EnumFacing.SOUTH, new AxisAlignedBB(0.25, 0.25, 0.625, 0.75, 0.625, 1.0)); + builder.put(EnumFacing.EAST, new AxisAlignedBB(0.625, 0.25, 0.25, 1, 0.625, 0.75)); + builder.put(EnumFacing.WEST, new AxisAlignedBB(0, 0.25, 0.25, 0.375, 0.625, 0.75)); + builder.put(EnumFacing.DOWN, FULL_BLOCK_AABB); + + BOUNDS = builder.build(); + } -public class BlockTreeTap extends BlockContainer { + public BlockTreeTap() { + super(Material.WOOD); + this.setHardness(3F); + this.setResistance(2F); + this.setSoundType(SoundType.WOOD); + this.setRegistryName("tree_tap"); + this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(HASBUCKET, false)); + } - public static int FLUIDPERTICK = 0; - - public static final PropertyBool HASBUCKET = PropertyBool.create("hasbucket"); - - public static final PropertyDirection FACING = PropertyDirection.create("facing", new Predicate() { @Override - public boolean apply(@Nullable EnumFacing input) { - return input != EnumFacing.DOWN && input != EnumFacing.UP; - } - }); - - @Override -public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state,EntityPlayer playerIn, EnumHand hand, ItemStack heldItem,EnumFacing side, float hitX, float hitY, float hitZ) { - super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem,side, hitX, hitY, hitZ); - if(worldIn.isRemote) { - return false; - } - if(this.hasTileEntity(this.getDefaultState())){ - if(playerIn.getActiveHand() != null){ - ItemStack stack = playerIn.getHeldItem(playerIn.getActiveHand()); - if(stack != null){ - System.out.println("yep"); - if(stack.getItem() == Items.BUCKET){ - if(stack.stackSize > 0){ - --stack.stackSize; - - TileEntity te = worldIn.getTileEntity(pos); - if(te instanceof TileTreeTap){ - ((TileTreeTap)te).hasBucket = true; - worldIn.setBlockState(pos, worldIn.getBlockState(pos).withProperty(HASBUCKET, true), 3); - return true; - } - } - } - } - } - } - return false; -} + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ); + if (worldIn.isRemote) { + return false; + } + + if (this.hasTileEntity(this.getDefaultState())) { + if (playerIn.getActiveHand() != null) { + ItemStack stack = playerIn.getHeldItem(playerIn.getActiveHand()); + if (stack != null) { + System.out.println("yep"); + if (stack.getItem() == Items.BUCKET) { + if (stack.getCount() > 0) { + stack.shrink(1); + + TileEntity te = worldIn.getTileEntity(pos); + if (te instanceof TileEntityTreeTap) { + ((TileEntityTreeTap) te).hasBucket = true; + worldIn.setBlockState(pos, worldIn.getBlockState(pos).withProperty(HASBUCKET, true), 3); + return true; + } + } + } + } + } + } + return false; + } -@Override -public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { - -} + @Override + public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { + } -public BlockTreeTap() { - super(Material.WOOD); - this.setHardness(3F); - this.setResistance(2F); - this.setSoundType(SoundType.WOOD); - this.setRegistryName("tree_tap"); - this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(HASBUCKET, false)); - } - - @Nonnull - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, new IProperty[] {FACING, HASBUCKET}); - } - - /** - * Convert the given metadata into a BlockState for this Block - */ - @Nonnull - @Override - public IBlockState getStateFromMeta(int meta) { - if(meta >= EnumFacing.HORIZONTALS.length) { - meta = 1; - } - EnumFacing face = EnumFacing.values()[meta>>1]; - if(face == EnumFacing.DOWN || face == EnumFacing.UP) { - face = EnumFacing.NORTH; - } - - return this.getDefaultState().withProperty(FACING, face); - } - - /** - * Convert the BlockState into the correct metadata value - */ - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(FACING).ordinal()<<1-1+(state.getValue(HASBUCKET)?1:0); - } - - @Override - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { - if(worldIn.isRemote) { - return; - } - Block block = worldIn.getBlockState(pos).getBlock(); - if(block instanceof BlockTreeTap) { - this.breakBlock(worldIn, pos, state); - } - - } - - - - private static final ImmutableMap BOUNDS; - - static { - ImmutableMap.Builder builder = ImmutableMap.builder(); - builder.put(EnumFacing.UP, FULL_BLOCK_AABB); - builder.put(EnumFacing.NORTH, new AxisAlignedBB(0.25, 0.25, 0, 0.75, 0.625, 0.375)); - builder.put(EnumFacing.SOUTH, new AxisAlignedBB(0.25, 0.25, 0.625, 0.75, 0.625, 1.0)); - builder.put(EnumFacing.EAST, new AxisAlignedBB(0.625, 0.25, 0.25, 1, 0.625, 0.75)); - builder.put(EnumFacing.WEST, new AxisAlignedBB(0, 0.25, 0.25, 0.375, 0.625, 0.75)); - builder.put(EnumFacing.DOWN, FULL_BLOCK_AABB); - - BOUNDS = builder.build(); - } - - @Nonnull - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - return BOUNDS.get(state.getValue(FACING)); - } - - @Nonnull - @Override - public EnumBlockRenderType getRenderType(IBlockState state) { - return EnumBlockRenderType.MODEL; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, @Nonnull IBlockAccess blockAccess, @Nonnull BlockPos pos, EnumFacing side) { - return true; - } - - @Override - public boolean isFullCube(IBlockState state) { - return false; - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - - @Nonnull - @Override - public TileEntity createNewTileEntity(@Nonnull World worldIn, int meta) { - System.out.println(FLUIDPERTICK); - return new TileTreeTap().setLiquidAmount(FLUIDPERTICK); - } - -//gets the amount of sap transfered to the bucket per tick, determined by the number of log blocks and the tree type - public int getAmountPerTick(World world, BlockPos pos,EnumFacing facing){ - int amtPerBlock = 2; //mb - - BlockPos start = pos.offset(facing); - int totalAmount = 0 ; - if(world.getBlockState(start) instanceof BlockLog){ - - for(int k= -1;k<14;k++){ - for(int i= -1;i<2;i++){ - for(int j= -1;j<2;j++){ - if(world.getBlockState(start.add(i, j, k)) instanceof BlockLog){ - totalAmount += amtPerBlock; - } - } - } - } - } - return totalAmount; - } - - @Override -public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { - this.FLUIDPERTICK = getAmountPerTick(worldIn,pos,state.getValue(FACING)); - super.onBlockAdded(worldIn, pos, state); -} + @Nonnull + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, FACING, HASBUCKET); + } + + /** + * Convert the given metadata into a BlockState for this Block + */ + @Nonnull + @Override + public IBlockState getStateFromMeta(int meta) { + if (meta >= EnumFacing.HORIZONTALS.length) { + meta = 1; + } + + EnumFacing face = EnumFacing.values()[meta >> 1]; + if (face == EnumFacing.DOWN || face == EnumFacing.UP) { + face = EnumFacing.NORTH; + } + return this.getDefaultState().withProperty(FACING, face); + } - @Override - public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, ItemStack stack) { - EnumFacing enumfacing = facing.getOpposite(); + /** + * Convert the BlockState into the correct metadata value + */ + @Override + public int getMetaFromState(IBlockState state) { + return state.getValue(FACING).ordinal() << (state.getValue(HASBUCKET) ? 1 : 0); + } + + @Override + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { + if (worldIn.isRemote) { + return; + } + + Block block = worldIn.getBlockState(pos).getBlock(); + if (block instanceof BlockTreeTap) { + this.breakBlock(worldIn, pos, state); + } + } - if(enumfacing == EnumFacing.DOWN || enumfacing == EnumFacing.UP) { - enumfacing = placer.getHorizontalFacing().getOpposite(); + @Nonnull + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return BOUNDS.get(state.getValue(FACING)); + } + + @Nonnull + @Override + public EnumBlockRenderType getRenderType(IBlockState state) { + return EnumBlockRenderType.MODEL; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockState blockState, @Nonnull IBlockAccess blockAccess, @Nonnull BlockPos pos, EnumFacing side) { + return true; + } + + @Override + public boolean isFullCube(IBlockState state) { + return false; + } + + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } + + @Nonnull + @Override + public TileEntity createNewTileEntity(@Nonnull World worldIn, int meta) { + System.out.println(FLUIDPERTICK); + return new TileEntityTreeTap().setLiquidAmount(FLUIDPERTICK); + } + + //gets the amount of sap transfered to the bucket per tick, determined by the number of log blocks and the tree type + public int getAmountPerTick(World world, BlockPos pos, EnumFacing facing) { + int amtPerBlock = 2; //mb + BlockPos start = pos.offset(facing); + int totalAmount = 0; + if (world.getBlockState(start) instanceof BlockLog) { + for (int k = -1; k < 14; k++) { + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (world.getBlockState(start.add(i, j, k)) instanceof BlockLog) { + totalAmount += amtPerBlock; + } + } + } + } + } + return totalAmount; + } + + @Override + public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { + FLUIDPERTICK = getAmountPerTick(worldIn, pos, state.getValue(FACING)); + super.onBlockAdded(worldIn, pos, state); + } + + @Override + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { + EnumFacing enumfacing = facing.getOpposite(); + if (enumfacing == EnumFacing.DOWN || enumfacing == EnumFacing.UP) { + enumfacing = placer.getHorizontalFacing().getOpposite(); + } + return this.getDefaultState().withProperty(FACING, enumfacing); } - - return this.getDefaultState().withProperty(FACING, enumfacing); - } } diff --git a/src/main/java/panda/gotwood/blocks/BlockWoodFence.java b/src/main/java/panda/gotwood/blocks/BlockWoodFence.java index 10bb540..ee702e3 100644 --- a/src/main/java/panda/gotwood/blocks/BlockWoodFence.java +++ b/src/main/java/panda/gotwood/blocks/BlockWoodFence.java @@ -1,43 +1,31 @@ package panda.gotwood.blocks; -import java.util.List; - -import panda.gotwood.util.IOreDictionaryEntry; -import panda.gotwood.util.WoodMaterial; -import net.minecraft.block.Block; import net.minecraft.block.BlockFence; import net.minecraft.block.BlockPlanks; -import net.minecraft.block.BlockWall; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import panda.gotwood.util.IOreDictionaryEntry; +import panda.gotwood.util.WoodMaterial; /** - * * @author Jasmine Iwanek - * */ -public class BlockWoodFence extends BlockFence implements IOreDictionaryEntry{ - - final WoodMaterial wood; - - - public BlockWoodFence(WoodMaterial wood) { - //TODO maptypes - super(Material.WOOD,BlockPlanks.EnumType.OAK.getMapColor()); - this.setSoundType(SoundType.WOOD); - this.wood = wood; - this.blockHardness = wood.getPlankBlockHardness(); - this.blockResistance = wood.getBlastResistance(); - this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); - Blocks.FIRE.setFireInfo(this, 5, 20); - this.setRegistryName(wood.getName()+"_fence"); - } +public class BlockWoodFence extends BlockFence implements IOreDictionaryEntry { + + final WoodMaterial wood; + + public BlockWoodFence(WoodMaterial wood) { + //TODO maptypes + super(Material.WOOD, BlockPlanks.EnumType.OAK.getMapColor()); + this.setSoundType(SoundType.WOOD); + this.wood = wood; + this.blockHardness = wood.getPlankBlockHardness(); + this.blockResistance = wood.getBlastResistance(); + this.setHarvestLevel("axe", wood.getRequiredHarvestLevel()); + Blocks.FIRE.setFireInfo(this, 5, 20); + this.setRegistryName(wood.getName() + "_fence"); + } /*@Override @SideOnly(Side.CLIENT) @@ -45,13 +33,12 @@ public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { list.add(new ItemStack(itemIn, 1, BlockFence..EnumType.NORMAL.getMetadata())); }*/ + public WoodMaterial getWoodMaterial() { + return this.wood; + } - public WoodMaterial getWoodMaterial() { - return this.wood; - } - -@Override - public String getOreDictionaryName() { - return "fence" + this.wood.getCapitalizedName(); - } + @Override + public String getOreDictionaryName() { + return "fence" + this.wood.getCapitalizedName(); + } } \ No newline at end of file diff --git a/src/main/java/panda/gotwood/blocks/BlockWoodLeaves.java b/src/main/java/panda/gotwood/blocks/BlockWoodLeaves.java index affe7ad..2277cf9 100644 --- a/src/main/java/panda/gotwood/blocks/BlockWoodLeaves.java +++ b/src/main/java/panda/gotwood/blocks/BlockWoodLeaves.java @@ -1,233 +1,202 @@ package panda.gotwood.blocks; -import java.util.List; -import java.util.Random; - -import javax.annotation.Nullable; - -import panda.gotwood.events.ConfigurationHandler; -import panda.gotwood.util.IOreDictionaryEntry; -import panda.gotwood.util.WoodMaterial; -import panda.gotwood.util.WoodMaterials; - -import com.google.common.base.Predicate; - -import net.minecraft.block.Block; import net.minecraft.block.BlockLeaves; -import net.minecraft.block.BlockLog; -import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockPlanks.EnumType; -import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.stats.StatList; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import panda.gotwood.GotWood; +import panda.gotwood.events.ConfigurationHandler; +import panda.gotwood.util.IOreDictionaryEntry; +import panda.gotwood.util.WoodMaterial; +import panda.gotwood.util.WoodMaterials; + +import java.util.Arrays; +import java.util.List; +import java.util.Random; -public class BlockWoodLeaves extends BlockLeaves implements IOreDictionaryEntry{ - public static final PropertyBool DECAYABLE = PropertyBool.create("decayable"); +public class BlockWoodLeaves extends BlockLeaves implements IOreDictionaryEntry { + + public static final PropertyBool DECAYABLE = PropertyBool.create("decayable"); public static final PropertyBool CHECK_DECAY = PropertyBool.create("check_decay"); - final WoodMaterial wood; - - public BlockWoodLeaves( WoodMaterial wood){ - this.wood = wood; - Blocks.FIRE.setFireInfo(this, 30, 60); - this.setDefaultState(this.blockState.getBaseState().withProperty(DECAYABLE, false).withProperty(CHECK_DECAY, false)); - this.setRegistryName(wood.getName()+"_leaves"); - } - - //protected int getSaplingDropChance(IBlockState state) + final WoodMaterial wood; + + public BlockWoodLeaves(WoodMaterial wood) { + this.wood = wood; + Blocks.FIRE.setFireInfo(this, 30, 60); + this.setDefaultState(this.blockState.getBaseState().withProperty(DECAYABLE, false).withProperty(CHECK_DECAY, false)); + this.setRegistryName(wood.getName() + "_leaves"); + } + + //protected int getSaplingDropChance(IBlockState state) //{ // return state.getValue(VARIANT) == BlockPlanks.EnumType.JUNGLE ? 40 : super.getSaplingDropChance(state); //} - - //Should never be called for apple trees - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) - { - return GameRegistry.findItem("gotwood", wood+"_seed"); + + //Should never be called for apple trees + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + //return GameRegistry.findItem("gotwood", wood + "_seed"); + return ForgeRegistries.ITEMS.getValue(new ResourceLocation(GotWood.MODID, wood + "_seed")); } - @Override - public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) - { + @Override + public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { java.util.List ret = new java.util.ArrayList(); - Random rand = world instanceof World ? ((World)world).rand : new Random(); - int chance = -1; - if(wood != WoodMaterials.apple){ - //20,2,10 - chance = getModifiedSeedChance(this.wood,fortune); - if (rand.nextInt(chance) == 0){ - ret.add(new ItemStack(getItemDropped(state, rand, fortune), 1, damageDropped(state))); + Random rand = world instanceof World ? ((World) world).rand : new Random(); + int chance = -1; + if (wood != WoodMaterials.apple) { + //20,2,10 + chance = getModifiedSeedChance(this.wood, fortune); + if (rand.nextInt(chance) == 0) { + ret.add(new ItemStack(getItemDropped(state, rand, fortune), 1, damageDropped(state))); } } - - - if(wood == WoodMaterials.apple){ - chance = getModifiedChance(ConfigurationHandler.appleChance, fortune, ConfigurationHandler.appleDropFortuneDecrement,ConfigurationHandler.appleDropMinChance); - if (rand.nextInt(chance) == 0){ - ret.add(new ItemStack(Items.APPLE)); - } - - chance = getModifiedChance(ConfigurationHandler.goldenDropChance, fortune, ConfigurationHandler.goldenDropFortuneDecrement,ConfigurationHandler.goldenDropMinChance); - if (rand.nextInt(chance) == 0){ - ret.add(new ItemStack(Items.GOLDEN_APPLE)); + + if (wood == WoodMaterials.apple) { + chance = getModifiedChance(ConfigurationHandler.appleChance, fortune, ConfigurationHandler.appleDropFortuneDecrement, ConfigurationHandler.appleDropMinChance); + if (rand.nextInt(chance) == 0) { + ret.add(new ItemStack(Items.APPLE)); + } + + chance = getModifiedChance(ConfigurationHandler.goldenDropChance, fortune, ConfigurationHandler.goldenDropFortuneDecrement, ConfigurationHandler.goldenDropMinChance); + if (rand.nextInt(chance) == 0) { + ret.add(new ItemStack(Items.GOLDEN_APPLE)); } } - - this.captureDrops(true); + this.captureDrops(true); ret.addAll(this.captureDrops(false)); return ret; } - - private int getModifiedSeedChance(WoodMaterial wood, int fortune) { - //should never happen but fallback to vanilla if so. - int ch = 20; - int dec = ConfigurationHandler.seedDropFortuneDecrement; - int min = ConfigurationHandler.mapleChance; - - switch(wood.getName()){ - case "maple": - ch = ConfigurationHandler.mapleChance; - case "pine": - ch = ConfigurationHandler.pineChance; - case "willow": - ch = ConfigurationHandler.willowChance; - case "yew": - ch = ConfigurationHandler.yewChance; - case "ebony": - ch = ConfigurationHandler.ebonyChance; - case "fir": - ch = ConfigurationHandler.firChance; - case "bamboo": - ch = ConfigurationHandler.bambooChance; - - } - return getModifiedChance(ch, fortune,dec,min); - } - - private int getModifiedChance(int chance, int fortune,int decrement,int minchance){ - if (fortune > 0) - { + + private int getModifiedSeedChance(WoodMaterial wood, int fortune) { + //should never happen but fallback to vanilla if so. + int ch = 20; + int dec = ConfigurationHandler.seedDropFortuneDecrement; + int min = ConfigurationHandler.mapleChance; + switch (wood.getName()) { + case "maple": + ch = ConfigurationHandler.mapleChance; + case "pine": + ch = ConfigurationHandler.pineChance; + case "willow": + ch = ConfigurationHandler.willowChance; + case "yew": + ch = ConfigurationHandler.yewChance; + case "ebony": + ch = ConfigurationHandler.ebonyChance; + case "fir": + ch = ConfigurationHandler.firChance; + case "bamboo": + ch = ConfigurationHandler.bambooChance; + } + return getModifiedChance(ch, fortune, dec, min); + } + + private int getModifiedChance(int chance, int fortune, int decrement, int minchance) { + if (fortune > 0) { chance -= decrement << fortune; - if (chance < minchance){ - chance = minchance; + if (chance < minchance) { + chance = minchance; } } return chance; -} - - + } + @SideOnly(Side.CLIENT) - public int getBlockColor() - { + public int getBlockColor() { return 16777215; } @SideOnly(Side.CLIENT) - public int getRenderColor(IBlockState state) - { + public int getRenderColor(IBlockState state) { return 16777215; } @SideOnly(Side.CLIENT) - public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) - { + public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { return 16777215; } - + @SideOnly(Side.CLIENT) @Override - public BlockRenderLayer getBlockLayer() - { - return BlockRenderLayer.CUTOUT_MIPPED ; + public BlockRenderLayer getRenderLayer() { + return BlockRenderLayer.CUTOUT_MIPPED; } - @Override - public boolean shouldSideBeRendered(IBlockState blockState, - IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { - return true; - } + @Override + public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { + return true; + } - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } + @Override + public boolean isOpaqueCube(IBlockState state) { + return false; + } - @Override - public boolean isFoliage(IBlockAccess world, BlockPos pos) - { + @Override + public boolean isFoliage(IBlockAccess world, BlockPos pos) { return true; } - @Override - public EnumType getWoodType(int meta) { - return null; - } - - public WoodMaterial getWoodMaterial() { - return this.wood; - } - -@Override - public String getOreDictionaryName() { - return "leaves" + this.wood.getCapitalizedName(); - } -@Override -public IBlockState getStateFromMeta(int meta) -{ - return this.getDefaultState().withProperty(DECAYABLE, Boolean.valueOf((meta) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf(meta > 0)); -} + @Override + public EnumType getWoodType(int meta) { + return null; + } -/** - * Convert the BlockState into the correct metadata value - */ -@Override -public int getMetaFromState(IBlockState state) -{ - int i = 0; + public WoodMaterial getWoodMaterial() { + return this.wood; + } - if (!((Boolean)state.getValue(DECAYABLE)).booleanValue()) - { - i |= 1; + @Override + public String getOreDictionaryName() { + return "leaves" + this.wood.getCapitalizedName(); } - if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue()) - { - i |= 2; + @Override + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(DECAYABLE, meta == 0).withProperty(CHECK_DECAY, meta > 0); } - return i; -} -@Override -protected BlockStateContainer createBlockState() -{ - return new BlockStateContainer(this, new IProperty[] {CHECK_DECAY, DECAYABLE}); -} + /** + * Convert the BlockState into the correct metadata value + */ + @Override + public int getMetaFromState(IBlockState state) { + int i = 0; + if (!state.getValue(DECAYABLE)) { + i |= 1; + } -@Override -public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) -{ - return java.util.Arrays.asList(new ItemStack(this, 1)); -} + if (state.getValue(CHECK_DECAY)) { + i |= 2; + } + return i; + } + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, CHECK_DECAY, DECAYABLE); + } + @Override + public List onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { + return Arrays.asList(new ItemStack(this, 1)); + } } diff --git a/src/main/java/panda/gotwood/blocks/BlockWoodSapling.java b/src/main/java/panda/gotwood/blocks/BlockWoodSapling.java index fec2091..08d1bfa 100644 --- a/src/main/java/panda/gotwood/blocks/BlockWoodSapling.java +++ b/src/main/java/panda/gotwood/blocks/BlockWoodSapling.java @@ -1,130 +1,92 @@ package panda.gotwood.blocks; -import java.util.List; -import java.util.Random; - -import panda.gotwood.generation.WorldGenApple; -import panda.gotwood.generation.WorldGenBamboo; -import panda.gotwood.generation.WorldGenEbony; -import panda.gotwood.generation.WorldGenFir; -import panda.gotwood.generation.WorldGenMaple; -import panda.gotwood.generation.WorldGenPalm; -import panda.gotwood.generation.WorldGenPine; -import panda.gotwood.generation.WorldGenWillow; -import panda.gotwood.generation.WorldGenYew; -import panda.gotwood.registry.BlockRegistry; -import panda.gotwood.util.IOreDictionaryEntry; -import panda.gotwood.util.WoodMaterial; -import panda.gotwood.util.WoodMaterials; -import net.minecraft.block.Block; import net.minecraft.block.BlockBush; -import net.minecraft.block.BlockLeaves; -import net.minecraft.block.BlockOldLeaf; -import net.minecraft.block.BlockOldLog; -import net.minecraft.block.BlockPlanks; -import net.minecraft.block.BlockSapling; import net.minecraft.block.IGrowable; import net.minecraft.block.SoundType; -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.translation.I18n; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.IPlantable; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class BlockWoodSapling extends BlockBush implements IOreDictionaryEntry, IGrowable, IPlantable -{ - public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 1); - protected static final AxisAlignedBB SAPLING_AABB = new AxisAlignedBB(0.09999999403953552D, 0.0D, 0.09999999403953552D, 0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D); - - final WoodMaterial wood; - - public BlockWoodSapling(WoodMaterial wood) - { - this.wood = wood; - this.setDefaultState(this.blockState.getBaseState().withProperty(STAGE, Integer.valueOf(0))); - this.setTickRandomly(true); - this.setHardness(0.0F); - this.setSoundType(SoundType.PLANT); - this.setRegistryName(wood.getName()+"_sapling"); - - } - - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) - { - return SAPLING_AABB; - } - - @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) - { - return wood == WoodMaterials.bamboo? Item.getItemFromBlock(BlockRegistry.bamboo_sapling):Items.STICK; - } - - @Override - public int quantityDropped(Random random) - { - return random.nextBoolean() ? 2:1; - } - - - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) - { - if (!worldIn.isRemote) - { - super.updateTick(worldIn, pos, state, rand); - - if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) - { - this.grow(worldIn, pos, state, rand); - } - } - } - - - public void grow(World worldIn, BlockPos pos, IBlockState state, Random rand) - { - if (((Integer)state.getValue(STAGE)).intValue() == 0) - { - worldIn.setBlockState(pos, this.getStateFromMeta(1), 4); - } - else - { - this.generateTree(worldIn, pos, state, rand); - } - } +import net.minecraftforge.event.terraingen.TerrainGen; +import panda.gotwood.generation.*; +import panda.gotwood.registry.BlockRegistry; +import panda.gotwood.util.IOreDictionaryEntry; +import panda.gotwood.util.WoodMaterial; +import panda.gotwood.util.WoodMaterials; - //TODO - public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) - { - - if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos)) return; - - WorldGenerator worldgenerator = (WorldGenerator)( new WorldGenApple(true));///apple - int i = 0; - int j = 0; - boolean flag = false; +import java.util.Random; - switch (wood.getName()) - { +public class BlockWoodSapling extends BlockBush implements IOreDictionaryEntry, IGrowable, IPlantable { + + public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 1); + protected static final AxisAlignedBB SAPLING_AABB = new AxisAlignedBB(0.09999999403953552D, 0.0D, 0.09999999403953552D, 0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D); + final WoodMaterial wood; + + public BlockWoodSapling(WoodMaterial wood) { + this.wood = wood; + this.setDefaultState(this.blockState.getBaseState().withProperty(STAGE, 0)); + this.setTickRandomly(true); + this.setHardness(0.0F); + this.setSoundType(SoundType.PLANT); + this.setRegistryName(wood.getName() + "_sapling"); + } + + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + return SAPLING_AABB; + } + + @Override + public Item getItemDropped(IBlockState state, Random rand, int fortune) { + return wood == WoodMaterials.bamboo ? Item.getItemFromBlock(BlockRegistry.bamboo_sapling) : Items.STICK; + } + + @Override + public int quantityDropped(Random random) { + return random.nextBoolean() ? 2 : 1; + } + + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (!worldIn.isRemote) { + super.updateTick(worldIn, pos, state, rand); + + if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) { + this.grow(worldIn, pos, state, rand); + } + } + } + + + public void grow(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (state.getValue(STAGE) == 0) { + worldIn.setBlockState(pos, this.getStateFromMeta(1), 4); + } else { + this.generateTree(worldIn, pos, state, rand); + } + } + + //TODO + public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (!TerrainGen.saplingGrowTree(worldIn, rand, pos)) { + return; + } + + WorldGenerator worldgenerator = (new WorldGenApple(true)); + int i = 0; + int j = 0; + boolean flag = false; + switch (wood.getName()) { /*case SPRUCE: label114: - if (!flag) - { + if (!flag) { i = 0; j = 0; worldgenerator = new WorldGenTaiga2(true); @@ -135,140 +97,122 @@ public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random worldgenerator = new WorldGenBirchTree(true, false); break; */ - case "apple": - //already handled - worldgenerator = new WorldGenApple(true); + case "apple": + //already handled + worldgenerator = new WorldGenApple(true); break; - case "maple": - worldgenerator = new WorldGenMaple(true); + case "maple": + worldgenerator = new WorldGenMaple(true); break; - case "willow": - worldgenerator = new WorldGenWillow(); + case "willow": + worldgenerator = new WorldGenWillow(); break; - case "yew": - worldgenerator = new WorldGenYew(); + case "yew": + worldgenerator = new WorldGenYew(); break; - case "ebony": - worldgenerator = new WorldGenEbony(true); + case "ebony": + worldgenerator = new WorldGenEbony(true); break; - case "fir": - worldgenerator = new WorldGenFir(true); + case "fir": + worldgenerator = new WorldGenFir(true); break; - case "pine": - worldgenerator = new WorldGenPine(true); + case "pine": + worldgenerator = new WorldGenPine(true); break; - case "bamboo": - worldgenerator = new WorldGenBamboo(true); + case "bamboo": + worldgenerator = new WorldGenBamboo(true); break; - case "palm": - worldgenerator = new WorldGenPalm(true); + case "palm": + worldgenerator = new WorldGenPalm(true); break; - case "rubber": - //worldgenerator = new WorldGenPalm(true); + case "rubber": + //worldgenerator = new WorldGenPalm(true); break; - - - - } - - IBlockState iblockstate2 = Blocks.AIR.getDefaultState(); - - if (flag) - { - worldIn.setBlockState(pos.add(i, 0, j), iblockstate2, 4); - worldIn.setBlockState(pos.add(i + 1, 0, j), iblockstate2, 4); - worldIn.setBlockState(pos.add(i, 0, j + 1), iblockstate2, 4); - worldIn.setBlockState(pos.add(i + 1, 0, j + 1), iblockstate2, 4); - } - else - { - worldIn.setBlockState(pos, iblockstate2, 4); - } - - if (!worldgenerator.generate(worldIn, rand, pos.add(i, 0, j))) - { - if (flag) - { - worldIn.setBlockState(pos.add(i, 0, j), state, 4); - worldIn.setBlockState(pos.add(i + 1, 0, j), state, 4); - worldIn.setBlockState(pos.add(i, 0, j + 1), state, 4); - worldIn.setBlockState(pos.add(i + 1, 0, j + 1), state, 4); - } - else - { - worldIn.setBlockState(pos, state, 4); - } - } - } - - - /** - * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It - * returns the metadata of the dropped item based on the old metadata of the block. - */ - public int damageDropped(IBlockState state) - { - return 0; - } - - @Override - public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { - return wood.getName()=="palm"?EnumPlantType.Desert:EnumPlantType.Plains; - } - - @Override - public IBlockState getPlant(IBlockAccess world, BlockPos pos) { - IBlockState state = world.getBlockState(pos); - if (state.getBlock() != this) return getDefaultState(); - return state; - } - - /** - * Whether this IGrowable can grow - */ - public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) - { - return true; - } - - public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) - { - return true;//(double)worldIn.rand.nextFloat() < 0.45D - } - - public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) - { - this.grow(worldIn, pos, state, rand); - } - - /** - * Convert the given metadata into a BlockState for this Block - */ - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(STAGE, Integer.valueOf(meta)); - } - - /** - * Convert the BlockState into the correct metadata value - */ - public int getMetaFromState(IBlockState state) - { - return ((Integer)state.getValue(STAGE)).intValue(); - } - - protected BlockStateContainer createBlockState() - { - return new BlockStateContainer(this, new IProperty[] {STAGE}); - } - - public WoodMaterial getWoodMaterial() { - return this.wood; - } - - @Override - public String getOreDictionaryName() { - return "sapling" + this.wood.getCapitalizedName(); - } - + } + + IBlockState iblockstate2 = Blocks.AIR.getDefaultState(); + if (flag) { + worldIn.setBlockState(pos.add(i, 0, j), iblockstate2, 4); + worldIn.setBlockState(pos.add(i + 1, 0, j), iblockstate2, 4); + worldIn.setBlockState(pos.add(i, 0, j + 1), iblockstate2, 4); + worldIn.setBlockState(pos.add(i + 1, 0, j + 1), iblockstate2, 4); + } else { + worldIn.setBlockState(pos, iblockstate2, 4); + } + + if (!worldgenerator.generate(worldIn, rand, pos.add(i, 0, j))) { + if (flag) { + worldIn.setBlockState(pos.add(i, 0, j), state, 4); + worldIn.setBlockState(pos.add(i + 1, 0, j), state, 4); + worldIn.setBlockState(pos.add(i, 0, j + 1), state, 4); + worldIn.setBlockState(pos.add(i + 1, 0, j + 1), state, 4); + } else { + worldIn.setBlockState(pos, state, 4); + } + } + } + + /** + * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It + * returns the metadata of the dropped item based on the old metadata of the block. + */ + public int damageDropped(IBlockState state) { + return 0; + } + + @Override + public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { + return wood.getName().equals("palm") ? EnumPlantType.Desert : EnumPlantType.Plains; + } + + @Override + public IBlockState getPlant(IBlockAccess world, BlockPos pos) { + IBlockState state = world.getBlockState(pos); + if (state.getBlock() != this) { + return getDefaultState(); + } + return state; + } + + /** + * Whether this IGrowable can grow + */ + public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) { + return true; + } + + public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) { + return true;//(double)worldIn.rand.nextFloat() < 0.45D + } + + public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { + this.grow(worldIn, pos, state, rand); + } + + /** + * Convert the given metadata into a BlockState for this Block + */ + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(STAGE, meta); + } + + /** + * Convert the BlockState into the correct metadata value + */ + public int getMetaFromState(IBlockState state) { + return (state.getValue(STAGE)); + } + + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, STAGE); + } + + public WoodMaterial getWoodMaterial() { + return this.wood; + } + + @Override + public String getOreDictionaryName() { + return "sapling" + this.wood.getCapitalizedName(); + } } diff --git a/src/main/java/panda/gotwood/blocks/SappyLog.java b/src/main/java/panda/gotwood/blocks/SappyLog.java index b3f96cf..34dc6c7 100644 --- a/src/main/java/panda/gotwood/blocks/SappyLog.java +++ b/src/main/java/panda/gotwood/blocks/SappyLog.java @@ -1,7 +1,6 @@ package panda.gotwood.blocks; import net.minecraft.block.BlockLog; -import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; @@ -12,105 +11,88 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import panda.gotwood.block.BlockWoodLog; import panda.gotwood.registry.ItemRegistry; -import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; -import panda.gotwood.block.BlockWoodLog; public class SappyLog extends BlockWoodLog { - public static final PropertyInteger GENERATED = PropertyInteger.create("generated", 0, 1); - public SappyLog(WoodMaterial wood) { - super(wood); - this.setDefaultState(this.blockState.getBaseState().withProperty(GENERATED, 0).withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); - - } - - @Override - protected BlockStateContainer createBlockState() - { - return new BlockStateContainer(this, new IProperty[] {LOG_AXIS,GENERATED}); - } - - public IBlockState getStateFromMeta(int meta) - { - IBlockState iblockstate = this.getDefaultState(); - - switch (meta) - { - case 0: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y).withProperty(GENERATED, 0); - break; - case 1: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X).withProperty(GENERATED, 0); - break; - case 2: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z).withProperty(GENERATED, 0); - break; - case 3: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y).withProperty(GENERATED, 1); - break; - case 4: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X).withProperty(GENERATED, 1); - break; - case 5: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z).withProperty(GENERATED, 1); - break; - default: - iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE).withProperty(GENERATED, 0); - } + public static final PropertyInteger GENERATED = PropertyInteger.create("generated", 0, 1); - return iblockstate; - } + public SappyLog(WoodMaterial wood) { + super(wood); + this.setDefaultState(this.blockState.getBaseState().withProperty(GENERATED, 0).withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); + } - /** - * Convert the BlockState into the correct metadata value - */ - @SuppressWarnings("incomplete-switch") - public int getMetaFromState(IBlockState state) - { - int i = 0; + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, LOG_AXIS, GENERATED); + } - switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS)) - { - case X: - i |= 0; - break; - case Z: - i |= 1; - break; - case NONE: - i |= 2; - } - - int j = state.getValue(GENERATED); - i += j*3; + public IBlockState getStateFromMeta(int meta) { + IBlockState iblockstate = this.getDefaultState(); + switch (meta) { + case 0: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y).withProperty(GENERATED, 0); + break; + case 1: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X).withProperty(GENERATED, 0); + break; + case 2: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z).withProperty(GENERATED, 0); + break; + case 3: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y).withProperty(GENERATED, 1); + break; + case 4: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X).withProperty(GENERATED, 1); + break; + case 5: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z).withProperty(GENERATED, 1); + break; + default: + iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE).withProperty(GENERATED, 0); + } + return iblockstate; + } - return i; - } + /** + * Convert the BlockState into the correct metadata value + */ + @SuppressWarnings("incomplete-switch") + public int getMetaFromState(IBlockState state) { + int i = 0; + switch (state.getValue(LOG_AXIS)) { + case X: + i |= 0; + break; + case Z: + i |= 1; + break; + case NONE: + i |= 2; + } - @Override //&& state.getValue(GENERATED)==1 - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, - EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { - if(heldItem == null){ - return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ); - } - - if( !worldIn.isRemote && heldItem.getItem() == Items.BOWL && side != EnumFacing.UP && side != EnumFacing.DOWN){ - - ItemStack itemstack1 = new ItemStack(ItemRegistry.rubber_sap); + int j = state.getValue(GENERATED); + i += j * 3; + return i; + } - if (--heldItem.stackSize == 0) - { - playerIn.setHeldItem(hand, itemstack1); - } - else if (!playerIn.inventory.addItemStackToInventory(itemstack1)) - { - playerIn.dropItem(itemstack1, false); - } - } - return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ); - - } + @Override // && state.getValue(GENERATED) == 1 + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + ItemStack heldItem = playerIn.getHeldItem(hand); + if (heldItem == null) { + return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ); + } + if (!worldIn.isRemote && heldItem.getItem() == Items.BOWL && side != EnumFacing.UP && side != EnumFacing.DOWN) { + ItemStack itemstack1 = new ItemStack(ItemRegistry.rubber_sap); + if (heldItem.getCount() == 0) { + playerIn.setHeldItem(hand, itemstack1); + } else if (!playerIn.inventory.addItemStackToInventory(itemstack1)) { + playerIn.dropItem(itemstack1, false); + } + } + return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ); + } } diff --git a/src/main/java/panda/gotwood/blocks/SpecialFire.java b/src/main/java/panda/gotwood/blocks/SpecialFire.java index f1eeea4..bda6bf7 100644 --- a/src/main/java/panda/gotwood/blocks/SpecialFire.java +++ b/src/main/java/panda/gotwood/blocks/SpecialFire.java @@ -1,26 +1,8 @@ package panda.gotwood.blocks; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Random; - -import javax.annotation.Nullable; - -import panda.gotwood.registry.BlockRegistry; -import panda.gotwood.registry.ItemRegistry; -import panda.gotwood.util.IFireDrops; - import com.google.common.collect.Maps; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockFire; -import net.minecraft.block.BlockLog; -import net.minecraft.block.BlockTNT; -import net.minecraft.block.SoundType; +import net.minecraft.block.*; import net.minecraft.block.material.MapColor; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; @@ -30,7 +12,6 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; @@ -40,68 +21,42 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import panda.gotwood.registry.BlockRegistry; +import panda.gotwood.registry.ItemRegistry; +import panda.gotwood.util.IFireDrops; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Random; public class SpecialFire extends BlockFire { - public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15); + + public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15); public static final PropertyBool NORTH = PropertyBool.create("north"); public static final PropertyBool EAST = PropertyBool.create("east"); public static final PropertyBool SOUTH = PropertyBool.create("south"); public static final PropertyBool WEST = PropertyBool.create("west"); public static final PropertyBool UPPER = PropertyBool.create("up"); - private final Map encouragements = Maps.newIdentityHashMap(); - private final Map flammabilities = Maps.newIdentityHashMap(); - - /** - * Get the actual Block state of this Block at the given position. This applies properties not visible in the - * metadata, such as fence connections. - */ - public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) - { - if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) && !((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.down(), EnumFacing.UP)) - { - return state.withProperty(NORTH, this.canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH)) - .withProperty(EAST, this.canCatchFire(worldIn, pos.east(), EnumFacing.WEST)) - .withProperty(SOUTH, this.canCatchFire(worldIn, pos.south(), EnumFacing.NORTH)) - .withProperty(WEST, this.canCatchFire(worldIn, pos.west(), EnumFacing.EAST)) - .withProperty(UPPER, this.canCatchFire(worldIn, pos.up(), EnumFacing.DOWN)); - } - return this.getDefaultState(); - } + private final Map encouragements = Maps.newIdentityHashMap(); + private final Map flammabilities = Maps.newIdentityHashMap(); - public SpecialFire() - { - this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)).withProperty(UPPER, Boolean.valueOf(false))); + public SpecialFire() { + this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, 0).withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false).withProperty(UPPER, false)); this.setTickRandomly(true); this.setHardness(0.0F); this.setLightLevel(1.0F); this.setSoundType(SoundType.CLOTH); this.disableStats(); this.setRegistryName("fire"); - } - @Override - public void onEntityCollidedWithBlock(World worldIn, BlockPos pos,IBlockState state, Entity entityIn) { - super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn); - - - boolean flag1 = entityIn.isWet(); - - - if (!flag1) - { - entityIn.setFire(8); - } - - } - - public static void init() - { - ((BlockFire) BlockRegistry.specialfire).setFireInfo(Blocks.PLANKS, 5, 20); - ((BlockFire) BlockRegistry.specialfire).setFireInfo(Blocks.DOUBLE_WOODEN_SLAB, 5, 20); + public static void init() { + ((BlockFire) BlockRegistry.specialfire).setFireInfo(Blocks.PLANKS, 5, 20); + ((BlockFire) BlockRegistry.specialfire).setFireInfo(Blocks.DOUBLE_WOODEN_SLAB, 5, 20); ((BlockFire) BlockRegistry.specialfire).setFireInfo(Blocks.WOODEN_SLAB, 5, 20); ((BlockFire) BlockRegistry.specialfire).setFireInfo(Blocks.OAK_FENCE_GATE, 5, 20); ((BlockFire) BlockRegistry.specialfire).setFireInfo(Blocks.SPRUCE_FENCE_GATE, 5, 20); @@ -137,95 +92,97 @@ public static void init() ((BlockFire) BlockRegistry.specialfire).setFireInfo(Blocks.COAL_BLOCK, 5, 5); ((BlockFire) BlockRegistry.specialfire).setFireInfo(Blocks.HAY_BLOCK, 60, 20); ((BlockFire) BlockRegistry.specialfire).setFireInfo(Blocks.CARPET, 60, 20); - // ReflectionHelper.getPrivateValue(BlockFire.class, Blocks.FIRE, "encouragements"); + // ReflectionHelper.getPrivateValue(BlockFire.class, Blocks.FIRE, "encouragements"); //ReflectionHelper.getPrivateValue(BlockFire.class, Blocks.FIRE, "flammabilities"); } - public void setFireInfo(Block blockIn, int encouragement, int flammability) - { + /** + * Get the actual Block state of this Block at the given position. This applies properties not visible in the + * metadata, such as fence connections. + */ + public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { + if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) && !((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.down(), EnumFacing.UP)) { + return state.withProperty(NORTH, this.canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH)) + .withProperty(EAST, this.canCatchFire(worldIn, pos.east(), EnumFacing.WEST)) + .withProperty(SOUTH, this.canCatchFire(worldIn, pos.south(), EnumFacing.NORTH)) + .withProperty(WEST, this.canCatchFire(worldIn, pos.west(), EnumFacing.EAST)) + .withProperty(UPPER, this.canCatchFire(worldIn, pos.up(), EnumFacing.DOWN)); + } + return this.getDefaultState(); + } + + @Override + public void onEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { + super.onEntityCollision(worldIn, pos, state, entityIn); + boolean flag1 = entityIn.isWet(); + if (!flag1) { + entityIn.setFire(8); + } + } + + public void setFireInfo(Block blockIn, int encouragement, int flammability) { if (blockIn == Blocks.AIR) throw new IllegalArgumentException("Tried to set air on fire... This is bad."); - this.encouragements.put(blockIn, Integer.valueOf(encouragement)); - this.flammabilities.put(blockIn, Integer.valueOf(flammability)); + this.encouragements.put(blockIn, encouragement); + this.flammabilities.put(blockIn, flammability); } @Nullable - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) - { + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { return NULL_AABB; } /** * Used to determine ambient occlusion and culling when rebuilding chunks for render */ - public boolean isOpaqueCube(IBlockState state) - { + public boolean isOpaqueCube(IBlockState state) { return false; } - public boolean isFullCube(IBlockState state) - { + public boolean isFullCube(IBlockState state) { return false; } /** * Returns the quantity of items to drop on block destruction. */ - public int quantityDropped(Random random) - { + public int quantityDropped(Random random) { return 0; } /** * How many world ticks before ticking */ - public int tickRate(World worldIn) - { + public int tickRate(World worldIn) { return 30; } - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) - { - if (worldIn.getGameRules().getBoolean("doFireTick")) - { - - if (!this.canPlaceBlockAt(worldIn, pos)) - { + public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { + if (worldIn.getGameRules().getBoolean("doFireTick")) { + if (!this.canPlaceBlockAt(worldIn, pos)) { worldIn.setBlockToAir(pos); } Block block = worldIn.getBlockState(pos.down()).getBlock(); boolean flag = block.isFireSource(worldIn, pos.down(), EnumFacing.UP); - - int i = ((Integer)state.getValue(AGE)).intValue(); - - if (!flag && worldIn.isRaining() && this.canDie(worldIn, pos) && rand.nextFloat() < 0.2F + (float)i * 0.03F) - { + int i = state.getValue(AGE); + if (!flag && worldIn.isRaining() && this.canDie(worldIn, pos) && rand.nextFloat() < 0.2F + (float) i * 0.03F) { worldIn.setBlockToAir(pos); - } - else - { - if (i < 15) - { - state = state.withProperty(AGE, Integer.valueOf(i + rand.nextInt(3) / 2)); + } else { + if (i < 15) { + state = state.withProperty(AGE, i + rand.nextInt(3) / 2); worldIn.setBlockState(pos, state, 4); } worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + rand.nextInt(10)); - - if (!flag) - { - if (!this.canNeighborCatchFire(worldIn, pos)) - { - if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) || i > 3) - { + if (!flag) { + if (!this.canNeighborCatchFire(worldIn, pos)) { + if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) || i > 3) { worldIn.setBlockToAir(pos); } - return; } - if (!this.canCatchFire(worldIn, pos.down(), EnumFacing.UP) && i == 15 && rand.nextInt(4) == 0) - { + if (!this.canCatchFire(worldIn, pos.down(), EnumFacing.UP) && i == 15 && rand.nextInt(4) == 0) { worldIn.setBlockToAir(pos); return; } @@ -233,9 +190,7 @@ public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random ra boolean flag1 = worldIn.isBlockinHighHumidity(pos); int j = 0; - - if (flag1) - { + if (flag1) { j = -50; } @@ -245,44 +200,31 @@ public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random ra this.tryCatchFire(worldIn, pos.up(), 250 + j, rand, i, EnumFacing.DOWN); this.tryCatchFire(worldIn, pos.north(), 300 + j, rand, i, EnumFacing.SOUTH); this.tryCatchFire(worldIn, pos.south(), 300 + j, rand, i, EnumFacing.NORTH); - - for (int k = -1; k <= 1; ++k) - { - for (int l = -1; l <= 1; ++l) - { - for (int i1 = -1; i1 <= 4; ++i1) - { - if (k != 0 || i1 != 0 || l != 0) - { + for (int k = -1; k <= 1; ++k) { + for (int l = -1; l <= 1; ++l) { + for (int i1 = -1; i1 <= 4; ++i1) { + if (k != 0 || i1 != 0 || l != 0) { int j1 = 100; - if (i1 > 1) - { + if (i1 > 1) { j1 += (i1 - 1) * 100; } BlockPos blockpos = pos.add(k, i1, l); int k1 = this.getNeighborEncouragement(worldIn, blockpos); - - if (k1 > 0) - { - int l1 = (k1 + 40 + worldIn.getDifficulty().getDifficultyId() * 7) / (i + 30); - - if (flag1) - { + if (k1 > 0) { + int l1 = (k1 + 40 + worldIn.getDifficulty().getId() * 7) / (i + 30); + if (flag1) { l1 /= 2; } - if (l1 > 0 && rand.nextInt(j1) <= l1 && (!worldIn.isRaining() || !this.canDie(worldIn, blockpos))) - { + if (l1 > 0 && rand.nextInt(j1) <= l1 && (!worldIn.isRaining() || !this.canDie(worldIn, blockpos))) { int i2 = i + rand.nextInt(5) / 4; - - if (i2 > 15) - { + if (i2 > 15) { i2 = 15; } - worldIn.setBlockState(blockpos, state.withProperty(AGE, Integer.valueOf(i2)), 3); + worldIn.setBlockState(blockpos, state.withProperty(AGE, i2), 3); } } } @@ -293,118 +235,87 @@ public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random ra } } - protected boolean canDie(World worldIn, BlockPos pos) - { + protected boolean canDie(World worldIn, BlockPos pos) { return worldIn.isRainingAt(pos) || worldIn.isRainingAt(pos.west()) || worldIn.isRainingAt(pos.east()) || worldIn.isRainingAt(pos.north()) || worldIn.isRainingAt(pos.south()); } - public boolean requiresUpdates() - { + public boolean requiresUpdates() { return false; } @Deprecated // Use Block.getFlammability - public int getFlammability(Block blockIn) - { - Integer integer = (Integer)this.flammabilities.get(blockIn); - return integer == null ? 0 : integer.intValue(); + public int getFlammability(Block blockIn) { + Integer integer = this.flammabilities.get(blockIn); + return integer == null ? 0 : integer; } @Deprecated // Use Block.getFlammability - public int getEncouragement(Block blockIn) - { - Integer integer = (Integer)this.encouragements.get(blockIn); - return integer == null ? 0 : integer.intValue(); + public int getEncouragement(Block blockIn) { + Integer integer = this.encouragements.get(blockIn); + return integer == null ? 0 : integer; } @Deprecated // Use tryCatchFire with face below - private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age) - { + private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age) { this.tryCatchFire(worldIn, pos, chance, random, age, EnumFacing.UP); } - private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face) - { + private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face) { int i = worldIn.getBlockState(pos).getBlock().getFlammability(worldIn, pos, face); - - if (random.nextInt(chance) < i) - { + if (random.nextInt(chance) < i) { IBlockState iblockstate = worldIn.getBlockState(pos); - - if (random.nextInt(age + 10) < 5 && !worldIn.isRainingAt(pos)) - { + if (random.nextInt(age + 10) < 5 && !worldIn.isRainingAt(pos)) { int j = age + random.nextInt(5) / 4; - - if (j > 15) - { + if (j > 15) { j = 15; } - worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3); - } - else - { - + worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, j), 3); + } else { worldIn.setBlockToAir(pos); Block block = iblockstate.getBlock(); - if( block instanceof BlockLog && !(block instanceof IFireDrops) ){ - ItemStack burnitem = worldIn.rand.nextBoolean()? new ItemStack(ItemRegistry.ash): new ItemStack(Items.COAL,1,1); - EntityItem entityitem = new EntityItem(worldIn, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, burnitem); - - worldIn.spawnEntityInWorld(entityitem); - }else - if (block instanceof IFireDrops) { - IFireDrops fireDrops = (IFireDrops) block; - if (fireDrops.hasFireDrops()){ - ///use NonNullList for 1.11 - //also add an event that allows the modification of that same list. - List drops = new ArrayList(); - fireDrops.addFireDrops(drops, random); - for (ItemStack drop : drops){ - EntityItem entityitem = new EntityItem(worldIn, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, drop); - worldIn.spawnEntityInWorld(entityitem); - } - - - } - } + if (block instanceof BlockLog && !(block instanceof IFireDrops)) { + ItemStack burnitem = worldIn.rand.nextBoolean() ? new ItemStack(ItemRegistry.ash) : new ItemStack(Items.COAL, 1, 1); + EntityItem entityitem = new EntityItem(worldIn, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, burnitem); + worldIn.spawnEntity(entityitem); + } else if (block instanceof IFireDrops) { + IFireDrops fireDrops = (IFireDrops) block; + if (fireDrops.hasFireDrops()) { + ///use NonNullList for 1.11 + //also add an event that allows the modification of that same list. + List drops = new ArrayList<>(); + fireDrops.addFireDrops(drops, random); + for (ItemStack drop : drops) { + EntityItem entityitem = new EntityItem(worldIn, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, drop); + worldIn.spawnEntity(entityitem); + } + } + } } - if (iblockstate.getBlock() == Blocks.TNT) - { - Blocks.TNT.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true))); + if (iblockstate.getBlock() == Blocks.TNT) { + Blocks.TNT.onPlayerDestroy(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, true)); } } } - private boolean canNeighborCatchFire(World worldIn, BlockPos pos) - { - for (EnumFacing enumfacing : EnumFacing.values()) - { - if (this.canCatchFire(worldIn, pos.offset(enumfacing), enumfacing.getOpposite())) - { + private boolean canNeighborCatchFire(World worldIn, BlockPos pos) { + for (EnumFacing enumfacing : EnumFacing.values()) { + if (this.canCatchFire(worldIn, pos.offset(enumfacing), enumfacing.getOpposite())) { return true; } } - return false; } - private int getNeighborEncouragement(World worldIn, BlockPos pos) - { - if (!worldIn.isAirBlock(pos)) - { + private int getNeighborEncouragement(World worldIn, BlockPos pos) { + if (!worldIn.isAirBlock(pos)) { return 0; - } - else - { + } else { int i = 0; - - for (EnumFacing enumfacing : EnumFacing.values()) - { + for (EnumFacing enumfacing : EnumFacing.values()) { i = Math.max(worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getFireSpreadSpeed(worldIn, pos.offset(enumfacing), enumfacing.getOpposite()), i); } - return i; } } @@ -413,23 +324,20 @@ private int getNeighborEncouragement(World worldIn, BlockPos pos) * Returns if this block is collidable. Only used by fire, although stairs return that of the block that the stair * is made of (though nobody's going to make fire stairs, right?) */ - public boolean isCollidable() - { + public boolean isCollidable() { return false; } /** * Checks if the block can be caught on fire */ - // Use canCatchFire with face sensitive version below - public boolean canCatchFire(IBlockAccess worldIn, BlockPos pos) - { + // Use canCatchFire with face sensitive version below + public boolean canCatchFire(IBlockAccess worldIn, BlockPos pos) { return canCatchFire(worldIn, pos, EnumFacing.UP); } - public boolean canPlaceBlockAt(World worldIn, BlockPos pos) - { - return worldIn.getBlockState(pos.down()).isFullyOpaque() || this.canNeighborCatchFire(worldIn, pos); + public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { + return worldIn.getBlockState(pos.down()).isOpaqueCube() || this.canNeighborCatchFire(worldIn, pos); } /** @@ -437,102 +345,79 @@ public boolean canPlaceBlockAt(World worldIn, BlockPos pos) * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid * block, etc. */ - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) - { - if (!worldIn.getBlockState(pos.down()).isFullyOpaque() && !this.canNeighborCatchFire(worldIn, pos)) - { + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { + if (!worldIn.getBlockState(pos.down()).isOpaqueCube() && !this.canNeighborCatchFire(worldIn, pos)) { worldIn.setBlockToAir(pos); } } - public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) - { - if (worldIn.provider.getDimensionType().getId() > 0 || !Blocks.PORTAL.trySpawnPortal(worldIn, pos)) - { - if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos, EnumFacing.UP) && !this.canNeighborCatchFire(worldIn, pos)) - { + public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { + if (worldIn.provider.getDimensionType().getId() > 0 || !Blocks.PORTAL.trySpawnPortal(worldIn, pos)) { + if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos, EnumFacing.UP) && !this.canNeighborCatchFire(worldIn, pos)) { worldIn.setBlockToAir(pos); - } - else - { + } else { worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + worldIn.rand.nextInt(10)); } } } @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) - { - if (rand.nextInt(24) == 0) - { - worldIn.playSound((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F + rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false); + public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { + if (rand.nextInt(24) == 0) { + worldIn.playSound(((float) pos.getX() + 0.5F), (double) ((float) pos.getY() + 0.5F), ((float) pos.getZ() + 0.5F), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F + rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false); } - if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) && !((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.down(), EnumFacing.UP)) - { - if (((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.west(), EnumFacing.EAST)) - { - for (int j = 0; j < 2; ++j) - { - double d3 = (double)pos.getX() + rand.nextDouble() * 0.10000000149011612D; - double d8 = (double)pos.getY() + rand.nextDouble(); - double d13 = (double)pos.getZ() + rand.nextDouble(); - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d3, d8, d13, 0.0D, 0.0D, 0.0D, new int[0]); + if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn, pos.down(), EnumFacing.UP) && !((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.down(), EnumFacing.UP)) { + if (((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.west(), EnumFacing.EAST)) { + for (int j = 0; j < 2; ++j) { + double d3 = (double) pos.getX() + rand.nextDouble() * 0.10000000149011612D; + double d8 = (double) pos.getY() + rand.nextDouble(); + double d13 = (double) pos.getZ() + rand.nextDouble(); + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d3, d8, d13, 0.0D, 0.0D, 0.0D, 0); } } - if (((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.east(), EnumFacing.WEST)) - { - for (int k = 0; k < 2; ++k) - { - double d4 = (double)(pos.getX() + 1) - rand.nextDouble() * 0.10000000149011612D; - double d9 = (double)pos.getY() + rand.nextDouble(); - double d14 = (double)pos.getZ() + rand.nextDouble(); - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d4, d9, d14, 0.0D, 0.0D, 0.0D, new int[0]); + if (((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.east(), EnumFacing.WEST)) { + for (int k = 0; k < 2; ++k) { + double d4 = (double) (pos.getX() + 1) - rand.nextDouble() * 0.10000000149011612D; + double d9 = (double) pos.getY() + rand.nextDouble(); + double d14 = (double) pos.getZ() + rand.nextDouble(); + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d4, d9, d14, 0.0D, 0.0D, 0.0D, 0); } } - if (((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH)) - { - for (int l = 0; l < 2; ++l) - { - double d5 = (double)pos.getX() + rand.nextDouble(); - double d10 = (double)pos.getY() + rand.nextDouble(); - double d15 = (double)pos.getZ() + rand.nextDouble() * 0.10000000149011612D; - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d5, d10, d15, 0.0D, 0.0D, 0.0D, new int[0]); + if (((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.north(), EnumFacing.SOUTH)) { + for (int l = 0; l < 2; ++l) { + double d5 = (double) pos.getX() + rand.nextDouble(); + double d10 = (double) pos.getY() + rand.nextDouble(); + double d15 = (double) pos.getZ() + rand.nextDouble() * 0.10000000149011612D; + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d5, d10, d15, 0.0D, 0.0D, 0.0D, 0); } } - if (((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.south(), EnumFacing.NORTH)) - { - for (int i1 = 0; i1 < 2; ++i1) - { - double d6 = (double)pos.getX() + rand.nextDouble(); - double d11 = (double)pos.getY() + rand.nextDouble(); - double d16 = (double)(pos.getZ() + 1) - rand.nextDouble() * 0.10000000149011612D; - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d6, d11, d16, 0.0D, 0.0D, 0.0D, new int[0]); + if (((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.south(), EnumFacing.NORTH)) { + for (int i1 = 0; i1 < 2; ++i1) { + double d6 = (double) pos.getX() + rand.nextDouble(); + double d11 = (double) pos.getY() + rand.nextDouble(); + double d16 = (double) (pos.getZ() + 1) - rand.nextDouble() * 0.10000000149011612D; + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d6, d11, d16, 0.0D, 0.0D, 0.0D, 0); } } - if (((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.up(), EnumFacing.DOWN)) - { - for (int j1 = 0; j1 < 2; ++j1) - { - double d7 = (double)pos.getX() + rand.nextDouble(); - double d12 = (double)(pos.getY() + 1) - rand.nextDouble() * 0.10000000149011612D; - double d17 = (double)pos.getZ() + rand.nextDouble(); - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d7, d12, d17, 0.0D, 0.0D, 0.0D, new int[0]); + if (((BlockFire) BlockRegistry.specialfire).canCatchFire(worldIn, pos.up(), EnumFacing.DOWN)) { + for (int j1 = 0; j1 < 2; ++j1) { + double d7 = (double) pos.getX() + rand.nextDouble(); + double d12 = (double) (pos.getY() + 1) - rand.nextDouble() * 0.10000000149011612D; + double d17 = (double) pos.getZ() + rand.nextDouble(); + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d7, d12, d17, 0.0D, 0.0D, 0.0D, 0); } } - } - else - { - for (int i = 0; i < 3; ++i) - { - double d0 = (double)pos.getX() + rand.nextDouble(); - double d1 = (double)pos.getY() + rand.nextDouble() * 0.5D + 0.5D; - double d2 = (double)pos.getZ() + rand.nextDouble(); - worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]); + } else { + for (int i = 0; i < 3; ++i) { + double d0 = (double) pos.getX() + rand.nextDouble(); + double d1 = (double) pos.getY() + rand.nextDouble() * 0.5D + 0.5D; + double d2 = (double) pos.getZ() + rand.nextDouble(); + worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, 0); } } } @@ -540,40 +425,34 @@ public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, /** * Get the MapColor for this Block and the given BlockState */ - public MapColor getMapColor(IBlockState state) - { + public MapColor getMapColor(IBlockState state) { return MapColor.TNT; } @SideOnly(Side.CLIENT) - public BlockRenderLayer getBlockLayer() - { + public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } /** * Convert the given metadata into a BlockState for this Block */ - public IBlockState getStateFromMeta(int meta) - { - return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta)); + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(AGE, meta); } /** * Convert the BlockState into the correct metadata value */ - public int getMetaFromState(IBlockState state) - { - return ((Integer)state.getValue(AGE)).intValue(); + public int getMetaFromState(IBlockState state) { + return state.getValue(AGE); } - protected BlockStateContainer createBlockState() - { - return new BlockStateContainer(this, new IProperty[] {AGE, NORTH, EAST, SOUTH, WEST, UPPER}); + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, AGE, NORTH, EAST, SOUTH, WEST, UPPER); } - - public boolean canCatchFire(IBlockAccess world, BlockPos pos, EnumFacing face) - { + + public boolean canCatchFire(IBlockAccess world, BlockPos pos, EnumFacing face) { return world.getBlockState(pos).getBlock().isFlammable(world, pos, face); } } diff --git a/src/main/java/panda/gotwood/events/BlockBreakHandler.java b/src/main/java/panda/gotwood/events/BlockBreakHandler.java index f4abe0a..4593c38 100644 --- a/src/main/java/panda/gotwood/events/BlockBreakHandler.java +++ b/src/main/java/panda/gotwood/events/BlockBreakHandler.java @@ -11,113 +11,118 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - import panda.gotwood.registry.ItemRegistry; public final class BlockBreakHandler { - @SubscribeEvent - public void onDrops(BlockEvent.HarvestDropsEvent event) { - Block theblock = event.getState().getBlock(); - int fortune = event.getFortuneLevel(); - if (theblock instanceof BlockSapling || theblock instanceof BlockLeaves) { - for (int i = 0; i < event.getDrops().size(); i++) { - if (Block.getBlockFromItem(event.getDrops().get(i).getItem()) instanceof BlockBush && ((theblock == Blocks.LEAVES) || (theblock == Blocks.LEAVES2))) { - event.getDrops().remove(i); - } + @SubscribeEvent + public void onDrops(BlockEvent.HarvestDropsEvent event) { + Block theblock = event.getState().getBlock(); + int fortune = event.getFortuneLevel(); + if (theblock instanceof BlockSapling || theblock instanceof BlockLeaves) { + for (int i = 0; i < event.getDrops().size(); i++) { + if (Block.getBlockFromItem(event.getDrops().get(i).getItem()) instanceof BlockBush && ((theblock == Blocks.LEAVES) || (theblock == Blocks.LEAVES2))) { + event.getDrops().remove(i); + } + + if (theblock instanceof BlockSapling) { + if (event.getHarvester() != net.minecraftforge.common.util.FakePlayerFactory.getMinecraft((net.minecraft.world.WorldServer) event.getWorld())) { + if (event.getHarvester() != null) { + if (!event.getHarvester().getHeldItemMainhand().isEmpty()) { + if ((!(event.getHarvester().getHeldItemMainhand().getItem() instanceof ItemShears) && ConfigurationHandler.retrieveSaplingsMode == 1) || ConfigurationHandler.retrieveSaplingsMode == 0) { + if (Block.getBlockFromItem(event.getDrops().get(i).getItem()) instanceof BlockBush) { + event.getDrops().remove(i); + } + event.getDrops().add(new ItemStack(Items.STICK, event.getWorld().rand.nextBoolean() ? 2 : 1)); + } + } + } + } else { + if (Block.getBlockFromItem(event.getDrops().get(i).getItem()) instanceof BlockBush && (ConfigurationHandler.retrieveSaplingsMode == 1 || ConfigurationHandler.retrieveSaplingsMode == 0)) { + event.getDrops().remove(i); + } + event.getDrops().add(new ItemStack(Items.STICK, event.getWorld().rand.nextBoolean() ? 2 : 1)); + } + } + } - if (theblock instanceof BlockSapling) { - if (event.getHarvester() != net.minecraftforge.common.util.FakePlayerFactory.getMinecraft((net.minecraft.world.WorldServer) event.getWorld())) { - if (event.getHarvester() != null) { - if (!event.getHarvester().getHeldItemMainhand().isEmpty()) { - if ((!(event.getHarvester().getHeldItemMainhand().getItem() instanceof ItemShears) && ConfigurationHandler.retrieveSaplingsMode == 1) || ConfigurationHandler.retrieveSaplingsMode == 0) { - if (Block.getBlockFromItem(event.getDrops().get(i).getItem()) instanceof BlockBush) { - event.getDrops().remove(i); - } - event.getDrops().add(new ItemStack(Items.STICK, event.getWorld().rand.nextBoolean() ? 2 : 1)); - } - } - } - } else { - if (Block.getBlockFromItem(event.getDrops().get(i).getItem()) instanceof BlockBush && (ConfigurationHandler.retrieveSaplingsMode == 1 || ConfigurationHandler.retrieveSaplingsMode == 0)) { - event.getDrops().remove(i); - } - event.getDrops().add(new ItemStack(Items.STICK, event.getWorld().rand.nextBoolean() ? 2 : 1)); - } - } - } + //TODO compact + if (theblock == Blocks.LEAVES) { + int s = event.getDrops().size(); + for (int i = 0; i < s; i++) { + if (event.getDrops().get(i).getItem() == Items.APPLE && !ConfigurationHandler.removeAppleDrops) { + event.getDrops().remove(i); + } + } - //TODO compact - if (theblock == Blocks.LEAVES) { - int s = event.getDrops().size(); - for (int i = 0; i < s; i++) { - if (event.getDrops().get(i).getItem() == Items.APPLE && !ConfigurationHandler.removeAppleDrops) { - event.getDrops().remove(i); - } - ; - } - //Jungle - if (theblock.getMetaFromState(event.getState()) == 11) { - event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(3).getBlock()))); - if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.jungleChance, fortune)) == 0) { - event.getDrops().add(new ItemStack(ItemRegistry.jungle_seed)); - } - } else - //Birch - if (theblock.getMetaFromState(event.getState()) == 10) { - event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(2).getBlock()))); - if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.birchChance, fortune)) == 0) { - event.getDrops().add(new ItemStack(ItemRegistry.birch_seed)); - } - } else - //Spruce - if (theblock.getMetaFromState(event.getState()) == 9) { - event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(1).getBlock()))); - if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.spruceChance, fortune)) == 0) { - event.getDrops().add(new ItemStack(ItemRegistry.spruce_seed)); - } - } else - //Oak - if (theblock.getMetaFromState(event.getState()) == 8) { - event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(0).getBlock()))); - if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.oakChance, fortune)) == 0) { - event.getDrops().add(new ItemStack(ItemRegistry.oak_seed)); - } - } + //Jungle + if (theblock.getMetaFromState(event.getState()) == 11) { + event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(3).getBlock()))); + if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.jungleChance, fortune)) == 0) { + event.getDrops().add(new ItemStack(ItemRegistry.jungle_seed)); + } + } else { + //Birch + if (theblock.getMetaFromState(event.getState()) == 10) { + event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(2).getBlock()))); + if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.birchChance, fortune)) == 0) { + event.getDrops().add(new ItemStack(ItemRegistry.birch_seed)); + } + } else { + //Spruce + if (theblock.getMetaFromState(event.getState()) == 9) { + event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(1).getBlock()))); + if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.spruceChance, fortune)) == 0) { + event.getDrops().add(new ItemStack(ItemRegistry.spruce_seed)); + } + } else { + //Oak + if (theblock.getMetaFromState(event.getState()) == 8) { + event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(0).getBlock()))); + if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.oakChance, fortune)) == 0) { + event.getDrops().add(new ItemStack(ItemRegistry.oak_seed)); + } + } + } + } + } + } else { + if (theblock == Blocks.LEAVES2) { + int s = event.getDrops().size(); + for (int i = 0; i < s; i++) { + if (event.getDrops().get(i).getItem() == Items.APPLE) { + event.getDrops().remove(i); + } + } - } else if (theblock == Blocks.LEAVES2) { - int s = event.getDrops().size(); - for (int i = 0; i < s; i++) { - if (event.getDrops().get(i).getItem() == Items.APPLE) { - event.getDrops().remove(i); - } - } - //Acacia - if (theblock.getMetaFromState(event.getState()) == 8) { - event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(4).getBlock()))); - if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.acaciaChance, fortune)) == 0) { - event.getDrops().add(new ItemStack(ItemRegistry.acacia_seed)); - } - } else - //Dark Oak - if (theblock.getMetaFromState(event.getState()) == 9) { - event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(5).getBlock()))); - if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.darkoakChance, fortune)) == 0) { - event.getDrops().add(new ItemStack(ItemRegistry.dark_oak_seed)); - } - } - } - } - } + //Acacia + if (theblock.getMetaFromState(event.getState()) == 8) { + event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(4).getBlock()))); + if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.acaciaChance, fortune)) == 0) { + event.getDrops().add(new ItemStack(ItemRegistry.acacia_seed)); + } + } else { + //Dark Oak + if (theblock.getMetaFromState(event.getState()) == 9) { + event.getDrops().remove(new ItemStack(Item.getItemFromBlock(Blocks.SAPLING.getStateFromMeta(5).getBlock()))); + if (event.getWorld().rand.nextInt(getModifiedChance(ConfigurationHandler.darkoakChance, fortune)) == 0) { + event.getDrops().add(new ItemStack(ItemRegistry.dark_oak_seed)); + } + } + } + } + } + } + } - private int getModifiedChance(int chance, int fortune) { - int modifiedChance = chance; - if (fortune > 0) { - modifiedChance -= ConfigurationHandler.seedDropFortuneDecrement << fortune; - if (modifiedChance < 10) { - modifiedChance = 10; - } - } - return modifiedChance; - } + private int getModifiedChance(int chance, int fortune) { + int modifiedChance = chance; + if (fortune > 0) { + modifiedChance -= ConfigurationHandler.seedDropFortuneDecrement << fortune; + if (modifiedChance < 10) { + modifiedChance = 10; + } + } + return modifiedChance; + } } diff --git a/src/main/java/panda/gotwood/events/ConfigurationHandler.java b/src/main/java/panda/gotwood/events/ConfigurationHandler.java index 4cdcb0d..58a3b3c 100644 --- a/src/main/java/panda/gotwood/events/ConfigurationHandler.java +++ b/src/main/java/panda/gotwood/events/ConfigurationHandler.java @@ -4,111 +4,85 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public final class ConfigurationHandler { - private ConfigurationHandler() {} - public static int numStairs; - - //Seed Drop Chances - public static int oakChance; - - public static int birchChance; - - public static int spruceChance; - - public static int jungleChance; - - public static int acaciaChance; - - public static int darkoakChance; - - public static int mapleChance; - - public static int pineChance; - - public static int willowChance; - - public static int yewChance; - - public static int ebonyChance; - - public static int firChance; - - public static int seedDropFortuneDecrement; - - public static int seedDropMinChance; - - //Apple stuff - //40,5,10 - public static int appleChance; - - public static int appleDropFortuneDecrement; - - public static int appleDropMinChance; - - //1000,50,200 - public static int goldenDropChance; - - public static int goldenDropFortuneDecrement; - - public static int goldenDropMinChance; - - public static boolean removeAppleDrops; - - public static int retrieveSaplingsMode; - - public static String[] mega; - - public static String dL = ""; - - public static int bambooChance; - - public static int appleFruitingChance; - - public static int appleFruitingGenChance; - - public static int rubberChance; - public static boolean allowBonemealFruitSaplings; - public static Configuration config; - - public static void init(FMLPreInitializationEvent event) { - config = new Configuration(event.getSuggestedConfigurationFile()); - - config.load(); - - config.addCustomCategoryComment("Drops", "Tweaks for leaf drops\n Drop chances are 1/n. Fortune decrements are how much it changes for each level of fortune."); - oakChance = config.getInt("oakSeedChance", "Drops", 30, 1, 32767, ""); - birchChance = config.getInt("birchSeedChance", "Drops", 30, 1, 32767, ""); - spruceChance = config.getInt("spruceSeedChance", "Drops", 30, 1, 32767, ""); - jungleChance = config.getInt("jungleSeedChance", "Drops", 60, 1, 32767, ""); - acaciaChance = config.getInt("acaciaSeedChance", "Drops", 30, 1, 32767, ""); - darkoakChance = config.getInt("darkoakSeedChance", "Drops", 30, 1, 32767, ""); - appleChance = config.getInt("appleChance", "Drops", 6, 1, 32767, ""); - mapleChance = config.getInt("mapleSeedChance", "Drops", 30, 1, 32767, ""); - pineChance = config.getInt("pineSeedChance", "Drops", 27, 1, 32767, ""); - willowChance = config.getInt("willowSeedChance", "Drops", 52, 1, 32767, ""); - yewChance = config.getInt("yewSeedChance", "Drops", 24, 1, 32767, ""); - ebonyChance = config.getInt("ebonySeedChance", "Drops", 27, 1, 32767, ""); - firChance = config.getInt("firSeedChance", "Drops", 34, 1, 32767, ""); - bambooChance = config.getInt("bambooSeedChance", "Drops", 10, 1, 32767, ""); - rubberChance = config.getInt("rubberSeedChance", "Drops", 38, 1, 32767, ""); - goldenDropChance = config.getInt("goldenAppleChance", "Drops", 80, 1, 32767, ""); - goldenDropFortuneDecrement = config.getInt("goldenAppleFortuneDecrement", "Drops", 60, 1, 32767, "Must be less than the chance"); - goldenDropMinChance = config.getInt("goldenAppleMinChance", "Drops", 400, 1, 32767, "Must be less than the chance"); - appleDropFortuneDecrement = config.getInt("appleFortuneDecrement", "Drops", 2, 1, 32767, "Must be less than the chance"); - appleDropMinChance = config.getInt("appleMinChance", "Drops", 5, 1, 32767, "Must be less than the chance"); - seedDropFortuneDecrement = config.getInt("seedFortuneDecrement", "Drops", 2, 1, 32767, "Must be less than every seed chance. Effects all tree seed chances"); - seedDropMinChance = config.getInt("seedFortuneDecrement", "Drops", 10, 1, 32767, "Must be less than every seed chance. Effects all tree seed chances"); - removeAppleDrops = config.getBoolean("removeAppleDrops", "Drops", true, "Make apple trees the only natural source of apples besides loot"); - config.addCustomCategoryComment("Generation", "Tweaks for tree generation"); - appleFruitingChance = config.getInt("appleFruitingChance", "Drops", 8, 1, 32767, ""); - appleFruitingGenChance = config.getInt("appleFruitingGenerationChance", "Drops", 12, 1, 32767, ""); - config.addCustomCategoryComment("Misc", "Misc Tweaks"); - numStairs = config.getInt("NumStairsCrafting", "Misc", 4, 1, 8, ""); - retrieveSaplingsMode = config.getInt("goldenAppleChance", "Misc", 1, 0, 2, "0: Can't get sapling items normally/n1:Shear or silktouch a sapling block/n 2:Place a seed in a crafting grid"); - //can't get saplings - //shear or silktouch sapling block - //seed in crafting grid - allowBonemealFruitSaplings = config.getBoolean("allowBonemealFruitSaplings", "Drops", true, "Allow fruit trees to be bonemealed"); - config.save(); - } + public static int numStairs; + //Seed Drop Chances + public static int oakChance; + public static int birchChance; + public static int spruceChance; + public static int jungleChance; + public static int acaciaChance; + public static int darkoakChance; + public static int mapleChance; + public static int pineChance; + public static int willowChance; + public static int yewChance; + public static int ebonyChance; + public static int firChance; + public static int seedDropFortuneDecrement; + public static int seedDropMinChance; + //Apple stuff + //40, 5, 10 + public static int appleChance; + public static int appleDropFortuneDecrement; + public static int appleDropMinChance; + //1000,50,200 + public static int goldenDropChance; + public static int goldenDropFortuneDecrement; + public static int goldenDropMinChance; + public static boolean removeAppleDrops; + public static int retrieveSaplingsMode; + public static String[] mega; + public static String dL = ""; + public static int bambooChance; + public static int appleFruitingChance; + public static int appleFruitingGenChance; + public static int rubberChance; + public static boolean allowBonemealFruitSaplings; + public static Configuration config; + + private ConfigurationHandler() { + } + + public static void init(FMLPreInitializationEvent event) { + config = new Configuration(event.getSuggestedConfigurationFile()); + + config.load(); + + config.addCustomCategoryComment("Drops", "Tweaks for leaf drops\n Drop chances are 1/n. Fortune decrements are how much it changes for each level of fortune."); + oakChance = config.getInt("oakSeedChance", "Drops", 30, 1, 32767, ""); + birchChance = config.getInt("birchSeedChance", "Drops", 30, 1, 32767, ""); + spruceChance = config.getInt("spruceSeedChance", "Drops", 30, 1, 32767, ""); + jungleChance = config.getInt("jungleSeedChance", "Drops", 60, 1, 32767, ""); + acaciaChance = config.getInt("acaciaSeedChance", "Drops", 30, 1, 32767, ""); + darkoakChance = config.getInt("darkoakSeedChance", "Drops", 30, 1, 32767, ""); + appleChance = config.getInt("appleChance", "Drops", 6, 1, 32767, ""); + mapleChance = config.getInt("mapleSeedChance", "Drops", 30, 1, 32767, ""); + pineChance = config.getInt("pineSeedChance", "Drops", 27, 1, 32767, ""); + willowChance = config.getInt("willowSeedChance", "Drops", 52, 1, 32767, ""); + yewChance = config.getInt("yewSeedChance", "Drops", 24, 1, 32767, ""); + ebonyChance = config.getInt("ebonySeedChance", "Drops", 27, 1, 32767, ""); + firChance = config.getInt("firSeedChance", "Drops", 34, 1, 32767, ""); + bambooChance = config.getInt("bambooSeedChance", "Drops", 10, 1, 32767, ""); + rubberChance = config.getInt("rubberSeedChance", "Drops", 38, 1, 32767, ""); + goldenDropChance = config.getInt("goldenAppleChance", "Drops", 80, 1, 32767, ""); + goldenDropFortuneDecrement = config.getInt("goldenAppleFortuneDecrement", "Drops", 60, 1, 32767, "Must be less than the chance"); + goldenDropMinChance = config.getInt("goldenAppleMinChance", "Drops", 400, 1, 32767, "Must be less than the chance"); + appleDropFortuneDecrement = config.getInt("appleFortuneDecrement", "Drops", 2, 1, 32767, "Must be less than the chance"); + appleDropMinChance = config.getInt("appleMinChance", "Drops", 5, 1, 32767, "Must be less than the chance"); + seedDropFortuneDecrement = config.getInt("seedFortuneDecrement", "Drops", 2, 1, 32767, "Must be less than every seed chance. Effects all tree seed chances"); + seedDropMinChance = config.getInt("seedFortuneDecrement", "Drops", 10, 1, 32767, "Must be less than every seed chance. Effects all tree seed chances"); + removeAppleDrops = config.getBoolean("removeAppleDrops", "Drops", true, "Make apple trees the only natural source of apples besides loot"); + config.addCustomCategoryComment("Generation", "Tweaks for tree generation"); + appleFruitingChance = config.getInt("appleFruitingChance", "Drops", 8, 1, 32767, ""); + appleFruitingGenChance = config.getInt("appleFruitingGenerationChance", "Drops", 12, 1, 32767, ""); + config.addCustomCategoryComment("Misc", "Misc Tweaks"); + numStairs = config.getInt("NumStairsCrafting", "Misc", 4, 1, 8, ""); + retrieveSaplingsMode = config.getInt("goldenAppleChance", "Misc", 1, 0, 2, "0: Can't get sapling items normally/n1:Shear or silktouch a sapling block/n 2:Place a seed in a crafting grid"); + //can't get saplings + //shear or silktouch sapling block + //seed in crafting grid + allowBonemealFruitSaplings = config.getBoolean("allowBonemealFruitSaplings", "Drops", true, "Allow fruit trees to be bonemealed"); + config.save(); + } } diff --git a/src/main/java/panda/gotwood/events/ConsumedByFireListener.java b/src/main/java/panda/gotwood/events/ConsumedByFireListener.java index ab73405..36c6023 100644 --- a/src/main/java/panda/gotwood/events/ConsumedByFireListener.java +++ b/src/main/java/panda/gotwood/events/ConsumedByFireListener.java @@ -13,49 +13,60 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorldEventListener; import net.minecraft.world.World; - import panda.gotwood.block.BlockSpecialFire; import panda.gotwood.registry.BlockRegistry; public final class ConsumedByFireListener implements IWorldEventListener { - @Override - public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, IBlockState currentState, int flags) { - if (currentState.getBlock() == Blocks.FIRE && !(worldIn.getBlockState(pos.down()).getBlock() instanceof BlockObsidian) && !(worldIn.getBlockState(pos.down()).getBlock() instanceof BlockBush) && !(worldIn.getBlockState(pos.down()).getBlock() instanceof BlockTallGrass)) { - IBlockState newStateBlock = BlockRegistry.specialfire.getDefaultState().withProperty(BlockSpecialFire.AGE, currentState.getValue(BlockFire.AGE)).withProperty(BlockSpecialFire.NORTH, currentState.getValue(BlockFire.NORTH)).withProperty(BlockSpecialFire.EAST, currentState.getValue(BlockFire.EAST)).withProperty(BlockSpecialFire.SOUTH, currentState.getValue(BlockFire.SOUTH)).withProperty(BlockSpecialFire.WEST, currentState.getValue(BlockFire.WEST)).withProperty(BlockSpecialFire.UPPER, currentState.getValue(BlockFire.UPPER)); - worldIn.setBlockState(pos, newStateBlock, flags); - } - } - @Override - public void notifyLightSet(BlockPos pos) {} + @Override + public void notifyBlockUpdate(World worldIn, BlockPos pos, IBlockState oldState, IBlockState currentState, int flags) { + if (currentState.getBlock() == Blocks.FIRE && !(worldIn.getBlockState(pos.down()).getBlock() instanceof BlockObsidian) && !(worldIn.getBlockState(pos.down()).getBlock() instanceof BlockBush) && !(worldIn.getBlockState(pos.down()).getBlock() instanceof BlockTallGrass)) { + IBlockState newStateBlock = BlockRegistry.specialfire.getDefaultState().withProperty(BlockSpecialFire.AGE, currentState.getValue(BlockFire.AGE)).withProperty(BlockSpecialFire.NORTH, currentState.getValue(BlockFire.NORTH)).withProperty(BlockSpecialFire.EAST, currentState.getValue(BlockFire.EAST)).withProperty(BlockSpecialFire.SOUTH, currentState.getValue(BlockFire.SOUTH)).withProperty(BlockSpecialFire.WEST, currentState.getValue(BlockFire.WEST)).withProperty(BlockSpecialFire.UPPER, currentState.getValue(BlockFire.UPPER)); + worldIn.setBlockState(pos, newStateBlock, flags); + } + } + + @Override + public void notifyLightSet(BlockPos pos) { + } - @Override - public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {} + @Override + public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) { + } - @Override - public void playSoundToAllNearExcept(EntityPlayer player, SoundEvent soundIn, SoundCategory category, double x, double y, double z, float volume, float pitch) {} + @Override + public void playSoundToAllNearExcept(EntityPlayer player, SoundEvent soundIn, SoundCategory category, double x, double y, double z, float volume, float pitch) { + } - @Override - public void playRecord(SoundEvent soundIn, BlockPos pos) {} + @Override + public void playRecord(SoundEvent soundIn, BlockPos pos) { + } - @Override - public void spawnParticle(int particleID, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, int... parameters) {} + @Override + public void spawnParticle(int particleID, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed, int... parameters) { + } - @Override - public void onEntityAdded(Entity entityIn) {} + @Override + public void onEntityAdded(Entity entityIn) { + } - @Override - public void onEntityRemoved(Entity entityIn) {} + @Override + public void onEntityRemoved(Entity entityIn) { + } - @Override - public void broadcastSound(int soundID, BlockPos pos, int data) {} + @Override + public void broadcastSound(int soundID, BlockPos pos, int data) { + } - @Override - public void playEvent(EntityPlayer player, int type, BlockPos blockPosIn, int data) {} + @Override + public void playEvent(EntityPlayer player, int type, BlockPos blockPosIn, int data) { + } - @Override - public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {} + @Override + public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) { + } - @Override - public void spawnParticle(int one, boolean two, boolean three, double four, double five, double six, double seven, double eight, double nine, int... ten) {} + @Override + public void spawnParticle(int one, boolean two, boolean three, double four, double five, double six, double seven, double eight, double nine, int... ten) { + } } diff --git a/src/main/java/panda/gotwood/events/FireDropsEvent.java b/src/main/java/panda/gotwood/events/FireDropsEvent.java index 982455e..590e862 100644 --- a/src/main/java/panda/gotwood/events/FireDropsEvent.java +++ b/src/main/java/panda/gotwood/events/FireDropsEvent.java @@ -3,5 +3,5 @@ import net.minecraftforge.fml.common.eventhandler.Event; public class FireDropsEvent extends Event { - + //TODO Figure out why this is here and why it's empty... } diff --git a/src/main/java/panda/gotwood/events/FireHandler.java b/src/main/java/panda/gotwood/events/FireHandler.java index 3ce19b0..8ed92bd 100644 --- a/src/main/java/panda/gotwood/events/FireHandler.java +++ b/src/main/java/panda/gotwood/events/FireHandler.java @@ -1,7 +1,5 @@ package panda.gotwood.events; -import javax.annotation.Nullable; - import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; @@ -11,52 +9,54 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - import panda.gotwood.registry.BlockRegistry; +import javax.annotation.Nullable; + public final class FireHandler { - @SubscribeEvent - public void loadEvent(WorldEvent.Load event) { - World world = event.getWorld(); - world.addEventListener(new ConsumedByFireListener()); - } - - @SubscribeEvent - public void onLeftClickEvent(PlayerInteractEvent.EntityInteract.LeftClickBlock event) { - if (event.getEntityPlayer().isCreative()) { - extinguishFire(null, event.getPos(), event.getFace(), event.getWorld()); - } else { - IBlockState iblockstate = event.getWorld().getBlockState(event.getPos()); - Block block = iblockstate.getBlock(); - if (!iblockstate.getBlock().isAir(iblockstate, event.getWorld(), event.getPos())) { - block.onBlockClicked(event.getWorld(), event.getPos(), event.getEntityPlayer()); - extinguishFire(null, event.getPos(), event.getFace(), event.getWorld()); - - } - } - } - - @SubscribeEvent - public void onRightClickEvent(PlayerInteractEvent.EntityInteract.RightClickBlock event) { - if (event.getEntityPlayer().isCreative()) { - extinguishFire(null, event.getPos(), event.getFace(), event.getWorld()); - } else { - IBlockState iblockstate = event.getWorld().getBlockState(event.getPos()); - Block block = iblockstate.getBlock(); - if (!iblockstate.getBlock().isAir(iblockstate, event.getWorld(), event.getPos())) { - block.onBlockClicked(event.getWorld(), event.getPos(), event.getEntityPlayer()); - extinguishFire(null, event.getPos(), event.getFace(), event.getWorld()); - } - } - } - - public boolean extinguishFire(@Nullable EntityPlayer player, BlockPos pos, EnumFacing side, World world) { - pos = pos.offset(side); - if (world.getBlockState(pos).getBlock() == BlockRegistry.specialfire) { - world.playEvent(player, 1009, pos, 0); - world.setBlockToAir(pos); - return true; - } - return false; - } + + @SubscribeEvent + public void loadEvent(WorldEvent.Load event) { + World world = event.getWorld(); + world.addEventListener(new ConsumedByFireListener()); + } + + @SubscribeEvent + public void onLeftClickEvent(PlayerInteractEvent.EntityInteract.LeftClickBlock event) { + if (event.getEntityPlayer().isCreative()) { + extinguishFire(null, event.getPos(), event.getFace(), event.getWorld()); + } else { + IBlockState iblockstate = event.getWorld().getBlockState(event.getPos()); + Block block = iblockstate.getBlock(); + if (!iblockstate.getBlock().isAir(iblockstate, event.getWorld(), event.getPos())) { + block.onBlockClicked(event.getWorld(), event.getPos(), event.getEntityPlayer()); + extinguishFire(null, event.getPos(), event.getFace(), event.getWorld()); + + } + } + } + + @SubscribeEvent + public void onRightClickEvent(PlayerInteractEvent.EntityInteract.RightClickBlock event) { + if (event.getEntityPlayer().isCreative()) { + extinguishFire(null, event.getPos(), event.getFace(), event.getWorld()); + } else { + IBlockState iblockstate = event.getWorld().getBlockState(event.getPos()); + Block block = iblockstate.getBlock(); + if (!iblockstate.getBlock().isAir(iblockstate, event.getWorld(), event.getPos())) { + block.onBlockClicked(event.getWorld(), event.getPos(), event.getEntityPlayer()); + extinguishFire(null, event.getPos(), event.getFace(), event.getWorld()); + } + } + } + + public boolean extinguishFire(@Nullable EntityPlayer player, BlockPos pos, EnumFacing side, World world) { + pos = pos.offset(side); + if (world.getBlockState(pos).getBlock() == BlockRegistry.specialfire) { + world.playEvent(player, 1009, pos, 0); + world.setBlockToAir(pos); + return true; + } + return false; + } } diff --git a/src/main/java/panda/gotwood/generation/WorldGenApple.java b/src/main/java/panda/gotwood/generation/WorldGenApple.java index b915c62..5700940 100644 --- a/src/main/java/panda/gotwood/generation/WorldGenApple.java +++ b/src/main/java/panda/gotwood/generation/WorldGenApple.java @@ -1,127 +1,120 @@ package panda.gotwood.generation; -import java.util.Random; - +import net.minecraft.block.BlockSapling; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; - import panda.gotwood.block.BlockFruitingLeaves; import panda.gotwood.block.BlockWoodLeaves; import panda.gotwood.events.ConfigurationHandler; import panda.gotwood.registry.BlockRegistry; +import java.util.Random; + public class WorldGenApple extends WorldGenAbstractTree { - private static final IBlockState DEFAULT_TRUNK = BlockRegistry.apple_log.getDefaultState(); - - private static final IBlockState DEFAULT_LEAF = BlockRegistry.apple_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, Boolean.valueOf(true)); - - /** - * The minimum height of a generated tree. - */ - private final int minTreeHeight; - - /** - * The metadata value of the wood to use in tree generation. - */ - private final IBlockState metaWood; - - /** - * The metadata value of the leaves to use in tree generation. - */ - private final IBlockState metaLeaves; - - public WorldGenApple(boolean bool) { - this(bool, 4, DEFAULT_TRUNK, DEFAULT_LEAF); - } - - public WorldGenApple(boolean bool, int height, IBlockState metawood, IBlockState metaleaves) { - super(bool); - this.minTreeHeight = height; - this.metaWood = metawood; - this.metaLeaves = metaleaves; - } - - public boolean generate(World worldIn, Random rand, BlockPos position) { - int i = 2 + rand.nextInt(1) + this.minTreeHeight; - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { - for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { - int k = 1; - - if (j == position.getY()) { - k = 0; - } - - if (j >= position.getY() + 1 + i - 2) { - k = 2; - } - - BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos(); - - for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { - for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { - if (j >= 0 && j < worldIn.getHeight()) { - if (!this.isReplaceable(worldIn, blockposmutableblockpos.setPos(l, j, i1))) { - flag = false; - } - } else { - flag = false; - } - } - } - } - - if (!flag) { - return false; - } else { - IBlockState state = worldIn.getBlockState(position.down()); - - if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { - this.setDirtAt(worldIn, position.down()); - - for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { - int i4 = i3 - (position.getY() + i); - int j1 = 1 - i4 / 2; - - for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { - int l1 = k1 - position.getX(); - - for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { - int j2 = i2 - position.getZ(); - - if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { - BlockPos blockpos = new BlockPos(k1, i3, i2); - state = worldIn.getBlockState(blockpos); - - if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves.withProperty(BlockFruitingLeaves.FRUITING, rand.nextInt(ConfigurationHandler.appleFruitingGenChance) == 0?rand.nextInt(1)+1:0)); - } - } - } - } - } - - for (int j3 = 0; j3 < i; ++j3) { - BlockPos upN = position.up(j3); - state = worldIn.getBlockState(upN); - - if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); - } - } - - return true; - } else { - return false; - } - } - } else { - return false; - } - } + private static final IBlockState DEFAULT_TRUNK = BlockRegistry.apple_log.getDefaultState(); + private static final IBlockState DEFAULT_LEAF = BlockRegistry.apple_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, true); + + /** + * The minimum height of a generated tree. + */ + private final int minTreeHeight; + + /** + * The metadata value of the wood to use in tree generation. + */ + private final IBlockState metaWood; + + /** + * The metadata value of the leaves to use in tree generation. + */ + private final IBlockState metaLeaves; + + public WorldGenApple(boolean bool) { + this(bool, 4, DEFAULT_TRUNK, DEFAULT_LEAF); + } + + public WorldGenApple(boolean bool, int height, IBlockState metawood, IBlockState metaleaves) { + super(bool); + this.minTreeHeight = height; + this.metaWood = metawood; + this.metaLeaves = metaleaves; + } + + public boolean generate(World worldIn, Random rand, BlockPos position) { + int i = 2 + rand.nextInt(1) + this.minTreeHeight; + boolean flag = true; + if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { + for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { + int k = 1; + + if (j == position.getY()) { + k = 0; + } + + if (j >= position.getY() + 1 + i - 2) { + k = 2; + } + + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + + for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { + for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { + if (j >= 0 && j < worldIn.getHeight()) { + if (!this.isReplaceable(worldIn, mutableBlockPos.setPos(l, j, i1))) { + flag = false; + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + return false; + } else { + IBlockState state = worldIn.getBlockState(position.down()); + if (state.getBlock().canSustainPlant(state, worldIn, position.down(), EnumFacing.UP, (BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { + this.setDirtAt(worldIn, position.down()); + + for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { + int i4 = i3 - (position.getY() + i); + int j1 = 1 - i4 / 2; + for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { + int l1 = k1 - position.getX(); + for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { + int j2 = i2 - position.getZ(); + if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { + BlockPos blockpos = new BlockPos(k1, i3, i2); + state = worldIn.getBlockState(blockpos); + if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves.withProperty(BlockFruitingLeaves.FRUITING, rand.nextInt(ConfigurationHandler.appleFruitingGenChance) == 0 ? rand.nextInt(1) + 1 : 0)); + } + } + } + } + } + + for (int j3 = 0; j3 < i; ++j3) { + BlockPos upN = position.up(j3); + state = worldIn.getBlockState(upN); + if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } } diff --git a/src/main/java/panda/gotwood/generation/WorldGenBamboo.java b/src/main/java/panda/gotwood/generation/WorldGenBamboo.java index 07915e2..2951c1e 100644 --- a/src/main/java/panda/gotwood/generation/WorldGenBamboo.java +++ b/src/main/java/panda/gotwood/generation/WorldGenBamboo.java @@ -1,7 +1,5 @@ package panda.gotwood.generation; -import java.util.Random; - import net.minecraft.block.Block; import net.minecraft.block.BlockSapling; import net.minecraft.block.material.Material; @@ -11,144 +9,143 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; - import panda.gotwood.block.BlockWoodLeaves; import panda.gotwood.registry.BlockRegistry; +import java.util.Random; + public class WorldGenBamboo extends WorldGenAbstractTree { - private final int density = 64; - - private final int minTreeHeight = 12; - - private final int maxTreeHeight = 24; - - private final IBlockState leaves = BlockRegistry.bamboo_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, Boolean.valueOf(true)).withProperty(BlockWoodLeaves.CHECK_DECAY, Boolean.valueOf(true)); - - private final IBlockState log = BlockRegistry.bamboo_log.getDefaultState(); - - public WorldGenBamboo(boolean doblocknotify) { - super(doblocknotify); - } - - public boolean generateClumps(World world, Random rand, BlockPos pos) { - for (int loop = 0; loop < this.density; loop++) { - BlockPos newpos = pos.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8)); - - generate(world, rand, newpos); - } - return true; - } - - public boolean generate(World world, Random rand, BlockPos position) { - - int height = rand.nextInt(3) + this.minTreeHeight; - boolean flag = true; - int i = position.getX(); - int j = position.getY(); - int k = position.getZ(); - - //if ((j >= 1) && (height + 1 <= this.maxTreeHeight)) { - for (int y = j; y <= j + 1 + height; y++) { - byte b0 = 0; - if (y >= j + height - 3) { - b0 = 1; - } - for (int x = i - b0; (x <= i + b0) && (flag); x++) { - for (int z = k - b0; (z <= k + b0) && (flag); z++) { - if ((y >= 0) && (y < this.maxTreeHeight)) { - Block checkBlock = world.getBlockState(new BlockPos(x, y, z)).getBlock(); - if (!isReplaceable(world, x, y, z)) { - flag = false; - } - } else { - flag = false; - } - } - } - } - if (!flag) { - return false; - } - Block soil = world.getBlockState(new BlockPos(i, j - 1, k)).getBlock(); - boolean isSoil = (soil != null) && (soil.canSustainPlant(Blocks.SAPLING.getDefaultState(), world, new BlockPos(i, j - 1, k), EnumFacing.UP, (BlockSapling) Blocks.SAPLING)); - if ((isSoil) && (j < this.maxTreeHeight - height - 1)) { - soil.onPlantGrow(world.getBlockState(new BlockPos(i, j - 1, k)), world, new BlockPos(i, j - 1, k), new BlockPos(i, j, k)); - for (int it = 0; it <= 3; it++) { - int y = j + 5 + height - this.minTreeHeight + it * 2; - for (int x = i - 1; x <= i + 1; x++) { - int x2 = x - i; - for (int z = k - 1; z <= k + 1; z++) { - int z2 = z - k; - - Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); - if (((Math.abs(x2) != 1) || (Math.abs(z2) != 1)) && ((block == null) || (block.canBeReplacedByLeaves(world.getBlockState(new BlockPos(x, y, z)), world, new BlockPos(x, y, z))))) { - world.setBlockState(new BlockPos(x, y, z), this.leaves); - } - } - } - } - int y = j + height - 2; - for (int x = i - 1; x <= i + 1; x++) { - for (int z = k - 1; z <= k + 1; z++) { - Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); - if ((block == null) || (block.canBeReplacedByLeaves(world.getBlockState(new BlockPos(x, y, z)), world, new BlockPos(x, y, z)))) { - world.setBlockState(new BlockPos(x, y, z), this.leaves); - } - } - } - int x = i; - int z = k; - int it; - for (it = 0; it <= 3; it++) { - switch (it) { - case 0: - x = i - 2; - z = k; - break; - case 1: - x = i + 2; - z = k; - break; - case 2: - x = i; - z = k - 2; - break; - case 3: - x = i; - z = k + 2; - break; - } - Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); - if ((block == null) || (block.canBeReplacedByLeaves(world.getBlockState(new BlockPos(x, y, z)), world, new BlockPos(x, y, z)))) { - world.setBlockState(new BlockPos(x, y, z), this.leaves); - } - } - y = j + height; - Block block = world.getBlockState(new BlockPos(i, y, k)).getBlock(); - if ((block == null) || (block.canBeReplacedByLeaves(world.getBlockState(new BlockPos(i, y, k)), world, new BlockPos(i, y, k)))) { - world.setBlockState(new BlockPos(i, y, k), this.leaves); - } - for (y = 0; y < height - 1; y++) { - block = world.getBlockState(new BlockPos(i, j + y, k)).getBlock(); - if ((block.isAir(world.getBlockState(new BlockPos(i, j + y, k)), world, new BlockPos(it, j + y, k))) || (block.isLeaves(world.getBlockState(new BlockPos(i, j + y, k)), world, new BlockPos(i, j + y, k)))) { - world.setBlockState(new BlockPos(i, j + y, k), this.log); - } - } - return true; - } - return false; - //} - //return false; - } - - protected boolean func_150523_a(Block block) { - return (block.getMaterial(null) == Material.AIR) || (block.getMaterial(null) == Material.LEAVES) || (block == Blocks.GRASS) || (block == Blocks.DIRT) || (block == Blocks.LOG) || (block == Blocks.LOG2) || (block == Blocks.SAPLING) || (block == Blocks.VINE); - } - - protected boolean isReplaceable(World world, int x, int y, int z) { - IBlockState state = world.getBlockState(new BlockPos(x, y, z)); - Block block = state.getBlock(); - - return (block.isAir(state, world, new BlockPos(x, y, z))) || (block.isLeaves(state, world, new BlockPos(x, y, z))) || (block.isWood(world, new BlockPos(x, y, z))) || (func_150523_a(block)); - } + + private final int density = 64; + private final int minTreeHeight = 12; + private final int maxTreeHeight = 24; + private final IBlockState leaves = BlockRegistry.bamboo_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, true).withProperty(BlockWoodLeaves.CHECK_DECAY, true); + private final IBlockState log = BlockRegistry.bamboo_log.getDefaultState(); + + public WorldGenBamboo(boolean doblocknotify) { + super(doblocknotify); + } + + public boolean generateClumps(World world, Random rand, BlockPos pos) { + for (int loop = 0; loop < this.density; loop++) { + BlockPos newpos = pos.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8)); + generate(world, rand, newpos); + } + return true; + } + + public boolean generate(World world, Random rand, BlockPos position) { + int height = rand.nextInt(3) + this.minTreeHeight; + boolean flag = true; + int i = position.getX(); + int j = position.getY(); + int k = position.getZ(); + //if ((j >= 1) && (height + 1 <= this.maxTreeHeight)) { + for (int y = j; y <= j + 1 + height; y++) { + byte b0 = 0; + if (y >= j + height - 3) { + b0 = 1; + } + + for (int x = i - b0; (x <= i + b0) && (flag); x++) { + for (int z = k - b0; (z <= k + b0) && (flag); z++) { + if ((y >= 0) && (y < this.maxTreeHeight)) { + Block checkBlock = world.getBlockState(new BlockPos(x, y, z)).getBlock(); + if (!isReplaceable(world, x, y, z)) { + flag = false; + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + return false; + } + + Block soil = world.getBlockState(new BlockPos(i, j - 1, k)).getBlock(); + boolean isSoil = (soil != null) && (soil.canSustainPlant(Blocks.SAPLING.getDefaultState(), world, new BlockPos(i, j - 1, k), EnumFacing.UP, (BlockSapling) Blocks.SAPLING)); + if ((isSoil) && (j < this.maxTreeHeight - height - 1)) { + soil.onPlantGrow(world.getBlockState(new BlockPos(i, j - 1, k)), world, new BlockPos(i, j - 1, k), new BlockPos(i, j, k)); + for (int it = 0; it <= 3; it++) { + int y = j + 5 + height - this.minTreeHeight + it * 2; + for (int x = i - 1; x <= i + 1; x++) { + int x2 = x - i; + for (int z = k - 1; z <= k + 1; z++) { + int z2 = z - k; + Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); + if (((Math.abs(x2) != 1) || (Math.abs(z2) != 1)) && ((block == null) || (block.canBeReplacedByLeaves(world.getBlockState(new BlockPos(x, y, z)), world, new BlockPos(x, y, z))))) { + world.setBlockState(new BlockPos(x, y, z), this.leaves); + } + } + } + } + + int y = j + height - 2; + for (int x = i - 1; x <= i + 1; x++) { + for (int z = k - 1; z <= k + 1; z++) { + Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); + if ((block == null) || (block.canBeReplacedByLeaves(world.getBlockState(new BlockPos(x, y, z)), world, new BlockPos(x, y, z)))) { + world.setBlockState(new BlockPos(x, y, z), this.leaves); + } + } + } + + int x = i; + int z = k; + int it; + for (it = 0; it <= 3; it++) { + switch (it) { + case 0: + x = i - 2; + z = k; + break; + case 1: + x = i + 2; + z = k; + break; + case 2: + x = i; + z = k - 2; + break; + case 3: + x = i; + z = k + 2; + break; + } + + Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); + if ((block == null) || (block.canBeReplacedByLeaves(world.getBlockState(new BlockPos(x, y, z)), world, new BlockPos(x, y, z)))) { + world.setBlockState(new BlockPos(x, y, z), this.leaves); + } + } + + y = j + height; + Block block = world.getBlockState(new BlockPos(i, y, k)).getBlock(); + if ((block == null) || (block.canBeReplacedByLeaves(world.getBlockState(new BlockPos(i, y, k)), world, new BlockPos(i, y, k)))) { + world.setBlockState(new BlockPos(i, y, k), this.leaves); + } + + for (y = 0; y < height - 1; y++) { + block = world.getBlockState(new BlockPos(i, j + y, k)).getBlock(); + if ((block.isAir(world.getBlockState(new BlockPos(i, j + y, k)), world, new BlockPos(it, j + y, k))) || (block.isLeaves(world.getBlockState(new BlockPos(i, j + y, k)), world, new BlockPos(i, j + y, k)))) { + world.setBlockState(new BlockPos(i, j + y, k), this.log); + } + } + return true; + } + return false; + } + + protected boolean canGrowInto(Block block) { + return (block.getMaterial(null) == Material.AIR) || (block.getMaterial(null) == Material.LEAVES) || (block == Blocks.GRASS) || (block == Blocks.DIRT) || (block == Blocks.LOG) || (block == Blocks.LOG2) || (block == Blocks.SAPLING) || (block == Blocks.VINE); + } + + protected boolean isReplaceable(World world, int x, int y, int z) { + IBlockState state = world.getBlockState(new BlockPos(x, y, z)); + Block block = state.getBlock(); + return (block.isAir(state, world, new BlockPos(x, y, z))) || (block.isLeaves(state, world, new BlockPos(x, y, z))) || (block.isWood(world, new BlockPos(x, y, z))) || (canGrowInto(block)); + } } diff --git a/src/main/java/panda/gotwood/generation/WorldGenEbony.java b/src/main/java/panda/gotwood/generation/WorldGenEbony.java index ff2c2ef..48fa678 100644 --- a/src/main/java/panda/gotwood/generation/WorldGenEbony.java +++ b/src/main/java/panda/gotwood/generation/WorldGenEbony.java @@ -1,177 +1,164 @@ package panda.gotwood.generation; -import java.util.Random; - +import net.minecraft.block.BlockSapling; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; - import panda.gotwood.block.BlockWoodLeaves; import panda.gotwood.registry.BlockRegistry; +import java.util.Random; + public class WorldGenEbony extends WorldGenAbstractTree { - private static final IBlockState TRUNK = BlockRegistry.ebony_log.getDefaultState(); - - private static final IBlockState LEAF = BlockRegistry.ebony_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, Boolean.valueOf(true)); - - public WorldGenEbony(boolean doBlockNotify) { - super(doBlockNotify); - } - - public boolean generate(World worldIn, Random rand, BlockPos position) { - int i = rand.nextInt(3) + rand.nextInt(3) + 5; - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= 256) { - for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { - int k = 1; - - if (j == position.getY()) { - k = 0; - } - - if (j >= position.getY() + 1 + i - 2) { - k = 2; - } - - BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos(); - - for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { - for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { - if (j >= 0 && j < 256) { - if (!this.isReplaceable(worldIn, blockposmutableblockpos.setPos(l, j, i1))) { - flag = false; - } - } else { - flag = false; - } - } - } - } - - if (!flag) { - return false; - } else { - BlockPos down = position.down(); - IBlockState state = worldIn.getBlockState(down); - boolean isSoil = state.getBlock().canSustainPlant(state, worldIn, down, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING)); - - if (isSoil && position.getY() < worldIn.getHeight() - i - 1) { - state.getBlock().onPlantGrow(state, worldIn, down, position); - EnumFacing enumfacing = EnumFacing.Plane.HORIZONTAL.random(rand); - int k2 = i - rand.nextInt(4) - 1; - int l2 = 3 - rand.nextInt(3); - int i3 = position.getX(); - int j1 = position.getZ(); - int k1 = 0; - - for (int l1 = 0; l1 < i; ++l1) { - int i2 = position.getY() + l1; - - if (l1 >= k2 && l2 > 0) { - i3 += enumfacing.getFrontOffsetX(); - j1 += enumfacing.getFrontOffsetZ(); - --l2; - } - - BlockPos blockpos = new BlockPos(i3, i2, j1); - state = worldIn.getBlockState(blockpos); - - if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos)) { - this.placeLogAt(worldIn, blockpos); - k1 = i2; - } - } - - BlockPos blockpos2 = new BlockPos(i3, k1, j1); - - for (int j3 = -3; j3 <= 3; ++j3) { - for (int i4 = -3; i4 <= 3; ++i4) { - if (Math.abs(j3) != 3 || Math.abs(i4) != 3) { - this.placeLeafAt(worldIn, blockpos2.add(j3, 0, i4)); - } - } - } - - blockpos2 = blockpos2.up(); - - for (int k3 = -1; k3 <= 1; ++k3) { - for (int j4 = -1; j4 <= 1; ++j4) { - this.placeLeafAt(worldIn, blockpos2.add(k3, 0, j4)); - } - } - - this.placeLeafAt(worldIn, blockpos2.east(2)); - this.placeLeafAt(worldIn, blockpos2.west(2)); - this.placeLeafAt(worldIn, blockpos2.south(2)); - this.placeLeafAt(worldIn, blockpos2.north(2)); - i3 = position.getX(); - j1 = position.getZ(); - EnumFacing enumfacing1 = EnumFacing.Plane.HORIZONTAL.random(rand); - - if (enumfacing1 != enumfacing) { - int l3 = k2 - rand.nextInt(2) - 1; - int k4 = 1 + rand.nextInt(3); - k1 = 0; - - for (int l4 = l3; l4 < i && k4 > 0; --k4, ++l4) { - if (l4 >= 1) { - int j2 = position.getY() + l4; - i3 += enumfacing1.getFrontOffsetX(); - j1 += enumfacing1.getFrontOffsetZ(); - BlockPos blockpos1 = new BlockPos(i3, j2, j1); - state = worldIn.getBlockState(blockpos1); - - if (state.getBlock().isAir(state, worldIn, blockpos1) || state.getBlock().isLeaves(state, worldIn, blockpos1)) { - this.placeLogAt(worldIn, blockpos1); - k1 = j2; - } - } - - } - - if (k1 > 0) { - BlockPos blockpos3 = new BlockPos(i3, k1, j1); - - for (int i5 = -2; i5 <= 2; ++i5) { - for (int k5 = -2; k5 <= 2; ++k5) { - if (Math.abs(i5) != 2 || Math.abs(k5) != 2) { - this.placeLeafAt(worldIn, blockpos3.add(i5, 0, k5)); - } - } - } - - blockpos3 = blockpos3.up(); - - for (int j5 = -1; j5 <= 1; ++j5) { - for (int l5 = -1; l5 <= 1; ++l5) { - this.placeLeafAt(worldIn, blockpos3.add(j5, 0, l5)); - } - } - } - } - - return true; - } else { - return false; - } - } - } else { - return false; - } - } - - private void placeLogAt(World worldIn, BlockPos pos) { - this.setBlockAndNotifyAdequately(worldIn, pos, TRUNK); - } - - private void placeLeafAt(World worldIn, BlockPos pos) { - IBlockState state = worldIn.getBlockState(pos); - - if (state.getBlock().isAir(state, worldIn, pos) || state.getBlock().isLeaves(state, worldIn, pos)) { - this.setBlockAndNotifyAdequately(worldIn, pos, LEAF); - } - } + + private static final IBlockState TRUNK = BlockRegistry.ebony_log.getDefaultState(); + private static final IBlockState LEAF = BlockRegistry.ebony_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, true); + + public WorldGenEbony(boolean doBlockNotify) { + super(doBlockNotify); + } + + public boolean generate(World worldIn, Random rand, BlockPos position) { + int i = rand.nextInt(3) + rand.nextInt(3) + 5; + boolean flag = true; + + if (position.getY() >= 1 && position.getY() + i + 1 <= 256) { + for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { + int k = 1; + if (j == position.getY()) { + k = 0; + } + + if (j >= position.getY() + 1 + i - 2) { + k = 2; + } + + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { + for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { + if (j >= 0 && j < 256) { + if (!this.isReplaceable(worldIn, mutableBlockPos.setPos(l, j, i1))) { + flag = false; + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + return false; + } else { + BlockPos down = position.down(); + IBlockState state = worldIn.getBlockState(down); + boolean isSoil = state.getBlock().canSustainPlant(state, worldIn, down, EnumFacing.UP, ((BlockSapling) Blocks.SAPLING)); + if (isSoil && position.getY() < worldIn.getHeight() - i - 1) { + state.getBlock().onPlantGrow(state, worldIn, down, position); + EnumFacing enumfacing = EnumFacing.Plane.HORIZONTAL.random(rand); + int k2 = i - rand.nextInt(4) - 1; + int l2 = 3 - rand.nextInt(3); + int i3 = position.getX(); + int j1 = position.getZ(); + int k1 = 0; + + for (int l1 = 0; l1 < i; ++l1) { + int i2 = position.getY() + l1; + if (l1 >= k2 && l2 > 0) { + i3 += enumfacing.getXOffset(); + j1 += enumfacing.getZOffset(); + --l2; + } + + BlockPos blockpos = new BlockPos(i3, i2, j1); + state = worldIn.getBlockState(blockpos); + if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos)) { + this.placeLogAt(worldIn, blockpos); + k1 = i2; + } + } + + BlockPos blockpos2 = new BlockPos(i3, k1, j1); + for (int j3 = -3; j3 <= 3; ++j3) { + for (int i4 = -3; i4 <= 3; ++i4) { + if (Math.abs(j3) != 3 || Math.abs(i4) != 3) { + this.placeLeafAt(worldIn, blockpos2.add(j3, 0, i4)); + } + } + } + + blockpos2 = blockpos2.up(); + for (int k3 = -1; k3 <= 1; ++k3) { + for (int j4 = -1; j4 <= 1; ++j4) { + this.placeLeafAt(worldIn, blockpos2.add(k3, 0, j4)); + } + } + + this.placeLeafAt(worldIn, blockpos2.east(2)); + this.placeLeafAt(worldIn, blockpos2.west(2)); + this.placeLeafAt(worldIn, blockpos2.south(2)); + this.placeLeafAt(worldIn, blockpos2.north(2)); + i3 = position.getX(); + j1 = position.getZ(); + EnumFacing enumfacing1 = EnumFacing.Plane.HORIZONTAL.random(rand); + if (enumfacing1 != enumfacing) { + int l3 = k2 - rand.nextInt(2) - 1; + int k4 = 1 + rand.nextInt(3); + k1 = 0; + + for (int l4 = l3; l4 < i && k4 > 0; --k4, ++l4) { + if (l4 >= 1) { + int j2 = position.getY() + l4; + i3 += enumfacing1.getXOffset(); + j1 += enumfacing1.getZOffset(); + BlockPos blockpos1 = new BlockPos(i3, j2, j1); + state = worldIn.getBlockState(blockpos1); + if (state.getBlock().isAir(state, worldIn, blockpos1) || state.getBlock().isLeaves(state, worldIn, blockpos1)) { + this.placeLogAt(worldIn, blockpos1); + k1 = j2; + } + } + } + + if (k1 > 0) { + BlockPos blockpos3 = new BlockPos(i3, k1, j1); + for (int i5 = -2; i5 <= 2; ++i5) { + for (int k5 = -2; k5 <= 2; ++k5) { + if (Math.abs(i5) != 2 || Math.abs(k5) != 2) { + this.placeLeafAt(worldIn, blockpos3.add(i5, 0, k5)); + } + } + } + + blockpos3 = blockpos3.up(); + for (int j5 = -1; j5 <= 1; ++j5) { + for (int l5 = -1; l5 <= 1; ++l5) { + this.placeLeafAt(worldIn, blockpos3.add(j5, 0, l5)); + } + } + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } + + private void placeLogAt(World worldIn, BlockPos pos) { + this.setBlockAndNotifyAdequately(worldIn, pos, TRUNK); + } + + private void placeLeafAt(World worldIn, BlockPos pos) { + IBlockState state = worldIn.getBlockState(pos); + if (state.getBlock().isAir(state, worldIn, pos) || state.getBlock().isLeaves(state, worldIn, pos)) { + this.setBlockAndNotifyAdequately(worldIn, pos, LEAF); + } + } } diff --git a/src/main/java/panda/gotwood/generation/WorldGenFir.java b/src/main/java/panda/gotwood/generation/WorldGenFir.java index b4c78e4..d14a29d 100644 --- a/src/main/java/panda/gotwood/generation/WorldGenFir.java +++ b/src/main/java/panda/gotwood/generation/WorldGenFir.java @@ -1,121 +1,110 @@ package panda.gotwood.generation; -import java.util.Random; - import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; - import panda.gotwood.block.BlockWoodLeaves; import panda.gotwood.registry.BlockRegistry; -public class WorldGenFir extends WorldGenAbstractTree { - private static final IBlockState TRUNK = BlockRegistry.fir_log.getDefaultState(); - - private static final IBlockState LEAF = BlockRegistry.fir_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, Boolean.valueOf(true)); - - public WorldGenFir(boolean bool) { - super(bool); - } - - public boolean generate(World worldIn, Random rand, BlockPos position) { - int i = rand.nextInt(4) + 6; - int j = 1 + rand.nextInt(2); - int k = i - j; - int l = 2 + rand.nextInt(2); - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { - for (int i1 = position.getY(); i1 <= position.getY() + 1 + i && flag; ++i1) { - int j1; - - if (i1 - position.getY() < j) { - j1 = 0; - } else { - j1 = l; - } - - BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos(); - - for (int k1 = position.getX() - j1; k1 <= position.getX() + j1 && flag; ++k1) { - for (int l1 = position.getZ() - j1; l1 <= position.getZ() + j1 && flag; ++l1) { - if (i1 >= 0 && i1 < worldIn.getHeight()) { - IBlockState state = worldIn.getBlockState(blockposmutableblockpos.setPos(k1, i1, l1)); - - if (!state.getBlock().isAir(state, worldIn, blockposmutableblockpos.setPos(k1, i1, l1)) && !state.getBlock().isLeaves(state, worldIn, blockposmutableblockpos.setPos(k1, i1, l1))) { - flag = false; - } - } else { - flag = false; - } - } - } - } - - if (!flag) { - return false; - } else { - BlockPos down = position.down(); - IBlockState state = worldIn.getBlockState(down); - - if (state.getBlock().canSustainPlant(state, worldIn, down, net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { - state.getBlock().onPlantGrow(state, worldIn, down, position); - int i3 = rand.nextInt(2); - int j3 = 1; - int k3 = 0; - - for (int l3 = 0; l3 <= k; ++l3) { - int j4 = position.getY() + i - l3; - - for (int i2 = position.getX() - i3; i2 <= position.getX() + i3; ++i2) { - int j2 = i2 - position.getX(); - - for (int k2 = position.getZ() - i3; k2 <= position.getZ() + i3; ++k2) { - int l2 = k2 - position.getZ(); - - if (Math.abs(j2) != i3 || Math.abs(l2) != i3 || i3 <= 0) { - BlockPos blockpos = new BlockPos(i2, j4, k2); - state = worldIn.getBlockState(blockpos); - - if (state.getBlock().canBeReplacedByLeaves(state, worldIn, blockpos)) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, LEAF); - } - } - } - } - - if (i3 >= j3) { - i3 = k3; - k3 = 1; - ++j3; - - if (j3 > l) { - j3 = l; - } - } else { - ++i3; - } - } - - int i4 = rand.nextInt(3); - - for (int k4 = 0; k4 < i - i4; ++k4) { - BlockPos upN = position.up(k4); - state = worldIn.getBlockState(upN); +import java.util.Random; - if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN)) { - this.setBlockAndNotifyAdequately(worldIn, position.up(k4), TRUNK); - } - } +public class WorldGenFir extends WorldGenAbstractTree { - return true; - } else { - return false; - } - } - } else { - return false; - } - } + private static final IBlockState TRUNK = BlockRegistry.fir_log.getDefaultState(); + private static final IBlockState LEAF = BlockRegistry.fir_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, true); + + public WorldGenFir(boolean bool) { + super(bool); + } + + public boolean generate(World worldIn, Random rand, BlockPos position) { + int i = rand.nextInt(4) + 6; + int j = 1 + rand.nextInt(2); + int k = i - j; + int l = 2 + rand.nextInt(2); + boolean flag = true; + if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { + for (int i1 = position.getY(); i1 <= position.getY() + 1 + i && flag; ++i1) { + int j1; + if (i1 - position.getY() < j) { + j1 = 0; + } else { + j1 = l; + } + + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + + for (int k1 = position.getX() - j1; k1 <= position.getX() + j1 && flag; ++k1) { + for (int l1 = position.getZ() - j1; l1 <= position.getZ() + j1 && flag; ++l1) { + if (i1 >= 0 && i1 < worldIn.getHeight()) { + IBlockState state = worldIn.getBlockState(mutableBlockPos.setPos(k1, i1, l1)); + + if (!state.getBlock().isAir(state, worldIn, mutableBlockPos.setPos(k1, i1, l1)) && !state.getBlock().isLeaves(state, worldIn, mutableBlockPos.setPos(k1, i1, l1))) { + flag = false; + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + return false; + } else { + BlockPos down = position.down(); + IBlockState state = worldIn.getBlockState(down); + if (state.getBlock().canSustainPlant(state, worldIn, down, net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { + state.getBlock().onPlantGrow(state, worldIn, down, position); + int i3 = rand.nextInt(2); + int j3 = 1; + int k3 = 0; + + for (int l3 = 0; l3 <= k; ++l3) { + int j4 = position.getY() + i - l3; + for (int i2 = position.getX() - i3; i2 <= position.getX() + i3; ++i2) { + int j2 = i2 - position.getX(); + for (int k2 = position.getZ() - i3; k2 <= position.getZ() + i3; ++k2) { + int l2 = k2 - position.getZ(); + if (Math.abs(j2) != i3 || Math.abs(l2) != i3 || i3 <= 0) { + BlockPos blockpos = new BlockPos(i2, j4, k2); + state = worldIn.getBlockState(blockpos); + + if (state.getBlock().canBeReplacedByLeaves(state, worldIn, blockpos)) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, LEAF); + } + } + } + } + + if (i3 >= j3) { + i3 = k3; + k3 = 1; + ++j3; + if (j3 > l) { + j3 = l; + } + } else { + ++i3; + } + } + + int i4 = rand.nextInt(3); + for (int k4 = 0; k4 < i - i4; ++k4) { + BlockPos upN = position.up(k4); + state = worldIn.getBlockState(upN); + if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN)) { + this.setBlockAndNotifyAdequately(worldIn, position.up(k4), TRUNK); + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } } diff --git a/src/main/java/panda/gotwood/generation/WorldGenMaple.java b/src/main/java/panda/gotwood/generation/WorldGenMaple.java index 523f33d..4ab492e 100644 --- a/src/main/java/panda/gotwood/generation/WorldGenMaple.java +++ b/src/main/java/panda/gotwood/generation/WorldGenMaple.java @@ -1,292 +1,294 @@ package panda.gotwood.generation; -import java.util.Random; - import net.minecraft.block.BlockLog; +import net.minecraft.block.BlockSapling; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; - import panda.gotwood.block.BlockWoodLeaves; import panda.gotwood.registry.BlockRegistry; -public class WorldGenMaple extends WorldGenAbstractTree { - private static final IBlockState DEFAULT_TRUNK = BlockRegistry.maple_log.getDefaultState(); - - private static final IBlockState DEFAULT_LEAF = BlockRegistry.maple_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, Boolean.valueOf(true)); - - /** - * The metadata value of the wood to use in tree generation. - */ - private final IBlockState metaWood; - - /** - * The metadata value of the leaves to use in tree generation. - */ - private final IBlockState metaLeaves; - - /** - * Sets wither or not the generator should notify blocks of blocks it changes. When the world is first generated, - * this is false, when saplings grow, this is true. - */ - public WorldGenMaple(boolean notify) { - this(notify, DEFAULT_TRUNK, DEFAULT_LEAF); - } - - public WorldGenMaple(boolean notify, IBlockState metawood, IBlockState metaleaves) { - super(notify); - this.metaWood = metawood; - this.metaLeaves = metaleaves; - } - - @Override - public boolean generate(World world, Random rand, BlockPos pos) { - byte type = chooseTreeGenType(world); - if (type == 1) { - generateNormal(world, rand, pos); - return generateNormal(world, rand, pos); - } else if (type == 2) { - generateMini(world, rand, pos); - return generateMini(world, rand, pos); - } else if (type == 3) { - generateBig(world, rand, pos); - return generateBig(world, rand, pos); - } else - return generateNormal(world, rand, pos); - } - - private boolean generateNormal(World worldIn, Random rand, BlockPos position) { - int i = rand.nextInt(3) + 5; - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { - - flag = isAreaClear(worldIn, position, i); - - if (!flag) { - return false; - } else { - IBlockState state = worldIn.getBlockState(position.down()); - - if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { - this.setDirtAt(worldIn, position.down()); - - for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { - int i4 = i3 - (position.getY() + i); - int j1 = 1 - i4 / 2; - - for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { - int l1 = k1 - position.getX(); - - for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { - int j2 = i2 - position.getZ(); - - if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { - BlockPos blockpos = new BlockPos(k1, i3, i2); - state = worldIn.getBlockState(blockpos); - - if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); - } - } - } - } - } - - for (int j3 = 0; j3 < i; ++j3) { - BlockPos upN = position.up(j3); - state = worldIn.getBlockState(upN); - - if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); - } - } - - return true; - } else { - return false; - } - } - } else { - return false; - } - } - - private boolean generateBig(World worldIn, Random rand, BlockPos position) { - int i = rand.nextInt(2) + 9; - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { - flag = isAreaClear(worldIn, position, i); - - if (!flag) { - return false; - } - - //If we can actually make the tree - else { - IBlockState state = worldIn.getBlockState(position.down()); - - if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { - this.setDirtAt(worldIn, position.down()); - - //MAKE LEAVES - final int[][] leafPos = new int[][] { { -1, 0, 0 }, { 0, 0, 1 }, { 0, 0, -1 }, { 1, 0, 0 }, { -1, 1, 1 }, { -1, 1, 0 }, { -1, 1, -1 }, { 0, 1, 1 }, { 0, 1, -1 }, { 1, 1, 1 }, { 1, 1, 0 }, { 1, 1, -1 }, { 2, 1, 1 }, { -2, 1, 1 }, { -2, 1, 0 }, { -2, 1, -1 }, { -1, 1, 2 }, { -1, 1, -2 }, { 0, 1, 2 }, { 0, 1, -2 }, { 2, 1, 0 }, { 2, 1, -1 }, { 1, 1, 2 }, { 1, 1, -2 }, { -3, 1, 0 }, { 3, 1, 0 }, { 0, 1, -3 }, { 0, 1, 3 }, { -2, 1, 2 }, { -2, 1, -2 }, { 2, 1, 2 }, { 2, 1, -2 }, { -1, 2, 1 }, { -1, 2, 0 }, { -1, 2, -1 }, { 0, 2, 1 }, { 0, 2, -1 }, { 1, 2, 1 }, { 1, 2, 0 }, { 1, 2, -1 }, { 2, 2, 1 }, { -2, 2, 1 }, { -2, 2, 0 }, { -2, 2, -1 }, { -1, 2, 2 }, { -1, 2, -2 }, { 0, 2, 2 }, { 0, 2, -2 }, { 2, 2, 0 }, { 2, 2, -1 }, { 1, 2, 2 }, { 1, 2, -2 }, { -3, 2, 0 }, { 3, 2, 0 }, - { 0, 2, -3 }, { 0, 2, 3 }, { -2, 2, 2 }, { -2, 2, -2 }, { 2, 2, 2 }, { 2, 2, -2 }, { -3, 2, -1 }, { -3, 2, 1 }, { -1, 2, -3 }, { -1, 2, 3 }, { 1, 2, 3 }, { 3, 2, 1 }, { 1, 2, -3 }, { 3, 2, -1 }, { -1, 3, 1 }, { -1, 3, 0 }, { -1, 3, -1 }, { 0, 3, 1 }, { 0, 3, -1 }, { 1, 3, 1 }, { 1, 3, 0 }, { 1, 3, -1 }, { 2, 3, 1 }, { -2, 3, 1 }, { -2, 3, 0 }, { -2, 3, -1 }, { -1, 3, 2 }, { -1, 3, -2 }, { 0, 3, 2 }, { 0, 3, -2 }, { 2, 3, 0 }, { 2, 3, -1 }, { 1, 3, 2 }, { 1, 3, -2 }, { -3, 3, 0 }, { 3, 3, 0 }, { 0, 3, -3 }, { 0, 3, 3 }, { -2, 3, 2 }, { -2, 3, -2 }, { 2, 3, 2 }, { 2, 3, -2 }, { -3, 3, -1 }, { -3, 3, 1 }, { -1, 3, -3 }, { -1, 3, 3 }, { 1, 3, 3 }, { 3, 3, 1 }, { 1, 3, -3 }, { 3, 3, -1 }, { -1, 4, 1 }, { -1, 4, 0 }, { -1, 4, -1 }, { 0, 4, 1 }, { 0, 4, -1 }, { 1, 4, 1 }, - { 1, 4, 0 }, { 1, 4, -1 }, { 2, 4, 1 }, { -2, 4, 1 }, { -2, 4, 0 }, { -2, 4, -1 }, { -1, 4, 2 }, { -1, 4, -2 }, { 0, 4, 2 }, { 0, 4, -2 }, { 2, 4, 0 }, { 2, 4, -1 }, { 1, 4, 2 }, { 1, 4, -2 }, { -3, 4, 0 }, { 3, 4, 0 }, { 0, 4, -3 }, { 0, 4, 3 }, { -1, 5, 1 }, { -1, 5, 0 }, { -1, 5, -1 }, { 0, 5, 1 }, { 0, 5, -1 }, { 1, 5, 1 }, { 1, 5, 0 }, { 1, 5, -1 }, { 2, 5, 1 }, { -2, 5, 1 }, { -2, 5, 0 }, { -2, 5, -1 }, { -1, 5, 2 }, { -1, 5, -2 }, { 0, 5, 2 }, { 0, 5, -2 }, { 2, 5, 0 }, { 2, 5, -1 }, { 1, 5, 2 }, { 1, 5, -2 }, { -1, 6, 0 }, { 0, 6, 1 }, { 0, 6, -1 }, { 1, 6, 0 }, { 0, 7, 0 } }; - - for (int[] coord : leafPos) { - BlockPos blockpos = position.add(coord[0], coord[1] + (i - 7), coord[2]); - state = worldIn.getBlockState(blockpos); - if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); - } - } - - //MAKE TRUNK - for (int j3 = 0; j3 < i; ++j3) { - BlockPos upN = position.up(j3); - state = worldIn.getBlockState(upN); - - if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); - if (j3 == i - 4) { - - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - if (rand.nextBoolean()) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - } - - } else if (j3 == i - 6) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - if (rand.nextBoolean()) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - } - } - } - } - - return true; - } else { - return false; - } - } - } else { - return false; - } - } - - private boolean generateMini(World worldIn, Random rand, BlockPos position) { - int i = rand.nextInt(2) + 6; - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { - flag = isAreaClear(worldIn, position, i); - - if (!flag) { - return false; - } - - //If we can actually make the tree - else { - IBlockState state = worldIn.getBlockState(position.down()); - - if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { - this.setDirtAt(worldIn, position.down()); - - //MAKE LEAVES - final int[][] leafPos = new int[][] { { -1, 0, 1 }, { -1, 0, 0 }, { -1, 0, -1 }, { 0, 0, 1 }, { 0, 0, -1 }, { 1, 0, 1 }, { 1, 0, 0 }, { 1, 0, -1 }, { -1, 1, 1 }, { -1, 1, 0 }, { -1, 1, -1 }, { 0, 1, 1 }, { 0, 1, -1 }, { 0, 1, -2 }, { 1, 1, 1 }, { 1, 1, 0 }, { 1, 1, -1 }, { -1, 1, 0 }, { -1, 1, -1 }, { -2, 1, 1 }, { -2, 1, 0 }, { -2, 1, -1 }, { 2, 1, -1 }, { 2, 1, 0 }, { 2, 1, 1 }, { -1, 1, 2 }, { 0, 1, 2 }, { 1, 1, 2 }, { -1, 1, -2 }, { 1, 1, -2 }, { 1, 1, -2 }, { -1, 2, 1 }, { -1, 2, 0 }, { -1, 2, -1 }, { 0, 2, 1 }, { 0, 2, -1 }, { 1, 2, 1 }, { 1, 2, 0 }, { 1, 2, -1 }, { -2, 2, 0 }, { 2, 2, 0 }, { 0, 2, 2 }, { 0, 2, -2 }, { -1, 3, 1 }, { -1, 3, 0 }, { -1, 3, -1 }, { 0, 3, 1 }, { 0, 3, -1 }, { 1, 3, 1 }, { 1, 3, 0 }, { 1, 3, -1 }, { -1, 4, 0 }, { 0, 4, 1 }, - { 0, 4, -1 }, { 1, 4, 0 }, { 0, 5, 0 } }; - - for (int[] coord : leafPos) { - BlockPos blockpos = position.add(coord[0], coord[1] + (i - 5), coord[2]); - state = worldIn.getBlockState(blockpos); - if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); - } - } - //MAKE TRUNK - for (int j3 = 0; j3 < i; ++j3) { - BlockPos upN = position.up(j3); - state = worldIn.getBlockState(upN); - - if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); - if (j3 == i - 4) { - - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - if (rand.nextBoolean()) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - } - - } - } - } - - return true; - } else { - return false; - } - } - } else { - return false; - } - } - - public byte chooseTreeGenType(World world) { - byte r = (byte) world.rand.nextInt(4); - //big maple - if (r == 0) { - return 3; - } else - //mini maple - if (r == 1 || r == 2) { - return 2; - } else - //regular - return 1; - } - - private boolean isAreaClear(World worldIn, BlockPos position, int treeheight) { - boolean flag = false; - for (int j = position.getY(); j <= position.getY() + 1 + treeheight; ++j) { - int k = 1; - - if (j == position.getY()) { - k = 0; - } - - if (j >= position.getY() + 1 + treeheight - 2) { - k = 1; - } - - BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos(); +import java.util.Random; - for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { - for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { - if (j >= 0 && j < worldIn.getHeight()) { - if (!this.isReplaceable(worldIn, blockposmutableblockpos.setPos(l, j, i1))) { - return false; - } - } else { - return false; - } - } - } - } - return true; - } +public class WorldGenMaple extends WorldGenAbstractTree { + private static final IBlockState DEFAULT_TRUNK = BlockRegistry.maple_log.getDefaultState(); + private static final IBlockState DEFAULT_LEAF = BlockRegistry.maple_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, true); + + /** + * The metadata value of the wood to use in tree generation. + */ + private final IBlockState metaWood; + + /** + * The metadata value of the leaves to use in tree generation. + */ + private final IBlockState metaLeaves; + + /** + * Sets wither or not the generator should notify blocks of blocks it changes. When the world is first generated, + * this is false, when saplings grow, this is true. + */ + public WorldGenMaple(boolean notify) { + this(notify, DEFAULT_TRUNK, DEFAULT_LEAF); + } + + public WorldGenMaple(boolean notify, IBlockState metawood, IBlockState metaleaves) { + super(notify); + this.metaWood = metawood; + this.metaLeaves = metaleaves; + } + + @Override + public boolean generate(World world, Random rand, BlockPos pos) { + byte type = chooseTreeGenType(world); + if (type == 1) { + generateNormal(world, rand, pos); + return generateNormal(world, rand, pos); + } else { + if (type == 2) { + generateMini(world, rand, pos); + return generateMini(world, rand, pos); + } else { + if (type == 3) { + generateBig(world, rand, pos); + return generateBig(world, rand, pos); + } else { + + return generateNormal(world, rand, pos); + } + } + } + } + + private boolean generateNormal(World worldIn, Random rand, BlockPos position) { + int i = rand.nextInt(3) + 5; + boolean flag = true; + if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { + flag = isAreaClear(worldIn, position, i); + if (!flag) { + return false; + } else { + IBlockState state = worldIn.getBlockState(position.down()); + if (state.getBlock().canSustainPlant(state, worldIn, position.down(), EnumFacing.UP, (BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { + this.setDirtAt(worldIn, position.down()); + for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { + int i4 = i3 - (position.getY() + i); + int j1 = 1 - i4 / 2; + for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { + int l1 = k1 - position.getX(); + for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { + int j2 = i2 - position.getZ(); + if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { + BlockPos blockpos = new BlockPos(k1, i3, i2); + state = worldIn.getBlockState(blockpos); + if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); + } + } + } + } + } + + for (int j3 = 0; j3 < i; ++j3) { + BlockPos upN = position.up(j3); + state = worldIn.getBlockState(upN); + if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } + + private boolean generateBig(World worldIn, Random rand, BlockPos position) { + int i = rand.nextInt(2) + 9; + boolean flag = true; + if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { + flag = isAreaClear(worldIn, position, i); + if (!flag) { + return false; + } + + //If we can actually make the tree + else { + IBlockState state = worldIn.getBlockState(position.down()); + if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { + this.setDirtAt(worldIn, position.down()); + //MAKE LEAVES + final int[][] leafPos = new int[][]{{-1, 0, 0}, + {0, 0, 1}, {0, 0, -1}, {1, 0, 0}, {-1, 1, 1}, {-1, 1, 0}, {-1, 1, -1}, {0, 1, 1}, {0, 1, -1}, {1, 1, 1}, {1, 1, 0}, + {1, 1, -1}, {2, 1, 1}, {-2, 1, 1}, {-2, 1, 0}, {-2, 1, -1}, {-1, 1, 2}, {-1, 1, -2}, {0, 1, 2}, {0, 1, -2}, {2, 1, 0}, + {2, 1, -1}, {1, 1, 2}, {1, 1, -2}, {-3, 1, 0}, {3, 1, 0}, {0, 1, -3}, {0, 1, 3}, {-2, 1, 2}, {-2, 1, -2}, {2, 1, 2}, + {2, 1, -2}, {-1, 2, 1}, {-1, 2, 0}, {-1, 2, -1}, {0, 2, 1}, {0, 2, -1}, {1, 2, 1}, {1, 2, 0}, {1, 2, -1}, {2, 2, 1}, + {-2, 2, 1}, {-2, 2, 0}, {-2, 2, -1}, {-1, 2, 2}, {-1, 2, -2}, {0, 2, 2}, {0, 2, -2}, {2, 2, 0}, {2, 2, -1}, {1, 2, 2}, + {1, 2, -2}, {-3, 2, 0}, {3, 2, 0}, {0, 2, -3}, {0, 2, 3}, {-2, 2, 2}, {-2, 2, -2}, {2, 2, 2}, {2, 2, -2}, {-3, 2, -1}, + {-3, 2, 1}, {-1, 2, -3}, {-1, 2, 3}, {1, 2, 3}, {3, 2, 1}, {1, 2, -3}, {3, 2, -1}, {-1, 3, 1}, {-1, 3, 0}, {-1, 3, -1}, + {0, 3, 1}, {0, 3, -1}, {1, 3, 1}, {1, 3, 0}, {1, 3, -1}, {2, 3, 1}, {-2, 3, 1}, {-2, 3, 0}, {-2, 3, -1}, {-1, 3, 2}, + {-1, 3, -2}, {0, 3, 2}, {0, 3, -2}, {2, 3, 0}, {2, 3, -1}, {1, 3, 2}, {1, 3, -2}, {-3, 3, 0}, {3, 3, 0}, {0, 3, -3}, + {0, 3, 3}, {-2, 3, 2}, {-2, 3, -2}, {2, 3, 2}, {2, 3, -2}, {-3, 3, -1}, {-3, 3, 1}, {-1, 3, -3}, {-1, 3, 3}, {1, 3, 3}, + {3, 3, 1}, {1, 3, -3}, {3, 3, -1}, {-1, 4, 1}, {-1, 4, 0}, {-1, 4, -1}, {0, 4, 1}, {0, 4, -1}, {1, 4, 1}, {1, 4, 0}, + {1, 4, -1}, {2, 4, 1}, {-2, 4, 1}, {-2, 4, 0}, {-2, 4, -1}, {-1, 4, 2}, {-1, 4, -2}, {0, 4, 2}, {0, 4, -2}, {2, 4, 0}, + {2, 4, -1}, {1, 4, 2}, {1, 4, -2}, {-3, 4, 0}, {3, 4, 0}, {0, 4, -3}, {0, 4, 3}, {-1, 5, 1}, {-1, 5, 0}, {-1, 5, -1}, + {0, 5, 1}, {0, 5, -1}, {1, 5, 1}, {1, 5, 0}, {1, 5, -1}, {2, 5, 1}, {-2, 5, 1}, {-2, 5, 0}, {-2, 5, -1}, {-1, 5, 2}, + {-1, 5, -2}, {0, 5, 2}, {0, 5, -2}, {2, 5, 0}, {2, 5, -1}, {1, 5, 2}, {1, 5, -2}, {-1, 6, 0}, {0, 6, 1}, {0, 6, -1}, + {1, 6, 0}, {0, 7, 0}}; + + for (int[] coord : leafPos) { + BlockPos blockpos = position.add(coord[0], coord[1] + (i - 7), coord[2]); + state = worldIn.getBlockState(blockpos); + if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); + } + } + + //MAKE TRUNK + for (int j3 = 0; j3 < i; ++j3) { + BlockPos upN = position.up(j3); + state = worldIn.getBlockState(upN); + if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); + if (j3 == i - 4) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + + if (rand.nextBoolean()) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + } + } else if (j3 == i - 6) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + + if (rand.nextBoolean()) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + } + } + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } + + private boolean generateMini(World worldIn, Random rand, BlockPos position) { + int i = rand.nextInt(2) + 6; + boolean flag = true; + + if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { + flag = isAreaClear(worldIn, position, i); + if (!flag) { + return false; + } else { //If we can actually make the tree + IBlockState state = worldIn.getBlockState(position.down()); + if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { + this.setDirtAt(worldIn, position.down()); + + //MAKE LEAVES + final int[][] leafPos = new int[][]{{-1, 0, 1}, + {-1, 0, 0}, {-1, 0, -1}, {0, 0, 1}, {0, 0, -1}, {1, 0, 1}, {1, 0, 0}, {1, 0, -1}, {-1, 1, 1}, {-1, 1, 0}, + {-1, 1, -1}, {0, 1, 1}, {0, 1, -1}, {0, 1, -2}, {1, 1, 1}, {1, 1, 0}, {1, 1, -1}, {-1, 1, 0}, {-1, 1, -1}, + {-2, 1, 1}, {-2, 1, 0}, {-2, 1, -1}, {2, 1, -1}, {2, 1, 0}, {2, 1, 1}, {-1, 1, 2}, {0, 1, 2}, {1, 1, 2}, + {-1, 1, -2}, {1, 1, -2}, {1, 1, -2}, {-1, 2, 1}, {-1, 2, 0}, {-1, 2, -1}, {0, 2, 1}, {0, 2, -1}, {1, 2, 1}, + {1, 2, 0}, {1, 2, -1}, {-2, 2, 0}, {2, 2, 0}, {0, 2, 2}, {0, 2, -2}, {-1, 3, 1}, {-1, 3, 0}, {-1, 3, -1}, + {0, 3, 1}, {0, 3, -1}, {1, 3, 1}, {1, 3, 0}, {1, 3, -1}, {-1, 4, 0}, {0, 4, 1}, {0, 4, -1}, {1, 4, 0}, {0, 5, 0}}; + + for (int[] coord : leafPos) { + BlockPos blockpos = position.add(coord[0], coord[1] + (i - 5), coord[2]); + state = worldIn.getBlockState(blockpos); + if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); + } + } + //MAKE TRUNK + for (int j3 = 0; j3 < i; ++j3) { + BlockPos upN = position.up(j3); + state = worldIn.getBlockState(upN); + if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); + if (j3 == i - 4) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + + if (rand.nextBoolean()) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + } + } + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } + + public byte chooseTreeGenType(World world) { + byte r = (byte) world.rand.nextInt(4); + //big maple + if (r == 0) { + return 3; + } else { + //mini maple + if (r == 1 || r == 2) { + return 2; + } else { + //regular + return 1; + } + } + } + + private boolean isAreaClear(World worldIn, BlockPos position, int treeheight) { + boolean flag = false; + for (int j = position.getY(); j <= position.getY() + 1 + treeheight; ++j) { + int k = 1; + if (j == position.getY()) { + k = 0; + } + + if (j >= position.getY() + 1 + treeheight - 2) { + k = 1; + } + + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + + for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { + for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { + if (j >= 0 && j < worldIn.getHeight()) { + if (!this.isReplaceable(worldIn, mutableBlockPos.setPos(l, j, i1))) { + return false; + } + } else { + return false; + } + } + } + } + return true; + } } diff --git a/src/main/java/panda/gotwood/generation/WorldGenPalm.java b/src/main/java/panda/gotwood/generation/WorldGenPalm.java index 5d40b80..497119d 100644 --- a/src/main/java/panda/gotwood/generation/WorldGenPalm.java +++ b/src/main/java/panda/gotwood/generation/WorldGenPalm.java @@ -1,291 +1,288 @@ package panda.gotwood.generation; -import java.util.Random; - import net.minecraft.block.BlockLog; +import net.minecraft.block.BlockSapling; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; - import panda.gotwood.block.BlockWoodLeaves; import panda.gotwood.registry.BlockRegistry; -public class WorldGenPalm extends WorldGenAbstractTree { - private static final IBlockState DEFAULT_TRUNK = BlockRegistry.palm_log.getDefaultState(); - - private static final IBlockState DEFAULT_LEAF = BlockRegistry.palm_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, Boolean.valueOf(true)); - - /** - * The metadata value of the wood to use in tree generation. - */ - private final IBlockState metaWood; - - /** - * The metadata value of the leaves to use in tree generation. - */ - private final IBlockState metaLeaves; - - /** - * Sets wither or not the generator should notify blocks of blocks it changes. When the world is first generated, - * this is false, when saplings grow, this is true. - */ - public WorldGenPalm(boolean notify) { - this(notify, DEFAULT_TRUNK, DEFAULT_LEAF); - } - - public WorldGenPalm(boolean notify, IBlockState metawood, IBlockState metaleaves) { - super(notify); - this.metaWood = metawood; - this.metaLeaves = metaleaves; - } - - @Override - public boolean generate(World world, Random rand, BlockPos pos) { - byte type = chooseTreeGenType(world); - //TODO 3 and 2 do not work - System.out.println("type "+type); - if (type == 2) { - return generateMini(world, rand, pos); - } else if (type == 3) { - return generateBig(world, rand, pos); - } else - return generateNormal(world, rand, pos); - } - - private boolean generateNormal(World worldIn, Random rand, BlockPos position) { - int i = rand.nextInt(3) + 5; - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { - - flag = isAreaClear(worldIn, position, i); - - if (!flag) { - return false; - } else { - - IBlockState state = worldIn.getBlockState(position.down()); - - if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, net.minecraft.init.Blocks.DEADBUSH) && position.getY() < worldIn.getHeight() - i - 1) { - System.out.println("doot "); - this.setDirtAt(worldIn, position.down()); - - for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { - int i4 = i3 - (position.getY() + i); - int j1 = 1 - i4 / 2; - - for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { - int l1 = k1 - position.getX(); - - for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { - int j2 = i2 - position.getZ(); - - if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { - BlockPos blockpos = new BlockPos(k1, i3, i2); - state = worldIn.getBlockState(blockpos); - - if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); - } - } - } - } - } - - for (int j3 = 0; j3 < i; ++j3) { - BlockPos upN = position.up(j3); - state = worldIn.getBlockState(upN); - - if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); - } - } - - return true; - } else { - return false; - } - } - } else { - return false; - } - } - - private boolean generateBig(World worldIn, Random rand, BlockPos position) { - int i = rand.nextInt(2) + 9; - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { - flag = isAreaClear(worldIn, position, i); - - if (!flag) { - return false; - } - - //If we can actually make the tree - else { - IBlockState state = worldIn.getBlockState(position.down()); - - if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { - this.setDirtAt(worldIn, position.down()); - - //MAKE LEAVES - final int[][] leafPos = new int[][] { { -1, 0, 0 }, { 0, 0, 1 }, { 0, 0, -1 }, { 1, 0, 0 }, { -1, 1, 1 }, { -1, 1, 0 }, { -1, 1, -1 }, { 0, 1, 1 }, { 0, 1, -1 }, { 1, 1, 1 }, { 1, 1, 0 }, { 1, 1, -1 }, { 2, 1, 1 }, { -2, 1, 1 }, { -2, 1, 0 }, { -2, 1, -1 }, { -1, 1, 2 }, { -1, 1, -2 }, { 0, 1, 2 }, { 0, 1, -2 }, { 2, 1, 0 }, { 2, 1, -1 }, { 1, 1, 2 }, { 1, 1, -2 }, { -3, 1, 0 }, { 3, 1, 0 }, { 0, 1, -3 }, { 0, 1, 3 }, { -2, 1, 2 }, { -2, 1, -2 }, { 2, 1, 2 }, { 2, 1, -2 }, { -1, 2, 1 }, { -1, 2, 0 }, { -1, 2, -1 }, { 0, 2, 1 }, { 0, 2, -1 }, { 1, 2, 1 }, { 1, 2, 0 }, { 1, 2, -1 }, { 2, 2, 1 }, { -2, 2, 1 }, { -2, 2, 0 }, { -2, 2, -1 }, { -1, 2, 2 }, { -1, 2, -2 }, { 0, 2, 2 }, { 0, 2, -2 }, { 2, 2, 0 }, { 2, 2, -1 }, { 1, 2, 2 }, { 1, 2, -2 }, { -3, 2, 0 }, { 3, 2, 0 }, - { 0, 2, -3 }, { 0, 2, 3 }, { -2, 2, 2 }, { -2, 2, -2 }, { 2, 2, 2 }, { 2, 2, -2 }, { -3, 2, -1 }, { -3, 2, 1 }, { -1, 2, -3 }, { -1, 2, 3 }, { 1, 2, 3 }, { 3, 2, 1 }, { 1, 2, -3 }, { 3, 2, -1 }, { -1, 3, 1 }, { -1, 3, 0 }, { -1, 3, -1 }, { 0, 3, 1 }, { 0, 3, -1 }, { 1, 3, 1 }, { 1, 3, 0 }, { 1, 3, -1 }, { 2, 3, 1 }, { -2, 3, 1 }, { -2, 3, 0 }, { -2, 3, -1 }, { -1, 3, 2 }, { -1, 3, -2 }, { 0, 3, 2 }, { 0, 3, -2 }, { 2, 3, 0 }, { 2, 3, -1 }, { 1, 3, 2 }, { 1, 3, -2 }, { -3, 3, 0 }, { 3, 3, 0 }, { 0, 3, -3 }, { 0, 3, 3 }, { -2, 3, 2 }, { -2, 3, -2 }, { 2, 3, 2 }, { 2, 3, -2 }, { -3, 3, -1 }, { -3, 3, 1 }, { -1, 3, -3 }, { -1, 3, 3 }, { 1, 3, 3 }, { 3, 3, 1 }, { 1, 3, -3 }, { 3, 3, -1 }, { -1, 4, 1 }, { -1, 4, 0 }, { -1, 4, -1 }, { 0, 4, 1 }, { 0, 4, -1 }, { 1, 4, 1 }, - { 1, 4, 0 }, { 1, 4, -1 }, { 2, 4, 1 }, { -2, 4, 1 }, { -2, 4, 0 }, { -2, 4, -1 }, { -1, 4, 2 }, { -1, 4, -2 }, { 0, 4, 2 }, { 0, 4, -2 }, { 2, 4, 0 }, { 2, 4, -1 }, { 1, 4, 2 }, { 1, 4, -2 }, { -3, 4, 0 }, { 3, 4, 0 }, { 0, 4, -3 }, { 0, 4, 3 }, { -1, 5, 1 }, { -1, 5, 0 }, { -1, 5, -1 }, { 0, 5, 1 }, { 0, 5, -1 }, { 1, 5, 1 }, { 1, 5, 0 }, { 1, 5, -1 }, { 2, 5, 1 }, { -2, 5, 1 }, { -2, 5, 0 }, { -2, 5, -1 }, { -1, 5, 2 }, { -1, 5, -2 }, { 0, 5, 2 }, { 0, 5, -2 }, { 2, 5, 0 }, { 2, 5, -1 }, { 1, 5, 2 }, { 1, 5, -2 }, { -1, 6, 0 }, { 0, 6, 1 }, { 0, 6, -1 }, { 1, 6, 0 }, { 0, 7, 0 } }; - - for (int[] coord : leafPos) { - BlockPos blockpos = position.add(coord[0], coord[1] + (i - 7), coord[2]); - state = worldIn.getBlockState(blockpos); - if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); - } - } - - //MAKE TRUNK - for (int j3 = 0; j3 < i; ++j3) { - BlockPos upN = position.up(j3); - state = worldIn.getBlockState(upN); - - if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); - if (j3 == i - 4) { - - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - if (rand.nextBoolean()) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - } - - } else if (j3 == i - 6) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - if (rand.nextBoolean()) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - } - } - } - } - - return true; - } else { - return false; - } - } - } else { - return false; - } - } - - private boolean generateMini(World worldIn, Random rand, BlockPos position) { - int i = rand.nextInt(2) + 6; - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { - flag = isAreaClear(worldIn, position, i); - - if (!flag) { - return false; - } - - //If we can actually make the tree - else { - IBlockState state = worldIn.getBlockState(position.down()); - - if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { - this.setDirtAt(worldIn, position.down()); - - //MAKE LEAVES - final int[][] leafPos = new int[][] { { -1, 0, 1 }, { -1, 0, 0 }, { -1, 0, -1 }, { 0, 0, 1 }, { 0, 0, -1 }, { 1, 0, 1 }, { 1, 0, 0 }, { 1, 0, -1 }, { -1, 1, 1 }, { -1, 1, 0 }, { -1, 1, -1 }, { 0, 1, 1 }, { 0, 1, -1 }, { 0, 1, -2 }, { 1, 1, 1 }, { 1, 1, 0 }, { 1, 1, -1 }, { -1, 1, 0 }, { -1, 1, -1 }, { -2, 1, 1 }, { -2, 1, 0 }, { -2, 1, -1 }, { 2, 1, -1 }, { 2, 1, 0 }, { 2, 1, 1 }, { -1, 1, 2 }, { 0, 1, 2 }, { 1, 1, 2 }, { -1, 1, -2 }, { 1, 1, -2 }, { 1, 1, -2 }, { -1, 2, 1 }, { -1, 2, 0 }, { -1, 2, -1 }, { 0, 2, 1 }, { 0, 2, -1 }, { 1, 2, 1 }, { 1, 2, 0 }, { 1, 2, -1 }, { -2, 2, 0 }, { 2, 2, 0 }, { 0, 2, 2 }, { 0, 2, -2 }, { -1, 3, 1 }, { -1, 3, 0 }, { -1, 3, -1 }, { 0, 3, 1 }, { 0, 3, -1 }, { 1, 3, 1 }, { 1, 3, 0 }, { 1, 3, -1 }, { -1, 4, 0 }, { 0, 4, 1 }, - { 0, 4, -1 }, { 1, 4, 0 }, { 0, 5, 0 } }; - - for (int[] coord : leafPos) { - BlockPos blockpos = position.add(coord[0], coord[1] + (i - 5), coord[2]); - state = worldIn.getBlockState(blockpos); - if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); - } - } - //MAKE TRUNK - for (int j3 = 0; j3 < i; ++j3) { - BlockPos upN = position.up(j3); - state = worldIn.getBlockState(upN); - - if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); - if (j3 == i - 4) { - - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); - if (rand.nextBoolean()) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); - } - - } - } - } - - return true; - } else { - return false; - } - } - } else { - return false; - } - } - - public byte chooseTreeGenType(World world) { - byte r = (byte) world.rand.nextInt(4); - //big maple - if (r == 0) { - return 3; - } else - //mini maple - if (r == 1 || r == 2) { - return 2; - } else - //regular - return 1; - } - - private boolean isAreaClear(World worldIn, BlockPos position, int treeheight) { - boolean flag = false; - for (int j = position.getY(); j <= position.getY() + 1 + treeheight; ++j) { - int k = 1; - - if (j == position.getY()) { - k = 0; - } - - if (j >= position.getY() + 1 + treeheight - 2) { - k = 1; - } - - BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos(); +import java.util.Random; - for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { - for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { - if (j >= 0 && j < worldIn.getHeight()) { - if (!this.isReplaceable(worldIn, blockposmutableblockpos.setPos(l, j, i1))) { - return false; - } - } else { - return false; - } - } - } - } - return true; - } +public class WorldGenPalm extends WorldGenAbstractTree { + private static final IBlockState DEFAULT_TRUNK = BlockRegistry.palm_log.getDefaultState(); + private static final IBlockState DEFAULT_LEAF = BlockRegistry.palm_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, true); + + /** + * The metadata value of the wood to use in tree generation. + */ + private final IBlockState metaWood; + + /** + * The metadata value of the leaves to use in tree generation. + */ + private final IBlockState metaLeaves; + + /** + * Sets wither or not the generator should notify blocks of blocks it changes. When the world is first generated, + * this is false, when saplings grow, this is true. + */ + public WorldGenPalm(boolean notify) { + this(notify, DEFAULT_TRUNK, DEFAULT_LEAF); + } + + public WorldGenPalm(boolean notify, IBlockState metawood, IBlockState metaleaves) { + super(notify); + this.metaWood = metawood; + this.metaLeaves = metaleaves; + } + + @Override + public boolean generate(World world, Random rand, BlockPos pos) { + byte type = chooseTreeGenType(world); + //TODO 3 and 2 do not work + System.out.println("type " + type); + if (type == 2) { + return generateMini(world, rand, pos); + } else { + if (type == 3) { + return generateBig(world, rand, pos); + } else { + return generateNormal(world, rand, pos); + } + } + } + + private boolean generateNormal(World worldIn, Random rand, BlockPos position) { + int i = rand.nextInt(3) + 5; + boolean flag = true; + if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { + flag = isAreaClear(worldIn, position, i); + if (!flag) { + return false; + } else { + IBlockState state = worldIn.getBlockState(position.down()); + if (state.getBlock().canSustainPlant(state, worldIn, position.down(), EnumFacing.UP, Blocks.DEADBUSH) && position.getY() < worldIn.getHeight() - i - 1) { + System.out.println("doot "); + this.setDirtAt(worldIn, position.down()); + for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { + int i4 = i3 - (position.getY() + i); + int j1 = 1 - i4 / 2; + for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { + int l1 = k1 - position.getX(); + for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { + int j2 = i2 - position.getZ(); + if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { + BlockPos blockpos = new BlockPos(k1, i3, i2); + state = worldIn.getBlockState(blockpos); + + if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); + } + } + } + } + } + + for (int j3 = 0; j3 < i; ++j3) { + BlockPos upN = position.up(j3); + state = worldIn.getBlockState(upN); + if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } + + private boolean generateBig(World worldIn, Random rand, BlockPos position) { + int i = rand.nextInt(2) + 9; + boolean flag = true; + if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { + flag = isAreaClear(worldIn, position, i); + if (!flag) { + return false; + } else { //If we can actually make the tree + IBlockState state = worldIn.getBlockState(position.down()); + if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { + this.setDirtAt(worldIn, position.down()); + //MAKE LEAVES + final int[][] leafPos = new int[][]{{-1, 0, 0}, + {0, 0, 1}, {0, 0, -1}, {1, 0, 0}, {-1, 1, 1}, {-1, 1, 0}, {-1, 1, -1}, {0, 1, 1}, {0, 1, -1}, {1, 1, 1}, + {1, 1, 0}, {1, 1, -1}, {2, 1, 1}, {-2, 1, 1}, {-2, 1, 0}, {-2, 1, -1}, {-1, 1, 2}, {-1, 1, -2}, {0, 1, 2}, + {0, 1, -2}, {2, 1, 0}, {2, 1, -1}, {1, 1, 2}, {1, 1, -2}, {-3, 1, 0}, {3, 1, 0}, {0, 1, -3}, {0, 1, 3}, + {-2, 1, 2}, {-2, 1, -2}, {2, 1, 2}, {2, 1, -2}, {-1, 2, 1}, {-1, 2, 0}, {-1, 2, -1}, {0, 2, 1}, {0, 2, -1}, + {1, 2, 1}, {1, 2, 0}, {1, 2, -1}, {2, 2, 1}, {-2, 2, 1}, {-2, 2, 0}, {-2, 2, -1}, {-1, 2, 2}, {-1, 2, -2}, + {0, 2, 2}, {0, 2, -2}, {2, 2, 0}, {2, 2, -1}, {1, 2, 2}, {1, 2, -2}, {-3, 2, 0}, {3, 2, 0}, {0, 2, -3}, + {0, 2, 3}, {-2, 2, 2}, {-2, 2, -2}, {2, 2, 2}, {2, 2, -2}, {-3, 2, -1}, {-3, 2, 1}, {-1, 2, -3}, {-1, 2, 3}, + {1, 2, 3}, {3, 2, 1}, {1, 2, -3}, {3, 2, -1}, {-1, 3, 1}, {-1, 3, 0}, {-1, 3, -1}, {0, 3, 1}, {0, 3, -1}, + {1, 3, 1}, {1, 3, 0}, {1, 3, -1}, {2, 3, 1}, {-2, 3, 1}, {-2, 3, 0}, {-2, 3, -1}, {-1, 3, 2}, {-1, 3, -2}, + {0, 3, 2}, {0, 3, -2}, {2, 3, 0}, {2, 3, -1}, {1, 3, 2}, {1, 3, -2}, {-3, 3, 0}, {3, 3, 0}, {0, 3, -3}, + {0, 3, 3}, {-2, 3, 2}, {-2, 3, -2}, {2, 3, 2}, {2, 3, -2}, {-3, 3, -1}, {-3, 3, 1}, {-1, 3, -3}, {-1, 3, 3}, + {1, 3, 3}, {3, 3, 1}, {1, 3, -3}, {3, 3, -1}, {-1, 4, 1}, {-1, 4, 0}, {-1, 4, -1}, {0, 4, 1}, {0, 4, -1}, + {1, 4, 1}, {1, 4, 0}, {1, 4, -1}, {2, 4, 1}, {-2, 4, 1}, {-2, 4, 0}, {-2, 4, -1}, {-1, 4, 2}, {-1, 4, -2}, + {0, 4, 2}, {0, 4, -2}, {2, 4, 0}, {2, 4, -1}, {1, 4, 2}, {1, 4, -2}, {-3, 4, 0}, {3, 4, 0}, {0, 4, -3}, + {0, 4, 3}, {-1, 5, 1}, {-1, 5, 0}, {-1, 5, -1}, {0, 5, 1}, {0, 5, -1}, {1, 5, 1}, {1, 5, 0}, {1, 5, -1}, + {2, 5, 1}, {-2, 5, 1}, {-2, 5, 0}, {-2, 5, -1}, {-1, 5, 2}, {-1, 5, -2}, {0, 5, 2}, {0, 5, -2}, {2, 5, 0}, + {2, 5, -1}, {1, 5, 2}, {1, 5, -2}, {-1, 6, 0}, {0, 6, 1}, {0, 6, -1}, {1, 6, 0}, {0, 7, 0}}; + + for (int[] coord : leafPos) { + BlockPos blockpos = position.add(coord[0], coord[1] + (i - 7), coord[2]); + state = worldIn.getBlockState(blockpos); + if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); + } + } + + //MAKE TRUNK + for (int j3 = 0; j3 < i; ++j3) { + BlockPos upN = position.up(j3); + state = worldIn.getBlockState(upN); + if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); + if (j3 == i - 4) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + + if (rand.nextBoolean()) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(2), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + } + + } else { + if (j3 == i - 6) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + if (rand.nextBoolean()) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + } + } + } + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } + + private boolean generateMini(World worldIn, Random rand, BlockPos position) { + int i = rand.nextInt(2) + 6; + boolean flag = true; + if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { + flag = isAreaClear(worldIn, position, i); + if (!flag) { + return false; + } else { //If we can actually make the tree + IBlockState state = worldIn.getBlockState(position.down()); + if (state.getBlock().canSustainPlant(state, worldIn, position.down(), EnumFacing.UP, (BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { + this.setDirtAt(worldIn, position.down()); + //MAKE LEAVES + final int[][] leafPos = new int[][]{{-1, 0, 1}, + {-1, 0, 0}, {-1, 0, -1}, {0, 0, 1}, {0, 0, -1}, {1, 0, 1}, {1, 0, 0}, {1, 0, -1}, {-1, 1, 1}, {-1, 1, 0}, + {-1, 1, -1}, {0, 1, 1}, {0, 1, -1}, {0, 1, -2}, {1, 1, 1}, {1, 1, 0}, {1, 1, -1}, {-1, 1, 0}, {-1, 1, -1}, + {-2, 1, 1}, {-2, 1, 0}, {-2, 1, -1}, {2, 1, -1}, {2, 1, 0}, {2, 1, 1}, {-1, 1, 2}, {0, 1, 2}, {1, 1, 2}, + {-1, 1, -2}, {1, 1, -2}, {1, 1, -2}, {-1, 2, 1}, {-1, 2, 0}, {-1, 2, -1}, {0, 2, 1}, {0, 2, -1}, {1, 2, 1}, + {1, 2, 0}, {1, 2, -1}, {-2, 2, 0}, {2, 2, 0}, {0, 2, 2}, {0, 2, -2}, {-1, 3, 1}, {-1, 3, 0}, {-1, 3, -1}, + {0, 3, 1}, {0, 3, -1}, {1, 3, 1}, {1, 3, 0}, {1, 3, -1}, {-1, 4, 0}, {0, 4, 1}, {0, 4, -1}, {1, 4, 0}, {0, 5, 0}}; + + for (int[] coord : leafPos) { + BlockPos blockpos = position.add(coord[0], coord[1] + (i - 5), coord[2]); + state = worldIn.getBlockState(blockpos); + if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); + } + } + + //MAKE TRUNK + for (int j3 = 0; j3 < i; ++j3) { + BlockPos upN = position.up(j3); + state = worldIn.getBlockState(upN); + if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); + if (j3 == i - 4) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).north(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).south(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z)); + + if (rand.nextBoolean()) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).east(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + this.setBlockAndNotifyAdequately(worldIn, position.up(j3).west(), this.metaWood.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X)); + } + } + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } + + public byte chooseTreeGenType(World world) { + byte r = (byte) world.rand.nextInt(4); + //big maple + if (r == 0) { + return 3; + } else { + //mini maple + if (r == 1 || r == 2) { + return 2; + } else { + //regular + return 1; + } + } + } + + private boolean isAreaClear(World worldIn, BlockPos position, int treeheight) { + boolean flag = false; + for (int j = position.getY(); j <= position.getY() + 1 + treeheight; ++j) { + int k = 1; + if (j == position.getY()) { + k = 0; + } + + if (j >= position.getY() + 1 + treeheight - 2) { + k = 1; + } + + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { + for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { + if (j >= 0 && j < worldIn.getHeight()) { + if (!this.isReplaceable(worldIn, mutableBlockPos.setPos(l, j, i1))) { + return false; + } + } else { + return false; + } + } + } + } + return true; + } } diff --git a/src/main/java/panda/gotwood/generation/WorldGenPine.java b/src/main/java/panda/gotwood/generation/WorldGenPine.java index 6c4b5b5..8c4b16e 100644 --- a/src/main/java/panda/gotwood/generation/WorldGenPine.java +++ b/src/main/java/panda/gotwood/generation/WorldGenPine.java @@ -1,121 +1,109 @@ package panda.gotwood.generation; -import java.util.Random; - +import net.minecraft.block.BlockSapling; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; - import panda.gotwood.block.BlockWoodLeaves; import panda.gotwood.registry.BlockRegistry; -public class WorldGenPine extends WorldGenAbstractTree { - private static final IBlockState TRUNK = BlockRegistry.pine_log.getDefaultState(); - - private static final IBlockState LEAF = BlockRegistry.pine_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, Boolean.valueOf(true)); - - public WorldGenPine(boolean bool) { - super(bool); - } - - public boolean generate(World worldIn, Random rand, BlockPos position) { - int i = rand.nextInt(4) + 6; - int j = 1 + rand.nextInt(2); - int k = i - j; - int l = 2 + rand.nextInt(2); - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { - for (int i1 = position.getY(); i1 <= position.getY() + 1 + i && flag; ++i1) { - int j1; - - if (i1 - position.getY() < j) { - j1 = 0; - } else { - j1 = l; - } - - BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos(); - - for (int k1 = position.getX() - j1; k1 <= position.getX() + j1 && flag; ++k1) { - for (int l1 = position.getZ() - j1; l1 <= position.getZ() + j1 && flag; ++l1) { - if (i1 >= 0 && i1 < worldIn.getHeight()) { - IBlockState state = worldIn.getBlockState(blockposmutableblockpos.setPos(k1, i1, l1)); - - if (!state.getBlock().isAir(state, worldIn, blockposmutableblockpos.setPos(k1, i1, l1)) && !state.getBlock().isLeaves(state, worldIn, blockposmutableblockpos.setPos(k1, i1, l1))) { - flag = false; - } - } else { - flag = false; - } - } - } - } - - if (!flag) { - return false; - } else { - BlockPos down = position.down(); - IBlockState state = worldIn.getBlockState(down); - - if (state.getBlock().canSustainPlant(state, worldIn, down, net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { - state.getBlock().onPlantGrow(state, worldIn, down, position); - int i3 = rand.nextInt(2); - int j3 = 1; - int k3 = 0; - - for (int l3 = 0; l3 <= k; ++l3) { - int j4 = position.getY() + i - l3; - - for (int i2 = position.getX() - i3; i2 <= position.getX() + i3; ++i2) { - int j2 = i2 - position.getX(); - - for (int k2 = position.getZ() - i3; k2 <= position.getZ() + i3; ++k2) { - int l2 = k2 - position.getZ(); - - if (Math.abs(j2) != i3 || Math.abs(l2) != i3 || i3 <= 0) { - BlockPos blockpos = new BlockPos(i2, j4, k2); - state = worldIn.getBlockState(blockpos); - - if (state.getBlock().canBeReplacedByLeaves(state, worldIn, blockpos)) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, LEAF); - } - } - } - } - - if (i3 >= j3) { - i3 = k3; - k3 = 1; - ++j3; - - if (j3 > l) { - j3 = l; - } - } else { - ++i3; - } - } - - int i4 = rand.nextInt(3); - - for (int k4 = 0; k4 < i - i4; ++k4) { - BlockPos upN = position.up(k4); - state = worldIn.getBlockState(upN); +import java.util.Random; - if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN)) { - this.setBlockAndNotifyAdequately(worldIn, position.up(k4), TRUNK); - } - } +public class WorldGenPine extends WorldGenAbstractTree { - return true; - } else { - return false; - } - } - } else { - return false; - } - } + private static final IBlockState TRUNK = BlockRegistry.pine_log.getDefaultState(); + private static final IBlockState LEAF = BlockRegistry.pine_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, true); + + public WorldGenPine(boolean bool) { + super(bool); + } + + public boolean generate(World worldIn, Random rand, BlockPos position) { + int i = rand.nextInt(4) + 6; + int j = 1 + rand.nextInt(2); + int k = i - j; + int l = 2 + rand.nextInt(2); + boolean flag = true; + if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { + for (int i1 = position.getY(); i1 <= position.getY() + 1 + i && flag; ++i1) { + int j1; + if (i1 - position.getY() < j) { + j1 = 0; + } else { + j1 = l; + } + + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + for (int k1 = position.getX() - j1; k1 <= position.getX() + j1 && flag; ++k1) { + for (int l1 = position.getZ() - j1; l1 <= position.getZ() + j1 && flag; ++l1) { + if (i1 >= 0 && i1 < worldIn.getHeight()) { + IBlockState state = worldIn.getBlockState(mutableBlockPos.setPos(k1, i1, l1)); + if (!state.getBlock().isAir(state, worldIn, mutableBlockPos.setPos(k1, i1, l1)) && !state.getBlock().isLeaves(state, worldIn, mutableBlockPos.setPos(k1, i1, l1))) { + flag = false; + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + return false; + } else { + BlockPos down = position.down(); + IBlockState state = worldIn.getBlockState(down); + if (state.getBlock().canSustainPlant(state, worldIn, down, EnumFacing.UP, (BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { + state.getBlock().onPlantGrow(state, worldIn, down, position); + int i3 = rand.nextInt(2); + int j3 = 1; + int k3 = 0; + for (int l3 = 0; l3 <= k; ++l3) { + int j4 = position.getY() + i - l3; + for (int i2 = position.getX() - i3; i2 <= position.getX() + i3; ++i2) { + int j2 = i2 - position.getX(); + for (int k2 = position.getZ() - i3; k2 <= position.getZ() + i3; ++k2) { + int l2 = k2 - position.getZ(); + if (Math.abs(j2) != i3 || Math.abs(l2) != i3 || i3 <= 0) { + BlockPos blockpos = new BlockPos(i2, j4, k2); + state = worldIn.getBlockState(blockpos); + if (state.getBlock().canBeReplacedByLeaves(state, worldIn, blockpos)) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, LEAF); + } + } + } + } + + if (i3 >= j3) { + i3 = k3; + k3 = 1; + ++j3; + if (j3 > l) { + j3 = l; + } + } else { + ++i3; + } + } + + int i4 = rand.nextInt(3); + for (int k4 = 0; k4 < i - i4; ++k4) { + BlockPos upN = position.up(k4); + state = worldIn.getBlockState(upN); + if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN)) { + this.setBlockAndNotifyAdequately(worldIn, position.up(k4), TRUNK); + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } } diff --git a/src/main/java/panda/gotwood/generation/WorldGenRubber.java b/src/main/java/panda/gotwood/generation/WorldGenRubber.java index 2d2c21d..06e9ab9 100644 --- a/src/main/java/panda/gotwood/generation/WorldGenRubber.java +++ b/src/main/java/panda/gotwood/generation/WorldGenRubber.java @@ -1,126 +1,116 @@ package panda.gotwood.generation; -import java.util.Random; - +import net.minecraft.block.BlockSapling; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; - -import panda.gotwood.block.BlockWoodLeaves; import panda.gotwood.block.BlockSappyLog; +import panda.gotwood.block.BlockWoodLeaves; import panda.gotwood.registry.BlockRegistry; -public class WorldGenRubber extends WorldGenAbstractTree { - private static final IBlockState DEFAULT_TRUNK = BlockRegistry.rubber_log.getDefaultState().withProperty(BlockSappyLog.GENERATED, 1); - - private static final IBlockState DEFAULT_LEAF = BlockRegistry.rubber_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, Boolean.valueOf(true)); - - /** - * The minimum height of a generated tree. - */ - private final int minTreeHeight; - - /** - * The metadata value of the wood to use in tree generation. - */ - private final IBlockState metaWood; - - /** - * The metadata value of the leaves to use in tree generation. - */ - private final IBlockState metaLeaves; - - public WorldGenRubber(boolean bool) { - this(bool, 6, DEFAULT_TRUNK, DEFAULT_LEAF); - } - - public WorldGenRubber(boolean bool, int height, IBlockState metawood, IBlockState metaleaves) { - super(bool); - this.minTreeHeight = height; - this.metaWood = metawood; - this.metaLeaves = metaleaves; - } - - public boolean generate(World worldIn, Random rand, BlockPos position) { - int i = 2 + rand.nextInt(1) + this.minTreeHeight; - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { - for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { - int k = 1; - - if (j == position.getY()) { - k = 0; - } - - if (j >= position.getY() + 1 + i - 2) { - k = 2; - } - - BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos(); - - for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { - for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { - if (j >= 0 && j < worldIn.getHeight()) { - if (!this.isReplaceable(worldIn, blockposmutableblockpos.setPos(l, j, i1))) { - flag = false; - } - } else { - flag = false; - } - } - } - } - - if (!flag) { - return false; - } else { - IBlockState state = worldIn.getBlockState(position.down()); - - if (state.getBlock().canSustainPlant(state, worldIn, position.down(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { - this.setDirtAt(worldIn, position.down()); - - for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { - int i4 = i3 - (position.getY() + i); - int j1 = 1 - i4 / 2; - - for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { - int l1 = k1 - position.getX(); - - for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { - int j2 = i2 - position.getZ(); - - if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { - BlockPos blockpos = new BlockPos(k1, i3, i2); - state = worldIn.getBlockState(blockpos); - - if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); - } - } - } - } - } - - for (int j3 = 0; j3 < i; ++j3) { - BlockPos upN = position.up(j3); - state = worldIn.getBlockState(upN); - - if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { - this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); - } - } +import java.util.Random; - return true; - } else { - return false; - } - } - } else { - return false; - } - } +public class WorldGenRubber extends WorldGenAbstractTree { + private static final IBlockState DEFAULT_TRUNK = BlockRegistry.rubber_log.getDefaultState().withProperty(BlockSappyLog.GENERATED, 1); + private static final IBlockState DEFAULT_LEAF = BlockRegistry.rubber_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, true); + + /** + * The minimum height of a generated tree. + */ + private final int minTreeHeight; + + /** + * The metadata value of the wood to use in tree generation. + */ + private final IBlockState metaWood; + + /** + * The metadata value of the leaves to use in tree generation. + */ + private final IBlockState metaLeaves; + + public WorldGenRubber(boolean bool) { + this(bool, 6, DEFAULT_TRUNK, DEFAULT_LEAF); + } + + public WorldGenRubber(boolean bool, int height, IBlockState metawood, IBlockState metaleaves) { + super(bool); + this.minTreeHeight = height; + this.metaWood = metawood; + this.metaLeaves = metaleaves; + } + + public boolean generate(World worldIn, Random rand, BlockPos position) { + int i = 2 + rand.nextInt(1) + this.minTreeHeight; + boolean flag = true; + if (position.getY() >= 1 && position.getY() + i + 1 <= worldIn.getHeight()) { + for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { + int k = 1; + if (j == position.getY()) { + k = 0; + } + + if (j >= position.getY() + 1 + i - 2) { + k = 2; + } + + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { + for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { + if (j >= 0 && j < worldIn.getHeight()) { + if (!this.isReplaceable(worldIn, mutableBlockPos.setPos(l, j, i1))) { + flag = false; + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + return false; + } else { + IBlockState state = worldIn.getBlockState(position.down()); + if (state.getBlock().canSustainPlant(state, worldIn, position.down(), EnumFacing.UP, (BlockSapling) Blocks.SAPLING) && position.getY() < worldIn.getHeight() - i - 1) { + this.setDirtAt(worldIn, position.down()); + for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) { + int i4 = i3 - (position.getY() + i); + int j1 = 1 - i4 / 2; + for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { + int l1 = k1 - position.getX(); + for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { + int j2 = i2 - position.getZ(); + if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { + BlockPos blockpos = new BlockPos(k1, i3, i2); + state = worldIn.getBlockState(blockpos); + if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); + } + } + } + } + } + + for (int j3 = 0; j3 < i; ++j3) { + BlockPos upN = position.up(j3); + state = worldIn.getBlockState(upN); + if (state.getBlock().isAir(state, worldIn, upN) || state.getBlock().isLeaves(state, worldIn, upN) || state.getMaterial() == Material.VINE) { + this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } } diff --git a/src/main/java/panda/gotwood/generation/WorldGenWillow.java b/src/main/java/panda/gotwood/generation/WorldGenWillow.java index 78796ac..1cf1cff 100644 --- a/src/main/java/panda/gotwood/generation/WorldGenWillow.java +++ b/src/main/java/panda/gotwood/generation/WorldGenWillow.java @@ -1,171 +1,157 @@ package panda.gotwood.generation; -import java.util.Random; - import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; import net.minecraft.block.BlockVine; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; - import panda.gotwood.block.BlockWoodLeaves; import panda.gotwood.registry.BlockRegistry; +import java.util.Random; + public class WorldGenWillow extends WorldGenAbstractTree { - static final IBlockState TRUNK = BlockRegistry.willow_log.getDefaultState(); - - private static final IBlockState LEAF = BlockRegistry.willow_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, Boolean.valueOf(true)); - - public WorldGenWillow() { - super(false); - } - - public boolean generate(World worldIn, Random rand, BlockPos position) { - int i; - - for (i = rand.nextInt(4) + 5; worldIn.getBlockState(position.down()).getMaterial() == Material.WATER; position = position.down()) { - //Increment - } - - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= 256) { - for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { - int k = 1; - - if (j == position.getY()) { - k = 0; - } - - if (j >= position.getY() + 1 + i - 2) { - k = 3; - } - - BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos(); - - for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { - for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { - if (j >= 0 && j < 256) { - IBlockState iblockstate = worldIn.getBlockState(blockposmutableblockpos.setPos(l, j, i1)); - Block block = iblockstate.getBlock(); - - if (!iblockstate.getBlock().isAir(iblockstate, worldIn, blockposmutableblockpos.setPos(l, j, i1)) && !iblockstate.getBlock().isLeaves(iblockstate, worldIn, blockposmutableblockpos.setPos(l, j, i1))) { - if (block != net.minecraft.init.Blocks.WATER && block != net.minecraft.init.Blocks.FLOWING_WATER) { - flag = false; - } else if (j > position.getY()) { - flag = false; - } - } - } else { - flag = false; - } - } - } - } - - if (!flag) { - return false; - } else { - BlockPos down = position.down(); - IBlockState state = worldIn.getBlockState(down); - boolean isSoil = state.getBlock().canSustainPlant(state, worldIn, down, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING)); - - if (isSoil && position.getY() < worldIn.getHeight() - i - 1) { - state.getBlock().onPlantGrow(state, worldIn, position.down(), position); - - for (int k1 = position.getY() - 3 + i; k1 <= position.getY() + i; ++k1) { - int j2 = k1 - (position.getY() + i); - int l2 = 2 - j2 / 2; - - for (int j3 = position.getX() - l2; j3 <= position.getX() + l2; ++j3) { - int k3 = j3 - position.getX(); - - for (int i4 = position.getZ() - l2; i4 <= position.getZ() + l2; ++i4) { - int j1 = i4 - position.getZ(); - - if (Math.abs(k3) != l2 || Math.abs(j1) != l2 || rand.nextInt(2) != 0 && j2 != 0) { - BlockPos blockpos = new BlockPos(j3, k1, i4); - state = worldIn.getBlockState(blockpos); - - if (state.getBlock().canBeReplacedByLeaves(state, worldIn, blockpos)) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, LEAF); - } - } - } - } - } - - for (int l1 = 0; l1 < i; ++l1) { - BlockPos upN = position.up(l1); - IBlockState iblockstate1 = worldIn.getBlockState(upN); - Block block2 = iblockstate1.getBlock(); - - if (block2.isAir(iblockstate1, worldIn, upN) || block2.isLeaves(iblockstate1, worldIn, upN) || block2 == net.minecraft.init.Blocks.FLOWING_WATER || block2 == net.minecraft.init.Blocks.WATER) { - this.setBlockAndNotifyAdequately(worldIn, position.up(l1), TRUNK); - } - } - - for (int i2 = position.getY() - 3 + i; i2 <= position.getY() + i; ++i2) { - int k2 = i2 - (position.getY() + i); - int i3 = 2 - k2 / 2; - BlockPos.MutableBlockPos blockposmutableblockpos1 = new BlockPos.MutableBlockPos(); - - for (int l3 = position.getX() - i3; l3 <= position.getX() + i3; ++l3) { - for (int j4 = position.getZ() - i3; j4 <= position.getZ() + i3; ++j4) { - blockposmutableblockpos1.setPos(l3, i2, j4); - - if (worldIn.getBlockState(blockposmutableblockpos1).getMaterial() == Material.LEAVES) { - BlockPos blockpos3 = blockposmutableblockpos1.west(); - BlockPos blockpos4 = blockposmutableblockpos1.east(); - BlockPos blockpos1 = blockposmutableblockpos1.north(); - BlockPos blockpos2 = blockposmutableblockpos1.south(); - - if (rand.nextInt(4) == 0 && isAir(worldIn, blockpos3)) { - this.addVine(worldIn, blockpos3, BlockVine.EAST); - } - - if (rand.nextInt(4) == 0 && isAir(worldIn, blockpos4)) { - this.addVine(worldIn, blockpos4, BlockVine.WEST); - } - - if (rand.nextInt(4) == 0 && isAir(worldIn, blockpos1)) { - this.addVine(worldIn, blockpos1, BlockVine.SOUTH); - } - - if (rand.nextInt(4) == 0 && isAir(worldIn, blockpos2)) { - this.addVine(worldIn, blockpos2, BlockVine.NORTH); - } - } - } - } - } - - return true; - } else { - return false; - } - } - } else { - return false; - } - } - - private void addVine(World worldIn, BlockPos pos, PropertyBool prop) { - IBlockState iblockstate = net.minecraft.init.Blocks.VINE.getDefaultState().withProperty(prop, Boolean.valueOf(true)); - this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); - int i = 4; - - for (pos = pos.down(); isAir(worldIn, pos) && i > 0; --i) { - this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); - pos = pos.down(); - } - } - - private boolean isAir(World world, BlockPos pos) { - IBlockState state = world.getBlockState(pos); - return state.getBlock().isAir(state, world, pos); - } + + static final IBlockState TRUNK = BlockRegistry.willow_log.getDefaultState(); + private static final IBlockState LEAF = BlockRegistry.willow_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, true); + + public WorldGenWillow() { + super(false); + } + + public boolean generate(World worldIn, Random rand, BlockPos position) { + int i; + for (i = rand.nextInt(4) + 5; worldIn.getBlockState(position.down()).getMaterial() == Material.WATER; position = position.down()) { + //Increment + } + + boolean flag = true; + if (position.getY() >= 1 && position.getY() + i + 1 <= 256) { + for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { + int k = 1; + if (j == position.getY()) { + k = 0; + } + + if (j >= position.getY() + 1 + i - 2) { + k = 3; + } + + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { + for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { + if (j >= 0 && j < 256) { + IBlockState iblockstate = worldIn.getBlockState(mutableBlockPos.setPos(l, j, i1)); + Block block = iblockstate.getBlock(); + if (!iblockstate.getBlock().isAir(iblockstate, worldIn, mutableBlockPos.setPos(l, j, i1)) && !iblockstate.getBlock().isLeaves(iblockstate, worldIn, mutableBlockPos.setPos(l, j, i1))) { + if (block != Blocks.WATER && block != Blocks.FLOWING_WATER) { + flag = false; + } else if (j > position.getY()) { + flag = false; + } + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + return false; + } else { + BlockPos down = position.down(); + IBlockState state = worldIn.getBlockState(down); + boolean isSoil = state.getBlock().canSustainPlant(state, worldIn, down, EnumFacing.UP, ((BlockSapling) Blocks.SAPLING)); + if (isSoil && position.getY() < worldIn.getHeight() - i - 1) { + state.getBlock().onPlantGrow(state, worldIn, position.down(), position); + for (int k1 = position.getY() - 3 + i; k1 <= position.getY() + i; ++k1) { + int j2 = k1 - (position.getY() + i); + int l2 = 2 - j2 / 2; + for (int j3 = position.getX() - l2; j3 <= position.getX() + l2; ++j3) { + int k3 = j3 - position.getX(); + for (int i4 = position.getZ() - l2; i4 <= position.getZ() + l2; ++i4) { + int j1 = i4 - position.getZ(); + if (Math.abs(k3) != l2 || Math.abs(j1) != l2 || rand.nextInt(2) != 0 && j2 != 0) { + BlockPos blockpos = new BlockPos(j3, k1, i4); + state = worldIn.getBlockState(blockpos); + if (state.getBlock().canBeReplacedByLeaves(state, worldIn, blockpos)) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, LEAF); + } + } + } + } + } + + for (int l1 = 0; l1 < i; ++l1) { + BlockPos upN = position.up(l1); + IBlockState iblockstate1 = worldIn.getBlockState(upN); + Block block2 = iblockstate1.getBlock(); + if (block2.isAir(iblockstate1, worldIn, upN) || block2.isLeaves(iblockstate1, worldIn, upN) || block2 == Blocks.FLOWING_WATER || block2 == Blocks.WATER) { + this.setBlockAndNotifyAdequately(worldIn, position.up(l1), TRUNK); + } + } + + for (int i2 = position.getY() - 3 + i; i2 <= position.getY() + i; ++i2) { + int k2 = i2 - (position.getY() + i); + int i3 = 2 - k2 / 2; + BlockPos.MutableBlockPos mutableBlockPos1 = new BlockPos.MutableBlockPos(); + for (int l3 = position.getX() - i3; l3 <= position.getX() + i3; ++l3) { + for (int j4 = position.getZ() - i3; j4 <= position.getZ() + i3; ++j4) { + mutableBlockPos1.setPos(l3, i2, j4); + if (worldIn.getBlockState(mutableBlockPos1).getMaterial() == Material.LEAVES) { + BlockPos blockpos3 = mutableBlockPos1.west(); + BlockPos blockpos4 = mutableBlockPos1.east(); + BlockPos blockpos1 = mutableBlockPos1.north(); + BlockPos blockpos2 = mutableBlockPos1.south(); + + if (rand.nextInt(4) == 0 && isAir(worldIn, blockpos3)) { + this.addVine(worldIn, blockpos3, BlockVine.EAST); + } + + if (rand.nextInt(4) == 0 && isAir(worldIn, blockpos4)) { + this.addVine(worldIn, blockpos4, BlockVine.WEST); + } + + if (rand.nextInt(4) == 0 && isAir(worldIn, blockpos1)) { + this.addVine(worldIn, blockpos1, BlockVine.SOUTH); + } + + if (rand.nextInt(4) == 0 && isAir(worldIn, blockpos2)) { + this.addVine(worldIn, blockpos2, BlockVine.NORTH); + } + } + } + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } + + private void addVine(World worldIn, BlockPos pos, PropertyBool prop) { + IBlockState iblockstate = net.minecraft.init.Blocks.VINE.getDefaultState().withProperty(prop, true); + this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); + int i = 4; + for (pos = pos.down(); isAir(worldIn, pos) && i > 0; --i) { + this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); + pos = pos.down(); + } + } + + private boolean isAir(World world, BlockPos pos) { + IBlockState state = world.getBlockState(pos); + return state.getBlock().isAir(state, world, pos); + } } diff --git a/src/main/java/panda/gotwood/generation/WorldGenYew.java b/src/main/java/panda/gotwood/generation/WorldGenYew.java index da2978f..cf961f3 100644 --- a/src/main/java/panda/gotwood/generation/WorldGenYew.java +++ b/src/main/java/panda/gotwood/generation/WorldGenYew.java @@ -1,130 +1,117 @@ package panda.gotwood.generation; -import java.util.Random; - import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenAbstractTree; - import panda.gotwood.block.BlockWoodLeaves; import panda.gotwood.registry.BlockRegistry; -public class WorldGenYew extends WorldGenAbstractTree { - static final IBlockState TRUNK = BlockRegistry.yew_log.getDefaultState(); - - private static final IBlockState LEAF = BlockRegistry.yew_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, Boolean.valueOf(true)); - - public WorldGenYew() { - super(false); - } - - public boolean generate(World worldIn, Random rand, BlockPos position) { - int i; - - for (i = rand.nextInt(4) + 5; worldIn.getBlockState(position.down()).getMaterial() == Material.WATER; position = position.down()) { - } - - boolean flag = true; - - if (position.getY() >= 1 && position.getY() + i + 1 <= 256) { - for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { - int k = 1; - - if (j == position.getY()) { - k = 0; - } - - if (j >= position.getY() + 1 + i - 2) { - k = 3; - } - - BlockPos.MutableBlockPos blockposmutableblockpos = new BlockPos.MutableBlockPos(); - - for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { - for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { - if (j >= 0 && j < 256) { - IBlockState iblockstate = worldIn.getBlockState(blockposmutableblockpos.setPos(l, j, i1)); - Block block = iblockstate.getBlock(); - - if (!iblockstate.getBlock().isAir(iblockstate, worldIn, blockposmutableblockpos.setPos(l, j, i1)) && !iblockstate.getBlock().isLeaves(iblockstate, worldIn, blockposmutableblockpos.setPos(l, j, i1))) { - if (block != net.minecraft.init.Blocks.WATER && block != net.minecraft.init.Blocks.FLOWING_WATER) { - flag = false; - } else if (j > position.getY()) { - flag = false; - } - } - } else { - flag = false; - } - } - } - } - - if (!flag) { - return false; - } else { - BlockPos down = position.down(); - IBlockState state = worldIn.getBlockState(down); - boolean isSoil = state.getBlock().canSustainPlant(state, worldIn, down, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling) net.minecraft.init.Blocks.SAPLING)); - - if (isSoil && position.getY() < worldIn.getHeight() - i - 1) { - state.getBlock().onPlantGrow(state, worldIn, position.down(), position); - - for (int k1 = position.getY() - 3 + i; k1 <= position.getY() + i; ++k1) { - int j2 = k1 - (position.getY() + i); - int l2 = 2 - j2 / 2; - - for (int j3 = position.getX() - l2; j3 <= position.getX() + l2; ++j3) { - int k3 = j3 - position.getX(); - - for (int i4 = position.getZ() - l2; i4 <= position.getZ() + l2; ++i4) { - int j1 = i4 - position.getZ(); - - if (Math.abs(k3) != l2 || Math.abs(j1) != l2 || rand.nextInt(2) != 0 && j2 != 0) { - BlockPos blockpos = new BlockPos(j3, k1, i4); - state = worldIn.getBlockState(blockpos); - - if (state.getBlock().canBeReplacedByLeaves(state, worldIn, blockpos)) { - this.setBlockAndNotifyAdequately(worldIn, blockpos, LEAF); - } - } - } - } - } - - for (int l1 = 0; l1 < i; ++l1) { - BlockPos upN = position.up(l1); - IBlockState iblockstate1 = worldIn.getBlockState(upN); - Block block2 = iblockstate1.getBlock(); - - if (block2.isAir(iblockstate1, worldIn, upN) || block2.isLeaves(iblockstate1, worldIn, upN) || block2 == net.minecraft.init.Blocks.FLOWING_WATER || block2 == net.minecraft.init.Blocks.WATER) { - this.setBlockAndNotifyAdequately(worldIn, position.up(l1), TRUNK); - } - } - - for (int i2 = position.getY() - 3 + i; i2 <= position.getY() + i; ++i2) { - int k2 = i2 - (position.getY() + i); - int i3 = 2 - k2 / 2; - BlockPos.MutableBlockPos blockpos$mutableblockpos1 = new BlockPos.MutableBlockPos(); - - for (int l3 = position.getX() - i3; l3 <= position.getX() + i3; ++l3) { - for (int j4 = position.getZ() - i3; j4 <= position.getZ() + i3; ++j4) { - blockpos$mutableblockpos1.setPos(l3, i2, j4); +import java.util.Random; - } - } - } +public class WorldGenYew extends WorldGenAbstractTree { - return true; - } else { - return false; - } - } - } else { - return false; - } - } + static final IBlockState TRUNK = BlockRegistry.yew_log.getDefaultState(); + private static final IBlockState LEAF = BlockRegistry.yew_leaves.getDefaultState().withProperty(BlockWoodLeaves.DECAYABLE, true); + + public WorldGenYew() { + super(false); + } + + public boolean generate(World worldIn, Random rand, BlockPos position) { + int i; + for (i = rand.nextInt(4) + 5; worldIn.getBlockState(position.down()).getMaterial() == Material.WATER; position = position.down()) { + } + + boolean flag = true; + if (position.getY() >= 1 && position.getY() + i + 1 <= 256) { + for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { + int k = 1; + if (j == position.getY()) { + k = 0; + } + + if (j >= position.getY() + 1 + i - 2) { + k = 3; + } + + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { + for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { + if (j >= 0 && j < 256) { + IBlockState iblockstate = worldIn.getBlockState(mutableBlockPos.setPos(l, j, i1)); + Block block = iblockstate.getBlock(); + if (!iblockstate.getBlock().isAir(iblockstate, worldIn, mutableBlockPos.setPos(l, j, i1)) && !iblockstate.getBlock().isLeaves(iblockstate, worldIn, mutableBlockPos.setPos(l, j, i1))) { + if (block != Blocks.WATER && block != Blocks.FLOWING_WATER) { + flag = false; + } else if (j > position.getY()) { + flag = false; + } + } + } else { + flag = false; + } + } + } + } + + if (!flag) { + return false; + } else { + BlockPos down = position.down(); + IBlockState state = worldIn.getBlockState(down); + boolean isSoil = state.getBlock().canSustainPlant(state, worldIn, down, EnumFacing.UP, ((BlockSapling) Blocks.SAPLING)); + if (isSoil && position.getY() < worldIn.getHeight() - i - 1) { + state.getBlock().onPlantGrow(state, worldIn, position.down(), position); + for (int k1 = position.getY() - 3 + i; k1 <= position.getY() + i; ++k1) { + int j2 = k1 - (position.getY() + i); + int l2 = 2 - j2 / 2; + for (int j3 = position.getX() - l2; j3 <= position.getX() + l2; ++j3) { + int k3 = j3 - position.getX(); + for (int i4 = position.getZ() - l2; i4 <= position.getZ() + l2; ++i4) { + int j1 = i4 - position.getZ(); + if (Math.abs(k3) != l2 || Math.abs(j1) != l2 || rand.nextInt(2) != 0 && j2 != 0) { + BlockPos blockpos = new BlockPos(j3, k1, i4); + state = worldIn.getBlockState(blockpos); + if (state.getBlock().canBeReplacedByLeaves(state, worldIn, blockpos)) { + this.setBlockAndNotifyAdequately(worldIn, blockpos, LEAF); + } + } + } + } + } + + for (int l1 = 0; l1 < i; ++l1) { + BlockPos upN = position.up(l1); + IBlockState iblockstate1 = worldIn.getBlockState(upN); + Block block2 = iblockstate1.getBlock(); + if (block2.isAir(iblockstate1, worldIn, upN) || block2.isLeaves(iblockstate1, worldIn, upN) || block2 == Blocks.FLOWING_WATER || block2 == Blocks.WATER) { + this.setBlockAndNotifyAdequately(worldIn, position.up(l1), TRUNK); + } + } + + for (int i2 = position.getY() - 3 + i; i2 <= position.getY() + i; ++i2) { + int k2 = i2 - (position.getY() + i); + int i3 = 2 - k2 / 2; + BlockPos.MutableBlockPos mutableBlockPos1 = new BlockPos.MutableBlockPos(); + for (int l3 = position.getX() - i3; l3 <= position.getX() + i3; ++l3) { + for (int j4 = position.getZ() - i3; j4 <= position.getZ() + i3; ++j4) { + mutableBlockPos1.setPos(l3, i2, j4); + } + } + } + return true; + } else { + return false; + } + } + } else { + return false; + } + } } diff --git a/src/main/java/panda/gotwood/generation/WorldGenerator.java b/src/main/java/panda/gotwood/generation/WorldGenerator.java index 3643b54..803821a 100644 --- a/src/main/java/panda/gotwood/generation/WorldGenerator.java +++ b/src/main/java/panda/gotwood/generation/WorldGenerator.java @@ -1,107 +1,96 @@ package panda.gotwood.generation; -import java.util.Random; - import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.BiomeDesert; -import net.minecraft.world.biome.BiomeForest; -import net.minecraft.world.biome.BiomeForestMutated; -import net.minecraft.world.biome.BiomeHills; -import net.minecraft.world.biome.BiomeMesa; -import net.minecraft.world.biome.BiomePlains; -import net.minecraft.world.biome.BiomeRiver; -import net.minecraft.world.biome.BiomeSavanna; -import net.minecraft.world.biome.BiomeSwamp; -import net.minecraft.world.biome.BiomeTaiga; +import net.minecraft.world.biome.*; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.IChunkGenerator; import net.minecraft.world.gen.feature.WorldGenAbstractTree; import net.minecraftforge.fml.common.IWorldGenerator; +import java.util.Random; + public class WorldGenerator implements IWorldGenerator { - //private int min=-1,max=-1,numTrees=-1, - - private void makeTree(WorldGenAbstractTree tree, int chunkX, int chunkZ, Random random, World world, int min, int max) { - - int num = min + random.nextInt(max - min); - for (int i = 0; i < num; i++) { - int randX = chunkX * 16 + 8 + random.nextInt(16); - int randZ = chunkZ * 16 + 8 + random.nextInt(16); - tree.generate(world, random, world.getHeight(new BlockPos(randX, 0, randZ))); - } - } - - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { - if (world.provider.getDimension() == 0) { - - WorldGenAbstractTree apple = new WorldGenApple(false); - WorldGenAbstractTree maple = new WorldGenMaple(false); - WorldGenAbstractTree ebony = new WorldGenEbony(false); - WorldGenAbstractTree fir = new WorldGenFir(false); - WorldGenAbstractTree pine = new WorldGenPine(false); - WorldGenAbstractTree willow = new WorldGenWillow(); - WorldGenAbstractTree yew = new WorldGenYew(); - - // get the biome - Biome biome = world.getBiome(new BlockPos(chunkX * 16, 64, chunkZ * 16)); - - if (biome instanceof BiomeDesert) { - makeTree(ebony, chunkX, chunkZ, random, world, 0, 1); - } - - if (biome instanceof BiomeForest || biome instanceof BiomeForestMutated) { - if (random.nextInt(4) == 0) { - makeTree(maple, chunkX, chunkZ, random, world, 0, 3); - } - - if (random.nextInt(12) == 0) { - makeTree(apple, chunkX, chunkZ, random, world, 1, 2); - } - - makeTree(pine, chunkX, chunkZ, random, world, 0, 3); - } - - if (biome instanceof BiomeHills) { - makeTree(maple, chunkX, chunkZ, random, world, 0, 3); - makeTree(fir, chunkX, chunkZ, random, world, 0, 3); - } - - if (biome instanceof BiomeMesa && random.nextBoolean()) { - makeTree(ebony, chunkX, chunkZ, random, world, 1, 3); - } - - if (biome instanceof BiomePlains) { - makeTree(apple, chunkX, chunkZ, random, world, 0, 1); - } - - if (biome instanceof BiomeRiver && random.nextInt(3) == 0) { - makeTree(yew, chunkX, chunkZ, random, world, 0, 3); - } - - if (biome instanceof BiomeSavanna) { - makeTree(ebony, chunkX, chunkZ, random, world, 0, 3); - } - - if (biome instanceof BiomeSwamp) { - if (random.nextInt(2) == 0) { - makeTree(willow, chunkX, chunkZ, random, world, 0, 3); - } - if (random.nextInt(1) == 0) { - makeTree(yew, chunkX, chunkZ, random, world, 0, 3); - } - } - - if (biome instanceof BiomeTaiga) { - makeTree(pine, chunkX, chunkZ, random, world, 0, 3); - makeTree(fir, chunkX, chunkZ, random, world, 1, 4); - } - if (biome instanceof BiomeJungle) { - makeTree(rubber, chunkX, chunkZ, random, world, 0, 3); - } - } - } + //private int min=-1,max=-1,numTrees=-1, + private void makeTree(WorldGenAbstractTree tree, int chunkX, int chunkZ, Random random, World world, int min, int max) { + int num = min + random.nextInt(max - min); + for (int i = 0; i < num; i++) { + int randX = chunkX * 16 + 8 + random.nextInt(16); + int randZ = chunkZ * 16 + 8 + random.nextInt(16); + tree.generate(world, random, world.getHeight(new BlockPos(randX, 0, randZ))); + } + } + + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { + if (world.provider.getDimension() == 0) { + WorldGenAbstractTree apple = new WorldGenApple(false); + WorldGenAbstractTree maple = new WorldGenMaple(false); + WorldGenAbstractTree ebony = new WorldGenEbony(false); + WorldGenAbstractTree fir = new WorldGenFir(false); + WorldGenAbstractTree pine = new WorldGenPine(false); + WorldGenAbstractTree willow = new WorldGenWillow(); + WorldGenAbstractTree yew = new WorldGenYew(); + WorldGenAbstractTree rubber = new WorldGenRubber(false); + + // get the biome + Biome biome = world.getBiome(new BlockPos(chunkX * 16, 64, chunkZ * 16)); + if (biome instanceof BiomeDesert) { + makeTree(ebony, chunkX, chunkZ, random, world, 0, 1); + } + + if (biome instanceof BiomeForest || biome instanceof BiomeForestMutated) { + if (random.nextInt(4) == 0) { + makeTree(maple, chunkX, chunkZ, random, world, 0, 3); + } + + if (random.nextInt(12) == 0) { + makeTree(apple, chunkX, chunkZ, random, world, 1, 2); + } + + makeTree(pine, chunkX, chunkZ, random, world, 0, 3); + } + + if (biome instanceof BiomeHills) { + makeTree(maple, chunkX, chunkZ, random, world, 0, 3); + makeTree(fir, chunkX, chunkZ, random, world, 0, 3); + } + + if (biome instanceof BiomeMesa && random.nextBoolean()) { + makeTree(ebony, chunkX, chunkZ, random, world, 1, 3); + } + + if (biome instanceof BiomePlains) { + makeTree(apple, chunkX, chunkZ, random, world, 0, 1); + } + + if (biome instanceof BiomeRiver && random.nextInt(3) == 0) { + makeTree(yew, chunkX, chunkZ, random, world, 0, 3); + } + + if (biome instanceof BiomeSavanna) { + makeTree(ebony, chunkX, chunkZ, random, world, 0, 3); + } + + if (biome instanceof BiomeSwamp) { + if (random.nextInt(2) == 0) { + makeTree(willow, chunkX, chunkZ, random, world, 0, 3); + } + + if (random.nextInt(1) == 0) { + makeTree(yew, chunkX, chunkZ, random, world, 0, 3); + } + } + + if (biome instanceof BiomeTaiga) { + makeTree(pine, chunkX, chunkZ, random, world, 0, 3); + makeTree(fir, chunkX, chunkZ, random, world, 1, 4); + } + + if (biome instanceof BiomeJungle) { + makeTree(rubber, chunkX, chunkZ, random, world, 0, 3); + } + } + } } diff --git a/src/main/java/panda/gotwood/item/ItemDates.java b/src/main/java/panda/gotwood/item/ItemDates.java index 20c4b4e..b569d76 100644 --- a/src/main/java/panda/gotwood/item/ItemDates.java +++ b/src/main/java/panda/gotwood/item/ItemDates.java @@ -2,6 +2,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumActionResult; @@ -9,31 +10,29 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; - import panda.gotwood.registry.BlockRegistry; public class ItemDates extends ItemFood { - public ItemDates() { - super(2, 0.1f, false); - this.setRegistryName("dates"); - } - - @Override - public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - IBlockState state = worldIn.getBlockState(pos); - ItemStack heldItem = playerIn.getHeldItem(hand); + public ItemDates() { + super(2, 0.1f, false); + this.setRegistryName("dates"); + } - if (heldItem.isEmpty()) { - return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ); - } - if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, heldItem) && (state.getBlock() == net.minecraft.init.Blocks.GRASS || state.getBlock() == net.minecraft.init.Blocks.DIRT || state.getBlock() == net.minecraft.init.Blocks.SAND) && worldIn.isAirBlock(pos.up())) { - worldIn.setBlockState(pos.up(), BlockRegistry.palm_sapling.getDefaultState()); - heldItem.shrink(1); - return EnumActionResult.SUCCESS; - } else { - return EnumActionResult.FAIL; - } - } + @Override + public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + IBlockState state = worldIn.getBlockState(pos); + ItemStack heldItem = playerIn.getHeldItem(hand); + if (heldItem.isEmpty()) { + return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ); + } + if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, heldItem) && (state.getBlock() == Blocks.GRASS || state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.SAND) && worldIn.isAirBlock(pos.up())) { + worldIn.setBlockState(pos.up(), BlockRegistry.palm_sapling.getDefaultState()); + heldItem.shrink(1); + return EnumActionResult.SUCCESS; + } else { + return EnumActionResult.FAIL; + } + } } diff --git a/src/main/java/panda/gotwood/item/ItemSeed.java b/src/main/java/panda/gotwood/item/ItemSeed.java index 5366acf..6d0dce6 100644 --- a/src/main/java/panda/gotwood/item/ItemSeed.java +++ b/src/main/java/panda/gotwood/item/ItemSeed.java @@ -7,76 +7,72 @@ import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; +import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.IPlantable; - import panda.gotwood.GotWood; import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; import panda.gotwood.util.WoodMaterials; public class ItemSeed extends Item implements IOreDictionaryEntry, IPlantable { - private final WoodMaterial wood; - public final IBlockState sapling; + public final IBlockState sapling; + private final WoodMaterial wood; - public ItemSeed(WoodMaterial wood) { - this.wood = wood; - this.sapling = getSaplingState(); - this.setRegistryName(wood.getName() + "_seed"); - } + public ItemSeed(WoodMaterial wood) { + this.wood = wood; + this.sapling = getSaplingState(); + this.setRegistryName(wood.getName() + "_seed"); + } - @Override - public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { - ItemStack heldItem = playerIn.getHeldItem(hand); + @Override + public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + ItemStack heldItem = playerIn.getHeldItem(hand); + if (heldItem.isEmpty()) { + return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ); + } - if (heldItem.isEmpty()) { - return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ); - } - System.out.println(this.getSaplingState()); - if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, heldItem) && worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos).getBlock().canSustainPlant(worldIn.getBlockState(pos), worldIn, pos, facing, (IPlantable) this.getSaplingState().getBlock())) { - worldIn.setBlockState(pos.up(), this.getSaplingState()); - worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 1F, 1F); - heldItem.shrink(1); - return EnumActionResult.SUCCESS; - } else { - if (playerIn.canPlayerEdit(pos.offset(facing), facing, heldItem) && worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos)) { - worldIn.setBlockState(pos, this.getSaplingState()); - worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 1F, 1F); - heldItem.shrink(1); - return EnumActionResult.SUCCESS; - } - return EnumActionResult.FAIL; - } - } + System.out.println(this.getSaplingState()); + if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, heldItem) && worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos).getBlock().canSustainPlant(worldIn.getBlockState(pos), worldIn, pos, facing, (IPlantable) this.getSaplingState().getBlock())) { + worldIn.setBlockState(pos.up(), this.getSaplingState()); + worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 1F, 1F); + heldItem.shrink(1); + return EnumActionResult.SUCCESS; + } else { + if (playerIn.canPlayerEdit(pos.offset(facing), facing, heldItem) && worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos)) { + worldIn.setBlockState(pos, this.getSaplingState()); + worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 1F, 1F); + heldItem.shrink(1); + return EnumActionResult.SUCCESS; + } + return EnumActionResult.FAIL; + } + } - private IBlockState getSaplingState() { - if (wood == WoodMaterials.acacia || wood == WoodMaterials.birch || wood == WoodMaterials.darkOak || wood == WoodMaterials.jungle || wood == WoodMaterials.oak || wood == WoodMaterials.spruce) { - return Blocks.SAPLING.getStateFromMeta(wood.getMeta()); - } else - return Block.REGISTRY.getObject(new ResourceLocation(GotWood.ID, wood + "_sapling")).getDefaultState(); - } + private IBlockState getSaplingState() { + if (wood == WoodMaterials.acacia || wood == WoodMaterials.birch || wood == WoodMaterials.darkOak || wood == WoodMaterials.jungle || wood == WoodMaterials.oak || wood == WoodMaterials.spruce) { + return Blocks.SAPLING.getStateFromMeta(wood.getMeta()); + } else { + return Block.REGISTRY.getObject(new ResourceLocation(GotWood.MODID, wood + "_sapling")).getDefaultState(); + } + } - @Override - public String getOreDictionaryName() { - return "seed" + this.wood.getCapitalizedName(); - } + @Override + public String getOreDictionaryName() { + return "seed" + this.wood.getCapitalizedName(); + } - @Override - public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { - return EnumPlantType.Plains; - } + @Override + public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { + return EnumPlantType.Plains; + } - @Override - public IBlockState getPlant(IBlockAccess world, BlockPos pos) { - return getSaplingState(); - } + @Override + public IBlockState getPlant(IBlockAccess world, BlockPos pos) { + return getSaplingState(); + } } diff --git a/src/main/java/panda/gotwood/item/ItemWoodDoor.java b/src/main/java/panda/gotwood/item/ItemWoodDoor.java index af4b3f3..8818801 100644 --- a/src/main/java/panda/gotwood/item/ItemWoodDoor.java +++ b/src/main/java/panda/gotwood/item/ItemWoodDoor.java @@ -2,28 +2,27 @@ import net.minecraft.block.BlockDoor; import net.minecraft.item.ItemDoor; - import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; public final class ItemWoodDoor extends ItemDoor implements IOreDictionaryEntry { - private final WoodMaterial wood; - private final String oreDict; + private final WoodMaterial wood; + private final String oreDict; - public ItemWoodDoor(BlockDoor block, WoodMaterial wood) { - super(block); - this.wood = wood; - this.oreDict = "door" + wood.getCapitalizedName(); - this.setRegistryName(wood.getName() + "_door_item"); - } + public ItemWoodDoor(BlockDoor block, WoodMaterial wood) { + super(block); + this.wood = wood; + this.oreDict = "door" + wood.getCapitalizedName(); + this.setRegistryName(wood.getName() + "_door_item"); + } - @Override - public String getOreDictionaryName() { - return this.oreDict; - } + @Override + public String getOreDictionaryName() { + return this.oreDict; + } - public WoodMaterial getWoodMaterial() { - return this.wood; - } + public WoodMaterial getWoodMaterial() { + return this.wood; + } } diff --git a/src/main/java/panda/gotwood/item/ItemWoodSlab.java b/src/main/java/panda/gotwood/item/ItemWoodSlab.java index 916e8c2..6c1e7a9 100644 --- a/src/main/java/panda/gotwood/item/ItemWoodSlab.java +++ b/src/main/java/panda/gotwood/item/ItemWoodSlab.java @@ -2,25 +2,25 @@ import net.minecraft.block.BlockSlab; import net.minecraft.item.ItemSlab; - import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; public final class ItemWoodSlab extends ItemSlab implements IOreDictionaryEntry { - private final WoodMaterial wood; - public ItemWoodSlab(WoodMaterial wood, BlockSlab slab, BlockSlab doubleslab) { - super(slab, slab, doubleslab); - this.wood = wood; - this.setRegistryName(slab.getRegistryName()); - } + private final WoodMaterial wood; + + public ItemWoodSlab(WoodMaterial wood, BlockSlab slab, BlockSlab doubleslab) { + super(slab, slab, doubleslab); + this.wood = wood; + this.setRegistryName(slab.getRegistryName()); + } - public WoodMaterial getWoodMaterial() { - return this.wood; - } + public WoodMaterial getWoodMaterial() { + return this.wood; + } - @Override - public String getOreDictionaryName() { - return "slab" + this.wood.getCapitalizedName(); - } + @Override + public String getOreDictionaryName() { + return "slab" + this.wood.getCapitalizedName(); + } } diff --git a/src/main/java/panda/gotwood/items/ItemDates.java b/src/main/java/panda/gotwood/items/ItemDates.java index e0bfba0..8e4abb4 100644 --- a/src/main/java/panda/gotwood/items/ItemDates.java +++ b/src/main/java/panda/gotwood/items/ItemDates.java @@ -1,7 +1,9 @@ package panda.gotwood.items; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumActionResult; @@ -12,29 +14,23 @@ import net.minecraft.world.World; import panda.gotwood.GotWood; -public class ItemDates extends ItemFood{ +public class ItemDates extends ItemFood { - public ItemDates() { - super(2, 0.1f, false); - this.setRegistryName("dates"); - } - - - @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) - { - net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos); + public ItemDates() { + super(2, 0.1f, false); + this.setRegistryName("dates"); + } - if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && (state.getBlock()== net.minecraft.init.Blocks.GRASS ||state.getBlock()==net.minecraft.init.Blocks.DIRT|| state.getBlock()==net.minecraft.init.Blocks.SAND) && worldIn.isAirBlock(pos.up())) - { - worldIn.setBlockState(pos.up(), Block.REGISTRY.getObject(new ResourceLocation(GotWood.MODID, "palm_sapling")).getDefaultState()); - --stack.stackSize; + @Override + public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + IBlockState state = worldIn.getBlockState(pos); + ItemStack stack = playerIn.getHeldItem(hand); + if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && (state.getBlock() == Blocks.GRASS || state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.SAND) && worldIn.isAirBlock(pos.up())) { + worldIn.setBlockState(pos.up(), Block.REGISTRY.getObject(new ResourceLocation(GotWood.MODID, "palm_sapling")).getDefaultState()); + stack.getCount(); return EnumActionResult.SUCCESS; - } - else - { + } else { return EnumActionResult.FAIL; } } - } diff --git a/src/main/java/panda/gotwood/items/ItemSeed.java b/src/main/java/panda/gotwood/items/ItemSeed.java index 5bc37d9..a77f688 100644 --- a/src/main/java/panda/gotwood/items/ItemSeed.java +++ b/src/main/java/panda/gotwood/items/ItemSeed.java @@ -1,10 +1,7 @@ package panda.gotwood.items; import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -18,63 +15,58 @@ import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.IPlantable; -import net.minecraftforge.fml.common.registry.GameRegistry; import panda.gotwood.GotWood; import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterial; import panda.gotwood.util.WoodMaterials; -public class ItemSeed extends Item implements IOreDictionaryEntry, IPlantable{ - - final WoodMaterial wood; - public final IBlockState sapling; - - public ItemSeed(WoodMaterial wood) - { - this.wood = wood; - this.sapling = getSaplingState(); - this.setRegistryName(wood.getName()+"_seed"); +public class ItemSeed extends Item implements IOreDictionaryEntry, IPlantable { + + public final IBlockState sapling; + final WoodMaterial wood; + + public ItemSeed(WoodMaterial wood) { + this.wood = wood; + this.sapling = getSaplingState(); + this.setRegistryName(wood.getName() + "_seed"); } - - /** + + /** * Called when a Block is right-clicked with this Item */ - @Override - public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) - { - net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos); - - if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && (state.getBlock()== net.minecraft.init.Blocks.GRASS ||state.getBlock()==net.minecraft.init.Blocks.DIRT|| state.getBlock()==net.minecraft.init.Blocks.FARMLAND) && worldIn.isAirBlock(pos.up())) - { - worldIn.setBlockState(pos.up(), this.getSaplingState()); - --stack.stackSize; + @Override + public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + IBlockState state = worldIn.getBlockState(pos); + ItemStack stack = playerIn.getHeldItem(hand); + if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && (state.getBlock() == Blocks.GRASS || state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.FARMLAND) && worldIn.isAirBlock(pos.up())) { + worldIn.setBlockState(pos.up(), this.getSaplingState()); + stack.getCount(); return EnumActionResult.SUCCESS; - } - else - { + } else { return EnumActionResult.FAIL; } } - - private IBlockState getSaplingState(){ - if(wood ==WoodMaterials.acacia || wood ==WoodMaterials.birch || wood ==WoodMaterials.darkOak || wood ==WoodMaterials.jungle || wood ==WoodMaterials.oak || wood ==WoodMaterials.spruce){ - return Blocks.SAPLING.getStateFromMeta(wood.getMeta()); - }else - return Block.REGISTRY.getObject(new ResourceLocation(GotWood.MODID, wood+"_sapling")).getDefaultState(); - } - @Override - public String getOreDictionaryName() { - return "seed" + this.wood.getCapitalizedName(); - } + private IBlockState getSaplingState() { + if (wood == WoodMaterials.acacia || wood == WoodMaterials.birch || wood == WoodMaterials.darkOak || wood == WoodMaterials.jungle || wood == WoodMaterials.oak || wood == WoodMaterials.spruce) { + return Blocks.SAPLING.getStateFromMeta(wood.getMeta()); + } else { + return Block.REGISTRY.getObject(new ResourceLocation(GotWood.MODID, wood + "_sapling")).getDefaultState(); + } + } - @Override - public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { - return EnumPlantType.Plains; - } + @Override + public String getOreDictionaryName() { + return "seed" + this.wood.getCapitalizedName(); + } - @Override - public IBlockState getPlant(IBlockAccess world, BlockPos pos) { - return getSaplingState(); - } + @Override + public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { + return EnumPlantType.Plains; + } + + @Override + public IBlockState getPlant(IBlockAccess world, BlockPos pos) { + return getSaplingState(); + } } diff --git a/src/main/java/panda/gotwood/proxy/ClientProxy.java b/src/main/java/panda/gotwood/proxy/ClientProxy.java deleted file mode 100644 index 98461b6..0000000 --- a/src/main/java/panda/gotwood/proxy/ClientProxy.java +++ /dev/null @@ -1,4 +0,0 @@ -package panda.gotwood.proxy; - -public class ClientProxy extends CommonProxy { -} diff --git a/src/main/java/panda/gotwood/proxy/CommonProxy.java b/src/main/java/panda/gotwood/proxy/CommonProxy.java deleted file mode 100644 index 7b9184f..0000000 --- a/src/main/java/panda/gotwood/proxy/CommonProxy.java +++ /dev/null @@ -1,13 +0,0 @@ -package panda.gotwood.proxy; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public abstract class CommonProxy { - public void preInit(FMLPreInitializationEvent e) {} - - public void init(FMLInitializationEvent e) {} - - public void postInit(FMLPostInitializationEvent e) {} -} diff --git a/src/main/java/panda/gotwood/proxy/ServerProxy.java b/src/main/java/panda/gotwood/proxy/ServerProxy.java deleted file mode 100644 index 55fd8a8..0000000 --- a/src/main/java/panda/gotwood/proxy/ServerProxy.java +++ /dev/null @@ -1,5 +0,0 @@ -package panda.gotwood.proxy; - -public class ServerProxy extends CommonProxy { - -} diff --git a/src/main/java/panda/gotwood/registry/BlockRegistry.java b/src/main/java/panda/gotwood/registry/BlockRegistry.java index adeedd5..abd93f6 100644 --- a/src/main/java/panda/gotwood/registry/BlockRegistry.java +++ b/src/main/java/panda/gotwood/registry/BlockRegistry.java @@ -1,378 +1,256 @@ package panda.gotwood.registry; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import net.minecraft.block.Block; import net.minecraft.block.BlockDoor; import net.minecraft.block.BlockSlab; - -import panda.gotwood.block.BlockBambooFence; -import panda.gotwood.block.BlockBambooLog; -import panda.gotwood.block.BlockDates; -import panda.gotwood.block.BlockDoubleSlab; -import panda.gotwood.block.BlockFruitSapling; -import panda.gotwood.block.BlockFruitingLeaves; -import panda.gotwood.block.BlockHalfSlab; -import panda.gotwood.block.BlockPalmLeaves; -import panda.gotwood.block.BlockPlanks; -import panda.gotwood.block.BlockSappyLog; -import panda.gotwood.block.BlockSpecialFire; -import panda.gotwood.block.BlockTreeTap; -import panda.gotwood.block.BlockWoodDoor; -import panda.gotwood.block.BlockWoodFence; -import panda.gotwood.block.BlockWoodFenceGate; -import panda.gotwood.block.BlockWoodLeaves; -import panda.gotwood.block.BlockWoodLog; -import panda.gotwood.block.BlockWoodSapling; -import panda.gotwood.block.BlockWoodStairs; -import panda.gotwood.block.BlockWoodTrapdoor; +import panda.gotwood.block.*; import panda.gotwood.util.WoodMaterials; -public final class BlockRegistry { - private BlockRegistry() {} - - /* - * Declare items here and then subsequently add them to getList(); They will be automatically moved to registration and model loading. - */ - public static final Block apple_log = new BlockWoodLog(WoodMaterials.apple); - - public static final Block apple_planks = new BlockPlanks(WoodMaterials.apple); - - public static final BlockDoor apple_door = new BlockWoodDoor(WoodMaterials.apple); - - public static final Block apple_trapdoor = new BlockWoodTrapdoor(WoodMaterials.apple); - - public static final Block apple_leaves = new BlockFruitingLeaves(WoodMaterials.apple); - - public static final Block apple_sapling = new BlockFruitSapling(WoodMaterials.apple); - - public static final Block apple_gate = new BlockWoodFenceGate(WoodMaterials.apple); - - public static final BlockSlab apple_slab = new BlockHalfSlab(WoodMaterials.apple); - - public static final BlockSlab double_apple_slab = new BlockDoubleSlab(WoodMaterials.apple); - - public static final Block apple_stairs = new BlockWoodStairs(WoodMaterials.apple, apple_planks); - - public static final Block apple_fence = new BlockWoodFence(WoodMaterials.apple); - - public static final Block maple_log = new BlockWoodLog(WoodMaterials.maple); - - public static final Block maple_planks = new BlockPlanks(WoodMaterials.maple); - - public static final BlockDoor maple_door = new BlockWoodDoor(WoodMaterials.maple); - - public static final Block maple_trapdoor = new BlockWoodTrapdoor(WoodMaterials.maple); - - public static final Block maple_leaves = new BlockWoodLeaves(WoodMaterials.maple); - - public static final Block maple_sapling = new BlockWoodSapling(WoodMaterials.maple); - - public static final Block maple_gate = new BlockWoodFenceGate(WoodMaterials.maple); - - public static final BlockSlab maple_slab = new BlockHalfSlab(WoodMaterials.maple); - - public static final BlockSlab double_maple_slab = new BlockDoubleSlab(WoodMaterials.maple); - - public static final Block maple_stairs = new BlockWoodStairs(WoodMaterials.maple, maple_planks); - - public static final Block maple_fence = new BlockWoodFence(WoodMaterials.maple); - - public static final Block pine_log = new BlockWoodLog(WoodMaterials.pine); - - public static final Block pine_planks = new BlockPlanks(WoodMaterials.pine); - - public static final BlockDoor pine_door = new BlockWoodDoor(WoodMaterials.pine); - - public static final Block pine_trapdoor = new BlockWoodTrapdoor(WoodMaterials.pine); - - public static final Block pine_leaves = new BlockWoodLeaves(WoodMaterials.pine); - - public static final Block pine_sapling = new BlockWoodSapling(WoodMaterials.pine); - - public static final Block pine_gate = new BlockWoodFenceGate(WoodMaterials.pine); - - public static final BlockSlab pine_slab = new BlockHalfSlab(WoodMaterials.pine); - - public static final BlockSlab double_pine_slab = new BlockDoubleSlab(WoodMaterials.pine); - - public static final Block pine_stairs = new BlockWoodStairs(WoodMaterials.pine, pine_planks); - - public static final Block pine_fence = new BlockWoodFence(WoodMaterials.pine); - - public static final Block willow_log = new BlockWoodLog(WoodMaterials.willow); - - public static final Block willow_planks = new BlockPlanks(WoodMaterials.willow); - - public static final BlockDoor willow_door = new BlockWoodDoor(WoodMaterials.willow); - - public static final Block willow_trapdoor = new BlockWoodTrapdoor(WoodMaterials.willow); - - public static final Block willow_leaves = new BlockWoodLeaves(WoodMaterials.willow); - - public static final Block willow_sapling = new BlockWoodSapling(WoodMaterials.willow); - - public static final Block willow_gate = new BlockWoodFenceGate(WoodMaterials.willow); - - public static final BlockSlab willow_slab = new BlockHalfSlab(WoodMaterials.willow); - - public static final BlockSlab double_willow_slab = new BlockDoubleSlab(WoodMaterials.willow); - - public static final Block willow_stairs = new BlockWoodStairs(WoodMaterials.willow, willow_planks); - - public static final Block willow_fence = new BlockWoodFence(WoodMaterials.willow); - - public static final Block yew_log = new BlockWoodLog(WoodMaterials.yew); - - public static final Block yew_planks = new BlockPlanks(WoodMaterials.yew); - - public static final BlockDoor yew_door = new BlockWoodDoor(WoodMaterials.yew); - - public static final Block yew_trapdoor = new BlockWoodTrapdoor(WoodMaterials.yew); - - public static final Block yew_leaves = new BlockWoodLeaves(WoodMaterials.yew); - - public static final Block yew_sapling = new BlockWoodSapling(WoodMaterials.yew); - - public static final Block yew_gate = new BlockWoodFenceGate(WoodMaterials.yew); - - public static final BlockSlab yew_slab = new BlockHalfSlab(WoodMaterials.yew); - - public static final BlockSlab double_yew_slab = new BlockDoubleSlab(WoodMaterials.yew); - - public static final Block yew_stairs = new BlockWoodStairs(WoodMaterials.yew, yew_planks); - - public static final Block yew_fence = new BlockWoodFence(WoodMaterials.yew); - - public static final Block ebony_log = new BlockWoodLog(WoodMaterials.ebony); - - public static final Block ebony_planks = new BlockPlanks(WoodMaterials.ebony); - - public static final BlockDoor ebony_door = new BlockWoodDoor(WoodMaterials.ebony); - - public static final Block ebony_trapdoor = new BlockWoodTrapdoor(WoodMaterials.ebony); - - public static final Block ebony_leaves = new BlockWoodLeaves(WoodMaterials.ebony); - - public static final Block ebony_sapling = new BlockWoodSapling(WoodMaterials.ebony); - - public static final Block ebony_gate = new BlockWoodFenceGate(WoodMaterials.ebony); - - public static final BlockSlab ebony_slab = new BlockHalfSlab(WoodMaterials.ebony); - - public static final BlockSlab double_ebony_slab = new BlockDoubleSlab(WoodMaterials.ebony); - - public static final Block ebony_stairs = new BlockWoodStairs(WoodMaterials.ebony, ebony_planks); - - public static final Block ebony_fence = new BlockWoodFence(WoodMaterials.ebony); - - public static final Block fir_log = new BlockWoodLog(WoodMaterials.fir); - - public static final Block fir_planks = new BlockPlanks(WoodMaterials.fir); - - public static final BlockDoor fir_door = new BlockWoodDoor(WoodMaterials.fir); - - public static final Block fir_trapdoor = new BlockWoodTrapdoor(WoodMaterials.fir); - - public static final Block fir_leaves = new BlockWoodLeaves(WoodMaterials.fir); - - public static final Block fir_sapling = new BlockWoodSapling(WoodMaterials.fir); - - public static final Block fir_gate = new BlockWoodFenceGate(WoodMaterials.fir); - - public static final BlockSlab fir_slab = new BlockHalfSlab(WoodMaterials.fir); - - public static final BlockSlab double_fir_slab = new BlockDoubleSlab(WoodMaterials.fir); - - public static final Block fir_stairs = new BlockWoodStairs(WoodMaterials.fir, fir_planks); - - public static final Block fir_fence = new BlockWoodFence(WoodMaterials.fir); - - public static final BlockSpecialFire specialfire = new BlockSpecialFire(); - - public static final Block treetap = new BlockTreeTap(); - - public static final Block bamboo_sapling = new BlockWoodSapling(WoodMaterials.bamboo).setHardness(1.0F); - - public static final Block bamboo_leaves = new BlockWoodLeaves(WoodMaterials.bamboo); - - public static final Block bamboo_log = new BlockBambooLog(WoodMaterials.bamboo); - - public static final Block bamboo_planks = new BlockPlanks(WoodMaterials.bamboo); - - public static final BlockDoor bamboo_door = new BlockWoodDoor(WoodMaterials.bamboo); - - public static final Block bamboo_trapdoor = new BlockWoodTrapdoor(WoodMaterials.bamboo); - - public static final Block bamboo_stairs = new BlockWoodStairs(WoodMaterials.bamboo, bamboo_planks); - - public static final Block bamboo_fence = new BlockBambooFence(WoodMaterials.bamboo); - - public static final Block bamboo_gate = new BlockWoodFenceGate(WoodMaterials.bamboo); - - public static final BlockSlab bamboo_slab = new BlockHalfSlab(WoodMaterials.bamboo); - - public static final BlockSlab double_bamboo_slab = new BlockDoubleSlab(WoodMaterials.bamboo); - - public static final Block palm_log = new BlockWoodLog(WoodMaterials.palm); - - public static final Block palm_planks = new BlockPlanks(WoodMaterials.palm); - - public static final BlockDoor palm_door = new BlockWoodDoor(WoodMaterials.palm); - - public static final Block palm_trapdoor = new BlockWoodTrapdoor(WoodMaterials.palm); - - public static final Block palm_leaves = new BlockPalmLeaves(WoodMaterials.palm); - - public static final Block palm_sapling = new BlockWoodSapling(WoodMaterials.palm); - - public static final Block palm_gate = new BlockWoodFenceGate(WoodMaterials.palm); - - public static final BlockSlab palm_slab = new BlockHalfSlab(WoodMaterials.palm); - - public static final BlockSlab double_palm_slab = new BlockDoubleSlab(WoodMaterials.palm); - - public static final Block palm_stairs = new BlockWoodStairs(WoodMaterials.palm, palm_planks); - - public static final Block palm_fence = new BlockWoodFence(WoodMaterials.palm); - - public static final Block dates_block = new BlockDates(); - - public static final Block rubber_log = new BlockSappyLog(WoodMaterials.rubber); - - public static final Block rubber_leaves = new BlockWoodLeaves(WoodMaterials.rubber); - - public static final Block rubber_sapling = new BlockWoodSapling(WoodMaterials.rubber); - - public static List getBlockList() { - List list = new ArrayList<>(); - list.add(specialfire); - - list.add(apple_sapling); - list.add(maple_sapling); - list.add(pine_sapling); - list.add(willow_sapling); - list.add(yew_sapling); - list.add(fir_sapling); - list.add(ebony_sapling); - list.add(bamboo_sapling); - list.add(palm_sapling); - - list.add(apple_log); - list.add(maple_log); - list.add(pine_log); - list.add(willow_log); - list.add(yew_log); - list.add(fir_log); - list.add(ebony_log); - list.add(bamboo_log); - list.add(palm_log); - - list.add(apple_leaves); - list.add(maple_leaves); - list.add(pine_leaves); - list.add(willow_leaves); - list.add(yew_leaves); - list.add(fir_leaves); - list.add(ebony_leaves); - list.add(bamboo_leaves); - list.add(palm_leaves); - - list.add(apple_planks); - list.add(maple_planks); - list.add(pine_planks); - list.add(willow_planks); - list.add(yew_planks); - list.add(fir_planks); - list.add(ebony_planks); - list.add(bamboo_planks); - list.add(palm_planks); - - list.add(apple_door); - list.add(maple_door); - list.add(pine_door); - list.add(willow_door); - list.add(yew_door); - list.add(fir_door); - list.add(ebony_door); - list.add(bamboo_door); - list.add(palm_door); - - list.add(apple_trapdoor); - list.add(maple_trapdoor); - list.add(pine_trapdoor); - list.add(willow_trapdoor); - list.add(yew_trapdoor); - list.add(fir_trapdoor); - list.add(ebony_trapdoor); - list.add(bamboo_trapdoor); - list.add(palm_trapdoor); - - list.add(apple_gate); - list.add(maple_gate); - list.add(pine_gate); - list.add(willow_gate); - list.add(yew_gate); - list.add(fir_gate); - list.add(ebony_gate); - list.add(bamboo_gate); - list.add(palm_gate); - - list.add(apple_stairs); - list.add(maple_stairs); - list.add(pine_stairs); - list.add(willow_stairs); - list.add(yew_stairs); - list.add(fir_stairs); - list.add(ebony_stairs); - list.add(bamboo_stairs); - list.add(palm_stairs); - - list.add(apple_fence); - list.add(maple_fence); - list.add(pine_fence); - list.add(willow_fence); - list.add(yew_fence); - list.add(fir_fence); - list.add(ebony_fence); - list.add(bamboo_fence); - list.add(palm_fence); - list.add(rubber_log); - list.add(rubber_leaves); - list.add(rubber_sapling); - - list.add(apple_slab); - list.add(double_apple_slab); - list.add(maple_slab); - list.add(double_maple_slab); - list.add(pine_slab); - list.add(double_pine_slab); - list.add(willow_slab); - list.add(double_willow_slab); - list.add(yew_slab); - list.add(double_yew_slab); - list.add(fir_slab); - list.add(double_fir_slab); - list.add(ebony_slab); - list.add(double_ebony_slab); - list.add(bamboo_slab); - list.add(double_bamboo_slab); - list.add(palm_slab); - list.add(double_palm_slab); - - list.add(dates_block); - - //list.add(treetap); - - return list; - } +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; - static final Map registry = new HashMap<>(); +//TODO Use the EventBusSubscriber system and an object holder class elsewhere (Likely panda.gotwood.api.GWBlocks) +public final class BlockRegistry { - public static Block getBlockByName(String name) { - return registry.get(name); - } + /* + * Declare items here and then subsequently add them to getList(); They will be automatically moved to registration and model loading. + */ + public static final Block apple_log = new BlockWoodLog(WoodMaterials.apple); + public static final Block apple_planks = new BlockPlanks(WoodMaterials.apple); + public static final BlockDoor apple_door = new BlockWoodDoor(WoodMaterials.apple); + public static final Block apple_trapdoor = new BlockWoodTrapdoor(WoodMaterials.apple); + public static final Block apple_leaves = new BlockFruitingLeaves(WoodMaterials.apple); + public static final Block apple_sapling = new BlockFruitSapling(WoodMaterials.apple); + public static final Block apple_gate = new BlockWoodFenceGate(WoodMaterials.apple); + public static final BlockSlab apple_slab = new BlockHalfSlab(WoodMaterials.apple); + public static final BlockSlab double_apple_slab = new BlockDoubleSlab(WoodMaterials.apple); + public static final Block apple_stairs = new BlockWoodStairs(WoodMaterials.apple, apple_planks); + public static final Block apple_fence = new BlockWoodFence(WoodMaterials.apple); + public static final Block maple_log = new BlockWoodLog(WoodMaterials.maple); + public static final Block maple_planks = new BlockPlanks(WoodMaterials.maple); + public static final BlockDoor maple_door = new BlockWoodDoor(WoodMaterials.maple); + public static final Block maple_trapdoor = new BlockWoodTrapdoor(WoodMaterials.maple); + public static final Block maple_leaves = new BlockWoodLeaves(WoodMaterials.maple); + public static final Block maple_sapling = new BlockWoodSapling(WoodMaterials.maple); + public static final Block maple_gate = new BlockWoodFenceGate(WoodMaterials.maple); + public static final BlockSlab maple_slab = new BlockHalfSlab(WoodMaterials.maple); + public static final BlockSlab double_maple_slab = new BlockDoubleSlab(WoodMaterials.maple); + public static final Block maple_stairs = new BlockWoodStairs(WoodMaterials.maple, maple_planks); + public static final Block maple_fence = new BlockWoodFence(WoodMaterials.maple); + public static final Block pine_log = new BlockWoodLog(WoodMaterials.pine); + public static final Block pine_planks = new BlockPlanks(WoodMaterials.pine); + public static final BlockDoor pine_door = new BlockWoodDoor(WoodMaterials.pine); + public static final Block pine_trapdoor = new BlockWoodTrapdoor(WoodMaterials.pine); + public static final Block pine_leaves = new BlockWoodLeaves(WoodMaterials.pine); + public static final Block pine_sapling = new BlockWoodSapling(WoodMaterials.pine); + public static final Block pine_gate = new BlockWoodFenceGate(WoodMaterials.pine); + public static final BlockSlab pine_slab = new BlockHalfSlab(WoodMaterials.pine); + public static final BlockSlab double_pine_slab = new BlockDoubleSlab(WoodMaterials.pine); + public static final Block pine_stairs = new BlockWoodStairs(WoodMaterials.pine, pine_planks); + public static final Block pine_fence = new BlockWoodFence(WoodMaterials.pine); + public static final Block willow_log = new BlockWoodLog(WoodMaterials.willow); + public static final Block willow_planks = new BlockPlanks(WoodMaterials.willow); + public static final BlockDoor willow_door = new BlockWoodDoor(WoodMaterials.willow); + public static final Block willow_trapdoor = new BlockWoodTrapdoor(WoodMaterials.willow); + public static final Block willow_leaves = new BlockWoodLeaves(WoodMaterials.willow); + public static final Block willow_sapling = new BlockWoodSapling(WoodMaterials.willow); + public static final Block willow_gate = new BlockWoodFenceGate(WoodMaterials.willow); + public static final BlockSlab willow_slab = new BlockHalfSlab(WoodMaterials.willow); + public static final BlockSlab double_willow_slab = new BlockDoubleSlab(WoodMaterials.willow); + public static final Block willow_stairs = new BlockWoodStairs(WoodMaterials.willow, willow_planks); + public static final Block willow_fence = new BlockWoodFence(WoodMaterials.willow); + public static final Block yew_log = new BlockWoodLog(WoodMaterials.yew); + public static final Block yew_planks = new BlockPlanks(WoodMaterials.yew); + public static final BlockDoor yew_door = new BlockWoodDoor(WoodMaterials.yew); + public static final Block yew_trapdoor = new BlockWoodTrapdoor(WoodMaterials.yew); + public static final Block yew_leaves = new BlockWoodLeaves(WoodMaterials.yew); + public static final Block yew_sapling = new BlockWoodSapling(WoodMaterials.yew); + public static final Block yew_gate = new BlockWoodFenceGate(WoodMaterials.yew); + public static final BlockSlab yew_slab = new BlockHalfSlab(WoodMaterials.yew); + public static final BlockSlab double_yew_slab = new BlockDoubleSlab(WoodMaterials.yew); + public static final Block yew_stairs = new BlockWoodStairs(WoodMaterials.yew, yew_planks); + public static final Block yew_fence = new BlockWoodFence(WoodMaterials.yew); + public static final Block ebony_log = new BlockWoodLog(WoodMaterials.ebony); + public static final Block ebony_planks = new BlockPlanks(WoodMaterials.ebony); + public static final BlockDoor ebony_door = new BlockWoodDoor(WoodMaterials.ebony); + public static final Block ebony_trapdoor = new BlockWoodTrapdoor(WoodMaterials.ebony); + public static final Block ebony_leaves = new BlockWoodLeaves(WoodMaterials.ebony); + public static final Block ebony_sapling = new BlockWoodSapling(WoodMaterials.ebony); + public static final Block ebony_gate = new BlockWoodFenceGate(WoodMaterials.ebony); + public static final BlockSlab ebony_slab = new BlockHalfSlab(WoodMaterials.ebony); + public static final BlockSlab double_ebony_slab = new BlockDoubleSlab(WoodMaterials.ebony); + public static final Block ebony_stairs = new BlockWoodStairs(WoodMaterials.ebony, ebony_planks); + public static final Block ebony_fence = new BlockWoodFence(WoodMaterials.ebony); + public static final Block fir_log = new BlockWoodLog(WoodMaterials.fir); + public static final Block fir_planks = new BlockPlanks(WoodMaterials.fir); + public static final BlockDoor fir_door = new BlockWoodDoor(WoodMaterials.fir); + public static final Block fir_trapdoor = new BlockWoodTrapdoor(WoodMaterials.fir); + public static final Block fir_leaves = new BlockWoodLeaves(WoodMaterials.fir); + public static final Block fir_sapling = new BlockWoodSapling(WoodMaterials.fir); + public static final Block fir_gate = new BlockWoodFenceGate(WoodMaterials.fir); + public static final BlockSlab fir_slab = new BlockHalfSlab(WoodMaterials.fir); + public static final BlockSlab double_fir_slab = new BlockDoubleSlab(WoodMaterials.fir); + public static final Block fir_stairs = new BlockWoodStairs(WoodMaterials.fir, fir_planks); + public static final Block fir_fence = new BlockWoodFence(WoodMaterials.fir); + public static final BlockSpecialFire specialfire = new BlockSpecialFire(); + public static final Block treetap = new BlockTreeTap(); + public static final Block bamboo_sapling = new BlockWoodSapling(WoodMaterials.bamboo).setHardness(1.0F); + public static final Block bamboo_leaves = new BlockWoodLeaves(WoodMaterials.bamboo); + public static final Block bamboo_log = new BlockBambooLog(WoodMaterials.bamboo); + public static final Block bamboo_planks = new BlockPlanks(WoodMaterials.bamboo); + public static final BlockDoor bamboo_door = new BlockWoodDoor(WoodMaterials.bamboo); + public static final Block bamboo_trapdoor = new BlockWoodTrapdoor(WoodMaterials.bamboo); + public static final Block bamboo_stairs = new BlockWoodStairs(WoodMaterials.bamboo, bamboo_planks); + public static final Block bamboo_fence = new BlockBambooFence(WoodMaterials.bamboo); + public static final Block bamboo_gate = new BlockWoodFenceGate(WoodMaterials.bamboo); + public static final BlockSlab bamboo_slab = new BlockHalfSlab(WoodMaterials.bamboo); + public static final BlockSlab double_bamboo_slab = new BlockDoubleSlab(WoodMaterials.bamboo); + public static final Block palm_log = new BlockWoodLog(WoodMaterials.palm); + public static final Block palm_planks = new BlockPlanks(WoodMaterials.palm); + public static final BlockDoor palm_door = new BlockWoodDoor(WoodMaterials.palm); + public static final Block palm_trapdoor = new BlockWoodTrapdoor(WoodMaterials.palm); + public static final Block palm_leaves = new BlockPalmLeaves(WoodMaterials.palm); + public static final Block palm_sapling = new BlockWoodSapling(WoodMaterials.palm); + public static final Block palm_gate = new BlockWoodFenceGate(WoodMaterials.palm); + public static final BlockSlab palm_slab = new BlockHalfSlab(WoodMaterials.palm); + public static final BlockSlab double_palm_slab = new BlockDoubleSlab(WoodMaterials.palm); + public static final Block palm_stairs = new BlockWoodStairs(WoodMaterials.palm, palm_planks); + public static final Block palm_fence = new BlockWoodFence(WoodMaterials.palm); + public static final Block dates_block = new BlockDates(); + public static final Block rubber_log = new BlockSappyLog(WoodMaterials.rubber); + public static final Block rubber_leaves = new BlockWoodLeaves(WoodMaterials.rubber); + public static final Block rubber_sapling = new BlockWoodSapling(WoodMaterials.rubber); + static final Map registry = new HashMap<>(); + + private BlockRegistry() { + } + + public static List getBlockList() { + List list = new ArrayList<>(); + list.add(specialfire); + + list.add(apple_sapling); + list.add(maple_sapling); + list.add(pine_sapling); + list.add(willow_sapling); + list.add(yew_sapling); + list.add(fir_sapling); + list.add(ebony_sapling); + list.add(bamboo_sapling); + list.add(palm_sapling); + + list.add(apple_log); + list.add(maple_log); + list.add(pine_log); + list.add(willow_log); + list.add(yew_log); + list.add(fir_log); + list.add(ebony_log); + list.add(bamboo_log); + list.add(palm_log); + + list.add(apple_leaves); + list.add(maple_leaves); + list.add(pine_leaves); + list.add(willow_leaves); + list.add(yew_leaves); + list.add(fir_leaves); + list.add(ebony_leaves); + list.add(bamboo_leaves); + list.add(palm_leaves); + + list.add(apple_planks); + list.add(maple_planks); + list.add(pine_planks); + list.add(willow_planks); + list.add(yew_planks); + list.add(fir_planks); + list.add(ebony_planks); + list.add(bamboo_planks); + list.add(palm_planks); + + list.add(apple_door); + list.add(maple_door); + list.add(pine_door); + list.add(willow_door); + list.add(yew_door); + list.add(fir_door); + list.add(ebony_door); + list.add(bamboo_door); + list.add(palm_door); + + list.add(apple_trapdoor); + list.add(maple_trapdoor); + list.add(pine_trapdoor); + list.add(willow_trapdoor); + list.add(yew_trapdoor); + list.add(fir_trapdoor); + list.add(ebony_trapdoor); + list.add(bamboo_trapdoor); + list.add(palm_trapdoor); + + list.add(apple_gate); + list.add(maple_gate); + list.add(pine_gate); + list.add(willow_gate); + list.add(yew_gate); + list.add(fir_gate); + list.add(ebony_gate); + list.add(bamboo_gate); + list.add(palm_gate); + + list.add(apple_stairs); + list.add(maple_stairs); + list.add(pine_stairs); + list.add(willow_stairs); + list.add(yew_stairs); + list.add(fir_stairs); + list.add(ebony_stairs); + list.add(bamboo_stairs); + list.add(palm_stairs); + + list.add(apple_fence); + list.add(maple_fence); + list.add(pine_fence); + list.add(willow_fence); + list.add(yew_fence); + list.add(fir_fence); + list.add(ebony_fence); + list.add(bamboo_fence); + list.add(palm_fence); + list.add(rubber_log); + list.add(rubber_leaves); + list.add(rubber_sapling); + + list.add(apple_slab); + list.add(double_apple_slab); + list.add(maple_slab); + list.add(double_maple_slab); + list.add(pine_slab); + list.add(double_pine_slab); + list.add(willow_slab); + list.add(double_willow_slab); + list.add(yew_slab); + list.add(double_yew_slab); + list.add(fir_slab); + list.add(double_fir_slab); + list.add(ebony_slab); + list.add(double_ebony_slab); + list.add(bamboo_slab); + list.add(double_bamboo_slab); + list.add(palm_slab); + list.add(double_palm_slab); + + list.add(dates_block); + + //list.add(treetap); + + return list; + } + + public static Block getBlockByName(String name) { + return registry.get(name); + } } diff --git a/src/main/java/panda/gotwood/registry/ItemRegistry.java b/src/main/java/panda/gotwood/registry/ItemRegistry.java index 2bda159..e52fe06 100644 --- a/src/main/java/panda/gotwood/registry/ItemRegistry.java +++ b/src/main/java/panda/gotwood/registry/ItemRegistry.java @@ -1,145 +1,110 @@ package panda.gotwood.registry; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import net.minecraft.item.Item; - import panda.gotwood.item.ItemDates; import panda.gotwood.item.ItemSeed; import panda.gotwood.item.ItemWoodDoor; import panda.gotwood.item.ItemWoodSlab; import panda.gotwood.util.WoodMaterials; -public final class ItemRegistry { - private ItemRegistry() {} - - public static final Item apple_door = new ItemWoodDoor(BlockRegistry.apple_door, WoodMaterials.apple); - - public static final Item maple_door = new ItemWoodDoor(BlockRegistry.maple_door, WoodMaterials.maple); - - public static final Item pine_door = new ItemWoodDoor(BlockRegistry.pine_door, WoodMaterials.pine); - - public static final Item willow_door = new ItemWoodDoor(BlockRegistry.willow_door, WoodMaterials.willow); - - public static final Item yew_door = new ItemWoodDoor(BlockRegistry.yew_door, WoodMaterials.yew); - - public static final Item ebony_door = new ItemWoodDoor(BlockRegistry.ebony_door, WoodMaterials.ebony); - - public static final Item fir_door = new ItemWoodDoor(BlockRegistry.fir_door, WoodMaterials.fir); - - public static final Item bamboo_door = new ItemWoodDoor(BlockRegistry.bamboo_door, WoodMaterials.bamboo); - - public static final Item palm_door = new ItemWoodDoor(BlockRegistry.palm_door, WoodMaterials.palm); - - public static final Item apple_seed = new ItemSeed(WoodMaterials.apple); - - public static final Item maple_seed = new ItemSeed(WoodMaterials.maple); - - public static final Item pine_seed = new ItemSeed(WoodMaterials.pine); - - public static final Item willow_seed = new ItemSeed(WoodMaterials.willow); - - public static final Item yew_seed = new ItemSeed(WoodMaterials.yew); - - public static final Item ebony_seed = new ItemSeed(WoodMaterials.ebony); - - public static final Item fir_seed = new ItemSeed(WoodMaterials.fir); - - public static final Item bamboo_seed = new ItemSeed(WoodMaterials.bamboo); - - public static final Item rubber_seed = new ItemSeed(WoodMaterials.rubber); - - public static final Item oak_seed = new ItemSeed(WoodMaterials.oak); - - public static final Item birch_seed = new ItemSeed(WoodMaterials.birch); - - public static final Item spruce_seed = new ItemSeed(WoodMaterials.spruce); - - public static final Item dark_oak_seed = new ItemSeed(WoodMaterials.darkOak); - - public static final Item jungle_seed = new ItemSeed(WoodMaterials.jungle); - - public static final Item acacia_seed = new ItemSeed(WoodMaterials.acacia); - - public static final Item apple_slab = new ItemWoodSlab(WoodMaterials.apple, BlockRegistry.apple_slab, BlockRegistry.double_apple_slab); - - public static final Item maple_slab = new ItemWoodSlab(WoodMaterials.maple, BlockRegistry.maple_slab, BlockRegistry.double_maple_slab); - - public static final Item pine_slab = new ItemWoodSlab(WoodMaterials.pine, BlockRegistry.pine_slab, BlockRegistry.double_pine_slab); - - public static final Item willow_slab = new ItemWoodSlab(WoodMaterials.willow, BlockRegistry.willow_slab, BlockRegistry.double_willow_slab); - - public static final Item yew_slab = new ItemWoodSlab(WoodMaterials.yew, BlockRegistry.yew_slab, BlockRegistry.double_yew_slab); - - public static final Item ebony_slab = new ItemWoodSlab(WoodMaterials.ebony, BlockRegistry.ebony_slab, BlockRegistry.double_ebony_slab); - - public static final Item fir_slab = new ItemWoodSlab(WoodMaterials.fir, BlockRegistry.fir_slab, BlockRegistry.double_fir_slab); - - public static final Item ash = new Item().setRegistryName("ash"); - - public static final Item bamboo_pole = new Item().setRegistryName("bamboo_pole"); - - public static final Item bamboo_charcoal = new Item().setRegistryName("bamboo_charcoal"); - - public static final Item dates = new ItemDates(); - - public static final Item maple_sap = new Item().setRegistryName("maple_sap").setMaxStackSize(1); - - public static final Item rubber_sap = new Item().setRegistryName("rubber_sap").setMaxStackSize(1); - - public static List getItemList() { - List list = new ArrayList<>(); - list.add(apple_seed); - list.add(maple_seed); - list.add(pine_seed); - list.add(willow_seed); - list.add(yew_seed); - list.add(fir_seed); - list.add(ebony_seed); - list.add(dates); - list.add(bamboo_seed); - list.add(rubber_seed); - list.add(maple_sap); - list.add(rubber_sap); - - list.add(apple_door); - list.add(maple_door); - list.add(pine_door); - list.add(willow_door); - list.add(yew_door); - list.add(fir_door); - list.add(ebony_door); - list.add(bamboo_door); - list.add(palm_door); - - list.add(oak_seed); - list.add(birch_seed); - list.add(dark_oak_seed); - list.add(jungle_seed); - list.add(acacia_seed); - list.add(spruce_seed); - - list.add(apple_slab); - list.add(maple_slab); - list.add(pine_slab); - list.add(willow_slab); - list.add(yew_slab); - list.add(ebony_slab); - list.add(fir_slab); - - list.add(bamboo_charcoal); - list.add(bamboo_pole); - list.add(ash); - - return list; - } +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; - static final Map registry = new HashMap<>(); +//TODO Use the EventBusSubscriber system and an object holder class elsewhere (Likely panda.gotwood.api.GWItems) +public final class ItemRegistry { - public static Item getItemByName(String name) { - return registry.get(name); - } + public static final Item apple_door = new ItemWoodDoor(BlockRegistry.apple_door, WoodMaterials.apple); + public static final Item maple_door = new ItemWoodDoor(BlockRegistry.maple_door, WoodMaterials.maple); + public static final Item pine_door = new ItemWoodDoor(BlockRegistry.pine_door, WoodMaterials.pine); + public static final Item willow_door = new ItemWoodDoor(BlockRegistry.willow_door, WoodMaterials.willow); + public static final Item yew_door = new ItemWoodDoor(BlockRegistry.yew_door, WoodMaterials.yew); + public static final Item ebony_door = new ItemWoodDoor(BlockRegistry.ebony_door, WoodMaterials.ebony); + public static final Item fir_door = new ItemWoodDoor(BlockRegistry.fir_door, WoodMaterials.fir); + public static final Item bamboo_door = new ItemWoodDoor(BlockRegistry.bamboo_door, WoodMaterials.bamboo); + public static final Item palm_door = new ItemWoodDoor(BlockRegistry.palm_door, WoodMaterials.palm); + public static final Item apple_seed = new ItemSeed(WoodMaterials.apple); + public static final Item maple_seed = new ItemSeed(WoodMaterials.maple); + public static final Item pine_seed = new ItemSeed(WoodMaterials.pine); + public static final Item willow_seed = new ItemSeed(WoodMaterials.willow); + public static final Item yew_seed = new ItemSeed(WoodMaterials.yew); + public static final Item ebony_seed = new ItemSeed(WoodMaterials.ebony); + public static final Item fir_seed = new ItemSeed(WoodMaterials.fir); + public static final Item bamboo_seed = new ItemSeed(WoodMaterials.bamboo); + public static final Item rubber_seed = new ItemSeed(WoodMaterials.rubber); + public static final Item oak_seed = new ItemSeed(WoodMaterials.oak); + public static final Item birch_seed = new ItemSeed(WoodMaterials.birch); + public static final Item spruce_seed = new ItemSeed(WoodMaterials.spruce); + public static final Item dark_oak_seed = new ItemSeed(WoodMaterials.darkOak); + public static final Item jungle_seed = new ItemSeed(WoodMaterials.jungle); + public static final Item acacia_seed = new ItemSeed(WoodMaterials.acacia); + public static final Item apple_slab = new ItemWoodSlab(WoodMaterials.apple, BlockRegistry.apple_slab, BlockRegistry.double_apple_slab); + public static final Item maple_slab = new ItemWoodSlab(WoodMaterials.maple, BlockRegistry.maple_slab, BlockRegistry.double_maple_slab); + public static final Item pine_slab = new ItemWoodSlab(WoodMaterials.pine, BlockRegistry.pine_slab, BlockRegistry.double_pine_slab); + public static final Item willow_slab = new ItemWoodSlab(WoodMaterials.willow, BlockRegistry.willow_slab, BlockRegistry.double_willow_slab); + public static final Item yew_slab = new ItemWoodSlab(WoodMaterials.yew, BlockRegistry.yew_slab, BlockRegistry.double_yew_slab); + public static final Item ebony_slab = new ItemWoodSlab(WoodMaterials.ebony, BlockRegistry.ebony_slab, BlockRegistry.double_ebony_slab); + public static final Item fir_slab = new ItemWoodSlab(WoodMaterials.fir, BlockRegistry.fir_slab, BlockRegistry.double_fir_slab); + public static final Item ash = new Item().setRegistryName("ash"); + public static final Item bamboo_pole = new Item().setRegistryName("bamboo_pole"); + public static final Item bamboo_charcoal = new Item().setRegistryName("bamboo_charcoal"); + public static final Item dates = new ItemDates(); + public static final Item maple_sap = new Item().setRegistryName("maple_sap").setMaxStackSize(1); + public static final Item rubber_sap = new Item().setRegistryName("rubber_sap").setMaxStackSize(1); + static final Map registry = new HashMap<>(); + + private ItemRegistry() { + } + + public static List getItemList() { + List list = new ArrayList<>(); + list.add(apple_seed); + list.add(maple_seed); + list.add(pine_seed); + list.add(willow_seed); + list.add(yew_seed); + list.add(fir_seed); + list.add(ebony_seed); + list.add(dates); + list.add(bamboo_seed); + list.add(rubber_seed); + list.add(maple_sap); + list.add(rubber_sap); + + list.add(apple_door); + list.add(maple_door); + list.add(pine_door); + list.add(willow_door); + list.add(yew_door); + list.add(fir_door); + list.add(ebony_door); + list.add(bamboo_door); + list.add(palm_door); + + list.add(oak_seed); + list.add(birch_seed); + list.add(dark_oak_seed); + list.add(jungle_seed); + list.add(acacia_seed); + list.add(spruce_seed); + + list.add(apple_slab); + list.add(maple_slab); + list.add(pine_slab); + list.add(willow_slab); + list.add(yew_slab); + list.add(ebony_slab); + list.add(fir_slab); + + list.add(bamboo_charcoal); + list.add(bamboo_pole); + list.add(ash); + + return list; + } + + public static Item getItemByName(String name) { + return registry.get(name); + } } diff --git a/src/main/java/panda/gotwood/registry/MasterRegistrar.java b/src/main/java/panda/gotwood/registry/MasterRegistrar.java index 254ca7e..197ef14 100644 --- a/src/main/java/panda/gotwood/registry/MasterRegistrar.java +++ b/src/main/java/panda/gotwood/registry/MasterRegistrar.java @@ -1,8 +1,5 @@ package panda.gotwood.registry; -import java.util.Iterator; -import java.util.List; - import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; @@ -14,7 +11,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.oredict.OreDictionary; - import panda.gotwood.GotWood; import panda.gotwood.block.BlockDoubleSlab; import panda.gotwood.block.BlockSpecialFire; @@ -26,67 +22,76 @@ import panda.gotwood.util.IOreDictionaryEntry; import panda.gotwood.util.WoodMaterials; +import java.util.Iterator; +import java.util.List; + public final class MasterRegistrar { - private MasterRegistrar() {} - public static void register(FMLPreInitializationEvent e, List list) { - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - Object k = iterator.next(); - if (k instanceof Block) { - Block block = (Block) k; - ForgeRegistries.BLOCKS.register(block); - BlockRegistry.registry.put(block.getRegistryName().getResourcePath(), block); - if (!(k instanceof BlockSpecialFire) && !(k instanceof BlockWoodDoor)) { - ((Block) k).setCreativeTab(GotWood.TREE_TAB); - } - block.setUnlocalizedName(GotWood.ID + "." + block.getRegistryName().getResourcePath()); - if (!(k instanceof BlockDoubleSlab) && !ForgeRegistries.ITEMS.containsKey(block.getRegistryName())) { - ForgeRegistries.ITEMS.register(new ItemBlock(block).setRegistryName(block.getRegistryName())); - } - } else if (k instanceof Item) { - Item item = (Item) k; - ForgeRegistries.ITEMS.register((Item) k); - ItemRegistry.registry.put(item.getRegistryName().getResourcePath(), item); - ((Item) k).setCreativeTab(GotWood.TREE_TAB); - ((Item) k).setUnlocalizedName(GotWood.ID + "." + ((Item) k).getRegistryName().getResourcePath()); - } - } - if (e.getSide() == Side.CLIENT) { - registerModels(list); - } - } + private MasterRegistrar() { + } + + public static void register(FMLPreInitializationEvent e, List list) { + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + Object k = iterator.next(); + if (k instanceof Block) { + Block block = (Block) k; + ForgeRegistries.BLOCKS.register(block); + BlockRegistry.registry.put(block.getRegistryName().getPath(), block); + if (!(k instanceof BlockSpecialFire) && !(k instanceof BlockWoodDoor)) { + ((Block) k).setCreativeTab(GotWood.TREE_TAB); + } + + block.setTranslationKey(GotWood.MODID + "." + block.getRegistryName().getPath()); + if (!(k instanceof BlockDoubleSlab) && !ForgeRegistries.ITEMS.containsKey(block.getRegistryName())) { + ForgeRegistries.ITEMS.register(new ItemBlock(block).setRegistryName(block.getRegistryName())); + } + } else if (k instanceof Item) { + Item item = (Item) k; + ForgeRegistries.ITEMS.register((Item) k); + ItemRegistry.registry.put(item.getRegistryName().getPath(), item); + ((Item) k).setCreativeTab(GotWood.TREE_TAB); + ((Item) k).setTranslationKey(GotWood.MODID + "." + ((Item) k).getRegistryName().getPath()); + } + } + + if (e.getSide() == Side.CLIENT) { + registerModels(list); + } + } + + public static void registerModels(List list) { + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + Object k = iterator.next(); + Item item = null; + if (k instanceof Block) { + item = Item.getItemFromBlock((Block) k); + System.out.println(item.getRegistryName().getPath()); + } else if (k instanceof Item) { + item = (Item) k; + System.out.println(item.getRegistryName().getPath()); + } - public static void registerModels(List list) { - Iterator iterator = list.iterator(); - while (iterator.hasNext()) { - Object k = iterator.next(); - Item item = null; - if (k instanceof Block) { - item = Item.getItemFromBlock((Block) k); - System.out.println(item.getRegistryName().getResourcePath()); - } else if (k instanceof Item) { - item = (Item) k; - System.out.println(item.getRegistryName().getResourcePath()); - } - if (item != null) { - ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); - if (item instanceof IOreDictionaryEntry) { - OreDictionary.registerOre(((IOreDictionaryEntry) item).getOreDictionaryName(), item); // FIXME: will only happen on client side - } - } - } - } + if (item != null) { + ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); + if (item instanceof IOreDictionaryEntry) { + OreDictionary.registerOre(((IOreDictionaryEntry) item).getOreDictionaryName(), item); // FIXME: will only happen on client side + } + } + } + } - public static void callRegistry(FMLPreInitializationEvent e) { - ConfigurationHandler.init(e); - MinecraftForge.EVENT_BUS.register(new BlockBreakHandler()); - MinecraftForge.EVENT_BUS.register(new FireHandler()); - WoodMaterials.init(); - List blocks = BlockRegistry.getBlockList(); - register(e, ItemRegistry.getItemList()); - register(e, blocks); - RecipeRegistry.init(); - GameRegistry.registerFuelHandler(new FuelHandler()); - } + //TODO Move these out of here. + public static void callRegistry(FMLPreInitializationEvent e) { + ConfigurationHandler.init(e); + MinecraftForge.EVENT_BUS.register(new BlockBreakHandler()); + MinecraftForge.EVENT_BUS.register(new FireHandler()); + WoodMaterials.init(); + List blocks = BlockRegistry.getBlockList(); + register(e, ItemRegistry.getItemList()); + register(e, blocks); + RecipeRegistry.init(); + GameRegistry.registerFuelHandler(new FuelHandler()); + } } diff --git a/src/main/java/panda/gotwood/registry/RecipeRegistry.java b/src/main/java/panda/gotwood/registry/RecipeRegistry.java index a2c60f8..c1c7201 100644 --- a/src/main/java/panda/gotwood/registry/RecipeRegistry.java +++ b/src/main/java/panda/gotwood/registry/RecipeRegistry.java @@ -6,74 +6,79 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.OreDictionary; - import panda.gotwood.util.WoodMaterial; import panda.gotwood.util.WoodMaterials; +//TODO Eventually move all recipes to JSON files as crafttweaker no longer supports in code recipes in 1.14 and up (Plus they should really be done in JSON post 1.11) public final class RecipeRegistry { - private RecipeRegistry() {} - public static void init() { - for (WoodMaterial wood : WoodMaterials.getAllWoods()) { - if (wood == WoodMaterials.bamboo) { - String baseName = wood.getName() + "_"; - Item door = ItemRegistry.getItemByName(baseName + "door_item"); - Item pole = ItemRegistry.getItemByName(baseName + "pole"); - Block planks = BlockRegistry.getBlockByName(baseName + "planks"); - Block log = BlockRegistry.getBlockByName(baseName + "log"); - Block trapdoor = BlockRegistry.getBlockByName(baseName + "trapdoor"); - if ((log != null) && (planks != null)) { - OreDictionary.registerOre("plankWood", planks); - OreDictionary.registerOre("treeLeaves", BlockRegistry.getBlockByName(baseName + "leaves")); - } - if ((planks != null) && (door != null)) { - OreDictionary.registerOre("door", door); - } - if ((planks != null) && (trapdoor != null)) { - OreDictionary.registerOre("trapdoor", trapdoor); - } - } else { - String baseName = wood.getName() + "_"; - Item door = ItemRegistry.getItemByName(baseName + "door_item"); - Block planks = BlockRegistry.getBlockByName(baseName + "planks"); - Block log = BlockRegistry.getBlockByName(baseName + "log"); - Block trapdoor = BlockRegistry.getBlockByName(baseName + "trapdoor"); - //Item slab = ItemRegistry.getItemByName(baseName + "_slab"); - if ((log != null) && (planks != null)) { - GameRegistry.addSmelting(log, new ItemStack(Items.COAL, 1, 1), 0.2f); - OreDictionary.registerOre("plankWood", planks); - OreDictionary.registerOre("treeLeaves", BlockRegistry.getBlockByName(baseName + "leaves")); - } - if ((planks != null) && (door != null)) { - OreDictionary.registerOre("door", door); - } - if ((planks != null) && (trapdoor != null)) { - OreDictionary.registerOre("trapdoor", trapdoor); - } - } - } - //GameRegistry.addSmelting(new ItemStack(Items.COAL, 1, 1), new ItemStack(ItemRegistry.ash), 0.1f); - GameRegistry.addSmelting(new ItemStack(ItemRegistry.bamboo_pole), new ItemStack(ItemRegistry.bamboo_charcoal), 0.1f); + private RecipeRegistry() { + } + + public static void init() { + for (WoodMaterial wood : WoodMaterials.getAllWoods()) { + if (wood == WoodMaterials.bamboo) { + String baseName = wood.getName() + "_"; + Item door = ItemRegistry.getItemByName(baseName + "door_item"); + Item pole = ItemRegistry.getItemByName(baseName + "pole"); + Block planks = BlockRegistry.getBlockByName(baseName + "planks"); + Block log = BlockRegistry.getBlockByName(baseName + "log"); + Block trapdoor = BlockRegistry.getBlockByName(baseName + "trapdoor"); + if ((log != null) && (planks != null)) { + OreDictionary.registerOre("plankWood", planks); + OreDictionary.registerOre("treeLeaves", BlockRegistry.getBlockByName(baseName + "leaves")); + } + + if ((planks != null) && (door != null)) { + OreDictionary.registerOre("door", door); + } + + if ((planks != null) && (trapdoor != null)) { + OreDictionary.registerOre("trapdoor", trapdoor); + } + } else { + String baseName = wood.getName() + "_"; + Item door = ItemRegistry.getItemByName(baseName + "door_item"); + Block planks = BlockRegistry.getBlockByName(baseName + "planks"); + Block log = BlockRegistry.getBlockByName(baseName + "log"); + Block trapdoor = BlockRegistry.getBlockByName(baseName + "trapdoor"); + //Item slab = ItemRegistry.getItemByName(baseName + "_slab"); + if ((log != null) && (planks != null)) { + GameRegistry.addSmelting(log, new ItemStack(Items.COAL, 1, 1), 0.2f); + OreDictionary.registerOre("plankWood", planks); + OreDictionary.registerOre("treeLeaves", BlockRegistry.getBlockByName(baseName + "leaves")); + } + + if ((planks != null) && (door != null)) { + OreDictionary.registerOre("door", door); + } - } + if ((planks != null) && (trapdoor != null)) { + OreDictionary.registerOre("trapdoor", trapdoor); + } + } + } + //GameRegistry.addSmelting(new ItemStack(Items.COAL, 1, 1), new ItemStack(ItemRegistry.ash), 0.1f); + GameRegistry.addSmelting(new ItemStack(ItemRegistry.bamboo_pole), new ItemStack(ItemRegistry.bamboo_charcoal), 0.1f); + } - public static void addOredicts(String[] oreDictEntries, Block name) { - addOredicts(oreDictEntries, new ItemStack(name)); - // for(int i = 0; i < oreDictEntries.length; i++) - // OreDictionary.registerOre(oreDictEntries[i], name); - } + public static void addOredicts(String[] oreDictEntries, Block name) { + addOredicts(oreDictEntries, new ItemStack(name)); + // for(int i = 0; i < oreDictEntries.length; i++) + // OreDictionary.registerOre(oreDictEntries[i], name); + } - public static void addOredicts(String[] oreDictEntries, Item name) { - addOredicts(oreDictEntries, new ItemStack(name)); - // for(int i = 0; i < oreDictEntries.length; i++) - // OreDictionary.registerOre(oreDictEntries[i], name); - } + public static void addOredicts(String[] oreDictEntries, Item name) { + addOredicts(oreDictEntries, new ItemStack(name)); + // for(int i = 0; i < oreDictEntries.length; i++) + // OreDictionary.registerOre(oreDictEntries[i], name); + } - public static void addOredicts(String[] oreDictEntries, ItemStack itemStackName) { - // for(int i = 0; i < oreDictEntries.length; i++) - // OreDictionary.registerOre(oreDictEntries[i], itemStackName); - for (final String oreDictEntry : oreDictEntries) { - OreDictionary.registerOre(oreDictEntry, itemStackName); - } - } + public static void addOredicts(String[] oreDictEntries, ItemStack itemStackName) { + // for(int i = 0; i < oreDictEntries.length; i++) + // OreDictionary.registerOre(oreDictEntries[i], itemStackName); + for (final String oreDictEntry : oreDictEntries) { + OreDictionary.registerOre(oreDictEntry, itemStackName); + } + } } diff --git a/src/main/java/panda/gotwood/util/FuelHandler.java b/src/main/java/panda/gotwood/util/FuelHandler.java index 80f5db5..c65820d 100644 --- a/src/main/java/panda/gotwood/util/FuelHandler.java +++ b/src/main/java/panda/gotwood/util/FuelHandler.java @@ -2,14 +2,12 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.IFuelHandler; - import panda.gotwood.registry.ItemRegistry; public class FuelHandler implements IFuelHandler { - @Override - public int getBurnTime(ItemStack fuel) { - return fuel.getItem() == ItemRegistry.bamboo_charcoal ? 800 : 0; - } - + @Override + public int getBurnTime(ItemStack fuel) { + return fuel.getItem() == ItemRegistry.bamboo_charcoal ? 800 : 0; + } } diff --git a/src/main/java/panda/gotwood/util/IFireDrops.java b/src/main/java/panda/gotwood/util/IFireDrops.java index c121819..f0c7869 100644 --- a/src/main/java/panda/gotwood/util/IFireDrops.java +++ b/src/main/java/panda/gotwood/util/IFireDrops.java @@ -1,14 +1,13 @@ package panda.gotwood.util; +import net.minecraft.item.ItemStack; + import java.util.List; import java.util.Random; -import net.minecraft.item.ItemStack; - public interface IFireDrops { - boolean hasFireDrops(); - - List addFireDrops(List stacks, Random random); + boolean hasFireDrops(); + List addFireDrops(List stacks, Random random); } diff --git a/src/main/java/panda/gotwood/util/IOreDictionaryEntry.java b/src/main/java/panda/gotwood/util/IOreDictionaryEntry.java index 1c8eb61..8f2203b 100644 --- a/src/main/java/panda/gotwood/util/IOreDictionaryEntry.java +++ b/src/main/java/panda/gotwood/util/IOreDictionaryEntry.java @@ -1,5 +1,5 @@ package panda.gotwood.util; public interface IOreDictionaryEntry { - String getOreDictionaryName(); + String getOreDictionaryName(); } diff --git a/src/main/java/panda/gotwood/util/TapRegistry.java b/src/main/java/panda/gotwood/util/TapRegistry.java index c94a257..7bf7019 100644 --- a/src/main/java/panda/gotwood/util/TapRegistry.java +++ b/src/main/java/panda/gotwood/util/TapRegistry.java @@ -6,10 +6,9 @@ public class TapRegistry { - public static FluidStack find(Block block) { - // TODO - //Just return water for now - return new FluidStack(FluidRegistry.WATER, 0); - } - + public static FluidStack find(Block block) { + //TODO Find out what this was for/meant to do. + //Just return water for now + return new FluidStack(FluidRegistry.WATER, 0); + } } diff --git a/src/main/java/panda/gotwood/util/TreeTapRenderer.java b/src/main/java/panda/gotwood/util/TreeTapRenderer.java index 86eb56a..4bc2946 100644 --- a/src/main/java/panda/gotwood/util/TreeTapRenderer.java +++ b/src/main/java/panda/gotwood/util/TreeTapRenderer.java @@ -1,95 +1,87 @@ package panda.gotwood.util; -import javax.annotation.Nonnull; - -import org.lwjgl.opengl.GL11; - -import panda.gotwood.block.entity.TileEntityTreeTap; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.util.EnumFacing; +import org.lwjgl.opengl.GL11; +import panda.gotwood.block.entity.TileEntityTreeTap; public class TreeTapRenderer extends TileEntitySpecialRenderer { -//FROM TIC - @Override - public void renderTileEntityAt(@Nonnull TileEntityTreeTap te, double x, double y, double z, float partialTicks, int destroyStage) { - - if(te.sapInBucket == null || !te.hasBucket) { - return; - } - - // check how far into the 2nd block we want to render - float yMin = 0; - IBlockState state = te.getWorld().getBlockState(te.getPos().down()); - Block block = state.getBlock(); - - - yMin = -0.0001f; - - if(te.direction.getHorizontalIndex() >= 0) { - float r = -90f * (2 + te.direction.getHorizontalIndex()); - float o = 0.5f; - // custom rendering for flowing on top - RenderUtil.pre(x, y, z); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder renderer = tessellator.getBuffer(); - renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - int color = te.sapInBucket.getFluid().getColor(te.sapInBucket); - int brightness = te.getWorld().getCombinedLight(te.getPos(), te.sapInBucket.getFluid().getLuminosity()); - TextureAtlasSprite flowing = Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry(te.sapInBucket.getFluid().getFlowing(te.sapInBucket).toString()); + //FROM TIC + //@Override + public void renderTileEntityAt(TileEntityTreeTap te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) { + if (te.sapInBucket == null || !te.hasBucket) { + return; + } - GlStateManager.translate(o, 0, o); - GlStateManager.rotate(r, 0, 1, 0); - GlStateManager.translate(-o, 0, -o); + // check how far into the 2nd block we want to render + float yMin = 0; + IBlockState state = te.getWorld().getBlockState(te.getPos().down()); + Block block = state.getBlock(); + yMin = -0.0001f; + if (te.direction.getHorizontalIndex() >= 0) { + float r = -90f * (2 + te.direction.getHorizontalIndex()); + float o = 0.5f; + // custom rendering for flowing on top + //RenderUtil.pre(x, y, z); - double x1 = 0.375; - double x2 = 0.625; - double y1 = 0.375; - double y2 = 0.625; - double z1 = 0; - double z2 = 0.375; + Tessellator tessellator = Tessellator.getInstance(); + BufferBuilder renderer = tessellator.getBuffer(); + renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + int color = te.sapInBucket.getFluid().getColor(te.sapInBucket); + int brightness = te.getWorld().getCombinedLight(te.getPos(), te.sapInBucket.getFluid().getLuminosity()); + TextureAtlasSprite flowing = Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry(te.sapInBucket.getFluid().getFlowing(te.sapInBucket).toString()); - // the stuff in the faucet - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.DOWN, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.NORTH, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.EAST, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.WEST, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.UP, color, brightness, true); + GlStateManager.translate(o, 0, o); + GlStateManager.rotate(r, 0, 1, 0); + GlStateManager.translate(-o, 0, -o); + double x1 = 0.375; + double x2 = 0.625; + double y1 = 0.375; + double y2 = 0.625; + double z1 = 0; + double z2 = 0.375; - // the stuff flowing down - y1 = 0; - z1 = 0.375; - z2 = 0.5; - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.DOWN, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.NORTH, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.EAST, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.SOUTH, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.WEST, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.UP, color, brightness, true); + //TODO This stuff was missing from the repo... Where is it and what is it!? + // the stuff in the faucet + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.DOWN, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.NORTH, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.EAST, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.WEST, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.UP, color, brightness, true); - // render in the block beneath - if(yMin < 0) { - y1 = yMin; - y2 = 0; - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.DOWN, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.NORTH, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.EAST, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.SOUTH, color, brightness, true); - RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2-x1, y2-y1, z2-z1, EnumFacing.WEST, color, brightness, true); - } + // the stuff flowing down + y1 = 0; + z1 = 0.375; + z2 = 0.5; + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.DOWN, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.NORTH, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.EAST, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.SOUTH, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.WEST, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.UP, color, brightness, true); - tessellator.draw(); - RenderUtil.post(); - } - } - } + // render in the block beneath + if (yMin < 0) { + y1 = yMin; + y2 = 0; + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.DOWN, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.NORTH, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.EAST, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.SOUTH, color, brightness, true); + //RenderUtil.putTexturedQuad(renderer, flowing, x1, y1, z1, x2 - x1, y2 - y1, z2 - z1, EnumFacing.WEST, color, brightness, true); + } + tessellator.draw(); + //RenderUtil.post(); + } + } +} diff --git a/src/main/java/panda/gotwood/util/WoodMaterial.java b/src/main/java/panda/gotwood/util/WoodMaterial.java index c80e7d0..0f1a349 100644 --- a/src/main/java/panda/gotwood/util/WoodMaterial.java +++ b/src/main/java/panda/gotwood/util/WoodMaterial.java @@ -1,112 +1,103 @@ package panda.gotwood.util; -import java.util.Locale; - import net.minecraft.util.math.MathHelper; - import org.apache.commons.lang3.StringUtils; import panda.gotwood.GotWood; +import java.util.Locale; + public final class WoodMaterial { - private final float hardness; - - private final float strength; - - private final String identifier; - - private final String titleName; - - private final String enumName; - - private float blastResistance; - - public int meta; - - /** - * @param name - * String used to identify items and blocks using this material - * @param hardness - * hardness on a scale from 0 to 10 (or more), where 0 is - * non-solid and diamond is 10. For reference, wood is 3, stone - * is 5, iron is 8, diamond is 10. Used for damage, armor - * protection, and tool effectiveness calculations - * @param strength - * durability on a scale from 0 to 10 (or more). For reference, - * leather is 2.5, gold is 3, wood is 2, stone is 4, iron is 8, - * minecraft diamond is 10. Used for item durability calculations - * and blast resistance - */ - public WoodMaterial(String name, float hardness, float strength) { - this(name, hardness, strength, -1); - } - - public WoodMaterial(String name, float hardness, float strength, int meta) { - this.hardness = hardness; - this.strength = strength; - this.identifier = name; - this.titleName = StringUtils.capitalize(name); - this.enumName = (GotWood.ID + "_" + name).toUpperCase(Locale.ENGLISH); - this.blastResistance = 2.5f * this.strength; - this.meta = meta; - } - - public String getName() { - return this.identifier; - } - - public String getCapitalizedName() { - return this.titleName; - } - - @Override - public String toString() { - return this.getName(); - } - - @Override - public int hashCode() { - return this.identifier.hashCode(); - } - - @Override - public boolean equals(Object o) { - return o == this || o instanceof WoodMaterial && this.identifier.equals(((WoodMaterial) o).identifier); - } - - public int getMeta() { - return this.meta; - } - - public int getToolHarvestLevel() { - return (int) (this.hardness / 3f); - } - - public int getRequiredHarvestLevel() { - return (int) MathHelper.clamp(((0.9f * this.hardness) / 3f), -1, 3); - } - - public float getBlastResistance() { - return this.blastResistance; - } - - public float getToolEfficiency() { - return this.hardness; - } - - public float getLogBlockHardness() { - return 2.0f * this.hardness; - } - - public float getPlankBlockHardness() { - return 0.5f * this.hardness; - } - - public String getEnumName() { - return this.enumName; - } - - public WoodMaterial setBlastResistance(float resistance) { - this.blastResistance = resistance; - return this; - } + + private final float hardness; + private final float strength; + private final String identifier; + private final String titleName; + private final String enumName; + public int meta; + private float blastResistance; + + /** + * @param name String used to identify items and blocks using this material + * @param hardness hardness on a scale from 0 to 10 (or more), where 0 is + * non-solid and diamond is 10. For reference, wood is 3, stone + * is 5, iron is 8, diamond is 10. Used for damage, armor + * protection, and tool effectiveness calculations + * @param strength durability on a scale from 0 to 10 (or more). For reference, + * leather is 2.5, gold is 3, wood is 2, stone is 4, iron is 8, + * minecraft diamond is 10. Used for item durability calculations + * and blast resistance + */ + public WoodMaterial(String name, float hardness, float strength) { + this(name, hardness, strength, -1); + } + + public WoodMaterial(String name, float hardness, float strength, int meta) { + this.hardness = hardness; + this.strength = strength; + this.identifier = name; + this.titleName = StringUtils.capitalize(name); + this.enumName = (GotWood.MODID + "_" + name).toUpperCase(Locale.ENGLISH); + this.blastResistance = 2.5f * this.strength; + this.meta = meta; + } + + public String getName() { + return this.identifier; + } + + public String getCapitalizedName() { + return this.titleName; + } + + @Override + public String toString() { + return this.getName(); + } + + @Override + public int hashCode() { + return this.identifier.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o == this || o instanceof WoodMaterial && this.identifier.equals(((WoodMaterial) o).identifier); + } + + public int getMeta() { + return this.meta; + } + + public int getToolHarvestLevel() { + return (int) (this.hardness / 3f); + } + + public int getRequiredHarvestLevel() { + return (int) MathHelper.clamp(((0.9f * this.hardness) / 3f), -1, 3); + } + + public float getBlastResistance() { + return this.blastResistance; + } + + public WoodMaterial setBlastResistance(float resistance) { + this.blastResistance = resistance; + return this; + } + + public float getToolEfficiency() { + return this.hardness; + } + + public float getLogBlockHardness() { + return 2.0f * this.hardness; + } + + public float getPlankBlockHardness() { + return 0.5f * this.hardness; + } + + public String getEnumName() { + return this.enumName; + } } diff --git a/src/main/java/panda/gotwood/util/WoodMaterials.java b/src/main/java/panda/gotwood/util/WoodMaterials.java index 0f80c65..fc1939a 100644 --- a/src/main/java/panda/gotwood/util/WoodMaterials.java +++ b/src/main/java/panda/gotwood/util/WoodMaterials.java @@ -1,107 +1,77 @@ package panda.gotwood.util; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; public abstract class WoodMaterials { - private static Map allMaterials = new HashMap<>(); - - protected static List materials = new LinkedList<>(); - - public static WoodMaterial apple; - - public static WoodMaterial maple; - - public static WoodMaterial pine; - - public static WoodMaterial willow; - - public static WoodMaterial yew; - - public static WoodMaterial ebony; - - public static WoodMaterial fir; - - public static WoodMaterial bamboo; - - public static WoodMaterial rubber; - - public static WoodMaterial palm; - - //Vanilla woods - public static WoodMaterial oak; - - public static WoodMaterial spruce; - - public static WoodMaterial darkOak; - - public static WoodMaterial jungle; - - public static WoodMaterial acacia; - - public static WoodMaterial birch; - - private static boolean initDone = false; - - /** - * - */ - public static void init() { - if (initDone) - return; - - apple = addMaterial("apple", 3, 2); - maple = addMaterial("maple", 3, 2); - pine = addMaterial("pine", 3, 2); - willow = addMaterial("willow", 3, 2); - yew = addMaterial("yew", 3, 2); - ebony = addMaterial("ebony", 3, 2); - fir = addMaterial("fir", 3, 2); - - bamboo = addMaterial("bamboo", 3, 2); - rubber = addMaterial("rubber", 3, 2); - palm = addMaterial("palm", 3, 2); - - oak = addMaterial("oak", 3, 2, 0); - spruce = addMaterial("spruce", 3, 2, 1); - birch = addMaterial("birch", 3, 2, 2); - jungle = addMaterial("jungle", 3, 2, 3); - acacia = addMaterial("acacia", 3, 2, 4); - darkOak = addMaterial("dark_oak", 3, 2, 5); - - initDone = true; - } - - protected static WoodMaterial addMaterial(String name, double hardness, double strength, int meta) { - final WoodMaterial m = new WoodMaterial(name, (float) hardness, (float) strength, meta); - registerMaterial(name, m); - - materials.add(m); - return m; - } - - protected static WoodMaterial addMaterial(String name, double hardness, double strength) { - final WoodMaterial m = new WoodMaterial(name, (float) hardness, (float) strength, 0); - registerMaterial(name, m); - - materials.add(m); - return m; - } - - protected static void registerMaterial(String name, WoodMaterial m) { - - allMaterials.put(name, m); - } - - public static Collection getAllWoods() { - return allMaterials.values(); - } - - public static WoodMaterial getWoodByName(String woodName) { - return allMaterials.get(woodName); - } + public static WoodMaterial apple; + public static WoodMaterial maple; + public static WoodMaterial pine; + public static WoodMaterial willow; + public static WoodMaterial yew; + public static WoodMaterial ebony; + public static WoodMaterial fir; + public static WoodMaterial bamboo; + public static WoodMaterial rubber; + public static WoodMaterial palm; + //Vanilla woods + public static WoodMaterial oak; + public static WoodMaterial spruce; + public static WoodMaterial darkOak; + public static WoodMaterial jungle; + public static WoodMaterial acacia; + public static WoodMaterial birch; + protected static List materials = new LinkedList<>(); + private static Map allMaterials = new HashMap<>(); + private static boolean initDone = false; + + public static void init() { + if (initDone) { + return; + } + + apple = addMaterial("apple", 3, 2); + maple = addMaterial("maple", 3, 2); + pine = addMaterial("pine", 3, 2); + willow = addMaterial("willow", 3, 2); + yew = addMaterial("yew", 3, 2); + ebony = addMaterial("ebony", 3, 2); + fir = addMaterial("fir", 3, 2); + bamboo = addMaterial("bamboo", 3, 2); + rubber = addMaterial("rubber", 3, 2); + palm = addMaterial("palm", 3, 2); + oak = addMaterial("oak", 3, 2, 0); + spruce = addMaterial("spruce", 3, 2, 1); + birch = addMaterial("birch", 3, 2, 2); + jungle = addMaterial("jungle", 3, 2, 3); + acacia = addMaterial("acacia", 3, 2, 4); + darkOak = addMaterial("dark_oak", 3, 2, 5); + initDone = true; + } + + protected static WoodMaterial addMaterial(String name, double hardness, double strength, int meta) { + final WoodMaterial m = new WoodMaterial(name, (float) hardness, (float) strength, meta); + registerMaterial(name, m); + materials.add(m); + return m; + } + + protected static WoodMaterial addMaterial(String name, double hardness, double strength) { + final WoodMaterial m = new WoodMaterial(name, (float) hardness, (float) strength, 0); + registerMaterial(name, m); + materials.add(m); + return m; + } + + protected static void registerMaterial(String name, WoodMaterial m) { + allMaterials.put(name, m); + } + + public static Collection getAllWoods() { + return allMaterials.values(); + } + + public static WoodMaterial getWoodByName(String woodName) { + return allMaterials.get(woodName); + } } diff --git a/src/main/resources/assets/gotwood/lang/en_US.lang b/src/main/resources/assets/gotwood/lang/en_us.lang similarity index 98% rename from src/main/resources/assets/gotwood/lang/en_US.lang rename to src/main/resources/assets/gotwood/lang/en_us.lang index a9f5dfd..5c87506 100644 --- a/src/main/resources/assets/gotwood/lang/en_US.lang +++ b/src/main/resources/assets/gotwood/lang/en_us.lang @@ -1,4 +1,3 @@ -@@ -0,0 +1,7 @@ tile.gotwood.apple_slab.name=Apple Wood Slab tile.gotwood.apple_log.name=Apple Wood tile.gotwood.apple_planks.name=Apple Wood Planks @@ -114,6 +113,4 @@ item.gotwood.dates.name=Dates item.gotwood.bamboo_charcoal.name=Bamboo Charcoal item.gotwood.bamboo_pole.name=Bamboo Pole tile.gotwood.bamboo_slab.name=Bamboo Wood Slab -tile.gotwood.palm_slab.name=Palm Wood Slab - -\ No newline at end of file \ No newline at end of file +tile.gotwood.palm_slab.name=Palm Wood Slab \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index f480667..d261a9f 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,14 +1,14 @@ [ { - "modid": "examplemod", - "name": "Example Mod", - "description": "Example placeholder mod.", + "modid": "gotwood", + "name": "Got Wood?", + "description": "", "version": "${version}", "mcversion": "${mcversion}", "url": "", "updateUrl": "", - "authorList": ["ExampleDude"], - "credits": "The Forge and FML guys, for making this example", + "authorList": ["CleverPanda"], + "credits": "CleverPanda", "logoFile": "", "screenshots": [], "dependencies": []