-
Posts
150 -
Joined
-
Last visited
Everything posted by theishiopian
-
Ah, that makes much more sense. Ill try that out in a few minutes, thank you so much! EDIT: wait, isnt that what Im already doing? Field.get() is being called in the event handler. EDIT2: I backtracked a bit, going back to my original, working code from the first post, except with a static initilizer to get the field and no call of setAccessible. Now it works, but I need to run a few more tests to make sure the original problem is gone.
-
Ok, after some further experimentation, I managed to figure out what a static initilizer is. Even after implementing static init properly, it still throws the same error, just now in a different place. Code: package com.theishiopian.usefulpotionarrows; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityTippedArrow; import net.minecraft.potion.PotionType; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class DamageNullifier { private static EntityTippedArrow arrow; static Field potion; static { potion = ObfuscationReflectionHelper.getPrivateValue(EntityTippedArrow.class, arrow, "potion", "field_184560_g"); potion.setAccessible(true); } @SubscribeEvent public void Nullifier(ProjectileImpactEvent.Arrow event) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { arrow = (EntityTippedArrow) event.getArrow(); World world = arrow.getEntityWorld(); if(!world.isRemote && arrow instanceof EntityTippedArrow) { System.out.println(potion.get(arrow).toString()); // if(!()) // { // arrow.setDamage(0.0); // if(event.getRayTraceResult().typeOfHit == RayTraceResult.Type.ENTITY) // event.getRayTraceResult().entityHit.hurtResistantTime = 0; // } } } } Stacktrace of exception: https://pastebin.com/pKUwxBSr
-
Ok, I tried implementing the recommended changes. However, the game now crashes at startup when I try to access the field with an UnableToAccessFieldException. Im trying to get the field at startup in the postInit phase by calling reflectionSetup(). Did I misunderstand the phrase "static initialiser? Or can I not use static fields for this?" Code: package com.theishiopian.usefulpotionarrows; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityTippedArrow; import net.minecraft.potion.PotionType; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class DamageNullifier { private static EntityTippedArrow arrow = null; static Field potion; public static void reflectionSetup() { potion = ObfuscationReflectionHelper.getPrivateValue(EntityTippedArrow.class, arrow, "potion", "field_184560_g"); potion.setAccessible(true); } @SubscribeEvent public void Nullifier(ProjectileImpactEvent.Arrow event) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { arrow = (EntityTippedArrow) event.getArrow(); World world = arrow.getEntityWorld(); if(!world.isRemote && arrow instanceof EntityTippedArrow) { System.out.println(potion.get(arrow).toString()); // if(!()) // { // arrow.setDamage(0.0); // if(event.getRayTraceResult().typeOfHit == RayTraceResult.Type.ENTITY) // event.getRayTraceResult().entityHit.hurtResistantTime = 0; // } } } }
-
Ok, good to know, I'll try it.
-
I'm not editing obfuscated files, I'm using reflection to get the potion effects on an arrow. If there's a more efficient way to do it without reflection, I'm all ears.
-
I tried using only the srg name, it breaks it in the editor, since the files in the editor are deobfuscated. I will remove the set accessible, I kinda figured that was unnecessary.
-
Im attempting to make a mod that reduces the damage of potion arrows to 0, with good results so far. However, I'm running into a peculiar bug. Whenever a tipped arrow is shot at a player, theres about a 50-50 chance of the arrow bouncing off the player. The chance increases to 100% with dispensers, and seems not to occur with strays. Messing with the entity hurt resistance timer thing didn't really seem to make a difference. Non player entities can be hit normally. Code: package com.theishiopian.usefulpotionarrows; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Field; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntityTippedArrow; import net.minecraft.potion.PotionType; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.ReflectionHelper; public class DamageNullifier { //note to self: find these names in C:\Users\Andrew\.gradle\caches\minecraft\de\oceanlabs\mcp\mcp_snapshot\20171003\1.12.2\srgs Field potion = ReflectionHelper.findField(EntityTippedArrow.class, "potion", "field_184560_g"); @SubscribeEvent public void Nullifier(ProjectileImpactEvent.Arrow event) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { EntityArrow arrow = event.getArrow(); World world = arrow.getEntityWorld(); if(!world.isRemote && arrow instanceof EntityTippedArrow) { potion.setAccessible(true); PotionType plocal = (PotionType) potion.get(arrow); if(!(plocal.getRegistryName().toString().equals("minecraft:empty"))) { arrow.setDamage(0.0); if(event.getRayTraceResult().typeOfHit == RayTraceResult.Type.ENTITY) event.getRayTraceResult().entityHit.hurtResistantTime = 0; } } } } What could be causing this?
-
[1.12.2] [OS X] Certificate error when running setupDecompWorkspace
theishiopian replied to Kinniken's topic in ForgeGradle
Not sure if this is related, but I was having similar troubles with setupDecompWorkspace yesterday, and updating my JDK fixed it. More details in this thread: Edit: probably should have read this post more lol. Still, you might need to take extra steps, which are detailed in the above thread. -
Problem with reading arrow NBT, also weird entity behavior.
theishiopian replied to theishiopian's topic in Modder Support
ok, using both the obfuscated name and de-obfuscated name works perfectly. Thank you so much! -
Problem with reading arrow NBT, also weird entity behavior.
theishiopian replied to theishiopian's topic in Modder Support
Ok, that makes a lot more sense. Just searching it by potion didnt work, as expected, so i'll try the mcp names and srgs and such. Thank you for being so patient with me, this is very informative. -
Problem with reading arrow NBT, also weird entity behavior.
theishiopian replied to theishiopian's topic in Modder Support
Question regarding ReflectionHelper.findField: the method doesnt seem to take an obfuscated name. Do I put it in the top anyways? It looked like it could take multiple names. -
Problem with reading arrow NBT, also weird entity behavior.
theishiopian replied to theishiopian's topic in Modder Support
Theres nothing in the srg.exc that looks like that. Am I looking in the wrong place? EDIT: looks like I need to look in the srg files themselves. I feel like a moron now. -
Problem with reading arrow NBT, also weird entity behavior.
theishiopian replied to theishiopian's topic in Modder Support
ok, well what does a field look like in here? all there are are inits and funcs. -
Problem with reading arrow NBT, also weird entity behavior.
theishiopian replied to theishiopian's topic in Modder Support
net/minecraft/entity/EntityAreaEffectCloud.func_184484_a(Lnet/minecraft/potion/PotionType;)V=|p_184484_1_ is this the one for the potion type field? Forgive my noobishness, this is a lot to take in at once. -
Problem with reading arrow NBT, also weird entity behavior.
theishiopian replied to theishiopian's topic in Modder Support
I tried using reflection initially, but it didnt work when the mod was built. Additionally, when checking whether the arrow is an instance of EntityTippedArrow, it always returns true, regardless of whether the arrow is tipped or not. -
I'm trying to get the potion effect attached to a tipped arrow upon impact, but I'm running into two weird, possibly related issues. The first is that all arrows, tipped are not, turn into tipped arrows when fired, with regular arrows giving off blue particles. Second, the nbt tag is completely blank when I read it. Code: https://pastebin.com/9ezTvh70
-
fresh MDK from forge website not working
theishiopian replied to theishiopian's topic in Modder Support
Ok, got it working, more details here for those with the same issue: -
SetupDecompWorkspace returning: Unable to obtain url.
theishiopian replied to rafacost's topic in ForgeGradle
I'm still having the same issue, even after completing the above steps. EDIT: I accidentally changed the path instead of JAVA HOME. oops. EDIT2: After setting up the variables properly AND deleting the .gradle folder from c\users\me AND starting with a fresh JDK, I got it to work. Thanks for the help! -
SetupDecompWorkspace returning: Unable to obtain url.
theishiopian replied to rafacost's topic in ForgeGradle
Im having the exact same problem. Perhaps forge's servers are having issues? -
fresh MDK from forge website not working
theishiopian replied to theishiopian's topic in Modder Support
Full log with stacktrace and debug enabled: https://pastebin.com/HEPhApv6 -
fresh MDK from forge website not working
theishiopian replied to theishiopian's topic in Modder Support
ok, so now I'm getting a different error. I deleted the .gradle at both c\users\name and in the project directory, both gave the same error. FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\Andrew\Coding\Minecraft\Forge\UsefulPotionArrows\build.gradle' line: 10 * What went wrong: A problem occurred evaluating root project 'UsefulPotionArrows'. > Failed to apply plugin [id 'net.minecraftforge.gradle.forge'] > Unable to obtain url ([https://files.minecraftforge.net/maven/net/minecraftforge/forge/json]) with etag! * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED full log: https://pastebin.com/3dAUbNvf -
fresh MDK from forge website not working
theishiopian replied to theishiopian's topic in Modder Support
Im not sure. There should be. Ill check when I get home. -
fresh MDK from forge website not working
theishiopian replied to theishiopian's topic in Modder Support
Heres the build.gradle: https://pastebin.com/CVr2ukBB And the gradle.properties: https://pastebin.com/TvJVenzS THe project hasnt been opened in any ide yet, or modified in any way. -
fresh MDK from forge website not working
theishiopian replied to theishiopian's topic in Modder Support
Sure. My wifi is currently down, but it should be back in about 45 minutes. Ill post them then. -
fresh MDK from forge website not working
theishiopian replied to theishiopian's topic in Modder Support
Ok, here ya go: https://pastebin.com/xkfXuy9e