1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-28 03:09:08 +00:00

Mapping option for handheld display & fix for #3346 (#3672)

* Mapping option for handheld display and fix for #3346

* Fix custom items
This commit is contained in:
ImDaBigBoss
2023-04-11 20:32:31 +02:00
committed by GitHub
parent d22ee51633
commit 98dceee5e3
9 changed files with 106 additions and 26 deletions

View File

@@ -68,6 +68,13 @@ public interface CustomItemData {
*/
boolean allowOffhand();
/**
* Gets if the item should be displayed as handheld, like a tool.
*
* @return true if the item should be displayed as handheld, false otherwise
*/
boolean displayHandheld();
/**
* Gets the item's texture size. This is to resize the item if the texture is not 16x16.
*
@@ -100,6 +107,8 @@ public interface CustomItemData {
Builder allowOffhand(boolean allowOffhand);
Builder displayHandheld(boolean displayHandheld);
Builder textureSize(int textureSize);
Builder renderOffsets(@Nullable CustomRenderOffsets renderOffsets);

View File

@@ -56,6 +56,14 @@ public interface CustomItemOptions {
*/
@NonNull OptionalInt damagePredicate();
/**
* Gets if this mapping should just translate to the default item.
* This is used for the damage predicate of damaged 1 damage 0 that is required to allow the default item to exist.
*
* @return true if this mapping should just translate to the default item, false otherwise
*/
boolean defaultItem();
/**
* Checks if the item has at least one option set
*
@@ -78,6 +86,8 @@ public interface CustomItemOptions {
Builder damagePredicate(int damagePredicate);
Builder defaultItem(boolean defaultItem);
CustomItemOptions build();
}
}

View File

@@ -130,17 +130,22 @@ public interface NonVanillaCustomItemData extends CustomItemData {
boolean isHat();
/**
* @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.
*
* @return if the item is a tool
*/
boolean isTool();
@Deprecated
default boolean isTool() {
return displayHandheld();
}
static NonVanillaCustomItemData.Builder builder() {
return GeyserApi.api().provider(NonVanillaCustomItemData.Builder.class);
}
interface Builder extends CustomItemData.Builder {
@Override
Builder name(@NonNull String name);
Builder identifier(@NonNull String identifier);
@@ -169,14 +174,29 @@ public interface NonVanillaCustomItemData extends CustomItemData {
Builder hat(boolean isHat);
Builder tool(boolean isTool);
/**
* @deprecated Use {@link #displayHandheld(boolean)} instead.
*/
@Deprecated
default Builder tool(boolean isTool) {
return displayHandheld(isTool);
}
@Override
Builder customItemOptions(@NonNull CustomItemOptions customItemOptions);
@Override
Builder displayName(@NonNull String displayName);
@Override
Builder icon(@NonNull String icon);
@Override
Builder allowOffhand(boolean allowOffhand);
@Override
Builder displayHandheld(boolean displayHandheld);
@Override
Builder textureSize(int textureSize);