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

@@ -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);
}
}