@@ -54,7 +54,7 @@ public void tick() {
54
54
this .ticksToCheck = 20 ;
55
55
if (this .icon != null ) {
56
56
if (this .entity .level .isClientSide ) {
57
- this .clientHasIconResource = ClientSpottingIconMethods .hasTexture (this .icon .getTexture ());
57
+ this .clientHasIconResource = ClientSpottingIconMethods .hasTexture (this .icon .texture ());
58
58
}
59
59
if (!SpottingIconPredicate .getPredicate (this .icon .restrictionID ).test (this .entity )) {
60
60
this .removeIcon ();
@@ -76,7 +76,7 @@ public void setIcon(ResourceLocation texture, float startFade, float endFade, Re
76
76
ServerPlayNetworking .send (player , FrozenMain .SPOTTING_ICON_PACKET , byteBuf );
77
77
}
78
78
} else {
79
- this .clientHasIconResource = ClientSpottingIconMethods .hasTexture (this .icon .getTexture ());
79
+ this .clientHasIconResource = ClientSpottingIconMethods .hasTexture (this .icon .texture ());
80
80
}
81
81
SpottingIconPredicate .getPredicate (this .icon .restrictionID ).onAdded (this .entity );
82
82
}
@@ -106,7 +106,7 @@ public void sendIconPacket(ServerPlayer player) {
106
106
}
107
107
108
108
public void load (CompoundTag nbt ) {
109
- nbt .putInt ("frozenSpottingIconTicksToCheck" , this . ticksToCheck );
109
+ this . ticksToCheck = nbt .getInt ("frozenSpottingIconTicksToCheck" );
110
110
if (nbt .contains ("frozenSpottingIcons" )) {
111
111
this .icon = null ;
112
112
DataResult <SpottingIcon > var10000 = SpottingIcon .CODEC .parse (new Dynamic <>(NbtOps .INSTANCE , nbt .getCompound ("frozenSpottingIcons" )));
@@ -118,7 +118,7 @@ public void load(CompoundTag nbt) {
118
118
}
119
119
120
120
public void save (CompoundTag nbt ) {
121
- this . ticksToCheck = nbt .getInt ("frozenSpottingIconTicksToCheck" );
121
+ nbt .putInt ("frozenSpottingIconTicksToCheck" , this . ticksToCheck );
122
122
if (this .icon != null ) {
123
123
DataResult <Tag > var10000 = SpottingIcon .CODEC .encodeStart (NbtOps .INSTANCE , this .icon );
124
124
Logger var10001 = FrozenMain .LOGGER4 ;
@@ -129,40 +129,12 @@ public void save(CompoundTag nbt) {
129
129
}
130
130
}
131
131
132
- public static class SpottingIcon {
133
- public final ResourceLocation texture ;
134
- public final float startFadeDist ;
135
- public final float endFadeDist ;
136
- public final ResourceLocation restrictionID ;
137
-
138
- public static final Codec <SpottingIcon > CODEC = RecordCodecBuilder .create ((instance ) -> instance .group (
139
- ResourceLocation .CODEC .fieldOf ("texture" ).forGetter (SpottingIcon ::getTexture ),
140
- Codec .FLOAT .fieldOf ("startFadeDist" ).forGetter (SpottingIcon ::getStartFadeDist ),
141
- Codec .FLOAT .fieldOf ("endFadeDist" ).forGetter (SpottingIcon ::getEndFadeDist ),
142
- ResourceLocation .CODEC .fieldOf ("restrictionID" ).forGetter (SpottingIcon ::getRestrictionID )
143
- ).apply (instance , SpottingIcon ::new ));
144
-
145
- public SpottingIcon (ResourceLocation texture , float startFadeDist , float endFadeDist , ResourceLocation restrictionID ) {
146
- this .texture = texture ;
147
- this .startFadeDist = startFadeDist ;
148
- this .endFadeDist = endFadeDist ;
149
- this .restrictionID = restrictionID ;
150
- }
151
-
152
- public ResourceLocation getTexture () {
153
- return this .texture ;
154
- }
155
-
156
- public float getStartFadeDist () {
157
- return this .startFadeDist ;
158
- }
159
-
160
- public float getEndFadeDist () {
161
- return this .endFadeDist ;
162
- }
163
-
164
- public ResourceLocation getRestrictionID () {
165
- return this .restrictionID ;
166
- }
132
+ public record SpottingIcon (ResourceLocation texture , float startFadeDist , float endFadeDist , ResourceLocation restrictionID ) {
133
+ public static final Codec <SpottingIcon > CODEC = RecordCodecBuilder .create ((instance ) -> instance .group (
134
+ ResourceLocation .CODEC .fieldOf ("texture" ).forGetter (SpottingIcon ::texture ),
135
+ Codec .FLOAT .fieldOf ("startFadeDist" ).forGetter (SpottingIcon ::startFadeDist ),
136
+ Codec .FLOAT .fieldOf ("endFadeDist" ).forGetter (SpottingIcon ::endFadeDist ),
137
+ ResourceLocation .CODEC .fieldOf ("restrictionID" ).forGetter (SpottingIcon ::restrictionID )
138
+ ).apply (instance , SpottingIcon ::new ));
167
139
}
168
140
}
0 commit comments