Base item package, tc interaction items

This commit is contained in:
Vincent Lee committed 2015-11-18 08:33:32 -06:00
1 parent 4c0922f0b4
commit 9cbd2708db
22 files changed
+254 -286

No files matched your search

@@ -11,6 +11,7 @@
package vazkii.botania.api.item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
/**
@@ -22,20 +23,20 @@ public interface IHornHarvestable {
* Returns true if this block can be uprooted.
* Note that the stack param can be null if it's a drum breaking it.
*/
public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType);
public boolean canHornHarvest(World world, BlockPos pos, ItemStack stack, EnumHornType hornType);
/**
* Returns true if harvestByHorn() should be called. If false it just uses the normal
* block breaking method.
* Note that the stack param can be null if it's a drum breaking it.
*/
public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType);
public boolean hasSpecialHornHarvest(World world, BlockPos pos, ItemStack stack, EnumHornType hornType);
/**
* Called to harvest by a horn.
* Note that the stack param can be null if it's a drum breaking it.
*/
public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType);
public void harvestByHorn(World world, BlockPos pos, ItemStack stack, EnumHornType hornType);
public static enum EnumHornType {
@@ -138,17 +138,17 @@ public class BlockModMushroom extends BlockMushroom implements IInfusionStabilis
}
@Override
public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) {
public boolean canHornHarvest(World world, BlockPos pos, ItemStack stack, EnumHornType hornType) {
return false;
}
@Override
public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) {
public boolean hasSpecialHornHarvest(World world, BlockPos pos, ItemStack stack, EnumHornType hornType) {
return false;
}
@Override
public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) {
public void harvestByHorn(World world, BlockPos pos, ItemStack stack, EnumHornType hornType) {
// NO-OP
}
@@ -67,17 +67,17 @@ public class BlockShinyFlower extends BlockModFlower implements IInfusionStabili
}
@Override
public boolean canHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) {
public boolean canHornHarvest(World world, BlockPos pos, ItemStack stack, EnumHornType hornType) {
return false;
}
@Override
public boolean hasSpecialHornHarvest(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) {
public boolean hasSpecialHornHarvest(World world, BlockPos pos, ItemStack stack, EnumHornType hornType) {
return false;
}
@Override
public void harvestByHorn(World world, int x, int y, int z, ItemStack stack, EnumHornType hornType) {
public void harvestByHorn(World world, BlockPos pos, ItemStack stack, EnumHornType hornType) {
// NO-OP
}
@@ -14,6 +14,7 @@ import java.util.Arrays;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -71,18 +72,17 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
Block block = par3World.getBlock(par4, par5, par6);
int meta = par3World.getBlockMetadata(par4, par5, par6);
boolean set = setBlock(par1ItemStack, block, meta);
IBlockState state = par3World.getBlockState(pos);
boolean set = setBlock(par1ItemStack, state.getBlock(), state.getBlock().getMetaFromState(state));
if(!set) {
Block bBlock = getBlock(par1ItemStack);
int bmeta = getBlockMeta(par1ItemStack);
TileEntity tile = par3World.getTileEntity(par4, par5, par6);
TileEntity tile = par3World.getTileEntity(pos);
if(tile != null && tile instanceof IInventory) {
IInventory inv = (IInventory) tile;
int[] slots = inv instanceof ISidedInventory ? ((ISidedInventory) inv).getAccessibleSlotsFromSide(par7) : InventoryHelper.buildSlotsForLinearInventory(inv);
int[] slots = inv instanceof ISidedInventory ? ((ISidedInventory) inv).getSlotsForFace(side) : InventoryHelper.buildSlotsForLinearInventory(inv);
for(int slot : slots) {
ItemStack stackInSlot = inv.getStackInSlot(slot);
if(stackInSlot == null) {
@@ -90,7 +90,7 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
int maxSize = stack.getMaxStackSize();
stack.stackSize = remove(par1ItemStack, maxSize);
if(stack.stackSize != 0) {
if(inv.isItemValidForSlot(slot, stack) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stack, par7))) {
if(inv.isItemValidForSlot(slot, stack) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stack, side))) {
inv.setInventorySlotContents(slot, stack);
inv.markDirty();
set = true;
@@ -99,7 +99,7 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
} else if(stackInSlot.getItem() == Item.getItemFromBlock(bBlock) && stackInSlot.getItemDamage() == bmeta) {
int maxSize = stackInSlot.getMaxStackSize();
int missing = maxSize - stackInSlot.stackSize;
if(inv.isItemValidForSlot(slot, stackInSlot) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stackInSlot, par7))) {
if(inv.isItemValidForSlot(slot, stackInSlot) && (!(inv instanceof ISidedInventory) || ((ISidedInventory) inv).canInsertItem(slot, stackInSlot, side))) {
stackInSlot.stackSize += remove(par1ItemStack, missing);
inv.markDirty();
set = true;
@@ -107,8 +107,7 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
}
}
} else {
ForgeDirection dir = ForgeDirection.getOrientation(par7);
int entities = par3World.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(par4 + dir.offsetX, par5 + dir.offsetY, par6 + dir.offsetZ, par4 + dir.offsetX + 1, par5 + dir.offsetY + 1, par6 + dir.offsetZ + 1)).size();
int entities = par3World.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(pos.offset(side), pos.offset(side).add(1, 1, 1))).size();
if(entities == 0) {
int remove = par2EntityPlayer.capabilities.isCreativeMode ? 1 : remove(par1ItemStack, 1);
@@ -116,7 +115,7 @@ public class ItemBlackHoleTalisman extends ItemMod implements IBlockProvider {
ItemStack stack = new ItemStack(bBlock, 1, bmeta);
ItemsRemainingRenderHandler.set(stack, getBlockCount(par1ItemStack));
Item.getItemFromBlock(bBlock).onItemUse(stack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
Item.getItemFromBlock(bBlock).onItemUse(stack, par2EntityPlayer, par3World, pos, side, par8, par9, par10);
set = true;
}
}
@@ -24,6 +24,8 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import vazkii.botania.common.achievement.ICraftAchievement;
@@ -82,7 +84,7 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) {
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xs, float ys, float zs) {
boolean can = isDOIT(stack);
if(!can) {
String sound = ItemNBTHelper.getString(stack, TAG_SOUND, "");
@@ -92,10 +94,10 @@ public class ItemCacophonium extends ItemMod implements ICraftAchievement {
}
if(can) {
Block block = world.getBlock(x, y, z);
Block block = world.getBlockState(pos).getBlock();
if(block == Blocks.noteblock) {
world.setBlock(x, y, z, ModBlocks.cacophonium);
((TileCacophonium) world.getTileEntity(x, y, z)).stack = stack.copy();
world.setBlockState(pos, ModBlocks.cacophonium.getDefaultState());
((TileCacophonium) world.getTileEntity(pos)).stack = stack.copy();
stack.stackSize--;
return true;
}
@@ -19,6 +19,8 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.api.corporea.CorporeaHelper;
@@ -42,17 +44,17 @@ public class ItemCorporeaSpark extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xv, float yv, float zv) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof IInventory && !CorporeaHelper.doesBlockHaveSpark(world, , x)) {
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xv, float yv, float zv) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof IInventory && !CorporeaHelper.doesBlockHaveSpark(world, pos)) {
stack.stackSize--;
if(!world.isRemote) {
EntityCorporeaSpark spark = new EntityCorporeaSpark(world);
if(stack.getItemDamage() == 1)
spark.setMaster(true);
spark.setPosition(x + 0.5, y + 1.5, z + 0.5);
spark.setPosition(pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5);
world.spawnEntityInWorld(spark);
world.markBlockForUpdate(x, y, z);
world.markBlockForUpdate(pos);
}
return true;
}
@@ -18,6 +18,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.client.core.helper.IconHelper;
@@ -35,12 +37,12 @@ public class ItemCraftPattern extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer p, World world, int x, int y, int z, int s, float xs, float ys, float zs) {
TileEntity tile = world.getTileEntity(x, y, z);
public boolean onItemUse(ItemStack stack, EntityPlayer p, World world, BlockPos pos, EnumFacing side, float xs, float ys, float zs) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null && tile instanceof TileCraftCrate && !world.isRemote) {
TileCraftCrate crate = (TileCraftCrate) tile;
crate.pattern = stack.getItemDamage();
world.markBlockForUpdate(x, y, z);
world.markBlockForUpdate(pos);
}
return false;
}
@@ -490,20 +490,20 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
GL11.glDisable(GL11.GL_CULL_FACE);
ItemCraftingHalo item = (ItemCraftingHalo) stack.getItem();
mc.renderEngine.bindTexture(item.getGlowResource());
tess.startDrawingQuads();
tess.getWorldRenderer().startDrawingQuads();
for(int i = 0; i < segAngles; i++) {
float ang = i + seg * segAngles + shift;
double xp = Math.cos(ang * Math.PI / 180F) * s;
double zp = Math.sin(ang * Math.PI / 180F) * s;
tess.addVertexWithUV(xp * m, y, zp * m, u, v);
tess.addVertexWithUV(xp, y0, zp, u, 0);
tess.getWorldRenderer().addVertexWithUV(xp * m, y, zp * m, u, v);
tess.getWorldRenderer().addVertexWithUV(xp, y0, zp, u, 0);
xp = Math.cos((ang + 1) * Math.PI / 180F) * s;
zp = Math.sin((ang + 1) * Math.PI / 180F) * s;
tess.addVertexWithUV(xp, y0, zp, 0, 0);
tess.addVertexWithUV(xp * m, y, zp * m, 0, v);
tess.getWorldRenderer().addVertexWithUV(xp, y0, zp, 0, 0);
tess.getWorldRenderer().addVertexWithUV(xp * m, y, zp * m, 0, v);
}
y0 = 0;
tess.draw();
@@ -535,7 +535,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
Gui.drawRect(x - 4, y - 4, x + l + 4, y + 35, 0x22000000);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, craftingTable, resolution.getScaledWidth() / 2 - 8, resolution.getScaledHeight() / 2 - 52);
mc.getRenderItem().renderItemAndEffectIntoGUI(craftingTable, resolution.getScaledWidth() / 2 - 8, resolution.getScaledHeight() / 2 - 52);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
mc.fontRendererObj.drawStringWithShadow(name, x, y, 0xFFFFFF);
@@ -578,12 +578,12 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
int ypos = y + i / 3 * 18;
Gui.drawRect(xpos, ypos, xpos + 16, ypos + 16, 0x22000000);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, stack, xpos, ypos);
mc.getRenderItem().renderItemAndEffectIntoGUI(stack, xpos, ypos);
}
}
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, recipe[9], x + 72, y + 18);
RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, recipe[9], x + 72, y + 18);
mc.getRenderItem().renderItemAndEffectIntoGUI(recipe[9], x + 72, y + 18);
mc.getRenderItem().renderItemOverlayIntoGUI(mc.fontRendererObj, recipe[9], x + 72, y + 18);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
}
@@ -16,6 +16,7 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
@@ -29,7 +30,7 @@ public class ItemFertilizer extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
final int range = 3;
if(!par3World.isRemote) {
List<BlockPos> validCoords = new ArrayList();
@@ -37,11 +38,9 @@ public class ItemFertilizer extends ItemMod {
for(int i = -range - 1; i < range; i++)
for(int j = -range - 1; j < range; j++) {
for(int k = 2; k >= -2; k--) {
int x = par4 + i + 1;
int y = par5 + k + 1;
int z = par6 + j + 1;
if(par3World.isAirBlock(x, y, z) && (!par3World.provider.hasNoSky || y < 255) && ModBlocks.flower.canBlockStay(par3World, x, y, z))
validCoords.add(new BlockPos(x, y, z));
BlockPos pos_ = pos.add(i + 1, k + 1, j + 1);
if(par3World.isAirBlock(pos_) && (!par3World.provider.getHasNoSky() || pos_.getY() < 255) && ModBlocks.flower.canBlockStay(par3World, pos_))
validCoords.add(pos_);
}
}
@@ -49,14 +48,14 @@ public class ItemFertilizer extends ItemMod {
for(int i = 0; i < flowerCount; i++) {
BlockPos coords = validCoords.get(par3World.rand.nextInt(validCoords.size()));
validCoords.remove(coords);
par3World.setBlock(coords.posX, coords.posY, coords.posZ, ModBlocks.flower, par3World.rand.nextInt(16), 1 | 2);
par3World.setBlockState(coords, ModBlocks.flower, par3World.rand.nextInt(16), 1 | 2);
}
par1ItemStack.stackSize--;
} else {
for(int i = 0; i < 15; i++) {
double x = par4 - range + par3World.rand.nextInt(range * 2 + 1) + Math.random();
double y = par5 + 1;
double z = par6 - range + par3World.rand.nextInt(range * 2 + 1) + Math.random();
double x = pos.getX() - range + par3World.rand.nextInt(range * 2 + 1) + Math.random();
double y = pos.getY() + 1;
double z = pos.getZ() - range + par3World.rand.nextInt(range * 2 + 1) + Math.random();
float red = (float) Math.random();
float green = (float) Math.random();
float blue = (float) Math.random();
@@ -18,6 +18,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
@@ -91,11 +93,10 @@ public class ItemFlowerBag extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) {
TileEntity tile = world.getTileEntity(x, y, z);
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xs, float ys, float zs) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null && tile instanceof IInventory) {
if(!world.isRemote) {
ForgeDirection side = ForgeDirection.getOrientation(s);
IInventory inv = (IInventory) tile;
ItemStack[] stacks = loadStacks(stack);
ItemStack[] newStacks = new ItemStack[stacks.length];
@@ -10,17 +10,26 @@
*/
package vazkii.botania.common.item;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSkull;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.lib.LibItemNames;
import java.util.UUID;
public class ItemGaiaHead extends ItemMod {
public ItemGaiaHead() {
@@ -31,98 +40,94 @@ public class ItemGaiaHead extends ItemMod {
//
// Deal with it.
@Override
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if(p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_).isReplaceable(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_) && p_77648_7_ != 0)
if (worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos) && side != EnumFacing.DOWN)
{
p_77648_7_ = 1;
p_77648_5_--;
side = EnumFacing.UP;
pos = pos.down();
}
if (p_77648_7_ == 0)
{
return false;
}
else if (!p_77648_3_.isSideSolid(p_77648_4_, p_77648_5_, p_77648_6_, net.minecraftforge.common.util.ForgeDirection.getOrientation(p_77648_7_)))
if (side == EnumFacing.DOWN)
{
return false;
}
else
{
if (p_77648_7_ == 1)
{
++p_77648_5_;
}
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
boolean flag = block.isReplaceable(worldIn, pos);
if (p_77648_7_ == 2)
if (!flag)
{
--p_77648_6_;
}
if (p_77648_7_ == 3)
{
++p_77648_6_;
}
if (p_77648_7_ == 4)
{
--p_77648_4_;
}
if (p_77648_7_ == 5)
{
++p_77648_4_;
}
}
{
if (!p_77648_3_.isRemote)
{
if (!Blocks.skull.canPlaceBlockOnSide(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_)) return false;
p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, ModBlocks.gaiaHead, p_77648_7_, 2); // Gaia head instead of skull
int i1 = 0;
if (p_77648_7_ == 1)
if (!worldIn.isSideSolid(pos, side, true))
{
i1 = MathHelper.floor_double(p_77648_2_.rotationYaw * 16.0F / 360.0F + 0.5D) & 15;
return false;
}
TileEntity tileentity = p_77648_3_.getTileEntity(p_77648_4_, p_77648_5_, p_77648_6_);
pos = pos.offset(side);
}
if (tileentity != null && tileentity instanceof TileEntitySkull)
if (!playerIn.canPlayerEdit(pos, side, stack))
{
return false;
}
else if (!Blocks.skull.canPlaceBlockAt(worldIn, pos))
{
return false;
}
else
{
if (!worldIn.isRemote)
{
/*if (p_77648_1_.getItemDamage() == 3)
if (!Blocks.skull.canPlaceBlockOnSide(worldIn, pos, side)) return false;
worldIn.setBlockState(pos, Blocks.skull.getDefaultState().withProperty(BlockSkull.FACING, side), 3);
int i = 0;
if (side == EnumFacing.UP)
{
GameProfile gameprofile = null;
i = MathHelper.floor_double((double)(playerIn.rotationYaw * 16.0F / 360.0F) + 0.5D) & 15;
}
if (p_77648_1_.hasTagCompound())
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntitySkull)
{
TileEntitySkull tileentityskull = (TileEntitySkull)tileentity;
if (stack.getMetadata() == 3)
{
NBTTagCompound nbttagcompound = p_77648_1_.getTagCompound();
if (nbttagcompound.hasKey("SkullOwner", 10))
{
gameprofile = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("SkullOwner"));
}
else if (nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0)
{
gameprofile = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
}
// GameProfile gameprofile = null;
//
// if (stack.hasTagCompound())
// {
// NBTTagCompound nbttagcompound = stack.getTagCompound();
//
// if (nbttagcompound.hasKey("SkullOwner", 10))
// {
// gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
// }
// else if (nbttagcompound.hasKey("SkullOwner", 8) && nbttagcompound.getString("SkullOwner").length() > 0)
// {
// gameprofile = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
// }
// }
//
// tileentityskull.setPlayerProfile(gameprofile);
}
else
{
tileentityskull.setType(stack.getMetadata());
}
((TileEntitySkull)tileentity).func_152106_a(gameprofile);
tileentityskull.setSkullRotation(i);
Blocks.skull.checkWitherSpawn(worldIn, pos, tileentityskull);
}
else
{
((TileEntitySkull)tileentity).func_152107_a(p_77648_1_.getItemDamage());
}*/
((TileEntitySkull)tileentity).func_145903_a(i1);
((BlockSkull)Blocks.skull).func_149965_a(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, (TileEntitySkull)tileentity);
--stack.stackSize;
}
--p_77648_1_.stackSize;
return true;
}
return true;
}
}
@@ -17,6 +17,7 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
@@ -89,7 +90,7 @@ public class ItemGrassHorn extends ItemMod {
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
return EnumAction.bow;
return EnumAction.BOW;
}
@Override
@@ -112,9 +113,9 @@ public class ItemGrassHorn extends ItemMod {
player.worldObj.playSoundAtEntity(player, "note.bassattack", 1F, 0.001F);
}
public static void breakGrass(World world, ItemStack stack, int stackDmg, int srcx, int srcy, int srcz) {
public static void breakGrass(World world, ItemStack stack, int stackDmg, BlockPos srcPos) {
EnumHornType type = EnumHornType.getTypeForMeta(stackDmg);
Random rand = new Random(srcx ^ srcy ^ srcz);
Random rand = new Random(srcPos.toLong());
int range = 12 - stackDmg * 3;
int rangeY = 3 + stackDmg * 4;
List<BlockPos> coords = new ArrayList();
@@ -122,13 +123,10 @@ public class ItemGrassHorn extends ItemMod {
for(int i = -range; i < range + 1; i++)
for(int j = -range; j < range + 1; j++)
for(int k = -rangeY; k < rangeY + 1; k++) {
int x = srcx + i;
int y = srcy + k;
int z = srcz + j;
Block block = world.getBlock(x, y, z);
if(block instanceof IHornHarvestable ? ((IHornHarvestable) block).canHornHarvest(world, x, y, z, stack, type) : stackDmg == 0 && block instanceof BlockBush && !(block instanceof ISpecialFlower) && (!(block instanceof IGrassHornExcempt) || ((IGrassHornExcempt) block).canUproot(world, x, y, z)) || stackDmg == 1 && block.isLeaves(world, x, y, z) || stackDmg == 2 && block == Blocks.snow_layer)
coords.add(new BlockPos(x, y, z));
BlockPos pos = srcPos.add(i, k, j);
Block block = world.getBlockState(pos).getBlock();
if(block instanceof IHornHarvestable ? ((IHornHarvestable) block).canHornHarvest(world, pos, stack, type) : stackDmg == 0 && block instanceof BlockBush && !(block instanceof ISpecialFlower) && (!(block instanceof IGrassHornExcempt) || ((IGrassHornExcempt) block).canUproot(world, x, y, z)) || stackDmg == 1 && block.isLeaves(world, pos) || stackDmg == 2 && block == Blocks.snow_layer)
coords.add(pos);
}
Collections.shuffle(coords, rand);
@@ -137,19 +135,19 @@ public class ItemGrassHorn extends ItemMod {
for(int i = 0; i < count; i++) {
BlockPos currCoords = coords.get(i);
List<ItemStack> items = new ArrayList();
Block block = world.getBlock(currCoords.posX, currCoords.posY, currCoords.posZ);
int meta = world.getBlockMetadata(currCoords.posX, currCoords.posY, currCoords.posZ);
items.addAll(block.getDrops(world, currCoords.posX, currCoords.posY, currCoords.posZ, meta, 0));
IBlockState state = world.getBlockState(currCoords);
Block block = state.getBlock();
items.addAll(block.getDrops(world, currCoords, state, 0));
if(block instanceof IHornHarvestable && ((IHornHarvestable) block).hasSpecialHornHarvest(world, currCoords.posX, currCoords.posY, currCoords.posZ, stack, type))
((IHornHarvestable) block).harvestByHorn(world, currCoords.posX, currCoords.posY, currCoords.posZ, stack, type);
if(block instanceof IHornHarvestable && ((IHornHarvestable) block).hasSpecialHornHarvest(world, currCoords, stack, type))
((IHornHarvestable) block).harvestByHorn(world, currCoords, stack, type);
else if(!world.isRemote) {
world.setBlockToAir(currCoords.posX, currCoords.posY, currCoords.posZ);
world.setBlockToAir(currCoords);
if(ConfigHandler.blockBreakParticles)
world.playAuxSFX(2001, currCoords.posX, currCoords.posY, currCoords.posZ, Block.getIdFromBlock(block) + (meta << 12));
world.playAuxSFX(2001, currCoords, Block.getStateId(state));
for(ItemStack stack_ : items)
world.spawnEntityInWorld(new EntityItem(world, currCoords.posX + 0.5, currCoords.posY + 0.5, currCoords.posZ + 0.5, stack_));
world.spawnEntityInWorld(new EntityItem(world, currCoords.getX() + 0.5, currCoords.getY() + 0.5, currCoords.getZ() + 0.5, stack_));
}
}
}
@@ -17,6 +17,8 @@ import java.util.Map;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDirt;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -24,6 +26,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.client.core.helper.IconHelper;
@@ -81,15 +84,14 @@ public class ItemGrassSeeds extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
Block block = par3World.getBlock(par4, par5, par6);
int bmeta = par3World.getBlockMetadata(par4, par5, par6);
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
IBlockState state = par3World.getBlockState(pos);
if(block == Blocks.dirt && bmeta == 0) {
if(state == Blocks.dirt.getDefaultState()) {
int meta = par1ItemStack.getItemDamage();
BlockSwapper swapper = addBlockSwapper(par3World, par4, par5, par6, meta);
par3World.setBlock(par4, par5, par6, swapper.blockToSet, swapper.metaToSet, 1 | 2);
BlockSwapper swapper = addBlockSwapper(par3World, pos, meta);
par3World.setBlockState(pos, swapper.stateToSet, 1 | 2);
for(int i = 0; i < 50; i++) {
double x = (Math.random() - 0.5) * 3;
double y = Math.random() - 0.5 + 1;
@@ -110,7 +112,7 @@ public class ItemGrassSeeds extends ItemMod {
float velMul = 0.025F;
Botania.proxy.wispFX(par3World, par4 + 0.5 + x, par5 + 0.5 + y, par6 + 0.5 + z, r, g, b, (float) Math.random() * 0.15F + 0.15F, (float) -x * velMul, (float) -y * velMul, (float) -z * velMul);
Botania.proxy.wispFX(par3World, pos.getX() + 0.5 + x, pos.getY() + 0.5 + y, pos.getZ() + 0.5 + z, r, g, b, (float) Math.random() * 0.15F + 0.15F, (float) -x * velMul, (float) -y * velMul, (float) -z * velMul);
}
par1ItemStack.stackSize--;
@@ -122,7 +124,7 @@ public class ItemGrassSeeds extends ItemMod {
@SubscribeEvent
public void onTickEnd(TickEvent.WorldTickEvent event) {
if(event.phase == Phase.END) {
int dim = event.world.provider.dimensionId;
int dim = event.world.provider.getDimensionId();
if(blockSwappers.containsKey(dim)) {
List<BlockSwapper> swappers = blockSwappers.get(dim);
List<BlockSwapper> swappersSafe = new ArrayList(swappers);
@@ -133,10 +135,10 @@ public class ItemGrassSeeds extends ItemMod {
}
}
private static BlockSwapper addBlockSwapper(World world, int x, int y, int z, int meta) {
BlockSwapper swapper = swapperFromMeta(world, x, y, z, meta);
private static BlockSwapper addBlockSwapper(World world, BlockPos pos, int meta) {
BlockSwapper swapper = swapperFromMeta(world, pos, meta);
int dim = world.provider.dimensionId;
int dim = world.provider.getDimensionId();
if(!blockSwappers.containsKey(dim))
blockSwappers.put(dim, new ArrayList());
blockSwappers.get(dim).add(swapper);
@@ -144,11 +146,11 @@ public class ItemGrassSeeds extends ItemMod {
return swapper;
}
private static BlockSwapper swapperFromMeta(World world, int x, int y, int z, int meta) {
private static BlockSwapper swapperFromMeta(World world, BlockPos pos, int meta) {
switch(meta) {
case 1 : return new BlockSwapper(world, new BlockPos(x, y, z), Blocks.dirt, 2);
case 2 : return new BlockSwapper(world, new BlockPos(x, y, z), Blocks.mycelium, 0);
default : return new BlockSwapper(world, new BlockPos(x, y, z), Blocks.grass, 0);
case 1 : return new BlockSwapper(world, pos, Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL));
case 2 : return new BlockSwapper(world, pos, Blocks.mycelium.getDefaultState());
default : return new BlockSwapper(world, pos, Blocks.grass.getDefaultState());
}
}
@@ -156,17 +158,14 @@ public class ItemGrassSeeds extends ItemMod {
final World world;
final Random rand;
final Block blockToSet;
final int metaToSet;
final IBlockState stateToSet;
BlockPos startCoords;
int ticksExisted = 0;
BlockSwapper(World world, BlockPos coords, Block block, int meta) {
BlockSwapper(World world, BlockPos coords, IBlockState state) {
this.world = world;
blockToSet = block;
metaToSet = meta;
rand = new Random(coords.posX ^ coords.posY ^ coords.posZ);
stateToSet = state;
rand = new Random(coords.toLong());
startCoords = coords;
}
@@ -176,28 +175,25 @@ public class ItemGrassSeeds extends ItemMod {
int range = 3;
for(int i = -range; i < range + 1; i++)
for(int j = -range; j < range + 1; j++) {
int x = startCoords.posX + i;
int y = startCoords.posY;
int z = startCoords.posZ + j;
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
BlockPos pos = startCoords.add(i, 0, j);
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if(block == blockToSet && meta == metaToSet) {
if(state == stateToSet) {
if(ticksExisted % 20 == 0) {
List<BlockPos> validCoords = new ArrayList();
for(int k = -1; k < 2; k++)
for(int l = -1; l < 2; l++) {
int x1 = x + k;
int z1 = z + l;
Block block1 = world.getBlock(x1, y, z1);
int meta1 = world.getBlockMetadata(x1, y, z1);
if(block1 == Blocks.dirt && meta1 == 0)
validCoords.add(new BlockPos(x1, y, z1));
BlockPos pos1 = pos.add(k, 0, l);
IBlockState state1 = world.getBlockState(pos1);
if(state1.getBlock() == Blocks.dirt
&& state1.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT)
validCoords.add(pos1);
}
if(!validCoords.isEmpty() && !world.isRemote) {
BlockPos coords = validCoords.get(rand.nextInt(validCoords.size()));
world.setBlock(coords.posX, coords.posY, coords.posZ, blockToSet, metaToSet, 1 | 2);
world.setBlockState(coords, stateToSet, 1 | 2);
}
}
}
@@ -14,6 +14,7 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
@@ -21,8 +22,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.util.*;
import net.minecraft.world.World;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.BurstProperties;
@@ -71,10 +71,10 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
if(par5 < 160 && !par3World.provider.isHellWorld) {
par3World.playSound(par4 + 0.5D, par5 + 0.5D, par6 + 0.5D, "botania:laputaStart", 1.0F + par3World.rand.nextFloat(), par3World.rand.nextFloat() * 0.7F + 1.3F, false);
spawnBurstFirst(par3World, par4, par5, par6, par1ItemStack);
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
if(pos.getY() < 160 && !par3World.provider.doesWaterVaporize()) {
par3World.playSound(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, "botania:laputaStart", 1.0F + par3World.rand.nextFloat(), par3World.rand.nextFloat() * 0.7F + 1.3F, false);
spawnBurstFirst(par3World, pos, par1ItemStack);
par1ItemStack.stackSize--;
if(par1ItemStack.getItemDamage() == 19)
par2EntityPlayer.addStat(ModAchievements.l20ShardUse, 1);
@@ -83,21 +83,21 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
return true;
}
public void spawnBurstFirst(World world, int srcx, int srcy, int srcz, ItemStack lens) {
public void spawnBurstFirst(World world, BlockPos pos, ItemStack lens) {
int range = BASE_RANGE + lens.getItemDamage();
boolean pointy = world.rand.nextDouble() < 0.25;
double heightscale = (world.rand.nextDouble() + 0.5) * ((double)BASE_RANGE / (double)range);
spawnBurst(world, srcx, srcy, srcz, lens, pointy, heightscale);
spawnBurst(world, pos, lens, pointy, heightscale);
}
public void spawnBurst(World world, int srcx, int srcy, int srcz, ItemStack lens) {
public void spawnBurst(World world, BlockPos pos, ItemStack lens) {
boolean pointy = ItemNBTHelper.getBoolean(lens, TAG_POINTY, false);
double heightscale = ItemNBTHelper.getDouble(lens, TAG_HEIGHTSCALE, 1);
spawnBurst(world, srcx, srcy, srcz, lens, pointy, heightscale);
spawnBurst(world, pos, lens, pointy, heightscale);
}
public void spawnBurst(World world, int srcx, int srcy, int srcz, ItemStack lens, boolean pointy, double heightscale) {
public void spawnBurst(World world, BlockPos pos, ItemStack lens, boolean pointy, double heightscale) {
int range = BASE_RANGE + lens.getItemDamage();
int i = ItemNBTHelper.getInt(lens, TAG_ITERATION_I, 0);
@@ -113,42 +113,40 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
for(; i < range * 2 + 1; i++) {
for(; j > -BASE_RANGE * 2; j--) {
for(; k < range * 2 + 1; k++) {
int x = srcx - range + i;
int y = srcy - BASE_RANGE + j;
int z = srcz - range + k;
BlockPos pos_ = pos.add(-range + i, -BASE_RANGE + j, -range + k);
if(inRange(x, y, z, srcx, srcy, srcz, range, heightscale, pointy)) {
Block block = world.getBlock(x, y, z);
if(!block.isAir(world, x, y, z) && !block.isReplaceable(world, x, y, z) && !(block instanceof BlockFalling) && (!(block instanceof ILaputaImmobile) || ((ILaputaImmobile) block).canMove(world, , x)) && block.getBlockHardness(world, x, y, z) != -1) {
if(inRange(pos_, pos, range, heightscale, pointy)) {
Block block = world.getBlockState(pos_).getBlock();
if(!block.isAir(world, pos_) && !block.isReplaceable(world, pos_) && !(block instanceof BlockFalling) && (!(block instanceof ILaputaImmobile) || ((ILaputaImmobile) block).canMove(world, pos_)) && block.getBlockHardness(world, pos_) != -1) {
int id = Block.getIdFromBlock(block);
int meta = world.getBlockMetadata(x, y, z);
TileEntity tile = world.getTileEntity(x, y, z);
IBlockState state = world.getBlockState(pos_);
TileEntity tile = world.getTileEntity(pos_);
if(tile != null) {
TileEntity newTile = block.createTileEntity(world, meta);
world.setTileEntity(x, y, z, newTile);
TileEntity newTile = block.createTileEntity(world, state);
world.setTileEntity(pos_, newTile);
}
world.setBlockToAir(x, y, z);
world.playAuxSFX(2001, x, y, z, id + (meta << 12));
world.setBlockToAir(pos_);
world.playAuxSFX(2001, pos_, Block.getStateId(state));
ItemStack copyLens = new ItemStack(this, 1, lens.getItemDamage());
ItemNBTHelper.setInt(copyLens, TAG_BLOCK, id);
ItemNBTHelper.setInt(copyLens, TAG_META, meta);
ItemNBTHelper.setInt(copyLens, TAG_META, block.getMetaFromState(state));
NBTTagCompound cmp = new NBTTagCompound();
if(tile != null)
tile.writeToNBT(cmp);
ItemNBTHelper.setCompound(copyLens, TAG_TILE, cmp);
ItemNBTHelper.setInt(copyLens, TAG_X, srcx);
ItemNBTHelper.setInt(copyLens, TAG_Y, srcy);
ItemNBTHelper.setInt(copyLens, TAG_Y_START, y);
ItemNBTHelper.setInt(copyLens, TAG_Z, srcz);
ItemNBTHelper.setInt(copyLens, TAG_X, pos.getX());
ItemNBTHelper.setInt(copyLens, TAG_Y, pos.getY());
ItemNBTHelper.setInt(copyLens, TAG_Y_START, pos_.getY());
ItemNBTHelper.setInt(copyLens, TAG_Z, pos.getZ());
ItemNBTHelper.setBoolean(copyLens, TAG_POINTY, pointy);
ItemNBTHelper.setDouble(copyLens, TAG_HEIGHTSCALE, heightscale);
ItemNBTHelper.setInt(copyLens, TAG_ITERATION_I, i);
ItemNBTHelper.setInt(copyLens, TAG_ITERATION_J, j);
ItemNBTHelper.setInt(copyLens, TAG_ITERATION_K, k);
EntityManaBurst burst = getBurst(world, x, y, z, copyLens);
EntityManaBurst burst = getBurst(world, pos_, copyLens);
world.spawnEntityInWorld(burst);
return;
}
@@ -169,11 +167,11 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
else return MathHelper.pointDistanceSpace(x, 0, z, srcx, 0, srcz) < range - (srcy - y) / heightscale;
}
public EntityManaBurst getBurst(World world, int x, int y, int z, ItemStack stack) {
public EntityManaBurst getBurst(World world, BlockPos pos, ItemStack stack) {
EntityManaBurst burst = new EntityManaBurst(world);
burst.posX = x + 0.5;
burst.posY = y + 0.5;
burst.posZ = z + 0.5;
burst.posX = pos.getX() + 0.5;
burst.posY = pos.getY() + 0.5;
burst.posZ = pos.getZ() + 0.5;
burst.setColor(0x00EAFF);
burst.setMana(1);
@@ -218,13 +216,14 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
int z = ItemNBTHelper.getInt(lens, TAG_Z, 0);
if(y != -1)
spawnBurst(entity.worldObj, x, y, z, lens);
spawnBurst(entity.worldObj, new BlockPos(x, y, z), lens);
} else if(burst.getTicksExisted() == placeTicks) {
int x = net.minecraft.util.MathHelper.floor_double(entity.posX);
int y = ItemNBTHelper.getInt(lens, TAG_Y_START, -1) + targetDistance;
int z = net.minecraft.util.MathHelper.floor_double(entity.posZ);
BlockPos pos = new BlockPos(x, y, z);
if(entity.worldObj.isAirBlock(x, y, z)) {
if(entity.worldObj.isAirBlock(pos)) {
int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0);
Block block = Block.getBlockById(id);
int meta = ItemNBTHelper.getInt(lens, TAG_META, 0);
@@ -234,13 +233,11 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
if(tilecmp.hasKey("id"))
tile = TileEntity.createAndLoadEntity(tilecmp);
entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2);
entity.worldObj.playAuxSFX(2001, x, y, z, id + (meta << 12));
entity.worldObj.setBlockState(pos, block.getStateFromMeta(meta), 1 | 2);
entity.worldObj.playAuxSFX(2001, pos, Block.getStateId(block.getStateFromMeta(meta)));
if(tile != null) {
tile.xCoord = x;
tile.yCoord = y;
tile.zCoord = z;
entity.worldObj.setTileEntity(x, y, z, tile);
tile.setPos(pos);
entity.worldObj.setTileEntity(pos, tile);
}
}
@@ -254,9 +251,9 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
EntityThrowable entity = (EntityThrowable) burst;
ItemStack lens = burst.getSourceLens();
int id = ItemNBTHelper.getInt(lens, TAG_BLOCK, 0);
Block.getBlockById(id);
Block b = Block.getBlockById(id);
int meta = ItemNBTHelper.getInt(lens, TAG_META, 0);
entity.worldObj.spawnParticle("blockcrack_" + id + "_" + meta, entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ);
entity.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ, Block.getStateId(b.getStateFromMeta(meta)));
return true;
}
@@ -21,12 +21,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.util.Vec3;
import net.minecraft.util.*;
import net.minecraft.world.World;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.ILexicon;
@@ -57,13 +52,13 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
if(par2EntityPlayer.isSneaking()) {
Block block = par3World.getBlock(par4, par5, par6);
Block block = par3World.getBlockState(pos).getBlock();
if(block != null) {
if(block instanceof ILexiconable) {
LexiconEntry entry = ((ILexiconable) block).getEntry(par3World, , par4, par2EntityPlayer, par1ItemStack);
LexiconEntry entry = ((ILexiconable) block).getEntry(par3World, pos, par2EntityPlayer, par1ItemStack);
if(entry != null && isKnowledgeUnlocked(par1ItemStack, entry.getKnowledgeType())) {
Botania.proxy.setEntryToOpen(entry);
Botania.proxy.setLexiconStack(par1ItemStack);
@@ -72,8 +67,8 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
return true;
}
} else if(par3World.isRemote) {
MovingObjectPosition pos = new MovingObjectPosition(par4, par5, par6, par7, new Vec3(par8, par9, par10));
return Botania.proxy.openWikiPage(par3World, block, pos);
MovingObjectPosition mop = new MovingObjectPosition(new Vec3(par8, par9, par10), side, pos);
return Botania.proxy.openWikiPage(par3World, block, mop);
}
}
}
@@ -175,7 +170,7 @@ public class ItemLexicon extends ItemMod implements ILexicon, IElvenItem {
@Override
public EnumRarity getRarity(ItemStack par1ItemStack) {
return EnumRarity.uncommon;
return EnumRarity.UNCOMMON;
}
@Override
@@ -33,7 +33,7 @@ public class ItemManaCookie extends ItemFood {
public ItemManaCookie() {
super(0, 0.1F, false);
setPotionEffect(Potion.field_76443_y.id, 1, 0, 1F);
setPotionEffect(Potion.saturation.id, 1, 0, 1F);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setUnlocalizedName(LibItemNames.MANA_COOKIE);
}
@@ -179,11 +179,6 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem {
return getLens(itemStack);
}
@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack p_77630_1_) {
return false;
}
public EntityManaBurst getBurst(EntityPlayer player, ItemStack stack, boolean request) {
EntityManaBurst burst = new EntityManaBurst(player);
@@ -20,6 +20,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import vazkii.botania.api.mana.IManaItem;
@@ -65,11 +66,6 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
return 1000 - (int) (mana / TilePool.MAX_MANA * 1000);
}
@Override
public int getDisplayDamage(ItemStack stack) {
return getDamage(stack);
}
@Override
public void registerIcons(IIconRegister par1IconRegister) {
icons = new IIcon[2];
@@ -105,9 +101,9 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
if(par2EntityPlayer.isSneaking() && !par3World.isRemote) {
TileEntity tile = par3World.getTileEntity(par4, par5, par6);
TileEntity tile = par3World.getTileEntity(pos);
if(tile != null && tile instanceof IManaPool) {
bindPool(par1ItemStack, tile);
par3World.playSoundAtEntity(par2EntityPlayer, "botania:ding", 1F, 1F);
@@ -118,11 +114,6 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
return false;
}
@Override
public boolean requiresMultipleRenderPasses() {
return true;
}
/*public int getMana(ItemStack stack) {
IManaPool pool = getManaPool(stack);
return pool == null ? 0 : pool.getCurrentMana();
@@ -166,10 +157,10 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
}*/
public void bindPool(ItemStack stack, TileEntity pool) {
ItemNBTHelper.setInt(stack, TAG_POS_X, pool == null ? 0 : pool.xCoord);
ItemNBTHelper.setInt(stack, TAG_POS_Y, pool == null ? -1 : pool.yCoord);
ItemNBTHelper.setInt(stack, TAG_POS_Z, pool == null ? 0 : pool.zCoord);
ItemNBTHelper.setInt(stack, TAG_DIM, pool == null ? 0 : pool.getWorld().provider.dimensionId);
ItemNBTHelper.setInt(stack, TAG_POS_X, pool == null ? 0 : pool.getPos().getX());
ItemNBTHelper.setInt(stack, TAG_POS_Y, pool == null ? -1 : pool.getPos().getY());
ItemNBTHelper.setInt(stack, TAG_POS_Z, pool == null ? 0 : pool.getPos().getZ());
ItemNBTHelper.setInt(stack, TAG_DIM, pool == null ? 0 : pool.getWorld().provider.getDimensionId());
}
public BlockPos getPoolCoords(ItemStack stack) {
@@ -189,19 +180,19 @@ public class ItemManaMirror extends ItemMod implements IManaItem, ICoordBoundIte
return fallbackPool;
BlockPos coords = getPoolCoords(stack);
if(coords.posY == -1)
if(coords.getY() == -1)
return null;
int dim = getDimension(stack);
World world = null;
for(World w : server.worldServers)
if(w.provider.dimensionId == dim) {
if(w.provider.getDimensionId() == dim) {
world = w;
break;
}
if(world != null) {
TileEntity tile = world.getTileEntity(coords.posX, coords.posY, coords.posZ);
TileEntity tile = world.getTileEntity(coords);
if(tile != null && tile instanceof IManaPool)
return (IManaPool) tile;
}
@@ -73,11 +73,6 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP
return 1000 - (int) (mana / MAX_MANA * 1000);
}
@Override
public int getDisplayDamage(ItemStack stack) {
return getDamage(stack);
}
@Override
public void registerIcons(IIconRegister par1IconRegister) {
icons = new IIcon[2];
@@ -96,11 +91,6 @@ public class ItemManaTablet extends ItemMod implements IManaItem, ICreativeManaP
par3List.add(StatCollector.translateToLocal("botaniamisc.creative"));
}
@Override
public boolean requiresMultipleRenderPasses() {
return true;
}
@Override
public int getEntityLifespan(ItemStack itemStack, World world) {
return Integer.MAX_VALUE;
@@ -13,6 +13,8 @@ package vazkii.botania.common.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import vazkii.botania.api.mana.IManaCollector;
import vazkii.botania.api.mana.IManaPool;
@@ -32,8 +34,8 @@ public class ItemObedienceStick extends ItemMod {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) {
TileEntity tileAt = world.getTileEntity(x, y, z);
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xs, float ys, float zs) {
TileEntity tileAt = world.getTileEntity(pos);
if(tileAt != null && (tileAt instanceof IManaPool || tileAt instanceof IManaCollector)) {
boolean pool = tileAt instanceof IManaPool;
Actuator act = pool ? Actuator.functionalActuator : Actuator.generatingActuator;
@@ -42,18 +44,16 @@ public class ItemObedienceStick extends ItemMod {
for(int i = -range; i < range + 1; i++)
for(int j = -range; j < range + 1; j++)
for(int k = -range; k < range + 1; k++) {
int xp = x + i;
int yp = y + j;
int zp = z + k;
if(MathHelper.pointDistanceSpace(xp, yp, zp, x, y, z) > range)
BlockPos pos_ = pos.add(i, j, k);
if(MathHelper.pointDistanceSpace(pos_, pos) > range)
continue;
TileEntity tile = world.getTileEntity(xp, yp, zp);
TileEntity tile = world.getTileEntity(pos_);
if(tile instanceof ISubTileContainer) {
SubTileEntity subtile = ((ISubTileContainer) tile).getSubTile();
if(act.actuate(subtile, tileAt)) {
Vector3 orig = new Vector3(xp + 0.5, yp + 0.5, zp + 0.5);
Vector3 end = new Vector3(x + 0.5, y + 0.5, z + 0.5);
Vector3 orig = new Vector3(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5);
Vector3 end = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
ItemTwigWand.doParticleBeam(world, orig, end);
}
}
@@ -10,9 +10,11 @@
*/
package vazkii.botania.common.item;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import vazkii.botania.common.lib.LibItemNames;
@@ -32,26 +34,24 @@ public class ItemOpenBucket extends ItemMod {
return par1ItemStack;
else {
if(movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
int i = movingobjectposition.blockX;
int j = movingobjectposition.blockY;
int k = movingobjectposition.blockZ;
BlockPos pos = movingobjectposition.getBlockPos();
if(!par2World.canMineBlock(par3EntityPlayer, i, j, k))
if(!par2World.isBlockModifiable(par3EntityPlayer, pos))
return par1ItemStack;
if(!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack))
if(!par3EntityPlayer.canPlayerEdit(pos, movingobjectposition.sideHit, par1ItemStack))
return par1ItemStack;
Material material = par2World.getBlock(i, j, k).getMaterial();
int l = par2World.getBlockMetadata(i, j, k);
Material material = par2World.getBlockState(pos).getBlock().getMaterial();
int l = ((Integer) par2World.getBlockState(pos).getValue(BlockLiquid.LEVEL));
if(material == Material.water && l == 0) {
par2World.setBlockToAir(i, j, k);
par2World.setBlockToAir(pos);
return par1ItemStack;
}
if(material == Material.lava && l == 0) {
par2World.setBlockToAir(i, j, k);
par2World.setBlockToAir(pos);
return par1ItemStack;
}
}
@@ -66,11 +66,6 @@ public class ItemManaInkwell extends ItemMod implements IManaItem, IScribeTools
super.setDamage(stack, damage);
}
@Override
public int getDisplayDamage(ItemStack stack) {
return getDamage(stack);
}
@Override
public int getEntityLifespan(ItemStack itemStack, World world) {
return Integer.MAX_VALUE;