Use DefaultedList for equipment tracking
Because on 1.11+ a `null` item stack is not something that should exist. This then also allows us to compare item stacks by value rather than only by reference, potentially saving a few redundant entity equipment update packets (but more importantly, also allows us to store a copy instead of the original, which will be important for the next commit).
This commit is contained in:
@@ -15,6 +15,7 @@ import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.sound.PositionedSoundInstance;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.resource.Resource;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.text.LiteralText;
|
||||
@@ -49,6 +50,10 @@ import net.minecraft.client.util.Window;
|
||||
//$$ import net.minecraft.client.gui.GuiButton;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11100
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10904
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.crash.CrashCallable;
|
||||
@@ -669,4 +674,13 @@ class Patterns {
|
||||
return manager.getResource(id);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@Pattern
|
||||
private static List<ItemStack> DefaultedList_ofSize_ItemStack_Empty(int size) {
|
||||
//#if MC>=11100
|
||||
return DefaultedList.ofSize(size, ItemStack.EMPTY);
|
||||
//#else
|
||||
//$$ return java.util.Arrays.asList(new ItemStack[size]);
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user