MinecraftForge / ForgeFlower

Forge's modifications to FernFlower. Fixing various bugs/inconsistencies. Main Repo: https://github.com/MinecraftForge/FernFlower
Apache License 2.0
80 stars 44 forks source link

Static field initializes that reference itself or other static fields not inlined/compileable. #77

Closed LexManos closed 4 years ago

LexManos commented 4 years ago

So, apparently static fields can reference itself, and other static fields that are declared after it in their initalizer. IF they are fully qualified. I think this is a bug in the java spec/compiler, because the value for these fields will always be null... But hey Minecraft exposed it, so lets fix it. See 1.16-pre EntityPredicate.

LexManos commented 4 years ago
--- joined.decomp\/net/minecraft/advancements/criterion/EntityPredicate.java    2020-06-15 23:51:26.000000000 -0700
+++ joined.decomp.test\/net/minecraft/advancements/criterion/EntityPredicate.java   2020-06-15 23:59:46.000000000 -0700
@@ -28,7 +28,7 @@
 import net.minecraft.world.server.ServerWorld;

 public class EntityPredicate {
-   public static final EntityPredicate field_192483_a;
+   public static final EntityPredicate field_192483_a = new EntityPredicate(EntityTypePredicate.field_209371_a, DistancePredicate.field_193423_a, LocationPredicate.field_193455_a, MobEffectsPredicate.field_193473_a, NBTPredicate.field_193479_a, EntityFlagsPredicate.field_217979_a, EntityEquipmentPredicate.field_217958_a, PlayerPredicate.field_226989_a_, FishingPredicate.field_234635_a_, EntityPredicate.field_192483_a, EntityPredicate.field_192483_a, (String)null, (ResourceLocation)null);
    private final EntityTypePredicate field_192484_b;
    private final DistancePredicate field_192485_c;
    private final LocationPredicate field_193435_d;
@@ -163,10 +163,6 @@
       return (new LootContext.Builder(p_234575_0_.func_71121_q())).func_216015_a(LootParameters.field_216281_a, p_234575_1_).func_216015_a(LootParameters.field_216286_f, p_234575_1_.func_233580_cy_()).func_216015_a(LootParameters.field_237457_g_, p_234575_0_.func_213303_ch()).func_216023_a(p_234575_0_.func_70681_au()).func_216022_a(LootParameterSets.field_237454_j_);
    }

-   static {
-      field_192483_a = new EntityPredicate(EntityTypePredicate.field_209371_a, DistancePredicate.field_193423_a, LocationPredicate.field_193455_a, MobEffectsPredicate.field_193473_a, NBTPredicate.field_193479_a, EntityFlagsPredicate.field_217979_a, EntityEquipmentPredicate.field_217958_a, PlayerPredicate.field_226989_a_, FishingPredicate.field_234635_a_, field_192483_a, field_192483_a, (String)null, (ResourceLocation)null);
-   }
-
    public static class AndPredicate {
       public static final EntityPredicate.AndPredicate field_234582_a_ = new EntityPredicate.AndPredicate(new ILootCondition[0]);
       private final ILootCondition[] field_234583_b_;
diff -r -u joined.decomp\/net/minecraft/block/ScaffoldingBlock.java joined.decomp.test\/net/minecraft/block/ScaffoldingBlock.java
--- joined.decomp\/net/minecraft/block/ScaffoldingBlock.java    2020-06-15 23:50:00.000000000 -0700
+++ joined.decomp.test\/net/minecraft/block/ScaffoldingBlock.java   2020-06-15 23:58:26.000000000 -0700
@@ -149,6 +149,6 @@
       VoxelShape voxelshape6 = Block.func_208617_a(14.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D);
       VoxelShape voxelshape7 = Block.func_208617_a(0.0D, 0.0D, 14.0D, 16.0D, 2.0D, 16.0D);
       VoxelShape voxelshape8 = Block.func_208617_a(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 2.0D);
-      field_220122_e = VoxelShapes.func_216384_a(field_220123_f, field_220121_d, voxelshape6, voxelshape5, voxelshape8, voxelshape7);
+      field_220122_e = VoxelShapes.func_216384_a(ScaffoldingBlock.field_220123_f, field_220121_d, voxelshape6, voxelshape5, voxelshape8, voxelshape7);
    }
 }