Jump to content

[10.13.1188] NetHandlerPlayClient Attribute Bug


TLHPoE

Recommended Posts

Hi, I get a crash about an attribute having a base value that's lower than the minimum value.

 

It's in the NetHandlerPlayClient:

iattributeinstance = baseattributemap.registerAttribute(new RangedAttribute(snapshot.func_151409_a(), 0.0D, 2.2250738585072014E-308D, Double.MAX_VALUE));

Kain

Link to comment
Share on other sites

Ok, that didn't work either...

 

I did some more debugging and I tried not loading my attributes. It didn't crash. All of my attributes' base values are not below their minimum value. Is their a maximum amount of attributes that I can have?

Kain

Link to comment
Share on other sites

We would need full stack traces and code.

There shouldnt be a limit, but as this is computing there is always a limit, so its jsut a question of are you doing something crazy.

Also this should be in modder support not forge support as its your own code causing the issues.

 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Here's my code:

 

ModAttributes (I call the loadAttribute method in the pre initialization stage):

package terrarium.entity.attribute;

import net.minecraft.entity.ai.attributes.IAttribute;

public class ModAttributes {
public static IAttribute jumpHeight;

public static IAttribute maxJumps;

public static IAttribute stepHeight;

public static IAttribute maxMana;

public static IAttribute healthRegen;
public static IAttribute manaRegen;

public static IAttribute maxHurtResistantTime;

public static void loadAttributes() {
	jumpHeight = (new ModAttribute("generic.jumpHeight", 0.41999998688697815D, true)).setShouldWatch(true);

	maxJumps = (new ModAttribute("generic.maxJumps", 1, true)).setShouldWatch(true);

	stepHeight = (new ModAttribute("generic.stepHeight", 1, false)).setShouldWatch(true);

	maxMana = (new ModAttribute("generic.maxMana", 20, true)).setShouldWatch(true);

	healthRegen = new ModAttribute("generic.healthRegen", 1, false);
	manaRegen = new ModAttribute("generic.manaRegen", 1.5, true);

	maxHurtResistantTime = new ModAttribute("generic.maxHurtResistantTime", 20, false);
}
}

 

ModAttribute:

package terrarium.entity.attribute;

import net.minecraft.entity.ai.attributes.BaseAttribute;
import terrarium.Reference;

public class ModAttribute extends BaseAttribute {
public boolean isPlayerOnly = false;

public ModAttribute(String name, double defaultValue, boolean isPlayerOnly) {
	super(name, defaultValue);

	this.isPlayerOnly = isPlayerOnly;

	Reference.modAttributes.add(this);
}

@Override
public double clampValue(double value) {
	return value;
}
}

 

ForgeServerEventHandler:

@SubscribeEvent
public void entityConstruct(EntityConstructing event) {
	if(!event.entity.worldObj.isRemote) {
		if(event.entity instanceof EntityLivingBase) {
			EntityLivingBase entity = (EntityLivingBase) event.entity;
			boolean isPlayer = entity instanceof EntityPlayer;

			if(isPlayer) {
				ExtendedPlayerProperties.handlePropertiesFor((EntityPlayer) entity);
			}

			for(ModAttribute attribute : Reference.modAttributes) {
				if(attribute.isPlayerOnly && isPlayer) {
					entity.getAttributeMap().registerAttribute(attribute);
				} else if(!attribute.isPlayerOnly) {
					entity.getAttributeMap().registerAttribute(attribute);
				}
			}
		}
	}
}

 

Forgot the crash, sorry:

---- Minecraft Crash Report ----
// Ooh. Shiny.

Time: 7/26/14 7:21 PM
Description: Unexpected error

java.lang.IllegalArgumentException: Default value cannot be lower than minimum value!
at net.minecraft.entity.ai.attributes.RangedAttribute.<init>(RangedAttribute.java:22)
at net.minecraft.client.network.NetHandlerPlayClient.handleEntityProperties(NetHandlerPlayClient.java:1849)
at net.minecraft.network.play.server.S20PacketEntityProperties.processPacket(S20PacketEntityProperties.java:96)
at net.minecraft.network.play.server.S20PacketEntityProperties.processPacket(S20PacketEntityProperties.java:104)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:247)
at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:321)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1693)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039)
at net.minecraft.client.Minecraft.run(Minecraft.java:961)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at GradleStart.bounce(GradleStart.java:108)
at GradleStart.startClient(GradleStart.java:101)
at GradleStart.main(GradleStart.java:56)


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

-- Head --
Stacktrace:
at net.minecraft.entity.ai.attributes.RangedAttribute.<init>(RangedAttribute.java:22)
at net.minecraft.client.network.NetHandlerPlayClient.handleEntityProperties(NetHandlerPlayClient.java:1849)
at net.minecraft.network.play.server.S20PacketEntityProperties.processPacket(S20PacketEntityProperties.java:96)
at net.minecraft.network.play.server.S20PacketEntityProperties.processPacket(S20PacketEntityProperties.java:104)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:247)
at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:321)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['ForgeDevName'/275, l='MpServer', x=4.40, y=147.58, z=0.55]]
Chunk stats: MultiplayerChunkCache: 5, 5
Level seed: 0
Level generator: ID 00 - SIZE2, ver 0. Features enabled: false
Level generator options: 
Level spawn location: World: (-29,64,-19), Chunk: (at 3,4,13 in -2,-2; contains blocks -32,0,-32 to -17,255,-17), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
Level time: 76 game time, 76 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: 2 total; [EntityClientPlayerMP['ForgeDevName'/275, l='MpServer', x=4.40, y=147.58, z=0.55], EntitySheep['Sheep'/179, l='MpServer', x=17.22, y=147.00, z=29.78]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:417)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2568)
at net.minecraft.client.Minecraft.run(Minecraft.java:990)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at GradleStart.bounce(GradleStart.java:108)
at GradleStart.startClient(GradleStart.java:101)
at GradleStart.main(GradleStart.java:56)

-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 664297352 bytes (633 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 1, tcache: 1, allocated: 8, tallocated: 71
FML: MCP v9.05 FML v7.10.25.1188 Minecraft Forge 10.13.0.1188 4 mods loaded, 4 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
FML{7.10.25.1188} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.0.1188.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Forge{10.13.0.1188} [Minecraft Forge] (forgeSrc-1.7.10-10.13.0.1188.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
terrarium{Indev} [Terrarium] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.7.10
LWJGL: 2.9.1
OpenGL: GeForce GT 520/PCIe/SSE2 GL version 4.3.0, NVIDIA Corporation
GL Caps: Using GL 1.3 multitexturing.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Anisotropic filtering is supported and maximum anisotropy is 16.
Shaders are available because OpenGL 2.1 is supported.

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)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Anisotropic Filtering: Off (1)

Kain

Link to comment
Share on other sites

Hi Lex

 

I think his code is only indirectly causing the problem, I think it is a bug in Minecraft code.

 

This code is straight out of NetHandlerPlayClient::handleEntityProperties(..) -

 

  IAttributeInstance iattributeinstance = baseattributemap.getAttributeInstanceByName(snapshot.func_151409_a());
  if (iattributeinstance == null)  {
     iattributeinstance = baseattributemap.registerAttribute(new RangedAttribute(snapshot.func_151409_a(), 0.0D, 2.2250738585072014E-308D, Double.MAX_VALUE)); 
  }

and
  public RangedAttribute(String par1Str, double defaultValue, double minimumValue, double maximumValue) {
    super(par1Str, defaultValue);
    this.minimumValue = minimumValue;
    this.maximumValue = maximumValue;

    if (minimumValue > maximumValue) {
      throw new IllegalArgumentException("Minimum value cannot be bigger than maximum value!");
    } else if (defaultValue < minimumValue) {
      throw new IllegalArgumentException("Default value cannot be lower than minimum value!");
    } else if (defaultValue > maximumValue) {
      throw new IllegalArgumentException("Default value cannot be bigger than maximum value!");
    }
  }

 

Yes, the error is triggered by something his code does - attribute name is wrong maybe? - but the min value is for sure wrong, the code uses Double.MIN_NORMAL

but it should probably be

new RangedAttribute(snapshot.func_151409_a(), 0.0D, -Double.MAX_VALUE, Double.MAX_VALUE));

 

-TGG

Link to comment
Share on other sites

Hi TLHPoE

 

I would suggest the fastest way to narrow this down is to put a breakpoint on this line

  iattributeinstance = baseattributemap.registerAttribute(new RangedAttribute(snapshot.func_151409_a(), 0.0D, 2.2250738585072014E-308D, Double.MAX_VALUE));

and then look at snapshot.func_151409_a() to see what the attribute name is and (hopefully) why it's not being found in the baseattributemap.

 

-TGG

Link to comment
Share on other sites

Ok, I'm looking through it right now. It seems that the server goes through all of the entity's attributes, saves them to a snap shot, sends the snapshot to the client, and the client syncs up with the server via the data from the snapshot.

 

Not sure if I'm able to tell what the client is trying to sync there. :(

Kain

Link to comment
Share on other sites

Hi

 

When it stops at the breakpoint, inspect the snapshot variable and look at the value of the String field (in my forge version this is field_151412_b).  That is the attribute it was looking for but didn't find.

Then, look in baseattributemap.attributesByName to see the attributes that the client knows about for this entity.

 

My off-the-cuff guess is it's an upper-case / lower-case problem.  Try using only lower case for the attribute name.

 

    public class Snapshot
    {
        private final String field_151412_b;
        private final double field_151413_c;
        private final Collection field_151411_d;
        private static final String __OBFID = "CL_00001342";

 

-TGG

Link to comment
Share on other sites

Characters weren't a problem :|

 

I disabled all other mobs and loaded a world with my attributes. For some reason, whenever the break point hit at the snapshot class at world load, it was either maxHealth or speed. None of my attributes showed up. When I stepped up a block, the snapshot fired up and it was my step height attribute.

 

I'm not sure what to make of this. :(

Kain

Link to comment
Share on other sites

Hi

 

It appears that in your ModAttributes.loadAttributes, you have created two new ModAttributes which are being applied to all living creatures by the server.  So when the server sends an entity packet to the client, it includes information about those ModAttributes.  The Entities themselves don't contain these two new ModAttributes, which are normally added to attributeMap during construction (eg see EntityLivingBase.applyEntityAttributes()).

 

When the client gets the S20 packet, which contains information about your new ModAttributes (eg stepHeight), it looks for your new ModAttributes in the entity's attributeMap, doesn't find them, attempts to create a default object to hold the information, but due to a bug in vanilla, it crashes.

 

I think the answer is to make sure you also register your new attributes during construction of entities on the client side in

public void entityConstruct(EntityConstructing event) {

 

-TGG

 

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.