Jump to content

[1.11.2] How to tell if player has a potion effect.


K3YD0N

Recommended Posts

I'm new to modding and I'm mainly just trying to update a mod I used that has not been updated to 1.11.2, I want to be able to remove the fov change you get from speed/slowness potion effects. (YES I KNOW ABOUT OPTIFINE DYNAMIC FOV, I don't want it to effect sprinting or bows though.) I am mainly having trouble figuring out how to tell if a player has a status effect (IE, speed or slowness). I have tried quite a few things and tried to look this up everywhere but it all must be for different versions or something because I keep getting errors. (I'm using eclipse but if you know how to do this in another lang I would prob switch to that) Here is my current code, if it helps you understand what im trying to do. 

  }
  
  @SubscribeEvent
  public void onFOVUpdate(FOVUpdateEvent event)
  {
    EntityPlayer player = event.getEntity();
    float fov = 1.0F;
    
	
		
    if(player.isPotionActive(SPEED);) {
      event.setNewfov(1.0f);
    }
    if(player.isPotionActive(2);) {
        event.setNewfov(1.0f);
    }

  }

The if statement is my problem.

 

Mod I'm trying to update: https://minecraft.curseforge.com/projects/fov-control  (by update I mean just the parts I want because I'm lazy lol)

Edited by K3YD0N
link to mod im trying to update
Link to comment
Share on other sites

EntityLivingBase#isPotionActive is the method that checks is the specified potion active for the entity.  It takes a Potion argument and you can get the potion instances from the MobEffects class.

 

Your current code doesnt't work because it contains syntax errors.

Link to comment
Share on other sites

 @SubscribeEvent
  public void onFOVUpdate(FOVUpdateEvent event)
  {
    EntityPlayer player = event.getEntity();
    float fov = 1.0F;
    
	
		
    if (player.isPotionActive(1)) 
    	{
    		event.setNewfov(1.0f);
    	}
    
    if (player.isPotionActive(2)) 
    	{
    	event.setNewfov(1.0f);
    }

  }

I think I fixed the Syntax errors, however it still crashes every time I load into a world, Is this code wrong: 

EntityPlayer player = event.getEntity();

 

Edited by K3YD0N
more code
Link to comment
Share on other sites

Spoiler

---- Minecraft Crash Report ----
// There are four lights!

Time: 6/12/18 4:22 PM
Description: Unexpected error

java.lang.Error: Unresolved compilation problems: 
    The method isPotionActive(Potion) in the type EntityLivingBase is not applicable for the arguments (int)
    The method isPotionActive(Potion) in the type EntityLivingBase is not applicable for the arguments (int)

    at fovcontrol.FovControl.onFOVUpdate(FovControl.java:46)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_7_FovControl_onFOVUpdate_FOVUpdateEvent.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185)
    at net.minecraftforge.client.ForgeHooksClient.getOffsetFOV(ForgeHooksClient.java:238)
    at net.minecraft.client.entity.AbstractClientPlayer.getFovModifier(AbstractClientPlayer.java:173)
    at net.minecraft.client.renderer.EntityRenderer.updateFovModifierHand(EntityRenderer.java:498)
    at net.minecraft.client.renderer.EntityRenderer.updateRenderer(EntityRenderer.java:296)
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1862)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119)
    at net.minecraft.client.Minecraft.run(Minecraft.java:407)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:26)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
    at fovcontrol.FovControl.onFOVUpdate(FovControl.java:46)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_7_FovControl_onFOVUpdate_FOVUpdateEvent.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185)
    at net.minecraftforge.client.ForgeHooksClient.getOffsetFOV(ForgeHooksClient.java:238)
    at net.minecraft.client.entity.AbstractClientPlayer.getFovModifier(AbstractClientPlayer.java:173)
    at net.minecraft.client.renderer.EntityRenderer.updateFovModifierHand(EntityRenderer.java:498)
    at net.minecraft.client.renderer.EntityRenderer.updateRenderer(EntityRenderer.java:296)

-- Affected level --
Details:
    Level name: MpServer
    All players: 1 total; [EntityPlayerSP['Player223'/392, l='MpServer', x=12.50, y=72.00, z=138.50]]
    Chunk stats: MultiplayerChunkCache: 513, 513
    Level seed: 0
    Level generator: ID 00 - default, ver 1. Features enabled: false
    Level generator options: 
    Level spawn location: World: (16,64,140), Chunk: (at 0,4,12 in 1,8; contains blocks 16,0,128 to 31,255,143), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
    Level time: 290 game time, 290 day time
    Level dimension: 0
    Level storage version: 0x00000 - Unknown?
    Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
    Forced entities: 92 total; [EntityChicken['Chicken'/128, l='MpServer', x=-56.99, y=72.00, z=208.80], EntityCow['Cow'/256, l='MpServer', x=60.52, y=70.00, z=196.44], EntityChicken['Chicken'/129, l='MpServer', x=-57.68, y=72.00, z=208.45], EntityCow['Cow'/257, l='MpServer', x=63.50, y=70.00, z=192.95], EntityChicken['Chicken'/130, l='MpServer', x=-58.83, y=72.00, z=208.50], EntitySpider['Spider'/258, l='MpServer', x=53.48, y=16.00, z=217.49], EntitySkeleton['Skeleton'/135, l='MpServer', x=-44.50, y=55.00, z=84.50], EntityCow['Cow'/136, l='MpServer', x=-47.50, y=72.00, z=175.50], EntityCow['Cow'/137, l='MpServer', x=-46.50, y=72.00, z=173.50], EntityCow['Cow'/138, l='MpServer', x=-35.47, y=74.00, z=166.04], EntityCow['Cow'/139, l='MpServer', x=-35.50, y=74.00, z=167.12], EntityCow['Cow'/140, l='MpServer', x=-38.48, y=72.00, z=167.10], EntityCow['Cow'/141, l='MpServer', x=-38.50, y=72.00, z=162.50], EntityBat['Bat'/142, l='MpServer', x=-41.46, y=58.62, z=187.41], EntityCreeper['Creeper'/143, l='MpServer', x=-33.71, y=31.00, z=209.70], EntityZombie['Zombie'/271, l='MpServer', x=80.46, y=15.00, z=95.56], EntityZombie['Zombie'/144, l='MpServer', x=-42.50, y=56.00, z=214.50], EntitySkeleton['Skeleton'/272, l='MpServer', x=70.57, y=15.00, z=108.50], EntityZombie['Zombie'/145, l='MpServer', x=-38.77, y=57.00, z=215.51], EntityItem['item.tile.flower2.houstonia'/401, l='MpServer', x=-8.04, y=69.00, z=118.74], EntityPig['Pig'/273, l='MpServer', x=72.53, y=62.30, z=164.55], EntityPlayerSP['Player223'/392, l='MpServer', x=12.50, y=72.00, z=138.50], EntityZombie['Zombie'/146, l='MpServer', x=-35.86, y=58.00, z=210.32], EntityPig['Pig'/274, l='MpServer', x=72.50, y=63.00, z=165.50], EntityZombie['Zombie'/147, l='MpServer', x=-42.05, y=57.00, z=212.51], EntityPig['Pig'/275, l='MpServer', x=77.50, y=63.00, z=164.50], EntityZombie['Zombie'/148, l='MpServer', x=-38.01, y=57.00, z=213.52], EntityPig['Pig'/276, l='MpServer', x=72.81, y=64.00, z=167.48], EntitySpider['Spider'/149, l='MpServer', x=-35.50, y=58.00, z=211.50], EntityCow['Cow'/277, l='MpServer', x=64.69, y=70.00, z=191.55], EntityCow['Cow'/152, l='MpServer', x=-43.50, y=73.00, z=217.50], EntitySkeleton['Skeleton'/286, l='MpServer', x=81.50, y=14.00, z=70.50], EntityCreeper['Creeper'/287, l='MpServer', x=80.68, y=15.00, z=71.60], EntitySkeleton['Skeleton'/288, l='MpServer', x=88.51, y=17.02, z=82.79], EntityCreeper['Creeper'/289, l='MpServer', x=80.49, y=16.00, z=98.19], EntityPig['Pig'/290, l='MpServer', x=87.49, y=53.00, z=147.94], EntityPig['Pig'/291, l='MpServer', x=83.50, y=53.00, z=150.50], EntityBat['Bat'/164, l='MpServer', x=-18.46, y=36.50, z=60.33], EntityPig['Pig'/292, l='MpServer', x=83.31, y=63.00, z=156.15], EntitySkeleton['Skeleton'/165, l='MpServer', x=-19.51, y=12.00, z=106.19], EntityCow['Cow'/293, l='MpServer', x=91.50, y=71.00, z=193.12], EntityEnderman['Enderman'/166, l='MpServer', x=-28.50, y=12.00, z=169.50], EntityCreeper['Creeper'/167, l='MpServer', x=-29.50, y=12.00, z=167.50], EntityCreeper['Creeper'/168, l='MpServer', x=-29.50, y=31.00, z=210.50], EntityCow['Cow'/169, l='MpServer', x=-30.50, y=72.00, z=215.50], EntityCow['Cow'/170, l='MpServer', x=-31.50, y=72.00, z=213.50], EntityCow['Cow'/171, l='MpServer', x=-30.36, y=72.00, z=214.55], EntityCow['Cow'/172, l='MpServer', x=-27.50, y=72.00, z=214.50], EntityZombie['Zombie'/182, l='MpServer', x=-14.50, y=33.00, z=71.50], EntityBat['Bat'/183, l='MpServer', x=-3.89, y=31.17, z=91.49], EntitySkeleton['Skeleton'/184, l='MpServer', x=-7.50, y=33.00, z=91.50], EntityCreeper['Creeper'/185, l='MpServer', x=-14.50, y=13.00, z=102.50], EntitySpider['Spider'/186, l='MpServer', x=-8.08, y=15.00, z=103.18], EntityCreeper['Creeper'/187, l='MpServer', x=-2.50, y=16.00, z=101.50], EntitySpider['Spider'/188, l='MpServer', x=-2.30, y=34.00, z=97.70], EntityZombie['Zombie'/189, l='MpServer', x=-5.50, y=22.00, z=123.50], EntityZombie['Zombie'/190, l='MpServer', x=-1.50, y=22.00, z=127.50], EntityBat['Bat'/191, l='MpServer', x=-14.00, y=13.10, z=137.25], EntitySkeleton['Skeleton'/192, l='MpServer', x=-7.50, y=11.00, z=148.50], EntityCow['Cow'/193, l='MpServer', x=-12.50, y=72.00, z=217.50], EntityBat['Bat'/200, l='MpServer', x=9.45, y=18.23, z=85.53], EntityBat['Bat'/201, l='MpServer', x=7.47, y=18.35, z=80.96], EntityBat['Bat'/202, l='MpServer', x=10.26, y=18.40, z=83.57], EntityPig['Pig'/213, l='MpServer', x=29.97, y=69.00, z=71.07], EntityPig['Pig'/214, l='MpServer', x=31.51, y=69.00, z=73.27], EntityZombie['Zombie'/215, l='MpServer', x=30.34, y=13.00, z=110.76], EntitySkeleton['Skeleton'/216, l='MpServer', x=21.50, y=18.00, z=173.50], EntitySheep['Sheep'/221, l='MpServer', x=34.43, y=68.00, z=61.57], EntitySheep['Sheep'/222, l='MpServer', x=36.51, y=67.00, z=63.52], EntitySheep['Sheep'/223, l='MpServer', x=37.66, y=67.00, z=63.15], EntityPig['Pig'/226, l='MpServer', x=33.50, y=68.00, z=71.50], EntityPig['Pig'/227, l='MpServer', x=32.50, y=68.00, z=70.50], EntitySheep['Sheep'/228, l='MpServer', x=38.50, y=67.00, z=66.50], EntityCreeper['Creeper'/229, l='MpServer', x=36.50, y=15.00, z=90.50], EntityCreeper['Creeper'/230, l='MpServer', x=36.50, y=15.00, z=90.50], EntitySpider['Spider'/231, l='MpServer', x=36.50, y=15.00, z=90.50], EntityBat['Bat'/232, l='MpServer', x=37.51, y=16.99, z=90.92], EntityBat['Bat'/233, l='MpServer', x=38.18, y=15.19, z=194.58], EntityBat['Bat'/234, l='MpServer', x=35.36, y=12.37, z=188.67], EntityZombie['Zombie'/116, l='MpServer', x=-51.50, y=54.00, z=73.50], EntityBat['Bat'/117, l='MpServer', x=-52.27, y=14.03, z=100.04], EntityCow['Cow'/119, l='MpServer', x=-50.09, y=71.00, z=171.39], EntityCow['Cow'/120, l='MpServer', x=-51.08, y=71.00, z=171.83], EntityChicken['Chicken'/121, l='MpServer', x=-54.67, y=71.00, z=205.26], EntityChicken['Chicken'/122, l='MpServer', x=-62.50, y=70.00, z=203.50], EntityChicken['Chicken'/123, l='MpServer', x=-57.42, y=72.00, z=207.84], EntityZombie['Zombie'/124, l='MpServer', x=-54.91, y=47.00, z=209.70], EntityZombie['Zombie'/125, l='MpServer', x=-53.85, y=47.00, z=208.87], EntityBat['Bat'/253, l='MpServer', x=63.52, y=22.10, z=73.10], EntityChicken['Chicken'/126, l='MpServer', x=-57.50, y=72.00, z=210.50], EntityChicken['Chicken'/127, l='MpServer', x=-59.50, y=72.00, z=209.50], EntityCow['Cow'/255, l='MpServer', x=63.50, y=70.00, z=193.85]]
    Retry entities: 0 total; []
    Server brand: fml,forge
    Server type: Integrated singleplayer server
Stacktrace:
    at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:456)
    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2774)
    at net.minecraft.client.Minecraft.run(Minecraft.java:436)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:26)

-- System Details --
Details:
    Minecraft Version: 1.11.2
    Operating System: Windows 10 (amd64) version 10.0
    Java Version: 1.8.0_171, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 559183864 bytes (533 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
    FML: MCP 9.38 Powered by Forge 13.20.1.2386 5 mods loaded, 5 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    UCHIJAAAA    minecraft{1.11.2} [Minecraft] (minecraft.jar) 
    UCHIJAAAA    mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
    UCHIJAAAA    FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.11.2-13.20.1.2386.jar) 
    UCHIJAAAA    forge{13.20.1.2386} [Minecraft Forge] (forgeSrc-1.11.2-13.20.1.2386.jar) 
    UCHIJAAAA    fovcontrol{1.11.2} [fovcontrol] (bin) 
    Loaded coremods (and transformers): 
    GL info: ' Vendor: 'Intel' Version: '4.4.0 - Build 21.20.16.4542' Renderer: 'Intel(R) HD Graphics 520'
    Launched Version: 1.11.2
    LWJGL: 2.9.4
    OpenGL: Intel(R) HD Graphics 520 GL version 4.4.0 - Build 21.20.16.4542, Intel
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs: 
    Current Language: English (US)
    Profiler Position: N/A (disabled)
    CPU: 4x Intel(R) Core(TM) i7-6500U CPU @ 2.50GHz

 

Edited by K3YD0N
editing crash report
Link to comment
Share on other sites

24 minutes ago, diesieben07 said:

Your code has errors.

And you are using Eclipse, so you clicked "Ignore these errors and launch anyways". wtf did you expect to happen?

The error suggestion is to change isPotionActive to isPotionApplicable
The only problem is that isPotionApplicable has its own error with the only suggestion to change it to isPotionActive.

Yes I figured it would crash since it had errors, but I was hoping the crash report would help me figure something out.

Link to comment
Share on other sites

4 minutes ago, diesieben07 said:

Learn Java before Modding.

"Programming by Eclipse Quickfix" is not a viable technique.

Yeah no shit, The problem is I can't figure out what I did wrong, hence why I'm posting here.

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



×
×
  • Create New...

Important Information

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