mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 08:57:44 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: 3f5564f1 Port Optimize-Hoppers.patch to 1.15 (#2765)
103 lines
5.0 KiB
Diff
103 lines
5.0 KiB
Diff
From 743e226dce9e746bd2d0358ed10d487ca53a537b Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Thu, 1 Aug 2019 19:15:12 -0500
|
|
Subject: [PATCH] Add blacklist option for grindstone
|
|
|
|
---
|
|
.../minecraft/server/ContainerGrindstone.java | 17 +++++++++++++++++
|
|
.../java/net/minecraft/server/ItemStack.java | 6 ++++++
|
|
src/main/java/net/pl3x/purpur/PurpurConfig.java | 12 ++++++++++++
|
|
3 files changed, 35 insertions(+)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ContainerGrindstone.java b/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
|
index ed88e208d..0a5abd2e1 100644
|
|
--- a/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
|
+++ b/src/main/java/net/minecraft/server/ContainerGrindstone.java
|
|
@@ -57,12 +57,24 @@ public class ContainerGrindstone extends Container {
|
|
this.a(new Slot(this.craftInventory, 0, 49, 19) {
|
|
@Override
|
|
public boolean isAllowed(ItemStack itemstack) {
|
|
+ // Purpur start
|
|
+ if (net.pl3x.purpur.PurpurConfig.grindstoneBlacklistDisallowPlacement && net.pl3x.purpur.PurpurConfig.grindstoneBlacklist.contains(itemstack.getId())) {
|
|
+ getBukkitView().getTopInventory().getViewers().forEach(viewer -> ((Player) viewer).updateInventory());
|
|
+ return false;
|
|
+ }
|
|
+ // Purpur end
|
|
return itemstack.e() || itemstack.getItem() == Items.ENCHANTED_BOOK || itemstack.hasEnchantments();
|
|
}
|
|
});
|
|
this.a(new Slot(this.craftInventory, 1, 49, 40) {
|
|
@Override
|
|
public boolean isAllowed(ItemStack itemstack) {
|
|
+ // Purpur start
|
|
+ if (net.pl3x.purpur.PurpurConfig.grindstoneBlacklistDisallowPlacement && net.pl3x.purpur.PurpurConfig.grindstoneBlacklist.contains(itemstack.getId())) {
|
|
+ getBukkitView().getTopInventory().getViewers().forEach(viewer -> ((Player) viewer).updateInventory());
|
|
+ return false;
|
|
+ }
|
|
+ // Purpur end
|
|
return itemstack.e() || itemstack.getItem() == Items.ENCHANTED_BOOK || itemstack.hasEnchantments();
|
|
}
|
|
});
|
|
@@ -106,6 +118,11 @@ public class ContainerGrindstone extends Container {
|
|
}
|
|
|
|
private int e(ItemStack itemstack) {
|
|
+ // Purpur start
|
|
+ if (net.pl3x.purpur.PurpurConfig.grindstoneBlacklistReturnsZeroExp && net.pl3x.purpur.PurpurConfig.grindstoneBlacklist.contains(itemstack.getId())) {
|
|
+ return 0;
|
|
+ }
|
|
+ // Purpur end
|
|
int j = 0;
|
|
Map<Enchantment, Integer> map = EnchantmentManager.a(itemstack);
|
|
Iterator iterator = map.entrySet().iterator();
|
|
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
|
index 2b39d5ca2..e9801022e 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
|
@@ -541,6 +541,12 @@ public final class ItemStack {
|
|
return !this.e() ? this.doMaterialsMatch(itemstack) : !itemstack.isEmpty() && this.getItem() == itemstack.getItem();
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ public String getId() {
|
|
+ return IRegistry.ITEM.getKey(getItem()).toString();
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
public String j() {
|
|
return this.getItem().f(this);
|
|
}
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
index 7d3c5e176..73b0eec5a 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -1,6 +1,7 @@
|
|
package net.pl3x.purpur;
|
|
|
|
import com.google.common.base.Throwables;
|
|
+import com.google.common.collect.Lists;
|
|
import net.minecraft.server.Block;
|
|
import net.minecraft.server.IRegistry;
|
|
import net.minecraft.server.MinecraftKey;
|
|
@@ -171,6 +172,17 @@ public class PurpurConfig {
|
|
updatePermissionsOnWorldChange = getBoolean("settings.update-perms-on-world-change", updatePermissionsOnWorldChange);
|
|
}
|
|
|
|
+ public static boolean grindstoneBlacklistDisallowPlacement = true;
|
|
+ public static boolean grindstoneBlacklistReturnsZeroExp = true;
|
|
+ public static List<String> grindstoneBlacklist = Lists.newArrayList("minecraft:tripwire_hook");
|
|
+ private static void grindstoneBlacklist() {
|
|
+ grindstoneBlacklistDisallowPlacement = getBoolean("settings.grindstone.disallow-placement", grindstoneBlacklistDisallowPlacement);
|
|
+ grindstoneBlacklistReturnsZeroExp = getBoolean("settings.grindstone.returns-zero-exp", grindstoneBlacklistReturnsZeroExp);
|
|
+ List<String> blacklist = getList("settings.grindstone.blacklisted-items", grindstoneBlacklist);
|
|
+ grindstoneBlacklist.clear();
|
|
+ grindstoneBlacklist.addAll(blacklist);
|
|
+ }
|
|
+
|
|
public static boolean requireShiftToMount = true;
|
|
private static void requireShiftToMount() {
|
|
requireShiftToMount = getBoolean("settings.mobs.require-shift-to-mount", requireShiftToMount);
|
|
--
|
|
2.24.0.rc1
|
|
|