26
26
import com .viaversion .viabackwards .protocol .protocol1_10to1_11 .storage .ChestedHorseStorage ;
27
27
import com .viaversion .viabackwards .utils .Block ;
28
28
import com .viaversion .viaversion .api .data .entity .StoredEntityData ;
29
- import com .viaversion .viaversion .api .minecraft .entities .Entity1_11Types ;
30
- import com .viaversion .viaversion .api .minecraft .entities .Entity1_12Types ;
29
+ import com .viaversion .viaversion .api .minecraft .entities .EntityTypes1_11 ;
30
+ import com .viaversion .viaversion .api .minecraft .entities .EntityTypes1_12 ;
31
31
import com .viaversion .viaversion .api .minecraft .entities .EntityType ;
32
32
import com .viaversion .viaversion .api .minecraft .metadata .Metadata ;
33
33
import com .viaversion .viaversion .api .minecraft .metadata .types .MetaType1_9 ;
@@ -84,12 +84,12 @@ public void register() {
84
84
85
85
// Track Entity
86
86
handler (getObjectTrackerHandler ());
87
- handler (getObjectRewriter (id -> Entity1_11Types .ObjectType .findById (id ).orElse (null )));
87
+ handler (getObjectRewriter (id -> EntityTypes1_11 .ObjectType .findById (id ).orElse (null )));
88
88
89
89
// Handle FallingBlock blocks
90
90
handler (wrapper -> {
91
- Optional <Entity1_12Types .ObjectType > type = Entity1_12Types .ObjectType .findById (wrapper .get (Type .BYTE , 0 ));
92
- if (type .isPresent () && type .get () == Entity1_12Types .ObjectType .FALLING_BLOCK ) {
91
+ Optional <EntityTypes1_12 .ObjectType > type = EntityTypes1_12 .ObjectType .findById (wrapper .get (Type .BYTE , 0 ));
92
+ if (type .isPresent () && type .get () == EntityTypes1_12 .ObjectType .FALLING_BLOCK ) {
93
93
int objectData = wrapper .get (Type .INT , 0 );
94
94
int objType = objectData & 4095 ;
95
95
int data = objectData >> 12 & 15 ;
@@ -104,8 +104,8 @@ public void register() {
104
104
}
105
105
});
106
106
107
- registerTracker (ClientboundPackets1_9_3 .SPAWN_EXPERIENCE_ORB , Entity1_11Types .EntityType .EXPERIENCE_ORB );
108
- registerTracker (ClientboundPackets1_9_3 .SPAWN_GLOBAL_ENTITY , Entity1_11Types .EntityType .WEATHER );
107
+ registerTracker (ClientboundPackets1_9_3 .SPAWN_EXPERIENCE_ORB , EntityTypes1_11 .EntityType .EXPERIENCE_ORB );
108
+ registerTracker (ClientboundPackets1_9_3 .SPAWN_GLOBAL_ENTITY , EntityTypes1_11 .EntityType .WEATHER );
109
109
110
110
protocol .registerClientbound (ClientboundPackets1_9_3 .SPAWN_MOB , new PacketHandlers () {
111
111
@ Override
@@ -151,8 +151,8 @@ public void register() {
151
151
}
152
152
});
153
153
154
- registerTracker (ClientboundPackets1_9_3 .SPAWN_PAINTING , Entity1_11Types .EntityType .PAINTING );
155
- registerJoinGame (ClientboundPackets1_9_3 .JOIN_GAME , Entity1_11Types .EntityType .PLAYER );
154
+ registerTracker (ClientboundPackets1_9_3 .SPAWN_PAINTING , EntityTypes1_11 .EntityType .PAINTING );
155
+ registerJoinGame (ClientboundPackets1_9_3 .JOIN_GAME , EntityTypes1_11 .EntityType .PLAYER );
156
156
registerRespawn (ClientboundPackets1_9_3 .RESPAWN );
157
157
158
158
protocol .registerClientbound (ClientboundPackets1_9_3 .SPAWN_PLAYER , new PacketHandlers () {
@@ -167,7 +167,7 @@ public void register() {
167
167
map (Type .BYTE ); // 6 - Pitch
168
168
map (Types1_9 .METADATA_LIST ); // 7 - Metadata list
169
169
170
- handler (getTrackerAndMetaHandler (Types1_9 .METADATA_LIST , Entity1_11Types .EntityType .PLAYER ));
170
+ handler (getTrackerAndMetaHandler (Types1_9 .METADATA_LIST , EntityTypes1_11 .EntityType .PLAYER ));
171
171
handler (wrapper -> {
172
172
// Sub 1.11 clients will cry if the list is empty
173
173
List <Metadata > metadata = wrapper .get (Types1_9 .METADATA_LIST , 0 );
@@ -204,50 +204,50 @@ public void register() {
204
204
@ Override
205
205
protected void registerRewrites () {
206
206
// Guardian
207
- mapEntityTypeWithData (Entity1_11Types .EntityType .ELDER_GUARDIAN , Entity1_11Types .EntityType .GUARDIAN );
207
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .ELDER_GUARDIAN , EntityTypes1_11 .EntityType .GUARDIAN );
208
208
// Skeletons
209
- mapEntityTypeWithData (Entity1_11Types .EntityType .WITHER_SKELETON , Entity1_11Types .EntityType .SKELETON ).spawnMetadata (storage -> storage .add (getSkeletonTypeMeta (1 )));
210
- mapEntityTypeWithData (Entity1_11Types .EntityType .STRAY , Entity1_11Types .EntityType .SKELETON ).plainName ().spawnMetadata (storage -> storage .add (getSkeletonTypeMeta (2 )));
209
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .WITHER_SKELETON , EntityTypes1_11 .EntityType .SKELETON ).spawnMetadata (storage -> storage .add (getSkeletonTypeMeta (1 )));
210
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .STRAY , EntityTypes1_11 .EntityType .SKELETON ).plainName ().spawnMetadata (storage -> storage .add (getSkeletonTypeMeta (2 )));
211
211
// Zombies
212
- mapEntityTypeWithData (Entity1_11Types .EntityType .HUSK , Entity1_11Types .EntityType .ZOMBIE ).plainName ().spawnMetadata (storage -> handleZombieType (storage , 6 ));
213
- mapEntityTypeWithData (Entity1_11Types .EntityType .ZOMBIE_VILLAGER , Entity1_11Types .EntityType .ZOMBIE ).spawnMetadata (storage -> handleZombieType (storage , 1 ));
212
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .HUSK , EntityTypes1_11 .EntityType .ZOMBIE ).plainName ().spawnMetadata (storage -> handleZombieType (storage , 6 ));
213
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .ZOMBIE_VILLAGER , EntityTypes1_11 .EntityType .ZOMBIE ).spawnMetadata (storage -> handleZombieType (storage , 1 ));
214
214
// Horses
215
- mapEntityTypeWithData (Entity1_11Types .EntityType .HORSE , Entity1_11Types .EntityType .HORSE ).spawnMetadata (storage -> storage .add (getHorseMetaType (0 ))); // Nob able to ride the horse without having the MetaType sent.
216
- mapEntityTypeWithData (Entity1_11Types .EntityType .DONKEY , Entity1_11Types .EntityType .HORSE ).spawnMetadata (storage -> storage .add (getHorseMetaType (1 )));
217
- mapEntityTypeWithData (Entity1_11Types .EntityType .MULE , Entity1_11Types .EntityType .HORSE ).spawnMetadata (storage -> storage .add (getHorseMetaType (2 )));
218
- mapEntityTypeWithData (Entity1_11Types .EntityType .SKELETON_HORSE , Entity1_11Types .EntityType .HORSE ).spawnMetadata (storage -> storage .add (getHorseMetaType (4 )));
219
- mapEntityTypeWithData (Entity1_11Types .EntityType .ZOMBIE_HORSE , Entity1_11Types .EntityType .HORSE ).spawnMetadata (storage -> storage .add (getHorseMetaType (3 )));
215
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .HORSE , EntityTypes1_11 .EntityType .HORSE ).spawnMetadata (storage -> storage .add (getHorseMetaType (0 ))); // Nob able to ride the horse without having the MetaType sent.
216
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .DONKEY , EntityTypes1_11 .EntityType .HORSE ).spawnMetadata (storage -> storage .add (getHorseMetaType (1 )));
217
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .MULE , EntityTypes1_11 .EntityType .HORSE ).spawnMetadata (storage -> storage .add (getHorseMetaType (2 )));
218
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .SKELETON_HORSE , EntityTypes1_11 .EntityType .HORSE ).spawnMetadata (storage -> storage .add (getHorseMetaType (4 )));
219
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .ZOMBIE_HORSE , EntityTypes1_11 .EntityType .HORSE ).spawnMetadata (storage -> storage .add (getHorseMetaType (3 )));
220
220
// New mobs
221
- mapEntityTypeWithData (Entity1_11Types .EntityType .EVOCATION_FANGS , Entity1_11Types .EntityType .SHULKER );
222
- mapEntityTypeWithData (Entity1_11Types .EntityType .EVOCATION_ILLAGER , Entity1_11Types .EntityType .VILLAGER ).plainName ();
223
- mapEntityTypeWithData (Entity1_11Types .EntityType .VEX , Entity1_11Types .EntityType .BAT ).plainName ();
224
- mapEntityTypeWithData (Entity1_11Types .EntityType .VINDICATION_ILLAGER , Entity1_11Types .EntityType .VILLAGER ).plainName ().spawnMetadata (storage -> storage .add (new Metadata (13 , MetaType1_9 .VarInt , 4 ))); // Base Profession
225
- mapEntityTypeWithData (Entity1_11Types .EntityType .LIAMA , Entity1_11Types .EntityType .HORSE ).plainName ().spawnMetadata (storage -> storage .add (getHorseMetaType (1 )));
226
- mapEntityTypeWithData (Entity1_11Types .EntityType .LIAMA_SPIT , Entity1_11Types .EntityType .SNOWBALL );
227
-
228
- mapObjectType (Entity1_11Types .ObjectType .LIAMA_SPIT , Entity1_11Types .ObjectType .SNOWBALL , -1 );
221
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .EVOCATION_FANGS , EntityTypes1_11 .EntityType .SHULKER );
222
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .EVOCATION_ILLAGER , EntityTypes1_11 .EntityType .VILLAGER ).plainName ();
223
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .VEX , EntityTypes1_11 .EntityType .BAT ).plainName ();
224
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .VINDICATION_ILLAGER , EntityTypes1_11 .EntityType .VILLAGER ).plainName ().spawnMetadata (storage -> storage .add (new Metadata (13 , MetaType1_9 .VarInt , 4 ))); // Base Profession
225
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .LIAMA , EntityTypes1_11 .EntityType .HORSE ).plainName ().spawnMetadata (storage -> storage .add (getHorseMetaType (1 )));
226
+ mapEntityTypeWithData (EntityTypes1_11 .EntityType .LIAMA_SPIT , EntityTypes1_11 .EntityType .SNOWBALL );
227
+
228
+ mapObjectType (EntityTypes1_11 .ObjectType .LIAMA_SPIT , EntityTypes1_11 .ObjectType .SNOWBALL , -1 );
229
229
// Replace with endertorchthingies
230
- mapObjectType (Entity1_11Types .ObjectType .EVOCATION_FANGS , Entity1_11Types .ObjectType .FALLING_BLOCK , 198 | 1 << 12 );
230
+ mapObjectType (EntityTypes1_11 .ObjectType .EVOCATION_FANGS , EntityTypes1_11 .ObjectType .FALLING_BLOCK , 198 | 1 << 12 );
231
231
232
232
// Handle ElderGuardian & target metadata
233
- filter ().filterFamily (Entity1_11Types .EntityType .GUARDIAN ).index (12 ).handler ((event , meta ) -> {
233
+ filter ().filterFamily (EntityTypes1_11 .EntityType .GUARDIAN ).index (12 ).handler ((event , meta ) -> {
234
234
boolean b = (boolean ) meta .getValue ();
235
235
int bitmask = b ? 0x02 : 0 ;
236
236
237
- if (event .entityType () == Entity1_11Types .EntityType .ELDER_GUARDIAN ) {
237
+ if (event .entityType () == EntityTypes1_11 .EntityType .ELDER_GUARDIAN ) {
238
238
bitmask |= 0x04 ;
239
239
}
240
240
241
241
meta .setTypeAndValue (MetaType1_9 .Byte , (byte ) bitmask );
242
242
});
243
243
244
244
// Handle skeleton swing
245
- filter ().filterFamily (Entity1_11Types .EntityType .ABSTRACT_SKELETON ).index (12 ).toIndex (13 );
245
+ filter ().filterFamily (EntityTypes1_11 .EntityType .ABSTRACT_SKELETON ).index (12 ).toIndex (13 );
246
246
247
247
/*
248
248
ZOMBIE CHANGES
249
249
*/
250
- filter ().filterFamily (Entity1_11Types .EntityType .ZOMBIE ).handler ((event , meta ) -> {
250
+ filter ().filterFamily (EntityTypes1_11 .EntityType .ZOMBIE ).handler ((event , meta ) -> {
251
251
switch (meta .id ()) {
252
252
case 13 :
253
253
event .cancel ();
@@ -267,18 +267,18 @@ protected void registerRewrites() {
267
267
});
268
268
269
269
// Handle Evocation Illager
270
- filter ().type (Entity1_11Types .EntityType .EVOCATION_ILLAGER ).index (12 ).handler ((event , meta ) -> {
270
+ filter ().type (EntityTypes1_11 .EntityType .EVOCATION_ILLAGER ).index (12 ).handler ((event , meta ) -> {
271
271
event .setIndex (13 );
272
272
meta .setTypeAndValue (MetaType1_9 .VarInt , ((Byte ) meta .getValue ()).intValue ()); // Change the profession for the states
273
273
});
274
274
275
275
// Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ):
276
- filter ().type (Entity1_11Types .EntityType .VEX ).index (12 ).handler ((event , meta ) -> {
276
+ filter ().type (EntityTypes1_11 .EntityType .VEX ).index (12 ).handler ((event , meta ) -> {
277
277
meta .setValue ((byte ) 0x00 );
278
278
});
279
279
280
280
// Handle VindicationIllager
281
- filter ().type (Entity1_11Types .EntityType .VINDICATION_ILLAGER ).index (12 ).handler ((event , meta ) -> {
281
+ filter ().type (EntityTypes1_11 .EntityType .VINDICATION_ILLAGER ).index (12 ).handler ((event , meta ) -> {
282
282
event .setIndex (13 );
283
283
meta .setTypeAndValue (MetaType1_9 .VarInt , ((Number ) meta .getValue ()).intValue () == 1 ? 2 : 4 );
284
284
});
@@ -288,7 +288,7 @@ protected void registerRewrites() {
288
288
*/
289
289
290
290
// Handle horse flags
291
- filter ().filterFamily (Entity1_11Types .EntityType .ABSTRACT_HORSE ).index (13 ).handler ((event , meta ) -> {
291
+ filter ().filterFamily (EntityTypes1_11 .EntityType .ABSTRACT_HORSE ).index (13 ).handler ((event , meta ) -> {
292
292
StoredEntityData data = storedEntityData (event );
293
293
byte b = (byte ) meta .getValue ();
294
294
if (data .has (ChestedHorseStorage .class ) && data .get (ChestedHorseStorage .class ).isChested ()) {
@@ -298,18 +298,18 @@ protected void registerRewrites() {
298
298
});
299
299
300
300
// Create chested horse storage
301
- filter ().filterFamily (Entity1_11Types .EntityType .CHESTED_HORSE ).handler ((event , meta ) -> {
301
+ filter ().filterFamily (EntityTypes1_11 .EntityType .CHESTED_HORSE ).handler ((event , meta ) -> {
302
302
StoredEntityData data = storedEntityData (event );
303
303
if (!data .has (ChestedHorseStorage .class )) {
304
304
data .put (new ChestedHorseStorage ());
305
305
}
306
306
});
307
307
308
308
// Handle horse armor
309
- filter ().type (Entity1_11Types .EntityType .HORSE ).index (16 ).toIndex (17 );
309
+ filter ().type (EntityTypes1_11 .EntityType .HORSE ).index (16 ).toIndex (17 );
310
310
311
311
// Handle chested horse
312
- filter ().filterFamily (Entity1_11Types .EntityType .CHESTED_HORSE ).index (15 ).handler ((event , meta ) -> {
312
+ filter ().filterFamily (EntityTypes1_11 .EntityType .CHESTED_HORSE ).index (15 ).handler ((event , meta ) -> {
313
313
StoredEntityData data = storedEntityData (event );
314
314
ChestedHorseStorage storage = data .get (ChestedHorseStorage .class );
315
315
boolean b = (boolean ) meta .getValue ();
@@ -318,7 +318,7 @@ protected void registerRewrites() {
318
318
});
319
319
320
320
// Get rid of Liama metadata
321
- filter ().type (Entity1_11Types .EntityType .LIAMA ).handler ((event , meta ) -> {
321
+ filter ().type (EntityTypes1_11 .EntityType .LIAMA ).handler ((event , meta ) -> {
322
322
StoredEntityData data = storedEntityData (event );
323
323
ChestedHorseStorage storage = data .get (ChestedHorseStorage .class );
324
324
@@ -341,17 +341,17 @@ protected void registerRewrites() {
341
341
});
342
342
343
343
// Handle Horse (Correct owner)
344
- filter ().filterFamily (Entity1_11Types .EntityType .ABSTRACT_HORSE ).index (14 ).toIndex (16 );
344
+ filter ().filterFamily (EntityTypes1_11 .EntityType .ABSTRACT_HORSE ).index (14 ).toIndex (16 );
345
345
346
346
// Handle villager - Change non-existing profession
347
- filter ().type (Entity1_11Types .EntityType .VILLAGER ).index (13 ).handler ((event , meta ) -> {
347
+ filter ().type (EntityTypes1_11 .EntityType .VILLAGER ).index (13 ).handler ((event , meta ) -> {
348
348
if ((int ) meta .getValue () == 5 ) {
349
349
meta .setValue (0 );
350
350
}
351
351
});
352
352
353
353
// handle new Shulker color meta
354
- filter ().type (Entity1_11Types .EntityType .SHULKER ).cancel (15 );
354
+ filter ().type (EntityTypes1_11 .EntityType .SHULKER ).cancel (15 );
355
355
}
356
356
357
357
/*
@@ -393,11 +393,11 @@ private Metadata getHorseMetaType(int type) {
393
393
394
394
@ Override
395
395
public EntityType typeFromId (int typeId ) {
396
- return Entity1_11Types .getTypeFromId (typeId , false );
396
+ return EntityTypes1_11 .getTypeFromId (typeId , false );
397
397
}
398
398
399
399
@ Override
400
400
protected EntityType getObjectTypeFromId (int typeId ) {
401
- return Entity1_11Types .getTypeFromId (typeId , true );
401
+ return EntityTypes1_11 .getTypeFromId (typeId , true );
402
402
}
403
403
}
0 commit comments