mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Fudge the new item system stuff
This commit is contained in:
parent
81130ac0b9
commit
47568e5fbc
5 changed files with 0 additions and 118 deletions
|
@ -61,7 +61,6 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
|||
@Override
|
||||
public void onNumberReceived(int text, int textID, EntityPlayer player){
|
||||
if(text != -1){
|
||||
//TODO Find a better solution for the Math.max and Math.min stuff here (also below in initVars()!)
|
||||
if(textID == 0){
|
||||
this.slotToPutStart = this.placeToPut instanceof IInventory ? Math.max(Math.min(text, ((IInventory)this.placeToPut).getSizeInventory()-1), 0) : text;
|
||||
}
|
||||
|
@ -79,68 +78,10 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
|||
this.markDirty();
|
||||
}
|
||||
|
||||
//TODO Fix for new item system
|
||||
private boolean newPull(){
|
||||
/*for(EnumFacing facing : EnumFacing.values()){
|
||||
IItemHandler handler = this.placeToPull.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing);
|
||||
if(handler != null){
|
||||
for(int i = Math.max(this.lastPullStart, 0); i < Math.min(this.slotToPullEnd, handler.getSlots()); i++){
|
||||
ItemStack stackInOtherInv = handler.getStackInSlot(i);
|
||||
if(stackInOtherInv != null){
|
||||
if(this.slots[0] == null || ItemUtil.areItemsEqual(stackInOtherInv, this.slots[0], false)){
|
||||
|
||||
ItemStack pulled = handler.extractItem(i, this.slots[0] == null ? stackInOtherInv.stackSize : Math.min(stackInOtherInv.stackSize, this.slots[0].getMaxStackSize()-this.slots[0].stackSize), false);
|
||||
if(pulled != null){
|
||||
ItemStack slotCopy = this.slots[0] == null ? null : this.slots[0].copy();
|
||||
|
||||
if(this.slots[0] == null){
|
||||
this.slots[0] = pulled.copy();
|
||||
}
|
||||
else{
|
||||
this.slots[0].stackSize+=pulled.stackSize;
|
||||
}
|
||||
|
||||
if(!ItemUtil.areStacksEqualAndSameSize(slotCopy, this.slots[0], false)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean newPut(){
|
||||
/*if(this.slots[0] != null){
|
||||
for(EnumFacing facing : EnumFacing.values()){
|
||||
IItemHandler handler = this.placeToPut.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing);
|
||||
if(handler != null){
|
||||
for(int i = Math.max(this.slotToPutStart, 0); i < Math.min(this.slotToPutEnd, handler.getSlots()); i++){
|
||||
ItemStack slotCopy = this.slots[0].copy();
|
||||
|
||||
ItemStack remaining = handler.insertItem(i, slotCopy, false);
|
||||
this.slots[0] = remaining == null ? null : remaining.copy();
|
||||
|
||||
if(!ItemUtil.areStacksEqualAndSameSize(slotCopy, this.slots[0], false)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pulls Items from the specified Slots on the specified Side
|
||||
*/
|
||||
private void pull(){
|
||||
if(this.newPull()){
|
||||
return;
|
||||
}
|
||||
|
||||
//The Inventory to pull from
|
||||
IInventory theInventory = (IInventory)placeToPull;
|
||||
//Does the Inventory even have Slots!?
|
||||
|
@ -240,10 +181,6 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
|||
* (Check pull() for Description, similar to this)
|
||||
*/
|
||||
private void put(){
|
||||
if(this.newPut()){
|
||||
return;
|
||||
}
|
||||
|
||||
IInventory theInventory = (IInventory)placeToPut;
|
||||
if(theInventory.getSizeInventory() > 0){
|
||||
int theSlotToPut = this.slotToPutStart;
|
||||
|
|
|
@ -20,28 +20,15 @@ import net.minecraft.nbt.NBTTagList;
|
|||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class TileEntityInventoryBase extends TileEntityBase implements ISidedInventory{
|
||||
|
||||
public ItemStack slots[];
|
||||
public String name;
|
||||
|
||||
private Map<EnumFacing, IItemHandler> itemHandlers = new HashMap<EnumFacing, IItemHandler>();
|
||||
|
||||
public TileEntityInventoryBase(int slots, String name){
|
||||
this.initializeSlots(slots);
|
||||
this.name = "container."+ModUtil.MOD_ID_LOWER+"."+name;
|
||||
|
||||
for(EnumFacing facing : EnumFacing.values()){
|
||||
this.itemHandlers.put(facing, new SidedInvWrapper(this, facing));
|
||||
}
|
||||
}
|
||||
|
||||
public void initializeSlots(int itemAmount){
|
||||
|
@ -107,26 +94,11 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(net.minecraftforge.common.capabilities.Capability<?> capability, net.minecraft.util.EnumFacing facing){
|
||||
return this.getCapability(capability, facing) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit(){
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing){
|
||||
if(facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY){
|
||||
return (T)this.itemHandlers.get(facing);
|
||||
}
|
||||
else{
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player){
|
||||
return player.getDistanceSq(this.getPos().getX()+0.5D, this.pos.getY()+0.5D, this.pos.getZ()+0.5D) <= 64 && !this.isInvalid() && this.worldObj.getTileEntity(this.pos) == this;
|
||||
|
|
|
@ -16,9 +16,7 @@ import net.minecraft.inventory.ISidedInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
//TODO completely adapt to new item system?
|
||||
public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
||||
|
||||
public TileEntityPhantomItemface(){
|
||||
|
@ -105,17 +103,6 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing){
|
||||
if(this.isBoundThingInRange()){
|
||||
TileEntity tile = worldObj.getTileEntity(this.boundPosition);
|
||||
if(tile != null){
|
||||
return tile.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
||||
return this.isBoundThingInRange() && this.getInventory().isItemValidForSlot(i, stack);
|
||||
|
|
|
@ -23,9 +23,6 @@ import net.minecraft.util.BlockPos;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityDispatcher;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -40,12 +37,8 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
private BlockPos boundPosBefore;
|
||||
private Block boundBlockBefore;
|
||||
|
||||
private CapabilityDispatcher capabilities;
|
||||
|
||||
public TileEntityPhantomface(String name){
|
||||
super(0, name);
|
||||
|
||||
this.capabilities = ForgeEventFactory.gatherCapabilities(this);
|
||||
}
|
||||
|
||||
public static int upgradeRange(int defaultRange, World world, BlockPos pos){
|
||||
|
@ -118,11 +111,6 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing){
|
||||
return this.capabilities != null ? this.capabilities.getCapability(capability, facing) : super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack){
|
||||
return false;
|
||||
|
|
|
@ -246,8 +246,6 @@ public class WorldUtil{
|
|||
return blocks;
|
||||
}
|
||||
|
||||
//TODO make this work for the stupid new item system
|
||||
|
||||
public static boolean addToInventory(IInventory inventory, ArrayList<ItemStack> stacks, boolean actuallyDo, boolean shouldAlwaysWork){
|
||||
return addToInventory(inventory, stacks, EnumFacing.UP, actuallyDo, shouldAlwaysWork);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue