Posted January 14, 20197 yr I have a mod that I am converting from 1.7.10 to 1.12.2. For the most part I have it working, but two things I am noticing that I cannot seem to figure out. One part of the mod will mine ores from the surface, and here is the code that does that. It does mine the ores, but in 1.7.10 it also would give xp orbs for the mined ores. This does not. Also I am having trouble the dropped items are disappearing after spawning. I am thinking they may be sinking into a cave?? They show up for a second and then disappear, and they are not in the payers inventory. First how do I get the xp orb's to spawn again and how do I get the drops to spawn at the players Y or even better yet get them to just be added to inventory, or even attached inventory like a backpack. Thanks! for (X = start.x; X <= end.x; X++) { for (Z = start.z; Z <= end.z; Z++) { for (Y = surface; Y > 1; Y--) { BlockPos pos = new BlockPos(X, Y, Z); if (world.isAirBlock(pos)) continue; stateAt = world.getBlockState(pos); blockAt = stateAt.getBlock(); if (isMiningOre(blockAt, (mode.id().equals("vanilla")))) { BlockPos top = new BlockPos(X, surface, Z); blockAt.harvestBlock(world, entityplayer, top, stateAt, null, ItemStack.EMPTY); world.setBlockState(pos, Blocks.STONE.getDefaultState()); blockAt.onBlockDestroyedByPlayer(world, top, stateAt); cnt++; } } } }
January 14, 20197 yr Author Ok, finally found it. I assume the order is acceptable. - for (X = start.x; X <= end.x; X++) { for (Z = start.z; Z <= end.z; Z++) { for (Y = surface; Y > 1; Y--) { BlockPos pos = new BlockPos(X, Y, Z); if (world.isAirBlock(pos)) continue; stateAt = world.getBlockState(pos); blockAt = stateAt.getBlock(); if (isMiningOre(blockAt, (mode.id().equals("vanilla")))) { BlockPos top = new BlockPos(X, surface, Z); blockAt.harvestBlock(world, entityplayer, top, stateAt, null, ItemStack.EMPTY); blockAt.dropXpOnBlockBreak(world, top,blockAt.getExpDrop(stateAt, world, pos, fortune)); world.setBlockState(pos, Blocks.STONE.getDefaultState()); blockAt.onBlockDestroyedByPlayer(world, pos, stateAt); cnt++; } } } }
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.