Jump to content

Recommended Posts

Posted

So, I just need to get the XP set for a blocks furnace recipe but, through the code below, it always seems to return 0.0F. Any ideas of what I am doing wrong?

 

float xpToDrop = FurnaceRecipes.smelting().func_151398_b(new ItemStack(block, 1, blockMeta));
            	
LogHelper.logInfo("XP: " + xpToDrop);

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

The code should work. What was the block?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

I was testing it with gold ore and, it drops the ingot just fine. But the XP for any block with a smelting recipe seems to return 0.0F :/

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

I was testing it with gold ore and, it drops the ingot just fine. But the XP for any block with a smelting recipe seems to return 0.0F :/

So console prints "XP: 0.0"? I think it is impossible.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

I was testing it with gold ore and, it drops the ingot just fine. But the XP for any block with a smelting recipe seems to return 0.0F :/

So console prints "XP: 0.0"? I think it is impossible.

 

Yes, it does. Honestly, I have no clue why considering it SHOULD get the XP value just fine. Maybe I have to register my item in my postInit so it is registered after the crafting? Registering order has been a problem with some things I do.

 

@saxon564

Here is all the methods it uses from my Item class. It gets the block from the onBlockDestroyed method then, depending on the miningSize, checks the blocks around it. NOTE: No blocks drop the XP so it has nothing to do with how I break the extra blocks.

public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) {
	fixNBT(stack);

	EntityPlayer player = (EntityPlayer)entity;

	if(world != null && player != null) {
		LogHelper.logInfo("WORLD WAS NOT NULL NOR WAS PLAYER");

		MovingObjectPosition mop = EntityHelper.raytraceFromEntity(world, player, true, 5.0D);

		int sideHit = mop.sideHit;

		if(player.inventory.getCurrentItem() != null) {
			if(player.inventory.getCurrentItem().getItem().equals(CrewMod.crewHammer)) {
				int direction = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

				String miningArea = null;

				if(stack.hasTagCompound()) {
					miningArea = stack.getTagCompound().getString("MiningSize");
				}

				LogHelper.logInfo(miningArea);

				this.breakBlock(world, player, stack, x, y, z, direction, miningArea, sideHit);
			}else {
				super.onBlockDestroyed(stack, world, block, x, y, z, entity);
			}
		}else {
			super.onBlockDestroyed(stack, world, block, x, y, z, entity);
		}
	}

	return true;
}

/**
 * Used for breaking an area of blocks depending on the miningSize.
 * 
 * @param world Instance of the Minecraft world.
 * @param player Player breaking the block.
 * @param stack Stack in the player's hand.
 * @param x X coordinate of the block to be broken.
 * @param y	Y coordinate of the block to be broken.
 * @param z	Z coordinate of the block to be broken.
 * @param playerFacing The direction the player is facing: NORTH, SOUTH, EAST or, WEST.
 * @param miningArea The area of blocks to be destroyed: 1x1 = 0, 3x3 = 1, 5x5 = 2, 7x7 = 3.
 */
public void breakBlock(World world, EntityPlayer player, ItemStack stack, int x, int y, int z, int playerFacing, String miningArea, int sideHit) { //TODO Address Shift-Clicking error with onCrafted.
	System.out.println("BREAK BLOCK RUN");

	Block block = world.getBlock(x, y, z);
	int meta = world.getBlockMetadata(x, y, z);

	LogHelper.logInfo("[CrewHammer] Side Hit: " + sideHit);

	int refX = x;
	int refY = y;
	int refZ = z;

	if(!isEffective(block, meta, stack))
		return;

	int miningSize = 0;

	if(miningArea != null) {
		if(miningArea.equals("3x3"))
			miningSize = 1;
		else if(miningArea == "5x5")
			miningSize = 2;
		else if(miningArea == "7x7")
			miningSize = 3;
		else
			miningSize = 0;
	}else {
		LogHelper.logErr("[CrewHammer] The Mining Area was null!");
	}

	if(playerFacing == 0 || playerFacing == 2) {
		if(miningSize == 0) {
			return;
		}else if(miningSize == 1) {
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
		}else if(miningSize == 2) {
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
		}else {
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 3, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 3, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 3, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 3, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x - 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 3, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 3, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 3, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 3, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 3, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 3, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x - 1, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 3, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 3, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x - 1, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 1, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 2, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 2, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x - 3, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x + 3, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
		}
	}else {
		if(miningSize == 0) {
			return;
		}else if(miningSize == 1) {
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z - 1, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z + 1, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
		}else if(miningSize == 2) {
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 2, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 2, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 2, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 2, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z - 1, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z + 1, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z - 2, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z + 2, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z - 2, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z + 2, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z - 2, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z + 2, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
		}else {
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 2, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 2, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z - 3, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 1, z + 3, true, refX, refY, refZ, sideHit, 1, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 2, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 2, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z - 3, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 1, z + 3, true, refX, refY, refZ, sideHit, 2, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x, y, z - 1, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z + 1, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z - 2, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z + 2, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z - 3, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z + 3, true, refX, refY, refZ, sideHit, 0, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y, z, true, refX, refY, refZ, sideHit, 0, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z - 2, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z + 2, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z - 3, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z + 3, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 2, z, true, refX, refY, refZ, sideHit, 1, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z - 2, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z + 2, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z - 3, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z + 3, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 2, z, true, refX, refY, refZ, sideHit, 2, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z - 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z + 1, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z - 2, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z + 2, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z - 3, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z + 3, true, refX, refY, refZ, sideHit, 1, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y + 3, z, true, refX, refY, refZ, sideHit, 1, playerFacing);

			this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z - 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z + 1, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z - 2, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z + 2, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z - 3, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z + 3, true, refX, refY, refZ, sideHit, 2, playerFacing);
			this.destroyBlockIfAllowed(world, stack, player, x, y - 3, z, true, refX, refY, refZ, sideHit, 2, playerFacing);
		}
	}
}

/**
 * Destroys a block at the given coords if allowed.
 * 
 * @param world The instance of the World.
 * @param player The player destroying said block.
 * @param x X Coordinate of the block to be destroyed.
 * @param y Y Coordinate of the block to be destroyed.
 * @param z Z Coordinate of the block to be destroyed.
 * @param addDrops If true, adds drops to the block broken.
 * @param refX Reference point X of the center block if destroying multiple ones.
 * @param refY Reference point Y of the center block if destroying multiple ones.
 * @param refZ Reference point Z of the center block if destroying multiple ones.
 * @param Ymodifer Used to determine if the Y variable is added to or, subtracted from. 0 = Nothing, 1 = Added to, 2 = Subtracted from.
 * @param playerDirection The direction the player is facing: NORTH, SOUTH, EAST or, WEST.
 */
public void destroyBlockIfAllowed(World world, ItemStack stack, EntityPlayer player, int x, int y, int z, boolean addDrops, int refX, int refY, int refZ, int sideHit, int Ymodifer, int playerDirection) {
	int actualX = x;
	int actualY = y;
	int actualZ = z;

	if(sideHit == 0 || sideHit == 1) {
		//System.out.println("Z updated");

		actualY = refY;

		int amountToAdd = refY > y ? refY - y : y - refY;

		if(playerDirection == 0 || playerDirection == 2) {
			if(Ymodifer == 0)
				actualZ += 0;
			else if(Ymodifer == 1)
				actualZ += amountToAdd;
			else
				actualZ -= amountToAdd;
		}else {
			if(Ymodifer == 0)
				actualX += 0;
			else if(Ymodifer == 1)
				actualX += amountToAdd;
			else
				actualX -= amountToAdd;
		}

		/*System.out.println("Z: " + actualZ);
		System.out.println(additionZ);
		System.out.println("Y: " + y);
		System.out.println("refY: " + refY);*/
	}

	if(world.isAirBlock(actualX, actualY, actualZ))
		return;

	Block block = world.getBlock(actualX, actualY, actualZ);
	int meta = world.getBlockMetadata(actualX, actualY, actualZ);

	if(!isEffective(block, meta, stack))
		return;

	Block refBlock = world.getBlock(refX, refY, refZ);
        
        float refStrength = refBlock.getBlockHardness(world, refX, refY, refZ);
        float strength = block.getBlockHardness(world, actualX, actualY, actualZ);
        
        float strDifference = strength/refStrength;
        
        System.out.println(strDifference);

	if(!ForgeHooks.canHarvestBlock(block, player, meta) || strength <= -1 || strDifference > 10)
		return;

	EntityPlayerMP playerEntity = (EntityPlayerMP)player;

	if(block.getExpDrop(world, meta, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack)) > 0 && !stack.stackTagCompound.getBoolean("AutoSmelt"))
		block.dropXpOnBlockBreak(world, actualX, actualY, actualZ, block.getExpDrop(world, meta, 0));


	if(stack.stackTagCompound.getBoolean("AutoSmelt") == true) {
		ArrayList<ItemStack> drops = getFurnaceDrops(world, actualX, actualY, actualZ, 0, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack), 1, block, meta, player);

		LogHelper.logInfo("Drops: " + drops);

		for(ItemStack item : drops) {
			dropCustomItems(world, actualX, actualY, actualZ, item);
		}
	}

	world.func_147480_a(actualX, actualY, actualZ, stack.stackTagCompound.getBoolean("AutoSmelt") ? false : addDrops);

	if(!player.capabilities.isCreativeMode)
		stack.attemptDamageItem(1, world.rand);
}

public boolean isEffective(Block block, int meta, ItemStack stack) {
	if(ForgeHooks.canToolHarvestBlock(block, meta, stack))
		return true;

	return false;		
}

/**
     * Spawns EntityItem in the world for the given ItemStack if the world is not remote.
     */
    protected void dropCustomItems(World world, int x, int y, int z, ItemStack stack) {
        if (!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops") && !world.restoringBlockSnapshots) { // do not drop items while restoring blockstates, prevents item dupe
            float f = 0.7F;
            
            double d0 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
            double d1 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
            double d2 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
            
            EntityItem entityitem = new EntityItem(world, (double)x + d0, (double)y + d1, (double)z + d2, stack);
            
            entityitem.delayBeforeCanPickup = 10;
            
            world.spawnEntityInWorld(entityitem);
        }
    }
    
    /**
     * This returns a complete list of items dropped from this block.
     *
     * @param world The current world
     * @param x X Position
     * @param y Y Position
     * @param z Z Position
     * @param metadata Current metadata
     * @param fortune Breakers fortune level
     * @return A ArrayList containing all items this block drops
     */
    public ArrayList<ItemStack> getFurnaceDrops(World world, int x, int y, int z, int meta, int fortune, int quantity, Block block, int blockMeta, EntityPlayer player) {
        ArrayList<ItemStack> ret = new ArrayList<ItemStack>();

        int count = quantity;
        
        for(int i = 0; i < count; i++) {
            if(FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block, 1, blockMeta)) != null) {
            	
            	int itemMeta = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block, 1, blockMeta)).getItemDamage();
            	
            	float xpToDrop = FurnaceRecipes.smelting().func_151398_b(new ItemStack(block, 1, blockMeta));
            	
            	LogHelper.logInfo("XP: " + xpToDrop);
            
            Item item = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block, 1, blockMeta)).getItem();
            
            LogHelper.logInfo("Item Meta: " + itemMeta);
            
            if (item != null) {
                ret.add(new ItemStack(item, 1, itemMeta));
            }
            }else {
            	if(block.canSilkHarvest(world, player, x, y, z, meta))
            		ret.add(new ItemStack(block, 1, meta));
            	else
            		ret.add(new ItemStack(block.getItemDropped(blockMeta, world.rand, fortune)));
            }
        }
        
        return ret;
    }

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

try taking the ItemStack and adding .getItem().getSmeltingExperience(Your ItemStack) ane see what that returns, in the method you are calling it is using that to get the experience to return, but it doesnt seem like it is getting the right values. So try it that way and see what you get.

Posted

This is what I did:

float xpToDrop = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block, 1, blockMeta)).getItem().getSmeltingExperience(FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block, 1, blockMeta)));

 

This was the result in the console:

[21:50:24] [server thread/INFO] [Crew Mod]: XP: -1.0

 

That's the default for that method. ^

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Still returning -1 :/ It says that it is used to get the smelting experience of an item when it is pulled out (as a smelting result) yet, no items seem to use it (like gold ingots etc.)

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

That's really strange. Try printing the block's name, to make sure that it is gold ore.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

The block is oreBlock and the metadata makes it goldOre. :P I also printed the ItemStack I was using and got the same result.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

I think I fixed it. xD I changed my code a bit to make it neater and copied the smelting result. Here's it finished:

public ArrayList<ItemStack> getFurnaceDrops(World world, int x, int y, int z, int meta, int fortune, int quantity, Block block, int blockMeta, EntityPlayer player) {
        ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
        ArrayList<ItemStack> originalDrops = block.getDrops(world, x, y, z, blockMeta, fortune);

        int count = quantity;
        
        for(int i = 0; i < count; i++) {
        	for(ItemStack stack : originalDrops) {
            if(FurnaceRecipes.smelting().getSmeltingResult(stack) != null) {
            	ItemStack furnaceStack = FurnaceRecipes.smelting().getSmeltingResult(stack).copy();
            	
            	int itemMeta = furnaceStack.getItemDamage();
            	
            	//float xpToDrop = FurnaceRecipes.smelting().getSmeltingResult(stack).getItem().getSmeltingExperience(FurnaceRecipes.smelting().getSmeltingResult(stack));
            	
            	float xpToDrop = FurnaceRecipes.smelting().func_151398_b(furnaceStack);
            	
            	LogHelper.logInfo("Block: " + new ItemStack(block, 1, blockMeta));
            	
            	LogHelper.logInfo("XP: " + xpToDrop);
	            
	            Item item = furnaceStack.getItem();
	            
	            LogHelper.logInfo("Item Meta: " + itemMeta);
	            
	            if (item != null) {
	                ret.add(new ItemStack(item, 1, itemMeta));
	            }
            }else {
            	if(block.canSilkHarvest(world, player, x, y, z, meta))
            		ret.add(new ItemStack(block, 1, meta));
            	else
            		ret.add(new ItemStack(block.getItemDropped(blockMeta, world.rand, fortune)));
            }
        	}
        }
        
        return ret;
    }

 

Seems my problem was not copying the ItemStack. Honestly pretty weird. O.o

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.