Skip to content

Commit

Permalink
Fix linear and bow infinity fix
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Jun 23, 2024
1 parent 92f23ed commit adf56d0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
15 changes: 3 additions & 12 deletions patches/server/0095-Bow-infinity-fix.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,16 @@ Subject: [PATCH] Bow infinity fix


diff --git a/src/main/java/net/minecraft/world/item/BowItem.java b/src/main/java/net/minecraft/world/item/BowItem.java
index 6eb5c0f23d9dc61e69ad5ad493c89602a9dcd4b5..0b8a1c4ba8df45b0a162a468ff58357e048d43ca 100644
index 6eb5c0f23d9dc61e69ad5ad493c89602a9dcd4b5..7a5073539a451d31a89dc88e38468f141ef452cd 100644
--- a/src/main/java/net/minecraft/world/item/BowItem.java
+++ b/src/main/java/net/minecraft/world/item/BowItem.java
@@ -18,6 +18,8 @@ public class BowItem extends ProjectileWeaponItem {
public static final int MAX_DRAW_DURATION = 20;
public static final int DEFAULT_RANGE = 15;

+ private static final ItemStack EMPTY_ARROW = new ItemStack(Items.ARROW); // Leaves - Bow infinity fix
+
public BowItem(Item.Properties settings) {
super(settings);
}
@@ -81,7 +83,8 @@ public class BowItem extends ProjectileWeaponItem {
@@ -81,7 +81,8 @@ public class BowItem extends ProjectileWeaponItem {
@Override
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
ItemStack itemStack = user.getItemInHand(hand);
- boolean bl = !user.getProjectile(itemStack).isEmpty();
+ boolean bl = !user.getProjectile(itemStack).isEmpty()
+ || (org.leavesmc.leaves.LeavesConfig.bowInfinityFix && net.minecraft.world.item.enchantment.EnchantmentHelper.processAmmoUse((ServerLevel) world, itemStack, EMPTY_ARROW, 1) <= 0); // Leaves - Bow infinity fix
+ || (org.leavesmc.leaves.LeavesConfig.bowInfinityFix && net.minecraft.world.item.enchantment.EnchantmentHelper.processAmmoUse((ServerLevel) world, itemStack, new ItemStack(Items.ARROW), 1) <= 0); // Leaves - Bow infinity fix
if (!user.hasInfiniteMaterials() && !bl) {
return InteractionResultHolder.fail(itemStack);
} else {
20 changes: 19 additions & 1 deletion patches/server/0117-Linear-region-file-format.patch
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ index e761b63eebc1e76b2bb1cb887d83d0b63ad6ec90..2fefc69cc1df01a5ede2e5f2642adec6
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new InflaterInputStream(Files.newInputStream(file))))) {
return NbtIo.read((java.io.DataInput) out);
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
index 0615fd82b71efb9a397de01615050e6d906c2844..fd46492faadcccaaf5256ce37230ff07c22d682f 100644
index 0615fd82b71efb9a397de01615050e6d906c2844..1c83375beea629ebd78d7027fbba81f94f29f994 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -21,7 +21,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
Expand Down Expand Up @@ -188,6 +188,15 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..fd46492faadcccaaf5256ce37230ff07
if (ret != null) {
return ret;
}
@@ -98,7 +98,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise

FileUtil.createDirectoriesSafe(this.folder);

- ret = new RegionFile(this.info, regionPath, this.folder, this.sync);
+ ret = org.leavesmc.leaves.region.AbstractRegionFileFactory.getAbstractRegionFile(this.info, regionPath, this.folder, this.sync); // Leaves

this.regionCache.putAndMoveToFirst(key, ret);

@@ -112,7 +112,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
this.info = storageKey;
}
Expand All @@ -206,6 +215,15 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..fd46492faadcccaaf5256ce37230ff07
if (ret != null) {
return ret;
}
@@ -135,7 +135,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise

FileUtil.createDirectoriesSafe(this.folder);

- ret = new RegionFile(this.info, regionPath, this.folder, this.sync);
+ ret = org.leavesmc.leaves.region.AbstractRegionFileFactory.getAbstractRegionFile(this.info, regionPath, this.folder, this.sync); // Leaves

this.regionCache.putAndMoveToFirst(key, ret);

@@ -149,7 +149,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER - You may ask for help on Discord, but do not file an issue. These error messages can not be removed.");
}
Expand Down

0 comments on commit adf56d0

Please sign in to comment.