use a different method for dropping lapis, closes #1692

This commit is contained in:
granny
2025-07-22 18:01:23 -07:00
parent 8de15d66e3
commit 5053eb0c5d
2 changed files with 9 additions and 20 deletions

View File

@@ -1,19 +0,0 @@
--- a/net/minecraft/world/level/block/EnchantingTableBlock.java
+++ b/net/minecraft/world/level/block/EnchantingTableBlock.java
@@ -119,4 +_,16 @@
protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) {
return false;
}
+
+ // Purpur start - Enchantment Table Persists Lapis
+ @Override
+ protected void affectNeighborsAfterRemoval(BlockState state, net.minecraft.server.level.ServerLevel level, BlockPos pos, boolean movedByPiston) {
+ BlockEntity blockEntity = level.getBlockEntity(pos);
+
+ if (level.purpurConfig.enchantmentTableLapisPersists && blockEntity instanceof EnchantingTableBlockEntity enchantmentTable) {
+ net.minecraft.world.Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.LAPIS_LAZULI, enchantmentTable.getLapis()));
+ net.minecraft.world.Containers.updateNeighboursAfterDestroy(state, level, pos);
+ }
+ }
+ // Purpur end - Enchantment Table Persists Lapis
}

View File

@@ -23,7 +23,7 @@
}
public static void bookAnimationTick(Level level, BlockPos pos, BlockState state, EnchantingTableBlockEntity enchantingTable) {
@@ -136,4 +_,14 @@
@@ -136,4 +_,22 @@
public void removeComponentsFromTag(ValueOutput output) {
output.discard("CustomName");
}
@@ -36,5 +36,13 @@
+ public void setLapis(int lapis) {
+ this.lapis = lapis;
+ }
+
+ @Override
+ public void preRemoveSideEffects(BlockPos pos, BlockState state) {
+ super.preRemoveSideEffects(pos, state);
+ if (this.level != null && this.level.purpurConfig.enchantmentTableLapisPersists) {
+ net.minecraft.world.Containers.dropItemStack(this.level, pos.getX(), pos.getY(), pos.getZ(), new net.minecraft.world.item.ItemStack(net.minecraft.world.item.Items.LAPIS_LAZULI, this.getLapis()));
+ }
+ }
+ // Purpur end - Enchantment Table Persists Lapis
}