Fixes crash exploit related to out of bounds Axolotl variants

This commit is contained in:
Video 2022-03-20 04:41:32 -06:00
parent 529a33f1be
commit ca57c181e4

View File

@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Sun, 20 Mar 2022 04:39:09 -0600
Subject: [PATCH] Fixes crash exploit related to out of bounds Axolotl variants
diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
index 2b8725087fd3bfeca7162bda2783fdacd13a8390..802c9c87df190dce09f9e703cedcb06874c58389 100644
--- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
+++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
@@ -118,7 +118,7 @@ public class Axolotl extends Animal implements LerpingModel, Bucketable {
@Override
public void readAdditionalSaveData(CompoundTag nbt) {
super.readAdditionalSaveData(nbt);
- this.setVariant(Axolotl.Variant.BY_ID[nbt.getInt("Variant")]);
+ this.setVariant(Axolotl.Variant.BY_ID[Math.min(Math.abs(nbt.getInt("Variant")), 4)]); // Scissors - Fixes out of bounds Axolotl variant exploit
this.setFromBucket(nbt.getBoolean("FromBucket"));
}
@@ -361,7 +361,7 @@ public class Axolotl extends Animal implements LerpingModel, Bucketable {
@Override
public void loadFromBucketTag(CompoundTag nbt) {
Bucketable.loadDefaultDataFromBucketTag(this, nbt);
- this.setVariant(Axolotl.Variant.BY_ID[nbt.getInt("Variant")]);
+ this.setVariant(Axolotl.Variant.BY_ID[Math.min(Math.abs(nbt.getInt("Variant")), 4)]); // Scissors - Fix out-of-bounds Axolotl variant exploit
if (nbt.contains("Age")) {
this.setAge(nbt.getInt("Age"));
}