From 01e43d8a1874ccd8cbafba125b61ec13a3187f56 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 3 Dec 2015 12:19:04 -0800 Subject: [PATCH 1/8] #987 Use fluid names instead of IDs --- .../forestry/core/fluids/tanks/FilteredTank.java | 12 ++++++------ .../java/forestry/core/items/ItemRegistryFluids.java | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java index c595aa4c5..c63611a9e 100644 --- a/src/main/java/forestry/core/fluids/tanks/FilteredTank.java +++ b/src/main/java/forestry/core/fluids/tanks/FilteredTank.java @@ -32,7 +32,7 @@ import forestry.core.utils.StringUtil; */ public class FilteredTank extends StandardTank { - private final Set filters = new HashSet<>(); // FluidIDs + private final Set filters = new HashSet<>(); // FluidNames public FilteredTank(int capacity, Fluid... filters) { this(capacity, Arrays.asList(filters), null); @@ -50,7 +50,7 @@ public class FilteredTank extends StandardTank { public void setFilters(Collection filters) { this.filters.clear(); for (Fluid fluid : filters) { - this.filters.add(fluid.getID()); + this.filters.add(fluid.getName()); } } @@ -64,14 +64,14 @@ public class FilteredTank extends StandardTank { @Override public boolean accepts(Fluid fluid) { - return filters.contains(fluid.getID()); + return filters.contains(fluid.getName()); } private boolean liquidMatchesFilter(FluidStack resource) { if (resource == null || filters == null) { return false; } - return filters.contains(resource.getFluid().getID()); + return filters.contains(resource.getFluid().getName()); } @Override @@ -83,8 +83,8 @@ public class FilteredTank extends StandardTank { toolTip.clear(); if (Proxies.common.isShiftDown() || filters.size() < 5) { - for (Integer filterId : filters) { - Fluid fluidFilter = FluidRegistry.getFluid(filterId); + for (String filterName : filters) { + Fluid fluidFilter = FluidRegistry.getFluid(filterName); EnumRarity rarity = fluidFilter.getRarity(); if (rarity == null) { rarity = EnumRarity.common; diff --git a/src/main/java/forestry/core/items/ItemRegistryFluids.java b/src/main/java/forestry/core/items/ItemRegistryFluids.java index 54fe3d235..52f870705 100644 --- a/src/main/java/forestry/core/items/ItemRegistryFluids.java +++ b/src/main/java/forestry/core/items/ItemRegistryFluids.java @@ -22,10 +22,10 @@ public class ItemRegistryFluids extends ItemRegistry { public final ItemLiquidContainer waxCapsuleEmpty; public final ItemLiquidContainer refractoryEmpty; - private final Table containers = HashBasedTable.create(); + private final Table containers = HashBasedTable.create(); public ItemLiquidContainer getContainer(EnumContainerType type, Fluids fluid) { - return containers.get(type, fluid.getFluid().getID()); + return containers.get(type, fluid.getFluid().getName()); } public ItemRegistryFluids() { @@ -45,7 +45,7 @@ public class ItemRegistryFluids extends ItemRegistry { String name = type.getContainerNameKey() + fluidType.getContainerNameKey(); registerItem(liquidContainer, name); - containers.put(type, fluidType.getFluid().getID(), liquidContainer); + containers.put(type, fluidType.getFluid().getName(), liquidContainer); } } } From 721c8fd0adc918e644237878df8a29c5bd13eee4 Mon Sep 17 00:00:00 2001 From: mezz Date: Tue, 8 Dec 2015 18:22:16 -0800 Subject: [PATCH 2/8] Make AlleleEffectFertile only tick IGrowable and IPlantable --- .../apiculture/genetics/alleles/AlleleEffectFertile.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFertile.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFertile.java index dfae1c968..efcba3f62 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFertile.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFertile.java @@ -13,9 +13,12 @@ package forestry.apiculture.genetics.alleles; import java.util.Random; import net.minecraft.block.Block; +import net.minecraft.block.IGrowable; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; +import net.minecraftforge.common.IPlantable; + import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; @@ -58,8 +61,8 @@ public class AlleleEffectFertile extends AlleleEffectThrottled { private static boolean tryTickColumn(World world, int x, int z, int maxY, int minY) { for (int y = maxY; y >= minY; --y) { - if (!world.isAirBlock(x, y, z)) { - Block block = world.getBlock(x, y, z); + Block block = world.getBlock(x, y, z); + if (block.getTickRandomly() && (block instanceof IGrowable || block instanceof IPlantable)) { world.scheduleBlockUpdate(x, y, z, block, 5); return true; } From 8f8f6a05f7622e6c88154f96dee16e29d1ae031e Mon Sep 17 00:00:00 2001 From: mezz Date: Wed, 9 Dec 2015 14:43:58 -0800 Subject: [PATCH 3/8] Fix #1006 Farm Block Recipes broken --- .../forestry/core/recipes/RecipeUtil.java | 5 +- .../core/recipes/ShapedRecipeCustom.java | 170 +++++++++++++++--- 2 files changed, 150 insertions(+), 25 deletions(-) diff --git a/src/main/java/forestry/core/recipes/RecipeUtil.java b/src/main/java/forestry/core/recipes/RecipeUtil.java index e1ba4b7cd..d842d639b 100644 --- a/src/main/java/forestry/core/recipes/RecipeUtil.java +++ b/src/main/java/forestry/core/recipes/RecipeUtil.java @@ -24,7 +24,6 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; import cpw.mods.fml.common.registry.GameRegistry; @@ -215,12 +214,12 @@ public abstract class RecipeUtil { @SuppressWarnings("unchecked") public static void addRecipe(ItemStack itemstack, Object... obj) { - CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(itemstack, obj)); + CraftingManager.getInstance().getRecipeList().add(new ShapedRecipeCustom(itemstack, obj)); } @SuppressWarnings("unchecked") public static void addPriorityRecipe(ItemStack itemStack, Object... obj) { - CraftingManager.getInstance().getRecipeList().add(0, new ShapedOreRecipe(itemStack, obj)); + CraftingManager.getInstance().getRecipeList().add(0, new ShapedRecipeCustom(itemStack, obj)); } public static void addShapelessRecipe(Item item, Object... obj) { diff --git a/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java b/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java index 99c5157ac..64caf1d43 100644 --- a/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java +++ b/src/main/java/forestry/core/recipes/ShapedRecipeCustom.java @@ -10,22 +10,106 @@ ******************************************************************************/ package forestry.core.recipes; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import net.minecraft.block.Block; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import forestry.api.recipes.IDescriptiveRecipe; +import forestry.core.utils.ItemStackUtil; public class ShapedRecipeCustom extends ShapedOreRecipe implements IDescriptiveRecipe { - private final int width; - private final int height; + //Added in for future ease of change, but hard coded for now. + private static final int MAX_CRAFT_GRID_WIDTH = 3; + private static final int MAX_CRAFT_GRID_HEIGHT = 3; - public ShapedRecipeCustom(int width, int height, ItemStack product, Object... ingredients) { - super(product, ingredients); - this.width = width; - this.height = height; + private ItemStack output = null; + private Object[] input = null; + private int width; + private int height; + private boolean mirrored = true; + + public ShapedRecipeCustom(ItemStack result, Object... recipe) { + super(result, recipe); + output = result.copy(); + + String shape = ""; + int idx = 0; + + if (recipe[idx] instanceof Boolean) { + mirrored = (Boolean) recipe[idx]; + if (recipe[idx + 1] instanceof Object[]) { + recipe = (Object[]) recipe[idx + 1]; + } else { + idx = 1; + } + } + + if (recipe[idx] instanceof String[]) { + String[] parts = ((String[]) recipe[idx++]); + + for (String s : parts) { + width = s.length(); + shape += s; + } + + height = parts.length; + } else { + while (recipe[idx] instanceof String) { + String s = (String) recipe[idx++]; + shape += s; + width = s.length(); + height++; + } + } + + if (width * height != shape.length()) { + String ret = "Invalid shaped ore recipe: "; + for (Object tmp : recipe) { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + + HashMap itemMap = new HashMap(); + + for (; idx < recipe.length; idx += 2) { + Character chr = (Character) recipe[idx]; + Object in = recipe[idx + 1]; + + if (in instanceof ItemStack) { + itemMap.put(chr, ((ItemStack) in).copy()); + } else if (in instanceof Item) { + itemMap.put(chr, new ItemStack((Item) in)); + } else if (in instanceof Block) { + itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE)); + } else if (in instanceof String) { + itemMap.put(chr, OreDictionary.getOres((String) in)); + } else { + String ret = "Invalid shaped ore recipe: "; + for (Object tmp : recipe) { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + } + + input = new Object[width * height]; + int x = 0; + for (char chr : shape.toCharArray()) { + input[x++] = itemMap.get(chr); + } } @Override @@ -54,24 +138,66 @@ public class ShapedRecipeCustom extends ShapedOreRecipe implements IDescriptiveR return false; } - public static ShapedRecipeCustom createShapedRecipe(ItemStack product, Object... materials) { - int index = 0; - int columns = 0; - int rows = 0; - if (materials[index] instanceof String[]) { - String as[] = (String[]) materials[index]; - for (String pattern : as) { - rows++; - columns = pattern.length(); - } - } else { - while (materials[index] instanceof String) { - String pattern = (String) materials[index++]; - rows++; - columns = pattern.length(); + @Override + public boolean matches(InventoryCrafting inv, World world) { + for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) { + for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) { + if (checkMatch(inv, x, y, false)) { + return true; + } + + if (mirrored && checkMatch(inv, x, y, true)) { + return true; + } } } - return new ShapedRecipeCustom(columns, rows, product, materials); + return false; + } + + @SuppressWarnings("unchecked") + private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) { + for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) { + for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) { + int subX = x - startX; + int subY = y - startY; + Object target = null; + + if (subX >= 0 && subY >= 0 && subX < width && subY < height) { + if (mirror) { + target = input[width - subX - 1 + subY * width]; + } else { + target = input[subX + subY * width]; + } + } + + ItemStack slot = inv.getStackInRowAndColumn(x, y); + + if (target instanceof ItemStack) { + if (!ItemStackUtil.isCraftingEquivalent((ItemStack) target, slot)) { + return false; + } + } else if (target instanceof ArrayList) { + boolean matched = false; + + Iterator itr = ((ArrayList) target).iterator(); + while (itr.hasNext() && !matched) { + matched = ItemStackUtil.isCraftingEquivalent(itr.next(), slot); + } + + if (!matched) { + return false; + } + } else if (target == null && slot != null) { + return false; + } + } + } + + return true; + } + + public static ShapedRecipeCustom createShapedRecipe(ItemStack product, Object... materials) { + return new ShapedRecipeCustom(product, materials); } } From a8c84cfcf937c7b9364dbde448e70526b774f60a Mon Sep 17 00:00:00 2001 From: Nirek-K Date: Fri, 11 Dec 2015 12:06:28 -0600 Subject: [PATCH 4/8] Possibly fix IE plugin loading too early, add small RotaryCraft plugin. --- lang | 2 +- .../java/forestry/plugins/PluginManager.java | 2 + .../compat/PluginImmersiveEngineering.java | 2 +- .../plugins/compat/PluginRotaryCraft.java | 59 +++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 src/main/java/forestry/plugins/compat/PluginRotaryCraft.java diff --git a/lang b/lang index 265a8e573..cb5900228 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 265a8e573ab1e32146a2373118be3b8b6d836254 +Subproject commit cb5900228ed0e4ec7a8a16aa69dc329c1a11afb9 diff --git a/src/main/java/forestry/plugins/PluginManager.java b/src/main/java/forestry/plugins/PluginManager.java index c8ab1be25..4561527f1 100644 --- a/src/main/java/forestry/plugins/PluginManager.java +++ b/src/main/java/forestry/plugins/PluginManager.java @@ -59,6 +59,7 @@ import forestry.plugins.compat.PluginImmersiveEngineering; import forestry.plugins.compat.PluginMagicalCrops; import forestry.plugins.compat.PluginNatura; import forestry.plugins.compat.PluginPlantMegaPack; +import forestry.plugins.compat.PluginRotaryCraft; import forestry.plugins.compat.PluginWitchery; public class PluginManager { @@ -116,6 +117,7 @@ public class PluginManager { MAGICALCROPS(new PluginMagicalCrops()), NATURA(new PluginNatura()), PLANTMEGAPACK(new PluginPlantMegaPack()), + ROTARYCRAFT(new PluginRotaryCraft()), WITCHERY(new PluginWitchery()); static { diff --git a/src/main/java/forestry/plugins/compat/PluginImmersiveEngineering.java b/src/main/java/forestry/plugins/compat/PluginImmersiveEngineering.java index bf03c0776..f06dbf356 100644 --- a/src/main/java/forestry/plugins/compat/PluginImmersiveEngineering.java +++ b/src/main/java/forestry/plugins/compat/PluginImmersiveEngineering.java @@ -41,7 +41,7 @@ public class PluginImmersiveEngineering extends ForestryPlugin { } @Override - protected void registerRecipes() { + protected void postInit() { ItemStack hempSeed = GameRegistry.findItemStack(ImEng, "seed", 1); Block hempCrop = GameRegistry.findBlock(ImEng, "hemp"); diff --git a/src/main/java/forestry/plugins/compat/PluginRotaryCraft.java b/src/main/java/forestry/plugins/compat/PluginRotaryCraft.java new file mode 100644 index 000000000..ddb3f135f --- /dev/null +++ b/src/main/java/forestry/plugins/compat/PluginRotaryCraft.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.plugins.compat; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.common.registry.GameRegistry; + +import forestry.api.core.ForestryAPI; +import forestry.api.farming.Farmables; +import forestry.api.recipes.RecipeManagers; +import forestry.core.config.Constants; +import forestry.core.fluids.Fluids; +import forestry.core.utils.ModUtil; +import forestry.farming.logic.FarmableBasicFruit; +import forestry.farming.logic.FarmableGenericCrop; +import forestry.plugins.ForestryPlugin; +import forestry.plugins.Plugin; + +@Plugin(pluginID = "RotaryCraft", name = "RotaryCraft", author = "Nirek", url = Constants.URL, unlocalizedDescription = "for.plugin.rotarycraft.description") +public class PluginRotaryCraft extends ForestryPlugin { + + private static final String RC = "RotaryCraft"; + + @Override + public boolean isAvailable() { + return ModUtil.isModLoaded(RC); + } + + @Override + public String getFailMessage() { + return "RotaryCraft not found"; + } + + @Override + protected void registerRecipes() { + + ItemStack canolaSeed = GameRegistry.findItemStack(RC, "rotarycraft_item_canola", 1); + Block canolaCrop = GameRegistry.findBlock(RC, "rotarycraft_block_canola"); + + int seedAmount = (ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed")/16); + seedAmount = Math.max(seedAmount, 1); // Produce at least 1 mb. + if (canolaSeed != null && canolaCrop != null) { + RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{canolaSeed}, Fluids.SEEDOIL.getFluid(seedAmount)); + Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(canolaSeed, canolaCrop, 9)); + Farmables.farmables.get("farmOrchard").add(new FarmableBasicFruit(canolaCrop, 9)); + } + } + +} From d0c8c92863b791424127fdcca452b6bd62842398 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 12 Dec 2015 17:26:46 -0800 Subject: [PATCH 5/8] Fix #1010 Automatically sync breeding trackers to client --- api/forestry | 2 +- src/main/java/forestry/Forestry.java | 5 +++- .../entities/EntityMinecartApiary.java | 2 -- .../entities/EntityMinecartBeehouse.java | 2 -- .../apiculture/genetics/ApiaristTracker.java | 8 ++++--- .../apiculture/genetics/BeeHelper.java | 2 +- .../apiculture/items/ItemBeealyzer.java | 2 -- .../apiculture/items/ItemImprinter.java | 2 -- .../apiculture/multiblock/TileAlveary.java | 2 -- .../forestry/apiculture/tiles/TileApiary.java | 2 -- .../apiculture/tiles/TileBeehouse.java | 2 -- .../genetics/ArboristTracker.java | 7 +++--- .../arboriculture/genetics/TreeHelper.java | 2 +- .../java/forestry/core/EventHandlerCore.java | 20 ++++++++++++++++ .../core/genetics/BreedingTracker.java | 24 ++++++++++++++++--- src/main/java/forestry/core/gui/GuiUtil.java | 3 --- .../core/tiles/TileNaturalistChest.java | 1 - .../genetics/ButterflyHelper.java | 2 +- .../genetics/LepidopteristTracker.java | 7 +++--- 19 files changed, 62 insertions(+), 35 deletions(-) diff --git a/api/forestry b/api/forestry index b3ffac04d..5e44fe9c6 160000 --- a/api/forestry +++ b/api/forestry @@ -1 +1 @@ -Subproject commit b3ffac04d0b7cf6207450d5494e225ff84da2294 +Subproject commit 5e44fe9c6a9cfb4415b3e6f1d522f6ae057b9294 diff --git a/src/main/java/forestry/Forestry.java b/src/main/java/forestry/Forestry.java index d53d0374a..ff97381b7 100644 --- a/src/main/java/forestry/Forestry.java +++ b/src/main/java/forestry/Forestry.java @@ -17,6 +17,7 @@ import net.minecraft.item.Item; import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; @@ -85,7 +86,9 @@ public class Forestry { packetHandler = new PacketHandler(); // Register event handler - MinecraftForge.EVENT_BUS.register(new EventHandlerCore()); + EventHandlerCore eventHandlerCore = new EventHandlerCore(); + MinecraftForge.EVENT_BUS.register(eventHandlerCore); + FMLCommonHandler.instance().bus().register(eventHandlerCore); MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler()); configFolder = new File(event.getModConfigurationDirectory(), "forestry"); diff --git a/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java b/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java index c5eb9b589..a4fa21f11 100644 --- a/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java +++ b/src/main/java/forestry/apiculture/entities/EntityMinecartApiary.java @@ -20,7 +20,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.IBeeHousingInventory; import forestry.api.apiculture.IBeeListener; import forestry.api.apiculture.IBeeModifier; @@ -112,7 +111,6 @@ public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implement @Override public Object getContainer(EntityPlayer player, int data) { - BeeManager.beeRoot.syncBreedingTrackerToPlayer(player); return new ContainerMinecartBeehouse(player.inventory, this, true); } } diff --git a/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java b/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java index 913784255..b7714189e 100644 --- a/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java +++ b/src/main/java/forestry/apiculture/entities/EntityMinecartBeehouse.java @@ -18,7 +18,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.DefaultBeeListener; import forestry.api.apiculture.IBeeHousingInventory; import forestry.api.apiculture.IBeeListener; @@ -97,7 +96,6 @@ public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase { @Override public Object getContainer(EntityPlayer player, int data) { - BeeManager.beeRoot.syncBreedingTrackerToPlayer(player); return new ContainerMinecartBeehouse(player.inventory, this, false); } } diff --git a/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java b/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java index 225c134b2..0b061fc8b 100755 --- a/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java +++ b/src/main/java/forestry/apiculture/genetics/ApiaristTracker.java @@ -12,6 +12,7 @@ package forestry.apiculture.genetics; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; import com.mojang.authlib.GameProfile; @@ -26,12 +27,13 @@ import forestry.core.genetics.BreedingTracker; public class ApiaristTracker extends BreedingTracker implements IApiaristTracker { /** Required for creation from map storage */ + @SuppressWarnings("unused") public ApiaristTracker(String s) { - this(s, null); + this(s, null, null); } - public ApiaristTracker(String s, GameProfile player) { - super(s, player); + public ApiaristTracker(String s, GameProfile player, World world) { + super(s, player, world); } private int queensTotal = 0; diff --git a/src/main/java/forestry/apiculture/genetics/BeeHelper.java b/src/main/java/forestry/apiculture/genetics/BeeHelper.java index d42621c23..3f4dcd80e 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeHelper.java +++ b/src/main/java/forestry/apiculture/genetics/BeeHelper.java @@ -328,7 +328,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot { // Create a tracker if there is none yet. if (tracker == null) { - tracker = new ApiaristTracker(filename, player); + tracker = new ApiaristTracker(filename, player, world); world.setItemData(filename, tracker); } diff --git a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java index e9ea0fb18..6832199e3 100644 --- a/src/main/java/forestry/apiculture/items/ItemBeealyzer.java +++ b/src/main/java/forestry/apiculture/items/ItemBeealyzer.java @@ -13,7 +13,6 @@ package forestry.apiculture.items; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import forestry.api.apiculture.BeeManager; import forestry.api.core.Tabs; import forestry.apiculture.gui.GuiBeealyzer; import forestry.apiculture.inventory.ItemInventoryBeealyzer; @@ -33,7 +32,6 @@ public class ItemBeealyzer extends ItemWithGui { @Override public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) { - BeeManager.beeRoot.syncBreedingTrackerToPlayer(player); ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem); return new ContainerAlyzer(inventory, player); } diff --git a/src/main/java/forestry/apiculture/items/ItemImprinter.java b/src/main/java/forestry/apiculture/items/ItemImprinter.java index 825447fbc..57ab2a15f 100644 --- a/src/main/java/forestry/apiculture/items/ItemImprinter.java +++ b/src/main/java/forestry/apiculture/items/ItemImprinter.java @@ -13,7 +13,6 @@ package forestry.apiculture.items; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import forestry.api.apiculture.BeeManager; import forestry.api.core.Tabs; import forestry.apiculture.gui.ContainerImprinter; import forestry.apiculture.gui.GuiImprinter; @@ -32,7 +31,6 @@ public class ItemImprinter extends ItemWithGui { @Override public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) { - BeeManager.beeRoot.syncBreedingTrackerToPlayer(player); return new ContainerImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem)); } } diff --git a/src/main/java/forestry/apiculture/multiblock/TileAlveary.java b/src/main/java/forestry/apiculture/multiblock/TileAlveary.java index 3d546f6cf..409ac1bdb 100644 --- a/src/main/java/forestry/apiculture/multiblock/TileAlveary.java +++ b/src/main/java/forestry/apiculture/multiblock/TileAlveary.java @@ -18,7 +18,6 @@ import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.Vec3; import net.minecraft.world.biome.BiomeGenBase; -import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.IBeeHousing; import forestry.api.apiculture.IBeeHousingInventory; import forestry.api.apiculture.IBeeListener; @@ -195,7 +194,6 @@ public abstract class TileAlveary extends MultiblockTileEntityForestry speciesRoots = AlleleManager.alleleRegistry.getSpeciesRoot().values(); + for (ISpeciesRoot speciesRoot : speciesRoots) { + IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.getEntityWorld(), player.getGameProfile()); + breedingTracker.synchToPlayer(player); + } + } + } + @SubscribeEvent public void handleWorldLoad(WorldEvent.Load event) { for (ISaveEventHandler handler : PluginManager.saveEventHandlers) { diff --git a/src/main/java/forestry/core/genetics/BreedingTracker.java b/src/main/java/forestry/core/genetics/BreedingTracker.java index 2dc1bd2ab..2edf56269 100755 --- a/src/main/java/forestry/core/genetics/BreedingTracker.java +++ b/src/main/java/forestry/core/genetics/BreedingTracker.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.core.genetics; +import javax.annotation.Nullable; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; @@ -18,11 +19,13 @@ import java.util.Set; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; import com.mojang.authlib.GameProfile; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.FakePlayer; import forestry.api.core.ForestryEvent; import forestry.api.genetics.AlleleManager; @@ -52,11 +55,15 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin private final Set researchedMutations = new HashSet<>(); private String modeName; + @Nullable private final GameProfile username; + @Nullable + private final World world; - protected BreedingTracker(String s, GameProfile username) { + protected BreedingTracker(String s, @Nullable GameProfile username, @Nullable World world) { super(s); this.username = username; + this.world = world; } @Override @@ -83,16 +90,23 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin */ protected abstract String speciesRootUID(); + private void syncToPlayer() { + if (world != null && username != null) { + EntityPlayer player = world.getPlayerEntityByName(username.getName()); + synchToPlayer(player); + } + } + @Override public void synchToPlayer(EntityPlayer player) { - if (player instanceof EntityPlayerMP) { + if (player instanceof EntityPlayerMP && !(player instanceof FakePlayer)) { IBreedingTracker breedingTracker = getBreedingTracker(player); String modeName = breedingTracker.getModeName(); setModeName(modeName); NBTTagCompound nbttagcompound = new NBTTagCompound(); encodeToNBT(nbttagcompound); - Proxies.net.sendToPlayer(new PacketGenomeTrackerUpdate(nbttagcompound), (EntityPlayerMP) player); + Proxies.net.sendToPlayer(new PacketGenomeTrackerUpdate(nbttagcompound), player); } } @@ -175,6 +189,8 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(speciesRootUID()); ForestryEvent event = new ForestryEvent.MutationDiscovered(speciesRoot, username, mutation, this); MinecraftForge.EVENT_BUS.post(event); + + syncToPlayer(); } } @@ -208,6 +224,8 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(speciesRootUID()); ForestryEvent event = new ForestryEvent.SpeciesDiscovered(speciesRoot, username, species, this); MinecraftForge.EVENT_BUS.post(event); + + syncToPlayer(); } } diff --git a/src/main/java/forestry/core/gui/GuiUtil.java b/src/main/java/forestry/core/gui/GuiUtil.java index 7c84de1c4..2c7970939 100644 --- a/src/main/java/forestry/core/gui/GuiUtil.java +++ b/src/main/java/forestry/core/gui/GuiUtil.java @@ -28,9 +28,6 @@ import forestry.core.gui.tooltips.ToolTipLine; public class GuiUtil { public static void drawItemStack(GuiForestry gui, ItemStack stack, int xPos, int yPos) { GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderHelper.enableGUIStandardItemLighting(); RenderItem itemRender = GuiForestry.getItemRenderer(); diff --git a/src/main/java/forestry/core/tiles/TileNaturalistChest.java b/src/main/java/forestry/core/tiles/TileNaturalistChest.java index e1198bf10..af0cca5e6 100644 --- a/src/main/java/forestry/core/tiles/TileNaturalistChest.java +++ b/src/main/java/forestry/core/tiles/TileNaturalistChest.java @@ -114,7 +114,6 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve @Override public Object getContainer(EntityPlayer player, int page) { - speciesRoot.syncBreedingTrackerToPlayer(player); return new ContainerNaturalistInventory(player.inventory, this, page); } } diff --git a/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java b/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java index 8d6b00a1b..a479a1258 100755 --- a/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java +++ b/src/main/java/forestry/lepidopterology/genetics/ButterflyHelper.java @@ -236,7 +236,7 @@ public class ButterflyHelper extends SpeciesRoot implements IButterflyRoot { // Create a tracker if there is none yet. if (tracker == null) { - tracker = new LepidopteristTracker(filename, player); + tracker = new LepidopteristTracker(filename, player, world); world.setItemData(filename, tracker); } diff --git a/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java b/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java index 876c8df70..3fa441700 100755 --- a/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java +++ b/src/main/java/forestry/lepidopterology/genetics/LepidopteristTracker.java @@ -11,6 +11,7 @@ package forestry.lepidopterology.genetics; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; import com.mojang.authlib.GameProfile; @@ -25,11 +26,11 @@ public class LepidopteristTracker extends BreedingTracker implements ILepidopter /** Required for creation from map storage */ public LepidopteristTracker(String s) { - this(s, null); + this(s, null, null); } - public LepidopteristTracker(String s, GameProfile player) { - super(s, player); + public LepidopteristTracker(String s, GameProfile player, World world) { + super(s, player, world); } @Override From e2f32ab767623dcbc45ad48279f87e08e4e57e35 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 12 Dec 2015 17:45:12 -0800 Subject: [PATCH 6/8] Sync mail to client on login, do not display mail indicator on logout --- ...Client.java => EventHandlerMailAlert.java} | 29 +++++++----- src/main/java/forestry/mail/PostRegistry.java | 4 +- .../java/forestry/mail/PostalCarrier.java | 4 +- .../forestry/mail/gui/ContainerMailbox.java | 4 +- .../mail/network/PacketRegistryMail.java | 6 +-- .../packets/PacketPOBoxInfoRequest.java | 44 ------------------- ...sponse.java => PacketPOBoxInfoUpdate.java} | 6 +-- .../java/forestry/plugins/PluginMail.java | 4 +- 8 files changed, 31 insertions(+), 70 deletions(-) rename src/main/java/forestry/mail/{TickHandlerMailClient.java => EventHandlerMailAlert.java} (57%) mode change 100755 => 100644 delete mode 100644 src/main/java/forestry/mail/network/packets/PacketPOBoxInfoRequest.java rename src/main/java/forestry/mail/network/packets/{PacketPOBoxInfoResponse.java => PacketPOBoxInfoUpdate.java} (91%) diff --git a/src/main/java/forestry/mail/TickHandlerMailClient.java b/src/main/java/forestry/mail/EventHandlerMailAlert.java old mode 100755 new mode 100644 similarity index 57% rename from src/main/java/forestry/mail/TickHandlerMailClient.java rename to src/main/java/forestry/mail/EventHandlerMailAlert.java index 88319eb8d..d03c6b168 --- a/src/main/java/forestry/mail/TickHandlerMailClient.java +++ b/src/main/java/forestry/mail/EventHandlerMailAlert.java @@ -10,31 +10,38 @@ ******************************************************************************/ package forestry.mail; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; + import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import forestry.core.proxy.Proxies; import forestry.mail.gui.GuiMailboxInfo; -import forestry.mail.network.packets.PacketPOBoxInfoRequest; - -public class TickHandlerMailClient { - private static final int THROTTLE_TIME_MS = 10000; - private long lastInfoRequestTime; +import forestry.mail.network.packets.PacketPOBoxInfoUpdate; +public class EventHandlerMailAlert { @SubscribeEvent public void onRenderTick(TickEvent.RenderTickEvent event) { if (event.phase != Phase.END) { return; } - if (GuiMailboxInfo.instance.hasPOBoxInfo()) { + if (Minecraft.getMinecraft().theWorld != null && GuiMailboxInfo.instance.hasPOBoxInfo()) { GuiMailboxInfo.instance.render(); - } else { - long time = System.currentTimeMillis(); - if (time - lastInfoRequestTime > THROTTLE_TIME_MS) { - Proxies.net.sendToServer(new PacketPOBoxInfoRequest()); - lastInfoRequestTime = time; + } + } + + @SubscribeEvent + public void handlePlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) { + EntityPlayer player = event.player; + if (player != null) { + MailAddress address = new MailAddress(player.getGameProfile()); + POBox pobox = PostRegistry.getOrCreatePOBox(player.worldObj, address); + if (pobox != null) { + Proxies.net.sendToPlayer(new PacketPOBoxInfoUpdate(pobox.getPOBoxInfo()), player); } } } diff --git a/src/main/java/forestry/mail/PostRegistry.java b/src/main/java/forestry/mail/PostRegistry.java index 595244eb8..9dcee233d 100755 --- a/src/main/java/forestry/mail/PostRegistry.java +++ b/src/main/java/forestry/mail/PostRegistry.java @@ -32,7 +32,7 @@ import forestry.api.mail.ITradeStation; import forestry.api.mail.PostManager; import forestry.core.proxy.Proxies; import forestry.core.utils.PlayerUtil; -import forestry.mail.network.packets.PacketPOBoxInfoResponse; +import forestry.mail.network.packets.PacketPOBoxInfoUpdate; import forestry.plugins.PluginMail; public class PostRegistry implements IPostRegistry { @@ -75,7 +75,7 @@ public class PostRegistry implements IPostRegistry { EntityPlayer player = PlayerUtil.getPlayer(world, address.getPlayerProfile()); if (player != null) { - Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), player); + Proxies.net.sendToPlayer(new PacketPOBoxInfoUpdate(pobox.getPOBoxInfo()), player); } } diff --git a/src/main/java/forestry/mail/PostalCarrier.java b/src/main/java/forestry/mail/PostalCarrier.java index 3dff7662d..d66955314 100755 --- a/src/main/java/forestry/mail/PostalCarrier.java +++ b/src/main/java/forestry/mail/PostalCarrier.java @@ -30,7 +30,7 @@ import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; import forestry.core.utils.PlayerUtil; import forestry.core.utils.StringUtil; -import forestry.mail.network.packets.PacketPOBoxInfoResponse; +import forestry.mail.network.packets.PacketPOBoxInfoUpdate; public class PostalCarrier implements IPostalCarrier { @@ -88,7 +88,7 @@ public class PostalCarrier implements IPostalCarrier { } else { EntityPlayer player = PlayerUtil.getPlayer(world, recipient.getPlayerProfile()); if (player instanceof EntityPlayerMP) { - Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), (EntityPlayerMP) player); + Proxies.net.sendToPlayer(new PacketPOBoxInfoUpdate(pobox.getPOBoxInfo()), (EntityPlayerMP) player); } } diff --git a/src/main/java/forestry/mail/gui/ContainerMailbox.java b/src/main/java/forestry/mail/gui/ContainerMailbox.java index 9e78508ee..6bea0fc56 100755 --- a/src/main/java/forestry/mail/gui/ContainerMailbox.java +++ b/src/main/java/forestry/mail/gui/ContainerMailbox.java @@ -21,7 +21,7 @@ import forestry.core.proxy.Proxies; import forestry.core.utils.SlotUtil; import forestry.mail.POBox; import forestry.mail.POBoxInfo; -import forestry.mail.network.packets.PacketPOBoxInfoResponse; +import forestry.mail.network.packets.PacketPOBoxInfoUpdate; import forestry.mail.tiles.TileMailbox; public class ContainerMailbox extends ContainerTile { @@ -55,7 +55,7 @@ public class ContainerMailbox extends ContainerTile { if (SlotUtil.isSlotInRange(slotIndex, SLOT_LETTERS, SLOT_LETTERS_COUNT)) { if (!player.worldObj.isRemote && mailInventory != null) { POBoxInfo info = mailInventory.getPOBoxInfo(); - Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(info), player); + Proxies.net.sendToPlayer(new PacketPOBoxInfoUpdate(info), player); } } diff --git a/src/main/java/forestry/mail/network/PacketRegistryMail.java b/src/main/java/forestry/mail/network/PacketRegistryMail.java index 350067895..4dd7138e2 100644 --- a/src/main/java/forestry/mail/network/PacketRegistryMail.java +++ b/src/main/java/forestry/mail/network/PacketRegistryMail.java @@ -14,8 +14,7 @@ import forestry.core.network.PacketRegistry; import forestry.mail.network.packets.PacketLetterInfoRequest; import forestry.mail.network.packets.PacketLetterInfoResponse; import forestry.mail.network.packets.PacketLetterTextSet; -import forestry.mail.network.packets.PacketPOBoxInfoRequest; -import forestry.mail.network.packets.PacketPOBoxInfoResponse; +import forestry.mail.network.packets.PacketPOBoxInfoUpdate; import forestry.mail.network.packets.PacketTraderAddressRequest; import forestry.mail.network.packets.PacketTraderAddressResponse; @@ -24,11 +23,10 @@ public class PacketRegistryMail extends PacketRegistry { public void registerPackets() { registerServerPacket(new PacketLetterInfoRequest()); registerServerPacket(new PacketTraderAddressRequest()); - registerServerPacket(new PacketPOBoxInfoRequest()); registerServerPacket(new PacketLetterTextSet()); registerClientPacket(new PacketLetterInfoResponse()); registerClientPacket(new PacketTraderAddressResponse()); - registerClientPacket(new PacketPOBoxInfoResponse()); + registerClientPacket(new PacketPOBoxInfoUpdate()); } } diff --git a/src/main/java/forestry/mail/network/packets/PacketPOBoxInfoRequest.java b/src/main/java/forestry/mail/network/packets/PacketPOBoxInfoRequest.java deleted file mode 100644 index b68f643de..000000000 --- a/src/main/java/forestry/mail/network/packets/PacketPOBoxInfoRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.mail.network.packets; - -import java.io.IOException; - -import net.minecraft.entity.player.EntityPlayerMP; - -import forestry.core.network.DataInputStreamForestry; -import forestry.core.network.ForestryPacket; -import forestry.core.network.IForestryPacketServer; -import forestry.core.network.PacketIdServer; -import forestry.core.proxy.Proxies; -import forestry.mail.MailAddress; -import forestry.mail.POBox; -import forestry.mail.PostRegistry; - -public class PacketPOBoxInfoRequest extends ForestryPacket implements IForestryPacketServer { - - public PacketPOBoxInfoRequest() { - } - - @Override - public PacketIdServer getPacketId() { - return PacketIdServer.POBOX_INFO_REQUEST; - } - - @Override - public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException { - MailAddress address = new MailAddress(player.getGameProfile()); - POBox pobox = PostRegistry.getOrCreatePOBox(player.worldObj, address); - if (pobox != null) { - Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), player); - } - } -} diff --git a/src/main/java/forestry/mail/network/packets/PacketPOBoxInfoResponse.java b/src/main/java/forestry/mail/network/packets/PacketPOBoxInfoUpdate.java similarity index 91% rename from src/main/java/forestry/mail/network/packets/PacketPOBoxInfoResponse.java rename to src/main/java/forestry/mail/network/packets/PacketPOBoxInfoUpdate.java index 8b3f9e1ce..fd6224c5d 100644 --- a/src/main/java/forestry/mail/network/packets/PacketPOBoxInfoResponse.java +++ b/src/main/java/forestry/mail/network/packets/PacketPOBoxInfoUpdate.java @@ -22,14 +22,14 @@ import forestry.core.network.PacketIdClient; import forestry.mail.POBoxInfo; import forestry.mail.gui.GuiMailboxInfo; -public class PacketPOBoxInfoResponse extends ForestryPacket implements IForestryPacketClient { +public class PacketPOBoxInfoUpdate extends ForestryPacket implements IForestryPacketClient { public POBoxInfo poboxInfo; - public PacketPOBoxInfoResponse() { + public PacketPOBoxInfoUpdate() { } - public PacketPOBoxInfoResponse(POBoxInfo info) { + public PacketPOBoxInfoUpdate(POBoxInfo info) { this.poboxInfo = info; } diff --git a/src/main/java/forestry/plugins/PluginMail.java b/src/main/java/forestry/plugins/PluginMail.java index 29619fe7e..b4d3d9b4f 100755 --- a/src/main/java/forestry/plugins/PluginMail.java +++ b/src/main/java/forestry/plugins/PluginMail.java @@ -28,10 +28,10 @@ import forestry.core.items.EnumElectronTube; import forestry.core.network.IPacketRegistry; import forestry.core.recipes.RecipeUtil; import forestry.core.tiles.MachineDefinition; +import forestry.mail.EventHandlerMailAlert; import forestry.mail.PostRegistry; import forestry.mail.PostalCarrier; import forestry.mail.SaveEventHandlerMail; -import forestry.mail.TickHandlerMailClient; import forestry.mail.blocks.BlockMailType; import forestry.mail.blocks.BlockRegistryMail; import forestry.mail.commands.CommandMail; @@ -67,7 +67,7 @@ public class PluginMail extends ForestryPlugin { PluginCore.rootCommand.addChildCommand(new CommandMail()); if (Config.mailAlertEnabled) { - FMLCommonHandler.instance().bus().register(new TickHandlerMailClient()); + FMLCommonHandler.instance().bus().register(new EventHandlerMailAlert()); } blocks.mail.addDefinitions( From c2437a8a133e00f205fe5f7802c2d57598884653 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 12 Dec 2015 18:08:40 -0800 Subject: [PATCH 7/8] Fix #1009 Minor fluid dupe on right-clicking nearly-full machine --- .../java/forestry/core/fluids/FluidHelper.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/forestry/core/fluids/FluidHelper.java b/src/main/java/forestry/core/fluids/FluidHelper.java index 9403ed339..e06077391 100644 --- a/src/main/java/forestry/core/fluids/FluidHelper.java +++ b/src/main/java/forestry/core/fluids/FluidHelper.java @@ -49,11 +49,19 @@ public final class FluidHelper { FluidStack liquid = getFluidStackInContainer(current); if (fill && liquid != null) { - int used = tank.fill(side, liquid, true); + int canUseAmount = tank.fill(side, liquid, false); + if (canUseAmount == 0) { + return false; + } - if (used > 0) { + ItemStack drainedContainer = getDrainedContainer(current, canUseAmount); + if (ItemStackUtil.isIdenticalItem(current, drainedContainer)) { + return false; + } + + int usedAmount = tank.fill(side, liquid, true); + if (usedAmount > 0) { if (!player.capabilities.isCreativeMode) { - ItemStack drainedContainer = getDrainedContainer(current, used); if (current.stackSize > 1) { player.inventory.decrStackSize(player.inventory.currentItem, 1); if (drainedContainer != null && !player.inventory.addItemStackToInventory(drainedContainer)) { From f3ee4f8694c7e7b1e0b0fbd98f0eb14d0f943e07 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 12 Dec 2015 18:09:51 -0800 Subject: [PATCH 8/8] Bump version to 4.2.2 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index eec520d0c..5c431eea0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,4 +2,4 @@ mcversion=1.7.10 forgeversion=10.13.4.1541-1.7.10 version_major=4 version_minor=2 -version_patch=1 +version_patch=2