mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
forgor
This commit is contained in:
parent
90d552c03a
commit
622330b4cf
@ -1,11 +1,16 @@
|
|||||||
package com.hbm.tileentity.network;
|
package com.hbm.tileentity.network;
|
||||||
|
|
||||||
import com.hbm.interfaces.ICopiable;
|
import com.hbm.interfaces.ICopiable;
|
||||||
|
import com.hbm.tileentity.IControlReceiverFilter;
|
||||||
import com.hbm.tileentity.TileEntityMachineBase;
|
import com.hbm.tileentity.TileEntityMachineBase;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
@ -108,17 +113,60 @@ public abstract class TileEntityCraneBase extends TileEntityMachineBase implemen
|
|||||||
NBTTagCompound nbt = new NBTTagCompound();
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
nbt.setInteger("inputSide", getInputSide().ordinal());
|
nbt.setInteger("inputSide", getInputSide().ordinal());
|
||||||
nbt.setInteger("outputSide", getOutputSide().ordinal());
|
nbt.setInteger("outputSide", getOutputSide().ordinal());
|
||||||
|
|
||||||
|
if(this instanceof IControlReceiverFilter){
|
||||||
|
IControlReceiverFilter filter = ((IControlReceiverFilter) this);
|
||||||
|
IInventory inv = this;
|
||||||
|
NBTTagList tags = new NBTTagList();
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
for (int i = filter.getFilterSlots()[0]; i < filter.getFilterSlots()[1]; i++) {
|
||||||
|
NBTTagCompound slotNBT = new NBTTagCompound();
|
||||||
|
if(inv.getStackInSlot(i) != null) {
|
||||||
|
slotNBT.setByte("slot", (byte) count);
|
||||||
|
inv.getStackInSlot(i).writeToNBT(slotNBT);
|
||||||
|
tags.appendTag(slotNBT);
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
nbt.setTag("items", tags);
|
||||||
|
}
|
||||||
|
|
||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void pasteSettings(NBTTagCompound nbt) {
|
public void pasteSettings(NBTTagCompound nbt) {
|
||||||
if(nbt.hasKey("outputSide")){
|
if (nbt.hasKey("outputSide")) {
|
||||||
outputOverride = ForgeDirection.getOrientation(nbt.getInteger("outputSide"));
|
outputOverride = ForgeDirection.getOrientation(nbt.getInteger("outputSide"));
|
||||||
onBlockChanged();
|
onBlockChanged();
|
||||||
}
|
}
|
||||||
if(nbt.hasKey("inputSide")) {
|
if (nbt.hasKey("inputSide")) {
|
||||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, nbt.getInteger("inputSide"), 3);
|
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, nbt.getInteger("inputSide"), 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this instanceof IControlReceiverFilter) {
|
||||||
|
IControlReceiverFilter filter = ((IControlReceiverFilter) this);
|
||||||
|
IInventory inv = this;
|
||||||
|
|
||||||
|
NBTTagList items = nbt.getTagList("items", 10);
|
||||||
|
int listSize = items.tagCount();
|
||||||
|
if (listSize > 0) {
|
||||||
|
int count = 0;
|
||||||
|
for (int i = filter.getFilterSlots()[0]; i < filter.getFilterSlots()[1]; i++) {
|
||||||
|
if (i < listSize) {
|
||||||
|
NBTTagCompound slotNBT = items.getCompoundTagAt(count);
|
||||||
|
byte slot = slotNBT.getByte("slot");
|
||||||
|
ItemStack loadedStack = ItemStack.loadItemStackFromNBT(slotNBT);
|
||||||
|
if (loadedStack != null) {
|
||||||
|
inv.setInventorySlotContents(slot + filter.getFilterSlots()[0], ItemStack.loadItemStackFromNBT(slotNBT));
|
||||||
|
filter.nextMode(slot);
|
||||||
|
this.getWorldObj().markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user