mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
234 lines
5.4 KiB
Java
234 lines
5.4 KiB
Java
package tinker.tconstruct.blocks;
|
|
|
|
import java.util.List;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
import tinker.common.InventoryBlock;
|
|
import tinker.tconstruct.TConstruct;
|
|
import tinker.tconstruct.TContent;
|
|
import tinker.tconstruct.client.TableRender;
|
|
import tinker.tconstruct.logic.CastingTableLogic;
|
|
import tinker.tconstruct.logic.PartCrafterLogic;
|
|
import tinker.tconstruct.logic.PatternChestLogic;
|
|
import tinker.tconstruct.logic.PatternShaperLogic;
|
|
import tinker.tconstruct.logic.ToolStationLogic;
|
|
|
|
public class ToolStationBlock extends InventoryBlock
|
|
{
|
|
|
|
public ToolStationBlock(int id, Material material)
|
|
{
|
|
super(id, material);
|
|
this.setCreativeTab(TConstruct.blockTab);
|
|
this.setHardness(2f);
|
|
}
|
|
|
|
/* Rendering */
|
|
public String getTextureFile ()
|
|
{
|
|
return TContent.blockTexture;
|
|
}
|
|
|
|
public int getBlockTextureFromSideAndMetadata (int side, int meta)
|
|
{
|
|
if (meta == 0)
|
|
{
|
|
if (side == 0)
|
|
return 3;
|
|
else if (side == 1)
|
|
return 0;
|
|
else if (side == 2 || side == 3)
|
|
return 1;
|
|
else
|
|
return 2;
|
|
}
|
|
else if (meta <= 4)
|
|
{
|
|
return 1 + meta * 3 + getBlockTextureFromSide(side);
|
|
}
|
|
else if (meta <= 9)
|
|
{
|
|
return 16 + getBlockTextureFromSide(side);
|
|
}
|
|
else
|
|
{
|
|
return -10 + meta * 3 + getBlockTextureFromSide(side);
|
|
}
|
|
}
|
|
|
|
public int getBlockTextureFromSide (int side)
|
|
{
|
|
if (side == 0)
|
|
return 2;
|
|
if (side == 1)
|
|
return 0;
|
|
|
|
return 1;
|
|
}
|
|
|
|
@Override
|
|
public boolean renderAsNormalBlock ()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean isOpaqueCube ()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public int getRenderType ()
|
|
{
|
|
return TableRender.tabelModelID;
|
|
}
|
|
|
|
@Override
|
|
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
|
|
{
|
|
int metadata = world.getBlockMetadata(x, y, z);
|
|
if (metadata == 5)
|
|
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY - 0.125, (double) z + this.maxZ);
|
|
return AxisAlignedBB.getAABBPool().addOrModifyAABBInPool((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ);
|
|
}
|
|
|
|
/* Activation */
|
|
@Override
|
|
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ)
|
|
{
|
|
int md = world.getBlockMetadata(x, y, z);
|
|
if (md == 14)
|
|
{
|
|
return activateCastingTable(world, x, y, z, player);
|
|
}
|
|
else
|
|
return super.onBlockActivated(world, x, y, z, player, side, clickX, clickY, clickZ);
|
|
}
|
|
|
|
boolean activateCastingTable (World world, int x, int y, int z, EntityPlayer player)
|
|
{
|
|
if (!world.isRemote)
|
|
{
|
|
System.out.println("Castses");
|
|
CastingTableLogic logic = (CastingTableLogic) world.getBlockTileEntity(x, y, z);
|
|
if (!logic.isStackInSlot(0))
|
|
{
|
|
ItemStack stack = player.getCurrentEquippedItem();
|
|
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
|
logic.setInventorySlotContents(0, stack);
|
|
}
|
|
else
|
|
{
|
|
/*ItemStack insideStack = logic.takeItemInColumn(0);
|
|
|
|
if (insideStack == null)
|
|
{r
|
|
insideStack = logic.takeItemInColumn(1 - 0);
|
|
}
|
|
|
|
if (insideStack != null)
|
|
{
|
|
this.spawnItem(world, x, y, z, insideStack);
|
|
}*/
|
|
}
|
|
|
|
world.markBlockForUpdate(x, y, z);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/* Data */
|
|
public int damageDropped (int meta)
|
|
{
|
|
return meta;
|
|
}
|
|
|
|
public TileEntity createNewTileEntity (World world, int metadata)
|
|
{
|
|
switch (metadata)
|
|
{
|
|
case 0:
|
|
return new ToolStationLogic();
|
|
case 1:
|
|
return new PartCrafterLogic();
|
|
case 2:
|
|
return new PartCrafterLogic();
|
|
case 3:
|
|
return new PartCrafterLogic();
|
|
case 4:
|
|
return new PartCrafterLogic();
|
|
case 5:
|
|
return new PatternChestLogic();
|
|
case 6:
|
|
return new PatternChestLogic();
|
|
case 7:
|
|
return new PatternChestLogic();
|
|
case 8:
|
|
return new PatternChestLogic();
|
|
case 9:
|
|
return new PatternChestLogic();
|
|
case 10:
|
|
return new PatternShaperLogic();
|
|
case 11:
|
|
return new PatternShaperLogic();
|
|
case 12:
|
|
return new PatternShaperLogic();
|
|
case 13:
|
|
return new PatternShaperLogic();
|
|
case 14:
|
|
return new CastingTableLogic();
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
|
{
|
|
int md = world.getBlockMetadata(x, y, z);
|
|
if (md == 0)
|
|
return 0;
|
|
else if (md < 5)
|
|
return 1;
|
|
else if (md < 10)
|
|
return 2;
|
|
else
|
|
return 3;
|
|
|
|
//return -1;
|
|
}
|
|
|
|
@Override
|
|
public Object getModInstance ()
|
|
{
|
|
return TConstruct.instance;
|
|
}
|
|
|
|
@Override
|
|
public void getSubBlocks (int id, CreativeTabs tab, List list)
|
|
{
|
|
for (int iter = 0; iter < 6; iter++)
|
|
{
|
|
list.add(new ItemStack(id, 1, iter));
|
|
}
|
|
|
|
for (int iter = 10; iter < 15; iter++)
|
|
{
|
|
list.add(new ItemStack(id, 1, iter));
|
|
}
|
|
}
|
|
}
|