Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Arcaratus 2015-06-12 15:12:22 -04:00
commit 4f9acb223f
124 changed files with 4228 additions and 288 deletions

View file

@ -2,17 +2,34 @@ 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.AxisAlignedBB;
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 static IIcon topIcon;
@SideOnly(Side.CLIENT)
private static IIcon sideIcon;
@SideOnly(Side.CLIENT)
private static IIcon bottomIcon;
public BlockCrucible()
{
super(Material.anvil);
@ -20,18 +37,70 @@ public class BlockCrucible extends BlockContainer
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 AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are)
{
return null;
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.4F, 0.0F, 0.4F, 0.6F, 0.6F, 0.6F);
this.setBlockBounds(0.3125F, 0.0F, 0.3125F, 0.6875F, 0.625F, 0.6875F);
}
@Override
@ -61,4 +130,68 @@ public class BlockCrucible extends BlockContainer
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;
}
}
}
}