Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.event.entity.EntityLeaveLevelEvent;

import java.util.ArrayList;
Expand Down Expand Up @@ -160,6 +161,8 @@ private static void removeEnchantmentsFromItems(
continue;
}

var spawnLocation = Vec3.atBottomCenterOf(anvilPos);

// Determine how large the stack is
int stackSize = stack.getCount();

Expand All @@ -179,9 +182,9 @@ private static void removeEnchantmentsFromItems(
// Spawn the book in the world
level.addFreshEntity(new ItemEntity(
level,
anvilPos.getX(),
anvilPos.getY(),
anvilPos.getZ(),
spawnLocation.x,
spawnLocation.y,
spawnLocation.z,
enchantedBookToSpawn
));

Expand All @@ -202,13 +205,14 @@ private static void removeEnchantmentsFromItems(
}

// Respawn any remaining books
var spawnLocation = Vec3.atBottomCenterOf(anvilPos);
while (booksAvailable > 0) {
int toSpawn = Math.min(booksAvailable, 64);
level.addFreshEntity(new ItemEntity(
level,
anvilPos.getX(),
anvilPos.getY(),
anvilPos.getZ(),
spawnLocation.x,
spawnLocation.y,
spawnLocation.z,
new ItemStack(Items.BOOK, toSpawn)
));
booksAvailable -= toSpawn;
Expand All @@ -220,6 +224,7 @@ private static void crushEnchantedBooksIntoXpShards(
BlockPos anvilPos,
List<ItemEntity> items
) {
var spawnLocation = Vec3.atBottomCenterOf(anvilPos);

// For each item
for (ItemEntity itemEntity : items) {
Expand Down Expand Up @@ -262,9 +267,9 @@ private static void crushEnchantedBooksIntoXpShards(
// Spawn the stack
ItemEntity shardItemEntity = new ItemEntity(
level,
anvilPos.getX(),
anvilPos.getY(),
anvilPos.getZ(),
spawnLocation.x,
spawnLocation.y,
spawnLocation.z,
shardStack
);
level.addFreshEntity(shardItemEntity);
Expand All @@ -289,6 +294,8 @@ private static void handlePrintingPressFormCreation(
// Mark the block for consumption only if work is done
boolean consumeBlock = false;

var spawnLocation = Vec3.atBottomCenterOf(anvilPos);

// For each item entity
for (ItemEntity itemEntity : itemEntities) {

Expand All @@ -306,9 +313,9 @@ private static void handlePrintingPressFormCreation(
// Spawn the new item
level.addFreshEntity(new ItemEntity(
level,
anvilPos.getX(),
anvilPos.getY(),
anvilPos.getZ(),
spawnLocation.x,
spawnLocation.y,
spawnLocation.z,
formStack
));

Expand Down