Skip to content

Commit e1477bb

Browse files
committed
Depricate MetaOffsetConverter untill further notice
1 parent debb91e commit e1477bb

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@
1414
import me.tofaa.entitylib.EntityLib;
1515
import me.tofaa.entitylib.extras.InvalidVersionException;
1616
import net.kyori.adventure.text.Component;
17-
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
1817
import org.jetbrains.annotations.NotNull;
1918
import org.jetbrains.annotations.Nullable;
2019

2120
import java.util.List;
22-
import java.util.Map;
2321
import java.util.Optional;
24-
import java.util.concurrent.ConcurrentHashMap;
2522
import java.util.function.BiFunction;
2623

27-
import static me.tofaa.entitylib.meta.MetaOffsetConverter.EntityMetaOffsets.*;
28-
2924
public class EntityMeta implements EntityMetadataProvider {
3025

3126
private static final MetaConverterRegistry registry = new MetaConverterRegistry();
@@ -145,60 +140,60 @@ public void setFlyingWithElytra(boolean value) {
145140
}
146141

147142
public short getAirTicks() {
148-
return this.metadata.getIndex(airTicksOffset(), (short) 300);
143+
return this.metadata.getIndex((byte)1, (short) 300);
149144
}
150145

151146
public void setAirTicks(short value) {
152-
this.metadata.setIndex(airTicksOffset(), EntityDataTypes.SHORT, value);
147+
this.metadata.setIndex((byte)1, EntityDataTypes.SHORT, value);
153148
}
154149

155150
public Component getCustomName() {
156-
Optional<Component> component = this.metadata.getIndex(customNameOffset(), Optional.empty());
151+
Optional<Component> component = this.metadata.getIndex((byte)2, Optional.empty());
157152
return component.orElse(null);
158153
}
159154

160155
public void setCustomName(Component value) {
161-
this.metadata.setIndex(customNameOffset(), EntityDataTypes.OPTIONAL_ADV_COMPONENT, Optional.ofNullable(value));
156+
this.metadata.setIndex((byte)2, EntityDataTypes.OPTIONAL_ADV_COMPONENT, Optional.ofNullable(value));
162157
}
163158

164159
public boolean isCustomNameVisible() {
165-
return this.metadata.getIndex(customNameVisibleOffset(), false);
160+
return this.metadata.getIndex((byte)3, false);
166161
}
167162

168163
public void setCustomNameVisible(boolean value) {
169-
this.metadata.setIndex(customNameVisibleOffset(), EntityDataTypes.BOOLEAN, value);
164+
this.metadata.setIndex((byte)3, EntityDataTypes.BOOLEAN, value);
170165
}
171166

172167
public boolean isSilent() {
173-
return this.metadata.getIndex(silentOffset(), false);
168+
return this.metadata.getIndex((byte)4, false);
174169
}
175170

176171
public void setSilent(boolean value) {
177-
this.metadata.setIndex(silentOffset(), EntityDataTypes.BOOLEAN, value);
172+
this.metadata.setIndex((byte)4, EntityDataTypes.BOOLEAN, value);
178173
}
179174

180175
public boolean hasNoGravity() {
181-
return this.metadata.getIndex(hasNoGravityOffset(), true);
176+
return this.metadata.getIndex((byte)5, true);
182177
}
183178

184179
public void setHasNoGravity(boolean value) {
185-
this.metadata.setIndex(hasNoGravityOffset(), EntityDataTypes.BOOLEAN, value);
180+
this.metadata.setIndex((byte)5, EntityDataTypes.BOOLEAN, value);
186181
}
187182

188183
public EntityPose getPose() {
189-
return this.metadata.getIndex(poseOffset(), EntityPose.STANDING);
184+
return this.metadata.getIndex((byte)6, EntityPose.STANDING);
190185
}
191186

192187
public void setPose(EntityPose value) {
193-
this.metadata.setIndex(poseOffset(), EntityDataTypes.ENTITY_POSE, value);
188+
this.metadata.setIndex((byte)6, EntityDataTypes.ENTITY_POSE, value);
194189
}
195190

196191
public int getTicksFrozenInPowderedSnow() {
197-
return this.metadata.getIndex(ticksFrozenInPowderedSnowOffset(), 0);
192+
return this.metadata.getIndex((byte)7, 0);
198193
}
199194

200195
public void setTicksFrozenInPowderedSnow(int value) {
201-
this.metadata.setIndex(ticksFrozenInPowderedSnowOffset(), EntityDataTypes.INT, value);
196+
this.metadata.setIndex((byte)7, EntityDataTypes.INT, value);
202197
}
203198

204199
public WrapperPlayServerEntityMetadata createPacket() {

api/src/main/java/me/tofaa/entitylib/meta/MetaOffsetConverter.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88

99
@ApiStatus.Internal
1010
@SuppressWarnings("unused")
11+
@Deprecated
12+
@ApiStatus.ScheduledForRemoval
1113
public final class MetaOffsetConverter {
1214
private MetaOffsetConverter() {
1315
}
1416

17+
@Deprecated
18+
@ApiStatus.ScheduledForRemoval
1519
public static final class EntityMetaOffsets {
1620
private EntityMetaOffsets() {
1721
}
@@ -73,6 +77,8 @@ public static byte ticksFrozenInPowderedSnowOffset() {
7377
}
7478
}
7579

80+
@Deprecated
81+
@ApiStatus.ScheduledForRemoval
7682
public static final class AreaEffectCloudOffsets {
7783
private AreaEffectCloudOffsets() {
7884
}
@@ -87,10 +93,10 @@ public static byte radiusOffset() {
8793

8894
public static byte waitingOffset() {
8995
int protocolVersion = getApi().getPacketEvents().getServerManager().getVersion().getProtocolVersion();
90-
if (protocolVersion >= 769 && protocolVersion <= 757) {
91-
return 9;
92-
}
93-
throw new RuntimeException("Unknown protocol version for this method");
96+
return 9;
97+
// if (protocolVersion >= 769 && protocolVersion <= 757) {
98+
// }
99+
// throw new RuntimeException("Unknown protocol version for this method");
94100
}
95101

96102
public static byte particleOffset() {
@@ -102,6 +108,8 @@ public static byte particleOffset() {
102108
}
103109
}
104110

111+
@Deprecated
112+
@ApiStatus.ScheduledForRemoval
105113
public static final class AbstractDisplayMetaOffsets {
106114
private AbstractDisplayMetaOffsets() {
107115
}
@@ -263,6 +271,8 @@ public static byte glowColorOverrideOffset() {
263271
}
264272
}
265273

274+
@Deprecated
275+
@ApiStatus.ScheduledForRemoval
266276
public static final class BlockDisplayMetaOffsets {
267277
private BlockDisplayMetaOffsets() {
268278
}
@@ -279,6 +289,8 @@ public static byte blockIdOffset() {
279289
}
280290
}
281291

292+
@Deprecated
293+
@ApiStatus.ScheduledForRemoval
282294
public static final class ItemDisplayMetaOffsets {
283295
private ItemDisplayMetaOffsets() {
284296
}
@@ -306,6 +318,8 @@ public static byte displayTypeOffset() {
306318
}
307319
}
308320

321+
@Deprecated
322+
@ApiStatus.ScheduledForRemoval
309323
public static final class TextDisplayMetaOffsets {
310324
private TextDisplayMetaOffsets() {
311325
}

0 commit comments

Comments
 (0)