diff --git a/build.gradle b/build.gradle index 64f86c8..0024151 100644 --- a/build.gradle +++ b/build.gradle @@ -36,6 +36,10 @@ repositories { name = "tterrag" url = "http://maven.tterrag.com" } + maven { + name = "tterrag2" + url = "http://maven2.tterrag.com" + } maven { name = "tehnut" url = "http://tehnut.info/maven" @@ -48,23 +52,35 @@ repositories { name = "CoFH" url = "http://maven.covers1624.net" } + maven { + name = "Curse" + url = "https://minecraft.curseforge.com/api/maven/" + } } dependencies { deobfCompile "mezz.jei:jei_1.12.2:+" deobfCompile "mcp.mobius.waila:Hwyla:1.8.26-B41_1.12.2" deobfCompile "mcjty.theoneprobe:TheOneProbe-1.12:1.12+" - deobfCompile "codechicken:CodeChickenLib:1.12.2-3.2.1.353:universal" + deobfCompile "codechicken:CodeChickenLib:1.12.2-3.2.2.354:universal" deobfCompile "codechicken:EnderStorage:1.12.2-2.4.5.135:universal" deobfCompile "cpw.mods:ironchest:1.12.2-7.0.34.820" - deobfCompile "cofh:RedstoneFlux:1.12-2.0.2.4:universal" + deobfCompile "cofh:RedstoneFlux:1.12-2.1.0.6:universal" deobfCompile "cofh:ThermalDynamics:1.12.2-2+:universal" deobfCompile "cofh:ThermalFoundation:1.12.2-2+:universal" deobfCompile "cofh:ThermalExpansion:1.12.2-5+:universal" deobfCompile "cofh:CoFHCore:1.12.2-4+:universal" deobfCompile "cofh:CoFHWorld:1.12.2-1+:universal" - deobfCompile "slimeknights:TConstruct:1.12.2-2.9.1.70" + deobfCompile "slimeknights:TConstruct:1.12.2-2.10.1.518" deobfCompile "slimeknights.mantle:Mantle:1.12-1.3.2.38" + deobfCompile "immersive-engineering:ImmersiveEngineering:0.12:89" + deobfCompile "p455w0rd:p455w0rdslib:1.12.2-2.0.36" + deobfCompile "info.loenwind.autoconfig:AutoConfig:1.12.2-1.0.1" + deobfCompile "info.loenwind.autosave:AutoSave:1.12.2-1.0.8" + deobfCompile "com.enderio.core:EnderCore:1.12.2-0.5.44" + deobfCompile ("com.enderio:EnderIO:1.12.2-5.0.39") { + transitive = false + } } processResources { diff --git a/src/main/java/p455w0rd/endermanevo/EndermanEvolution.java b/src/main/java/p455w0rd/endermanevo/EndermanEvolution.java index 94e80b5..f3e4d1c 100644 --- a/src/main/java/p455w0rd/endermanevo/EndermanEvolution.java +++ b/src/main/java/p455w0rd/endermanevo/EndermanEvolution.java @@ -1,9 +1,10 @@ package p455w0rd.endermanevo; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.Mod.Instance; 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.event.*; import p455w0rd.endermanevo.init.ModGlobals; import p455w0rd.endermanevo.proxy.CommonProxy; @@ -13,18 +14,23 @@ public class EndermanEvolution { @SidedProxy(clientSide = ModGlobals.CLIENT_PROXY, serverSide = ModGlobals.SERVER_PROXY) public static CommonProxy PROXY; - @Mod.Instance("endermanevo") + @Instance("endermanevo") public static EndermanEvolution INSTANCE; - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent e) { + @EventHandler + public void preInit(final FMLPreInitializationEvent e) { INSTANCE = this; PROXY.preInit(e); } - @Mod.EventHandler - public void init(FMLInitializationEvent e) { + @EventHandler + public void init(final FMLInitializationEvent e) { PROXY.init(e); } + @EventHandler + public void postInit(final FMLPostInitializationEvent e) { + PROXY.postInit(e); + } + } diff --git a/src/main/java/p455w0rd/endermanevo/blocks/BlockEnderFlower.java b/src/main/java/p455w0rd/endermanevo/blocks/BlockEnderFlower.java index db1d1ce..ffc6bf0 100644 --- a/src/main/java/p455w0rd/endermanevo/blocks/BlockEnderFlower.java +++ b/src/main/java/p455w0rd/endermanevo/blocks/BlockEnderFlower.java @@ -42,6 +42,8 @@ public class BlockEnderFlower extends Block implements IGrowable, IPlantable { }; public static final List VALID_SOILS = Lists.newArrayList(Blocks.NETHERRACK, Blocks.DIRT, Blocks.GRASS, Blocks.FARMLAND); public static final List VALID_BONEMEAL_SOILS = Lists.newArrayList(Blocks.END_STONE, Blocks.END_BRICKS, Blocks.END_PORTAL_FRAME); + public static final List VALID_SOILS_STACKS = Lists.newArrayList(new ItemStack(Blocks.NETHERRACK), new ItemStack(Blocks.DIRT), new ItemStack(Blocks.GRASS), new ItemStack(Blocks.FARMLAND), new ItemStack(Blocks.END_STONE), new ItemStack(Blocks.END_BRICKS), new ItemStack(Blocks.END_PORTAL_FRAME)); + private static IBlockState[] stateList = null; public BlockEnderFlower() { super(Material.LEAVES, Material.LEAVES.getMaterialMapColor()); @@ -55,8 +57,18 @@ public BlockEnderFlower() { disableStats(); } + public static IBlockState[] getGrowthStates() { + if (stateList == null) { + stateList = new IBlockState[8]; + for (int i = 0; i < 8; i++) { + stateList[i] = ModBlocks.ENDER_FLOWER.getDefaultState().withProperty(STAGE, Integer.valueOf(i)); + } + } + return stateList; + } + @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final BlockPos pos, final IBlockState state, final EntityPlayer player, final EnumHand hand, final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { if (!world.isRemote) { if (getAge(state) == getMaxAge() && hand == EnumHand.MAIN_HAND) { /* @@ -82,12 +94,12 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En } @Override - public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) { + public void dropBlockAsItemWithChance(final World worldIn, final BlockPos pos, final IBlockState state, float chance, final int fortune) { if (!worldIn.isRemote && !worldIn.restoringBlockSnapshots) { - NonNullList drops = NonNullList.create(); + final NonNullList drops = NonNullList.create(); getDrops(drops, worldIn, pos, state, fortune); chance = ForgeEventFactory.fireBlockHarvesting(Lists.newArrayList(), worldIn, pos, state, fortune, chance, false, harvesters.get()); - for (ItemStack drop : drops) { + for (final ItemStack drop : drops) { if (worldIn.rand.nextFloat() <= chance) { spawnAsEntity(worldIn, pos, drop); } @@ -96,9 +108,9 @@ public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState s } @Override - public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - int age = getAge(state); - Random rand = world instanceof World ? ((World) world).rand : ModGlobals.RNG; + public void getDrops(final NonNullList drops, final IBlockAccess world, final BlockPos pos, final IBlockState state, int fortune) { + final int age = getAge(state); + final Random rand = world instanceof World ? ((World) world).rand : ModGlobals.RNG; drops.clear(); if (fortune > -1) { drops.add(new ItemStack(getItemBlock(), 1)); @@ -112,7 +124,7 @@ public void getDrops(NonNullList drops, IBlockAccess world, BlockPos } @Override - public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) { + public boolean canSustainPlant(final IBlockState state, final IBlockAccess world, final BlockPos pos, final EnumFacing direction, final net.minecraftforge.common.IPlantable plantable) { return false; } @@ -124,48 +136,48 @@ private int getMaxAge() { return 7; } - private int getAge(IBlockState state) { + private int getAge(final IBlockState state) { return state.getValue(getAgeProperty()).intValue(); } - private IBlockState withAge(int age) { + private IBlockState withAge(final int age) { return getDefaultState().withProperty(getAgeProperty(), Integer.valueOf(age)); } - private boolean isMaxAge(IBlockState state) { + private boolean isMaxAge(final IBlockState state) { return state.getValue(getAgeProperty()).intValue() >= getMaxAge(); } - public static boolean isValidSoil(Block block) { + public static boolean isValidSoil(final Block block) { return BlockEnderFlower.VALID_SOILS.contains(block) || BlockEnderFlower.VALID_BONEMEAL_SOILS.contains(block); } @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + public AxisAlignedBB getBoundingBox(final IBlockState state, final IBlockAccess source, final BlockPos pos) { return FLOWER_AABB[state.getValue(getAgeProperty()).intValue()]; } @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { + public AxisAlignedBB getCollisionBoundingBox(final IBlockState blockState, final IBlockAccess worldIn, final BlockPos pos) { return NULL_AABB; } - private boolean canSustainBush(IBlockState state) { + private boolean canSustainBush(final IBlockState state) { return isValidSoil(state.getBlock()); } - private int getBonemealAgeIncrease(World world) { + private int getBonemealAgeIncrease(final World world) { return world.rand.nextInt(8);//MathHelper.getInt(worldIn.rand, 2, 5); } @Override - public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { + public void updateTick(final World world, final BlockPos pos, final IBlockState state, final Random rand) { checkAndDropBlock(world, pos, state); - float f = getGrowChance(this, world, pos); + final float f = getGrowChance(this, world, pos); if (f == 1.0f) { - boolean bonusSoil = VALID_BONEMEAL_SOILS.contains(world.getBlockState(pos.down()).getBlock()); + final boolean bonusSoil = VALID_BONEMEAL_SOILS.contains(world.getBlockState(pos.down()).getBlock()); if (bonusSoil || world.getLightFromNeighbors(pos.up()) <= 8) { - int i = getAge(state); + final int i = getAge(state); if (i < getMaxAge()) { int newAge = bonusSoil ? i + 2 : i + 1; if (newAge > getMaxAge()) { @@ -180,21 +192,21 @@ public void updateTick(World world, BlockPos pos, IBlockState state, Random rand @SideOnly(Side.CLIENT) @Override - public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { + public void randomDisplayTick(final IBlockState state, final World world, final BlockPos pos, final Random rand) { if (getAge(state) >= getMaxAge()) { for (int i = 0; i < 2; ++i) { - double x = (pos.getX() + 0.5D) + (rand.nextDouble() - 0.5D) * 0.34D; - double y = (pos.getY() + 0.5D) + rand.nextDouble() * 0.55D - 0.25D; - double z = (pos.getZ() + 0.5D) + (rand.nextDouble() - 0.5D) * 0.34D; - double sx = (rand.nextDouble() - 0.5D) * 2.0D; - double sy = -rand.nextDouble(); - double sz = (rand.nextDouble() - 0.5D) * 2.0D; + final double x = pos.getX() + 0.5D + (rand.nextDouble() - 0.5D) * 0.34D; + final double y = pos.getY() + 0.5D + rand.nextDouble() * 0.55D - 0.25D; + final double z = pos.getZ() + 0.5D + (rand.nextDouble() - 0.5D) * 0.34D; + final double sx = (rand.nextDouble() - 0.5D) * 2.0D; + final double sy = -rand.nextDouble(); + final double sz = (rand.nextDouble() - 0.5D) * 2.0D; ParticleUtil.spawn(EnumParticles.PORTAL_GREEN, world, x, y, z, sx, sy, sz); } } } - protected static float getGrowChance(Block block, World world, BlockPos pos) { + protected static float getGrowChance(final Block block, final World world, final BlockPos pos) { float chance = world.rand.nextFloat() + 0.1f; if (VALID_BONEMEAL_SOILS.contains(world.getBlockState(pos.down()).getBlock())) { chance += 0.5f; @@ -208,23 +220,23 @@ protected static float getGrowChance(Block block, World world, BlockPos pos) { @Deprecated @Override - public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { + public void neighborChanged(final IBlockState state, final World worldIn, final BlockPos pos, final Block blockIn, final BlockPos fromPos) { super.neighborChanged(state, worldIn, pos, blockIn, fromPos); checkAndDropBlock(worldIn, pos, state); } - private void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state) { + private void checkAndDropBlock(final World worldIn, final BlockPos pos, final IBlockState state) { if (!canBlockStay(worldIn, pos, state)) { dropBlockAsItem(worldIn, pos, state, 0); worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 3); } } - private boolean canBlockStay(World world, BlockPos pos, IBlockState state) { + private boolean canBlockStay(final World world, final BlockPos pos, final IBlockState state) { if (state.getBlock() == this) { - IBlockState soil = world.getBlockState(pos.down()); + final IBlockState soil = world.getBlockState(pos.down()); boolean isNextToWater = false; - for (EnumFacing offset : EnumFacing.HORIZONTALS) { + for (final EnumFacing offset : EnumFacing.HORIZONTALS) { if (world.getBlockState(pos.offset(offset)).getMaterial() == Material.WATER) { isNextToWater = true; break; @@ -240,50 +252,50 @@ private Item getItemBlock() { } @Override - public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) { + public ItemStack getItem(final World worldIn, final BlockPos pos, final IBlockState state) { return new ItemStack(getItemBlock()); } @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) { + public Item getItemDropped(final IBlockState state, final Random rand, final int fortune) { return getItemBlock(); } @Override - public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { - IBlockState soil = worldIn.getBlockState(pos.down()); + public boolean canPlaceBlockAt(final World worldIn, final BlockPos pos) { + final IBlockState soil = worldIn.getBlockState(pos.down()); return super.canPlaceBlockAt(worldIn, pos) && isValidSoil(soil.getBlock()); } @Override - public boolean canGrow(World world, BlockPos pos, IBlockState state, boolean isClient) { + public boolean canGrow(final World world, final BlockPos pos, final IBlockState state, final boolean isClient) { return VALID_BONEMEAL_SOILS.contains(world.getBlockState(pos.down()).getBlock()) ? !isMaxAge(state) : false; } @Override - public boolean canUseBonemeal(World world, Random rand, BlockPos pos, IBlockState state) { - Block block = world.getBlockState(pos.down()).getBlock(); + public boolean canUseBonemeal(final World world, final Random rand, final BlockPos pos, final IBlockState state) { + final Block block = world.getBlockState(pos.down()).getBlock(); return VALID_BONEMEAL_SOILS.contains(block); } @Override - public void grow(World world, Random rand, BlockPos pos, IBlockState state) { + public void grow(final World world, final Random rand, final BlockPos pos, final IBlockState state) { if (getAge(state) < getMaxAge()) { - int i = Math.min(getAge(state) + getBonemealAgeIncrease(world), 7); + final int i = Math.min(getAge(state) + getBonemealAgeIncrease(world), 7); if (i <= getMaxAge()) { world.setBlockState(pos, withAge(i), 2); } } } - public static boolean tryBonemeal(ItemStack stack, World world, BlockPos target, EntityPlayer player, @Nullable EnumHand hand) { - IBlockState iblockstate = world.getBlockState(target); + public static boolean tryBonemeal(final ItemStack stack, final World world, final BlockPos target, final EntityPlayer player, @Nullable final EnumHand hand) { + final IBlockState iblockstate = world.getBlockState(target); //int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, world, target, iblockstate, stack, hand); //if (hook != 0) { // return hook > 0; //} if (iblockstate.getBlock() instanceof BlockEnderFlower) { - BlockEnderFlower flower = (BlockEnderFlower) iblockstate.getBlock(); + final BlockEnderFlower flower = (BlockEnderFlower) iblockstate.getBlock(); if (flower.canGrow(world, target, iblockstate, world.isRemote)) { if (!world.isRemote) { if (flower.canUseBonemeal(world, world.rand, target, iblockstate)) { @@ -300,23 +312,23 @@ public static boolean tryBonemeal(ItemStack stack, World world, BlockPos target, return false; } - public static void spawnBonemealParticles(World world, BlockPos pos) { - IBlockState iblockstate = world.getBlockState(pos); - Random rand = ModGlobals.RNG; + public static void spawnBonemealParticles(final World world, final BlockPos pos) { + final IBlockState iblockstate = world.getBlockState(pos); + final Random rand = ModGlobals.RNG; if (iblockstate.getMaterial() != Material.AIR) { for (int i = 0; i < 5; ++i) { - double d0 = rand.nextGaussian() * 0.02D; - double d1 = rand.nextGaussian() * 0.02D; - double d2 = rand.nextGaussian() * 0.02D; + final double d0 = rand.nextGaussian() * 0.02D; + final double d1 = rand.nextGaussian() * 0.02D; + final double d2 = rand.nextGaussian() * 0.02D; world.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() + rand.nextFloat(), pos.getY() + rand.nextFloat() * iblockstate.getBoundingBox(world, pos).maxY, pos.getZ() + rand.nextFloat(), d0, d1, d2); } } else { for (int i1 = 0; i1 < 5; ++i1) { - double d0 = rand.nextGaussian() * 0.02D; - double d1 = rand.nextGaussian() * 0.02D; - double d2 = rand.nextGaussian() * 0.02D; + final double d0 = rand.nextGaussian() * 0.02D; + final double d1 = rand.nextGaussian() * 0.02D; + final double d2 = rand.nextGaussian() * 0.02D; world.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() + rand.nextFloat(), pos.getY() + (double) rand.nextFloat() * 1.0f, pos.getZ() + rand.nextFloat(), d0, d1, d2, new int[0]); } } @@ -329,27 +341,27 @@ public BlockRenderLayer getBlockLayer() { } @Override - public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) { + public BlockFaceShape getBlockFaceShape(final IBlockAccess worldIn, final IBlockState state, final BlockPos pos, final EnumFacing face) { return BlockFaceShape.UNDEFINED; } @Override - public boolean isOpaqueCube(IBlockState state) { + public boolean isOpaqueCube(final IBlockState state) { return false; } @Override - public boolean isFullCube(IBlockState state) { + public boolean isFullCube(final IBlockState state) { return false; } @Override - public IBlockState getStateFromMeta(int meta) { + public IBlockState getStateFromMeta(final int meta) { return withAge(meta); } @Override - public int getMetaFromState(IBlockState state) { + public int getMetaFromState(final IBlockState state) { return getAge(state); } @@ -361,13 +373,13 @@ protected BlockStateContainer createBlockState() { } @Override - public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { + public EnumPlantType getPlantType(final IBlockAccess world, final BlockPos pos) { return EnumPlantType.getPlantType("EnderCrops"); } @Override - public IBlockState getPlant(IBlockAccess world, BlockPos pos) { - IBlockState state = world.getBlockState(pos); + public IBlockState getPlant(final IBlockAccess world, final BlockPos pos) { + final IBlockState state = world.getBlockState(pos); if (state.getBlock() != this) { return getDefaultState(); } diff --git a/src/main/java/p455w0rd/endermanevo/init/ModGlobals.java b/src/main/java/p455w0rd/endermanevo/init/ModGlobals.java index 9fc1cab..22e8c07 100644 --- a/src/main/java/p455w0rd/endermanevo/init/ModGlobals.java +++ b/src/main/java/p455w0rd/endermanevo/init/ModGlobals.java @@ -4,7 +4,7 @@ public class ModGlobals { public static final String MODID = "endermanevo"; - public static final String VERSION = "1.0.17"; + public static final String VERSION = "1.0.18"; public static final String NAME = "Enderman Evolution"; public static final String SERVER_PROXY = "p455w0rd.endermanevo.proxy.CommonProxy"; public static final String CLIENT_PROXY = "p455w0rd.endermanevo.proxy.ClientProxy"; diff --git a/src/main/java/p455w0rd/endermanevo/init/ModIntegration.java b/src/main/java/p455w0rd/endermanevo/init/ModIntegration.java index 95bd6cd..5f78cfd 100644 --- a/src/main/java/p455w0rd/endermanevo/init/ModIntegration.java +++ b/src/main/java/p455w0rd/endermanevo/init/ModIntegration.java @@ -27,16 +27,22 @@ public static void init() { } } + public static void postInit() { + if (Mods.IE.isLoaded()) { + IE.registerClocheRecipe(); + } + } + public static enum Mods { TOP("theoneprobe", "The One Probe"), ENDERSTORAGE("enderstorage", "Ender Storage"), WAILA("waila", "WAILA"), IRONCHESTS("ironchest", "Iron Chests"), JEI("jei", "Just Enough Items"), - TINKERS("tconstruct", "Tinkers Construct"); + TINKERS("tconstruct", "Tinkers Construct"), IE("immersiveengineering", "Immersive Engineering"); - private String modid, name; + private final String modid, name; - Mods(String modidIn, String nameIn) { + Mods(final String modidIn, final String nameIn) { modid = modidIn; name = nameIn; } diff --git a/src/main/java/p455w0rd/endermanevo/integration/IE.java b/src/main/java/p455w0rd/endermanevo/integration/IE.java new file mode 100644 index 0000000..e068efa --- /dev/null +++ b/src/main/java/p455w0rd/endermanevo/integration/IE.java @@ -0,0 +1,103 @@ +package p455w0rd.endermanevo.integration; + +import java.util.HashSet; + +import com.google.common.collect.Sets; + +import blusunrize.immersiveengineering.api.ComparableItemStack; +import blusunrize.immersiveengineering.api.tool.BelljarHandler; +import blusunrize.immersiveengineering.api.tool.BelljarHandler.DefaultPlantHandler; +import blusunrize.immersiveengineering.common.blocks.metal.TileEntityBelljar; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.Constants.NBT; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import p455w0rd.endermanevo.blocks.BlockEnderFlower; +import p455w0rd.endermanevo.init.ModItems; + +/** + * @author p455w0rd + * + */ +public class IE { + + private static final DefaultPlantHandler ENDERFLOWER_HANDLER = new DefaultPlantHandler() { + + private final HashSet validSeeds = Sets.newHashSet(new ComparableItemStack(new ItemStack(ModItems.ENDER_FLOWER), false, false)); + + @Override + protected HashSet getSeedSet() { + return validSeeds; + } + + @Override + public boolean isValid(final ItemStack seed) { + return seed != null && !seed.isEmpty() && seed.getItem() == ModItems.ENDER_FLOWER; + } + + @Override + public boolean isCorrectSoil(final ItemStack seed, final ItemStack soil) { + for (final ItemStack validSoil : BlockEnderFlower.VALID_SOILS_STACKS) { + if (validSoil.getItem() == soil.getItem()) { + return true; + } + } + return false; + } + + @Override + public float getGrowthStep(final ItemStack seed, final ItemStack soil, final float growth, final TileEntity tile, final float fertilizer, final boolean render) { + boolean isBonemealable = false; + for (final Block boneMealSoil : BlockEnderFlower.VALID_BONEMEAL_SOILS) { + if (boneMealSoil == Block.getBlockFromItem(soil.getItem())) { + isBonemealable = true; + break; + } + } + return .003125f * (isBonemealable ? fertilizer * 2 : 0.25f); + } + + @Override + public ItemStack[] getOutput(final ItemStack seed, final ItemStack soil, final TileEntity tile) { + if (tile instanceof TileEntityBelljar) { + final TileEntityBelljar bellJar = (TileEntityBelljar) tile; + final int age = getGrowth(bellJar); + if (age == 1) { + return new ItemStack[] { + new ItemStack(ModItems.ENDER_FRAGMENT) + }; + } + } + return new ItemStack[] { + ItemStack.EMPTY + }; + } + + private int getGrowth(final TileEntityBelljar tile) { + final NBTTagCompound nbt = new NBTTagCompound(); + tile.writeCustomNBT(nbt, false); + if (nbt.hasKey("growth", NBT.TAG_FLOAT)) { + return Math.round(nbt.getFloat("growth")); + } + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public IBlockState[] getRenderedPlant(final ItemStack seed, final ItemStack soil, final float growth, final TileEntity tile) { + return new IBlockState[] { + BlockEnderFlower.getGrowthStates()[Math.min(7, Math.round(7 * growth))] + }; + } + + }; + + public static void registerClocheRecipe() { + BelljarHandler.registerHandler(ENDERFLOWER_HANDLER); + } + +} diff --git a/src/main/java/p455w0rd/endermanevo/proxy/CommonProxy.java b/src/main/java/p455w0rd/endermanevo/proxy/CommonProxy.java index 7e1327a..9be97de 100644 --- a/src/main/java/p455w0rd/endermanevo/proxy/CommonProxy.java +++ b/src/main/java/p455w0rd/endermanevo/proxy/CommonProxy.java @@ -1,13 +1,12 @@ package p455w0rd.endermanevo.proxy; import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.event.*; import p455w0rd.endermanevo.init.*; public class CommonProxy { - public void preInit(FMLPreInitializationEvent e) { + public void preInit(final FMLPreInitializationEvent e) { ModConfig.init(); ModBlocks.init(); ModIntegration.preInit(); @@ -15,12 +14,16 @@ public void preInit(FMLPreInitializationEvent e) { ModEvents.init(); } - public void init(FMLInitializationEvent e) { + public void init(final FMLInitializationEvent e) { ModEntities.init(); ModIntegration.init(); ModWorldGeneration.init(); } + public void postInit(final FMLPostInitializationEvent e) { + ModIntegration.postInit(); + } + public EntityPlayer getPlayer() { return null; }