mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
add Anchor Upgrade to Entangleporter
This commit is contained in:
1 parent
81e56b207c
commit
aabcd0d77a
4 files changed
+288
-11
No files matched your search
@@ -9,6 +9,7 @@ import mekanism.api.EnumColor;
|
||||
import mekanism.client.gui.element.GuiScrollList;
|
||||
import mekanism.client.gui.element.GuiSideConfigurationTab;
|
||||
import mekanism.client.gui.element.GuiTransporterConfigTab;
|
||||
import mekanism.client.gui.element.GuiUpgradeTab;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.frequency.Frequency;
|
||||
@@ -61,6 +62,7 @@ public class GuiQuantumEntangloporter extends GuiMekanism
|
||||
guiElements.add(scrollList = new GuiScrollList(this, resource, 28, 37, 120, 4));
|
||||
guiElements.add(new GuiSideConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png")));
|
||||
guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png")));
|
||||
guiElements.add(new GuiUpgradeTab(this, tileEntity, resource));
|
||||
|
||||
if(tileEntity.frequency != null)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
package mekanism.common.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
|
||||
/*Copied & modified from net.minecraft.inventory.InventoryBasic */
|
||||
public class InventoryList implements IInventory
|
||||
{
|
||||
private String inventoryTitle;
|
||||
private final int slotsCount;
|
||||
private final NonNullList<ItemStack> inventoryContents;
|
||||
private final TileEntity te;
|
||||
|
||||
public InventoryList(NonNullList<ItemStack> list, TileEntity parent)
|
||||
{
|
||||
this.inventoryTitle = "Proxy";
|
||||
this.slotsCount = list.size();
|
||||
this.inventoryContents = list;
|
||||
this.te = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stack in the given slot.
|
||||
*/
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
return index >= 0 && index < this.inventoryContents.size() ? (ItemStack)this.inventoryContents.get(index) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes up to a specified number of items from an inventory slot and returns them in a new stack.
|
||||
*/
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
ItemStack itemstack = ItemStackHelper.getAndSplit(this.inventoryContents, index, count);
|
||||
|
||||
if (!itemstack.isEmpty())
|
||||
{
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a stack from the given slot and returns it.
|
||||
*/
|
||||
public ItemStack removeStackFromSlot(int index)
|
||||
{
|
||||
ItemStack itemstack = (ItemStack)this.inventoryContents.get(index);
|
||||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inventoryContents.set(index, ItemStack.EMPTY);
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
|
||||
*/
|
||||
public void setInventorySlotContents(int index, ItemStack stack)
|
||||
{
|
||||
this.inventoryContents.set(index, stack);
|
||||
|
||||
if (!stack.isEmpty() && stack.getCount() > this.getInventoryStackLimit())
|
||||
{
|
||||
stack.setCount(this.getInventoryStackLimit());
|
||||
}
|
||||
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of slots in the inventory.
|
||||
*/
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.slotsCount;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for (ItemStack itemstack : this.inventoryContents)
|
||||
{
|
||||
if (!itemstack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of this object. For players this returns their username
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return this.inventoryTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this thing is named
|
||||
*/
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of this inventory. This is displayed to the client on opening.
|
||||
*/
|
||||
public void setCustomName(String inventoryTitleIn)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted ChatComponent that will be used for the sender's username in chat
|
||||
*/
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
return (ITextComponent)(this.hasCustomName() ? new TextComponentString(this.getName()) : new TextComponentTranslation(this.getName(), new Object[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended.
|
||||
*/
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* For tile entities, ensures the chunk containing the tile entity is saved to disk later - the game won't think it
|
||||
* hasn't changed and skip it.
|
||||
*/
|
||||
public void markDirty()
|
||||
{
|
||||
this.te.markDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't rename this method to canInteractWith due to conflicts with Container
|
||||
*/
|
||||
public boolean isUsableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For
|
||||
* guis use Slot.isItemValid
|
||||
*/
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getField(int id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
}
|
||||
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
this.inventoryContents.clear();
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,17 @@ package mekanism.common.inventory.container;
|
||||
|
||||
import mekanism.common.base.IUpgradeItem;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.inventory.InventoryList;
|
||||
import mekanism.common.inventory.slot.SlotMachineUpgrade;
|
||||
import mekanism.common.tile.TileEntityQuantumEntangloporter;
|
||||
import mekanism.common.tile.prefab.TileEntityContainerBlock;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class ContainerUpgradeManagement extends Container
|
||||
{
|
||||
@@ -17,7 +21,17 @@ public class ContainerUpgradeManagement extends Container
|
||||
public ContainerUpgradeManagement(InventoryPlayer inventory, IUpgradeTile tile)
|
||||
{
|
||||
tileEntity = tile;
|
||||
addSlotToContainer(new SlotMachineUpgrade((TileEntityContainerBlock)tile, tileEntity.getComponent().getUpgradeSlot(), 154, 7));
|
||||
IInventory upgradeInv;
|
||||
if (tileEntity instanceof TileEntityQuantumEntangloporter)
|
||||
{
|
||||
upgradeInv = new InventoryList(((TileEntityQuantumEntangloporter) tileEntity).inventory, (TileEntity) tileEntity);
|
||||
}
|
||||
else
|
||||
{
|
||||
upgradeInv = (TileEntityContainerBlock)tile;
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotMachineUpgrade(upgradeInv, tileEntity.getComponent().getUpgradeSlot(), 154, 7));
|
||||
|
||||
int slotY;
|
||||
|
||||
|
||||
@@ -3,9 +3,11 @@ package mekanism.common.tile;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.Chunk3D;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.IHeatTransfer;
|
||||
import mekanism.api.gas.Gas;
|
||||
@@ -16,20 +18,17 @@ import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.SideData.IOState;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.base.ITankManager;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.*;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.chunkloading.IChunkLoader;
|
||||
import mekanism.common.content.entangloporter.InventoryFrequency;
|
||||
import mekanism.common.frequency.Frequency;
|
||||
import mekanism.common.frequency.FrequencyManager;
|
||||
import mekanism.common.frequency.IFrequencyHandler;
|
||||
import mekanism.common.integration.computer.IComputerIntegration;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.*;
|
||||
import mekanism.common.tile.prefab.TileEntityElectricBlock;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.common.util.CapabilityUtils;
|
||||
@@ -39,17 +38,20 @@ import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock implements ISideConfiguration, ITankManager, IFluidHandlerWrapper, IFrequencyHandler, IGasHandler, IHeatTransfer, ITubeConnection, IComputerIntegration, ISecurityTile
|
||||
public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock implements ISideConfiguration, ITankManager, IFluidHandlerWrapper, IFrequencyHandler, IGasHandler, IHeatTransfer, ITubeConnection, IComputerIntegration, ISecurityTile, IChunkLoader, IUpgradeTile
|
||||
{
|
||||
public InventoryFrequency frequency;
|
||||
|
||||
@@ -64,6 +66,10 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
|
||||
public TileComponentEjector ejectorComponent;
|
||||
public TileComponentConfig configComponent;
|
||||
public TileComponentSecurity securityComponent;
|
||||
public TileComponentChunkLoader chunkLoaderComponent;
|
||||
public TileComponentUpgrade upgradeComponent;
|
||||
|
||||
private static final int INV_SIZE = 1;//this.inventory size, used for upgrades. Manually handled
|
||||
|
||||
public TileEntityQuantumEntangloporter()
|
||||
{
|
||||
@@ -82,7 +88,7 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
|
||||
}
|
||||
}
|
||||
|
||||
inventory = NonNullList.withSize(0, ItemStack.EMPTY);
|
||||
inventory = NonNullList.withSize(INV_SIZE, ItemStack.EMPTY);
|
||||
|
||||
configComponent.getOutputs(TransmissionType.ITEM).get(2).availableSlots = new int[] {0};
|
||||
configComponent.getOutputs(TransmissionType.FLUID).get(2).availableSlots = new int[] {0};
|
||||
@@ -94,6 +100,11 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
|
||||
ejectorComponent.setOutputData(TransmissionType.GAS, configComponent.getOutputs(TransmissionType.GAS).get(2));
|
||||
|
||||
securityComponent = new TileComponentSecurity(this);
|
||||
chunkLoaderComponent = new TileComponentChunkLoader(this);
|
||||
|
||||
upgradeComponent = new TileComponentUpgrade(this, 0);
|
||||
upgradeComponent.clearSupportedTypes();
|
||||
upgradeComponent.setSupported(Upgrade.ANCHOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,6 +252,21 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
|
||||
frequency = new InventoryFrequency(nbtTags.getCompoundTag("frequency"));
|
||||
frequency.valid = false;
|
||||
}
|
||||
|
||||
NBTTagList tagList = nbtTags.getTagList("upgradesInv", Constants.NBT.TAG_COMPOUND);
|
||||
inventory = NonNullList.withSize(INV_SIZE, ItemStack.EMPTY);
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount);
|
||||
byte slotID = tagCompound.getByte("Slot");
|
||||
|
||||
if(slotID >= 0 && slotID < inventory.size())
|
||||
{
|
||||
inventory.set(slotID, InventoryUtils.loadFromNBT(tagCompound));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -254,6 +280,21 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
|
||||
frequency.write(frequencyTag);
|
||||
nbtTags.setTag("frequency", frequencyTag);
|
||||
}
|
||||
|
||||
//Upgrades inventory
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for(int slotCount = 0; slotCount < inventory.size(); slotCount++)
|
||||
{
|
||||
ItemStack stackInSlot = inventory.get(slotCount);
|
||||
if(!stackInSlot.isEmpty())
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte)slotCount);
|
||||
stackInSlot.writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
nbtTags.setTag("upgradesInv", tagList);
|
||||
|
||||
return nbtTags;
|
||||
}
|
||||
@@ -706,4 +747,26 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
|
||||
throw new NoSuchMethodException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentChunkLoader getChunkLoader()
|
||||
{
|
||||
return chunkLoaderComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ChunkPos> getChunkSet()
|
||||
{
|
||||
Set<ChunkPos> ret = new HashSet<ChunkPos>();
|
||||
|
||||
ret.add(new Chunk3D(Coord4D.get(this)).getPos());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileComponentUpgrade getComponent()
|
||||
{
|
||||
return this.upgradeComponent;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user