Posted September 21, 20214 yr So I'm nearly finished with a version of my mod and, although I haven't done mapping changes in awhile, I'm confident that I have the correct MCP name so that an instance of reflection runs properly. However, the new method name isn't recognized during load in the real environment (I'm aware it needs to be changed back to run in dev). I cross-referenced both the output.srg as well as a Discord bot and they tell me that: func_221052_a in PointOfInterestType.class should be registerBlockStates Attached is the relevant class and log file. Any help is appreciated. Loading Output Log Villager Util class: Spoiler import com.google.common.collect.ImmutableSet; import net.minecraft.block.*; import net.minecraft.entity.merchant.villager.VillagerProfession; import net.minecraft.item.Item; import net.minecraft.util.SoundEvent; import net.minecraft.village.PointOfInterestType; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import javax.annotation.Nullable; import java.lang.reflect.*; import java.util.Set; public class VillagerUtil { private static Method blockStatesInjector; static { VillagerUtil.blockStatesInjector = ObfuscationReflectionHelper.findMethod(PointOfInterestType.class, "registerBlockStates", PointOfInterestType.class); } //func_221052_a should be registerBlockStates? public static Set<BlockState> getAllStates(Block block) { return ImmutableSet.copyOf(block.getStateDefinition().getPossibleStates()); } public static void fixPOITypeBlockStates(PointOfInterestType poiType) { try { VillagerUtil.blockStatesInjector.invoke(null, poiType); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } } public static PointOfInterestType pointOfInterestType(String p1, Set<BlockState> p2, int p3, int p4) { try { //Constructor<PointOfInterestType> c = (Constructor<PointOfInterestType>)PointOfInterestType.class.getDeclaredConstructors()[1]; Constructor<PointOfInterestType> c = PointOfInterestType.class.getDeclaredConstructor(String.class, Set.class, Integer.TYPE, Integer.TYPE); c.setAccessible(true); return c.newInstance(p1, p2, p3, p4); } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } return null; } public static VillagerProfession villagerProfession(String p1, PointOfInterestType p2, ImmutableSet<Item> p3, ImmutableSet<Block> p4, @Nullable SoundEvent p5) { try { Constructor<VillagerProfession> c = VillagerProfession.class.getDeclaredConstructor(String.class, PointOfInterestType.class, ImmutableSet.class, ImmutableSet.class, SoundEvent.class); c.setAccessible(true); return c.newInstance(p1, p2, p3, p4, p5); } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } return null; } } Edited September 22, 20214 yr by urbanxx001
September 22, 20214 yr I'm confused on why you are using reflection. Everything above does not need it. All are public except for the method which just returns itself so it doesn't matter. They are all forge registry entries which you can register normally.
September 22, 20214 yr Author Yeah the VillagerUtil was used in conjunction with the POI Forge registry, but you're right it's superfluous and I should stick with the simpler way. Thank you Ash
September 22, 20214 yr ObfuscationReflectionHelper methods always take SRG names, even in the development environment. In development, the SRG name is automatically remapped to the corresponding MCP name. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.