Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-25 15:50:14 +01:00
Allow custom bows and food to be registered using the API (#3782)
Dieser Commit ist enthalten in:
Ursprung
551f159fc5
Commit
178fb2136f
@ -136,6 +136,27 @@ public interface NonVanillaCustomItemData extends CustomItemData {
|
||||
*/
|
||||
boolean isFoil();
|
||||
|
||||
/**
|
||||
* Gets if the item is edible.
|
||||
*
|
||||
* @return if the item is edible
|
||||
*/
|
||||
boolean isEdible();
|
||||
|
||||
/**
|
||||
* Gets if the food item can always be eaten.
|
||||
*
|
||||
* @return if the item is allowed to be eaten all the time
|
||||
*/
|
||||
boolean canAlwaysEat();
|
||||
|
||||
/**
|
||||
* Gets if the item is chargable, like a bow.
|
||||
*
|
||||
* @return if the item should act like a chargable item
|
||||
*/
|
||||
boolean isChargeable();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #displayHandheld()} instead.
|
||||
* Gets if the item is a tool. This is used to set the render type of the item, if the item is handheld.
|
||||
@ -183,6 +204,12 @@ public interface NonVanillaCustomItemData extends CustomItemData {
|
||||
|
||||
Builder foil(boolean isFoil);
|
||||
|
||||
Builder edible(boolean isEdible);
|
||||
|
||||
Builder canAlwaysEat(boolean canAlwaysEat);
|
||||
|
||||
Builder chargeable(boolean isChargeable);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #displayHandheld(boolean)} instead.
|
||||
*/
|
||||
|
@ -55,6 +55,9 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||
private final boolean isHat;
|
||||
private final boolean isFoil;
|
||||
private final boolean isTool;
|
||||
private final boolean isEdible;
|
||||
private final boolean canAlwaysEat;
|
||||
private final boolean isChargeable;
|
||||
|
||||
public GeyserNonVanillaCustomItemData(NonVanillaCustomItemDataBuilder builder) {
|
||||
super(builder.name, builder.customItemOptions, builder.displayName, builder.icon, builder.allowOffhand,
|
||||
@ -75,6 +78,9 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||
this.isHat = builder.hat;
|
||||
this.isFoil = builder.foil;
|
||||
this.isTool = builder.tool;
|
||||
this.isEdible = builder.edible;
|
||||
this.canAlwaysEat = builder.canAlwaysEat;
|
||||
this.isChargeable = builder.chargeable;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -147,6 +153,21 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||
return isFoil;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEdible() {
|
||||
return isEdible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAlwaysEat() {
|
||||
return canAlwaysEat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChargeable() {
|
||||
return isChargeable;
|
||||
}
|
||||
|
||||
public static class NonVanillaCustomItemDataBuilder extends GeyserCustomItemData.CustomItemDataBuilder implements NonVanillaCustomItemData.Builder {
|
||||
private String identifier = null;
|
||||
private int javaId = -1;
|
||||
@ -171,6 +192,9 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||
private boolean hat = false;
|
||||
private boolean foil = false;
|
||||
private boolean tool = false;
|
||||
private boolean edible = false;
|
||||
private boolean canAlwaysEat = false;
|
||||
private boolean chargeable = false;
|
||||
|
||||
@Override
|
||||
public NonVanillaCustomItemData.Builder name(@NonNull String name) {
|
||||
@ -297,6 +321,24 @@ public final class GeyserNonVanillaCustomItemData extends GeyserCustomItemData i
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonVanillaCustomItemData.Builder edible(boolean isEdible) {
|
||||
this.edible = isEdible;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonVanillaCustomItemData.Builder canAlwaysEat(boolean canAlwaysEat) {
|
||||
this.canAlwaysEat = canAlwaysEat;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonVanillaCustomItemData.Builder chargeable(boolean isChargeable) {
|
||||
this.chargeable = isChargeable;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonVanillaCustomItemData build() {
|
||||
if (identifier == null || javaId == -1) {
|
||||
|
@ -238,6 +238,14 @@ public class CustomItemRegistryPopulator {
|
||||
computeArmorProperties(armorType, customItemData.protectionValue(), componentBuilder);
|
||||
}
|
||||
|
||||
if (customItemData.isEdible()) {
|
||||
computeConsumableProperties(itemProperties, componentBuilder, 1, customItemData.canAlwaysEat());
|
||||
}
|
||||
|
||||
if (customItemData.isChargeable()) {
|
||||
computeChargeableProperties(itemProperties, componentBuilder);
|
||||
}
|
||||
|
||||
computeRenderOffsets(isHat, customItemData, componentBuilder);
|
||||
|
||||
if (creativeGroup != null) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren