mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-20 04:09:40 +00:00
Reorganize folders for modules
This commit is contained in:
1 parent
2c14f315de
commit
e2f0558b6f
370 files changed
+4274
-4788
No files matched your search
@@ -1,689 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import static net.minecraftforge.common.util.ForgeDirection.DOWN;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.EAST;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.NORTH;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.UP;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.WEST;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mantle.blocks.BlockUtils;
|
||||
import mantle.world.WorldHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.BlockPressurePlate.Sensitivity;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityTNTPrimed;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.LandmineExplodeLogic;
|
||||
import tconstruct.blocks.logic.TileEntityLandmine;
|
||||
import tconstruct.client.block.RenderLandmine;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.util.landmine.Helper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class BlockLandmine extends BlockContainer
|
||||
{
|
||||
|
||||
// Should explode when broken instead of dropping items(may not actually
|
||||
// work
|
||||
boolean explodeOnBroken = false;
|
||||
|
||||
public BlockLandmine()
|
||||
{
|
||||
super(Material.tnt);
|
||||
this.setTickRandomly(true);
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F - 0.0625F, 0.0625F, 1.0F - 0.0625F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if (world.getBlock(x, y, z) == (Block) this && world.getTileEntity(x, y, z) instanceof TileEntityLandmine)
|
||||
{
|
||||
TileEntityLandmine te = (TileEntityLandmine) world.getTileEntity(x, y, z);
|
||||
|
||||
if (te != null)
|
||||
{
|
||||
if (te.getStackInSlot(3) != null && te.getStackInSlot(3).getItem() instanceof ItemBlock)
|
||||
{
|
||||
return (BlockUtils.getBlockFromItem(te.getStackInSlot(3).getItem())).getLightValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getLightValue(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tickRate (World par1World)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1IBlockAccess.getTileEntity(par2, par3, par4);
|
||||
|
||||
ItemStack camo = te.getStackInSlot(3);
|
||||
if (camo != null)
|
||||
{
|
||||
return BlockUtils.getBlockFromItem(camo.getItem()).getIcon(par5, camo.getItemDamage());
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.getIcon(par5, par1IBlockAccess.getBlockMetadata(par2, par3, par4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return RenderLandmine.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)
|
||||
{
|
||||
super.onBlockClicked(par1World, par2, par3, par4, par5EntityPlayer);
|
||||
|
||||
if (this.explodeOnBroken)
|
||||
{
|
||||
checkExplosion(par1World, par2, par3, par4, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("tinker:Landmine");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
par5EntityPlayer.openGui(TConstruct.instance, TProxyCommon.landmineID, par1World, par2, par3, par4);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World par1World, int par2, int par3, int par4, Block par5Block, int par6)
|
||||
{
|
||||
TileEntityLandmine tileentity = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
|
||||
int metadata = par1World.getBlockMetadata(par2, par3, par4);
|
||||
|
||||
if (tileentity != null && (!explodeOnBroken || !hasItems(par1World, par2, par3, par4)) && par6 != 193 && !tileentity.isExploding)
|
||||
{
|
||||
if (this != null)
|
||||
{
|
||||
ItemStack is = new ItemStack(this, 1, damageDropped(tileentity.triggerType));
|
||||
if (tileentity.hasCustomInventoryName())
|
||||
{
|
||||
is.setStackDisplayName(tileentity.getInventoryName());
|
||||
}
|
||||
dropBlockAsItem(par1World, par2, par3, par4, new ItemStack(this, 1, damageDropped(tileentity.triggerType)));
|
||||
}
|
||||
|
||||
for (int j1 = 0; j1 < tileentity.getSizeInventory(); ++j1)
|
||||
{
|
||||
ItemStack itemstack = tileentity.getStackInSlot(j1);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
while (itemstack.stackSize > 0)
|
||||
{
|
||||
|
||||
int ss = itemstack.stackSize;
|
||||
itemstack.stackSize -= ss;
|
||||
EntityItem entityitem = new EntityItem(par1World, (double) ((float) par2), (double) ((float) par3), (double) ((float) par4), new ItemStack(itemstack.getItem(), ss,
|
||||
itemstack.getItemDamage()));
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (double) (f3);
|
||||
entityitem.motionY = (double) (f3 + 0.2F);
|
||||
entityitem.motionZ = (double) (f3);
|
||||
par1World.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
||||
}
|
||||
else if (explodeOnBroken)
|
||||
{
|
||||
checkExplosion(par1World, par2, par3, par4, true);
|
||||
}
|
||||
|
||||
super.breakBlock(par1World, par2, par3, par4, par5Block, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
par3List.add(new ItemStack(par1, 1, 2));
|
||||
par3List.add(new ItemStack(par1, 1, 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBlocksMovement (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockOnSide (World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(par5);
|
||||
return (dir == DOWN && par1World.isSideSolid(par2, par3 + 1, par4, DOWN)) || (dir == UP && par1World.isSideSolid(par2, par3 - 1, par4, UP))
|
||||
|| (dir == NORTH && par1World.isSideSolid(par2, par3, par4 + 1, NORTH)) || (dir == SOUTH && par1World.isSideSolid(par2, par3, par4 - 1, SOUTH))
|
||||
|| (dir == WEST && par1World.isSideSolid(par2 + 1, par3, par4, WEST)) || (dir == EAST && par1World.isSideSolid(par2 - 1, par3, par4, EAST));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.isSideSolid(par2 - 1, par3, par4, EAST) || par1World.isSideSolid(par2 + 1, par3, par4, WEST) || par1World.isSideSolid(par2, par3, par4 - 1, SOUTH)
|
||||
|| par1World.isSideSolid(par2, par3, par4 + 1, NORTH) || par1World.isSideSolid(par2, par3 - 1, par4, UP) || par1World.isSideSolid(par2, par3 + 1, par4, DOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced (World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
|
||||
{
|
||||
int j1 = par9 & 8;
|
||||
int k1 = par9 & 7;
|
||||
byte b0 = -1;
|
||||
|
||||
if (par5 == 0 && par1World.isSideSolid(par2, par3 + 1, par4, DOWN))
|
||||
{
|
||||
b0 = 0;
|
||||
}
|
||||
|
||||
if (par5 == 1 && par1World.isSideSolid(par2, par3 - 1, par4, UP))
|
||||
{
|
||||
b0 = 5;
|
||||
}
|
||||
|
||||
if (par5 == 2 && par1World.isSideSolid(par2, par3, par4 + 1, NORTH))
|
||||
{
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
if (par5 == 3 && par1World.isSideSolid(par2, par3, par4 - 1, SOUTH))
|
||||
{
|
||||
b0 = 3;
|
||||
}
|
||||
|
||||
if (par5 == 4 && par1World.isSideSolid(par2 + 1, par3, par4, WEST))
|
||||
{
|
||||
b0 = 2;
|
||||
}
|
||||
|
||||
if (par5 == 5 && par1World.isSideSolid(par2 - 1, par3, par4, EAST))
|
||||
{
|
||||
b0 = 1;
|
||||
}
|
||||
|
||||
return b0 + j1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
int l = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int i1 = l & 7;
|
||||
int j1 = l & 8;
|
||||
|
||||
if (i1 == invertMetadata(1))
|
||||
{
|
||||
if ((MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 1) == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 5 | j1, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 6 | j1, 2);
|
||||
}
|
||||
}
|
||||
else if (i1 == invertMetadata(0))
|
||||
{
|
||||
if ((MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 1) == 0)
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 7 | j1, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | j1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (par6ItemStack.hasDisplayName())
|
||||
{
|
||||
((TileEntityLandmine) par1World.getTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
public static int invertMetadata (int par0)
|
||||
{
|
||||
switch (par0)
|
||||
{
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return 5;
|
||||
case 2:
|
||||
return 4;
|
||||
case 3:
|
||||
return 3;
|
||||
case 4:
|
||||
return 2;
|
||||
case 5:
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, Block par5Block)
|
||||
{
|
||||
checkPlacement(par1World, par2, par3, par4, par5Block);
|
||||
|
||||
checkExplosion(par1World, par2, par3, par4, false);
|
||||
}
|
||||
|
||||
public void checkPlacement (World par1World, int par2, int par3, int par4, Block par5Block)
|
||||
{
|
||||
if (this.checkIfAttachedToBlock(par1World, par2, par3, par4))
|
||||
{
|
||||
int i1 = par1World.getBlockMetadata(par2, par3, par4) & 7;
|
||||
boolean flag = false;
|
||||
|
||||
if (!par1World.isSideSolid(par2 - 1, par3, par4, EAST) && i1 == 1)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2 + 1, par3, par4, WEST) && i1 == 2)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3, par4 - 1, SOUTH) && i1 == 3)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3, par4 + 1, NORTH) && i1 == 4)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3 - 1, par4, UP) && i1 == 5)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3 - 1, par4, UP) && i1 == 6)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3 + 1, par4, DOWN) && i1 == 0)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3 + 1, par4, DOWN) && i1 == 7)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkIfAttachedToBlock (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (!this.canPlaceBlockAt(par1World, par2, par3, par4))
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick (World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
checkExplosion(par1World, par2, par3, par4, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
this.checkExplosion(par1World, par2, par3, par4, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkExplosion (World par1World, int par2, int par3, int par4, boolean skipCheck)
|
||||
{
|
||||
if (skipCheck || getMineState(par1World, par2, par3, par4) > 0)
|
||||
{
|
||||
if (hasItems(par1World, par2, par3, par4))
|
||||
{
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
if (te.soundcountything <= 0)
|
||||
{
|
||||
par1World.playSoundEffect((double) par2 + 0.5D, (double) par3 + 0.1D, (double) par4 + 0.5D, "random.click", 0.3F, 0.6F);
|
||||
te.setSoundPlayed();
|
||||
}
|
||||
new LandmineExplodeLogic(par1World, par2, par3, par4, getMineTriggerer(par1World, par2, par3, par4)).explode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean hasItems (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
if (te != null && te.getStackInSlot(0) != null || te.getStackInSlot(1) != null || te.getStackInSlot(2) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected int getMineState (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
|
||||
Sensitivity triggerType;
|
||||
|
||||
// Change to return 1 if you want the landmine to blow up when the block
|
||||
// holding it is broken
|
||||
if (te == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
switch (te.triggerType)
|
||||
{
|
||||
case 0:
|
||||
triggerType = Sensitivity.everything;
|
||||
break;
|
||||
case 1:
|
||||
triggerType = Sensitivity.mobs;
|
||||
break;
|
||||
case 2:
|
||||
triggerType = Sensitivity.players;
|
||||
break;
|
||||
default:
|
||||
triggerType = null;
|
||||
break;
|
||||
}
|
||||
|
||||
if (triggerType != null)
|
||||
{
|
||||
List list = null;
|
||||
|
||||
if (triggerType == Sensitivity.everything)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABBExcludingEntity((Entity) null, getSensitiveAABB(par1World, par2, par3, par4));
|
||||
}
|
||||
|
||||
if (triggerType == Sensitivity.mobs)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityLivingBase.class, getSensitiveAABB(par1World, par2, par3, par4));
|
||||
}
|
||||
|
||||
if (triggerType == Sensitivity.players)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityPlayer.class, this.getSensitiveAABB(par1World, par2, par3, par4));
|
||||
}
|
||||
|
||||
if (list != null && !list.isEmpty())
|
||||
{
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
if (!entity.doesEntityNotTriggerPressurePlate())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1World.isBlockIndirectlyGettingPowered(par2, par3, par4) ? 1 : 0;
|
||||
}
|
||||
|
||||
protected AxisAlignedBB getSensitiveAABB (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
float f = 0.125F;
|
||||
// return AxisAlignedBB.getAABBPool().getAABB((double)((float)par1 + f),
|
||||
// (double)par2, (double)((float)par3 + f), (double)((float)(par1 + 1) -
|
||||
// f), (double)par2 + 0.25D, (double)((float)(par3 + 1) - f));
|
||||
|
||||
int l = par1World.getBlockMetadata(par2, par3, par4);
|
||||
int i1 = l & 7;
|
||||
boolean flag = (l & 8) > 0;
|
||||
|
||||
float minX = par2 + f, minY = par3, minZ = par4 + f, maxX = par2 + 1 - f, maxY = par3 + 0.25F, maxZ = par4 + 1 - f;
|
||||
|
||||
ForgeDirection dir = Helper.convertMetaToForgeOrientation(i1);
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
break;
|
||||
case UP:
|
||||
minY = par3 + 0.75F;
|
||||
maxY = par3 + 1;
|
||||
break;
|
||||
default:
|
||||
minX = par2;
|
||||
minY = par3;
|
||||
minZ = par4;
|
||||
maxX = par2 + 1;
|
||||
maxY = par3 + 1;
|
||||
maxZ = par4 + 1;
|
||||
}
|
||||
return AxisAlignedBB.getAABBPool().getAABB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public Entity getMineTriggerer (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
|
||||
TileEntityLandmine te = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
|
||||
Sensitivity triggerType;
|
||||
|
||||
// Change to return 1 if you want the landmine to blow up when the
|
||||
// block holding it is broken
|
||||
if (te == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
switch (te.triggerType)
|
||||
{
|
||||
case 0:
|
||||
triggerType = Sensitivity.everything;
|
||||
break;
|
||||
case 1:
|
||||
triggerType = Sensitivity.mobs;
|
||||
break;
|
||||
case 2:
|
||||
triggerType = Sensitivity.players;
|
||||
break;
|
||||
default:
|
||||
triggerType = null;
|
||||
break;
|
||||
}
|
||||
|
||||
if (triggerType != null)
|
||||
{
|
||||
List list = null;
|
||||
|
||||
if (triggerType == Sensitivity.everything)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABBExcludingEntity((Entity) null, AxisAlignedBB.getAABBPool().getAABB(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
}
|
||||
|
||||
if (triggerType == Sensitivity.mobs)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getAABBPool().getAABB(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
}
|
||||
|
||||
if (triggerType == Sensitivity.players)
|
||||
{
|
||||
list = par1World.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getAABBPool().getAABB(par2 + 0D, par3 + 0D, par4 + 0D, par2 + 1D, par3 + 1D, par4 + 1D));
|
||||
}
|
||||
|
||||
if (list != null && !list.isEmpty())
|
||||
{
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
if (!entity.doesEntityNotTriggerPressurePlate())
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new EntityTNTPrimed(par1World, par2, par3, par4, (EntityLivingBase) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropFromExplosion (Explosion par1Explosion)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int l = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
int i1 = l & 7;
|
||||
boolean flag = (l & 8) > 0;
|
||||
|
||||
ForgeDirection dir = Helper.convertMetaToForgeOrientation(i1);
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F - 0.0625F, 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case UP:
|
||||
this.setBlockBounds(0.0625F, 1.0F - 0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case NORTH:
|
||||
this.setBlockBounds(0.0625F, 0.0625F, 0.0F, 1.0F - 0.0625F, 1.0F - 0.0625F, 0.0625F);
|
||||
break;
|
||||
case SOUTH:
|
||||
this.setBlockBounds(0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F, 1.0F);
|
||||
break;
|
||||
case EAST:
|
||||
this.setBlockBounds(1.0F - 0.0625F, 0.0625F, 0.0625F, 1.0F, 1.0F - 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
case WEST:
|
||||
this.setBlockBounds(0.0F, 0.0625F, 0.0625F, 0.0625F, 1.0F - 0.0625F, 1.0F - 0.0625F);
|
||||
break;
|
||||
default:
|
||||
this.setBlockBounds(0, 0, 0, 1, 1, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int meta)
|
||||
{
|
||||
return new TileEntityLandmine();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class BloodBlock extends TConstructFluid
|
||||
{
|
||||
|
||||
public BloodBlock(Fluid fluid, Material material, String texture)
|
||||
{
|
||||
super(fluid, material, texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.field_76434_w.id, 20 * 15, 0));
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.poison.id, 20 * 5, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.blocks.logic.CastingChannelLogic;
|
||||
import tconstruct.client.block.BlockRenderCastingChannel;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
/**
|
||||
* @author BluSunrize
|
||||
*/
|
||||
|
||||
public class CastingChannelBlock extends BlockContainer
|
||||
{
|
||||
|
||||
public CastingChannelBlock()
|
||||
{
|
||||
super(Material.rock);
|
||||
this.setHardness(1F);
|
||||
this.setResistance(10);
|
||||
this.stepSound = soundTypeStone;
|
||||
setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
CastingChannelLogic tile = (CastingChannelLogic) world.getTileEntity(x, y, z);
|
||||
|
||||
if (stack == null)
|
||||
tile.changeOutputs(player, side, hitX, hitY, hitZ);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
CastingChannelLogic tile = (CastingChannelLogic) world.getTileEntity(x, y, z);
|
||||
float minX = 0.3125F;
|
||||
float maxX = 0.6875F;
|
||||
float minZ = 0.3125F;
|
||||
float maxZ = 0.6875F;
|
||||
minZ = 0F;
|
||||
maxZ = 1F;
|
||||
minX = 0F;
|
||||
maxX = 1F;
|
||||
this.setBlockBounds(minX, 0.375F, minZ, maxX, 0.625F, maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return BlockRenderCastingChannel.renderID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.blockIcon = iconRegister.registerIcon("tinker:searedstone");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World var1, int var2)
|
||||
{
|
||||
return new CastingChannelLogic();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import mantle.blocks.MantleBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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;
|
||||
import tconstruct.client.block.SlimeChannelRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ConveyorBase extends MantleBlock
|
||||
{
|
||||
String texturename;
|
||||
|
||||
public ConveyorBase(Material material, String name)
|
||||
{
|
||||
super(material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setBlockBounds(0f, 0f, 0f, 1f, 0.5f, 1f);
|
||||
texturename = name;
|
||||
}
|
||||
|
||||
public boolean isBlockReplaceable (World world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (!world.isBlockIndirectlyGettingPowered(x, y, z))
|
||||
{
|
||||
double moveX = 0;
|
||||
double moveZ = 0;
|
||||
|
||||
double speed = 0.01;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta % 8)
|
||||
{
|
||||
case 6:
|
||||
moveX += speed;
|
||||
break;
|
||||
case 7:
|
||||
moveX += speed;
|
||||
moveZ += speed;
|
||||
break;
|
||||
case 0:
|
||||
moveZ += speed;
|
||||
break;
|
||||
case 1:
|
||||
moveZ += speed;
|
||||
moveX -= speed;
|
||||
break;
|
||||
case 2:
|
||||
moveX -= speed;
|
||||
break;
|
||||
case 3:
|
||||
moveX -= speed;
|
||||
moveZ -= speed;
|
||||
break;
|
||||
case 4:
|
||||
moveZ -= speed;
|
||||
break;
|
||||
case 5:
|
||||
moveZ -= speed;
|
||||
moveX += speed;
|
||||
break;
|
||||
}
|
||||
|
||||
entity.addVelocity(moveX, 0, moveZ);
|
||||
}
|
||||
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
((EntityItem) entity).age = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack)
|
||||
{
|
||||
int face = MathHelper.floor_double((double) (entity.rotationYaw * 8.0F / 360.0F) + 0.5D) + (entity.isSneaking() ? 4 : 0) & 7;
|
||||
int meta = world.getBlockMetadata(x, y, z) & 8;
|
||||
world.setBlockMetadataWithNotify(x, y, z, face | meta, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
if (side == 1)
|
||||
return false;
|
||||
return super.shouldSideBeRendered(world, x, y, z, side);
|
||||
}
|
||||
|
||||
public IIcon[] icons;
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return SlimeChannelRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
String[] textureNames = new String[] { texturename, texturename + "_flow" };
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta >= 8)
|
||||
return icons[0];
|
||||
return side == 1 ? icons[1] : icons[0];
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.InventorySlab;
|
||||
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;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
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;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class CraftingSlab extends InventorySlab
|
||||
{
|
||||
public CraftingSlab(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(2f);
|
||||
this.stepSound = Block.soundTypeWood;
|
||||
}
|
||||
|
||||
/* 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 String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon 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 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) % 8;
|
||||
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 (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 6; iter++)
|
||||
{
|
||||
list.add(new ItemStack(b, 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.getTileEntity(x, y, z);
|
||||
for (int i = 1; i <= 13; i++)
|
||||
{
|
||||
logic.setInventorySlotContents(i - 1, new ItemStack(TRepo.woodPattern, 1, i));
|
||||
}
|
||||
logic.setInventorySlotContents(13, new ItemStack(TRepo.woodPattern, 1, 22));
|
||||
}
|
||||
}
|
||||
super.onBlockPlacedBy(world, x, y, z, entityliving, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.CraftingStationLogic;
|
||||
import tconstruct.client.block.TableRender;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class CraftingStationBlock extends InventoryBlock
|
||||
{
|
||||
public CraftingStationBlock(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(2f);
|
||||
this.setStepSound(Block.soundTypeWood);
|
||||
}
|
||||
|
||||
//Block.hasComparatorInputOverride and Block.getComparatorInputOverride
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "craftingstation_top", "craftingstation_side", "craftingstation_bottom" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[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 int getRenderType ()
|
||||
{
|
||||
return TableRender.tabelModelID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return TProxyCommon.craftingStationID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 1; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World arg0, int arg1)
|
||||
{
|
||||
return new CraftingStationLogic();
|
||||
}
|
||||
}
|
||||
@@ -1,316 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
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;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.DryingRackLogic;
|
||||
import tconstruct.client.block.DryingRackRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class DryingRack extends InventoryBlock
|
||||
{
|
||||
|
||||
public DryingRack()
|
||||
{
|
||||
super(Material.wood);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setHardness(2.0f);
|
||||
stepSound = soundTypeMetal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int metadata)
|
||||
{
|
||||
return new DryingRackLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLiving living, ItemStack stack)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 0)
|
||||
{
|
||||
int l = MathHelper.floor_double((double) (living.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
int direction = l % 2;
|
||||
if (direction == 1)
|
||||
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Activation */
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
return activateDryingRack(world, x, y, z, player);
|
||||
}
|
||||
|
||||
boolean activateDryingRack (World world, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
DryingRackLogic logic = (DryingRackLogic) world.getTileEntity(x, y, z);
|
||||
|
||||
if (!logic.isStackInSlot(0))
|
||||
{
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null)
|
||||
{
|
||||
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
logic.setInventorySlotContents(0, stack);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logic.isStackInSlot(0))
|
||||
{
|
||||
ItemStack decrStack = logic.decrStackSize(0, 1);
|
||||
if (decrStack != null)
|
||||
addItemToInventory(player, world, x, y, z, decrStack);
|
||||
}
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addItemToInventory (EntityPlayer player, World world, int x, int y, int z, ItemStack stack)
|
||||
{
|
||||
AbilityHelper.spawnItemAtPlayer(player, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
}
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double) x + xMin, (double) y + yMin, (double) z + zMin, (double) x + xMax, (double) y + yMax, (double) z + zMax);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
}
|
||||
this.setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity)
|
||||
{
|
||||
this.setBlockBoundsBasedOnState(world, x, y, z);
|
||||
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
|
||||
}
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return DryingRackRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "castingtable_top", "castingtable_side", "castingtable_bottom", "faucet", "blockcast_top", "blockcast_side", "blockcast_bottom" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return Blocks.planks.getIcon(side, 0);
|
||||
}
|
||||
|
||||
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 TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
return new DryingRackLogic();
|
||||
}
|
||||
|
||||
/*
|
||||
* @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 = world.getBlockMetadata(x, y, z);
|
||||
* if (meta != 1) { return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x +
|
||||
* 1, y + 1, z + 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 = 1.0F; break; case 5: xMax = 0.375F; xMin = 0F; break; }
|
||||
*
|
||||
* return AxisAlignedBB.getAABBPool().getAABB((double) ((float) x + 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); }
|
||||
*/
|
||||
|
||||
/* Redstone */
|
||||
}
|
||||
@@ -1,209 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.EquipLogic;
|
||||
import tconstruct.blocks.logic.FrypanLogic;
|
||||
import tconstruct.client.block.FrypanRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class EquipBlock extends InventoryBlock
|
||||
{
|
||||
|
||||
public EquipBlock(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setHardness(0.3f);
|
||||
this.setBlockBounds(0, 0, 0, 1, 0.25f, 1);
|
||||
// this.setCreativeTab(ToolConstruct.materialTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
return new String[] { "toolstation_top" };
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return Blocks.iron_block.getIcon(side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister par1IconRegister)
|
||||
{
|
||||
// this.blockIcon =
|
||||
// par1iconRegister.registerIcon(Block.blockIron.getUnlocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return FrypanRender.frypanModelID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int metadata)
|
||||
{
|
||||
return new FrypanLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick (World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if (isActive(world, x, y, z))
|
||||
{
|
||||
float f = (float) x + 0.5F;
|
||||
float f1 = (float) y + 0.25F + (random.nextFloat() * 6F) / 16F;
|
||||
float f2 = (float) z + 0.5F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
world.spawnParticle("smoke", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
|
||||
int i3 = MathHelper.floor_double((par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
int newMeta = 0;
|
||||
|
||||
switch (i3)
|
||||
{
|
||||
case 3:
|
||||
newMeta = 0;
|
||||
break;
|
||||
case 0:
|
||||
newMeta = 3;
|
||||
break;
|
||||
case 1:
|
||||
newMeta = 1;
|
||||
break;
|
||||
case 2:
|
||||
newMeta = 2;
|
||||
break;
|
||||
}
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, newMeta, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World par1World, int x, int y, int z, Block par5, int meta)
|
||||
{
|
||||
TileEntity te = par1World.getTileEntity(x, y, z);
|
||||
|
||||
if (te != null && te instanceof EquipLogic)
|
||||
{
|
||||
EquipLogic logic = (EquipLogic) te;
|
||||
for (int iter = 0; iter < logic.getSizeInventory(); ++iter)
|
||||
{
|
||||
ItemStack stack = iter == 0 ? logic.getEquipmentItem() : 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.getItem(),
|
||||
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, par5, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return !isActive(world, x, y, z) ? 0 : 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return TConstruct.proxy.frypanGuiID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
return new FrypanLogic();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import mantle.blocks.abstracts.InventorySlab;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.FurnaceLogic;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class FurnaceSlab extends InventorySlab
|
||||
{
|
||||
|
||||
public FurnaceSlab(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(3.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata % 8)
|
||||
{
|
||||
case 0:
|
||||
return new FurnaceLogic();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return TProxyCommon.furnaceID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "furnaceslab_front", "furnaceslab_front_active", "furnaceslab_side", "furnace_top" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[(meta % 8) * 3 + getTextureIndex(side)];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity logic = world.getTileEntity(x, y, z);
|
||||
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0;
|
||||
int meta = world.getBlockMetadata(x, y, z) % 8;
|
||||
|
||||
if (meta == 0)
|
||||
{
|
||||
if (side == direction)
|
||||
{
|
||||
if (((IActiveLogic) logic).getActive())
|
||||
return icons[1];
|
||||
else
|
||||
return icons[0];
|
||||
}
|
||||
else if (side > 1)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
return icons[3];
|
||||
}
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return 3;
|
||||
if (side == 3)
|
||||
return 0;
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
String[] textureNames = getTextureNames();
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
if (i == 3)
|
||||
this.icons[i] = iconRegister.registerIcon("minecraft:" + textureNames[i]);
|
||||
else
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World var1, int metadata)
|
||||
{
|
||||
switch (metadata % 8)
|
||||
{
|
||||
case 0:
|
||||
return new FurnaceLogic();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class GlassBlock extends TConstructBlock
|
||||
{
|
||||
static String blockTextures[] = { "glass_clear", "soulglass", "soulglass_clear" };
|
||||
|
||||
public GlassBlock()
|
||||
{
|
||||
super(Material.glass, 3f, blockTextures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
Block i1 = par1IBlockAccess.getBlock(par2, par3, par4);
|
||||
return i1 == (Block) this ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return 0.3F;
|
||||
case 1:
|
||||
return 50.0F;
|
||||
case 2:
|
||||
return 50.0F;
|
||||
default:
|
||||
return blockHardness;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return 1.5F;
|
||||
case 1:
|
||||
return 2000F;
|
||||
case 2:
|
||||
return 2000F;
|
||||
default:
|
||||
return getExplosionResistance(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:glass/" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,651 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import mantle.blocks.MantleBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
|
||||
public class GlassBlockConnected extends MantleBlock
|
||||
{
|
||||
protected IIcon[] icons = new IIcon[16];
|
||||
private boolean shouldRenderSelectionBox = true;
|
||||
protected String folder;
|
||||
private int renderPass;
|
||||
|
||||
public GlassBlockConnected(String location, boolean hasAlpha)
|
||||
{
|
||||
super(Material.glass);
|
||||
this.stepSound = soundTypeGlass;
|
||||
folder = location;
|
||||
renderPass = hasAlpha ? 1 : 0;
|
||||
setHardness(0.3F);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
// For FMP support
|
||||
public IIcon[] getIcons ()
|
||||
{
|
||||
return icons;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return renderPass;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is checked to see if the texture should connect to this block
|
||||
*
|
||||
* @param par2
|
||||
* x
|
||||
* @param par3
|
||||
* y
|
||||
* @param par4
|
||||
* z
|
||||
* @param par5
|
||||
* ID this block is asking to connect to (may be 0 if there is no
|
||||
* block)
|
||||
* @param par6
|
||||
* Metadata of the block this block is trying to connect to
|
||||
* @return true if should connect
|
||||
*/
|
||||
public boolean shouldConnectToBlock (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, Block par5, int par6)
|
||||
{
|
||||
return par5 == (Block) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 15 ? icons[0] : getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons);
|
||||
}
|
||||
|
||||
public IIcon getConnectedBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, IIcon[] icons)
|
||||
{
|
||||
if (PHConstruct.connectedTexturesMode == 0)
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
boolean isOpenUp = false, isOpenDown = false, isOpenLeft = false, isOpenRight = false;
|
||||
|
||||
switch (par5)
|
||||
{
|
||||
case 0:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
Block b = par1IBlockAccess.getBlock(par2, par3, par4);
|
||||
return b == (Block) this ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int par1, int par2)
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (shouldRenderSelectionBox)
|
||||
{
|
||||
return super.getSelectedBoundingBoxFromPool(par1World, par2, par3, par4);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AxisAlignedBB.getAABBPool().getAABB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister par1IconRegister)
|
||||
{
|
||||
icons[0] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass");
|
||||
icons[1] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_d");
|
||||
icons[2] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_u");
|
||||
icons[3] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_l");
|
||||
icons[4] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_1_r");
|
||||
icons[5] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_h");
|
||||
icons[6] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_v");
|
||||
icons[7] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_dl");
|
||||
icons[8] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_dr");
|
||||
icons[9] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_ul");
|
||||
icons[10] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_2_ur");
|
||||
icons[11] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_d");
|
||||
icons[12] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_u");
|
||||
icons[13] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_l");
|
||||
icons[14] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_3_r");
|
||||
icons[15] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_4");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceTorchOnTop (World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
|
||||
public class GlassBlockConnectedMeta extends GlassBlockConnected
|
||||
{
|
||||
public String[] textures;
|
||||
public IIcon[][] icons;
|
||||
boolean ignoreMetaForConnectedGlass = PHConstruct.connectedTexturesMode == 2;
|
||||
|
||||
public GlassBlockConnectedMeta(String location, boolean hasAlpha, String... textures)
|
||||
{
|
||||
super(location, hasAlpha);
|
||||
this.textures = textures;
|
||||
this.icons = new IIcon[textures.length][16];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
|
||||
if (meta < icons.length)
|
||||
{
|
||||
return getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons[meta]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldConnectToBlock (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, Block par5, int par6)
|
||||
{
|
||||
return par5 == this && (par6 == par1IBlockAccess.getBlockMetadata(par2, par3, par4) || ignoreMetaForConnectedGlass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int par1, int par2)
|
||||
{
|
||||
return icons[par2][0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item b, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int i = 0; i < textures.length; i++)
|
||||
{
|
||||
par3List.add(new ItemStack(b, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister par1IconRegister)
|
||||
{
|
||||
for (int i = 0; i < textures.length; i++)
|
||||
{
|
||||
icons[i][0] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass");
|
||||
icons[i][1] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_d");
|
||||
icons[i][2] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_u");
|
||||
icons[i][3] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_l");
|
||||
icons[i][4] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_1_r");
|
||||
icons[i][5] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_h");
|
||||
icons[i][6] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_v");
|
||||
icons[i][7] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_dl");
|
||||
icons[i][8] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_dr");
|
||||
icons[i][9] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_ul");
|
||||
icons[i][10] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_2_ur");
|
||||
icons[i][11] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_d");
|
||||
icons[i][12] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_u");
|
||||
icons[i][13] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_l");
|
||||
icons[i][14] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_3_r");
|
||||
icons[i][15] = par1IconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_4");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceTorchOnTop (World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class GlassBlockStained extends TConstructBlock
|
||||
{
|
||||
static String blockTextures[] = { "white", "orange", "magenta", "lightblue", "yellow", "lime", "pink", "gray", "lightgray", "cyan", "purple", "blue", "brown", "green", "red", "black" };
|
||||
String textureName;
|
||||
|
||||
public GlassBlockStained(String tex)
|
||||
{
|
||||
super(Material.glass, 3f, blockTextures);
|
||||
this.textureName = tex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block == this ? false : super.shouldSideBeRendered(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:glass/" + textureName + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
public class GlassPane extends PaneBase
|
||||
{
|
||||
static String blockTextures[] = { "glass_clear", "soulglass", "soulglass_clear" };
|
||||
|
||||
public GlassPane()
|
||||
{
|
||||
super(Material.glass, "glass/", blockTextures);
|
||||
this.setHardness(0.3F);
|
||||
this.stepSound = soundTypeGlass;
|
||||
this.setBlockName("tconstruct.glasspane");
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
}
|
||||
@@ -1,700 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.client.block.PaneConnectedRender;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class GlassPaneConnected extends GlassBlockConnected
|
||||
{
|
||||
|
||||
private IIcon theIcon;
|
||||
|
||||
public GlassPaneConnected(String location, boolean hasAlpha)
|
||||
{
|
||||
super(location, hasAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return PaneConnectedRender.model;
|
||||
// return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
if (par5 == 0 || par5 == 1)
|
||||
{
|
||||
return par1IBlockAccess.getBlock(par2, par3 - 1, par4) == this && par5 == 0 ? icons[15] : par1IBlockAccess.getBlock(par2, par3 + 1, par4) == this && par5 == 1 ? icons[15]
|
||||
: getSideTextureIndex();
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.getIcon(par1IBlockAccess, par2, par3, par4, par5);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getConnectedBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, IIcon[] icons)
|
||||
{
|
||||
if (par5 == 0 || par5 == 1)
|
||||
{
|
||||
return getSideTextureIndex();
|
||||
}
|
||||
|
||||
if (PHConstruct.connectedTexturesMode == 0)
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
boolean isOpenUp = false, isOpenDown = false, isOpenLeft = false, isOpenRight = false;
|
||||
|
||||
switch (par5)
|
||||
{
|
||||
case 0:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
|
||||
{
|
||||
isOpenDown = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
|
||||
{
|
||||
isOpenUp = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
|
||||
{
|
||||
isOpenLeft = true;
|
||||
}
|
||||
|
||||
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlock(par2, par3, par4 + 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1)))
|
||||
{
|
||||
isOpenRight = true;
|
||||
}
|
||||
|
||||
if (isOpenUp && isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[15];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[13];
|
||||
}
|
||||
else if (isOpenUp && isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[14];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[11];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[12];
|
||||
}
|
||||
else if (isOpenDown && isOpenUp)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (isOpenLeft && isOpenRight)
|
||||
{
|
||||
return icons[5];
|
||||
}
|
||||
else if (isOpenDown && isOpenLeft)
|
||||
{
|
||||
return icons[10];
|
||||
}
|
||||
else if (isOpenDown && isOpenRight)
|
||||
{
|
||||
return icons[9];
|
||||
}
|
||||
else if (isOpenUp && isOpenLeft)
|
||||
{
|
||||
return icons[8];
|
||||
}
|
||||
else if (isOpenUp && isOpenRight)
|
||||
{
|
||||
return icons[7];
|
||||
}
|
||||
else if (isOpenDown)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else if (isOpenUp)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else if (isOpenLeft)
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
else if (isOpenRight)
|
||||
{
|
||||
return icons[4];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList (World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
|
||||
{
|
||||
boolean flag = this.canPaneConnectTo(par1World, par2, par3, par4, ForgeDirection.NORTH);
|
||||
boolean flag1 = this.canPaneConnectTo(par1World, par2, par3, par4, ForgeDirection.SOUTH);
|
||||
boolean flag2 = this.canPaneConnectTo(par1World, par2, par3, par4, ForgeDirection.WEST);
|
||||
boolean flag3 = this.canPaneConnectTo(par1World, par2, par3, par4, ForgeDirection.EAST);
|
||||
|
||||
if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1))
|
||||
{
|
||||
if (flag2 && !flag3)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
else if (!flag2 && flag3)
|
||||
{
|
||||
this.setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
|
||||
if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1))
|
||||
{
|
||||
if (flag && !flag1)
|
||||
{
|
||||
this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
else if (!flag && flag1)
|
||||
{
|
||||
this.setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsForItemRender ()
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
float f = 0.4375F;
|
||||
float f1 = 0.5625F;
|
||||
float f2 = 0.4375F;
|
||||
float f3 = 0.5625F;
|
||||
boolean flag = this.canPaneConnectTo(par1IBlockAccess, par2, par3, par4, ForgeDirection.NORTH);
|
||||
boolean flag1 = this.canPaneConnectTo(par1IBlockAccess, par2, par3, par4, ForgeDirection.SOUTH);
|
||||
boolean flag2 = this.canPaneConnectTo(par1IBlockAccess, par2, par3, par4, ForgeDirection.WEST);
|
||||
boolean flag3 = this.canPaneConnectTo(par1IBlockAccess, par2, par3, par4, ForgeDirection.EAST);
|
||||
|
||||
if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1))
|
||||
{
|
||||
if (flag2 && !flag3)
|
||||
{
|
||||
f = 0.0F;
|
||||
}
|
||||
else if (!flag2 && flag3)
|
||||
{
|
||||
f1 = 1.0F;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
f = 0.0F;
|
||||
f1 = 1.0F;
|
||||
}
|
||||
|
||||
if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1))
|
||||
{
|
||||
if (flag && !flag1)
|
||||
{
|
||||
f2 = 0.0F;
|
||||
}
|
||||
else if (!flag && flag1)
|
||||
{
|
||||
f3 = 1.0F;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
f2 = 0.0F;
|
||||
f3 = 1.0F;
|
||||
}
|
||||
|
||||
this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
|
||||
}
|
||||
|
||||
public IIcon getSideTextureIndex ()
|
||||
{
|
||||
return this.theIcon;
|
||||
}
|
||||
|
||||
public final boolean canThisPaneConnectToThisBlock (Block b)
|
||||
{
|
||||
return b.isOpaqueCube() || b == (Block) this || b == Blocks.glass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister par1IconRegister)
|
||||
{
|
||||
super.registerBlockIcons(par1IconRegister);
|
||||
this.theIcon = par1IconRegister.registerIcon("tinker:glass/" + folder + "/glass_side");
|
||||
}
|
||||
|
||||
public boolean canPaneConnectTo (IBlockAccess access, int x, int y, int z, ForgeDirection dir)
|
||||
{
|
||||
return canThisPaneConnectToThisBlock(access.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ))
|
||||
|| access.isSideSolid(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
// if(par5 == 0 || par5 == 1){
|
||||
// return par1IBlockAccess.getBlock(par2, par3, par4) != this.blockID;
|
||||
// }else{
|
||||
// return true;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
public class GlassPaneStained extends PaneBase
|
||||
{
|
||||
static String blockTextures[] = { "white", "orange", "magenta", "lightblue", "yellow", "lime", "pink", "gray", "lightgray", "cyan", "purple", "blue", "brown", "green", "red", "black" };
|
||||
|
||||
public GlassPaneStained()
|
||||
{
|
||||
super(Material.glass, "glass/", assembleBlockTextures());
|
||||
// TODO setHardness
|
||||
this.setHardness(0.3F);
|
||||
this.stepSound = soundTypeGlass;
|
||||
this.setBlockName("tconstruct.glasspanestained");
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
private static String[] assembleBlockTextures ()
|
||||
{
|
||||
String[] textures = new String[blockTextures.length];
|
||||
for (int i = 0; i < blockTextures.length; i++)
|
||||
{
|
||||
textures[i] = "stainedglass_" + blockTextures[i];
|
||||
}
|
||||
return textures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GlueBlock extends TConstructBlock
|
||||
{
|
||||
|
||||
public GlueBlock()
|
||||
{
|
||||
super(Material.ground, 4.0f, new String[] { "glue" });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
entity.motionX *= 0.1;
|
||||
entity.motionZ *= 0.1;
|
||||
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
EntityLivingBase living = (EntityLivingBase) entity;
|
||||
// Well you'd feel ill too standing on glue...
|
||||
living.addPotionEffect(new PotionEffect(Potion.hunger.getId(), 20, 4));
|
||||
|
||||
// Glue is sticky stuff
|
||||
living.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 30, 4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
return Blocks.soul_sand.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.BlockFluidFinite;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class GlueFluid extends BlockFluidFinite
|
||||
{
|
||||
|
||||
IIcon stillIcon;
|
||||
IIcon flowIcon;
|
||||
|
||||
public GlueFluid(Fluid fluid, Material material)
|
||||
{
|
||||
super(fluid, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
stillIcon = iconRegister.registerIcon("tinker:liquid_glue");
|
||||
flowIcon = iconRegister.registerIcon("tinker:liquid_glue_flow");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return stillIcon;
|
||||
return flowIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
entity.motionX *= 0.1;
|
||||
entity.motionZ *= 0.1;
|
||||
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
EntityLivingBase living = (EntityLivingBase) entity;
|
||||
// Well you'd feel ill too standing in glue...
|
||||
living.addPotionEffect(new PotionEffect(Potion.hunger.getId(), 20, 4));
|
||||
|
||||
// Glue is sticky stuff
|
||||
living.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 30, 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import net.minecraft.block.BlockSand;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GravelOre extends BlockSand
|
||||
{
|
||||
public String[] textureNames = new String[] { "iron", "gold", "copper", "tin", "aluminum", "cobalt" };
|
||||
public IIcon[] icons;
|
||||
|
||||
public GravelOre()
|
||||
{
|
||||
//super(Material.craftedSnow);
|
||||
//this.blockMaterial = Material.craftedSnow;
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setStepSound(soundTypeGravel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:ore_" + textureNames[i] + "_gravel");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 5)
|
||||
return 10f;
|
||||
else
|
||||
return 3f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
/*if (meta == 1)
|
||||
return 0;*/
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
/*if (par1 == 1)
|
||||
return Item.goldNugget.itemID;*/
|
||||
return Item.getItemFromBlock(TRepo.oreGravel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 6; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,326 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.LavaTankLogic;
|
||||
import tconstruct.client.block.TankRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class LavaTankBlock extends BlockContainer
|
||||
{
|
||||
public IIcon[] icons;
|
||||
String texturePrefix = "";
|
||||
|
||||
public LavaTankBlock()
|
||||
{
|
||||
super(Material.rock);
|
||||
setHardness(3F);
|
||||
setResistance(20F);
|
||||
setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setBlockName("TConstruct.LavaTank");
|
||||
setStepSound(Block.soundTypeGrass);
|
||||
}
|
||||
|
||||
public LavaTankBlock(String prefix)
|
||||
{
|
||||
this();
|
||||
texturePrefix = prefix;
|
||||
}
|
||||
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "lavatank_side", "lavatank_top", "searedgague_top", "searedgague_side", "searedgague_bottom", "searedwindow_top", "searedwindow_side", "searedwindow_bottom" };
|
||||
|
||||
if (!texturePrefix.equals(""))
|
||||
for (int i = 0; i < textureNames.length; i++)
|
||||
textureNames[i] = texturePrefix + "_" + textureNames[i];
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister IIconRegister)
|
||||
{
|
||||
String[] textureNames = getTextureNames();
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = IIconRegister.registerIcon("tinker:" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
// if (side == 0 && world.getBlockMetadata(x, y, z) == 0)
|
||||
// return super.shouldSideBeRendered(world, x, y, z, side);
|
||||
Block bID = world.getBlock(x, y, z);
|
||||
return bID == this ? false : super.shouldSideBeRendered(world, x, y, z, side);
|
||||
// return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
TileEntity logic = world.getTileEntity(x, y, z);
|
||||
if (logic != null && logic instanceof LavaTankLogic)
|
||||
return ((LavaTankLogic) logic).getBrightness();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public int getRenderBlockPass() { return 1; }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return TankRender.tankModelID;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta >= 3)
|
||||
meta = 0;
|
||||
if (meta == 0)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[meta * 3 + getTextureIndex(side) - 1];
|
||||
}
|
||||
}
|
||||
|
||||
public int getTextureIndex (int side)
|
||||
{
|
||||
if (side == 0)
|
||||
return 2;
|
||||
if (side == 1)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
return new LavaTankLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
ItemStack current = entityplayer.inventory.getCurrentItem();
|
||||
if (current != null)
|
||||
{
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current);
|
||||
LavaTankLogic logic = (LavaTankLogic) world.getTileEntity(i, j, k);
|
||||
if (liquid != null)
|
||||
{
|
||||
int amount = logic.fill(ForgeDirection.UNKNOWN, liquid, false);
|
||||
if (amount == liquid.amount)
|
||||
{
|
||||
logic.fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||
if (!entityplayer.capabilities.isCreativeMode)
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, consumeItem(current));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
else if (FluidContainerRegistry.isBucket(current))
|
||||
{
|
||||
FluidTankInfo[] tanks = logic.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
FluidStack fillFluid = tanks[0].fluid;// getFluid();
|
||||
ItemStack fillStack = FluidContainerRegistry.fillFluidContainer(fillFluid, current);
|
||||
if (fillStack != null)
|
||||
{
|
||||
logic.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.getFluidForFilledItem(fillStack).amount, true);
|
||||
if (!entityplayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (current.stackSize == 1)
|
||||
{
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, fillStack);
|
||||
}
|
||||
else
|
||||
{
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, consumeItem(current));
|
||||
|
||||
if (!entityplayer.inventory.addItemStackToInventory(fillStack))
|
||||
{
|
||||
entityplayer.dropPlayerItemWithRandomChoice(fillStack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack consumeItem (ItemStack stack)
|
||||
{
|
||||
if (stack.stackSize == 1)
|
||||
{
|
||||
if (stack.getItem().hasContainerItem())
|
||||
return stack.getItem().getContainerItem(stack);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.splitStack(1);
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int test)
|
||||
{
|
||||
return createTileEntity(world, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 3; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
/* Data */
|
||||
@Override
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
/* Updates */
|
||||
public void onNeighborBlockChange (World world, int x, int y, int z, Block nBlockID)
|
||||
{
|
||||
TileEntity logic = world.getTileEntity(x, y, z);
|
||||
if (logic instanceof IServantLogic)
|
||||
{
|
||||
((IServantLogic) logic).notifyMasterOfChange();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer (World world, EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
player.addExhaustion(0.025F);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
ItemStack stack = new ItemStack(this, 1, meta);
|
||||
LavaTankLogic logic = (LavaTankLogic) world.getTileEntity(x, y, z);
|
||||
FluidStack liquid = logic.tank.getFluid();
|
||||
if (liquid != null)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
NBTTagCompound liquidTag = new NBTTagCompound();
|
||||
liquid.writeToNBT(liquidTag);
|
||||
tag.setTag("Fluid", liquidTag);
|
||||
stack.setTagCompound(tag);
|
||||
}
|
||||
if (!player.capabilities.isCreativeMode || player.isSneaking())
|
||||
dropTankBlock(world, x, y, z, stack);
|
||||
|
||||
return world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
protected void dropTankBlock (World world, int x, int y, int z, ItemStack stack)
|
||||
{
|
||||
if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops"))
|
||||
{
|
||||
float f = 0.7F;
|
||||
double d0 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d1 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
double d2 = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(world, (double) x + d0, (double) y + d1, (double) z + d2, stack);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock (World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound liquidTag = stack.getTagCompound().getCompoundTag("Fluid");
|
||||
if (liquidTag != null)
|
||||
{
|
||||
FluidStack liquid = FluidStack.loadFluidStackFromNBT(liquidTag);
|
||||
LavaTankLogic logic = (LavaTankLogic) world.getTileEntity(x, y, z);
|
||||
logic.tank.setFluid(liquid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.BlockFluidFinite;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
public class LiquidMetalFinite extends BlockFluidFinite
|
||||
{
|
||||
String texture;
|
||||
public IIcon stillIcon;
|
||||
public IIcon flowIcon;
|
||||
|
||||
public LiquidMetalFinite(Fluid fluid, String texture)
|
||||
{
|
||||
super(fluid, TRepo.liquidMetal);
|
||||
this.texture = texture;
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
stillIcon = iconRegister.registerIcon("tinker:" + texture);
|
||||
flowIcon = iconRegister.registerIcon("tinker:" + texture + "_flow");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return stillIcon;
|
||||
return flowIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World par1World, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
entity.motionX *= 0.4D;
|
||||
entity.motionZ *= 0.4D;
|
||||
}
|
||||
if (!(entity instanceof EntityItem) && !entity.isImmuneToFire())
|
||||
{
|
||||
entity.attackEntityFrom(DamageSource.lava, 4.0F);
|
||||
entity.setFire(15);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockWood;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MeatBlock extends BlockWood
|
||||
{
|
||||
public IIcon[] icons;
|
||||
public String[] textureNames = new String[] { "ham_skin", "ham_bone" };
|
||||
|
||||
public MeatBlock()
|
||||
{
|
||||
this.setHardness(1.0F);
|
||||
this.setStepSound(Block.soundTypeWood);
|
||||
// setBurnProperties(this.blockID, 5, 20);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int metadata)
|
||||
{
|
||||
int tex = (metadata % 4) * 2;
|
||||
int orientation = metadata / 4;
|
||||
|
||||
switch (orientation)
|
||||
// Ends of logs
|
||||
{
|
||||
case 0:
|
||||
if (side == 0 || side == 1)
|
||||
return icons[tex + 1];
|
||||
break;
|
||||
case 1:
|
||||
if (side == 4 || side == 5)
|
||||
return icons[tex + 1];
|
||||
break;
|
||||
case 2:
|
||||
if (side == 2 || side == 3)
|
||||
return icons[tex + 1];
|
||||
break;
|
||||
}
|
||||
|
||||
return icons[tex];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped (int par1, Random par2Random, int par3)
|
||||
{
|
||||
return new ItemStack(this).getItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* ejects contained items into the world, and notifies neighbours of an
|
||||
* update, as appropriate
|
||||
*/
|
||||
public void breakBlock (World par1World, int par2, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
byte b0 = 4;
|
||||
int j1 = b0 + 1;
|
||||
|
||||
if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1))
|
||||
{
|
||||
for (int k1 = -b0; k1 <= b0; ++k1)
|
||||
{
|
||||
for (int l1 = -b0; l1 <= b0; ++l1)
|
||||
{
|
||||
for (int i2 = -b0; i2 <= b0; ++i2)
|
||||
{
|
||||
Block j2 = par1World.getBlock(par2 + k1, par3 + l1, par4 + i2);
|
||||
|
||||
if (j2 != null)
|
||||
{
|
||||
j2.beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z,
|
||||
* side, hitX, hitY, hitZ, block metadata
|
||||
*/
|
||||
@Override
|
||||
public int onBlockPlaced (World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
|
||||
{
|
||||
int j1 = par9 & 3;
|
||||
byte b0 = 0;
|
||||
|
||||
switch (par5)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
b0 = 0;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
b0 = 8;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
return j1 | b0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the damage on the item the block drops. Used in cloth and
|
||||
* wood.
|
||||
*/
|
||||
@Override
|
||||
public int damageDropped (int par1)
|
||||
{
|
||||
return par1 & 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a number between 0 and 3
|
||||
*/
|
||||
public static int limitToValidMetadata (int par0)
|
||||
{
|
||||
return par0 & 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack createStackedBlock (int par1)
|
||||
{
|
||||
return new ItemStack(this, 1, limitToValidMetadata(par1));
|
||||
}
|
||||
|
||||
public boolean isBlockReplaceable (World world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* public void onBlockHarvested (World world, int x, int y, int z, int meta,
|
||||
* EntityPlayer player) { if (meta % 4 == 1) { if (world.difficultySetting >
|
||||
* 2) world.createExplosion(null, x, y, z, 1.75f, false); else
|
||||
* world.createExplosion(null, x, y, z, 2f, false); } }
|
||||
*/
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks (Item b, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int i = 0; i < icons.length / 2; i++)
|
||||
par3List.add(new ItemStack(b, 1, i));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean canSustainLeaves (World world, int x, int y, int z)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isWood (World world, int x, int y, int z)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
public boolean isBeaconBase (World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MetalOre extends TConstructBlock
|
||||
{
|
||||
public MetalOre(Material material, float hardness, String[] tex)
|
||||
{
|
||||
super(material, hardness, tex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta <= 2)
|
||||
return 10f;
|
||||
else
|
||||
return 3f;
|
||||
// return this.blockHardness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 1; iter < 6; iter++)
|
||||
{
|
||||
list.add(new ItemStack(b, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MultiBrick extends TConstructBlock
|
||||
{
|
||||
static String blockTextures[] = { "brick_obsidian", "brick_sandstone", "brick_netherrack", "brick_stone_refined", "brick_iron", "brick_gold", "brick_lapis", "brick_diamond", "brick_redstone",
|
||||
"brick_bone", "brick_slime", "brick_blueslime", "brick_endstone", "brick_obsidian_ingot" };
|
||||
|
||||
public MultiBrick()
|
||||
{
|
||||
super(Material.rock, 3f, blockTextures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Blocks.obsidian.getBlockHardness(world, x, y, z);
|
||||
case 1:
|
||||
return Blocks.sandstone.getBlockHardness(world, x, y, z);
|
||||
case 2:
|
||||
return Blocks.netherrack.getBlockHardness(world, x, y, z);
|
||||
case 3:
|
||||
return Blocks.stone.getBlockHardness(world, x, y, z);
|
||||
case 4:
|
||||
return Blocks.iron_block.getBlockHardness(world, x, y, z);
|
||||
case 5:
|
||||
return Blocks.gold_block.getBlockHardness(world, x, y, z);
|
||||
case 6:
|
||||
return Blocks.lapis_block.getBlockHardness(world, x, y, z);
|
||||
case 7:
|
||||
return Blocks.diamond_block.getBlockHardness(world, x, y, z);
|
||||
case 8:
|
||||
return Blocks.redstone_block.getBlockHardness(world, x, y, z);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Blocks.end_stone.getBlockHardness(world, x, y, z);
|
||||
case 13:
|
||||
return Blocks.obsidian.getBlockHardness(world, x, y, z);
|
||||
default:
|
||||
return blockHardness;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 1:
|
||||
return Blocks.sandstone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 2:
|
||||
return Blocks.netherrack.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 3:
|
||||
return Blocks.stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 4:
|
||||
return Blocks.iron_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 5:
|
||||
return Blocks.gold_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 6:
|
||||
return Blocks.lapis_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 7:
|
||||
return Blocks.diamond_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 8:
|
||||
return Blocks.redstone_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Blocks.end_stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 13:
|
||||
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
default:
|
||||
return getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
{
|
||||
if (entity.motionY < 0)
|
||||
entity.motionY *= -1.2F;
|
||||
entity.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO getCollisionBoundingBoxFromPool
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D);
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public int getRenderType () { return BrickRender.model; }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
if (world.getBlockMetadata(x, y, z) == 8)
|
||||
return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MultiBrickFancy extends TConstructBlock
|
||||
{
|
||||
static String blockTextures[] = { "fancybrick_obsidian", "fancybrick_sandstone", "fancybrick_netherrack", "fancybrick_stone_refined", "fancybrick_iron", "fancybrick_gold", "fancybrick_lapis",
|
||||
"fancybrick_diamond", "fancybrick_redstone", "fancybrick_bone", "fancybrick_slime", "fancybrick_blueslime", "fancybrick_endstone", "fancybrick_obsidian_ingot", "fancybrick_stone",
|
||||
"road_stone" };
|
||||
|
||||
public MultiBrickFancy()
|
||||
{
|
||||
super(Material.rock, 3f, blockTextures);
|
||||
}
|
||||
|
||||
// TODO getBlockHardness
|
||||
@Override
|
||||
public float getBlockHardness (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Blocks.obsidian.getBlockHardness(world, x, y, z);
|
||||
case 1:
|
||||
return Blocks.sandstone.getBlockHardness(world, x, y, z);
|
||||
case 2:
|
||||
return Blocks.netherrack.getBlockHardness(world, x, y, z);
|
||||
case 4:
|
||||
return Blocks.iron_block.getBlockHardness(world, x, y, z);
|
||||
case 5:
|
||||
return Blocks.gold_block.getBlockHardness(world, x, y, z);
|
||||
case 6:
|
||||
return Blocks.lapis_block.getBlockHardness(world, x, y, z);
|
||||
case 7:
|
||||
return Blocks.diamond_block.getBlockHardness(world, x, y, z);
|
||||
case 8:
|
||||
return Blocks.redstone_block.getBlockHardness(world, x, y, z);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Blocks.end_stone.getBlockHardness(world, x, y, z);
|
||||
case 13:
|
||||
return Blocks.obsidian.getBlockHardness(world, x, y, z);
|
||||
case 3:
|
||||
case 14:
|
||||
case 15:
|
||||
return Blocks.stone.getBlockHardness(world, x, y, z);
|
||||
default:
|
||||
return blockHardness;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance (Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 1:
|
||||
return Blocks.sandstone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 2:
|
||||
return Blocks.netherrack.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 4:
|
||||
return Blocks.iron_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 5:
|
||||
return Blocks.gold_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 6:
|
||||
return Blocks.lapis_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 7:
|
||||
return Blocks.diamond_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 8:
|
||||
return Blocks.redstone_block.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 9:
|
||||
return 1.0F;
|
||||
case 10:
|
||||
return 1.5F;
|
||||
case 11:
|
||||
return 1.5F;
|
||||
case 12:
|
||||
return Blocks.end_stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 13:
|
||||
return Blocks.obsidian.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
case 3:
|
||||
case 14:
|
||||
case 15:
|
||||
return Blocks.stone.getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
default:
|
||||
return getExplosionResistance(entity, world, meta, meta, meta, explosionZ, explosionZ, explosionZ);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO onEntityCollidedWithBlock
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
{
|
||||
if (entity.motionY < 0)
|
||||
entity.motionY *= -1.2F;
|
||||
entity.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 10 || meta == 11)
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.625D, (double) z + 1.0D);
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public int getRenderType () { return BrickRender.model; }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int isProvidingWeakPower (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
if (world.getBlockMetadata(x, y, z) == 8)
|
||||
return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,336 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.client.block.OreberryRender;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class OreberryBush extends BlockLeavesBase implements IPlantable
|
||||
{
|
||||
Random random;
|
||||
public IIcon[] fastIcons;
|
||||
public IIcon[] fancyIcons;
|
||||
public String[] textureNames;
|
||||
public String[] oreTypes;
|
||||
public int itemMeat;
|
||||
private int subitems;
|
||||
|
||||
public OreberryBush(String[] textureNames, int meta, int sub, String[] oreTypes)
|
||||
{
|
||||
super(Material.leaves, false);
|
||||
this.textureNames = textureNames;
|
||||
this.itemMeat = meta;
|
||||
this.subitems = sub;
|
||||
this.oreTypes = oreTypes;
|
||||
this.setTickRandomly(true);
|
||||
random = new Random();
|
||||
this.setHardness(0.3F);
|
||||
this.setStepSound(Block.soundTypeMetal);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
/* Berries show up at meta 12-15 */
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.fastIcons = new IIcon[textureNames.length];
|
||||
this.fancyIcons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.fastIcons.length; i++)
|
||||
{
|
||||
if (textureNames[i] != "")
|
||||
{
|
||||
this.fastIcons[i] = iconRegister.registerIcon("tinker:crops/" + textureNames[i] + "_fast");
|
||||
this.fancyIcons[i] = iconRegister.registerIcon("tinker:crops/" + textureNames[i] + "_fancy");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon (int side, int metadata)
|
||||
{
|
||||
if (field_150121_P)
|
||||
{
|
||||
if (metadata < 12)
|
||||
{
|
||||
return fancyIcons[metadata % 4];
|
||||
}
|
||||
else
|
||||
{
|
||||
return fancyIcons[metadata % 4 + 4];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (metadata < 12)
|
||||
{
|
||||
return fastIcons[metadata % 4];
|
||||
}
|
||||
else
|
||||
{
|
||||
return fastIcons[metadata % 4 + 4];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Bushes are stored by size then type */
|
||||
@Override
|
||||
public int damageDropped (int metadata)
|
||||
{
|
||||
return metadata % 4;
|
||||
}
|
||||
|
||||
/* The following methods define a berry bush's size depending on metadata */
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int l = world.getBlockMetadata(x, y, z);
|
||||
if (l < 4)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D);
|
||||
}
|
||||
else if (l < 8)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox(x + 0.0625, y, z + 0.0625, (double) x + 0.9375D, (double) y + 0.9375D, (double) z + 0.9375D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
int l = world.getBlockMetadata(x, y, z);
|
||||
if (l < 4)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox((double) x + 0.25D, y, (double) z + 0.25D, (double) x + 0.75D, (double) y + 0.5D, (double) z + 0.75D);
|
||||
}
|
||||
else if (l < 8)
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox((double) x + 0.125D, y, (double) z + 0.125D, (double) x + 0.875D, (double) y + 0.75D, (double) z + 0.875D);
|
||||
}
|
||||
else
|
||||
{
|
||||
return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 1.0D, (double) z + 1.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess iblockaccess, int x, int y, int z)
|
||||
{
|
||||
int md = iblockaccess.getBlockMetadata(x, y, z);
|
||||
|
||||
float minX;
|
||||
float minY = 0F;
|
||||
float minZ;
|
||||
float maxX;
|
||||
float maxY;
|
||||
float maxZ;
|
||||
|
||||
if (md < 4)
|
||||
{
|
||||
minX = minZ = 0.25F;
|
||||
maxX = maxZ = 0.75F;
|
||||
maxY = 0.5F;
|
||||
}
|
||||
else
|
||||
|
||||
if (md < 8)
|
||||
{
|
||||
minX = minZ = 0.125F;
|
||||
maxX = maxZ = 0.875F;
|
||||
maxY = 0.75F;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
minX = minZ = 0.0F;
|
||||
maxX = maxZ = 1.0F;
|
||||
maxY = 1.0F;
|
||||
}
|
||||
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
/* Left-click harvests berries */
|
||||
@Override
|
||||
public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta >= 12)
|
||||
{
|
||||
world.setBlock(x, y, z, this, meta - 4, 3);
|
||||
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TRepo.oreBerries, 1, meta % 4 + itemMeat));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Right-click harvests berries */
|
||||
@Override
|
||||
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
/*if (world.isRemote)
|
||||
return false;*/
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta >= 12)
|
||||
{
|
||||
if (world.isRemote)
|
||||
return true;
|
||||
|
||||
world.setBlock(x, y, z, this, meta - 4, 3);
|
||||
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TRepo.oreBerries, random.nextInt(3) + 1, meta % 4 + itemMeat));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Render logic */
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setGraphicsLevel (boolean flag)
|
||||
{
|
||||
field_150121_P = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return OreberryRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess iblockaccess, int x, int y, int z, int meta)
|
||||
{
|
||||
if (meta > 7 || field_150121_P)
|
||||
{
|
||||
return super.shouldSideBeRendered(iblockaccess, x, y, z, meta);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Bush growth */
|
||||
|
||||
@Override
|
||||
public void updateTick (World world, int x, int y, int z, Random random1)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (random1.nextInt(20) == 0)// && world.getBlockLightValue(x, y, z) <= 8)
|
||||
{
|
||||
if (world.getFullBlockLightValue(x, y, z) < 10)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta < 12)
|
||||
{
|
||||
world.setBlock(x, y, z, this, meta + 4, 3);
|
||||
}
|
||||
}
|
||||
/*else if (meta < 8)
|
||||
{
|
||||
world.setBlock(x, y, z, blockID, meta + 4, 3);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canSustainPlant (World world, int x, int y, int z, ForgeDirection direction, IPlantable plant)
|
||||
{
|
||||
if (plant instanceof OreberryBush)
|
||||
return (world.getBlockMetadata(x, y, z) > 7);
|
||||
return super.canSustainPlant(world, x, y, z, direction, plant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt (World world, int x, int y, int z)
|
||||
{
|
||||
if (world.getFullBlockLightValue(x, y, z) < 13)
|
||||
return super.canPlaceBlockAt(world, x, y, z);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Resistance to fire */
|
||||
|
||||
/**
|
||||
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks (Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (int var4 = 8; var4 < 8 + subitems; ++var4)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, var4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPlantType getPlantType (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return EnumPlantType.Cave;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getPlant (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlantMetadata (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return world.getBlockMetadata(x, y, z) - 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (!(entity instanceof EntityItem))
|
||||
entity.attackEntityFrom(DamageSource.cactus, 1);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
public class OreberryBushEssence extends OreberryBush implements IPlantable
|
||||
{
|
||||
public OreberryBushEssence(String[] textureNames, int meta, int sub, String[] oreTypes)
|
||||
{
|
||||
super(textureNames, meta, sub, oreTypes);
|
||||
}
|
||||
|
||||
/* Bush growth */
|
||||
|
||||
@Override
|
||||
public void updateTick (World world, int x, int y, int z, Random random1)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (random1.nextInt(20) == 0)// && world.getBlockLightValue(x, y, z) <=
|
||||
// 8)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (world.getFullBlockLightValue(x, y, z) < 10 || meta % 4 == 1)
|
||||
{
|
||||
if (meta < 12)
|
||||
{
|
||||
world.setBlock(x, y, z, (Block) this, meta + 4, 3);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* else if (meta < 8) { world.setBlock(x, y, z, blockID, meta + 4,
|
||||
* 3); }
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt (World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
/*
|
||||
* if (world.getFullBlockLightValue(x, y, z) < 13) return
|
||||
* super.canPlaceBlockAt(world, x, y, z); return false;
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -1,200 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPane;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.client.block.PaneRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PaneBase extends Block
|
||||
{
|
||||
public String[] textureNames;
|
||||
public String folder;
|
||||
public IIcon[] icons;
|
||||
public IIcon[] sideIcons;
|
||||
|
||||
public PaneBase(Material material, String folder, String[] blockTextures)
|
||||
{
|
||||
super(material);
|
||||
textureNames = blockTextures;
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
public final boolean canPaneConnectToBlock (Block p_150098_1_)
|
||||
{
|
||||
return p_150098_1_.func_149730_j() || p_150098_1_ == this || p_150098_1_ == Blocks.glass || p_150098_1_ == Blocks.stained_glass || p_150098_1_ == Blocks.stained_glass_pane
|
||||
|| p_150098_1_ instanceof BlockPane;
|
||||
}
|
||||
|
||||
public boolean canConnectTo (IBlockAccess world, int x, int y, int z, ForgeDirection dir)
|
||||
{
|
||||
return canPaneConnectToBlock(world.getBlock(x, y, z)) || world.isSideSolid(x, y, z, dir.getOpposite(), false);
|
||||
}
|
||||
|
||||
public IIcon getSideTextureIndex (int meta)
|
||||
{
|
||||
return sideIcons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.icons = new IIcon[textureNames.length];
|
||||
this.sideIcons = new IIcon[textureNames.length];
|
||||
|
||||
for (int i = 0; i < this.icons.length; ++i)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]);
|
||||
this.sideIcons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i] + "_side");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < textureNames.length; iter++)
|
||||
{
|
||||
list.add(new ItemStack(b, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return PaneRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess iblockaccess, int i, int j, int k, int l)
|
||||
{
|
||||
Block b = iblockaccess.getBlock(i, j, k);
|
||||
if (b instanceof PaneBase || b instanceof BlockPane)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.shouldSideBeRendered(iblockaccess, i, j, k, l);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity)
|
||||
{
|
||||
boolean south = canConnectTo(world, x, y, z - 1, ForgeDirection.NORTH);
|
||||
boolean north = canConnectTo(world, x, y, z + 1, ForgeDirection.SOUTH);
|
||||
boolean east = canConnectTo(world, x - 1, y, z, ForgeDirection.EAST);
|
||||
boolean west = canConnectTo(world, x + 1, y, z, ForgeDirection.WEST);
|
||||
if (east && west || !east && !west && !south && !north)
|
||||
{
|
||||
setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
else if (east && !west)
|
||||
{
|
||||
setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
else if (!east && west)
|
||||
{
|
||||
setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
if (south && north || !east && !west && !south && !north)
|
||||
{
|
||||
setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
else if (south && !north)
|
||||
{
|
||||
setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
else if (!south && north)
|
||||
{
|
||||
setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
|
||||
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsForItemRender ()
|
||||
{
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState (IBlockAccess iblockaccess, int i, int j, int k)
|
||||
{
|
||||
float f = 0.4375F;
|
||||
float f1 = 0.5625F;
|
||||
float f2 = 0.4375F;
|
||||
float f3 = 0.5625F;
|
||||
boolean flag = canConnectTo(iblockaccess, i, j, k - 1, ForgeDirection.NORTH);
|
||||
boolean flag1 = canConnectTo(iblockaccess, i, j, k + 1, ForgeDirection.SOUTH);
|
||||
boolean flag2 = canConnectTo(iblockaccess, i - 1, j, k, ForgeDirection.EAST);
|
||||
boolean flag3 = canConnectTo(iblockaccess, i + 1, j, k, ForgeDirection.WEST);
|
||||
if (flag2 && flag3 || !flag2 && !flag3 && !flag && !flag1)
|
||||
{
|
||||
f = 0.0F;
|
||||
f1 = 1.0F;
|
||||
}
|
||||
else if (flag2 && !flag3)
|
||||
{
|
||||
f = 0.0F;
|
||||
}
|
||||
else if (!flag2 && flag3)
|
||||
{
|
||||
f1 = 1.0F;
|
||||
}
|
||||
if (flag && flag1 || !flag2 && !flag3 && !flag && !flag1)
|
||||
{
|
||||
f2 = 0.0F;
|
||||
f3 = 1.0F;
|
||||
}
|
||||
else if (flag && !flag1)
|
||||
{
|
||||
f2 = 0.0F;
|
||||
}
|
||||
else if (!flag && flag1)
|
||||
{
|
||||
f3 = 1.0F;
|
||||
}
|
||||
setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,398 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.CastingBasinLogic;
|
||||
import tconstruct.blocks.logic.CastingTableLogic;
|
||||
import tconstruct.blocks.logic.FaucetLogic;
|
||||
import tconstruct.client.block.SearedRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.event.SmelteryEvent;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SearedBlock extends InventoryBlock
|
||||
{
|
||||
|
||||
public SearedBlock()
|
||||
{
|
||||
super(Material.rock);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setHardness(3F);
|
||||
setResistance(20F);
|
||||
setStepSound(soundTypeMetal);
|
||||
}
|
||||
|
||||
public SearedBlock(String texture)
|
||||
{
|
||||
this();
|
||||
this.texturePrefix = texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return new CastingTableLogic();
|
||||
case 1:
|
||||
return new FaucetLogic();
|
||||
case 2:
|
||||
return new CastingBasinLogic();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
/* 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 == 0)
|
||||
{
|
||||
return activateCastingTable(world, x, y, z, player);
|
||||
}
|
||||
if (md == 2)
|
||||
{
|
||||
return activateCastingBasin(world, x, y, z, player);
|
||||
}
|
||||
else if (md == 1)
|
||||
{
|
||||
if (player.isSneaking())
|
||||
return false;
|
||||
|
||||
FaucetLogic logic = (FaucetLogic) world.getTileEntity(x, y, z);
|
||||
logic.setActive(true);
|
||||
return true;
|
||||
}
|
||||
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)
|
||||
{
|
||||
CastingTableLogic logic = (CastingTableLogic) world.getTileEntity(x, y, z);
|
||||
if (logic.liquid != null)
|
||||
return true;
|
||||
|
||||
if (!logic.isStackInSlot(0) && !logic.isStackInSlot(1))
|
||||
{
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
logic.setInventorySlotContents(0, stack);
|
||||
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemInsertedIntoCasting(logic, x, y, z, stack, player));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logic.isStackInSlot(1))
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemRemovedFromCasting(logic, x, y, z, logic.getStackInSlot(1), player));
|
||||
ItemStack stack = logic.decrStackSize(1, 1);
|
||||
if (stack != null)
|
||||
addItemToInventory(player, world, x, y, z, stack);
|
||||
}
|
||||
else if (logic.isStackInSlot(0))
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemRemovedFromCasting(logic, x, y, z, logic.getStackInSlot(0), player));
|
||||
ItemStack stack = logic.decrStackSize(0, 1);
|
||||
if (stack != null)
|
||||
addItemToInventory(player, world, x, y, z, stack);
|
||||
}
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean activateCastingBasin (World world, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
CastingBasinLogic logic = (CastingBasinLogic) world.getTileEntity(x, y, z);
|
||||
if (logic.liquid != null)
|
||||
return true;
|
||||
|
||||
if (!logic.isStackInSlot(0) && !logic.isStackInSlot(1))
|
||||
{
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
logic.setInventorySlotContents(0, stack);
|
||||
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemInsertedIntoCasting(logic, x, y, z, stack, player));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logic.isStackInSlot(1))
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemRemovedFromCasting(logic, x, y, z, logic.getStackInSlot(1), player));
|
||||
ItemStack stack = logic.decrStackSize(1, 1);
|
||||
if (stack != null)
|
||||
addItemToInventory(player, world, x, y, z, stack);
|
||||
}
|
||||
else if (logic.isStackInSlot(0))
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new SmelteryEvent.ItemRemovedFromCasting(logic, x, y, z, logic.getStackInSlot(0), player));
|
||||
ItemStack stack = logic.decrStackSize(0, 1);
|
||||
if (stack != null)
|
||||
addItemToInventory(player, world, x, y, z, stack);
|
||||
}
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addItemToInventory (EntityPlayer player, World world, int x, int y, int z, ItemStack stack)
|
||||
{
|
||||
AbilityHelper.spawnItemAtPlayer(player, stack);
|
||||
/*if (!world.isRemote)
|
||||
{
|
||||
EntityItem entityitem = new EntityItem(world, (double) x + 0.5D, (double) y + 0.9325D, (double) z + 0.5D, stack);
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
entityitem.onCollideWithPlayer(player);
|
||||
}*/
|
||||
}
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return SearedRender.searedModel;
|
||||
}
|
||||
|
||||
String texturePrefix = "";
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "castingtable_top", "castingtable_side", "castingtable_bottom", "faucet", "blockcast_top", "blockcast_side", "blockcast_bottom" };
|
||||
|
||||
if (!texturePrefix.equals(""))
|
||||
for (int i = 0; i < textureNames.length; i++)
|
||||
textureNames[i] = texturePrefix + "_" + textureNames[i];
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
// TODO getIcon
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta == 0)
|
||||
return icons[getTextureIndex(side)];
|
||||
else if (meta == 2)
|
||||
return icons[getTextureIndex(side) + 4];
|
||||
else
|
||||
return icons[3];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item 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.getTileEntity(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 = world.getBlockMetadata(x, y, z);
|
||||
if (meta != 1)
|
||||
{
|
||||
return AxisAlignedBB.getAABBPool().getAABB(x, y, z, x + 1, y + 1, z + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
FaucetLogic logic = (FaucetLogic) world.getTileEntity(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 = 1.0F;
|
||||
break;
|
||||
case 5:
|
||||
xMax = 0.375F;
|
||||
xMin = 0F;
|
||||
break;
|
||||
}
|
||||
|
||||
return AxisAlignedBB.getAABBPool().getAABB((double) ((float) x + 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);
|
||||
}
|
||||
|
||||
/* Redstone */
|
||||
@Override
|
||||
public boolean canConnectRedstone (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
return world.getBlockMetadata(x, y, z) == 1;
|
||||
}
|
||||
|
||||
private boolean wasPowered = false;
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange (World world, int x, int y, int z, Block neighborBlockID)
|
||||
{
|
||||
if (world.getBlockMetadata(x, y, z) == 1)
|
||||
{
|
||||
boolean isPowered = world.isBlockIndirectlyGettingPowered(x, y, z);
|
||||
if (!wasPowered && isPowered)
|
||||
{
|
||||
FaucetLogic logic = (FaucetLogic) world.getTileEntity(x, y, z);
|
||||
logic.setActive(true);
|
||||
}
|
||||
wasPowered = isPowered;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return new CastingTableLogic();
|
||||
case 1:
|
||||
return new FaucetLogic();
|
||||
case 2:
|
||||
return new CastingBasinLogic();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SearedSlab extends SlabBase
|
||||
{
|
||||
public SearedSlab()
|
||||
{
|
||||
super(Material.rock);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setHardness(12F);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
meta = meta % 8;
|
||||
if (meta == 0)
|
||||
return TRepo.smeltery.getIcon(side, 2);
|
||||
if (meta <= 3)
|
||||
return TRepo.smeltery.getIcon(side, meta + 3);
|
||||
|
||||
return TRepo.smeltery.getIcon(side, meta + 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 8; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.world.WorldHelper;
|
||||
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.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.entity.item.ExplosivePrimed;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SlimeExplosive extends TConstructBlock
|
||||
{
|
||||
|
||||
public SlimeExplosive()
|
||||
{
|
||||
super(Material.tnt, 0f, getTextureNames());
|
||||
}
|
||||
|
||||
static String[] getTextureNames ()
|
||||
{
|
||||
String[] names = new String[6];
|
||||
String[] types = new String[] { "green", "blue" };
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
names[i * 3 + 0] = "sdx_bottom_" + types[i];
|
||||
names[i * 3 + 1] = "sdx_side_" + types[i];
|
||||
names[i * 3 + 2] = "sdx_top_" + types[i];
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return icons[(meta / 2) * 3 + getSideTextureIndex(side)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 2; iter++)
|
||||
{
|
||||
list.add(new ItemStack(b, 1, iter * 2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
super.onBlockAdded(par1World, par2, par3, par4);
|
||||
|
||||
if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
|
||||
{
|
||||
this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
|
||||
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, Block par5Block)
|
||||
{
|
||||
if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4))
|
||||
{
|
||||
this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
|
||||
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByExplosion (World par1World, int par2, int par3, int par4, Explosion par5Explosion)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
ExplosivePrimed entitytntprimed = new ExplosivePrimed(par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F),
|
||||
par5Explosion.getExplosivePlacedBy());
|
||||
entitytntprimed.fuse = par1World.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
|
||||
par1World.spawnEntityInWorld(entitytntprimed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByPlayer (World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
this.primeTnt(par1World, par2, par3, par4, par5, (EntityLivingBase) null);
|
||||
}
|
||||
|
||||
public void primeTnt (World par1World, int par2, int par3, int par4, int par5, EntityLivingBase par6EntityLivingBase)
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
{
|
||||
if ((par5 % 2) == 1)
|
||||
{
|
||||
ExplosivePrimed entitytntprimed = new ExplosivePrimed(par1World, (double) ((float) par2 + 0.5F), (double) ((float) par3 + 0.5F), (double) ((float) par4 + 0.5F), par6EntityLivingBase);
|
||||
par1World.spawnEntityInWorld(entitytntprimed);
|
||||
par1World.playSoundAtEntity(entitytntprimed, "random.fuse", 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (par5EntityPlayer.getCurrentEquippedItem() != null && par5EntityPlayer.getCurrentEquippedItem().getItem() == Items.flint_and_steel)
|
||||
{
|
||||
this.primeTnt(par1World, par2, par3, par4, 1, par5EntityPlayer);
|
||||
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
||||
par5EntityPlayer.getCurrentEquippedItem().damageItem(1, par5EntityPlayer);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World par1World, int par2, int par3, int par4, Entity par5Entity)
|
||||
{
|
||||
if (par5Entity instanceof EntityArrow && !par1World.isRemote)
|
||||
{
|
||||
EntityArrow entityarrow = (EntityArrow) par5Entity;
|
||||
|
||||
if (entityarrow.isBurning())
|
||||
{
|
||||
this.primeTnt(par1World, par2, par3, par4, 1, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null);
|
||||
WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropFromExplosion (Explosion par1Explosion)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import mantle.blocks.MantleBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.client.block.SlimePadRender;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SlimePad extends MantleBlock
|
||||
{
|
||||
|
||||
public SlimePad(Material par2Material)
|
||||
{
|
||||
super(par2Material);
|
||||
setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.625F, 0.875F);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (!world.isBlockIndirectlyGettingPowered(x, y, z))
|
||||
{
|
||||
double moveX = 0;
|
||||
double moveZ = 0;
|
||||
|
||||
double speed = 0.25;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
switch (meta % 8)
|
||||
{
|
||||
case 6:
|
||||
moveX += speed;
|
||||
break;
|
||||
case 7:
|
||||
moveX += speed;
|
||||
moveZ += speed;
|
||||
break;
|
||||
case 0:
|
||||
moveZ += speed;
|
||||
break;
|
||||
case 1:
|
||||
moveZ += speed;
|
||||
moveX -= speed;
|
||||
break;
|
||||
case 2:
|
||||
moveX -= speed;
|
||||
break;
|
||||
case 3:
|
||||
moveX -= speed;
|
||||
moveZ -= speed;
|
||||
break;
|
||||
case 4:
|
||||
moveZ -= speed;
|
||||
break;
|
||||
case 5:
|
||||
moveZ -= speed;
|
||||
moveX += speed;
|
||||
break;
|
||||
}
|
||||
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
entity.posY += 1;
|
||||
}
|
||||
entity.addVelocity(moveX, speed * 2, moveZ);
|
||||
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, this.stepSound.getStepResourcePath(), (this.stepSound.getVolume()) / 2.0F, this.stepSound.getPitch() * 0.65F);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBlockReplaceable (World world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack)
|
||||
{
|
||||
int face = MathHelper.floor_double((double) (entity.rotationYaw * 8.0F / 360.0F) + 0.5D) + (entity.isSneaking() ? 4 : 0) & 7;
|
||||
int meta = world.getBlockMetadata(x, y, z) & 8;
|
||||
world.setBlockMetadataWithNotify(x, y, z, face | meta, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return SlimePadRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
return TRepo.slimeGel.getIcon(side, 1);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getFluidIcon (int meta)
|
||||
{
|
||||
return TRepo.slimeChannel.getIcon(2, 0);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getNubIcon (int meta)
|
||||
{
|
||||
return TRepo.slimeGel.getIcon(0, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,322 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import mantle.blocks.abstracts.MultiServantLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
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;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.AdaptiveDrainLogic;
|
||||
import tconstruct.blocks.logic.AdaptiveSmelteryLogic;
|
||||
import tconstruct.blocks.logic.SmelteryDrainLogic;
|
||||
import tconstruct.blocks.logic.SmelteryLogic;
|
||||
import tconstruct.client.block.SmelteryRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SmelteryBlock extends InventoryBlock
|
||||
{
|
||||
Random rand;
|
||||
String texturePrefix = "";
|
||||
|
||||
public SmelteryBlock()
|
||||
{
|
||||
super(Material.rock);
|
||||
setHardness(3F);
|
||||
setResistance(20F);
|
||||
setStepSound(soundTypeMetal);
|
||||
rand = new Random();
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setBlockName("tconstruct.Smeltery");
|
||||
}
|
||||
|
||||
public SmelteryBlock(String prefix)
|
||||
{
|
||||
this();
|
||||
texturePrefix = prefix;
|
||||
}
|
||||
|
||||
/* Rendering */
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return PHConstruct.newSmeltery ? 0 : SmelteryRender.smelteryModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "smeltery_side", "smeltery_inactive", "smeltery_active", "drain_side", "drain_out", "drain_basin", "searedbrick", "searedstone", "searedcobble", "searedpaver",
|
||||
"searedbrickcracked", "searedroad", "searedbrickfancy", "searedbricksquare", "searedcreeper" };
|
||||
|
||||
if (!texturePrefix.equals(""))
|
||||
for (int i = 0; i < textureNames.length; i++)
|
||||
textureNames[i] = texturePrefix + "_" + textureNames[i];
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta < 2)
|
||||
{
|
||||
int sideTex = side == 3 ? 1 : 0;
|
||||
return icons[sideTex + meta * 3];
|
||||
}
|
||||
else if (meta == 2)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (meta == 11)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return icons[9];
|
||||
}
|
||||
|
||||
return icons[3 + meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity logic = world.getTileEntity(x, y, z);
|
||||
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 0) // Smeltery
|
||||
{
|
||||
if (side == direction)
|
||||
{
|
||||
if (isActive(world, x, y, z))
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
}
|
||||
if (meta == 1) // Drain
|
||||
{
|
||||
if (side == direction)
|
||||
return icons[5];
|
||||
else if (side / 2 == direction / 2)
|
||||
return icons[4];
|
||||
else
|
||||
return icons[3];
|
||||
}
|
||||
else if (meta == 2)
|
||||
{
|
||||
return icons[6];
|
||||
}
|
||||
else if (meta == 11)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return icons[9];
|
||||
}
|
||||
return icons[3 + meta];
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public int getRenderBlockPass() { return 1; }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped (Random random)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
// return -1;
|
||||
return TConstruct.proxy.smelteryGuiID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick (World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if (isActive(world, x, y, z))
|
||||
{
|
||||
TileEntity logic = world.getTileEntity(x, y, z);
|
||||
byte face = 0;
|
||||
if (logic instanceof IFacingLogic)
|
||||
face = ((IFacingLogic) logic).getRenderDirection();
|
||||
float f = (float) x + 0.5F;
|
||||
float f1 = (float) y + 0.5F + (random.nextFloat() * 6F) / 16F;
|
||||
float f2 = (float) z + 0.5F;
|
||||
float f3 = 0.52F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
switch (face)
|
||||
{
|
||||
case 4:
|
||||
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return !isActive(world, x, y, z) ? 0 : 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@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() || world.getBlockMetadata(x, y, z) != 0)
|
||||
return false;
|
||||
|
||||
Integer integer = getGui(world, x, y, z, player);
|
||||
if (integer == null || integer == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// world.markBlockForUpdate(x, y, z);
|
||||
player.openGui(getModInstance(), integer, world, x, y, z);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
if (PHConstruct.newSmeltery)
|
||||
return new AdaptiveSmelteryLogic();
|
||||
else
|
||||
return new SmelteryLogic();
|
||||
|
||||
case 1:
|
||||
if (PHConstruct.newSmeltery)
|
||||
return new AdaptiveDrainLogic();
|
||||
else
|
||||
return new SmelteryDrainLogic();
|
||||
case 3:
|
||||
return null; // Furnace
|
||||
}
|
||||
return new MultiServantLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack)
|
||||
{
|
||||
super.onBlockPlacedBy(world, x, y, z, entityliving, stack);
|
||||
if (world.getBlockMetadata(x, y, z) == 0 && !PHConstruct.newSmeltery)
|
||||
onBlockPlacedElsewhere(world, x, y, z, entityliving);
|
||||
}
|
||||
|
||||
public void onBlockPlacedElsewhere (World world, int x, int y, int z, EntityLivingBase entityliving)
|
||||
{
|
||||
SmelteryLogic logic = (SmelteryLogic) world.getTileEntity(x, y, z);
|
||||
logic.checkValidPlacement();
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public void breakBlock (World world, int x, int y, int z, int
|
||||
* par5, int par6) //Don't drop inventory { world.removeBlockTileEntity(x,
|
||||
* y, z); }
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 12; iter++)
|
||||
{
|
||||
if (iter != 3)
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
/* Updating */
|
||||
@Override
|
||||
public void onNeighborBlockChange (World world, int x, int y, int z, Block block)
|
||||
{
|
||||
//System.out.println("Neighbor changed");
|
||||
TileEntity logic = world.getTileEntity(x, y, z);
|
||||
if (logic instanceof IServantLogic)
|
||||
{
|
||||
((IServantLogic) logic).notifyMasterOfChange();
|
||||
}
|
||||
else if (logic instanceof IMasterLogic)
|
||||
{
|
||||
((IMasterLogic) logic).notifyChange(null, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock (World world, int x, int y, int z, Block blockID, int meta)
|
||||
{
|
||||
TileEntity logic = world.getTileEntity(x, y, z);
|
||||
if (logic instanceof IServantLogic)
|
||||
{
|
||||
((IServantLogic) logic).notifyMasterOfChange();
|
||||
}
|
||||
super.breakBlock(world, x, y, z, blockID, meta);
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EnumCreatureAttribute;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class SoilBlock extends TConstructBlock
|
||||
{
|
||||
static String[] soilTypes = new String[] { "slimesand", "grout", "slimesandblue", "graveyardsoil", "consecratedsoil", "slimedirt_blue", "nether_grout" };
|
||||
|
||||
public SoilBlock()
|
||||
{
|
||||
super(Material.ground, 3.0F, soilTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityWalking (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if (entity instanceof EntityLivingBase)
|
||||
{
|
||||
if (((EntityLivingBase) entity).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD)
|
||||
{
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 3)
|
||||
{
|
||||
((EntityLivingBase) entity).heal(1);
|
||||
}
|
||||
else if (metadata == 4)
|
||||
{
|
||||
((EntityLivingBase) entity).attackEntityFrom(DamageSource.magic, 1);
|
||||
((EntityLivingBase) entity).setFire(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta < 3)
|
||||
{
|
||||
entity.motionX *= 0.4;
|
||||
entity.motionZ *= 0.4;
|
||||
if (meta != 1 && entity instanceof EntityLivingBase)
|
||||
{
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.weakness.id, 1));
|
||||
((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Potion.jump.id, 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
return Blocks.soul_sand.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
}
|
||||
|
||||
/*
|
||||
* public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y,
|
||||
* int z) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); if
|
||||
* (world.getBlockMetadata(x, y, z) >= 3) { this.setBlockBounds(0.0F, 0.0F,
|
||||
* 0.0F, 1.0F, 0.875F, 1.0F); } }
|
||||
*/
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.ColorizerGrass;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SoilSlab extends SlabBase
|
||||
{
|
||||
public SoilSlab()
|
||||
{
|
||||
super(Material.ground);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.blockIcon = iconRegister.registerIcon("tinker:grass_top");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
switch (meta % 8)
|
||||
{
|
||||
case 0:
|
||||
return this.blockIcon;// Block.grass.getIcon(1, 0);
|
||||
case 1:
|
||||
return Blocks.dirt.getIcon(side, 0);
|
||||
case 2:
|
||||
return Blocks.mycelium.getIcon(1, 0);
|
||||
default:
|
||||
return TRepo.craftedSoil.getIcon(side, meta - 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 8; iter++)
|
||||
{
|
||||
list.add(new ItemStack(b, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBlockColor ()
|
||||
{
|
||||
double d0 = 0.5D;
|
||||
double d1 = 1.0D;
|
||||
return ColorizerGrass.getGrassColor(d0, d1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderColor (int par1)
|
||||
{
|
||||
// if (par1 % 8 == 0)
|
||||
return this.getBlockColor();
|
||||
// return 0xFFFFFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int colorMultiplier (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
int l = 0;
|
||||
int i1 = 0;
|
||||
int j1 = 0;
|
||||
|
||||
for (int k1 = -1; k1 <= 1; ++k1)
|
||||
{
|
||||
for (int l1 = -1; l1 <= 1; ++l1)
|
||||
{
|
||||
int i2 = world.getBiomeGenForCoords(x + l1, z + k1).getBiomeGrassColor(x, y, z);
|
||||
l += (i2 & 16711680) >> 16;
|
||||
i1 += (i2 & 65280) >> 8;
|
||||
j1 += i2 & 255;
|
||||
}
|
||||
}
|
||||
return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SpeedBlock extends TConstructBlock
|
||||
{
|
||||
public static String[] textureNames = new String[] { "brownstone_rough", "brownstone_rough_road", "brownstone_smooth", "brownstone_smooth_brick", "brownstone_smooth_road",
|
||||
"brownstone_smooth_fancy", "brownstone_smooth_chiseled" };
|
||||
|
||||
public SpeedBlock()
|
||||
{
|
||||
super(Material.rock, 3.0f, textureNames);
|
||||
// this.setBlockBounds(0f, 0f, 0f, 1.0f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityWalking (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
double boost = 2.2D;
|
||||
int metadata = world.getBlockMetadata(x, y, z);
|
||||
if (metadata == 1 || metadata == 4)
|
||||
boost = 2.7D;
|
||||
|
||||
double mX = Math.abs(entity.motionX);
|
||||
double mZ = Math.abs(entity.motionZ);
|
||||
if (mX < 0.5D)
|
||||
{
|
||||
entity.motionX *= boost;
|
||||
}
|
||||
if (mZ < 0.5D)
|
||||
{
|
||||
entity.motionZ *= boost;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped (int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < textureNames.length; iter++)
|
||||
{
|
||||
list.add(new ItemStack(b, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class SpeedSlab extends SlabBase
|
||||
{
|
||||
public SpeedSlab()
|
||||
{
|
||||
super(Material.rock);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
setHardness(3F);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
meta = meta % 8;
|
||||
return TRepo.speedBlock.getIcon(side, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 7; iter++)
|
||||
{
|
||||
list.add(new ItemStack(b, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityWalking (World world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
double boost = 2.2D;
|
||||
int metadata = world.getBlockMetadata(x, y, z) % 8;
|
||||
if (metadata == 1 || metadata == 4)
|
||||
boost = 2.7D;
|
||||
|
||||
double mX = Math.abs(entity.motionX);
|
||||
double mZ = Math.abs(entity.motionZ);
|
||||
if (mX < 0.5D)
|
||||
{
|
||||
entity.motionX *= boost;
|
||||
}
|
||||
if (mZ < 0.5D)
|
||||
{
|
||||
entity.motionZ *= boost;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.BlockLadder;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.util.IIcon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class StoneLadder extends BlockLadder
|
||||
{
|
||||
|
||||
// Override ladder material
|
||||
public final Material blockMaterial = Material.rock;
|
||||
|
||||
private IIcon icon;
|
||||
|
||||
// Use the normally protected constructor
|
||||
public StoneLadder()
|
||||
{
|
||||
super();
|
||||
this.setBlockName("decoration.stoneladder");
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister register)
|
||||
{
|
||||
icon = register.registerIcon("tinker:ladder_stone");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int meta, int side)
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,342 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import static net.minecraftforge.common.util.ForgeDirection.EAST;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.NORTH;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.WEST;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mantle.blocks.MantleBlock;
|
||||
import mantle.world.WorldHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class StoneTorch extends MantleBlock
|
||||
{
|
||||
public StoneTorch()
|
||||
{
|
||||
super(Material.circuits);
|
||||
this.setCreativeTab(CreativeTabs.tabDecorations);
|
||||
setLightLevel(0.9375F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bounding box from the pool of bounding boxes (this means this
|
||||
* box can change after the pool has been cleared to be reused)
|
||||
*/
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether
|
||||
* or not to render the shared face of two adjacent blocks and also whether
|
||||
* the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this block doesn't render as an ordinary block it will return False
|
||||
* (examples: signs, buttons, stairs, etc)
|
||||
*/
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of render function that is called for this block
|
||||
*/
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if we can place a torch on a block.
|
||||
*/
|
||||
private boolean canPlaceTorchOn (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (par1World.doesBlockHaveSolidTopSurface(par1World, par2, par3, par4))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Block b = par1World.getBlock(par2, par3, par4);
|
||||
return (b != null && b.canPlaceTorchOnTop(par1World, par2, par3, par4));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if its valid to put this block at the specified
|
||||
* coordinates. Args: world, x, y, z
|
||||
*/
|
||||
@Override
|
||||
public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
return par1World.isSideSolid(par2 - 1, par3, par4, EAST, true) || par1World.isSideSolid(par2 + 1, par3, par4, WEST, true) || par1World.isSideSolid(par2, par3, par4 - 1, SOUTH, true)
|
||||
|| par1World.isSideSolid(par2, par3, par4 + 1, NORTH, true) || canPlaceTorchOn(par1World, par2, par3 - 1, par4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z,
|
||||
* side, hitX, hitY, hitZ, block metadata
|
||||
*/
|
||||
@Override
|
||||
public int onBlockPlaced (World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)
|
||||
{
|
||||
int j1 = par9;
|
||||
|
||||
if (par5 == 1 && this.canPlaceTorchOn(par1World, par2, par3 - 1, par4))
|
||||
{
|
||||
j1 = 5;
|
||||
}
|
||||
|
||||
if (par5 == 2 && par1World.isSideSolid(par2, par3, par4 + 1, NORTH, true))
|
||||
{
|
||||
j1 = 4;
|
||||
}
|
||||
|
||||
if (par5 == 3 && par1World.isSideSolid(par2, par3, par4 - 1, SOUTH, true))
|
||||
{
|
||||
j1 = 3;
|
||||
}
|
||||
|
||||
if (par5 == 4 && par1World.isSideSolid(par2 + 1, par3, par4, WEST, true))
|
||||
{
|
||||
j1 = 2;
|
||||
}
|
||||
|
||||
if (par5 == 5 && par1World.isSideSolid(par2 - 1, par3, par4, EAST, true))
|
||||
{
|
||||
j1 = 1;
|
||||
}
|
||||
|
||||
return j1;
|
||||
}
|
||||
|
||||
public void updateTick (World par1World, int par2, int par3, int par4, Random random)
|
||||
{
|
||||
super.updateTick(par1World, par2, par3, par4, random);
|
||||
|
||||
if (par1World.getBlockMetadata(par2, par3, par4) == 0)
|
||||
{
|
||||
this.onBlockAdded(par1World, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
|
||||
// JAVADOC METHOD $$ func_149726_b
|
||||
public void onBlockAdded (World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_)
|
||||
{
|
||||
if (p_149726_1_.getBlockMetadata(p_149726_2_, p_149726_3_, p_149726_4_) == 0)
|
||||
{
|
||||
if (p_149726_1_.isSideSolid(p_149726_2_ - 1, p_149726_3_, p_149726_4_, EAST, true))
|
||||
{
|
||||
p_149726_1_.setBlockMetadataWithNotify(p_149726_2_, p_149726_3_, p_149726_4_, 1, 2);
|
||||
}
|
||||
else if (p_149726_1_.isSideSolid(p_149726_2_ + 1, p_149726_3_, p_149726_4_, WEST, true))
|
||||
{
|
||||
p_149726_1_.setBlockMetadataWithNotify(p_149726_2_, p_149726_3_, p_149726_4_, 2, 2);
|
||||
}
|
||||
else if (p_149726_1_.isSideSolid(p_149726_2_, p_149726_3_, p_149726_4_ - 1, SOUTH, true))
|
||||
{
|
||||
p_149726_1_.setBlockMetadataWithNotify(p_149726_2_, p_149726_3_, p_149726_4_, 3, 2);
|
||||
}
|
||||
else if (p_149726_1_.isSideSolid(p_149726_2_, p_149726_3_, p_149726_4_ + 1, NORTH, true))
|
||||
{
|
||||
p_149726_1_.setBlockMetadataWithNotify(p_149726_2_, p_149726_3_, p_149726_4_, 4, 2);
|
||||
}
|
||||
else if (this.canPlaceTorchOn(p_149726_1_, p_149726_2_, p_149726_3_ - 1, p_149726_4_))
|
||||
{
|
||||
p_149726_1_.setBlockMetadataWithNotify(p_149726_2_, p_149726_3_, p_149726_4_, 5, 2);
|
||||
}
|
||||
}
|
||||
|
||||
this.dropTorchIfCantStay(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("tinker:torch_stone");
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets the block know when one of its neighbor changes. Doesn't know which
|
||||
* neighbor changed (coordinates passed are their own) Args: x, y, z,
|
||||
* neighbor blockID
|
||||
*/
|
||||
@Override
|
||||
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, Block par5)
|
||||
{
|
||||
this.func_94397_d(par1World, par2, par3, par4, par5);
|
||||
}
|
||||
|
||||
protected boolean func_94397_d (World par1World, int par2, int par3, int par4, Block par5)
|
||||
{
|
||||
if (this.dropTorchIfCantStay(par1World, par2, par3, par4))
|
||||
{
|
||||
int i1 = par1World.getBlockMetadata(par2, par3, par4);
|
||||
boolean flag = false;
|
||||
|
||||
if (!par1World.isSideSolid(par2 - 1, par3, par4, EAST, true) && i1 == 1)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2 + 1, par3, par4, WEST, true) && i1 == 2)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3, par4 - 1, SOUTH, true) && i1 == 3)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3, par4 + 1, NORTH, true) && i1 == 4)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the block can remain at its current location and will drop as an
|
||||
* item if it is unable to stay. Returns True if it can stay and False if it
|
||||
* drops. Args: world, x, y, z
|
||||
*/
|
||||
protected boolean dropTorchIfCantStay (World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (!this.canPlaceBlockAt(par1World, par2, par3, par4))
|
||||
{
|
||||
if (par1World.getBlock(par2, par3, par4) == (Block) this)
|
||||
{
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
//WorldHelper.setBlockToAir(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ray traces through the blocks collision from start vector to end vector
|
||||
* returning a ray trace hit. Args: world, x, y, z, startVec, endVec
|
||||
*/
|
||||
@Override
|
||||
public MovingObjectPosition collisionRayTrace (World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
|
||||
{
|
||||
int l = par1World.getBlockMetadata(par2, par3, par4) & 7;
|
||||
float f = 0.15F;
|
||||
|
||||
if (l == 1)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
|
||||
}
|
||||
else if (l == 2)
|
||||
{
|
||||
this.setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
|
||||
}
|
||||
else if (l == 3)
|
||||
{
|
||||
this.setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
|
||||
}
|
||||
else if (l == 4)
|
||||
{
|
||||
this.setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
f = 0.1F;
|
||||
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
|
||||
}
|
||||
|
||||
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* A randomly called display update to be able to add particles or other items for display
|
||||
*/
|
||||
public void randomDisplayTick (World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
int meta = par1World.getBlockMetadata(par2, par3, par4);
|
||||
double d0 = (double) ((float) par2 + 0.5F);
|
||||
double d1 = (double) ((float) par3 + 0.7F);
|
||||
double d2 = (double) ((float) par4 + 0.5F);
|
||||
double d3 = 0.2199999988079071D;
|
||||
double d4 = 0.27000001072883606D;
|
||||
|
||||
if (meta == 1)
|
||||
{
|
||||
par1World.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (meta == 2)
|
||||
{
|
||||
par1World.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (meta == 3)
|
||||
{
|
||||
par1World.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (meta == 4)
|
||||
{
|
||||
par1World.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else
|
||||
{
|
||||
par1World.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
par1World.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.BlockFluidClassic;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
|
||||
public class TConstructFluid extends BlockFluidClassic
|
||||
{
|
||||
String texture;
|
||||
boolean alpha;
|
||||
public IIcon stillIcon;
|
||||
public IIcon flowIcon;
|
||||
|
||||
public TConstructFluid(Fluid fluid, Material material, String texture)
|
||||
{
|
||||
super(fluid, material);
|
||||
this.texture = texture;
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
}
|
||||
|
||||
public TConstructFluid(Fluid fluid, Material material, String texture, boolean alpha)
|
||||
{
|
||||
this(fluid, material, texture);
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass ()
|
||||
{
|
||||
return alpha ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
stillIcon = iconRegister.registerIcon("tinker:" + texture);
|
||||
flowIcon = iconRegister.registerIcon("tinker:" + texture + "_flow");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return stillIcon;
|
||||
return flowIcon;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TMetalBlock extends TConstructBlock
|
||||
{
|
||||
|
||||
static String[] metalTypes = new String[] { "compressed_cobalt", "compressed_ardite", "compressed_manyullyn", "compressed_copper", "compressed_bronze", "compressed_tin", "compressed_aluminum",
|
||||
"compressed_alubrass", "compressed_alumite", "compressed_steel", "compressed_ender" };
|
||||
|
||||
public TMetalBlock(Material material, float hardness)
|
||||
{
|
||||
super(material, hardness, metalTypes);
|
||||
this.setStepSound(Block.soundTypeMetal);
|
||||
}
|
||||
|
||||
public boolean isBeaconBase (World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import tconstruct.blocks.logic.TankAirLogic;
|
||||
import tconstruct.client.block.TankAirRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TankAirBlock extends BlockContainer
|
||||
{
|
||||
|
||||
public TankAirBlock(Material material)
|
||||
{
|
||||
super(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int var2)
|
||||
{
|
||||
return new TankAirLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return TankAirRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons (IIconRegister par1IconRegister)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z)
|
||||
{
|
||||
TankAirLogic tank = (TankAirLogic) world.getTileEntity(x, y, z);
|
||||
if (tank != null && tank.hasItem())
|
||||
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition collisionRayTrace (World world, int x, int y, int z, Vec3 par5Vec3, Vec3 par6Vec3)
|
||||
{
|
||||
TankAirLogic tank = (TankAirLogic) world.getTileEntity(x, y, z);
|
||||
if (tank.hasItem())
|
||||
return super.collisionRayTrace(world, x, y, z, par5Vec3, par6Vec3);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock (MovingObjectPosition target, World world, int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock (EntityPlayer player, int meta)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir (IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.ToolForgeLogic;
|
||||
import tconstruct.client.block.TableForgeRender;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ToolForgeBlock extends InventoryBlock
|
||||
{
|
||||
|
||||
public ToolForgeBlock(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(2f);
|
||||
this.setStepSound(Block.soundTypeMetal);
|
||||
}
|
||||
|
||||
String[] textureNames = { "toolforge_iron", "toolforge_gold", "toolforge_diamond", "toolforge_emerald", "toolforge_cobalt", "toolforge_ardite", "toolforge_manyullyn", "toolforge_copper",
|
||||
"toolforge_bronze", "toolforge_tin", "toolforge_aluminum", "toolforge_alubrass", "toolforge_alumite", "toolforge_steel" };
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
|
||||
IIcon textureTop;
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons (IIconRegister iconRegister)
|
||||
{
|
||||
super.registerBlockIcons(iconRegister);
|
||||
textureTop = iconRegister.registerIcon("tinker:toolforge_top");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
if (side == 1)
|
||||
{
|
||||
return textureTop;
|
||||
}
|
||||
if (side == 0)
|
||||
{
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return Blocks.iron_block.getIcon(side, 0);
|
||||
case 1:
|
||||
return Blocks.gold_block.getIcon(side, 0);
|
||||
case 2:
|
||||
return Blocks.diamond_block.getIcon(side, 0);
|
||||
case 3:
|
||||
return Blocks.emerald_block.getIcon(side, 0);
|
||||
default:
|
||||
return TRepo.metalBlock.getIcon(side, meta - 4);
|
||||
}
|
||||
}
|
||||
|
||||
return this.icons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return side == ForgeDirection.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return TableForgeRender.model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity (World world, int metadata)
|
||||
{
|
||||
return new ToolForgeLogic();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
|
||||
{
|
||||
int md = world.getBlockMetadata(x, y, z);
|
||||
return TProxyCommon.toolForgeID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getModInstance ()
|
||||
{
|
||||
return TConstruct.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks (Item b, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < textureNames.length; iter++)
|
||||
{
|
||||
list.add(new ItemStack(b, 1, iter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryBlock;
|
||||
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;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.logic.PartBuilderLogic;
|
||||
import tconstruct.blocks.logic.PatternChestLogic;
|
||||
import tconstruct.blocks.logic.StencilTableLogic;
|
||||
import tconstruct.blocks.logic.ToolStationLogic;
|
||||
import tconstruct.client.block.TableRender;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ToolStationBlock extends InventoryBlock
|
||||
{
|
||||
public ToolStationBlock(Material material)
|
||||
{
|
||||
super(material);
|
||||
this.setCreativeTab(TConstructRegistry.blockTab);
|
||||
this.setHardness(2f);
|
||||
this.setStepSound(Block.soundTypeWood);
|
||||
}
|
||||
|
||||
//Block.hasComparatorInputOverride and Block.getComparatorInputOverride
|
||||
|
||||
/* Rendering */
|
||||
@Override
|
||||
public String[] getTextureNames ()
|
||||
{
|
||||
String[] textureNames = { "toolstation_top", "toolstation_side", "toolstation_bottom", "partbuilder_oak_top", "partbuilder_oak_side", "partbuilder_oak_bottom", "partbuilder_spruce_top",
|
||||
"partbuilder_spruce_side", "partbuilder_spruce_bottom", "partbuilder_birch_top", "partbuilder_birch_side", "partbuilder_birch_bottom", "partbuilder_jungle_top",
|
||||
"partbuilder_jungle_side", "partbuilder_jungle_bottom", "patternchest_top", "patternchest_side", "patternchest_bottom", "stenciltable_oak_top", "stenciltable_oak_side",
|
||||
"stenciltable_oak_bottom", "stenciltable_spruce_top", "stenciltable_spruce_side", "stenciltable_spruce_bottom", "stenciltable_birch_top", "stenciltable_birch_side",
|
||||
"stenciltable_birch_bottom", "stenciltable_jungle_top", "stenciltable_jungle_side", "stenciltable_jungle_bottom" };
|
||||
|
||||
return textureNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (int side, int meta)
|
||||
{
|
||||
if (meta <= 4)
|
||||
{
|
||||
return icons[meta * 3 + getTextureIndex(side)];
|
||||
}
|
||||
else if (meta <= 9)
|
||||
{
|
||||
return icons[15 + getTextureIndex(side)];
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[meta * 3 + getTextureIndex(side) - 12];
|
||||
}
|
||||
}
|
||||
|
||||
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 isSideSolid (IBlockAccess world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return side == ForgeDirection.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType ()
|
||||
{
|
||||
return TableRender.tabelModelID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 createNewTileEntity (World world, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return new ToolStationLogic();
|
||||
case 1:
|
||||
return new PartBuilderLogic();
|
||||
case 2:
|
||||
return new PartBuilderLogic();
|
||||
case 3:
|
||||
return new PartBuilderLogic();
|
||||
case 4:
|
||||
return new PartBuilderLogic();
|
||||
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 StencilTableLogic();
|
||||
case 11:
|
||||
return new StencilTableLogic();
|
||||
case 12:
|
||||
return new StencilTableLogic();
|
||||
case 13:
|
||||
return new StencilTableLogic();
|
||||
/*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 (Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
for (int iter = 0; iter < 6; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
|
||||
for (int iter = 10; iter < 14; iter++)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, iter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack)
|
||||
{
|
||||
if (PHConstruct.freePatterns)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 5)
|
||||
{
|
||||
PatternChestLogic logic = (PatternChestLogic) world.getTileEntity(x, y, z);
|
||||
for (int i = 1; i <= 13; i++)
|
||||
{
|
||||
logic.setInventorySlotContents(i - 1, new ItemStack(TRepo.woodPattern, 1, i));
|
||||
}
|
||||
logic.setInventorySlotContents(13, new ItemStack(TRepo.woodPattern, 1, 22));
|
||||
}
|
||||
}
|
||||
super.onBlockPlacedBy(world, x, y, z, par5EntityLiving, par6ItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureDomain (int textureNameIndex)
|
||||
{
|
||||
return "tinker";
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package tconstruct.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRailBase;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class WoodRail extends BlockRailBase
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon theIcon;
|
||||
|
||||
public WoodRail()
|
||||
{
|
||||
super(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
|
||||
*/
|
||||
public IIcon getIcon (int par1, int par2)
|
||||
{
|
||||
return par2 >= 6 ? this.theIcon : this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
/**
|
||||
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
|
||||
* is the only chance you get to register icons.
|
||||
*/
|
||||
public void registerBlockIcons (IIconRegister par1IconRegister)
|
||||
{
|
||||
this.blockIcon = par1IconRegister.registerIcon("tinker:woodrail");
|
||||
this.theIcon = par1IconRegister.registerIcon("tinker:woodrail_turn");
|
||||
}
|
||||
|
||||
protected void func_94358_a (World par1World, int par2, int par3, int par4, int par5, int par6, Block par7)
|
||||
{
|
||||
if (par7 != Blocks.air && par7.canProvidePower() && (new Rail(par1World, par2, par3, par4)).func_150650_a() == 3)
|
||||
{
|
||||
this.func_150052_a(par1World, par2, par3, par4, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRailMaxSpeed (World world, EntityMinecart cart, int y, int x, int z)
|
||||
{
|
||||
return 0.3f;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,284 +0,0 @@
|
||||
package tconstruct.blocks.component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mantle.world.CoordTuple;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import tconstruct.blocks.logic.AdaptiveSmelteryLogic;
|
||||
import tconstruct.library.component.LogicComponent;
|
||||
import tconstruct.library.component.MultiFluidTank;
|
||||
import tconstruct.library.crafting.Smeltery;
|
||||
|
||||
public class SmelteryComponent extends LogicComponent
|
||||
{
|
||||
final AdaptiveSmelteryLogic master;
|
||||
final SmelteryScan structure;
|
||||
final MultiFluidTank multitank;
|
||||
int maxTemp;
|
||||
|
||||
public int fuelTicks;
|
||||
public int fuelGague;
|
||||
public int fuelAmount;
|
||||
boolean inUse;
|
||||
|
||||
public int[] activeTemps = new int[0];
|
||||
public int[] meltingTemps = new int[0];
|
||||
|
||||
CoordTuple activeLavaTank;
|
||||
|
||||
public SmelteryComponent(AdaptiveSmelteryLogic inventory, SmelteryScan structure, MultiFluidTank multitank, int maxTemp)
|
||||
{
|
||||
master = inventory;
|
||||
this.structure = structure;
|
||||
this.multitank = multitank;
|
||||
this.maxTemp = maxTemp;
|
||||
}
|
||||
|
||||
public void update ()
|
||||
{
|
||||
/*
|
||||
* if (useTime > 0 && inUse) useTime -= 3;
|
||||
*/
|
||||
if (activeTemps.length == 0)
|
||||
inUse = false;
|
||||
|
||||
updateFuelGague();
|
||||
}
|
||||
|
||||
public void adjustSize (int size, boolean forceAdjust)
|
||||
{
|
||||
if (size != activeTemps.length || forceAdjust)
|
||||
{
|
||||
int[] tempActive = activeTemps;
|
||||
activeTemps = new int[size];
|
||||
int activeLength = tempActive.length > activeTemps.length ? activeTemps.length : tempActive.length;
|
||||
System.arraycopy(tempActive, 0, activeTemps, 0, activeLength);
|
||||
|
||||
int[] tempMelting = meltingTemps;
|
||||
meltingTemps = new int[size];
|
||||
int meltingLength = tempMelting.length > meltingTemps.length ? meltingTemps.length : tempMelting.length;
|
||||
System.arraycopy(tempMelting, 0, meltingTemps, 0, meltingLength);
|
||||
|
||||
if (activeTemps.length > 0 && activeTemps.length > tempActive.length)
|
||||
{
|
||||
for (int i = tempActive.length; i < activeTemps.length; i++)
|
||||
{
|
||||
activeTemps[i] = 20;
|
||||
meltingTemps[i] = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTemperatures ()
|
||||
{
|
||||
inUse = true;
|
||||
for (int i = 0; i < meltingTemps.length; i++)
|
||||
{
|
||||
meltingTemps[i] = Smeltery.instance.getLiquifyTemperature(master.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void heatItems ()
|
||||
{
|
||||
if (fuelTicks > 0)
|
||||
{
|
||||
boolean hasUse = false;
|
||||
for (int i = 0; i < meltingTemps.length; i++)
|
||||
{
|
||||
fuelTicks--;
|
||||
if (fuelTicks <= 0)
|
||||
break;
|
||||
|
||||
ItemStack slot = master.getStackInSlot(i);
|
||||
if (meltingTemps[i] > 20 && slot != null)
|
||||
{
|
||||
hasUse = true;
|
||||
if (activeTemps[i] < maxTemp && activeTemps[i] < meltingTemps[i])
|
||||
{
|
||||
activeTemps[i] += 1;
|
||||
}
|
||||
else if (activeTemps[i] >= meltingTemps[i] && !world.isRemote)
|
||||
{
|
||||
FluidStack result = getResultFor(slot);
|
||||
if (result != null)
|
||||
{
|
||||
if (multitank.addFluidToTank(result, false))
|
||||
{
|
||||
master.setInventorySlotContents(i, null);
|
||||
activeTemps[i] = 20;
|
||||
ArrayList alloys = Smeltery.mixMetals(multitank.fluidlist);
|
||||
for (int al = 0; al < alloys.size(); al++)
|
||||
{
|
||||
FluidStack liquid = (FluidStack) alloys.get(al);
|
||||
multitank.addFluidToTank(liquid, true);
|
||||
}
|
||||
master.markDirty();
|
||||
master.setUpdateFluids();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
activeTemps[i] = 20;
|
||||
}
|
||||
inUse = hasUse;
|
||||
}
|
||||
}
|
||||
|
||||
void updateFuelGague ()
|
||||
{
|
||||
if (activeLavaTank == null || fuelTicks > 0 || structure.lavaTanks.size() < 1)
|
||||
return;
|
||||
|
||||
if (!world.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z))
|
||||
{
|
||||
fuelAmount = 0;
|
||||
fuelGague = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntity tankContainer = world.getTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z);
|
||||
if (tankContainer == null)
|
||||
{
|
||||
fuelAmount = 0;
|
||||
fuelGague = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (tankContainer instanceof IFluidHandler && inUse)
|
||||
{
|
||||
FluidStack liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, drainFuelAmount(), false);
|
||||
if (liquid != null && liquid.getFluid().getBlock() == Blocks.lava)
|
||||
{
|
||||
liquid = ((IFluidHandler) tankContainer).drain(ForgeDirection.DOWN, drainFuelAmount(), true);
|
||||
fuelTicks += liquid.amount * 15;
|
||||
|
||||
FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN);
|
||||
liquid = info[0].fluid;
|
||||
int capacity = info[0].capacity;
|
||||
if (liquid != null)
|
||||
{
|
||||
fuelAmount = liquid.amount;
|
||||
fuelGague = liquid.amount * 52 / capacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
fuelAmount = 0;
|
||||
fuelGague = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean foundTank = false;
|
||||
int iter = 0;
|
||||
while (!foundTank)
|
||||
{
|
||||
CoordTuple possibleTank = structure.lavaTanks.get(iter);
|
||||
TileEntity newTankContainer = world.getTileEntity(possibleTank.x, possibleTank.y, possibleTank.z);
|
||||
if (newTankContainer instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack newliquid = ((IFluidHandler) newTankContainer).drain(ForgeDirection.UNKNOWN, drainFuelAmount(), false);
|
||||
if (newliquid != null && newliquid.getFluid().getBlock() == Blocks.lava && newliquid.amount > 0)
|
||||
{
|
||||
foundTank = true;
|
||||
setActiveLavaTank(possibleTank);
|
||||
iter = structure.lavaTanks.size();
|
||||
|
||||
FluidTankInfo[] info = ((IFluidHandler) tankContainer).getTankInfo(ForgeDirection.DOWN);
|
||||
liquid = info[0].fluid;
|
||||
int capacity = info[0].capacity;
|
||||
if (liquid != null)
|
||||
{
|
||||
fuelAmount = liquid.amount;
|
||||
fuelGague = liquid.amount * 52 / capacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
fuelAmount = 0;
|
||||
fuelGague = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
iter++;
|
||||
if (iter >= structure.lavaTanks.size())
|
||||
foundTank = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setActiveLavaTank (CoordTuple coord)
|
||||
{
|
||||
activeLavaTank = coord;
|
||||
}
|
||||
|
||||
private int drainFuelAmount ()
|
||||
{
|
||||
if (activeTemps.length == 0)
|
||||
return 0;
|
||||
|
||||
int amount = activeTemps.length / 3;
|
||||
if (amount < 150)
|
||||
amount = 150;
|
||||
return amount;
|
||||
}
|
||||
|
||||
public FluidStack getResultFor (ItemStack stack)
|
||||
{
|
||||
return Smeltery.instance.getSmelteryResult(stack);
|
||||
}
|
||||
|
||||
public int getInternalTemperature ()
|
||||
{
|
||||
return maxTemp;
|
||||
}
|
||||
|
||||
public int getTempForSlot (int slot)
|
||||
{
|
||||
return activeTemps[slot];
|
||||
}
|
||||
|
||||
public int getMeltingPointForSlot (int slot)
|
||||
{
|
||||
return meltingTemps[slot];
|
||||
}
|
||||
|
||||
public int getScaledFuelGague (int scale)
|
||||
{
|
||||
int ret = (fuelGague * scale) / 52;
|
||||
if (ret < 1)
|
||||
ret = 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
activeTemps = tags.getIntArray("Temperature");
|
||||
meltingTemps = tags.getIntArray("Melting");
|
||||
fuelAmount = tags.getInteger("Fuel");
|
||||
int[] tank = tags.getIntArray("LavaTank");
|
||||
if (tank.length > 0)
|
||||
activeLavaTank = new CoordTuple(tank[0], tank[1], tank[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setIntArray("Temperature", activeTemps);
|
||||
tags.setIntArray("Melting", meltingTemps);
|
||||
tags.setInteger("Fuel", fuelAmount);
|
||||
if (activeLavaTank != null)
|
||||
tags.setIntArray("LavaTank", new int[] { activeLavaTank.x, activeLavaTank.y, activeLavaTank.z });
|
||||
}
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
package tconstruct.blocks.component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
import mantle.world.CoordTuple;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagIntArray;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.component.TankLayerScan;
|
||||
|
||||
public class SmelteryScan extends TankLayerScan
|
||||
{
|
||||
public ArrayList<CoordTuple> lavaTanks = new ArrayList<CoordTuple>();
|
||||
|
||||
public SmelteryScan(TileEntity te, Block... id)
|
||||
{
|
||||
super(te, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkValidStructure ()
|
||||
{
|
||||
lavaTanks.clear();
|
||||
super.checkValidStructure();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkAir (int x, int y, int z)
|
||||
{
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block == null || world.isAirBlock(x, y, z) || block == TRepo.tankAir)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkServant (int x, int y, int z)
|
||||
{
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block == null || world.isAirBlock(x, y, z) || !isValidBlock(x, y, z))
|
||||
return false;
|
||||
|
||||
if (!block.hasTileEntity(world.getBlockMetadata(x, y, z)))
|
||||
return false;
|
||||
|
||||
TileEntity be = world.getTileEntity(x, y, z);
|
||||
if (be instanceof IServantLogic)
|
||||
{
|
||||
boolean ret = ((IServantLogic) be).setPotentialMaster(this.imaster, this.world, x, y, z);
|
||||
if (ret && block == TRepo.lavaTank)
|
||||
lavaTanks.add(new CoordTuple(x, y, z));
|
||||
return ret;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalizeStructure ()
|
||||
{
|
||||
super.finalizeStructure();
|
||||
if (lavaTanks.size() < 1)
|
||||
completeStructure = false;
|
||||
else
|
||||
{
|
||||
for (CoordTuple coord : airCoords)
|
||||
{
|
||||
if (world.getBlock(coord.x, coord.y, coord.z) != TRepo.tankAir)
|
||||
{
|
||||
world.setBlock(coord.x, coord.y, coord.z, TRepo.tankAir);
|
||||
IServantLogic servant = (IServantLogic) world.getTileEntity(coord.x, coord.y, coord.z);
|
||||
servant.verifyMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invalidateStructure ()
|
||||
{
|
||||
super.invalidateStructure();
|
||||
for (CoordTuple coord : airCoords)
|
||||
{
|
||||
TileEntity servant = world.getTileEntity(coord.x, coord.y, coord.z);
|
||||
if (servant instanceof IServantLogic)
|
||||
((IServantLogic) servant).invalidateMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void invalidateBlocksAbove (int height)
|
||||
{
|
||||
for (CoordTuple coord : airCoords)
|
||||
{
|
||||
if (coord.y < height)
|
||||
continue;
|
||||
|
||||
TileEntity servant = world.getTileEntity(coord.x, coord.y, coord.z);
|
||||
if (servant instanceof IServantLogic)
|
||||
((IServantLogic) servant).invalidateMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup ()
|
||||
{
|
||||
super.cleanup();
|
||||
Iterator i = airCoords.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
CoordTuple coord = (CoordTuple) i.next();
|
||||
TileEntity te = world.getTileEntity(coord.x, coord.y, coord.z);
|
||||
if (te != null && te instanceof IServantLogic)
|
||||
{
|
||||
((IServantLogic) te).invalidateMaster(imaster, world, master.xCoord, master.yCoord, master.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sync lava tanks for fuel values
|
||||
@Override
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readNetworkNBT(tags);
|
||||
|
||||
NBTTagList tanks = tags.getTagList("Tanks", 10);
|
||||
if (tanks != null)
|
||||
{
|
||||
lavaTanks.clear();
|
||||
|
||||
for (int i = 0; i < tanks.tagCount(); ++i)
|
||||
{
|
||||
int[] coord = tanks.func_150306_c(i);
|
||||
layerAirCoords.add(new CoordTuple(coord[0], coord[1], coord[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeNetworkNBT(tags);
|
||||
|
||||
NBTTagList tanks = new NBTTagList();
|
||||
for (CoordTuple coord : lavaTanks)
|
||||
{
|
||||
tanks.appendTag(new NBTTagIntArray(new int[] { coord.x, coord.y, coord.z }));
|
||||
}
|
||||
tags.setTag("Tanks", tanks);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package tconstruct.blocks.component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import tconstruct.library.component.MultiFluidTank;
|
||||
|
||||
public class TankAirComponent extends MultiFluidTank
|
||||
{
|
||||
public TankAirComponent()
|
||||
{
|
||||
}
|
||||
|
||||
public TankAirComponent(int i)
|
||||
{
|
||||
super(i);
|
||||
}
|
||||
|
||||
public void overrideFluids (ArrayList<FluidStack> fluids)
|
||||
{
|
||||
fluidlist = fluids;
|
||||
}
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.crafting.AlloyMix;
|
||||
import mantle.blocks.abstracts.MultiServantLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class AdaptiveDrainLogic extends MultiServantLogic implements IFluidHandler, IFacingLogic// , ISwitchableMaster
|
||||
{
|
||||
byte direction;
|
||||
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPotentialMaster (IMasterLogic master, World world, int x, int y, int z)
|
||||
{
|
||||
// TConstruct.logger.info("Master: "+master);
|
||||
return (master instanceof AdaptiveSmelteryLogic || master instanceof AdaptiveDrainLogic) && !getHasMaster();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (hasValidMaster() && canDrain(from, null))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.fill(from, resource, doFill);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
// TConstruct.logger.info("Attempting drain " + hasValidMaster());
|
||||
if (hasValidMaster() && canDrain(from, null))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
// TConstruct.logger.info("Found master");
|
||||
return smeltery.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if (hasValidMaster() && canDrain(from, null))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.drain(from, resource, doDrain);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.getFillState() < 2;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
if (hasValidMaster())
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.getFillState() > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
if (hasValidMaster() && (from == getForgeDirection() || from == getForgeDirection().getOpposite() || from == ForgeDirection.UNKNOWN))
|
||||
{
|
||||
AdaptiveSmelteryLogic smeltery = (AdaptiveSmelteryLogic) worldObj.getTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.getTankInfo(ForgeDirection.UNKNOWN);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (int side)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (float yaw, float pitch, EntityLivingBase player)
|
||||
{
|
||||
if (pitch > 45)
|
||||
direction = 1;
|
||||
else if (pitch < -45)
|
||||
direction = 0;
|
||||
else
|
||||
{
|
||||
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
direction = tags.getByte("Direction");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setByte("Direction", direction);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readFromNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -1,614 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mantle.blocks.abstracts.AdaptiveInventoryLogic;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
import mantle.world.CoordTuple;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.component.SmelteryComponent;
|
||||
import tconstruct.blocks.component.SmelteryScan;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.inventory.AdaptiveSmelteryContainer;
|
||||
import tconstruct.library.component.IComponentHolder;
|
||||
import tconstruct.library.component.LogicComponent;
|
||||
import tconstruct.library.component.MultiFluidTank;
|
||||
|
||||
public class AdaptiveSmelteryLogic extends AdaptiveInventoryLogic implements IActiveLogic, IMasterLogic, IComponentHolder, IFluidHandler
|
||||
{
|
||||
byte direction;
|
||||
boolean updateFluids = false;
|
||||
boolean recheckStructure = false;
|
||||
boolean updateAir = false;
|
||||
SmelteryScan structure = new SmelteryScan(this, TRepo.smeltery, TRepo.lavaTank);
|
||||
MultiFluidTank multitank = new MultiFluidTank();
|
||||
SmelteryComponent smeltery = new SmelteryComponent(this, structure, multitank, 800);
|
||||
HashMap<CoordTuple, LiquidDataInstance> airUpdates = new HashMap<CoordTuple, LiquidDataInstance>();
|
||||
int tick = 0;
|
||||
|
||||
public MultiFluidTank getMultiTank ()
|
||||
{
|
||||
return multitank;
|
||||
}
|
||||
|
||||
public SmelteryComponent getSmeltery ()
|
||||
{
|
||||
return smeltery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
tick++;
|
||||
if (tick % 4 == 0)
|
||||
smeltery.heatItems();
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
if (tick % 20 == 0)
|
||||
{
|
||||
if (structure.isComplete())
|
||||
smeltery.update();
|
||||
|
||||
if (updateFluids)
|
||||
{
|
||||
distributeFluids();
|
||||
updateFluids = false;
|
||||
}
|
||||
|
||||
if (updateAir)
|
||||
{
|
||||
updateAir();
|
||||
updateAir = false;
|
||||
}
|
||||
|
||||
if (recheckStructure)
|
||||
{
|
||||
structure.recheckStructure();
|
||||
recheckStructure = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (tick >= 60)
|
||||
{
|
||||
if (!structure.isComplete())
|
||||
{
|
||||
structure.checkValidStructure();
|
||||
if (structure.isComplete())
|
||||
{
|
||||
validateSmeltery();
|
||||
}
|
||||
}
|
||||
tick = 0;
|
||||
}
|
||||
|
||||
if (airUpdates.size() > 0)
|
||||
updateFluidBlocks();
|
||||
}
|
||||
}
|
||||
|
||||
public void setUpdateFluids ()
|
||||
{
|
||||
updateFluids = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicComponent> getComponents ()
|
||||
{
|
||||
ArrayList<LogicComponent> ret = new ArrayList<LogicComponent>(3);
|
||||
ret.add(structure);
|
||||
ret.add(multitank);
|
||||
ret.add(smeltery);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Structure */
|
||||
|
||||
@Override
|
||||
public void setWorldObj (World world)
|
||||
{
|
||||
super.setWorldObj(world);
|
||||
structure.setWorld(world);
|
||||
smeltery.setWorld(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyChange (IServantLogic servant, int x, int y, int z)
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
// System.out.println("Notifying of change from "+new CoordTuple(x,
|
||||
// y, z));
|
||||
recheckStructure = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeBlock (EntityLivingBase entity, ItemStack itemstack)
|
||||
{
|
||||
structure.checkValidStructure();
|
||||
if (structure.isComplete())
|
||||
{
|
||||
validateSmeltery();
|
||||
}
|
||||
}
|
||||
|
||||
void validateSmeltery ()
|
||||
{
|
||||
adjustInventory(structure.getAirSize(), true);
|
||||
smeltery.adjustSize(structure.getAirSize(), true);
|
||||
multitank.setCapacity(structure.getAirSize() * (TConstruct.ingotLiquidValue * 18));
|
||||
smeltery.setActiveLavaTank(structure.lavaTanks.get(0));
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBlock ()
|
||||
{
|
||||
structure.cleanup();
|
||||
}
|
||||
|
||||
/* Direction */
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (int side)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (float yaw, float pitch, EntityLivingBase player)
|
||||
{
|
||||
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return structure.isComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* Inventory */
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
inventory[slot] = itemstack;
|
||||
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
updateWorldBlock(slot, itemstack);
|
||||
updateAir = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
if (inventory[slot].stackSize <= quantity)
|
||||
{
|
||||
ItemStack stack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
updateWorldBlock(slot, inventory[slot]);
|
||||
return stack;
|
||||
}
|
||||
ItemStack split = inventory[slot].splitStack(quantity);
|
||||
if (inventory[slot].stackSize == 0)
|
||||
{
|
||||
inventory[slot] = null;
|
||||
}
|
||||
|
||||
updateWorldBlock(slot, inventory[slot]);
|
||||
return split;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty ()
|
||||
{
|
||||
smeltery.updateTemperatures();
|
||||
updateAir = true;
|
||||
super.markDirty();
|
||||
}
|
||||
|
||||
void updateWorldBlock (int slot, ItemStack itemstack)
|
||||
{
|
||||
CoordTuple air = structure.getAirByIndex(slot);
|
||||
if (air != null)
|
||||
{
|
||||
TileEntity te = worldObj.getTileEntity(air.x, air.y, air.z);
|
||||
if (te != null && te instanceof TankAirLogic)
|
||||
{
|
||||
((TankAirLogic) te).setInventorySlotContents(0, itemstack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static final int pixelLayer = 162;
|
||||
|
||||
// Do the Monster Mash~
|
||||
public void distributeFluids ()
|
||||
{
|
||||
// Calculate liquids in each block
|
||||
int size = structure.getAirLayerSize();
|
||||
// HashMap<CoordTuple, LiquidDataInstance> blocks = new
|
||||
// HashMap<CoordTuple, LiquidDataInstance>();
|
||||
|
||||
for (FluidStack fluid : multitank.fluidlist)
|
||||
{
|
||||
// Base calculations per liquid
|
||||
LiquidData data = new LiquidData(fluid.amount, size);
|
||||
int baseY = structure.airCoords.get(0).y;
|
||||
int layerSize = structure.getAirLayerSize();
|
||||
|
||||
// Calculate where to distribute liquids
|
||||
for (int i = 0; i < structure.airCoords.size(); i++)
|
||||
{
|
||||
LiquidDataInstance instance;
|
||||
CoordTuple coord = structure.airCoords.get(i);
|
||||
int height = 16 * (coord.y - baseY);
|
||||
int position = i % layerSize;
|
||||
|
||||
if (!airUpdates.containsKey(coord))
|
||||
{
|
||||
instance = new LiquidDataInstance();
|
||||
airUpdates.put(coord, instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
instance = airUpdates.get(coord);
|
||||
}
|
||||
|
||||
if (instance.openLayers() > 0) // This is capable of sending
|
||||
// negative liquid sizes to
|
||||
// blocks without the stopgap
|
||||
// check
|
||||
{
|
||||
if (position > data.blocksWithExtra)
|
||||
{
|
||||
// Calculate open layers
|
||||
int open = data.layers - height + 1;
|
||||
if (open < 1) // Temporary stopgap check
|
||||
continue;
|
||||
if (open > instance.openLayers())
|
||||
open = instance.openLayers();
|
||||
|
||||
// Copy fluid
|
||||
FluidStack newFluid = fluid.copy();
|
||||
newFluid.amount = pixelLayer * open;
|
||||
instance.addFluid(open, newFluid);
|
||||
|
||||
// Subtract from total
|
||||
data.totalAmount -= newFluid.amount;
|
||||
if (data.totalAmount <= 0)
|
||||
break;
|
||||
}
|
||||
else if (position == data.blocksWithExtra && data.leftovers > 0)
|
||||
{
|
||||
// Calculate open layers
|
||||
int open = data.layers - height + 1;
|
||||
if (open < 1) // Temporary stopgap check
|
||||
continue;
|
||||
boolean full = false;
|
||||
if (open > instance.openLayers())
|
||||
{
|
||||
open = instance.openLayers();
|
||||
full = true;
|
||||
}
|
||||
|
||||
// Copy fluid
|
||||
FluidStack newFluid = fluid.copy();
|
||||
newFluid.amount = pixelLayer * open;
|
||||
if (!full)
|
||||
newFluid.amount += data.leftovers;
|
||||
instance.addFluid(open, newFluid);
|
||||
|
||||
// Subtract from total
|
||||
data.totalAmount -= newFluid.amount;
|
||||
if (data.totalAmount <= 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate open layers
|
||||
int open = data.layers - height;
|
||||
if (open < 1) // Temporary stopgap check
|
||||
continue;
|
||||
if (open > instance.openLayers())
|
||||
open = instance.openLayers();
|
||||
|
||||
// Copy fluid
|
||||
FluidStack newFluid = fluid.copy();
|
||||
newFluid.amount = pixelLayer * open;
|
||||
instance.addFluid(open, newFluid);
|
||||
|
||||
// Subtract from total
|
||||
data.totalAmount -= newFluid.amount;
|
||||
if (data.totalAmount <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Distribute liquids to each block
|
||||
}
|
||||
|
||||
protected void updateFluidBlocks ()
|
||||
{
|
||||
Iterator iter = airUpdates.entrySet().iterator();
|
||||
byte count = 0;
|
||||
while (iter.hasNext() && count < 40)
|
||||
{
|
||||
Map.Entry pairs = (Map.Entry) iter.next();
|
||||
CoordTuple coord = (CoordTuple) pairs.getKey();
|
||||
TileEntity te = worldObj.getTileEntity(coord.x, coord.y, coord.z);
|
||||
if (te instanceof TankAirLogic)
|
||||
{
|
||||
((TankAirLogic) te).overrideFluids(((LiquidDataInstance) pairs.getValue()).fluids);
|
||||
}
|
||||
iter.remove();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAir ()
|
||||
{
|
||||
for (CoordTuple loc : structure.airCoords)
|
||||
worldObj.markBlockForUpdate(loc.x, loc.y, loc.z);
|
||||
}
|
||||
|
||||
class LiquidData
|
||||
{
|
||||
public int totalAmount;
|
||||
public int layers;
|
||||
public int leftovers;
|
||||
public int blocksWithExtra;
|
||||
|
||||
LiquidData(int amount, int blocks)
|
||||
{
|
||||
totalAmount = amount;
|
||||
int layerAmount = pixelLayer * blocks;
|
||||
layers = amount / layerAmount;
|
||||
leftovers = amount % pixelLayer;
|
||||
blocksWithExtra = (amount % layerAmount) / pixelLayer;
|
||||
}
|
||||
}
|
||||
|
||||
class LiquidDataInstance
|
||||
{
|
||||
public ArrayList<FluidStack> fluids = new ArrayList<FluidStack>();
|
||||
int layers = 0;
|
||||
|
||||
public int openLayers ()
|
||||
{
|
||||
return 16 - layers;
|
||||
}
|
||||
|
||||
public void addFluid (int l, FluidStack fluid)
|
||||
{
|
||||
layers += l;
|
||||
fluids.add(fluid);
|
||||
}
|
||||
}
|
||||
|
||||
/* Gui */
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new AdaptiveSmelteryContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
public int getTempForSlot (int slot)
|
||||
{
|
||||
return smeltery.activeTemps[slot];
|
||||
}
|
||||
|
||||
public int getMeltingPointForSlot (int slot)
|
||||
{
|
||||
return smeltery.meltingTemps[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "crafters.Smeltery";
|
||||
}
|
||||
|
||||
/* Fluids */
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return multitank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return multitank.drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return multitank.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
return multitank.getMultiTankInfo();
|
||||
}
|
||||
|
||||
public int getFillState ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readNetworkNBT(tags);
|
||||
|
||||
structure.readFromNBT(tags);
|
||||
multitank.readFromNBT(tags);
|
||||
smeltery.readFromNBT(tags);
|
||||
}
|
||||
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
direction = tags.getByte("Direction");
|
||||
adjustInventory(tags.getInteger("InvSize"), false);
|
||||
super.readInventoryFromNBT(tags);
|
||||
|
||||
structure.readNetworkNBT(tags);
|
||||
multitank.readNetworkNBT(tags);
|
||||
smeltery.readNetworkNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeNetworkNBT(tags);
|
||||
|
||||
structure.writeToNBT(tags);
|
||||
multitank.writeToNBT(tags);
|
||||
smeltery.writeToNBT(tags);
|
||||
}
|
||||
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setByte("Direction", direction);
|
||||
tags.setInteger("InvSize", inventory.length);
|
||||
super.writeInventoryToNBT(tags);
|
||||
|
||||
structure.writeNetworkNBT(tags);
|
||||
multitank.writeNetworkNBT(tags);
|
||||
smeltery.writeNetworkNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readNetworkNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeNetworkNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class AqueductLogic extends TileEntity // implements ITankContainer
|
||||
{
|
||||
|
||||
/*
|
||||
* @Override public int fill (ForgeDirection from, FluidStack resource,
|
||||
* boolean doFill) { return 0; }
|
||||
*
|
||||
* @Override public int fill (int tankIndex, FluidStack resource, boolean
|
||||
* doFill) { return 0; }
|
||||
*
|
||||
* @Override public FluidStack drain (ForgeDirection from, int maxDrain,
|
||||
* boolean doDrain) { return null; }
|
||||
*
|
||||
* @Override public FluidStack drain (int tankIndex, int maxDrain, boolean
|
||||
* doDrain) { return null; }
|
||||
*
|
||||
* @Override public ILiquidTank[] getTanks (ForgeDirection direction) {
|
||||
* return null; }
|
||||
*
|
||||
* @Override public ILiquidTank getTank (ForgeDirection direction,
|
||||
* FluidStack type) { return null; }
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.inventory.FrypanContainer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
/* Slots
|
||||
* 0: Battlesign item
|
||||
*/
|
||||
|
||||
public class BattlesignLogic extends EquipLogic
|
||||
{
|
||||
|
||||
public BattlesignLogic()
|
||||
{
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "decoration.battlesign";
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
}
|
||||
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return null; //Not a normal gui block
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,456 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidEvent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import tconstruct.library.util.IPattern;
|
||||
|
||||
public class CastingBasinLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory
|
||||
{
|
||||
public FluidStack liquid;
|
||||
int castingDelay = 0;
|
||||
int renderOffset = 0;
|
||||
int capacity = 0;
|
||||
boolean needsUpdate;
|
||||
boolean init = true;
|
||||
int tick;
|
||||
|
||||
public CastingBasinLogic()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName () // Not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName () // Still not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) // Definitely not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* Tank */
|
||||
|
||||
@Override
|
||||
public int getCapacity ()
|
||||
{
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
public int updateCapacity () // Only used to initialize
|
||||
{
|
||||
ItemStack inv = inventory[0];
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
int rec = TConstruct.basinCasting.getCastingAmount(this.liquid, inv);
|
||||
|
||||
if (rec > 0)
|
||||
ret = rec;
|
||||
else {
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
{
|
||||
int cost = ((IPattern) inv.getItem()).getPatternCost(inv);
|
||||
if (cost > 0)
|
||||
ret *= ((IPattern) inv.getItem()).getPatternCost(inv) * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
TConstruct.logger.info("Ret: " + ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int updateCapacity (int capacity)
|
||||
{
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
|
||||
if (capacity > 0)
|
||||
ret = capacity;
|
||||
else {
|
||||
ItemStack inv = inventory[0];
|
||||
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
{
|
||||
int cost = ((IPattern) inv.getItem()).getPatternCost(inv);
|
||||
if (cost > 0)
|
||||
ret *= cost * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null)
|
||||
return 0;
|
||||
|
||||
if (this.liquid == null)
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.basinCasting.getCastingRecipe(resource, inventory[0]);
|
||||
if (recipe == null)
|
||||
return 0;
|
||||
this.capacity = updateCapacity(recipe.castingMetal.amount);
|
||||
|
||||
if (inventory[1] == null)
|
||||
{
|
||||
FluidStack copyLiquid = resource.copy();
|
||||
|
||||
if (copyLiquid.amount > this.capacity)
|
||||
{
|
||||
copyLiquid.amount = this.capacity;
|
||||
}
|
||||
|
||||
if (doFill)
|
||||
{
|
||||
if (copyLiquid.amount == this.capacity)
|
||||
{
|
||||
castingDelay = recipe.coolTime;
|
||||
}
|
||||
renderOffset = copyLiquid.amount;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
this.liquid = copyLiquid;
|
||||
needsUpdate = true;
|
||||
}
|
||||
return copyLiquid.amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if (resource.isFluidEqual(this.liquid))
|
||||
{
|
||||
if (resource.amount + this.liquid.amount >= this.capacity) // Start
|
||||
// timer
|
||||
// here
|
||||
{
|
||||
int roomInTank = this.capacity - liquid.amount;
|
||||
if (doFill && roomInTank > 0)
|
||||
{
|
||||
renderOffset = roomInTank;
|
||||
castingDelay = TConstruct.basinCasting.getCastingDelay(this.liquid, inventory[0]);
|
||||
this.liquid.amount = this.capacity;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return roomInTank;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (doFill)
|
||||
{
|
||||
this.liquid.amount += resource.amount;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return resource.amount;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty () // Isn't actually called?
|
||||
{
|
||||
super.markDirty();
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
ItemStack stack = super.decrStackSize(slot, quantity);
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (liquid == null || liquid.fluidID <= 0 || castingDelay > 0)
|
||||
return null;
|
||||
if (liquid.amount <= 0)
|
||||
return null;
|
||||
|
||||
int used = maxDrain;
|
||||
if (liquid.amount < used)
|
||||
used = liquid.amount;
|
||||
|
||||
if (doDrain)
|
||||
{
|
||||
liquid.amount -= used;
|
||||
}
|
||||
|
||||
FluidStack drained = liquid.copy();// new FluidStack(liquid.itemID,
|
||||
// used, liquid.itemMeta);
|
||||
drained.amount = used;
|
||||
|
||||
// Reset liquid if emptied
|
||||
if (liquid.amount <= 0)
|
||||
liquid = null;
|
||||
|
||||
if (doDrain)
|
||||
FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(drained, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this));
|
||||
|
||||
return drained;
|
||||
}
|
||||
|
||||
/* Tank Container */
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
// if (from == ForgeDirection.UP)
|
||||
return fill(resource, doFill);
|
||||
// return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] { getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid ()
|
||||
{
|
||||
return liquid == null ? null : liquid.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmount ()
|
||||
{
|
||||
return liquid != null ? liquid.amount : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo getInfo ()
|
||||
{
|
||||
FluidTankInfo info = new FluidTankInfo(this);
|
||||
return info;
|
||||
}
|
||||
|
||||
public int getLiquidAmount ()
|
||||
{
|
||||
return liquid.amount - renderOffset;
|
||||
}
|
||||
|
||||
/* Updating */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (castingDelay > 0)
|
||||
{
|
||||
// TConstruct.logger.info("Casting");
|
||||
castingDelay--;
|
||||
if (castingDelay == 0)
|
||||
castLiquid();
|
||||
}
|
||||
if (renderOffset > 0)
|
||||
{
|
||||
renderOffset -= 6;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
tick++;
|
||||
if (tick % 20 == 0)
|
||||
{
|
||||
tick = 0;
|
||||
if (needsUpdate)
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void castLiquid ()
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.basinCasting.getCastingRecipe(liquid, inventory[0]);
|
||||
if (recipe != null)
|
||||
{
|
||||
inventory[1] = recipe.getResult();
|
||||
if (recipe.consumeCast)
|
||||
inventory[0] = null;
|
||||
liquid = null;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
if (tags.getBoolean("hasLiquid"))
|
||||
{
|
||||
this.liquid = FluidStack.loadFluidStackFromNBT(tags.getCompoundTag("Fluid"));
|
||||
}
|
||||
// FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt);
|
||||
// this.liquid = new FluidStack(tags.getInteger("itemID"),
|
||||
// tags.getInteger("amount"), tags.getInteger("itemMeta"));
|
||||
else
|
||||
this.liquid = null;
|
||||
|
||||
if (tags.getBoolean("Initialized"))
|
||||
this.capacity = tags.getInteger("Capacity");
|
||||
else
|
||||
this.capacity = updateCapacity();
|
||||
this.castingDelay = tags.getInteger("castingDelay");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setBoolean("hasLiquid", liquid != null);
|
||||
if (liquid != null)
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
liquid.writeToNBT(nbt);
|
||||
tags.setTag("Fluid", nbt);
|
||||
}
|
||||
tags.setBoolean("Initialized", init);
|
||||
tags.setInteger("Capacity", capacity);
|
||||
tags.setInteger("castingDelay", castingDelay);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readFromNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (liquid != null)
|
||||
return false;
|
||||
|
||||
if (slot == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (slot == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,584 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidEvent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import tconstruct.TConstruct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @author BluSunrize
|
||||
*/
|
||||
|
||||
public class CastingChannelLogic extends TileEntity implements IFluidHandler
|
||||
{
|
||||
public final static int fillMax = TConstruct.ingotLiquidValue;
|
||||
public final static int outputMax = TConstruct.ingotLiquidValue;
|
||||
FluidTank internalTank = new FluidTank(fillMax);
|
||||
HashMap<ForgeDirection, FluidTank> subTanks = new HashMap();
|
||||
public ForgeDirection lastProvider;
|
||||
public ArrayList<ForgeDirection> validOutputs = new ArrayList();
|
||||
public int ticks = 0;
|
||||
public int recentlyFilledDelay;
|
||||
|
||||
/* UNUSED
|
||||
public CastingChannelMode mode = CastingChannelMode.SINGLEDRAIN;
|
||||
*/
|
||||
|
||||
public CastingChannelLogic()
|
||||
{
|
||||
lastProvider = ForgeDirection.UNKNOWN;
|
||||
validOutputs.add(ForgeDirection.DOWN);
|
||||
validOutputs.add(ForgeDirection.NORTH);
|
||||
validOutputs.add(ForgeDirection.SOUTH);
|
||||
validOutputs.add(ForgeDirection.EAST);
|
||||
validOutputs.add(ForgeDirection.WEST);
|
||||
|
||||
subTanks.put(ForgeDirection.NORTH, new FluidTank(TConstruct.ingotLiquidValue / 4));
|
||||
subTanks.put(ForgeDirection.SOUTH, new FluidTank(TConstruct.ingotLiquidValue / 4));
|
||||
subTanks.put(ForgeDirection.WEST, new FluidTank(TConstruct.ingotLiquidValue / 4));
|
||||
subTanks.put(ForgeDirection.EAST, new FluidTank(TConstruct.ingotLiquidValue / 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
ticks++;
|
||||
|
||||
boolean flagActiveFaucet = false;
|
||||
|
||||
TileEntity possibleFaucet = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
|
||||
if (possibleFaucet != null && possibleFaucet instanceof FaucetLogic)
|
||||
flagActiveFaucet = ((FaucetLogic) possibleFaucet).active;
|
||||
|
||||
if (ticks == 6 && !flagActiveFaucet)
|
||||
this.distributeFluids();
|
||||
if (ticks >= 12 && !flagActiveFaucet)
|
||||
{
|
||||
if (recentlyFilledDelay != 0)
|
||||
recentlyFilledDelay--;
|
||||
if (recentlyFilledDelay == 0 || lastProvider == ForgeDirection.UP)
|
||||
this.outputFluids();
|
||||
|
||||
ticks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void changeOutputs (EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
/*
|
||||
* UNUSED
|
||||
if(player.isSneaking())
|
||||
{
|
||||
|
||||
if(mode == null || mode == CastingChannelMode.SINGLEDRAIN)
|
||||
mode = CastingChannelMode.CONTINUEDRAIN;
|
||||
else
|
||||
mode = CastingChannelMode.SINGLEDRAIN;
|
||||
|
||||
String s = "Casting Channel Mode "+(worldObj.isRemote?"client side: ":"server side: ");
|
||||
player.addChatMessage(s+mode.toString());
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
ForgeDirection toggle = ForgeDirection.UNKNOWN;
|
||||
if (side == 0 || side == 1)
|
||||
{
|
||||
if (hitX > 0.3125 && hitX < 0.6875)
|
||||
if (hitZ > 0 && hitZ < 0.3125)
|
||||
toggle = ForgeDirection.NORTH;
|
||||
if (hitX > 0.3125 && hitX < 0.6875)
|
||||
if (hitZ > 0.6875 && hitZ < 1)
|
||||
toggle = ForgeDirection.SOUTH;
|
||||
if (hitZ > 0.3125 && hitZ < 0.6875)
|
||||
if (hitX > 0 && hitX < 0.3125)
|
||||
toggle = ForgeDirection.WEST;
|
||||
if (hitZ > 0.3125 && hitZ < 0.6875)
|
||||
if (hitX > 0.6875 && hitX < 1)
|
||||
toggle = ForgeDirection.EAST;
|
||||
|
||||
if (side == 0)
|
||||
if (hitX > 0.3125 && hitX < 0.6875)
|
||||
if (hitZ > 0.3125 && hitZ < 0.6875)
|
||||
toggle = ForgeDirection.DOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (side == 2)
|
||||
{
|
||||
if (hitX > 0 && hitX < 0.3125)
|
||||
toggle = ForgeDirection.WEST;
|
||||
if (hitX > 0.6875 && hitX < 1)
|
||||
toggle = ForgeDirection.EAST;
|
||||
}
|
||||
if (side == 3)
|
||||
{
|
||||
if (hitX > 0 && hitX < 0.3125)
|
||||
toggle = ForgeDirection.WEST;
|
||||
if (hitX > 0.6875 && hitX < 1)
|
||||
toggle = ForgeDirection.EAST;
|
||||
}
|
||||
if (side == 4)
|
||||
{
|
||||
if (hitZ > 0 && hitZ < 0.3125)
|
||||
toggle = ForgeDirection.NORTH;
|
||||
if (hitZ > 0.6875 && hitZ < 1)
|
||||
toggle = ForgeDirection.SOUTH;
|
||||
}
|
||||
if (side == 5)
|
||||
{
|
||||
if (hitZ > 0 && hitZ < 0.3125)
|
||||
toggle = ForgeDirection.NORTH;
|
||||
if (hitZ > 0.6875 && hitZ < 1)
|
||||
toggle = ForgeDirection.SOUTH;
|
||||
}
|
||||
}
|
||||
|
||||
if (toggle != ForgeDirection.UNKNOWN && toggle != ForgeDirection.UP)
|
||||
{
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + toggle.offsetX, yCoord + toggle.offsetY, zCoord + toggle.offsetZ);
|
||||
if (tile instanceof IFluidHandler)
|
||||
if (validOutputs.contains(toggle))
|
||||
{
|
||||
validOutputs.remove(toggle);
|
||||
if (tile instanceof CastingChannelLogic && toggle != ForgeDirection.DOWN)
|
||||
((CastingChannelLogic) tile).validOutputs.remove(toggle.getOpposite());
|
||||
}
|
||||
else
|
||||
{
|
||||
validOutputs.add(toggle);
|
||||
if (tile instanceof CastingChannelLogic && toggle != ForgeDirection.DOWN)
|
||||
if (!((CastingChannelLogic) tile).validOutputs.contains(toggle.getOpposite()))
|
||||
((CastingChannelLogic) tile).validOutputs.add(toggle.getOpposite());
|
||||
}
|
||||
|
||||
}
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
private void distributeFluids ()
|
||||
{
|
||||
/* DEBUG
|
||||
boolean printDebugLog = false;
|
||||
ArrayList<String> debugLog = new ArrayList();
|
||||
*/
|
||||
//Move Fluid to Output Tanks
|
||||
Set<ForgeDirection> connected = this.getOutputs().keySet();
|
||||
|
||||
if (connected.contains(ForgeDirection.DOWN))
|
||||
connected.remove(ForgeDirection.DOWN);
|
||||
if (connected.contains(lastProvider))
|
||||
connected.remove(lastProvider);
|
||||
|
||||
int output = Math.min(internalTank.getFluidAmount(), 12);
|
||||
int connectedAmount = connected.size();
|
||||
if (connectedAmount < 1)
|
||||
connectedAmount = 1;
|
||||
int scaledAmount = output / connectedAmount;
|
||||
|
||||
for (ForgeDirection dirOut : connected)
|
||||
{
|
||||
if (this.internalTank.getFluid() == null)
|
||||
break;
|
||||
|
||||
/* DEBUG
|
||||
debugLog.add("Moving to "+dirOut+"ern SubTank");
|
||||
*/
|
||||
FluidStack tempFS = new FluidStack(internalTank.getFluid().getFluid(), scaledAmount);
|
||||
int fit = subTanks.get(dirOut).fill(tempFS, false);
|
||||
/* DEBUG
|
||||
debugLog.add("SubTank will accept "+fit+"mb");
|
||||
*/
|
||||
if (fit > 0)
|
||||
fit = internalTank.drain(fit, true).amount;
|
||||
/* DEBUG
|
||||
debugLog.add("Internal Tank was drained by "+fit+"mb");
|
||||
*/
|
||||
tempFS.amount = fit;
|
||||
fit = subTanks.get(dirOut).fill(tempFS, true);
|
||||
/* DEBUG
|
||||
debugLog.add("SubTank was filled by "+fit+"mb");
|
||||
if(fit > 0)
|
||||
printDebugLog = true;
|
||||
debugLog.add("Internal Tank now contains: "+internalTank.getFluidAmount()+"mb");
|
||||
debugLog.add("SubTank now contains: "+subTanks.get(dirOut).getFluidAmount()+"mb");
|
||||
*/
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
/* DEBUG
|
||||
if(printDebugLog)
|
||||
{
|
||||
for(String s: debugLog)
|
||||
System.out.println(s);
|
||||
debugLog.clear();
|
||||
}
|
||||
printDebugLog = false;
|
||||
*/
|
||||
|
||||
//Get Fluid from most recent InputTank
|
||||
FluidTank inputTank = subTanks.get(lastProvider);
|
||||
if (inputTank != null && inputTank.getFluid() != null) //Tank can be null if input was received from top
|
||||
{
|
||||
/* DEBUG
|
||||
debugLog.add("Importing from "+lastProvider+"ern SubTank");
|
||||
*/
|
||||
FluidStack tempFS = new FluidStack(inputTank.getFluid().getFluid(), Math.min(inputTank.getFluidAmount(), 12));
|
||||
int fit = internalTank.fill(tempFS, false);
|
||||
/* DEBUG
|
||||
debugLog.add("Internal Tank will accept "+fit+"mb");
|
||||
*/
|
||||
if (fit > 0)
|
||||
fit = inputTank.drain(fit, true).amount;
|
||||
/* DEBUG
|
||||
debugLog.add("Import Tank was drained by "+fit+"mb");
|
||||
*/
|
||||
tempFS.amount = fit;
|
||||
fit = internalTank.fill(tempFS, true);
|
||||
/* DEBUG
|
||||
debugLog.add("Internal Tank was filled by "+fit+"mb");
|
||||
if(fit > 0)
|
||||
printDebugLog = true;
|
||||
debugLog.add("Internal Tank now contains: "+internalTank.getFluidAmount()+"mb");
|
||||
debugLog.add("SubTank now contains: "+inputTank.getFluidAmount()+"mb");
|
||||
*/
|
||||
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
/* DEBUG
|
||||
if(printDebugLog)
|
||||
{
|
||||
for(String s: debugLog)
|
||||
System.out.println(s);
|
||||
debugLog.clear();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private void outputFluids ()
|
||||
{
|
||||
/* DEBUG
|
||||
boolean printDebugLog = false;
|
||||
ArrayList<String> debugLog = new ArrayList();
|
||||
*/
|
||||
|
||||
HashMap<ForgeDirection, TileEntity> connected = this.getOutputs();
|
||||
if (connected.containsKey(lastProvider))
|
||||
connected.remove(lastProvider);
|
||||
if (connected.containsKey(ForgeDirection.DOWN) && this.internalTank.getFluid() != null) // Prioritizes FluidHandlers below
|
||||
{
|
||||
int output = Math.min(internalTank.getFluid().amount, 12);
|
||||
FluidStack tempFS = new FluidStack(internalTank.getFluid().getFluid(), output);
|
||||
int fittingBelow = ((IFluidHandler) connected.get(ForgeDirection.DOWN)).fill(ForgeDirection.UP, tempFS, false);
|
||||
if (fittingBelow > 0)
|
||||
fittingBelow = this.drain(ForgeDirection.DOWN, fittingBelow, true).amount;
|
||||
tempFS.amount = fittingBelow;
|
||||
fittingBelow = ((IFluidHandler) connected.get(ForgeDirection.DOWN)).fill(ForgeDirection.UP, tempFS, true);
|
||||
|
||||
connected.remove(ForgeDirection.DOWN);
|
||||
}
|
||||
if (connected.size() != 0)
|
||||
{
|
||||
for (ForgeDirection dir : connected.keySet()) //Iterates to connected FluidHandlers
|
||||
{
|
||||
if (subTanks.get(dir) != null && subTanks.get(dir).getFluid() != null)
|
||||
{
|
||||
/* DEBUG
|
||||
debugLog.add("Exporting from "+dir+"ern SubTank");
|
||||
*/
|
||||
FluidStack tempFS = new FluidStack(subTanks.get(dir).getFluid().getFluid(), Math.min(subTanks.get(dir).getFluidAmount(), 12));
|
||||
int fit = ((IFluidHandler) connected.get(dir)).fill(dir.getOpposite(), tempFS, false);
|
||||
/* DEBUG
|
||||
debugLog.add("New Channel will accept "+fit+"mb");
|
||||
*/
|
||||
if (fit > 0)
|
||||
fit = this.drain(dir, fit, true).amount;
|
||||
/* DEBUG
|
||||
debugLog.add("OldSubTank was drained by "+fit+"mb");
|
||||
*/
|
||||
tempFS.amount = fit;
|
||||
fit = ((IFluidHandler) connected.get(dir)).fill(dir.getOpposite(), tempFS, true);
|
||||
/* DEBUG
|
||||
debugLog.add("New Channel was filled by "+fit+"mb");
|
||||
|
||||
debugLog.add("OldSubTank now contains: "+drain(dir, 100000, false).amount+"mb");
|
||||
if(fit > 0)
|
||||
printDebugLog = true;
|
||||
*/
|
||||
}
|
||||
/* DEBUG
|
||||
for(String s: debugLog)
|
||||
System.out.println(s);
|
||||
debugLog.clear();
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float tankBelow ()
|
||||
{
|
||||
TileEntity te = this.worldObj.getTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
|
||||
if (te instanceof CastingChannelLogic)
|
||||
return -0.5f;
|
||||
if (te instanceof LavaTankLogic)
|
||||
return -1.0f;
|
||||
if (te instanceof CastingBasinLogic)
|
||||
return -0.75f;
|
||||
if (te instanceof CastingTableLogic)
|
||||
return -0.125f;
|
||||
if (te instanceof IFluidHandler)
|
||||
return 0f;
|
||||
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
public HashMap<ForgeDirection, TileEntity> getOutputs ()
|
||||
{
|
||||
HashMap<ForgeDirection, TileEntity> map = new HashMap();
|
||||
for (ForgeDirection fd : this.validOutputs)
|
||||
{
|
||||
int tX = this.xCoord + fd.offsetX;
|
||||
int tY = this.yCoord + fd.offsetY;
|
||||
int tZ = this.zCoord + fd.offsetZ;
|
||||
TileEntity tile = this.worldObj.getTileEntity(tX, tY, tZ);
|
||||
|
||||
if (tile != null && tile instanceof IFluidHandler)
|
||||
map.put(fd, tile);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (doFill)
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
this.lastProvider = from;
|
||||
if (this.internalTank.getFluid() == null)
|
||||
this.recentlyFilledDelay = 2;
|
||||
}
|
||||
|
||||
if (from == ForgeDirection.UP)
|
||||
{
|
||||
return this.internalTank.fill(resource, doFill);
|
||||
}
|
||||
else if (from == ForgeDirection.NORTH || from == ForgeDirection.SOUTH || from == ForgeDirection.WEST || from == ForgeDirection.EAST)
|
||||
{
|
||||
return this.subTanks.get(from).fill(resource, doFill);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return drain(from, resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
//if(doDrain)
|
||||
// this.worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||
if (from == ForgeDirection.DOWN)
|
||||
return this.internalTank.drain(maxDrain, doDrain);
|
||||
else if (from == ForgeDirection.NORTH || from == ForgeDirection.SOUTH || from == ForgeDirection.WEST || from == ForgeDirection.EAST)
|
||||
{
|
||||
return this.subTanks.get(from).drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
if (from == ForgeDirection.DOWN)
|
||||
return false;
|
||||
if (from == ForgeDirection.UP)
|
||||
return true;
|
||||
return validOutputs.contains(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
if (from == ForgeDirection.UP)
|
||||
return false;
|
||||
return validOutputs.contains(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
if (from == null || from == ForgeDirection.UP || from == ForgeDirection.DOWN || from == ForgeDirection.UNKNOWN)
|
||||
return new FluidTankInfo[] { new FluidTankInfo(internalTank) };
|
||||
else
|
||||
return new FluidTankInfo[] { new FluidTankInfo(subTanks.get(from)) };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
|
||||
NBTTagCompound nbtTank = tags.getCompoundTag("internalTank");
|
||||
if (nbtTank != null)
|
||||
internalTank.readFromNBT(nbtTank);
|
||||
|
||||
for (ForgeDirection fdSub : subTanks.keySet())
|
||||
{
|
||||
NBTTagCompound nbtSubTank = tags.getCompoundTag("subTank_" + fdSub.name());
|
||||
if (nbtSubTank != null)
|
||||
subTanks.get(fdSub).readFromNBT(nbtSubTank);
|
||||
}
|
||||
|
||||
int[] validFDs = tags.getIntArray("validOutputs");
|
||||
if (validFDs != null)
|
||||
{
|
||||
validOutputs = new ArrayList();
|
||||
for (int i : validFDs)
|
||||
validOutputs.add(convertIntToFD(i));
|
||||
}
|
||||
/* UNUSED
|
||||
this.mode = CastingChannelMode.readFromNBT(tags);
|
||||
*/
|
||||
this.lastProvider = this.convertIntToFD(tags.getInteger("LastProvider"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
NBTTagCompound nbtTank = new NBTTagCompound();
|
||||
internalTank.writeToNBT(nbtTank);
|
||||
tags.setTag("internalTank", nbtTank);
|
||||
for (ForgeDirection fdSub : subTanks.keySet())
|
||||
{
|
||||
NBTTagCompound nbtSubTank = new NBTTagCompound();
|
||||
subTanks.get(fdSub).writeToNBT(nbtSubTank);
|
||||
tags.setTag("subTank_" + fdSub.name(), nbtSubTank);
|
||||
}
|
||||
|
||||
int[] validFDs = new int[validOutputs.size()];
|
||||
int it = 0;
|
||||
for (ForgeDirection fd : validOutputs)
|
||||
{
|
||||
if (fd != null)
|
||||
validFDs[it] = convertFDToInt(fd);
|
||||
it++;
|
||||
}
|
||||
tags.setIntArray("validOutputs", validFDs);
|
||||
/* UNUSED
|
||||
CastingChannelMode.writeToNBT(tags, this.mode);
|
||||
*/
|
||||
tags.setInteger("LastProvider", this.convertFDToInt(this.lastProvider));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readCustomNBT(packet.func_148857_g());
|
||||
this.worldObj.func_147479_m(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
|
||||
public int convertFDToInt (ForgeDirection dir)
|
||||
{
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
return 0;
|
||||
case UP:
|
||||
return 1;
|
||||
case NORTH:
|
||||
return 2;
|
||||
case SOUTH:
|
||||
return 3;
|
||||
case WEST:
|
||||
return 4;
|
||||
case EAST:
|
||||
return 5;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public ForgeDirection convertIntToFD (int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
return ForgeDirection.DOWN;
|
||||
case 1:
|
||||
return ForgeDirection.UP;
|
||||
case 2:
|
||||
return ForgeDirection.NORTH;
|
||||
case 3:
|
||||
return ForgeDirection.SOUTH;
|
||||
case 4:
|
||||
return ForgeDirection.WEST;
|
||||
case 5:
|
||||
return ForgeDirection.EAST;
|
||||
default:
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
}
|
||||
/* UNUSED
|
||||
public enum CastingChannelMode
|
||||
{
|
||||
//Will not output while being filled by Faucet, hence only taking one ingots worth from the Smeltery
|
||||
SINGLEDRAIN,
|
||||
//Will keep the Faucet above it open
|
||||
CONTINUEDRAIN;
|
||||
|
||||
public static void writeToNBT(NBTTagCompound tag, CastingChannelMode mode)
|
||||
{
|
||||
if(mode == SINGLEDRAIN)
|
||||
tag.setString("CastingChannelMode","single");
|
||||
else
|
||||
tag.setString("CastingChannelMode","continue");
|
||||
}
|
||||
public static CastingChannelMode readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
return (!tag.hasKey("CastingChannelMode") || tag.getString("CastingChannelMode")=="single") ? SINGLEDRAIN : CONTINUEDRAIN ;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -1,454 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidEvent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.library.crafting.CastingRecipe;
|
||||
import tconstruct.library.util.IPattern;
|
||||
|
||||
public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory
|
||||
{
|
||||
public FluidStack liquid;
|
||||
int castingDelay = 0;
|
||||
int renderOffset = 0;
|
||||
int capacity = 0;
|
||||
boolean needsUpdate;
|
||||
boolean init = true;
|
||||
int tick;
|
||||
|
||||
public CastingTableLogic()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName () // Not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName () // Still not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z) // Definitely not a gui block
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/* Tank */
|
||||
|
||||
@Override
|
||||
public int getCapacity ()
|
||||
{
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
public int updateCapacity () // Only used to initialize
|
||||
{
|
||||
ItemStack inv = inventory[0];
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
int rec = TConstruct.tableCasting.getCastingAmount(this.liquid, inv);
|
||||
|
||||
if (rec > 0)
|
||||
ret = rec;
|
||||
else {
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
{
|
||||
int cost = ((IPattern) inv.getItem()).getPatternCost(inv);
|
||||
if (cost > 0)
|
||||
ret *= ((IPattern) inv.getItem()).getPatternCost(inv) * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
TConstruct.logger.info("Ret: " + ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int updateCapacity (int capacity)
|
||||
{
|
||||
int ret = TConstruct.ingotLiquidValue;
|
||||
|
||||
if (capacity > 0)
|
||||
ret = capacity;
|
||||
else {
|
||||
ItemStack inv = inventory[0];
|
||||
|
||||
if (inv != null && inv.getItem() instanceof IPattern)
|
||||
{
|
||||
int cost = ((IPattern) inv.getItem()).getPatternCost(inv);
|
||||
if (cost > 0)
|
||||
ret *= cost * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null)
|
||||
return 0;
|
||||
|
||||
if (this.liquid == null)
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(resource, inventory[0]);
|
||||
if (recipe == null)
|
||||
return 0;
|
||||
this.capacity = updateCapacity(recipe.castingMetal.amount);
|
||||
|
||||
if (inventory[1] == null)
|
||||
{
|
||||
FluidStack copyLiquid = resource.copy();
|
||||
|
||||
if (copyLiquid.amount > this.capacity)
|
||||
{
|
||||
copyLiquid.amount = this.capacity;
|
||||
}
|
||||
|
||||
if (doFill)
|
||||
{
|
||||
if (copyLiquid.amount == this.capacity)
|
||||
{
|
||||
castingDelay = recipe.coolTime;
|
||||
}
|
||||
renderOffset = copyLiquid.amount;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
this.liquid = copyLiquid;
|
||||
needsUpdate = true;
|
||||
}
|
||||
return copyLiquid.amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
else if (resource.isFluidEqual(this.liquid))
|
||||
{
|
||||
if (resource.amount + this.liquid.amount >= this.capacity) // Start
|
||||
// timer
|
||||
// here
|
||||
{
|
||||
int roomInTank = this.capacity - liquid.amount;
|
||||
if (doFill && roomInTank > 0)
|
||||
{
|
||||
renderOffset = roomInTank;
|
||||
castingDelay = TConstruct.tableCasting.getCastingDelay(this.liquid, inventory[0]);
|
||||
this.liquid.amount = this.capacity;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return roomInTank;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (doFill)
|
||||
{
|
||||
this.liquid.amount += resource.amount;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
return resource.amount;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty () // Isn't actually called?
|
||||
{
|
||||
super.markDirty();
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
ItemStack stack = super.decrStackSize(slot, quantity);
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (liquid == null || liquid.fluidID <= 0 || castingDelay > 0)
|
||||
return null;
|
||||
if (liquid.amount <= 0)
|
||||
return null;
|
||||
|
||||
int used = maxDrain;
|
||||
if (liquid.amount < used)
|
||||
used = liquid.amount;
|
||||
|
||||
if (doDrain)
|
||||
{
|
||||
liquid.amount -= used;
|
||||
}
|
||||
|
||||
FluidStack drained = liquid.copy();// new FluidStack(liquid.itemID,
|
||||
// used, liquid.itemMeta);
|
||||
drained.amount = used;
|
||||
|
||||
// Reset liquid if emptied
|
||||
if (liquid.amount <= 0)
|
||||
liquid = null;
|
||||
|
||||
if (doDrain)
|
||||
FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(drained, this.worldObj, this.xCoord, this.yCoord, this.zCoord, this));
|
||||
|
||||
return drained;
|
||||
}
|
||||
|
||||
/* Tank Container */
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
// if (from == ForgeDirection.UP)
|
||||
return fill(resource, doFill);
|
||||
// return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
return drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] { getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid ()
|
||||
{
|
||||
return liquid == null ? null : liquid.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmount ()
|
||||
{
|
||||
return liquid != null ? liquid.amount : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo getInfo ()
|
||||
{
|
||||
FluidTankInfo info = new FluidTankInfo(this);
|
||||
return info;
|
||||
}
|
||||
|
||||
public int getLiquidAmount ()
|
||||
{
|
||||
return liquid.amount - renderOffset;
|
||||
}
|
||||
|
||||
/* Updating */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (castingDelay > 0)
|
||||
{
|
||||
// TConstruct.logger.info("Casting");
|
||||
castingDelay--;
|
||||
if (castingDelay == 0)
|
||||
castLiquid();
|
||||
}
|
||||
if (renderOffset > 0)
|
||||
{
|
||||
renderOffset -= 6;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
tick++;
|
||||
if (tick % 20 == 0)
|
||||
{
|
||||
tick = 0;
|
||||
if (needsUpdate)
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void castLiquid ()
|
||||
{
|
||||
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(liquid, inventory[0]);
|
||||
if (recipe != null)
|
||||
{
|
||||
inventory[1] = recipe.getResult();
|
||||
if (recipe.consumeCast)
|
||||
inventory[0] = null;
|
||||
liquid = null;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
if (tags.getBoolean("hasLiquid"))
|
||||
{
|
||||
this.liquid = FluidStack.loadFluidStackFromNBT(tags.getCompoundTag("Fluid"));
|
||||
}
|
||||
else
|
||||
this.liquid = null;
|
||||
|
||||
if (tags.getBoolean("Initialized"))
|
||||
this.capacity = tags.getInteger("Capacity");
|
||||
else
|
||||
this.capacity = updateCapacity();
|
||||
this.castingDelay = tags.getInteger("castingDelay");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setBoolean("hasLiquid", liquid != null);
|
||||
if (liquid != null)
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
liquid.writeToNBT(nbt);
|
||||
tags.setTag("Fluid", nbt);
|
||||
}
|
||||
tags.setBoolean("Initialized", init);
|
||||
tags.setInteger("Capacity", capacity);
|
||||
tags.setInteger("castingDelay", castingDelay);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readFromNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (liquid != null)
|
||||
return false;
|
||||
|
||||
if (slot == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int slot, ItemStack itemstack, int side)
|
||||
{
|
||||
if (slot == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.inventory.CraftingStationContainer;
|
||||
|
||||
public class CraftingStationLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public WeakReference<IInventory> chest; // TODO: These are prototypes
|
||||
public WeakReference<IInventory> doubleChest;
|
||||
public WeakReference<IInventory> patternChest;
|
||||
public WeakReference<IInventory> furnace;
|
||||
public boolean tinkerTable;
|
||||
public boolean stencilTable;
|
||||
public boolean doubleFirst;
|
||||
|
||||
public CraftingStationLogic()
|
||||
{
|
||||
super(17); // 9 for crafting, 1 for output, 6 for extensions, 1 for
|
||||
// plans
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
chest = null;
|
||||
doubleChest = null;
|
||||
patternChest = null;
|
||||
furnace = null;
|
||||
tinkerTable = false;
|
||||
int[] ys = {y, y - 1, y + 1};
|
||||
for (byte iy = 0; iy < 3; iy++)
|
||||
{
|
||||
int yPos = ys[iy];
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
|
||||
if (chest == null && tile instanceof TileEntityChest)
|
||||
{
|
||||
chest = new WeakReference(tile);
|
||||
checkForChest(world, xPos, yPos, zPos, 1, 0);
|
||||
checkForChest(world, xPos, yPos, zPos, -1, 0);
|
||||
checkForChest(world, xPos, yPos, zPos, 0, 1);
|
||||
checkForChest(world, xPos, yPos, zPos, 0, -1);
|
||||
}
|
||||
else if (patternChest == null && tile instanceof PatternChestLogic)
|
||||
patternChest = new WeakReference(tile);
|
||||
else if (furnace == null && (tile instanceof TileEntityFurnace || tile instanceof FurnaceLogic))
|
||||
furnace = new WeakReference(tile);
|
||||
else if (tinkerTable == false && tile instanceof ToolStationLogic)
|
||||
tinkerTable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new CraftingStationContainer(inventoryplayer, this, x, y, z);
|
||||
}
|
||||
|
||||
void checkForChest (World world, int x, int y, int z, int dx, int dz)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x + dx, y, z + dz);
|
||||
if (tile instanceof TileEntityChest)
|
||||
{
|
||||
doubleChest = new WeakReference(tile);
|
||||
doubleFirst = dx + dz < 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName ()
|
||||
{
|
||||
return "crafters.CraftingStation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int var1)
|
||||
{
|
||||
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return i != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (slot == 0)
|
||||
{
|
||||
for (int i = 1; i < getSizeInventory(); i++)
|
||||
decrStackSize(i, 1);
|
||||
}
|
||||
return super.decrStackSize(slot, quantity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return i == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/* Slots
|
||||
* 0: Frying pan item
|
||||
* 1: Fuel
|
||||
* 2-9: Food
|
||||
*/
|
||||
|
||||
public abstract class EquipLogic extends InventoryLogic
|
||||
{
|
||||
|
||||
public EquipLogic(int invSize)
|
||||
{
|
||||
super(invSize);
|
||||
}
|
||||
|
||||
public void setEquipmentItem (ItemStack stack)
|
||||
{
|
||||
inventory[0] = stack.copy();
|
||||
}
|
||||
|
||||
public boolean hasEquipmentItem ()
|
||||
{
|
||||
return inventory[0] != null;
|
||||
}
|
||||
|
||||
public ItemStack getEquipmentItem ()
|
||||
{
|
||||
return inventory[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack stack)
|
||||
{
|
||||
if (slot == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
super.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int slot)
|
||||
{
|
||||
return slot != 0 ? inventory[slot] : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStackInSlot (int slot)
|
||||
{
|
||||
return slot != 0 ? inventory[slot] != null : false;
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.TConstruct;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogic, IFluidHandler
|
||||
{
|
||||
byte direction;
|
||||
boolean active;
|
||||
public FluidStack liquid;
|
||||
|
||||
public boolean activateFaucet ()
|
||||
{
|
||||
if (liquid == null && active)
|
||||
{
|
||||
int x = xCoord, z = zCoord;
|
||||
switch (getRenderDirection())
|
||||
{
|
||||
case 2:
|
||||
z++;
|
||||
break;
|
||||
case 3:
|
||||
z--;
|
||||
break;
|
||||
case 4:
|
||||
x++;
|
||||
break;
|
||||
case 5:
|
||||
x--;
|
||||
break;
|
||||
}
|
||||
|
||||
TileEntity drainte = worldObj.getTileEntity(x, yCoord, z);
|
||||
TileEntity tankte = worldObj.getTileEntity(xCoord, yCoord - 1, zCoord);
|
||||
|
||||
if (drainte != null && drainte instanceof IFluidHandler && tankte != null && tankte instanceof IFluidHandler)
|
||||
{
|
||||
FluidStack templiquid = ((IFluidHandler) drainte).drain(getForgeDirection(), TConstruct.ingotLiquidValue, false);
|
||||
if (templiquid != null)
|
||||
{
|
||||
int drained = ((IFluidHandler) tankte).fill(ForgeDirection.UP, templiquid, false);
|
||||
if (drained > 0)
|
||||
{
|
||||
liquid = ((IFluidHandler) drainte).drain(getForgeDirection(), drained, true);
|
||||
((IFluidHandler) tankte).fill(ForgeDirection.UP, liquid, true);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (liquid != null)
|
||||
{
|
||||
liquid.amount -= TConstruct.liquidUpdateAmount;
|
||||
if (liquid.amount <= 0)
|
||||
{
|
||||
liquid = null;
|
||||
if (!activateFaucet())
|
||||
{
|
||||
active = false;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (int side)
|
||||
{
|
||||
if (side != 0 && side != 1)
|
||||
{
|
||||
direction = (byte) side;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (float yaw, float pitch, EntityLivingBase player)
|
||||
{
|
||||
/*int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
direction = tags.getByte("Direction");
|
||||
if (tags.getBoolean("hasLiquid"))
|
||||
{
|
||||
this.liquid = FluidStack.loadFluidStackFromNBT(tags.getCompoundTag("Fluid"));
|
||||
}
|
||||
else
|
||||
this.liquid = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setByte("Direction", direction);
|
||||
tags.setBoolean("hasLiquid", liquid != null);
|
||||
if (liquid != null)
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
liquid.writeToNBT(nbt);
|
||||
tags.setTag("Fluid", nbt);
|
||||
}
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readCustomNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
if (!active)
|
||||
{
|
||||
active = true;
|
||||
activateFaucet();
|
||||
}
|
||||
else
|
||||
{
|
||||
active = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,324 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import tconstruct.inventory.FrypanContainer;
|
||||
import mantle.blocks.BlockUtils;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
/* Slots
|
||||
* 0: Frying pan item
|
||||
* 1: Fuel
|
||||
* 2-9: Food
|
||||
*/
|
||||
|
||||
public class FrypanLogic extends EquipLogic implements IActiveLogic
|
||||
{
|
||||
boolean active;
|
||||
public int fuel;
|
||||
public int fuelGague;
|
||||
public int progress;
|
||||
|
||||
public FrypanLogic()
|
||||
{
|
||||
super(10);
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "crafters.frypan";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
active = flag;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* Fuel gauge */
|
||||
public int gaugeProgressScaled (int scale)
|
||||
{
|
||||
return (progress * scale) / 1000;
|
||||
}
|
||||
|
||||
public int gaugeFuelScaled (int scale)
|
||||
{
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = fuel;
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = 1000;
|
||||
}
|
||||
}
|
||||
return (fuel * scale) / fuelGague;
|
||||
}
|
||||
|
||||
/* Item cooking */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (fuel <= 0 && canCook())
|
||||
{
|
||||
fuel = fuelGague = (int) (getItemBurnTime(inventory[1]) * 2.5);
|
||||
if (fuel > 0)
|
||||
{
|
||||
if (inventory[1].getItem().hasContainerItem()) //Fuel slot
|
||||
{
|
||||
inventory[1] = new ItemStack(inventory[1].getItem().getContainerItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[1].stackSize--;
|
||||
}
|
||||
if (inventory[1].stackSize <= 0)
|
||||
{
|
||||
inventory[1] = null;
|
||||
}
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
if (isBurning() && canCook())
|
||||
{
|
||||
progress++;
|
||||
if (progress >= 1000)
|
||||
{
|
||||
progress = 0;
|
||||
cookItems();
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
progress = 0;
|
||||
}
|
||||
if (fuel > 0)
|
||||
{
|
||||
fuel--;
|
||||
}
|
||||
if (burning != isBurning())
|
||||
{
|
||||
setActive(isBurning());
|
||||
updateInventory = true;
|
||||
}
|
||||
if (updateInventory)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void cookItems ()
|
||||
{
|
||||
if (!canCook())
|
||||
return;
|
||||
|
||||
for (int id = 2; id < 10; id++) //Check every slot
|
||||
{
|
||||
if (canCook())
|
||||
{
|
||||
ItemStack result = getResultFor(inventory[id]);
|
||||
if (result != null)
|
||||
{
|
||||
int ids = 2;
|
||||
boolean placed = false;
|
||||
while (ids < 10 && !placed) //Try to merge stacks first
|
||||
{
|
||||
if (inventory[ids] != null && inventory[ids].isItemEqual(result) && inventory[ids].stackSize < inventory[ids].getMaxStackSize())
|
||||
{
|
||||
if (inventory[ids].stackSize + result.stackSize <= inventory[ids].getMaxStackSize())
|
||||
{
|
||||
inventory[ids].stackSize += result.stackSize;
|
||||
placed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
int decrement = inventory[ids].getMaxStackSize() - inventory[ids].stackSize;
|
||||
inventory[ids].stackSize = inventory[ids].getMaxStackSize();
|
||||
result.stackSize -= decrement;
|
||||
}
|
||||
}
|
||||
ids++;
|
||||
}
|
||||
|
||||
ids = 2;
|
||||
while (!placed && ids < 10) //Place remaining in slot
|
||||
{
|
||||
if (inventory[ids] == null)
|
||||
{
|
||||
inventory[ids] = result;
|
||||
placed = true;
|
||||
}
|
||||
ids++;
|
||||
}
|
||||
|
||||
if (placed)
|
||||
decrStackSize(id, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canCook ()
|
||||
{
|
||||
for (int id = 2; id < 10; id++)
|
||||
{
|
||||
if (inventory[id] == null) //Nothing here!
|
||||
continue;
|
||||
|
||||
ItemStack result = getResultFor(inventory[id]);
|
||||
if (result == null) //Doesn't cook into anything
|
||||
continue;
|
||||
|
||||
for (int slotid = 2; slotid < 10; slotid++)
|
||||
{
|
||||
if (inventory[slotid] == null)
|
||||
return true;
|
||||
|
||||
else if (inventory[slotid].isItemEqual(result) && inventory[slotid].stackSize + result.stackSize <= inventory[slotid].getMaxStackSize())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isBurning ()
|
||||
{
|
||||
return fuel > 0;
|
||||
}
|
||||
|
||||
public ItemStack getResultFor (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
|
||||
if (result != null && result.getItem() instanceof ItemFood) //Only valid for food
|
||||
return result.copy();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int getItemBurnTime (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null)
|
||||
{
|
||||
Block block = BlockUtils.getBlockFromItem(item);
|
||||
|
||||
if (block == Blocks.wooden_slab)
|
||||
{
|
||||
return 150;
|
||||
}
|
||||
|
||||
if (block == Blocks.log)
|
||||
{
|
||||
return 2400;
|
||||
}
|
||||
|
||||
if (block.getMaterial() == Material.wood)
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item == Items.stick)
|
||||
return 100;
|
||||
if (item == Items.coal)
|
||||
return 800;
|
||||
if (item == Items.lava_bucket)
|
||||
return 20000;
|
||||
if (new ItemStack(item).equals(new ItemStack(Blocks.sapling)))
|
||||
return 100;
|
||||
if (item == Items.blaze_rod)
|
||||
return 2400;
|
||||
return GameRegistry.getFuelValue(stack);
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
active = tags.getBoolean("Active");
|
||||
fuel = tags.getInteger("Fuel");
|
||||
fuelGague = tags.getInteger("FuelGague");
|
||||
}
|
||||
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("Active", active);
|
||||
tags.setInteger("Fuel", fuel);
|
||||
tags.setInteger("FuelGague", fuelGague);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new FrypanContainer(inventoryplayer.player, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,376 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.BlockUtils;
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.inventory.FurnaceContainer;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
/* Slots
|
||||
* 0: Input
|
||||
* 1: Fuel
|
||||
* 2: Output
|
||||
* 3-16: Chest
|
||||
*/
|
||||
|
||||
public class FurnaceLogic extends InventoryLogic implements IActiveLogic, IFacingLogic
|
||||
{
|
||||
boolean active;
|
||||
public int fuel;
|
||||
public int fuelGague;
|
||||
public int progress;
|
||||
public int fuelScale = 200;
|
||||
byte direction;
|
||||
|
||||
public FurnaceLogic()
|
||||
{
|
||||
super(3);
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "container.furnace";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive ()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive (boolean flag)
|
||||
{
|
||||
active = flag;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* Fuel gauge */
|
||||
public int gaugeProgressScaled (int scale)
|
||||
{
|
||||
return (progress * scale) / fuelScale;
|
||||
}
|
||||
|
||||
public int gaugeFuelScaled (int scale)
|
||||
{
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = fuel;
|
||||
if (fuelGague == 0)
|
||||
{
|
||||
fuelGague = fuelScale;
|
||||
}
|
||||
}
|
||||
return (fuel * scale) / fuelGague;
|
||||
}
|
||||
|
||||
/* Item cooking */
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
boolean burning = isBurning();
|
||||
boolean updateInventory = false;
|
||||
if (fuel <= 0 && canSmelt())
|
||||
{
|
||||
fuel = fuelGague = (int) (getItemBurnTime(inventory[1]));
|
||||
if (fuel > 0)
|
||||
{
|
||||
if (inventory[1].getItem().hasContainerItem()) // Fuel slot
|
||||
{
|
||||
inventory[1] = new ItemStack(inventory[1].getItem().getContainerItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[1].stackSize--;
|
||||
}
|
||||
if (inventory[1].stackSize <= 0)
|
||||
{
|
||||
inventory[1] = null;
|
||||
}
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
if (isBurning() && canSmelt())
|
||||
{
|
||||
progress++;
|
||||
if (progress >= fuelScale)
|
||||
{
|
||||
progress = 0;
|
||||
cookItems();
|
||||
updateInventory = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
progress = 0;
|
||||
}
|
||||
if (fuel > 0)
|
||||
{
|
||||
fuel--;
|
||||
}
|
||||
if (burning != isBurning())
|
||||
{
|
||||
setActive(isBurning());
|
||||
updateInventory = true;
|
||||
}
|
||||
if (updateInventory)
|
||||
{
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void cookItems ()
|
||||
{
|
||||
if (this.canSmelt())
|
||||
{
|
||||
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
|
||||
|
||||
if (this.inventory[2] == null)
|
||||
{
|
||||
this.inventory[2] = itemstack.copy();
|
||||
}
|
||||
else if (this.inventory[2].isItemEqual(itemstack))
|
||||
{
|
||||
inventory[2].stackSize += itemstack.stackSize;
|
||||
}
|
||||
|
||||
--this.inventory[0].stackSize;
|
||||
|
||||
if (this.inventory[0].stackSize <= 0)
|
||||
{
|
||||
this.inventory[0] = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean canSmelt ()
|
||||
{
|
||||
if (inventory[0] == null) // Nothing here!
|
||||
return false;
|
||||
else
|
||||
{
|
||||
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]);
|
||||
if (itemstack == null)
|
||||
return false;
|
||||
if (this.inventory[2] == null)
|
||||
return true;
|
||||
if (!this.inventory[2].isItemEqual(itemstack))
|
||||
return false;
|
||||
int result = inventory[2].stackSize + itemstack.stackSize;
|
||||
return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBurning ()
|
||||
{
|
||||
return fuel > 0;
|
||||
}
|
||||
|
||||
public ItemStack getResultFor (ItemStack stack)
|
||||
{
|
||||
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
|
||||
if (result != null) // Only valid for food
|
||||
return result.copy();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getItemBurnTime (ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (stack.getItem() instanceof ItemBlock && BlockUtils.getBlockFromItem(item) != null)
|
||||
{
|
||||
Block block = BlockUtils.getBlockFromItem(item);
|
||||
|
||||
if (block == Blocks.wooden_slab)
|
||||
{
|
||||
return 150;
|
||||
}
|
||||
|
||||
if (block == Blocks.log)
|
||||
{
|
||||
return 1200;
|
||||
}
|
||||
|
||||
if (block.getMaterial() == Material.wood)
|
||||
{
|
||||
return 300;
|
||||
}
|
||||
|
||||
if (block == Blocks.coal_block)
|
||||
{
|
||||
return 16000;
|
||||
}
|
||||
}
|
||||
|
||||
if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD"))
|
||||
return 200;
|
||||
if (item == Items.stick)
|
||||
return 100;
|
||||
if (item == Items.coal)
|
||||
return 1600;
|
||||
if (item == Items.lava_bucket)
|
||||
return 20000;
|
||||
if (item == new ItemStack(Blocks.sapling).getItem())
|
||||
return 100;
|
||||
if (item == Items.blaze_rod)
|
||||
return 2400;
|
||||
return GameRegistry.getFuelValue(stack);
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
active = tags.getBoolean("Active");
|
||||
fuel = tags.getInteger("Fuel");
|
||||
fuelGague = tags.getInteger("FuelGague");
|
||||
readNetworkNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("Active", active);
|
||||
tags.setInteger("Fuel", fuel);
|
||||
tags.setInteger("FuelGague", fuelGague);
|
||||
writeNetworkNBT(tags);
|
||||
}
|
||||
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
direction = tags.getByte("Direction");
|
||||
}
|
||||
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setByte("Direction", direction);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeNetworkNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readNetworkNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new FurnaceContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setDirection (int side)
|
||||
{
|
||||
// Nope!
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setDirection (float yaw, float pitch, EntityLivingBase player)
|
||||
{
|
||||
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import mantle.world.WorldHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.util.landmine.behavior.Behavior;
|
||||
|
||||
/**
|
||||
* This logic is designed only for blocks having TileEntityLandmine as their
|
||||
* tileEntity(otherwise ClassCastException will be awarded)
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class LandmineExplodeLogic
|
||||
{
|
||||
|
||||
private final World worldObj;
|
||||
private final Entity triggerer;
|
||||
private final TileEntityLandmine tileEntity;
|
||||
private final int x, y, z;
|
||||
|
||||
public LandmineExplodeLogic(World par1World, int par2, int par3, int par4, Entity entity)
|
||||
{
|
||||
worldObj = par1World;
|
||||
this.tileEntity = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
this.x = par2;
|
||||
this.y = par3;
|
||||
this.z = par4;
|
||||
this.triggerer = entity;
|
||||
}
|
||||
|
||||
public void explode ()
|
||||
{
|
||||
if (triggerer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean preventExplode = false;
|
||||
boolean isOffensive = true;
|
||||
boolean cancelDefault = false;
|
||||
|
||||
ArrayList<ItemStack> stacks = new ArrayList<ItemStack>();
|
||||
boolean hasExploded = false;
|
||||
|
||||
if (tileEntity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tileEntity.isExploding = true;
|
||||
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory(); i++)
|
||||
{
|
||||
ItemStack currentStack = tileEntity.getStackInSlot(i);
|
||||
Behavior b = Behavior.getBehaviorFromStack(currentStack);
|
||||
if (b != null)
|
||||
{
|
||||
|
||||
if (b.doesBehaviorPreventRemovalOfBlock(currentStack))
|
||||
{
|
||||
preventExplode = true;
|
||||
}
|
||||
|
||||
if (!b.isBehaviorExchangableWithOffensive(currentStack))
|
||||
{
|
||||
isOffensive = false;
|
||||
}
|
||||
|
||||
if (b.overridesDefault())
|
||||
{
|
||||
cancelDefault = true;
|
||||
}
|
||||
|
||||
if (!stacks.isEmpty() && Behavior.arrayContainsEqualStack(stacks, currentStack) && b.effectStacks())
|
||||
{
|
||||
stacks.get(Behavior.arrayIndexOfStack(stacks, currentStack)).stackSize += currentStack.stackSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
stacks.add(currentStack.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LandmineSpecialStackLogic specialStacks = new LandmineSpecialStackLogic(worldObj, x, y, z, triggerer, isOffensive, stacks);
|
||||
specialStacks.handleSpecialStacks();
|
||||
|
||||
Iterator<ItemStack> i1 = stacks.iterator();
|
||||
while (i1.hasNext())
|
||||
{
|
||||
ItemStack currentStack = i1.next();
|
||||
Behavior b = Behavior.getBehaviorFromStack(currentStack);
|
||||
if (b != null)
|
||||
{
|
||||
if (isOffensive || !b.isOffensive(currentStack))
|
||||
{
|
||||
b.executeLogic(worldObj, x, y, z, currentStack, triggerer, !preventExplode);
|
||||
if (b.shouldItemBeRemoved(currentStack, !preventExplode))
|
||||
{
|
||||
if (b.effectStacks())
|
||||
{
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory(); i++)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i) != null)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i).isItemEqual(currentStack))
|
||||
{
|
||||
tileEntity.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean hasRemoved = false;
|
||||
|
||||
for (int i = 0; i < tileEntity.getSizeTriggerInventory() && !hasRemoved; i++)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i) != null)
|
||||
{
|
||||
if (tileEntity.getStackInSlot(i).isItemEqual(currentStack))
|
||||
{
|
||||
tileEntity.setInventorySlotContents(i, null);
|
||||
hasRemoved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Behavior defBeh = Behavior.getDefaulBehavior();
|
||||
if (defBeh != null && isOffensive && !cancelDefault)
|
||||
{
|
||||
defBeh.executeLogic(worldObj, x, y, z, null, triggerer, !preventExplode);
|
||||
}
|
||||
|
||||
if (hasExploded || defBeh != null && !preventExplode)
|
||||
{
|
||||
worldObj.removeTileEntity(x, y, z);
|
||||
WorldHelper.setBlockToAir(worldObj, x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
tileEntity.isExploding = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.util.landmine.behavior.stackCombo.SpecialStackHandler;
|
||||
|
||||
public class LandmineSpecialStackLogic
|
||||
{
|
||||
|
||||
private final World worldObj;
|
||||
private final Entity triggerer;
|
||||
private final TileEntityLandmine tileEntity;
|
||||
private final int x, y, z;
|
||||
private final boolean isOffensive;
|
||||
private final ArrayList<ItemStack> stackEffects;
|
||||
|
||||
public LandmineSpecialStackLogic(World par1World, int par2, int par3, int par4, Entity entity, boolean mayHurtPlayer, ArrayList<ItemStack> items)
|
||||
{
|
||||
worldObj = par1World;
|
||||
this.tileEntity = (TileEntityLandmine) par1World.getTileEntity(par2, par3, par4);
|
||||
this.x = par2;
|
||||
this.y = par3;
|
||||
this.z = par4;
|
||||
this.triggerer = entity;
|
||||
this.isOffensive = mayHurtPlayer;
|
||||
this.stackEffects = items;
|
||||
}
|
||||
|
||||
public void handleSpecialStacks ()
|
||||
{
|
||||
Iterator<SpecialStackHandler> i1 = SpecialStackHandler.handlers.iterator();
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
SpecialStackHandler h = i1.next();
|
||||
if (isOffensive || !h.isOffensive(stackEffects))
|
||||
{
|
||||
h.checkStack(worldObj, x, y, z, triggerer, stackEffects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.abstracts.MultiServantLogic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class LavaTankLogic extends MultiServantLogic implements IFluidHandler
|
||||
{
|
||||
public FluidTank tank;
|
||||
public int renderOffset;
|
||||
|
||||
public LavaTankLogic()
|
||||
{
|
||||
tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
int amount = tank.fill(resource, doFill);
|
||||
if (amount > 0 && doFill)
|
||||
{
|
||||
renderOffset = resource.amount;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
FluidStack amount = tank.drain(maxDrain, doDrain);
|
||||
if (amount != null && doDrain)
|
||||
{
|
||||
renderOffset = -maxDrain;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// return tank.fill(fluid, false) > 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
FluidStack fluid = null;
|
||||
if (tank.getFluid() != null)
|
||||
fluid = tank.getFluid().copy();
|
||||
return new FluidTankInfo[] { new FluidTankInfo(fluid, tank.getCapacity()) };
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public IFluidTank[] getTanks (ForgeDirection direction) {
|
||||
* return new IFluidTank[] { tank }; }
|
||||
*
|
||||
* @Override public IFluidTank getTank (ForgeDirection direction, FluidStack
|
||||
* type) { return tank; }
|
||||
*/
|
||||
|
||||
public float getFluidAmountScaled ()
|
||||
{
|
||||
return (float) (tank.getFluid().amount - renderOffset) / (float) (tank.getCapacity() * 1.01F);
|
||||
}
|
||||
|
||||
public boolean containsFluid ()
|
||||
{
|
||||
return tank.getFluid() != null;
|
||||
}
|
||||
|
||||
public int getBrightness ()
|
||||
{
|
||||
if (containsFluid())
|
||||
{
|
||||
int id = tank.getFluid().fluidID;
|
||||
if (id < 4096)
|
||||
{
|
||||
Block block = Block.getBlockById(id);
|
||||
return block.getLightValue();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
if (tags.getBoolean("hasFluid"))
|
||||
tank.setFluid(new FluidStack(tags.getInteger("itemID"), tags.getInteger("amount")));
|
||||
else
|
||||
tank.setFluid(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
FluidStack liquid = tank.getFluid();
|
||||
tags.setBoolean("hasFluid", liquid != null);
|
||||
if (liquid != null)
|
||||
{
|
||||
tags.setInteger("itemID", liquid.fluidID);
|
||||
tags.setInteger("amount", liquid.amount);
|
||||
}
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readCustomNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* Updating */
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (renderOffset > 0)
|
||||
{
|
||||
renderOffset -= 6;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class LiquidTextureLogic extends TileEntity
|
||||
{
|
||||
int texturePos;
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setLiquidType (int tex)
|
||||
{
|
||||
texturePos = tex;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public int getLiquidType ()
|
||||
{
|
||||
return texturePos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
texturePos = tags.getInteger("Texture");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
tags.setInteger("Texture", texturePos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readCustomNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.inventory.PartCrafterChestContainer;
|
||||
import tconstruct.inventory.PartCrafterContainer;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.util.IPattern;
|
||||
|
||||
public class PartBuilderLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
boolean craftedTop;
|
||||
boolean craftedBottom;
|
||||
|
||||
public PartBuilderLogic()
|
||||
{
|
||||
super(10);
|
||||
craftedTop = false;
|
||||
craftedBottom = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "toolstation.parts";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
for (int xPos = x - 1; xPos <= x + 1; xPos++)
|
||||
{
|
||||
for (int zPos = z - 1; zPos <= z + 1; zPos++)
|
||||
{
|
||||
for (int yPos = y - 1; yPos <= y + 1; yPos++)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(xPos, yPos, zPos);
|
||||
if (tile != null && tile instanceof PatternChestLogic && (x == xPos || z == zPos))
|
||||
return new PartCrafterChestContainer(inventoryplayer, this, (PatternChestLogic) tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new PartCrafterContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
//Called when emptying a slot, not when another item is placed in it
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slotID, int quantity)
|
||||
{
|
||||
ItemStack returnStack = super.decrStackSize(slotID, quantity);
|
||||
tryBuildPart(slotID);
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
public void tryBuildPart (int slotID)
|
||||
{
|
||||
if (slotID == 4 || slotID == 5)
|
||||
{
|
||||
if (!craftedTop && inventory[0] != null)
|
||||
{
|
||||
int value = PatternBuilder.instance.getPartValue(inventory[2]);
|
||||
IPattern item = (IPattern) inventory[0].getItem();
|
||||
int cost = item != null ? item.getPatternCost(inventory[0]) : 0;
|
||||
if (value > 0 && cost > 0)
|
||||
{
|
||||
int decrease = cost / value;
|
||||
if (cost % value != 0)
|
||||
decrease++;
|
||||
super.decrStackSize(2, decrease); //Call super to avoid crafting again
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory[4] != null || inventory[5] != null)
|
||||
craftedTop = true;
|
||||
else
|
||||
craftedTop = false;
|
||||
}
|
||||
|
||||
if (!craftedTop)
|
||||
buildTopPart();
|
||||
|
||||
if (slotID == 6 || slotID == 7)
|
||||
{
|
||||
if (!craftedBottom && inventory[1] != null)
|
||||
{
|
||||
int value = PatternBuilder.instance.getPartValue(inventory[3]);
|
||||
IPattern item = (IPattern) inventory[1].getItem();
|
||||
int cost = item != null ? item.getPatternCost(inventory[1]) : 0;
|
||||
if (value > 0 && cost > 0)
|
||||
{
|
||||
int decrease = cost / value;
|
||||
if (cost % value != 0)
|
||||
decrease++;
|
||||
super.decrStackSize(3, decrease); //Call super to avoid crafting again
|
||||
}
|
||||
}
|
||||
|
||||
if (inventory[6] != null || inventory[7] != null)
|
||||
craftedBottom = true;
|
||||
else
|
||||
craftedBottom = false;
|
||||
}
|
||||
|
||||
if (!craftedBottom)
|
||||
buildBottomPart();
|
||||
}
|
||||
|
||||
//Called when a slot has something placed into it.
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if ((slot == 0 || slot == 2) && !craftedTop)
|
||||
buildTopPart();
|
||||
if ((slot == 1 || slot == 3) && !craftedBottom)
|
||||
buildBottomPart();
|
||||
}
|
||||
|
||||
void buildTopPart ()
|
||||
{
|
||||
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[2], inventory[0], inventory[1]);
|
||||
if (parts != null)
|
||||
{
|
||||
inventory[4] = parts[0];
|
||||
inventory[5] = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[4] = inventory[5] = null;
|
||||
}
|
||||
}
|
||||
|
||||
void buildBottomPart ()
|
||||
{
|
||||
ItemStack[] parts = PatternBuilder.instance.getToolPart(inventory[3], inventory[1], inventory[0]);
|
||||
if (parts != null)
|
||||
{
|
||||
inventory[6] = parts[0];
|
||||
inventory[7] = parts[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
inventory[6] = inventory[7] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
craftedTop = tags.getBoolean("CraftedTop");
|
||||
craftedBottom = tags.getBoolean("CraftedBottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setBoolean("CraftedTop", craftedTop);
|
||||
tags.setBoolean("CraftedBottom", craftedBottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.inventory.PatternChestContainer;
|
||||
|
||||
public class PatternChestLogic extends InventoryLogic
|
||||
{
|
||||
public PatternChestLogic()
|
||||
{
|
||||
super(30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "toolstation.patternholder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new PatternChestContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return getDefaultName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class RedwireLogic extends TileEntity
|
||||
{
|
||||
byte facesUsed;
|
||||
byte type;
|
||||
byte distanceTravelled;
|
||||
byte maxDistance;
|
||||
|
||||
public void readCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
/*
|
||||
* hasMaster = tags.getBoolean("HasMaster"); if (hasMaster) { int
|
||||
* xCenter = tags.getInteger("xCenter"); int yCenter =
|
||||
* tags.getInteger("yCenter"); int zCenter = tags.getInteger("zCenter");
|
||||
* master = new CoordTuple(xCenter, yCenter, zCenter); masterID =
|
||||
* tags.getShort("MasterID"); masterMeat = tags.getByte("masterMeat"); }
|
||||
*/
|
||||
}
|
||||
|
||||
public void writeCustomNBT (NBTTagCompound tags)
|
||||
{
|
||||
/*
|
||||
* tags.setBoolean("HasMaster", hasMaster); if (hasMaster) {
|
||||
* tags.setInteger("xCenter", master.x); tags.setInteger("yCenter",
|
||||
* master.y); tags.setInteger("zCenter", master.z);
|
||||
* tags.setShort("MasterID", masterID); tags.setByte("masterMeat",
|
||||
* masterMeat); }
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readCustomNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readCustomNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.abstracts.MultiServantLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class SmelteryDrainLogic extends MultiServantLogic implements IFluidHandler, IFacingLogic
|
||||
{
|
||||
byte direction;
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if (hasValidMaster() && resource != null && canFill(from, resource.getFluid()))
|
||||
{
|
||||
if (doFill)
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.fill(resource, doFill);
|
||||
}
|
||||
else
|
||||
{
|
||||
return resource.amount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (hasValidMaster() && canDrain(from, null))
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.drain(maxDrain, doDrain);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain (ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return true;
|
||||
// return from == getForgeDirection();//.getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain (ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// Check that the drain is coming from the from the front of the block
|
||||
// and that the fluid to be drained is in the smeltery.
|
||||
boolean containsFluid = fluid == null;
|
||||
if (fluid != null)
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
for (FluidStack fstack : smeltery.moltenMetal)
|
||||
{
|
||||
if (fstack.fluidID == fluid.getID())
|
||||
{
|
||||
containsFluid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// return from == getForgeDirection().getOpposite() && containsFluid;
|
||||
return containsFluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo (ForgeDirection from)
|
||||
{
|
||||
if (hasValidMaster() && (from == getForgeDirection() || from == getForgeDirection().getOpposite() || from == ForgeDirection.UNKNOWN))
|
||||
{
|
||||
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getTileEntity(getMasterPosition().x, getMasterPosition().y, getMasterPosition().z);
|
||||
return smeltery.getMultiTankInfo();
|
||||
// return new FluidTankInfo[] { smeltery.getInfo() };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getRenderDirection ()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getForgeDirection ()
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS[direction];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (int side)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection (float yaw, float pitch, EntityLivingBase player)
|
||||
{
|
||||
if (pitch > 45)
|
||||
direction = 1;
|
||||
else if (pitch < -45)
|
||||
direction = 0;
|
||||
else
|
||||
{
|
||||
int facing = MathHelper.floor_double((double) (yaw / 360) + 0.5D) & 3;
|
||||
switch (facing)
|
||||
{
|
||||
case 0:
|
||||
direction = 2;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
direction = 5;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
direction = 3;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
direction = 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
direction = tags.getByte("Direction");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
tags.setByte("Direction", direction);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeToNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readFromNBT(packet.func_148857_g());
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,146 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.inventory.PatternShaperContainer;
|
||||
|
||||
public class StencilTableLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public StencilTableLogic()
|
||||
{
|
||||
super(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "toolstation.PatternShaper";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new PatternShaperContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void onInventoryChanged()
|
||||
{
|
||||
if (inventory[0] == null)
|
||||
inventory[1] = null;
|
||||
super.onInventoryChanged();
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
super.setInventorySlotContents(slot, itemstack);
|
||||
if (slot == 0 && itemstack != null && itemstack.getItem() == TRepo.blankPattern)//instanceof tconstruct.items.Pattern)
|
||||
{
|
||||
if (itemstack.getItemDamage() == 0)
|
||||
setInventorySlotContents(1, new ItemStack(TRepo.woodPattern, 1, 1));
|
||||
/*else if (itemstack.getItemDamage() == 1)
|
||||
setInventorySlotContents(1, new ItemStack(TContent.metalPattern, 1, 0));*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (slot == 1)
|
||||
{
|
||||
super.decrStackSize(0, 1);
|
||||
if (inventory[0] == null)
|
||||
return super.decrStackSize(slot, quantity);
|
||||
else
|
||||
return inventory[1].copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack ret = super.decrStackSize(slot, quantity);
|
||||
if (inventory[0] == null)
|
||||
super.decrStackSize(1, 1);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public void altDecrStackSize (int slot, int quantity)
|
||||
{
|
||||
if (inventory[slot] != null)
|
||||
{
|
||||
if (inventory[slot].stackSize <= quantity)
|
||||
{
|
||||
ItemStack stack = inventory[slot];
|
||||
inventory[slot] = null;
|
||||
return;
|
||||
}
|
||||
ItemStack split = inventory[slot].splitStack(quantity);
|
||||
if (inventory[slot].stackSize == 0)
|
||||
{
|
||||
inventory[slot] = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return StatCollector.translateToLocal("toolstation.PatternShaper");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
import mantle.blocks.iface.IServantLogic;
|
||||
import mantle.world.CoordTuple;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.blocks.component.TankAirComponent;
|
||||
|
||||
public class TankAirLogic extends InventoryLogic implements IServantLogic, ISidedInventory
|
||||
{
|
||||
TankAirComponent multitank = new TankAirComponent(TConstruct.ingotLiquidValue * 18);
|
||||
CoordTuple master;
|
||||
|
||||
public TankAirLogic()
|
||||
{
|
||||
super(1);
|
||||
}
|
||||
|
||||
public void overrideFluids (ArrayList<FluidStack> fluids)
|
||||
{
|
||||
/*
|
||||
* multitank.overrideFluids(fluids); worldObj.markBlockForUpdate(xCoord,
|
||||
* yCoord, zCoord);
|
||||
*/
|
||||
}
|
||||
|
||||
public boolean hasItem ()
|
||||
{
|
||||
return inventory[0] != null;
|
||||
}
|
||||
|
||||
public boolean hasFluids ()
|
||||
{
|
||||
return multitank.fluidlist.size() > 0;
|
||||
}
|
||||
|
||||
public List<FluidStack> getFluids ()
|
||||
{
|
||||
return multitank.fluidlist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int slot, ItemStack itemstack)
|
||||
{
|
||||
/*
|
||||
* inventory[slot] = itemstack; if (itemstack != null &&
|
||||
* itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize
|
||||
* = getInventoryStackLimit();
|
||||
* worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord,
|
||||
* itemstack.getItemDamage(), 3); worldObj.markBlockForUpdate(xCoord,
|
||||
* yCoord, zCoord); }
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return null; // Not a gui block
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultName ()
|
||||
{
|
||||
return null; // Not a gui block
|
||||
}
|
||||
|
||||
@Override
|
||||
public CoordTuple getMasterPosition ()
|
||||
{
|
||||
return master;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyMasterOfChange ()
|
||||
{
|
||||
// Probably not useful here
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPotentialMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster)
|
||||
{
|
||||
return false; // Master should be verified right after placement
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean verifyMaster (IMasterLogic logic, World world, int xMaster, int yMaster, int zMaster)
|
||||
{
|
||||
/*
|
||||
* if (master != null) //Is this even needed? return false;
|
||||
*/
|
||||
|
||||
master = new CoordTuple(xMaster, yMaster, zMaster);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidateMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster)
|
||||
{
|
||||
world.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int var1)
|
||||
{
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public boolean canUpdate() { return false; }
|
||||
*/
|
||||
|
||||
// DELETE
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
// Keep TE regardless of metadata
|
||||
public boolean shouldRefresh (int oldID, int newID, int oldMeta, int newMeta, World world, int x, int y, int z)
|
||||
{
|
||||
return oldID != newID;
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.readFromNBT(tags);
|
||||
readNetworkNBT(tags);
|
||||
multitank.readFromNBT(tags);
|
||||
}
|
||||
|
||||
public void readNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
multitank.readNetworkNBT(tags);
|
||||
super.readInventoryFromNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound tags)
|
||||
{
|
||||
super.writeToNBT(tags);
|
||||
writeNetworkNBT(tags);
|
||||
multitank.writeToNBT(tags);
|
||||
}
|
||||
|
||||
public void writeNetworkNBT (NBTTagCompound tags)
|
||||
{
|
||||
multitank.writeNetworkNBT(tags);
|
||||
super.writeInventoryToNBT(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
readNetworkNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeNetworkNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return this.getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,269 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fuj1n
|
||||
*
|
||||
*/
|
||||
public class TileEntityLandmine extends TileEntity implements IInventory
|
||||
{
|
||||
|
||||
private ItemStack[] inventory = new ItemStack[getSizeInventory()];
|
||||
private String containerName;
|
||||
|
||||
public int soundcountythingmax = 10;
|
||||
public int soundcountything = 0;
|
||||
|
||||
private boolean shouldUpdateLogic = true;
|
||||
|
||||
public int triggerType;
|
||||
public boolean isExploding = false;
|
||||
|
||||
public int getSizeTriggerInventory ()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory ()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < this.inventory.length; ++i)
|
||||
{
|
||||
if (this.inventory[i] != null)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte) i);
|
||||
this.inventory[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
par1NBTTagCompound.setTag("Items", nbttaglist);
|
||||
|
||||
par1NBTTagCompound.setInteger("triggerType", triggerType);
|
||||
|
||||
if (this.hasCustomInventoryName())
|
||||
{
|
||||
par1NBTTagCompound.setString("CustomName", this.containerName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT (NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items", 10);
|
||||
this.inventory = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.getCompoundTagAt(i);
|
||||
byte b0 = nbttagcompound1.getByte("Slot");
|
||||
|
||||
if (b0 >= 0 && b0 < this.inventory.length)
|
||||
{
|
||||
this.inventory[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
triggerType = par1NBTTagCompound.getInteger("triggerType");
|
||||
|
||||
if (par1NBTTagCompound.hasKey("CustomName"))
|
||||
{
|
||||
this.containerName = par1NBTTagCompound.getString("CustomName");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket ()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
|
||||
{
|
||||
readFromNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot (int i)
|
||||
{
|
||||
if (i < inventory.length)
|
||||
{
|
||||
return inventory[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize (int par1, int par2)
|
||||
{
|
||||
if (par1 < inventory.length)
|
||||
{
|
||||
if (inventory[par1] != null)
|
||||
{
|
||||
ItemStack itemstack;
|
||||
|
||||
if (inventory[par1].stackSize <= par2)
|
||||
{
|
||||
itemstack = inventory[par1];
|
||||
inventory[par1] = null;
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = inventory[par1].splitStack(par2);
|
||||
|
||||
if (inventory[par1].stackSize == 0)
|
||||
{
|
||||
inventory[par1] = null;
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int i)
|
||||
{
|
||||
if (i < inventory.length && this.inventory[i] != null)
|
||||
{
|
||||
ItemStack itemstack = this.inventory[i];
|
||||
this.inventory[i] = null;
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents (int i, ItemStack itemstack)
|
||||
{
|
||||
if (i < inventory.length)
|
||||
{
|
||||
inventory[i] = itemstack;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return this.hasCustomInventoryName() ? this.containerName : "Landmine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return containerName != null && containerName.length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit ()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
public void setGuiDisplayName (String par1Str)
|
||||
{
|
||||
this.containerName = par1Str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer (EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D,
|
||||
(double) this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty ()
|
||||
{
|
||||
super.markDirty();
|
||||
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot (int i, ItemStack itemstack)
|
||||
{
|
||||
// Should automatic camo insertion be allowed.
|
||||
if (i == 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Here for mDiyo to decide if he wants automation for
|
||||
// insertion/extraction of the items to be an option.
|
||||
// Would be useful for building automated mine laying machines.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setSoundPlayed ()
|
||||
{
|
||||
soundcountythingmax = 35;
|
||||
soundcountything = soundcountythingmax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity ()
|
||||
{
|
||||
if (shouldUpdateLogic)
|
||||
{
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
shouldUpdateLogic = false;
|
||||
}
|
||||
if (soundcountything > 0)
|
||||
{
|
||||
soundcountything--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.inventory.ToolForgeContainer;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
|
||||
/* Simple class for storing items in the block
|
||||
*/
|
||||
|
||||
public class ToolForgeLogic extends ToolStationLogic implements ISidedInventory
|
||||
{
|
||||
ItemStack previousTool;
|
||||
String toolName;
|
||||
|
||||
public ToolForgeLogic()
|
||||
{
|
||||
super(6);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "crafters.ToolForge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new ToolForgeContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildTool (String name)
|
||||
{
|
||||
toolName = name;
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], inventory[4], name);
|
||||
if (inventory[0] == null)
|
||||
inventory[0] = tool;
|
||||
else
|
||||
{
|
||||
NBTTagCompound tags = inventory[0].getTagCompound();
|
||||
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
|
||||
{
|
||||
inventory[0] = tool;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.abstracts.InventoryLogic;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.inventory.ToolStationContainer;
|
||||
import tconstruct.library.crafting.ToolBuilder;
|
||||
|
||||
/* Simple class for storing items in the block
|
||||
*/
|
||||
|
||||
public class ToolStationLogic extends InventoryLogic implements ISidedInventory
|
||||
{
|
||||
public ItemStack previousTool;
|
||||
public String toolName;
|
||||
|
||||
public ToolStationLogic()
|
||||
{
|
||||
super(4);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
public ToolStationLogic(int slots)
|
||||
{
|
||||
super(slots);
|
||||
toolName = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropInventorySlot (int slot)
|
||||
{
|
||||
if (slot == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing (int var1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultName ()
|
||||
{
|
||||
return "crafters.ToolStation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
|
||||
{
|
||||
return new ToolStationContainer(inventoryplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty ()
|
||||
{
|
||||
buildTool(toolName);
|
||||
if (this.worldObj != null)
|
||||
{
|
||||
this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
||||
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void buildTool (String name)
|
||||
{
|
||||
toolName = name;
|
||||
ItemStack tool = ToolBuilder.instance.buildTool(inventory[1], inventory[2], inventory[3], name);
|
||||
if (inventory[0] == null)
|
||||
inventory[0] = tool;
|
||||
else
|
||||
{
|
||||
NBTTagCompound tags = inventory[0].getTagCompound();
|
||||
if (!tags.getCompoundTag("InfiTool").hasKey("Built"))
|
||||
{
|
||||
inventory[0] = tool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setToolname (String name)
|
||||
{
|
||||
toolName = name;
|
||||
buildTool(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide (int side)
|
||||
{
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem (int i, ItemStack itemstack, int j)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory ()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory ()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package tconstruct.blocks.logic;
|
||||
|
||||
import mantle.blocks.abstracts.AdaptiveInventoryLogic;
|
||||
import mantle.blocks.iface.IActiveLogic;
|
||||
import mantle.blocks.iface.IFacingLogic;
|
||||
import mantle.blocks.iface.IMasterLogic;
|
||||
|
||||
//Not actually abstract
|
||||
public abstract class TowerFurnaceLogic extends AdaptiveInventoryLogic implements IActiveLogic, IFacingLogic, IMasterLogic
|
||||
{
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.BlockFluidClassic;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import tconstruct.entity.BlueSlime;
|
||||
import tconstruct.world.entity.BlueSlime;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -99,7 +99,7 @@ public class SlimeGrass extends MantleBlock
|
||||
@Override
|
||||
public void onPlantGrow (World world, int x, int y, int z, int sourceX, int sourceY, int sourceZ)
|
||||
{
|
||||
world.setBlock(x, y, z, TRepo.craftedSoil, 5, 3);
|
||||
world.setBlock(x, y, z, TinkerTools.craftedSoil, 5, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,7 +109,7 @@ public class SlimeGrass extends MantleBlock
|
||||
{
|
||||
if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && par1World.getBlockLightOpacity(par2, par3 + 1, par4) > 2)
|
||||
{
|
||||
par1World.setBlock(par2, par3, par4, TRepo.craftedSoil, 5, 3);
|
||||
par1World.setBlock(par2, par3, par4, TinkerTools.craftedSoil, 5, 3);
|
||||
}
|
||||
else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ public class SlimeGrass extends MantleBlock
|
||||
return;
|
||||
}
|
||||
int blockMeta = par1World.getBlockMetadata(posX, posY, posZ);
|
||||
if (block == TRepo.craftedSoil)
|
||||
if (block == TinkerTools.craftedSoil)
|
||||
{
|
||||
if (blockMeta == 5)
|
||||
par1World.setBlock(posX, posY, posZ, (Block) this, 0, 3);
|
||||
@@ -145,6 +145,6 @@ public class SlimeGrass extends MantleBlock
|
||||
if (metadata == 1)
|
||||
return Blocks.dirt;
|
||||
else
|
||||
return TRepo.craftedSoil;
|
||||
return TinkerTools.craftedSoil;
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.world.TinkerWorld;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -103,7 +103,7 @@ public class SlimeLeaves extends BlockLeaves
|
||||
@Override
|
||||
public Item getItemDropped (int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
||||
{
|
||||
return Item.getItemFromBlock(TRepo.slimeSapling);
|
||||
return Item.getItemFromBlock(TinkerWorld.slimeSapling);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,7 +151,7 @@ public class SlimeLeaves extends BlockLeaves
|
||||
|
||||
if ((meta & 3) == 0 && world.rand.nextInt(dropChance) == 0)
|
||||
{
|
||||
this.dropBlockAsItem(world, x, y, z, new ItemStack(TRepo.strangeFood, 1, 0));
|
||||
this.dropBlockAsItem(world, x, y, z, new ItemStack(TinkerWorld.strangeFood, 1, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
import tconstruct.common.TContent;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.worldgen.SlimeTreeGen;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.world.TinkerWorld;
|
||||
import tconstruct.world.gen.SlimeTreeGen;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class SlimeSapling extends BlockSapling
|
||||
@Override
|
||||
public boolean canPlaceBlockOn (Block id)
|
||||
{
|
||||
return id == Blocks.grass || id == Blocks.dirt || id == TRepo.slimeGrass || id == TRepo.craftedSoil;
|
||||
return id == Blocks.grass || id == Blocks.dirt || id == TinkerWorld.slimeGrass || id == TinkerTools.craftedSoil;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,8 +13,8 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.client.block.BarricadeRender;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.world.model.BarricadeRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tconstruct.client.block.PunjiRender;
|
||||
import tconstruct.common.TRepo;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.world.TinkerWorld;
|
||||
import tconstruct.world.model.PunjiRender;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class Punji extends MantleBlock
|
||||
if (meta < 4)
|
||||
{
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && stack.getItem() == Item.getItemFromBlock(TRepo.punji))
|
||||
if (stack != null && stack.getItem() == Item.getItemFromBlock(TinkerWorld.punji))
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta + 1, 3);
|
||||
world.playSoundEffect((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), this.stepSound.soundName, (this.stepSound.getVolume() + 1.0F) / 2.0F,
|
||||
|
||||
Reference in new issue
Block a user