Java Code Examples for net.minecraft.util.math.MathHelper#floor()

The following examples show how to use net.minecraft.util.math.MathHelper#floor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityChristmasCow.java    From Moo-Fluids with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onLivingUpdate() {
  super.onLivingUpdate();

  for (int side = 0; side < 4; ++side) {
    int x = MathHelper.floor(posX + (double) ((float) (side % 2 * 2 - 1) * 0.25F));
    int y = MathHelper.floor(posY);
    int z = MathHelper.floor(posZ + (double) ((float) (side / 2 % 2 * 2 - 1) * 0.25F));

    BlockPos pos = new BlockPos(x, y, z);

    if (world.getBlockState(pos).getBlock() == Blocks.AIR
        && world.getBiome(pos).getTemperature(pos) < 2F
        && Blocks.SNOW_LAYER.canPlaceBlockAt(world, pos)) {
      double randX = (double) ((float) posX + rand.nextFloat());
      double randY = (double) ((float) posY + rand.nextFloat());
      double randZ = (double) ((float) posZ + rand.nextFloat());

      world.spawnParticle(EnumParticleTypes.SNOWBALL, randX, randY, randZ, 0.0D, 0.0D, 0.0D);

      world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState());
    }
  }
}
 
Example 2
Source File: PotionPhase.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Nullable
public BlockPos getBottomBlock(@Nonnull Entity entity) {
	boolean isSpectator = (entity instanceof EntityPlayer && ((EntityPlayer) entity).isSpectator());
	if (isSpectator) return null;
	AxisAlignedBB bb = entity.getEntityBoundingBox();
	int mX = MathHelper.floor(bb.minX);
	int mY = MathHelper.floor(bb.minY);
	int mZ = MathHelper.floor(bb.minZ);
	for (int y2 = mY; y2 < bb.maxY; y2++) {
		for (int x2 = mX; x2 < bb.maxX; x2++) {
			for (int z2 = mZ; z2 < bb.maxZ; z2++) {
				BlockPos tmp = new BlockPos(x2, y2, z2);
				if (!entity.world.isAirBlock(tmp)) return tmp;
			}
		}
	}

	return null;
}
 
Example 3
Source File: TeleporterPaths.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean makePortal(Entity entityIn)
{
	if(entityIn.world.isRemote)
		return true;
	int playerX = MathHelper.floor(entityIn.posX);
	int playerZ = MathHelper.floor(entityIn.posZ);
	IslandMap islandMap = WorldGen.getInstance().getIslandMap(((playerX*8) >> 12), ((playerZ*8) >> 12));
	Center closest = islandMap.getClosestCenter(new Point((playerX*8) % 4096,(playerZ*8) % 4096));
	//Sometimes due to the world scaling, we might find the closest center is actually a neighbor of the portal hex
	closest = this.getPortalNeighbor(closest);
	BlockPos portalPos = new BlockPos(entityIn).down();

	if(closest != null)
	{
		PortalAttribute attr = (PortalAttribute) closest.getAttribute(Attribute.Portal);
		WorldGenPortalsHex.BuildPortalSchem(worldServerInstance, closest, portalPos, islandMap, true);
	}
	else return false;

	return true;
}
 
Example 4
Source File: ItemEnderTool.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean useHoeArea(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, int rWidth, int rHeight)
{
    boolean northSouth = (((int)MathHelper.floor(player.rotationYaw * 4.0f / 360.0f + 0.5f)) & 1) == 0;
    boolean retValue = false;

    if (northSouth == false)
    {
        int tmp = rWidth;
        rWidth = rHeight;
        rHeight = tmp;
    }

    for (int x = pos.getX() - rWidth; x <= (pos.getX() + rWidth); ++x)
    {
        for (int z = pos.getZ() - rHeight; z <= (pos.getZ() + rHeight); ++z)
        {
            retValue |= this.useHoe(stack, player, world, new BlockPos(x, pos.getY(), z), side);
        }
    }

    return retValue;
}
 
Example 5
Source File: ItemStackTocPage.java    From OpenModsLib with MIT License 6 votes vote down vote up
public ItemStackTocPage(int rows, int columns, float iconScale) {
	this.capacity = rows * columns;

	this.iconScale = iconScale;
	this.iconSize = MathHelper.floor(16 * iconScale);

	this.columns = columns;

	int requiredWidth = iconSize * columns;
	int requiredHeight = iconSize * rows;

	int leftoverWidth = getWidth() - requiredWidth;
	int leftoverHeight = getHeight() - requiredHeight;

	this.spacerWidth = leftoverWidth / (columns - 1);
	this.spacerHeight = leftoverHeight / (rows - 1);
}
 
Example 6
Source File: EntityUtils.java    From ForgeHax with MIT License 6 votes vote down vote up
public static boolean isInWater(Entity entity) {
  if (entity == null) {
    return false;
  }
  
  double y = entity.posY + 0.01;
  
  for (int x = MathHelper.floor(entity.posX); x < MathHelper.ceil(entity.posX); x++) {
    for (int z = MathHelper.floor(entity.posZ); z < MathHelper.ceil(entity.posZ); z++) {
      BlockPos pos = new BlockPos(x, (int) y, z);
      
      if (getWorld().getBlockState(pos).getBlock() instanceof BlockLiquid) {
        return true;
      }
    }
  }
  
  return false;
}
 
Example 7
Source File: MetaTileEntityTank.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public int getActualComparatorValue() {
    IFluidTankProperties properties = getTankProperties();
    if (properties == null) {
        return 0;
    }
    FluidStack fluidStack = properties.getContents();
    int fluidAmount = fluidStack == null ? 0 : fluidStack.amount;
    int maxCapacity = properties.getCapacity();
    float f = fluidAmount / (maxCapacity * 1.0f);
    return MathHelper.floor(f * 14.0f) + (fluidAmount > 0 ? 1 : 0);
}
 
Example 8
Source File: ClientStateMachine.java    From malmo with MIT License 5 votes vote down vote up
private boolean isChunkReady()
{
    // First, find the starting position we ought to have:
    List<AgentSection> agents = currentMissionInit().getMission().getAgentSection();
    if (agents == null || agents.size() <= currentMissionInit().getClientRole())
        return true;    // This should never happen.
    AgentSection as = agents.get(currentMissionInit().getClientRole());
    if (as.getAgentStart() != null && as.getAgentStart().getPlacement() != null)
    {
        PosAndDirection pos = as.getAgentStart().getPlacement();
        int x = MathHelper.floor(pos.getX().doubleValue()) >> 4;
        int z = MathHelper.floor(pos.getZ().doubleValue()) >> 4;
        // Now get the chunk we should be starting in:
        IChunkProvider chunkprov = Minecraft.getMinecraft().world.getChunkProvider();
        EntityPlayerSP player = Minecraft.getMinecraft().player;
        if (player.addedToChunk)
        {
            // Our player is already added to a chunk - is it the right one?
            Chunk actualChunk = chunkprov.provideChunk(player.chunkCoordX, player.chunkCoordZ);
            Chunk requestedChunk = chunkprov.provideChunk(x,  z);
            if (actualChunk == requestedChunk && actualChunk != null && !actualChunk.isEmpty())
            {
                // We're in the right chunk, and it's not an empty chunk.
                // We're ready to proceed, but first set our client positions to where we ought to be.
                // The server should be doing this too, but there's no harm (probably) in doing it ourselves.
                player.posX = pos.getX().doubleValue();
                player.posY = pos.getY().doubleValue();
                player.posZ = pos.getZ().doubleValue();
                return true;
            }
        }
        return false;   // Our starting position has been specified, but it's not yet ready.
    }
    return true;    // No starting position specified, so doesn't matter where we start.
}
 
Example 9
Source File: MixinEntity.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Redirect(method = "createRunningParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;floor(D)I", ordinal = 0))
    public int runningParticlesFirstFloor(double d) {
        PhysicsWrapperEntity worldBelow = thisAsDraggable.getWorldBelowFeet();

        if (worldBelow == null) {
            searchVector = null;
            return MathHelper.floor(d);
        } else {
            searchVector = new Vector(this.posX, this.posY - 0.20000000298023224D, this.posZ);
//            searchVector.transform(worldBelow.wrapping.coordTransform.wToLTransform);
            worldBelow.getPhysicsObject().getShipTransformationManager().getCurrentTickTransform()
                .transform(searchVector, TransformType.GLOBAL_TO_SUBSPACE);
            return MathHelper.floor(searchVector.X);
        }
    }
 
Example 10
Source File: MixinEntity.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Redirect(method = "createRunningParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;floor(D)I", ordinal = 1))
public int runningParticlesSecondFloor(double d) {
    if (searchVector == null) {
        return MathHelper.floor(d);
    } else {
        return MathHelper.floor(searchVector.Y);
    }
}
 
Example 11
Source File: SlotItemHandlerFurnaceOutput.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void onCrafting(ItemStack stack)
{
    stack.onCrafting(this.player.getEntityWorld(), this.player, this.amountCrafted);

    if (this.player.getEntityWorld().isRemote == false)
    {
        int i = this.amountCrafted;
        float f = FurnaceRecipes.instance().getSmeltingExperience(stack);

        if (f == 0.0F)
        {
            i = 0;
        }
        else if (f < 1.0F)
        {
            int j = MathHelper.floor((float)i * f);

            if (j < MathHelper.ceil((float)i * f) && Math.random() < (double)((float)i * f - (float)j))
            {
                ++j;
            }

            i = j;
        }

        while (i > 0)
        {
            int k = EntityXPOrb.getXPSplit(i);
            i -= k;
            this.player.getEntityWorld().spawnEntity(new EntityXPOrb(this.player.getEntityWorld(), this.player.posX, this.player.posY + 0.5D, this.player.posZ + 0.5D, k));
        }
    }

    this.amountCrafted = 0;
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerSmeltedEvent(player, stack);
}
 
Example 12
Source File: EntityAIFollowPlayer.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Keep ticking a continuous task that has already been started
 */
@SuppressWarnings("deprecation")
@Override
public void updateTask() {
	if (this.owner == null) return;
	this.entity.getLookHelper().setLookPositionWithEntity(this.owner, 10.0F, (float) this.entity.getVerticalFaceSpeed());

	if (--this.timeToRecalcPath <= 0) {
		this.timeToRecalcPath = 10;

		if (!this.petPathfinder.tryMoveToEntityLiving(this.owner, this.followSpeed)) {
			if (!this.entity.getLeashed()) {
				if (this.entity.getDistance(this.owner) >= 12.0D) {
					int i = MathHelper.floor(this.owner.posX) - 2;
					int j = MathHelper.floor(this.owner.posZ) - 2;
					int k = MathHelper.floor(this.owner.getEntityBoundingBox().minY);

					for (int l = 0; l <= 4; ++l) {
						for (int i1 = 0; i1 <= 4; ++i1) {
							if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && this.world.getBlockState(new BlockPos(i + l, k - 1, j + i1)).isTopSolid() && this.isEmptyBlock(new BlockPos(i + l, k, j + i1)) && this.isEmptyBlock(new BlockPos(i + l, k + 1, j + i1))) {
								this.entity.setLocationAndAngles((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.entity.rotationYaw, this.entity.rotationPitch);
								this.petPathfinder.clearPath();
								return;
							}
						}
					}
				}
			}
		}
	}
}
 
Example 13
Source File: GuiComponentItemStack.java    From OpenModsLib with MIT License 5 votes vote down vote up
public GuiComponentItemStack(int x, int y, @Nonnull ItemStack stack, boolean drawTooltip, float scale) {
	super(x, y);
	this.stack = stack;
	this.drawTooltip = drawTooltip;
	this.scale = scale;

	this.size = MathHelper.floor(16 * scale);
	this.displayName = ImmutableList.of(stack.getDisplayName());
}
 
Example 14
Source File: TeleportHelper.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public static boolean teleportTo(EntityLivingBase entity, double x, double y, double z, boolean fireEndermanEvent) {

    EnderTeleportEvent event = new EnderTeleportEvent(entity, x, y, z, 0);
    if (fireEndermanEvent) {
      if (MinecraftForge.EVENT_BUS.post(event)) {
        return false;
      }
    }

    double origX = entity.posX;
    double origY = entity.posY;
    double origZ = entity.posZ;
    entity.posX = event.getTargetX();
    entity.posY = event.getTargetY();
    entity.posZ = event.getTargetZ();

    int xInt = MathHelper.floor(entity.posX);
    int yInt = Math.max(2, MathHelper.floor(entity.posY));
    int zInt = MathHelper.floor(entity.posZ);

    boolean doTeleport = false;
    World worldObj = entity.getEntityWorld();
    if (worldObj.isBlockLoaded(new BlockPos(xInt, yInt, zInt), true)) {
      boolean foundGround = false;
      while (!foundGround && yInt > 2) {
        IBlockState bs = worldObj.getBlockState(new BlockPos(xInt, yInt - 1, zInt));
        if (bs != null && bs.getBlock() != null && bs.getMaterial().blocksMovement()) {
          foundGround = true;
        } else {
          --entity.posY;
          --yInt;
        }
      }

      if (foundGround) {
        entity.setPosition(entity.posX, entity.posY, entity.posZ);
        if (worldObj.getCollisionBoxes(entity, entity.getEntityBoundingBox()).isEmpty()
            && !worldObj.containsAnyLiquid(entity.getEntityBoundingBox())) {
          doTeleport = true;
        } else if (yInt <= 0) {
          doTeleport = false;
        }
      }
    }

    if (!doTeleport) {
      entity.setPosition(origX, origY, origZ);
      return false;
    }

    entity.setPositionAndUpdate(entity.posX, entity.posY, entity.posZ);

    short short1 = 128;
    for (int l = 0; l < short1; ++l) {
      double d6 = l / (short1 - 1.0D);
      float f = (rand.nextFloat() - 0.5F) * 0.2F;
      float f1 = (rand.nextFloat() - 0.5F) * 0.2F;
      float f2 = (rand.nextFloat() - 0.5F) * 0.2F;
      double d7 = origX + (entity.posX - origX) * d6 + (rand.nextDouble() - 0.5D) * entity.width * 2.0D;
      double d8 = origY + (entity.posY - origY) * d6 + rand.nextDouble() * entity.height;
      double d9 = origZ + (entity.posZ - origZ) * d6 + (rand.nextDouble() - 0.5D) * entity.width * 2.0D;
      worldObj.spawnParticle(EnumParticleTypes.PORTAL, d7, d8, d9, f, f1, f2);
    }

    worldObj.playSound(origX, origY, origZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.NEUTRAL, 1.0F, 1.0F, false);
    entity.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
    return true;

  }
 
Example 15
Source File: MixinRecipeGridAligner.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * @author qouteall
 * @reason https://github.com/FabricMC/Mixin/issues/15
 */
@Overwrite
default void alignRecipeToGrid(
		int gridWidth, int gridHeight, int gridOutputSlot,
		Recipe<?> recipe, Iterator<?> inputs, int amount
) {
	int width = gridWidth;
	int height = gridHeight;

	// change start
	if (recipe instanceof IShapedRecipe) {
		IShapedRecipe<?> shapedRecipe = (IShapedRecipe<?>) recipe;
		width = shapedRecipe.getRecipeWidth();
		height = shapedRecipe.getRecipeHeight();
	}

	// change end

	int slot = 0;

	for (int y = 0; y < gridHeight; ++y) {
		if (slot == gridOutputSlot) {
			++slot;
		}

		boolean bl = (float) height < (float) gridHeight / 2.0F;

		int m = MathHelper.floor((float) gridHeight / 2.0F - (float) height / 2.0F);

		if (bl && m > y) {
			slot += gridWidth;
			++y;
		}

		for (int x = 0; x < gridWidth; ++x) {
			if (!inputs.hasNext()) {
				return;
			}

			bl = (float) width < (float) gridWidth / 2.0F;
			m = MathHelper.floor((float) gridWidth / 2.0F - (float) width / 2.0F);
			int o = width;

			boolean bl2 = x < width;

			if (bl) {
				o = m + width;
				bl2 = m <= x && x < m + width;
			}

			if (bl2) {
				this.acceptAlignedInput(inputs, slot, amount, y, x);
			} else if (o == x) {
				slot += gridWidth - x;
				break;
			}

			++slot;
		}
	}
}
 
Example 16
Source File: MBlockPos.java    From LunatriusCore with MIT License 4 votes vote down vote up
public MBlockPos(final double x, final double y, final double z) {
    this(MathHelper.floor(x), MathHelper.floor(y), MathHelper.floor(z));
}
 
Example 17
Source File: ShipCollisionTask.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
private void processNumber(int integer) {
        SpatialDetector.setPosWithRespectTo(integer, toTask.getCenterPotentialHit(), mutablePos);
        inWorldState = toTask.getParent().getCachedSurroundingChunks().getBlockState(mutablePos);

        inWorld.X = mutablePos.getX() + .5;
        inWorld.Y = mutablePos.getY() + .5;
        inWorld.Z = mutablePos.getZ() + .5;

//        toTask.getParent().coordTransform.fromGlobalToLocal(inWorld);
        toTask.getParent().getShipTransformationManager().getCurrentPhysicsTransform()
            .transform(inWorld, TransformType.GLOBAL_TO_SUBSPACE);

        int midX = MathHelper.floor(inWorld.X + .5D);
        int midY = MathHelper.floor(inWorld.Y + .5D);
        int midZ = MathHelper.floor(inWorld.Z + .5D);

        // Check the 27 possible positions
        checkPosition(midX - 1, midY - 1, midZ - 1, integer);
        checkPosition(midX - 1, midY - 1, midZ, integer);
        checkPosition(midX - 1, midY - 1, midZ + 1, integer);
        checkPosition(midX - 1, midY, midZ - 1, integer);
        checkPosition(midX - 1, midY, midZ, integer);
        checkPosition(midX - 1, midY, midZ + 1, integer);
        checkPosition(midX - 1, midY + 1, midZ - 1, integer);
        checkPosition(midX - 1, midY + 1, midZ, integer);
        checkPosition(midX - 1, midY + 1, midZ + 1, integer);

        checkPosition(midX, midY - 1, midZ - 1, integer);
        checkPosition(midX, midY - 1, midZ, integer);
        checkPosition(midX, midY - 1, midZ + 1, integer);
        checkPosition(midX, midY, midZ - 1, integer);
        checkPosition(midX, midY, midZ, integer);
        checkPosition(midX, midY, midZ + 1, integer);
        checkPosition(midX, midY + 1, midZ - 1, integer);
        checkPosition(midX, midY + 1, midZ, integer);
        checkPosition(midX, midY + 1, midZ + 1, integer);

        checkPosition(midX + 1, midY - 1, midZ - 1, integer);
        checkPosition(midX + 1, midY - 1, midZ, integer);
        checkPosition(midX + 1, midY - 1, midZ + 1, integer);
        checkPosition(midX + 1, midY, midZ - 1, integer);
        checkPosition(midX + 1, midY, midZ, integer);
        checkPosition(midX + 1, midY, midZ + 1, integer);
        checkPosition(midX + 1, midY + 1, midZ - 1, integer);
        checkPosition(midX + 1, midY + 1, midZ, integer);
        checkPosition(midX + 1, midY + 1, midZ + 1, integer);

    }
 
Example 18
Source File: EntityEnderminy.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
protected boolean teleportTo(double x, double y, double z) {

    EnderTeleportEvent event = new EnderTeleportEvent(this, x, y, z, 0);
    if(MinecraftForge.EVENT_BUS.post(event)) {
      return false;
    }
    double d3 = posX;
    double d4 = posY;
    double d5 = posZ;
    posX = event.getTargetX();
    posY = event.getTargetY();
    posZ = event.getTargetZ();

    int xInt = MathHelper.floor(posX);
    int yInt = MathHelper.floor(posY);
    int zInt = MathHelper.floor(posZ);

    boolean flag = false;
    if(world.isBlockLoaded(new BlockPos(xInt, yInt, zInt))) {

      boolean foundGround = false;
      while (!foundGround && yInt > 0) {
        IBlockState bs = world.getBlockState(new BlockPos(xInt, yInt - 1, zInt));
        if(bs.getMaterial().blocksMovement()) {
          foundGround = true;
        } else {
          --posY;
          --yInt;
        }
      }

      if(foundGround) {
        setPosition(posX, posY, posZ);
        if(world.getCollisionBoxes(this, getEntityBoundingBox()).isEmpty() && !world.containsAnyLiquid(getEntityBoundingBox())) {
          flag = true;
        }
      }
    }

    if(!flag) {
      setPosition(d3, d4, d5);
      return false;
    }

    short short1 = 128;
    for (int l = 0; l < short1; ++l) {
      double d6 = l / (short1 - 1.0D);
      float f = (rand.nextFloat() - 0.5F) * 0.2F;
      float f1 = (rand.nextFloat() - 0.5F) * 0.2F;
      float f2 = (rand.nextFloat() - 0.5F) * 0.2F;
      double d7 = d3 + (posX - d3) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D;
      double d8 = d4 + (posY - d4) * d6 + rand.nextDouble() * height;
      double d9 = d5 + (posZ - d5) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D;
      world.spawnParticle(EnumParticleTypes.PORTAL, d7, d8, d9, f, f1, f2);
    }

    world.playSound(d3, d4, d5, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.NEUTRAL, 1.0F, 1.0F, false);    
    playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
    return true;

  }
 
Example 19
Source File: Coord.java    From OpenModsLib with MIT License 4 votes vote down vote up
public Coord(double x, double y, double z) {
	this.x = MathHelper.floor(x);
	this.y = MathHelper.floor(y);
	this.z = MathHelper.floor(z);
}
 
Example 20
Source File: SlotSaltFurnace.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
 */
@Override
protected void onCrafting(ItemStack par1ItemStack)
{
    par1ItemStack.onCrafting(this.thePlayer.world, this.thePlayer, this.field_75228_b);

    if (!this.thePlayer.world.isRemote)
    {
        int i = this.field_75228_b;
        float f = par1ItemStack.getItem() == ItemLoader.material ? 0.2f : par1ItemStack.getItem() == ItemLoader.nigari ? 0.3f : 0.0f;
        int j;

        if (f == 0.0F)
        {
            i = 0;
        }
        else if (f < 1.0F)
        {
            j = MathHelper.floor(i * f);

            if (j < MathHelper.ceil(i * f) && (float)Math.random() < i * f - j)
            {
                ++j;
            }

            i = j;
        }

        while (i > 0)
        {
            j = EntityXPOrb.getXPSplit(i);
            i -= j;
            this.thePlayer.world.spawnEntity(new EntityXPOrb(this.thePlayer.world, this.thePlayer.posX, this.thePlayer.posY + 0.5D, this.thePlayer.posZ + 0.5D, j));
        }
    }

    this.field_75228_b = 0;


    if (par1ItemStack.getItem() == ItemLoader.material)
    {
        TofuAdvancements.grantAdvancement(this.thePlayer, "getsalt");
    }
    else if (par1ItemStack.getItem() == ItemLoader.nigari)
    {
        TofuAdvancements.grantAdvancement(this.thePlayer, "getnigari");
    }
}