mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 18:44:42 +00:00
spotless apply
This commit is contained in:
1 parent
6acf2bace1
commit
5e31096c7e
191 files changed
+5046
-5165
No files matched your search
@@ -12,193 +12,155 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
public class AEFluidInventory implements IAEFluidTank
|
||||
{
|
||||
public class AEFluidInventory implements IAEFluidTank {
|
||||
private final IAEFluidStack[] fluids;
|
||||
private final IAEFluidInventory handler;
|
||||
private final int capacity;
|
||||
public int lastIndex;
|
||||
|
||||
public AEFluidInventory( final IAEFluidInventory handler, final int slots, final int capcity )
|
||||
{
|
||||
public AEFluidInventory(final IAEFluidInventory handler, final int slots, final int capcity) {
|
||||
this.fluids = new IAEFluidStack[slots];
|
||||
this.handler = handler;
|
||||
this.capacity = capcity;
|
||||
}
|
||||
|
||||
public AEFluidInventory( final IAEFluidInventory handler, final int slots )
|
||||
{
|
||||
this( handler, slots, Integer.MAX_VALUE );
|
||||
public AEFluidInventory(final IAEFluidInventory handler, final int slots) {
|
||||
this(handler, slots, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFluidInSlot( final int slot, final IAEFluidStack fluid )
|
||||
{
|
||||
if( slot >= 0 && slot < this.getSlots() )
|
||||
{
|
||||
if( fluid != null && this.fluids[slot] != null && fluid.getFluidStack().isFluidEqual(this.fluids[slot].getFluidStack()) )
|
||||
{
|
||||
if(fluid.getStackSize() != this.fluids[slot].getStackSize())
|
||||
{
|
||||
this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) );
|
||||
this.onContentChanged( slot );
|
||||
public void setFluidInSlot(final int slot, final IAEFluidStack fluid) {
|
||||
if (slot >= 0 && slot < this.getSlots()) {
|
||||
if (fluid != null
|
||||
&& this.fluids[slot] != null
|
||||
&& fluid.getFluidStack().isFluidEqual(this.fluids[slot].getFluidStack())) {
|
||||
if (fluid.getStackSize() != this.fluids[slot].getStackSize()) {
|
||||
this.fluids[slot].setStackSize(Math.min(fluid.getStackSize(), this.capacity));
|
||||
this.onContentChanged(slot);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fluid == null )
|
||||
{
|
||||
} else {
|
||||
if (fluid == null) {
|
||||
this.fluids[slot] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.fluids[slot] = fluid.copy();
|
||||
this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) );
|
||||
this.fluids[slot].setStackSize(Math.min(fluid.getStackSize(), this.capacity));
|
||||
}
|
||||
|
||||
this.onContentChanged( slot );
|
||||
this.onContentChanged(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onContentChanged( final int slot )
|
||||
{
|
||||
if( this.handler != null && Platform.isServer() )
|
||||
{
|
||||
this.handler.onFluidInventoryChanged( this, slot );
|
||||
private void onContentChanged(final int slot) {
|
||||
if (this.handler != null && Platform.isServer()) {
|
||||
this.handler.onFluidInventoryChanged(this, slot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack getFluidInSlot( final int slot )
|
||||
{
|
||||
if( slot >= 0 && slot < this.getSlots() )
|
||||
{
|
||||
public IAEFluidStack getFluidInSlot(final int slot) {
|
||||
if (slot >= 0 && slot < this.getSlots()) {
|
||||
return this.fluids[slot];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public FluidStack getFluidStackInSlot( final int slot )
|
||||
{
|
||||
if( getFluidInSlot(slot) != null )
|
||||
{
|
||||
public FluidStack getFluidStackInSlot(final int slot) {
|
||||
if (getFluidInSlot(slot) != null) {
|
||||
return getFluidInSlot(slot).getFluidStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{
|
||||
public int getSlots() {
|
||||
return this.fluids.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
FluidTankInfo[] props = new FluidTankInfo[this.getSlots()];
|
||||
for( int i = 0; i < this.getSlots(); ++i )
|
||||
{
|
||||
props[i] = new FluidTankInfo(new FluidTankPropertiesWrapper( i ));
|
||||
for (int i = 0; i < this.getSlots(); ++i) {
|
||||
props[i] = new FluidTankInfo(new FluidTankPropertiesWrapper(i));
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
public int fill( final int slot, final FluidStack resource, final boolean doFill )
|
||||
{
|
||||
if( resource == null || resource.amount <= 0 )
|
||||
{
|
||||
public int fill(final int slot, final FluidStack resource, final boolean doFill) {
|
||||
if (resource == null || resource.amount <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
final IAEFluidStack fluid = this.fluids[slot];
|
||||
|
||||
if( fluid != null && !fluid.getFluidStack().isFluidEqual( resource ) )
|
||||
{
|
||||
if (fluid != null && !fluid.getFluidStack().isFluidEqual(resource)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int amountToStore = this.capacity;
|
||||
|
||||
if( fluid != null )
|
||||
{
|
||||
if (fluid != null) {
|
||||
amountToStore -= fluid.getStackSize();
|
||||
}
|
||||
|
||||
amountToStore = Math.min( amountToStore, resource.amount );
|
||||
amountToStore = Math.min(amountToStore, resource.amount);
|
||||
|
||||
if( doFill )
|
||||
{
|
||||
if( fluid == null )
|
||||
{
|
||||
this.setFluidInSlot( slot, AEFluidStack.create( resource ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fluid.setStackSize( fluid.getStackSize() + amountToStore );
|
||||
this.onContentChanged( slot );
|
||||
if (doFill) {
|
||||
if (fluid == null) {
|
||||
this.setFluidInSlot(slot, AEFluidStack.create(resource));
|
||||
} else {
|
||||
fluid.setStackSize(fluid.getStackSize() + amountToStore);
|
||||
this.onContentChanged(slot);
|
||||
}
|
||||
}
|
||||
|
||||
return amountToStore;
|
||||
}
|
||||
|
||||
public FluidStack drain( final int slot, final FluidStack resource, final boolean doDrain )
|
||||
{
|
||||
public FluidStack drain(final int slot, final FluidStack resource, final boolean doDrain) {
|
||||
final IAEFluidStack fluid = this.fluids[slot];
|
||||
if(fluid == null || !fluid.getFluidStack().isFluidEqual(resource))
|
||||
{
|
||||
if (fluid == null || !fluid.getFluidStack().isFluidEqual(resource)) {
|
||||
return null;
|
||||
}
|
||||
return this.drain( slot, resource.amount, doDrain );
|
||||
return this.drain(slot, resource.amount, doDrain);
|
||||
}
|
||||
|
||||
public FluidStack drain( final int slot, final int maxDrain, boolean doDrain )
|
||||
{
|
||||
public FluidStack drain(final int slot, final int maxDrain, boolean doDrain) {
|
||||
final IAEFluidStack fluid = this.fluids[slot];
|
||||
if( fluid == null || maxDrain <= 0 )
|
||||
{
|
||||
if (fluid == null || maxDrain <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int drained = maxDrain;
|
||||
if( fluid.getStackSize() < drained )
|
||||
{
|
||||
if (fluid.getStackSize() < drained) {
|
||||
drained = (int) fluid.getStackSize();
|
||||
}
|
||||
|
||||
FluidStack stack = new FluidStack( fluid.getFluid(), drained );
|
||||
if( doDrain )
|
||||
{
|
||||
fluid.setStackSize( fluid.getStackSize() - drained );
|
||||
if( fluid.getStackSize() <= 0 )
|
||||
{
|
||||
FluidStack stack = new FluidStack(fluid.getFluid(), drained);
|
||||
if (doDrain) {
|
||||
fluid.setStackSize(fluid.getStackSize() - drained);
|
||||
if (fluid.getStackSize() <= 0) {
|
||||
this.fluids[slot] = null;
|
||||
}
|
||||
this.onContentChanged( slot );
|
||||
this.onContentChanged(slot);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, final FluidStack fluid, final boolean doFill )
|
||||
{
|
||||
if( fluid == null || fluid.amount <= 0 )
|
||||
{
|
||||
public int fill(ForgeDirection from, final FluidStack fluid, final boolean doFill) {
|
||||
if (fluid == null || fluid.amount <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
final FluidStack insert = fluid.copy();
|
||||
|
||||
int totalFillAmount = 0;
|
||||
for( int slot = 0; slot < this.getSlots(); ++slot )
|
||||
{
|
||||
int fillAmount = this.fill( slot, insert, doFill );
|
||||
for (int slot = 0; slot < this.getSlots(); ++slot) {
|
||||
int fillAmount = this.fill(slot, insert, doFill);
|
||||
totalFillAmount += fillAmount;
|
||||
insert.amount -= fillAmount;
|
||||
if( insert.amount <= 0 )
|
||||
{
|
||||
if (insert.amount <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -206,36 +168,28 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, final FluidStack fluid, final boolean doDrain )
|
||||
{
|
||||
if( fluid == null || fluid.amount <= 0 )
|
||||
{
|
||||
public FluidStack drain(ForgeDirection from, final FluidStack fluid, final boolean doDrain) {
|
||||
if (fluid == null || fluid.amount <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final FluidStack resource = fluid.copy();
|
||||
|
||||
FluidStack totalDrained = null;
|
||||
for( int slot = 0; slot < this.getSlots(); ++slot )
|
||||
{
|
||||
for (int slot = 0; slot < this.getSlots(); ++slot) {
|
||||
if (!fluid.isFluidEqual(getFluidStackInSlot(slot))) {
|
||||
continue;
|
||||
}
|
||||
FluidStack drain = this.drain( slot, resource, doDrain );
|
||||
if( drain != null )
|
||||
{
|
||||
if( totalDrained == null )
|
||||
{
|
||||
FluidStack drain = this.drain(slot, resource, doDrain);
|
||||
if (drain != null) {
|
||||
if (totalDrained == null) {
|
||||
totalDrained = drain;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
totalDrained.amount += drain.amount;
|
||||
}
|
||||
|
||||
resource.amount -= drain.amount;
|
||||
if( resource.amount <= 0 )
|
||||
{
|
||||
if (resource.amount <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -244,46 +198,37 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain( ForgeDirection from, final int maxDrain, final boolean doDrain )
|
||||
{
|
||||
if( maxDrain == 0 )
|
||||
{
|
||||
public FluidStack drain(ForgeDirection from, final int maxDrain, final boolean doDrain) {
|
||||
if (maxDrain == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FluidStack totalDrained = null;
|
||||
int toDrain = maxDrain;
|
||||
|
||||
for( int slot = lastIndex; slot < this.getSlots(); ++slot )
|
||||
{
|
||||
for (int slot = lastIndex; slot < this.getSlots(); ++slot) {
|
||||
if (this.getFluidInSlot(slot) == null) {
|
||||
if(slot == this.getSlots()-1) lastIndex = 0;
|
||||
if (slot == this.getSlots() - 1) lastIndex = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( totalDrained == null )
|
||||
{
|
||||
totalDrained = this.drain( slot, toDrain, doDrain );
|
||||
if( totalDrained != null )
|
||||
{
|
||||
if (totalDrained == null) {
|
||||
totalDrained = this.drain(slot, toDrain, doDrain);
|
||||
if (totalDrained != null) {
|
||||
lastIndex = slot;
|
||||
toDrain -= totalDrained.amount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
FluidStack copy = totalDrained.copy();
|
||||
copy.amount = toDrain;
|
||||
FluidStack drain = this.drain( slot, copy, doDrain );
|
||||
if( drain != null )
|
||||
{
|
||||
FluidStack drain = this.drain(slot, copy, doDrain);
|
||||
if (drain != null) {
|
||||
totalDrained.amount += drain.amount;
|
||||
toDrain -= drain.amount;
|
||||
}
|
||||
}
|
||||
|
||||
if( toDrain <= 0 )
|
||||
{
|
||||
if (toDrain <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -300,77 +245,61 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
return drain(from, new FluidStack(fluid, 1), false) != null;
|
||||
}
|
||||
|
||||
public void writeToNBT( final NBTTagCompound data, final String name )
|
||||
{
|
||||
public void writeToNBT(final NBTTagCompound data, final String name) {
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
this.writeToNBT( c );
|
||||
data.setTag( name, c );
|
||||
this.writeToNBT(c);
|
||||
data.setTag(name, c);
|
||||
}
|
||||
|
||||
private void writeToNBT( final NBTTagCompound target )
|
||||
{
|
||||
for( int x = 0; x < this.fluids.length; x++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
private void writeToNBT(final NBTTagCompound target) {
|
||||
for (int x = 0; x < this.fluids.length; x++) {
|
||||
try {
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
|
||||
if( this.fluids[x] != null )
|
||||
{
|
||||
this.fluids[x].writeToNBT( c );
|
||||
if (this.fluids[x] != null) {
|
||||
this.fluids[x].writeToNBT(c);
|
||||
}
|
||||
|
||||
target.setTag( "#" + x, c );
|
||||
}
|
||||
catch( final Exception ignored )
|
||||
{
|
||||
target.setTag("#" + x, c);
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT( final NBTTagCompound data, final String name )
|
||||
{
|
||||
final NBTTagCompound c = data.getCompoundTag( name );
|
||||
if( c != null )
|
||||
{
|
||||
this.readFromNBT( c );
|
||||
public void readFromNBT(final NBTTagCompound data, final String name) {
|
||||
final NBTTagCompound c = data.getCompoundTag(name);
|
||||
if (c != null) {
|
||||
this.readFromNBT(c);
|
||||
}
|
||||
}
|
||||
|
||||
private void readFromNBT( final NBTTagCompound target )
|
||||
{
|
||||
for( int x = 0; x < this.fluids.length; x++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
final NBTTagCompound c = target.getCompoundTag( "#" + x );
|
||||
private void readFromNBT(final NBTTagCompound target) {
|
||||
for (int x = 0; x < this.fluids.length; x++) {
|
||||
try {
|
||||
final NBTTagCompound c = target.getCompoundTag("#" + x);
|
||||
|
||||
if( c != null )
|
||||
{
|
||||
this.fluids[x] = Util.loadFluidStackFromNBT( c );
|
||||
if (c != null) {
|
||||
this.fluids[x] = Util.loadFluidStackFromNBT(c);
|
||||
}
|
||||
}
|
||||
catch( final Exception e )
|
||||
{
|
||||
} catch (final Exception e) {
|
||||
this.fluids[x] = null;
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class FluidTankPropertiesWrapper implements IFluidTank
|
||||
{
|
||||
private class FluidTankPropertiesWrapper implements IFluidTank {
|
||||
private final int slot;
|
||||
|
||||
public FluidTankPropertiesWrapper( final int slot )
|
||||
{
|
||||
public FluidTankPropertiesWrapper(final int slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid()
|
||||
{
|
||||
return AEFluidInventory.this.fluids[this.slot] == null ? null : AEFluidInventory.this.fluids[this.slot].getFluidStack();
|
||||
public FluidStack getFluid() {
|
||||
return AEFluidInventory.this.fluids[this.slot] == null
|
||||
? null
|
||||
: AEFluidInventory.this.fluids[this.slot].getFluidStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -379,9 +308,8 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
return Math.min( AEFluidInventory.this.capacity, Integer.MAX_VALUE );
|
||||
public int getCapacity() {
|
||||
return Math.min(AEFluidInventory.this.capacity, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -401,7 +329,8 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
}
|
||||
if (doFill) {
|
||||
if (getFluid() == null)
|
||||
AEFluidInventory.this.setFluidInSlot(this.slot, AEFluidStack.create(new FluidStack(resource.getFluid(), acc)));
|
||||
AEFluidInventory.this.setFluidInSlot(
|
||||
this.slot, AEFluidStack.create(new FluidStack(resource.getFluid(), acc)));
|
||||
else getFluid().amount += acc;
|
||||
}
|
||||
return acc;
|
||||
@@ -416,8 +345,7 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
if (doDrain) {
|
||||
if (amt == getFluid().amount) {
|
||||
AEFluidInventory.this.setFluidInSlot(this.slot, null);
|
||||
}
|
||||
else getFluid().amount -= amt;
|
||||
} else getFluid().amount -= amt;
|
||||
}
|
||||
return remove;
|
||||
}
|
||||
|
||||
@@ -38,9 +38,7 @@ public class AeItemStackHandler implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
|
||||
|
||||
}
|
||||
public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
@@ -58,8 +56,7 @@ public class AeItemStackHandler implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
}
|
||||
public void markDirty() {}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
|
||||
@@ -67,18 +64,13 @@ public class AeItemStackHandler implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
|
||||
}
|
||||
public void openInventory() {}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
|
||||
}
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.glodblock.github.inventory;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface AeStackInventory<T extends IAEStack<T>> extends Iterable<T> {
|
||||
|
||||
@@ -15,5 +14,4 @@ public interface AeStackInventory<T extends IAEStack<T>> extends Iterable<T> {
|
||||
void setStack(int slot, @Nullable T stack);
|
||||
|
||||
Stream<T> stream();
|
||||
|
||||
}
|
||||
@@ -6,16 +6,15 @@ import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.util.ObjectArrayIterator;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class AeStackInventoryImpl <T extends IAEStack<T>> implements AeStackInventory<T> {
|
||||
public class AeStackInventoryImpl<T extends IAEStack<T>> implements AeStackInventory<T> {
|
||||
|
||||
private final StorageChannel channel;
|
||||
private final T[] inv;
|
||||
@@ -24,7 +23,7 @@ public class AeStackInventoryImpl <T extends IAEStack<T>> implements AeStackInve
|
||||
@SuppressWarnings("unchecked")
|
||||
public AeStackInventoryImpl(StorageChannel channel, int slotCount, @Nullable IAEAppEngInventory owner) {
|
||||
this.channel = channel;
|
||||
this.inv = (T[])new IAEStack[slotCount];
|
||||
this.inv = (T[]) new IAEStack[slotCount];
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@@ -88,8 +87,7 @@ public class AeStackInventoryImpl <T extends IAEStack<T>> implements AeStackInve
|
||||
NBTTagCompound stackTag = stacksTag.getCompoundTagAt(i);
|
||||
if (channel == StorageChannel.ITEMS) {
|
||||
inv[i] = stackTag == null ? null : (T) AEItemStack.loadItemStackFromNBT(stackTag);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inv[i] = stackTag == null ? null : (T) Util.loadFluidStackFromNBT(stackTag);
|
||||
}
|
||||
}
|
||||
@@ -98,5 +96,4 @@ public class AeStackInventoryImpl <T extends IAEStack<T>> implements AeStackInve
|
||||
public void readFromNbt(NBTTagCompound parentTag, String key) {
|
||||
readFromNbt(parentTag.getCompoundTag(key));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,5 +53,4 @@ public class BiggerAppEngInventory extends AppEngInternalInventory {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,11 @@ import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -28,20 +33,43 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
|
||||
public FluidConvertingInventoryAdaptor(
|
||||
@Nullable InventoryAdaptor invItems,
|
||||
@Nullable IFluidHandler invFluids,
|
||||
EnumFacing facing,
|
||||
BlockPos pos,
|
||||
boolean isOnmi,
|
||||
Object eioConduct) {
|
||||
this.invItems = invItems;
|
||||
this.invFluids = invFluids;
|
||||
this.side = Util.from(facing);
|
||||
this.posInterface = pos;
|
||||
this.eioDuct = eioConduct;
|
||||
this.onmi = isOnmi;
|
||||
}
|
||||
|
||||
private final InventoryAdaptor invItems;
|
||||
private final IFluidHandler invFluids;
|
||||
private final ForgeDirection side;
|
||||
private final BlockPos posInterface;
|
||||
private final Object eioDuct;
|
||||
private final boolean onmi;
|
||||
|
||||
public static InventoryAdaptor wrap(TileEntity capProvider, EnumFacing face) {
|
||||
// sometimes i wish 1.7.10 has cap system.
|
||||
ForgeDirection f = Util.from(face);
|
||||
TileEntity inter = capProvider.getWorldObj().getTileEntity(capProvider.xCoord + f.offsetX, capProvider.yCoord + f.offsetY, capProvider.zCoord + f.offsetZ);
|
||||
if (!Config.noFluidPacket && !(inter instanceof TileFluidInterface ||
|
||||
(inter instanceof TileCableBus && (((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidInterface || ((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidExportBus))))
|
||||
TileEntity inter = capProvider
|
||||
.getWorldObj()
|
||||
.getTileEntity(
|
||||
capProvider.xCoord + f.offsetX, capProvider.yCoord + f.offsetY, capProvider.zCoord + f.offsetZ);
|
||||
if (!Config.noFluidPacket
|
||||
&& !(inter instanceof TileFluidInterface
|
||||
|| (inter instanceof TileCableBus
|
||||
&& (((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidInterface
|
||||
|| ((TileCableBus) inter).getPart(f.getOpposite())
|
||||
instanceof PartFluidExportBus))))
|
||||
return InventoryAdaptor.getAdaptor(capProvider, f);
|
||||
InventoryAdaptor item = InventoryAdaptor.getAdaptor(capProvider, f);
|
||||
IFluidHandler fluid = capProvider instanceof IFluidHandler ? (IFluidHandler) capProvider : null;
|
||||
@@ -56,27 +84,11 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
return new FluidConvertingInventoryAdaptor(item, fluid, face, new BlockPos(inter), onmi, conduct);
|
||||
}
|
||||
|
||||
private final InventoryAdaptor invItems;
|
||||
private final IFluidHandler invFluids;
|
||||
private final ForgeDirection side;
|
||||
private final BlockPos posInterface;
|
||||
private final Object eioDuct;
|
||||
private final boolean onmi;
|
||||
|
||||
public FluidConvertingInventoryAdaptor(@Nullable InventoryAdaptor invItems, @Nullable IFluidHandler invFluids, EnumFacing facing, BlockPos pos, boolean isOnmi, Object eioConduct) {
|
||||
this.invItems = invItems;
|
||||
this.invFluids = invFluids;
|
||||
this.side = Util.from(facing);
|
||||
this.posInterface = pos;
|
||||
this.eioDuct = eioConduct;
|
||||
this.onmi = isOnmi;
|
||||
}
|
||||
|
||||
public ItemStack addItems( ItemStack toBeAdded, InsertionMode insertionMode ) {
|
||||
public ItemStack addItems(ItemStack toBeAdded, InsertionMode insertionMode) {
|
||||
if (toBeAdded.getItem() instanceof ItemFluidPacket || toBeAdded.getItem() instanceof ItemFluidDrop) {
|
||||
if (invFluids != null) {
|
||||
FluidStack fluid;
|
||||
if( toBeAdded.getItem() instanceof ItemFluidPacket ) {
|
||||
if (toBeAdded.getItem() instanceof ItemFluidPacket) {
|
||||
fluid = ItemFluidPacket.getFluidStack(toBeAdded);
|
||||
} else {
|
||||
fluid = ItemFluidDrop.getFluidStack(toBeAdded);
|
||||
@@ -95,7 +107,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
if (eioDuct != null) {
|
||||
return ((IItemDuct) eioDuct).insertItem(side, toBeAdded);
|
||||
}
|
||||
return invItems != null ? invItems.addItems(toBeAdded,insertionMode) : toBeAdded;
|
||||
return invItems != null ? invItems.addItems(toBeAdded, insertionMode) : toBeAdded;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,7 +126,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
if (onmi) {
|
||||
boolean sus = false;
|
||||
FluidStack fluid;
|
||||
if( toBeSimulated.getItem() instanceof ItemFluidPacket ) {
|
||||
if (toBeSimulated.getItem() instanceof ItemFluidPacket) {
|
||||
fluid = ItemFluidPacket.getFluidStack(toBeSimulated);
|
||||
} else {
|
||||
fluid = ItemFluidDrop.getFluidStack(toBeSimulated);
|
||||
@@ -138,7 +150,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
}
|
||||
if (invFluids != null) {
|
||||
FluidStack fluid;
|
||||
if( toBeSimulated.getItem() instanceof ItemFluidPacket ) {
|
||||
if (toBeSimulated.getItem() instanceof ItemFluidPacket) {
|
||||
fluid = ItemFluidPacket.getFluidStack(toBeSimulated);
|
||||
} else {
|
||||
fluid = ItemFluidDrop.getFluidStack(toBeSimulated);
|
||||
@@ -154,7 +166,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
}
|
||||
return toBeSimulated;
|
||||
}
|
||||
//Assert EIO conduct can hold all item, as it is the origin practice in AE2
|
||||
// Assert EIO conduct can hold all item, as it is the origin practice in AE2
|
||||
if (eioDuct != null) {
|
||||
return null;
|
||||
}
|
||||
@@ -172,12 +184,14 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeSimilarItems(int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination) {
|
||||
public ItemStack removeSimilarItems(
|
||||
int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination) {
|
||||
return invItems != null ? invItems.removeSimilarItems(amount, filter, fuzzyMode, destination) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateSimilarRemove(int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination) {
|
||||
public ItemStack simulateSimilarRemove(
|
||||
int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination) {
|
||||
return invItems != null ? invItems.simulateSimilarRemove(amount, filter, fuzzyMode, destination) : null;
|
||||
}
|
||||
|
||||
@@ -189,7 +203,8 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
}
|
||||
if (invFluids != null && invFluids.getTankInfo(this.side) != null) {
|
||||
List<FluidTankInfo[]> tankInfos = new LinkedList<>();
|
||||
if (invFluids instanceof TileCableBus && ((TileCableBus) invFluids).getPart(this.side) instanceof PartP2PLiquids) {
|
||||
if (invFluids instanceof TileCableBus
|
||||
&& ((TileCableBus) invFluids).getPart(this.side) instanceof PartP2PLiquids) {
|
||||
// read other ends of p2p for blocking mode
|
||||
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) ((TileCableBus) invFluids).getPart(this.side);
|
||||
try {
|
||||
@@ -203,11 +218,9 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
p2p = invFluidsP2P.getInput();
|
||||
checkedInput = true;
|
||||
}
|
||||
if (p2p == invFluidsP2P || p2p == null)
|
||||
continue;
|
||||
if (p2p == invFluidsP2P || p2p == null) continue;
|
||||
IFluidHandler target = Ae2Reflect.getP2PLiquidTarget(p2p);
|
||||
if (target == null)
|
||||
continue;
|
||||
if (target == null) continue;
|
||||
tankInfos.add(target.getTankInfo(p2p.getSide().getOpposite()));
|
||||
}
|
||||
} catch (GridAccessException e) {
|
||||
@@ -235,15 +248,14 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
}
|
||||
|
||||
public boolean hasSlots() {
|
||||
return (invFluids != null && invFluids.getTankInfo(side).length > 0)
|
||||
|| (invItems != null);
|
||||
return (invFluids != null && invFluids.getTankInfo(side).length > 0) || (invItems != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ItemSlot> iterator() {
|
||||
return new SlotIterator(
|
||||
invFluids != null ? invFluids.getTankInfo(side) : new FluidTankInfo[0],
|
||||
invItems != null ? invItems.iterator() : Collections.emptyIterator());
|
||||
invFluids != null ? invFluids.getTankInfo(side) : new FluidTankInfo[0],
|
||||
invItems != null ? invItems.iterator() : Collections.emptyIterator());
|
||||
}
|
||||
|
||||
private static class SlotIterator implements Iterator<ItemSlot> {
|
||||
@@ -277,7 +289,5 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,11 +22,11 @@ public class FluidConvertingInventoryCrafting extends InventoryCrafting {
|
||||
super.setInventorySlotContents(index, ItemFluidPacket.newStack(new FluidStack(fluid, stack.stackSize)));
|
||||
} else {
|
||||
// wtf?
|
||||
super.setInventorySlotContents(index, ItemFluidPacket.newStack(new FluidStack(FluidRegistry.WATER, 1000)));
|
||||
super.setInventorySlotContents(
|
||||
index, ItemFluidPacket.newStack(new FluidStack(FluidRegistry.WATER, 1000)));
|
||||
}
|
||||
} else {
|
||||
super.setInventorySlotContents(index, stack);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.glodblock.github.inventory;
|
||||
|
||||
public interface IAEFluidInventory
|
||||
{
|
||||
public interface IAEFluidInventory {
|
||||
void onFluidInventoryChanged(final IAEFluidTank inv, final int slot);
|
||||
|
||||
AEFluidInventory getInternalFluid();
|
||||
|
||||
@@ -4,10 +4,9 @@ import appeng.api.storage.data.IAEFluidStack;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public interface IAEFluidTank extends IFluidHandler {
|
||||
void setFluidInSlot( final int slot, final IAEFluidStack fluid );
|
||||
void setFluidInSlot(final int slot, final IAEFluidStack fluid);
|
||||
|
||||
IAEFluidStack getFluidInSlot( final int slot );
|
||||
IAEFluidStack getFluidInSlot(final int slot);
|
||||
|
||||
int getSlots();
|
||||
|
||||
}
|
||||
@@ -7,12 +7,11 @@ import com.glodblock.github.util.BlockPos;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class InventoryHandler implements IGuiHandler {
|
||||
|
||||
public static void switchGui(GuiType guiType) {
|
||||
@@ -20,8 +19,13 @@ public class InventoryHandler implements IGuiHandler {
|
||||
}
|
||||
|
||||
public static void openGui(EntityPlayer player, World world, BlockPos pos, EnumFacing face, GuiType guiType) {
|
||||
player.openGui(FluidCraft.INSTANCE,
|
||||
(guiType.ordinal() << 3) | face.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||
player.openGui(
|
||||
FluidCraft.INSTANCE,
|
||||
(guiType.ordinal() << 3) | face.ordinal(),
|
||||
world,
|
||||
pos.getX(),
|
||||
pos.getY(),
|
||||
pos.getZ());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -12,13 +12,12 @@ import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import java.util.*;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
|
||||
private final IFluidHandler handler;
|
||||
private IItemList<IAEFluidStack> cache = AEApi.instance().storage().createFluidList();
|
||||
@@ -43,11 +42,11 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
|
||||
int filled = this.handler.fill(ForgeDirection.UNKNOWN, input.getFluidStack(), type == Actionable.MODULATE);
|
||||
if (filled == 0) {
|
||||
return input.copy();
|
||||
} else if ((long)filled == input.getStackSize()) {
|
||||
} else if ((long) filled == input.getStackSize()) {
|
||||
return null;
|
||||
} else {
|
||||
IAEFluidStack o = input.copy();
|
||||
o.setStackSize(input.getStackSize() - (long)filled);
|
||||
o.setStackSize(input.getStackSize() - (long) filled);
|
||||
if (type == Actionable.MODULATE) {
|
||||
IAEFluidStack added = o.copy();
|
||||
this.cache.add(added);
|
||||
@@ -59,7 +58,8 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
|
||||
}
|
||||
|
||||
public IAEFluidStack extractItems(IAEFluidStack request, Actionable type, BaseActionSource src) {
|
||||
FluidStack removed = this.handler.drain(ForgeDirection.UNKNOWN, request.getFluidStack(), type == Actionable.MODULATE);
|
||||
FluidStack removed =
|
||||
this.handler.drain(ForgeDirection.UNKNOWN, request.getFluidStack(), type == Actionable.MODULATE);
|
||||
if (removed != null && removed.amount != 0) {
|
||||
IAEFluidStack o = request.copy();
|
||||
o.setStackSize(removed.amount);
|
||||
@@ -77,12 +77,11 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
public StorageChannel getChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
//*Decompiled Stuff*//
|
||||
// *Decompiled Stuff*//
|
||||
|
||||
public TickRateModulation onTick() {
|
||||
boolean changed = false;
|
||||
@@ -91,7 +90,8 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
|
||||
IItemList<IAEFluidStack> currentlyOnStorage = AEApi.instance().storage().createFluidList();
|
||||
|
||||
for (FluidTankInfo tankProperty : tankProperties) {
|
||||
if (this.mode != StorageFilter.EXTRACTABLE_ONLY || this.handler.drain(ForgeDirection.UNKNOWN, 1, false) != null) {
|
||||
if (this.mode != StorageFilter.EXTRACTABLE_ONLY
|
||||
|| this.handler.drain(ForgeDirection.UNKNOWN, 1, false) != null) {
|
||||
currentlyOnStorage.add(AEFluidStack.create(tankProperty.fluid));
|
||||
}
|
||||
}
|
||||
@@ -99,22 +99,22 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
|
||||
Iterator<?> var9 = this.cache.iterator();
|
||||
|
||||
IAEFluidStack is;
|
||||
while(var9.hasNext()) {
|
||||
is = (IAEFluidStack)var9.next();
|
||||
while (var9.hasNext()) {
|
||||
is = (IAEFluidStack) var9.next();
|
||||
is.setStackSize(-is.getStackSize());
|
||||
}
|
||||
|
||||
var9 = currentlyOnStorage.iterator();
|
||||
|
||||
while(var9.hasNext()) {
|
||||
is = (IAEFluidStack)var9.next();
|
||||
while (var9.hasNext()) {
|
||||
is = (IAEFluidStack) var9.next();
|
||||
this.cache.add(is);
|
||||
}
|
||||
|
||||
var9 = this.cache.iterator();
|
||||
|
||||
while(var9.hasNext()) {
|
||||
is = (IAEFluidStack)var9.next();
|
||||
while (var9.hasNext()) {
|
||||
is = (IAEFluidStack) var9.next();
|
||||
if (is.getStackSize() != 0L) {
|
||||
changes.add(is);
|
||||
}
|
||||
@@ -133,8 +133,8 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
|
||||
if (a != null) {
|
||||
Iterator i = this.listeners.entrySet().iterator();
|
||||
|
||||
while(i.hasNext()) {
|
||||
Map.Entry<IMEMonitorHandlerReceiver<IAEFluidStack>, Object> l = (Map.Entry)i.next();
|
||||
while (i.hasNext()) {
|
||||
Map.Entry<IMEMonitorHandlerReceiver<IAEFluidStack>, Object> l = (Map.Entry) i.next();
|
||||
IMEMonitorHandlerReceiver key = l.getKey();
|
||||
if (key.isValid(l.getValue())) {
|
||||
key.postChange(this, a, this.getActionSource());
|
||||
@@ -143,7 +143,6 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public AccessRestriction getAccess() {
|
||||
@@ -173,8 +172,8 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
|
||||
public IItemList<IAEFluidStack> getAvailableItems(IItemList out) {
|
||||
Iterator var2 = this.cache.iterator();
|
||||
|
||||
while(var2.hasNext()) {
|
||||
IAEFluidStack fs = (IAEFluidStack)var2.next();
|
||||
while (var2.hasNext()) {
|
||||
IAEFluidStack fs = (IAEFluidStack) var2.next();
|
||||
out.addStorage(fs);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,5 +5,4 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
public interface PatternConsumer {
|
||||
|
||||
void acceptPattern(IAEItemStack[] inputs, IAEItemStack[] outputs);
|
||||
|
||||
}
|
||||
@@ -4,16 +4,16 @@ import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.TankDumpable;
|
||||
import com.glodblock.github.network.CPacketDumpTank;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
public class ButtonMouseHandler implements MouseRegionManager.Handler {
|
||||
|
||||
@Nullable
|
||||
private final String tooltipKey;
|
||||
|
||||
private final Runnable callback;
|
||||
|
||||
public ButtonMouseHandler(@Nullable String tooltipKey, Runnable callback) {
|
||||
@@ -43,5 +43,4 @@ public class ButtonMouseHandler implements MouseRegionManager.Handler {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,12 +2,11 @@ package com.glodblock.github.inventory.gui;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface GuiFactory {
|
||||
|
||||
@Nullable
|
||||
@@ -16,5 +15,4 @@ public interface GuiFactory {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nullable
|
||||
Object createClientGui(EntityPlayer player, World world, int x, int y, int z, EnumFacing face);
|
||||
|
||||
}
|
||||
@@ -13,10 +13,9 @@ import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.parts.PartSharedFluidBus;
|
||||
import com.glodblock.github.common.tile.*;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public enum GuiType {
|
||||
LEVEL_MAINTAINER(new TileGuiFactory<TileLevelMaintainer>(TileLevelMaintainer.class) {
|
||||
@@ -270,5 +269,4 @@ public enum GuiType {
|
||||
GuiType(GuiFactory guiFactory) {
|
||||
this.guiFactory = guiFactory;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.glodblock.github.inventory.gui;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MouseRegionManager {
|
||||
private final GuiContainer gui;
|
||||
private final List<Region> regions = new ArrayList<>();
|
||||
@@ -26,7 +25,9 @@ public class MouseRegionManager {
|
||||
mY -= gui.guiTop;
|
||||
for (Region region : regions) {
|
||||
if (region.containsMouse(mX, mY) && region.handler.onClick(button)) {
|
||||
gui.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1F));
|
||||
gui.mc
|
||||
.getSoundHandler()
|
||||
.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1F));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +41,7 @@ public class MouseRegionManager {
|
||||
if (region.containsMouse(mX, mY)) {
|
||||
List<String> tooltip = region.handler.getTooltip();
|
||||
if (tooltip != null) {
|
||||
((AEBaseGui)gui).drawTooltip(mX,mY,0,String.join("\n",tooltip));
|
||||
((AEBaseGui) gui).drawTooltip(mX, mY, 0, String.join("\n", tooltip));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +64,6 @@ public class MouseRegionManager {
|
||||
boolean containsMouse(int mX, int mY) {
|
||||
return mX >= x && mX < x + width && mY >= y && mY < y + height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public interface Handler {
|
||||
@@ -76,7 +76,5 @@ public class MouseRegionManager {
|
||||
default boolean onClick(int button) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,11 +3,10 @@ package com.glodblock.github.inventory.gui;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import com.glodblock.github.util.Util;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class PartGuiFactory<T> extends TileGuiFactory<T> {
|
||||
|
||||
PartGuiFactory(Class<T> invClass) {
|
||||
@@ -18,7 +17,7 @@ public abstract class PartGuiFactory<T> extends TileGuiFactory<T> {
|
||||
@Override
|
||||
protected T getInventory(TileEntity tile, EnumFacing face) {
|
||||
if (tile instanceof IPartHost) {
|
||||
IPart part = ((IPartHost)tile).getPart(Util.from(face));
|
||||
IPart part = ((IPartHost) tile).getPart(Util.from(face));
|
||||
if (invClass.isInstance(part)) {
|
||||
return invClass.cast(part);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,13 @@ package com.glodblock.github.inventory.gui;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class TankMouseHandler implements MouseRegionManager.Handler {
|
||||
|
||||
private final IAEFluidTank tank;
|
||||
@@ -26,9 +25,11 @@ public class TankMouseHandler implements MouseRegionManager.Handler {
|
||||
public List<String> getTooltip() {
|
||||
IAEFluidStack fluid = tank.getFluidInSlot(index);
|
||||
return Arrays.asList(
|
||||
fluid != null ? fluid.getFluidStack().getLocalizedName() : I18n.format(NameConst.TT_EMPTY),
|
||||
EnumChatFormatting.GRAY + String.format("%,d / %,d mB",
|
||||
fluid != null ? fluid.getStackSize() : 0L, tank.getTankInfo(ForgeDirection.UNKNOWN)[index].capacity));
|
||||
fluid != null ? fluid.getFluidStack().getLocalizedName() : I18n.format(NameConst.TT_EMPTY),
|
||||
EnumChatFormatting.GRAY
|
||||
+ String.format(
|
||||
"%,d / %,d mB",
|
||||
fluid != null ? fluid.getStackSize() : 0L,
|
||||
tank.getTankInfo(ForgeDirection.UNKNOWN)[index].capacity));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,13 +3,12 @@ package com.glodblock.github.inventory.gui;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import com.glodblock.github.util.Util;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class TileGuiFactory<T> implements GuiFactory {
|
||||
|
||||
protected final Class<T> invClass;
|
||||
@@ -42,7 +41,7 @@ public abstract class TileGuiFactory<T> implements GuiFactory {
|
||||
ctx.setY(y);
|
||||
ctx.setZ(z);
|
||||
ctx.setSide(Util.from(face));
|
||||
((AEBaseContainer)gui).setOpenContext(ctx);
|
||||
((AEBaseContainer) gui).setOpenContext(ctx);
|
||||
}
|
||||
return gui;
|
||||
}
|
||||
|
||||
+12
-6
@@ -14,14 +14,22 @@ public class OptionalFluidSlotFakeTypeOnly extends OptionalSlotFakeTypeOnly {
|
||||
|
||||
AEFluidInventory fluidInv;
|
||||
|
||||
public OptionalFluidSlotFakeTypeOnly(IInventory inv, AEFluidInventory fluidInv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) {
|
||||
public OptionalFluidSlotFakeTypeOnly(
|
||||
IInventory inv,
|
||||
AEFluidInventory fluidInv,
|
||||
IOptionalSlotHost containerBus,
|
||||
int idx,
|
||||
int x,
|
||||
int y,
|
||||
int offX,
|
||||
int offY,
|
||||
int groupNum) {
|
||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
||||
this.fluidInv = fluidInv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack( ItemStack is )
|
||||
{
|
||||
public void putStack(ItemStack is) {
|
||||
FluidStack fluidStack = Util.getFluidFromItem(is);
|
||||
if (fluidStack != null) {
|
||||
ItemStack tmp = ItemFluidPacket.newDisplayStack(fluidStack);
|
||||
@@ -31,13 +39,11 @@ public class OptionalFluidSlotFakeTypeOnly extends OptionalSlotFakeTypeOnly {
|
||||
fluidInv.setFluidInSlot(getSlotIndex(), AEFluidStack.create(standard));
|
||||
}
|
||||
super.putStack(tmp);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
super.putStack(null);
|
||||
if (fluidInv != null) {
|
||||
fluidInv.setFluidInSlot(getSlotIndex(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.glodblock.github.inventory.slot;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface SlotFluid {
|
||||
@@ -10,6 +9,4 @@ public interface SlotFluid {
|
||||
IAEItemStack getAeStack();
|
||||
|
||||
void setAeStack(@Nullable IAEItemStack stack, boolean sync);
|
||||
|
||||
|
||||
}
|
||||
@@ -98,5 +98,4 @@ public class SlotSingleItem extends Slot {
|
||||
public int getSlotIndex() {
|
||||
return delegate.getSlotIndex();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user