mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 18:44:42 +00:00
clean up
This commit is contained in:
1 parent
a3eb353a5d
commit
bd5c2eb171
19 files changed
+5
-678
No files matched your search
@@ -1,15 +1,12 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.implementations.GuiCraftingStatus;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.container.implementations.CraftingCPURecord;
|
||||
import appeng.helpers.MultiCraftingTracker;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.me.storage.MEPassThrough;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
@@ -33,8 +30,6 @@ public class Ae2Reflect {
|
||||
|
||||
private static final Field fInventory_container;
|
||||
private static final Field fInventory_width;
|
||||
private static final Field fInventory_stackList;
|
||||
private static final Field fAEContainer_upgradeable;
|
||||
private static final Field fAEPass_internal;
|
||||
private static final Field fAEInv_partitionList;
|
||||
private static final Method mItemSlot_setExtractable;
|
||||
@@ -43,8 +38,6 @@ public class Ae2Reflect {
|
||||
try {
|
||||
fInventory_container = reflectField(InventoryCrafting.class, "eventHandler", "field_70465_c", "c");
|
||||
fInventory_width = reflectField(InventoryCrafting.class, "inventoryWidth", "field_70464_b", "b");
|
||||
fInventory_stackList = reflectField(InventoryCrafting.class, "stackList", "field_70466_a", "a");
|
||||
fAEContainer_upgradeable = reflectField(ContainerUpgradeable.class, "upgradeable");
|
||||
fAEPass_internal = reflectField(MEPassThrough.class, "internal");
|
||||
fAEInv_partitionList = reflectField(MEInventoryHandler.class, "myPartitionList");
|
||||
mItemSlot_setExtractable = reflectMethod(ItemSlot.class, "setExtractable", boolean.class);
|
||||
@@ -99,10 +92,6 @@ public class Ae2Reflect {
|
||||
return Ae2Reflect.readField(me, fAEPass_internal);
|
||||
}
|
||||
|
||||
public static IUpgradeableHost getUpgrade(ContainerUpgradeable container) {
|
||||
return Ae2Reflect.readField(container, fAEContainer_upgradeable);
|
||||
}
|
||||
|
||||
public static Container getCraftContainer(InventoryCrafting inv) {
|
||||
return Ae2Reflect.readField(inv, fInventory_container);
|
||||
}
|
||||
@@ -111,10 +100,6 @@ public class Ae2Reflect {
|
||||
return Ae2Reflect.readField(inv, fInventory_width);
|
||||
}
|
||||
|
||||
public static ItemStack[] getCraftStackList(InventoryCrafting inv) {
|
||||
return Ae2Reflect.readField(inv, fInventory_stackList);
|
||||
}
|
||||
|
||||
public static void setItemSlotExtractable(ItemSlot slot, boolean extractable) {
|
||||
try {
|
||||
mItemSlot_setExtractable.invoke(slot, extractable);
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.inventory.AEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.network.SPacketFluidSlot;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class FluidSyncHelper {
|
||||
private final IAEFluidTank inv;
|
||||
private final IAEFluidTank cache;
|
||||
private final int idOffset;
|
||||
|
||||
public FluidSyncHelper(final IAEFluidTank inv, final int idOffset )
|
||||
{
|
||||
this.inv = inv;
|
||||
this.cache = new AEFluidInventory( null, inv.getSlots() );
|
||||
this.idOffset = idOffset;
|
||||
}
|
||||
|
||||
public void sendFull( final Iterable<ICrafting> listeners )
|
||||
{
|
||||
this.sendDiffMap( this.createDiffMap( true ), listeners );
|
||||
}
|
||||
|
||||
public void sendDiff( final Iterable<ICrafting> listeners )
|
||||
{
|
||||
this.sendDiffMap( this.createDiffMap( false ), listeners );
|
||||
}
|
||||
|
||||
public void readPacket( final Map<Integer, IAEFluidStack> data )
|
||||
{
|
||||
for( int i = 0; i < this.inv.getSlots(); ++i )
|
||||
{
|
||||
if( data.containsKey( i + this.idOffset ) )
|
||||
{
|
||||
this.inv.setFluidInSlot( i, data.get( i + this.idOffset ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendDiffMap( final Map<Integer, IAEFluidStack> data, final Iterable<ICrafting> listeners )
|
||||
{
|
||||
if( data.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for( final ICrafting l : listeners )
|
||||
{
|
||||
if( l instanceof EntityPlayerMP)
|
||||
{
|
||||
FluidCraft.proxy.netHandler.sendTo( new SPacketFluidSlot( data ), (EntityPlayerMP) l );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Integer, IAEFluidStack> createDiffMap(final boolean full )
|
||||
{
|
||||
final Map<Integer, IAEFluidStack> ret = new HashMap<>();
|
||||
for( int i = 0; i < this.inv.getSlots(); ++i )
|
||||
{
|
||||
if( full || !this.equalsSlot( i ) )
|
||||
{
|
||||
ret.put( i + this.idOffset, this.inv.getFluidInSlot( i ) );
|
||||
}
|
||||
if( !full )
|
||||
{
|
||||
this.cache.setFluidInSlot( i, this.inv.getFluidInSlot( i ) );
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean equalsSlot(int slot )
|
||||
{
|
||||
final IAEFluidStack stackA = this.inv.getFluidInSlot( slot );
|
||||
final IAEFluidStack stackB = this.cache.getFluidInSlot( slot );
|
||||
|
||||
if( !Objects.equals( stackA, stackB ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return stackA == null || stackA.getStackSize() == stackB.getStackSize();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user