mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
clean up
This commit is contained in:
1 parent
a3eb353a5d
commit
bd5c2eb171
19 files changed
+5
-678
No files matched your search
@@ -16,7 +16,6 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.*;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.glodblock.github.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.network.CPacketEncodePattern;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -33,7 +32,7 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
|
||||
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/fluid_pattern_encoder.png");
|
||||
|
||||
private final ContainerFluidPatternEncoder cont;
|
||||
private final MouseRegionManager mouseRegions = new MouseRegionManager(this, fontRendererObj);
|
||||
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2Reflect.getStackSizeRenderer(this);
|
||||
|
||||
public GuiFluidPatternEncoder(InventoryPlayer ipl, TileFluidPatternEncoder tile) {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class GuiIngredientBuffer extends AEBaseGui {
|
||||
private static final int TANK_WIDTH = 16, TANK_HEIGHT = 74;
|
||||
|
||||
private final ContainerIngredientBuffer cont;
|
||||
private final MouseRegionManager mouseRegions = new MouseRegionManager(this, this.fontRendererObj);
|
||||
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
|
||||
|
||||
public GuiIngredientBuffer(InventoryPlayer ipl, TileIngredientBuffer tile) {
|
||||
super(new ContainerIngredientBuffer(ipl, tile));
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface IFluidSyncContainer {
|
||||
void receiveFluidSlots( final Map<Integer, IAEFluidStack> fluids );
|
||||
}
|
||||
-382
@@ -1,382 +0,0 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.container.slot.*;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.gui.IFluidSyncContainer;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.FluidSyncHelper;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class ContainerFluidConfigurable extends ContainerUpgradeable implements IFluidSyncContainer
|
||||
{
|
||||
private FluidSyncHelper sync = null;
|
||||
|
||||
public ContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te )
|
||||
{
|
||||
super( ip, te );
|
||||
}
|
||||
|
||||
public abstract IAEFluidTank getFluidConfigInventory();
|
||||
|
||||
private FluidSyncHelper getSynchHelper()
|
||||
{
|
||||
if( this.sync == null )
|
||||
{
|
||||
this.sync = new FluidSyncHelper( this.getFluidConfigInventory(), 0 );
|
||||
}
|
||||
return this.sync;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean hasMETiles = false;
|
||||
for( final Object is : this.inventorySlots )
|
||||
{
|
||||
if( is instanceof InternalSlotME)
|
||||
{
|
||||
hasMETiles = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( hasMETiles && Platform.isClient() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get( idx ); // require AE SLots!
|
||||
|
||||
if( clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessible)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if( clickSlot != null && clickSlot.getHasStack() )
|
||||
{
|
||||
ItemStack tis = clickSlot.getStack();
|
||||
|
||||
if( tis == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<Slot> selectedSlots = new ArrayList<Slot>();
|
||||
|
||||
/**
|
||||
* Gather a list of valid destinations.
|
||||
*/
|
||||
if( clickSlot.isPlayerSide() )
|
||||
{
|
||||
tis = this.transferStackToContainer( tis );
|
||||
|
||||
// target slots in the container...
|
||||
for( final Object inventorySlot : this.inventorySlots )
|
||||
{
|
||||
final AppEngSlot cs = (AppEngSlot) inventorySlot;
|
||||
|
||||
if( !( cs.isPlayerSide() ) && !( cs instanceof SlotFake) && !( cs instanceof SlotCraftingMatrix) )
|
||||
{
|
||||
if( cs.isItemValid( tis ) )
|
||||
{
|
||||
selectedSlots.add( cs );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// target slots in the container...
|
||||
for( final Object inventorySlot : this.inventorySlots )
|
||||
{
|
||||
final AppEngSlot cs = (AppEngSlot) inventorySlot;
|
||||
|
||||
if( ( cs.isPlayerSide() ) && !( cs instanceof SlotFake ) && !( cs instanceof SlotCraftingMatrix ) )
|
||||
{
|
||||
if( cs.isItemValid( tis ) )
|
||||
{
|
||||
selectedSlots.add( cs );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Fake Slot Shift clicking.
|
||||
*/
|
||||
if( selectedSlots.isEmpty() && clickSlot.isPlayerSide() )
|
||||
{
|
||||
if( tis != null )
|
||||
{
|
||||
// target slots in the container...
|
||||
for( final Object inventorySlot : this.inventorySlots )
|
||||
{
|
||||
final AppEngSlot cs = (AppEngSlot) inventorySlot;
|
||||
final ItemStack destination = cs.getStack();
|
||||
|
||||
if( !( cs.isPlayerSide() ) && cs instanceof SlotFake )
|
||||
{
|
||||
if( Platform.isSameItemPrecise( destination, tis ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if( destination == null )
|
||||
{
|
||||
cs.putStack( tis.copy() );
|
||||
cs.onSlotChanged();
|
||||
this.detectAndSendChanges();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( tis != null )
|
||||
{
|
||||
// find partials..
|
||||
for( final Slot d : selectedSlots )
|
||||
{
|
||||
if( d instanceof SlotDisabled || d instanceof SlotME)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( d.isItemValid( tis ) )
|
||||
{
|
||||
if( d.getHasStack() )
|
||||
{
|
||||
final ItemStack t = d.getStack();
|
||||
|
||||
if( Platform.isSameItemPrecise( tis, t ) ) // t.isItemEqual(tis))
|
||||
{
|
||||
int maxSize = t.getMaxStackSize();
|
||||
if( maxSize > d.getSlotStackLimit() )
|
||||
{
|
||||
maxSize = d.getSlotStackLimit();
|
||||
}
|
||||
|
||||
int placeAble = maxSize - t.stackSize;
|
||||
|
||||
if( tis.stackSize < placeAble )
|
||||
{
|
||||
placeAble = tis.stackSize;
|
||||
}
|
||||
|
||||
t.stackSize += placeAble;
|
||||
tis.stackSize -= placeAble;
|
||||
|
||||
if( tis.stackSize <= 0 )
|
||||
{
|
||||
clickSlot.putStack( null );
|
||||
d.onSlotChanged();
|
||||
|
||||
// if ( hasMETiles ) updateClient();
|
||||
|
||||
this.detectAndSendChanges();
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// any match..
|
||||
for( final Slot d : selectedSlots )
|
||||
{
|
||||
if( d instanceof SlotDisabled || d instanceof SlotME )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( d.isItemValid( tis ) )
|
||||
{
|
||||
if( d.getHasStack() )
|
||||
{
|
||||
final ItemStack t = d.getStack();
|
||||
|
||||
if( Platform.isSameItemPrecise( t, tis ) )
|
||||
{
|
||||
int maxSize = t.getMaxStackSize();
|
||||
if( d.getSlotStackLimit() < maxSize )
|
||||
{
|
||||
maxSize = d.getSlotStackLimit();
|
||||
}
|
||||
|
||||
int placeAble = maxSize - t.stackSize;
|
||||
|
||||
if( tis.stackSize < placeAble )
|
||||
{
|
||||
placeAble = tis.stackSize;
|
||||
}
|
||||
|
||||
t.stackSize += placeAble;
|
||||
tis.stackSize -= placeAble;
|
||||
|
||||
if( tis.stackSize <= 0 )
|
||||
{
|
||||
clickSlot.putStack( null );
|
||||
d.onSlotChanged();
|
||||
|
||||
// if ( worldEntity != null )
|
||||
// worldEntity.markDirty();
|
||||
// if ( hasMETiles ) updateClient();
|
||||
|
||||
this.detectAndSendChanges();
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int maxSize = tis.getMaxStackSize();
|
||||
if( maxSize > d.getSlotStackLimit() )
|
||||
{
|
||||
maxSize = d.getSlotStackLimit();
|
||||
}
|
||||
|
||||
final ItemStack tmp = tis.copy();
|
||||
if( tmp.stackSize > maxSize )
|
||||
{
|
||||
tmp.stackSize = maxSize;
|
||||
}
|
||||
|
||||
tis.stackSize -= tmp.stackSize;
|
||||
d.putStack( tmp );
|
||||
|
||||
if( tis.stackSize <= 0 )
|
||||
{
|
||||
clickSlot.putStack( null );
|
||||
d.onSlotChanged();
|
||||
|
||||
// if ( worldEntity != null )
|
||||
// worldEntity.markDirty();
|
||||
// if ( hasMETiles ) updateClient();
|
||||
|
||||
this.detectAndSendChanges();
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clickSlot.putStack( tis != null ? tis.copy() : null );
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ItemStack transferStackToContainer(ItemStack input )
|
||||
{
|
||||
FluidStack fs = Util.getFluidFromItem( input );
|
||||
if( fs != null )
|
||||
{
|
||||
final IAEFluidTank t = this.getFluidConfigInventory();
|
||||
final IAEFluidStack stack = AEFluidStack.create( fs );
|
||||
for( int i = 0; i < t.getSlots(); ++i )
|
||||
{
|
||||
if( t.getFluidInSlot( i ) == null && this.isValidForConfig( i, stack ) )
|
||||
{
|
||||
t.setFluidInSlot( i, stack );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
protected boolean isValidForConfig( int slot, IAEFluidStack fs )
|
||||
{
|
||||
if( this.supportCapacity() )
|
||||
{
|
||||
// assumes 4 slots per upgrade
|
||||
final int upgrades = Ae2Reflect.getUpgrade(this).getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
|
||||
if( slot > 0 && upgrades < 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if( slot > 4 && upgrades < 2 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void standardDetectAndSendChanges()
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
this.getSynchHelper().sendDiff( this.crafters );
|
||||
|
||||
// clear out config items that are no longer valid (eg capacity upgrade removed)
|
||||
final IAEFluidTank t = this.getFluidConfigInventory();
|
||||
for( int i = 0; i < t.getSlots(); ++i )
|
||||
{
|
||||
if( t.getFluidInSlot( i ) != null && !this.isValidForConfig( i, t.getFluidInSlot( i ) ) )
|
||||
{
|
||||
t.setFluidInSlot( i, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
super.standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters( ICrafting listener )
|
||||
{
|
||||
super.addCraftingToCrafters( listener );
|
||||
this.getSynchHelper().sendFull( Collections.singleton( listener ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveFluidSlots( Map<Integer, IAEFluidStack> fluids )
|
||||
{
|
||||
this.getSynchHelper().readPacket( fluids );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,14 +2,9 @@ package com.glodblock.github.client.render;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.glodblock.github.client.render;
|
||||
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BlockRenderInfo;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.block.BlockFluidInterface;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.glodblock.github.common.block;
|
||||
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.FluidPatternDetails;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class FCClassTransformer implements IClassTransformer {
|
||||
break;
|
||||
/*case "appeng.container.implementations.ContainerInterfaceTerminal":
|
||||
tform = ContainerInterfaceTerminalTransformer.INSTANCE;
|
||||
break;*/ //unfinished
|
||||
break;*/ //To-Do
|
||||
default:
|
||||
return code;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
@IFMLLoadingPlugin.Name("FluidCraftCore")
|
||||
@IFMLLoadingPlugin.MCVersion("1.7.10")
|
||||
@IFMLLoadingPlugin.TransformerExclusions("com.glodblock.github.coremod")
|
||||
public class FluidCraftCore implements IFMLLoadingPlugin {
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.glodblock.github.inventory;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
public class AEFluidTank extends FluidTank implements IAEFluidTank
|
||||
{
|
||||
private final IAEFluidInventory host;
|
||||
|
||||
public AEFluidTank( IAEFluidInventory host, int capacity )
|
||||
{
|
||||
super( capacity );
|
||||
this.host = host;
|
||||
if( host instanceof TileEntity) {
|
||||
this.tile = (TileEntity) host;
|
||||
}
|
||||
}
|
||||
|
||||
protected void onContentsChanged()
|
||||
{
|
||||
if( this.host != null && Platform.isServer() )
|
||||
{
|
||||
this.host.onFluidInventoryChanged( this, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFluidInSlot( int slot, IAEFluidStack fluid )
|
||||
{
|
||||
if( slot == 0 )
|
||||
{
|
||||
this.setFluid( fluid == null ? null : fluid.getFluidStack() );
|
||||
this.onContentsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack getFluidInSlot(int slot )
|
||||
{
|
||||
if( slot == 0 )
|
||||
{
|
||||
return AEFluidStack.create( this.getFluid() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return super.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
if (resource == null || !resource.equals(this.getFluid())) return null;
|
||||
return super.drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return super.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return super.fill(new FluidStack(fluid, 1), false) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return drain(ForgeDirection.UNKNOWN, new FluidStack(fluid, 1), false) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return new FluidTankInfo[]{super.getInfo()};
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.glodblock.github.inventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.util.ObjectArrayIterator;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.glodblock.github.inventory.gui;
|
||||
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -13,11 +12,9 @@ import java.util.List;
|
||||
public class MouseRegionManager {
|
||||
private final GuiContainer gui;
|
||||
private final List<Region> regions = new ArrayList<>();
|
||||
private final FontRenderer font;
|
||||
|
||||
public MouseRegionManager(GuiContainer gui, FontRenderer font) {
|
||||
public MouseRegionManager(GuiContainer gui) {
|
||||
this.gui = gui;
|
||||
this.font = font;
|
||||
}
|
||||
|
||||
public void addRegion(int x, int y, int width, int height, Handler handler) {
|
||||
|
||||
@@ -16,7 +16,6 @@ public class ChannelLoader implements Runnable {
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketInventoryAction.Handler(), CPacketInventoryAction.class, id ++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketSetTargetItem.Handler(), CPacketSetTargetItem.class, id ++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id ++, Side.CLIENT);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new SPacketFluidSlot.Handler(), SPacketFluidSlot.class, id ++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketTransferRecipe.Handler(), CPacketTransferRecipe.class, id ++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new CPacketDumpTank.Handler(), CPacketDumpTank.class, id ++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(new SPacketFluidUpdate.Handler(), SPacketFluidUpdate.class, id ++, Side.CLIENT);
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.gui.IFluidSyncContainer;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SPacketFluidSlot implements IMessage {
|
||||
|
||||
private Map<Integer, IAEFluidStack> list;
|
||||
|
||||
public SPacketFluidSlot() {
|
||||
}
|
||||
|
||||
public SPacketFluidSlot(Map<Integer, IAEFluidStack> data) {
|
||||
this.list = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
int size = buf.readInt();
|
||||
this.list = new HashMap<>();
|
||||
try {
|
||||
for (int i = 0; i < size; i ++) {
|
||||
int id = buf.readInt();
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(buf);
|
||||
list.put(id, fluid);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(list.size());
|
||||
try {
|
||||
for (Map.Entry<Integer, IAEFluidStack> fs : list.entrySet()) {
|
||||
buf.writeInt(fs.getKey());
|
||||
fs.getValue().writeToPacket(buf);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<SPacketFluidSlot, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(SPacketFluidSlot message, MessageContext ctx) {
|
||||
final Container c = ctx.getServerHandler().playerEntity.openContainer;
|
||||
if( c instanceof IFluidSyncContainer)
|
||||
{
|
||||
( (IFluidSyncContainer) c ).receiveFluidSlots( message.list );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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