mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Update implementations
This commit is contained in:
parent
e6c9c519c9
commit
9cd847e1e9
2 changed files with 157 additions and 178 deletions
|
@ -37,6 +37,7 @@ import java.util.HashSet;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.geysermc.geyser.api.item.custom.NonVanillaCustomItemData;
|
||||||
|
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@ToString
|
@ToString
|
||||||
|
@ -52,29 +53,39 @@ public class GeyserCustomItemData implements CustomItemData {
|
||||||
private final int textureSize;
|
private final int textureSize;
|
||||||
private final CustomRenderOffsets renderOffsets;
|
private final CustomRenderOffsets renderOffsets;
|
||||||
private final Set<String> tags;
|
private final Set<String> tags;
|
||||||
|
private final int stackSize;
|
||||||
|
private final int maxDamage;
|
||||||
|
private final int attackDamage;
|
||||||
|
private final String toolType;
|
||||||
|
private final String toolTier;
|
||||||
|
private final String translationString;
|
||||||
|
private final int protectionValue;
|
||||||
|
private final boolean isFoil;
|
||||||
|
private final boolean isEdible;
|
||||||
|
private final boolean canAlwaysEat;
|
||||||
|
|
||||||
public GeyserCustomItemData(String name,
|
public GeyserCustomItemData(Builder builder) {
|
||||||
CustomItemOptions customItemOptions,
|
this.name = builder.name;
|
||||||
String displayName,
|
this.customItemOptions = builder.customItemOptions;
|
||||||
String icon,
|
this.displayName = builder.displayName;
|
||||||
boolean allowOffhand,
|
this.icon = builder.icon;
|
||||||
boolean displayHandheld,
|
this.allowOffhand = builder.allowOffhand;
|
||||||
OptionalInt creativeCategory,
|
this.displayHandheld = builder.displayHandheld;
|
||||||
String creativeGroup,
|
this.creativeCategory = builder.creativeCategory;
|
||||||
int textureSize,
|
this.creativeGroup = builder.creativeGroup;
|
||||||
CustomRenderOffsets renderOffsets,
|
this.textureSize = builder.textureSize;
|
||||||
Set<String> tags) {
|
this.renderOffsets = builder.renderOffsets;
|
||||||
this.name = name;
|
this.tags = builder.tags;
|
||||||
this.customItemOptions = customItemOptions;
|
this.stackSize = builder.stackSize;
|
||||||
this.displayName = displayName;
|
this.maxDamage = builder.maxDamage;
|
||||||
this.icon = icon;
|
this.attackDamage = builder.attackDamage;
|
||||||
this.allowOffhand = allowOffhand;
|
this.toolType = builder.toolType;
|
||||||
this.displayHandheld = displayHandheld;
|
this.toolTier = builder.toolTier;
|
||||||
this.creativeCategory = creativeCategory;
|
this.translationString = builder.translationString;
|
||||||
this.creativeGroup = creativeGroup;
|
this.protectionValue = builder.protectionValue;
|
||||||
this.textureSize = textureSize;
|
this.isFoil = builder.foil;
|
||||||
this.renderOffsets = renderOffsets;
|
this.isEdible = builder.edible;
|
||||||
this.tags = tags;
|
this.canAlwaysEat = builder.canAlwaysEat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -132,6 +143,56 @@ public class GeyserCustomItemData implements CustomItemData {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int stackSize() {
|
||||||
|
return stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int maxDamage() {
|
||||||
|
return maxDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int attackDamage() {
|
||||||
|
return attackDamage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toolType() {
|
||||||
|
return toolType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toolTier() {
|
||||||
|
return toolTier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int protectionValue() {
|
||||||
|
return protectionValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String translationString() {
|
||||||
|
return translationString;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFoil() {
|
||||||
|
return isFoil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEdible() {
|
||||||
|
return isEdible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canAlwaysEat() {
|
||||||
|
return canAlwaysEat;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Builder implements CustomItemData.Builder {
|
public static class Builder implements CustomItemData.Builder {
|
||||||
protected String name = null;
|
protected String name = null;
|
||||||
protected CustomItemOptions customItemOptions = null;
|
protected CustomItemOptions customItemOptions = null;
|
||||||
|
@ -144,6 +205,17 @@ public class GeyserCustomItemData implements CustomItemData {
|
||||||
protected int textureSize = 16;
|
protected int textureSize = 16;
|
||||||
protected CustomRenderOffsets renderOffsets = null;
|
protected CustomRenderOffsets renderOffsets = null;
|
||||||
protected Set<String> tags = new HashSet<>();
|
protected Set<String> tags = new HashSet<>();
|
||||||
|
private int stackSize = 64;
|
||||||
|
private int maxDamage = 0;
|
||||||
|
private int attackDamage = 0;
|
||||||
|
private String toolType = null;
|
||||||
|
private String toolTier = null;
|
||||||
|
private int protectionValue = 0;
|
||||||
|
private String translationString;
|
||||||
|
private boolean foil = false;
|
||||||
|
private boolean tool = false;
|
||||||
|
private boolean edible = false;
|
||||||
|
private boolean canAlwaysEat = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder name(@NonNull String name) {
|
public Builder name(@NonNull String name) {
|
||||||
|
@ -211,6 +283,66 @@ public class GeyserCustomItemData implements CustomItemData {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder stackSize(int stackSize) {
|
||||||
|
this.stackSize = stackSize;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder maxDamage(int maxDamage) {
|
||||||
|
this.maxDamage = maxDamage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder attackDamage(int attackDamage) {
|
||||||
|
this.attackDamage = attackDamage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toolType(@Nullable String toolType) {
|
||||||
|
this.toolType = toolType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toolTier(@Nullable String toolTier) {
|
||||||
|
this.toolTier = toolTier;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder protectionValue(int protectionValue) {
|
||||||
|
this.protectionValue = protectionValue;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder translationString(@Nullable String translationString) {
|
||||||
|
this.translationString = translationString;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder foil(boolean isFoil) {
|
||||||
|
this.foil = isFoil;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder edible(boolean isEdible) {
|
||||||
|
this.edible = isEdible;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder canAlwaysEat(boolean canAlwaysEat) {
|
||||||
|
this.canAlwaysEat = canAlwaysEat;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomItemData build() {
|
public CustomItemData build() {
|
||||||
if (this.name == null || this.customItemOptions == null) {
|
if (this.name == null || this.customItemOptions == null) {
|
||||||
|
@ -223,8 +355,8 @@ public class GeyserCustomItemData implements CustomItemData {
|
||||||
if (this.icon == null) {
|
if (this.icon == null) {
|
||||||
this.icon = this.name;
|
this.icon = this.name;
|
||||||
}
|
}
|
||||||
return new GeyserCustomItemData(this.name, this.customItemOptions, this.displayName, this.icon, this.allowOffhand,
|
|
||||||
this.displayHandheld, this.creativeCategory, this.creativeGroup, this.textureSize, this.renderOffsets, this.tags);
|
return new GeyserCustomItemData(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,44 +40,20 @@ import java.util.Set;
|
||||||
public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData implements NonVanillaCustomItemData {
|
public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData implements NonVanillaCustomItemData {
|
||||||
private final String identifier;
|
private final String identifier;
|
||||||
private final int javaId;
|
private final int javaId;
|
||||||
private final int stackSize;
|
|
||||||
private final int maxDamage;
|
|
||||||
private final int attackDamage;
|
|
||||||
private final String toolType;
|
|
||||||
private final String toolTier;
|
|
||||||
private final String armorType;
|
private final String armorType;
|
||||||
private final int protectionValue;
|
|
||||||
private final String translationString;
|
|
||||||
private final Set<String> repairMaterials;
|
private final Set<String> repairMaterials;
|
||||||
private final boolean isHat;
|
private final boolean isHat;
|
||||||
private final boolean isFoil;
|
|
||||||
private final boolean isTool;
|
|
||||||
private final boolean isEdible;
|
|
||||||
private final boolean canAlwaysEat;
|
|
||||||
private final boolean isChargeable;
|
private final boolean isChargeable;
|
||||||
private final String block;
|
private final String block;
|
||||||
|
|
||||||
public GeyserNonVanillaCustomItemData(Builder builder) {
|
public GeyserNonVanillaCustomItemData(Builder builder) {
|
||||||
super(builder.name, builder.customItemOptions, builder.displayName, builder.icon, builder.allowOffhand,
|
super(builder);
|
||||||
builder.displayHandheld, builder.creativeCategory, builder.creativeGroup,
|
|
||||||
builder.textureSize, builder.renderOffsets, builder.tags);
|
|
||||||
|
|
||||||
this.identifier = builder.identifier;
|
this.identifier = builder.identifier;
|
||||||
this.javaId = builder.javaId;
|
this.javaId = builder.javaId;
|
||||||
this.stackSize = builder.stackSize;
|
|
||||||
this.maxDamage = builder.maxDamage;
|
|
||||||
this.attackDamage = builder.attackDamage;
|
|
||||||
this.toolType = builder.toolType;
|
|
||||||
this.toolTier = builder.toolTier;
|
|
||||||
this.armorType = builder.armorType;
|
this.armorType = builder.armorType;
|
||||||
this.protectionValue = builder.protectionValue;
|
|
||||||
this.translationString = builder.translationString;
|
|
||||||
this.repairMaterials = builder.repairMaterials;
|
this.repairMaterials = builder.repairMaterials;
|
||||||
this.isHat = builder.hat;
|
this.isHat = builder.hat;
|
||||||
this.isFoil = builder.foil;
|
|
||||||
this.isTool = builder.tool;
|
|
||||||
this.isEdible = builder.edible;
|
|
||||||
this.canAlwaysEat = builder.canAlwaysEat;
|
|
||||||
this.isChargeable = builder.chargeable;
|
this.isChargeable = builder.chargeable;
|
||||||
this.block = builder.block;
|
this.block = builder.block;
|
||||||
}
|
}
|
||||||
|
@ -92,46 +68,11 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||||
return javaId;
|
return javaId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int stackSize() {
|
|
||||||
return stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int maxDamage() {
|
|
||||||
return maxDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int attackDamage() {
|
|
||||||
return attackDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toolType() {
|
|
||||||
return toolType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toolTier() {
|
|
||||||
return toolTier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable String armorType() {
|
public @Nullable String armorType() {
|
||||||
return armorType;
|
return armorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int protectionValue() {
|
|
||||||
return protectionValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String translationString() {
|
|
||||||
return translationString;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> repairMaterials() {
|
public Set<String> repairMaterials() {
|
||||||
return repairMaterials;
|
return repairMaterials;
|
||||||
|
@ -142,21 +83,6 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||||
return isHat;
|
return isHat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFoil() {
|
|
||||||
return isFoil;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEdible() {
|
|
||||||
return isEdible;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canAlwaysEat() {
|
|
||||||
return canAlwaysEat;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChargeable() {
|
public boolean isChargeable() {
|
||||||
return isChargeable;
|
return isChargeable;
|
||||||
|
@ -170,28 +96,9 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||||
public static class Builder extends GeyserCustomItemData.Builder implements NonVanillaCustomItemData.Builder {
|
public static class Builder extends GeyserCustomItemData.Builder implements NonVanillaCustomItemData.Builder {
|
||||||
private String identifier = null;
|
private String identifier = null;
|
||||||
private int javaId = -1;
|
private int javaId = -1;
|
||||||
|
|
||||||
private int stackSize = 64;
|
|
||||||
|
|
||||||
private int maxDamage = 0;
|
|
||||||
|
|
||||||
private int attackDamage = 0;
|
|
||||||
|
|
||||||
private String toolType = null;
|
|
||||||
private String toolTier = null;
|
|
||||||
|
|
||||||
private String armorType = null;
|
private String armorType = null;
|
||||||
private int protectionValue = 0;
|
|
||||||
|
|
||||||
private String translationString;
|
|
||||||
|
|
||||||
private Set<String> repairMaterials;
|
private Set<String> repairMaterials;
|
||||||
|
|
||||||
private boolean hat = false;
|
private boolean hat = false;
|
||||||
private boolean foil = false;
|
|
||||||
private boolean tool = false;
|
|
||||||
private boolean edible = false;
|
|
||||||
private boolean canAlwaysEat = false;
|
|
||||||
private boolean chargeable = false;
|
private boolean chargeable = false;
|
||||||
private String block = null;
|
private String block = null;
|
||||||
|
|
||||||
|
@ -253,54 +160,12 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Builder stackSize(int stackSize) {
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Builder maxDamage(int maxDamage) {
|
|
||||||
this.maxDamage = maxDamage;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NonVanillaCustomItemData.Builder attackDamage(int attackDamage) {
|
|
||||||
this.attackDamage = attackDamage;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Builder toolType(@Nullable String toolType) {
|
|
||||||
this.toolType = toolType;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Builder toolTier(@Nullable String toolTier) {
|
|
||||||
this.toolTier = toolTier;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder armorType(@Nullable String armorType) {
|
public Builder armorType(@Nullable String armorType) {
|
||||||
this.armorType = armorType;
|
this.armorType = armorType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Builder protectionValue(int protectionValue) {
|
|
||||||
this.protectionValue = protectionValue;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Builder translationString(@Nullable String translationString) {
|
|
||||||
this.translationString = translationString;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder repairMaterials(@Nullable Set<String> repairMaterials) {
|
public Builder repairMaterials(@Nullable Set<String> repairMaterials) {
|
||||||
this.repairMaterials = repairMaterials;
|
this.repairMaterials = repairMaterials;
|
||||||
|
@ -323,24 +188,6 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Builder foil(boolean isFoil) {
|
|
||||||
this.foil = isFoil;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Builder edible(boolean isEdible) {
|
|
||||||
this.edible = isEdible;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Builder canAlwaysEat(boolean canAlwaysEat) {
|
|
||||||
this.canAlwaysEat = canAlwaysEat;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder chargeable(boolean isChargeable) {
|
public Builder chargeable(boolean isChargeable) {
|
||||||
this.chargeable = isChargeable;
|
this.chargeable = isChargeable;
|
||||||
|
|
Loading…
Reference in a new issue