@@ -26,9 +26,17 @@ public EntityData(String type) {
2626 if (type .equalsIgnoreCase ("human" ) || type .equalsIgnoreCase ("player" )) {
2727 type = "player" ;
2828 } else if (type .equalsIgnoreCase ("wither skeleton" )) {
29+ if (V1_11EntityTypeHandler .newEntityTypesPresent ()) {
30+ entityType = EntityType .WITHER_SKELETON ;
31+ } else {
32+ entityType = EntityType .SKELETON ;
33+ }
2934 type = "skeleton" ;
3035 flag = true ;
3136 } else if (type .equalsIgnoreCase ("zombie villager" ) || type .equalsIgnoreCase ("villager zombie" )) {
37+ if (V1_11EntityTypeHandler .newEntityTypesPresent ()) {
38+ entityType = EntityType .ZOMBIE_VILLAGER ;
39+ }
3240 type = "zombie" ;
3341 var1 = 1 ;
3442 } else if (type .equalsIgnoreCase ("powered creeper" )) {
@@ -147,14 +155,29 @@ public EntityData(String type) {
147155 String t = data .remove (0 ).toLowerCase ();
148156 if (t .equals ("donkey" )) {
149157 var1 = 1 ;
158+ if (V1_11EntityTypeHandler .newEntityTypesPresent ()) {
159+ entityType = EntityType .DONKEY ;
160+ }
150161 } else if (t .equals ("mule" )) {
151162 var1 = 2 ;
163+ if (V1_11EntityTypeHandler .newEntityTypesPresent ()) {
164+ entityType = EntityType .MULE ;
165+ }
152166 } else if (t .equals ("skeleton" ) || t .equals ("skeletal" )) {
153167 var1 = 4 ;
168+ if (V1_11EntityTypeHandler .newEntityTypesPresent ()) {
169+ entityType = EntityType .SKELETON_HORSE ;
170+ }
154171 } else if (t .equals ("zombie" ) || t .equals ("undead" )) {
155172 var1 = 3 ;
173+ if (V1_11EntityTypeHandler .newEntityTypesPresent ()) {
174+ entityType = EntityType .ZOMBIE_HORSE ;
175+ }
156176 } else {
157177 var1 = 0 ;
178+ if (V1_11EntityTypeHandler .newEntityTypesPresent ()) {
179+ entityType = EntityType .HORSE ;
180+ }
158181 }
159182 data .remove (0 );
160183 }
@@ -174,10 +197,16 @@ public EntityData(String type) {
174197 } else if (type .equalsIgnoreCase ("mule" )) {
175198 var1 = 2 ;
176199 type = "entityhorse" ;
200+ if (V1_11EntityTypeHandler .newEntityTypesPresent ()) {
201+ entityType = EntityType .MULE ;
202+ }
177203 } else if (type .equalsIgnoreCase ("donkey" )) {
178204 var1 = 1 ;
179205 type = "entityhorse" ;
180206 } else if (type .equalsIgnoreCase ("elder guardian" )) {
207+ if (V1_11EntityTypeHandler .newEntityTypesPresent ()) {
208+ entityType = EntityType .ELDER_GUARDIAN ;
209+ }
181210 flag = true ;
182211 type = "guardian" ;
183212 }
@@ -196,10 +225,12 @@ public EntityData(String type) {
196225 if (type .equals ("magmacube" )) type = "lavaslime" ;
197226 var1 = Integer .parseInt (data [1 ]);
198227 }
199- if (type .equals ("player" )) {
200- entityType = EntityType .PLAYER ;
201- } else {
202- entityType = EntityType .fromName (type );
228+ if (entityType == null ) {
229+ if (type .equals ("player" )) {
230+ entityType = EntityType .PLAYER ;
231+ } else {
232+ entityType = EntityType .fromName (type );
233+ }
203234 }
204235 }
205236
@@ -224,16 +255,21 @@ public int getVar3() {
224255 }
225256
226257 public Entity spawn (Location loc ) {
258+
227259 Entity entity = loc .getWorld ().spawnEntity (loc , entityType );
228260 if (entity instanceof Ageable && flag ) {
229261 ((Ageable )entity ).setBaby ();
230262 }
231263 if (entityType == EntityType .ZOMBIE ) {
232264 ((Zombie )entity ).setBaby (flag );
233- ((Zombie )entity ).setVillager (var1 == 1 );
265+ if (!V1_11EntityTypeHandler .newEntityTypesPresent ()) {
266+ ((Zombie )entity ).setVillager (var1 == 1 ); // this is safe due to version checks
267+ }
234268 } else if (entityType == EntityType .SKELETON ) {
235- if (flag ) {
236- ((Skeleton )entity ).setSkeletonType (Skeleton .SkeletonType .WITHER );
269+ if (!V1_11EntityTypeHandler .newEntityTypesPresent ()) {
270+ if (flag ) {
271+ ((Skeleton )entity ).setSkeletonType (Skeleton .SkeletonType .WITHER ); // this is safe due to version checks
272+ }
237273 }
238274 } else if (entityType == EntityType .CREEPER ) {
239275 if (flag ) {
@@ -295,20 +331,24 @@ public Entity spawn(Location loc) {
295331 ((Rabbit)entity).setRabbitType(Rabbit.Type.THE_KILLER_BUNNY);
296332 }*/
297333 } else if (entityType == EntityType .GUARDIAN ) {
298- if (flag ) {
299- ((Guardian )entity ).setElder (true );
334+ if (!V1_11EntityTypeHandler .newEntityTypesPresent ()) {
335+ if (flag ) {
336+ ((Guardian )entity ).setElder (true ); // this is safe due to version checks
337+ }
300338 }
301339 } else if (entityType == EntityType .HORSE ) {
302- if (var1 == 0 ) {
303- ((Horse )entity ).setVariant (Horse .Variant .HORSE );
304- } else if (var1 == 1 ) {
305- ((Horse )entity ).setVariant (Horse .Variant .DONKEY );
306- } else if (var1 == 2 ) {
307- ((Horse )entity ).setVariant (Horse .Variant .MULE );
308- } else if (var1 == 3 ) {
309- ((Horse )entity ).setVariant (Horse .Variant .UNDEAD_HORSE );
310- } else if (var1 == 4 ) {
311- ((Horse )entity ).setVariant (Horse .Variant .SKELETON_HORSE );
340+ if (!V1_11EntityTypeHandler .newEntityTypesPresent ()) {
341+ if (var1 == 0 ) {
342+ ((Horse )entity ).setVariant (Horse .Variant .HORSE ); // this is safe due to version checks
343+ } else if (var1 == 1 ) {
344+ ((Horse )entity ).setVariant (Horse .Variant .DONKEY ); // this is safe due to version checks
345+ } else if (var1 == 2 ) {
346+ ((Horse )entity ).setVariant (Horse .Variant .MULE ); // this is safe due to version checks
347+ } else if (var1 == 3 ) {
348+ ((Horse )entity ).setVariant (Horse .Variant .UNDEAD_HORSE ); // this is safe due to version checks
349+ } else if (var1 == 4 ) {
350+ ((Horse )entity ).setVariant (Horse .Variant .SKELETON_HORSE ); // this is safe due to version checks
351+ }
312352 }
313353 }
314354 return entity ;
0 commit comments