mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-14 01:04:12 +00:00
Fix pipette display. Updates icon on click, shows fluid amount tooltip
This commit is contained in:
1 parent
58a8b29bbf
commit
852604e9d4
4 files changed
+31
-20
No files matched your search
@@ -10,6 +10,17 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IToolPipette;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
@@ -18,12 +29,6 @@ import forestry.core.network.PacketIds;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.core.network.PacketUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class ContainerLiquidTanks extends ContainerForestry {
|
||||
|
||||
@@ -34,7 +39,18 @@ public class ContainerLiquidTanks extends ContainerForestry {
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
public void handlePipetteClick(int slot, EntityPlayer player) {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void handlePipetteClickClient(int slot, EntityPlayer player) {
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
if (itemstack == null || !(itemstack.getItem() instanceof IToolPipette))
|
||||
return;
|
||||
|
||||
PacketPayload payload = new PacketPayload(1, 0, 0);
|
||||
payload.intPayload[0] = slot;
|
||||
Proxies.net.sendToServer(new PacketUpdate(PacketIds.PIPETTE_CLICK, payload));
|
||||
}
|
||||
|
||||
public void handlePipetteClick(int slot, EntityPlayerMP player) {
|
||||
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
if (itemstack == null)
|
||||
@@ -44,13 +60,6 @@ public class ContainerLiquidTanks extends ContainerForestry {
|
||||
if (!(held instanceof IToolPipette))
|
||||
return;
|
||||
|
||||
if (!Proxies.common.isSimulating(player.worldObj)) {
|
||||
PacketPayload payload = new PacketPayload(1, 0, 0);
|
||||
payload.intPayload[0] = slot;
|
||||
Proxies.net.sendToServer(new PacketUpdate(PacketIds.PIPETTE_CLICK, payload));
|
||||
return;
|
||||
}
|
||||
|
||||
IToolPipette pipette = (IToolPipette) held;
|
||||
StandardTank tank = tile.getTankManager().get(slot);
|
||||
int liquidAmount = tank.getFluidAmount();
|
||||
@@ -60,11 +69,14 @@ public class ContainerLiquidTanks extends ContainerForestry {
|
||||
FluidStack fillAmount = tank.drain(1000, false);
|
||||
int filled = pipette.fill(itemstack, fillAmount, true);
|
||||
tank.drain(filled, true);
|
||||
player.updateHeldItem();
|
||||
}
|
||||
} else {
|
||||
FluidStack potential = pipette.drain(itemstack, pipette.getCapacity(itemstack), false);
|
||||
if (potential != null)
|
||||
if (potential != null) {
|
||||
pipette.drain(itemstack, tank.fill(potential, true), true);
|
||||
player.updateHeldItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public class TankWidget extends Widget {
|
||||
|
||||
Item held = itemstack.getItem();
|
||||
if (held instanceof IToolPipette && manager.gui.inventorySlots instanceof ContainerLiquidTanks)
|
||||
((ContainerLiquidTanks) manager.gui.inventorySlots).handlePipetteClick(slot, manager.minecraft.thePlayer);
|
||||
((ContainerLiquidTanks) manager.gui.inventorySlots).handlePipetteClickClient(slot, manager.minecraft.thePlayer);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,7 @@ public class ItemPipette extends ItemForestry implements IToolPipette {
|
||||
return;
|
||||
|
||||
String descr = contents.getFluid().getLocalizedName(contents);
|
||||
if (Config.isDebug)
|
||||
descr += " (" + contents.amount + ")";
|
||||
descr += " (" + contents.amount + " mb)";
|
||||
|
||||
list.add(descr);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class PacketHandler {
|
||||
null);
|
||||
}
|
||||
|
||||
public void onPacketData(InputStream is, EntityPlayer player) {
|
||||
public void onPacketData(InputStream is, EntityPlayerMP player) {
|
||||
DataInputStream data = new DataInputStream(is);
|
||||
PacketUpdate packetU;
|
||||
|
||||
@@ -263,7 +263,7 @@ public class PacketHandler {
|
||||
tile.switchAccessRule(playerEntity);
|
||||
}
|
||||
|
||||
private void onPipetteClick(PacketUpdate packet, EntityPlayer player) {
|
||||
private void onPipetteClick(PacketUpdate packet, EntityPlayerMP player) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
|
||||
if (!(player.openContainer instanceof ContainerLiquidTanks))
|
||||
|
||||
Reference in new issue
Block a user