Most of rod package

This commit is contained in:
Vincent Lee committed 2015-11-20 13:45:35 -06:00
1 parent e3b22975cb
commit 55bf02798d
23 files changed
+172 -178

No files matched your search

@@ -85,7 +85,7 @@ public final class RedStringRenderer {
GL11.glLineWidth(1F);
tessellator.getWorldRenderer().startDrawing(GL11.GL_LINES);
double len = (double) -ClientTickHandler.ticksInGame / 100F + new Random(dir.ordinal() ^ tile.getPos().toLong()).nextInt(10000);
double len = (double) -ClientTickHandler.ticksInGame / 100F + new Random(dir.ordinal() ^ tile.getPos().hashCode()).nextInt(10000);
double add = vecMag.mag();
double rand = Math.random() - 0.5;
for(int i = 0; i < stages; i++) {
@@ -39,7 +39,7 @@ public class RenderTileFloatingFlower extends TileEntitySpecialRenderer {
double worldTime = tile.getWorld() == null ? 0 : (double) (ClientTickHandler.ticksInGame + t);
if(tile.getWorld() != null)
worldTime += new Random(tile.getPos().toLong()).nextInt(1000);
worldTime += new Random(tile.getPos().hashCode()).nextInt(1000);
GL11.glTranslatef(0.5F, 0F, 0.5F);
GL11.glRotatef(-((float) worldTime * 0.5F), 0F, 1F, 0F);
@@ -43,7 +43,7 @@ public class RenderTileHourglass extends TileEntitySpecialRenderer {
int wtime = tileentity.getWorld() == null ? 0 : ClientTickHandler.ticksInGame;
if(wtime != 0)
wtime += new Random(tileentity.getPos().toLong()).nextInt(360);
wtime += new Random(tileentity.getPos().hashCode()).nextInt(360);
float time = wtime == 0 ? 0 : wtime + ticks;
float x = 0.5F + (float) Math.cos(time * 0.05F) * 0.025F;
@@ -68,7 +68,7 @@ public class RenderTilePylon extends TileEntitySpecialRenderer {
double worldTime = tileentity.getWorld() == null ? 0 : (double) (ClientTickHandler.ticksInGame + pticks);
if(tileentity != null)
worldTime += new Random(tileentity.getPos().toLong()).nextInt(360);
worldTime += new Random(tileentity.getPos().hashCode()).nextInt(360);
if(ConfigHandler.oldPylonModel) {
GL11.glTranslated(d0 + 0.5, d1 + 2.2, d2 + 0.5);
@@ -70,7 +70,7 @@ public class RenderTileSpreader extends TileEntitySpecialRenderer {
double time = ClientTickHandler.ticksInGame + ticks;
if(spreader.isULTRA_SPREADER()) {
Color color = Color.getHSBColor((float) ((time * 5 + new Random(spreader.getPos().toLong()).nextInt(10000)) % 360) / 360F, 0.4F, 0.9F);
Color color = Color.getHSBColor((float) ((time * 5 + new Random(spreader.getPos().hashCode()).nextInt(10000)) % 360) / 360F, 0.4F, 0.9F);
GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
}
model.render();
@@ -45,7 +45,7 @@ public class RenderTileTeruTeruBozu extends TileEntitySpecialRenderer {
double time = Botania.proxy.getWorldElapsedTicks() + f;
boolean hasWorld = tileentity.getWorld() != null;
if(hasWorld)
time += new Random(tileentity.getPos().toLong()).nextInt(1000);
time += new Random(tileentity.getPos().hashCode()).nextInt(1000);
GL11.glTranslatef(0.5F, -1.25F + (hasWorld ? (float) Math.sin(time * 0.01F) * 0.05F : 0F), -0.5F);
if(hasWorld) {
@@ -115,7 +115,7 @@ public class ItemGrassHorn extends ItemMod {
public static void breakGrass(World world, ItemStack stack, int stackDmg, BlockPos srcPos) {
EnumHornType type = EnumHornType.getTypeForMeta(stackDmg);
Random rand = new Random(srcPos.toLong());
Random rand = new Random(srcPos.hashCode());
int range = 12 - stackDmg * 3;
int rangeY = 3 + stackDmg * 4;
List<BlockPos> coords = new ArrayList();
@@ -214,7 +214,7 @@ public class ItemGrassSeeds extends ItemMod {
BlockSwapper(World world, BlockPos coords, IBlockState state) {
this.world = world;
stateToSet = state;
rand = new Random(coords.toLong());
rand = new Random(coords.hashCode());
startCoords = coords;
}
@@ -17,7 +17,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.common.core.helper.ItemNBTHelper;
@@ -27,8 +27,8 @@ public class LensFirework extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(!burst.isFake()) {
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) {
BlockPos coords = burst.getBurstSourceBlockPos();
if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && !pos.getBlockPos().equals(coords)) {
ItemStack fireworkStack = generateFirework(burst.getColor());
EntityFireworkRocket rocket = new EntityFireworkRocket(entity.worldObj, entity.posX, entity.posY, entity.posZ, fireworkStack);
@@ -13,6 +13,7 @@ package vazkii.botania.common.item.lens;
import java.awt.Color;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
@@ -52,18 +53,18 @@ public class LensFlare extends Lens {
TileEntity tile = (TileEntity) spreader;
if(storedColor == 16) {
Color c = Color.getHSBColor(tile.getWorldObj().getTotalWorldTime() * 2 % 360 / 360F, 1F, 1F);
Color c = Color.getHSBColor(tile.getWorld().getTotalWorldTime() * 2 % 360 / 360F, 1F, 1F);
r = (float) c.getRed() / 255F;
g = (float) c.getGreen() / 255F;
b = (float) c.getBlue() / 255F;
} else if(storedColor >= 0) {
float[] colortable = EntitySheep.fleeceColorTable[storedColor];
r = colortable[0];
g = colortable[1];
b = colortable[2];
int hex = EnumDyeColor.byMetadata(storedColor).getMapColor().colorValue;
r = (hex & 0xFF0000) >> 16;
g = (hex & 0xFF00) >> 8;
b = (hex & 0xFF);
}
Botania.proxy.wispFX(tile.getWorldObj(), tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5, r, g, b, 0.4F, mx, my, mz);
Botania.proxy.wispFX(tile.getWorld(), tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, r, g, b, 0.4F, mx, my, mz);
}
}
@@ -28,53 +28,51 @@ public class LensMagnet extends Lens {
@Override
public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) {
int x = (int) entity.posX;
int y = (int) entity.posY;
int z = (int) entity.posZ;
BlockPos basePos = new BlockPos(entity);
boolean magnetized = entity.getEntityData().hasKey(TAG_MAGNETIZED);
int range = 3;
magnetize : {
for(int i = -range; i < range; i++)
for(int j = -range; j < range; j++)
for(int k = -range; k < range; k++)
if(entity.worldObj.getTileEntity(i + x, j + y, k + z) instanceof IManaReceiver) {
TileEntity tile = entity.worldObj.getTileEntity(i + x, j + y, k + z);
for (BlockPos pos : ((Iterable<BlockPos>) BlockPos.getAllInBox(basePos.add(-range, -range, -range), basePos.add(range, range, range)))) {
if(entity.worldObj.getTileEntity(pos) instanceof IManaReceiver) {
TileEntity tile = entity.worldObj.getTileEntity(pos);
if(magnetized) {
int magX = entity.getEntityData().getInteger(TAG_MAGNETIZED_X);
int magY = entity.getEntityData().getInteger(TAG_MAGNETIZED_Y);
int magZ = entity.getEntityData().getInteger(TAG_MAGNETIZED_Z);
if(tile.xCoord != magX || tile.yCoord != magY || tile.zCoord != magZ)
continue;
}
if(magnetized) {
int magX = entity.getEntityData().getInteger(TAG_MAGNETIZED_X);
int magY = entity.getEntityData().getInteger(TAG_MAGNETIZED_Y);
int magZ = entity.getEntityData().getInteger(TAG_MAGNETIZED_Z);
if(tile.getPos().getX() != magX || tile.getPos().getY() != magY || tile.getPos().getZ() != magZ)
continue;
}
IManaReceiver receiver = (IManaReceiver) tile;
IManaReceiver receiver = (IManaReceiver) tile;
BlockPos srcCoords = burst.getBurstSourceBlockPos();
BlockPos srcCoords = burst.getBurstSourceBlockPos();
if(MathHelper.pointDistanceSpace(tile.xCoord, tile.yCoord, tile.zCoord, srcCoords.posX, srcCoords.posY, srcCoords.posZ) > 3 && receiver.canRecieveManaFromBursts() && !receiver.isFull()) {
Vector3 burstVec = Vector3.fromEntity(entity);
Vector3 tileVec = Vector3.fromTileEntityCenter(tile).add(0, -0.1, 0);
Vector3 motionVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ);
if(MathHelper.pointDistanceSpace(tile.getPos(), srcCoords) > 3 && receiver.canRecieveManaFromBursts() && !receiver.isFull()) {
Vector3 burstVec = Vector3.fromEntity(entity);
Vector3 tileVec = Vector3.fromTileEntityCenter(tile).add(0, -0.1, 0);
Vector3 motionVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ);
Vector3 normalMotionVec = motionVec.copy().normalize();
Vector3 magnetVec = tileVec.sub(burstVec).normalize();
Vector3 differenceVec = normalMotionVec.sub(magnetVec).multiply(motionVec.mag() * 0.1);
Vector3 normalMotionVec = motionVec.copy().normalize();
Vector3 magnetVec = tileVec.sub(burstVec).normalize();
Vector3 differenceVec = normalMotionVec.sub(magnetVec).multiply(motionVec.mag() * 0.1);
Vector3 finalMotionVec = motionVec.sub(differenceVec);
if(!magnetized) {
finalMotionVec.multiply(0.75);
entity.getEntityData().setBoolean(TAG_MAGNETIZED, true);
entity.getEntityData().setInteger(TAG_MAGNETIZED_X, tile.xCoord);
entity.getEntityData().setInteger(TAG_MAGNETIZED_Y, tile.yCoord);
entity.getEntityData().setInteger(TAG_MAGNETIZED_Z, tile.zCoord);
}
burst.setMotion(finalMotionVec.x, finalMotionVec.y, finalMotionVec.z);
break magnetize;
}
Vector3 finalMotionVec = motionVec.sub(differenceVec);
if(!magnetized) {
finalMotionVec.multiply(0.75);
entity.getEntityData().setBoolean(TAG_MAGNETIZED, true);
entity.getEntityData().setInteger(TAG_MAGNETIZED_X, tile.getPos().getX());
entity.getEntityData().setInteger(TAG_MAGNETIZED_Y, tile.getPos().getY());
entity.getEntityData().setInteger(TAG_MAGNETIZED_Z, tile.getPos().getZ());
}
burst.setMotion(finalMotionVec.x, finalMotionVec.y, finalMotionVec.z);
break magnetize;
}
}
}
}
}
@@ -14,11 +14,14 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.util.ForgeDirection;
import vazkii.botania.api.BotaniaAPI;
@@ -33,21 +36,21 @@ public class LensPaint extends Lens {
if(!burst.isFake() && storedColor > -1 && storedColor < 17) {
if(pos.entityHit != null && pos.entityHit instanceof EntitySheep) {
int r = 20;
int sheepColor = ((EntitySheep) pos.entityHit).getFleeceColor();
EnumDyeColor sheepColor = ((EntitySheep) pos.entityHit).getFleeceColor();
List<EntitySheep> sheepList = entity.worldObj.getEntitiesWithinAABB(EntitySheep.class, new AxisAlignedBB(pos.entityHit.posX - r, pos.entityHit.posY - r, pos.entityHit.posZ - r, pos.entityHit.posX + r, pos.entityHit.posY + r, pos.entityHit.posZ + r));
for(EntitySheep sheep : sheepList) {
if(sheep.getFleeceColor() == sheepColor)
sheep.setFleeceColor(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor);
sheep.setFleeceColor(EnumDyeColor.byMetadata(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor));
}
dead = true;
} else {
Block block = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
Block block = entity.worldObj.getBlockState(pos.getBlockPos()).getBlock();
if(BotaniaAPI.paintableBlocks.contains(block)) {
int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
IBlockState state = entity.worldObj.getBlockState(pos.getBlockPos());
List<BlockPos> coordsToPaint = new ArrayList();
List<BlockPos> coordsFound = new ArrayList();
BlockPos theseCoords = new BlockPos(pos.blockX, pos.blockY, pos.blockZ);
BlockPos theseCoords = pos.getBlockPos();
coordsFound.add(theseCoords);
do {
@@ -56,29 +59,28 @@ public class LensPaint extends Lens {
coordsFound.remove(coords);
coordsToPaint.add(coords);
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Block block_ = entity.worldObj.getBlock(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ);
int meta_ = entity.worldObj.getBlockMetadata(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ);
BlockPos coords_ = new BlockPos(coords.posX + dir.offsetX, coords.posY + dir.offsetY, coords.posZ + dir.offsetZ);
if(block_ == block && meta_ == meta && !coordsFound.contains(coords_) && !coordsToPaint.contains(coords_))
for(EnumFacing dir : EnumFacing.VALUES) {
IBlockState state_ = entity.worldObj.getBlockState(coords.offset(dir));
BlockPos coords_ = new BlockPos(coords.offset(dir));
if(state_ == state && !coordsFound.contains(coords_) && !coordsToPaint.contains(coords_))
coordsFound.add(coords_);
}
}
} while(!coordsFound.isEmpty() && coordsToPaint.size() < 1000);
for(BlockPos coords : coordsToPaint) {
int placeColor = storedColor == 16 ? entity.worldObj.rand.nextInt(16) : storedColor;
int metaThere = entity.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ);
EnumDyeColor placeColor = EnumDyeColor.byMetadata(storedColor == 16 ? entity.worldObj.rand.nextInt(16) : storedColor);
IBlockState stateThere = entity.worldObj.getBlockState(coords);
if(metaThere != placeColor) {
if(!entity.worldObj.isRemote)
entity.worldObj.setBlockMetadataWithNotify(coords.posX, coords.posY, coords.posZ, placeColor, 2);
float[] color = EntitySheep.fleeceColorTable[placeColor];
float r = color[0];
float g = color[1];
float b = color[2];
entity.worldObj.setBlockState(coords, placeColor, 2);
int hex = placeColor.getMapColor().colorValue;
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = (hex & 0xFF);
for(int i = 0; i < 4; i++)
Botania.proxy.sparkleFX(entity.worldObj, coords.posX + (float) Math.random(), coords.posY + (float) Math.random(), coords.posZ + (float) Math.random(), r, g, b, 0.6F + (float) Math.random() * 0.3F, 5);
Botania.proxy.sparkleFX(entity.worldObj, coords.getX() + (float) Math.random(), coords.getY() + (float) Math.random(), coords.getZ() + (float) Math.random(), r, g, b, 0.6F + (float) Math.random() * 0.3F, 5);
}
}
@@ -14,7 +14,7 @@ import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.IDirectioned;
@@ -28,18 +28,18 @@ public class LensRedirect extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
if(!entity.worldObj.isRemote && pos.entityHit == null && coords.posY != -1 && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) {
TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
BlockPos coords = burst.getBurstSourceBlockPos();
if(!entity.worldObj.isRemote && pos.entityHit == null && coords.getY() != -1 && !pos.getBlockPos().equals(coords)) {
TileEntity tile = entity.worldObj.getTileEntity(pos.getBlockPos());
if(tile != null && tile instanceof IRedirectable) {
if(!burst.isFake()) {
IRedirectable redir = (IRedirectable) tile;
Vector3 tileVec = Vector3.fromTileEntityCenter(tile);
Vector3 sourceVec = new Vector3(coords.posX + 0.5, coords.posY + 0.5, coords.posZ + 0.5);
Vector3 sourceVec = new Vector3(coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5);
AxisAlignedBB axis = entity.worldObj.getBlock(coords.posX, coords.posY, coords.posZ).getCollisionBoundingBoxFromPool(entity.worldObj, coords.posX, coords.posY, coords.posZ);
AxisAlignedBB axis = entity.worldObj.getBlockState(coords).getBlock().getCollisionBoundingBox(entity.worldObj, coords, entity.worldObj.getBlockState(coords));
if(axis == null)
axis = AxisAlignedBB.getBoundingBox(coords.posX, coords.posY, coords.posZ, coords.posX + 1, coords.posY + 1, coords.posZ + 1);
axis = new AxisAlignedBB(coords, coords.add(1, 1, 1));
if(!sourceVec.isInside(axis))
sourceVec = new Vector3(axis.minX + (axis.maxX - axis.minX) / 2, axis.minY + (axis.maxY - axis.minY) / 2, axis.minZ + (axis.maxZ - axis.minZ) / 2);
@@ -14,6 +14,8 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import vazkii.botania.api.item.IBlockProvider;
import vazkii.botania.api.mana.IManaUsingItem;
@@ -31,7 +33,7 @@ public class ItemCobbleRod extends ItemMod implements IManaUsingItem, IBlockProv
}
@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) {
return ItemDirtRod.place(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, Blocks.cobblestone, COST, 0.3F, 0.3F, 0.3F);
}
@@ -18,8 +18,9 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import vazkii.botania.api.item.IBlockProvider;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
@@ -44,23 +45,22 @@ public class ItemDirtRod extends ItemMod implements IManaUsingItem, ICraftAchiev
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
return place(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, Blocks.dirt, COST, 0.35F, 0.2F, 0.05F);
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
return place(par1ItemStack, par2EntityPlayer, par3World, pos, side, par8, par9, par10, Blocks.dirt, COST, 0.35F, 0.2F, 0.05F);
}
public static boolean place(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10, Block block, int cost, float r, float g, float b) {
public static boolean place(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10, Block block, int cost, float r, float g, float b) {
if(ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, cost, false)) {
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) {
ItemStack stackToPlace = new ItemStack(block);
stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
stackToPlace.onItemUse(par2EntityPlayer, par3World, pos, side, par8, par9, par10);
if(stackToPlace.stackSize == 0) {
ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, cost, true);
for(int i = 0; i < 6; i++)
Botania.proxy.sparkleFX(par3World, par4 + dir.offsetX + Math.random(), par5 + dir.offsetY + Math.random(), par6 + dir.offsetZ + Math.random(), r, g, b, 1F, 5);
Botania.proxy.sparkleFX(par3World, pos.getX() + side.getFrontOffsetX() + Math.random(), pos.getY() + side.getFrontOffsetY() + Math.random(), pos.getZ() + side.getFrontOffsetZ() + Math.random(), r, g, b, 1F, 5);
}
}
}
@@ -13,9 +13,11 @@ package vazkii.botania.common.item.rod;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
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.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@@ -45,12 +47,9 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarW
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer p) {
if(ManaItemHandler.requestManaExactForTool(stack, p, COST, true)) {
if(world.isRemote) {
int x = MathHelper.floor_double(p.posX);
int y = MathHelper.floor_double(p.posY);
int z = MathHelper.floor_double(p.posZ);
int range = IManaProficiencyArmor.Helper.hasProficiency(p) ? 20 : 15;
long seedxor = world.rand.nextLong();
doHighlight(world, x, y, z, range, seedxor);
doHighlight(world, new BlockPos(p), range, seedxor);
p.swingItem();
} else world.playSoundAtEntity(p, "botania:divinationRod", 1F, 1F);
}
@@ -58,22 +57,19 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarW
return stack;
}
public void doHighlight(World world, int x, int y, int z, int range, long seedxor) {
public void doHighlight(World world, BlockPos pos, int range, long seedxor) {
Botania.proxy.setWispFXDepthTest(false);
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;
Block block = world.getBlock(xp, yp, zp);
int meta = world.getBlockMetadata(xp, yp, zp);
ItemStack orestack = new ItemStack(block, 1, meta);
BlockPos pos_ = pos.add(i, j, k);
IBlockState state = world.getBlockState(pos_);
ItemStack orestack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
for(int id : OreDictionary.getOreIDs(orestack)) {
String s = OreDictionary.getOreName(id);
if(s.matches("^ore[A-Z].+")) {
Random rand = new Random(s.hashCode() ^ seedxor);
Botania.proxy.wispFX(world, xp + world.rand.nextFloat(), yp + world.rand.nextFloat(), zp + world.rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 0.25F, 0F, 8);
Botania.proxy.wispFX(world, pos_.getX() + world.rand.nextFloat(), pos_.getY() + world.rand.nextFloat(), pos_.getZ() + world.rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 0.25F, 0F, 8);
break;
}
}
@@ -91,7 +87,7 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarW
TileEntity te = (TileEntity) tile;
World world = te.getWorld();
if(tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 200 == 0 && tile.isEnabled()) {
doHighlight(world, te.xCoord, te.yCoord, te.zCoord, 18, te.xCoord ^ te.yCoord ^ te.zCoord);
doHighlight(world, te.getPos(), 18, te.getPos().hashCode());
tile.recieveMana(-COST);
}
}
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
@@ -25,10 +26,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import vazkii.botania.api.item.IBlockProvider;
@@ -67,19 +68,16 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
}
@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 wblock = par3World.getBlock(par4, par5, par6);
int wmeta = 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 wstate = par3World.getBlockState(pos);
if(par2EntityPlayer.isSneaking()) {
TileEntity tile = par3World.getTileEntity(par4, par5, par6);
TileEntity tile = par3World.getTileEntity(pos);
if(tile == null) {
if(BlockCamo.isValidBlock(wblock)) {
Item item = Item.getItemFromBlock(wblock);
if(!item.getHasSubtypes())
wmeta = 0;
if(BlockCamo.isValidBlock(wstate.getBlock())) {
Item item = Item.getItemFromBlock(wstate.getBlock());
boolean set = setBlock(par1ItemStack, wblock, wmeta);
boolean set = setBlock(par1ItemStack, wstate.getBlock(), !item.getHasSubtypes() ? 0 : wstate.getBlock().getMetaFromState(wstate));
par2EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack);
displayRemainderCounter(par2EntityPlayer, par1ItemStack);
@@ -89,13 +87,13 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
} else if(canExchange(par1ItemStack) && !ItemNBTHelper.getBoolean(par1ItemStack, TAG_SWAPPING, false)) {
Block block = getBlock(par1ItemStack);
int meta = getBlockMeta(par1ItemStack);
List<BlockPos> swap = getBlocksToSwap(par3World, par1ItemStack, block, meta, par4, par5, par6, null, 0);
List<BlockPos> swap = getBlocksToSwap(par3World, par1ItemStack, block.getStateFromMeta(meta), pos, null);
if(swap.size() > 0) {
ItemNBTHelper.setBoolean(par1ItemStack, TAG_SWAPPING, true);
ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_X, par4);
ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Y, par5);
ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Z, par6);
setTargetBlock(par1ItemStack, wblock, wmeta);
ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_X, pos.getX());
ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Y, pos.getY());
ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_Z, pos.getZ());
setTargetBlock(par1ItemStack, wstate.getBlock(), wstate.getBlock().getMetaFromState(wstate));
if(par3World.isRemote)
par2EntityPlayer.swingItem();
}
@@ -109,7 +107,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
if(event.action == Action.LEFT_CLICK_BLOCK) {
ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
if(stack != null && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, false)) {
if(exchange(event.world, event.entityPlayer, event.x, event.y, event.z, stack, getBlock(stack), getBlockMeta(stack)))
if(exchange(event.world, event.entityPlayer, event.pos, stack, getBlock(stack).getStateFromMeta(getBlockMeta(stack))))
ManaItemHandler.requestManaExactForTool(stack, event.entityPlayer, COST, true);
}
}
@@ -140,24 +138,23 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
int z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0);
Block targetBlock = getTargetBlock(stack);
int targetMeta = getTargetBlockMeta(stack);
List<BlockPos> swap = getBlocksToSwap(world, stack, block, meta, x, y, z, targetBlock, targetMeta);
List<BlockPos> swap = getBlocksToSwap(world, stack, block.getStateFromMeta(meta), new BlockPos(x, y, z), targetBlock.getStateFromMeta(targetMeta));
if(swap.size() == 0) {
ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
return;
}
BlockPos coords = swap.get(world.rand.nextInt(swap.size()));
boolean exchange = exchange(world, player, coords.posX, coords.posY, coords.posZ, stack, block, meta);
boolean exchange = exchange(world, player, coords, stack, block.getStateFromMeta(meta));
if(exchange)
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
else ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
}
}
public Boolean[][][] createMatrix(World world, ItemStack stack, Block blockToSwap, int metaToSwap, int xc, int yc, int zc, Block targetBlock, int targetMeta) {
if(targetBlock == null) {
targetBlock = world.getBlock(xc, yc, zc);
targetMeta = world.getBlockMetadata(xc, yc, zc);
public Boolean[][][] createMatrix(World world, ItemStack stack, IBlockState swapState, BlockPos pos, IBlockState targetState) {
if(targetState == null) {
targetState = world.getBlockState(pos);
}
int effrange = RANGE + ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1);
@@ -166,15 +163,12 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
for(int i = 0; i < diameter; i++)
for(int j = 0; j < diameter; j++)
for(int k = 0; k < diameter; k++) {
int x = xc + i - effrange;
int y = yc + j - effrange;
int z = zc + k - effrange;
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
boolean invalid = !BlockCamo.isValidBlock(block);
BlockPos pos_ = pos.add(i - effrange, j - effrange, k - effrange);
IBlockState state = world.getBlockState(pos_);
boolean invalid = !BlockCamo.isValidBlock(state.getBlock());
if(invalid)
matrix[i][j][k] = true;
else if(block == blockToSwap && meta == metaToSwap || block != targetBlock || meta != targetMeta)
else if(state == swapState || state != targetState)
matrix[i][j][k] = null;
else matrix[i][j][k] = false;
}
@@ -182,25 +176,22 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
return matrix;
}
public List<BlockPos> getBlocksToSwap(World world, ItemStack stack, Block blockToSwap, int metaToSwap, int xc, int yc, int zc, Block targetBlock, int targetMeta) {
public List<BlockPos> getBlocksToSwap(World world, ItemStack stack, IBlockState swapState, BlockPos pos, IBlockState targetState) {
List<BlockPos> coordsList = new ArrayList();
Boolean[][][] matrix = createMatrix(world, stack, blockToSwap, metaToSwap, xc, yc, zc, targetBlock, targetMeta);
Boolean[][][] matrix = createMatrix(world, stack, swapState, pos, targetState);
int effrange = RANGE + ItemNBTHelper.getInt(stack, TAG_EXTRA_RANGE, 1);
int diameter = effrange * 2;
for(int i = 1; i < diameter; i++)
for(int j = 1; j < diameter; j++)
for(int k = 1; k < diameter; k++) {
int x = xc + i - effrange;
int y = yc + j - effrange;
int z = zc + k - effrange;
BlockPos pos_ = pos.add(i - effrange, j - effrange, k - effrange);
Boolean bool = matrix[i][j][k];
if(bool != null && !bool)
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Boolean obool = matrix[i + dir.offsetX][j + dir.offsetY][k + dir.offsetZ];
for(EnumFacing dir : EnumFacing.VALUES) {
Boolean obool = matrix[i + dir.getFrontOffsetX()][j + dir.getFrontOffsetY()][k + dir.getFrontOffsetZ()];
if(obool != null && obool) {
coordsList.add(new BlockPos(x, y, z));
coordsList.add(pos_);
break;
}
}
@@ -209,26 +200,26 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
return coordsList;
}
public boolean exchange(World world, EntityPlayer player, int x, int y, int z, ItemStack stack, Block blockToSet, int metaToSet) {
TileEntity tile = world.getTileEntity(x, y, z);
public boolean exchange(World world, EntityPlayer player, BlockPos pos, ItemStack stack, IBlockState state) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null)
return false;
ItemStack placeStack = removeFromInventory(player, stack, blockToSet, metaToSet, false);
ItemStack placeStack = removeFromInventory(player, stack, state.getBlock(), state.getBlock().getMetaFromState(state), false);
if(placeStack != null) {
Block blockAt = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if(!blockAt.isAir(world, x, y, z) && blockAt.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0 && (blockAt != blockToSet || meta != metaToSet)) {
IBlockState stateAt = world.getBlockState(pos);
Block blockAt = stateAt.getBlock();
if(!blockAt.isAir(world, pos) && blockAt.getPlayerRelativeBlockHardness(player, world, pos) > 0 && stateAt != state) {
if(!world.isRemote) {
if(!player.capabilities.isCreativeMode) {
List<ItemStack> drops = blockAt.getDrops(world, x, y, z, meta, 0);
List<ItemStack> drops = blockAt.getDrops(world, pos, stateAt, 0);
for(ItemStack drop : drops)
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop));
removeFromInventory(player, stack, blockToSet, metaToSet, true);
world.spawnEntityInWorld(new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, drop));
removeFromInventory(player, stack, state.getBlock(), state.getBlock().getMetaFromState(state), true);
}
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blockAt) + (meta << 12));
world.setBlock(x, y, z, blockToSet, metaToSet, 1 | 2);
blockToSet.onBlockPlacedBy(world, x, y, z, player, placeStack);
world.playAuxSFX(2001, pos, Block.getStateId(state));
world.setBlockState(pos, state, 1 | 2);
state.getBlock().onBlockPlacedBy(world, pos, state, player, placeStack);
}
displayRemainderCounter(player, stack);
return true;
@@ -332,7 +323,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
}
private boolean setBlock(ItemStack stack, Block block, int meta) {
ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.blockRegistry.getNameForObject(block));
ItemNBTHelper.setString(stack, TAG_BLOCK_NAME, Block.blockRegistry.getNameForObject(block).toString());
ItemNBTHelper.setInt(stack, TAG_BLOCK_META, meta);
return true;
}
@@ -358,7 +349,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
}
private boolean setTargetBlock(ItemStack stack, Block block, int meta) {
ItemNBTHelper.setString(stack, TAG_TARGET_BLOCK_NAME, Block.blockRegistry.getNameForObject(block));
ItemNBTHelper.setString(stack, TAG_TARGET_BLOCK_NAME, Block.blockRegistry.getNameForObject(block).toString());
ItemNBTHelper.setInt(stack, TAG_TARGET_BLOCK_META, meta);
return true;
}
@@ -388,23 +379,23 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver;
if(pos != null) {
int x = pos.blockX;
int y = pos.blockY;
int z = pos.blockZ;
BlockPos bPos = pos.getBlockPos();
Block targetBlock = null;
int targetMeta = 0;
if(ItemNBTHelper.getBoolean(stack, TAG_SWAPPING, false)) {
x = ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0);
y = ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0);
z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0);
bPos = new BlockPos(
ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0),
ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0),
ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0)
);
targetBlock = getTargetBlock(stack);
targetMeta = getTargetBlockMeta(stack);
}
if(!player.worldObj.isAirBlock(x, y, z)) {
List<BlockPos> coordsList = getBlocksToSwap(player.worldObj, stack, block, meta, x, y, z, targetBlock, targetMeta);
if(!player.worldObj.isAirBlock(bPos)) {
List<BlockPos> coordsList = getBlocksToSwap(player.worldObj, stack, block.getStateFromMeta(meta), bPos, targetBlock == null ? null : targetBlock.getStateFromMeta(targetMeta));
for(BlockPos coords : coordsList)
if(coords.posX == x && coords.posY == y && coords.posZ == z) {
if(coords.equals(bPos)) {
coordsList.remove(coords);
break;
}
@@ -14,6 +14,8 @@ import net.minecraft.entity.Entity;
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.util.ResourceLocation;
import net.minecraft.world.World;
import vazkii.botania.api.item.IAvatarTile;
@@ -40,10 +42,10 @@ public class ItemFireRod extends ItemMod implements IManaUsingItem, IAvatarWield
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int x, int y, int z, int par7, float par8, float par9, float par10) {
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
if(!par3World.isRemote && par1ItemStack.getItemDamage() == 0 && ManaItemHandler.requestManaExactForTool(par1ItemStack, player, COST, false)) {
EntityFlameRing entity = new EntityFlameRing(player.worldObj);
entity.setPosition(x + 0.5, y + 1, z + 0.5);
entity.setPosition(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5);
player.worldObj.spawnEntityInWorld(entity);
par1ItemStack.setItemDamage(COOLDOWN);
@@ -77,7 +79,7 @@ public class ItemFireRod extends ItemMod implements IManaUsingItem, IAvatarWield
if(!world.isRemote && tile.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 300 == 0 && tile.isEnabled()) {
EntityFlameRing entity = new EntityFlameRing(world);
entity.setPosition(te.xCoord + 0.5, te.yCoord, te.zCoord + 0.5);
entity.setPosition(te.getPos().getX() + 0.5, te.getPos().getY(), te.getPos().getZ() + 0.5);
world.spawnEntityInWorld(entity);
tile.recieveMana(-COST);
}
@@ -131,7 +131,7 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
EntityLivingBase targetEntity = (EntityLivingBase)item;
targetEntity.fallDistance = 0.0F;
if(targetEntity.getActivePotionEffect(Potion.moveSlowdown) == null)
targetEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 3, true));
targetEntity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 2, 3, true, true));
}
Vector3 target3 = Vector3.fromEntityCenter(player);
@@ -43,7 +43,7 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWi
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
return EnumAction.bow;
return EnumAction.BOW;
}
@Override
@@ -100,10 +100,10 @@ public class ItemMissileRod extends ItemMod implements IManaUsingItem, IAvatarWi
TileEntity te = (TileEntity) tile;
World world = te.getWorld();
if(tile.getCurrentMana() >= COST_AVATAR && tile.getElapsedFunctionalTicks() % 3 == 0 && tile.isEnabled())
if(spawnMissile(world, null, te.xCoord + 0.5 + (Math.random() - 0.5 * 0.1), te.yCoord + 2.5 + (Math.random() - 0.5 * 0.1), te.zCoord + (Math.random() - 0.5 * 0.1))) {
if(spawnMissile(world, null, te.getPos().getX() + 0.5 + (Math.random() - 0.5 * 0.1), te.getPos().getY() + 2.5 + (Math.random() - 0.5 * 0.1), te.getPos().getZ() + (Math.random() - 0.5 * 0.1))) {
if(!world.isRemote)
tile.recieveMana(-COST_AVATAR);
Botania.proxy.sparkleFX(world, te.xCoord + 0.5, te.yCoord + 2.5, te.zCoord + 0.5, 1F, 0.4F, 1F, 6F, 6);
Botania.proxy.sparkleFX(world, te.getPos().getX() + 0.5, te.getPos().getY() + 2.5, te.getPos().getZ() + 0.5, 1F, 0.4F, 1F, 6F, 6);
}
}
@@ -15,6 +15,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import vazkii.botania.api.mana.ManaItemHandler;
@@ -43,7 +45,7 @@ public class ItemSkyDirtRod extends ItemDirtRod {
if(entities == 0) {
ItemStack stackToPlace = new ItemStack(Blocks.dirt);
stackToPlace.tryPlaceItemIntoWorld(player, world, x, y, z, 0, 0F, 0F, 0F);
stackToPlace.onItemUse(player, world, new BlockPos(x, y, z), EnumFacing.DOWN, 0F, 0F, 0F);
if(stackToPlace.stackSize == 0) {
ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true);
@@ -44,7 +44,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
return EnumAction.bow;
return EnumAction.BOW;
}
@Override
@@ -70,7 +70,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
int meta = p.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
ItemStack blockStack = new ItemStack(block, 1, meta);
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(blockStack);
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(blockStack);
if(result != null && result.getItem() instanceof ItemBlock) {
boolean decremented = false;
@@ -139,7 +139,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
}
public boolean equalPos(MovingObjectPosition pos) {
return pos.blockX == this.pos.blockX && pos.blockY == this.pos.blockY && pos.blockZ == this.pos.blockZ;
return pos.getBlockPos().equals(this.pos.getBlockPos());
}
}
}
@@ -3,8 +3,9 @@ package vazkii.botania.common.item.rod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.Botania;
@@ -22,17 +23,16 @@ public class ItemWaterRod extends ItemMod implements IManaUsingItem {
}
@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(ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, false) && !par3World.provider.isHellWorld) {
ForgeDirection dir = ForgeDirection.getOrientation(par7);
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
if(ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, false) && !par3World.provider.doesWaterVaporize()) {
ItemStack stackToPlace = new ItemStack(Blocks.flowing_water);
stackToPlace.tryPlaceItemIntoWorld(par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
stackToPlace.onItemUse(par2EntityPlayer, par3World, pos, side, par8, par9, par10);
if(stackToPlace.stackSize == 0) {
ManaItemHandler.requestManaExactForTool(par1ItemStack, par2EntityPlayer, COST, true);
for(int i = 0; i < 6; i++)
Botania.proxy.sparkleFX(par3World, par4 + dir.offsetX + Math.random(), par5 + dir.offsetY + Math.random(), par6 + dir.offsetZ + Math.random(), 0.2F, 0.2F, 1F, 1F, 5);
Botania.proxy.sparkleFX(par3World, pos.getX() + side.getFrontOffsetX() + Math.random(), pos.getY() + side.getFrontOffsetY() + Math.random(), pos.getZ() + side.getFrontOffsetZ() + Math.random(), 0.2F, 0.2F, 1F, 1F, 5);
}
}
return true;