Skip to content

Commit de95eb5

Browse files
Bye bye render offsets
1 parent 3fff601 commit de95eb5

File tree

4 files changed

+2
-69
lines changed

4 files changed

+2
-69
lines changed

api/src/main/java/org/geysermc/geyser/api/item/custom/CustomItemData.java

-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ default CustomItemDefinition.Builder toDefinition(Identifier javaItem) {
140140
.displayHandheld(displayHandheld())
141141
.creativeCategory(creativeCategory().isEmpty() ? CreativeCategory.NONE : CreativeCategory.values()[creativeCategory().getAsInt()])
142142
.creativeGroup(creativeGroup())
143-
.textureSize(textureSize())
144-
.renderOffsets(renderOffsets())
145143
.tags(tags())
146144
);
147145

api/src/main/java/org/geysermc/geyser/api/item/custom/v2/CustomItemBedrockOptions.java

-25
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,6 @@ public interface CustomItemBedrockOptions {
8787
@Nullable
8888
String creativeGroup();
8989

90-
/**
91-
* Gets the item's texture size. This is to resize the item if the texture is not 16x16.
92-
*
93-
* @deprecated resizing is done with render offsets, which are deprecated in favour of attachables.
94-
* @return the item's texture size
95-
*/
96-
@Deprecated
97-
int textureSize();
98-
99-
/**
100-
* Gets the item's render offsets. If it is null, the item will be rendered normally, with no offsets.
101-
*
102-
* @deprecated attachables are now preferred instead of using render offsets.
103-
* @return the item's render offsets
104-
*/
105-
@Nullable
106-
@Deprecated
107-
CustomRenderOffsets renderOffsets();
108-
10990
/**
11091
* Gets the item's set of tags that can be used in Molang.
11192
* Equivalent to "tag:some_tag"
@@ -133,12 +114,6 @@ interface Builder {
133114

134115
Builder creativeGroup(@Nullable String creativeGroup);
135116

136-
@Deprecated
137-
Builder textureSize(int textureSize);
138-
139-
@Deprecated
140-
Builder renderOffsets(@Nullable CustomRenderOffsets renderOffsets);
141-
142117
Builder tags(@Nullable Set<String> tags);
143118

144119
CustomItemBedrockOptions build();

core/src/main/java/org/geysermc/geyser/item/custom/GeyserCustomItemBedrockOptions.java

+2-19
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
import java.util.Set;
3737

3838
public record GeyserCustomItemBedrockOptions(@Nullable String icon, boolean allowOffhand, boolean displayHandheld, int protectionValue,
39-
@NonNull CreativeCategory creativeCategory, @Nullable String creativeGroup,
40-
int textureSize, @Nullable CustomRenderOffsets renderOffsets, @NonNull Set<String> tags) implements CustomItemBedrockOptions {
39+
@NonNull CreativeCategory creativeCategory, @Nullable String creativeGroup, @NonNull Set<String> tags) implements CustomItemBedrockOptions {
4140

4241
public static class Builder implements CustomItemBedrockOptions.Builder {
4342
private String icon = null;
@@ -46,8 +45,6 @@ public static class Builder implements CustomItemBedrockOptions.Builder {
4645
private int protectionValue = 0;
4746
private CreativeCategory creativeCategory = CreativeCategory.NONE;
4847
private String creativeGroup = null;
49-
private int textureSize = 16;
50-
private CustomRenderOffsets renderOffsets = null;
5148
private Set<String> tags = new HashSet<>();
5249

5350
@Override
@@ -86,20 +83,6 @@ public Builder creativeGroup(@Nullable String creativeGroup) {
8683
return this;
8784
}
8885

89-
@Override
90-
@Deprecated
91-
public Builder textureSize(int textureSize) {
92-
this.textureSize = textureSize;
93-
return this;
94-
}
95-
96-
@Override
97-
@Deprecated
98-
public Builder renderOffsets(@Nullable CustomRenderOffsets renderOffsets) {
99-
this.renderOffsets = renderOffsets;
100-
return this;
101-
}
102-
10386
@Override
10487
public Builder tags(@Nullable Set<String> tags) {
10588
this.tags = Objects.requireNonNullElseGet(tags, Set::of);
@@ -109,7 +92,7 @@ public Builder tags(@Nullable Set<String> tags) {
10992
@Override
11093
public CustomItemBedrockOptions build() {
11194
return new GeyserCustomItemBedrockOptions(icon, allowOffhand, displayHandheld, protectionValue,
112-
creativeCategory, creativeGroup, textureSize, renderOffsets, tags);
95+
creativeCategory, creativeGroup, tags);
11396
}
11497
}
11598
}

core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java

-23
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,6 @@ private static NbtMapBuilder createComponentNbt(CustomItemDefinition customItemD
286286
computeUseCooldownProperties(useCooldown, componentBuilder);
287287
}
288288

289-
computeRenderOffsets(customItemDefinition.bedrockOptions(), componentBuilder);
290-
291289
componentBuilder.putCompound("item_properties", itemProperties.build());
292290
builder.putCompound("components", componentBuilder.build());
293291

@@ -560,27 +558,6 @@ private static void computeUseCooldownProperties(UseCooldown cooldown, NbtMapBui
560558
);
561559
}
562560

563-
private static void computeRenderOffsets(CustomItemBedrockOptions bedrockOptions, NbtMapBuilder componentBuilder) {
564-
// TODO remove this one day when, probably when removing the old format, as render offsets are deprecated
565-
CustomRenderOffsets renderOffsets = bedrockOptions.renderOffsets();
566-
if (renderOffsets != null) {
567-
componentBuilder.remove("minecraft:render_offsets");
568-
componentBuilder.putCompound("minecraft:render_offsets", toNbtMap(renderOffsets));
569-
} else if (bedrockOptions.textureSize() != 16 && !componentBuilder.containsKey("minecraft:render_offsets")) {
570-
float scale1 = (float) (0.075 / (bedrockOptions.textureSize() / 16f));
571-
float scale2 = (float) (0.125 / (bedrockOptions.textureSize() / 16f));
572-
float scale3 = (float) (0.075 / (bedrockOptions.textureSize() / 16f * 2.4f));
573-
574-
componentBuilder.putCompound("minecraft:render_offsets",
575-
NbtMap.builder().putCompound("main_hand", NbtMap.builder()
576-
.putCompound("first_person", xyzToScaleList(scale3, scale3, scale3))
577-
.putCompound("third_person", xyzToScaleList(scale1, scale2, scale1)).build())
578-
.putCompound("off_hand", NbtMap.builder()
579-
.putCompound("first_person", xyzToScaleList(scale1, scale2, scale1))
580-
.putCompound("third_person", xyzToScaleList(scale1, scale2, scale1)).build()).build());
581-
}
582-
}
583-
584561
private static NbtMap toNbtMap(CustomRenderOffsets renderOffsets) {
585562
NbtMapBuilder builder = NbtMap.builder();
586563

0 commit comments

Comments
 (0)