diff --git a/build.gradle b/build.gradle index 918e44427..f47f63ffa 100755 --- a/build.gradle +++ b/build.gradle @@ -71,8 +71,8 @@ repositories { dependencies { deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}" - deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}:api" - runtime "net.industrial-craft:industrialcraft-2:${ic2_version}:dev" +// deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}:api" +// runtime "net.industrial-craft:industrialcraft-2:${ic2_version}:dev" } configurations { diff --git a/gradle.properties b/gradle.properties index 8ef54a08e..dde737d37 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,6 @@ forgeversion=12.16.1.1887 mcp_mappings=snapshot_20160504 jei_version=3.3.3.+ -ic2_version=2.3.235-ex18 version_major=5 version_minor=0 diff --git a/src/main/java/forestry/api/apiculture/IArmorApiaristHelper.java b/src/main/java/forestry/api/apiculture/IArmorApiaristHelper.java index e7dd35617..ff04fa65c 100644 --- a/src/main/java/forestry/api/apiculture/IArmorApiaristHelper.java +++ b/src/main/java/forestry/api/apiculture/IArmorApiaristHelper.java @@ -31,7 +31,8 @@ public interface IArmorApiaristHelper { * @param entity Entity being attacked * @param cause Optional cause of attack, such as a bee effect identifier * @param doProtect Whether or not to actually do the side effects of protection - * @return The number of valid Apiarist Armor pieces the player is wearing that are actually protecting + * @return The number of valid Apiarist Armor pieces the player is wearing that are actually protecting. + * 4 means full protection, but it can go higher if they are holding items like the smoker. * @since Forestry 4.2 */ int wearsItems(EntityLivingBase entity, String cause, boolean doProtect); diff --git a/src/main/java/forestry/api/apiculture/hives/IHiveRegistry.java b/src/main/java/forestry/api/apiculture/hives/IHiveRegistry.java index ac89674f1..66df70d5f 100644 --- a/src/main/java/forestry/api/apiculture/hives/IHiveRegistry.java +++ b/src/main/java/forestry/api/apiculture/hives/IHiveRegistry.java @@ -7,6 +7,7 @@ package forestry.api.apiculture.hives; import javax.annotation.Nonnull; import java.util.List; +import java.util.Locale; import net.minecraft.util.IStringSerializable; @@ -49,7 +50,7 @@ public interface IHiveRegistry { @Override public String getName() { - return name().toLowerCase(); + return name().toLowerCase(Locale.ENGLISH); } public int getMeta() { diff --git a/src/main/java/forestry/apiculture/ArmorApiaristHelper.java b/src/main/java/forestry/apiculture/ArmorApiaristHelper.java index db735de98..a019fdcae 100644 --- a/src/main/java/forestry/apiculture/ArmorApiaristHelper.java +++ b/src/main/java/forestry/apiculture/ArmorApiaristHelper.java @@ -38,18 +38,12 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper { public int wearsItems(EntityLivingBase entity, String cause, boolean doProtect) { int count = 0; - for (int i = 1; i <= 4; i++) { - ItemStack armorItem = entity.getEquipmentInSlot(i); + for (ItemStack armorItem : entity.getEquipmentAndArmor()) { if (isArmorApiarist(armorItem, entity, cause, doProtect)) { count++; } } - ItemStack heldItem = entity.getHeldItem(); - if (isArmorApiarist(heldItem, entity, cause, doProtect)) { - count++; - } - return count; } } diff --git a/src/main/java/forestry/apiculture/PluginApiculture.java b/src/main/java/forestry/apiculture/PluginApiculture.java index 30c0ac3d2..72d23eda9 100644 --- a/src/main/java/forestry/apiculture/PluginApiculture.java +++ b/src/main/java/forestry/apiculture/PluginApiculture.java @@ -199,10 +199,11 @@ public class PluginApiculture extends BlankForestryPlugin { PluginCore.rootCommand.addChildCommand(new CommandBee()); } - @Override - public void registerTriggers() { - ApicultureTriggers.initialize(); - } + // TODO: Buildcraft for 1.9 +// @Override +// public void registerTriggers() { +// ApicultureTriggers.initialize(); +// } @Override public void doInit() { diff --git a/src/main/java/forestry/apiculture/blocks/BlockAlveary.java b/src/main/java/forestry/apiculture/blocks/BlockAlveary.java index 8aabf68b3..47eb20e8a 100644 --- a/src/main/java/forestry/apiculture/blocks/BlockAlveary.java +++ b/src/main/java/forestry/apiculture/blocks/BlockAlveary.java @@ -14,6 +14,7 @@ import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.EnumMap; import java.util.List; +import java.util.Locale; import java.util.Map; import net.minecraft.block.Block; @@ -63,7 +64,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe @Override public String getName() { - return name().toLowerCase(); + return name().toLowerCase(Locale.ENGLISH); } } @@ -72,7 +73,7 @@ public abstract class BlockAlveary extends BlockStructure implements IStateMappe @Override public String getName() { - return name().toLowerCase(); + return name().toLowerCase(Locale.ENGLISH); } } diff --git a/src/main/java/forestry/apiculture/blocks/BlockCandle.java b/src/main/java/forestry/apiculture/blocks/BlockCandle.java index b694a75f9..c2e41e86d 100644 --- a/src/main/java/forestry/apiculture/blocks/BlockCandle.java +++ b/src/main/java/forestry/apiculture/blocks/BlockCandle.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Random; import java.util.Set; @@ -65,11 +66,17 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister, ITile private static final PropertyEnum STATE = PropertyEnum.create("state", State.class); private enum State implements IStringSerializable { - ON, OFF; + ON("on"), OFF("off"); + + private final String name; + + State(String name) { + this.name = name; + } @Override public String getName() { - return name(); + return name; } } diff --git a/src/main/java/forestry/apiculture/blocks/BlockTypeApiculture.java b/src/main/java/forestry/apiculture/blocks/BlockTypeApiculture.java index 83d21fea3..527dc290f 100644 --- a/src/main/java/forestry/apiculture/blocks/BlockTypeApiculture.java +++ b/src/main/java/forestry/apiculture/blocks/BlockTypeApiculture.java @@ -21,7 +21,7 @@ import forestry.core.tiles.TileForestry; public enum BlockTypeApiculture implements IBlockType { APIARY(0, TileApiary.class, "apiary"), - BEE_HOUSE(1, TileBeeHouse.class, "bee.house"); + BEE_HOUSE(1, TileBeeHouse.class, "bee_house"); public static final BlockTypeApiculture[] VALUES = values(); diff --git a/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java b/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java index ade4ea812..b9e40a2b7 100644 --- a/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java +++ b/src/main/java/forestry/apiculture/blocks/BlockTypeApicultureTesr.java @@ -26,7 +26,7 @@ import forestry.core.tiles.TileForestry; import forestry.core.tiles.TileNaturalistChest; public enum BlockTypeApicultureTesr implements IBlockTypeTesr { - APIARIST_CHEST(0, TileApiaristChest.class, "api.chest", Proxies.render.getRenderChest("apiaristchest"), TileNaturalistChest.chestBoundingBox); + APIARIST_CHEST(0, TileApiaristChest.class, "api_chest", Proxies.render.getRenderChest("apiaristchest"), TileNaturalistChest.chestBoundingBox); public static final BlockTypeApicultureTesr[] VALUES = values(); diff --git a/src/main/java/forestry/apiculture/flowers/GrowthRuleFlowerPot.java b/src/main/java/forestry/apiculture/flowers/GrowthRuleFlowerPot.java index 3d151bc54..97d9a2e17 100644 --- a/src/main/java/forestry/apiculture/flowers/GrowthRuleFlowerPot.java +++ b/src/main/java/forestry/apiculture/flowers/GrowthRuleFlowerPot.java @@ -71,7 +71,7 @@ public class GrowthRuleFlowerPot implements IFlowerGrowthRule { flowerPotTile.markDirty(); if (!world.setBlockState(pos, world.getBlockState(pos).getBlock().getStateFromMeta(1), 2)) { - world.markBlockForUpdate(pos); + world.markBlockRangeForRenderUpdate(pos, pos); } return true; diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java index 9fe7854ad..cc5460207 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java @@ -13,6 +13,9 @@ package forestry.apiculture.genetics.alleles; import java.util.List; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.SoundEvents; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -82,8 +85,8 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled { continue; } - world.playSoundEffect(housingCoords.getX(), housingCoords.getY(), housingCoords.getZ(), "mob.creeper", 4F, - (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F); + float pitch = (1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F; + world.playSound((EntityPlayer)null, housingCoords.getX(), housingCoords.getY(), housingCoords.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, pitch); storedData.setInteger(indexExplosionTimer, 2); // Set explosion timer } diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectRadioactive.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectRadioactive.java index 57ee7baf4..ebb8af238 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectRadioactive.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectRadioactive.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.Random; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; @@ -85,7 +86,8 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled { continue; } - Block block = world.getBlockState(posBlock).getBlock(); + IBlockState blockState = world.getBlockState(posBlock); + Block block = blockState.getBlock(); if (block instanceof BlockAlveary) { continue; @@ -96,7 +98,7 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled { continue; } - if (block.getBlockHardness(world, posBlock) < 0) { + if (block.getBlockHardness(blockState, world, posBlock) < 0) { continue; } diff --git a/src/main/java/forestry/apiculture/items/ItemBlockCandle.java b/src/main/java/forestry/apiculture/items/ItemBlockCandle.java index 2fc468451..7515c8918 100644 --- a/src/main/java/forestry/apiculture/items/ItemBlockCandle.java +++ b/src/main/java/forestry/apiculture/items/ItemBlockCandle.java @@ -11,6 +11,7 @@ package forestry.apiculture.items; import net.minecraft.block.Block; +import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -20,7 +21,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import forestry.apiculture.blocks.BlockCandle; import forestry.core.items.ItemBlockForestry; -public class ItemBlockCandle extends ItemBlockForestry { +public class ItemBlockCandle extends ItemBlockForestry implements IItemColor { public ItemBlockCandle(Block block) { super(block); @@ -28,7 +29,7 @@ public class ItemBlockCandle extends ItemBlockForestry { @Override @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int pass) { + public int getColorFromItemstack(ItemStack stack, int pass) { int value = 0xffffff; if (pass == 1 && stack.hasTagCompound()) { NBTTagCompound tag = stack.getTagCompound(); diff --git a/src/main/java/forestry/apiculture/multiblock/AlvearyController.java b/src/main/java/forestry/apiculture/multiblock/AlvearyController.java index 79a9f23df..94197a4db 100644 --- a/src/main/java/forestry/apiculture/multiblock/AlvearyController.java +++ b/src/main/java/forestry/apiculture/multiblock/AlvearyController.java @@ -177,7 +177,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple BlockPos pos = new BlockPos(slabX, slabY, slabZ); IBlockState state = worldObj.getBlockState(pos); Block block = state.getBlock(); - if (!BlockUtil.isWoodSlabBlock(block, worldObj, pos)) { + if (!BlockUtil.isWoodSlabBlock(state, block, worldObj, pos)) { throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.alveary.error.needSlabs")); } @@ -196,8 +196,9 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple if (isCoordInMultiblock(airX, airY, airZ)) { continue; } - Block block = BlockUtil.getBlock(worldObj, new BlockPos(airX, airY, airZ)); - if (block.isOpaqueCube()) { + IBlockState blockState = worldObj.getBlockState(new BlockPos(airX, airY, airZ)); + Block block = blockState.getBlock(); + if (block.isOpaqueCube(blockState)) { throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.alveary.error.needSpace")); } } diff --git a/src/main/java/forestry/apiculture/multiblock/TileAlvearyPlain.java b/src/main/java/forestry/apiculture/multiblock/TileAlvearyPlain.java index 5d014e930..eafc74dec 100644 --- a/src/main/java/forestry/apiculture/multiblock/TileAlvearyPlain.java +++ b/src/main/java/forestry/apiculture/multiblock/TileAlvearyPlain.java @@ -10,23 +10,8 @@ ******************************************************************************/ package forestry.apiculture.multiblock; -import java.util.ArrayList; -import java.util.Collection; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.fml.common.Optional; - -import forestry.apiculture.trigger.ApicultureTriggers; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.ITriggerExternal; -import buildcraft.api.statements.ITriggerInternal; -import buildcraft.api.statements.ITriggerProvider; - -@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") -public class TileAlvearyPlain extends TileAlveary implements ITriggerProvider { +//@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") +public class TileAlvearyPlain extends TileAlveary {//implements ITriggerProvider { @Override public boolean allowsAutomation() { @@ -34,18 +19,19 @@ public class TileAlvearyPlain extends TileAlveary implements ITriggerProvider { } /* ITRIGGERPROVIDER */ - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getInternalTriggers(IStatementContainer container) { - return null; - } - - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { - Collection res = new ArrayList<>(); - res.add(ApicultureTriggers.missingQueen); - res.add(ApicultureTriggers.missingDrone); - return res; - } + // TODO: buildcraft for 1.9 +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getInternalTriggers(IStatementContainer container) { +// return null; +// } +// +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { +// Collection res = new ArrayList<>(); +// res.add(ApicultureTriggers.missingQueen); +// res.add(ApicultureTriggers.missingDrone); +// return res; +// } } diff --git a/src/main/java/forestry/apiculture/tiles/TileApiary.java b/src/main/java/forestry/apiculture/tiles/TileApiary.java index 037bb331b..50ca40e06 100644 --- a/src/main/java/forestry/apiculture/tiles/TileApiary.java +++ b/src/main/java/forestry/apiculture/tiles/TileApiary.java @@ -13,14 +13,9 @@ package forestry.apiculture.tiles; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.fml.common.Optional; import forestry.api.apiculture.IBeeHousingInventory; import forestry.api.apiculture.IBeeListener; @@ -33,9 +28,6 @@ import forestry.apiculture.gui.ContainerBeeHousing; import forestry.apiculture.gui.GuiBeeHousing; import forestry.apiculture.inventory.IApiaryInventory; import forestry.apiculture.inventory.InventoryApiary; -import forestry.apiculture.trigger.ApicultureTriggers; - -import buildcraft.api.statements.ITriggerExternal; public class TileApiary extends TileBeeHousingBase implements IApiary { private final IBeeModifier beeModifier = new ApiaryBeeModifier(); @@ -76,15 +68,16 @@ public class TileApiary extends TileBeeHousingBase implements IApiary { } /* ITRIGGERPROVIDER */ - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { - LinkedList res = new LinkedList<>(); - res.add(ApicultureTriggers.missingQueen); - res.add(ApicultureTriggers.missingDrone); - res.add(ApicultureTriggers.noFrames); - return res; - } + // TODO: buildcraft for 1.9 +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { +// LinkedList res = new LinkedList<>(); +// res.add(ApicultureTriggers.missingQueen); +// res.add(ApicultureTriggers.missingDrone); +// res.add(ApicultureTriggers.noFrames); +// return res; +// } @Override public Object getGui(EntityPlayer player, int data) { diff --git a/src/main/java/forestry/apiculture/trigger/ApicultureTriggers.java b/src/main/java/forestry/apiculture/trigger/ApicultureTriggers.java index 27cd7735b..d02e24937 100644 --- a/src/main/java/forestry/apiculture/trigger/ApicultureTriggers.java +++ b/src/main/java/forestry/apiculture/trigger/ApicultureTriggers.java @@ -12,15 +12,16 @@ package forestry.apiculture.trigger; import forestry.core.triggers.Trigger; +// TODO: Buildcraft for 1.9 public class ApicultureTriggers { - public static Trigger noFrames; - public static Trigger missingQueen; - public static Trigger missingDrone; - - public static void initialize() { - noFrames = new TriggerNoFrames(); - - missingQueen = new TriggerMissingQueen(); - missingDrone = new TriggerMissingDrone(); - } +// public static Trigger noFrames; +// public static Trigger missingQueen; +// public static Trigger missingDrone; +// +// public static void initialize() { +// noFrames = new TriggerNoFrames(); +// +// missingQueen = new TriggerMissingQueen(); +// missingDrone = new TriggerMissingDrone(); +// } } diff --git a/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java b/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java index 153c8bc22..0bf00e54d 100644 --- a/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java +++ b/src/main/java/forestry/apiculture/trigger/TriggerMissingDrone.java @@ -10,34 +10,25 @@ ******************************************************************************/ package forestry.apiculture.trigger; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +// TODO: Buildcraft for 1.9 +public class TriggerMissingDrone {//extends Trigger { -import forestry.api.core.IErrorLogicSource; -import forestry.core.errors.EnumErrorCode; -import forestry.core.triggers.Trigger; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; - -public class TriggerMissingDrone extends Trigger { - - public TriggerMissingDrone() { - super("missingDrone"); - } - - /** - * Return true if the tile given in parameter activates the trigger, given the parameters. - */ - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - - if (!(tile instanceof IErrorLogicSource)) { - return false; - } - - IErrorLogicSource apiary = (IErrorLogicSource) tile; - return apiary.getErrorLogic().contains(EnumErrorCode.NO_DRONE); - } +// public TriggerMissingDrone() { +// super("missingDrone"); +// } +// +// /** +// * Return true if the tile given in parameter activates the trigger, given the parameters. +// */ +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// +// if (!(tile instanceof IErrorLogicSource)) { +// return false; +// } +// +// IErrorLogicSource apiary = (IErrorLogicSource) tile; +// return apiary.getErrorLogic().contains(EnumErrorCode.NO_DRONE); +// } } diff --git a/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java b/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java index 6cff4c162..50e7f3a3d 100644 --- a/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java +++ b/src/main/java/forestry/apiculture/trigger/TriggerMissingQueen.java @@ -10,33 +10,24 @@ ******************************************************************************/ package forestry.apiculture.trigger; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +public class TriggerMissingQueen {//extends Trigger { -import forestry.api.core.IErrorLogicSource; -import forestry.core.errors.EnumErrorCode; -import forestry.core.triggers.Trigger; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; - -public class TriggerMissingQueen extends Trigger { - - public TriggerMissingQueen() { - super("missingQueen"); - } +// public TriggerMissingQueen() { +// super("missingQueen"); +// } /** * Return true if the tile given in parameter activates the trigger, given the parameters. */ - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - - if (!(tile instanceof IErrorLogicSource)) { - return false; - } - - IErrorLogicSource apiary = (IErrorLogicSource) tile; - return apiary.getErrorLogic().contains(EnumErrorCode.NO_QUEEN); - } + // TODO: buildcraft for 1.9 +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// +// if (!(tile instanceof IErrorLogicSource)) { +// return false; +// } +// +// IErrorLogicSource apiary = (IErrorLogicSource) tile; +// return apiary.getErrorLogic().contains(EnumErrorCode.NO_QUEEN); +// } } diff --git a/src/main/java/forestry/apiculture/trigger/TriggerNoFrames.java b/src/main/java/forestry/apiculture/trigger/TriggerNoFrames.java index f5fa4e088..70f60fabc 100755 --- a/src/main/java/forestry/apiculture/trigger/TriggerNoFrames.java +++ b/src/main/java/forestry/apiculture/trigger/TriggerNoFrames.java @@ -10,37 +10,30 @@ ******************************************************************************/ package forestry.apiculture.trigger; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import forestry.apiculture.inventory.InventoryApiary; -import forestry.apiculture.tiles.TileApiary; import forestry.core.triggers.Trigger; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +public class TriggerNoFrames {//extends Trigger { -public class TriggerNoFrames extends Trigger { - - public TriggerNoFrames() { - super("noFrames"); - } +// public TriggerNoFrames() { +// super("noFrames"); +// } /** * Return true if the tile given in parameter activates the trigger, given the parameters. */ - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - - if (!(tile instanceof TileApiary)) { - return false; - } - - TileApiary apiary = (TileApiary) tile; - - InventoryApiary inventory = (InventoryApiary) apiary.getInternalInventory(); - - return inventory.getFrames().isEmpty(); - } + // TODO: buildcraft for 1.9 +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// +// if (!(tile instanceof TileApiary)) { +// return false; +// } +// +// TileApiary apiary = (TileApiary) tile; +// +// InventoryApiary inventory = (InventoryApiary) apiary.getInternalInventory(); +// +// return inventory.getFrames().isEmpty(); +// } } diff --git a/src/main/java/forestry/arboriculture/blocks/BlockTypeArboricultureTesr.java b/src/main/java/forestry/arboriculture/blocks/BlockTypeArboricultureTesr.java index 7dd06a7a6..c2f80c147 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockTypeArboricultureTesr.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockTypeArboricultureTesr.java @@ -26,7 +26,7 @@ import forestry.core.tiles.TileForestry; import forestry.core.tiles.TileNaturalistChest; public enum BlockTypeArboricultureTesr implements IBlockTypeTesr { - ARB_CHEST(0, TileArboristChest.class, "arb.chest", Proxies.render.getRenderChest("arbchest"), TileNaturalistChest.chestBoundingBox); + ARB_CHEST(0, TileArboristChest.class, "arb_chest", Proxies.render.getRenderChest("arbchest"), TileNaturalistChest.chestBoundingBox); public static final BlockTypeArboricultureTesr[] VALUES = values(); diff --git a/src/main/java/forestry/arboriculture/blocks/property/PropertyTree.java b/src/main/java/forestry/arboriculture/blocks/property/PropertyTree.java index 9a791eba6..4b8cf6078 100644 --- a/src/main/java/forestry/arboriculture/blocks/property/PropertyTree.java +++ b/src/main/java/forestry/arboriculture/blocks/property/PropertyTree.java @@ -15,6 +15,7 @@ import com.google.common.base.Optional; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.genetics.AlleleManager; @@ -55,7 +56,7 @@ public class PropertyTree extends PropertyAllele { @Override public String getName(IAlleleTreeSpecies value) { - return value.getModelName().replace("tree", ""); + return value.getModelName().replace("tree", "").toLowerCase(Locale.ENGLISH); } } diff --git a/src/main/java/forestry/arboriculture/blocks/property/PropertyTreeType.java b/src/main/java/forestry/arboriculture/blocks/property/PropertyTreeType.java index a09955bfc..ea13fea68 100644 --- a/src/main/java/forestry/arboriculture/blocks/property/PropertyTreeType.java +++ b/src/main/java/forestry/arboriculture/blocks/property/PropertyTreeType.java @@ -15,6 +15,7 @@ import com.google.common.collect.Lists; import javax.annotation.Nonnull; import java.util.Collection; +import java.util.Locale; import net.minecraft.block.properties.PropertyEnum; diff --git a/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java b/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java index 919d08ee5..fa4f6881f 100644 --- a/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java +++ b/src/main/java/forestry/arboriculture/commands/TreeGenHelper.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.arboriculture.commands; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -46,8 +47,9 @@ public final class TreeGenHelper { }else{ pos = BlockUtil.getNextReplaceableUpPos(world, pos); } - - if(BlockUtil.canPlaceTree(world, pos)){ + + IBlockState blockState = world.getBlockState(pos); + if (BlockUtil.canPlaceTree(blockState, world, pos)){ if (gen instanceof WorldGenBase) { ((WorldGenBase) gen).generate(world, pos, false); } else { diff --git a/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java b/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java index 4e89c1435..87f242e5e 100755 --- a/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java +++ b/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java @@ -10,10 +10,10 @@ ******************************************************************************/ package forestry.arboriculture.genetics; +import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; import forestry.api.arboriculture.EnumGrowthConditions; import forestry.api.arboriculture.IGrowthProvider; @@ -56,8 +56,6 @@ public class GrowthProvider implements IGrowthProvider { } protected static EnumGrowthConditions getConditionsFromRainfall(World world, BlockPos pos, float min, float max) { - - BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenerator(pos); float humidity = ForestryAPI.climateManager.getHumidity(world, pos); if (humidity < min || humidity > max) { @@ -68,8 +66,6 @@ public class GrowthProvider implements IGrowthProvider { } protected static EnumGrowthConditions getConditionsFromTemperature(World world, BlockPos pos, float min, float max) { - - BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenerator(pos); float biomeTemperature = ForestryAPI.climateManager.getTemperature(world, pos); if (biomeTemperature < min || biomeTemperature > max) { return EnumGrowthConditions.HOSTILE; @@ -110,7 +106,8 @@ public class GrowthProvider implements IGrowthProvider { for (int y = start.getY(); y < start.getY() + area.getY(); y++) { for (int z = start.getZ(); z < start.getZ() + area.getZ(); z++) { BlockPos pos = new BlockPos(x, y, z); - if (!world.isAirBlock(pos) && !BlockUtil.isReplaceableBlock(world, pos)) { + IBlockState blockState = world.getBlockState(pos); + if (!world.isAirBlock(pos) && !BlockUtil.isReplaceableBlock(blockState, world, pos)) { return false; } } diff --git a/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java index 6b720a437..86c8b1040 100644 --- a/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java @@ -12,6 +12,7 @@ package forestry.arboriculture.genetics; import java.awt.Color; import java.util.Arrays; +import java.util.Locale; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -1112,7 +1113,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe @Override public String getName() { - return name(); + return name().toLowerCase(Locale.ENGLISH); } public int getMetadata() { diff --git a/src/main/java/forestry/arboriculture/models/SaplingStateMapper.java b/src/main/java/forestry/arboriculture/models/SaplingStateMapper.java index 974462b0e..dff420fe6 100644 --- a/src/main/java/forestry/arboriculture/models/SaplingStateMapper.java +++ b/src/main/java/forestry/arboriculture/models/SaplingStateMapper.java @@ -29,7 +29,7 @@ public class SaplingStateMapper extends ForestryStateMapper { if (allele instanceof IAlleleTreeSpecies) { IAlleleTreeSpecies tree = (IAlleleTreeSpecies) allele; IBlockState state = block.getDefaultState().withProperty(BlockSapling.TREE, tree); - LinkedHashMap linkedhashmap = Maps.newLinkedHashMap(state.getProperties()); + LinkedHashMap, Comparable> linkedhashmap = Maps.newLinkedHashMap(state.getProperties()); String modID = tree.getModID(); if (modID == null) { modID = Constants.MOD_ID; diff --git a/src/main/java/forestry/arboriculture/tiles/TileFruitPod.java b/src/main/java/forestry/arboriculture/tiles/TileFruitPod.java index 06dee6235..4e4f5ac28 100644 --- a/src/main/java/forestry/arboriculture/tiles/TileFruitPod.java +++ b/src/main/java/forestry/arboriculture/tiles/TileFruitPod.java @@ -190,6 +190,6 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl } else { allele = (IAlleleFruit) AlleleManager.alleleRegistry.getAllele(Constants.MOD_ID + ".fruitCocoa"); } - worldObj.markBlockForUpdate(getPos()); + worldObj.markBlockRangeForRenderUpdate(getPos(), getPos()); } } diff --git a/src/main/java/forestry/arboriculture/tiles/TileLeaves.java b/src/main/java/forestry/arboriculture/tiles/TileLeaves.java index ea364a326..1e37533d8 100644 --- a/src/main/java/forestry/arboriculture/tiles/TileLeaves.java +++ b/src/main/java/forestry/arboriculture/tiles/TileLeaves.java @@ -287,7 +287,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru } tree.mate(individual); - worldObj.markBlockForUpdate(getPos()); + worldObj.markBlockRangeForRenderUpdate(getPos(), getPos()); } @Override @@ -380,7 +380,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru setTree(tree); - worldObj.markBlockForUpdate(getPos()); + worldObj.markBlockRangeForRenderUpdate(getPos(), getPos()); } } @@ -390,7 +390,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru return; } colourFruits = newColourFruits; - worldObj.markBlockForUpdate(getPos()); + worldObj.markBlockRangeForRenderUpdate(getPos(), getPos()); } /* IFRUITBEARER */ diff --git a/src/main/java/forestry/core/EventHandlerCore.java b/src/main/java/forestry/core/EventHandlerCore.java index 61cb3ddfe..b8552067a 100755 --- a/src/main/java/forestry/core/EventHandlerCore.java +++ b/src/main/java/forestry/core/EventHandlerCore.java @@ -43,7 +43,7 @@ public class EventHandlerCore { } for (IPickupHandler handler : PluginManager.pickupHandlers) { - if (handler.onItemPickup(event.entityPlayer, event.item)) { + if (handler.onItemPickup(event.getEntityPlayer(), event.getItem())) { event.setResult(Result.ALLOW); return; } @@ -65,21 +65,21 @@ public class EventHandlerCore { @SubscribeEvent public void handleWorldLoad(WorldEvent.Load event) { for (ISaveEventHandler handler : PluginManager.saveEventHandlers) { - handler.onWorldLoad(event.world); + handler.onWorldLoad(event.getWorld()); } } @SubscribeEvent public void handleWorldSave(WorldEvent.Save event) { for (ISaveEventHandler handler : PluginManager.saveEventHandlers) { - handler.onWorldSave(event.world); + handler.onWorldSave(event.getWorld()); } } @SubscribeEvent public void handleWorldUnload(WorldEvent.Unload event) { for (ISaveEventHandler handler : PluginManager.saveEventHandlers) { - handler.onWorldUnload(event.world); + handler.onWorldUnload(event.getWorld()); } } diff --git a/src/main/java/forestry/core/TickHandlerCoreServer.java b/src/main/java/forestry/core/TickHandlerCoreServer.java index d198fdbc7..c216a8c0f 100755 --- a/src/main/java/forestry/core/TickHandlerCoreServer.java +++ b/src/main/java/forestry/core/TickHandlerCoreServer.java @@ -56,7 +56,7 @@ public class TickHandlerCoreServer { if (Config.doRetrogen) { World world = event.world; - int dimensionID = world.provider.getDimensionId(); + int dimensionID = world.provider.getDimension(); List chunkList = chunkRegenList.get(dimensionID); if (!chunkList.isEmpty()) { @@ -102,7 +102,7 @@ public class TickHandlerCoreServer { public final int zCoord; public ChunkCoords(Chunk chunk) { - this.dimension = chunk.getWorld().provider.getDimensionId(); + this.dimension = chunk.getWorld().provider.getDimension(); this.xCoord = chunk.xPosition; this.zCoord = chunk.zPosition; } diff --git a/src/main/java/forestry/core/blocks/BlockResourceOre.java b/src/main/java/forestry/core/blocks/BlockResourceOre.java index 910bc59eb..9602fe7ed 100644 --- a/src/main/java/forestry/core/blocks/BlockResourceOre.java +++ b/src/main/java/forestry/core/blocks/BlockResourceOre.java @@ -10,9 +10,10 @@ ******************************************************************************/ package forestry.core.blocks; +import com.google.common.base.Predicate; + import java.util.ArrayList; import java.util.List; -import com.google.common.base.Predicate; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -44,7 +45,7 @@ public class BlockResourceOre extends Block implements IItemModelRegister, IBloc }); public BlockResourceOre() { - super(Material.rock); + super(Material.ROCK); setHardness(3F); setResistance(5F); setCreativeTab(CreativeTabForestry.tabForestry); @@ -97,11 +98,6 @@ public class BlockResourceOre extends Block implements IItemModelRegister, IBloc return drops; } - @Override - public int getDamageValue(World world, BlockPos pos) { - return getMetaFromState(world.getBlockState(pos)); - } - @Override public int damageDropped(IBlockState state) { return getMetaFromState(state); diff --git a/src/main/java/forestry/core/blocks/BlockSoil.java b/src/main/java/forestry/core/blocks/BlockSoil.java index f1289684e..7f4bf4a0a 100644 --- a/src/main/java/forestry/core/blocks/BlockSoil.java +++ b/src/main/java/forestry/core/blocks/BlockSoil.java @@ -54,7 +54,7 @@ public class BlockSoil extends Block implements IItemModelRegister, IBlockWithMe public enum SoilType implements IStringSerializable { HUMUS("humus"), - BOG_EARTH("bog.earth"), + BOG_EARTH("bog_earth"), PEAT("peat"); @Nonnull diff --git a/src/main/java/forestry/core/circuits/ItemCircuitBoard.java b/src/main/java/forestry/core/circuits/ItemCircuitBoard.java index b29a1fd18..c327fc0e6 100755 --- a/src/main/java/forestry/core/circuits/ItemCircuitBoard.java +++ b/src/main/java/forestry/core/circuits/ItemCircuitBoard.java @@ -13,6 +13,7 @@ package forestry.core.circuits; import java.util.List; import java.util.Locale; +import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -30,7 +31,7 @@ import forestry.api.core.IModelManager; import forestry.core.PluginCore; import forestry.core.items.ItemForestry; -public class ItemCircuitBoard extends ItemForestry { +public class ItemCircuitBoard extends ItemForestry implements IItemColor { public ItemCircuitBoard() { setHasSubtypes(true); @@ -62,9 +63,9 @@ public class ItemCircuitBoard extends ItemForestry { } @Override - public int getColorFromItemStack(ItemStack itemstack, int pass) { + public int getColorFromItemstack(ItemStack itemstack, int tintIndex) { EnumCircuitBoardType type = EnumCircuitBoardType.values()[itemstack.getItemDamage()]; - if (pass == 0) { + if (tintIndex == 0) { return type.getPrimaryColor(); } else { return type.getSecondaryColor(); diff --git a/src/main/java/forestry/core/commands/CommandPlugins.java b/src/main/java/forestry/core/commands/CommandPlugins.java index 80bf02b45..e281c1c1a 100644 --- a/src/main/java/forestry/core/commands/CommandPlugins.java +++ b/src/main/java/forestry/core/commands/CommandPlugins.java @@ -13,6 +13,7 @@ package forestry.core.commands; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.text.TextFormatting; import forestry.core.utils.Translator; @@ -32,7 +33,7 @@ public class CommandPlugins extends SubCommand { } @Override - public void processSubCommand(ICommandSender sender, String[] args) throws WrongUsageException { + public void executeSubCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length == 0) { listPluginsForSender(sender); } else { @@ -75,7 +76,7 @@ public class CommandPlugins extends SubCommand { } @Override - public void processSubCommand(ICommandSender sender, String[] args) throws CommandException { + public void executeSubCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length == 1) { listPluginInfoForSender(sender, args[0]); } else { diff --git a/src/main/java/forestry/core/commands/CommandSaveStats.java b/src/main/java/forestry/core/commands/CommandSaveStats.java index 2facf0c55..be44aa0c2 100644 --- a/src/main/java/forestry/core/commands/CommandSaveStats.java +++ b/src/main/java/forestry/core/commands/CommandSaveStats.java @@ -22,8 +22,10 @@ import java.util.Date; import java.util.List; import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.command.PlayerNotFoundException; +import net.minecraft.command.WrongUsageException; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; @@ -59,26 +61,27 @@ public final class CommandSaveStats extends SubCommand { this.modeHelper = modeHelper; } + @Override - public List addTabCompletionOptions(ICommandSender sender, String[] parameters, BlockPos pos) { - return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers()); + public List getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) { + return CommandHelpers.getListOfStringsMatchingLastWord(args, server.getAllUsernames()); } @Override - public void processSubCommand(ICommandSender sender, String[] args) throws PlayerNotFoundException { + public void executeSubCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length > 1) { printHelp(sender); return; } String newLine = System.getProperty("line.separator"); - World world = CommandHelpers.getWorld(sender, this); + World world = sender.getEntityWorld(); EntityPlayerMP player; if (args.length > 0) { - player = CommandBase.getPlayer((MinecraftServer) sender, (ICommandSender) args[0], null); + player = CommandBase.getPlayer(server, sender, args[0]); } else { - player = CommandBase.getPlayer((MinecraftServer) sender, (ICommandSender) sender.getName(), null); + player = CommandBase.getPlayer(server, sender, sender.getName()); } Collection statistics = new ArrayList<>(); diff --git a/src/main/java/forestry/core/entities/EntityFXColoredDropParticle.java b/src/main/java/forestry/core/entities/EntityFXColoredDripParticle.java similarity index 92% rename from src/main/java/forestry/core/entities/EntityFXColoredDropParticle.java rename to src/main/java/forestry/core/entities/EntityFXColoredDripParticle.java index 3ef97e735..d9608685a 100644 --- a/src/main/java/forestry/core/entities/EntityFXColoredDropParticle.java +++ b/src/main/java/forestry/core/entities/EntityFXColoredDripParticle.java @@ -1,90 +1,90 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.entities; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.particle.EntityFX; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.World; - -public class EntityFXColoredDropParticle extends EntityFX { - - /** - * The height of the current bob - */ - private int bobTimer; - - public EntityFXColoredDropParticle(World world, double x, double y, double z, float red, float green, float blue) { - super(world, x, y, z); - this.particleRed = red; - this.particleGreen = green; - this.particleBlue = blue; - - this.setParticleTextureIndex(113); - this.setSize(0.01F, 0.01F); - this.particleGravity = 0.06F; - this.bobTimer = 40; - this.particleMaxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D)); - } - - /** - * Called to update the entity's position/logic. - */ - @Override - public void onUpdate() { - this.prevPosX = this.posX; - this.prevPosY = this.posY; - this.prevPosZ = this.posZ; - - this.ySpeed -= this.particleGravity; - - if (this.bobTimer-- > 0) { - this.xSpeed *= 0.02D; - this.ySpeed *= 0.02D; - this.zSpeed *= 0.02D; - this.setParticleTextureIndex(113); - } else { - this.setParticleTextureIndex(112); - } - - this.moveEntity(this.xSpeed, this.ySpeed, this.zSpeed); - this.xSpeed *= 0.9800000190734863D; - this.ySpeed *= 0.9800000190734863D; - this.zSpeed *= 0.9800000190734863D; - - if (this.particleMaxAge-- <= 0) { - this.setExpired(); - } - - if (this.isCollided) { - this.setParticleTextureIndex(114); - - this.xSpeed *= 0.699999988079071D; - this.zSpeed *= 0.699999988079071D; - } - - IBlockState state = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ))); - Block block = state.getBlock(); - Material material = block.getMaterial(state); - - if (material.isLiquid() || material.isSolid()) { - double d0 = MathHelper.floor_double(this.posY) + 1 - BlockLiquid.getLiquidHeightPercent(block.getMetaFromState(state)); - - if (this.posY < d0) { - this.setExpired(); - } - } - } +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.entities; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.World; + +public class EntityFXColoredDripParticle extends EntityFX { + + /** + * The height of the current bob + */ + private int bobTimer; + + public EntityFXColoredDripParticle(World world, double x, double y, double z, float red, float green, float blue) { + super(world, x, y, z); + this.particleRed = red; + this.particleGreen = green; + this.particleBlue = blue; + + this.setParticleTextureIndex(113); + this.setSize(0.01F, 0.01F); + this.particleGravity = 0.06F; + this.bobTimer = 40; + this.particleMaxAge = (int) (64.0D / (Math.random() * 0.8D + 0.2D)); + } + + /** + * Called to update the entity's position/logic. + */ + @Override + public void onUpdate() { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + this.ySpeed -= this.particleGravity; + + if (this.bobTimer-- > 0) { + this.xSpeed *= 0.02D; + this.ySpeed *= 0.02D; + this.zSpeed *= 0.02D; + this.setParticleTextureIndex(113); + } else { + this.setParticleTextureIndex(112); + } + + this.moveEntity(this.xSpeed, this.ySpeed, this.zSpeed); + this.xSpeed *= 0.9800000190734863D; + this.ySpeed *= 0.9800000190734863D; + this.zSpeed *= 0.9800000190734863D; + + if (this.particleMaxAge-- <= 0) { + this.setExpired(); + } + + if (this.isCollided) { + this.setParticleTextureIndex(114); + + this.xSpeed *= 0.699999988079071D; + this.zSpeed *= 0.699999988079071D; + } + + IBlockState state = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ))); + Block block = state.getBlock(); + Material material = block.getMaterial(state); + + if (material.isLiquid() || material.isSolid()) { + double d0 = MathHelper.floor_double(this.posY) + 1 - BlockLiquid.getLiquidHeightPercent(block.getMetaFromState(state)); + + if (this.posY < d0) { + this.setExpired(); + } + } + } } \ No newline at end of file diff --git a/src/main/java/forestry/core/fluids/BlockForestryFluid.java b/src/main/java/forestry/core/fluids/BlockForestryFluid.java index a5712aa24..978facdc5 100644 --- a/src/main/java/forestry/core/fluids/BlockForestryFluid.java +++ b/src/main/java/forestry/core/fluids/BlockForestryFluid.java @@ -14,14 +14,18 @@ import java.awt.Color; import java.util.Random; import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.particle.EntityFX; import net.minecraft.init.Blocks; +import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -34,7 +38,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import forestry.api.core.IItemModelRegister; import forestry.api.core.IModelManager; -import forestry.core.entities.EntityFXColoredDropParticle; +import forestry.core.entities.EntityFXColoredDripParticle; import forestry.core.utils.BlockUtil; public class BlockForestryFluid extends BlockFluidClassic implements IItemModelRegister { @@ -52,7 +56,7 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR } private BlockForestryFluid(Fluid fluid, int flammability, boolean flammable, Color color) { - super(fluid, Material.water); + super(fluid, Material.WATER); setDensity(fluid.getDensity()); @@ -72,22 +76,61 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR return FluidRegistry.getFluid(fluidName); } + /** + * Copied from {@link BlockLiquid#randomDisplayTick(IBlockState, World, BlockPos, Random)} + * and modified to have colored particles. + */ @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand) { - if (rand.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(world, new BlockPos(pos.getX(), pos.getY() - 1, pos.getZ())) && !world.getBlockState(new BlockPos(pos.getX(), pos.getY() - 2, pos.getZ())).getBlock().getMaterial().blocksMovement()) { - double px = pos.getX() + rand.nextFloat(); - double py = pos.getY() - 1.05D; - double pz = pos.getZ() + rand.nextFloat(); + public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { + double d0 = (double) pos.getX(); + double d1 = (double) pos.getY(); + double d2 = (double) pos.getZ(); - EntityFX fx = new EntityFXColoredDropParticle(world, px, py, pz, color.getRed(), color.getGreen(), color.getBlue()); - FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx); + if (this.blockMaterial == Material.WATER) { + int i = stateIn.getValue(LEVEL); + + if (i > 0 && i < 8) { + if (rand.nextInt(64) == 0) { + worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, SoundEvents.BLOCK_WATER_AMBIENT, SoundCategory.BLOCKS, rand.nextFloat() * 0.25F + 0.75F, rand.nextFloat() + 0.5F, false); + } + } else if (rand.nextInt(10) == 0) { + worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + (double) rand.nextFloat(), d1 + (double) rand.nextFloat(), d2 + (double) rand.nextFloat(), 0.0D, 0.0D, 0.0D); + } + } + + if (this.blockMaterial == Material.LAVA && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && !worldIn.getBlockState(pos.up()).isOpaqueCube()) { + if (rand.nextInt(100) == 0) { + double d8 = d0 + (double) rand.nextFloat(); + double d4 = d1 + stateIn.getBoundingBox(worldIn, pos).maxY; + double d6 = d2 + (double) rand.nextFloat(); + worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D); + worldIn.playSound(d8, d4, d6, SoundEvents.BLOCK_LAVA_POP, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false); + } + + if (rand.nextInt(200) == 0) { + worldIn.playSound(d0, d1, d2, SoundEvents.BLOCK_LAVA_AMBIENT, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false); + } + } + + if (rand.nextInt(10) == 0 && worldIn.getBlockState(pos.down()).isFullyOpaque()) { + Material material = worldIn.getBlockState(pos.down(2)).getMaterial(); + + if (!material.blocksMovement() && !material.isLiquid()) { + double px = d0 + (double) rand.nextFloat(); + double py = d1 - 1.05D; + double pz = d2 + (double) rand.nextFloat(); + + EntityFX fx = new EntityFXColoredDripParticle(worldIn, px, py, pz, color.getRed(), color.getGreen(), color.getBlue()); + FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx); + } } } @Override public boolean canDisplace(IBlockAccess world, BlockPos pos) { - if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) { + IBlockState blockState = world.getBlockState(pos); + if (blockState.getBlock().getMaterial(blockState).isLiquid()) { return false; } return super.canDisplace(world, pos); @@ -95,7 +138,8 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR @Override public boolean displaceIfPossible(World world, BlockPos pos) { - if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) { + IBlockState blockState = world.getBlockState(pos); + if (blockState.getBlock().getMaterial(blockState).isLiquid()) { return false; } return super.displaceIfPossible(world, pos); @@ -130,13 +174,13 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR } @Override - public Material getMaterial() { + public Material getMaterial(IBlockState state) { // Fahrenheit 451 = 505.928 Kelvin // The temperature at which book-paper catches fire, and burns. if (temperature > 505) { - return Material.lava; + return Material.LAVA; } else { - return super.getMaterial(); + return super.getMaterial(state); } } @@ -155,21 +199,22 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR int z = pos.getZ(); // Start fires if the fluid is lava-like - if (getMaterial() == Material.lava) { + if (getMaterial(state) == Material.LAVA) { int rangeUp = rand.nextInt(3); for (int i = 0; i < rangeUp; ++i) { x += rand.nextInt(3) - 1; ++y; z += rand.nextInt(3) - 1; - Block block = world.getBlockState(new BlockPos(x, y, z)).getBlock(); + IBlockState blockState = world.getBlockState(new BlockPos(x, y, z)); + Block block = blockState.getBlock(); - if (block.getMaterial() == Material.air) { + if (block.getMaterial(blockState) == Material.AIR) { if (isNeighborFlammable(world, x, y, z)) { world.setBlockState(new BlockPos(x, y, z), Blocks.FIRE.getDefaultState()); return; } - } else if (block.getMaterial().blocksMovement()) { + } else if (block.getMaterial(blockState).blocksMovement()) { return; } } diff --git a/src/main/java/forestry/core/genetics/mutations/MutationConditionHumidity.java b/src/main/java/forestry/core/genetics/mutations/MutationConditionHumidity.java index 66583704a..df30c7c37 100644 --- a/src/main/java/forestry/core/genetics/mutations/MutationConditionHumidity.java +++ b/src/main/java/forestry/core/genetics/mutations/MutationConditionHumidity.java @@ -12,7 +12,6 @@ package forestry.core.genetics.mutations; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; import forestry.api.core.EnumHumidity; import forestry.api.core.ForestryAPI; @@ -33,7 +32,6 @@ public class MutationConditionHumidity implements IMutationCondition { @Override public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) { - BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenerator(pos); EnumHumidity biomeHumidity = EnumHumidity.getFromValue(ForestryAPI.climateManager.getHumidity(world, pos)); if (biomeHumidity.ordinal() < minHumidity.ordinal() || biomeHumidity.ordinal() > maxHumidity.ordinal()) { diff --git a/src/main/java/forestry/core/genetics/mutations/MutationConditionTemperature.java b/src/main/java/forestry/core/genetics/mutations/MutationConditionTemperature.java index c819d2646..edc83b05d 100644 --- a/src/main/java/forestry/core/genetics/mutations/MutationConditionTemperature.java +++ b/src/main/java/forestry/core/genetics/mutations/MutationConditionTemperature.java @@ -33,7 +33,7 @@ public class MutationConditionTemperature implements IMutationCondition { @Override public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) { - BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenerator(pos); + BiomeGenBase biome = world.getBiomeProvider().getBiomeGenerator(pos); EnumTemperature biomeTemperature = EnumTemperature.getFromBiome(biome, world, pos); if (biomeTemperature.ordinal() < minTemperature.ordinal() || biomeTemperature.ordinal() > maxTemperature.ordinal()) { diff --git a/src/main/java/forestry/core/gui/ContainerLiquidTanksSocketed.java b/src/main/java/forestry/core/gui/ContainerLiquidTanksSocketed.java index 8c3d6aa3a..7bfa33d73 100644 --- a/src/main/java/forestry/core/gui/ContainerLiquidTanksSocketed.java +++ b/src/main/java/forestry/core/gui/ContainerLiquidTanksSocketed.java @@ -47,7 +47,7 @@ public abstract class ContainerLiquidTanksSocketed onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { + if (!worldIn.isRemote) { + itemStackIn.stackSize--; + EntityItem entity = new EntityItem(worldIn, playerIn.posX, playerIn.posY, playerIn.posZ, assembled.copy()); + worldIn.spawnEntityInWorld(entity); } - return itemstack; + return ActionResult.newResult(EnumActionResult.SUCCESS, itemStackIn); } } diff --git a/src/main/java/forestry/core/items/ItemForestryBonemeal.java b/src/main/java/forestry/core/items/ItemFertilizer.java similarity index 58% rename from src/main/java/forestry/core/items/ItemForestryBonemeal.java rename to src/main/java/forestry/core/items/ItemFertilizer.java index bda98c33e..d310816a0 100644 --- a/src/main/java/forestry/core/items/ItemForestryBonemeal.java +++ b/src/main/java/forestry/core/items/ItemFertilizer.java @@ -1,32 +1,40 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.core.items; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemDye; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; - -public class ItemForestryBonemeal extends ItemForestry { - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { - if (ItemDye.applyBonemeal(stack, world, pos, player)) { - if (!world.isRemote) { - world.playAuxSFX(2005, pos, 0); - } - - return true; - } - return super.onItemUse(stack, player, world, pos, side, hitX, hitY, hitZ); - } -} +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.items; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemDye; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class ItemFertilizer extends ItemForestry { + + @Override + public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack)) { + return EnumActionResult.FAIL; + } + + if (ItemDye.applyBonemeal(stack, worldIn, pos, playerIn)) { + if (!worldIn.isRemote) { + worldIn.playAuxSFX(2005, pos, 0); + } + + return EnumActionResult.SUCCESS; + } + + return EnumActionResult.PASS; + } +} diff --git a/src/main/java/forestry/core/items/ItemLiquidContainerDrinkable.java b/src/main/java/forestry/core/items/ItemLiquidContainerDrinkable.java index 93e97e313..d468b3b63 100644 --- a/src/main/java/forestry/core/items/ItemLiquidContainerDrinkable.java +++ b/src/main/java/forestry/core/items/ItemLiquidContainerDrinkable.java @@ -1,9 +1,17 @@ package forestry.core.items; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.init.SoundEvents; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; import net.minecraft.util.FoodStats; +import net.minecraft.util.SoundCategory; import net.minecraft.world.World; public class ItemLiquidContainerDrinkable extends ItemLiquidContainer { @@ -15,11 +23,22 @@ public class ItemLiquidContainerDrinkable extends ItemLiquidContainer { } @Override - public ItemStack onItemUseFinish(ItemStack stack, World world, EntityPlayer player) { - stack.stackSize--; - FoodStats foodStats = player.getFoodStats(); - foodStats.addStats(properties.getHealAmount(), properties.getSaturationModifier()); - world.playSoundAtEntity(player, "random.burp", 0.5F, world.rand.nextFloat() * 0.1F + 0.9F); + public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) { + if (entityLiving instanceof EntityPlayer && !((EntityPlayer)entityLiving).capabilities.isCreativeMode) { + EntityPlayer player = (EntityPlayer) entityLiving; + if (!player.capabilities.isCreativeMode) { + --stack.stackSize; + } + + if (!worldIn.isRemote) { + FoodStats foodStats = player.getFoodStats(); + foodStats.addStats(properties.getHealAmount(), properties.getSaturationModifier()); + worldIn.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F); + } + + player.addStat(StatList.getObjectUseStats(this)); + } + return stack; } @@ -34,10 +53,12 @@ public class ItemLiquidContainerDrinkable extends ItemLiquidContainer { } @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (entityplayer.canEat(false)) { - entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack)); + public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { + if (playerIn.canEat(false)) { + playerIn.setActiveHand(hand); + return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn); + } else { + return new ActionResult<>(EnumActionResult.FAIL, itemStackIn); } - return itemstack; } } diff --git a/src/main/java/forestry/core/items/ItemRegistryCore.java b/src/main/java/forestry/core/items/ItemRegistryCore.java index 3cad50545..325ea2e0c 100644 --- a/src/main/java/forestry/core/items/ItemRegistryCore.java +++ b/src/main/java/forestry/core/items/ItemRegistryCore.java @@ -21,7 +21,7 @@ import forestry.core.genetics.ItemResearchNote; public class ItemRegistryCore extends ItemRegistry { /* Fertilizer */ public final ItemForestry fertilizerBio; - public final ItemForestryBonemeal fertilizerCompound; + public final ItemFertilizer fertilizerCompound; /* Gems */ public final ItemForestry apatite; @@ -87,7 +87,7 @@ public class ItemRegistryCore extends ItemRegistry { public ItemRegistryCore() { fertilizerBio = registerItem(new ItemForestry(), "fertilizerBio"); - fertilizerCompound = registerItem(new ItemForestryBonemeal(), "fertilizerCompound"); + fertilizerCompound = registerItem(new ItemFertilizer(), "fertilizerCompound"); apatite = registerItem(new ItemForestry(), "apatite"); OreDictionary.registerOre("gemApatite", apatite); diff --git a/src/main/java/forestry/core/items/ItemWrench.java b/src/main/java/forestry/core/items/ItemWrench.java index 527339a30..df249f46e 100755 --- a/src/main/java/forestry/core/items/ItemWrench.java +++ b/src/main/java/forestry/core/items/ItemWrench.java @@ -11,34 +11,32 @@ package forestry.core.items; import net.minecraft.block.Block; -import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.common.Optional; - -import buildcraft.api.tools.IToolWrench; - -@Optional.Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|tools") -public class ItemWrench extends ItemForestry implements IToolWrench { +//@Optional.Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|tools") +public class ItemWrench extends ItemForestry {//implements IToolWrench { public ItemWrench() { setHarvestLevel("wrench", 0); } - + @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { + public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { Block block = world.getBlockState(pos).getBlock(); if (block.rotateBlock(world, pos, side)) { - player.swingItem(); - return !world.isRemote; + player.swingArm(hand); + return EnumActionResult.SUCCESS; } - return false; + return EnumActionResult.FAIL; } + /* @Override public boolean canWrench(EntityPlayer player, BlockPos pos) { return true; @@ -56,4 +54,5 @@ public class ItemWrench extends ItemForestry implements IToolWrench { @Override public void wrenchUsed(EntityPlayer entityPlayer, Entity entity) { } + */ } diff --git a/src/main/java/forestry/core/models/ModelManager.java b/src/main/java/forestry/core/models/ModelManager.java index c22f7e2ab..1c49862e8 100644 --- a/src/main/java/forestry/core/models/ModelManager.java +++ b/src/main/java/forestry/core/models/ModelManager.java @@ -103,10 +103,6 @@ public class ModelManager implements IModelManager { */ @SideOnly(Side.CLIENT) public static void registerModels() { - Minecraft minecraft = Minecraft.getMinecraft(); - BlockColors blockColors = minecraft.getBlockColors(); - ItemColors itemColors = minecraft.getItemColors(); - for (Block block : GameData.getBlockRegistry()) { if (block instanceof IItemModelRegister) { ((IItemModelRegister) block).registerModel(Item.getItemFromBlock(block), getInstance()); @@ -114,14 +110,30 @@ public class ModelManager implements IModelManager { if (block instanceof IStateMapperRegister) { ((IStateMapperRegister) block).registerStateMapper(); } - if (block instanceof IBlockColor) { - blockColors.registerBlockColorHandler((IBlockColor) block, block); - } } for (Item item : GameData.getItemRegistry()) { if (item instanceof IItemModelRegister) { ((IItemModelRegister) item).registerModel(item, getInstance()); } + } + } + + /** + * TODO: keep lists of each type of block and item to be registered. + * Iterating over GameData.getBlockRegistry() and GameData.getItemRegistry() will be VERY slow on a big pack. + */ + @SideOnly(Side.CLIENT) + public static void registerItemAndBlockColors() { + Minecraft minecraft = Minecraft.getMinecraft(); + BlockColors blockColors = minecraft.getBlockColors(); + ItemColors itemColors = minecraft.getItemColors(); + + for (Block block : GameData.getBlockRegistry()) { + if (block instanceof IBlockColor) { + blockColors.registerBlockColorHandler((IBlockColor) block, block); + } + } + for (Item item : GameData.getItemRegistry()) { if (item instanceof IItemColor) { itemColors.registerItemColorHandler((IItemColor) item, item); } diff --git a/src/main/java/forestry/core/multiblock/MultiblockUtil.java b/src/main/java/forestry/core/multiblock/MultiblockUtil.java index e0e84cd40..637c244c3 100644 --- a/src/main/java/forestry/core/multiblock/MultiblockUtil.java +++ b/src/main/java/forestry/core/multiblock/MultiblockUtil.java @@ -43,7 +43,7 @@ public class MultiblockUtil { List neighborParts = new ArrayList<>(); IChunkProvider chunkProvider = world.getChunkProvider(); for (BlockPos neighbor : neighbors) { - if (!chunkProvider.chunkExists(neighbor.getX() >> 4, neighbor.getZ() >> 4)) { + if (chunkProvider.getLoadedChunk(neighbor.getX() >> 4, neighbor.getZ() >> 4) == null) { // Chunk not loaded, skip it. continue; } diff --git a/src/main/java/forestry/core/multiblock/MultiblockWorldRegistry.java b/src/main/java/forestry/core/multiblock/MultiblockWorldRegistry.java index 657a67091..536972baa 100644 --- a/src/main/java/forestry/core/multiblock/MultiblockWorldRegistry.java +++ b/src/main/java/forestry/core/multiblock/MultiblockWorldRegistry.java @@ -116,7 +116,7 @@ public class MultiblockWorldRegistry { // These are blocks that exist in a valid chunk and require a controller for (IMultiblockComponent orphan : orphansToProcess) { coord = orphan.getCoordinates(); - if (!chunkProvider.chunkExists(coord.getX() >> 4, coord.getZ() >> 4)) { + if (chunkProvider.getLoadedChunk(coord.getX() >> 4, coord.getZ() >> 4) == null) { continue; } @@ -312,7 +312,7 @@ public class MultiblockWorldRegistry { public void onPartAdded(IMultiblockComponent part) { BlockPos worldLocation = part.getCoordinates(); - if (!worldObj.getChunkProvider().chunkExists(worldLocation.getX() >> 4, worldLocation.getZ() >> 4)) { + if (worldObj.getChunkProvider().getLoadedChunk(worldLocation.getX() >> 4, worldLocation.getZ() >> 4) == null) { // Part goes into the waiting-for-chunk-load list Set partSet; long chunkHash = ChunkCoordIntPair.chunkXZ2Int(worldLocation.getX() >> 4, worldLocation.getZ() >> 4); diff --git a/src/main/java/forestry/core/network/PacketHandler.java b/src/main/java/forestry/core/network/PacketHandler.java index a9c5a7ff9..1f64bab2f 100644 --- a/src/main/java/forestry/core/network/PacketHandler.java +++ b/src/main/java/forestry/core/network/PacketHandler.java @@ -42,14 +42,14 @@ public class PacketHandler { @SubscribeEvent public void onPacket(ServerCustomPacketEvent event) { - DataInputStreamForestry data = getStream(event.packet); - EntityPlayerMP player = ((NetHandlerPlayServer) event.handler).playerEntity; + DataInputStreamForestry data = getStream(event.getPacket()); + EntityPlayerMP player = ((NetHandlerPlayServer) event.getHandler()).playerEntity; try { byte packetIdOrdinal = data.readByte(); PacketIdServer packetId = PacketIdServer.VALUES[packetIdOrdinal]; IForestryPacketServer packetHandler = packetId.getPacketHandler(); - checkThreadAndEnqueue(packetHandler, data, player, player.getServerForPlayer()); + checkThreadAndEnqueue(packetHandler, data, player, player.getServerWorld()); } catch (IOException e) { Log.error("Failed to read packet.", e); } @@ -57,7 +57,7 @@ public class PacketHandler { @SubscribeEvent public void onPacket(ClientCustomPacketEvent event) { - DataInputStreamForestry data = getStream(event.packet); + DataInputStreamForestry data = getStream(event.getPacket()); EntityPlayer player = Proxies.common.getPlayer(); try { diff --git a/src/main/java/forestry/core/proxy/ProxyRender.java b/src/main/java/forestry/core/proxy/ProxyRender.java index 1dbd7e82a..9292f1f56 100644 --- a/src/main/java/forestry/core/proxy/ProxyRender.java +++ b/src/main/java/forestry/core/proxy/ProxyRender.java @@ -106,6 +106,9 @@ public class ProxyRender { public void registerModels() { } + + public void registerItemAndBlockColors() { + } // public IAnimationStateMachine loadAnimationState(ResourceLocation location, ImmutableMap parameters){ // return null; diff --git a/src/main/java/forestry/core/proxy/ProxyRenderClient.java b/src/main/java/forestry/core/proxy/ProxyRenderClient.java index 4c1e60efa..b0f7c04ec 100644 --- a/src/main/java/forestry/core/proxy/ProxyRenderClient.java +++ b/src/main/java/forestry/core/proxy/ProxyRenderClient.java @@ -192,8 +192,13 @@ public class ProxyRenderClient extends ProxyRender { public void registerModels() { ModelManager.registerModels(); } - -// @Override + + @Override + public void registerItemAndBlockColors() { + ModelManager.registerItemAndBlockColors(); + } + + // @Override // public IAnimationStateMachine loadAnimationState(ResourceLocation location, ImmutableMap parameters){ // return Animation.INSTANCE.load(location, parameters); // } diff --git a/src/main/java/forestry/core/render/ForestryStateMapper.java b/src/main/java/forestry/core/render/ForestryStateMapper.java index 32bed4e0c..15761dfcb 100644 --- a/src/main/java/forestry/core/render/ForestryStateMapper.java +++ b/src/main/java/forestry/core/render/ForestryStateMapper.java @@ -15,10 +15,10 @@ public abstract class ForestryStateMapper implements IStateMapper { protected Map mapStateModelLocations = Maps.newLinkedHashMap(); @SuppressWarnings("unchecked") - public String getPropertyString(Map map) { + public String getPropertyString(Map, Comparable> map) { StringBuilder stringbuilder = new StringBuilder(); - for (Entry entry : map.entrySet()) { + for (Entry, Comparable> entry : map.entrySet()) { if (stringbuilder.length() != 0) { stringbuilder.append(","); } diff --git a/src/main/java/forestry/core/render/MachineStateMapper.java b/src/main/java/forestry/core/render/MachineStateMapper.java index d35f87a4c..8c16579f8 100644 --- a/src/main/java/forestry/core/render/MachineStateMapper.java +++ b/src/main/java/forestry/core/render/MachineStateMapper.java @@ -44,8 +44,8 @@ public class MachineStateMapper & IBlockType & IStringSerializ continue; } IBlockState state = block.getDefaultState().withProperty(META, type).withProperty(FACE, facing); - LinkedHashMap linkedhashmap = Maps.newLinkedHashMap(state.getProperties()); - ResourceLocation blockLocation = Block.blockRegistry.getNameForObject(block); + LinkedHashMap, Comparable> linkedhashmap = Maps.newLinkedHashMap(state.getProperties()); + ResourceLocation blockLocation = Block.REGISTRY.getNameForObject(block); String s = String.format("%s:%s", blockLocation.getResourceDomain(), blockLocation.getResourcePath() + "_" + META.getName((T) linkedhashmap.remove(META))); mapStateModelLocations.put(state, new ModelResourceLocation(s, getPropertyString(linkedhashmap))); } diff --git a/src/main/java/forestry/core/render/RenderAnalyzer.java b/src/main/java/forestry/core/render/RenderAnalyzer.java index 18aea58cb..268695378 100755 --- a/src/main/java/forestry/core/render/RenderAnalyzer.java +++ b/src/main/java/forestry/core/render/RenderAnalyzer.java @@ -66,7 +66,7 @@ public class RenderAnalyzer extends TileEntitySpecialRenderer { } RenderManager rendermanager = Proxies.common.getClientInstance().getRenderManager(); - rendermanager.renderEntityWithPosYaw(dummyEntityItem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + rendermanager.doRenderEntity(dummyEntityItem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F, false); GlStateManager.popMatrix(); } diff --git a/src/main/java/forestry/core/tiles/TileForestry.java b/src/main/java/forestry/core/tiles/TileForestry.java index 95d0e7636..0c6396079 100644 --- a/src/main/java/forestry/core/tiles/TileForestry.java +++ b/src/main/java/forestry/core/tiles/TileForestry.java @@ -12,7 +12,6 @@ package forestry.core.tiles; import javax.annotation.Nonnull; import java.io.IOException; -import java.util.Collection; import java.util.Random; import net.minecraft.block.Block; @@ -31,7 +30,6 @@ import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.fml.common.Optional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.wrapper.SidedInvWrapper; @@ -52,13 +50,8 @@ import forestry.core.network.packets.PacketTileStream; import forestry.core.proxy.Proxies; import forestry.core.utils.BlockUtil; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.ITriggerExternal; -import buildcraft.api.statements.ITriggerInternal; -import buildcraft.api.statements.ITriggerProvider; - -@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") -public abstract class TileForestry extends TileEntity implements IStreamable, IErrorLogicSource, ITriggerProvider, ISidedInventory, IFilterSlotDelegate, IRestrictedAccess, ITitled, ILocatable, IGuiHandlerTile, ITickable { +//@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") +public abstract class TileForestry extends TileEntity implements IStreamable, IErrorLogicSource, ISidedInventory, IFilterSlotDelegate, IRestrictedAccess, ITitled, ILocatable, IGuiHandlerTile, ITickable { private static final EnumFacing[] forgeDirections = EnumFacing.values(); private static final Random rand = new Random(); @@ -199,17 +192,18 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE } /* ITriggerProvider */ - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getInternalTriggers(IStatementContainer container) { - return null; - } - - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { - return null; - } + // TODO: buildcraft for 1.9 +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getInternalTriggers(IStatementContainer container) { +// return null; +// } +// +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { +// return null; +// } // / REDSTONE INFO protected boolean isRedstoneActivated() { diff --git a/src/main/java/forestry/core/tiles/TilePowered.java b/src/main/java/forestry/core/tiles/TilePowered.java index 95b8b9810..8629cdbfa 100644 --- a/src/main/java/forestry/core/tiles/TilePowered.java +++ b/src/main/java/forestry/core/tiles/TilePowered.java @@ -15,8 +15,6 @@ import java.io.IOException; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; -import net.minecraftforge.fml.common.Optional; - import forestry.api.core.IErrorLogic; import forestry.core.circuits.ISpeedUpgradable; import forestry.core.config.Config; @@ -27,11 +25,10 @@ import forestry.core.network.IStreamableGui; import forestry.core.render.TankRenderInfo; import forestry.energy.EnergyManager; -import buildcraft.api.tiles.IHasWork; import cofh.api.energy.IEnergyReceiver; -@Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraftAPI|tiles") -public abstract class TilePowered extends TileBase implements IRenderableTile, IEnergyReceiver, IPowerHandler, IHasWork, ISpeedUpgradable, IStreamableGui { +//@Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraftAPI|tiles") +public abstract class TilePowered extends TileBase implements IRenderableTile, IEnergyReceiver, IPowerHandler, ISpeedUpgradable, IStreamableGui { private static final int WORK_TICK_INTERVAL = 5; // one Forestry work tick happens every WORK_TICK_INTERVAL game ticks private final EnergyManager energyManager; @@ -89,7 +86,8 @@ public abstract class TilePowered extends TileBase implements IRenderableTile, I return false; } - @Override + // TODO: buildcraft for 1.9 +// @Override public abstract boolean hasWork(); @Override diff --git a/src/main/java/forestry/core/triggers/Trigger.java b/src/main/java/forestry/core/triggers/Trigger.java index eb0ef4715..b515d2117 100755 --- a/src/main/java/forestry/core/triggers/Trigger.java +++ b/src/main/java/forestry/core/triggers/Trigger.java @@ -10,74 +10,62 @@ ******************************************************************************/ package forestry.core.triggers; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; +// TODO: buildcraft for 1.9 +public abstract class Trigger {//implements ITriggerExternal { -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +// private final String uid; +// private final String localization; -import forestry.core.render.TextureManager; -import forestry.core.utils.Translator; - -import buildcraft.api.statements.IStatement; -import buildcraft.api.statements.IStatementParameter; -import buildcraft.api.statements.ITriggerExternal; -import buildcraft.api.statements.StatementManager; - -public abstract class Trigger implements ITriggerExternal { - - private final String uid; - private final String localization; - - protected Trigger(String uid) { - this(uid, uid); - } - - protected Trigger(String uid, String localization) { - this.uid = "forestry:" + uid; - this.localization = localization; - StatementManager.registerStatement(this); - } - - @Override - public String getUniqueTag() { - return uid; - } - - @Override - public String getDescription() { - return Translator.translateToLocal("for.trigger." + localization); - } - - @Override - public IStatementParameter createParameter(int index) { - return null; - } - - @Override - public int maxParameters() { - return 0; - } - - @Override - public int minParameters() { - return 0; - } - - @SideOnly(Side.CLIENT) - private TextureAtlasSprite icon; - - @SideOnly(Side.CLIENT) - public void registerSprites() { - icon = TextureManager.registerSprite("triggers/" + localization); - } - - @Override - public TextureAtlasSprite getGuiSprite() { - return icon; - } - - @Override - public IStatement rotateLeft() { - return this; - } +// protected Trigger(String uid) { +// this(uid, uid); +// } +// +// protected Trigger(String uid, String localization) { +// this.uid = "forestry:" + uid; +// this.localization = localization; +// StatementManager.registerStatement(this); +// } +// +// @Override +// public String getUniqueTag() { +// return uid; +// } +// +// @Override +// public String getDescription() { +// return Translator.translateToLocal("for.trigger." + localization); +// } +// +// @Override +// public IStatementParameter createParameter(int index) { +// return null; +// } +// +// @Override +// public int maxParameters() { +// return 0; +// } +// +// @Override +// public int minParameters() { +// return 0; +// } +// +// @SideOnly(Side.CLIENT) +// private TextureAtlasSprite icon; +// +// @SideOnly(Side.CLIENT) +// public void registerSprites() { +// icon = TextureManager.registerSprite("triggers/" + localization); +// } +// +// @Override +// public TextureAtlasSprite getGuiSprite() { +// return icon; +// } +// +// @Override +// public IStatement rotateLeft() { +// return this; +// } } diff --git a/src/main/java/forestry/core/utils/InventoryUtil.java b/src/main/java/forestry/core/utils/InventoryUtil.java index 55886ae74..4ecd660c5 100644 --- a/src/main/java/forestry/core/utils/InventoryUtil.java +++ b/src/main/java/forestry/core/utils/InventoryUtil.java @@ -10,11 +10,7 @@ ******************************************************************************/ package forestry.core.utils; -import java.util.AbstractMap; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; -import java.util.Map; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -23,13 +19,11 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; +import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.fml.common.Optional; import net.minecraftforge.oredict.OreDictionary; @@ -41,13 +35,10 @@ import forestry.core.inventory.filters.StandardStackFilters; import forestry.core.inventory.iterators.IExtInvSlot; import forestry.core.inventory.iterators.InventoryIterator; import forestry.core.inventory.manipulators.InventoryManipulator; -import forestry.core.inventory.wrappers.InventoryCopy; import forestry.core.inventory.wrappers.SidedInventoryMapper; import forestry.core.tiles.AdjacentTileCache; import forestry.plugins.ForestryPluginUids; -import buildcraft.api.transport.IPipeTile; - public abstract class InventoryUtil { public static IInventory getInventory(IInventory inv, EnumFacing side) { @@ -286,42 +277,43 @@ public abstract class InventoryUtil { return false; } + //TODO Buildcraft for 1.9 @Optional.Method(modid = "BuildCraftAPI|transport") private static boolean internal_moveOneItemToPipe(IInventory source, AdjacentTileCache tileCache, EnumFacing[] directions) { - IInventory invClone = new InventoryCopy(source); - ItemStack stackToMove = removeOneItem(invClone); - if (stackToMove == null) { - return false; - } - if (stackToMove.stackSize <= 0) { - return false; - } - - List> pipes = new ArrayList<>(); - boolean foundPipe = false; - for (EnumFacing side : directions) { - TileEntity tile = tileCache.getTileOnSide(side); - if (tile instanceof IPipeTile) { - IPipeTile pipe = (IPipeTile) tile; - if (pipe.getPipeType() == IPipeTile.PipeType.ITEM && pipe.isPipeConnected(side.getOpposite())) { - pipes.add(new AbstractMap.SimpleEntry<>(side, pipe)); - foundPipe = true; - } - } - } - - if (!foundPipe) { - return false; - } - - int choice = tileCache.getSource().getWorld().rand.nextInt(pipes.size()); - Map.Entry pipe = pipes.get(choice); - if (pipe.getValue().injectItem(stackToMove, false, pipe.getKey().getOpposite(), null) > 0) { - if (removeOneItem(source, stackToMove) != null) { - pipe.getValue().injectItem(stackToMove, true, pipe.getKey().getOpposite(), null); - return true; - } - } +// IInventory invClone = new InventoryCopy(source); +// ItemStack stackToMove = removeOneItem(invClone); +// if (stackToMove == null) { +// return false; +// } +// if (stackToMove.stackSize <= 0) { +// return false; +// } +// +// List> pipes = new ArrayList<>(); +// boolean foundPipe = false; +// for (EnumFacing side : directions) { +// TileEntity tile = tileCache.getTileOnSide(side); +// if (tile instanceof IPipeTile) { +// IPipeTile pipe = (IPipeTile) tile; +// if (pipe.getPipeType() == IPipeTile.PipeType.ITEM && pipe.isPipeConnected(side.getOpposite())) { +// pipes.add(new AbstractMap.SimpleEntry<>(side, pipe)); +// foundPipe = true; +// } +// } +// } +// +// if (!foundPipe) { +// return false; +// } +// +// int choice = tileCache.getSource().getWorld().rand.nextInt(pipes.size()); +// Map.Entry pipe = pipes.get(choice); +// if (pipe.getValue().injectItem(stackToMove, false, pipe.getKey().getOpposite(), null) > 0) { +// if (removeOneItem(source, stackToMove) != null) { +// pipe.getValue().injectItem(stackToMove, true, pipe.getKey().getOpposite(), null); +// return true; +// } +// } return false; } @@ -628,19 +620,11 @@ public abstract class InventoryUtil { return; } - ItemStack container = itemstack.getItem().getContainerItem(itemstack); - - if (container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) { - if (player != null) { - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, container)); - } - container = null; - } - + ItemStack container = ForgeHooks.getContainerItem(itemstack); if (container != null) { if (!tryAddStack(stowing, container, slotIndex, 1, true)) { if (!tryAddStack(stowing, container, true) && player != null) { - player.dropPlayerItemWithRandomChoice(container, true); + player.dropItem(container, true); } } } diff --git a/src/main/java/forestry/energy/gui/ContainerGenerator.java b/src/main/java/forestry/energy/gui/ContainerGenerator.java index 980b2b7dc..d7cf3b526 100755 --- a/src/main/java/forestry/energy/gui/ContainerGenerator.java +++ b/src/main/java/forestry/energy/gui/ContainerGenerator.java @@ -34,12 +34,11 @@ public class ContainerGenerator extends ContainerLiquidTanks { } @Override - @SuppressWarnings("unchecked") public void detectAndSendChanges() { super.detectAndSendChanges(); - for (Object crafter : crafters) { - tile.sendGUINetworkData(this, (ICrafting) crafter); + for (ICrafting crafter : listeners) { + tile.sendGUINetworkData(this, crafter); } } } diff --git a/src/main/java/forestry/energy/gui/GuiEngineElectric.java b/src/main/java/forestry/energy/gui/GuiEngineElectric.java index 9e5cdaef8..3c3254a75 100644 --- a/src/main/java/forestry/energy/gui/GuiEngineElectric.java +++ b/src/main/java/forestry/energy/gui/GuiEngineElectric.java @@ -17,6 +17,7 @@ import forestry.core.gui.widgets.SocketWidget; import forestry.core.render.EnumTankLevel; import forestry.energy.tiles.TileEngineElectric; +// TODO: IC2 for 1.9 public class GuiEngineElectric extends GuiEngine { public GuiEngineElectric(InventoryPlayer inventory, TileEngineElectric tile) { @@ -24,23 +25,23 @@ public class GuiEngineElectric extends GuiEngine { public GuiGenerator(InventoryPlayer inventory, TileEuGenerator tile) { @@ -24,14 +25,14 @@ public class GuiGenerator extends GuiForestryTitled 0) { - drawTexturedModalRect(guiLeft + 108, guiTop + 38, 176, 91, progress, 18); - } - } +// @Override +// protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { +// super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); +// +// int progress = inventory.getStoredScaled(49); +// if (progress > 0) { +// drawTexturedModalRect(guiLeft + 108, guiTop + 38, 176, 91, progress, 18); +// } +// } } diff --git a/src/main/java/forestry/energy/inventory/InventoryEngineElectric.java b/src/main/java/forestry/energy/inventory/InventoryEngineElectric.java index 8af78b513..a6514eff2 100644 --- a/src/main/java/forestry/energy/inventory/InventoryEngineElectric.java +++ b/src/main/java/forestry/energy/inventory/InventoryEngineElectric.java @@ -15,8 +15,7 @@ import net.minecraft.item.ItemStack; import forestry.core.inventory.InventoryAdapterTile; import forestry.energy.tiles.TileEngineElectric; -import ic2.api.item.ElectricItem; - +// TODO: IC2 for 1.9 public class InventoryEngineElectric extends InventoryAdapterTile { public static final short SLOT_BATTERY = 0; @@ -26,9 +25,9 @@ public class InventoryEngineElectric extends InventoryAdapterTile 0; - } +// if (slotIndex == SLOT_BATTERY) { +// return ElectricItem.manager.getCharge(itemStack) > 0; +// } return false; } } diff --git a/src/main/java/forestry/energy/tiles/TileEngineClockwork.java b/src/main/java/forestry/energy/tiles/TileEngineClockwork.java index 618c33556..edb26152c 100644 --- a/src/main/java/forestry/energy/tiles/TileEngineClockwork.java +++ b/src/main/java/forestry/energy/tiles/TileEngineClockwork.java @@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.FakePlayer; @@ -41,10 +42,9 @@ public class TileEngineClockwork extends TileEngine { public TileEngineClockwork() { super(null, ENGINE_CLOCKWORK_HEAT_MAX, 10000); } - + @Override - public void openGui(EntityPlayer player) { - + public void openGui(EntityPlayer player, ItemStack heldItem) { if (!(player instanceof EntityPlayerMP)) { return; } diff --git a/src/main/java/forestry/energy/tiles/TileEngineElectric.java b/src/main/java/forestry/energy/tiles/TileEngineElectric.java index 51d221c39..865bf4a5c 100644 --- a/src/main/java/forestry/energy/tiles/TileEngineElectric.java +++ b/src/main/java/forestry/energy/tiles/TileEngineElectric.java @@ -26,7 +26,6 @@ import forestry.api.circuits.ICircuitSocketType; import forestry.api.core.IErrorLogic; import forestry.core.circuits.ISocketable; import forestry.core.config.Constants; -import forestry.core.errors.EnumErrorCode; import forestry.core.inventory.InventoryAdapter; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; @@ -36,10 +35,8 @@ import forestry.core.tiles.TileEngine; import forestry.energy.gui.ContainerEngineElectric; import forestry.energy.gui.GuiEngineElectric; import forestry.energy.inventory.InventoryEngineElectric; -import forestry.plugins.compat.PluginIC2; - -import ic2.api.energy.prefab.BasicSink; +// TODO: IC2 for 1.9 public class TileEngineElectric extends TileEngine implements ISocketable, IInventory, IStreamableGui { protected static class EuConfig { @@ -57,16 +54,16 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets"); private final EuConfig euConfig = new EuConfig(); - private BasicSink ic2EnergySink; +// private BasicSink ic2EnergySink; public TileEngineElectric() { super("engine.tin", Constants.ENGINE_ELECTRIC_HEAT_MAX, 100000); setInternalInventory(new InventoryEngineElectric(this)); - if (PluginIC2.instance.isAvailable()) { - ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3); - } +// if (PluginIC2.instance.isAvailable()) { +// ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3); +// } } // / SAVING / LOADING @@ -74,9 +71,9 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - if (ic2EnergySink != null) { - ic2EnergySink.readFromNBT(nbttagcompound); - } +// if (ic2EnergySink != null) { +// ic2EnergySink.readFromNBT(nbttagcompound); +// } sockets.readFromNBT(nbttagcompound); ItemStack chip = sockets.getStackInSlot(0); @@ -92,26 +89,26 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - if (ic2EnergySink != null) { - ic2EnergySink.writeToNBT(nbttagcompound); - } +// if (ic2EnergySink != null) { +// ic2EnergySink.writeToNBT(nbttagcompound); +// } sockets.writeToNBT(nbttagcompound); } @Override public void onChunkUnload() { - if (ic2EnergySink != null) { - ic2EnergySink.onChunkUnload(); - } +// if (ic2EnergySink != null) { +// ic2EnergySink.onChunkUnload(); +// } super.onChunkUnload(); } @Override public void invalidate() { - if (ic2EnergySink != null) { - ic2EnergySink.invalidate(); - } +// if (ic2EnergySink != null) { +// ic2EnergySink.invalidate(); +// } super.invalidate(); } @@ -159,11 +156,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve IErrorLogic errorLogic = getErrorLogic(); // No work to be done if IC2 is unavailable. - if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) { - return; - } - - ic2EnergySink.update(); +// if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) { +// return; +// } +// +// ic2EnergySink.update(); super.updateServerSide(); @@ -180,8 +177,8 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve return; } - boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle); - errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL); +// boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle); +// errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL); } @Override @@ -193,10 +190,10 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve return; } - if (ic2EnergySink.useEnergy(euConfig.euForCycle)) { - currentOutput = euConfig.rfPerCycle; - energyManager.generateEnergy(euConfig.rfPerCycle); - } +// if (ic2EnergySink.useEnergy(euConfig.euForCycle)) { +// currentOutput = euConfig.rfPerCycle; +// energyManager.generateEnergy(euConfig.rfPerCycle); +// } } @@ -205,22 +202,23 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve return; } - ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3); +// ic2EnergySink.discharge(getStackInSlot(slot), euConfig.euForCycle * 3); } // / STATE INFORMATION @Override protected boolean isBurning() { - return mayBurn() && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle); + // TODO: IC2 for 1.9 + return mayBurn();// && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle); } - public int getStorageScaled(int i) { - if (ic2EnergySink == null) { - return 0; - } - - return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity()); - } +// public int getStorageScaled(int i) { +// if (ic2EnergySink == null) { +// return 0; +// } +// +// return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity()); +// } // / SMP GUI @Override @@ -229,11 +227,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve data.writeVarInt(heat); sockets.writeData(data); energyManager.writeData(data); - final boolean hasIc2EnergySink = (ic2EnergySink != null); - data.writeBoolean(hasIc2EnergySink); - if (hasIc2EnergySink) { - data.writeVarInt((int) ic2EnergySink.getEnergyStored()); - } +// final boolean hasIc2EnergySink = (ic2EnergySink != null); +// data.writeBoolean(hasIc2EnergySink); +// if (hasIc2EnergySink) { +// data.writeVarInt((int) ic2EnergySink.getEnergyStored()); +// } } @Override @@ -242,11 +240,11 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve heat = data.readVarInt(); sockets.readData(data); energyManager.readData(data); - final boolean hasIc2EnergySink = data.readBoolean(); - if (hasIc2EnergySink) { - final int energyStored = data.readVarInt(); - ic2EnergySink.setEnergyStored(energyStored); - } +// final boolean hasIc2EnergySink = data.readBoolean(); +// if (hasIc2EnergySink) { +// final int energyStored = data.readVarInt(); +// ic2EnergySink.setEnergyStored(energyStored); +// } } @Override @@ -265,9 +263,9 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve euConfig.rfPerCycle += rfChange; euConfig.euStorage += storageChange; - if (ic2EnergySink != null) { - ic2EnergySink.setCapacity(euConfig.euStorage); - } +// if (ic2EnergySink != null) { +// ic2EnergySink.setCapacity(euConfig.euStorage); +// } } /* ISocketable */ diff --git a/src/main/java/forestry/energy/tiles/TileEnginePeat.java b/src/main/java/forestry/energy/tiles/TileEnginePeat.java index 4a8a804c7..33438f6b1 100644 --- a/src/main/java/forestry/energy/tiles/TileEnginePeat.java +++ b/src/main/java/forestry/energy/tiles/TileEnginePeat.java @@ -42,8 +42,6 @@ import forestry.energy.gui.GuiEnginePeat; import forestry.energy.inventory.InventoryEnginePeat; import forestry.factory.triggers.FactoryTriggers; -import buildcraft.api.statements.ITriggerExternal; - public class TileEnginePeat extends TileEngine implements ISidedInventory { private Item fuelItem; private int fuelItemMeta; @@ -331,14 +329,15 @@ public class TileEnginePeat extends TileEngine implements ISidedInventory { } /* ITriggerProvider */ - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { - LinkedList res = new LinkedList<>(); - res.add(FactoryTriggers.lowFuel25); - res.add(FactoryTriggers.lowFuel10); - return res; - } + // TODO: buildcraft for 1.9 +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { +// LinkedList res = new LinkedList<>(); +// res.add(FactoryTriggers.lowFuel25); +// res.add(FactoryTriggers.lowFuel10); +// return res; +// } @Override public Object getGui(EntityPlayer player, int data) { diff --git a/src/main/java/forestry/energy/tiles/TileEuGenerator.java b/src/main/java/forestry/energy/tiles/TileEuGenerator.java index e20c9d77f..e6cffbf52 100644 --- a/src/main/java/forestry/energy/tiles/TileEuGenerator.java +++ b/src/main/java/forestry/energy/tiles/TileEuGenerator.java @@ -26,7 +26,6 @@ import net.minecraftforge.fluids.IFluidHandler; import forestry.api.core.IErrorLogic; import forestry.api.fuels.FuelManager; -import forestry.api.fuels.GeneratorFuel; import forestry.core.config.Constants; import forestry.core.errors.EnumErrorCode; import forestry.core.fluids.FluidHelper; @@ -41,10 +40,8 @@ import forestry.core.tiles.TileBase; import forestry.energy.gui.ContainerGenerator; import forestry.energy.gui.GuiGenerator; import forestry.energy.inventory.InventoryGenerator; -import forestry.plugins.compat.PluginIC2; - -import ic2.api.energy.prefab.BasicSource; +// TODO: IC2 for 1.9 public class TileEuGenerator extends TileBase implements ISidedInventory, ILiquidTankTile, IFluidHandler, IRenderableTile { private static final int maxEnergy = 30000; @@ -53,7 +50,7 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui private int tickCount = 0; - private BasicSource ic2EnergySource; +// private BasicSource ic2EnergySource; public TileEuGenerator() { super("generator"); @@ -63,18 +60,18 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY, FuelManager.generatorFuel.keySet()); tankManager = new TankManager(this, resourceTank); - if (PluginIC2.instance.isAvailable()) { - ic2EnergySource = new BasicSource(this, maxEnergy, 1); - } +// if (PluginIC2.instance.isAvailable()) { +// ic2EnergySource = new BasicSource(this, maxEnergy, 1); +// } } @Override public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); - if (ic2EnergySource != null) { - ic2EnergySource.writeToNBT(nbttagcompound); - } +// if (ic2EnergySource != null) { +// ic2EnergySource.writeToNBT(nbttagcompound); +// } tankManager.writeToNBT(nbttagcompound); } @@ -83,9 +80,9 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - if (ic2EnergySource != null) { - ic2EnergySource.readFromNBT(nbttagcompound); - } +// if (ic2EnergySource != null) { +// ic2EnergySource.readFromNBT(nbttagcompound); +// } tankManager.readFromNBT(nbttagcompound); } @@ -104,18 +101,18 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui @Override public void onChunkUnload() { - if (ic2EnergySource != null) { - ic2EnergySource.onChunkUnload(); - } +// if (ic2EnergySource != null) { +// ic2EnergySource.onChunkUnload(); +// } super.onChunkUnload(); } @Override public void invalidate() { - if (ic2EnergySource != null) { - ic2EnergySource.invalidate(); - } +// if (ic2EnergySource != null) { +// ic2EnergySource.invalidate(); +// } super.invalidate(); } @@ -129,25 +126,25 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui IErrorLogic errorLogic = getErrorLogic(); // No work to be done if IC2 is unavailable. - if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NO_ENERGY_NET)) { - return; - } - - ic2EnergySource.update(); - - if (resourceTank.getFluidAmount() > 0) { - GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid()); - if (resourceTank.canDrain(fuel.fuelConsumed) && ic2EnergySource.getFreeCapacity() >= fuel.eu) { - ic2EnergySource.addEnergy(fuel.eu); - this.tickCount++; - - if (tickCount >= fuel.rate) { - tickCount = 0; - resourceTank.drain(fuel.fuelConsumed.amount, true); - } - } - - } +// if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NO_ENERGY_NET)) { +// return; +// } +// +// ic2EnergySource.update(); +// +// if (resourceTank.getFluidAmount() > 0) { +// GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid()); +// if (resourceTank.canDrain(fuel.fuelConsumed) && ic2EnergySource.getFreeCapacity() >= fuel.eu) { +// ic2EnergySource.addEnergy(fuel.eu); +// this.tickCount++; +// +// if (tickCount >= fuel.rate) { +// tickCount = 0; +// resourceTank.drain(fuel.fuelConsumed.amount, true); +// } +// } +// +// } boolean hasFuel = resourceTank.getFluidAmount() > 0; errorLogic.setCondition(!hasFuel, EnumErrorCode.NO_FUEL); @@ -161,13 +158,13 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui return (resourceTank.getFluidAmount() * i) / Constants.PROCESSOR_TANK_CAPACITY; } - public int getStoredScaled(int i) { - if (ic2EnergySource == null) { - return 0; - } - - return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy; - } +// public int getStoredScaled(int i) { +// if (ic2EnergySource == null) { +// return 0; +// } +// +// return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy; +// } @Override public TankRenderInfo getResourceTankInfo() { @@ -182,16 +179,16 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui /* SMP GUI */ public void getGUINetworkData(int i, int j) { if (i == 0) { - if (ic2EnergySource != null) { - ic2EnergySource.setEnergyStored(j); - } +// if (ic2EnergySource != null) { +// ic2EnergySource.setEnergyStored(j); +// } } } public void sendGUINetworkData(Container container, ICrafting iCrafting) { - if (ic2EnergySource != null) { - iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored()); - } +// if (ic2EnergySource != null) { +// iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored()); +// } } /* ILiquidTankTile */ diff --git a/src/main/java/forestry/factory/gui/ContainerFabricator.java b/src/main/java/forestry/factory/gui/ContainerFabricator.java index 41f8c2c7c..74d5ce4f1 100755 --- a/src/main/java/forestry/factory/gui/ContainerFabricator.java +++ b/src/main/java/forestry/factory/gui/ContainerFabricator.java @@ -69,7 +69,7 @@ public class ContainerFabricator extends ContainerLiquidTanks im public void detectAndSendChanges() { super.detectAndSendChanges(); - for (ICrafting crafter : crafters) { + for (ICrafting crafter : listeners) { tile.sendGUINetworkData(this, crafter); } } diff --git a/src/main/java/forestry/factory/gui/ContainerFermenter.java b/src/main/java/forestry/factory/gui/ContainerFermenter.java index c40e5748f..6e61d7d0c 100755 --- a/src/main/java/forestry/factory/gui/ContainerFermenter.java +++ b/src/main/java/forestry/factory/gui/ContainerFermenter.java @@ -42,7 +42,7 @@ public class ContainerFermenter extends ContainerLiquidTanks { public void detectAndSendChanges() { super.detectAndSendChanges(); - for (ICrafting crafter : crafters) { + for (ICrafting crafter : listeners) { tile.sendGUINetworkData(this, crafter); } } diff --git a/src/main/java/forestry/factory/gui/ContainerMoistener.java b/src/main/java/forestry/factory/gui/ContainerMoistener.java index 9526da581..4f084ae43 100755 --- a/src/main/java/forestry/factory/gui/ContainerMoistener.java +++ b/src/main/java/forestry/factory/gui/ContainerMoistener.java @@ -63,7 +63,7 @@ public class ContainerMoistener extends ContainerLiquidTanks impl public void detectAndSendChanges() { super.detectAndSendChanges(); - for (ICrafting crafter : crafters) { + for (ICrafting crafter : listeners) { tile.sendGUINetworkData(this, crafter); } } diff --git a/src/main/java/forestry/factory/gui/ContainerRaintank.java b/src/main/java/forestry/factory/gui/ContainerRaintank.java index 5ace30fda..e61ea0968 100755 --- a/src/main/java/forestry/factory/gui/ContainerRaintank.java +++ b/src/main/java/forestry/factory/gui/ContainerRaintank.java @@ -39,7 +39,7 @@ public class ContainerRaintank extends ContainerLiquidTanks { public void detectAndSendChanges() { super.detectAndSendChanges(); - for (ICrafting crafter : crafters) { + for (ICrafting crafter : listeners) { tile.sendGUINetworkData(this, crafter); } } diff --git a/src/main/java/forestry/factory/tiles/TileBottler.java b/src/main/java/forestry/factory/tiles/TileBottler.java index bd05dda27..0bd4bb65c 100644 --- a/src/main/java/forestry/factory/tiles/TileBottler.java +++ b/src/main/java/forestry/factory/tiles/TileBottler.java @@ -11,21 +11,17 @@ package forestry.factory.tiles; import java.io.IOException; -import java.util.Collection; -import java.util.LinkedList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import net.minecraftforge.fml.common.Optional; import forestry.api.core.IErrorLogic; import forestry.core.config.Constants; @@ -43,9 +39,6 @@ import forestry.factory.gui.ContainerBottler; import forestry.factory.gui.GuiBottler; import forestry.factory.inventory.InventoryBottler; import forestry.factory.recipes.BottlerRecipe; -import forestry.factory.triggers.FactoryTriggers; - -import buildcraft.api.statements.ITriggerExternal; public class TileBottler extends TilePowered implements ISidedInventory, ILiquidTankTile, IFluidHandler { private static final int TICKS_PER_RECIPE_TIME = 5; @@ -197,14 +190,15 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid } /* ITRIGGERPROVIDER */ - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { - LinkedList res = new LinkedList<>(); - res.add(FactoryTriggers.lowResource25); - res.add(FactoryTriggers.lowResource10); - return res; - } + // TODO: BuildCraft for 1.9 +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { +// LinkedList res = new LinkedList<>(); +// res.add(FactoryTriggers.lowResource25); +// res.add(FactoryTriggers.lowResource10); +// return res; +// } @Override public Object getGui(EntityPlayer player, int data) { diff --git a/src/main/java/forestry/factory/tiles/TileCentrifuge.java b/src/main/java/forestry/factory/tiles/TileCentrifuge.java index a541141f0..1269bf9cb 100644 --- a/src/main/java/forestry/factory/tiles/TileCentrifuge.java +++ b/src/main/java/forestry/factory/tiles/TileCentrifuge.java @@ -12,7 +12,6 @@ package forestry.factory.tiles; import java.io.IOException; import java.util.Collection; -import java.util.LinkedList; import java.util.Stack; import net.minecraft.entity.player.EntityPlayer; @@ -20,10 +19,6 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.fml.common.Optional; import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.CircuitSocketType; @@ -44,9 +39,6 @@ import forestry.factory.gui.ContainerCentrifuge; import forestry.factory.gui.GuiCentrifuge; import forestry.factory.inventory.InventoryCentrifuge; import forestry.factory.recipes.CentrifugeRecipeManager; -import forestry.factory.triggers.FactoryTriggers; - -import buildcraft.api.statements.ITriggerExternal; public class TileCentrifuge extends TilePowered implements ISocketable, ISidedInventory { private static final int TICKS_PER_RECIPE_TIME = 1; @@ -196,14 +188,15 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn } /* ITRIGGERPROVIDER */ - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { - LinkedList res = new LinkedList<>(); - res.add(FactoryTriggers.lowResource25); - res.add(FactoryTriggers.lowResource10); - return res; - } + // TODO: BuildCraft for 1.9 +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { +// LinkedList res = new LinkedList<>(); +// res.add(FactoryTriggers.lowResource25); +// res.add(FactoryTriggers.lowResource10); +// return res; +// } /* ISocketable */ @Override diff --git a/src/main/java/forestry/factory/tiles/TileFermenter.java b/src/main/java/forestry/factory/tiles/TileFermenter.java index 3a351b06c..ca46e10ea 100644 --- a/src/main/java/forestry/factory/tiles/TileFermenter.java +++ b/src/main/java/forestry/factory/tiles/TileFermenter.java @@ -11,8 +11,6 @@ package forestry.factory.tiles; import java.io.IOException; -import java.util.Collection; -import java.util.LinkedList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; @@ -20,14 +18,12 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import net.minecraftforge.fml.common.Optional; import forestry.api.core.IErrorLogic; import forestry.api.fuels.FermenterFuel; @@ -49,9 +45,6 @@ import forestry.factory.gui.ContainerFermenter; import forestry.factory.gui.GuiFermenter; import forestry.factory.inventory.InventoryFermenter; import forestry.factory.recipes.FermenterRecipeManager; -import forestry.factory.triggers.FactoryTriggers; - -import buildcraft.api.statements.ITriggerExternal; public class TileFermenter extends TilePowered implements ISidedInventory, ILiquidTankTile, IFluidHandler { private final FilteredTank resourceTank; @@ -331,14 +324,15 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu } /* ITRIGGERPROVIDER */ - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { - LinkedList res = new LinkedList<>(); - res.add(FactoryTriggers.lowResource25); - res.add(FactoryTriggers.lowResource10); - return res; - } + // TODO: BuildCraft for 1.9 +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { +// LinkedList res = new LinkedList<>(); +// res.add(FactoryTriggers.lowResource25); +// res.add(FactoryTriggers.lowResource10); +// return res; +// } @Override public Object getGui(EntityPlayer player, int data) { diff --git a/src/main/java/forestry/factory/triggers/TriggerLowFuel.java b/src/main/java/forestry/factory/triggers/TriggerLowFuel.java index 8ab539005..fe7203c29 100644 --- a/src/main/java/forestry/factory/triggers/TriggerLowFuel.java +++ b/src/main/java/forestry/factory/triggers/TriggerLowFuel.java @@ -10,46 +10,39 @@ ******************************************************************************/ package forestry.factory.triggers; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import forestry.core.tiles.TileEngine; -import forestry.core.tiles.TilePowered; import forestry.core.triggers.Trigger; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; - +// TODO: BuildCraft for 1.9 public class TriggerLowFuel extends Trigger { private float threshold = 0.25F; public TriggerLowFuel(String uid, float threshold) { - super(uid, "lowFuel"); +// super(uid, "lowFuel"); this.threshold = threshold; } - @Override - public String getDescription() { - return super.getDescription() + " < " + threshold * 100 + "%"; - } - - /** - * Return true if the tile given in parameter activates the trigger, given the parameters. - */ - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - - if (tile instanceof TilePowered) { - return !((TilePowered) tile).hasFuelMin(threshold); - } - - if (tile instanceof TileEngine) { - TileEngine tileEngine = (TileEngine) tile; - return !tileEngine.hasFuelMin(threshold); - } - - return false; - } +// @Override +// public String getDescription() { +// return super.getDescription() + " < " + threshold * 100 + "%"; +// } +// +// /** +// * Return true if the tile given in parameter activates the trigger, given the parameters. +// */ +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// +// if (tile instanceof TilePowered) { +// return !((TilePowered) tile).hasFuelMin(threshold); +// } +// +// if (tile instanceof TileEngine) { +// TileEngine tileEngine = (TileEngine) tile; +// return !tileEngine.hasFuelMin(threshold); +// } +// +// return false; +// } } diff --git a/src/main/java/forestry/factory/triggers/TriggerLowResource.java b/src/main/java/forestry/factory/triggers/TriggerLowResource.java index 5ff5d57cc..9e4cd3d97 100644 --- a/src/main/java/forestry/factory/triggers/TriggerLowResource.java +++ b/src/main/java/forestry/factory/triggers/TriggerLowResource.java @@ -10,39 +10,33 @@ ******************************************************************************/ package forestry.factory.triggers; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import forestry.core.tiles.TilePowered; import forestry.core.triggers.Trigger; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; - +// TODO: BuildCraft for 1.9 public class TriggerLowResource extends Trigger { private float threshold = 0.25F; public TriggerLowResource(String tag, float threshold) { - super(tag, "lowResources"); +// super(tag, "lowResources"); this.threshold = threshold; } - @Override - public String getDescription() { - return super.getDescription() + " < " + threshold * 100 + "%"; - } - - /** - * Return true if the tile given in parameter activates the trigger, given the parameters. - */ - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof TilePowered)) { - return false; - } - - return !((TilePowered) tile).hasResourcesMin(threshold); - } +// @Override +// public String getDescription() { +// return super.getDescription() + " < " + threshold * 100 + "%"; +// } +// +// /** +// * Return true if the tile given in parameter activates the trigger, given the parameters. +// */ +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// if (!(tile instanceof TilePowered)) { +// return false; +// } +// +// return !((TilePowered) tile).hasResourcesMin(threshold); +// } } diff --git a/src/main/java/forestry/farming/blocks/BlockMushroom.java b/src/main/java/forestry/farming/blocks/BlockMushroom.java index 999e7bb6a..f7aef1a52 100644 --- a/src/main/java/forestry/farming/blocks/BlockMushroom.java +++ b/src/main/java/forestry/farming/blocks/BlockMushroom.java @@ -12,6 +12,7 @@ package forestry.farming.blocks; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Random; import net.minecraft.block.BlockBush; @@ -49,7 +50,7 @@ public class BlockMushroom extends BlockBush implements IItemModelRegister, IGro @Override public String getName() { - return name().toLowerCase(); + return name().toLowerCase(Locale.ENGLISH); } } diff --git a/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java b/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java index 07f6c3582..dc49ceb35 100644 --- a/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java +++ b/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java @@ -1,81 +1,68 @@ package forestry.farming.logic; -import java.util.Collection; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import net.minecraftforge.fml.common.Optional; - -import forestry.core.utils.vect.Vect; -import forestry.plugins.compat.PluginIC2; - -import ic2.api.crops.ICropTile; - -public class CropBasicIC2Crop extends Crop { - private final TileEntity tileEntity; - - public CropBasicIC2Crop(World world, TileEntity tileEntity, Vect position) { - super(world, position); - this.tileEntity = tileEntity; - } - - @Override - protected boolean isCrop(Vect pos) { - return canHarvestCrop(this.tileEntity); - } - - @Override - protected Collection harvestBlock(Vect pos) { - return getCropDrops(this.tileEntity); - } - - /** - * Check if there is an instance of ICropTile. - * @param tileEntity tile entity to be checked. - * @return true if there is an IC2 crop and false otherwise. - */ - @Optional.Method(modid = PluginIC2.modId) - public static boolean isIC2Crop(TileEntity tileEntity) { - if (tileEntity instanceof ICropTile) { - return true; - } - return false; - } - - /** - * Check if an IC2 crop is ready to be harvested. - * @param tileEntity tile entity to be checked. - * @return true if crop size is optimal for harvest and false otherwise. - */ - @Optional.Method(modid = PluginIC2.modId) - public static boolean canHarvestCrop(TileEntity tileEntity) { - if (isIC2Crop(tileEntity)) { - ICropTile crop = (ICropTile) tileEntity; - if (crop.getCrop() == null) { - return false; - } - if (crop.getCurrentSize() == crop.getCrop().getOptimalHarvestSize(crop)) { - return true; - } - } - return false; - } - - /** - * This function takes care of everything related to the harvesting of the - * crop meaning it will calculate the drops and also do setSizeAfterHarvest(). - * @param tileEntity tile entity to be checked. - * @return list containing the drops. - */ - @Optional.Method(modid = PluginIC2.modId) - private static List getCropDrops(TileEntity tileEntity) { - if (isIC2Crop(tileEntity)) { - ICropTile crop = (ICropTile) tileEntity; - return crop.performHarvest(); - } - return null; - } +// TODO: IC2 for 1.9 +public class CropBasicIC2Crop {//extends Crop { +// private final TileEntity tileEntity; +// +// public CropBasicIC2Crop(World world, TileEntity tileEntity, Vect position) { +// super(world, position); +// this.tileEntity = tileEntity; +// } +// +// @Override +// protected boolean isCrop(Vect pos) { +// return canHarvestCrop(this.tileEntity); +// } +// +// @Override +// protected Collection harvestBlock(Vect pos) { +// return getCropDrops(this.tileEntity); +// } +// +// /** +// * Check if there is an instance of ICropTile. +// * @param tileEntity tile entity to be checked. +// * @return true if there is an IC2 crop and false otherwise. +// */ +// @Optional.Method(modid = PluginIC2.modId) +// public static boolean isIC2Crop(TileEntity tileEntity) { +// if (tileEntity instanceof ICropTile) { +// return true; +// } +// return false; +// } +// +// /** +// * Check if an IC2 crop is ready to be harvested. +// * @param tileEntity tile entity to be checked. +// * @return true if crop size is optimal for harvest and false otherwise. +// */ +// @Optional.Method(modid = PluginIC2.modId) +// public static boolean canHarvestCrop(TileEntity tileEntity) { +// if (isIC2Crop(tileEntity)) { +// ICropTile crop = (ICropTile) tileEntity; +// if (crop.getCrop() == null) { +// return false; +// } +// if (crop.getCurrentSize() == crop.getCrop().getOptimalHarvestSize(crop)) { +// return true; +// } +// } +// return false; +// } +// +// /** +// * This function takes care of everything related to the harvesting of the +// * crop meaning it will calculate the drops and also do setSizeAfterHarvest(). +// * @param tileEntity tile entity to be checked. +// * @return list containing the drops. +// */ +// @Optional.Method(modid = PluginIC2.modId) +// private static List getCropDrops(TileEntity tileEntity) { +// if (isIC2Crop(tileEntity)) { +// ICropTile crop = (ICropTile) tileEntity; +// return crop.performHarvest(); +// } +// return null; +// } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index 75e6de660..15acb41d3 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -13,6 +13,7 @@ package forestry.farming.logic; import java.util.Collection; import java.util.Stack; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -79,7 +80,8 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(pos, direction, i); - if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getWorld(), position)) { + IBlockState state = world.getBlockState(position); + if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(state, world, position)) { continue; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicEnder.java b/src/main/java/forestry/farming/logic/FarmLogicEnder.java index a870ea17f..5fb98b303 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicEnder.java +++ b/src/main/java/forestry/farming/logic/FarmLogicEnder.java @@ -13,6 +13,7 @@ package forestry.farming.logic; import java.util.Collection; import java.util.Stack; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -89,7 +90,8 @@ public class FarmLogicEnder extends FarmLogicHomogeneous { for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(pos, direction, i); - if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(world, position)) { + IBlockState state = world.getBlockState(position); + if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(state, world, position)) { continue; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index a4bc8db61..e4354b74c 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -13,6 +13,7 @@ package forestry.farming.logic; import java.util.Collection; import java.util.Stack; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -89,7 +90,8 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { for (int i = 0; i < extent; i++) { Vect position = translateWithOffset(pos, direction, i); - if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(world, position)) { + IBlockState blockState = world.getBlockState(position); + if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(blockState, world, position)) { continue; } diff --git a/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java b/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java index dc7b916d5..9b127901e 100644 --- a/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java +++ b/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java @@ -1,82 +1,68 @@ package forestry.farming.logic; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +// TODO: IC2 for 1.9 +public class FarmableBasicIC2Crop {//implements IFarmable { -import net.minecraftforge.fml.common.Optional; - -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmable; -import forestry.core.utils.vect.Vect; -import forestry.plugins.compat.PluginIC2; - -import ic2.api.crops.ICropTile; - -public class FarmableBasicIC2Crop implements IFarmable { - - /** - * Perform some of the actions of the crop-matron. - */ - @Optional.Method(modid = PluginIC2.modId) - public static void babysitCrop(TileEntity tileEntity) { - if (CropBasicIC2Crop.isIC2Crop(tileEntity)) { - ICropTile crop = (ICropTile) tileEntity; - /* - This part might be unbalanced until a custom farm logic is added and makes use of weed-ex. - if (crop.getCrop() != null) { - if (crop.getCrop().isWeed(crop)) { - crop.reset(); - } - }*/ - if (crop.getStorageWater() <= 200) { - crop.setStorageWater(200); - } - if (crop.getStorageNutrient() <= 100) { - crop.setStorageNutrient(crop.getStorageNutrient() + 100); - } - } - } - - @Override - public boolean isSaplingAt(World world, BlockPos pos) { - TileEntity crop = world.getTileEntity(pos); - if (CropBasicIC2Crop.isIC2Crop(crop)) { - babysitCrop(crop); - return true; - } - return false; - } - - @Override - public ICrop getCropAt(World world, BlockPos pos) { - TileEntity crop = world.getTileEntity(pos); - if (crop == null) { - return null; - } - if (!CropBasicIC2Crop.isIC2Crop(crop)) { - return null; - } - if (!CropBasicIC2Crop.canHarvestCrop(crop)) { - return null; - } - return new CropBasicIC2Crop(world, crop, new Vect(pos)); - } - - @Override - public boolean isGermling(ItemStack itemstack) { - return false; - } - - @Override - public boolean isWindfall(ItemStack itemstack) { - return false; - } - - @Override - public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { - return false; - } +// /** +// * Perform some of the actions of the crop-matron. +// */ +// @Optional.Method(modid = PluginIC2.modId) +// public static void babysitCrop(TileEntity tileEntity) { +// if (CropBasicIC2Crop.isIC2Crop(tileEntity)) { +// ICropTile crop = (ICropTile) tileEntity; +// /* +// This part might be unbalanced until a custom farm logic is added and makes use of weed-ex. +// if (crop.getCrop() != null) { +// if (crop.getCrop().isWeed(crop)) { +// crop.reset(); +// } +// }*/ +// if (crop.getStorageWater() <= 200) { +// crop.setStorageWater(200); +// } +// if (crop.getStorageNutrient() <= 100) { +// crop.setStorageNutrient(crop.getStorageNutrient() + 100); +// } +// } +// } +// +// @Override +// public boolean isSaplingAt(World world, BlockPos pos) { +// TileEntity crop = world.getTileEntity(pos); +// if (CropBasicIC2Crop.isIC2Crop(crop)) { +// babysitCrop(crop); +// return true; +// } +// return false; +// } +// +// @Override +// public ICrop getCropAt(World world, BlockPos pos) { +// TileEntity crop = world.getTileEntity(pos); +// if (crop == null) { +// return null; +// } +// if (!CropBasicIC2Crop.isIC2Crop(crop)) { +// return null; +// } +// if (!CropBasicIC2Crop.canHarvestCrop(crop)) { +// return null; +// } +// return new CropBasicIC2Crop(world, crop, new Vect(pos)); +// } +// +// @Override +// public boolean isGermling(ItemStack itemstack) { +// return false; +// } +// +// @Override +// public boolean isWindfall(ItemStack itemstack) { +// return false; +// } +// +// @Override +// public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { +// return false; +// } } diff --git a/src/main/java/forestry/farming/logic/FarmableGE.java b/src/main/java/forestry/farming/logic/FarmableGE.java index 4b78f09e3..277bcd762 100755 --- a/src/main/java/forestry/farming/logic/FarmableGE.java +++ b/src/main/java/forestry/farming/logic/FarmableGE.java @@ -13,6 +13,8 @@ package forestry.farming.logic; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; @@ -51,7 +53,7 @@ public class FarmableGE implements IFarmable { @Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { - return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0); + return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java index 594229d69..0d3f6f649 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java @@ -13,6 +13,8 @@ package forestry.farming.logic; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; @@ -68,7 +70,7 @@ public class FarmableGenericCrop implements IFarmable { @Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { - return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0); + return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java index 153846482..6d7bf7b05 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java @@ -13,6 +13,8 @@ package forestry.farming.logic; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; @@ -90,7 +92,7 @@ public class FarmableGenericSapling implements IFarmable { @Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { - return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0); + return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS; } } diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaMushroom.java b/src/main/java/forestry/farming/logic/FarmableVanillaMushroom.java index 2e699a77f..139a01ffe 100644 --- a/src/main/java/forestry/farming/logic/FarmableVanillaMushroom.java +++ b/src/main/java/forestry/farming/logic/FarmableVanillaMushroom.java @@ -35,7 +35,7 @@ public class FarmableVanillaMushroom extends FarmableGenericSapling { public ICrop getCropAt(World world, BlockPos pos) { Block block = BlockUtil.getBlock(world, pos); - if (block != Blocks.BROWN_MUSHROOM_block && block != Blocks.RED_MUSHROOM_block) { + if (block != Blocks.BROWN_MUSHROOM_BLOCK && block != Blocks.RED_MUSHROOM_BLOCK) { return null; } diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java b/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java index 27b7d07e8..39efe6907 100755 --- a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java @@ -14,6 +14,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; @@ -41,7 +43,7 @@ public class FarmableVanillaSapling extends FarmableGenericSapling { return TreeManager.treeRoot.plantSapling(world, (ITree) tree, player.getGameProfile(), pos); } else { - return germling.copy().onItemUse(player, world, pos.down(), EnumFacing.UP, 0, 0, 0); + return germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0) == EnumActionResult.SUCCESS; } } diff --git a/src/main/java/forestry/farming/tiles/TileFarmHatch.java b/src/main/java/forestry/farming/tiles/TileFarmHatch.java index ccdaab558..47d780ac4 100644 --- a/src/main/java/forestry/farming/tiles/TileFarmHatch.java +++ b/src/main/java/forestry/farming/tiles/TileFarmHatch.java @@ -10,29 +10,19 @@ ******************************************************************************/ package forestry.farming.tiles; -import java.util.Collection; -import java.util.Collections; - import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; -import net.minecraftforge.fml.common.Optional; - import forestry.api.multiblock.IFarmComponent; import forestry.core.inventory.AdjacentInventoryCache; import forestry.core.tiles.AdjacentTileCache; import forestry.core.utils.InventoryUtil; -import forestry.farming.triggers.FarmingTriggers; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.ITriggerExternal; -import buildcraft.api.statements.ITriggerInternal; -import buildcraft.api.statements.ITriggerProvider; - -@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") -public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmComponent.Active, ITriggerProvider { +// TODO: Buildcraft for 1.9 +//@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") +public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmComponent.Active { private static final EnumFacing[] dumpDirections = new EnumFacing[]{EnumFacing.DOWN}; @@ -70,21 +60,22 @@ public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmCom } - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getInternalTriggers(IStatementContainer container) { - return Collections.emptyList(); - } - - /* ITRIGGERPROVIDER */ - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { - if (!getMultiblockLogic().isConnected()) { - return Collections.emptyList(); - } - - return FarmingTriggers.allExternalTriggers; - } + // TODO: Buildcraft for 1.9 +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getInternalTriggers(IStatementContainer container) { +// return Collections.emptyList(); +// } +// +// /* ITRIGGERPROVIDER */ +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { +// if (!getMultiblockLogic().isConnected()) { +// return Collections.emptyList(); +// } +// +// return FarmingTriggers.allExternalTriggers; +// } } diff --git a/src/main/java/forestry/farming/triggers/FarmingTriggers.java b/src/main/java/forestry/farming/triggers/FarmingTriggers.java index 80df09a84..d0cfdca8c 100644 --- a/src/main/java/forestry/farming/triggers/FarmingTriggers.java +++ b/src/main/java/forestry/farming/triggers/FarmingTriggers.java @@ -10,36 +10,30 @@ ******************************************************************************/ package forestry.farming.triggers; -import java.util.Arrays; -import java.util.List; - -import forestry.core.triggers.Trigger; - -import buildcraft.api.statements.ITriggerExternal; - +// TODO: Buildcraft for 1.9 public class FarmingTriggers { - public static Trigger lowResourceLiquid50; - public static Trigger lowResourceLiquid25; - public static Trigger lowSoil128; - public static Trigger lowSoil64; - public static Trigger lowSoil32; - public static Trigger lowFertilizer50; - public static Trigger lowFertilizer25; - public static Trigger lowGermlings25; - public static Trigger lowGermlings10; - public static List allExternalTriggers; +// public static Trigger lowResourceLiquid50; +// public static Trigger lowResourceLiquid25; +// public static Trigger lowSoil128; +// public static Trigger lowSoil64; +// public static Trigger lowSoil32; +// public static Trigger lowFertilizer50; +// public static Trigger lowFertilizer25; +// public static Trigger lowGermlings25; +// public static Trigger lowGermlings10; +// public static List allExternalTriggers; public static void initialize() { - allExternalTriggers = Arrays.asList( - lowResourceLiquid50 = new TriggerLowLiquid("lowLiquid.50", 0.5f), - lowResourceLiquid25 = new TriggerLowLiquid("lowLiquid.25", 0.25f), - lowSoil128 = new TriggerLowSoil(128), - lowSoil64 = new TriggerLowSoil(64), - lowSoil32 = new TriggerLowSoil(32), - lowFertilizer50 = new TriggerLowFertilizer("lowFertilizer.50", 0.5f), - lowFertilizer25 = new TriggerLowFertilizer("lowFertilizer.25", 0.25f), - lowGermlings25 = new TriggerLowGermlings("lowGermlings.25", 0.25f), - lowGermlings10 = new TriggerLowGermlings("lowGermlings.10", 0.1f) - ); +// allExternalTriggers = Arrays.asList( +// lowResourceLiquid50 = new TriggerLowLiquid("lowLiquid.50", 0.5f), +// lowResourceLiquid25 = new TriggerLowLiquid("lowLiquid.25", 0.25f), +// lowSoil128 = new TriggerLowSoil(128), +// lowSoil64 = new TriggerLowSoil(64), +// lowSoil32 = new TriggerLowSoil(32), +// lowFertilizer50 = new TriggerLowFertilizer("lowFertilizer.50", 0.5f), +// lowFertilizer25 = new TriggerLowFertilizer("lowFertilizer.25", 0.25f), +// lowGermlings25 = new TriggerLowGermlings("lowGermlings.25", 0.25f), +// lowGermlings10 = new TriggerLowGermlings("lowGermlings.10", 0.1f) +// ); } } diff --git a/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java b/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java index fe1075090..4ad5755dd 100755 --- a/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java +++ b/src/main/java/forestry/farming/triggers/TriggerLowFertilizer.java @@ -10,39 +10,29 @@ ******************************************************************************/ package forestry.farming.triggers; -import net.minecraft.inventory.IInventory; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +// TODO: Buildcraft for 1.9 +public class TriggerLowFertilizer {//} extends Trigger { -import forestry.core.triggers.Trigger; -import forestry.core.utils.InventoryUtil; -import forestry.farming.tiles.TileFarmHatch; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; - -public class TriggerLowFertilizer extends Trigger { - - private final float threshold; - - public TriggerLowFertilizer(String tag, float threshold) { - super(tag, "lowFertilizer"); - this.threshold = threshold; - } - - @Override - public String getDescription() { - return super.getDescription() + " < " + threshold * 100 + "%"; - } - - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof TileFarmHatch)) { - return false; - } - - TileFarmHatch tileHatch = (TileFarmHatch) tile; - IInventory fertilizerInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getFertilizerInventory(); - return InventoryUtil.containsPercent(fertilizerInventory, threshold); - } +// private final float threshold; +// +// public TriggerLowFertilizer(String tag, float threshold) { +// super(tag, "lowFertilizer"); +// this.threshold = threshold; +// } +// +// @Override +// public String getDescription() { +// return super.getDescription() + " < " + threshold * 100 + "%"; +// } +// +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// if (!(tile instanceof TileFarmHatch)) { +// return false; +// } +// +// TileFarmHatch tileHatch = (TileFarmHatch) tile; +// IInventory fertilizerInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getFertilizerInventory(); +// return InventoryUtil.containsPercent(fertilizerInventory, threshold); +// } } diff --git a/src/main/java/forestry/farming/triggers/TriggerLowGermlings.java b/src/main/java/forestry/farming/triggers/TriggerLowGermlings.java index b18d3622f..690a89111 100644 --- a/src/main/java/forestry/farming/triggers/TriggerLowGermlings.java +++ b/src/main/java/forestry/farming/triggers/TriggerLowGermlings.java @@ -10,42 +10,34 @@ ******************************************************************************/ package forestry.farming.triggers; -import net.minecraft.inventory.IInventory; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - import forestry.core.triggers.Trigger; -import forestry.core.utils.InventoryUtil; -import forestry.farming.tiles.TileFarmHatch; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +// TODO: Buildcraft for 1.9 public class TriggerLowGermlings extends Trigger { private final float threshold; public TriggerLowGermlings(String tag, float threshold) { - super(tag, "lowGermlings"); +// super(tag, "lowGermlings"); this.threshold = threshold; } - @Override - public String getDescription() { - return super.getDescription() + " < " + threshold * 100 + "%"; - } - - /** - * Return true if the tile given in parameter activates the trigger, given the parameters. - */ - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof TileFarmHatch)) { - return false; - } - - TileFarmHatch tileHatch = (TileFarmHatch) tile; - IInventory germlingsInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getGermlingsInventory(); - return InventoryUtil.containsPercent(germlingsInventory, threshold); - } +// @Override +// public String getDescription() { +// return super.getDescription() + " < " + threshold * 100 + "%"; +// } +// +// /** +// * Return true if the tile given in parameter activates the trigger, given the parameters. +// */ +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// if (!(tile instanceof TileFarmHatch)) { +// return false; +// } +// +// TileFarmHatch tileHatch = (TileFarmHatch) tile; +// IInventory germlingsInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getGermlingsInventory(); +// return InventoryUtil.containsPercent(germlingsInventory, threshold); +// } } diff --git a/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java b/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java index aedd853f6..aeb378483 100755 --- a/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java +++ b/src/main/java/forestry/farming/triggers/TriggerLowLiquid.java @@ -10,49 +10,40 @@ ******************************************************************************/ package forestry.farming.triggers; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.fluids.IFluidTank; - -import forestry.core.fluids.ITankManager; import forestry.core.triggers.Trigger; -import forestry.farming.tiles.TileFarmHatch; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +// TODO: Buildcraft for 1.9 public class TriggerLowLiquid extends Trigger { private final float threshold; public TriggerLowLiquid(String tag, float threshold) { - super(tag, "lowLiquid"); +// super(tag, "lowLiquid"); this.threshold = threshold; } - @Override - public String getDescription() { - return super.getDescription() + " < " + threshold * 100 + "%"; - } - - /** - * Return true if the tile given in parameter activates the trigger, given - * the parameters. - */ - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - if (!(tile instanceof TileFarmHatch)) { - return false; - } - - TileFarmHatch tileHatch = (TileFarmHatch) tile; - ITankManager tankManager = tileHatch.getMultiblockLogic().getController().getTankManager(); - - IFluidTank tank = tankManager.getTank(0); - if (tank.getCapacity() == 0) { - return false; - } - return (float) tank.getFluidAmount() / tank.getCapacity() <= threshold; - } +// @Override +// public String getDescription() { +// return super.getDescription() + " < " + threshold * 100 + "%"; +// } +// +// /** +// * Return true if the tile given in parameter activates the trigger, given +// * the parameters. +// */ +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// if (!(tile instanceof TileFarmHatch)) { +// return false; +// } +// +// TileFarmHatch tileHatch = (TileFarmHatch) tile; +// ITankManager tankManager = tileHatch.getMultiblockLogic().getController().getTankManager(); +// +// IFluidTank tank = tankManager.getTank(0); +// if (tank.getCapacity() == 0) { +// return false; +// } +// return (float) tank.getFluidAmount() / tank.getCapacity() <= threshold; +// } } diff --git a/src/main/java/forestry/farming/triggers/TriggerLowSoil.java b/src/main/java/forestry/farming/triggers/TriggerLowSoil.java index b21c2c649..cbe72944a 100755 --- a/src/main/java/forestry/farming/triggers/TriggerLowSoil.java +++ b/src/main/java/forestry/farming/triggers/TriggerLowSoil.java @@ -10,65 +10,54 @@ ******************************************************************************/ package forestry.farming.triggers; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import forestry.api.farming.IFarmInventory; -import forestry.api.multiblock.IFarmController; import forestry.core.triggers.Trigger; -import forestry.core.utils.InventoryUtil; -import forestry.farming.tiles.TileFarmHatch; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; +// TODO: Buildcraft for 1.9 public class TriggerLowSoil extends Trigger { private final int threshold; public TriggerLowSoil(int threshold) { - super("lowSoil." + threshold, "lowSoil"); +// super("lowSoil." + threshold, "lowSoil"); this.threshold = threshold; } - @Override - public String getDescription() { - return super.getDescription() + " < " + threshold; - } - - @Override - public int maxParameters() { - return 1; - } - - /** - * Return true if the tile given in parameter activates the trigger, given - * the parameters. - */ - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - IStatementParameter parameter = null; - if (parameters.length > 0) { - parameter = parameters[0]; - } - - if (!(tile instanceof TileFarmHatch)) { - return false; - } - - TileFarmHatch tileHatch = (TileFarmHatch) tile; - IFarmController farmController = tileHatch.getMultiblockLogic().getController(); - IFarmInventory farmInventory = farmController.getFarmInventory(); - - if (parameter == null || parameter.getItemStack() == null) { - IInventory resourcesInventory = farmInventory.getResourcesInventory(); - return InventoryUtil.containsPercent(resourcesInventory, threshold); - } else { - ItemStack filter = parameter.getItemStack().copy(); - filter.stackSize = threshold; - return farmInventory.hasResources(new ItemStack[]{filter}); - } - } +// @Override +// public String getDescription() { +// return super.getDescription() + " < " + threshold; +// } +// +// @Override +// public int maxParameters() { +// return 1; +// } +// +// /** +// * Return true if the tile given in parameter activates the trigger, given +// * the parameters. +// */ +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// IStatementParameter parameter = null; +// if (parameters.length > 0) { +// parameter = parameters[0]; +// } +// +// if (!(tile instanceof TileFarmHatch)) { +// return false; +// } +// +// TileFarmHatch tileHatch = (TileFarmHatch) tile; +// IFarmController farmController = tileHatch.getMultiblockLogic().getController(); +// IFarmInventory farmInventory = farmController.getFarmInventory(); +// +// if (parameter == null || parameter.getItemStack() == null) { +// IInventory resourcesInventory = farmInventory.getResourcesInventory(); +// return InventoryUtil.containsPercent(resourcesInventory, threshold); +// } else { +// ItemStack filter = parameter.getItemStack().copy(); +// filter.stackSize = threshold; +// return farmInventory.hasResources(new ItemStack[]{filter}); +// } +// } } diff --git a/src/main/java/forestry/food/BeverageEffectAntidote.java b/src/main/java/forestry/food/BeverageEffectAntidote.java index 0476fa923..4de68c2c2 100755 --- a/src/main/java/forestry/food/BeverageEffectAntidote.java +++ b/src/main/java/forestry/food/BeverageEffectAntidote.java @@ -11,6 +11,7 @@ package forestry.food; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.potion.Potion; import net.minecraft.world.World; @@ -25,12 +26,9 @@ public class BeverageEffectAntidote extends BeverageEffect { @Override public void doEffect(World world, EntityPlayer player) { - - if (world.rand.nextFloat() >= chance) { - return; + if (world.rand.nextFloat() < chance) { + player.removePotionEffect(MobEffects.POISON); } - - player.removePotionEffect(Potion.poison.getId()); } @Override diff --git a/src/main/java/forestry/food/BeverageEffectDrunk.java b/src/main/java/forestry/food/BeverageEffectDrunk.java index 80bdfcfb7..f32984baf 100755 --- a/src/main/java/forestry/food/BeverageEffectDrunk.java +++ b/src/main/java/forestry/food/BeverageEffectDrunk.java @@ -11,6 +11,7 @@ package forestry.food; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; @@ -23,7 +24,7 @@ public class BeverageEffectDrunk extends BeverageEffect { public BeverageEffectDrunk(int id, float chance) { super(id, "for.beverage.effect.alcoholic"); this.chance = chance; - this.drunkEffect = new PotionEffect(Potion.confusion.id, 25 * 20, 0); + this.drunkEffect = new PotionEffect(MobEffects.NAUSEA, 25 * 20, 0); } @Override diff --git a/src/main/java/forestry/food/items/ItemAmbrosia.java b/src/main/java/forestry/food/items/ItemAmbrosia.java index 3c416f5f7..8d06625db 100755 --- a/src/main/java/forestry/food/items/ItemAmbrosia.java +++ b/src/main/java/forestry/food/items/ItemAmbrosia.java @@ -10,8 +10,10 @@ ******************************************************************************/ package forestry.food.items; +import net.minecraft.init.MobEffects; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import forestry.core.config.Constants; import forestry.core.items.ItemForestryFood; @@ -21,7 +23,8 @@ public class ItemAmbrosia extends ItemForestryFood { public ItemAmbrosia() { super(Constants.FOOD_AMBROSIA_HEAL, 0.6f); setAlwaysEdible(); - setPotionEffect(Potion.regeneration.id, 40, 0, 1.0F); + PotionEffect potionEffect = new PotionEffect(MobEffects.REGENERATION, 40, 0); + setPotionEffect(potionEffect, 1.0F); } @Override diff --git a/src/main/java/forestry/food/items/ItemBeverage.java b/src/main/java/forestry/food/items/ItemBeverage.java index 8e6fe85e8..ea09e5f68 100755 --- a/src/main/java/forestry/food/items/ItemBeverage.java +++ b/src/main/java/forestry/food/items/ItemBeverage.java @@ -12,6 +12,7 @@ package forestry.food.items; import java.util.List; +import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -36,7 +37,7 @@ import forestry.core.items.ItemForestryFood; import forestry.core.items.ItemOverlay; import forestry.food.BeverageEffect; -public class ItemBeverage extends ItemForestryFood { +public class ItemBeverage extends ItemForestryFood implements IItemColor { public interface IBeverageInfo extends ItemOverlay.IOverlayInfo { int getHeal(); @@ -160,7 +161,7 @@ public class ItemBeverage extends ItemForestryFood { } @Override - public int getColorFromItemStack(ItemStack itemstack, int j) { + public int getColorFromItemstack(ItemStack itemstack, int j) { if (j == 1 || beverages[itemstack.getItemDamage()].getSecondaryColor() == 0) { return beverages[itemstack.getItemDamage()].getPrimaryColor(); } else { diff --git a/src/main/java/forestry/greenhouse/GreenhouseAccess.java b/src/main/java/forestry/greenhouse/GreenhouseAccess.java index 81f272488..75846c6cd 100644 --- a/src/main/java/forestry/greenhouse/GreenhouseAccess.java +++ b/src/main/java/forestry/greenhouse/GreenhouseAccess.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import forestry.api.core.EnumCamouflageType; @@ -42,8 +43,13 @@ public class GreenhouseAccess implements IGreenhouseAccess { return; } Block block = Block.getBlockFromItem(glass.getItem()); - if (block == null || block.isOpaqueCube()) { - Log.error("Fail to register greenhouse glass: " + block + "."); + if (block == null) { + Log.error("Fail to register greenhouse glass, it has no matching block: " + glass + "."); + return; + } + IBlockState defaultBlockState = block.getDefaultState(); + if (block.isOpaqueCube(defaultBlockState)) { + Log.error("Fail to register greenhouse glass, it is opaque: " + block + "."); return; } for (ItemStack greenhouseGlass : greenhouseGlasses.keySet()) { diff --git a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java index d09a91aba..9cc0b2e41 100644 --- a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java +++ b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java @@ -13,6 +13,7 @@ package forestry.greenhouse.blocks; import javax.annotation.Nonnull; import java.util.EnumMap; import java.util.List; +import java.util.Locale; import java.util.Map; import net.minecraft.block.Block; @@ -75,7 +76,7 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR @Override public String getName() { - return name().toLowerCase(); + return name().toLowerCase(Locale.ENGLISH); } } diff --git a/src/main/java/forestry/greenhouse/items/ItemBlockGreenhouseDoor.java b/src/main/java/forestry/greenhouse/items/ItemBlockGreenhouseDoor.java index 2dce08686..0bd4959a6 100644 --- a/src/main/java/forestry/greenhouse/items/ItemBlockGreenhouseDoor.java +++ b/src/main/java/forestry/greenhouse/items/ItemBlockGreenhouseDoor.java @@ -11,12 +11,16 @@ package forestry.greenhouse.items; import net.minecraft.block.Block; -import net.minecraft.block.BlockDoor; +import net.minecraft.block.SoundType; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemDoor; import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.core.items.ItemBlockForestry; @@ -27,50 +31,35 @@ public class ItemBlockGreenhouseDoor extends ItemBlockForestry 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F; + ItemDoor.placeDoor(worldIn, pos, enumfacing, this.block, flag); + SoundType soundtype = this.block.getSoundType(); + worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); --stack.stackSize; - return true; + return EnumActionResult.SUCCESS; + } else { + return EnumActionResult.FAIL; } } } - - private void placeDoor(World worldIn, BlockPos pos, EnumFacing facing, Block door) { - BlockPos blockpos = pos.offset(facing.rotateY()); - BlockPos blockpos1 = pos.offset(facing.rotateYCCW()); - int i = (worldIn.getBlockState(blockpos1).getBlock().isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos1.up()).getBlock().isNormalCube() ? 1 : 0); - int j = (worldIn.getBlockState(blockpos).getBlock().isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos.up()).getBlock().isNormalCube() ? 1 : 0); - boolean flag = worldIn.getBlockState(blockpos1).getBlock() == door || worldIn.getBlockState(blockpos1.up()).getBlock() == door; - boolean flag1 = worldIn.getBlockState(blockpos).getBlock() == door || worldIn.getBlockState(blockpos.up()).getBlock() == door; - boolean flag2 = false; - - if (flag && !flag1 || j > i) { - flag2 = true; - } - - BlockPos blockpos2 = pos.up(); - IBlockState iblockstate = door.getDefaultState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HINGE, flag2 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT); - worldIn.setBlockState(pos, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2); - worldIn.setBlockState(blockpos2, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2); - worldIn.notifyNeighborsOfStateChange(pos, door); - worldIn.notifyNeighborsOfStateChange(blockpos2, door); - } - } diff --git a/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java b/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java index 9a2c1ab1e..58a5770db 100644 --- a/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java +++ b/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java @@ -23,8 +23,8 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -311,7 +311,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im if (comp instanceof ICamouflagedBlock) { ICamouflagedBlock camBlock = (ICamouflagedBlock) comp; if (camBlock.getCamouflageType() == type) { - worldObj.markBlockForUpdate(camBlock.getCoordinates()); + worldObj.markBlockRangeForRenderUpdate(camBlock.getCoordinates(), camBlock.getCoordinates()); } } } diff --git a/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java b/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java index 3ea13076d..16c5704a4 100644 --- a/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java +++ b/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java @@ -96,7 +96,7 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry 1) { CommandHelpers.throwWrongUsage(sender, this); } - World world = CommandHelpers.getWorld(sender, this, args, 0); - if (world == null) { - CommandHelpers.throwWrongUsage(sender, this); - } else { - for (Object entity : world.loadedEntityList) { - if (entity instanceof EntityButterfly) { - ((EntityButterfly) entity).setDead(); - } + for (Object entity : sender.getEntityWorld().getLoadedEntityList()) { + if (entity instanceof EntityButterfly) { + ((EntityButterfly) entity).setDead(); } } } diff --git a/src/main/java/forestry/lepidopterology/entities/AIButterflyRest.java b/src/main/java/forestry/lepidopterology/entities/AIButterflyRest.java index 2424c83e8..fc1c9f926 100755 --- a/src/main/java/forestry/lepidopterology/entities/AIButterflyRest.java +++ b/src/main/java/forestry/lepidopterology/entities/AIButterflyRest.java @@ -16,6 +16,7 @@ import net.minecraft.block.BlockFlower; import net.minecraft.block.BlockWall; import net.minecraft.block.IGrowable; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.IPlantable; @@ -48,7 +49,8 @@ public class AIButterflyRest extends AIButterflyBase { if (entity.worldObj.isAirBlock(pos)) { return false; } - if (entity.worldObj.getBlockState(pos).getBlock().getMaterial().isLiquid()) { + IBlockState blockState = entity.worldObj.getBlockState(pos); + if (blockState.getBlock().getMaterial(blockState).isLiquid()) { return false; } if (!entity.getButterfly().isAcceptedEnvironment(entity.worldObj, x, pos.getY(), z)) { @@ -82,15 +84,18 @@ public class AIButterflyRest extends AIButterflyBase { } private boolean canLand(BlockPos pos) { - Block block = entity.worldObj.getBlockState(pos).getBlock(); + IBlockState blockState = entity.worldObj.getBlockState(pos); + Block block = blockState.getBlock(); if (!block.isPassable(entity.worldObj, pos)) { return false; } - if (isPlant(block)) { + if (isPlant(blockState)) { return true; } - block = entity.worldObj.getBlockState(pos.down()).getBlock(); - return isRest(block) || block.isLeaves(entity.worldObj, pos.down()); + + IBlockState blockStateBelow = entity.worldObj.getBlockState(pos.down()); + Block blockBelow = blockStateBelow.getBlock(); + return isRest(blockBelow) || blockBelow.isLeaves(blockStateBelow, entity.worldObj, pos.down()); } private static boolean isRest(Block block) { @@ -100,14 +105,15 @@ public class AIButterflyRest extends AIButterflyBase { return block instanceof BlockWall; } - private static boolean isPlant(Block block) { + private static boolean isPlant(IBlockState blockState) { + Block block = blockState.getBlock(); if (block instanceof BlockFlower) { return true; } else if (block instanceof IPlantable) { return true; } else if (block instanceof IGrowable) { return true; - } else if (block.getMaterial() == Material.plants) { + } else if (block.getMaterial(blockState) == Material.PLANTS) { return true; } return false; diff --git a/src/main/java/forestry/lepidopterology/genetics/ButterflyRoot.java b/src/main/java/forestry/lepidopterology/genetics/ButterflyRoot.java index 7dabdeb6f..99cda8b9b 100644 --- a/src/main/java/forestry/lepidopterology/genetics/ButterflyRoot.java +++ b/src/main/java/forestry/lepidopterology/genetics/ButterflyRoot.java @@ -17,6 +17,7 @@ import java.util.Collections; import java.util.Map.Entry; import net.minecraft.block.Block; +import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -206,15 +207,13 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot { } private BlockPos getNextPos(World world, BlockPos pos){ - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); - + IBlockState blockState; do { - y--; - } while (!BlockUtil.canReplace(world, new BlockPos(x, y, z))); + pos.down(); + blockState = world.getBlockState(pos); + } while (!BlockUtil.canReplace(blockState, world, pos)); - return new BlockPos(x, y, z); + return pos; } @Override diff --git a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java index 42e81757e..2c1f63994 100755 --- a/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java +++ b/src/main/java/forestry/lepidopterology/items/ItemButterflyGE.java @@ -16,6 +16,7 @@ import java.util.Random; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -59,7 +60,7 @@ import forestry.lepidopterology.PluginLepidopterology; import forestry.lepidopterology.entities.EntityButterfly; import forestry.lepidopterology.genetics.ButterflyGenome; -public class ItemButterflyGE extends ItemGE implements ISpriteRegister { +public class ItemButterflyGE extends ItemGE implements ISpriteRegister, IItemColor { private static final Random rand = new Random(); public static final String NBT_AGE = "Age"; @@ -312,4 +313,15 @@ public class ItemButterflyGE extends ItemGE implements ISpriteRegister { return grammar.replaceAll("%SPECIES", speciesString).replaceAll("%TYPE", typeString); } + @Override + public int getColorFromItemstack(ItemStack stack, int tintIndex) { + if (stack.hasTagCompound()) { + IAlleleSpecies species = AlleleManager.alleleRegistry.getIndividual(stack).getGenome().getPrimary(); + if (species != null) { + return species.getSpriteColour(tintIndex); + } + } + return 0xffffff; + } + } diff --git a/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterologyClient.java b/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterologyClient.java index 87f81f902..355c83406 100644 --- a/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterologyClient.java +++ b/src/main/java/forestry/lepidopterology/proxy/ProxyLepidopterologyClient.java @@ -10,21 +10,11 @@ ******************************************************************************/ package forestry.lepidopterology.proxy; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.client.renderer.color.ItemColors; -import net.minecraft.item.ItemStack; - import net.minecraftforge.fml.client.registry.RenderingRegistry; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAlleleSpecies; import forestry.core.models.ModelIndex; import forestry.core.models.ModelManager; import forestry.core.proxy.Proxies; -import forestry.lepidopterology.PluginLepidopterology; import forestry.lepidopterology.entities.EntityButterfly; import forestry.lepidopterology.render.ModelButterflyItem; import forestry.lepidopterology.render.RenderButterflyEntity; @@ -35,26 +25,5 @@ public class ProxyLepidopterologyClient extends ProxyLepidopterology { public void preInitializeRendering() { RenderingRegistry.registerEntityRenderingHandler(EntityButterfly.class, new RenderButterflyEntity.Factory()); Proxies.render.registerModel(new ModelIndex(ModelManager.getInstance().getModelLocation("butterflyGE"), new ModelButterflyItem())); - - Minecraft minecraft = Minecraft.getMinecraft(); - - ItemColors itemColors = minecraft.getItemColors(); - - itemColors.registerItemColorHandler(new ButterflyItemColor(), - PluginLepidopterology.items.butterflyGE - ); - } - - private static class ButterflyItemColor implements IItemColor { - @Override - public int getColorFromItemstack(ItemStack stack, int tintIndex) { - if (stack.hasTagCompound()) { - IAlleleSpecies species = AlleleManager.alleleRegistry.getIndividual(stack).getGenome().getPrimary(); - if (species != null) { - return species.getSpriteColour(tintIndex); - } - } - return 0xffffff; - } } } diff --git a/src/main/java/forestry/lepidopterology/render/TextureAtlasButterfly.java b/src/main/java/forestry/lepidopterology/render/TextureAtlasButterfly.java index 32c654859..c0ac5d9ea 100644 --- a/src/main/java/forestry/lepidopterology/render/TextureAtlasButterfly.java +++ b/src/main/java/forestry/lepidopterology/render/TextureAtlasButterfly.java @@ -23,30 +23,31 @@ public class TextureAtlasButterfly extends TextureAtlasSprite { public TextureAtlasButterfly(String spriteName) { super(spriteName); } - - @Override - public void loadSprite(BufferedImage[] images, AnimationMetadataSection meta) throws IOException { - this.resetSprite(); - int i = images[0].getWidth(); - int j = images[0].getHeight(); - this.width = i; - this.height = j; - int[][] aint = new int[images.length][]; - for (int k = 0; k < images.length; ++k) { - BufferedImage bufferedimage = images[k]; - - if (bufferedimage != null) { - if (k > 0 && (bufferedimage.getWidth() != i >> k || bufferedimage.getHeight() != j >> k)) { - throw new RuntimeException(String.format("Unable to load miplevel: %d, image is size: %dx%d, expected %dx%d", new Object[]{Integer.valueOf(k), Integer.valueOf(bufferedimage.getWidth()), Integer.valueOf(bufferedimage.getHeight()), Integer.valueOf(i >> k), Integer.valueOf(j >> k)})); - } - - aint[k] = new int[bufferedimage.getWidth() * bufferedimage.getHeight()]; - bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), aint[k], 0, bufferedimage.getWidth()); - } - } - this.framesTextureData.add(aint); - } +// TODO: fix butterfly sprite +// @Override +// public void loadSprite(BufferedImage[] images, AnimationMetadataSection meta) throws IOException { +// this.resetSprite(); +// int i = images[0].getWidth(); +// int j = images[0].getHeight(); +// this.width = i; +// this.height = j; +// int[][] aint = new int[images.length][]; +// +// for (int k = 0; k < images.length; ++k) { +// BufferedImage bufferedimage = images[k]; +// +// if (bufferedimage != null) { +// if (k > 0 && (bufferedimage.getWidth() != i >> k || bufferedimage.getHeight() != j >> k)) { +// throw new RuntimeException(String.format("Unable to load miplevel: %d, image is size: %dx%d, expected %dx%d", new Object[]{Integer.valueOf(k), Integer.valueOf(bufferedimage.getWidth()), Integer.valueOf(bufferedimage.getHeight()), Integer.valueOf(i >> k), Integer.valueOf(j >> k)})); +// } +// +// aint[k] = new int[bufferedimage.getWidth() * bufferedimage.getHeight()]; +// bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), aint[k], 0, bufferedimage.getWidth()); +// } +// } +// this.framesTextureData.add(aint); +// } private void resetSprite() { this.setFramesTextureData(Lists.newArrayList()); diff --git a/src/main/java/forestry/mail/PluginMail.java b/src/main/java/forestry/mail/PluginMail.java index 0734d2510..4b2a88de1 100644 --- a/src/main/java/forestry/mail/PluginMail.java +++ b/src/main/java/forestry/mail/PluginMail.java @@ -71,10 +71,11 @@ public class PluginMail extends BlankForestryPlugin { blocks.mail.addDefinitions(BlockTypeMail.VALUES); } - @Override - public void registerTriggers() { - MailTriggers.initialize(); - } + // TODO: Buildcraft for 1.9 +// @Override +// public void registerTriggers() { +// MailTriggers.initialize(); +// } @Override public void doInit() { diff --git a/src/main/java/forestry/mail/blocks/BlockTypeMail.java b/src/main/java/forestry/mail/blocks/BlockTypeMail.java index ad6795453..c13297af2 100644 --- a/src/main/java/forestry/mail/blocks/BlockTypeMail.java +++ b/src/main/java/forestry/mail/blocks/BlockTypeMail.java @@ -22,8 +22,8 @@ import forestry.mail.tiles.TileTrader; public enum BlockTypeMail implements IBlockType { MAILBOX(0, TileMailbox.class, "mailbox"), - TRADE_STATION(1, TileTrader.class, "trade.station"), - PHILATELIST(2, TileStampCollector.class, "stamp.collector"); + TRADE_STATION(1, TileTrader.class, "trade_station"), + PHILATELIST(2, TileStampCollector.class, "stamp_collector"); public static final BlockTypeMail[] VALUES = values(); diff --git a/src/main/java/forestry/mail/gui/ContainerCatalogue.java b/src/main/java/forestry/mail/gui/ContainerCatalogue.java index 1b3684164..59e5d939d 100755 --- a/src/main/java/forestry/mail/gui/ContainerCatalogue.java +++ b/src/main/java/forestry/mail/gui/ContainerCatalogue.java @@ -179,7 +179,7 @@ public class ContainerCatalogue extends Container implements IGuiSelectable, ILe super.detectAndSendChanges(); if (needsSynch) { - for (ICrafting crafter : crafters) { + for (ICrafting crafter : listeners) { crafter.sendProgressBarUpdate(this, 0, stationIndex); crafter.sendProgressBarUpdate(this, 1, stations.size()); crafter.sendProgressBarUpdate(this, 2, currentFilter); diff --git a/src/main/java/forestry/mail/gui/ContainerLetter.java b/src/main/java/forestry/mail/gui/ContainerLetter.java index 73a43d133..a31a5aebb 100755 --- a/src/main/java/forestry/mail/gui/ContainerLetter.java +++ b/src/main/java/forestry/mail/gui/ContainerLetter.java @@ -19,6 +19,8 @@ import net.minecraft.world.World; import com.mojang.authlib.GameProfile; +import net.minecraftforge.fml.common.FMLCommonHandler; + import forestry.api.mail.EnumAddressee; import forestry.api.mail.ILetter; import forestry.api.mail.IMailAddress; @@ -121,7 +123,7 @@ public class ContainerLetter extends ContainerItemInventory } public void handleRequestLetterInfo(EntityPlayer player, String recipientName, EnumAddressee type) { - IMailAddress recipient = getRecipient(recipientName, type); + IMailAddress recipient = getRecipient(player.getServer(), recipientName, type); getLetter().setRecipient(recipient); @@ -134,10 +136,10 @@ public class ContainerLetter extends ContainerItemInventory Proxies.net.sendToPlayer(new PacketLetterInfoResponse(type, tradeInfo, recipient), player); } - private static IMailAddress getRecipient(String recipientName, EnumAddressee type) { + private static IMailAddress getRecipient(MinecraftServer minecraftServer, String recipientName, EnumAddressee type) { switch (type) { case PLAYER: { - GameProfile gameProfile = MinecraftServer.getServer().getPlayerProfileCache().getGameProfileForUsername(recipientName); + GameProfile gameProfile = minecraftServer.getPlayerProfileCache().getGameProfileForUsername(recipientName); if (gameProfile == null) { gameProfile = new GameProfile(new UUID(0, 0), recipientName); } diff --git a/src/main/java/forestry/mail/gui/ContainerMailbox.java b/src/main/java/forestry/mail/gui/ContainerMailbox.java index 6bea0fc56..cc3ec7de3 100755 --- a/src/main/java/forestry/mail/gui/ContainerMailbox.java +++ b/src/main/java/forestry/mail/gui/ContainerMailbox.java @@ -12,6 +12,7 @@ package forestry.mail.gui; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ClickType; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -49,10 +50,10 @@ public class ContainerMailbox extends ContainerTile { } @Override - public ItemStack slotClick(int slotIndex, int button, int par3, EntityPlayer player) { - ItemStack stack = super.slotClick(slotIndex, button, par3, player); + public ItemStack slotClick(int slotId, int dragType_or_button, ClickType clickTypeIn, EntityPlayer player) { + ItemStack stack = super.slotClick(slotId, dragType_or_button, clickTypeIn, player); - if (SlotUtil.isSlotInRange(slotIndex, SLOT_LETTERS, SLOT_LETTERS_COUNT)) { + if (SlotUtil.isSlotInRange(slotId, SLOT_LETTERS, SLOT_LETTERS_COUNT)) { if (!player.worldObj.isRemote && mailInventory != null) { POBoxInfo info = mailInventory.getPOBoxInfo(); Proxies.net.sendToPlayer(new PacketPOBoxInfoUpdate(info), player); diff --git a/src/main/java/forestry/mail/gui/ContainerTradeName.java b/src/main/java/forestry/mail/gui/ContainerTradeName.java index d73947462..43847d1af 100755 --- a/src/main/java/forestry/mail/gui/ContainerTradeName.java +++ b/src/main/java/forestry/mail/gui/ContainerTradeName.java @@ -31,10 +31,10 @@ public class ContainerTradeName extends ContainerTile { super.detectAndSendChanges(); if (tile.isLinked()) { - for (Object crafter : crafters) { + for (Object crafter : listeners) { if (crafter instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) crafter; - tile.openGui(player); + tile.openGui(player, player.getHeldItemMainhand()); } } } diff --git a/src/main/java/forestry/mail/gui/GuiMailboxInfo.java b/src/main/java/forestry/mail/gui/GuiMailboxInfo.java index fb119932b..7dd2bbdd3 100755 --- a/src/main/java/forestry/mail/gui/GuiMailboxInfo.java +++ b/src/main/java/forestry/mail/gui/GuiMailboxInfo.java @@ -11,11 +11,15 @@ package forestry.mail.gui; import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.init.SoundEvents; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundCategory; +import net.minecraft.world.World; import forestry.core.config.Config; import forestry.core.config.Constants; @@ -92,7 +96,9 @@ public class GuiMailboxInfo extends Gui { } if (playJingle) { - Proxies.common.getRenderWorld().playSoundAtEntity(Proxies.common.getClientInstance().thePlayer, "random.levelup", 1.0f, 1.0f); + EntityPlayerSP thePlayer = Proxies.common.getClientInstance().thePlayer; + World world = Proxies.common.getRenderWorld(); + world.playSound(null, thePlayer.posX, thePlayer.posY, thePlayer.posZ, SoundEvents.ENTITY_PLAYER_LEVELUP, SoundCategory.PLAYERS, 1.0f, 1.0F); } this.poInfo = info; diff --git a/src/main/java/forestry/mail/items/ItemLetter.java b/src/main/java/forestry/mail/items/ItemLetter.java index 7dbf4a241..ca178f619 100755 --- a/src/main/java/forestry/mail/items/ItemLetter.java +++ b/src/main/java/forestry/mail/items/ItemLetter.java @@ -17,6 +17,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; @@ -39,16 +42,13 @@ public class ItemLetter extends ItemWithGui { } @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if (!world.isRemote) { - if (itemstack.stackSize == 1) { - openGui(entityplayer); - } else { - entityplayer.addChatMessage(new TextComponentTranslation("for.chat.mail.wrongstacksize")); - } + public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { + if (itemStackIn.stackSize == 1) { + return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand); + } else { + playerIn.addChatMessage(new TextComponentTranslation("for.chat.mail.wrongstacksize")); + return ActionResult.newResult(EnumActionResult.FAIL, itemStackIn); } - - return itemstack; } @Override diff --git a/src/main/java/forestry/mail/tiles/TileMailbox.java b/src/main/java/forestry/mail/tiles/TileMailbox.java index 563a3368c..6dd02d5a1 100644 --- a/src/main/java/forestry/mail/tiles/TileMailbox.java +++ b/src/main/java/forestry/mail/tiles/TileMailbox.java @@ -10,21 +10,14 @@ ******************************************************************************/ package forestry.mail.tiles; -import java.util.Collection; -import java.util.LinkedList; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import com.mojang.authlib.GameProfile; -import net.minecraftforge.fml.common.Optional; - import forestry.api.mail.ILetter; import forestry.api.mail.IMailAddress; import forestry.api.mail.IPostalState; @@ -36,9 +29,6 @@ import forestry.mail.POBox; import forestry.mail.PostRegistry; import forestry.mail.gui.ContainerMailbox; import forestry.mail.gui.GuiMailbox; -import forestry.mail.triggers.MailTriggers; - -import buildcraft.api.statements.ITriggerExternal; public class TileMailbox extends TileBase implements IMailContainer { @@ -114,13 +104,14 @@ public class TileMailbox extends TileBase implements IMailContainer { return false; } - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { - LinkedList res = new LinkedList<>(); - res.add(MailTriggers.triggerHasMail); - return res; - } + // TODO: Buildcraft for 1.9 +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { +// LinkedList res = new LinkedList<>(); +// res.add(MailTriggers.triggerHasMail); +// return res; +// } @Override public Object getGui(EntityPlayer player, int data) { diff --git a/src/main/java/forestry/mail/tiles/TileTrader.java b/src/main/java/forestry/mail/tiles/TileTrader.java index 3791c90c7..dd8e001a1 100644 --- a/src/main/java/forestry/mail/tiles/TileTrader.java +++ b/src/main/java/forestry/mail/tiles/TileTrader.java @@ -11,18 +11,12 @@ package forestry.mail.tiles; import java.io.IOException; -import java.util.Collection; -import java.util.LinkedList; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.fml.common.Optional; import forestry.api.core.IErrorLogic; import forestry.api.mail.IMailAddress; @@ -44,9 +38,6 @@ import forestry.mail.gui.GuiTradeName; import forestry.mail.gui.GuiTrader; import forestry.mail.inventory.InventoryTradeStation; import forestry.mail.network.packets.PacketTraderAddressResponse; -import forestry.mail.triggers.MailTriggers; - -import buildcraft.api.statements.ITriggerExternal; public class TileTrader extends TileBase { @@ -59,7 +50,7 @@ public class TileTrader extends TileBase { } @Override - public void openGui(EntityPlayer player) { + public void openGui(EntityPlayer player, ItemStack heldItem) { short data = (short) (isLinked() ? 0 : 1); GuiHandler.openGui(player, this, data); } @@ -312,20 +303,21 @@ public class TileTrader extends TileBase { return (TradeStation) PostManager.postRegistry.getOrCreateTradeStation(worldObj, getAccessHandler().getOwner(), address); } - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { - LinkedList res = new LinkedList<>(); - res.add(MailTriggers.lowPaper64); - res.add(MailTriggers.lowPaper32); - res.add(MailTriggers.lowInput25); - res.add(MailTriggers.lowInput10); - res.add(MailTriggers.lowPostage40); - res.add(MailTriggers.lowPostage20); - res.add(MailTriggers.highBuffer90); - res.add(MailTriggers.highBuffer75); - return res; - } + // TODO: Buildcraft for 1.9 +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { +// LinkedList res = new LinkedList<>(); +// res.add(MailTriggers.lowPaper64); +// res.add(MailTriggers.lowPaper32); +// res.add(MailTriggers.lowInput25); +// res.add(MailTriggers.lowInput10); +// res.add(MailTriggers.lowPostage40); +// res.add(MailTriggers.lowPostage20); +// res.add(MailTriggers.highBuffer90); +// res.add(MailTriggers.highBuffer75); +// return res; +// } @Override public Object getGui(EntityPlayer player, int data) { diff --git a/src/main/java/forestry/mail/triggers/MailTriggers.java b/src/main/java/forestry/mail/triggers/MailTriggers.java index aa57d1d73..907df2903 100644 --- a/src/main/java/forestry/mail/triggers/MailTriggers.java +++ b/src/main/java/forestry/mail/triggers/MailTriggers.java @@ -10,28 +10,27 @@ ******************************************************************************/ package forestry.mail.triggers; -import forestry.core.triggers.Trigger; - +// TODO: Buildcraft for 1.9 public class MailTriggers { - public static Trigger triggerHasMail; - public static Trigger lowPaper64; - public static Trigger lowPaper32; - public static Trigger lowPostage40; - public static Trigger lowPostage20; - public static Trigger lowInput25; - public static Trigger lowInput10; - public static Trigger highBuffer75; - public static Trigger highBuffer90; - - public static void initialize() { - triggerHasMail = new TriggerHasMail(); - lowPaper64 = new TriggerLowPaper("mail.lowPaper.64", 64); - lowPaper32 = new TriggerLowPaper("mail.lowPaper.32", 32); - lowPostage40 = new TriggerLowStamps("mail.lowStamps.40", 40); - lowPostage20 = new TriggerLowStamps("mail.lowStamps.20", 20); - lowInput25 = new TriggerLowInput("mail.lowInput.25", 0.25f); - lowInput10 = new TriggerLowInput("mail.lowInput.10", 0.1f); - highBuffer75 = new TriggerBuffer("mail.lowBuffer.75", 0.75f); - highBuffer90 = new TriggerBuffer("mail.lowBuffer.90", 0.90f); - } +// public static Trigger triggerHasMail; +// public static Trigger lowPaper64; +// public static Trigger lowPaper32; +// public static Trigger lowPostage40; +// public static Trigger lowPostage20; +// public static Trigger lowInput25; +// public static Trigger lowInput10; +// public static Trigger highBuffer75; +// public static Trigger highBuffer90; +// +// public static void initialize() { +// triggerHasMail = new TriggerHasMail(); +// lowPaper64 = new TriggerLowPaper("mail.lowPaper.64", 64); +// lowPaper32 = new TriggerLowPaper("mail.lowPaper.32", 32); +// lowPostage40 = new TriggerLowStamps("mail.lowStamps.40", 40); +// lowPostage20 = new TriggerLowStamps("mail.lowStamps.20", 20); +// lowInput25 = new TriggerLowInput("mail.lowInput.25", 0.25f); +// lowInput10 = new TriggerLowInput("mail.lowInput.10", 0.1f); +// highBuffer75 = new TriggerBuffer("mail.lowBuffer.75", 0.75f); +// highBuffer90 = new TriggerBuffer("mail.lowBuffer.90", 0.90f); +// } } diff --git a/src/main/java/forestry/mail/triggers/TriggerBuffer.java b/src/main/java/forestry/mail/triggers/TriggerBuffer.java index 6e149c5db..d6690e32a 100755 --- a/src/main/java/forestry/mail/triggers/TriggerBuffer.java +++ b/src/main/java/forestry/mail/triggers/TriggerBuffer.java @@ -10,36 +10,28 @@ ******************************************************************************/ package forestry.mail.triggers; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +// TODO: Buildcraft for 1.9 +public class TriggerBuffer {//extends Trigger { -import forestry.core.triggers.Trigger; -import forestry.mail.tiles.TileTrader; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; - -public class TriggerBuffer extends Trigger { - - private final float threshold; - - public TriggerBuffer(String tag, float threshold) { - super(tag, "mailBuffer"); - this.threshold = threshold; - } - - @Override - public String getDescription() { - return super.getDescription() + " > " + threshold * 100 + "%"; - } - - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - - if (!(tile instanceof TileTrader)) { - return false; - } - - return ((TileTrader) tile).hasOutputBufMin(threshold); - } +// private final float threshold; +// +// public TriggerBuffer(String tag, float threshold) { +// super(tag, "mailBuffer"); +// this.threshold = threshold; +// } +// +// @Override +// public String getDescription() { +// return super.getDescription() + " > " + threshold * 100 + "%"; +// } +// +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// +// if (!(tile instanceof TileTrader)) { +// return false; +// } +// +// return ((TileTrader) tile).hasOutputBufMin(threshold); +// } } diff --git a/src/main/java/forestry/mail/triggers/TriggerHasMail.java b/src/main/java/forestry/mail/triggers/TriggerHasMail.java index c1e5186d1..7dc81ddcf 100755 --- a/src/main/java/forestry/mail/triggers/TriggerHasMail.java +++ b/src/main/java/forestry/mail/triggers/TriggerHasMail.java @@ -10,29 +10,21 @@ ******************************************************************************/ package forestry.mail.triggers; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +// TODO: Buildcraft for 1.9 +public class TriggerHasMail {//extends Trigger { -import forestry.core.triggers.Trigger; -import forestry.mail.tiles.IMailContainer; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; - -public class TriggerHasMail extends Trigger { - - public TriggerHasMail() { - super("mail.hasMail", "hasMail"); - } - - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - - if (!(tile instanceof IMailContainer)) { - return false; - } - - return ((IMailContainer) tile).hasMail(); - } +// public TriggerHasMail() { +// super("mail.hasMail", "hasMail"); +// } +// +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// +// if (!(tile instanceof IMailContainer)) { +// return false; +// } +// +// return ((IMailContainer) tile).hasMail(); +// } } diff --git a/src/main/java/forestry/mail/triggers/TriggerLowInput.java b/src/main/java/forestry/mail/triggers/TriggerLowInput.java index b185dea60..d8a440519 100755 --- a/src/main/java/forestry/mail/triggers/TriggerLowInput.java +++ b/src/main/java/forestry/mail/triggers/TriggerLowInput.java @@ -10,36 +10,28 @@ ******************************************************************************/ package forestry.mail.triggers; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +// TODO: Buildcraft for 1.9 +public class TriggerLowInput {//extends Trigger { -import forestry.core.triggers.Trigger; -import forestry.mail.tiles.TileTrader; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; - -public class TriggerLowInput extends Trigger { - - private final float threshold; - - public TriggerLowInput(String tag, float threshold) { - super(tag, "lowInput"); - this.threshold = threshold; - } - - @Override - public String getDescription() { - return super.getDescription() + " < " + threshold * 100 + "%"; - } - - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - - if (!(tile instanceof TileTrader)) { - return false; - } - - return !((TileTrader) tile).hasInputBufMin(threshold); - } +// private final float threshold; +// +// public TriggerLowInput(String tag, float threshold) { +// super(tag, "lowInput"); +// this.threshold = threshold; +// } +// +// @Override +// public String getDescription() { +// return super.getDescription() + " < " + threshold * 100 + "%"; +// } +// +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// +// if (!(tile instanceof TileTrader)) { +// return false; +// } +// +// return !((TileTrader) tile).hasInputBufMin(threshold); +// } } diff --git a/src/main/java/forestry/mail/triggers/TriggerLowPaper.java b/src/main/java/forestry/mail/triggers/TriggerLowPaper.java index 665186949..e7d4138a4 100755 --- a/src/main/java/forestry/mail/triggers/TriggerLowPaper.java +++ b/src/main/java/forestry/mail/triggers/TriggerLowPaper.java @@ -10,37 +10,29 @@ ******************************************************************************/ package forestry.mail.triggers; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; +// TODO: Buildcraft for 1.9 +public class TriggerLowPaper {//} extends Trigger { -import forestry.core.triggers.Trigger; -import forestry.mail.tiles.TileTrader; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; - -public class TriggerLowPaper extends Trigger { - - private final int threshold; - - public TriggerLowPaper(String tag, int threshold) { - super(tag, "lowPaper"); - this.threshold = threshold; - } - - @Override - public String getDescription() { - return super.getDescription() + " < " + threshold; - } - - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - - if (!(tile instanceof TileTrader)) { - return false; - } - - return !((TileTrader) tile).hasPaperMin(threshold); - } +// private final int threshold; +// +// public TriggerLowPaper(String tag, int threshold) { +// super(tag, "lowPaper"); +// this.threshold = threshold; +// } +// +// @Override +// public String getDescription() { +// return super.getDescription() + " < " + threshold; +// } +// +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// +// if (!(tile instanceof TileTrader)) { +// return false; +// } +// +// return !((TileTrader) tile).hasPaperMin(threshold); +// } } diff --git a/src/main/java/forestry/mail/triggers/TriggerLowStamps.java b/src/main/java/forestry/mail/triggers/TriggerLowStamps.java index 22c6b1bbf..e83bdadf4 100755 --- a/src/main/java/forestry/mail/triggers/TriggerLowStamps.java +++ b/src/main/java/forestry/mail/triggers/TriggerLowStamps.java @@ -10,37 +10,29 @@ ******************************************************************************/ package forestry.mail.triggers; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import forestry.core.triggers.Trigger; -import forestry.mail.tiles.TileTrader; - -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.IStatementParameter; - -public class TriggerLowStamps extends Trigger { - - private final int threshold; - - public TriggerLowStamps(String tag, int threshold) { - super(tag, "lowStamps"); - this.threshold = threshold; - } - - @Override - public String getDescription() { - return super.getDescription() + " < " + threshold + "p"; - } - - @Override - public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { - - if (!(tile instanceof TileTrader)) { - return false; - } - - return !((TileTrader) tile).hasPostageMin(threshold); - } +// TODO: Buildcraft for 1.9 +public class TriggerLowStamps {//extends Trigger { +// +// private final int threshold; +// +// public TriggerLowStamps(String tag, int threshold) { +// super(tag, "lowStamps"); +// this.threshold = threshold; +// } +// +// @Override +// public String getDescription() { +// return super.getDescription() + " < " + threshold + "p"; +// } +// +// @Override +// public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { +// +// if (!(tile instanceof TileTrader)) { +// return false; +// } +// +// return !((TileTrader) tile).hasPostageMin(threshold); +// } } diff --git a/src/main/java/forestry/plugins/compat/PluginBuildCraftFuels.java b/src/main/java/forestry/plugins/compat/PluginBuildCraftFuels.java index 3881d382b..7c6fe2aae 100644 --- a/src/main/java/forestry/plugins/compat/PluginBuildCraftFuels.java +++ b/src/main/java/forestry/plugins/compat/PluginBuildCraftFuels.java @@ -10,21 +10,13 @@ ******************************************************************************/ package forestry.plugins.compat; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fml.common.Optional; - -import forestry.api.core.ForestryAPI; import forestry.core.config.Constants; -import forestry.core.fluids.Fluids; import forestry.core.utils.ModUtil; import forestry.plugins.BlankForestryPlugin; import forestry.plugins.ForestryPlugin; import forestry.plugins.ForestryPluginUids; -import buildcraft.api.fuels.BuildcraftFuelRegistry; -import buildcraft.api.fuels.ICoolant; -import buildcraft.api.fuels.ICoolantManager; - +// TODO: Buildcraft for 1.9 @ForestryPlugin(pluginID = ForestryPluginUids.BUILDCRAFT_FUELS, name = "BuildCraft 6 Fuels", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") public class PluginBuildCraftFuels extends BlankForestryPlugin { @@ -38,21 +30,21 @@ public class PluginBuildCraftFuels extends BlankForestryPlugin { return "Compatible BuildCraftAPI|fuels version not found"; } - @Optional.Method(modid = "BuildCraftAPI|fuels") - @Override - public void doInit() { - ICoolantManager coolantManager = BuildcraftFuelRegistry.coolant; - ICoolant waterCoolant = coolantManager.getCoolant(Fluids.WATER.getFluid()); - float waterCooling = waterCoolant.getDegreesCoolingPerMB(100); - - coolantManager.addCoolant(Fluids.ICE.getFluid(), Constants.ICE_COOLING_MULTIPLIER * waterCooling); - - Fluid ethanol = Fluids.BIO_ETHANOL.getFluid(); - if (ethanol != null) { - int ethanolPower = 40; - int ethanolBurnTime = Math.round(Constants.ENGINE_CYCLE_DURATION_ETHANOL * ForestryAPI.activeMode.getFloatSetting("fuel.ethanol.combustion")); - BuildcraftFuelRegistry.fuel.addFuel(ethanol, ethanolPower, ethanolBurnTime); - } - } +// @Optional.Method(modid = "BuildCraftAPI|fuels") +// @Override +// public void doInit() { +// ICoolantManager coolantManager = BuildcraftFuelRegistry.coolant; +// ICoolant waterCoolant = coolantManager.getCoolant(Fluids.WATER.getFluid()); +// float waterCooling = waterCoolant.getDegreesCoolingPerMB(100); +// +// coolantManager.addCoolant(Fluids.ICE.getFluid(), Constants.ICE_COOLING_MULTIPLIER * waterCooling); +// +// Fluid ethanol = Fluids.BIO_ETHANOL.getFluid(); +// if (ethanol != null) { +// int ethanolPower = 40; +// int ethanolBurnTime = Math.round(Constants.ENGINE_CYCLE_DURATION_ETHANOL * ForestryAPI.activeMode.getFloatSetting("fuel.ethanol.combustion")); +// BuildcraftFuelRegistry.fuel.addFuel(ethanol, ethanolPower, ethanolBurnTime); +// } +// } } diff --git a/src/main/java/forestry/plugins/compat/PluginBuildCraftRecipes.java b/src/main/java/forestry/plugins/compat/PluginBuildCraftRecipes.java index bd3b4d499..cd7bbee70 100644 --- a/src/main/java/forestry/plugins/compat/PluginBuildCraftRecipes.java +++ b/src/main/java/forestry/plugins/compat/PluginBuildCraftRecipes.java @@ -13,13 +13,11 @@ package forestry.plugins.compat; import net.minecraftforge.fml.common.Optional; import forestry.core.config.Constants; -import forestry.core.fluids.Fluids; import forestry.core.utils.ModUtil; import forestry.plugins.BlankForestryPlugin; import forestry.plugins.ForestryPlugin; import forestry.plugins.ForestryPluginUids; -import buildcraft.api.recipes.BuildcraftRecipeRegistry; @ForestryPlugin(pluginID = ForestryPluginUids.BUILDCRAFT_RECIPES, name = "BuildCraft 6 Recipes", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") public class PluginBuildCraftRecipes extends BlankForestryPlugin { @@ -38,6 +36,7 @@ public class PluginBuildCraftRecipes extends BlankForestryPlugin { @Override public void registerRecipes() { // Add recipe for ethanol - BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", Fluids.BIOMASS.getFluid(4), Fluids.BIO_ETHANOL.getFluid(1), 100, 1); + // TODO: Buildcraft for 1.9 +// BuildcraftRecipeRegistry.refinery.addRecipe("forestry:BiomassToEthanol", Fluids.BIOMASS.getFluid(4), Fluids.BIO_ETHANOL.getFluid(1), 100, 1); } } diff --git a/src/main/java/forestry/plugins/compat/PluginBuildCraftStatements.java b/src/main/java/forestry/plugins/compat/PluginBuildCraftStatements.java index cc9c9174d..4fae913d1 100644 --- a/src/main/java/forestry/plugins/compat/PluginBuildCraftStatements.java +++ b/src/main/java/forestry/plugins/compat/PluginBuildCraftStatements.java @@ -10,11 +10,6 @@ ******************************************************************************/ package forestry.plugins.compat; -import java.util.Collection; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - import net.minecraftforge.fml.common.Optional; import forestry.core.config.Constants; @@ -23,15 +18,9 @@ import forestry.plugins.BlankForestryPlugin; import forestry.plugins.ForestryPlugin; import forestry.plugins.ForestryPluginUids; -import buildcraft.api.statements.IStatementContainer; -import buildcraft.api.statements.ITriggerExternal; -import buildcraft.api.statements.ITriggerInternal; -import buildcraft.api.statements.ITriggerProvider; -import buildcraft.api.statements.StatementManager; - @ForestryPlugin(pluginID = ForestryPluginUids.BUILDCRAFT_STATEMENTS, name = "BuildCraft 6 Statements", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.plugin.buildcraft6.description") -@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") -public class PluginBuildCraftStatements extends BlankForestryPlugin implements ITriggerProvider { +//@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") +public class PluginBuildCraftStatements extends BlankForestryPlugin {//implements ITriggerProvider { @Override public boolean isAvailable() { @@ -47,29 +36,31 @@ public class PluginBuildCraftStatements extends BlankForestryPlugin implements I @Override public void doInit() { // Add custom trigger handler - StatementManager.registerTriggerProvider(this); + // TODO: Buildcraft for 1.9 +// StatementManager.registerTriggerProvider(this); } /* ITriggerProvider */ - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getInternalTriggers(IStatementContainer container) { - TileEntity tile = container.getTile(); - if (tile instanceof ITriggerProvider) { - return ((ITriggerProvider) tile).getInternalTriggers(container); - } - - return null; - } - - @Optional.Method(modid = "BuildCraftAPI|statements") - @Override - public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { - if (tile instanceof ITriggerProvider) { - return ((ITriggerProvider) tile).getExternalTriggers(side, tile); - } - - return null; - } + // TODO: Buildcraft for 1.9 +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getInternalTriggers(IStatementContainer container) { +// TileEntity tile = container.getTile(); +// if (tile instanceof ITriggerProvider) { +// return ((ITriggerProvider) tile).getInternalTriggers(container); +// } +// +// return null; +// } +// +// @Optional.Method(modid = "BuildCraftAPI|statements") +// @Override +// public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { +// if (tile instanceof ITriggerProvider) { +// return ((ITriggerProvider) tile).getExternalTriggers(side, tile); +// } +// +// return null; +// } } diff --git a/src/main/java/forestry/plugins/compat/PluginIC2.java b/src/main/java/forestry/plugins/compat/PluginIC2.java index b022717e2..a91acf5fd 100644 --- a/src/main/java/forestry/plugins/compat/PluginIC2.java +++ b/src/main/java/forestry/plugins/compat/PluginIC2.java @@ -10,63 +10,18 @@ ******************************************************************************/ package forestry.plugins.compat; -import com.google.common.collect.ImmutableMap; - import javax.annotation.Nonnull; import java.util.Set; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.common.Optional; -import net.minecraftforge.fml.common.event.FMLInterModComms; - -import forestry.api.circuits.ChipsetManager; -import forestry.api.circuits.CircuitSocketType; -import forestry.api.circuits.ICircuitLayout; -import forestry.api.core.ForestryAPI; -import forestry.api.farming.Farmables; -import forestry.api.fuels.EngineBronzeFuel; -import forestry.api.fuels.FuelManager; -import forestry.api.recipes.RecipeManagers; -import forestry.api.storage.BackpackManager; -import forestry.api.storage.IBackpackDefinition; -import forestry.api.storage.ICrateRegistry; -import forestry.api.storage.StorageManager; -import forestry.apiculture.PluginApiculture; -import forestry.apiculture.items.EnumPropolis; -import forestry.apiculture.items.ItemRegistryApiculture; -import forestry.core.PluginCore; -import forestry.core.blocks.BlockSoil; -import forestry.core.circuits.Circuit; -import forestry.core.circuits.CircuitLayout; import forestry.core.config.Constants; -import forestry.core.fluids.Fluids; -import forestry.core.items.EnumElectronTube; -import forestry.core.items.ItemRegistryCore; -import forestry.core.recipes.RecipeUtil; -import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.Log; import forestry.core.utils.ModUtil; -import forestry.energy.PluginEnergy; -import forestry.energy.blocks.BlockRegistryEnergy; -import forestry.energy.blocks.BlockTypeEngine; -import forestry.energy.circuits.CircuitElectricBoost; -import forestry.energy.circuits.CircuitElectricChoke; -import forestry.energy.circuits.CircuitElectricEfficiency; -import forestry.farming.circuits.CircuitFarmLogic; -import forestry.farming.logic.FarmLogicRubber; -import forestry.farming.logic.FarmableBasicIC2Crop; import forestry.plugins.BlankForestryPlugin; import forestry.plugins.ForestryPlugin; import forestry.plugins.ForestryPluginUids; -import ic2.api.item.IC2Items; -import ic2.api.recipe.RecipeInputItemStack; -import ic2.api.recipe.Recipes; - +// TODO: IC2 for 1.9 @ForestryPlugin(pluginID = "IC2", name = "IndustrialCraft2", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.ic2.description") public class PluginIC2 extends BlankForestryPlugin { public static final String modId = "IC2"; @@ -102,214 +57,214 @@ public class PluginIC2 extends BlankForestryPlugin { return dependencyUids; } - @Override - @Optional.Method(modid = PluginIC2.modId) - public void preInit() { - super.preInit(); - - BlockRegistryEnergy energyBlocks = PluginEnergy.blocks; - if (energyBlocks != null) { - energyBlocks.engine.addDefinitions(BlockTypeEngine.ELECTRICAL); - energyBlocks.engine.addDefinitions(BlockTypeEngine.GENERATOR); - } - - // rubber chain - rubberWood = IC2Items.getItem("rubber_wood"); - resin = IC2Items.getItem("misc_resource", "resin"); - rubberSapling = IC2Items.getItem("sapling"); - rubber = IC2Items.getItem("crafting", "rubber"); - - Circuit.farmRubberManual = new CircuitFarmLogic("manualRubber", FarmLogicRubber.class); - - ICircuitLayout layoutEngineTin = new CircuitLayout("engine.tin", CircuitSocketType.ELECTRIC_ENGINE); - ChipsetManager.circuitRegistry.registerLayout(layoutEngineTin); - } - - @Override - @Optional.Method(modid = PluginIC2.modId) - public void doInit() { - super.doInit(); - - // Remove some items from the recycler - if (Recipes.recyclerBlacklist != null) { - ItemRegistryApiculture beeItems = PluginApiculture.items; - if (beeItems != null) { - Recipes.recyclerBlacklist.add(new RecipeInputItemStack(new ItemStack(beeItems.beeQueenGE))); - Recipes.recyclerBlacklist.add(new RecipeInputItemStack(new ItemStack(beeItems.beePrincessGE))); - } - } else { - Log.error("IC2 Recipes.recyclerBlacklist not found."); - } - - Circuit.energyElectricChoke1 = new CircuitElectricChoke("electric.choke.1"); - Circuit.energyElectricEfficiency1 = new CircuitElectricEfficiency("electric.efficiency.1"); - Circuit.energyElectricBoost1 = new CircuitElectricBoost("electric.boost.1", 2, 7, 20); - Circuit.energyElectricBoost2 = new CircuitElectricBoost("electric.boost.2", 2, 15, 40); - } - - @Override - public void postInit() { - super.postInit(); - - if (BackpackManager.backpackInterface == null) { - return; - } - - IBackpackDefinition forester = BackpackManager.backpackInterface.getBackpack(BackpackManager.FORESTER_UID); - - if (resin != null) { - forester.addValidItem(resin); - } - if (rubber != null) { - forester.addValidItem(rubber); - } - if (rubberSapling != null) { - forester.addValidItem(rubberSapling); - } - ItemStack rubberLeaves = IC2Items.getItem("leaves"); - if (rubberLeaves != null) { - forester.addValidItem(rubberLeaves); - } - } - - @Override - public void registerCrates() { - ICrateRegistry crateRegistry = StorageManager.crateRegistry; - if (crateRegistry == null) { - return; - } - - if (resin != null) { - crateRegistry.registerCrate(resin); - } - - if (rubber != null) { - crateRegistry.registerCrate(rubber); - } - - ItemStack scrap = IC2Items.getItem("crafting", "scrap"); - if (scrap != null) { - crateRegistry.registerCrate(scrap); - } - - ItemStack uuMatter = IC2Items.getItem("misc_resource", "matter"); - if (uuMatter != null) { - crateRegistry.registerCrate(uuMatter); - } - - ItemStack silver = IC2Items.getItem("ingot", "silver"); - if (silver != null) { - crateRegistry.registerCrateUsingOreDict(silver); - } - - ItemStack brass = IC2Items.getItem("ingot", "bronze"); - if (brass != null) { - crateRegistry.registerCrateUsingOreDict(brass); - } - } - - @Override - @Optional.Method(modid = PluginIC2.modId) - public void registerRecipes() { - ItemRegistryCore coreItems = PluginCore.items; - - if (rubber != null) { - for (Object rubberOreDict : RecipeUtil.getOreDictRecipeEquivalents(rubber)) { - RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), coreItems.tubes.get(EnumElectronTube.RUBBER, 4), - new Object[]{" X ", "#X#", "XXX", '#', "dustRedstone", 'X', rubberOreDict}); - } - } - - ItemStack plantBall = IC2Items.getItem("crafting", "plant_ball"); - if (plantBall != null) { - RecipeUtil.addFermenterRecipes(plantBall, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS); - } - - ItemStack bioChaff = IC2Items.getItem("crafting", "bio_chaff"); - if (bioChaff != null) { - RecipeUtil.addFermenterRecipes(bioChaff, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS); - } - - ItemRegistryApiculture beeItems = PluginApiculture.items; - if (beeItems != null) { - if (resin != null) { - RecipeManagers.centrifugeManager.addRecipe(20, beeItems.propolis.get(EnumPropolis.NORMAL, 1), ImmutableMap.of(resin, 1.0f)); - } else { - Log.info("Missing IC2 resin, skipping centrifuge recipe for propolis to resin."); - } - } - - if (rubberSapling != null) { - RecipeUtil.addFermenterRecipes(rubberSapling, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); - } else { - Log.info("Missing IC2 rubber sapling, skipping fermenter recipe for converting rubber sapling to biomass."); - } - - if (rubberSapling != null && resin != null) { - String saplingName = ItemStackUtil.getBlockNameFromRegistryAsSting(ItemStackUtil.getBlock(rubberSapling)); - String resinName = ItemStackUtil.getItemNameFromRegistryAsString(resin.getItem()); - String imc = String.format("farmArboreal@%s.%s.%s.%s", - saplingName, rubberSapling.getItemDamage(), - resinName, resin.getItemDamage()); - Log.trace("Sending IMC '%s'.", imc); - FMLInterModComms.sendMessage(Constants.MOD_ID, "add-farmable-sapling", imc); - } - - - if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ENERGY)) { - FluidStack biogas = FluidRegistry.getFluidStack("ic2biogas", 1000); - if (biogas != null) { - int burnDuration = Math.round(Constants.ENGINE_CYCLE_DURATION_BIOMASS * ForestryAPI.activeMode.getFloatSetting("fuel.biomass.biogas")); - EngineBronzeFuel bronzeFuel = new EngineBronzeFuel(Fluids.BIOMASS.getFluid(), Constants.ENGINE_FUEL_VALUE_BIOMASS, burnDuration, 1); - FuelManager.bronzeEngineFuel.put(biogas.getFluid(), bronzeFuel); - } - } - - ItemStack waterCell = IC2Items.getItem("fluid_cell", "water"); - if (waterCell != null) { - int bogEarthOutputCan = ForestryAPI.activeMode.getIntegerSetting("recipe.output.bogearth.can"); - if (bogEarthOutputCan > 0) { - ItemStack bogEarthCan = PluginCore.blocks.soil.get(BlockSoil.SoilType.BOG_EARTH, bogEarthOutputCan); - RecipeUtil.addRecipe(bogEarthCan, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', waterCell, 'Y', "sand"); - } - } - - ICircuitLayout layout = ChipsetManager.circuitRegistry.getLayout("forestry.engine.tin"); - - // / Solder Manager - ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.COPPER, 1), Circuit.energyElectricChoke1); - ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuit.energyElectricBoost1); - ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuit.energyElectricBoost2); - ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.IRON, 1), Circuit.energyElectricEfficiency1); - - if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING)) { - if (resin != null && rubberWood != null) { - ICircuitLayout layoutManual = ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual"); - ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.RUBBER, 1), Circuit.farmRubberManual); - } - - Farmables.farmables.get("farmOrchard").add(new FarmableBasicIC2Crop()); - } - - - BlockRegistryEnergy energyBlocks = PluginEnergy.blocks; - if (energyBlocks != null) { - RecipeUtil.addRecipe(energyBlocks.engine.get(BlockTypeEngine.GENERATOR), - "X#X", - "XYX", - "X#X", - '#', "blockGlass", - 'X', "ingotGold", - 'Y', coreItems.sturdyCasing); - - RecipeUtil.addRecipe(energyBlocks.engine.get(BlockTypeEngine.ELECTRICAL), - "###", - " X ", - "YVY", - '#', "ingotTin", - 'X', "blockGlass", - 'Y', "gearTin", - 'V', Blocks.PISTON); - } - } +// @Override +// @Optional.Method(modid = PluginIC2.modId) +// public void preInit() { +// super.preInit(); +// +// BlockRegistryEnergy energyBlocks = PluginEnergy.blocks; +// if (energyBlocks != null) { +// energyBlocks.engine.addDefinitions(BlockTypeEngine.ELECTRICAL); +// energyBlocks.engine.addDefinitions(BlockTypeEngine.GENERATOR); +// } +// +// // rubber chain +// rubberWood = IC2Items.getItem("rubber_wood"); +// resin = IC2Items.getItem("misc_resource", "resin"); +// rubberSapling = IC2Items.getItem("sapling"); +// rubber = IC2Items.getItem("crafting", "rubber"); +// +// Circuit.farmRubberManual = new CircuitFarmLogic("manualRubber", FarmLogicRubber.class); +// +// ICircuitLayout layoutEngineTin = new CircuitLayout("engine.tin", CircuitSocketType.ELECTRIC_ENGINE); +// ChipsetManager.circuitRegistry.registerLayout(layoutEngineTin); +// } +// +// @Override +// @Optional.Method(modid = PluginIC2.modId) +// public void doInit() { +// super.doInit(); +// +// // Remove some items from the recycler +// if (Recipes.recyclerBlacklist != null) { +// ItemRegistryApiculture beeItems = PluginApiculture.items; +// if (beeItems != null) { +// Recipes.recyclerBlacklist.add(new RecipeInputItemStack(new ItemStack(beeItems.beeQueenGE))); +// Recipes.recyclerBlacklist.add(new RecipeInputItemStack(new ItemStack(beeItems.beePrincessGE))); +// } +// } else { +// Log.error("IC2 Recipes.recyclerBlacklist not found."); +// } +// +// Circuit.energyElectricChoke1 = new CircuitElectricChoke("electric.choke.1"); +// Circuit.energyElectricEfficiency1 = new CircuitElectricEfficiency("electric.efficiency.1"); +// Circuit.energyElectricBoost1 = new CircuitElectricBoost("electric.boost.1", 2, 7, 20); +// Circuit.energyElectricBoost2 = new CircuitElectricBoost("electric.boost.2", 2, 15, 40); +// } +// +// @Override +// public void postInit() { +// super.postInit(); +// +// if (BackpackManager.backpackInterface == null) { +// return; +// } +// +// IBackpackDefinition forester = BackpackManager.backpackInterface.getBackpack(BackpackManager.FORESTER_UID); +// +// if (resin != null) { +// forester.addValidItem(resin); +// } +// if (rubber != null) { +// forester.addValidItem(rubber); +// } +// if (rubberSapling != null) { +// forester.addValidItem(rubberSapling); +// } +// ItemStack rubberLeaves = IC2Items.getItem("leaves"); +// if (rubberLeaves != null) { +// forester.addValidItem(rubberLeaves); +// } +// } +// +// @Override +// public void registerCrates() { +// ICrateRegistry crateRegistry = StorageManager.crateRegistry; +// if (crateRegistry == null) { +// return; +// } +// +// if (resin != null) { +// crateRegistry.registerCrate(resin); +// } +// +// if (rubber != null) { +// crateRegistry.registerCrate(rubber); +// } +// +// ItemStack scrap = IC2Items.getItem("crafting", "scrap"); +// if (scrap != null) { +// crateRegistry.registerCrate(scrap); +// } +// +// ItemStack uuMatter = IC2Items.getItem("misc_resource", "matter"); +// if (uuMatter != null) { +// crateRegistry.registerCrate(uuMatter); +// } +// +// ItemStack silver = IC2Items.getItem("ingot", "silver"); +// if (silver != null) { +// crateRegistry.registerCrateUsingOreDict(silver); +// } +// +// ItemStack brass = IC2Items.getItem("ingot", "bronze"); +// if (brass != null) { +// crateRegistry.registerCrateUsingOreDict(brass); +// } +// } +// +// @Override +// @Optional.Method(modid = PluginIC2.modId) +// public void registerRecipes() { +// ItemRegistryCore coreItems = PluginCore.items; +// +// if (rubber != null) { +// for (Object rubberOreDict : RecipeUtil.getOreDictRecipeEquivalents(rubber)) { +// RecipeManagers.fabricatorManager.addRecipe(null, Fluids.GLASS.getFluid(500), coreItems.tubes.get(EnumElectronTube.RUBBER, 4), +// new Object[]{" X ", "#X#", "XXX", '#', "dustRedstone", 'X', rubberOreDict}); +// } +// } +// +// ItemStack plantBall = IC2Items.getItem("crafting", "plant_ball"); +// if (plantBall != null) { +// RecipeUtil.addFermenterRecipes(plantBall, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS); +// } +// +// ItemStack bioChaff = IC2Items.getItem("crafting", "bio_chaff"); +// if (bioChaff != null) { +// RecipeUtil.addFermenterRecipes(bioChaff, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS); +// } +// +// ItemRegistryApiculture beeItems = PluginApiculture.items; +// if (beeItems != null) { +// if (resin != null) { +// RecipeManagers.centrifugeManager.addRecipe(20, beeItems.propolis.get(EnumPropolis.NORMAL, 1), ImmutableMap.of(resin, 1.0f)); +// } else { +// Log.info("Missing IC2 resin, skipping centrifuge recipe for propolis to resin."); +// } +// } +// +// if (rubberSapling != null) { +// RecipeUtil.addFermenterRecipes(rubberSapling, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS); +// } else { +// Log.info("Missing IC2 rubber sapling, skipping fermenter recipe for converting rubber sapling to biomass."); +// } +// +// if (rubberSapling != null && resin != null) { +// String saplingName = ItemStackUtil.getBlockNameFromRegistryAsSting(ItemStackUtil.getBlock(rubberSapling)); +// String resinName = ItemStackUtil.getItemNameFromRegistryAsString(resin.getItem()); +// String imc = String.format("farmArboreal@%s.%s.%s.%s", +// saplingName, rubberSapling.getItemDamage(), +// resinName, resin.getItemDamage()); +// Log.trace("Sending IMC '%s'.", imc); +// FMLInterModComms.sendMessage(Constants.MOD_ID, "add-farmable-sapling", imc); +// } +// +// +// if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ENERGY)) { +// FluidStack biogas = FluidRegistry.getFluidStack("ic2biogas", 1000); +// if (biogas != null) { +// int burnDuration = Math.round(Constants.ENGINE_CYCLE_DURATION_BIOMASS * ForestryAPI.activeMode.getFloatSetting("fuel.biomass.biogas")); +// EngineBronzeFuel bronzeFuel = new EngineBronzeFuel(Fluids.BIOMASS.getFluid(), Constants.ENGINE_FUEL_VALUE_BIOMASS, burnDuration, 1); +// FuelManager.bronzeEngineFuel.put(biogas.getFluid(), bronzeFuel); +// } +// } +// +// ItemStack waterCell = IC2Items.getItem("fluid_cell", "water"); +// if (waterCell != null) { +// int bogEarthOutputCan = ForestryAPI.activeMode.getIntegerSetting("recipe.output.bogearth.can"); +// if (bogEarthOutputCan > 0) { +// ItemStack bogEarthCan = PluginCore.blocks.soil.get(BlockSoil.SoilType.BOG_EARTH, bogEarthOutputCan); +// RecipeUtil.addRecipe(bogEarthCan, "#Y#", "YXY", "#Y#", '#', Blocks.DIRT, 'X', waterCell, 'Y', "sand"); +// } +// } +// +// ICircuitLayout layout = ChipsetManager.circuitRegistry.getLayout("forestry.engine.tin"); +// +// // / Solder Manager +// ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.COPPER, 1), Circuit.energyElectricChoke1); +// ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuit.energyElectricBoost1); +// ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuit.energyElectricBoost2); +// ChipsetManager.solderManager.addRecipe(layout, coreItems.tubes.get(EnumElectronTube.IRON, 1), Circuit.energyElectricEfficiency1); +// +// if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING)) { +// if (resin != null && rubberWood != null) { +// ICircuitLayout layoutManual = ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual"); +// ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.RUBBER, 1), Circuit.farmRubberManual); +// } +// +// Farmables.farmables.get("farmOrchard").add(new FarmableBasicIC2Crop()); +// } +// +// +// BlockRegistryEnergy energyBlocks = PluginEnergy.blocks; +// if (energyBlocks != null) { +// RecipeUtil.addRecipe(energyBlocks.engine.get(BlockTypeEngine.GENERATOR), +// "X#X", +// "XYX", +// "X#X", +// '#', "blockGlass", +// 'X', "ingotGold", +// 'Y', coreItems.sturdyCasing); +// +// RecipeUtil.addRecipe(energyBlocks.engine.get(BlockTypeEngine.ELECTRICAL), +// "###", +// " X ", +// "YVY", +// '#', "ingotTin", +// 'X', "blockGlass", +// 'Y', "gearTin", +// 'V', Blocks.PISTON); +// } +// } } diff --git a/src/main/java/forestry/storage/items/ItemBackpack.java b/src/main/java/forestry/storage/items/ItemBackpack.java index d48f20488..37e297c12 100755 --- a/src/main/java/forestry/storage/items/ItemBackpack.java +++ b/src/main/java/forestry/storage/items/ItemBackpack.java @@ -15,11 +15,15 @@ import java.util.Locale; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; @@ -50,7 +54,7 @@ import forestry.storage.gui.GuiBackpack; import forestry.storage.gui.GuiBackpackT2; import forestry.storage.inventory.ItemInventoryBackpack; -public class ItemBackpack extends ItemWithGui { +public class ItemBackpack extends ItemWithGui implements IItemColor { private final IBackpackDefinition definition; private final EnumBackpackType type; @@ -74,36 +78,31 @@ public class ItemBackpack extends ItemWithGui { } @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { - if (!world.isRemote) { - if (!player.isSneaking()) { - openGui(player); - } else { - switchMode(itemstack); - } + public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { + if (!playerIn.isSneaking()) { + return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand); + } else { + switchMode(itemStackIn); + return ActionResult.newResult(EnumActionResult.SUCCESS, itemStackIn); } - - return itemstack; } @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { - return getInventoryHit(world, pos, side) != null; + public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + if (getInventoryHit(worldIn, pos, facing) != null) { + return EnumActionResult.SUCCESS; + } + return EnumActionResult.FAIL; } @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { - - if (world.isRemote) { - return false; - } - + public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { // We only do this when shift is clicked if (!player.isSneaking()) { - return false; + return EnumActionResult.FAIL; } - return evaluateTileHit(stack, player, world, pos, side); + return evaluateTileHit(stack, player, world, pos, side) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; } public static ItemStack tryStowing(EntityPlayer player, ItemStack backpackStack, ItemStack stack) { @@ -260,7 +259,7 @@ public class ItemBackpack extends ItemWithGui { } @Override - public int getColorFromItemStack(ItemStack itemstack, int j) { + public int getColorFromItemstack(ItemStack itemstack, int j) { if (j == 0) { return definition.getPrimaryColour();