Skip to content

Commit

Permalink
Move translation string back to non vanilla and move hat to vanilla
Browse files Browse the repository at this point in the history
  • Loading branch information
eclipseisoffline committed May 11, 2024
1 parent 965d11c commit 72da5a5
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,6 @@ public interface CustomItemData {
*/
@Nullable String toolTier();

/**
* Gets the item's translation string.
*
* @return the item's translation string
*/
@Nullable String translationString();

/**
* Gets the armor type of the item.
*
Expand All @@ -179,6 +172,14 @@ public interface CustomItemData {
*/
int protectionValue();

/**
* Gets if the item is a hat. This is used to determine if the item should be rendered on the player's head, and
* normally allow the player to equip it. This is not meant for armor.
*
* @return if the item is a hat
*/
boolean isHat();

/**
* Gets if the item is a foil. This is used to determine if the item should be rendered with an enchantment glint effect.
*
Expand Down Expand Up @@ -255,7 +256,7 @@ interface Builder {

Builder protectionValue(int protectionValue);

Builder translationString(@Nullable String translationString);
Builder hat(boolean isHat);

Builder foil(boolean isFoil);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,18 @@ public interface NonVanillaCustomItemData extends CustomItemData {
@NonNegative int javaId();

/**
* Gets the repair materials of the item.
* Gets the item's translation string.
*
* @return the repair materials of the item
* @return the item's translation string
*/
@Nullable Set<String> repairMaterials();
@Nullable String translationString();

/**
* Gets if the item is a hat. This is used to determine if the item should be rendered on the player's head, and
* normally allow the player to equip it. This is not meant for armor.
* Gets the repair materials of the item.
*
* @return if the item is a hat
* @return the repair materials of the item
*/
boolean isHat();
@Nullable Set<String> repairMaterials();

/**
* Gets if the item is chargable, like a bow.
Expand Down Expand Up @@ -91,9 +90,9 @@ interface Builder extends CustomItemData.Builder {

Builder javaId(@NonNegative int javaId);

Builder repairMaterials(@Nullable Set<String> repairMaterials);
Builder translationString(@Nullable String translationString);

Builder hat(boolean isHat);
Builder repairMaterials(@Nullable Set<String> repairMaterials);

Builder chargeable(boolean isChargeable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public class GeyserCustomItemData implements CustomItemData {
private final int attackDamage;
private final String toolType;
private final String toolTier;
private final String translationString;
private final String armorType;
private final int protectionValue;
private final boolean isHat;
private final boolean isFoil;
private final boolean isEdible;
private final boolean canAlwaysEat;
Expand All @@ -81,9 +81,9 @@ public GeyserCustomItemData(Builder builder) {
this.attackDamage = builder.attackDamage;
this.toolType = builder.toolType;
this.toolTier = builder.toolTier;
this.translationString = builder.translationString;
this.armorType = builder.armorType;
this.protectionValue = builder.protectionValue;
this.isHat = builder.hat;
this.isFoil = builder.foil;
this.isEdible = builder.edible;
this.canAlwaysEat = builder.canAlwaysEat;
Expand Down Expand Up @@ -180,8 +180,8 @@ public int protectionValue() {
}

@Override
public String translationString() {
return translationString;
public boolean isHat() {
return isHat;
}

@Override
Expand Down Expand Up @@ -218,7 +218,7 @@ public static class Builder implements CustomItemData.Builder {
private String toolTier = null;
private String armorType = null;
private int protectionValue = 0;
private String translationString;
private boolean hat = false;
private boolean foil = false;
private boolean edible = false;
private boolean canAlwaysEat = false;
Expand Down Expand Up @@ -332,8 +332,8 @@ public Builder protectionValue(int protectionValue) {
}

@Override
public Builder translationString(@Nullable String translationString) {
this.translationString = translationString;
public Builder hat(boolean isHat) {
this.hat = isHat;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData implements NonVanillaCustomItemData {
private final String identifier;
private final int javaId;
private final String translationString;
private final Set<String> repairMaterials;
private final boolean isHat;
private final boolean isChargeable;
private final String block;

Expand All @@ -50,8 +50,8 @@ public GeyserNonVanillaCustomItemData(Builder builder) {

this.identifier = builder.identifier;
this.javaId = builder.javaId;
this.translationString = builder.translationString;
this.repairMaterials = builder.repairMaterials;
this.isHat = builder.hat;
this.isChargeable = builder.chargeable;
this.block = builder.block;
}
Expand All @@ -67,13 +67,13 @@ public int javaId() {
}

@Override
public Set<String> repairMaterials() {
return repairMaterials;
public String translationString() {
return translationString;
}

@Override
public boolean isHat() {
return isHat;
public Set<String> repairMaterials() {
return repairMaterials;
}

@Override
Expand All @@ -89,8 +89,8 @@ public String block() {
public static class Builder extends GeyserCustomItemData.Builder implements NonVanillaCustomItemData.Builder {
private String identifier = null;
private int javaId = -1;
private String translationString;
private Set<String> repairMaterials;
private boolean hat = false;
private boolean chargeable = false;
private String block = null;

Expand Down Expand Up @@ -152,6 +152,12 @@ public Builder javaId(int javaId) {
return this;
}

@Override
public Builder translationString(@Nullable String translationString) {
this.translationString = translationString;
return this;
}

@Override
public Builder repairMaterials(@Nullable Set<String> repairMaterials) {
this.repairMaterials = repairMaterials;
Expand All @@ -168,12 +174,6 @@ public Builder creativeGroup(@Nullable String creativeGroup) {
return (Builder) super.creativeGroup(creativeGroup);
}

@Override
public Builder hat(boolean isHat) {
this.hat = isHat;
return this;
}

@Override
public Builder chargeable(boolean isChargeable) {
this.chargeable = isChargeable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public boolean isValidRepairItem(Item other) {
.build();

NbtMapBuilder builder = createComponentNbt(customItemData, customItemData.identifier(), customItemId,
customItemData.isHat(), customItemData.displayHandheld(), protocolVersion);
customItemData.displayHandheld(), protocolVersion);
ComponentItemData componentItemData = new ComponentItemData(customIdentifier, builder.build());

return new NonVanillaItemRegistration(componentItemData, item, customItemMapping);
Expand Down Expand Up @@ -226,7 +226,7 @@ private static NbtMapBuilder createComponentNbt(CustomItemData customItemData, I
computeThrowableProperties(componentBuilder);
}

computeRenderOffsets(false, customItemData, componentBuilder);
computeRenderOffsets(customItemData.isHat(), customItemData, componentBuilder);

componentBuilder.putCompound("item_properties", itemProperties.build());
builder.putCompound("components", componentBuilder.build());
Expand All @@ -235,7 +235,7 @@ private static NbtMapBuilder createComponentNbt(CustomItemData customItemData, I
}

private static NbtMapBuilder createComponentNbt(NonVanillaCustomItemData customItemData, String customItemName,
int customItemId, boolean isHat, boolean displayHandheld, int protocolVersion) {
int customItemId, boolean displayHandheld, int protocolVersion) {
NbtMapBuilder builder = NbtMap.builder();
builder.putString("name", customItemName)
.putInt("id", customItemId);
Expand Down Expand Up @@ -269,7 +269,7 @@ private static NbtMapBuilder createComponentNbt(NonVanillaCustomItemData customI
computeChargeableProperties(itemProperties, componentBuilder, "minecraft:" + tooltype, protocolVersion);
}

computeRenderOffsets(isHat, customItemData, componentBuilder);
computeRenderOffsets(customItemData.isHat(), customItemData, componentBuilder);

if (customItemData.isFoil()) {
itemProperties.putBoolean("foil", true);
Expand Down

0 comments on commit 72da5a5

Please sign in to comment.