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

Fix variables in finally blocks not getting renamed #105

Closed coehlrich closed 2 years ago

coehlrich commented 2 years ago

The variable's are detected by using the start and and type but in the finally block the store instruction for the exception was removed but not the offset for that instruction causing the instruction offset to be different than expected

1.18 Pre Release 1 diff:

diff --git a/net/minecraft/client/resources/model/ModelBakery.java b/net/minecraft/client/resources/model/ModelBakery.java
index 98d5127..6708b64 100644
--- a/net/minecraft/client/resources/model/ModelBakery.java
+++ b/net/minecraft/client/resources/model/ModelBakery.java
@@ -19,7 +19,6 @@ import java.io.Reader;
 import java.io.StringReader;
 import java.nio.charset.StandardCharsets;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -428,7 +427,7 @@ public class ModelBakery {
             } catch (Exception exception) {
                throw new ModelBakery.BlockStateDefinitionException(String.format("Exception loading blockstate definition: '%s': %s", resourcelocation1, exception));
             } finally {
-               HashMap $$26 = Maps.newHashMap();
+               Map<ModelBakery.ModelGroupKey, Set<BlockState>> map3 = Maps.newHashMap();
                map.forEach((p_119336_, p_119337_) -> {
                   Pair<UnbakedModel, Supplier<ModelBakery.ModelGroupKey>> pair2 = map1.get(p_119337_);
                   if (pair2 == null) {
@@ -440,7 +439,7 @@ public class ModelBakery {

                   try {
                      ModelBakery.ModelGroupKey modelbakery$modelgroupkey1 = pair2.getSecond().get();
-                     $$26.computeIfAbsent(modelbakery$modelgroupkey1, (p_174894_) -> {
+                     map3.computeIfAbsent(modelbakery$modelgroupkey1, (p_174894_) -> {
                         return Sets.newIdentityHashSet();
                      }).add(p_119337_);
                   } catch (Exception exception1) {
@@ -448,7 +447,7 @@ public class ModelBakery {
                   }

                });
-               $$26.forEach((p_119304_, p_119305_) -> {
+               map3.forEach((p_119304_, p_119305_) -> {
                   Iterator<BlockState> iterator = p_119305_.iterator();

                   while(iterator.hasNext()) {