mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Semi-implemented new item system I guess?
This commit is contained in:
parent
7a6fda911f
commit
235d86ab8c
2 changed files with 28 additions and 2 deletions
|
@ -17,7 +17,7 @@ group = "de.ellpeck.actuallyadditions"
|
||||||
archivesBaseName = "ActuallyAdditions"
|
archivesBaseName = "ActuallyAdditions"
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.8.9-11.15.0.1715"
|
version = "1.8.9-11.15.0.1718"
|
||||||
runDir = "idea"
|
runDir = "idea"
|
||||||
|
|
||||||
mappings = "stable_20"
|
mappings = "stable_20"
|
||||||
|
|
|
@ -11,22 +11,37 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.IChatComponent;
|
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 abstract class TileEntityInventoryBase extends TileEntityBase implements ISidedInventory{
|
||||||
|
|
||||||
public ItemStack slots[];
|
public ItemStack slots[];
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
|
private Map<EnumFacing, IItemHandler> itemHandlers = new HashMap<EnumFacing, IItemHandler>();
|
||||||
|
|
||||||
public TileEntityInventoryBase(int slots, String name){
|
public TileEntityInventoryBase(int slots, String name){
|
||||||
this.initializeSlots(slots);
|
this.initializeSlots(slots);
|
||||||
this.name = "container."+ModUtil.MOD_ID_LOWER+"."+name;
|
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){
|
public void initializeSlots(int itemAmount){
|
||||||
|
@ -198,6 +213,17 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IChatComponent getDisplayName(){
|
public IChatComponent getDisplayName(){
|
||||||
return null;
|
return new ChatComponentText(StringUtil.localize(this.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue