mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-13 17:04:24 +00:00
206 lines
6.4 KiB
Java
206 lines
6.4 KiB
Java
package tconstruct.blocks;
|
|||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
import net.minecraft.block.Block;
|
||
|
|
import net.minecraft.block.material.Material;
|
||
|
|
import net.minecraft.creativetab.CreativeTabs;
|
||
|
|
import net.minecraft.entity.Entity;
|
||
|
|
import net.minecraft.entity.EntityLivingBase;
|
||
|
|
import net.minecraft.entity.player.EntityPlayer;
|
||
|
|
import net.minecraft.item.ItemStack;
|
||
|
|
import net.minecraft.tileentity.TileEntity;
|
||
|
|
import net.minecraft.util.AxisAlignedBB;
|
||
|
|
import net.minecraft.util.Icon;
|
||
|
|
import net.minecraft.world.IBlockAccess;
|
||
|
|
import net.minecraft.world.World;
|
||
|
|
import tconstruct.TConstruct;
|
||
|
|
import tconstruct.blocks.logic.CraftingStationLogic;
|
||
|
|
import tconstruct.blocks.logic.PartBuilderLogic;
|
||
|
|
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.library.TConstructRegistry;
|
||
|
|
import tconstruct.library.blocks.InventoryBlock;
|
||
|
|
import tconstruct.util.PHConstruct;
|
||
|
|
|
||
|
|
public class CraftingSlab extends InventoryBlock
|
||
|
|
{
|
||
|
|
public CraftingSlab(int id, Material material)
|
||
|
|
{
|
||
|
|
super(id, material);
|
||
|
|
this.setCreativeTab(TConstructRegistry.blockTab);
|
||
|
|
this.setHardness(2f);
|
||
|
|
this.setStepSound(Block.soundWoodFootstep);
|
||
|
|
}
|
||
|
|
|
||
|
|
/* Rendering */
|
||
|
|
@Override
|
||
|
|
public String[] getTextureNames ()
|
||
|
|
{
|
||
|
|
String[] textureNames = {
|
||
|
|
"craftingstation_top", "craftingstation_slab_side", "craftingstation_bottom",
|
||
|
|
"toolstation_top", "toolstation_slab_side", "toolstation_bottom",
|
||
|
|
"partbuilder_oak_top", "partbuilder_slab_side", "partbuilder_oak_bottom",
|
||
|
|
"stenciltable_oak_top", "stenciltable_slab_side", "stenciltable_oak_bottom",
|
||
|
|
"patternchest_top", "patternchest_slab_side", "patternchest_bottom",
|
||
|
|
"toolforge_top", "toolforge_slab_side", "toolforge_top" };
|
||
|
|
|
||
|
|
return textureNames;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public Icon getIcon (int side, int meta)
|
||
|
|
{
|
||
|
|
return icons[(meta % 8) * 3 + getTextureIndex(side)];
|
||
|
|
}
|
||
|
|
|
||
|
|
public int getTextureIndex (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 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().getAABB((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().getAABB((double) x + this.minX, (double) y + this.minY, (double) z + this.minZ, (double) x + this.maxX, (double) y + this.maxY, (double) z + this.maxZ);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public TileEntity createTileEntity (World world, int metadata)
|
||
|
|
{
|
||
|
|
switch (metadata % 8)
|
||
|
|
{
|
||
|
|
case 0:
|
||
|
|
return new CraftingStationLogic();
|
||
|
|
case 1:
|
||
|
|
return new ToolStationLogic();
|
||
|
|
case 2:
|
||
|
|
return new PartBuilderLogic();
|
||
|
|
case 3:
|
||
|
|
return new StencilTableLogic();
|
||
|
|
case 4:
|
||
|
|
return new PatternChestLogic();
|
||
|
|
case 5:
|
||
|
|
return new ToolForgeLogic();
|
||
|
|
default:
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||
|
|
{
|
||
|
|
int meta = world.getBlockMetadata(x, y, z);
|
||
|
|
switch (meta)
|
||
|
|
{
|
||
|
|
case 0:
|
||
|
|
return TProxyCommon.craftingStationID;
|
||
|
|
case 1:
|
||
|
|
return TProxyCommon.toolStationID;
|
||
|
|
case 2:
|
||
|
|
return TProxyCommon.partBuilderID;
|
||
|
|
case 3:
|
||
|
|
return TProxyCommon.stencilTableID;
|
||
|
|
case 4:
|
||
|
|
return TProxyCommon.patternChestID;
|
||
|
|
case 5:
|
||
|
|
return TProxyCommon.toolForgeID;
|
||
|
|
}
|
||
|
|
|
||
|
|
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));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack)
|
||
|
|
{
|
||
|
|
if (PHConstruct.freePatterns)
|
||
|
|
{
|
||
|
|
int meta = world.getBlockMetadata(x, y, z);
|
||
|
|
if (meta == 4)
|
||
|
|
{
|
||
|
|
PatternChestLogic logic = (PatternChestLogic) world.getBlockTileEntity(x, y, z);
|
||
|
|
for (int i = 1; i <= 13; i++)
|
||
|
|
{
|
||
|
|
logic.setInventorySlotContents(i - 1, new ItemStack(TContent.woodPattern, 1, i));
|
||
|
|
}
|
||
|
|
logic.setInventorySlotContents(13, new ItemStack(TContent.woodPattern, 1, 22));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
super.onBlockPlacedBy(world, x, y, z, entityliving, stack);
|
||
|
|
}
|
||
|
|
|
||
|
|
@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;
|
||
|
|
}
|
||
|
|
}
|