Attempt to fix repository

This commit is contained in:
WayofTime committed 2015-07-31 12:09:09 -04:00
1 parent e242207d50
commit 1aac4686db
932 files changed
+39272 -11544

No files matched your search

@@ -0,0 +1,197 @@
package WayofTime.alchemicalWizardry.common.block;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.sacrifice.IIncense;
import WayofTime.alchemicalWizardry.common.tileEntity.TECrucible;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCrucible extends BlockContainer
{
@SideOnly(Side.CLIENT)
private IIcon topIcon;
@SideOnly(Side.CLIENT)
private IIcon sideIcon;
@SideOnly(Side.CLIENT)
private IIcon bottomIcon;
public BlockCrucible()
{
super(Material.anvil);
this.setHardness(2.0f);
this.setResistance(1.5f);
this.setCreativeTab(AlchemicalWizardry.tabBloodMagic);
this.setBlockName("blockCrucible");
this.setBlockBounds(0.3125F, 0.0F, 0.3125F, 0.6875F, 0.625F, 0.6875F);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
{
TECrucible tileEntity = (TECrucible) world.getTileEntity(x, y, z);
if (tileEntity == null || player.isSneaking())
{
return false;
}
ItemStack playerItem = player.getCurrentEquippedItem();
if (tileEntity.getStackInSlot(0) == null && playerItem != null && playerItem.getItem() instanceof IIncense)
{
ItemStack newItem = playerItem.copy();
newItem.stackSize = 1;
--playerItem.stackSize;
tileEntity.setInventorySlotContents(0, newItem);
// } else if (tileEntity.getStackInSlot(0) != null && playerItem == null) //Disabled currently
// {
// player.inventory.addItemStackToInventory(tileEntity.getStackInSlot(0));
// tileEntity.setInventorySlotContents(0, null);
}
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
this.topIcon = iconRegister.registerIcon("AlchemicalWizardry:Crucible_Top");
this.sideIcon = iconRegister.registerIcon("AlchemicalWizardry:Crucible_Side");
this.bottomIcon = iconRegister.registerIcon("AlchemicalWizardry:Crucible_Bottom");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
switch (side)
{
case 0:
return bottomIcon;
case 1:
return topIcon;
default:
return sideIcon;
}
}
// @Override
// public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
// {
// return null;
// }
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
{
this.setBlockBounds(0.3125F, 0.0F, 0.3125F, 0.6875F, 0.625F, 0.6875F);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new TECrucible();
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
if (rand.nextInt(3) != 0)
{
TECrucible tile = (TECrucible)world.getTileEntity(x, y, z);
tile.spawnClientParticle(world, x, y, z, rand);
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block par5, int par6)
{
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, par5, par6);
}
@Override
public boolean hasComparatorInputOverride()
{
return true;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int meta)
{
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TECrucible)
{
return ((TECrucible) tile).getRSPowerOutput();
}
return 15;
}
private void dropItems(World world, int x, int y, int z)
{
Random rand = new Random();
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory))
{
return;
}
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
ItemStack item = inventory.getStackInSlot(i);
if (item != null && item.stackSize > 0)
{
float rx = rand.nextFloat() * 0.8F + 0.1F;
float ry = rand.nextFloat() * 0.8F + 0.1F;
float rz = rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world,
x + rx, y + ry, z + rz,
new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
if (item.hasTagCompound())
{
entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = rand.nextGaussian() * factor;
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
item.stackSize = 0;
}
}
}
}