Files
TinkersConstruct/src/main/java/tconstruct/blocks/CraftingSlab.java
T

175 lines
5.6 KiB
Java
Raw Normal View History

2013-08-16 13:51:33 -07:00
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.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
2014-01-18 02:52:49 -05:00
import net.minecraft.item.Item;
2013-08-16 13:51:33 -07:00
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
2013-12-31 20:24:06 -05:00
import net.minecraft.util.IIcon;
2013-08-16 13:51:33 -07:00
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.TProxyCommon;
2013-11-29 23:16:32 -05:00
import tconstruct.common.TRepo;
2013-08-16 13:51:33 -07:00
import tconstruct.library.TConstructRegistry;
2013-12-01 12:19:43 +00:00
import mantle.blocks.abstracts.InventorySlab;
2013-10-01 19:44:04 -07:00
import tconstruct.util.config.PHConstruct;
2013-08-16 13:51:33 -07:00
public class CraftingSlab extends InventorySlab
2013-08-16 13:51:33 -07:00
{
2013-12-31 15:30:34 -05:00
public CraftingSlab(Material material)
2013-08-16 13:51:33 -07:00
{
2013-12-31 15:30:34 -05:00
super(material);
2014-01-16 01:36:18 -05:00
this.func_149647_a(TConstructRegistry.blockTab);
2014-01-15 23:19:27 -05:00
this.func_149711_c(2f);
2014-01-29 00:41:17 -05:00
this.setStepSound(Block.field_149766_f);
2013-08-16 13:51:33 -07:00
}
/* Rendering */
@Override
public String[] getTextureNames ()
{
2013-08-31 05:13:31 -07:00
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" };
2013-08-16 13:51:33 -07:00
return textureNames;
}
@Override
2014-01-29 00:41:17 -05:00
public IIcon func_149691_a (int side, int meta)
2013-08-16 13:51:33 -07:00
{
return icons[(meta % 8) * 3 + getTextureIndex(side)];
}
public int getTextureIndex (int side)
{
if (side == 0)
return 2;
if (side == 1)
return 0;
return 1;
}
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
{
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 5)
2014-01-29 00:41:17 -05:00
return AxisAlignedBB.getAABBPool().getAABB((double) x + this.field_149759_B, (double) y + this.field_149760_C, (double) z + this.field_149754_D, (double) x + this.field_149755_E, (double) y + this.field_149756_F - 0.125,
(double) z + this.field_149757_G);
return AxisAlignedBB.getAABBPool().getAABB((double) x + this.field_149759_B, (double) y + this.field_149760_C, (double) z + this.field_149754_D, (double) x + this.field_149755_E, (double) y + this.field_149756_F, (double) z + this.field_149757_G);
2013-08-16 13:51:33 -07:00
}
@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) % 8;
2013-08-16 13:51:33 -07:00
switch (meta)
{
case 0:
return TProxyCommon.craftingStationID;
2013-08-31 05:13:31 -07:00
case 1:
2013-08-16 13:51:33 -07:00
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
2014-01-29 00:41:17 -05:00
public void func_149666_a (Item b, CreativeTabs tab, List list)
2013-08-16 13:51:33 -07:00
{
for (int iter = 0; iter < 6; iter++)
{
2013-12-31 15:30:34 -05:00
list.add(new ItemStack(b, 1, iter));
2013-08-16 13:51:33 -07:00
}
}
@Override
2014-01-29 00:41:17 -05:00
public void func_149689_a (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack)
2013-08-16 13:51:33 -07:00
{
if (PHConstruct.freePatterns)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta == 4)
{
2014-01-29 00:41:17 -05:00
PatternChestLogic logic = (PatternChestLogic) world.func_147438_o(x, y, z);
2013-08-16 13:51:33 -07:00
for (int i = 1; i <= 13; i++)
{
2013-11-29 23:16:32 -05:00
logic.setInventorySlotContents(i - 1, new ItemStack(TRepo.woodPattern, 1, i));
2013-08-16 13:51:33 -07:00
}
2013-11-29 23:16:32 -05:00
logic.setInventorySlotContents(13, new ItemStack(TRepo.woodPattern, 1, 22));
2013-08-16 13:51:33 -07:00
}
}
2014-01-29 00:41:17 -05:00
super.func_149689_a(world, x, y, z, entityliving, stack);
}
@Override
public TileEntity func_149915_a (World var1, 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;
}
2013-08-16 13:51:33 -07:00
}
}