Skip to content

Commit

Permalink
Revert unwanted changes from #5276 (#5280)
Browse files Browse the repository at this point in the history
Also fixes incorrect documentation.
  • Loading branch information
yueh authored Jun 7, 2021
1 parent c80b51b commit 4d8112d
Showing 1 changed file with 24 additions and 29 deletions.
53 changes: 24 additions & 29 deletions src/main/java/appeng/parts/automation/AnnihilationPlanePart.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ public void getBoxes(final IPartCollisionHelper bch) {

// For collision, we're using a simplified bounding box
if (bch.isBBCollision()) {
// The smaller collision hitbox here is needed to allow for the entity collision
// event
// The smaller collision hitbox here is needed to allow for the entity collision event
bch.addBox(0, 0, 14, 16, 16, 15.5);
return;
}
Expand Down Expand Up @@ -333,9 +332,8 @@ private void performBreakBlock(ServerWorld w, BlockPos pos, BlockState blockStat

for (ItemStack item : items) {
IAEItemStack overflow = storeItemStack(item);
// If inserting the item fully was not possible, drop it as an item entity
// instead
// if the storage clears up, we'll pick it up that way
// If inserting the item fully was not possible, drop it as an item entity instead if the storage clears up,
// we'll pick it up that way
if (overflow != null) {
Platform.spawnDrops(w, pos, Collections.singletonList(overflow.createItemStack()));
}
Expand Down Expand Up @@ -379,28 +377,24 @@ private boolean canHandleBlock(final ServerWorld w, final BlockPos pos, final Bl
final Material material = state.getMaterial();
// Note: bedrock, portals, and other unbreakable blocks have a hardness < 0, hence the >= 0 check below.
final float hardness = state.getBlockHardness(w, pos);
final boolean ignoreMaterials = material == Material.AIR || material == Material.LAVA
|| material == Material.WATER || material.isLiquid();
final boolean ignoreAirAndFluids = material == Material.AIR || material.isLiquid();

return !ignoreMaterials && hardness >= 0f && w.isBlockLoaded(pos)
return !ignoreAirAndFluids && hardness >= 0f && w.isBlockLoaded(pos)
&& w.isBlockModifiable(Platform.getPlayer(w), pos);
}

protected List<ItemStack> obtainBlockDrops(final ServerWorld w, final BlockPos pos) {

Entity fakePlayer = FakePlayerFactory.getMinecraft(w);

final Entity fakePlayer = FakePlayerFactory.getMinecraft(w);
final BlockState state = w.getBlockState(pos);
final TileEntity te = w.getTileEntity(pos);

ItemStack harvestTool = createHarvestTool(state);

if (!state.getRequiresTool() && !harvestTool.isEnchanted()) {
// If the state does not require a tool, and the tool is not enchanted (with silk touch for example in case
// of the identity annihilation plane), then we don't use a tool.
if (!state.getRequiresTool() && state.getHarvestTool() == null && !harvestTool.isEnchanted()) {
// Do not use a tool when not required, no hints about it and not enchanted in cases like silk touch.
harvestTool = ItemStack.EMPTY;
}

TileEntity te = w.getTileEntity(pos);
return Block.getDrops(state, w, pos, te, fakePlayer, harvestTool);
}

Expand Down Expand Up @@ -457,9 +451,8 @@ private boolean breakBlockAndStoreExtraItems(final ServerWorld w, final BlockPos
return false;
}

// This handles items that do not spawn via loot-tables but rather normal block
// breaking
// i.e. our cable-buses do this (bad practice, really)
// This handles items that do not spawn via loot-tables but rather normal block breaking i.e. our cable-buses do
// this (bad practice, really)
final AxisAlignedBB box = new AxisAlignedBB(pos).grow(0.2);
for (final Object ei : w.getEntitiesWithinAABB(ItemEntity.class, box)) {
if (ei instanceof ItemEntity) {
Expand Down Expand Up @@ -494,24 +487,26 @@ public IModelData getModelData() {
}

/**
* Creates the fake (and temporary) tool that will be used to calculate the loot tables of a block this plane wants
* to break.
* Creates the fake (and temporary) tool based on the provided hints in case a loot table relies on it.
*
* Generally could use a stick as tool or anything else which can be enchanted. {@link ItemStack#EMPTY} is not an
* option as at least anything having a fortune effect need something enchantable even without the enchantment,
* otherwise it will not drop anything.
*
* @param state The state of the block about to be broken.
* @param state The block state of the block about to be broken.
*/
protected ItemStack createHarvestTool(BlockState state) {
// Try to use the right tool...
ToolType harvestToolType = state.getBlock().getHarvestTool(state);

if (harvestToolType == ToolType.AXE) {
return new ItemStack(Items.NETHERITE_AXE, 1);
return new ItemStack(Items.DIAMOND_AXE, 1);
} else if (harvestToolType == ToolType.SHOVEL) {
return new ItemStack(Items.NETHERITE_SHOVEL, 1);
} else if (harvestToolType == ToolType.PICKAXE) {
return new ItemStack(Items.NETHERITE_PICKAXE, 1);
return new ItemStack(Items.DIAMOND_SHOVEL, 1);
} else if (harvestToolType == ToolType.HOE) {
return new ItemStack(Items.DIAMOND_HOE, 1);
} else {
// In doubt, try with a pickaxe. As of 1.16.5, some blocks require a pickaxe, but return null in
// getHarvestTool(). This workaround should allow correctly retrieving their drops.
return new ItemStack(Items.NETHERITE_PICKAXE, 1);
// Use a pickaxe for everything else. Mostly to allow silk touch enchants
return new ItemStack(Items.DIAMOND_PICKAXE, 1);
}
}

Expand Down

0 comments on commit 4d8112d

Please sign in to comment.