mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-30 08:06:01 +00:00
Add a few more patches
This commit is contained in:
parent
400436d77a
commit
0d6eb6daef
@ -5,10 +5,10 @@ Subject: [PATCH] Limit ListTags to 1024 elements
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java
|
||||
index ea68b26e506e48d8238b7ee4266e61b211d52bd2..10d3a1b31233f884823ee9a4bb27d70eac3914df 100644
|
||||
index f346306d61854bdc6b395f5d8f799909537a1b50..fef39a78552188e90ebfcd608e7bf9e15c385bd1 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/ListTag.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/ListTag.java
|
||||
@@ -33,6 +33,7 @@ public class ListTag extends CollectionTag<Tag> {
|
||||
@@ -30,6 +30,7 @@ public class ListTag extends CollectionTag<Tag> {
|
||||
list.add(tagType.load(dataInput, i + 1, nbtAccounter));
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Mon, 11 Apr 2022 13:33:52 -0600
|
||||
Subject: [PATCH] Fixes creative-killing potion effects and certain potion
|
||||
effect overflows
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/effect/MobEffect.java b/src/main/java/net/minecraft/world/effect/MobEffect.java
|
||||
index 17ffab92f4ae2c06fa9f9249a474d4b6c9c55090..b2701b5779d9930e2cf6460b1e258cd80c4465f0 100644
|
||||
--- a/src/main/java/net/minecraft/world/effect/MobEffect.java
|
||||
+++ b/src/main/java/net/minecraft/world/effect/MobEffect.java
|
||||
@@ -59,6 +59,7 @@ public class MobEffect {
|
||||
}
|
||||
|
||||
public void applyEffectTick(LivingEntity entity, int amplifier) {
|
||||
+ boolean god = entity instanceof Player player && (player.isCreative() || player.isInvulnerable()); // Scissors
|
||||
if (this == MobEffects.REGENERATION) {
|
||||
if (entity.getHealth() < entity.getMaxHealth()) {
|
||||
entity.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
|
||||
@@ -87,17 +88,31 @@ public class MobEffect {
|
||||
// CraftBukkit end
|
||||
}
|
||||
} else if ((this != MobEffects.HEAL || entity.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entity.isInvertedHealAndHarm())) {
|
||||
- if (this == MobEffects.HARM && !entity.isInvertedHealAndHarm() || this == MobEffects.HEAL && entity.isInvertedHealAndHarm()) {
|
||||
+ // Scissors start
|
||||
+ amplifier = Math.min(Math.abs(amplifier), 124);
|
||||
+ if (!god && (this == MobEffects.HARM && !entity.isInvertedHealAndHarm() || this == MobEffects.HEAL && entity.isInvertedHealAndHarm())) {
|
||||
entity.hurt(DamageSource.MAGIC, (float) (6 << amplifier));
|
||||
}
|
||||
+ // Scissors end
|
||||
} else {
|
||||
- entity.heal((float) Math.max(4 << amplifier, 0), RegainReason.MAGIC); // CraftBukkit
|
||||
+ // Scissors start
|
||||
+ if (!god) {
|
||||
+ amplifier = Math.min(Math.abs(amplifier), 124);
|
||||
+ entity.heal((float) Math.max(4 << amplifier, 0), RegainReason.MAGIC); // CraftBukkit
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void applyInstantenousEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
||||
int j;
|
||||
+ // Scissors start - Don't apply any healing/harming effects for Creative/Invulnerable players and cap the amplifier for those who aren't.
|
||||
+ if (target instanceof Player player && (player.isCreative() || player.isInvulnerable())) {
|
||||
+ return;
|
||||
+ }
|
||||
+ amplifier = Math.min(Math.abs(amplifier), 124);
|
||||
+ // Scissors end
|
||||
|
||||
if ((this != MobEffects.HEAL || target.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !target.isInvertedHealAndHarm())) {
|
||||
if ((this != MobEffects.HARM || target.isInvertedHealAndHarm()) && (this != MobEffects.HEAL || !target.isInvertedHealAndHarm())) {
|
19
patches/server/0020-Fix-negative-death-times.patch
Normal file
19
patches/server/0020-Fix-negative-death-times.patch
Normal file
@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Fri, 3 Jun 2022 19:30:14 -0500
|
||||
Subject: [PATCH] Fix negative death times
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index e8dc99752d06ca40f17f3ad2c829b2447b703d7c..ac85b2444322d1f2bd5ccdc285443bfc1a4855ca 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -622,7 +622,7 @@ public abstract class LivingEntity extends Entity {
|
||||
|
||||
protected void tickDeath() {
|
||||
++this.deathTime;
|
||||
- if (this.deathTime == 20 && !this.level.isClientSide()) {
|
||||
+ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.level.isClientSide()) {
|
||||
this.level.broadcastEntityEvent(this, (byte) 60);
|
||||
this.remove(Entity.RemovalReason.KILLED);
|
||||
}
|
87
patches/server/0021-Reset-large-tags.patch
Normal file
87
patches/server/0021-Reset-large-tags.patch
Normal file
@ -0,0 +1,87 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Fri, 22 Apr 2022 01:56:03 -0500
|
||||
Subject: [PATCH] Reset large tags
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/totalfreedom/scissors/NbtUtility.java b/src/main/java/me/totalfreedom/scissors/NbtUtility.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fd408bd8bb0ad4a96abfbd5721fe4ecd7066297c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/NbtUtility.java
|
||||
@@ -0,0 +1,28 @@
|
||||
+package me.totalfreedom.scissors;
|
||||
+
|
||||
+import java.nio.charset.StandardCharsets;
|
||||
+import javax.annotation.Nullable;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+
|
||||
+public class NbtUtility
|
||||
+{
|
||||
+ public static boolean isTooLarge(@Nullable CompoundTag tag)
|
||||
+ {
|
||||
+ if (tag == null)
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ return tag.toString().getBytes(StandardCharsets.UTF_8).length > (256 * 1024);
|
||||
+ }
|
||||
+
|
||||
+ public static class Item
|
||||
+ {
|
||||
+ public static CompoundTag removeItemData(CompoundTag tag)
|
||||
+ {
|
||||
+ CompoundTag cleaned = new CompoundTag();
|
||||
+ cleaned.putString("id", tag.getString("id"));
|
||||
+ cleaned.putByte("Count", tag.getByte("Count"));
|
||||
+ return cleaned;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index 6b3cfc19c4fd1382ddf534265a1114995a4f6b55..10eb3261e215870997784751523e1609360f27ee 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -20,6 +20,7 @@ import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
@@ -251,6 +252,12 @@ public final class ItemStack {
|
||||
|
||||
// CraftBukkit - break into own method
|
||||
private void load(CompoundTag nbttagcompound) {
|
||||
+ // Scissors start - Reset large tags
|
||||
+ if (NbtUtility.isTooLarge(nbttagcompound)) {
|
||||
+ // Reset tag without destroying item
|
||||
+ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound);
|
||||
+ }
|
||||
+ // Scissors end
|
||||
this.item = (Item) Registry.ITEM.get(new ResourceLocation(nbttagcompound.getString("id")));
|
||||
this.count = nbttagcompound.getByte("Count");
|
||||
if (nbttagcompound.contains("tag", 10)) {
|
||||
@@ -682,6 +689,11 @@ public final class ItemStack {
|
||||
|
||||
itemstack.setPopTime(this.getPopTime());
|
||||
if (this.tag != null) {
|
||||
+ // Scissors start - Don't save large tags
|
||||
+ if (!NbtUtility.isTooLarge(this.tag)) {
|
||||
+ itemstack.tag.put("tag", this.tag.copy());
|
||||
+ }
|
||||
+ // Scissors end
|
||||
itemstack.tag = this.tag.copy();
|
||||
}
|
||||
|
||||
@@ -839,6 +851,9 @@ public final class ItemStack {
|
||||
// Paper end
|
||||
|
||||
public void setTag(@Nullable CompoundTag nbt) {
|
||||
+ // Scissors start - Ignore large tags
|
||||
+ if (NbtUtility.isTooLarge(nbt)) return;
|
||||
+ // Scissors end
|
||||
this.tag = nbt;
|
||||
this.processEnchantOrder(this.tag); // Paper
|
||||
if (this.getItem().canBeDepleted()) {
|
Loading…
Reference in New Issue
Block a user