mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Fixed Quantum Entangloporters
This commit is contained in:
1 parent
796c9e502a
commit
a9d438c962
8 files changed
+56
-82
No files matched your search
@@ -11,6 +11,9 @@ import mekanism.common.frequency.Frequency;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
@@ -24,7 +27,7 @@ public class InventoryFrequency extends Frequency
|
||||
public double storedEnergy;
|
||||
public FluidTank storedFluid;
|
||||
public GasTank storedGas;
|
||||
public ItemStack storedItem = ItemStack.EMPTY;
|
||||
public NonNullList<ItemStack> inventory = NonNullList.withSize(1, ItemStack.EMPTY);
|
||||
public double temperature;
|
||||
|
||||
public InventoryFrequency(String n, String o)
|
||||
@@ -62,10 +65,20 @@ public class InventoryFrequency extends Frequency
|
||||
nbtTags.setTag("storedGas", storedGas.write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(!storedItem.isEmpty())
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for(int slotCount = 0; slotCount < 1; slotCount++)
|
||||
{
|
||||
nbtTags.setTag("storedItem", storedItem.writeToNBT(new NBTTagCompound()));
|
||||
if(!inventory.get(slotCount).isEmpty())
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte)slotCount);
|
||||
inventory.get(slotCount).writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbtTags.setTag("Items", tagList);
|
||||
|
||||
nbtTags.setDouble("temperature", temperature);
|
||||
}
|
||||
@@ -90,9 +103,18 @@ public class InventoryFrequency extends Frequency
|
||||
storedGas.read(nbtTags.getCompoundTag("storedGas"));
|
||||
}
|
||||
|
||||
if(nbtTags.hasKey("storedItem"))
|
||||
NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND);
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
storedItem = InventoryUtils.loadFromNBT(nbtTags.getCompoundTag("storedItem"));
|
||||
NBTTagCompound tagCompound = (NBTTagCompound)tagList.getCompoundTagAt(tagCount);
|
||||
byte slotID = tagCompound.getByte("Slot");
|
||||
|
||||
if(slotID >= 0 && slotID < 1)
|
||||
{
|
||||
inventory.set(slotID, InventoryUtils.loadFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
|
||||
temperature = nbtTags.getDouble("temperature");
|
||||
|
||||
@@ -41,7 +41,7 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for(ItemStack stack : inventory)
|
||||
for(ItemStack stack : getInventory())
|
||||
{
|
||||
if(!stack.isEmpty())
|
||||
{
|
||||
@@ -100,45 +100,50 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
|
||||
|
||||
return nbtTags;
|
||||
}
|
||||
|
||||
protected NonNullList<ItemStack> getInventory()
|
||||
{
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return inventory != null ? inventory.size() : 0;
|
||||
return getInventory() != null ? getInventory().size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotID)
|
||||
{
|
||||
return inventory != null ? inventory.get(slotID) : null;
|
||||
return getInventory() != null ? getInventory().get(slotID) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotID, int amount)
|
||||
{
|
||||
if(inventory == null)
|
||||
if(getInventory() == null)
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return ItemStackHelper.getAndSplit(inventory, slotID, amount);
|
||||
return ItemStackHelper.getAndSplit(getInventory(), slotID, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slotID)
|
||||
{
|
||||
if(inventory == null)
|
||||
if(getInventory() == null)
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return ItemStackHelper.getAndRemove(inventory, slotID);
|
||||
return ItemStackHelper.getAndRemove(getInventory(), slotID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotID, ItemStack itemstack)
|
||||
{
|
||||
inventory.set(slotID, itemstack);
|
||||
getInventory().set(slotID, itemstack);
|
||||
|
||||
if(!itemstack.isEmpty() && itemstack.getCount() > getInventoryStackLimit())
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@ import mekanism.common.multiblock.MultiblockManager;
|
||||
import mekanism.common.multiblock.SynchronizedData;
|
||||
import mekanism.common.multiblock.UpdateProtocol;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -22,9 +21,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -274,45 +272,9 @@ public abstract class TileEntityMultiblock<T extends SynchronizedData<T>> extend
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotID)
|
||||
protected NonNullList<ItemStack> getInventory()
|
||||
{
|
||||
return structure != null && getSynchronizedData().getInventory() != null ? getSynchronizedData().getInventory().get(slotID) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotID, ItemStack itemstack)
|
||||
{
|
||||
if(structure != null && getSynchronizedData().getInventory() != null)
|
||||
{
|
||||
getSynchronizedData().getInventory().set(slotID, itemstack);
|
||||
|
||||
if(!itemstack.isEmpty() && itemstack.getCount() > getInventoryStackLimit())
|
||||
{
|
||||
itemstack.setCount(getInventoryStackLimit());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotID, int amount)
|
||||
{
|
||||
if(structure == null || getSynchronizedData().getInventory() == null)
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return ItemStackHelper.getAndSplit(getSynchronizedData().getInventory(), slotID, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slotID)
|
||||
{
|
||||
if(structure == null || getSynchronizedData().getInventory() == null)
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return ItemStackHelper.getAndRemove(getSynchronizedData().getInventory(), slotID);
|
||||
return structure != null ? structure.getInventory() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -509,29 +509,9 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
public NonNullList<ItemStack> getInventory()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotID)
|
||||
{
|
||||
return hasFrequency() && slotID == 0 ? frequency.storedItem : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotID, ItemStack itemstack)
|
||||
{
|
||||
if(hasFrequency() && slotID == 0)
|
||||
{
|
||||
frequency.storedItem = itemstack;
|
||||
|
||||
if(!itemstack.isEmpty() && itemstack.getCount() > getInventoryStackLimit())
|
||||
{
|
||||
itemstack.setCount(getInventoryStackLimit());
|
||||
}
|
||||
}
|
||||
return hasFrequency() ? frequency.inventory : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -143,6 +143,11 @@ public class TileComponentConfig implements ITileComponent
|
||||
|
||||
public SideData getOutput(TransmissionType type, EnumFacing side)
|
||||
{
|
||||
if(side == null)
|
||||
{
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
int index = getConfig(type)[side.ordinal()];
|
||||
|
||||
if(index == -1)
|
||||
|
||||
@@ -28,14 +28,10 @@ public final class TransporterUtils
|
||||
return false;
|
||||
}
|
||||
|
||||
if(InventoryUtils.isItemHandler(tile, side.getOpposite()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(tile instanceof IInventory)
|
||||
if(tile instanceof IInventory)
|
||||
{
|
||||
IInventory inventory = (IInventory)tile;
|
||||
|
||||
|
||||
if(inventory.getSizeInventory() > 0)
|
||||
{
|
||||
if(!(inventory instanceof ISidedInventory))
|
||||
@@ -48,6 +44,10 @@ public final class TransporterUtils
|
||||
return (slots != null && slots.length > 0);
|
||||
}
|
||||
}
|
||||
else if(InventoryUtils.isItemHandler(tile, side.getOpposite()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user