1.6.2 test - Finished liquids, added connected textures on glass

This commit is contained in:
mDiyo committed 2013-07-26 21:18:53 -07:00
1 parent 40c6f445a2
commit a80fcbce86
704 files changed
+60909

No files matched your search

+136
View File
@@ -0,0 +1,136 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.GlowstoneAggregator;
import tconstruct.common.TProxyCommon;
import tconstruct.crystal.TheftValueTracker;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.blocks.InventoryBlock;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Aggregator extends InventoryBlock
{
public String[] textureNames = { "glowstone_top", "glowstone_top_inactive", "glowstone_side", "glowstone_bottom" };
public Icon[] icons;
public Aggregator(int id)
{
super(id, Material.iron);
setHardness(2.0f);
this.setCreativeTab(TConstructRegistry.blockTab);
setLightValue(1.0f);
}
@Override
public int damageDropped (int meta)
{
return meta;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IconRegister iconRegister)
{
this.icons = new Icon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:machines/aggregator_" + textureNames[i]);
}
}
@Override
public Icon getBlockTexture (IBlockAccess iblockaccess, int x, int y, int z, int side)
{
if (side == 1)
{
GlowstoneAggregator logic = (GlowstoneAggregator) iblockaccess.getBlockTileEntity(x, y, z);
if (logic.getActive())
return icons[0];
else
return icons[1];
}
return this.getIcon(side, iblockaccess.getBlockMetadata(x, y, z));
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon (int side, int meta)
{
if (side == 0)
return icons[3];
if (side == 1)
return icons[1];
return icons[2];
//return icons[meta];
}
@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.isRemote)
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, 4);
}
@Override
public void breakBlock (World world, int x, int y, int z, int par5, int par6)
{
super.breakBlock(world, x, y, z, par5, par6);
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -4);
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
list.add(new ItemStack(id, 1, 0));
/*for (int iter = 0; iter < icons.length; iter++)
{
list.add(new ItemStack(id, 1, iter));
}*/
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
return new GlowstoneAggregator();
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
return TProxyCommon.glowstoneAggregatorGui;
}
@Override
public Object getModInstance ()
{
return TConstruct.instance;
}
@Override
public String[] getTextureNames ()
{
return textureNames;
}
public void updateCrystalValue (World world, int x, int y, int z)
{
GlowstoneAggregator logic = (GlowstoneAggregator) world.getBlockTileEntity(x, y, z);
logic.updateCrystalValue();
}
}
+363
View File
@@ -0,0 +1,363 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.DryingRackLogic;
import tconstruct.client.block.DryingRackRender;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.blocks.InventoryBlock;
import tconstruct.library.tools.AbilityHelper;
import net.minecraft.block.Block;
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.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class DryingRack extends InventoryBlock
{
public DryingRack(int id)
{
super(id, Material.rock);
this.setCreativeTab(TConstructRegistry.blockTab);
setHardness(12);
setStepSound(soundMetalFootstep);
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
/*switch (metadata)
{
case 0:
case 1:
return new FaucetLogic();
case 2:
return new CastingBasinLogic();
default:
return null;
}*/
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;
}
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.getBlockTileEntity(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);
}
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);
}
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);
}
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 Icon getIcon (int side, int meta)
{
return Block.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 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 */
}
+108
View File
@@ -0,0 +1,108 @@
package tconstruct.blocks;
import java.util.Random;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.FrypanLogic;
import tconstruct.client.block.FrypanRender;
import tconstruct.library.blocks.InventoryBlock;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class EquipBlock extends InventoryBlock
{
public EquipBlock(int id, Material material)
{
super(id, 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" };
}
public Icon getIcon (int side, int meta)
{
return Block.blockIron.getIcon(side, meta);
}
@SideOnly(Side.CLIENT)
public void registerIcons (IconRegister 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 int idDropped (int par1, Random par2Random, int par3)
{
return 0;
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
return new FrypanLogic();
}
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);
}
}
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;
}
}
+77
View File
@@ -0,0 +1,77 @@
package tconstruct.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.Icon;
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(int id)
{
super(id, Material.glass, 3f, blockTextures);
}
public boolean isOpaqueCube ()
{
return false;
}
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
int i1 = par1IBlockAccess.getBlockId(par2, par3, par4);
return i1 == this.blockID ? 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;
}
}
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 registerIcons (IconRegister iconRegister)
{
this.icons = new Icon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:glass/" + textureNames[i]);
}
}
}
+619
View File
@@ -0,0 +1,619 @@
package tconstruct.blocks;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
/** @author fuj1n
*
*/
public class GlassBlockConnected extends Block
{
private Icon[] icons = new Icon[16];
private boolean shouldRenderSelectionBox = true;
protected String folder;
private int renderPass;
public GlassBlockConnected(int par1, String location, boolean hasAlpha)
{
super(par1, Material.glass);
this.setStepSound(soundGlassFootstep);
folder = location;
renderPass = hasAlpha ? 1 : 0;
this.setCreativeTab(TConstructRegistry.blockTab);
}
@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, int par5, int par6)
{
return par5 == this.blockID;
}
@Override
public Icon getBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return getConnectedBlockTexture(par1IBlockAccess, par2, par3, par4, par5, icons);
}
public Icon getConnectedBlockTexture (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5, Icon[] icons)
{
boolean isOpenUp = false, isOpenDown = false, isOpenLeft = false, isOpenRight = false;
switch (par5)
{
case 0:
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
{
isOpenDown = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
{
isOpenUp = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
{
isOpenLeft = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(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.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
{
isOpenDown = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 + 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4)))
{
isOpenUp = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
{
isOpenLeft = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(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.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
{
isOpenDown = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
{
isOpenUp = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
{
isOpenLeft = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(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.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
{
isOpenDown = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
{
isOpenUp = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2 - 1, par3, par4), par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4)))
{
isOpenLeft = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(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[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 4:
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
{
isOpenDown = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
{
isOpenUp = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
{
isOpenLeft = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(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.getBlockId(par2, par3 - 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4)))
{
isOpenDown = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3 + 1, par4), par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4)))
{
isOpenUp = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(par2, par3, par4 - 1), par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1)))
{
isOpenLeft = true;
}
if (shouldConnectToBlock(par1IBlockAccess, par2, par3, par4, par1IBlockAccess.getBlockId(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[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;
}
return icons[0];
}
@Override
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
int i1 = par1IBlockAccess.getBlockId(par2, par3, par4);
return i1 == this.blockID ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5);
}
@Override
public Icon 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 registerIcons (IconRegister 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");
}
}
@@ -0,0 +1,93 @@
package tconstruct.blocks;
import java.util.List;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
/** @author fuj1n
*
*/
public class GlassBlockConnectedMeta extends GlassBlockConnected
{
public String[] textures;
public Icon[][] icons;
boolean ignoreMetaForConnectedGlass = true;
public GlassBlockConnectedMeta(int par1, String location, boolean hasAlpha, String... textures)
{
super(par1, location, hasAlpha);
this.textures = textures;
this.icons = new Icon[textures.length][16];
}
@Override
public Icon getBlockTexture (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, int par5, int par6)
{
return par5 == this.blockID && (par6 == par1IBlockAccess.getBlockMetadata(par2, par3, par4) || ignoreMetaForConnectedGlass);
}
@Override
public Icon getIcon (int par1, int par2)
{
return icons[par2][0];
}
@Override
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < textures.length; i++)
{
par3List.add(new ItemStack(par1, 1, i));
}
}
@Override
public void registerIcons (IconRegister 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;
}
}
+50
View File
@@ -0,0 +1,50 @@
package tconstruct.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
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(int id, String tex)
{
super(id, Material.glass, 3f, blockTextures);
this.textureName = tex;
}
@Override
public int getRenderBlockPass ()
{
return 1;
}
public boolean isOpaqueCube ()
{
return false;
}
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side)
{
int blockID = world.getBlockId(x, y, z);
return blockID == this.blockID ? false : super.shouldSideBeRendered(world, x, y, z, side);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IconRegister iconRegister)
{
this.icons = new Icon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:glass/" + textureName + textureNames[i]);
}
}
}
+18
View File
@@ -0,0 +1,18 @@
package tconstruct.blocks;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.material.Material;
public class GlassPane extends PaneBase
{
static String blockTextures[] = { "glass_clear", "soulglass", "soulglass_clear" };
public GlassPane(int id)
{
super(id, Material.glass, "glass/", blockTextures);
this.setHardness(0.3F);
this.setStepSound(soundGlassFootstep);
this.setUnlocalizedName("tconstruct.glasspane");
this.setCreativeTab(TConstructRegistry.blockTab);
}
}
+72
View File
@@ -0,0 +1,72 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.client.block.PaneConnectedRender;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class GlassPaneConnected extends GlassBlockConnected
{
private Icon theIcon;
public GlassPaneConnected(int par1, String location, boolean hasAlpha)
{
super(par1, location, hasAlpha);
}
@Override
public int getRenderType ()
{
return PaneConnectedRender.model;
}
@Override
public void addCollisionBoxesToList (World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
{
Block.thinGlass.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
@Override
public void setBlockBoundsForItemRender ()
{
Block.thinGlass.setBlockBoundsForItemRender();
}
@Override
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
Block.thinGlass.setBlockBoundsBasedOnState(par1IBlockAccess, par2, par3, par4);
}
public Icon getSideTextureIndex ()
{
return this.theIcon;
}
public final boolean canThisPaneConnectToThisBlockID (int par1)
{
return Block.opaqueCubeLookup[par1] || par1 == this.blockID || par1 == Block.glass.blockID;
}
public void registerIcons (IconRegister par1IconRegister)
{
super.registerIcons(par1IconRegister);
this.theIcon = par1IconRegister.registerIcon("tinkersconstruct:glass/" + folder + "/glass_side");
}
public boolean canPaneConnectTo (IBlockAccess access, int x, int y, int z, ForgeDirection dir)
{
return canThisPaneConnectToThisBlockID(access.getBlockId(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ))
|| access.isBlockSolidOnSide(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false);
}
}
+34
View File
@@ -0,0 +1,34 @@
package tconstruct.blocks;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.material.Material;
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(int id)
{
super(id, Material.glass, "glass/", assembleBlockTextures());
this.setHardness(0.3F);
this.setStepSound(soundGlassFootstep);
this.setUnlocalizedName("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;
}
}
+115
View File
@@ -0,0 +1,115 @@
package tconstruct.blocks;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.GolemCoreLogic;
import tconstruct.client.block.GolemCoreRender;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.blocks.InventoryBlock;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class GolemCoreBlock extends InventoryBlock
{
public GolemCoreBlock(int id)
{
super(id, Material.rock);
this.setCreativeTab(TConstructRegistry.blockTab);
}
public boolean isOpaqueCube ()
{
return false;
}
public boolean renderAsNormalBlock ()
{
return false;
}
public int getRenderType ()
{
return GolemCoreRender.model;
}
@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)
{
GolemCoreLogic logic = (GolemCoreLogic) world.getBlockTileEntity(x, y, z);
if (!logic.isStackInSlot(0))
{
ItemStack stack = player.getCurrentEquippedItem();
stack = player.inventory.decrStackSize(player.inventory.currentItem, 1);
logic.setInventorySlotContents(0, stack);
}
else
{
ItemStack stack = logic.decrStackSize(0, 1);
if (stack != null)
addItemToInventory(player, world, x, y, z, stack);
}
world.markBlockForUpdate(x, y, z);
}
return true;
}
protected void addItemToInventory (EntityPlayer player, World world, int x, int y, int z, ItemStack 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);
}
}
public int damageDropped (int meta)
{
return meta;
}
@Override
public Icon getIcon (int side, int meta)
{
return icons[0];
}
@Override
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return true;
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
return new GolemCoreLogic();
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
return null; //Not sure if gui block or not, probably not
}
@Override
public Object getModInstance ()
{
return TConstruct.instance;
}
@Override
public String[] getTextureNames ()
{
return new String[] { "golemcore" };
}
}
File diff suppressed because it is too large. Load diff
+146
View File
@@ -0,0 +1,146 @@
package tconstruct.blocks;
import java.util.Random;
import tconstruct.blocks.logic.GolemPedestalLogic;
import tconstruct.library.blocks.InventoryBlock;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class GolemPedestalBlock extends InventoryBlock
{
/*public static int texTop;
public static int texTopp;
public static int texSide;
public static int texBottom;*/
public GolemPedestalBlock(int i)
{
super(i, Material.wood);
/*texTop = ModLoader.addOverride("/terrain.png", "/GGE/pedestaltop.png");
texTopp = ModLoader.addOverride("/terrain.png", "/GGE/pedestaltopp.png");
texSide = ModLoader.addOverride("/terrain.png", "/GGE/pedestalside.png");
texBottom = ModLoader.addOverride("/terrain.png", "/GGE/pedestalbottom.png");*/
}
/*public int getIcon(int i, int j)
{
if (i == 1)
{
return j == 0 ? texTop : texTopp;
}
if (i == 0)
{
return texBottom;
}
if (i == 2 || i == 4)
{
return texSide;
}
else
{
return texSide;
}
}*/
/*public int idDropped(int i, Random random, int j)
{
return super.idDropped(i, random, j);
}*/
/*public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving)
{
super.onBlockPlacedBy(world, i, j, k, entityliving);
ItemStack itemstack = ((EntityPlayer)entityliving).getCurrentEquippedItem();
world.setBlockMetadata(i, j, k, itemstack.getItemDamage());
}*/
public void onBlockRemoval (World world, int i, int j, int k)
{
Random random = new Random();
GolemPedestalLogic tileentitygolempedestal = (GolemPedestalLogic) world.getBlockTileEntity(i, j, k);
if (tileentitygolempedestal != null)
{
label0: for (int l = 0; l < tileentitygolempedestal.getSizeInventory(); l++)
{
ItemStack itemstack = tileentitygolempedestal.getStackInSlot(l);
if (itemstack == null)
{
continue;
}
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F;
do
{
if (itemstack.stackSize <= 0)
{
continue label0;
}
int i1 = random.nextInt(21) + 10;
if (i1 > itemstack.stackSize)
{
i1 = itemstack.stackSize;
}
itemstack.stackSize -= i1;
EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float) random.nextGaussian() * f3;
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) random.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
} while (true);
}
}
//super.onBlockRemoval(world, i, j, k);
}
public boolean blockActivated (World world, int i, int j, int k, EntityPlayer entityplayer)
{
/*ItemStack itemstack = entityplayer.getCurrentEquippedItem();
if (world.isRemote)
{
return true;
}
if (itemstack == null || itemstack != null && (itemstack.itemID >= 256 || itemstack.itemID == 0 || itemstack.itemID == Block.slowSand.blockID))
{
ModLoader.openGUI(entityplayer, new GuiGolemPedestal(entityplayer.inventory, world, i, j, k));
return true;
}
else
{
return false;
}*/
return false;
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
return new GolemPedestalLogic();
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
// TODO Auto-generated method stub
return null;
}
@Override
public Object getModInstance ()
{
return null;
}
@Override
public String[] getTextureNames ()
{
return null;
}
}
+77
View File
@@ -0,0 +1,77 @@
package tconstruct.blocks;
import java.util.List;
import java.util.Random;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.BlockSand;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
public class GravelOre extends BlockSand
{
public String[] textureNames = new String[] { "iron", "gold", "copper", "tin", "aluminum", "cobalt" };
public Icon[] icons;
public GravelOre(int id)
{
super(id, Material.craftedSnow);
this.setCreativeTab(TConstructRegistry.blockTab);
this.setStepSound(soundGravelFootstep);
}
public void registerIcons (IconRegister iconRegister)
{
this.icons = new Icon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:ore_" + textureNames[i] + "_gravel");
}
}
@Override
public Icon 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;
}
public int idDropped (int par1, Random par2Random, int par3)
{
/*if (par1 == 1)
return Item.goldNugget.itemID;*/
return this.blockID;
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 6; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
}
+246
View File
@@ -0,0 +1,246 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.blocks.logic.LavaTankLogic;
import tconstruct.client.block.TankRender;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.util.IServantLogic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidTank;
public class LavaTankBlock extends BlockContainer
{
public Icon[] icons;
public LavaTankBlock(int id)
{
super(id, Material.rock);
setHardness(12);
setCreativeTab(TConstructRegistry.blockTab);
setUnlocalizedName("TConstruct.LavaTank");
setStepSound(Block.soundGlassFootstep);
}
public String[] getTextureNames ()
{
String[] textureNames = { "lavatank_side", "lavatank_top", "searedgague_top", "searedgague_side", "searedgague_bottom", "searedwindow_top", "searedwindow_side", "searedwindow_bottom" };
return textureNames;
}
public void registerIcons (IconRegister iconRegister)
{
String[] textureNames = getTextureNames();
this.icons = new Icon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.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);
int bID = world.getBlockId(x, y, z);
return bID == this.blockID ? 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.getBlockTileEntity(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;
}
public Icon getIcon (int side, int meta)
{
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 x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ)
{
ItemStack heldItem = player.inventory.getCurrentItem();
if (heldItem != null)
{
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(player.getCurrentEquippedItem());
LavaTankLogic logic = (LavaTankLogic) world.getBlockTileEntity(x, y, z);
if (liquid != null)
{
int amount = logic.fill(ForgeDirection.UNKNOWN, liquid, false);
if (amount == liquid.amount)
{
logic.fill(ForgeDirection.UNKNOWN, liquid, true);
if (!player.capabilities.isCreativeMode)
player.inventory.setInventorySlotContents(player.inventory.currentItem, consumeItem(heldItem));
return true;
}
else
return true;
}
else if (FluidContainerRegistry.isBucket(heldItem))
{
FluidTankInfo[] tanks = logic.getTankInfo(ForgeDirection.UNKNOWN);
FluidStack fillFluid = tanks[0].fluid;//getFluid();
ItemStack fillStack = FluidContainerRegistry.fillFluidContainer(fillFluid, heldItem);
if (fillStack != null)
{
logic.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.getFluidForFilledItem(fillStack).amount, true);
if (!player.capabilities.isCreativeMode)
{
if (heldItem.stackSize == 1)
{
player.inventory.setInventorySlotContents(player.inventory.currentItem, fillStack);
}
else
{
player.inventory.setInventorySlotContents(player.inventory.currentItem, consumeItem(heldItem));
if (!player.inventory.addItemStackToInventory(fillStack))
{
player.dropPlayerItem(fillStack);
}
}
}
return true;
}
else
{
return true;
}
}
}
return false;
}
public static ItemStack consumeItem (ItemStack stack)
{
if (stack.stackSize == 1)
{
if (stack.getItem().hasContainerItem())
return stack.getItem().getContainerItemStack(stack);
else
return null;
}
else
{
stack.splitStack(1);
return stack;
}
}
@Override
public TileEntity createNewTileEntity (World world)
{
return createTileEntity(world, 0);
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 3; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
/* Data */
public int damageDropped (int meta)
{
return meta;
}
/* Updates */
public void onNeighborBlockChange (World world, int x, int y, int z, int nBlockID)
{
TileEntity logic = world.getBlockTileEntity(x, y, z);
if (logic instanceof IServantLogic)
{
((IServantLogic) logic).notifyMasterOfChange();
}
}
}
+103
View File
@@ -0,0 +1,103 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.client.block.CrystalBlockRender;
import tconstruct.common.TContent;
import tconstruct.crystal.TheftValueTracker;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
public class LightCrystalBase extends Block
{
String[] textureNames = { "amber_crystal" };
Icon[] icons;
public LightCrystalBase(int id)
{
super(id, Material.glass);
this.setCreativeTab(TConstructRegistry.blockTab);
}
@Override
public Icon getIcon (int side, int meta)
{
if (meta < 5)
return Block.glowStone.getIcon(side, meta);
if (meta < 10)
return Block.blockNetherQuartz.getIcon(side, 1);
return icons[0];
}
@Override
public boolean renderAsNormalBlock ()
{
return false;
}
@Override
public boolean isOpaqueCube ()
{
return false;
}
@Override
public int getRenderType ()
{
return CrystalBlockRender.model;
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 15; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
@Override
public void registerIcons (IconRegister iconRegister)
{
this.icons = new Icon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
}
}
@Override
public void breakBlock (World world, int x, int y, int z, int par5, int meta)
{
switch (meta % 5)
{
case 0:
case 4:
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -10);
break;
case 1:
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -20);
break;
case 2:
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -35);
break;
case 3:
TheftValueTracker.updateCrystallinity(world.provider.dimensionId, x, z, -60);
break;
}
Block block = Block.blocksList[world.getBlockId(x, y - 1, z)];
if (block == TContent.aggregator)
{
((Aggregator) block).updateCrystalValue(world, x, y - 1, z);
}
}
}
+57
View File
@@ -0,0 +1,57 @@
package tconstruct.blocks;
import net.minecraft.client.renderer.texture.IconRegister;
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.Icon;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidFinite;
import net.minecraftforge.fluids.Fluid;
import tconstruct.common.TContent;
import tconstruct.library.TConstructRegistry;
public class LiquidMetalFinite extends BlockFluidFinite
{
String texture;
public Icon stillIcon;
public Icon flowIcon;
public LiquidMetalFinite(int id, Fluid fluid, String texture)
{
super(id, fluid, TContent.liquidMetal);
this.texture = texture;
this.setCreativeTab(TConstructRegistry.blockTab);
}
@Override
public void registerIcons (IconRegister iconRegister)
{
stillIcon = iconRegister.registerIcon("tinker:" + texture);
flowIcon = iconRegister.registerIcon("tinker:" + texture + "_flow");
}
@Override
public Icon 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);
entity.setFire(15);
}
}
}
+35
View File
@@ -0,0 +1,35 @@
package tconstruct.blocks;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class MetalOre extends TConstructBlock
{
public MetalOre(int id, Material material, float hardness, String[] tex)
{
super(id, material, hardness, tex);
}
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 (int id, CreativeTabs tab, List list)
{
for (int iter = 1; iter < 6; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
}
+159
View File
@@ -0,0 +1,159 @@
package tconstruct.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
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(int id)
{
super(id, 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 Block.obsidian.getBlockHardness(world, x, y, z);
case 1:
return Block.sandStone.getBlockHardness(world, x, y, z);
case 2:
return Block.netherrack.getBlockHardness(world, x, y, z);
case 3:
return Block.stone.getBlockHardness(world, x, y, z);
case 4:
return Block.blockIron.getBlockHardness(world, x, y, z);
case 5:
return Block.blockGold.getBlockHardness(world, x, y, z);
case 6:
return Block.blockLapis.getBlockHardness(world, x, y, z);
case 7:
return Block.blockDiamond.getBlockHardness(world, x, y, z);
case 8:
return Block.blockRedstone.getBlockHardness(world, x, y, z);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Block.whiteStone.getBlockHardness(world, x, y, z);
case 13:
return Block.obsidian.getBlockHardness(world, x, y, z);
default:
return blockHardness;
}
}
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 Block.obsidian.getExplosionResistance(entity);
case 1:
return Block.sandStone.getExplosionResistance(entity);
case 2:
return Block.netherrack.getExplosionResistance(entity);
case 3:
return Block.stone.getExplosionResistance(entity);
case 4:
return Block.blockIron.getExplosionResistance(entity);
case 5:
return Block.blockGold.getExplosionResistance(entity);
case 6:
return Block.blockLapis.getExplosionResistance(entity);
case 7:
return Block.blockDiamond.getExplosionResistance(entity);
case 8:
return Block.blockRedstone.getExplosionResistance(entity);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Block.whiteStone.getExplosionResistance(entity);
case 13:
return Block.obsidian.getExplosionResistance(entity);
default:
return getExplosionResistance(entity);
}
}
@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 isBlockNormalCube (World world, int x, int y, int z)
{
return world.getBlockMetadata(x, y, z) != 8;
}
@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 registerIcons (IconRegister iconRegister)
{
this.icons = new Icon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
}
}
}
+164
View File
@@ -0,0 +1,164 @@
package tconstruct.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
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(int id)
{
super(id, 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 Block.obsidian.getBlockHardness(world, x, y, z);
case 1:
return Block.sandStone.getBlockHardness(world, x, y, z);
case 2:
return Block.netherrack.getBlockHardness(world, x, y, z);
case 4:
return Block.blockIron.getBlockHardness(world, x, y, z);
case 5:
return Block.blockGold.getBlockHardness(world, x, y, z);
case 6:
return Block.blockLapis.getBlockHardness(world, x, y, z);
case 7:
return Block.blockDiamond.getBlockHardness(world, x, y, z);
case 8:
return Block.blockRedstone.getBlockHardness(world, x, y, z);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Block.whiteStone.getBlockHardness(world, x, y, z);
case 13:
return Block.obsidian.getBlockHardness(world, x, y, z);
case 3:
case 14:
case 15:
return Block.stone.getBlockHardness(world, x, y, z);
default:
return blockHardness;
}
}
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 Block.obsidian.getExplosionResistance(entity);
case 1:
return Block.sandStone.getExplosionResistance(entity);
case 2:
return Block.netherrack.getExplosionResistance(entity);
case 4:
return Block.blockIron.getExplosionResistance(entity);
case 5:
return Block.blockGold.getExplosionResistance(entity);
case 6:
return Block.blockLapis.getExplosionResistance(entity);
case 7:
return Block.blockDiamond.getExplosionResistance(entity);
case 8:
return Block.blockRedstone.getExplosionResistance(entity);
case 9:
return 1.0F;
case 10:
return 1.5F;
case 11:
return 1.5F;
case 12:
return Block.whiteStone.getExplosionResistance(entity);
case 13:
return Block.obsidian.getExplosionResistance(entity);
case 3:
case 14:
case 15:
return Block.stone.getExplosionResistance(entity);
default:
return getExplosionResistance(entity);
}
}
@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 isBlockNormalCube (World world, int x, int y, int z)
{
return world.getBlockMetadata(x, y, z) != 8;
}
@Override
public boolean canProvidePower ()
{
return false;
}
@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 registerIcons (IconRegister iconRegister)
{
this.icons = new Icon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:bricks/" + textureNames[i]);
}
}
}
+350
View File
@@ -0,0 +1,350 @@
package tconstruct.blocks;
import java.util.List;
import java.util.Random;
import tconstruct.client.block.OreberryRender;
import tconstruct.common.TContent;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.AbilityHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeavesBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
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.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.IPlantable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class OreberryBush extends BlockLeavesBase implements IPlantable
{
Random random;
public Icon[] fastIcons;
public Icon[] fancyIcons;
public String[] textureNames;
public String[] oreTypes;
public int itemMeat;
private int subitems;
public OreberryBush(int id, String[] textureNames, int meta, int sub, String[] oreTypes)
{
super(id, 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.soundMetalFootstep);
this.setCreativeTab(TConstructRegistry.blockTab);
}
/* Berries show up at meta 12-15 */
@SideOnly(Side.CLIENT)
@Override
public void registerIcons (IconRegister iconRegister)
{
this.fastIcons = new Icon[textureNames.length];
this.fancyIcons = new Icon[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 Icon getIcon (int side, int metadata)
{
if (graphicsLevel)
{
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);
}
}
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, blockID, meta - 4, 3);
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.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, blockID, meta - 4, 3);
AbilityHelper.spawnItemAtPlayer(player, new ItemStack(TContent.oreBerries, 1, meta % 4 + itemMeat));
return true;
}
return false;
}
/* Render logic */
@Override
public boolean isOpaqueCube ()
{
return false;
}
public void setGraphicsLevel (boolean flag)
{
graphicsLevel = flag;
}
@Override
public boolean renderAsNormalBlock ()
{
return false;
}
public int getRenderType ()
{
return OreberryRender.model;
}
public boolean shouldSideBeRendered (IBlockAccess iblockaccess, int x, int y, int z, int meta)
{
if (meta > 7 || graphicsLevel)
{
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, blockID, 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);
}
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 */
@Override
public int getFlammability (IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
return 0;
}
@Override
public boolean isFlammable (IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face)
{
return false;
}
@Override
public int getFireSpreadSpeed (World world, int x, int y, int z, int metadata, ForgeDirection face)
{
return 0;
}
/**
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
*/
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks (int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int var4 = 8; var4 < 8 + subitems; ++var4)
{
par3List.add(new ItemStack(par1, 1, var4));
}
}
@Override
public EnumPlantType getPlantType (World world, int x, int y, int z)
{
return EnumPlantType.Cave;
}
@Override
public int getPlantID (World world, int x, int y, int z)
{
return this.blockID;
}
@Override
public int getPlantMetadata (World 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);
}
}
@@ -0,0 +1,49 @@
package tconstruct.blocks;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
public class OreberryBushEssence extends OreberryBush implements IPlantable
{
public OreberryBushEssence(int id, String[] textureNames, int meta, int sub, String[] oreTypes)
{
super(id, 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, blockID, meta + 4, 3);
}
}
/*else if (meta < 8)
{
world.setBlock(x, y, z, blockID, meta + 4, 3);
}*/
}
}
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;*/
}
}
+187
View File
@@ -0,0 +1,187 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.client.block.PaneRender;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPane;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PaneBase extends Block
{
public String[] textureNames;
public String folder;
public Icon[] icons;
public Icon[] sideIcons;
public PaneBase(int id, Material material, String folder, String[] blockTextures)
{
super(id, material);
textureNames = blockTextures;
this.folder = folder;
}
public boolean canConnectTo (int blockID)
{
Block block = Block.blocksList[blockID];
return Block.opaqueCubeLookup[blockID] || block instanceof PaneBase || block instanceof BlockPane || blockID == Block.glass.blockID;
}
public Icon getSideTextureIndex (int meta)
{
return sideIcons[meta];
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IconRegister iconRegister)
{
this.icons = new Icon[textureNames.length];
this.sideIcons = new Icon[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 Icon getIcon (int side, int meta)
{
return icons[meta];
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < textureNames.length; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
public boolean isOpaqueCube ()
{
return false;
}
public boolean renderAsNormalBlock ()
{
return false;
}
public int getRenderType ()
{
return PaneRender.model;
}
public boolean shouldSideBeRendered (IBlockAccess iblockaccess, int i, int j, int k, int l)
{
int bID = iblockaccess.getBlockId(i, j, k);
if (Block.blocksList[bID] instanceof PaneBase || Block.blocksList[bID] 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.getBlockId(x, y, z - 1));
boolean north = canConnectTo(world.getBlockId(x, y, z + 1));
boolean east = canConnectTo(world.getBlockId(x - 1, y, z));
boolean west = canConnectTo(world.getBlockId(x + 1, y, z));
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);
}
}
public void setBlockBoundsForItemRender ()
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
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.getBlockId(i, j, k - 1));
boolean flag1 = canConnectTo(iblockaccess.getBlockId(i, j, k + 1));
boolean flag2 = canConnectTo(iblockaccess.getBlockId(i - 1, j, k));
boolean flag3 = canConnectTo(iblockaccess.getBlockId(i + 1, j, k));
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);
}
}
+217
View File
@@ -0,0 +1,217 @@
package tconstruct.blocks;
import java.util.Random;
import tconstruct.client.block.BallRepeaterRender;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneLogic;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.Direction;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class RedstoneBallRepeater extends BlockRedstoneLogic
{
/** The offsets for the two torches in redstone repeater blocks. */
public static final double[] repeaterTorchOffset = new double[] { -0.0625D, 0.0625D, 0.1875D, 0.3125D };
/** The states in which the redstone repeater blocks can be. */
public static final int[] repeaterState = new int[] { 1, 2, 3, 4 };
@SideOnly(Side.CLIENT)
public static Icon field_94413_c;
@SideOnly(Side.CLIENT)
public static Icon field_94410_cO;
@SideOnly(Side.CLIENT)
public static Icon field_94411_cP;
@SideOnly(Side.CLIENT)
public static Icon field_94412_cQ;
public RedstoneBallRepeater(int par1, boolean par2)
{
super(par1, par2);
//this.setCreativeTab(CreativeTabs.tabRedstone);
}
/**
* Called upon block activation (right click on the block.)
*/
public boolean onBlockActivated (World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
int i1 = par1World.getBlockMetadata(par2, par3, par4);
int j1 = (i1 & 12) >> 2;
j1 = j1 + 1 << 2 & 12;
par1World.setBlockMetadataWithNotify(par2, par3, par4, j1 | i1 & 3, 3);
return true;
}
public int func_94481_j_ (int par1)
{
return repeaterState[(par1 & 12) >> 2] * 2;
}
public BlockRedstoneLogic func_94485_e ()
{
return Block.redstoneRepeaterActive;
}
public BlockRedstoneLogic func_94484_i ()
{
return Block.redstoneRepeaterIdle;
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped (int par1, Random par2Random, int par3)
{
return this.blockID;
}
@SideOnly(Side.CLIENT)
/**
* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)
*/
/*public int idPicked(World par1World, int par2, int par3, int par4)
{
return Item.redstoneRepeater.itemID;
}*/
/**
* The type of render function that is called for this block
*/
public int getRenderType ()
{
return BallRepeaterRender.model;
}
public boolean func_94476_e (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return this.func_94482_f(par1IBlockAccess, par2, par3, par4, par5) > 0;
}
public boolean func_94477_d (int par1)
{
return isRedstoneRepeaterBlockID(par1);
}
public static boolean isPowerProviderOrWire (IBlockAccess par0IBlockAccess, int par1, int par2, int par3, int par4)
{
int i1 = par0IBlockAccess.getBlockId(par1, par2, par3);
if (i1 == Block.redstoneWire.blockID)
{
return true;
}
else if (i1 == 0)
{
return false;
}
else if (!Block.redstoneRepeaterIdle.func_94487_f(i1))
{
return (Block.blocksList[i1] != null && Block.blocksList[i1].canConnectRedstone(par0IBlockAccess, par1, par2, par3, par4));
}
else
{
int j1 = par0IBlockAccess.getBlockMetadata(par1, par2, par3);
return par4 == (j1 & 3) || par4 == Direction.rotateOpposite[j1 & 3];
}
}
@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)
{
if (this.isRepeaterPowered)
{
int l = par1World.getBlockMetadata(par2, par3, par4);
int i1 = getDirection(l);
double d0 = (double) ((float) par2 + 0.5F) + (double) (par5Random.nextFloat() - 0.5F) * 0.2D;
double d1 = (double) ((float) par3 + 0.4F) + (double) (par5Random.nextFloat() - 0.5F) * 0.2D;
double d2 = (double) ((float) par4 + 0.5F) + (double) (par5Random.nextFloat() - 0.5F) * 0.2D;
double d3 = 0.0D;
double d4 = 0.0D;
if (par5Random.nextInt(2) == 0)
{
switch (i1)
{
case 0:
d4 = -0.3125D;
break;
case 1:
d3 = 0.3125D;
break;
case 2:
d4 = 0.3125D;
break;
case 3:
d3 = -0.3125D;
}
}
else
{
int j1 = (l & 12) >> 2;
switch (i1)
{
case 0:
d4 = repeaterTorchOffset[j1];
break;
case 1:
d3 = -repeaterTorchOffset[j1];
break;
case 2:
d4 = -repeaterTorchOffset[j1];
break;
case 3:
d3 = repeaterTorchOffset[j1];
}
}
par1World.spawnParticle("reddust", d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
}
}
public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4)
{
return par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || par1World.getBlockId(par2, par3 - 1, par4) == Block.glowStone.blockID;
}
/**
* 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)
{
super.breakBlock(par1World, par2, par3, par4, par5, par6);
this.func_94483_i_(par1World, par2, par3, par4);
}
@Override
public int colorMultiplier (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
return 8388608;
}
public void registerIcons (IconRegister par1IconRegister)
{
this.field_94413_c = par1IconRegister.registerIcon("tinker:repeaterDust_cross");
this.field_94410_cO = par1IconRegister.registerIcon("tinker:repeaterDust_line");
this.field_94411_cP = par1IconRegister.registerIcon("tinker:repeaterDust_cross_overlay");
this.field_94412_cQ = par1IconRegister.registerIcon("tinker:repeaterDust_line_overlay");
this.blockIcon = this.field_94413_c;
}
@SideOnly(Side.CLIENT)
public static Icon func_94409_b (String par0Str)
{
return par0Str == "repeaterDust_cross" ? field_94413_c : (par0Str == "repeaterDust_line" ? field_94410_cO : (par0Str == "repeaterDust_cross_overlay" ? field_94411_cP
: (par0Str == "repeaterDust_line_overlay" ? field_94412_cQ : null)));
}
}
+205
View File
@@ -0,0 +1,205 @@
package tconstruct.blocks;
import static net.minecraftforge.common.ForgeDirection.UP;
import java.util.List;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.DrawbridgeLogic;
import tconstruct.blocks.logic.FirestarterLogic;
import tconstruct.client.block.MachineRender;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.blocks.InventoryBlock;
import tconstruct.library.util.IActiveLogic;
import tconstruct.library.util.IFacingLogic;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class RedstoneMachine extends InventoryBlock
{
public RedstoneMachine(int id)
{
super(id, Material.iron);
this.setCreativeTab(TConstructRegistry.blockTab);
setHardness(12);
setStepSound(soundMetalFootstep);
}
@Override
public int getLightValue (IBlockAccess world, int x, int y, int z)
{
if (world.getBlockMetadata(x, y, z) == 0)
{
TileEntity logic = world.getBlockTileEntity(x, y, z);
if (logic != null && logic instanceof IInventory)
{
if (((IInventory) logic).getStackInSlot(1) != null)
{
return lightValue[((IInventory) logic).getStackInSlot(1).itemID];
}
}
}
return super.getLightValue(world, x, y, z);
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
switch (metadata)
{
case 0:
return new DrawbridgeLogic();
case 1:
return new FirestarterLogic();
default:
return null;
}
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
int meta = world.getBlockMetadata(x, y, z);
switch (meta)
{
case 0:
return TConstruct.proxy.drawbridgeGui;
}
return null;
}
@Override
public Object getModInstance ()
{
return TConstruct.instance;
}
/* Rendering */
@Override
public String[] getTextureNames ()
{
String[] textureNames = { "drawbridge_top", "drawbridge_side", "drawbridge_bottom", "drawbridge_top_face", "drawbridge_side_face", "drawbridge_bottom_face", "firestarter_top",
"firestarter_side", "firestarter_bottom" };
return textureNames;
}
@Override
public void registerIcons (IconRegister iconRegister)
{
String[] textureNames = getTextureNames();
this.icons = new Icon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:machines/" + textureNames[i]);
}
}
@Override
public Icon getIcon (int side, int meta)
{
if (meta == 0)
{
if (side == 5)
return icons[5];
return icons[getTextureIndex(side)];
}
if (meta == 1)
{
return icons[getTextureIndex(side) + 6];
}
return icons[0];
}
public Icon getBlockTexture (IBlockAccess world, int x, int y, int z, int side)
{
TileEntity logic = world.getBlockTileEntity(x, y, z);
short direction = (logic instanceof IFacingLogic) ? ((IFacingLogic) logic).getRenderDirection() : 0;
int meta = world.getBlockMetadata(x, y, z);
if (meta == 0)
{
DrawbridgeLogic drawbridge = (DrawbridgeLogic) logic;
ItemStack stack = drawbridge.getStackInSlot(1);
if (stack != null && stack.itemID < 4096)
{
Block block = Block.blocksList[stack.itemID];
if (block != null && block.renderAsNormalBlock())
return block.getIcon(side, stack.getItemDamage());
}
if (side == direction)
{
return icons[getTextureIndex(side) + 3];
}
else
{
return icons[getTextureIndex(side)];
}
}
if (meta == 1)
{
if (side == direction)
{
return icons[6];
}
else if (side / 2 == direction / 2)
{
return icons[8];
}
return icons[7];
}
return icons[0];
}
public int getTextureIndex (int side)
{
if (side == 0)
return 2;
if (side == 1)
return 0;
return 1;
}
public int getRenderType ()
{
return MachineRender.model;
}
public boolean isFireSource (World world, int x, int y, int z, int metadata, ForgeDirection side)
{
if (metadata == 1)
return side == UP;
return false;
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 2; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
/* Redstone */
public void onNeighborBlockChange (World world, int x, int y, int z, int neighborBlockID)
{
IActiveLogic logic = (IActiveLogic) world.getBlockTileEntity(x, y, z);
logic.setActive(world.isBlockIndirectlyGettingPowered(x, y, z));
}
}
+339
View File
@@ -0,0 +1,339 @@
package tconstruct.blocks;
import java.util.List;
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.blocks.InventoryBlock;
import tconstruct.library.tools.AbilityHelper;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class SearedBlock extends InventoryBlock
{
public SearedBlock(int id)
{
super(id, Material.rock);
this.setCreativeTab(TConstructRegistry.blockTab);
setHardness(12);
setStepSound(soundMetalFootstep);
}
@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.getBlockTileEntity(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.getBlockTileEntity(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);
}
else
{
if (logic.isStackInSlot(1))
{
ItemStack stack = logic.decrStackSize(1, 1);
if (stack != null)
addItemToInventory(player, world, x, y, z, stack);
}
else if (logic.isStackInSlot(0))
{
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.getBlockTileEntity(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);
}
else
{
if (logic.isStackInSlot(1))
{
ItemStack stack = logic.decrStackSize(1, 1);
if (stack != null)
addItemToInventory(player, world, x, y, z, stack);
}
else if (logic.isStackInSlot(0))
{
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;
}
@Override
public String[] getTextureNames ()
{
String[] textureNames = { "castingtable_top", "castingtable_side", "castingtable_bottom", "faucet", "blockcast_top", "blockcast_side", "blockcast_bottom" };
return textureNames;
}
@Override
public Icon 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 (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 */
public boolean canConnectRedstone (IBlockAccess world, int x, int y, int z, int side)
{
return world.getBlockMetadata(x, y, z) == 1;
}
public void onNeighborBlockChange (World world, int x, int y, int z, int neighborBlockID)
{
if (world.isBlockIndirectlyGettingPowered(x, y, z) && world.getBlockMetadata(x, y, z) == 1)
{
FaucetLogic logic = (FaucetLogic) world.getBlockTileEntity(x, y, z);
logic.setActive(true);
}
}
}
+52
View File
@@ -0,0 +1,52 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.common.TContent;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class SearedSlab extends SlabBase
{
public SearedSlab(int id)
{
super(id, Material.rock);
this.setCreativeTab(TConstructRegistry.blockTab);
setHardness(12F);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IconRegister iconRegister)
{
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon (int side, int meta)
{
meta = meta % 8;
if (meta == 0)
return TContent.smeltery.getIcon(side, 2);
if (meta <= 3)
return TContent.smeltery.getIcon(side, meta + 3);
return TContent.smeltery.getIcon(side, meta + 4);
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 8; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
}
+58
View File
@@ -0,0 +1,58 @@
package tconstruct.blocks;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class SlabBase extends Block
{
public SlabBase(int id, Material material)
{
super(id, material);
}
@Override
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity)
{
setBlockBoundsBasedOnState(world, x, y, z);
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity);
}
public void setBlockBoundsForItemRender ()
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z) / 8;
float minY = meta == 1 ? 0.5F : 0.0F;
float maxY = meta == 1 ? 1.0F : 0.5F;
setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F);
}
public int onBlockPlaced (World par1World, int blockX, int blockY, int blockZ, int side, float clickX, float clickY, float clickZ, int metadata)
{
if (side == 1)
return metadata;
if (side == 0 || clickY >= 0.5F)
return metadata | 8;
return metadata;
}
public boolean isOpaqueCube ()
{
return false;
}
public boolean renderAsNormalBlock ()
{
return false;
}
}
+280
View File
@@ -0,0 +1,280 @@
package tconstruct.blocks;
import java.util.List;
import java.util.Random;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.MultiServantLogic;
import tconstruct.blocks.logic.SmelteryDrainLogic;
import tconstruct.blocks.logic.SmelteryLogic;
import tconstruct.client.block.SmelteryRender;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.blocks.InventoryBlock;
import tconstruct.library.util.IFacingLogic;
import tconstruct.library.util.IMasterLogic;
import tconstruct.library.util.IServantLogic;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class SmelteryBlock extends InventoryBlock
{
Random rand;
public SmelteryBlock(int id)
{
super(id, Material.rock);
setHardness(12F);
setStepSound(soundMetalFootstep);
rand = new Random();
this.setCreativeTab(TConstructRegistry.blockTab);
this.setUnlocalizedName("tconstruct.Smeltery");
}
/* Rendering */
@Override
public int getRenderType ()
{
return 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" };
return textureNames;
}
public Icon 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];
}
public Icon getBlockTexture (IBlockAccess world, int x, int y, int z, int side)
{
TileEntity logic = world.getBlockTileEntity(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;
}*/
public int damageDropped (int meta)
{
return meta;
}
public int quantityDropped (Random random)
{
return 1;
}
@Override
public Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer)
{
return TConstruct.proxy.smelteryGuiID;
}
public void randomDisplayTick (World world, int x, int y, int z, Random random)
{
if (isActive(world, x, y, z))
{
TileEntity logic = world.getBlockTileEntity(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;
}
}
}
public int getLightValue (IBlockAccess world, int x, int y, int z)
{
return !isActive(world, x, y, z) ? 0 : 9;
}
//@Override
/*public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 9; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}*/
@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
{
player.openGui(getModInstance(), integer, world, x, y, z);
return true;
}
}
@Override
public TileEntity createTileEntity (World world, int metadata)
{
switch (metadata)
{
case 0:
return new SmelteryLogic();
case 1:
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)
onBlockPlacedElsewhere(world, x, y, z, entityliving);
}
public void onBlockPlacedElsewhere (World world, int x, int y, int z, EntityLivingBase entityliving)
{
SmelteryLogic logic = (SmelteryLogic) world.getBlockTileEntity(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 (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 12; iter++)
{
if (iter != 3)
list.add(new ItemStack(id, 1, iter));
}
}
/* Updating */
public void onNeighborBlockChange (World world, int x, int y, int z, int nBlockID)
{
TileEntity logic = world.getBlockTileEntity(x, y, z);
if (logic instanceof IServantLogic)
{
((IServantLogic) logic).notifyMasterOfChange();
}
else if (logic instanceof IMasterLogic)
{
((IMasterLogic) logic).notifyChange(x, y, z);
}
}
}
+49
View File
@@ -0,0 +1,49 @@
package tconstruct.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EnumCreatureAttribute;
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" };
public SoilBlock(int id)
{
super(id, Material.ground, 3.0F, soilTypes);
}
@Override
public void onEntityWalking (World world, int x, int y, int z, Entity entity)
{
if (entity instanceof EntityLiving)
{
EntityLiving living = ((EntityLiving) entity);
if (living.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD)
{
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 3)
{
living.heal(1);
}
else if (metadata == 4)
{
living.attackEntityFrom(DamageSource.magic, 1);
living.setFire(1);
}
}
}
}
/*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);
}
}*/
}
+98
View File
@@ -0,0 +1,98 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.common.TContent;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class SoilSlab extends SlabBase
{
public SoilSlab(int id)
{
super(id, Material.ground);
this.setCreativeTab(TConstructRegistry.blockTab);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon("tinker:grass_top");
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon (int side, int meta)
{
switch (meta % 8)
{
case 0:
return this.blockIcon;//Block.grass.getIcon(1, 0);
case 1:
return Block.dirt.getIcon(side, 0);
case 2:
return Block.mycelium.getIcon(1, 0);
default:
return TContent.craftedSoil.getIcon(side, meta - 3);
}
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 8; iter++)
{
list.add(new ItemStack(id, 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();
l += (i2 & 16711680) >> 16;
i1 += (i2 & 65280) >> 8;
j1 += i2 & 255;
}
}
return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255;
}
}
+59
View File
@@ -0,0 +1,59 @@
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.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(int id)
{
super(id, 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 (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < textureNames.length; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
}
+69
View File
@@ -0,0 +1,69 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.common.TContent;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class SpeedSlab extends SlabBase
{
public SpeedSlab(int id)
{
super(id, Material.rock);
this.setCreativeTab(TConstructRegistry.blockTab);
setHardness(3F);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IconRegister iconRegister)
{
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon (int side, int meta)
{
meta = meta % 8;
return TContent.speedBlock.getIcon(side, meta);
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 7; iter++)
{
list.add(new ItemStack(id, 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;
}
}
}
+308
View File
@@ -0,0 +1,308 @@
package tconstruct.blocks;
import static net.minecraftforge.common.ForgeDirection.EAST;
import static net.minecraftforge.common.ForgeDirection.NORTH;
import static net.minecraftforge.common.ForgeDirection.SOUTH;
import static net.minecraftforge.common.ForgeDirection.WEST;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
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 Block
{
public StoneTorch(int id)
{
super(id, Material.circuits);
this.setCreativeTab(CreativeTabs.tabDecorations);
setLightValue(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)
*/
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.
*/
public boolean isOpaqueCube ()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock ()
{
return false;
}
/**
* The type of render function that is called for this block
*/
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(par2, par3, par4))
{
return true;
}
else
{
int l = par1World.getBlockId(par2, par3, par4);
return (Block.blocksList[l] != null && Block.blocksList[l].canPlaceTorchOnTop(par1World, par2, par3, par4));
}
}
/**
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
*/
public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4)
{
return par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true) || par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true)
|| par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true) || par1World.isBlockSolidOnSide(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
*/
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 == 0)
{
if (this.canPlaceTorchOn(par1World, par2, par3 - 1, par4))
{
j1 = 5;
}
else if (par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true))
{
j1 = 4;
}
else if (par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true))
{
j1 = 3;
}
else if (par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true))
{
j1 = 2;
}
else if (par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true))
{
j1 = 1;
}
}
if (par5 == 1 && this.canPlaceTorchOn(par1World, par2, par3 - 1, par4))
{
j1 = 5;
}
if (par5 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH, true))
{
j1 = 4;
}
if (par5 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true))
{
j1 = 3;
}
if (par5 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true))
{
j1 = 2;
}
if (par5 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true))
{
j1 = 1;
}
return j1;
}
@SideOnly(Side.CLIENT)
public void registerIcons (IconRegister 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
*/
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, int par5)
{
this.func_94397_d(par1World, par2, par3, par4, par5);
}
protected boolean func_94397_d (World par1World, int par2, int par3, int par4, int par5)
{
if (this.dropTorchIfCantStay(par1World, par2, par3, par4))
{
int i1 = par1World.getBlockMetadata(par2, par3, par4);
boolean flag = false;
if (!par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST, true) && i1 == 1)
{
flag = true;
}
if (!par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST, true) && i1 == 2)
{
flag = true;
}
if (!par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH, true) && i1 == 3)
{
flag = true;
}
if (!par1World.isBlockSolidOnSide(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.getBlockId(par2, par3, par4) == this.blockID)
{
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockToAir(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
*/
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);
}
@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);
}
}
}
+63
View File
@@ -0,0 +1,63 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TConstructBlock extends Block
{
public String[] textureNames;
public Icon[] icons;
public TConstructBlock(int id, Material material, float hardness, String[] tex)
{
super(id, material);
setHardness(hardness);
this.setCreativeTab(TConstructRegistry.blockTab);
textureNames = tex;
}
@Override
public int damageDropped (int meta)
{
return meta;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IconRegister iconRegister)
{
this.icons = new Icon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
}
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon (int side, int meta)
{
return icons[meta];
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < icons.length; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
}
+23
View File
@@ -0,0 +1,23 @@
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" };
public TMetalBlock(int id, Material material, float hardness)
{
super(id, material, hardness, metalTypes);
this.setStepSound(Block.soundMetalFootstep);
}
public boolean isBeaconBase (World worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ)
{
return true;
}
}
+135
View File
@@ -0,0 +1,135 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.ToolForgeLogic;
import tconstruct.client.block.TableForgeRender;
import tconstruct.common.TContent;
import tconstruct.common.TProxyCommon;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.blocks.InventoryBlock;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class ToolForgeBlock extends InventoryBlock
{
public ToolForgeBlock(int id, Material material)
{
super(id, material);
this.setCreativeTab(TConstructRegistry.blockTab);
this.setHardness(2f);
this.setStepSound(Block.soundWoodFootstep);
}
//Block.hasComparatorInputOverride and Block.getComparatorInputOverride
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;
}
Icon textureTop;
@Override
public void registerIcons (IconRegister iconRegister)
{
super.registerIcons(iconRegister);
textureTop = iconRegister.registerIcon("tinker:toolforge_top");
}
@Override
public Icon getIcon (int side, int meta)
{
if (side == 1)
{
return textureTop;
}
if (side == 0)
{
switch (meta)
{
case 0:
return Block.blockIron.getIcon(side, 0);
case 1:
return Block.blockGold.getIcon(side, 0);
case 2:
return Block.blockDiamond.getIcon(side, 0);
case 3:
return Block.blockEmerald.getIcon(side, 0);
default:
return TContent.metalBlock.getIcon(side, meta - 4);
}
}
return this.icons[meta];
}
@Override
public boolean renderAsNormalBlock ()
{
return false;
}
@Override
public boolean isOpaqueCube ()
{
return false;
}
@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 createTileEntity (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.toolForge;
//return -1;
}
@Override
public Object getModInstance ()
{
return TConstruct.instance;
}
@Override
public void getSubBlocks (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < textureNames.length; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
}
}
+206
View File
@@ -0,0 +1,206 @@
package tconstruct.blocks;
import java.util.List;
import tconstruct.TConstruct;
import tconstruct.blocks.logic.PartCrafterLogic;
import tconstruct.blocks.logic.PatternChestLogic;
import tconstruct.blocks.logic.StencilTableLogic;
import tconstruct.blocks.logic.ToolStationLogic;
import tconstruct.client.block.TableRender;
import tconstruct.common.TContent;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.blocks.InventoryBlock;
import tconstruct.util.PHConstruct;
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.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class ToolStationBlock extends InventoryBlock
{
public ToolStationBlock(int id, Material material)
{
super(id, material);
this.setCreativeTab(TConstructRegistry.blockTab);
this.setHardness(2f);
this.setStepSound(Block.soundWoodFootstep);
}
//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
public Icon 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 int getRenderType ()
{
return TableRender.tabelModelID;
}
@Override
public boolean shouldSideBeRendered (IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
return true;
}
public AxisAlignedBB getSelectedBoundingBoxFromPool (World world, int x, int y, int z)
{
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 5)
return AxisAlignedBB.getAABBPool().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)
{
case 0:
return new ToolStationLogic();
case 1:
return new PartCrafterLogic();
case 2:
return new PartCrafterLogic();
case 3:
return new PartCrafterLogic();
case 4:
return new PartCrafterLogic();
case 5:
return new PatternChestLogic();
case 6:
return new PatternChestLogic();
case 7:
return new PatternChestLogic();
case 8:
return new PatternChestLogic();
case 9:
return new PatternChestLogic();
case 10:
return new 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 (int id, CreativeTabs tab, List list)
{
for (int iter = 0; iter < 6; iter++)
{
list.add(new ItemStack(id, 1, iter));
}
for (int iter = 10; iter < 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.getBlockTileEntity(x, y, z);
for (int i = 1; i <= 13; i++)
{
logic.setInventorySlotContents(i - 1, new ItemStack(TContent.woodPattern, 1, i));
}
logic.setInventorySlotContents(13, new ItemStack(TContent.woodPattern, 1, 22));
}
}
}
}
@@ -0,0 +1,11 @@
package tconstruct.blocks.logic;
import tconstruct.library.blocks.InventoryLogic;
public abstract class AggregatorLogic extends InventoryLogic
{
public AggregatorLogic(int invSize)
{
super(invSize);
}
}
@@ -0,0 +1,44 @@
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;
}*/
}
@@ -0,0 +1,429 @@
package tconstruct.blocks.logic;
import tconstruct.TConstruct;
import tconstruct.library.blocks.InventoryLogic;
import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.util.IPattern;
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.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.world.World;
import net.minecraftforge.common.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;
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
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
{
int ret = TConstruct.ingotLiquidValue;
ItemStack inv = inventory[0];
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;
else
ret = TConstruct.basinCasting.getCastingAmount(this.liquid, inv);
}
else
{
ret = TConstruct.basinCasting.getCastingAmount(this.liquid, inv);
}
System.out.println("Ret: " + ret);
return ret;
}
public int updateCapacity (int capacity)
{
int ret = TConstruct.ingotLiquidValue;
ItemStack inv = inventory[0];
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;
else
ret = capacity;
}
else
ret = capacity;
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.markBlockForRenderUpdate(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.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
needsUpdate = true;
}
return roomInTank;
}
else
{
if (doFill)
{
this.liquid.amount += resource.amount;
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
needsUpdate = true;
}
return resource.amount;
}
}
else
{
return 0;
}
}
@Override
public void onInventoryChanged () //Isn't actually called?
{
super.onInventoryChanged();
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
needsUpdate = true;
}
public ItemStack decrStackSize (int slot, int quantity)
{
ItemStack stack = super.decrStackSize(slot, quantity);
worldObj.markBlockForRenderUpdate(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.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)
{
//System.out.println("Casting");
castingDelay--;
if (castingDelay == 0)
castLiquid();
}
if (renderOffset > 0)
{
renderOffset -= 6;
worldObj.markBlockForRenderUpdate(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();
}
@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.setCompoundTag("Fluid", nbt);
}
tags.setBoolean("Initialized", init);
tags.setInteger("Capacity", capacity);
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readFromNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(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;
}
}
@@ -0,0 +1,429 @@
package tconstruct.blocks.logic;
import tconstruct.TConstruct;
import tconstruct.library.blocks.InventoryLogic;
import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.util.IPattern;
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.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.world.World;
import net.minecraftforge.common.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;
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
{
int ret = TConstruct.ingotLiquidValue;
ItemStack inv = inventory[0];
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;
else
ret = TConstruct.tableCasting.getCastingAmount(this.liquid, inv);
}
else
{
ret = TConstruct.tableCasting.getCastingAmount(this.liquid, inv);
}
System.out.println("Ret: " + ret);
return ret;
}
public int updateCapacity (int capacity)
{
int ret = TConstruct.ingotLiquidValue;
ItemStack inv = inventory[0];
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;
else
ret = capacity;
}
else
ret = capacity;
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.markBlockForRenderUpdate(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.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
needsUpdate = true;
}
return roomInTank;
}
else
{
if (doFill)
{
this.liquid.amount += resource.amount;
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
needsUpdate = true;
}
return resource.amount;
}
}
else
{
return 0;
}
}
@Override
public void onInventoryChanged () //Isn't actually called?
{
super.onInventoryChanged();
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
needsUpdate = true;
}
public ItemStack decrStackSize (int slot, int quantity)
{
ItemStack stack = super.decrStackSize(slot, quantity);
worldObj.markBlockForRenderUpdate(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.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)
{
//System.out.println("Casting");
castingDelay--;
if (castingDelay == 0)
castLiquid();
}
if (renderOffset > 0)
{
renderOffset -= 6;
worldObj.markBlockForRenderUpdate(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"));
}
//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();
}
@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.setCompoundTag("Fluid", nbt);
}
tags.setBoolean("Initialized", init);
tags.setInteger("Capacity", capacity);
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readFromNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(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;
}
}
@@ -0,0 +1,358 @@
package tconstruct.blocks.logic;
import tconstruct.inventory.DrawbridgeContainer;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.blocks.InventoryLogic;
import tconstruct.library.util.IActiveLogic;
import tconstruct.library.util.IFacingLogic;
import net.minecraft.block.Block;
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.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class DrawbridgeLogic extends InventoryLogic implements IFacingLogic, IActiveLogic
{
boolean active;
boolean working;
int ticks;
byte extension;
byte direction;
public DrawbridgeLogic()
{
super(2);
}
@Override
public boolean getActive ()
{
return active;
}
@Override
public void setActive (boolean flag)
{
active = flag;
working = true;
}
@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 Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return new DrawbridgeContainer(inventoryplayer, this);
}
@Override
protected String getDefaultName ()
{
return "tinker.drawbridge";
}
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
super.setInventorySlotContents(slot, itemstack);
if (slot == 1)
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public ItemStack decrStackSize (int slot, int quantity)
{
ItemStack stack = super.decrStackSize(slot, quantity);
if (slot == 1)
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
return stack;
}
public void updateEntity ()
{
if (working)
{
ticks++;
if (ticks == 5)
{
ticks = 0;
if (active) //Placement
{
if (inventory[0] != null && inventory[0].stackSize > 1 && extension < 15)
{
extension++;
int xPos = xCoord;
int yPos = yCoord;
int zPos = zCoord;
switch (direction)
{
case 0:
yPos -= extension;
break;
case 1:
yPos += extension;
break;
case 2:
zPos -= extension;
break;
case 3:
zPos += extension;
break;
case 4:
xPos -= extension;
break;
case 5:
xPos += extension;
break;
}
Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)];
if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos) || block.isBlockReplaceable(worldObj, xPos, yPos, zPos))
{
//tryExtend(worldObj, xPos, yPos, zPos, direction);
int blockToItem = TConstructRegistry.blockToItemMapping[inventory[0].itemID];
if (blockToItem == 0)
{
if (inventory[0].itemID >= 4096 || Block.blocksList[inventory[0].itemID] == null)
return;
worldObj.setBlock(xPos, yPos, zPos, inventory[0].itemID, inventory[0].getItemDamage(), 3);
}
else
{
worldObj.setBlock(xPos, yPos, zPos, blockToItem, inventory[0].getItemDamage(), 3);
}
worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "tile.piston.out", 0.25F, worldObj.rand.nextFloat() * 0.25F + 0.6F);
inventory[0].stackSize--;
}
else
{
extension--;
working = false;
}
}
else
{
working = false;
}
}
else
//Retraction
{
if ((inventory[0] == null || inventory[0].stackSize < inventory[0].getMaxStackSize()) && extension > 0)
{
int xPos = xCoord;
int yPos = yCoord;
int zPos = zCoord;
switch (direction)
{
case 0:
yPos -= extension;
break;
case 1:
yPos += extension;
break;
case 2:
zPos -= extension;
break;
case 3:
zPos += extension;
break;
case 4:
xPos -= extension;
break;
case 5:
xPos += extension;
break;
}
Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)];
if (block != null)
{
int meta = worldObj.getBlockMetadata(xPos, yPos, zPos);
if (inventory[0] != null && validBlock(block) && validMetadata(block.blockID, meta))
{
worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "tile.piston.in", 0.25F, worldObj.rand.nextFloat() * 0.15F + 0.6F);
worldObj.setBlock(xPos, yPos, zPos, 0);
inventory[0].stackSize++;
}
else
{
working = false;
}
}
extension--;
}
else
{
working = false;
}
}
}
}
}
boolean validBlock (Block block)
{
int type = TConstructRegistry.interchangableBlockMapping[block.blockID];
if (type != 0)
{
if (type == inventory[0].itemID)
return true;
}
int blockToItem = TConstructRegistry.blockToItemMapping[block.blockID];
if (blockToItem != 0)
{
if (blockToItem == inventory[0].itemID)
return true;
}
return block.blockID == inventory[0].itemID;
}
boolean validMetadata (int blockID, int metadata)
{
int type = TConstructRegistry.drawbridgeState[blockID];
if (type == 0)
{
return metadata == inventory[0].getItemDamage();
}
if (type == 1)
{
return true;
}
if (type == 2)
{
return false;
}
if (type == 3)
{
return true; //TODO: rotational metadata
}
if (type == 4)
{
return true;
}
if (type == 5)
{
return metadata == inventory[0].getItemDamage();
}
return false;
}
@Override
public void readFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
active = tags.getBoolean("Active");
working = tags.getBoolean("Working");
extension = tags.getByte("Extension");
readCustomNBT(tags);
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
tags.setBoolean("Active", active);
tags.setBoolean("Working", working);
tags.setByte("Extension", extension);
writeCustomNBT(tags);
}
public void readCustomNBT (NBTTagCompound tags)
{
direction = tags.getByte("Direction");
}
public void writeCustomNBT (NBTTagCompound tags)
{
tags.setByte("Direction", direction);
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readFromNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
public boolean hasExtended ()
{
return extension != 0;
}
@Override
public void onInventoryChanged() {
super.onInventoryChanged();
this.worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
@@ -0,0 +1,127 @@
package tconstruct.blocks.logic;
import tconstruct.library.blocks.InventoryLogic;
import tconstruct.library.crafting.DryingRackRecipes;
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.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class DryingRackLogic extends InventoryLogic
{
int currentTime;
int maxTime;
public DryingRackLogic()
{
super(1);
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return null;
}
@Override
protected String getDefaultName ()
{
return "";
}
@Override
public void updateEntity ()
{
if (maxTime > 0 && currentTime < maxTime)
{
currentTime++;
if (currentTime >= maxTime)
{
inventory[0] = DryingRackRecipes.getDryingResult(inventory[0]);
updateDryingTime();
}
}
}
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
super.setInventorySlotContents(slot, itemstack);
updateDryingTime();
}
@Override
public ItemStack decrStackSize (int slot, int quantity)
{
ItemStack stack = super.decrStackSize(slot, quantity);
maxTime = 0;
currentTime = 0;
return stack;
}
public void updateDryingTime ()
{
currentTime = 0;
if (inventory[0] != null)
maxTime = DryingRackRecipes.getDryingTime(inventory[0]);
else
maxTime = 0;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public void readFromNBT (NBTTagCompound tags)
{
tags.setInteger("Time", currentTime);
tags.setInteger("MaxTime", maxTime);
readCustomNBT(tags);
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
currentTime = tags.getInteger("Time");
maxTime = tags.getInteger("MaxTime");
writeCustomNBT(tags);
}
public void readCustomNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
}
public void writeCustomNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeCustomNBT(tag);
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readCustomNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox ()
{
AxisAlignedBB cbb = AxisAlignedBB.getAABBPool().getAABB(xCoord, yCoord - 1, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
return cbb;
}
}
+51
View File
@@ -0,0 +1,51 @@
package tconstruct.blocks.logic;
import tconstruct.library.blocks.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 ItemStack getStackInSlot(int slot)
{
return inventory[slot +1];
}
public boolean isStackInSlot(int slot)
{
return inventory[slot +1] != null;
}
@Override
public int getSizeInventory()
{
return inventory.length - 1;
}*/
}
+247
View File
@@ -0,0 +1,247 @@
package tconstruct.blocks.logic;
import tconstruct.TConstruct;
import tconstruct.library.util.IActiveLogic;
import tconstruct.library.util.IFacingLogic;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.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.getBlockTileEntity(x, yCoord, z);
TileEntity tankte = worldObj.getBlockTileEntity(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)
{
//direction = (byte) 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 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.setCompoundTag("Fluid", nbt);
}
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeCustomNBT(tag);
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readCustomNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(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;
}
}
@@ -0,0 +1,196 @@
package tconstruct.blocks.logic;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.util.IActiveLogic;
import tconstruct.library.util.IFacingLogic;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.ForgeDirection;
public class FirestarterLogic extends TileEntity implements IFacingLogic, IActiveLogic
{
boolean active;
//boolean putOut;
boolean shouldActivate;
byte direction;
@Override
public boolean getActive ()
{
return active;
}
@Override
public void setActive (boolean flag)
{
/*if (active && !flag)
{
putOut = true;
}*/
active = flag;
shouldActivate = true;
//setFire();
}
void setFire ()
{
int xPos = xCoord;
int yPos = yCoord;
int zPos = zCoord;
switch (direction)
{
case 0:
yPos -= 1;
break;
case 1:
yPos += 1;
break;
case 2:
zPos -= 1;
break;
case 3:
zPos += 1;
break;
case 4:
xPos -= 1;
break;
case 5:
xPos += 1;
break;
}
Block block = Block.blocksList[worldObj.getBlockId(xPos, yPos, zPos)];
if (active)
{
System.out.println("Setting fire");
if (block == null || block.isAirBlock(worldObj, xPos, yPos, zPos))
{
worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "fire.ignite", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F);
worldObj.setBlock(xPos, yPos, zPos, Block.fire.blockID);
}
}
else
{
//System.out.println("Stopping fire "+putOut);
if (block == Block.fire)
{
//worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "random.fizz", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F);
worldObj.playSoundEffect((double) xPos + 0.5D, (double) yPos + 0.5D, (double) zPos + 0.5D, "fire.ignite", 1.0F, AbilityHelper.random.nextFloat() * 0.4F + 0.8F);
worldObj.setBlock(xPos, yPos, zPos, 0, 0, 3);
//putOut = false;
shouldActivate = true;
}
}
}
public void updateEntity ()
{
if (shouldActivate)
{
shouldActivate = false;
setFire();
}
}
@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);
tags.setBoolean("Active", active);
readCustomNBT(tags);
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
active = tags.getBoolean("Active");
writeCustomNBT(tags);
}
public void readCustomNBT (NBTTagCompound tags)
{
direction = tags.getByte("Direction");
}
public void writeCustomNBT (NBTTagCompound tags)
{
tags.setByte("Direction", direction);
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeCustomNBT(tag);
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readCustomNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
}
+301
View File
@@ -0,0 +1,301 @@
package tconstruct.blocks.logic;
import tconstruct.inventory.FrypanContainer;
import tconstruct.library.util.IActiveLogic;
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: 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 */
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)
{
onInventoryChanged();
}
}
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)
{
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
{
int itemID = stack.getItem().itemID;
Item item = stack.getItem();
if (stack.getItem() instanceof ItemBlock && Block.blocksList[itemID] != null)
{
Block block = Block.blocksList[itemID];
if (block == Block.woodSingleSlab)
{
return 150;
}
if (block == Block.wood)
{
return 2400;
}
if (block.blockMaterial == 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).getMaterialName().equals("WOOD"))
return 200;
if (itemID == Item.stick.itemID)
return 100;
if (itemID == Item.coal.itemID)
return 800;
if (itemID == Item.bucketLava.itemID)
return 20000;
if (itemID == Block.sapling.blockID)
return 100;
if (itemID == Item.blazeRod.itemID)
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, this);
}
/*@Override
public boolean canDropInventorySlot(int slot)
{
if (slot == 0)
return false;
else
return true;
}*/
}
@@ -0,0 +1,197 @@
package tconstruct.blocks.logic;
import tconstruct.common.TContent;
import tconstruct.crystal.TheftValueTracker;
import tconstruct.inventory.AggregatorContainer;
import tconstruct.library.util.IActiveLogic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
public class GlowstoneAggregator extends AggregatorLogic implements IActiveLogic
{
short currentTime;
short maxTime = 20 * 60 * 5;
public int currentLightLevel;
public boolean active;
public byte crystalValue;
public GlowstoneAggregator()
{
super(3);
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return new AggregatorContainer(inventoryplayer, this);
}
@Override
protected String getDefaultName ()
{
return "aggregator.glowstone";
}
@Override
public void updateEntity ()
{
if (worldObj.isRemote)
return;
if (worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord) && crystalValue < 64)
{
Block block = Block.blocksList[worldObj.getBlockId(xCoord, yCoord + 1, zCoord)];
if (block == null || validBlock(block) || block.isAirBlock(worldObj, xCoord, yCoord + 1, zCoord))
{
currentLightLevel = worldObj.getSavedLightValue(EnumSkyBlock.Sky, xCoord, yCoord, zCoord) - worldObj.skylightSubtracted;
if (currentLightLevel > 12)
{
currentTime++;
if (currentTime >= 180)
{
currentTime = 0;
crystalValue++;
if (block == TContent.lightCrystalBase)
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord);
if (crystalValue >= 64)
{
if (meta < 3)
{
worldObj.setBlockMetadataWithNotify(xCoord, yCoord + 1, zCoord, 3, 3);
TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 25); //Total 60
}
}
else if (crystalValue >= 28)
{
if (meta < 2)
{
worldObj.setBlockMetadataWithNotify(xCoord, yCoord + 1, zCoord, 2, 3);
TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 15); //Total 35
}
}
else if (crystalValue >= 8)
{
if (meta < 1)
{
worldObj.setBlockMetadataWithNotify(xCoord, yCoord + 1, zCoord, 1, 3);
TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 10); //Total 20
}
}
}
else
{
worldObj.setBlock(xCoord, yCoord + 1, zCoord, TContent.lightCrystalBase.blockID, 0, 3);
TheftValueTracker.updateCrystallinity(worldObj.provider.dimensionId, xCoord, zCoord, 10); //Total 10
}
}
if (active == false)
{
active = true;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
else
{
if (active == true)
{
active = false;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
}
}
boolean validBlock (Block block)
{
return block == TContent.lightCrystalBase;
}
@Override
public boolean getActive ()
{
return active;
}
@Override
public void setActive (boolean flag)
{
active = flag;
}
@Override
public void readFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
tags.setShort("Time", currentTime);
tags.setByte("Value", crystalValue);
readCustomNBT(tags);
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
currentTime = tags.getShort("Time");
crystalValue = tags.getByte("Value");
writeCustomNBT(tags);
}
public void readCustomNBT (NBTTagCompound tags)
{
active = tags.getBoolean("Active");
}
public void writeCustomNBT (NBTTagCompound tags)
{
tags.setBoolean("Active", active);
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeCustomNBT(tag);
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readCustomNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
public void updateCrystalValue ()
{
if (crystalValue > 0)
{
Block block = Block.blocksList[worldObj.getBlockId(xCoord, yCoord + 1, zCoord)];
if (block == TContent.lightCrystalBase)
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord + 1, zCoord);
if (meta == 3)
crystalValue = 64;
else if (meta == 2)
crystalValue = 28;
else if (meta == 1)
crystalValue = 8;
else
crystalValue = 1;
}
else
{
crystalValue = 0;
}
}
}
}
+117
View File
@@ -0,0 +1,117 @@
package tconstruct.blocks.logic;
import tconstruct.library.blocks.InventoryLogic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.world.World;
public class GolemCoreLogic extends InventoryLogic implements IInventory
{
public GolemCoreLogic()
{
super(1);
}
public ItemStack getKey ()
{
return inventory[0];
}
public void setKey (ItemStack itemstack)
{
inventory[0] = itemstack;
onInventoryChanged();
}
public void clear ()
{
inventory[0] = null;
}
public int getSizeInventory ()
{
return 1;
}
public ItemStack getStackInSlot (int slot)
{
return inventory[0];
}
public int getInventoryStackLimit ()
{
return 1;
}
public boolean canInteractWith (EntityPlayer entityplayer)
{
return true;
}
public void openChest ()
{
}
public void closeChest ()
{
}
public boolean isUseableByPlayer (EntityPlayer entityplayer)
{
return true;
}
@Override
public ItemStack getStackInSlotOnClosing (int i)
{
return null;
}
@Override
public boolean isInvNameLocalized ()
{
return false;
}
@Override
public boolean isItemValidForSlot (int i, ItemStack itemstack)
{
return true;
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return null;
}
@Override
protected String getDefaultName ()
{
return "golems.core";
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readFromNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
}
@@ -0,0 +1,360 @@
package tconstruct.blocks.logic;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.src.ModLoader;
import net.minecraft.tileentity.TileEntity;
public class GolemPedestalLogic extends TileEntity implements IInventory
{
public ItemStack supply;
public static int cost[] = null;
public static int souls[] = null;
public GolemPedestalLogic()
{
supply = null;
if (cost == null)
{
cost = new int[512];
souls = new int[512];
cost[Block.planks.blockID] = 0;
cost[Block.wood.blockID] = 32;
cost[Block.cloth.blockID] = 8;
cost[Block.cobblestoneMossy.blockID] = 16;
cost[Block.obsidian.blockID] = 8;
cost[Block.pumpkin.blockID] = 8;
cost[Block.netherrack.blockID] = 64;
cost[Block.slowSand.blockID] = 1;
cost[Block.glowStone.blockID] = 1;
cost[Block.pumpkinLantern.blockID] = 8;
cost[Block.blockDiamond.blockID] = 1;
cost[Block.blockGold.blockID] = 1;
cost[Block.blockIron.blockID] = 1;
cost[Block.blockLapis.blockID] = 1;
cost[Block.jukebox.blockID] = 1;
cost[Block.music.blockID] = 1;
cost[Block.melon.blockID] = 8;
cost[Block.torchRedstoneIdle.blockID] = 6;
cost[Block.torchRedstoneActive.blockID] = cost[Block.torchRedstoneIdle.blockID];
cost[Item.redstone.itemID] = 6;
cost[Item.beefRaw.itemID] = 8;
cost[Item.beefCooked.itemID] = cost[Item.beefRaw.itemID];
cost[Item.porkRaw.itemID] = cost[Item.beefRaw.itemID];
cost[Item.porkCooked.itemID] = cost[Item.beefRaw.itemID];
cost[Item.enderPearl.itemID] = 1;
cost[Item.eyeOfEnder.itemID] = 1;
cost[Item.blazeRod.itemID] = 2;
cost[Block.mushroomBrown.blockID] = 16;
cost[Block.mushroomRed.blockID] = cost[Block.mushroomBrown.blockID];
cost[Block.netherStalk.blockID] = 6;
cost[Item.glowstone.itemID] = 4;
cost[Item.diamond.itemID] = 1;
cost[Item.ingotIron.itemID] = 8;
cost[Item.ingotGold.itemID] = 2;
cost[Item.reed.itemID] = 8;
cost[Item.sugar.itemID] = cost[Item.reed.itemID];
cost[Item.bucketLava.itemID] = 1;
cost[Item.cake.itemID] = 1;
cost[Item.bucketMilk.itemID] = 1;
cost[Item.wheat.itemID] = 32;
cost[Item.bread.itemID] = 8;
cost[Block.plantYellow.blockID] = 32;
cost[Block.plantRed.blockID] = cost[Block.plantYellow.blockID];
cost[Block.dragonEgg.blockID] = 1;
cost[Block.tallGrass.blockID] = 64;
cost[Block.sapling.blockID] = 64;
cost[Item.ghastTear.itemID] = 8;
cost[Item.goldNugget.itemID] = 18;
cost[Item.spiderEye.itemID] = 16;
cost[Item.fermentedSpiderEye.itemID] = 6;
cost[Item.bowlSoup.itemID] = 0;
cost[Item.fishRaw.itemID] = 1;
cost[Item.fishCooked.itemID] = cost[Item.fishRaw.itemID];
cost[Item.magmaCream.itemID] = 2;
cost[Item.blazePowder.itemID] = 4;
cost[Item.speckledMelon.itemID] = 1;
cost[Item.paper.itemID] = 8;
cost[Item.book.itemID] = 2;
cost[Item.egg.itemID] = 4;
cost[Item.slimeBall.itemID] = 2;
cost[Item.saddle.itemID] = 1;
cost[Item.feather.itemID] = 48;
cost[Item.gunpowder.itemID] = 16;
cost[Item.appleRed.itemID] = 8;
cost[Item.appleGold.itemID] = 1;
cost[Item.dyePowder.itemID] = 64;
cost[Item.bone.itemID] = 2;
cost[Item.rottenFlesh.itemID] = 48;
cost[Item.cookie.itemID] = 16;
cost[Item.melon.itemID] = 32;
cost[Item.chickenCooked.itemID] = 8;
cost[Item.chickenRaw.itemID] = cost[Item.chickenCooked.itemID];
cost[Item.silk.itemID] = 64;
cost[Block.cactus.blockID] = 32;
souls[Block.planks.blockID] = 0;
souls[Block.wood.blockID] = 1;
souls[Block.cloth.blockID] = 1;
souls[Block.cobblestoneMossy.blockID] = 1;
souls[Block.obsidian.blockID] = 1;
souls[Block.pumpkin.blockID] = 1;
souls[Block.netherrack.blockID] = 1;
souls[Block.slowSand.blockID] = 1;
souls[Block.glowStone.blockID] = 2;
souls[Block.pumpkinLantern.blockID] = 1;
souls[Block.blockDiamond.blockID] = 27;
souls[Block.blockGold.blockID] = 2;
souls[Block.blockIron.blockID] = 2;
souls[Block.blockLapis.blockID] = 3;
souls[Block.jukebox.blockID] = 3;
souls[Block.music.blockID] = 1;
souls[Block.melon.blockID] = 1;
souls[Block.torchRedstoneIdle.blockID] = 1;
souls[Block.torchRedstoneActive.blockID] = souls[Block.torchRedstoneIdle.blockID];
souls[Item.redstone.itemID] = 1;
souls[Item.beefRaw.itemID] = 1;
souls[Item.beefCooked.itemID] = souls[Item.beefRaw.itemID];
souls[Item.porkRaw.itemID] = souls[Item.beefRaw.itemID];
souls[Item.porkCooked.itemID] = souls[Item.beefRaw.itemID];
souls[Item.enderPearl.itemID] = 1;
souls[Item.eyeOfEnder.itemID] = 2;
souls[Item.blazeRod.itemID] = 2;
souls[Block.mushroomBrown.blockID] = 1;
souls[Block.mushroomRed.blockID] = souls[Block.mushroomBrown.blockID];
souls[Block.netherStalk.blockID] = 1;
souls[Item.glowstone.itemID] = 1;
souls[Item.diamond.itemID] = 3;
souls[Item.ingotIron.itemID] = 1;
souls[Item.ingotGold.itemID] = 1;
souls[Item.reed.itemID] = 1;
souls[Item.sugar.itemID] = souls[Item.reed.itemID];
souls[Item.bucketLava.itemID] = 1;
souls[Item.cake.itemID] = 1;
souls[Item.bucketMilk.itemID] = 1;
souls[Item.wheat.itemID] = 1;
souls[Item.bread.itemID] = 1;
souls[Block.plantYellow.blockID] = 1;
souls[Block.plantRed.blockID] = souls[Block.plantYellow.blockID];
souls[Block.dragonEgg.blockID] = 1;
souls[Block.tallGrass.blockID] = 1;
souls[Block.sapling.blockID] = 1;
souls[Item.ghastTear.itemID] = 1;
souls[Item.goldNugget.itemID] = 1;
souls[Item.spiderEye.itemID] = 1;
souls[Item.fermentedSpiderEye.itemID] = 1;
souls[Item.bowlSoup.itemID] = 1;
souls[Item.fishRaw.itemID] = 1;
souls[Item.fishCooked.itemID] = souls[Item.fishRaw.itemID];
souls[Item.magmaCream.itemID] = 1;
souls[Item.blazePowder.itemID] = 1;
souls[Item.speckledMelon.itemID] = 1;
souls[Item.paper.itemID] = 1;
souls[Item.book.itemID] = 1;
souls[Item.egg.itemID] = 1;
souls[Item.slimeBall.itemID] = 1;
souls[Item.saddle.itemID] = 1;
souls[Item.feather.itemID] = 1;
souls[Item.gunpowder.itemID] = 1;
souls[Item.appleRed.itemID] = 1;
souls[Item.appleGold.itemID] = 3;
souls[Item.dyePowder.itemID] = 1;
souls[Item.bone.itemID] = 1;
souls[Item.rottenFlesh.itemID] = 1;
souls[Item.cookie.itemID] = 1;
souls[Item.melon.itemID] = 1;
souls[Item.chickenCooked.itemID] = 1;
souls[Item.chickenRaw.itemID] = souls[Item.chickenCooked.itemID];
souls[Item.silk.itemID] = 1;
souls[Block.cactus.blockID] = 1;
}
}
public int getSizeInventory ()
{
return 9;
}
public ItemStack getStackInSlot (int i)
{
if (supply != null && supply.getItem() == null)
{
supply = null;
}
return supply;
}
public boolean subtractSoul (int i)
{
System.out.println("SUBTRACT WHY");
if (supply == null || supply.itemID >= 512 || cost[supply.itemID] == 0)
{
worldObj.playSoundAtEntity(ModLoader.getMinecraftInstance().thePlayer, "mob.blaze.death", 1.0F, 0.5F);
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("I require more souls...");
return false;
}
int j = cost[supply.itemID];
int k = souls[supply.itemID];
int l = (supply.stackSize / j) * k;
System.out.println((new StringBuilder()).append("Subtracting amt").append(i).append(" s").append(k).append(" c").append(j).append(" ss").append(supply.stackSize).append(" id")
.append(supply.itemID).append(" sa").append(l).append(" calc").append(Math.ceil((double) i / (double) k)).toString());
if (l < i)
{
worldObj.playSoundAtEntity(ModLoader.getMinecraftInstance().thePlayer, "mob.blaze.death", 1.0F, 0.5F);
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("I need more souls...");
return false;
}
supply.stackSize -= Math.ceil((double) i / (double) k) * (double) j;
if (supply.stackSize == 0)
{
supply = null;
}
else if (supply.stackSize < 0)
{
throw new UnsupportedOperationException((new StringBuilder())
.append("If you are getting this error then your golems mod has derped, \nplease contact billythegoat101 on the minecraftforums with the error code: LERN YO MATHS [i")
.append(supply.itemID).append(",ss").append(supply.stackSize).append(",a").append(i).append("]").toString());
}
return true;
}
public ItemStack decrStackSize (int i, int j)
{
if (supply != null && supply.getItem() == null)
{
supply = null;
}
if (supply != null)
{
if (supply.stackSize <= j)
{
ItemStack itemstack = supply;
supply = null;
onInventoryChanged();
return itemstack;
}
ItemStack itemstack1 = supply.splitStack(j);
if (supply.stackSize == 0)
{
supply = null;
}
onInventoryChanged();
return itemstack1;
}
else
{
return null;
}
}
public void setInventorySlotContents (int i, ItemStack itemstack)
{
supply = itemstack;
if (itemstack != null && itemstack.stackSize > getInventoryStackLimit())
{
itemstack.stackSize = getInventoryStackLimit();
}
if (supply != null && supply.getItem() == null)
{
supply = null;
}
onInventoryChanged();
}
public void writeToNBT (NBTTagCompound nbttagcompound)
{
super.writeToNBT(nbttagcompound);
if (supply == null)
{
supply = new ItemStack(0, 0, 0);
}
NBTTagList nbttaglist = new NBTTagList();
if (supply != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) 0);
supply.writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
nbttagcompound.setTag("Items", nbttaglist);
}
public void readFromNBT (NBTTagCompound nbttagcompound)
{
super.readFromNBT(nbttagcompound);
supply = new ItemStack(0, 0, 0);
NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
for (int i = 0; i < nbttaglist.tagCount(); i++)
{
NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
int j = nbttagcompound1.getByte("Slot") & 0xff;
if (j >= 0 && j < 1)
{
supply = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
if (supply != null && supply.getItem() == null)
{
supply = null;
}
}
public String getInvName ()
{
return "golempedestalinv";
}
public int getInventoryStackLimit ()
{
return 64;
}
public boolean canInteractWith (EntityPlayer entityplayer)
{
return true;
}
public void openChest ()
{
}
public void closeChest ()
{
}
public void clear ()
{
supply = null;
}
public boolean isUseableByPlayer (EntityPlayer entityplayer)
{
return true;
}
@Override
public ItemStack getStackInSlotOnClosing (int i)
{
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isInvNameLocalized ()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isItemValidForSlot (int i, ItemStack itemstack)
{
// TODO Auto-generated method stub
return false;
}
}
+180
View File
@@ -0,0 +1,180 @@
package tconstruct.blocks.logic;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraftforge.common.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;
import net.minecraftforge.fluids.IFluidTank;
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)
{
return Block.lightValue[id];
}
}
return 0;
}
@Override
public void readFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
readCustomNBT(tags);
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
writeCustomNBT(tags);
}
public void readCustomNBT (NBTTagCompound tags)
{
if (tags.getBoolean("hasFluid"))
tank.setFluid(new FluidStack(tags.getInteger("itemID"), tags.getInteger("amount")));
else
tank.setFluid(null);
}
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 Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readCustomNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
/* Updating */
public boolean canUpdate ()
{
return true;
}
@Override
public void updateEntity ()
{
if (renderOffset > 0)
{
renderOffset -= 6;
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
}
}
@@ -0,0 +1,65 @@
package tconstruct.blocks.logic;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
public class LiquidTextureLogic extends TileEntity
{
int texturePos;
public boolean canUpdate ()
{
return false;
}
public void setLiquidType (int tex)
{
texturePos = tex;
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
public int getLiquidType ()
{
return texturePos;
}
public void readFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
readCustomNBT(tags);
}
public void readCustomNBT (NBTTagCompound tags)
{
texturePos = tags.getInteger("Texture");
}
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 Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readCustomNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
}
@@ -0,0 +1,146 @@
package tconstruct.blocks.logic;
import tconstruct.library.util.CoordTuple;
import tconstruct.library.util.IMasterLogic;
import tconstruct.library.util.IServantLogic;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.tileentity.TileEntity;
public class MultiServantLogic extends TileEntity implements IServantLogic
{
boolean hasMaster;
CoordTuple master;
short masterID;
byte masterMeat; //Typo, it stays!
public boolean canUpdate ()
{
return false;
}
public boolean hasValidMaster ()
{
if (!hasMaster)
return false;
if (worldObj.getBlockId(master.x, master.y, master.z) == masterID && worldObj.getBlockMetadata(master.x, master.y, master.z) == masterMeat)
return true;
else
{
hasMaster = false;
master = null;
return false;
}
}
public CoordTuple getMasterPosition ()
{
return master;
}
public void overrideMaster (int x, int y, int z)
{
hasMaster = true;
master = new CoordTuple(x, y, z);
masterID = (short) worldObj.getBlockId(x, y, z);
masterMeat = (byte) worldObj.getBlockMetadata(x, y, z);
}
public void removeMaster ()
{
hasMaster = false;
master = null;
masterID = 0;
masterMeat = 0;
}
public boolean verifyMaster (int x, int y, int z)
{
if (master.equalCoords(x, y, z) && worldObj.getBlockId(x, y, z) == masterID && worldObj.getBlockMetadata(x, y, z) == masterMeat)
return true;
else
return false;
}
public boolean setMaster (int x, int y, int z)
{
if (!hasMaster || worldObj.getBlockId(master.x, master.y, master.z) != masterID || (worldObj.getBlockMetadata(master.x, master.y, master.z) != masterMeat))
{
overrideMaster(x, y, z);
return true;
}
else
{
return false;
}
}
public void notifyMasterOfChange ()
{
if (hasValidMaster())
{
IMasterLogic logic = (IMasterLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
logic.notifyChange(xCoord, yCoord, zCoord);
}
}
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 Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readCustomNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
}
@@ -0,0 +1,180 @@
package tconstruct.blocks.logic;
import tconstruct.inventory.PartCrafterChestContainer;
import tconstruct.inventory.PartCrafterContainer;
import tconstruct.library.blocks.InventoryLogic;
import tconstruct.library.crafting.PatternBuilder;
import tconstruct.library.util.IPattern;
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;
public class PartCrafterLogic extends InventoryLogic implements ISidedInventory
{
boolean craftedTop;
boolean craftedBottom;
public PartCrafterLogic()
{
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++)
{
TileEntity tile = world.getBlockTileEntity(xPos, y, zPos);
if (tile != null && tile instanceof PatternChestLogic)
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
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.
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 */
public void readFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
craftedTop = tags.getBoolean("CraftedTop");
craftedBottom = tags.getBoolean("CraftedBottom");
}
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;
}
}
@@ -0,0 +1,32 @@
package tconstruct.blocks.logic;
import tconstruct.inventory.PatternChestContainer;
import tconstruct.library.blocks.InventoryLogic;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.world.World;
public class PatternChestLogic extends InventoryLogic
{
public PatternChestLogic()
{
super(30);
}
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);
}
}
+72
View File
@@ -0,0 +1,72 @@
package tconstruct.blocks.logic;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
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 Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readCustomNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
}
@@ -0,0 +1,213 @@
package tconstruct.blocks.logic;
import tconstruct.library.util.IFacingLogic;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet132TileEntityData;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.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;
public boolean canUpdate ()
{
return false;
}
/*@Override
public FluidStack getLiquid ()
{
return null;
}
@Override
public int getCapacity ()
{
if (!hasMaster)
return 0;
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
return smeltery.getCapacity();
}*/
/*@Override
public int fill (FluidStack resource, boolean doFill)
{
}*/
/*@Override
public FluidStack drain (int maxDrain, boolean doDrain)
{
}*/
@Override
public int fill (ForgeDirection from, FluidStack resource, boolean doFill)
{
if (hasMaster && resource != null)
{
if (doFill)
{
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.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())
{
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.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 false;
}
@Override
public boolean canDrain (ForgeDirection from, Fluid fluid)
{
return false;
}
@Override
public FluidTankInfo[] getTankInfo (ForgeDirection from)
{
return null;
}
/*
@Override
public ILiquidTank[] getTanks (ForgeDirection direction)
{
if (hasValidMaster())
{
SmelteryLogic smeltery = (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
return new ILiquidTank[] { smeltery };
}
return null;
}
@Override
public ILiquidTank getTank (ForgeDirection direction, FluidStack type)
{
if (hasValidMaster())
{
return (SmelteryLogic) worldObj.getBlockTileEntity(master.x, master.y, master.z);
}
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 Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (INetworkManager net, Packet132TileEntityData packet)
{
readFromNBT(packet.customParam1);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,122 @@
package tconstruct.blocks.logic;
import tconstruct.common.TContent;
import tconstruct.inventory.PatternShaperContainer;
import tconstruct.library.blocks.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.world.World;
public class StencilTableLogic extends InventoryLogic implements ISidedInventory
{
public StencilTableLogic()
{
super(2);
}
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() instanceof tconstruct.items.Pattern)
{
if (itemstack.getItemDamage() == 0)
setInventorySlotContents(1, new ItemStack(TContent.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;
}
}
@@ -0,0 +1,53 @@
package tconstruct.blocks.logic;
import tconstruct.inventory.ToolForgeContainer;
import tconstruct.library.crafting.ToolBuilder;
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;
/* 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 "toolforge.crafting";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return new ToolForgeContainer(inventoryplayer, this);
}
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;
}
}
}
}
@@ -0,0 +1,112 @@
package tconstruct.blocks.logic;
import tconstruct.inventory.ToolStationContainer;
import tconstruct.library.blocks.InventoryLogic;
import tconstruct.library.crafting.ToolBuilder;
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;
/* 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 = "";
}
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 "toolstation.crafting";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return new ToolStationContainer(inventoryplayer, this);
}
public void onInventoryChanged ()
{
buildTool(toolName);
if (this.worldObj != null)
{
this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
this.worldObj.updateTileEntityChunkAndDoNothing(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);
}
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;
}
}
@@ -0,0 +1,92 @@
package tconstruct.blocks.traps;
import tconstruct.client.block.BarricadeRender;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BarricadeBlock extends Block
{
public BarricadeBlock(int blockID)//, String name, int texture)
{
super(blockID, Material.wood);
setHardness(4.0F);
this.setCreativeTab(TConstructRegistry.blockTab);
//setUnlocalizedName("barricade" + name);
//GameRegistry.addName(this, name + " Barricade");
}
public Icon getIcon (int side, int meta)
{
return Block.wood.getIcon(2, meta % 4);
}
public boolean renderAsNormalBlock ()
{
return false;
}
public boolean isOpaqueCube ()
{
return false;
}
public int getRenderType ()
{
return BarricadeRender.model;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool (World par1World, int x, int y, int z)
{
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
}
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int x, int y, int z)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void harvestBlock (World world, EntityPlayer player, int x, int y, int z, int meta)
{
if (meta % 4 > 0)
{
world.setBlock(x, y, z, this.blockID, meta - 1, 3);
dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
}
else
{
dropBlockAsItem_do(world, x, y, z, new ItemStack(this));
}
}
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
{
ItemStack stack = player.getCurrentEquippedItem();
if ((stack != null) && (stack.itemID == this.blockID) && (!player.isSneaking()))
{
int meta = world.getBlockMetadata(x, y, z);
if (meta % 4 != 3)
{
world.setBlock(x, y, z, this.blockID, meta + 1, 3);
Block.blocksList[this.blockID].onBlockPlacedBy(world, x, y, z, player, stack);
Block.blocksList[this.blockID].onPostBlockPlaced(world, x, y, z, meta);
Block var9 = Block.blocksList[this.blockID];
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, var9.stepSound.getStepSound(), (var9.stepSound.getVolume() + 1.0F) / 2.0F, var9.stepSound.getPitch() * 0.8F);
player.swingItem();
if (!player.capabilities.isCreativeMode)
stack.stackSize -= 1;
return true;
}
}
return false;
}
}
+280
View File
@@ -0,0 +1,280 @@
package tconstruct.blocks.traps;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import tconstruct.library.TConstructRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFence;
import net.minecraft.block.EnumMobType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class Landmine extends Block
{
/** The mob type that can trigger this pressure plate. */
private EnumMobType triggerMobType;
public Landmine(int par1, EnumMobType par3EnumMobType, Material par4Material)
{
super(par1, par4Material);
this.triggerMobType = EnumMobType.mobs;
this.setCreativeTab(TConstructRegistry.blockTab);
this.setTickRandomly(true);
float var5 = 0.0625F;
this.setBlockBounds(var5, 0.0F, var5, 1.0F - var5, 0.03125F, 1.0F - var5);
}
public Icon getBlockTexture (IBlockAccess world, int x, int y, int z, int side)
{
Block block = Block.blocksList[world.getBlockId(x, y - 1, z)];
if (block != null)
{
return block.getBlockTexture(world, x, y - 1, z, side);
}
return Block.sponge.getIcon(side, world.getBlockMetadata(x, y, z));
}
public Icon getIcon (int side, int meta)
{
return Block.sponge.getIcon(1, meta);
}
public void registerIcons (IconRegister par1IconRegister)
{
}
/**
* How many world ticks before ticking
*/
public int tickRate ()
{
return 20;
}
/**
* 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)
*/
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.
*/
public boolean isOpaqueCube ()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock ()
{
return false;
}
public boolean getBlocksMovement (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
return true;
}
/**
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
*/
public boolean canPlaceBlockAt (World par1World, int par2, int par3, int par4)
{
return par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || BlockFence.isIdAFence(par1World.getBlockId(par2, par3 - 1, par4));
}
/**
* 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
*/
public void onNeighborBlockChange (World par1World, int par2, int par3, int par4, int par5)
{
boolean var6 = false;
if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && !BlockFence.isIdAFence(par1World.getBlockId(par2, par3 - 1, par4)))
{
var6 = true;
}
if (var6)
{
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
//par1World.setBlock(par2, par3, par4, 0);
}
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick (World par1World, int par2, int par3, int par4, Random par5Random)
{
if (!par1World.isRemote)
{
if (par1World.getBlockMetadata(par2, par3, par4) != 0)
{
this.setStateIfMobInteractsWithPlate(par1World, par2, par3, par4);
}
}
}
/**
* Triggered whenever an entity collides with this block (enters into the block). Args: world, x, y, z, entity
*/
public void onEntityCollidedWithBlock (World par1World, int par2, int par3, int par4, Entity par5Entity)
{
if (!par1World.isRemote)
{
if (par1World.getBlockMetadata(par2, par3, par4) != 1)
{
this.setStateIfMobInteractsWithPlate(par1World, par2, par3, par4);
}
}
}
/**
* Checks if there are mobs on the plate. If a mob is on the plate and it is off, it turns it on, and vice versa.
*/
private void setStateIfMobInteractsWithPlate (World world, int posX, int posY, int posZ)
{
boolean var5 = world.getBlockMetadata(posX, posY, posZ) == 1;
boolean var6 = false;
float var7 = 0.125F;
List var8 = null;
if (this.triggerMobType == EnumMobType.everything)
{
var8 = world.getEntitiesWithinAABBExcludingEntity(
(Entity) null,
AxisAlignedBB.getAABBPool().getAABB((double) ((float) posX + var7), (double) posY, (double) ((float) posZ + var7), (double) ((float) (posX + 1) - var7), (double) posY + 0.25D,
(double) ((float) (posZ + 1) - var7)));
}
if (this.triggerMobType == EnumMobType.mobs)
{
var8 = world.getEntitiesWithinAABB(
EntityLiving.class,
AxisAlignedBB.getAABBPool().getAABB((double) ((float) posX + var7), (double) posY, (double) ((float) posZ + var7), (double) ((float) (posX + 1) - var7), (double) posY + 0.25D,
(double) ((float) (posZ + 1) - var7)));
}
if (this.triggerMobType == EnumMobType.players)
{
var8 = world.getEntitiesWithinAABB(
EntityPlayer.class,
AxisAlignedBB.getAABBPool().getAABB((double) ((float) posX + var7), (double) posY, (double) ((float) posZ + var7), (double) ((float) (posX + 1) - var7), (double) posY + 0.25D,
(double) ((float) (posZ + 1) - var7)));
}
if (!var8.isEmpty())
{
Iterator var9 = var8.iterator();
while (var9.hasNext())
{
Entity var10 = (Entity) var9.next();
if (!var10.doesEntityNotTriggerPressurePlate())
{
var6 = true;
break;
}
}
}
if (var6 && !var5)
{
world.setBlock(posX, posY, posZ, 0);
world.createExplosion((Entity) null, posX, posY, posZ, 2.0F, true);
/*par1World.setBlockMetadataWithNotify(posX, posY, posZ, 1);
par1World.notifyBlocksOfNeighborChange(posX, posY, posZ, this.blockID);
par1World.notifyBlocksOfNeighborChange(posX, posY - 1, posZ, this.blockID);
par1World.markBlockRangeForRenderUpdate(posX, posY, posZ, posX, posY, posZ);
par1World.playSoundEffect((double)posX + 0.5D, (double)posY + 0.1D, (double)posZ + 0.5D, "random.click", 0.3F, 0.6F);*/
}
/*if (!var6 && var5)
{
par1World.setBlockMetadataWithNotify(posX, posY, posZ, 0);
par1World.notifyBlocksOfNeighborChange(posX, posY, posZ, this.blockID);
par1World.notifyBlocksOfNeighborChange(posX, posY - 1, posZ, this.blockID);
par1World.markBlockRangeForRenderUpdate(posX, posY, posZ, posX, posY, posZ);
par1World.playSoundEffect((double)posX + 0.5D, (double)posY + 0.1D, (double)posZ + 0.5D, "random.click", 0.3F, 0.5F);
}
if (var6)
{
par1World.scheduleBlockUpdate(posX, posY, posZ, this.blockID, this.tickRate());
}*/
}
/**
* 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)
{
if (par6 > 0)
{
par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState (IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
boolean var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 1;
float var6 = 0.0625F;
if (var5)
{
this.setBlockBounds(var6, 0.0F, var6, 1.0F - var6, 0.03125F, 1.0F - var6);
}
else
{
this.setBlockBounds(var6, 0.0F, var6, 1.0F - var6, 0.0625F, 1.0F - var6);
}
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender ()
{
float var1 = 0.5F;
float var2 = 0.125F;
float var3 = 0.5F;
this.setBlockBounds(0.5F - var1, 0.5F - var2, 0.5F - var3, 0.5F + var1, 0.5F + var2, 0.5F + var3);
}
/**
* Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility
* and stop pistons
*/
public int getMobilityFlag ()
{
return 1;
}
}
+22
View File
@@ -0,0 +1,22 @@
package tconstruct.blocks.traps;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
public class Punji extends Block
{
public Punji(int id)
{
super(id, Material.circuits);
}
@Override
public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity)
{
entity.fallDistance *= 2.0F;
}
}