Sneak to bulk process composter

This commit is contained in:
BillyGalbreath
2021-03-21 23:20:54 -05:00
parent 1362f49b24
commit f754a7b616
2 changed files with 61 additions and 4 deletions

View File

@@ -52,7 +52,3 @@ subprojects {
credentials(PasswordCredentials::class) credentials(PasswordCredentials::class)
} }
} }
tasks.withType<xyz.jpenilla.toothpick.task.ApplyPatches> {
applyCommand("am", "--no-3way", "--ignore-whitespace", "--reject", "-C0")
}

View File

@@ -0,0 +1,61 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <blake.galbreath@gmail.com>
Date: Sun, 21 Mar 2021 15:49:15 -0500
Subject: [PATCH] Sneak to bulk process composter
diff --git a/src/main/java/net/minecraft/world/level/block/BlockComposter.java b/src/main/java/net/minecraft/world/level/block/BlockComposter.java
index e4e519ba773388b8d26a8f794a6eff51e3d8f72e..c0b235d5edf3cd14021696d1b4f76ce3de41f5d5 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockComposter.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockComposter.java
@@ -44,7 +44,7 @@ import org.bukkit.craftbukkit.util.DummyGeneratorAccess;
public class BlockComposter extends Block implements IInventoryHolder {
- public static final BlockStateInteger a = BlockProperties.as;
+ public static final BlockStateInteger a = BlockProperties.as; public static BlockStateInteger level() { return BlockComposter.a; } // Purpur - OBFHELPER
public static final Object2FloatMap<IMaterial> b = new Object2FloatOpenHashMap();
private static final VoxelShape c = VoxelShapes.b();
private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((new VoxelShape[9]), (avoxelshape) -> { // CraftBukkit - decompile error
@@ -203,6 +203,25 @@ public class BlockComposter extends Block implements IInventoryHolder {
public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, Entity entity) { // CraftBukkit
int i = (Integer) iblockdata.get(BlockComposter.a);
+ // Purpur start
+ IBlockData newState = process(i, iblockdata, worldserver, itemstack, blockposition, entity);
+
+ if (worldserver.purpurConfig.composterBulkProcess && entity.isSneaking()) {
+ IBlockData oldState;
+ int oldCount, newCount, oldLevel, newLevel;
+ do {
+ oldState = newState;
+ oldCount = itemstack.getCount();
+ oldLevel = oldState.get(BlockComposter.level());
+ newState = process(oldLevel, oldState, worldserver, itemstack, blockposition, entity);
+ newCount = itemstack.getCount();
+ newLevel = newState.get(BlockComposter.level());
+ } while (newCount > 0 && (newCount != oldCount || newLevel != oldLevel || newState != oldState));
+ }
+ return newState;
+ }
+ private static IBlockData process(int i, IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, Entity entity) {
+ // Purpur end
if (i < 7 && BlockComposter.b.containsKey(itemstack.getItem())) {
// CraftBukkit start
double rand = worldserver.getRandom().nextDouble();
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 94f975521e9770577975810bb2c6c40d96303392..546d10217ffdf6de4c0c76ad4a55911b9fb6e903 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -444,6 +444,11 @@ public class PurpurWorldConfig {
chestOpenWithBlockOnTop = getBoolean("blocks.chest.open-with-solid-block-on-top", chestOpenWithBlockOnTop);
}
+ public boolean composterBulkProcess = false;
+ private void composterSettings() {
+ composterBulkProcess = getBoolean("blocks.composter.sneak-to-bulk-process", composterBulkProcess);
+ }
+
public boolean dispenserApplyCursedArmor = true;
public boolean dispenserPlaceAnvils = false;
private void dispenserSettings() {