From ed658301fdb9f68c56c4fe4559c5dbb9d429f6f7 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 5 Jun 2016 21:40:52 -0700 Subject: [PATCH 01/15] Clean up warnings --- .../java/forestry/apiculture/PluginApiculture.java | 2 -- .../forestry/apiculture/VillagerApiaristTrades.java | 3 ++- .../genetics/alleles/AlleleEffectCreeper.java | 2 +- .../forestry/apiculture/proxy/ProxyApiculture.java | 3 --- .../apiculture/proxy/ProxyApicultureClient.java | 4 ---- .../java/forestry/apiculture/render/ModelBee.java | 5 ----- .../forestry/apiculture/worldgen/HiveDecorator.java | 2 +- .../forestry/arboriculture/PluginArboriculture.java | 1 - .../forestry/arboriculture/blocks/BlockPile.java | 13 ++++++------- .../forestry/arboriculture/items/ItemCharcoal.java | 3 --- .../arboriculture/worldgen/WorldGenBalsa.java | 7 ------- .../arboriculture/worldgen/WorldGenDate.java | 7 ------- .../arboriculture/worldgen/WorldGenLarch.java | 7 ------- .../arboriculture/worldgen/WorldGenLemon.java | 7 ------- .../arboriculture/worldgen/WorldGenPlum.java | 7 ------- .../arboriculture/worldgen/WorldGenPoplar.java | 7 ------- .../java/forestry/core/blocks/BlockRegistry.java | 3 --- .../java/forestry/core/blocks/BlockResourceOre.java | 1 - .../java/forestry/core/entities/EntitySelector.java | 5 ----- src/main/java/forestry/core/fluids/TankManager.java | 1 + .../core/items/ItemFluidContainerForestry.java | 2 +- src/main/java/forestry/core/models/ModelCrate.java | 4 ++-- .../forestry/core/models/baker/ModelBakerModel.java | 5 +++-- .../multiblock/MultiblockTileEntityForestry.java | 2 +- src/main/java/forestry/core/proxy/ProxyRender.java | 1 - .../forestry/core/tiles/TileNaturalistChest.java | 2 +- src/main/java/forestry/core/utils/OreDictUtil.java | 7 ------- .../forestry/factory/tiles/TileMillRainmaker.java | 2 +- .../forestry/farming/multiblock/FarmController.java | 11 ----------- src/main/java/forestry/food/items/ItemBeverage.java | 2 +- .../greenhouse/blocks/BlockGreenhouseDoor.java | 2 +- .../lepidopterology/render/ModelButterfly.java | 5 ----- .../lepidopterology/worldgen/CocoonDecorator.java | 2 +- .../plugins/compat/PluginBiomesOPlenty.java | 3 --- src/main/java/forestry/storage/CrateRegistry.java | 1 - 35 files changed, 23 insertions(+), 118 deletions(-) diff --git a/src/main/java/forestry/apiculture/PluginApiculture.java b/src/main/java/forestry/apiculture/PluginApiculture.java index a836d409c..a8aa8455b 100644 --- a/src/main/java/forestry/apiculture/PluginApiculture.java +++ b/src/main/java/forestry/apiculture/PluginApiculture.java @@ -298,8 +298,6 @@ public class PluginApiculture extends BlankForestryPlugin { ); } - proxy.initializeRendering(); - blocks.apiary.init(); blocks.beeHouse.init(); blocks.beeChest.init(); diff --git a/src/main/java/forestry/apiculture/VillagerApiaristTrades.java b/src/main/java/forestry/apiculture/VillagerApiaristTrades.java index db78334bc..79e6c4dcb 100644 --- a/src/main/java/forestry/apiculture/VillagerApiaristTrades.java +++ b/src/main/java/forestry/apiculture/VillagerApiaristTrades.java @@ -1,5 +1,6 @@ package forestry.apiculture; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Random; @@ -24,7 +25,7 @@ public class VillagerApiaristTrades { } @Override - public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) { + public void modifyMerchantRecipeList(@Nonnull MerchantRecipeList recipeList, @Nonnull Random random) { int sellAmount = 1; if (this.priceInfo != null) { sellAmount = this.priceInfo.getPrice(random); diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java index 2acfc2689..ca0c79a19 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectCreeper.java @@ -85,7 +85,7 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled { } 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); + world.playSound(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/proxy/ProxyApiculture.java b/src/main/java/forestry/apiculture/proxy/ProxyApiculture.java index 9ff0cdb44..15b47a346 100755 --- a/src/main/java/forestry/apiculture/proxy/ProxyApiculture.java +++ b/src/main/java/forestry/apiculture/proxy/ProxyApiculture.java @@ -12,7 +12,4 @@ package forestry.apiculture.proxy; public class ProxyApiculture { - public void initializeRendering() { - } - } diff --git a/src/main/java/forestry/apiculture/proxy/ProxyApicultureClient.java b/src/main/java/forestry/apiculture/proxy/ProxyApicultureClient.java index 45e3e0c9e..adce14d32 100644 --- a/src/main/java/forestry/apiculture/proxy/ProxyApicultureClient.java +++ b/src/main/java/forestry/apiculture/proxy/ProxyApicultureClient.java @@ -16,8 +16,4 @@ public class ProxyApicultureClient extends ProxyApiculture { public static TextureAtlasSprite beeSprite; - @Override - public void initializeRendering() { - // TODO: remove unused bee entity model completely - } } diff --git a/src/main/java/forestry/apiculture/render/ModelBee.java b/src/main/java/forestry/apiculture/render/ModelBee.java index 463761fec..a7ad29c9d 100755 --- a/src/main/java/forestry/apiculture/render/ModelBee.java +++ b/src/main/java/forestry/apiculture/render/ModelBee.java @@ -160,9 +160,4 @@ public class ModelBee extends ModelBase { model.rotateAngleZ = z; } - @Override - public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { - super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); - } - } diff --git a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java index 57193ce5f..120fde160 100755 --- a/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java +++ b/src/main/java/forestry/apiculture/worldgen/HiveDecorator.java @@ -34,7 +34,7 @@ import forestry.core.utils.Log; public abstract class HiveDecorator { - private static final EventType EVENT_TYPE = EnumHelper.addEnum(EventType.class, "FORESTRY_HIVES", new Class[0], new Object[0]); + private static final EventType EVENT_TYPE = EnumHelper.addEnum(EventType.class, "FORESTRY_HIVES", new Class[0]); public static void decorateHives(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) { if (!TerrainGen.populate(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, EVENT_TYPE)) { diff --git a/src/main/java/forestry/arboriculture/PluginArboriculture.java b/src/main/java/forestry/arboriculture/PluginArboriculture.java index 03b2c2d01..cf0857248 100644 --- a/src/main/java/forestry/arboriculture/PluginArboriculture.java +++ b/src/main/java/forestry/arboriculture/PluginArboriculture.java @@ -71,7 +71,6 @@ import forestry.arboriculture.genetics.alleles.AlleleFruit; import forestry.arboriculture.genetics.alleles.AlleleGrowth; import forestry.arboriculture.genetics.alleles.AlleleLeafEffect; import forestry.arboriculture.items.ItemCharcoal; -import forestry.arboriculture.items.ItemGermlingGE; import forestry.arboriculture.items.ItemRegistryArboriculture; import forestry.arboriculture.models.TextureLeaves; import forestry.arboriculture.network.PacketRegistryArboriculture; diff --git a/src/main/java/forestry/arboriculture/blocks/BlockPile.java b/src/main/java/forestry/arboriculture/blocks/BlockPile.java index 87533b56c..138da742b 100644 --- a/src/main/java/forestry/arboriculture/blocks/BlockPile.java +++ b/src/main/java/forestry/arboriculture/blocks/BlockPile.java @@ -47,7 +47,6 @@ import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.arboriculture.EnumGermlingType; import forestry.api.arboriculture.EnumPileType; import forestry.api.arboriculture.IAlleleTreeSpecies; import forestry.api.arboriculture.ITree; @@ -192,7 +191,7 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro @Override public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end){ - List list = Lists.newArrayList(); + List list = Lists.newArrayList(); for (AxisAlignedBB axisalignedbb : getCollisionBoxList(this.getActualState(blockState, worldIn, pos))) { @@ -229,7 +228,7 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro } private static List getCollisionBoxList(IBlockState state){ - List list = Lists.newArrayList(); + List list = Lists.newArrayList(); EnumPilePosition position = state.getValue(PILE_POSITION); if(position != EnumPilePosition.INTERIOR){ @@ -312,15 +311,15 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro float f2 = pos.getZ() + 0.5F; float f3 = 0.52F; float f4 = rand.nextFloat() * 0.6F - 0.3F; - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f3 - 0.5, f1 + 0.5, f2 + f4, 0.0D, 0.0D, 0.0D, new int[0]); + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f3 - 0.5, f1 + 0.5, f2 + f4, 0.0D, 0.0D, 0.0D); } } @SideOnly(Side.CLIENT) @Override - public void getSubBlocks(Item item, CreativeTabs tab, List subItems) { + public void getSubBlocks(Item item, CreativeTabs tab, List subItems) { if(getPileType() == EnumPileType.WOOD){ - List woodPiles = new ArrayList(); + List woodPiles = new ArrayList<>(); for(ITree tree : TreeManager.treeRoot.getIndividualTemplates()) { woodPiles.add(createWoodPile(tree)); } @@ -407,7 +406,7 @@ public abstract class BlockPile extends BlockStructure implements ITileEntityPro @Nonnull private List getPileDrop(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - ArrayList list = new ArrayList(); + List list = new ArrayList<>(); TileEntity tile = world.getTileEntity(pos); if (tile instanceof ICharcoalPileComponent) { ICharcoalPileComponent pile = (ICharcoalPileComponent) tile; diff --git a/src/main/java/forestry/arboriculture/items/ItemCharcoal.java b/src/main/java/forestry/arboriculture/items/ItemCharcoal.java index 6176700eb..682e5746e 100644 --- a/src/main/java/forestry/arboriculture/items/ItemCharcoal.java +++ b/src/main/java/forestry/arboriculture/items/ItemCharcoal.java @@ -2,11 +2,8 @@ package forestry.arboriculture.items; import java.util.List; -import forestry.api.arboriculture.ITree; -import forestry.api.arboriculture.TreeManager; import forestry.api.core.IModelManager; import forestry.api.core.Tabs; -import forestry.core.genetics.alleles.AlleleHelper; import forestry.core.items.ItemForestry; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java index 75390e354..63b1d02a4 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java @@ -29,13 +29,6 @@ public class WorldGenBalsa extends WorldGenTree { super(tree, 6, 6); } - @Nonnull - @Override - public Set generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) { - WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); - return Collections.emptySet(); - } - @Override protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List branchEnds, BlockPos startPos) { BlockPos.MutableBlockPos leafCenter = new BlockPos.MutableBlockPos(startPos.add(0, height, 0)); diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java index dcc6fc88a..bbe763bf4 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenDate.java @@ -28,13 +28,6 @@ public class WorldGenDate extends WorldGenTree { super(tree, 6, 2); } - @Nonnull - @Override - public Set generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) { - WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); - return Collections.emptySet(); - } - @Override protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List branchEnds, BlockPos startPos) { int leafSpawn = height + 1; diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java index 26a7f38b2..0a4327c51 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenLarch.java @@ -28,13 +28,6 @@ public class WorldGenLarch extends WorldGenTree { super(tree, 6, 5); } - @Nonnull - @Override - public Set generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) { - WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); - return Collections.emptySet(); - } - @Override protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List branchEnds, BlockPos startPos) { int leafSpawn = height + 1; diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java index de956862e..a126da5a9 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenLemon.java @@ -28,13 +28,6 @@ public class WorldGenLemon extends WorldGenTree { super(tree, 6, 3); } - @Nonnull - @Override - public Set generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) { - WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); - return Collections.emptySet(); - } - @Override protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List branchEnds, BlockPos startPos) { int yCenter = height - girth; diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java index a2bf26898..f9992d013 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPlum.java @@ -28,13 +28,6 @@ public class WorldGenPlum extends WorldGenTree { super(tree, 6, 3); } - @Nonnull - @Override - public Set generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) { - WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); - return Collections.emptySet(); - } - @Override protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List branchEnds, BlockPos startPos) { int yCenter = height - girth; diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java index fb68a6540..abfbe9887 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenPoplar.java @@ -28,13 +28,6 @@ public class WorldGenPoplar extends WorldGenTree { super(tree, 8, 3); } - @Nonnull - @Override - public Set generateTrunk(World world, Random rand, TreeBlockTypeLog wood, BlockPos startPos) { - WorldGenHelper.generateTreeTrunk(world, rand, wood, startPos, height, girth, 0, 0, null, 0); - return Collections.emptySet(); - } - @Override protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List branchEnds, BlockPos startPos) { int leafSpawn = height + 1; diff --git a/src/main/java/forestry/core/blocks/BlockRegistry.java b/src/main/java/forestry/core/blocks/BlockRegistry.java index 30c640fa4..989136a76 100644 --- a/src/main/java/forestry/core/blocks/BlockRegistry.java +++ b/src/main/java/forestry/core/blocks/BlockRegistry.java @@ -10,8 +10,6 @@ ******************************************************************************/ package forestry.core.blocks; -import javax.annotation.Nonnull; - import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -20,7 +18,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.OreDictionary; import forestry.core.proxy.Proxies; -import forestry.core.utils.OreDictUtil; import forestry.plugins.PluginManager; public abstract class BlockRegistry { diff --git a/src/main/java/forestry/core/blocks/BlockResourceOre.java b/src/main/java/forestry/core/blocks/BlockResourceOre.java index 9b91c1fbd..e324b2d7e 100644 --- a/src/main/java/forestry/core/blocks/BlockResourceOre.java +++ b/src/main/java/forestry/core/blocks/BlockResourceOre.java @@ -35,7 +35,6 @@ import forestry.api.core.IItemModelRegister; import forestry.api.core.IModelManager; import forestry.core.CreativeTabForestry; import forestry.core.PluginCore; -import forestry.core.utils.OreDictUtil; public class BlockResourceOre extends Block implements IItemModelRegister, IBlockWithMeta { public static final PropertyEnum ORE_RESOURCES = PropertyEnum.create("resource", EnumResourceType.class, new Predicate(){ diff --git a/src/main/java/forestry/core/entities/EntitySelector.java b/src/main/java/forestry/core/entities/EntitySelector.java index 4eab6e1dd..c0ce87257 100644 --- a/src/main/java/forestry/core/entities/EntitySelector.java +++ b/src/main/java/forestry/core/entities/EntitySelector.java @@ -33,11 +33,6 @@ public abstract class EntitySelector implements Predicate { T castEntity = entityClass.cast(entity); return isEntityApplicableTyped(castEntity); } - - @Override - public boolean equals(Object obj) { - return super.equals(obj); - } protected abstract boolean isEntityApplicableTyped(T entity); } diff --git a/src/main/java/forestry/core/fluids/TankManager.java b/src/main/java/forestry/core/fluids/TankManager.java index e4e71f905..795f921c6 100644 --- a/src/main/java/forestry/core/fluids/TankManager.java +++ b/src/main/java/forestry/core/fluids/TankManager.java @@ -275,6 +275,7 @@ public class TankManager implements ITankManager, ITankUpdateHandler, IStreamabl return tank.drain(maxDrain, doDrain); } + @Override public FluidStack drain(FluidStack resource, boolean doDrain) { for (StandardTank tank : tanks) { if (tankCanDrainFluid(tank, resource)) { diff --git a/src/main/java/forestry/core/items/ItemFluidContainerForestry.java b/src/main/java/forestry/core/items/ItemFluidContainerForestry.java index f78c46e9f..37481bc3c 100644 --- a/src/main/java/forestry/core/items/ItemFluidContainerForestry.java +++ b/src/main/java/forestry/core/items/ItemFluidContainerForestry.java @@ -132,7 +132,7 @@ public class ItemFluidContainerForestry extends ItemForestry implements IColored if (!worldIn.isRemote) { FoodStats foodStats = player.getFoodStats(); foodStats.addStats(drinkProperties.getHealAmount(), drinkProperties.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); + worldIn.playSound(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)); diff --git a/src/main/java/forestry/core/models/ModelCrate.java b/src/main/java/forestry/core/models/ModelCrate.java index e5f7077e6..e9c820131 100644 --- a/src/main/java/forestry/core/models/ModelCrate.java +++ b/src/main/java/forestry/core/models/ModelCrate.java @@ -178,7 +178,7 @@ public class ModelCrate extends BlankItemModel { * Bake the crate model. */ private List bakeModel(ItemCrated crateItem, IBakedModel crateModel) { - List models = new ArrayList(); + List models = new ArrayList<>(); IBakedModel containedModel = getModel(crateItem.getContained()); @@ -235,7 +235,7 @@ public class ModelCrate extends BlankItemModel { @Override public List getQuads(IBlockState state, EnumFacing side, long rand) { - List quads = new ArrayList(); + List quads = new ArrayList<>(); for(IBakedModel bakedModel : models){ quads.addAll(bakedModel.getQuads(null, side, rand++)); } diff --git a/src/main/java/forestry/core/models/baker/ModelBakerModel.java b/src/main/java/forestry/core/models/baker/ModelBakerModel.java index f138d3912..36b948b1a 100644 --- a/src/main/java/forestry/core/models/baker/ModelBakerModel.java +++ b/src/main/java/forestry/core/models/baker/ModelBakerModel.java @@ -11,6 +11,7 @@ package forestry.core.models.baker; import java.util.ArrayList; +import java.util.EnumMap; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -56,14 +57,14 @@ public class ModelBakerModel implements IModelBakerModel { public ModelBakerModel(IModelState modelState) { models = new ArrayList<>(); - faceQuads = new HashMap<>(); + faceQuads = new EnumMap<>(EnumFacing.class); generalQuads = new ArrayList<>(); isGui3d = true; isAmbientOcclusion = false; setModelState(modelState); for(EnumFacing face : EnumFacing.VALUES){ - faceQuads.put(face, new ArrayList()); + faceQuads.put(face, new ArrayList<>()); } } diff --git a/src/main/java/forestry/core/multiblock/MultiblockTileEntityForestry.java b/src/main/java/forestry/core/multiblock/MultiblockTileEntityForestry.java index e393cac5b..150cee2f0 100644 --- a/src/main/java/forestry/core/multiblock/MultiblockTileEntityForestry.java +++ b/src/main/java/forestry/core/multiblock/MultiblockTileEntityForestry.java @@ -194,7 +194,7 @@ public abstract class MultiblockTileEntityForestry e } /* IMultiblockComponent */ - @Nullable + @Nonnull @Override public final GameProfile getOwner() { return owner; diff --git a/src/main/java/forestry/core/proxy/ProxyRender.java b/src/main/java/forestry/core/proxy/ProxyRender.java index e11be2fb1..2eec17ddb 100644 --- a/src/main/java/forestry/core/proxy/ProxyRender.java +++ b/src/main/java/forestry/core/proxy/ProxyRender.java @@ -23,7 +23,6 @@ import net.minecraft.client.resources.IResourceManager; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import net.minecraftforge.common.animation.ITimeValue; diff --git a/src/main/java/forestry/core/tiles/TileNaturalistChest.java b/src/main/java/forestry/core/tiles/TileNaturalistChest.java index 3005c423c..33d3f5c33 100644 --- a/src/main/java/forestry/core/tiles/TileNaturalistChest.java +++ b/src/main/java/forestry/core/tiles/TileNaturalistChest.java @@ -89,7 +89,7 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve } private void playLidSound(String sound) { - this.worldObj.playSound((EntityPlayer)null, getPos(), SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + this.worldObj.playSound(null, getPos(), SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); } @Override diff --git a/src/main/java/forestry/core/utils/OreDictUtil.java b/src/main/java/forestry/core/utils/OreDictUtil.java index 114c0e5e0..73b0baaac 100644 --- a/src/main/java/forestry/core/utils/OreDictUtil.java +++ b/src/main/java/forestry/core/utils/OreDictUtil.java @@ -1,12 +1,5 @@ package forestry.core.utils; -import javax.annotation.Nullable; -import java.util.List; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.oredict.OreDictionary; - public class OreDictUtil { public static final String ORE_COPPER = "oreCopper"; public static final String ORE_TIN = "oreTin"; diff --git a/src/main/java/forestry/factory/tiles/TileMillRainmaker.java b/src/main/java/forestry/factory/tiles/TileMillRainmaker.java index cb199d034..3dad33d8b 100644 --- a/src/main/java/forestry/factory/tiles/TileMillRainmaker.java +++ b/src/main/java/forestry/factory/tiles/TileMillRainmaker.java @@ -90,7 +90,7 @@ public class TileMillRainmaker extends TileMill { @Override public void activate() { if (Proxies.render.hasRendering()) { - worldObj.playSound((EntityPlayer)null, getPos(), SoundEvents.ENTITY_LIGHTNING_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + worldObj.rand.nextFloat() * 0.2F); + worldObj.playSound(null, getPos(), SoundEvents.ENTITY_LIGHTNING_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + worldObj.rand.nextFloat() * 0.2F); float f = getPos().getX() + 0.5F; float f1 = getPos().getY() + 0.0F + worldObj.rand.nextFloat() * 6F / 16F; diff --git a/src/main/java/forestry/farming/multiblock/FarmController.java b/src/main/java/forestry/farming/multiblock/FarmController.java index cfd00f658..575a608ee 100644 --- a/src/main/java/forestry/farming/multiblock/FarmController.java +++ b/src/main/java/forestry/farming/multiblock/FarmController.java @@ -37,7 +37,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -142,8 +141,6 @@ public class FarmController extends RectangularMultiblockControllerBase implemen // tick updates can come from multiple gearboxes so keep track of them here private int farmWorkTicks = 0; - private Biome cachedBiome; - public FarmController(World world) { super(world, FarmMultiblockSizeLimits.instance); @@ -180,14 +177,6 @@ public class FarmController extends RectangularMultiblockControllerBase implemen return tankManager; } - private Biome getBiome() { - if (cachedBiome == null) { - BlockPos coords = getReferenceCoord(); - cachedBiome = worldObj.getBiome(coords); - } - return cachedBiome; - } - @Override public void onAttachedPartWithMultiblockData(IMultiblockComponent part, NBTTagCompound data) { this.readFromNBT(data); diff --git a/src/main/java/forestry/food/items/ItemBeverage.java b/src/main/java/forestry/food/items/ItemBeverage.java index 80ac5ebd2..9adc33678 100755 --- a/src/main/java/forestry/food/items/ItemBeverage.java +++ b/src/main/java/forestry/food/items/ItemBeverage.java @@ -73,7 +73,7 @@ public class ItemBeverage extends ItemForestryFood implements IColoredItem { if (entityLiving instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer) entityLiving; entityplayer.getFoodStats().addStats(this, stack); - worldIn.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F); + worldIn.playSound(null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F); if (worldIn.isRemote) { return stack; diff --git a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseDoor.java b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseDoor.java index dd9012211..00b2f28a3 100644 --- a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseDoor.java +++ b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseDoor.java @@ -174,7 +174,7 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMapper if (flag != state.getValue(OPEN)) { worldIn.setBlockState(pos, state.withProperty(OPEN, flag), 2); worldIn.markBlockRangeForRenderUpdate(pos, pos); - worldIn.playEvent((EntityPlayer) null, flag ? 1003 : 1006, pos, 0); + worldIn.playEvent(null, flag ? 1003 : 1006, pos, 0); } } } diff --git a/src/main/java/forestry/lepidopterology/render/ModelButterfly.java b/src/main/java/forestry/lepidopterology/render/ModelButterfly.java index d5d2a3546..2c1c718c9 100755 --- a/src/main/java/forestry/lepidopterology/render/ModelButterfly.java +++ b/src/main/java/forestry/lepidopterology/render/ModelButterfly.java @@ -93,9 +93,4 @@ public class ModelButterfly extends ModelBase { model.rotateAngleZ = z; } - @Override - public void setRotationAngles(float f, float f1, float swing, float f3, float f4, float f5, Entity entity) { - super.setRotationAngles(f, f1, swing, f3, f4, f5, entity); - } - } diff --git a/src/main/java/forestry/lepidopterology/worldgen/CocoonDecorator.java b/src/main/java/forestry/lepidopterology/worldgen/CocoonDecorator.java index 0d7527d12..4232d7ec1 100644 --- a/src/main/java/forestry/lepidopterology/worldgen/CocoonDecorator.java +++ b/src/main/java/forestry/lepidopterology/worldgen/CocoonDecorator.java @@ -38,7 +38,7 @@ import forestry.lepidopterology.tiles.TileCocoon; public abstract class CocoonDecorator { - private static final EventType EVENT_TYPE = EnumHelper.addEnum(EventType.class, "FORESTRY_COCOONS", new Class[0], new Object[0]); + private static final EventType EVENT_TYPE = EnumHelper.addEnum(EventType.class, "FORESTRY_COCOONS", new Class[0]); public static void decorateCocoons(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) { if (!TerrainGen.populate(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, EVENT_TYPE)) { diff --git a/src/main/java/forestry/plugins/compat/PluginBiomesOPlenty.java b/src/main/java/forestry/plugins/compat/PluginBiomesOPlenty.java index 5210764e4..5481da891 100644 --- a/src/main/java/forestry/plugins/compat/PluginBiomesOPlenty.java +++ b/src/main/java/forestry/plugins/compat/PluginBiomesOPlenty.java @@ -14,16 +14,13 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.event.FMLInterModComms; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.OreDictionary; -import forestry.api.apiculture.FlowerManager; import forestry.api.core.ForestryAPI; import forestry.api.recipes.RecipeManagers; import forestry.api.storage.BackpackManager; diff --git a/src/main/java/forestry/storage/CrateRegistry.java b/src/main/java/forestry/storage/CrateRegistry.java index d409e158c..b68a506cc 100644 --- a/src/main/java/forestry/storage/CrateRegistry.java +++ b/src/main/java/forestry/storage/CrateRegistry.java @@ -25,7 +25,6 @@ import forestry.core.items.ItemCrated; import forestry.core.proxy.Proxies; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; -import forestry.core.utils.OreDictUtil; public class CrateRegistry implements ICrateRegistry { From eb9ef642cda9a13ac73300484e4ecf8c19636416 Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 5 Jun 2016 22:53:12 -0700 Subject: [PATCH 02/15] Reenable IC2 support --- build.gradle | 3 +- gradle.properties | 1 + .../energy/gui/GuiEngineElectric.java | 38 +- .../forestry/energy/gui/GuiGenerator.java | 19 +- .../inventory/InventoryEngineElectric.java | 9 +- .../energy/tiles/TileEngineElectric.java | 104 ++-- .../energy/tiles/TileEuGenerator.java | 101 ++-- .../farming/logic/CropBasicIC2Crop.java | 145 +++--- .../forestry/farming/logic/CropRubber.java | 14 +- .../farming/logic/FarmLogicRubber.java | 21 +- .../farming/logic/FarmableBasicIC2Crop.java | 145 +++--- .../forestry/plugins/compat/PluginIC2.java | 479 ++++++++++-------- 12 files changed, 587 insertions(+), 492 deletions(-) diff --git a/build.gradle b/build.gradle index 1d9706664..6aef1ab53 100755 --- a/build.gradle +++ b/build.gradle @@ -67,8 +67,7 @@ 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" } configurations { diff --git a/gradle.properties b/gradle.properties index 59cd29c8d..5324fc312 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,7 @@ forgeversion=12.17.0.1950 mcp_mappings=snapshot_20160525 jei_version=3.4.0.+ +ic2_version=2.5.5-ex19 version_major=5 version_minor=0 diff --git a/src/main/java/forestry/energy/gui/GuiEngineElectric.java b/src/main/java/forestry/energy/gui/GuiEngineElectric.java index 810e59ee6..9e5cdaef8 100644 --- a/src/main/java/forestry/energy/gui/GuiEngineElectric.java +++ b/src/main/java/forestry/energy/gui/GuiEngineElectric.java @@ -14,9 +14,9 @@ import net.minecraft.entity.player.InventoryPlayer; import forestry.core.config.Constants; 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 +24,23 @@ public class GuiEngineElectric extends GuiEngine { public GuiGenerator(InventoryPlayer inventory, TileEuGenerator tile) { @@ -25,14 +24,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 a6514eff2..8af78b513 100644 --- a/src/main/java/forestry/energy/inventory/InventoryEngineElectric.java +++ b/src/main/java/forestry/energy/inventory/InventoryEngineElectric.java @@ -15,7 +15,8 @@ import net.minecraft.item.ItemStack; import forestry.core.inventory.InventoryAdapterTile; import forestry.energy.tiles.TileEngineElectric; -// TODO: IC2 for 1.9 +import ic2.api.item.ElectricItem; + public class InventoryEngineElectric extends InventoryAdapterTile { public static final short SLOT_BATTERY = 0; @@ -25,9 +26,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/TileEngineElectric.java b/src/main/java/forestry/energy/tiles/TileEngineElectric.java index 62826ee7f..5b5c07d17 100644 --- a/src/main/java/forestry/energy/tiles/TileEngineElectric.java +++ b/src/main/java/forestry/energy/tiles/TileEngineElectric.java @@ -27,6 +27,7 @@ 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,8 +37,10 @@ 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 { @@ -55,16 +58,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 @@ -72,9 +75,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); @@ -91,27 +94,27 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound = super.writeToNBT(nbttagcompound); -// if (ic2EnergySink != null) { -// ic2EnergySink.writeToNBT(nbttagcompound); -// } + if (ic2EnergySink != null) { + ic2EnergySink.writeToNBT(nbttagcompound); + } sockets.writeToNBT(nbttagcompound); return 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 +162,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 +183,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 +196,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,23 +208,22 @@ 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() { - // TODO: IC2 for 1.9 - return mayBurn();// && ic2EnergySink != null && ic2EnergySink.canUseEnergy(euConfig.euForCycle); + 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 @@ -230,11 +232,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 @@ -243,11 +245,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 @@ -266,9 +268,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/TileEuGenerator.java b/src/main/java/forestry/energy/tiles/TileEuGenerator.java index 74ebb380a..d83781c29 100644 --- a/src/main/java/forestry/energy/tiles/TileEuGenerator.java +++ b/src/main/java/forestry/energy/tiles/TileEuGenerator.java @@ -25,6 +25,7 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler; 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; @@ -40,8 +41,10 @@ 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, IRenderableTile { private static final int maxEnergy = 30000; @@ -50,7 +53,7 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui private int tickCount = 0; -// private BasicSource ic2EnergySource; + private BasicSource ic2EnergySource; public TileEuGenerator() { super("generator"); @@ -62,9 +65,9 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui 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); + } } @Nonnull @@ -72,9 +75,9 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { nbttagcompound = super.writeToNBT(nbttagcompound); -// if (ic2EnergySource != null) { -// ic2EnergySource.writeToNBT(nbttagcompound); -// } + if (ic2EnergySource != null) { + ic2EnergySource.writeToNBT(nbttagcompound); + } tankManager.writeToNBT(nbttagcompound); return nbttagcompound; @@ -84,9 +87,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); } @@ -105,18 +108,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(); } @@ -130,25 +133,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.canDrainFluidType(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.canDrainFluidType(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); @@ -162,13 +165,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() { @@ -183,16 +186,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, IContainerListener iCrafting) { -// if (ic2EnergySource != null) { -// iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored()); -// } + if (ic2EnergySource != null) { + iCrafting.sendProgressBarUpdate(container, 0, (short) ic2EnergySource.getEnergyStored()); + } } @Override diff --git a/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java b/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java index dc49ceb35..4c7ea4889 100644 --- a/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java +++ b/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java @@ -1,68 +1,83 @@ package forestry.farming.logic; -// 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; -// } +import javax.annotation.Nonnull; + +import java.util.Collection; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import net.minecraftforge.fml.common.Optional; + +import forestry.plugins.compat.PluginIC2; + +import ic2.api.crops.ICropTile; + +public class CropBasicIC2Crop extends Crop { + private final TileEntity tileEntity; + + public CropBasicIC2Crop(@Nonnull World world, @Nonnull TileEntity tileEntity, @Nonnull BlockPos position) { + super(world, position); + this.tileEntity = tileEntity; + } + + @Override + protected boolean isCrop(World world, BlockPos pos) { + return canHarvestCrop(this.tileEntity); + } + + @Override + protected Collection harvestBlock(World world, BlockPos 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/CropRubber.java b/src/main/java/forestry/farming/logic/CropRubber.java index 585caaa2a..a29688870 100755 --- a/src/main/java/forestry/farming/logic/CropRubber.java +++ b/src/main/java/forestry/farming/logic/CropRubber.java @@ -13,6 +13,7 @@ package forestry.farming.logic; import java.util.ArrayList; import java.util.Collection; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -26,8 +27,17 @@ import forestry.plugins.compat.PluginIC2; public class CropRubber extends CropDestroy { public CropRubber(World world, IBlockState blockState, BlockPos position) { - //TODO IC2 for 1.9: check that this is setting the right state for replanting. - super(world, blockState, position, blockState.getBlock().getDefaultState()); + super(world, blockState, position, getReplantState(blockState)); + } + + /** + * Convert a "wet" rubber log blockstate into the dry version. + * Total hack since we don't have access to the blockstates. + */ + private static IBlockState getReplantState(IBlockState sappyState) { + Block block = sappyState.getBlock(); + int sappyMeta = block.getMetaFromState(sappyState); + return block.getStateFromMeta(sappyMeta - 4); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 936b79f79..108c6d5f4 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -39,25 +39,34 @@ import forestry.plugins.compat.PluginIC2; public class FarmLogicRubber extends FarmLogic { - private boolean inActive; + private boolean active = true; public FarmLogicRubber() { if (PluginIC2.rubberWood == null || PluginIC2.resin == null) { Log.warning("Failed to init a farm logic %s since IC2 was not found", getClass().getName()); - inActive = true; + active = false; } } @Override @SideOnly(Side.CLIENT) public Item getItem() { - if (!inActive) { + if (active) { return PluginIC2.resin.getItem(); } else { return Items.GUNPOWDER; } } + @Override + public int getMetadata() { + if (active) { + return PluginIC2.resin.getMetadata(); + } else { + return super.getMetadata(); + } + } + @Override public String getName() { return "Rubber Plantation"; @@ -102,7 +111,7 @@ public class FarmLogicRubber extends FarmLogic { @Override public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { - if (inActive) { + if (!active) { return null; } @@ -135,7 +144,7 @@ public class FarmLogicRubber extends FarmLogic { } int meta = block.getMetaFromState(blockState); - if (meta >= 2 && meta <= 5) { + if (meta >= 7 && meta <= 10) { crops.push(new CropDestroy(world, blockState, position, null)); } @@ -172,7 +181,7 @@ public class FarmLogicRubber extends FarmLogic { Block block = blockState.getBlock(); if (ItemStackUtil.equals(block, PluginIC2.rubberWood)) { int meta = block.getMetaFromState(blockState); - if (meta >= 2 && meta <= 5) { + if (meta >= 7 && meta <= 10) { crops.push(new CropRubber(world, blockState, candidate)); } candidates.add(candidate); diff --git a/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java b/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java index 9b127901e..8700f63da 100644 --- a/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java +++ b/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java @@ -1,68 +1,85 @@ package forestry.farming.logic; -// TODO: IC2 for 1.9 -public class FarmableBasicIC2Crop {//implements IFarmable { +import javax.annotation.Nullable; -// /** -// * 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; -// } +import net.minecraft.block.state.IBlockState; +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; + +import net.minecraftforge.fml.common.Optional; + +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmable; +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; + } + + @Nullable + @Override + public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) { + 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, 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/plugins/compat/PluginIC2.java b/src/main/java/forestry/plugins/compat/PluginIC2.java index ef892fb20..aaa2424a7 100644 --- a/src/main/java/forestry/plugins/compat/PluginIC2.java +++ b/src/main/java/forestry/plugins/compat/PluginIC2.java @@ -10,18 +10,63 @@ ******************************************************************************/ 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.BlockBogEarth; +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; -// TODO: IC2 for 1.9 +import ic2.api.item.IC2Items; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.Recipes; + @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"; @@ -59,223 +104,217 @@ 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); - // - // blocks.electricalEngine.init(); - // blocks.generator.init(); -// } -// -// @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(BlockBogEarth.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 - // public void registerItemsAndBlocks() { - // super.registerItemsAndBlocks(); - // blocks = new BlockRegistryIC2(); -// } + @Override + @Optional.Method(modid = PluginIC2.modId) + public void preInit() { + super.preInit(); + + // 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", new FarmLogicRubber()); + + 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); + + blocks.electricalEngine.init(); + blocks.generator.init(); + } + + @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.registerCrate(silver); + } + + ItemStack brass = IC2Items.getItem("ingot", "bronze"); + if (brass != null) { + crateRegistry.registerCrate(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.bogEarth.get(BlockBogEarth.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(blocks.generator, + "X#X", + "XYX", + "X#X", + '#', "blockGlass", + 'X', "ingotGold", + 'Y', coreItems.sturdyCasing); + + RecipeUtil.addRecipe(blocks.electricalEngine, + "###", + " X ", + "YVY", + '#', "ingotTin", + 'X', "blockGlass", + 'Y', "gearTin", + 'V', Blocks.PISTON); + } + } + + @Override + public void registerItemsAndBlocks() { + super.registerItemsAndBlocks(); + blocks = new BlockRegistryIC2(); + } } From b8be42548e716e7f5ac03f68a7872791f4fda8fc Mon Sep 17 00:00:00 2001 From: mezz Date: Sun, 5 Jun 2016 23:01:01 -0700 Subject: [PATCH 03/15] Use IconItemStack for farm logic icon --- gradle.properties | 2 +- .../java/forestry/api/farming/IFarmLogic.java | 6 +++-- .../farming/gui/widgets/FarmLogicSlot.java | 2 +- .../forestry/farming/logic/FarmLogic.java | 14 +---------- .../farming/logic/FarmLogicArboreal.java | 11 +++------ .../farming/logic/FarmLogicCereal.java | 11 +++------ .../farming/logic/FarmLogicCocoa.java | 15 ++---------- .../farming/logic/FarmLogicEnder.java | 9 ++------ .../farming/logic/FarmLogicGourd.java | 9 ++------ .../farming/logic/FarmLogicInfernal.java | 9 ++------ .../farming/logic/FarmLogicMushroom.java | 9 ++------ .../farming/logic/FarmLogicOrchard.java | 9 ++------ .../forestry/farming/logic/FarmLogicPeat.java | 10 ++------ .../farming/logic/FarmLogicReeds.java | 9 ++------ .../farming/logic/FarmLogicRubber.java | 23 ++----------------- .../farming/logic/FarmLogicSucculent.java | 15 ++---------- .../farming/logic/FarmLogicVegetable.java | 10 +++----- 17 files changed, 36 insertions(+), 137 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5324fc312..3db0c5749 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,4 +7,4 @@ ic2_version=2.5.5-ex19 version_major=5 version_minor=0 -version_patch=8 +version_patch=9 diff --git a/src/main/java/forestry/api/farming/IFarmLogic.java b/src/main/java/forestry/api/farming/IFarmLogic.java index c2a0b14f9..985db22ea 100644 --- a/src/main/java/forestry/api/farming/IFarmLogic.java +++ b/src/main/java/forestry/api/farming/IFarmLogic.java @@ -38,6 +38,8 @@ public interface IFarmLogic { String getName(); - @SideOnly(Side.CLIENT) - ItemStack getStack(); + /** + * @return the itemStack that represents this farm logic. Used as an icon for the farm logic. + */ + ItemStack getIconItemStack(); } diff --git a/src/main/java/forestry/farming/gui/widgets/FarmLogicSlot.java b/src/main/java/forestry/farming/gui/widgets/FarmLogicSlot.java index f30912201..deb19d1d1 100644 --- a/src/main/java/forestry/farming/gui/widgets/FarmLogicSlot.java +++ b/src/main/java/forestry/farming/gui/widgets/FarmLogicSlot.java @@ -40,7 +40,7 @@ public class FarmLogicSlot extends Widget { if (getLogic() == null) { return null; } - return getLogic().getStack(); + return getLogic().getIconItemStack(); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 3136a8b52..3241a0822 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -19,7 +19,6 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; @@ -53,18 +52,7 @@ public abstract class FarmLogic implements IFarmLogic { } @Override - @SideOnly(Side.CLIENT) - public ItemStack getStack() { - return new ItemStack(getItem(), 1, getMetadata()); - } - - @SideOnly(Side.CLIENT) - public abstract Item getItem(); - - @SideOnly(Side.CLIENT) - public int getMetadata() { - return 0; - } + public abstract ItemStack getIconItemStack(); public abstract boolean isAcceptedWindfall(ItemStack stack); diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index e392e3af3..62ae06109 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -20,14 +20,10 @@ import java.util.Stack; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.FarmDirection; import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; @@ -48,11 +44,10 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { public String getName() { return "Managed Arboretum"; } - - @SideOnly(Side.CLIENT) + @Override - public Item getItem() { - return Item.getItemFromBlock(Blocks.SAPLING); + public ItemStack getIconItemStack() { + return new ItemStack(Blocks.SAPLING); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicCereal.java b/src/main/java/forestry/farming/logic/FarmLogicCereal.java index 0226b49ba..0d48a0051 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCereal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCereal.java @@ -11,10 +11,7 @@ package forestry.farming.logic; import net.minecraft.init.Items; -import net.minecraft.item.Item; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.item.ItemStack; import forestry.api.farming.Farmables; @@ -34,9 +31,7 @@ public class FarmLogicCereal extends FarmLogicCrops { } @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - return Items.WHEAT; + public ItemStack getIconItemStack() { + return new ItemStack(Items.WHEAT); } - } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index 6e78abbdd..390e73c1a 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -25,15 +25,11 @@ import net.minecraft.block.BlockPlanks; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; @@ -43,15 +39,8 @@ public class FarmLogicCocoa extends FarmLogic { private final IFarmable cocoa = new FarmableCocoa(); @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - return Items.DYE; - } - - @Override - @SideOnly(Side.CLIENT) - public int getMetadata() { - return 3; + public ItemStack getIconItemStack() { + return new ItemStack(Items.DYE, 1, 3); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicEnder.java b/src/main/java/forestry/farming/logic/FarmLogicEnder.java index bbd0d7bac..48b03b15b 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicEnder.java +++ b/src/main/java/forestry/farming/logic/FarmLogicEnder.java @@ -16,14 +16,10 @@ 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; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.FarmDirection; import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; @@ -43,9 +39,8 @@ public class FarmLogicEnder extends FarmLogicHomogeneous { } @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - return Items.ENDER_EYE; + public ItemStack getIconItemStack() { + return new ItemStack(Items.ENDER_EYE); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicGourd.java b/src/main/java/forestry/farming/logic/FarmLogicGourd.java index 8cea09c09..b50f99ddd 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicGourd.java +++ b/src/main/java/forestry/farming/logic/FarmLogicGourd.java @@ -15,14 +15,10 @@ import java.util.Stack; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.FarmDirection; import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; @@ -39,9 +35,8 @@ public class FarmLogicGourd extends FarmLogic { } @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - return Items.MELON; + public ItemStack getIconItemStack() { + return new ItemStack(Items.MELON); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index 8a040895f..ed0cbcdb3 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -16,14 +16,10 @@ 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; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.FarmDirection; import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; @@ -43,9 +39,8 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { } @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - return Items.NETHER_WART; + public ItemStack getIconItemStack() { + return new ItemStack(Items.NETHER_WART); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicMushroom.java b/src/main/java/forestry/farming/logic/FarmLogicMushroom.java index 828ac2561..843962a79 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicMushroom.java +++ b/src/main/java/forestry/farming/logic/FarmLogicMushroom.java @@ -14,13 +14,9 @@ import java.util.ArrayList; import java.util.Collection; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.Farmables; import forestry.api.farming.IFarmHousing; @@ -40,9 +36,8 @@ public class FarmLogicMushroom extends FarmLogicArboreal { } @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - return Item.getItemFromBlock(Blocks.RED_MUSHROOM); + public ItemStack getIconItemStack() { + return new ItemStack(Blocks.RED_MUSHROOM); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index a6f960697..ce15dafbb 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -22,15 +22,11 @@ import java.util.Stack; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.FarmDirection; import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; @@ -126,9 +122,8 @@ public class FarmLogicOrchard extends FarmLogic { } @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - return PluginCore.items.fruits; + public ItemStack getIconItemStack() { + return new ItemStack(PluginCore.items.fruits); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index 5eb788938..cd0cc9761 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -15,14 +15,10 @@ import java.util.Stack; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.core.PluginCore; @@ -89,9 +85,7 @@ public class FarmLogicPeat extends FarmLogicWatered { } @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - return PluginCore.items.peat; + public ItemStack getIconItemStack() { + return new ItemStack(PluginCore.items.peat); } - } diff --git a/src/main/java/forestry/farming/logic/FarmLogicReeds.java b/src/main/java/forestry/farming/logic/FarmLogicReeds.java index 08a51c258..1e1126ce9 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicReeds.java +++ b/src/main/java/forestry/farming/logic/FarmLogicReeds.java @@ -16,14 +16,10 @@ 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; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.FarmDirection; import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; @@ -35,9 +31,8 @@ public class FarmLogicReeds extends FarmLogic { private final Collection germlings = Farmables.farmables.get("farmPoales"); @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - return Items.REEDS; + public ItemStack getIconItemStack() { + return new ItemStack(Items.REEDS); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 108c6d5f4..b2dfd6b93 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -21,15 +21,10 @@ import java.util.Stack; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; @@ -49,22 +44,8 @@ public class FarmLogicRubber extends FarmLogic { } @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - if (active) { - return PluginIC2.resin.getItem(); - } else { - return Items.GUNPOWDER; - } - } - - @Override - public int getMetadata() { - if (active) { - return PluginIC2.resin.getMetadata(); - } else { - return super.getMetadata(); - } + public ItemStack getIconItemStack() { + return PluginIC2.resin; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java index 7355d4877..fc1d2dd6a 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java @@ -16,14 +16,10 @@ 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; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.FarmDirection; import forestry.api.farming.Farmables; import forestry.api.farming.ICrop; @@ -35,15 +31,8 @@ public class FarmLogicSucculent extends FarmLogic { private final Collection germlings = Farmables.farmables.get("farmSucculentes"); @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - return Items.DYE; - } - - @Override - @SideOnly(Side.CLIENT) - public int getMetadata() { - return 2; + public ItemStack getIconItemStack() { + return new ItemStack(Items.DYE, 1, 2); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicVegetable.java b/src/main/java/forestry/farming/logic/FarmLogicVegetable.java index 5b00fb20c..460046abb 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicVegetable.java +++ b/src/main/java/forestry/farming/logic/FarmLogicVegetable.java @@ -11,10 +11,7 @@ package forestry.farming.logic; import net.minecraft.init.Items; -import net.minecraft.item.Item; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraft.item.ItemStack; import forestry.api.farming.Farmables; @@ -25,9 +22,8 @@ public class FarmLogicVegetable extends FarmLogicCrops { } @Override - @SideOnly(Side.CLIENT) - public Item getItem() { - return Items.CARROT; + public ItemStack getIconItemStack() { + return new ItemStack(Items.CARROT); } @Override From 68fb27410e5c6a4c7987babb2b411def462c6380 Mon Sep 17 00:00:00 2001 From: mezz Date: Mon, 6 Jun 2016 19:00:44 -0700 Subject: [PATCH 04/15] #1295 Add Forestry recipes to the RecipeSorter --- src/main/java/forestry/core/PluginCore.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/forestry/core/PluginCore.java b/src/main/java/forestry/core/PluginCore.java index 2898ab00f..2a915544a 100644 --- a/src/main/java/forestry/core/PluginCore.java +++ b/src/main/java/forestry/core/PluginCore.java @@ -32,6 +32,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.RecipeSorter; import forestry.api.circuits.ChipsetManager; import forestry.api.core.ForestryAPI; @@ -61,6 +62,7 @@ import forestry.core.network.IPacketRegistry; import forestry.core.network.PacketRegistryCore; import forestry.core.proxy.Proxies; import forestry.core.recipes.RecipeUtil; +import forestry.core.recipes.ShapedRecipeCustom; import forestry.core.render.TextureManager; import forestry.core.utils.ClimateUtil; import forestry.core.utils.ForestryModEnvWarningCallable; @@ -133,6 +135,8 @@ public class PluginCore extends BlankForestryPlugin { AlleleHelper.instance.init(); Proxies.render.initRendering(); + + RecipeSorter.register("forestry:shaped", ShapedRecipeCustom.class, RecipeSorter.Category.SHAPED, ""); } @Override From f97a737185061470d82a6dd849895946f0524db9 Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Tue, 7 Jun 2016 20:17:11 -0500 Subject: [PATCH 05/15] Migrate new 1.7 villager trades, fix ic2 uid --- lang | 2 +- .../forestry/apiculture/PluginApiculture.java | 20 ++++++- .../core/utils/VillagerTradeLists.java | 55 +++++++++++++++++++ .../forestry/plugins/ForestryPluginUids.java | 1 + .../forestry/plugins/compat/PluginIC2.java | 2 +- 5 files changed, 76 insertions(+), 4 deletions(-) diff --git a/lang b/lang index 50cc3f6cf..2a4b65a20 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 50cc3f6cfccce773a97d944bf8c7539b5b0780d5 +Subproject commit 2a4b65a20c3153f71cea5d323da843524e358695 diff --git a/src/main/java/forestry/apiculture/PluginApiculture.java b/src/main/java/forestry/apiculture/PluginApiculture.java index a8aa8455b..f0e7d63b4 100644 --- a/src/main/java/forestry/apiculture/PluginApiculture.java +++ b/src/main/java/forestry/apiculture/PluginApiculture.java @@ -275,9 +275,18 @@ public class PluginApiculture extends BlankForestryPlugin { villagerRegistry.register(villagerApiarist); ItemStack wildcardPrincess = new ItemStack(items.beePrincessGE, 1); + ItemStack wildcardDrone = new ItemStack(items.beeDroneGE, 1); ItemStack apiary = new ItemStack(blocks.apiary); ItemStack provenFrames = items.frameProven.getItemStack(); ItemStack monasticDrone = BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE); + ItemStack endDrone = BeeDefinition.ENDED.getMemberStack(EnumBeeType.DRONE); + ItemStack propolis = new ItemStack(PluginApiculture.items.propolis,1); + ItemStack forestDrone = BeeDefinition.FOREST.getMemberStack(EnumBeeType.DRONE); + ItemStack meadowsDrone = BeeDefinition.MEADOWS.getMemberStack(EnumBeeType.DRONE); + ItemStack modestDrone = BeeDefinition.MODEST.getMemberStack(EnumBeeType.DRONE); + ItemStack tropicalDrone = BeeDefinition.TROPICAL.getMemberStack(EnumBeeType.DRONE); + ItemStack wintryDrone = BeeDefinition.WINTRY.getMemberStack(EnumBeeType.DRONE); + ItemStack marshyDrone = BeeDefinition.MARSHY.getMemberStack(EnumBeeType.DRONE); VillagerRegistry.VillagerCareer apiaristCareer = new VillagerRegistry.VillagerCareer(villagerApiarist, "apiarist"); apiaristCareer.addTrade(1, @@ -291,10 +300,17 @@ public class PluginApiculture extends BlankForestryPlugin { ); apiaristCareer.addTrade(3, new VillagerTradeLists.GiveEmeraldForItems(wildcardPrincess, null), - new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 2), provenFrames, new EntityVillager.PriceInfo(1, 6)) + new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 2), provenFrames, new EntityVillager.PriceInfo(1, 6)), + new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), forestDrone, null), + new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), meadowsDrone, null), + new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), modestDrone, null), + new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), tropicalDrone, null), + new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), wintryDrone, null), + new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), marshyDrone, null) ); apiaristCareer.addTrade(4, - new VillagerTradeLists.GiveItemForItemAndEmerald(wildcardPrincess, null, new EntityVillager.PriceInfo(10, 64), monasticDrone, null) + new VillagerTradeLists.GiveItemForItemAndEmerald(wildcardPrincess, null, new EntityVillager.PriceInfo(10, 64), monasticDrone, null), + new VillagerTradeLists.GiveItemForTwoItems(wildcardPrincess, null,new ItemStack(Items.ENDER_EYE),new EntityVillager.PriceInfo(12, 16),endDrone, null) ); } diff --git a/src/main/java/forestry/core/utils/VillagerTradeLists.java b/src/main/java/forestry/core/utils/VillagerTradeLists.java index 92b613c0f..6a1b832e9 100644 --- a/src/main/java/forestry/core/utils/VillagerTradeLists.java +++ b/src/main/java/forestry/core/utils/VillagerTradeLists.java @@ -174,4 +174,59 @@ public class VillagerTradeLists { recipeList.add(new MerchantRecipe(randomLog, new ItemStack(Items.EMERALD, emeraldsAmount), itemToSell)); } } + public static class GiveItemForTwoItems implements EntityVillager.ITradeList { + @Nonnull + public ItemStack buyingItemStack; + @Nullable + public EntityVillager.PriceInfo buyingPriceInfo; + @Nonnull + public ItemStack buyingItemStackTwo; + @Nullable + public EntityVillager.PriceInfo buyingItemTwoInfo; + @Nonnull + public ItemStack sellingItemstack; + @Nullable + public EntityVillager.PriceInfo sellingPriceInfo; + + public GiveItemForTwoItems( + @Nonnull ItemStack buyingItemStack, + @Nullable EntityVillager.PriceInfo buyingPriceInfo, + @Nonnull ItemStack buyingItemStackTwo, + @Nullable EntityVillager.PriceInfo buyingItemTwoInfo, + @Nonnull ItemStack sellingItemstack, + @Nullable EntityVillager.PriceInfo sellingPriceInfo) { + this.buyingItemStack = buyingItemStack; + this.buyingPriceInfo = buyingPriceInfo; + this.buyingItemStackTwo = buyingItemStackTwo; + this.buyingItemTwoInfo = buyingItemTwoInfo; + this.sellingItemstack = sellingItemstack; + this.sellingPriceInfo = sellingPriceInfo; + } + + @Override + public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) { + int buyAmount = 1; + if (this.buyingPriceInfo != null) { + buyAmount = this.buyingPriceInfo.getPrice(random); + } + + int buyTwoAmount = 1; + if (this.buyingItemTwoInfo != null) { + buyTwoAmount = this.buyingItemTwoInfo.getPrice(random); + } + + int sellAmount = 1; + if (this.sellingPriceInfo != null) { + sellAmount = this.sellingPriceInfo.getPrice(random); + } + + ItemStack buyItemStack = this.buyingItemStack.copy(); + buyItemStack.stackSize = buyAmount; + ItemStack buyItemStackTwo = this.buyingItemStackTwo.copy(); + buyItemStackTwo.stackSize = buyTwoAmount; + ItemStack sellItemStack = this.sellingItemstack.copy(); + sellItemStack.stackSize = sellAmount; + recipeList.add(new MerchantRecipe(buyItemStack, buyItemStackTwo, sellItemStack)); + } + } } diff --git a/src/main/java/forestry/plugins/ForestryPluginUids.java b/src/main/java/forestry/plugins/ForestryPluginUids.java index a1734534a..ffcfa7476 100644 --- a/src/main/java/forestry/plugins/ForestryPluginUids.java +++ b/src/main/java/forestry/plugins/ForestryPluginUids.java @@ -21,4 +21,5 @@ public class ForestryPluginUids { public static final String BUILDCRAFT_TRANSPORT = "forestry.buildcraft.transport"; public static final String CHISEL = "forestry.chisel"; public static final String NATURA = "forestry.natura"; + public static final String INDUSTRIALCRAFT2 = "forestry.industrialcraft2"; } diff --git a/src/main/java/forestry/plugins/compat/PluginIC2.java b/src/main/java/forestry/plugins/compat/PluginIC2.java index aaa2424a7..7d083f49c 100644 --- a/src/main/java/forestry/plugins/compat/PluginIC2.java +++ b/src/main/java/forestry/plugins/compat/PluginIC2.java @@ -67,7 +67,7 @@ import ic2.api.item.IC2Items; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.Recipes; -@ForestryPlugin(pluginID = "IC2", name = "IndustrialCraft2", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.ic2.description") +@ForestryPlugin(pluginID = ForestryPluginUids.INDUSTRIALCRAFT2, name = "IndustrialCraft2", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.ic2.description") public class PluginIC2 extends BlankForestryPlugin { public static final String modId = "IC2"; public static PluginIC2 instance; From b9dd19a5567590cb816b17ab4e8eff440cec5068 Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Tue, 7 Jun 2016 23:49:05 -0500 Subject: [PATCH 06/15] Make hive bee trade a random one --- .../forestry/apiculture/PluginApiculture.java | 17 ++----- .../apiculture/VillagerApiaristTrades.java | 44 +++++++++++++++++++ .../core/utils/VillagerTradeLists.java | 10 ++--- 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/src/main/java/forestry/apiculture/PluginApiculture.java b/src/main/java/forestry/apiculture/PluginApiculture.java index f0e7d63b4..7a757c02b 100644 --- a/src/main/java/forestry/apiculture/PluginApiculture.java +++ b/src/main/java/forestry/apiculture/PluginApiculture.java @@ -281,12 +281,6 @@ public class PluginApiculture extends BlankForestryPlugin { ItemStack monasticDrone = BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE); ItemStack endDrone = BeeDefinition.ENDED.getMemberStack(EnumBeeType.DRONE); ItemStack propolis = new ItemStack(PluginApiculture.items.propolis,1); - ItemStack forestDrone = BeeDefinition.FOREST.getMemberStack(EnumBeeType.DRONE); - ItemStack meadowsDrone = BeeDefinition.MEADOWS.getMemberStack(EnumBeeType.DRONE); - ItemStack modestDrone = BeeDefinition.MODEST.getMemberStack(EnumBeeType.DRONE); - ItemStack tropicalDrone = BeeDefinition.TROPICAL.getMemberStack(EnumBeeType.DRONE); - ItemStack wintryDrone = BeeDefinition.WINTRY.getMemberStack(EnumBeeType.DRONE); - ItemStack marshyDrone = BeeDefinition.MARSHY.getMemberStack(EnumBeeType.DRONE); VillagerRegistry.VillagerCareer apiaristCareer = new VillagerRegistry.VillagerCareer(villagerApiarist, "apiarist"); apiaristCareer.addTrade(1, @@ -296,17 +290,12 @@ public class PluginApiculture extends BlankForestryPlugin { ); apiaristCareer.addTrade(2, new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 4), new ItemStack(items.smoker), null), - new VillagerTradeLists.GiveItemForLogsAndEmeralds(apiary, new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(16, 32), new EntityVillager.PriceInfo(1, 2)) + new VillagerTradeLists.GiveItemForLogsAndEmeralds(apiary, new EntityVillager.PriceInfo(1, 1), new EntityVillager.PriceInfo(16, 32), new EntityVillager.PriceInfo(1, 2)), + new VillagerApiaristTrades.GiveRandomHiveDroneForItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4)) ); apiaristCareer.addTrade(3, new VillagerTradeLists.GiveEmeraldForItems(wildcardPrincess, null), - new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 2), provenFrames, new EntityVillager.PriceInfo(1, 6)), - new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), forestDrone, null), - new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), meadowsDrone, null), - new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), modestDrone, null), - new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), tropicalDrone, null), - new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), wintryDrone, null), - new VillagerTradeLists.GiveItemForTwoItems(propolis, null, wildcardDrone, new EntityVillager.PriceInfo(2, 4), marshyDrone, null) + new VillagerTradeLists.GiveItemForEmeralds(new EntityVillager.PriceInfo(1, 2), provenFrames, new EntityVillager.PriceInfo(1, 6)) ); apiaristCareer.addTrade(4, new VillagerTradeLists.GiveItemForItemAndEmerald(wildcardPrincess, null, new EntityVillager.PriceInfo(10, 64), monasticDrone, null), diff --git a/src/main/java/forestry/apiculture/VillagerApiaristTrades.java b/src/main/java/forestry/apiculture/VillagerApiaristTrades.java index 79e6c4dcb..73bd2c631 100644 --- a/src/main/java/forestry/apiculture/VillagerApiaristTrades.java +++ b/src/main/java/forestry/apiculture/VillagerApiaristTrades.java @@ -9,6 +9,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipeList; +import forestry.api.apiculture.EnumBeeType; +import forestry.apiculture.genetics.BeeDefinition; + public class VillagerApiaristTrades { public static class GiveRandomCombsForItems implements EntityVillager.ITradeList { @@ -42,5 +45,46 @@ public class VillagerApiaristTrades { recipeList.add(new MerchantRecipe(itemToBuy, randomComb)); } } + public static class GiveRandomHiveDroneForItems implements EntityVillager.ITradeList { + @Nonnull + public ItemStack buyingItemStack; + @Nullable + public EntityVillager.PriceInfo buyingPriceInfo; + @Nonnull + public ItemStack buyingItemStackTwo; + @Nullable + public EntityVillager.PriceInfo buyingPriceItemTwoInfo; + public GiveRandomHiveDroneForItems( + @Nonnull ItemStack buyingItemStack, + @Nullable EntityVillager.PriceInfo buyingPriceInfo, + @Nonnull ItemStack buyingItemStackTwo, + @Nullable EntityVillager.PriceInfo buyingPriceItemTwoInfo) { + this.buyingItemStack = buyingItemStack; + this.buyingPriceInfo = buyingPriceInfo; + this.buyingItemStackTwo = buyingItemStackTwo; + this.buyingPriceItemTwoInfo = buyingPriceItemTwoInfo; + } + + @Override + public void modifyMerchantRecipeList(@Nonnull MerchantRecipeList recipeList, @Nonnull Random random) { + + int buyAmount = 1; + if (this.buyingPriceInfo != null) { + buyAmount = this.buyingPriceInfo.getPrice(random); + } + + int buyTwoAmount = 1; + if (this.buyingPriceItemTwoInfo != null) { + buyTwoAmount = this.buyingPriceItemTwoInfo.getPrice(random); + } + BeeDefinition [] forestryMundane = new BeeDefinition[] { BeeDefinition.FOREST, BeeDefinition.MEADOWS, BeeDefinition.MODEST, BeeDefinition.WINTRY, BeeDefinition.TROPICAL, BeeDefinition.MARSHY }; + ItemStack randomHiveDrone = forestryMundane[random.nextInt(forestryMundane.length)].getMemberStack(EnumBeeType.DRONE); + ItemStack buyItemStack = this.buyingItemStack.copy(); + buyItemStack.stackSize = buyAmount; + ItemStack buyItemStackTwo = this.buyingItemStackTwo.copy(); + buyItemStackTwo.stackSize = buyTwoAmount; + recipeList.add(new MerchantRecipe(buyItemStack, buyItemStackTwo, randomHiveDrone)); + } + } } diff --git a/src/main/java/forestry/core/utils/VillagerTradeLists.java b/src/main/java/forestry/core/utils/VillagerTradeLists.java index 6a1b832e9..0c1495601 100644 --- a/src/main/java/forestry/core/utils/VillagerTradeLists.java +++ b/src/main/java/forestry/core/utils/VillagerTradeLists.java @@ -182,7 +182,7 @@ public class VillagerTradeLists { @Nonnull public ItemStack buyingItemStackTwo; @Nullable - public EntityVillager.PriceInfo buyingItemTwoInfo; + public EntityVillager.PriceInfo buyingPriceItemTwoInfo; @Nonnull public ItemStack sellingItemstack; @Nullable @@ -192,13 +192,13 @@ public class VillagerTradeLists { @Nonnull ItemStack buyingItemStack, @Nullable EntityVillager.PriceInfo buyingPriceInfo, @Nonnull ItemStack buyingItemStackTwo, - @Nullable EntityVillager.PriceInfo buyingItemTwoInfo, + @Nullable EntityVillager.PriceInfo buyingPriceItemTwoInfo, @Nonnull ItemStack sellingItemstack, @Nullable EntityVillager.PriceInfo sellingPriceInfo) { this.buyingItemStack = buyingItemStack; this.buyingPriceInfo = buyingPriceInfo; this.buyingItemStackTwo = buyingItemStackTwo; - this.buyingItemTwoInfo = buyingItemTwoInfo; + this.buyingPriceItemTwoInfo = buyingPriceItemTwoInfo; this.sellingItemstack = sellingItemstack; this.sellingPriceInfo = sellingPriceInfo; } @@ -211,8 +211,8 @@ public class VillagerTradeLists { } int buyTwoAmount = 1; - if (this.buyingItemTwoInfo != null) { - buyTwoAmount = this.buyingItemTwoInfo.getPrice(random); + if (this.buyingPriceItemTwoInfo != null) { + buyTwoAmount = this.buyingPriceItemTwoInfo.getPrice(random); } int sellAmount = 1; From 4681bf4cfb75b8bd8b0b6e603883efe354feb713 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 7 Jun 2016 23:33:05 -0700 Subject: [PATCH 07/15] Update Chinese localization --- lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang b/lang index 2a4b65a20..ac5825bcc 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 2a4b65a20c3153f71cea5d323da843524e358695 +Subproject commit ac5825bcc93092a5705135757fa33761eecfdc7a From 1117b820f13684a1c73795874bab4f5e370f2030 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 7 Jun 2016 23:34:01 -0700 Subject: [PATCH 08/15] Update to latest version of JEI --- gradle.properties | 2 +- src/main/java/forestry/Forestry.java | 1 + .../compat/ApicultureJeiPlugin.java | 21 +++++++++++++++++++ .../java/forestry/core/genetics/Genome.java | 6 +++++- .../jei/bottler/BottlerRecipeHandler.java | 6 ++++++ .../jei/carpenter/CarpenterRecipeHandler.java | 6 ++++++ .../centrifuge/CentrifugeRecipeHandler.java | 6 ++++++ .../fabricator/FabricatorRecipeHandler.java | 6 ++++++ .../jei/fermenter/FermenterRecipeHandler.java | 6 ++++++ .../jei/moistener/MoistenerRecipeHandler.java | 6 ++++++ .../jei/rainmaker/RainmakerRecipeHandler.java | 6 ++++++ .../jei/squeezer/SqueezerRecipeHandler.java | 6 ++++++ .../recipes/jei/still/StillRecipeHandler.java | 6 ++++++ 13 files changed, 82 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 3db0c5749..41cefa854 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ mcversion=1.9.4 forgeversion=12.17.0.1950 mcp_mappings=snapshot_20160525 -jei_version=3.4.0.+ +jei_version=3.6.0.+ ic2_version=2.5.5-ex19 version_major=5 diff --git a/src/main/java/forestry/Forestry.java b/src/main/java/forestry/Forestry.java index 5458488bd..b89353a84 100644 --- a/src/main/java/forestry/Forestry.java +++ b/src/main/java/forestry/Forestry.java @@ -57,6 +57,7 @@ import forestry.plugins.PluginManager; + "after:IC2@[2.3.235,);" + "after:Natura@[2.2.0,);" + "after:HardcoreEnderExpansion;" + + "after:JEI@[3.6.0,);" + "after:basemetals;") public class Forestry { diff --git a/src/main/java/forestry/apiculture/compat/ApicultureJeiPlugin.java b/src/main/java/forestry/apiculture/compat/ApicultureJeiPlugin.java index a778f6da1..f0113612b 100644 --- a/src/main/java/forestry/apiculture/compat/ApicultureJeiPlugin.java +++ b/src/main/java/forestry/apiculture/compat/ApicultureJeiPlugin.java @@ -1,15 +1,20 @@ package forestry.apiculture.compat; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.Arrays; import java.util.List; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import forestry.api.genetics.IAlleleSpecies; import forestry.apiculture.PluginApiculture; +import forestry.apiculture.genetics.BeeGenome; import mezz.jei.api.BlankModPlugin; import mezz.jei.api.IModRegistry; +import mezz.jei.api.INbtRegistry; import mezz.jei.api.JEIPlugin; @JEIPlugin @@ -34,5 +39,21 @@ public class ApicultureJeiPlugin extends BlankModPlugin { registry.addDescription(new ItemStack(PluginApiculture.items.habitatLocator), "for.jei.description.habitat.locator"); registry.addDescription(new ItemStack(PluginApiculture.items.scoop), "for.jei.description.scoop"); + + INbtRegistry nbtRegistry = registry.getJeiHelpers().getNbtRegistry(); + nbtRegistry.registerNbtInterpreter(PluginApiculture.items.beeDroneGE, BeeNbtInterpreter.INSTANCE); + nbtRegistry.registerNbtInterpreter(PluginApiculture.items.beePrincessGE, BeeNbtInterpreter.INSTANCE); + nbtRegistry.registerNbtInterpreter(PluginApiculture.items.beeQueenGE, BeeNbtInterpreter.INSTANCE); + } + + private static class BeeNbtInterpreter implements INbtRegistry.INbtInterpreter { + public static BeeNbtInterpreter INSTANCE = new BeeNbtInterpreter(); + + @Nullable + @Override + public String getSubtypeInfoFromNbt(@Nonnull NBTTagCompound nbtTagCompound) { + IAlleleSpecies species = BeeGenome.getSpeciesDirectly(nbtTagCompound); + return species == null ? null : species.getUID(); + } } } diff --git a/src/main/java/forestry/core/genetics/Genome.java b/src/main/java/forestry/core/genetics/Genome.java index 192583779..af5269d0a 100755 --- a/src/main/java/forestry/core/genetics/Genome.java +++ b/src/main/java/forestry/core/genetics/Genome.java @@ -115,11 +115,15 @@ public abstract class Genome implements IGenome { * Quickly gets the species without loading the whole genome. * We need this because the client uses the species for rendering. */ - protected static IAlleleSpecies getSpeciesDirectly(ItemStack itemStack) { + public static IAlleleSpecies getSpeciesDirectly(ItemStack itemStack) { NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); if (nbtTagCompound == null) { return null; } + return getSpeciesDirectly(nbtTagCompound); + } + + public static IAlleleSpecies getSpeciesDirectly(@Nonnull NBTTagCompound nbtTagCompound) { NBTTagCompound genomeNBT = nbtTagCompound.getCompoundTag("Genome"); if (genomeNBT == null) { diff --git a/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipeHandler.java b/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipeHandler.java index c2ffd91e1..7b7754f49 100644 --- a/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipeHandler.java +++ b/src/main/java/forestry/factory/recipes/jei/bottler/BottlerRecipeHandler.java @@ -22,6 +22,12 @@ public class BottlerRecipeHandler implements IRecipeHandler implements I return ForestryRecipeCategoryUid.SQUEEZER; } + @Nonnull + @Override + public String getRecipeCategoryUid(@Nonnull R recipe) { + return ForestryRecipeCategoryUid.SQUEEZER; + } + @Nonnull @Override public IRecipeWrapper getRecipeWrapper(@Nonnull R recipe) { diff --git a/src/main/java/forestry/factory/recipes/jei/still/StillRecipeHandler.java b/src/main/java/forestry/factory/recipes/jei/still/StillRecipeHandler.java index 7d8aa7caa..582cad2a9 100644 --- a/src/main/java/forestry/factory/recipes/jei/still/StillRecipeHandler.java +++ b/src/main/java/forestry/factory/recipes/jei/still/StillRecipeHandler.java @@ -22,6 +22,12 @@ public class StillRecipeHandler implements IRecipeHandler { return ForestryRecipeCategoryUid.STILL; } + @Nonnull + @Override + public String getRecipeCategoryUid(@Nonnull StillRecipeWrapper recipe) { + return ForestryRecipeCategoryUid.STILL; + } + @Nonnull @Override public IRecipeWrapper getRecipeWrapper(@Nonnull StillRecipeWrapper recipe) { From a1f7a678c1eed3d583af097d2ad6b3d9d8dd8932 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 7 Jun 2016 23:40:33 -0700 Subject: [PATCH 09/15] Use ForgeRegistries instead of Item and Block registries --- src/main/java/forestry/core/PluginFluids.java | 28 ++++++++++------- .../forestry/core/utils/ItemStackUtil.java | 30 +++++++------------ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/main/java/forestry/core/PluginFluids.java b/src/main/java/forestry/core/PluginFluids.java index 5fe88e6d0..3f56940d6 100644 --- a/src/main/java/forestry/core/PluginFluids.java +++ b/src/main/java/forestry/core/PluginFluids.java @@ -10,6 +10,16 @@ ******************************************************************************/ package forestry.core; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fml.common.registry.ForgeRegistries; +import net.minecraftforge.fml.common.registry.GameRegistry; + import forestry.api.core.ForestryAPI; import forestry.api.fuels.FuelManager; import forestry.api.fuels.GeneratorFuel; @@ -23,14 +33,6 @@ import forestry.core.utils.Log; import forestry.plugins.BlankForestryPlugin; import forestry.plugins.ForestryPlugin; import forestry.plugins.ForestryPluginUids; -import net.minecraft.block.Block; -import net.minecraft.item.ItemBlock; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fml.common.registry.GameData; -import net.minecraftforge.fml.common.registry.GameRegistry; @ForestryPlugin(pluginID = ForestryPluginUids.FLUIDS, name = "Fluids", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.plugin.fluids.description") public class PluginFluids extends BlankForestryPlugin { @@ -62,14 +64,20 @@ public class PluginFluids extends BlankForestryPlugin { if (fluidBlock != null) { String name = "fluid." + forestryFluid.getTag(); fluidBlock.setUnlocalizedName("forestry." + name); - GameRegistry.registerBlock(fluidBlock, ItemBlock.class, name); + fluidBlock.setRegistryName(name); + GameRegistry.register(fluidBlock); + + ItemBlock itemBlock = new ItemBlock(fluidBlock); + itemBlock.setRegistryName(name); + GameRegistry.register(itemBlock); + Proxies.render.registerFluidStateMapper(fluidBlock, forestryFluid); if (forestryFluid.getOtherContainers().isEmpty()) { FluidRegistry.addBucketForFluid(fluid); } } } else { - ResourceLocation resourceLocation = GameData.getBlockRegistry().getNameForObject(fluidBlock); + ResourceLocation resourceLocation = ForgeRegistries.BLOCKS.getKey(fluidBlock); Log.warning("Pre-existing {} fluid block detected, deferring to {}:{}, " + "this may cause issues if the server/client have different mod load orders, " + "recommended that you disable all but one instance of {} fluid blocks via your configs.", fluid.getName(), resourceLocation.getResourceDomain(), resourceLocation.getResourcePath(), fluid.getName()); diff --git a/src/main/java/forestry/core/utils/ItemStackUtil.java b/src/main/java/forestry/core/utils/ItemStackUtil.java index b470c3e30..9a70f4bd4 100644 --- a/src/main/java/forestry/core/utils/ItemStackUtil.java +++ b/src/main/java/forestry/core/utils/ItemStackUtil.java @@ -23,12 +23,12 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry; -import net.minecraftforge.fml.common.registry.GameData; +import net.minecraftforge.fml.common.registry.ForgeRegistries; +import net.minecraftforge.fml.common.registry.IForgeRegistry; import net.minecraftforge.oredict.OreDictionary; public abstract class ItemStackUtil { @@ -68,8 +68,8 @@ public abstract class ItemStackUtil { if (item == null) { return null; } - FMLControlledNamespacedRegistry itemRegistry = GameData.getItemRegistry(); - return itemRegistry.getNameForObject(item); + IForgeRegistry itemRegistry = ForgeRegistries.ITEMS; + return itemRegistry.getKey(item); } /** @@ -125,12 +125,8 @@ public abstract class ItemStackUtil { if (itemName == null) { return null; } - FMLControlledNamespacedRegistry itemRegistry = GameData.getItemRegistry(); - int registryID = itemRegistry.getId(itemName); - if (registryID == -1) { - return null; - } - return itemRegistry.getRaw(registryID); + IForgeRegistry itemRegistry = ForgeRegistries.ITEMS; + return itemRegistry.getValue(itemName); } /** @@ -141,8 +137,8 @@ public abstract class ItemStackUtil { if (block == null) { return null; } - FMLControlledNamespacedRegistry blockRegistry = GameData.getBlockRegistry(); - return blockRegistry.getNameForObject(block); + IForgeRegistry blockRegistry = ForgeRegistries.BLOCKS; + return blockRegistry.getKey(block); } /** @@ -169,12 +165,8 @@ public abstract class ItemStackUtil { if (itemName == null) { return null; } - FMLControlledNamespacedRegistry blockRegistry = GameData.getBlockRegistry(); - int registryID = blockRegistry.getId(itemName); - if (registryID == -1) { - return null; - } - return blockRegistry.getRaw(registryID); + IForgeRegistry blockRegistry = ForgeRegistries.BLOCKS; + return blockRegistry.getValue(itemName); } /** From c1a590961d6bee6ba7da5b44106bed1d6c288067 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 7 Jun 2016 23:40:41 -0700 Subject: [PATCH 10/15] Cleanup unused fields --- gradle.properties | 2 +- src/main/java/forestry/apiculture/PluginApiculture.java | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 41cefa854..4d696f799 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,4 +7,4 @@ ic2_version=2.5.5-ex19 version_major=5 version_minor=0 -version_patch=9 +version_patch=10 diff --git a/src/main/java/forestry/apiculture/PluginApiculture.java b/src/main/java/forestry/apiculture/PluginApiculture.java index 7a757c02b..528da91f8 100644 --- a/src/main/java/forestry/apiculture/PluginApiculture.java +++ b/src/main/java/forestry/apiculture/PluginApiculture.java @@ -130,16 +130,12 @@ public class PluginApiculture extends BlankForestryPlugin { public static String beekeepingMode = "NORMAL"; private static float secondPrincessChance = 0; public static final int ticksPerBeeWorkCycle = 550; - public static boolean fancyRenderedBees = false; public static ItemRegistryApiculture items; public static BlockRegistryApiculture blocks; public static HiveRegistry hiveRegistry; - private final Map defaultAcceptedFlowers = new HashMap<>(); - private final Map defaultPlantableFlowers = new HashMap<>(); - public static VillagerRegistry.VillagerProfession villagerApiarist; @Override From 4ba3370fc9c9a65166c3e58e09d86a61ac5445cc Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Wed, 8 Jun 2016 11:06:29 -0500 Subject: [PATCH 11/15] Fix rare possible npe in random hive trade --- src/main/java/forestry/apiculture/VillagerApiaristTrades.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/VillagerApiaristTrades.java b/src/main/java/forestry/apiculture/VillagerApiaristTrades.java index 73bd2c631..00ac4a8d3 100644 --- a/src/main/java/forestry/apiculture/VillagerApiaristTrades.java +++ b/src/main/java/forestry/apiculture/VillagerApiaristTrades.java @@ -79,7 +79,7 @@ public class VillagerApiaristTrades { buyTwoAmount = this.buyingPriceItemTwoInfo.getPrice(random); } BeeDefinition [] forestryMundane = new BeeDefinition[] { BeeDefinition.FOREST, BeeDefinition.MEADOWS, BeeDefinition.MODEST, BeeDefinition.WINTRY, BeeDefinition.TROPICAL, BeeDefinition.MARSHY }; - ItemStack randomHiveDrone = forestryMundane[random.nextInt(forestryMundane.length)].getMemberStack(EnumBeeType.DRONE); + ItemStack randomHiveDrone = forestryMundane[random.nextInt(forestryMundane.length-1)].getMemberStack(EnumBeeType.DRONE); ItemStack buyItemStack = this.buyingItemStack.copy(); buyItemStack.stackSize = buyAmount; ItemStack buyItemStackTwo = this.buyingItemStackTwo.copy(); From ab88e7d57cc603d50e5e80f97748812987d8b106 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 9 Jun 2016 16:29:14 -0700 Subject: [PATCH 12/15] Fix #1311 Crash with WAILA and butterfly or using butterfly kill command --- gradle.properties | 4 ++-- .../lepidopterology/commands/CommandButterfly.java | 7 +++---- .../lepidopterology/entities/EntityButterfly.java | 8 +++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4d696f799..127736ead 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ mcversion=1.9.4 -forgeversion=12.17.0.1950 +forgeversion=12.17.0.1957 mcp_mappings=snapshot_20160525 jei_version=3.6.0.+ @@ -7,4 +7,4 @@ ic2_version=2.5.5-ex19 version_major=5 version_minor=0 -version_patch=10 +version_patch=11 diff --git a/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java b/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java index 0081abd4b..4b4c7cef0 100644 --- a/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java +++ b/src/main/java/forestry/lepidopterology/commands/CommandButterfly.java @@ -13,6 +13,7 @@ package forestry.lepidopterology.commands; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; import net.minecraft.server.MinecraftServer; +import net.minecraft.util.EntitySelectors; import forestry.core.commands.CommandHelpers; import forestry.core.commands.SubCommand; @@ -43,10 +44,8 @@ public class CommandButterfly extends SubCommand { CommandHelpers.throwWrongUsage(sender, this); } - for (Object entity : sender.getEntityWorld().getLoadedEntityList()) { - if (entity instanceof EntityButterfly) { - ((EntityButterfly) entity).setDead(); - } + for (EntityButterfly butterfly : sender.getEntityWorld().getEntities(EntityButterfly.class, EntitySelectors.IS_ALIVE)) { + butterfly.setDead(); } } diff --git a/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java b/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java index d12f9fa9e..02645851b 100755 --- a/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java +++ b/src/main/java/forestry/lepidopterology/entities/EntityButterfly.java @@ -131,9 +131,11 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly public void writeEntityToNBT(NBTTagCompound nbttagcompound) { super.writeEntityToNBT(nbttagcompound); - NBTTagCompound bio = new NBTTagCompound(); - contained.writeToNBT(bio); - nbttagcompound.setTag("BTFLY", bio); + if (contained != null) { + NBTTagCompound bio = new NBTTagCompound(); + contained.writeToNBT(bio); + nbttagcompound.setTag("BTFLY", bio); + } if (pollen != null) { NBTTagCompound pln = new NBTTagCompound(); From 12f5d7be6cd4ab9b43349b9b1506176ab0757d5f Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 9 Jun 2016 16:36:32 -0700 Subject: [PATCH 13/15] Revert "Fix rare possible npe in random hive trade" This reverts commit 4ba3370fc9c9a65166c3e58e09d86a61ac5445cc. --- src/main/java/forestry/apiculture/VillagerApiaristTrades.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/forestry/apiculture/VillagerApiaristTrades.java b/src/main/java/forestry/apiculture/VillagerApiaristTrades.java index 00ac4a8d3..73bd2c631 100644 --- a/src/main/java/forestry/apiculture/VillagerApiaristTrades.java +++ b/src/main/java/forestry/apiculture/VillagerApiaristTrades.java @@ -79,7 +79,7 @@ public class VillagerApiaristTrades { buyTwoAmount = this.buyingPriceItemTwoInfo.getPrice(random); } BeeDefinition [] forestryMundane = new BeeDefinition[] { BeeDefinition.FOREST, BeeDefinition.MEADOWS, BeeDefinition.MODEST, BeeDefinition.WINTRY, BeeDefinition.TROPICAL, BeeDefinition.MARSHY }; - ItemStack randomHiveDrone = forestryMundane[random.nextInt(forestryMundane.length-1)].getMemberStack(EnumBeeType.DRONE); + ItemStack randomHiveDrone = forestryMundane[random.nextInt(forestryMundane.length)].getMemberStack(EnumBeeType.DRONE); ItemStack buyItemStack = this.buyingItemStack.copy(); buyItemStack.stackSize = buyAmount; ItemStack buyItemStackTwo = this.buyingItemStackTwo.copy(); From 92eab8d47a03eec9aa3f439fa68d4902d08656c6 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 9 Jun 2016 18:34:57 -0700 Subject: [PATCH 14/15] Fix #1308 Restore compatibility with old fluid pipes --- gradle.properties | 2 +- .../forestry/core/tiles/ILiquidTankTile.java | 45 ++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 127736ead..30f611a8b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,4 +7,4 @@ ic2_version=2.5.5-ex19 version_major=5 version_minor=0 -version_patch=11 +version_patch=12 diff --git a/src/main/java/forestry/core/tiles/ILiquidTankTile.java b/src/main/java/forestry/core/tiles/ILiquidTankTile.java index 622a73191..8b2f03e3b 100644 --- a/src/main/java/forestry/core/tiles/ILiquidTankTile.java +++ b/src/main/java/forestry/core/tiles/ILiquidTankTile.java @@ -12,11 +12,54 @@ package forestry.core.tiles; import javax.annotation.Nonnull; +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.fluids.capability.IFluidTankProperties; + import forestry.core.fluids.ITankManager; -public interface ILiquidTankTile extends ILocatable { +public interface ILiquidTankTile extends ILocatable, IFluidHandler { @Nonnull ITankManager getTankManager(); + @Override + default int fill(EnumFacing from, FluidStack resource, boolean doFill) { + return getTankManager().fill(resource, doFill); + } + + @Override + default FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) { + return getTankManager().drain(resource, doDrain); + } + + @Override + default FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) { + return getTankManager().drain(maxDrain, doDrain); + } + + @Override + default boolean canFill(EnumFacing from, Fluid fluid) { + return getTankManager().canFillFluidType(new FluidStack(fluid, Fluid.BUCKET_VOLUME)); + } + + @Override + default boolean canDrain(EnumFacing from, Fluid fluid) { + return getTankManager().canDrainFluidType(new FluidStack(fluid, Fluid.BUCKET_VOLUME)); + } + + @Override + default FluidTankInfo[] getTankInfo(EnumFacing from) { + IFluidTankProperties[] tankProperties = getTankManager().getTankProperties(); + FluidTankInfo[] tankInfos = new FluidTankInfo[tankProperties.length]; + for (int i = 0; i < tankProperties.length; i++) { + IFluidTankProperties fluidTankProperties = tankProperties[i]; + tankInfos[i] = new FluidTankInfo(fluidTankProperties.getContents(), fluidTankProperties.getCapacity()); + } + return tankInfos; + } } From 6ddc9f307918a66671aa307635bfce8f15b546d3 Mon Sep 17 00:00:00 2001 From: The-Fireplace Date: Sun, 12 Jun 2016 16:09:31 -0500 Subject: [PATCH 15/15] Fixed chests playing the open sound when they close (#1316) --- .../java/forestry/core/tiles/TileNaturalistChest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/forestry/core/tiles/TileNaturalistChest.java b/src/main/java/forestry/core/tiles/TileNaturalistChest.java index 33d3f5c33..1fc0e6b06 100644 --- a/src/main/java/forestry/core/tiles/TileNaturalistChest.java +++ b/src/main/java/forestry/core/tiles/TileNaturalistChest.java @@ -68,7 +68,7 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve prevLidAngle = lidAngle; if (numPlayersUsing > 0 && lidAngle == 0.0F) { - playLidSound("random.chestopen"); + playLidSound(SoundEvents.BLOCK_CHEST_OPEN); } if (numPlayersUsing == 0 && lidAngle > 0.0F || numPlayersUsing > 0 && lidAngle < 1.0F) { @@ -83,13 +83,13 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve lidAngle = Math.max(Math.min(lidAngle, 1), 0); if (lidAngle < 0.5F && oldAngle >= 0.5F) { - playLidSound("random.chestclosed"); + playLidSound(SoundEvents.BLOCK_CHEST_CLOSE); } } } - private void playLidSound(String sound) { - this.worldObj.playSound(null, getPos(), SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + private void playLidSound(SoundEvent sound) { + this.worldObj.playSound(null, getPos(), sound, SoundCategory.BLOCKS, 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); } @Override