Jump to content

Why does game freezes with Entity.setFlag(7,true);? (for flying with elytra)


PassoDuplo

Recommended Posts

I want to make another elytra, but an elytra which is used on baubles's pendant inventory. After looking for a while the minecraft code I found out that to make the player use the elytra, this flag needs to be active, but, as said on the title, the game crashes when this code is executed. Why does it happen?

 

My item's code:

package mod.pdm.elytrabb;

import baubles.api.BaubleType;
import baubles.api.IBauble;
import baubles.common.container.InventoryBaubles;
import baubles.common.lib.PlayerHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemElytra;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;

/**
*
* @author PassoDuplo
*/
public class BaublesElytra extends ItemElytra implements IBauble{
    private Method setFlagMethod;
    
    public BaublesElytra(){
        super();
        this.setUnlocalizedName("elytra");
        this.setRegistryName("elytra");
        try {
            setFlagMethod = Class.forName("net.minecraft.entity.EntityLivingBase").getDeclaredMethod("setFlag");
            setFlagMethod.setAccessible(true);
        } catch(ClassNotFoundException ex){
            Logger.getLogger(BaublesElytra.class.getName()).log(Level.SEVERE, null, ex);
        }        
        catch (NoSuchMethodException ex) {
            Logger.getLogger(BaublesElytra.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SecurityException ex) {
            Logger.getLogger(BaublesElytra.class.getName()).log(Level.SEVERE, null, ex);
        }                
}
    
    @Override
    public BaubleType getBaubleType(ItemStack i){
        return BaubleType.AMULET;
    }
    
    @Override
    public void onWornTick(ItemStack itemstack, EntityLivingBase player){
        if(!player.isElytraFlying() && player.motionY < 0.0D && !player.isInLava() && !player.isInWater() && !player.onGround){
            try {
                setFlagMethod.invoke(player, 7, true);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(BaublesElytra.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalArgumentException ex) {
                Logger.getLogger(BaublesElytra.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InvocationTargetException ex) {
                Logger.getLogger(BaublesElytra.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
    }
    
    @Override
    public void onEquipped(ItemStack itemstack, EntityLivingBase player){
        player.playSound(SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 1.0F, 1.0F);
    }
    
    @Override
    public void onUnequipped(ItemStack itemstack, EntityLivingBase player){}
    
    @Override
    public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
return true;
    }

    @Override
    public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
return true;
    }
    
    @Override
    public ActionResult<ItemStack> onItemRightClick(ItemStack i, World w, EntityPlayer p, EnumHand h){
        InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(p);
        
        if (null == baubles.getStackInSlot(0)) {
                   baubles.setInventorySlotContents(0, i.copy());
                   onEquipped(i,p);
                   i.stackSize = 0;
                   return new ActionResult(EnumActionResult.SUCCESS, i);
        } else {
            return new ActionResult(EnumActionResult.FAIL, i);
        }
    }
}

Link to comment
Share on other sites

the game crashes

 

I don't see a crash log.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Forge still saves a .log file.

 

But I suspect that this isn't a Java issue but a computer issue.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Oh, yes. This is my last one:

 

[12:53:53] [Client thread/INFO]: Setting user: Player127
[12:53:56] [Client thread/WARN]: Skipping bad option: lastServer:
[12:53:56] [Client thread/INFO]: LWJGL Version: 2.9.4
[12:53:59] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Baubles, FMLFileResourcePack:ElytraBb
[12:54:01] [sound Library Loader/INFO]: Starting up SoundSystem...
[12:54:01] [Thread-7/INFO]: Initializing LWJGL OpenAL
[12:54:01] [Thread-7/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[12:54:01] [Thread-7/INFO]: OpenAL initialized.
[12:54:01] [sound Library Loader/INFO]: Sound engine started
[12:54:02] [Client thread/INFO]: Created: 16x16 textures-atlas
[12:54:03] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Baubles, FMLFileResourcePack:ElytraBb
[12:54:04] [Client thread/INFO]: SoundSystem shutting down...
[12:54:04] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com
[12:54:04] [sound Library Loader/INFO]: Starting up SoundSystem...
[12:54:04] [Thread-9/INFO]: Initializing LWJGL OpenAL
[12:54:04] [Thread-9/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[12:54:04] [Thread-9/INFO]: OpenAL initialized.
[12:54:04] [sound Library Loader/INFO]: Sound engine started
[12:54:05] [Client thread/INFO]: Created: 1024x512 textures-atlas
[12:54:06] [Client thread/WARN]: Skipping bad option: lastServer:
[12:54:07] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id
[12:54:11] [server thread/INFO]: Starting integrated minecraft server version 1.10.2
[12:54:11] [server thread/INFO]: Generating keypair
[12:54:11] [server thread/INFO]: Preparing start region for level 0
[12:54:12] [server thread/INFO]: Preparing spawn area: 25%
[12:54:13] [server thread/INFO]: Changing view distance to 12, from 10
[12:54:15] [server thread/INFO]: Player127[local:E:32a76d41] logged in with entity id 360 at (-150.4123439768444, 65.41999998688698, 323.73730224811607)
[12:54:15] [server thread/INFO]: Player127 joined the game
[12:54:16] [server thread/INFO]: Saving and pausing game...
[12:54:16] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/Overworld
[12:54:16] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/Nether
[12:54:16] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/The End
[12:54:16] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@5cf90377[id=181bbcbe-77b5-3b29-b98c-87ba0992cbd8,name=Player127,properties={},legacy=false]
com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time
at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:175) [YggdrasilMinecraftSessionService.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:59) [YggdrasilMinecraftSessionService$1.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:56) [YggdrasilMinecraftSessionService$1.class:?]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:165) [YggdrasilMinecraftSessionService.class:?]
at net.minecraft.client.Minecraft.getProfileProperties(Minecraft.java:3060) [Minecraft.class:?]
at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:131) [skinManager$3.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_101]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_101]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_101]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_101]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_101]
[12:54:20] [server thread/INFO]: Player127 has just earned the achievement [Taking Inventory]
[12:54:20] [Client thread/INFO]: [CHAT] Player127 has just earned the achievement [Taking Inventory]
[12:54:43] [server thread/INFO]: [Player127: Given [Elytra] * 1 to Player127]
[12:54:43] [Client thread/INFO]: [CHAT] Given [Elytra] * 1 to Player127
[12:54:51] [server thread/INFO]: Stopping server
[12:54:51] [server thread/INFO]: Saving players
[12:54:51] [server thread/INFO]: Saving worlds
[12:54:51] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/Overworld
[12:54:51] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/Nether
[12:54:51] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/The End
[12:54:52] [Client thread/FATAL]: Reported exception thrown!
net.minecraft.util.ReportedException: Ticking entity
at net.minecraft.world.World.updateEntities(World.java:1899) ~[World.class:?]
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1886) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1118) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:406) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_101]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_101]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_101]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_101]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.ClassCastException: net.minecraft.client.entity.EntityPlayerSP cannot be cast to net.minecraft.entity.player.EntityPlayerMP
at mod.pdm.elytrabb.BaublesElytra.onWornTick(BaublesElytra.java:67) ~[baublesElytra.class:?]
at baubles.common.event.EventHandlerEntity.playerTick(EventHandlerEntity.java:38) ~[EventHandlerEntity.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_9_EventHandlerEntity_playerTick_LivingUpdateEvent.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:68) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:159) ~[EventBus.class:?]
at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:491) ~[ForgeHooks.class:?]
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2136) ~[EntityLivingBase.class:?]
at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259) ~[EntityPlayer.class:?]
at net.minecraft.client.entity.EntityPlayerSP.onUpdate(EntityPlayerSP.java:210) ~[EntityPlayerSP.class:?]
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2106) ~[World.class:?]
at net.minecraft.world.World.updateEntity(World.java:2073) ~[World.class:?]
at net.minecraft.world.World.updateEntities(World.java:1886) ~[World.class:?]
... 16 more

Link to comment
Share on other sites

Caused by: java.lang.ClassCastException: net.minecraft.client.entity.EntityPlayerSP cannot be cast to net.minecraft.entity.player.EntityPlayerMP

 

Should be self explanatory.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Considering that the crash occurs on line 67 of your custome elytra class, yes, I do think its related to your code.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

It is an old crash log since the game doesn't freeze when I put the item on the pendant inventory. It freezes when I am in the air falling. I could get a new crash log by killing the java proccess and it points to the line 54 -- setFlagMethod.invoke(player, 7, true);

 

[15:50:55] [Client thread/INFO]: Setting user: Player231
[15:50:58] [Client thread/WARN]: Skipping bad option: lastServer:
[15:50:58] [Client thread/INFO]: LWJGL Version: 2.9.4
[15:51:00] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Baubles, FMLFileResourcePack:ElytraBb
[15:51:02] [sound Library Loader/INFO]: Starting up SoundSystem...
[15:51:03] [Thread-7/INFO]: Initializing LWJGL OpenAL
[15:51:03] [Thread-7/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[15:51:03] [Thread-7/INFO]: OpenAL initialized.
[15:51:03] [sound Library Loader/INFO]: Sound engine started
[15:51:04] [Client thread/INFO]: Created: 16x16 textures-atlas
[15:51:05] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Baubles, FMLFileResourcePack:ElytraBb
[15:51:05] [Client thread/INFO]: SoundSystem shutting down...
[15:51:06] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com
[15:51:06] [sound Library Loader/INFO]: Starting up SoundSystem...
[15:51:06] [Thread-9/INFO]: Initializing LWJGL OpenAL
[15:51:06] [Thread-9/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[15:51:06] [Thread-9/INFO]: OpenAL initialized.
[15:51:06] [sound Library Loader/INFO]: Sound engine started
[15:51:06] [Client thread/INFO]: Created: 1024x512 textures-atlas
[15:51:08] [Client thread/WARN]: Skipping bad option: lastServer:
[15:51:09] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id
[15:51:14] [server thread/INFO]: Starting integrated minecraft server version 1.10.2
[15:51:14] [server thread/INFO]: Generating keypair
[15:51:14] [server thread/INFO]: Preparing start region for level 0
[15:51:15] [server thread/INFO]: Preparing spawn area: 30%
[15:51:16] [server thread/INFO]: Changing view distance to 12, from 10
[15:51:17] [server thread/INFO]: Player231[local:E:5adee19d] logged in with entity id 358 at (-158.67645229317893, 64.92159999847412, 323.96597658775363)
[15:51:17] [server thread/INFO]: Player231 joined the game
[15:51:18] [server thread/INFO]: Saving and pausing game...
[15:51:18] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/Overworld
[15:51:19] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/Nether
[15:51:19] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/The End
[15:51:19] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@628cd6e2[id=0ef61a2a-d91b-37b4-a10d-af67b917d543,name=Player231,properties={},legacy=false]
com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time
at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:175) [YggdrasilMinecraftSessionService.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:59) [YggdrasilMinecraftSessionService$1.class:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:56) [YggdrasilMinecraftSessionService$1.class:?]
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]
at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:165) [YggdrasilMinecraftSessionService.class:?]
at net.minecraft.client.Minecraft.getProfileProperties(Minecraft.java:3060) [Minecraft.class:?]
at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:131) [skinManager$3.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_101]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_101]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_101]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_101]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_101]
[15:51:27] [server thread/INFO]: [@: Given [Elytra] * 1 to Player231]
[15:51:27] [Client thread/INFO]: [CHAT] [@: Given [Elytra] * 1 to Player231]
[15:51:33] [server thread/ERROR]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Ticking player
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:210) ~[NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:806) ~[MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_101]
Caused by: java.lang.NullPointerException
at mod.pdm.elytrabb.BaublesElytra.onWornTick(BaublesElytra.java:54) ~[baublesElytra.class:?]
at baubles.common.event.EventHandlerEntity.playerTick(EventHandlerEntity.java:38) ~[EventHandlerEntity.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_9_EventHandlerEntity_playerTick_LivingUpdateEvent.invoke(.dynamic) ~[?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:68) ~[ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:159) ~[EventBus.class:?]
at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:491) ~[ForgeHooks.class:?]
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2136) ~[EntityLivingBase.class:?]
at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259) ~[EntityPlayer.class:?]
at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:341) ~[EntityPlayerMP.class:?]
at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:174) ~[NetHandlerPlayServer.class:?]
at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:215) ~[NetworkDispatcher$1.class:?]
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308) ~[NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) ~[NetworkSystem.class:?]
... 5 more
[15:51:33] [server thread/ERROR]: This crash report has been saved to: /home/lucio/Documentos/Java/Forge/run/./crash-reports/crash-2016-08-20_15.51.33-server.txt
[15:51:33] [server thread/INFO]: Stopping server
[15:51:33] [server thread/INFO]: Saving players
[15:51:33] [server thread/INFO]: Saving worlds
[15:51:33] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/Overworld
[15:51:33] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/Nether
[15:51:33] [server thread/INFO]: Saving chunks for level 'Mundo Teste'/The End
[15:52:02] [Client Shutdown Thread/INFO]: Stopping server

 

And I had the same result by adding

private void Fly(EntityPlayerMP p){
        p.setElytraFlying();
    }

and replacing setFlagMethod.invoke(player, 7, true); with:  Fly((EntityPlayerMP) player);  -- It does the same thing but without reflection

 

The game uses the same code to activate the elytra flying code. Look at net.minecraft.network.NetHandlerPlayServer on line 1031

Link to comment
Share on other sites

Caused by: java.lang.NullPointerException

at mod.pdm.elytrabb.BaublesElytra.onWornTick(BaublesElytra.java:54) ~[baublesElytra.class:?]

 

Also self explanatory.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Because the object is never set to anything.

 

I can't tell you because you haven't posted your current code.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

According to the code you posted,

setFlagMethod

is null when called, also, wouldn't it be easier that instead of using

Class.forName("net.minecraft.entity.EntityLivingBase")

that you just use

EntityLivingBase.class

?

 

I'm not sure that reflection is the only way here though.

 

Edit: After looking at minecraft's code,

setFlag(int, boolean)

is for

Entity

not

EntityLivingBase

Link to comment
Share on other sites

Fields and methods added by vanilla have three names: The MCP (deobfuscated) name, the SRG (semi-obfuscated) name and the Notch (obfuscated) name.

 

When writing normal Forge code, you only need to use MCP names and your code will be obfuscated to SRG names when you build it.

 

When accessing a vanilla field/method via reflection, you need to check for both the MCP and SRG names since ForgeGradle's obfuscation process doesn't change field/method names in strings.

 

Use

ReflectionHelper.findField

to access a vanilla field or

ReflectionHelper.findMethod

to access a vanilla method (the

instance

argument is unused, so you can just pass

null

). These iterate through the provided names until they find a matching field/method. This lookup process is expensive, so you should do it once and store the

Field

/

Method

object in a

private static final

field.

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So I saw that mixin is shipped as a library with forge, but is it available for 1.7.10 ?  
    • So I've read the EULA, and lets be straight...     If I split my modpack(of my mods, yeah I'm nuts) into several(many) individual mods(like just one boss) with minor additions(plus not working together), then have a complete/modpack version on patreon/onlyfans having each addon work together... Would people buy my idea?
    • German A1 – C1, TestDAF, Goethe B1, B2, C1, C2, valid GOETHE certificate German A1 – C1, TestDAF, Goethe B1, B2, C1, C2, valid GOETHE certificate(+27(838-80-8170
    • Done, it still crashed. New log https://paste.ee/p/kYv6e
    • I am migrating a mod from 1.16.5 to 1.20.2 The version for 1.16.5 can be found here https://github.com/beothorn/automataCraft For the block called automata_start, it uses TileEntities and has blockstates, model/block and textures on json files. This is currently working fine on 1.16.5 https://github.com/beothorn/automataCraft/tree/master/src/main/resources/assets/automata For 1.20.2 I migrated the logic from TileEntities to BlockEntity. The mod is working fine. All blocks and Items are working with the correct textures except for the textures for each state of the automata_start block. No changes where made to the json files. This is the branch I am working on (there were some refactorings, but all is basically the same): https://github.com/beothorn/automataCraft/tree/1_20/src/main/resources/assets/automata The only difference I can think that may be related is that i had to implement createBlockStateDefinition on the BaseEntityBlock: https://github.com/beothorn/automataCraft/blob/1_20/src/main/java/br/com/isageek/automata/automata/AutomataStartBlock.java#L43 This is driving me crazy. I know the jsons are being loaded as I put a breakpoint at `net.minecraft.client.resources.model.ModelBakery#loadModel` and I can see BlockModelDefinition.fromJsonElement being called with automata_start. I also printed the state from the arguments of the tick function call and they look correct (https://github.com/beothorn/automataCraft/blob/1_20/src/main/java/br/com/isageek/automata/automata/Ticker.java#L32 ): blockState Block{automata:automata_start}[state=loadreplaceables] In game, all I see is the no textures. I think it is weird it is not the "missing texture" texture so I think it may be related to the material, but I had no success tweaking it (https://github.com/beothorn/automataCraft/blob/1_20/src/main/java/br/com/isageek/automata/automata/AutomataStartBlock.java#L37).   public static final Property<AutomataStartState> state = EnumProperty.create("state", AutomataStartState.class); private final AtomicReference<RegistryObject<BlockEntityType<?>>> blockEntityType; private final Map<String, RegistryObject<Block>> registeredBlocks; public AutomataStartBlock( final AtomicReference<RegistryObject<BlockEntityType<?>>> blockEntityType, final Map<String, RegistryObject<Block>> registeredBlocks ) { super(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).strength(1.5F, 6.0F)); this.blockEntityType = blockEntityType; this.registeredBlocks = registeredBlocks; this.registerDefaultState(this.getStateDefinition().any().setValue(state, AutomataStartState.LOAD_REPLACEABLES)); } @Override protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> stateBuilder) { stateBuilder.add(state); }     So my cry for help is, anyone has any ideas? Is there a way to easily debug this, for example somewhere where I can list the textures for a given state, or make sure this is loaded?   Thanks in advance for the hints
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.