mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
Move some stuff out into Mantle.
This commit is contained in:
1 parent
ef70d27bee
commit
e763bb6363
32 files changed
+32
-544
No files matched your search
@@ -19,11 +19,10 @@ import tconstruct.blocks.logic.PatternChestLogic;
|
||||
import tconstruct.blocks.logic.StencilTableLogic;
|
||||
import tconstruct.blocks.logic.ToolForgeLogic;
|
||||
import tconstruct.blocks.logic.ToolStationLogic;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventorySlab;
|
||||
import mantle.blocks.abstracts.InventorySlab;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
public class CraftingSlab extends InventorySlab
|
||||
|
||||
@@ -16,7 +16,7 @@ import tconstruct.blocks.logic.CraftingStationLogic;
|
||||
import tconstruct.client.block.TableRender;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
|
||||
public class CraftingStationBlock extends InventoryBlock
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.DryingRackLogic;
|
||||
import tconstruct.client.block.DryingRackRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@@ -5,7 +5,6 @@ import tconstruct.blocks.logic.EquipLogic;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -14,7 +13,7 @@ import cpw.mods.fml.relauncher.*;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.FrypanLogic;
|
||||
import tconstruct.client.block.FrypanRender;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -13,7 +11,7 @@ import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.FurnaceLogic;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventorySlab;
|
||||
import mantle.blocks.abstracts.InventorySlab;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.GolemCoreLogic;
|
||||
import tconstruct.client.block.GolemCoreRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@@ -3,7 +3,7 @@ package tconstruct.blocks;
|
||||
import java.util.Random;
|
||||
|
||||
import tconstruct.blocks.logic.GolemPedestalLogic;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
||||
@@ -8,7 +8,7 @@ import tconstruct.blocks.logic.CastingTableLogic;
|
||||
import tconstruct.blocks.logic.FaucetLogic;
|
||||
import tconstruct.client.block.SearedRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
@@ -20,7 +20,7 @@ import tconstruct.blocks.logic.SmelteryDrainLogic;
|
||||
import tconstruct.blocks.logic.SmelteryLogic;
|
||||
import tconstruct.client.block.SmelteryRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
|
||||
@@ -1,24 +1,15 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import static net.minecraftforge.common.ForgeDirection.DOWN;
|
||||
import static net.minecraftforge.common.ForgeDirection.UP;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.ToolForgeLogic;
|
||||
import tconstruct.client.block.TableForgeRender;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFarmland;
|
||||
import net.minecraft.block.BlockHalfSlab;
|
||||
import net.minecraft.block.BlockHopper;
|
||||
import net.minecraft.block.BlockPoweredOre;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
@@ -8,10 +8,9 @@ import tconstruct.blocks.logic.PatternChestLogic;
|
||||
import tconstruct.blocks.logic.StencilTableLogic;
|
||||
import tconstruct.blocks.logic.ToolStationLogic;
|
||||
import tconstruct.client.block.TableRender;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.blocks.InventoryBlock;
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -49,7 +49,7 @@ public class CastingBasinLogic extends InventoryLogic implements IFluidTank, IFl
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName () //Still not a gui block
|
||||
public String getDefaultName () //Still not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.inventory.CraftingStationContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
|
||||
public class CraftingStationLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.library.crafting.DryingRackRecipes;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -31,7 +31,7 @@ public class DryingRackLogic extends InventoryLogic
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName ()
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/* Slots
|
||||
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import tconstruct.inventory.FurnaceContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@@ -2,7 +2,7 @@ package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.inventory.PartCrafterChestContainer;
|
||||
import tconstruct.inventory.PartCrafterContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.util.IPattern;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.inventory.PatternChestContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -33,7 +33,7 @@ import net.minecraftforge.fluids.IFluidTank;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.inventory.SmelteryContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.library.crafting.Smeltery;
|
||||
import tconstruct.library.util.CoordTuple;
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
|
||||
@@ -3,7 +3,7 @@ package tconstruct.blocks.logic;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.inventory.PatternShaperContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.component.TankAirComponent;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.library.util.CoordTuple;
|
||||
import tconstruct.library.util.IMasterLogic;
|
||||
import tconstruct.library.util.IServantLogic;
|
||||
@@ -71,7 +71,7 @@ public class TankAirLogic extends InventoryLogic implements IServantLogic, ISide
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName ()
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return null; //Not a gui block
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.inventory.ToolStationContainer;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
@@ -2,15 +2,13 @@ package tconstruct.common;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.TileEntityLandmine;
|
||||
import tconstruct.inventory.*;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import tconstruct.util.player.TPlayerStats;
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
|
||||
public class InventoryCraftingStation extends InventoryCrafting
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
|
||||
public abstract class AdaptiveInventoryLogic extends InventoryLogic implements IFacingLogic
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.world.World;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
|
||||
public abstract class ExpandableInventoryLogic extends InventoryLogic implements IInventory
|
||||
{
|
||||
|
||||
@@ -1,191 +0,0 @@
|
||||
package tconstruct.library.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import tconstruct.library.util.IActiveLogic;
|
||||
import tconstruct.library.util.IFacingLogic;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class InventoryBlock extends BlockContainer
|
||||
{
|
||||
protected Random rand = new Random();
|
||||
|
||||
protected InventoryBlock(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
}
|
||||
|
||||
/* Logic backend */
|
||||
public TileEntity createNewTileEntity (World var1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract TileEntity createTileEntity (World world, int metadata);
|
||||
|
||||
public abstract Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer);
|
||||
|
||||
public abstract Object getModInstance ();
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
if (player.isSneaking())
|
||||
return false;
|
||||
|
||||
Integer integer = getGui(world, x, y, z, player);
|
||||
if (integer == null || integer == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!world.isRemote)
|
||||
player.openGui(getModInstance(), integer, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Inventory */
|
||||
|
||||
@Override
|
||||
public void breakBlock (World par1World, int x, int y, int z, int blockID, int meta)
|
||||
{
|
||||
TileEntity te = par1World.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (te != null && te instanceof InventoryLogic)
|
||||
{
|
||||
InventoryLogic logic = (InventoryLogic) te;
|
||||
logic.removeBlock();
|
||||
for (int iter = 0; iter < logic.getSizeInventory(); ++iter)
|
||||
{
|
||||
ItemStack stack = logic.getStackInSlot(iter);
|
||||
|
||||
if (stack != null && logic.canDropInventorySlot(iter))
|
||||
{
|
||||
float jumpX = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float jumpY = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float jumpZ = rand.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (stack.stackSize > 0)
|
||||
{
|
||||
int itemSize = rand.nextInt(21) + 10;
|
||||
|
||||
if (itemSize > stack.stackSize)
|
||||
{
|
||||
itemSize = stack.stackSize;
|
||||
}
|
||||
|
||||
stack.stackSize -= itemSize;
|
||||
EntityItem entityitem = new EntityItem(par1World, (double) ((float) x + jumpX), (double) ((float) y + jumpY), (double) ((float) z + jumpZ), new ItemStack(stack.itemID,
|
||||
itemSize, stack.getItemDamage()));
|
||||
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float offset = 0.05F;
|
||||
entityitem.motionX = (double) ((float) rand.nextGaussian() * offset);
|
||||
entityitem.motionY = (double) ((float) rand.nextGaussian() * offset + 0.2F);
|
||||
entityitem.motionZ = (double) ((float) rand.nextGaussian() * offset);
|
||||
par1World.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, x, y, z, blockID, meta);
|
||||
}
|
||||
|
||||
/* Placement */
|
||||
|
||||
int side = -1;
|
||||
|
||||
//This class does not have an actual block placed in the world
|
||||
@Override
|
||||
public int onBlockPlaced (World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta)
|
||||
{
|
||||
this.side = side;
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack)
|
||||
{
|
||||
TileEntity logic = world.getBlockTileEntity(x, y, z);
|
||||
if (logic instanceof IFacingLogic)
|
||||
{
|
||||
IFacingLogic direction = (IFacingLogic) logic;
|
||||
if (side != -1)
|
||||
{
|
||||
direction.setDirection(side);
|
||||
side = -1;
|
||||
}
|
||||
if (entityliving == null)
|
||||
{
|
||||
direction.setDirection(0F, 0F, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
direction.setDirection(entityliving.rotationYaw * 4F, entityliving.rotationPitch, entityliving);
|
||||
}
|
||||
}
|
||||
|
||||
if (logic instanceof InventoryLogic)
|
||||
{
|
||||
InventoryLogic inv = (InventoryLogic) logic;
|
||||
inv.placeBlock(entityliving, stack);
|
||||
if (stack.hasDisplayName())
|
||||
{
|
||||
inv.setInvName(stack.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isActive (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
TileEntity logic = world.getBlockTileEntity(x, y, z);
|
||||
if (logic instanceof IActiveLogic)
|
||||
{
|
||||
return ((IActiveLogic) logic).getActive();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
/* Textures */
|
||||
public Icon[] icons;
|
||||
|
||||
public abstract String[] getTextureNames ();
|
||||
|
||||
@Override
|
||||
public void registerIcons (IconRegister iconRegister)
|
||||
{
|
||||
String[] textureNames = getTextureNames();
|
||||
this.icons = new Icon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,227 +0,0 @@
|
||||
package tconstruct.library.blocks;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/*
|
||||
* A simple logic class for storing items
|
||||
* Abstract to avoid instantiation
|
||||
*/
|
||||
|
||||
public abstract class InventoryLogic extends TileEntity implements IInventory
|
||||
{
|
||||
protected ItemStack[] inventory;
|
||||
protected String invName;
|
||||
protected int stackSizeLimit;
|
||||
|
||||
public InventoryLogic(int invSize)
|
||||
{
|
||||
this(invSize, 64);
|
||||
}
|
||||
|
||||
public InventoryLogic(int invSize, int maxStackSize)
|
||||
{
|
||||
inventory = new ItemStack[invSize];
|
||||
stackSizeLimit = maxStackSize;
|
||||
}
|
||||
|
||||
/* Inventory management */
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int slot)
|
||||
{
|
||||
return inventory[slot];
|
||||
}
|
||||
|
||||
public boolean isStackInSlot (int slot)
|
||||
{
|
||||
return inventory[slot] != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory ()
|
||||
{
|
||||
return inventory.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return stackSizeLimit;
|
||||
}
|
||||
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
inventory[slot] = itemstack;
|
||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
if (inventory[slot].stackSize <= quantity)
|
||||
{
|
||||
ItemStack stack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return stack;
|
||||
}
|
||||
ItemStack split = inventory[slot].splitStack(quantity);
|
||||
if (inventory[slot].stackSize == 0)
|
||||
{
|
||||
inventory[slot] = null;
|
||||
}
|
||||
return split;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* Supporting methods */
|
||||
@Override
|
||||
public boolean isUseableByPlayer (EntityPlayer entityplayer)
|
||||
{
|
||||
if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this)
|
||||
return false;
|
||||
|
||||
else
|
||||
return entityplayer.getDistance((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D;
|
||||
|
||||
}
|
||||
|
||||
public abstract Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z);
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readInventoryFromNBT(tags);
|
||||
}
|
||||
|
||||
public void readInventoryFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
this.invName = tags.getString("InvName");
|
||||
NBTTagList nbttaglist = tags.getTagList("Items");
|
||||
inventory = new ItemStack[getSizeInventory()];
|
||||
for (int iter = 0; iter < nbttaglist.tagCount(); iter++)
|
||||
{
|
||||
NBTTagCompound tagList = (NBTTagCompound) nbttaglist.tagAt(iter);
|
||||
byte slotID = tagList.getByte("Slot");
|
||||
if (slotID >= 0 && slotID < inventory.length)
|
||||
{
|
||||
inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeInventoryToNBT(tags);
|
||||
}
|
||||
|
||||
public void writeInventoryToNBT (NBTTagCompound tags)
|
||||
{
|
||||
if (invName != null)
|
||||
tags.setString("InvName", invName);
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for (int iter = 0; iter < inventory.length; iter++)
|
||||
{
|
||||
if (inventory[iter] != null)
|
||||
{
|
||||
NBTTagCompound tagList = new NBTTagCompound();
|
||||
tagList.setByte("Slot", (byte) iter);
|
||||
inventory[iter].writeToNBT(tagList);
|
||||
nbttaglist.appendTag(tagList);
|
||||
}
|
||||
}
|
||||
|
||||
tags.setTag("Items", nbttaglist);
|
||||
}
|
||||
|
||||
/* Cause of the heisenbug. Do not uncomment! */
|
||||
/*public void superReadFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
}
|
||||
|
||||
public void superWriteToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
}*/
|
||||
|
||||
/* Default implementations of hardly used methods */
|
||||
public ItemStack getStackInSlotOnClosing (int slot)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void openChest ()
|
||||
{
|
||||
}
|
||||
|
||||
public void closeChest ()
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract String getDefaultName ();
|
||||
|
||||
public void setInvName (String name)
|
||||
{
|
||||
this.invName = name;
|
||||
}
|
||||
|
||||
public String getInvName ()
|
||||
{
|
||||
return this.isInvNameLocalized() ? this.invName : getDefaultName();
|
||||
}
|
||||
|
||||
public boolean isInvNameLocalized ()
|
||||
{
|
||||
return this.invName != null && this.invName.length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int slot, ItemStack itemstack)
|
||||
{
|
||||
if (slot < getSizeInventory())
|
||||
{
|
||||
if (inventory[slot] == null || itemstack.stackSize + inventory[slot].stackSize <= getInventoryStackLimit())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void placeBlock (EntityLivingBase entity, ItemStack stack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void removeBlock ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package tconstruct.library.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class InventorySlab extends InventoryBlock
|
||||
{
|
||||
public InventorySlab(int id, Material material)
|
||||
{
|
||||
super(id, material);
|
||||
}
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
if (side > 1)
|
||||
return super.shouldSideBeRendered(world, x, y, z, side);
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
boolean top = (meta | 8) == 1;
|
||||
if ((top && side == 0) || (!top && side == 1))
|
||||
return true;
|
||||
|
||||
return super.shouldSideBeRendered(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity)
|
||||
{
|
||||
setBlockBoundsBasedOnState(world, x, y, z);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
|
||||
public void setBlockBoundsForItemRender ()
|
||||
{
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
|
||||
}
|
||||
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z) / 8;
|
||||
float minY = meta == 1 ? 0.5F : 0.0F;
|
||||
float maxY = meta == 1 ? 1.0F : 0.5F;
|
||||
setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F);
|
||||
}
|
||||
|
||||
public int onBlockPlaced (World par1World, int blockX, int blockY, int blockZ, int side, float clickX, float clickY, float clickZ, int metadata)
|
||||
{
|
||||
if (side == 1)
|
||||
return metadata;
|
||||
if (side == 0 || clickY >= 0.5F)
|
||||
return metadata | 8;
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta % 8;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.SmelteryLogic;
|
||||
import tconstruct.blocks.logic.ToolForgeLogic;
|
||||
import tconstruct.blocks.logic.ToolStationLogic;
|
||||
import tconstruct.library.blocks.InventoryLogic;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.IPacketHandler;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
Reference in new issue
Block a user