1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
|
package net.minecraft.server;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Callable;
// CraftBukkit start
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.plugin.PluginManager;
// CraftBukkit end
public abstract class Entity {
// CraftBukkit start
private static final int CURRENT_LEVEL = 1;
static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
}
// CraftBukkit end
private static int entityCount = 0;
public int id;
public double l;
public boolean m;
public Entity passenger;
public Entity vehicle;
public World world;
public double lastX;
public double lastY;
public double lastZ;
public double locX;
public double locY;
public double locZ;
public double motX;
public double motY;
public double motZ;
public float yaw;
public float pitch;
public float lastYaw;
public float lastPitch;
public final AxisAlignedBB boundingBox;
public boolean onGround;
public boolean positionChanged;
public boolean G;
public boolean H;
public boolean velocityChanged;
protected boolean J;
public boolean K;
public boolean dead;
public float height;
public float width;
public float length;
public float P;
public float Q;
public float R;
public float fallDistance;
private int c;
public double T;
public double U;
public double V;
public float W;
public float X;
public boolean Y;
public float Z;
protected Random random;
public int ticksLived;
public int maxFireTicks;
public int fireTicks; // CraftBukkit - private -> public
protected boolean ad;
public int noDamageTicks;
private boolean justCreated;
protected boolean fireProof;
protected DataWatcher datawatcher;
private double f;
private double g;
public boolean ah;
public int ai;
public int aj;
public int ak;
public boolean al;
public boolean am;
public int portalCooldown;
protected boolean ao;
protected int ap;
public int dimension;
protected int ar;
private boolean invulnerable;
public EnumEntitySize as;
public UUID uniqueId = UUID.randomUUID(); // CraftBukkit
public boolean valid = false; // CraftBukkit
public Entity(World world) {
this.id = entityCount++;
this.l = 1.0D;
this.m = false;
this.boundingBox = AxisAlignedBB.a(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
this.onGround = false;
this.H = false;
this.velocityChanged = false;
this.K = true;
this.dead = false;
this.height = 0.0F;
this.width = 0.6F;
this.length = 1.8F;
this.P = 0.0F;
this.Q = 0.0F;
this.R = 0.0F;
this.fallDistance = 0.0F;
this.c = 1;
this.W = 0.0F;
this.X = 0.0F;
this.Y = false;
this.Z = 0.0F;
this.random = new Random();
this.ticksLived = 0;
this.maxFireTicks = 1;
this.fireTicks = 0;
this.ad = false;
this.noDamageTicks = 0;
this.justCreated = true;
this.fireProof = false;
this.datawatcher = new DataWatcher();
this.ah = false;
this.ar = 0;
this.invulnerable = false;
this.as = EnumEntitySize.SIZE_2;
this.world = world;
this.setPosition(0.0D, 0.0D, 0.0D);
if (world != null) {
this.dimension = world.worldProvider.dimension;
}
this.datawatcher.a(0, Byte.valueOf((byte) 0));
this.datawatcher.a(1, Short.valueOf((short) 300));
this.a();
}
protected abstract void a();
public DataWatcher getDataWatcher() {
return this.datawatcher;
}
public boolean equals(Object object) {
return object instanceof Entity ? ((Entity) object).id == this.id : false;
}
public int hashCode() {
return this.id;
}
public void die() {
this.dead = true;
}
protected void a(float f, float f1) {
this.width = f;
this.length = f1;
float f2 = f % 2.0F;
if ((double) f2 < 0.375D) {
this.as = EnumEntitySize.SIZE_1;
} else if ((double) f2 < 0.75D) {
this.as = EnumEntitySize.SIZE_2;
} else if ((double) f2 < 1.0D) {
this.as = EnumEntitySize.SIZE_3;
} else if ((double) f2 < 1.375D) {
this.as = EnumEntitySize.SIZE_4;
} else if ((double) f2 < 1.75D) {
this.as = EnumEntitySize.SIZE_5;
} else {
this.as = EnumEntitySize.SIZE_6;
}
}
protected void b(float f, float f1) {
// CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0
if (Float.isNaN(f)) {
f = 0;
}
if ((f == Float.POSITIVE_INFINITY) || (f == Float.NEGATIVE_INFINITY)) {
if (this instanceof EntityPlayer) {
System.err.println(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid yaw");
((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope");
}
f = 0;
}
// pitch was sometimes set to NaN, so we need to set it back to 0.
if (Float.isNaN(f1)) {
f1 = 0;
}
if ((f1 == Float.POSITIVE_INFINITY) || (f1 == Float.NEGATIVE_INFINITY)) {
if (this instanceof EntityPlayer) {
System.err.println(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid pitch");
((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope");
}
f1 = 0;
}
// CraftBukkit end
this.yaw = f % 360.0F;
this.pitch = f1 % 360.0F;
}
public void setPosition(double d0, double d1, double d2) {
this.locX = d0;
this.locY = d1;
this.locZ = d2;
float f = this.width / 2.0F;
float f1 = this.length;
this.boundingBox.b(d0 - (double) f, d1 - (double) this.height + (double) this.W, d2 - (double) f, d0 + (double) f, d1 - (double) this.height + (double) this.W + (double) f1, d2 + (double) f);
}
public void j_() {
this.y();
}
public void y() {
this.world.methodProfiler.a("entityBaseTick");
if (this.vehicle != null && this.vehicle.dead) {
this.vehicle = null;
}
this.P = this.Q;
this.lastX = this.locX;
this.lastY = this.locY;
this.lastZ = this.locZ;
this.lastPitch = this.pitch;
this.lastYaw = this.yaw;
int i;
if (!this.world.isStatic && this.world instanceof WorldServer) {
this.world.methodProfiler.a("portal");
MinecraftServer minecraftserver = ((WorldServer) this.world).getMinecraftServer();
i = this.z();
if (this.ao) {
if (true || minecraftserver.getAllowNether()) { // CraftBukkit
if (this.vehicle == null && this.ap++ >= i) {
this.ap = i;
this.portalCooldown = this.ab();
byte b0;
if (this.world.worldProvider.dimension == -1) {
b0 = 0;
} else {
b0 = -1;
}
this.b(b0);
}
this.ao = false;
}
} else {
if (this.ap > 0) {
this.ap -= 4;
}
if (this.ap < 0) {
this.ap = 0;
}
}
if (this.portalCooldown > 0) {
--this.portalCooldown;
}
this.world.methodProfiler.b();
}
if (this.isSprinting() && !this.H()) {
int j = MathHelper.floor(this.locX);
i = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height);
int k = MathHelper.floor(this.locZ);
int l = this.world.getTypeId(j, i, k);
if (l > 0) {
this.world.addParticle("tilecrack_" + l + "_" + this.world.getData(j, i, k), this.locX + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, this.boundingBox.b + 0.1D, this.locZ + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, -this.motX * 4.0D, 1.5D, -this.motZ * 4.0D);
}
}
this.I();
if (this.world.isStatic) {
this.fireTicks = 0;
} else if (this.fireTicks > 0) {
if (this.fireProof) {
this.fireTicks -= 4;
if (this.fireTicks < 0) {
this.fireTicks = 0;
}
} else {
if (this.fireTicks % 20 == 0) {
// CraftBukkit start - TODO: this event spams!
if (this instanceof EntityLiving) {
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.FIRE_TICK, 1);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
event.getEntity().setLastDamageCause(event);
this.damageEntity(DamageSource.BURN, event.getDamage());
}
} else {
this.damageEntity(DamageSource.BURN, 1);
}
// CraftBukkit end
}
--this.fireTicks;
}
}
if (this.J()) {
this.A();
this.fallDistance *= 0.5F;
}
if (this.locY < -64.0D) {
this.C();
}
if (!this.world.isStatic) {
this.a(0, this.fireTicks > 0);
this.a(2, this.vehicle != null);
}
this.justCreated = false;
this.world.methodProfiler.b();
}
public int z() {
return 0;
}
protected void A() {
if (!this.fireProof) {
// CraftBukkit start - fallen in lava TODO: this event spams!
if (this instanceof EntityLiving) {
Server server = this.world.getServer();
// TODO: shouldn't be sending null for the block.
org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
org.bukkit.entity.Entity damagee = this.getBukkitEntity();
EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee, EntityDamageEvent.DamageCause.LAVA, 4);
server.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
damagee.setLastDamageCause(event);
this.damageEntity(DamageSource.LAVA, event.getDamage());
}
if (this.fireTicks <= 0) {
// not on fire yet
EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15);
server.getPluginManager().callEvent(combustEvent);
if (!combustEvent.isCancelled()) {
this.setOnFire(combustEvent.getDuration());
}
} else {
// This will be called every single tick the entity is in lava, so don't throw an event
this.setOnFire(15);
}
return;
}
// CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
this.damageEntity(DamageSource.LAVA, 4);
this.setOnFire(15);
}
}
public void setOnFire(int i) {
int j = i * 20;
j = EnchantmentProtection.a(this, j);
if (this.fireTicks < j) {
this.fireTicks = j;
}
}
public void extinguish() {
this.fireTicks = 0;
}
protected void C() {
this.die();
}
public boolean c(double d0, double d1, double d2) {
AxisAlignedBB axisalignedbb = this.boundingBox.c(d0, d1, d2);
List list = this.world.getCubes(this, axisalignedbb);
return !list.isEmpty() ? false : !this.world.containsLiquid(axisalignedbb);
}
public void move(double d0, double d1, double d2) {
if (this.Y) {
this.boundingBox.d(d0, d1, d2);
this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D;
this.locY = this.boundingBox.b + (double) this.height - (double) this.W;
this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D;
} else {
this.world.methodProfiler.a("move");
this.W *= 0.4F;
double d3 = this.locX;
double d4 = this.locY;
double d5 = this.locZ;
if (this.J) {
this.J = false;
d0 *= 0.25D;
d1 *= 0.05000000074505806D;
d2 *= 0.25D;
this.motX = 0.0D;
this.motY = 0.0D;
this.motZ = 0.0D;
}
double d6 = d0;
double d7 = d1;
double d8 = d2;
AxisAlignedBB axisalignedbb = this.boundingBox.clone();
boolean flag = this.onGround && this.isSneaking() && this instanceof EntityHuman;
if (flag) {
double d9;
for (d9 = 0.05D; d0 != 0.0D && this.world.getCubes(this, this.boundingBox.c(d0, -1.0D, 0.0D)).isEmpty(); d6 = d0) {
if (d0 < d9 && d0 >= -d9) {
d0 = 0.0D;
} else if (d0 > 0.0D) {
d0 -= d9;
} else {
d0 += d9;
}
}
for (; d2 != 0.0D && this.world.getCubes(this, this.boundingBox.c(0.0D, -1.0D, d2)).isEmpty(); d8 = d2) {
if (d2 < d9 && d2 >= -d9) {
d2 = 0.0D;
} else if (d2 > 0.0D) {
d2 -= d9;
} else {
d2 += d9;
}
}
while (d0 != 0.0D && d2 != 0.0D && this.world.getCubes(this, this.boundingBox.c(d0, -1.0D, d2)).isEmpty()) {
if (d0 < d9 && d0 >= -d9) {
d0 = 0.0D;
} else if (d0 > 0.0D) {
d0 -= d9;
} else {
d0 += d9;
}
if (d2 < d9 && d2 >= -d9) {
d2 = 0.0D;
} else if (d2 > 0.0D) {
d2 -= d9;
} else {
d2 += d9;
}
d6 = d0;
d8 = d2;
}
}
List list = this.world.getCubes(this, this.boundingBox.a(d0, d1, d2));
for (int i = 0; i < list.size(); ++i) {
d1 = ((AxisAlignedBB) list.get(i)).b(this.boundingBox, d1);
}
this.boundingBox.d(0.0D, d1, 0.0D);
if (!this.K && d7 != d1) {
d2 = 0.0D;
d1 = 0.0D;
d0 = 0.0D;
}
boolean flag1 = this.onGround || d7 != d1 && d7 < 0.0D;
int j;
for (j = 0; j < list.size(); ++j) {
d0 = ((AxisAlignedBB) list.get(j)).a(this.boundingBox, d0);
}
this.boundingBox.d(d0, 0.0D, 0.0D);
if (!this.K && d6 != d0) {
d2 = 0.0D;
d1 = 0.0D;
d0 = 0.0D;
}
for (j = 0; j < list.size(); ++j) {
d2 = ((AxisAlignedBB) list.get(j)).c(this.boundingBox, d2);
}
this.boundingBox.d(0.0D, 0.0D, d2);
if (!this.K && d8 != d2) {
d2 = 0.0D;
d1 = 0.0D;
d0 = 0.0D;
}
double d10;
double d11;
double d12;
int k;
if (this.X > 0.0F && flag1 && (flag || this.W < 0.05F) && (d6 != d0 || d8 != d2)) {
d10 = d0;
d11 = d1;
d12 = d2;
d0 = d6;
d1 = (double) this.X;
d2 = d8;
AxisAlignedBB axisalignedbb1 = this.boundingBox.clone();
this.boundingBox.c(axisalignedbb);
list = this.world.getCubes(this, this.boundingBox.a(d6, d1, d8));
for (k = 0; k < list.size(); ++k) {
d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1);
}
this.boundingBox.d(0.0D, d1, 0.0D);
if (!this.K && d7 != d1) {
d2 = 0.0D;
d1 = 0.0D;
d0 = 0.0D;
}
for (k = 0; k < list.size(); ++k) {
d0 = ((AxisAlignedBB) list.get(k)).a(this.boundingBox, d0);
}
this.boundingBox.d(d0, 0.0D, 0.0D);
if (!this.K && d6 != d0) {
d2 = 0.0D;
d1 = 0.0D;
d0 = 0.0D;
}
for (k = 0; k < list.size(); ++k) {
d2 = ((AxisAlignedBB) list.get(k)).c(this.boundingBox, d2);
}
this.boundingBox.d(0.0D, 0.0D, d2);
if (!this.K && d8 != d2) {
d2 = 0.0D;
d1 = 0.0D;
d0 = 0.0D;
}
if (!this.K && d7 != d1) {
d2 = 0.0D;
d1 = 0.0D;
d0 = 0.0D;
} else {
d1 = (double) (-this.X);
for (k = 0; k < list.size(); ++k) {
d1 = ((AxisAlignedBB) list.get(k)).b(this.boundingBox, d1);
}
this.boundingBox.d(0.0D, d1, 0.0D);
}
if (d10 * d10 + d12 * d12 >= d0 * d0 + d2 * d2) {
d0 = d10;
d1 = d11;
d2 = d12;
this.boundingBox.c(axisalignedbb1);
} else {
double d13 = this.boundingBox.b - (double) ((int) this.boundingBox.b);
if (d13 > 0.0D) {
this.W = (float) ((double) this.W + d13 + 0.01D);
}
}
}
this.world.methodProfiler.b();
this.world.methodProfiler.a("rest");
this.locX = (this.boundingBox.a + this.boundingBox.d) / 2.0D;
this.locY = this.boundingBox.b + (double) this.height - (double) this.W;
this.locZ = (this.boundingBox.c + this.boundingBox.f) / 2.0D;
this.positionChanged = d6 != d0 || d8 != d2;
this.G = d7 != d1;
this.onGround = d7 != d1 && d7 < 0.0D;
this.H = this.positionChanged || this.G;
this.a(d1, this.onGround);
if (d6 != d0) {
this.motX = 0.0D;
}
if (d7 != d1) {
this.motY = 0.0D;
}
if (d8 != d2) {
this.motZ = 0.0D;
}
d10 = this.locX - d3;
d11 = this.locY - d4;
d12 = this.locZ - d5;
// CraftBukkit start
if ((this.positionChanged) && (this.getBukkitEntity() instanceof Vehicle)) {
Vehicle vehicle = (Vehicle) this.getBukkitEntity();
org.bukkit.block.Block block = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY - (double) this.height), MathHelper.floor(this.locZ));
if (d6 > d0) {
block = block.getRelative(BlockFace.EAST);
} else if (d6 < d0) {
block = block.getRelative(BlockFace.WEST);
} else if (d8 > d2) {
block = block.getRelative(BlockFace.SOUTH);
} else if (d8 < d2) {
block = block.getRelative(BlockFace.NORTH);
}
VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, block);
this.world.getServer().getPluginManager().callEvent(event);
}
// CraftBukkit end
if (this.f_() && !flag && this.vehicle == null) {
int l = MathHelper.floor(this.locX);
k = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height);
int i1 = MathHelper.floor(this.locZ);
int j1 = this.world.getTypeId(l, k, i1);
if (j1 == 0) {
int k1 = this.world.e(l, k - 1, i1);
if (k1 == 11 || k1 == 32 || k1 == 21) {
j1 = this.world.getTypeId(l, k - 1, i1);
}
}
if (j1 != Block.LADDER.id) {
d11 = 0.0D;
}
this.Q = (float) ((double) this.Q + (double) MathHelper.sqrt(d10 * d10 + d12 * d12) * 0.6D);
this.R = (float) ((double) this.R + (double) MathHelper.sqrt(d10 * d10 + d11 * d11 + d12 * d12) * 0.6D);
if (this.R > (float) this.c && j1 > 0) {
this.c = (int) this.R + 1;
if (this.H()) {
float f = MathHelper.sqrt(this.motX * this.motX * 0.20000000298023224D + this.motY * this.motY + this.motZ * this.motZ * 0.20000000298023224D) * 0.35F;
if (f > 1.0F) {
f = 1.0F;
}
this.makeSound("liquid.swim", f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
}
this.a(l, k, i1, j1);
Block.byId[j1].b(this.world, l, k, i1, this);
}
}
this.D();
boolean flag2 = this.G();
if (this.world.e(this.boundingBox.shrink(0.001D, 0.001D, 0.001D))) {
this.burn(1);
if (!flag2) {
++this.fireTicks;
// CraftBukkit start - not on fire yet
if (this.fireTicks <= 0) { // only throw events on the first combust, otherwise it spams
EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.setOnFire(event.getDuration());
}
} else {
// CraftBukkit end
this.setOnFire(8);
}
}
} else if (this.fireTicks <= 0) {
this.fireTicks = -this.maxFireTicks;
}
if (flag2 && this.fireTicks > 0) {
this.makeSound("random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
this.fireTicks = -this.maxFireTicks;
}
this.world.methodProfiler.b();
}
}
protected void D() {
int i = MathHelper.floor(this.boundingBox.a + 0.001D);
int j = MathHelper.floor(this.boundingBox.b + 0.001D);
int k = MathHelper.floor(this.boundingBox.c + 0.001D);
int l = MathHelper.floor(this.boundingBox.d - 0.001D);
int i1 = MathHelper.floor(this.boundingBox.e - 0.001D);
int j1 = MathHelper.floor(this.boundingBox.f - 0.001D);
if (this.world.d(i, j, k, l, i1, j1)) {
for (int k1 = i; k1 <= l; ++k1) {
for (int l1 = j; l1 <= i1; ++l1) {
for (int i2 = k; i2 <= j1; ++i2) {
int j2 = this.world.getTypeId(k1, l1, i2);
if (j2 > 0) {
Block.byId[j2].a(this.world, k1, l1, i2, this);
}
}
}
}
}
}
protected void a(int i, int j, int k, int l) {
StepSound stepsound = Block.byId[l].stepSound;
if (this.world.getTypeId(i, j + 1, k) == Block.SNOW.id) {
stepsound = Block.SNOW.stepSound;
this.makeSound(stepsound.getStepSound(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2());
} else if (!Block.byId[l].material.isLiquid()) {
this.makeSound(stepsound.getStepSound(), stepsound.getVolume1() * 0.15F, stepsound.getVolume2());
}
}
public void makeSound(String s, float f, float f1) {
this.world.makeSound(this, s, f, f1);
}
protected boolean f_() {
return true;
}
protected void a(double d0, boolean flag) {
if (flag) {
if (this.fallDistance > 0.0F) {
this.a(this.fallDistance);
this.fallDistance = 0.0F;
}
} else if (d0 < 0.0D) {
this.fallDistance = (float) ((double) this.fallDistance - d0);
}
}
public AxisAlignedBB E() {
return null;
}
protected void burn(int i) {
if (!this.fireProof) {
// CraftBukkit start
if (this instanceof EntityLiving) {
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.FIRE, i);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
i = event.getDamage();
event.getEntity().setLastDamageCause(event);
}
// CraftBukkit end
this.damageEntity(DamageSource.FIRE, i);
}
}
public final boolean isFireproof() {
return this.fireProof;
}
protected void a(float f) {
if (this.passenger != null) {
this.passenger.a(f);
}
}
public boolean G() {
return this.ad || this.world.D(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) || this.world.D(MathHelper.floor(this.locX), MathHelper.floor(this.locY + (double) this.length), MathHelper.floor(this.locZ));
}
public boolean H() {
return this.ad;
}
public boolean I() {
if (this.world.a(this.boundingBox.grow(0.0D, -0.4000000059604645D, 0.0D).shrink(0.001D, 0.001D, 0.001D), Material.WATER, this)) {
if (!this.ad && !this.justCreated) {
float f = MathHelper.sqrt(this.motX * this.motX * 0.20000000298023224D + this.motY * this.motY + this.motZ * this.motZ * 0.20000000298023224D) * 0.2F;
if (f > 1.0F) {
f = 1.0F;
}
this.makeSound("liquid.splash", f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
float f1 = (float) MathHelper.floor(this.boundingBox.b);
int i;
float f2;
float f3;
for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) {
f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
this.world.addParticle("bubble", this.locX + (double) f2, (double) (f1 + 1.0F), this.locZ + (double) f3, this.motX, this.motY - (double) (this.random.nextFloat() * 0.2F), this.motZ);
}
for (i = 0; (float) i < 1.0F + this.width * 20.0F; ++i) {
f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
f3 = (this.random.nextFloat() * 2.0F - 1.0F) * this.width;
this.world.addParticle("splash", this.locX + (double) f2, (double) (f1 + 1.0F), this.locZ + (double) f3, this.motX, this.motY, this.motZ);
}
}
this.fallDistance = 0.0F;
this.ad = true;
this.fireTicks = 0;
} else {
this.ad = false;
}
return this.ad;
}
public boolean a(Material material) {
double d0 = this.locY + (double) this.getHeadHeight();
int i = MathHelper.floor(this.locX);
int j = MathHelper.d((float) MathHelper.floor(d0));
int k = MathHelper.floor(this.locZ);
int l = this.world.getTypeId(i, j, k);
if (l != 0 && Block.byId[l].material == material) {
float f = BlockFluids.e(this.world.getData(i, j, k)) - 0.11111111F;
float f1 = (float) (j + 1) - f;
return d0 < (double) f1;
} else {
return false;
}
}
public float getHeadHeight() {
return 0.0F;
}
public boolean J() {
return this.world.a(this.boundingBox.grow(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.LAVA);
}
public void a(float f, float f1, float f2) {
float f3 = f * f + f1 * f1;
if (f3 >= 1.0E-4F) {
f3 = MathHelper.c(f3);
if (f3 < 1.0F) {
f3 = 1.0F;
}
f3 = f2 / f3;
f *= f3;
f1 *= f3;
float f4 = MathHelper.sin(this.yaw * 3.1415927F / 180.0F);
float f5 = MathHelper.cos(this.yaw * 3.1415927F / 180.0F);
this.motX += (double) (f * f5 - f1 * f4);
this.motZ += (double) (f1 * f5 + f * f4);
}
}
public float c(float f) {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locZ);
if (this.world.isLoaded(i, 0, j)) {
double d0 = (this.boundingBox.e - this.boundingBox.b) * 0.66D;
int k = MathHelper.floor(this.locY - (double) this.height + d0);
return this.world.p(i, k, j);
} else {
return 0.0F;
}
}
public void spawnIn(World world) {
// CraftBukkit start
if (world == null) {
this.die();
this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
return;
}
// CraftBukkit end
this.world = world;
}
public void setLocation(double d0, double d1, double d2, float f, float f1) {
this.lastX = this.locX = d0;
this.lastY = this.locY = d1;
this.lastZ = this.locZ = d2;
this.lastYaw = this.yaw = f;
this.lastPitch = this.pitch = f1;
this.W = 0.0F;
double d3 = (double) (this.lastYaw - f);
if (d3 < -180.0D) {
this.lastYaw += 360.0F;
}
if (d3 >= 180.0D) {
this.lastYaw -= 360.0F;
}
this.setPosition(this.locX, this.locY, this.locZ);
this.b(f, f1);
}
public void setPositionRotation(double d0, double d1, double d2, float f, float f1) {
this.T = this.lastX = this.locX = d0;
this.U = this.lastY = this.locY = d1 + (double) this.height;
this.V = this.lastZ = this.locZ = d2;
this.yaw = f;
this.pitch = f1;
this.setPosition(this.locX, this.locY, this.locZ);
}
public float d(Entity entity) {
float f = (float) (this.locX - entity.locX);
float f1 = (float) (this.locY - entity.locY);
float f2 = (float) (this.locZ - entity.locZ);
return MathHelper.c(f * f + f1 * f1 + f2 * f2);
}
public double e(double d0, double d1, double d2) {
double d3 = this.locX - d0;
double d4 = this.locY - d1;
double d5 = this.locZ - d2;
return d3 * d3 + d4 * d4 + d5 * d5;
}
public double f(double d0, double d1, double d2) {
double d3 = this.locX - d0;
double d4 = this.locY - d1;
double d5 = this.locZ - d2;
return (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
}
public double e(Entity entity) {
double d0 = this.locX - entity.locX;
double d1 = this.locY - entity.locY;
double d2 = this.locZ - entity.locZ;
return d0 * d0 + d1 * d1 + d2 * d2;
}
public void c_(EntityHuman entityhuman) {}
public void collide(Entity entity) {
if (entity.passenger != this && entity.vehicle != this) {
double d0 = entity.locX - this.locX;
double d1 = entity.locZ - this.locZ;
double d2 = MathHelper.a(d0, d1);
if (d2 >= 0.009999999776482582D) {
d2 = (double) MathHelper.sqrt(d2);
d0 /= d2;
d1 /= d2;
double d3 = 1.0D / d2;
if (d3 > 1.0D) {
d3 = 1.0D;
}
d0 *= d3;
d1 *= d3;
d0 *= 0.05000000074505806D;
d1 *= 0.05000000074505806D;
d0 *= (double) (1.0F - this.Z);
d1 *= (double) (1.0F - this.Z);
this.g(-d0, 0.0D, -d1);
entity.g(d0, 0.0D, d1);
}
}
}
public void g(double d0, double d1, double d2) {
this.motX += d0;
this.motY += d1;
this.motZ += d2;
this.am = true;
}
protected void K() {
this.velocityChanged = true;
}
public boolean damageEntity(DamageSource damagesource, int i) {
if (this.isInvulnerable()) {
return false;
} else {
this.K();
return false;
}
}
public boolean L() {
return false;
}
public boolean M() {
return false;
}
public void c(Entity entity, int i) {}
public boolean c(NBTTagCompound nbttagcompound) {
String s = this.Q();
if (!this.dead && s != null) {
nbttagcompound.setString("id", s);
this.d(nbttagcompound);
return true;
} else {
return false;
}
}
public void d(NBTTagCompound nbttagcompound) {
try {
nbttagcompound.set("Pos", this.a(new double[] { this.locX, this.locY + (double) this.W, this.locZ}));
nbttagcompound.set("Motion", this.a(new double[] { this.motX, this.motY, this.motZ}));
// CraftBukkit start - checking for NaN pitch/yaw and resetting to zero
// TODO: make sure this is the best way to address this.
if (Float.isNaN(this.yaw)) {
this.yaw = 0;
}
if (Float.isNaN(this.pitch)) {
this.pitch = 0;
}
// CraftBukkit end
nbttagcompound.set("Rotation", this.a(new float[] { this.yaw, this.pitch}));
nbttagcompound.setFloat("FallDistance", this.fallDistance);
nbttagcompound.setShort("Fire", (short) this.fireTicks);
nbttagcompound.setShort("Air", (short) this.getAirTicks());
nbttagcompound.setBoolean("OnGround", this.onGround);
nbttagcompound.setInt("Dimension", this.dimension);
nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
// CraftBukkit start
nbttagcompound.setLong("WorldUUIDLeast", this.world.getDataManager().getUUID().getLeastSignificantBits());
nbttagcompound.setLong("WorldUUIDMost", this.world.getDataManager().getUUID().getMostSignificantBits());
nbttagcompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits());
nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits());
nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL);
// CraftBukkit end
this.b(nbttagcompound);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being saved");
this.a(crashreportsystemdetails);
throw new ReportedException(crashreport);
}
}
public void e(NBTTagCompound nbttagcompound) {
try {
NBTTagList nbttaglist = nbttagcompound.getList("Pos");
NBTTagList nbttaglist1 = nbttagcompound.getList("Motion");
NBTTagList nbttaglist2 = nbttagcompound.getList("Rotation");
this.motX = ((NBTTagDouble) nbttaglist1.get(0)).data;
this.motY = ((NBTTagDouble) nbttaglist1.get(1)).data;
this.motZ = ((NBTTagDouble) nbttaglist1.get(2)).data;
/* CraftBukkit start - moved section down
if (Math.abs(this.motX) > 10.0D) {
this.motX = 0.0D;
}
if (Math.abs(this.motY) > 10.0D) {
this.motY = 0.0D;
}
if (Math.abs(this.motZ) > 10.0D) {
this.motZ = 0.0D;
}
// CraftBukkit end */
this.lastX = this.T = this.locX = ((NBTTagDouble) nbttaglist.get(0)).data;
this.lastY = this.U = this.locY = ((NBTTagDouble) nbttaglist.get(1)).data;
this.lastZ = this.V = this.locZ = ((NBTTagDouble) nbttaglist.get(2)).data;
this.lastYaw = this.yaw = ((NBTTagFloat) nbttaglist2.get(0)).data;
this.lastPitch = this.pitch = ((NBTTagFloat) nbttaglist2.get(1)).data;
this.fallDistance = nbttagcompound.getFloat("FallDistance");
this.fireTicks = nbttagcompound.getShort("Fire");
this.setAirTicks(nbttagcompound.getShort("Air"));
this.onGround = nbttagcompound.getBoolean("OnGround");
this.dimension = nbttagcompound.getInt("Dimension");
this.invulnerable = nbttagcompound.getBoolean("Invulnerable");
this.portalCooldown = nbttagcompound.getInt("PortalCooldown");
this.setPosition(this.locX, this.locY, this.locZ);
// CraftBukkit start
long least = nbttagcompound.getLong("UUIDLeast");
long most = nbttagcompound.getLong("UUIDMost");
if (least != 0L && most != 0L) {
this.uniqueId = new UUID(most, least);
}
// CraftBukkit end
this.b(this.yaw, this.pitch);
this.a(nbttagcompound);
// CraftBukkit start - exempt Vehicles from notch's sanity check
if (!(this.getBukkitEntity() instanceof Vehicle)) {
if (Math.abs(this.motX) > 10.0D) {
this.motX = 0.0D;
}
if (Math.abs(this.motY) > 10.0D) {
this.motY = 0.0D;
}
if (Math.abs(this.motZ) > 10.0D) {
this.motZ = 0.0D;
}
}
// CraftBukkit end
// CraftBukkit start - reset world
if (this instanceof EntityPlayer) {
Server server = Bukkit.getServer();
org.bukkit.World bworld = null;
// TODO: Remove World related checks, replaced with WorldUID.
String worldName = nbttagcompound.getString("World");
if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) {
UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast"));
bworld = server.getWorld(uid);
} else {
bworld = server.getWorld(worldName);
}
if (bworld == null) {
EntityPlayer entityPlayer = (EntityPlayer) this;
bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(entityPlayer.dimension).getWorld();
}
this.spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle());
}
// CraftBukkit end
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
this.a(crashreportsystemdetails);
throw new ReportedException(crashreport);
}
}
protected final String Q() {
return EntityTypes.b(this);
}
protected abstract void a(NBTTagCompound nbttagcompound);
protected abstract void b(NBTTagCompound nbttagcompound);
protected NBTTagList a(double... adouble) {
NBTTagList nbttaglist = new NBTTagList();
double[] adouble1 = adouble;
int i = adouble.length;
for (int j = 0; j < i; ++j) {
double d0 = adouble1[j];
nbttaglist.add(new NBTTagDouble((String) null, d0));
}
return nbttaglist;
}
protected NBTTagList a(float... afloat) {
NBTTagList nbttaglist = new NBTTagList();
float[] afloat1 = afloat;
int i = afloat.length;
for (int j = 0; j < i; ++j) {
float f = afloat1[j];
nbttaglist.add(new NBTTagFloat((String) null, f));
}
return nbttaglist;
}
public EntityItem b(int i, int j) {
return this.a(i, j, 0.0F);
}
public EntityItem a(int i, int j, float f) {
return this.a(new ItemStack(i, j, 0), f);
}
public EntityItem a(ItemStack itemstack, float f) {
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY + (double) f, this.locZ, itemstack);
entityitem.pickupDelay = 10;
this.world.addEntity(entityitem);
return entityitem;
}
public boolean isAlive() {
return !this.dead;
}
public boolean inBlock() {
for (int i = 0; i < 8; ++i) {
float f = ((float) ((i >> 0) % 2) - 0.5F) * this.width * 0.8F;
float f1 = ((float) ((i >> 1) % 2) - 0.5F) * 0.1F;
float f2 = ((float) ((i >> 2) % 2) - 0.5F) * this.width * 0.8F;
int j = MathHelper.floor(this.locX + (double) f);
int k = MathHelper.floor(this.locY + (double) this.getHeadHeight() + (double) f1);
int l = MathHelper.floor(this.locZ + (double) f2);
if (this.world.t(j, k, l)) {
return true;
}
}
return false;
}
public boolean a(EntityHuman entityhuman) {
return false;
}
public AxisAlignedBB g(Entity entity) {
return null;
}
public void U() {
if (this.vehicle.dead) {
this.vehicle = null;
} else {
this.motX = 0.0D;
this.motY = 0.0D;
this.motZ = 0.0D;
this.j_();
if (this.vehicle != null) {
this.vehicle.V();
this.g += (double) (this.vehicle.yaw - this.vehicle.lastYaw);
for (this.f += (double) (this.vehicle.pitch - this.vehicle.lastPitch); this.g >= 180.0D; this.g -= 360.0D) {
;
}
while (this.g < -180.0D) {
this.g += 360.0D;
}
while (this.f >= 180.0D) {
this.f -= 360.0D;
}
while (this.f < -180.0D) {
this.f += 360.0D;
}
double d0 = this.g * 0.5D;
double d1 = this.f * 0.5D;
float f = 10.0F;
if (d0 > (double) f) {
d0 = (double) f;
}
if (d0 < (double) (-f)) {
d0 = (double) (-f);
}
if (d1 > (double) f) {
d1 = (double) f;
}
if (d1 < (double) (-f)) {
d1 = (double) (-f);
}
this.g -= d0;
this.f -= d1;
this.yaw = (float) ((double) this.yaw + d0);
this.pitch = (float) ((double) this.pitch + d1);
}
}
}
public void V() {
if (!(this.passenger instanceof EntityHuman) || !((EntityHuman) this.passenger).bV()) {
this.passenger.T = this.T;
this.passenger.U = this.U + this.X() + this.passenger.W();
this.passenger.V = this.V;
}
this.passenger.setPosition(this.locX, this.locY + this.X() + this.passenger.W(), this.locZ);
}
public double W() {
return (double) this.height;
}
public double X() {
return (double) this.length * 0.75D;
}
public void mount(Entity entity) {
// CraftBukkit start
this.setPassengerOf(entity);
}
protected org.bukkit.entity.Entity bukkitEntity;
public org.bukkit.entity.Entity getBukkitEntity() {
if (this.bukkitEntity == null) {
this.bukkitEntity = org.bukkit.craftbukkit.entity.CraftEntity.getEntity(this.world.getServer(), this);
}
return this.bukkitEntity;
}
public void setPassengerOf(Entity entity) {
// b(null) doesn't really fly for overloaded methods,
// so this method is needed
PluginManager pluginManager = Bukkit.getPluginManager();
this.getBukkitEntity(); // make sure bukkitEntity is initialised
// CraftBukkit end
this.f = 0.0D;
this.g = 0.0D;
if (entity == null) {
if (this.vehicle != null) {
// CraftBukkit start
if ((this.bukkitEntity instanceof LivingEntity) && (this.vehicle.getBukkitEntity() instanceof Vehicle)) {
VehicleExitEvent event = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
pluginManager.callEvent(event);
}
// CraftBukkit end
this.setPositionRotation(this.vehicle.locX, this.vehicle.boundingBox.b + (double) this.vehicle.length, this.vehicle.locZ, this.yaw, this.pitch);
this.vehicle.passenger = null;
}
this.vehicle = null;
} else if (this.vehicle == entity) {
// CraftBukkit start
if ((this.bukkitEntity instanceof LivingEntity) && (this.vehicle.getBukkitEntity() instanceof Vehicle)) {
VehicleExitEvent event = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
pluginManager.callEvent(event);
}
// CraftBukkit end
this.h(entity);
this.vehicle.passenger = null;
this.vehicle = null;
} else {
// CraftBukkit start
if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle)) {
VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.bukkitEntity);
pluginManager.callEvent(event);
if (event.isCancelled()) {
return;
}
}
// CraftBukkit end
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
if (entity.passenger != null) {
entity.passenger.vehicle = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}
public void h(Entity entity) {
double d0 = entity.locX;
double d1 = entity.boundingBox.b + (double) entity.length;
double d2 = entity.locZ;
for (double d3 = -1.5D; d3 < 2.0D; ++d3) {
for (double d4 = -1.5D; d4 < 2.0D; ++d4) {
if (d3 != 0.0D || d4 != 0.0D) {
int i = (int) (this.locX + d3);
int j = (int) (this.locZ + d4);
AxisAlignedBB axisalignedbb = this.boundingBox.c(d3, 1.0D, d4);
if (this.world.a(axisalignedbb).isEmpty()) {
if (this.world.v(i, (int) this.locY, j)) {
this.setPositionRotation(this.locX + d3, this.locY + 1.0D, this.locZ + d4, this.yaw, this.pitch);
return;
}
if (this.world.v(i, (int) this.locY - 1, j) || this.world.getMaterial(i, (int) this.locY - 1, j) == Material.WATER) {
d0 = this.locX + d3;
d1 = this.locY + 1.0D;
d2 = this.locZ + d4;
}
}
}
}
}
this.setPositionRotation(d0, d1, d2, this.yaw, this.pitch);
}
public float Y() {
return 0.1F;
}
public Vec3D Z() {
return null;
}
public void aa() {
if (this.portalCooldown > 0) {
this.portalCooldown = this.ab();
} else {
double d0 = this.lastX - this.locX;
double d1 = this.lastZ - this.locZ;
if (!this.world.isStatic && !this.ao) {
this.ar = Direction.a(d0, d1);
}
this.ao = true;
}
}
public int ab() {
return 900;
}
public ItemStack[] getEquipment() {
return null;
}
public void setEquipment(int i, ItemStack itemstack) {}
public boolean isBurning() {
return this.fireTicks > 0 || this.e(0);
}
public boolean ag() {
return this.vehicle != null || this.e(2);
}
public boolean isSneaking() {
return this.e(1);
}
public void setSneaking(boolean flag) {
this.a(1, flag);
}
public boolean isSprinting() {
return this.e(3);
}
public void setSprinting(boolean flag) {
this.a(3, flag);
}
public boolean isInvisible() {
return this.e(5);
}
public void setInvisible(boolean flag) {
this.a(5, flag);
}
public void d(boolean flag) {
this.a(4, flag);
}
protected boolean e(int i) {
return (this.datawatcher.getByte(0) & 1 << i) != 0;
}
protected void a(int i, boolean flag) {
byte b0 = this.datawatcher.getByte(0);
if (flag) {
this.datawatcher.watch(0, Byte.valueOf((byte) (b0 | 1 << i)));
} else {
this.datawatcher.watch(0, Byte.valueOf((byte) (b0 & ~(1 << i))));
}
}
public int getAirTicks() {
return this.datawatcher.getShort(1);
}
public void setAirTicks(int i) {
this.datawatcher.watch(1, Short.valueOf((short) i));
}
public void a(EntityLightning entitylightning) {
// CraftBukkit start
final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity();
final PluginManager pluginManager = Bukkit.getPluginManager();
if (thisBukkitEntity instanceof Painting) {
PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity);
pluginManager.callEvent(event);
if (event.isCancelled()) {
return;
}
}
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(stormBukkitEntity, thisBukkitEntity, EntityDamageEvent.DamageCause.LIGHTNING, 5);
pluginManager.callEvent(event);
if (event.isCancelled()) {
return;
}
thisBukkitEntity.setLastDamageCause(event);
this.burn(event.getDamage());
// CraftBukkit end
++this.fireTicks;
if (this.fireTicks == 0) {
// CraftBukkit start - raise a combust event when lightning strikes
EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8);
pluginManager.callEvent(entityCombustEvent);
if (!entityCombustEvent.isCancelled()) {
this.setOnFire(entityCombustEvent.getDuration());
}
// CraftBukkit end
}
}
public void a(EntityLiving entityliving) {}
protected boolean i(double d0, double d1, double d2) {
int i = MathHelper.floor(d0);
int j = MathHelper.floor(d1);
int k = MathHelper.floor(d2);
double d3 = d0 - (double) i;
double d4 = d1 - (double) j;
double d5 = d2 - (double) k;
List list = this.world.a(this.boundingBox);
if (list.isEmpty() && !this.world.u(i, j, k)) {
return false;
} else {
boolean flag = !this.world.u(i - 1, j, k);
boolean flag1 = !this.world.u(i + 1, j, k);
boolean flag2 = !this.world.u(i, j - 1, k);
boolean flag3 = !this.world.u(i, j + 1, k);
boolean flag4 = !this.world.u(i, j, k - 1);
boolean flag5 = !this.world.u(i, j, k + 1);
byte b0 = 3;
double d6 = 9999.0D;
if (flag && d3 < d6) {
d6 = d3;
b0 = 0;
}
if (flag1 && 1.0D - d3 < d6) {
d6 = 1.0D - d3;
b0 = 1;
}
if (flag3 && 1.0D - d4 < d6) {
d6 = 1.0D - d4;
b0 = 3;
}
if (flag4 && d5 < d6) {
d6 = d5;
b0 = 4;
}
if (flag5 && 1.0D - d5 < d6) {
d6 = 1.0D - d5;
b0 = 5;
}
float f = this.random.nextFloat() * 0.2F + 0.1F;
if (b0 == 0) {
this.motX = (double) (-f);
}
if (b0 == 1) {
this.motX = (double) f;
}
if (b0 == 2) {
this.motY = (double) (-f);
}
if (b0 == 3) {
this.motY = (double) f;
}
if (b0 == 4) {
this.motZ = (double) (-f);
}
if (b0 == 5) {
this.motZ = (double) f;
}
return true;
}
}
public void am() {
this.J = true;
this.fallDistance = 0.0F;
}
public String getLocalizedName() {
String s = EntityTypes.b(this);
if (s == null) {
s = "generic";
}
return LocaleI18n.get("entity." + s + ".name");
}
public Entity[] ao() {
return null;
}
public boolean i(Entity entity) {
return this == entity;
}
public float ap() {
return 0.0F;
}
public boolean aq() {
return true;
}
public boolean j(Entity entity) {
return false;
}
public String toString() {
return String.format("%s[\'%s\'/%d, l=\'%s\', x=%.2f, y=%.2f, z=%.2f]", new Object[] { this.getClass().getSimpleName(), this.getLocalizedName(), Integer.valueOf(this.id), this.world == null ? "~NULL~" : this.world.getWorldData().getName(), Double.valueOf(this.locX), Double.valueOf(this.locY), Double.valueOf(this.locZ)});
}
public boolean isInvulnerable() {
return this.invulnerable;
}
public void k(Entity entity) {
this.setPositionRotation(entity.locX, entity.locY, entity.locZ, entity.yaw, entity.pitch);
}
public void a(Entity entity, boolean flag) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
entity.d(nbttagcompound);
this.e(nbttagcompound);
this.portalCooldown = entity.portalCooldown;
this.ar = entity.ar;
}
public void b(int i) {
if (false && !this.world.isStatic && !this.dead) { // CraftBukkit - disable entity portal support for now.
this.world.methodProfiler.a("changeDimension");
MinecraftServer minecraftserver = MinecraftServer.getServer();
int j = this.dimension;
WorldServer worldserver = minecraftserver.getWorldServer(j);
WorldServer worldserver1 = minecraftserver.getWorldServer(i);
this.dimension = i;
this.world.kill(this);
this.dead = false;
this.world.methodProfiler.a("reposition");
minecraftserver.getPlayerList().a(this, j, worldserver, worldserver1);
this.world.methodProfiler.c("reloading");
Entity entity = EntityTypes.createEntityByName(EntityTypes.b(this), worldserver1);
if (entity != null) {
entity.a(this, true);
worldserver1.addEntity(entity);
}
this.dead = true;
this.world.methodProfiler.b();
worldserver.i();
worldserver1.i();
this.world.methodProfiler.b();
}
}
public float a(Explosion explosion, Block block, int i, int j, int k) {
return block.a(this);
}
public int as() {
return 3;
}
public int at() {
return this.ar;
}
public boolean au() {
return false;
}
public void a(CrashReportSystemDetails crashreportsystemdetails) {
crashreportsystemdetails.a("Entity Type", (Callable) (new CrashReportEntityType(this)));
crashreportsystemdetails.a("Entity ID", Integer.valueOf(this.id));
crashreportsystemdetails.a("Name", this.getLocalizedName());
crashreportsystemdetails.a("Exact location", String.format("%.2f, %.2f, %.2f", new Object[] { Double.valueOf(this.locX), Double.valueOf(this.locY), Double.valueOf(this.locZ)}));
crashreportsystemdetails.a("Block location", CrashReportSystemDetails.a(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)));
crashreportsystemdetails.a("Momentum", String.format("%.2f, %.2f, %.2f", new Object[] { Double.valueOf(this.motX), Double.valueOf(this.motY), Double.valueOf(this.motZ)}));
}
}
|