2014-06-04 21:44:48 -08:00
|
|
|
package tconstruct.armor.blocks;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
import java.util.List;
|
2023-01-28 18:04:28 -08:00
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.block.material.Material;
|
2023-09-25 00:12:38 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.entity.EntityLiving;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-12-31 15:30:34 -05:00
|
|
|
import net.minecraft.init.Blocks;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2023-09-24 22:57:55 +02:00
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
|
import net.minecraft.world.World;
|
2023-01-28 18:04:28 -08:00
|
|
|
|
2023-09-25 00:17:50 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2023-05-15 15:07:18 +09:00
|
|
|
import mantle.blocks.abstracts.InventoryBlock;
|
2014-02-05 10:28:54 -05:00
|
|
|
import tconstruct.TConstruct;
|
2014-06-04 21:44:48 -08:00
|
|
|
import tconstruct.armor.modelblock.DryingRackRender;
|
2014-02-05 10:28:54 -05:00
|
|
|
import tconstruct.blocks.logic.DryingRackLogic;
|
|
|
|
|
import tconstruct.library.TConstructRegistry;
|
|
|
|
|
import tconstruct.library.tools.AbilityHelper;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public class DryingRack extends InventoryBlock {
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public DryingRack() {
|
2014-02-05 08:28:53 -05:00
|
|
|
super(Material.wood);
|
|
|
|
|
this.setCreativeTab(TConstructRegistry.blockTab);
|
|
|
|
|
setHardness(2.0f);
|
|
|
|
|
stepSound = soundTypeMetal;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public TileEntity createNewTileEntity(World world, int metadata) {
|
2013-07-26 21:18:53 -07:00
|
|
|
return new DryingRackLogic();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public int getRenderBlockPass() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer) {
|
2013-07-26 21:18:53 -07:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public Object getModInstance() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return TConstruct.instance;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) {
|
|
|
|
|
if (side > 1) return side;
|
2013-07-26 21:18:53 -07:00
|
|
|
return meta;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving living, ItemStack stack) {
|
2013-07-26 21:18:53 -07:00
|
|
|
int meta = world.getBlockMetadata(x, y, z);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (meta == 0) {
|
2013-07-26 21:18:53 -07:00
|
|
|
int l = MathHelper.floor_double((double) (living.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
|
|
|
|
int direction = l % 2;
|
2022-09-22 19:51:23 +01:00
|
|
|
if (direction == 1) world.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Activation */
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float clickX,
|
|
|
|
|
float clickY, float clickZ) {
|
2013-07-26 21:18:53 -07:00
|
|
|
return activateDryingRack(world, x, y, z, player);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
boolean activateDryingRack(World world, int x, int y, int z, EntityPlayer player) {
|
|
|
|
|
if (!world.isRemote) {
|
2014-02-05 08:28:53 -05:00
|
|
|
DryingRackLogic logic = (DryingRackLogic) world.getTileEntity(x, y, z);
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
if (!logic.isStackInSlot(0)) {
|
2013-07-26 21:18:53 -07:00
|
|
|
ItemStack stack = player.getCurrentEquippedItem();
|
2022-09-22 19:51:23 +01:00
|
|
|
if (stack != null) {
|
2013-07-26 21:18:53 -07:00
|
|
|
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
|
|
|
|
logic.setInventorySlotContents(0, stack);
|
|
|
|
|
}
|
2022-09-22 19:51:23 +01:00
|
|
|
} else {
|
2014-11-23 18:30:19 +01:00
|
|
|
ItemStack decrStack = logic.decrStackSize(0, 1);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (decrStack != null) AbilityHelper.spawnItemAtPlayer(player, decrStack);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-05 08:28:53 -05:00
|
|
|
world.markBlockForUpdate(x, y, z);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
|
2013-07-26 21:18:53 -07:00
|
|
|
int metadata = world.getBlockMetadata(x, y, z);
|
|
|
|
|
float xMin = 0F;
|
|
|
|
|
float yMin = 0F;
|
|
|
|
|
float zMin = 0F;
|
|
|
|
|
float xMax = 1F;
|
|
|
|
|
float yMax = 1F;
|
|
|
|
|
float zMax = 1F;
|
2022-09-22 19:51:23 +01:00
|
|
|
switch (metadata) {
|
|
|
|
|
case 0:
|
|
|
|
|
zMin = 0.375F;
|
|
|
|
|
yMax = 0.25F;
|
|
|
|
|
zMax = 0.625F;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
xMin = 0.375F;
|
|
|
|
|
yMax = 0.25F;
|
|
|
|
|
xMax = 0.625F;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
zMin = 0.75F;
|
|
|
|
|
yMin = 0.75F;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
zMax = 0.25F;
|
|
|
|
|
yMin = 0.75F;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
xMin = 0.75F;
|
|
|
|
|
yMin = 0.75F;
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
xMax = 0.25F;
|
|
|
|
|
yMin = 0.75F;
|
|
|
|
|
break;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
2022-09-22 19:51:23 +01:00
|
|
|
return AxisAlignedBB.getBoundingBox(
|
|
|
|
|
(double) x + xMin,
|
|
|
|
|
(double) y + yMin,
|
|
|
|
|
(double) z + zMin,
|
|
|
|
|
(double) x + xMax,
|
|
|
|
|
(double) y + yMax,
|
|
|
|
|
(double) z + zMax);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
2013-07-26 21:18:53 -07:00
|
|
|
int metadata = world.getBlockMetadata(x, y, z);
|
|
|
|
|
float xMin = 0F;
|
|
|
|
|
float yMin = 0F;
|
|
|
|
|
float zMin = 0F;
|
|
|
|
|
float xMax = 1F;
|
|
|
|
|
float yMax = 1F;
|
|
|
|
|
float zMax = 1F;
|
2022-09-22 19:51:23 +01:00
|
|
|
switch (metadata) {
|
|
|
|
|
case 0:
|
|
|
|
|
zMin = 0.375F;
|
|
|
|
|
yMax = 0.25F;
|
|
|
|
|
zMax = 0.625F;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
xMin = 0.375F;
|
|
|
|
|
yMax = 0.25F;
|
|
|
|
|
xMax = 0.625F;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
zMin = 0.75F;
|
|
|
|
|
yMin = 0.75F;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
zMax = 0.25F;
|
|
|
|
|
yMin = 0.75F;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
xMin = 0.75F;
|
|
|
|
|
yMin = 0.75F;
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
xMax = 0.25F;
|
|
|
|
|
yMin = 0.75F;
|
|
|
|
|
break;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
2014-02-05 08:28:53 -05:00
|
|
|
this.setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list,
|
|
|
|
|
Entity entity) {
|
2013-07-26 21:18:53 -07:00
|
|
|
this.setBlockBoundsBasedOnState(world, x, y, z);
|
2014-02-05 08:28:53 -05:00
|
|
|
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Rendering */
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public int getRenderType() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return DryingRackRender.model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public String[] getTextureNames() {
|
|
|
|
|
return new String[] { "castingtable_top", "castingtable_side", "castingtable_bottom", "faucet", "blockcast_top",
|
|
|
|
|
"blockcast_side", "blockcast_bottom" };
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-27 15:27:44 -05:00
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public String getTextureDomain(int textureNameIndex) {
|
2014-02-27 15:27:44 -05:00
|
|
|
return "tinker";
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
@Override
|
2014-02-17 15:30:13 -05:00
|
|
|
@SideOnly(Side.CLIENT)
|
2022-09-22 19:51:23 +01:00
|
|
|
public IIcon getIcon(int side, int meta) {
|
2014-02-05 08:28:53 -05:00
|
|
|
return Blocks.planks.getIcon(side, 0);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public int getTextureIndex(int side) {
|
|
|
|
|
if (side == 0) return 2;
|
|
|
|
|
if (side == 1) return 0;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public boolean renderAsNormalBlock() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public boolean isOpaqueCube() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-15 23:19:27 -05:00
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public TileEntity createTileEntity(World world, int metadata) {
|
2014-01-15 23:19:27 -05:00
|
|
|
return new DryingRackLogic();
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/*
|
|
|
|
|
* @Override public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int
|
|
|
|
|
* par5) { return true; }
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @Override public void getSubBlocks (int id, CreativeTabs tab, List list) { for (int iter = 0; iter < 3; iter++) {
|
|
|
|
|
* list.add(new ItemStack(id, 1, iter)); } }
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @Override public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z) { int meta =
|
|
|
|
|
* world.getBlockMetadata(x, y, z); if (meta != 1) { this.setBlockBounds(0, 0, 0, 1, 1, 1); } else { FaucetLogic
|
|
|
|
|
* logic = (FaucetLogic) world.getBlockTileEntity(x, y, z); float xMin = 0.25F; float xMax = 0.75F; float zMin =
|
|
|
|
|
* 0.25F; float zMax = 0.75F; switch (logic.getRenderDirection()) { case 2: zMin = 0.625F; zMax = 1.0F; break; case
|
|
|
|
|
* 3: zMax = 0.375F; zMin = 0F; break; case 4: xMin = 0.625F; xMax = 1.0F; break; case 5: xMax = 0.375F; xMin = 0F;
|
|
|
|
|
* break; } this.setBlockBounds(xMin, 0.25F, zMin, xMax, 0.625F, zMax); } }
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @Override public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z) { int meta =
|
2014-06-08 14:37:02 -04:00
|
|
|
* world.getBlockMetadata(x, y, z); if (meta != 1) { return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z +
|
2014-02-16 14:23:50 -05:00
|
|
|
* 1); } else { FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z); if (logic != null) { float xMin
|
|
|
|
|
* = 0.25F; float xMax = 0.75F; float zMin = 0.25F; float zMax = 0.75F; switch (logic.getRenderDirection()) { case
|
|
|
|
|
* 2: zMin = 0.625F; zMax = 1.0F; break; case 3: zMax = 0.375F; zMin = 0F; break; case 4: xMin = 0.625F; xMax =
|
2014-06-08 14:37:02 -04:00
|
|
|
* 1.0F; break; case 5: xMax = 0.375F; xMin = 0F; break; } return AxisAlignedBB.getBoundingBox((double) ((float) x +
|
2014-02-16 14:23:50 -05:00
|
|
|
* xMin), (double) y + 0.25, (double) ((float) z + zMin), (double) ((float) x + xMax), (double) y + 0.625, (double)
|
|
|
|
|
* ((float) z + zMax)); } } return super.getCollisionBoundingBoxFromPool(world, x, y, z); }
|
|
|
|
|
*/
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
/* Redstone */
|
|
|
|
|
}
|