mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Enchantment Table Persists Lapis
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/world/inventory/EnchantmentMenu.java
|
||||
+++ b/net/minecraft/world/inventory/EnchantmentMenu.java
|
||||
@@ -63,6 +_,22 @@
|
||||
return access.getLocation();
|
||||
}
|
||||
// CraftBukkit end
|
||||
+
|
||||
+ // Purpur start - Enchantment Table Persists Lapis
|
||||
+ @Override
|
||||
+ public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity who) {
|
||||
+ super.onClose(who);
|
||||
+
|
||||
+ if (who.getHandle().level().purpurConfig.enchantmentTableLapisPersists) {
|
||||
+ access.execute((level, pos) -> {
|
||||
+ net.minecraft.world.level.block.entity.BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
+ if (blockEntity instanceof net.minecraft.world.level.block.entity.EnchantingTableBlockEntity enchantmentTable) {
|
||||
+ enchantmentTable.setLapis(this.getItem(1).getCount());
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Enchantment Table Persists Lapis
|
||||
};
|
||||
// Paper end - Add missing InventoryHolders
|
||||
this.access = access;
|
||||
@@ -83,6 +_,16 @@
|
||||
return EnchantmentMenu.EMPTY_SLOT_LAPIS_LAZULI;
|
||||
}
|
||||
});
|
||||
+ // Purpur start - Enchantment Table Persists Lapis
|
||||
+ access.execute((level, pos) -> {
|
||||
+ if (level.purpurConfig.enchantmentTableLapisPersists) {
|
||||
+ net.minecraft.world.level.block.entity.BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
+ if (blockEntity instanceof net.minecraft.world.level.block.entity.EnchantingTableBlockEntity enchantmentTable) {
|
||||
+ this.getSlot(1).set(new ItemStack(Items.LAPIS_LAZULI, enchantmentTable.getLapis()));
|
||||
+ }
|
||||
+ }
|
||||
+ });
|
||||
+ // Purpur end - Enchantment Table Persists Lapis
|
||||
this.addStandardInventorySlots(playerInventory, 8, 84);
|
||||
this.addDataSlot(DataSlot.shared(this.costs, 0));
|
||||
this.addDataSlot(DataSlot.shared(this.costs, 1));
|
||||
@@ -292,7 +_,7 @@
|
||||
@Override
|
||||
public void removed(Player player) {
|
||||
super.removed(player);
|
||||
- this.access.execute((level, blockPos) -> this.clearContainer(player, this.enchantSlots));
|
||||
+ this.access.execute((level, blockPos) -> {if (level.purpurConfig.enchantmentTableLapisPersists) this.getSlot(1).set(ItemStack.EMPTY);this.clearContainer(player, this.enchantSlots);}); // Purpur - Enchantment Table Persists Lapis
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/net/minecraft/world/level/block/EnchantingTableBlock.java
|
||||
+++ b/net/minecraft/world/level/block/EnchantingTableBlock.java
|
||||
@@ -119,4 +_,18 @@
|
||||
protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) {
|
||||
return false;
|
||||
}
|
||||
+
|
||||
+ // Purpur start - Enchantment Table Persists Lapis
|
||||
+ @Override
|
||||
+ public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean moved) {
|
||||
+ 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()));
|
||||
+ level.updateNeighbourForOutputSignal(pos, this);
|
||||
+ }
|
||||
+
|
||||
+ super.onRemove(state, level, pos, newState, moved);
|
||||
+ }
|
||||
+ // Purpur end - Enchantment Table Persists Lapis
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
--- a/net/minecraft/world/level/block/entity/EnchantingTableBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/EnchantingTableBlockEntity.java
|
||||
@@ -28,6 +_,7 @@
|
||||
private static final RandomSource RANDOM = RandomSource.create();
|
||||
@Nullable
|
||||
private Component name;
|
||||
+ private int lapis = 0; // Purpur - Enchantment Table Persists Lapis
|
||||
|
||||
public EnchantingTableBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityType.ENCHANTING_TABLE, pos, state);
|
||||
@@ -39,6 +_,7 @@
|
||||
if (this.hasCustomName()) {
|
||||
tag.putString("CustomName", Component.Serializer.toJson(this.name, registries));
|
||||
}
|
||||
+ tag.putInt("Purpur.Lapis", this.lapis); // Purpur - Enchantment Table Persists Lapis
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,6 +_,7 @@
|
||||
if (tag.contains("CustomName", 8)) {
|
||||
this.name = parseCustomNameSafe(tag.getString("CustomName"), registries);
|
||||
}
|
||||
+ this.lapis = tag.getInt("Purpur.Lapis"); // Purpur - Enchantment Table Persists Lapis
|
||||
}
|
||||
|
||||
public static void bookAnimationTick(Level level, BlockPos pos, BlockState state, EnchantingTableBlockEntity enchantingTable) {
|
||||
@@ -138,4 +_,14 @@
|
||||
public void removeComponentsFromTag(CompoundTag tag) {
|
||||
tag.remove("CustomName");
|
||||
}
|
||||
+
|
||||
+ // Purpur start - Enchantment Table Persists Lapis
|
||||
+ public int getLapis() {
|
||||
+ return this.lapis;
|
||||
+ }
|
||||
+
|
||||
+ public void setLapis(int lapis) {
|
||||
+ this.lapis = lapis;
|
||||
+ }
|
||||
+ // Purpur end - Enchantment Table Persists Lapis
|
||||
}
|
||||
@@ -1564,6 +1564,11 @@ public class PurpurWorldConfig {
|
||||
elderGuardianAlwaysDropExp = getBoolean("mobs.elder_guardian.always-drop-exp", elderGuardianAlwaysDropExp);
|
||||
}
|
||||
|
||||
public boolean enchantmentTableLapisPersists = false;
|
||||
private void enchantmentTableSettings() {
|
||||
enchantmentTableLapisPersists = getBoolean("blocks.enchantment-table.lapis-persists", enchantmentTableLapisPersists);
|
||||
}
|
||||
|
||||
public boolean enderDragonRidable = false;
|
||||
public boolean enderDragonRidableInWater = true;
|
||||
public boolean enderDragonControllable = true;
|
||||
|
||||
Reference in New Issue
Block a user