Fix contains may not have title set.
This commit is contained in:
parent
08ab476f57
commit
fa9ec260ac
|
@ -15,10 +15,12 @@ import net.minecraft.inventory.CraftResultInventory;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.ClickType;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.server.SSetSlotPacket;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v.entity.CraftHumanEntity;
|
||||
|
@ -66,6 +68,8 @@ public abstract class ContainerMixin implements ContainerBridge {
|
|||
@Shadow public static boolean canAddItemToSlot(@Nullable Slot slotIn, ItemStack stack, boolean stackSizeMatters) { return false; }
|
||||
@Shadow public static void computeStackSize(Set<Slot> dragSlotsIn, int dragModeIn, ItemStack stack, int slotStackSize) { }
|
||||
@Shadow public static boolean areItemsAndTagsEqual(ItemStack stack1, ItemStack stack2) { return false; }
|
||||
@Shadow protected abstract boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection);
|
||||
@Shadow @Final @javax.annotation.Nullable private ContainerType<?> containerType;
|
||||
// @formatter:on
|
||||
|
||||
public boolean checkReachable = true;
|
||||
|
@ -135,7 +139,14 @@ public abstract class ContainerMixin implements ContainerBridge {
|
|||
private ITextComponent title;
|
||||
|
||||
public final ITextComponent getTitle() {
|
||||
Preconditions.checkState(this.title != null, "Title not set");
|
||||
if (this.title == null) {
|
||||
if (this.containerType != null && this.containerType.getRegistryName() != null) {
|
||||
this.title = new StringTextComponent(this.containerType.getRegistryName().toString());
|
||||
} else {
|
||||
this.title = new StringTextComponent(this.toString());
|
||||
}
|
||||
ArclightMod.LOGGER.warn("Container {}/{} has no title.", this, this.getClass().getName());
|
||||
}
|
||||
return this.title;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user