Skip to content

Commit

Permalink
fix a lots of patches
Browse files Browse the repository at this point in the history
  • Loading branch information
MC-XiaoHei committed May 11, 2024
1 parent 5e07c06 commit d91185d
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 30 deletions.
6 changes: 3 additions & 3 deletions patches/server/0010-Placeholder-of-Fakeplayer-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ index 0000000000000000000000000000000000000000..ed7e8cc97bb0394695d67e7849ea7337
+}
diff --git a/src/main/java/top/leavesmc/leaves/bot/BotInventoryContainer.java b/src/main/java/top/leavesmc/leaves/bot/BotInventoryContainer.java
new file mode 100644
index 0000000000000000000000000000000000000000..b83ad5bf2a338d589eb200d3f3b3153571ba2cad
index 0000000000000000000000000000000000000000..7a57749909c886953d233dc0910effc0c4a3f115
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/bot/BotInventoryContainer.java
@@ -0,0 +1,180 @@
Expand Down Expand Up @@ -605,8 +605,8 @@ index 0000000000000000000000000000000000000000..b83ad5bf2a338d589eb200d3f3b31535
+ private void createButton() {
+ for (int i = 0; i < 13; i++) {
+ ItemStack button = new ItemStack(Items.STRUCTURE_VOID);
+ button.setHoverName(Component.empty());
+ button.getOrCreateTag().putBoolean("Leaves.Gui.Placeholder", true);
+ // button.setHoverName(Component.empty()); // Leaves - remove bot temporarily
+ // button.getOrCreateTag().putBoolean("Leaves.Gui.Placeholder", true); // Leaves - remove bot temporarily
+ buttons.set(i, button);
+ }
+ }
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0047-MC-Technical-Survival-Mode.patch
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ index 592b330f187fb5eca51d60911bbebbaeaf46ef87..c4aed4ed80ca0ed427c777e81d2cf219

diff --git a/src/main/java/top/leavesmc/leaves/util/McTechnicalModeHelper.java b/src/main/java/top/leavesmc/leaves/util/McTechnicalModeHelper.java
new file mode 100644
index 0000000000000000000000000000000000000000..4822a3806c55126e219364c3f76d0159a6f6453e
index 0000000000000000000000000000000000000000..d9041f1a56a7c04203e3f462206414c7b890df44
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/util/McTechnicalModeHelper.java
@@ -0,0 +1,27 @@
Expand All @@ -179,7 +179,7 @@ index 0000000000000000000000000000000000000000..4822a3806c55126e219364c3f76d0159
+ GlobalConfiguration.get().packetLimiter.allPackets = new GlobalConfiguration.PacketLimiter.PacketLimit(GlobalConfiguration.get().packetLimiter.allPackets.interval(),
+ 5000.0, GlobalConfiguration.get().packetLimiter.allPackets.action());
+ GlobalConfiguration.get().packetLimiter.overrides = Map.of();
+ GlobalConfiguration.get().unsupportedSettings.allowGrindstoneOverstacking = true;
+ // GlobalConfiguration.get().unsupportedSettings.allowGrindstoneOverstacking = true;
+ GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks = true;
+ GlobalConfiguration.get().scoreboards.saveEmptyScoreboardTeams = true;
+ }
Expand Down
14 changes: 11 additions & 3 deletions patches/server/0058-No-feather-falling-trample.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ Subject: [PATCH] No feather falling trample


diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
index d59e33e7326489c6d55d316d0130f22235f4c63c..a454b8e6ef9133fbbae168bd4748c90ecd9fea37 100644
index d59e33e7326489c6d55d316d0130f22235f4c63c..1667d1220e934b74a4a2f26ae27982388062f09b 100644
--- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
@@ -112,6 +112,13 @@ public class FarmBlock extends Block {
@@ -14,6 +14,7 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.context.BlockPlaceContext;
+import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
@@ -112,6 +113,13 @@ public class FarmBlock extends Block {
public void fallOn(Level world, BlockState state, BlockPos pos, Entity entity, float fallDistance) {
super.fallOn(world, state, pos, entity, fallDistance); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage.
if (!world.isClientSide && world.random.nextFloat() < fallDistance - 0.5F && entity instanceof LivingEntity && (entity instanceof Player || world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) {
+ // Leaves start - noFeatherFallingTrample
+ if (top.leavesmc.leaves.LeavesConfig.noFeatherFallingTrample) {
+ if (net.minecraft.world.item.enchantment.EnchantmentHelper.getEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.FALL_PROTECTION, (LivingEntity) entity) > 0) {
+ if (net.minecraft.world.item.enchantment.EnchantmentHelper.getEnchantmentLevel(Enchantments.FEATHER_FALLING, (LivingEntity) entity) > 0) {
+ return;
+ }
+ }
Expand Down
45 changes: 38 additions & 7 deletions patches/server/0067-Shave-snow-layers.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@ Subject: [PATCH] Shave snow layers


diff --git a/src/main/java/net/minecraft/world/item/ShovelItem.java b/src/main/java/net/minecraft/world/item/ShovelItem.java
index 24f6a158e4759aac3be8da4cf5e0d40bd295355b..59c6c9b4d574b2c1f6c54a116c4bab43b71da7f8 100644
index 24f6a158e4759aac3be8da4cf5e0d40bd295355b..8c6773ee217b0a69f47e82d536e1d29f067bc960 100644
--- a/src/main/java/net/minecraft/world/item/ShovelItem.java
+++ b/src/main/java/net/minecraft/world/item/ShovelItem.java
@@ -12,10 +12,12 @@ import net.minecraft.world.InteractionResult;
@@ -2,20 +2,25 @@ package net.minecraft.world.item;

import com.google.common.collect.Maps;
import com.google.common.collect.ImmutableMap.Builder;
+
import java.util.Map;
+
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.InteractionResult;
+import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.context.UseOnContext;
Expand All @@ -21,7 +34,7 @@ index 24f6a158e4759aac3be8da4cf5e0d40bd295355b..59c6c9b4d574b2c1f6c54a116c4bab43
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;

@@ -44,6 +46,22 @@ public class ShovelItem extends DiggerItem {
@@ -44,6 +49,24 @@ public class ShovelItem extends DiggerItem {
return InteractionResult.PASS;
} else {
Player player = context.getPlayer();
Expand All @@ -32,10 +45,12 @@ index 24f6a158e4759aac3be8da4cf5e0d40bd295355b..59c6c9b4d574b2c1f6c54a116c4bab43
+ Block.popResource(level, blockPos, new ItemStack(EnchantmentHelper.hasSilkTouch(context.getItemInHand()) ? Items.SNOW : Items.SNOWBALL));
+ level.playSound(player, blockPos, SoundEvents.SNOW_BREAK, SoundSource.BLOCKS, 1.0F, 1.0F);
+
+ if(player != null) {
+ context.getItemInHand().hurtAndBreak(1, player, (p) -> {
+ p.broadcastBreakEvent(context.getHand());
+ });
+ if (player != null) {
+ context.getItemInHand().hurtAndBreak(1, player.getRandom(), player, () ->
+ player.broadcastBreakEvent(switch (context.getHand()) {
+ case MAIN_HAND -> EquipmentSlot.MAINHAND;
+ case OFF_HAND -> EquipmentSlot.OFFHAND;
+ }));
+ }
+
+ return InteractionResult.SUCCESS;
Expand All @@ -44,3 +59,19 @@ index 24f6a158e4759aac3be8da4cf5e0d40bd295355b..59c6c9b4d574b2c1f6c54a116c4bab43
BlockState blockState2 = FLATTENABLES.get(blockState.getBlock());
BlockState blockState3 = null;
Runnable afterAction = null; // Paper
@@ -52,11 +75,11 @@ public class ShovelItem extends DiggerItem {
blockState3 = blockState2;
} else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) {
afterAction = () -> { // Paper
- if (!level.isClientSide()) {
- level.levelEvent(null, 1009, blockPos, 0);
- }
+ if (!level.isClientSide()) {
+ level.levelEvent(null, 1009, blockPos, 0);
+ }

- CampfireBlock.dowse(context.getPlayer(), level, blockPos, blockState);
+ CampfireBlock.dowse(context.getPlayer(), level, blockPos, blockState);
}; // Paper
blockState3 = blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false));
}
15 changes: 8 additions & 7 deletions patches/server/0074-Container-open-passthrough.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ Subject: [PATCH] Container open passthrough


diff --git a/src/main/java/net/minecraft/world/level/block/SignBlock.java b/src/main/java/net/minecraft/world/level/block/SignBlock.java
index f7bae8060d993176799ff3ff4653d760a137faba..ec45b1aacc9244d08b7870f63a08a27a71499a79 100644
index f7bae8060d993176799ff3ff4653d760a137faba..4498755c7b826e4218214a71c70e5fa1898861cf 100644
--- a/src/main/java/net/minecraft/world/level/block/SignBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SignBlock.java
@@ -141,6 +141,25 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
@@ -141,6 +141,26 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo
return InteractionResult.SUCCESS;
} else if (flag1) {
return InteractionResult.SUCCESS;
+ // Leaves start - signContainerPassthrough
+ } else if (top.leavesmc.leaves.LeavesConfig.containerPassthrough) {
+ if (item == net.minecraft.world.item.Items.AIR && player.isShiftKeyDown()) {
+ if (state.isAir() && player.isShiftKeyDown()) {
+ if (!this.otherPlayerIsEditingSign(player, tileentitysign) && player.mayBuild() && this.hasEditableText(player, tileentitysign, flag1)) {
+ this.openTextEdit(player, tileentitysign, flag1);
+ return InteractionResult.SUCCESS;
Expand All @@ -25,10 +25,11 @@ index f7bae8060d993176799ff3ff4653d760a137faba..ec45b1aacc9244d08b7870f63a08a27a
+ if (this instanceof WallSignBlock || this instanceof WallHangingSignBlock) {
+ pos1 = pos.relative(state.getValue(HorizontalDirectionalBlock.FACING).getOpposite());
+ }
+ if (world.getBlockEntity(pos1) instanceof net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) {
+ BlockState state1 = world.getBlockState(pos1);
+ return state1.use(world, player, hand, hit.withPosition(pos1));
+ }
+ // TODO fix this
+ // if (world.getBlockEntity(pos1) instanceof net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) {
+ // BlockState state1 = world.getBlockState(pos1);
+ // return state1.use(world, player, hand, hit.withPosition(pos1));
+ // }
+ return InteractionResult.PASS;
+ // Leaves end - signContainerPassthrough
} else if (!this.otherPlayerIsEditingSign(player, tileentitysign) && player.mayBuild() && this.hasEditableText(player, tileentitysign, flag)) {
Expand Down
37 changes: 30 additions & 7 deletions patches/server/0108-Wool-Hopper-Counter.patch
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,40 @@ index e314f36951e9ac15c57137e24fce8c410373130a..dd232d9e86c5bf03cfb4597d3291a172
@Nullable
public ItemStack[] itemStacks;
@Nullable
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
index a31326e24cb68472c81cd781c5e3041772712862..f0422a70ef79c837405284fd42a74af6c57959de 100644
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
@@ -45,7 +45,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
private static final Logger LOGGER = LogUtils.getLogger();
private final HolderLookup.Provider registries;
public Multimap<RecipeType<?>, RecipeHolder<?>> byType = ImmutableMultimap.of();
- private Map<ResourceLocation, RecipeHolder<?>> byName = ImmutableMap.of();
+ public Map<ResourceLocation, RecipeHolder<?>> byName = ImmutableMap.of(); // Leaves - hopper counter
private boolean hasErrors;

public RecipeManager(HolderLookup.Provider registryLookup) {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index c4aed4ed80ca0ed427c777e81d2cf21956888fad..1668b62910bb18adaeb54ba49119553d69bb2812 100644
index c4aed4ed80ca0ed427c777e81d2cf21956888fad..f2fde04a6cb56c0c54edd8d48026f200a415d589 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -433,6 +433,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -202,7 +202,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen

final int fullState = getFullState(blockEntity); // Paper - Perf: Optimize Hoppers
if (fullState != HOPPER_EMPTY) { // Paper - Perf: Optimize Hoppers
- flag = HopperBlockEntity.ejectItems(world, pos, blockEntity);
+ flag = HopperBlockEntity.ejectItems(world, pos, blockEntity); // Leaves - hopper counter
}

if (fullState != HOPPER_IS_FULL || flag) { // Paper - Perf: Optimize Hoppers
@@ -432,7 +432,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
private static final java.util.function.BiPredicate<ItemStack, Integer> IS_EMPTY_TEST = (itemstack, i) -> itemstack.isEmpty();
// Paper end - Perf: Optimize Hoppers

+ // Leaves start - hopper counter
private static boolean ejectItems(Level world, BlockPos pos, HopperBlockEntity blockEntity) {
+ // Leaves start - hopper counter
+ if (top.leavesmc.leaves.util.HopperCounter.isEnabled()) {
+ if (woolHopperCounter(world, pos, blockEntity.getBlockState(), blockEntity.persistentDataContainer, blockEntity)) {
+ if (woolHopperCounter(world, pos, world.getBlockState(pos), (Container) blockEntity, blockEntity)) {
+ return true;
+ }
+ }
Expand Down Expand Up @@ -209,7 +232,7 @@ index 0000000000000000000000000000000000000000..24eecf862f3f5fab678813de7de8d3ba
+}
diff --git a/src/main/java/top/leavesmc/leaves/util/HopperCounter.java b/src/main/java/top/leavesmc/leaves/util/HopperCounter.java
new file mode 100644
index 0000000000000000000000000000000000000000..3b173b175fe3412ac9f87fb1d520777182125348
index 0000000000000000000000000000000000000000..54244e9eb3aa830bf5c90e285465662aa11b2e9c
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/util/HopperCounter.java
@@ -0,0 +1,334 @@
Expand Down Expand Up @@ -394,7 +417,7 @@ index 0000000000000000000000000000000000000000..3b173b175fe3412ac9f87fb1d5207771
+ entry(Items.POISONOUS_POTATO, Blocks.SLIME_BLOCK),
+ entry(Items.SPIDER_EYE, Blocks.NETHERRACK),
+ entry(Items.GUNPOWDER, Blocks.GRAY_WOOL),
+ entry(Items.SCUTE, Blocks.LIME_WOOL),
+ entry(Items.TURTLE_SCUTE, Blocks.LIME_WOOL),
+ entry(Items.FEATHER, Blocks.WHITE_WOOL),
+ entry(Items.FLINT, Blocks.BLACK_WOOL),
+ entry(Items.LEATHER, Blocks.SPRUCE_PLANKS),
Expand Down Expand Up @@ -492,7 +515,7 @@ index 0000000000000000000000000000000000000000..3b173b175fe3412ac9f87fb1d5207771
+ }
+
+ public static List<Recipe<?>> getAllMatching(@NotNull RecipeManager manager, RecipeType<?> type, ResourceLocation output, final RegistryAccess registryAccess) {
+ Map<ResourceLocation, RecipeHolder<?>> typeRecipes = manager.recipes.get(type);
+ Map<ResourceLocation, RecipeHolder<?>> typeRecipes = manager.byName; // Leaves - hopper counter
+ if (typeRecipes == null) {
+ return Collections.emptyList();
+ }
Expand Down
2 changes: 1 addition & 1 deletion patches/server/0130-Vanilla-hopper.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Vanilla hopper
This is a temporary solution designed to attempt to restore the vanilla behavior of the funnel while preserving optimizations as much as possible. It should ultimately be replaced by the optimization solution provided by lithium.

diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index 1668b62910bb18adaeb54ba49119553d69bb2812..030d2da3408543ecbecd67e08ec44f51b7d32ef5 100644
index f2fde04a6cb56c0c54edd8d48026f200a415d589..3220250073ec05c43da0f2830008652539ef3cf6 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -290,36 +290,49 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
Expand Down

0 comments on commit d91185d

Please sign in to comment.