-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
World.java.patch
1022 lines (936 loc) · 43.4 KB
/
World.java.patch
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
--- ../src-base/minecraft/net/minecraft/world/World.java
+++ ../src-work/minecraft/net/minecraft/world/World.java
@@ -59,8 +59,15 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
-public abstract class World implements IBlockAccess
+public abstract class World implements IBlockAccess, net.minecraftforge.common.capabilities.ICapabilityProvider
{
+ /**
+ * Used in the getEntitiesWithinAABB functions to expand the search area for entities.
+ * Modders should change this variable to a higher value if it is less then the radius
+ * of one of there entities.
+ */
+ public static double MAX_ENTITY_RADIUS = 2.0D;
+
private int field_181546_a = 63;
protected boolean field_72999_e;
public final List<Entity> field_72996_f = Lists.<Entity>newArrayList();
@@ -102,6 +109,12 @@
private final WorldBorder field_175728_M;
int[] field_72994_J;
+ public boolean restoringBlockSnapshots = false;
+ public boolean captureBlockSnapshots = false;
+ public java.util.ArrayList<net.minecraftforge.common.util.BlockSnapshot> capturedBlockSnapshots = new java.util.ArrayList<net.minecraftforge.common.util.BlockSnapshot>();
+ private net.minecraftforge.common.capabilities.CapabilityDispatcher capabilities;
+ private net.minecraftforge.common.util.WorldCapabilityData capabilityData;
+
protected World(ISaveHandler p_i45749_1_, WorldInfo p_i45749_2_, WorldProvider p_i45749_3_, Profiler p_i45749_4_, boolean p_i45749_5_)
{
this.field_73021_x = Lists.newArrayList(new IWorldEventListener[] {this.field_184152_t});
@@ -116,6 +129,7 @@
this.field_73011_w = p_i45749_3_;
this.field_72995_K = p_i45749_5_;
this.field_175728_M = p_i45749_3_.func_177501_r();
+ perWorldStorage = new MapStorage((ISaveHandler)null);
}
public World func_175643_b()
@@ -125,6 +139,11 @@
public Biome func_180494_b(final BlockPos p_180494_1_)
{
+ return this.field_73011_w.getBiomeForCoords(p_180494_1_);
+ }
+
+ public Biome getBiomeForCoordsBody(final BlockPos p_180494_1_)
+ {
if (this.func_175667_e(p_180494_1_))
{
Chunk chunk = this.func_175726_f(p_180494_1_);
@@ -201,7 +220,7 @@
public boolean func_175623_d(BlockPos p_175623_1_)
{
- return this.func_180495_p(p_175623_1_).func_185904_a() == Material.field_151579_a;
+ return this.func_180495_p(p_175623_1_).func_177230_c().isAir(this.func_180495_p(p_175623_1_), this, p_175623_1_);
}
public boolean func_175667_e(BlockPos p_175667_1_)
@@ -302,24 +321,50 @@
else
{
Chunk chunk = this.func_175726_f(p_180501_1_);
- Block block = p_180501_2_.func_177230_c();
+
+ net.minecraftforge.common.util.BlockSnapshot blockSnapshot = null;
+ if (this.captureBlockSnapshots && !this.field_72995_K)
+ {
+ blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(this, p_180501_1_, p_180501_3_);
+ this.capturedBlockSnapshots.add(blockSnapshot);
+ }
+ IBlockState oldState = func_180495_p(p_180501_1_);
+ int oldLight = oldState.getLightValue(this, p_180501_1_);
+ int oldOpacity = oldState.getLightOpacity(this, p_180501_1_);
+
IBlockState iblockstate = chunk.func_177436_a(p_180501_1_, p_180501_2_);
if (iblockstate == null)
{
+ if (blockSnapshot != null) this.capturedBlockSnapshots.remove(blockSnapshot);
return false;
}
else
{
- if (p_180501_2_.func_185891_c() != iblockstate.func_185891_c() || p_180501_2_.func_185906_d() != iblockstate.func_185906_d())
+ if (p_180501_2_.getLightOpacity(this, p_180501_1_) != oldOpacity || p_180501_2_.getLightValue(this, p_180501_1_) != oldLight)
{
this.field_72984_F.func_76320_a("checkLight");
this.func_175664_x(p_180501_1_);
this.field_72984_F.func_76319_b();
}
- if ((p_180501_3_ & 2) != 0 && (!this.field_72995_K || (p_180501_3_ & 4) == 0) && chunk.func_150802_k())
+ if (blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates
{
+ this.markAndNotifyBlock(p_180501_1_, chunk, iblockstate, p_180501_2_, p_180501_3_);
+ }
+ return true;
+ }
+ }
+ }
+
+ // Split off from original setBlockState(BlockPos, IBlockState, int) method in order to directly send client and physic updates
+ public void markAndNotifyBlock(BlockPos p_180501_1_, @Nullable Chunk chunk, IBlockState iblockstate, IBlockState p_180501_2_, int p_180501_3_)
+ {
+ Block block = p_180501_2_.func_177230_c();
+ {
+ {
+ if ((p_180501_3_ & 2) != 0 && (!this.field_72995_K || (p_180501_3_ & 4) == 0) && (chunk == null || chunk.func_150802_k()))
+ {
this.func_184138_a(p_180501_1_, iblockstate, p_180501_2_, p_180501_3_);
}
@@ -336,8 +381,6 @@
{
this.func_190522_c(p_180501_1_, block);
}
-
- return true;
}
}
}
@@ -352,7 +395,7 @@
IBlockState iblockstate = this.func_180495_p(p_175655_1_);
Block block = iblockstate.func_177230_c();
- if (iblockstate.func_185904_a() == Material.field_151579_a)
+ if (block.isAir(iblockstate, this, p_175655_1_))
{
return false;
}
@@ -435,6 +478,9 @@
public void func_175685_c(BlockPos p_175685_1_, Block p_175685_2_, boolean p_175685_3_)
{
+ if(net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_175685_1_, this.func_180495_p(p_175685_1_), java.util.EnumSet.allOf(EnumFacing.class), p_175685_3_).isCanceled())
+ return;
+
this.func_190524_a(p_175685_1_.func_177976_e(), p_175685_2_, p_175685_1_);
this.func_190524_a(p_175685_1_.func_177974_f(), p_175685_2_, p_175685_1_);
this.func_190524_a(p_175685_1_.func_177977_b(), p_175685_2_, p_175685_1_);
@@ -450,6 +496,11 @@
public void func_175695_a(BlockPos p_175695_1_, Block p_175695_2_, EnumFacing p_175695_3_)
{
+ java.util.EnumSet<EnumFacing> directions = java.util.EnumSet.allOf(EnumFacing.class);
+ directions.remove(p_175695_3_);
+ if(net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(this, p_175695_1_, this.func_180495_p(p_175695_1_), directions, false).isCanceled())
+ return;
+
if (p_175695_3_ != EnumFacing.WEST)
{
this.func_190524_a(p_175695_1_.func_177976_e(), p_175695_2_, p_175695_1_);
@@ -521,11 +572,11 @@
{
IBlockState iblockstate = this.func_180495_p(p_190529_1_);
- if (iblockstate.func_177230_c() == Blocks.field_190976_dk)
+ if (true)
{
try
{
- ((BlockObserver)iblockstate.func_177230_c()).func_190962_b(iblockstate, this, p_190529_1_, p_190529_2_, p_190529_3_);
+ iblockstate.func_177230_c().observedNeighborChange(iblockstate, this, p_190529_1_, p_190529_2_, p_190529_3_);
}
catch (Throwable throwable)
{
@@ -582,7 +633,7 @@
{
IBlockState iblockstate = this.func_180495_p(blockpos);
- if (iblockstate.func_185891_c() > 0 && !iblockstate.func_185904_a().func_76224_d())
+ if (iblockstate.func_177230_c().getLightOpacity(iblockstate, this, blockpos) > 0 && !iblockstate.func_185904_a().func_76224_d())
{
return false;
}
@@ -856,7 +907,7 @@
public boolean func_72935_r()
{
- return this.field_73008_k < 4;
+ return this.field_73011_w.isDaytime();
}
@Nullable
@@ -1059,6 +1110,13 @@
public void func_184148_a(@Nullable EntityPlayer p_184148_1_, double p_184148_2_, double p_184148_4_, double p_184148_6_, SoundEvent p_184148_8_, SoundCategory p_184148_9_, float p_184148_10_, float p_184148_11_)
{
+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_184148_1_, p_184148_8_, p_184148_9_, p_184148_10_, p_184148_11_);
+ if (event.isCanceled() || event.getSound() == null) return;
+ p_184148_8_ = event.getSound();
+ p_184148_9_ = event.getCategory();
+ p_184148_10_ = event.getVolume();
+ p_184148_11_ = event.getPitch();
+
for (int i = 0; i < this.field_73021_x.size(); ++i)
{
((IWorldEventListener)this.field_73021_x.get(i)).func_184375_a(p_184148_1_, p_184148_8_, p_184148_9_, p_184148_2_, p_184148_4_, p_184148_6_, p_184148_10_, p_184148_11_);
@@ -1112,6 +1170,9 @@
public boolean func_72838_d(Entity p_72838_1_)
{
+ // do not drop any items while restoring blocksnapshots. Prevents dupes
+ if (!this.field_72995_K && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false;
+
int i = MathHelper.func_76128_c(p_72838_1_.field_70165_t / 16.0D);
int j = MathHelper.func_76128_c(p_72838_1_.field_70161_v / 16.0D);
boolean flag = p_72838_1_.field_98038_p;
@@ -1134,6 +1195,8 @@
this.func_72854_c();
}
+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_72838_1_, this)) && !flag) return false;
+
this.func_72964_e(i, j).func_76612_a(p_72838_1_);
this.field_72996_f.add(p_72838_1_);
this.func_72923_a(p_72838_1_);
@@ -1262,6 +1325,7 @@
}
iblockstate1.func_185908_a(this, blockpos$pooledmutableblockpos, p_191504_2_, p_191504_4_, p_191504_1_, false);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.GetCollisionBoxesEvent(this, null, p_191504_2_, p_191504_4_));
if (p_191504_3_ && !p_191504_4_.isEmpty())
{
@@ -1313,11 +1377,10 @@
}
}
}
-
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.GetCollisionBoxesEvent(this, p_184144_1_, p_184144_2_, list));
return list;
}
- @SideOnly(Side.CLIENT)
public void func_72848_b(IWorldEventListener p_72848_1_)
{
this.field_73021_x.remove(p_72848_1_);
@@ -1355,19 +1418,38 @@
public int func_72967_a(float p_72967_1_)
{
+ float f = field_73011_w.getSunBrightnessFactor(p_72967_1_);
+ f = 1 - f;
+ return (int)(f * 11);
+ }
+
+ /**
+ * The current sun brightness factor for this dimension.
+ * 0.0f means no light at all, and 1.0f means maximum sunlight.
+ * Highly recommended for sunlight detection like solar panel.
+ *
+ * @return The current brightness factor
+ * */
+ public float getSunBrightnessFactor(float p_72967_1_)
+ {
float f = this.func_72826_c(p_72967_1_);
float f1 = 1.0F - (MathHelper.func_76134_b(f * ((float)Math.PI * 2F)) * 2.0F + 0.5F);
f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F);
f1 = 1.0F - f1;
f1 = (float)((double)f1 * (1.0D - (double)(this.func_72867_j(p_72967_1_) * 5.0F) / 16.0D));
f1 = (float)((double)f1 * (1.0D - (double)(this.func_72819_i(p_72967_1_) * 5.0F) / 16.0D));
- f1 = 1.0F - f1;
- return (int)(f1 * 11.0F);
+ return f1;
}
@SideOnly(Side.CLIENT)
public float func_72971_b(float p_72971_1_)
{
+ return this.field_73011_w.getSunBrightness(p_72971_1_);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public float getSunBrightnessBody(float p_72971_1_)
+ {
float f = this.func_72826_c(p_72971_1_);
float f1 = 1.0F - (MathHelper.func_76134_b(f * ((float)Math.PI * 2F)) * 2.0F + 0.2F);
f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F);
@@ -1380,6 +1462,12 @@
@SideOnly(Side.CLIENT)
public Vec3d func_72833_a(Entity p_72833_1_, float p_72833_2_)
{
+ return this.field_73011_w.getSkyColor(p_72833_1_, p_72833_2_);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public Vec3d getSkyColorBody(Entity p_72833_1_, float p_72833_2_)
+ {
float f = this.func_72826_c(p_72833_2_);
float f1 = MathHelper.func_76134_b(f * ((float)Math.PI * 2F)) * 2.0F + 0.5F;
f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F);
@@ -1387,9 +1475,7 @@
int j = MathHelper.func_76128_c(p_72833_1_.field_70163_u);
int k = MathHelper.func_76128_c(p_72833_1_.field_70161_v);
BlockPos blockpos = new BlockPos(i, j, k);
- Biome biome = this.func_180494_b(blockpos);
- float f2 = biome.func_180626_a(blockpos);
- int l = biome.func_76731_a(f2);
+ int l = net.minecraftforge.client.ForgeHooksClient.getSkyBlendColour(this, blockpos);
float f3 = (float)(l >> 16 & 255) / 255.0F;
float f4 = (float)(l >> 8 & 255) / 255.0F;
float f5 = (float)(l & 255) / 255.0F;
@@ -1438,20 +1524,25 @@
public float func_72826_c(float p_72826_1_)
{
- return this.field_73011_w.func_76563_a(this.field_72986_A.func_76073_f(), p_72826_1_);
+ return this.field_73011_w.func_76563_a(this.func_72820_D(), p_72826_1_);
}
@SideOnly(Side.CLIENT)
public int func_72853_d()
{
- return this.field_73011_w.func_76559_b(this.field_72986_A.func_76073_f());
+ return this.field_73011_w.func_76559_b(this.func_72820_D());
}
public float func_130001_d()
{
- return WorldProvider.field_111203_a[this.field_73011_w.func_76559_b(this.field_72986_A.func_76073_f())];
+ return field_73011_w.getCurrentMoonPhaseFactor();
}
+ public float getCurrentMoonPhaseFactorBody()
+ {
+ return WorldProvider.field_111203_a[this.field_73011_w.func_76559_b(this.func_72820_D())];
+ }
+
public float func_72929_e(float p_72929_1_)
{
float f = this.func_72826_c(p_72929_1_);
@@ -1461,6 +1552,12 @@
@SideOnly(Side.CLIENT)
public Vec3d func_72824_f(float p_72824_1_)
{
+ return this.field_73011_w.getCloudColor(p_72824_1_);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public Vec3d getCloudColorBody(float p_72824_1_)
+ {
float f = this.func_72826_c(p_72824_1_);
float f1 = MathHelper.func_76134_b(f * ((float)Math.PI * 2F)) * 2.0F + 0.5F;
f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F);
@@ -1516,9 +1613,9 @@
for (blockpos = new BlockPos(p_175672_1_.func_177958_n(), chunk.func_76625_h() + 16, p_175672_1_.func_177952_p()); blockpos.func_177956_o() >= 0; blockpos = blockpos1)
{
blockpos1 = blockpos.func_177977_b();
- Material material = chunk.func_177435_g(blockpos1).func_185904_a();
+ IBlockState state = chunk.func_177435_g(blockpos1);
- if (material.func_76230_c() && material != Material.field_151584_j)
+ if (state.func_185904_a().func_76230_c() && !state.func_177230_c().isLeaves(state, this, blockpos1) && !state.func_177230_c().isFoliage(this, blockpos1))
{
break;
}
@@ -1530,6 +1627,12 @@
@SideOnly(Side.CLIENT)
public float func_72880_h(float p_72880_1_)
{
+ return this.field_73011_w.getStarBrightness(p_72880_1_);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public float getStarBrightnessBody(float p_72880_1_)
+ {
float f = this.func_72826_c(p_72880_1_);
float f1 = 1.0F - (MathHelper.func_76134_b(f * ((float)Math.PI * 2F)) * 2.0F + 0.25F);
f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F);
@@ -1564,6 +1667,7 @@
try
{
+ if(entity.updateBlocked) continue;
++entity.field_70173_aa;
entity.func_70071_h_();
}
@@ -1581,6 +1685,12 @@
entity.func_85029_a(crashreportcategory);
}
+ if (net.minecraftforge.common.ForgeModContainer.removeErroringEntities)
+ {
+ net.minecraftforge.fml.common.FMLLog.severe(crashreport.func_71502_e());
+ func_72900_e(entity);
+ }
+ else
throw new ReportedException(crashreport);
}
@@ -1642,6 +1752,12 @@
CrashReport crashreport1 = CrashReport.func_85055_a(throwable1, "Ticking entity");
CrashReportCategory crashreportcategory1 = crashreport1.func_85058_a("Entity being ticked");
entity2.func_85029_a(crashreportcategory1);
+ if (net.minecraftforge.common.ForgeModContainer.removeErroringEntities)
+ {
+ net.minecraftforge.fml.common.FMLLog.severe(crashreport1.func_71502_e());
+ func_72900_e(entity2);
+ }
+ else
throw new ReportedException(crashreport1);
}
}
@@ -1678,11 +1794,11 @@
{
BlockPos blockpos = tileentity.func_174877_v();
- if (this.func_175667_e(blockpos) && this.field_175728_M.func_177746_a(blockpos))
+ if (this.func_175668_a(blockpos, false) && this.field_175728_M.func_177746_a(blockpos)) //Forge: Fix TE's getting an extra tick on the client side....
{
try
{
- this.field_72984_F.func_76320_a(tileentity.getClass().getSimpleName());
+ this.field_72984_F.startSection(tileentity.getClass()); // Fix for MC-117087
((ITickable)tileentity).func_73660_a();
this.field_72984_F.func_76319_b();
}
@@ -1691,6 +1807,13 @@
CrashReport crashreport2 = CrashReport.func_85055_a(throwable, "Ticking block entity");
CrashReportCategory crashreportcategory2 = crashreport2.func_85058_a("Block entity being ticked");
tileentity.func_145828_a(crashreportcategory2);
+ if (net.minecraftforge.common.ForgeModContainer.removeErroringTileEntities)
+ {
+ net.minecraftforge.fml.common.FMLLog.severe(crashreport2.func_71502_e());
+ tileentity.func_145843_s();
+ this.func_175713_t(tileentity.func_174877_v());
+ }
+ else
throw new ReportedException(crashreport2);
}
}
@@ -1703,20 +1826,28 @@
if (this.func_175667_e(tileentity.func_174877_v()))
{
- this.func_175726_f(tileentity.func_174877_v()).func_177425_e(tileentity.func_174877_v());
+ //Forge: Bugfix: If we set the tile entity it immediately sets it in the chunk, so we could be desyned
+ Chunk chunk = this.func_175726_f(tileentity.func_174877_v());
+ if (chunk.func_177424_a(tileentity.func_174877_v(), net.minecraft.world.chunk.Chunk.EnumCreateEntityType.CHECK) == tileentity)
+ chunk.func_177425_e(tileentity.func_174877_v());
}
}
}
- this.field_147481_N = false;
-
if (!this.field_147483_b.isEmpty())
{
+ for (Object tile : field_147483_b)
+ {
+ ((TileEntity)tile).onChunkUnload();
+ }
+
this.field_175730_i.removeAll(this.field_147483_b);
this.field_147482_g.removeAll(this.field_147483_b);
this.field_147483_b.clear();
}
+ this.field_147481_N = false; //FML Move below remove to prevent CMEs
+
this.field_72984_F.func_76318_c("pendingBlockEntities");
if (!this.field_147484_a.isEmpty())
@@ -1755,12 +1886,18 @@
public boolean func_175700_a(TileEntity p_175700_1_)
{
+ // Forge - set the world early as vanilla doesn't set it until next tick
+ if (p_175700_1_.func_145831_w() != this) p_175700_1_.func_145834_a(this);
+ // Forge: wait to add new TE if we're currently processing existing ones
+ if (field_147481_N) return field_147484_a.add(p_175700_1_);
+
boolean flag = this.field_147482_g.add(p_175700_1_);
if (flag && p_175700_1_ instanceof ITickable)
{
this.field_175730_i.add(p_175700_1_);
}
+ p_175700_1_.onLoad();
if (this.field_72995_K)
{
@@ -1776,6 +1913,11 @@
{
if (this.field_147481_N)
{
+ for (TileEntity te : p_147448_1_)
+ {
+ if (te.func_145831_w() != this) // Forge - set the world early as vanilla doesn't set it until next tick
+ te.func_145834_a(this);
+ }
this.field_147484_a.addAll(p_147448_1_);
}
else
@@ -1796,9 +1938,12 @@
{
int i = MathHelper.func_76128_c(p_72866_1_.field_70165_t);
int j = MathHelper.func_76128_c(p_72866_1_.field_70161_v);
- int k = 32;
+ boolean isForced = getPersistentChunks().containsKey(new net.minecraft.util.math.ChunkPos(i >> 4, j >> 4));
+ int k = isForced ? 0 : 32;
+ boolean canUpdate = !p_72866_2_ || this.func_175663_a(i - k, 0, j - k, i + k, 0, j + k, true);
+ if (!canUpdate) canUpdate = net.minecraftforge.event.ForgeEventFactory.canEntityUpdate(p_72866_1_);
- if (!p_72866_2_ || this.func_175663_a(i - 32, 0, j - 32, i + 32, 0, j + 32, true))
+ if (canUpdate)
{
p_72866_1_.field_70142_S = p_72866_1_.field_70165_t;
p_72866_1_.field_70137_T = p_72866_1_.field_70163_u;
@@ -1816,6 +1961,7 @@
}
else
{
+ if(!p_72866_1_.updateBlocked)
p_72866_1_.func_70071_h_();
}
}
@@ -1997,6 +2143,11 @@
blockpos$pooledmutableblockpos.func_185344_t();
return true;
}
+ else if (block.isBurning(this, new BlockPos(k1, l1, i2)))
+ {
+ blockpos$pooledmutableblockpos.func_185344_t();
+ return true;
+ }
}
}
}
@@ -2036,6 +2187,16 @@
IBlockState iblockstate = this.func_180495_p(blockpos$pooledmutableblockpos);
Block block = iblockstate.func_177230_c();
+ Boolean result = block.isEntityInsideMaterial(this, blockpos$pooledmutableblockpos, iblockstate, p_72918_3_, (double)l, p_72918_2_, false);
+ if (result != null && result == true)
+ {
+ // Forge: When requested call blocks modifyAcceleration method, and more importantly cause this method to return true, which results in an entity being "inWater"
+ flag = true;
+ vec3d = block.func_176197_a(this, blockpos$pooledmutableblockpos, p_72918_3_, vec3d);
+ continue;
+ }
+ else if (result != null && result == false) continue;
+
if (iblockstate.func_185904_a() == p_72918_2_)
{
double d0 = (double)((float)(l1 + 1) - BlockLiquid.func_149801_b(((Integer)iblockstate.func_177229_b(BlockLiquid.field_176367_b)).intValue()));
@@ -2102,6 +2263,7 @@
public Explosion func_72885_a(@Nullable Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_)
{
Explosion explosion = new Explosion(this, p_72885_1_, p_72885_2_, p_72885_4_, p_72885_6_, p_72885_8_, p_72885_9_, p_72885_10_);
+ if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) return explosion;
explosion.func_77278_a();
explosion.func_77279_a(true);
return explosion;
@@ -2224,6 +2386,7 @@
public void func_175690_a(BlockPos p_175690_1_, @Nullable TileEntity p_175690_2_)
{
+ p_175690_1_ = p_175690_1_.func_185334_h(); // Forge - prevent mutable BlockPos leaks
if (!this.func_189509_E(p_175690_1_))
{
if (p_175690_2_ != null && !p_175690_2_.func_145837_r())
@@ -2231,6 +2394,8 @@
if (this.field_147481_N)
{
p_175690_2_.func_174878_a(p_175690_1_);
+ if (p_175690_2_.func_145831_w() != this)
+ p_175690_2_.func_145834_a(this); // Forge - set the world early as vanilla doesn't set it until next tick
Iterator<TileEntity> iterator = this.field_147484_a.iterator();
while (iterator.hasNext())
@@ -2248,7 +2413,8 @@
}
else
{
- this.func_175726_f(p_175690_1_).func_177426_a(p_175690_1_, p_175690_2_);
+ Chunk chunk = this.func_175726_f(p_175690_1_);
+ if (chunk != null) chunk.func_177426_a(p_175690_1_, p_175690_2_);
this.func_175700_a(p_175690_2_);
}
}
@@ -2263,6 +2429,8 @@
{
tileentity.func_145843_s();
this.field_147484_a.remove(tileentity);
+ if (!(tileentity instanceof ITickable)) //Forge: If they are not tickable they wont be removed in the update loop.
+ this.field_147482_g.remove(tileentity);
}
else
{
@@ -2275,6 +2443,7 @@
this.func_175726_f(p_175713_1_).func_177425_e(p_175713_1_);
}
+ this.func_175666_e(p_175713_1_, func_180495_p(p_175713_1_).func_177230_c()); //Notify neighbors of changes
}
public void func_147457_a(TileEntity p_147457_1_)
@@ -2301,7 +2470,7 @@
if (chunk != null && !chunk.func_76621_g())
{
IBlockState iblockstate = this.func_180495_p(p_175677_1_);
- return iblockstate.func_185904_a().func_76218_k() && iblockstate.func_185917_h();
+ return iblockstate.func_177230_c().isNormalCube(iblockstate, this, p_175677_1_);
}
else
{
@@ -2324,6 +2493,7 @@
{
this.field_72985_G = p_72891_1_;
this.field_72992_H = p_72891_2_;
+ this.field_73011_w.setAllowedSpawnTypes(p_72891_1_, p_72891_2_);
}
public void func_72835_b()
@@ -2333,6 +2503,11 @@
protected void func_72947_a()
{
+ this.field_73011_w.calculateInitialWeather();
+ }
+
+ public void calculateInitialWeatherBody()
+ {
if (this.field_72986_A.func_76059_o())
{
this.field_73004_o = 1.0F;
@@ -2346,6 +2521,11 @@
protected void func_72979_l()
{
+ this.field_73011_w.updateWeather();
+ }
+
+ public void updateWeatherBody()
+ {
if (this.field_73011_w.func_191066_m())
{
if (!this.field_72995_K)
@@ -2470,6 +2650,11 @@
public boolean func_175670_e(BlockPos p_175670_1_, boolean p_175670_2_)
{
+ return this.field_73011_w.canBlockFreeze(p_175670_1_, p_175670_2_);
+ }
+
+ public boolean canBlockFreezeBody(BlockPos p_175670_1_, boolean p_175670_2_)
+ {
Biome biome = this.func_180494_b(p_175670_1_);
float f = biome.func_180626_a(p_175670_1_);
@@ -2511,6 +2696,11 @@
public boolean func_175708_f(BlockPos p_175708_1_, boolean p_175708_2_)
{
+ return this.field_73011_w.canSnowAt(p_175708_1_, p_175708_2_);
+ }
+
+ public boolean canSnowAtBody(BlockPos p_175708_1_, boolean p_175708_2_)
+ {
Biome biome = this.func_180494_b(p_175708_1_);
float f = biome.func_180626_a(p_175708_1_);
@@ -2528,7 +2718,7 @@
{
IBlockState iblockstate = this.func_180495_p(p_175708_1_);
- if (iblockstate.func_185904_a() == Material.field_151579_a && Blocks.field_150431_aC.func_176196_c(this, p_175708_1_))
+ if (iblockstate.func_177230_c().isAir(iblockstate, this, p_175708_1_) && Blocks.field_150431_aC.func_176196_c(this, p_175708_1_))
{
return true;
}
@@ -2560,10 +2750,11 @@
else
{
IBlockState iblockstate = this.func_180495_p(p_175638_1_);
- int i = p_175638_2_ == EnumSkyBlock.SKY ? 0 : iblockstate.func_185906_d();
- int j = iblockstate.func_185891_c();
+ int blockLight = iblockstate.func_177230_c().getLightValue(iblockstate, this, p_175638_1_);
+ int i = p_175638_2_ == EnumSkyBlock.SKY ? 0 : blockLight;
+ int j = iblockstate.func_177230_c().getLightOpacity(iblockstate, this, p_175638_1_);
- if (j >= 15 && iblockstate.func_185906_d() > 0)
+ if (j >= 15 && blockLight > 0)
{
j = 1;
}
@@ -2597,6 +2788,7 @@
if (i >= 14)
{
+ blockpos$pooledmutableblockpos.func_185344_t(); // Forge fix mutable blockpos leak MC-114281
return i;
}
}
@@ -2662,7 +2854,7 @@
int j4 = j2 + enumfacing.func_96559_d();
int k4 = k2 + enumfacing.func_82599_e();
blockpos$pooledmutableblockpos.func_181079_c(i4, j4, k4);
- int l4 = Math.max(1, this.func_180495_p(blockpos$pooledmutableblockpos).func_185891_c());
+ int l4 = Math.max(1, this.func_180495_p(blockpos$pooledmutableblockpos).func_177230_c().getLightOpacity(this.func_180495_p(blockpos$pooledmutableblockpos), this, blockpos$pooledmutableblockpos));
i3 = this.func_175642_b(p_180500_1_, blockpos$pooledmutableblockpos);
if (i3 == l2 - l4 && j < this.field_72994_J.length)
@@ -2770,10 +2962,10 @@
public List<Entity> func_175674_a(@Nullable Entity p_175674_1_, AxisAlignedBB p_175674_2_, @Nullable Predicate <? super Entity > p_175674_3_)
{
List<Entity> list = Lists.<Entity>newArrayList();
- int i = MathHelper.func_76128_c((p_175674_2_.field_72340_a - 2.0D) / 16.0D);
- int j = MathHelper.func_76128_c((p_175674_2_.field_72336_d + 2.0D) / 16.0D);
- int k = MathHelper.func_76128_c((p_175674_2_.field_72339_c - 2.0D) / 16.0D);
- int l = MathHelper.func_76128_c((p_175674_2_.field_72334_f + 2.0D) / 16.0D);
+ int i = MathHelper.func_76128_c((p_175674_2_.field_72340_a - MAX_ENTITY_RADIUS) / 16.0D);
+ int j = MathHelper.func_76128_c((p_175674_2_.field_72336_d + MAX_ENTITY_RADIUS) / 16.0D);
+ int k = MathHelper.func_76128_c((p_175674_2_.field_72339_c - MAX_ENTITY_RADIUS) / 16.0D);
+ int l = MathHelper.func_76128_c((p_175674_2_.field_72334_f + MAX_ENTITY_RADIUS) / 16.0D);
for (int i1 = i; i1 <= j; ++i1)
{
@@ -2826,10 +3018,10 @@
public <T extends Entity> List<T> func_175647_a(Class <? extends T > p_175647_1_, AxisAlignedBB p_175647_2_, @Nullable Predicate <? super T > p_175647_3_)
{
- int i = MathHelper.func_76128_c((p_175647_2_.field_72340_a - 2.0D) / 16.0D);
- int j = MathHelper.func_76143_f((p_175647_2_.field_72336_d + 2.0D) / 16.0D);
- int k = MathHelper.func_76128_c((p_175647_2_.field_72339_c - 2.0D) / 16.0D);
- int l = MathHelper.func_76143_f((p_175647_2_.field_72334_f + 2.0D) / 16.0D);
+ int i = MathHelper.func_76128_c((p_175647_2_.field_72340_a - MAX_ENTITY_RADIUS) / 16.0D);
+ int j = MathHelper.func_76143_f((p_175647_2_.field_72336_d + MAX_ENTITY_RADIUS) / 16.0D);
+ int k = MathHelper.func_76128_c((p_175647_2_.field_72339_c - MAX_ENTITY_RADIUS) / 16.0D);
+ int l = MathHelper.func_76143_f((p_175647_2_.field_72334_f + MAX_ENTITY_RADIUS) / 16.0D);
List<T> list = Lists.<T>newArrayList();
for (int i1 = i; i1 < j; ++i1)
@@ -2909,11 +3101,13 @@
public void func_175650_b(Collection<Entity> p_175650_1_)
{
- this.field_72996_f.addAll(p_175650_1_);
-
for (Entity entity : p_175650_1_)
{
- this.func_72923_a(entity);
+ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(entity, this)))
+ {
+ field_72996_f.add(entity);
+ this.func_72923_a(entity);
+ }
}
}
@@ -2926,7 +3120,7 @@
{
IBlockState iblockstate = this.func_180495_p(p_190527_2_);
AxisAlignedBB axisalignedbb = p_190527_3_ ? null : p_190527_1_.func_176223_P().func_185890_d(this, p_190527_2_);
- return axisalignedbb != Block.field_185506_k && !this.func_72917_a(axisalignedbb.func_186670_a(p_190527_2_), p_190527_5_) ? false : (iblockstate.func_185904_a() == Material.field_151594_q && p_190527_1_ == Blocks.field_150467_bQ ? true : iblockstate.func_185904_a().func_76222_j() && p_190527_1_.func_176198_a(this, p_190527_2_, p_190527_4_));
+ return axisalignedbb != Block.field_185506_k && !this.func_72917_a(axisalignedbb.func_186670_a(p_190527_2_), p_190527_5_) ? false : (iblockstate.func_185904_a() == Material.field_151594_q && p_190527_1_ == Blocks.field_150467_bQ ? true : iblockstate.func_177230_c().func_176200_f(this, p_190527_2_) && p_190527_1_.func_176198_a(this, p_190527_2_, p_190527_4_));
}
public int func_181545_F()
@@ -3009,7 +3203,7 @@
public int func_175651_c(BlockPos p_175651_1_, EnumFacing p_175651_2_)
{
IBlockState iblockstate = this.func_180495_p(p_175651_1_);
- return iblockstate.func_185915_l() ? this.func_175676_y(p_175651_1_) : iblockstate.func_185911_a(this, p_175651_1_, p_175651_2_);
+ return iblockstate.func_177230_c().shouldCheckWeakPower(iblockstate, this, p_175651_1_, p_175651_2_) ? this.func_175676_y(p_175651_1_) : iblockstate.func_185911_a(this, p_175651_1_, p_175651_2_);
}
public boolean func_175640_z(BlockPos p_175640_1_)
@@ -3152,6 +3346,8 @@
d2 *= ((Double)Objects.firstNonNull(p_184150_11_.apply(entityplayer1), Double.valueOf(1.0D))).doubleValue();
}
+ d2 = net.minecraftforge.common.ForgeHooks.getPlayerVisibilityDistance(entityplayer1, d2, p_184150_9_);
+
if ((p_184150_9_ < 0.0D || Math.abs(entityplayer1.field_70163_u - p_184150_3_) < p_184150_9_ * p_184150_9_) && (p_184150_7_ < 0.0D || d1 < d2 * d2) && (d0 == -1.0D || d1 < d0))
{
d0 = d1;
@@ -3213,7 +3409,7 @@
public long func_72905_C()
{
- return this.field_72986_A.func_76063_b();
+ return this.field_73011_w.getSeed();
}
public long func_82737_E()
@@ -3223,17 +3419,17 @@
public long func_72820_D()
{
- return this.field_72986_A.func_76073_f();
+ return this.field_73011_w.getWorldTime();
}
public void func_72877_b(long p_72877_1_)
{
- this.field_72986_A.func_76068_b(p_72877_1_);
+ this.field_73011_w.setWorldTime(p_72877_1_);
}
public BlockPos func_175694_M()
{
- BlockPos blockpos = new BlockPos(this.field_72986_A.func_76079_c(), this.field_72986_A.func_76075_d(), this.field_72986_A.func_76074_e());
+ BlockPos blockpos = this.field_73011_w.getSpawnPoint();
if (!this.func_175723_af().func_177746_a(blockpos))
{
@@ -3245,7 +3441,7 @@
public void func_175652_B(BlockPos p_175652_1_)
{
- this.field_72986_A.func_176143_a(p_175652_1_);
+ this.field_73011_w.setSpawnPoint(p_175652_1_);
}
@SideOnly(Side.CLIENT)
@@ -3265,12 +3461,18 @@
if (!this.field_72996_f.contains(p_72897_1_))
{
+ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(p_72897_1_, this)))
this.field_72996_f.add(p_72897_1_);
}
}
public boolean func_175660_a(EntityPlayer p_175660_1_, BlockPos p_175660_2_)
{
+ return this.field_73011_w.canMineBlock(p_175660_1_, p_175660_2_);
+ }
+
+ public boolean canMineBlockBody(EntityPlayer p_175660_1_, BlockPos p_175660_2_)
+ {
return true;
}
@@ -3364,8 +3566,7 @@
public boolean func_180502_D(BlockPos p_180502_1_)
{
- Biome biome = this.func_180494_b(p_180502_1_);
- return biome.func_76736_e();
+ return this.field_73011_w.isBlockHighHumidity(p_180502_1_);
}
@Nullable
@@ -3426,12 +3627,12 @@
public int func_72800_K()
{
- return 256;
+ return this.field_73011_w.getHeight();
}
public int func_72940_L()
{
- return this.field_73011_w.func_177495_o() ? 128 : 256;
+ return this.field_73011_w.getActualHeight();
}
public Random func_72843_D(int p_72843_1_, int p_72843_2_, int p_72843_3_)
@@ -3475,7 +3676,7 @@
@SideOnly(Side.CLIENT)
public double func_72919_O()
{
- return this.field_72986_A.func_76067_t() == WorldType.field_77138_c ? 0.0D : 63.0D;
+ return field_73011_w.getHorizon();
}
public void func_175715_c(int p_175715_1_, BlockPos p_175715_2_, int p_175715_3_)
@@ -3509,7 +3710,7 @@
public void func_175666_e(BlockPos p_175666_1_, Block p_175666_2_)
{
- for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
+ for (EnumFacing enumfacing : EnumFacing.field_82609_l)
{
BlockPos blockpos = p_175666_1_.func_177972_a(enumfacing);
@@ -3517,18 +3718,14 @@
{
IBlockState iblockstate = this.func_180495_p(blockpos);
- if (Blocks.field_150441_bU.func_185547_C(iblockstate))
+ iblockstate.func_177230_c().onNeighborChange(this, blockpos, p_175666_1_);
+ if (iblockstate.func_177230_c().isNormalCube(iblockstate, this, blockpos))
{
- iblockstate.func_189546_a(this, blockpos, p_175666_2_, p_175666_1_);
- }
- else if (iblockstate.func_185915_l())
- {
blockpos = blockpos.func_177972_a(enumfacing);
iblockstate = this.func_180495_p(blockpos);
-
- if (Blocks.field_150441_bU.func_185547_C(iblockstate))
+ if (iblockstate.func_177230_c().getWeakChanges(this, blockpos))
{
- iblockstate.func_189546_a(this, blockpos, p_175666_2_, p_175666_1_);
+ iblockstate.func_177230_c().onNeighborChange(this, blockpos, p_175666_1_);
}
}
}
@@ -3594,6 +3791,115 @@
return i >= -128 && i <= 128 && j >= -128 && j <= 128;
}
+ /* ======================================== FORGE START =====================================*/
+ /**
+ * Determine if the given block is considered solid on the
+ * specified side. Used by placement logic.
+ *
+ * @param pos Block Position
+ * @param side The Side in question
+ * @return True if the side is solid
+ */
+ public boolean isSideSolid(BlockPos pos, EnumFacing side)
+ {
+ return isSideSolid(pos, side, false);
+ }
+
+ /**
+ * Determine if the given block is considered solid on the
+ * specified side. Used by placement logic.
+ *
+ * @param pos Block Position
+ * @param side The Side in question
+ * @param _default The default to return if the block doesn't exist.
+ * @return True if the side is solid
+ */
+ @Override
+ public boolean isSideSolid(BlockPos pos, EnumFacing side, boolean _default)
+ {
+ if (!this.func_175701_a(pos)) return _default;
+
+ Chunk chunk = func_175726_f(pos);
+ if (chunk == null || chunk.func_76621_g()) return _default;
+ return func_180495_p(pos).isSideSolid(this, pos, side);
+ }
+
+ /**
+ * Get the persistent chunks for this world
+ *
+ * @return
+ */
+ public com.google.common.collect.ImmutableSetMultimap<net.minecraft.util.math.ChunkPos, net.minecraftforge.common.ForgeChunkManager.Ticket> getPersistentChunks()
+ {
+ return net.minecraftforge.common.ForgeChunkManager.getPersistentChunksFor(this);
+ }
+
+ public Iterator<Chunk> getPersistentChunkIterable(Iterator<Chunk> chunkIterator)
+ {
+ return net.minecraftforge.common.ForgeChunkManager.getPersistentChunksIterableFor(this, chunkIterator);
+ }
+ /**
+ * Readded as it was removed, very useful helper function
+ *
+ * @param pos Block position
+ * @return The blocks light opacity
+ */
+ public int getBlockLightOpacity(BlockPos pos)
+ {
+ if (!this.func_175701_a(pos)) return 0;
+ return func_175726_f(pos).func_177437_b(pos);
+ }
+
+ /**
+ * Returns a count of entities that classify themselves as the specified creature type.
+ */
+ public int countEntities(net.minecraft.entity.EnumCreatureType type, boolean forSpawnCount)
+ {
+ int count = 0;
+ for (int x = 0; x < field_72996_f.size(); x++)
+ {
+ if (((Entity)field_72996_f.get(x)).isCreatureType(type, forSpawnCount))
+ {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ protected void initCapabilities()
+ {
+ net.minecraftforge.common.capabilities.ICapabilityProvider parent = field_73011_w.initCapabilities();
+ capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this, parent);
+ net.minecraftforge.common.util.WorldCapabilityData data = (net.minecraftforge.common.util.WorldCapabilityData)perWorldStorage.func_75742_a(net.minecraftforge.common.util.WorldCapabilityData.class, net.minecraftforge.common.util.WorldCapabilityData.ID);
+ if (data == null)
+ {
+ capabilityData = new net.minecraftforge.common.util.WorldCapabilityData(capabilities);
+ perWorldStorage.func_75745_a(capabilityData.field_76190_i, capabilityData);
+ }
+ else
+ {
+ capabilityData = data;
+ capabilityData.setCapabilities(field_73011_w, capabilities);
+ }