Spaces:
Build error
Build error
File size: 3,254 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
package net.minecraft.world.entity;
import io.netty.buffer.ByteBuf;
import java.util.List;
import java.util.function.IntFunction;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.util.ByIdMap;
import net.minecraft.util.StringRepresentable;
import net.minecraft.world.item.ItemStack;
public enum EquipmentSlot implements StringRepresentable {
MAINHAND(EquipmentSlot.Type.HAND, 0, 0, "mainhand"),
OFFHAND(EquipmentSlot.Type.HAND, 1, 5, "offhand"),
FEET(EquipmentSlot.Type.HUMANOID_ARMOR, 0, 1, 1, "feet"),
LEGS(EquipmentSlot.Type.HUMANOID_ARMOR, 1, 1, 2, "legs"),
CHEST(EquipmentSlot.Type.HUMANOID_ARMOR, 2, 1, 3, "chest"),
HEAD(EquipmentSlot.Type.HUMANOID_ARMOR, 3, 1, 4, "head"),
BODY(EquipmentSlot.Type.ANIMAL_ARMOR, 0, 1, 6, "body");
public static final int NO_COUNT_LIMIT = 0;
public static final List<EquipmentSlot> VALUES = List.of(values());
public static final IntFunction<EquipmentSlot> BY_ID = ByIdMap.continuous(p_362028_ -> p_362028_.id, values(), ByIdMap.OutOfBoundsStrategy.ZERO);
public static final StringRepresentable.EnumCodec<EquipmentSlot> CODEC = StringRepresentable.fromEnum(EquipmentSlot::values);
public static final StreamCodec<ByteBuf, EquipmentSlot> STREAM_CODEC = ByteBufCodecs.idMapper(BY_ID, p_365000_ -> p_365000_.id);
private final EquipmentSlot.Type type;
private final int index;
private final int countLimit;
private final int id;
private final String name;
private EquipmentSlot(final EquipmentSlot.Type p_342397_, final int p_343935_, final int p_343943_, final int p_345166_, final String p_345481_) {
this.type = p_342397_;
this.index = p_343935_;
this.countLimit = p_343943_;
this.id = p_345166_;
this.name = p_345481_;
}
private EquipmentSlot(final EquipmentSlot.Type p_20739_, final int p_20740_, final int p_20741_, final String p_20742_) {
this(p_20739_, p_20740_, 0, p_20741_, p_20742_);
}
public EquipmentSlot.Type getType() {
return this.type;
}
public int getIndex() {
return this.index;
}
public int getIndex(int p_147069_) {
return p_147069_ + this.index;
}
public ItemStack limit(ItemStack p_343527_) {
return this.countLimit > 0 ? p_343527_.split(this.countLimit) : p_343527_;
}
public int getId() {
return this.id;
}
public int getFilterBit(int p_367101_) {
return this.id + p_367101_;
}
public String getName() {
return this.name;
}
public boolean isArmor() {
return this.type == EquipmentSlot.Type.HUMANOID_ARMOR || this.type == EquipmentSlot.Type.ANIMAL_ARMOR;
}
@Override
public String getSerializedName() {
return this.name;
}
public static EquipmentSlot byName(String p_20748_) {
EquipmentSlot equipmentslot = CODEC.byName(p_20748_);
if (equipmentslot != null) {
return equipmentslot;
} else {
throw new IllegalArgumentException("Invalid slot '" + p_20748_ + "'");
}
}
public static enum Type {
HAND,
HUMANOID_ARMOR,
ANIMAL_ARMOR;
}
} |