Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8][SOLVED] Attribute Modifier Help


NovaViper
 Share

Recommended Posts

Hey, I'm trying to the health and damage attributes switch values whenever a certain condition for the entity is met. I tried switching where the method is called but nothing changes. Here is my code

 

	@Override
public void applyEntityAttributes() {
	super.applyEntityAttributes();
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896);
	this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.wildHealth());
	this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(this.wildDamage());
	this.updateEntityAttributes();
}

public void updateEntityAttributes() {
	if (this.isTamed()) {
		if (!this.isChild() && !this.hasEvolved()) {
			this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.tamedHealth() + this.effectiveLevel());
			this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(this.tamedDamage());
		}
		else if (!this.isChild() && this.hasEvolved()) {
			this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.evoHealth());
		}
		else {
			this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.babyHealth());
			this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(this.babyDamage());
		}
	}
	else {
		if (this.isChild()) {
			this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(this.babyHealth());
			this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(this.babyDamage());
		}
	}
}

public double tamedHealth() { // TODO
	if (this instanceof EntityZertum || this instanceof EntityRedZertum) {
		return 35;
	}
	else if (this instanceof EntityMetalZertum || this instanceof EntityIceZertum || this instanceof EntityForisZertum || this instanceof EntityDestroZertum || this instanceof EntityDarkZertum) {
		return 40;
	}
	return 0;
}

public double tamedDamage() {
	if (this instanceof EntityZertum || this instanceof EntityRedZertum || this instanceof EntityMetalZertum || this instanceof EntityIceZertum || this instanceof EntityForisZertum) {
		return 8;
	}
	else if (this instanceof EntityDestroZertum) {
		return 10;
	}
	else if (this instanceof EntityDarkZertum) {
		return 12;
	}
	return 0;
}

public double evoHealth() {
	if (this instanceof EntityZertum || this instanceof EntityRedZertum || this instanceof EntityIceZertum) {
		return 45;
	}
	else if (this instanceof EntityMetalZertum || this instanceof EntityForisZertum || this instanceof EntityDestroZertum) {
		return 50;
	}
	else if (this instanceof EntityDarkZertum) {
		return 60;
	}
	return 0;
}

public double wildHealth() {
	if (this instanceof EntityZertum || this instanceof EntityRedZertum || this instanceof EntityForisZertum) {
		return 25;
	}
	else if (this instanceof EntityMetalZertum || this instanceof EntityDestroZertum || this instanceof EntityDarkZertum) {
		return 30;
	}
	else if (this instanceof EntityIceZertum) {
		return 35;
	}
	return 0;
}

public double wildDamage() {
	if (this instanceof EntityZertum || this instanceof EntityRedZertum || this instanceof EntityMetalZertum || this instanceof EntityIceZertum || this instanceof EntityForisZertum) {
		return 6;
	}
	else if (this instanceof EntityDestroZertum) {
		return 8;
	}
	else if (this instanceof EntityDarkZertum) {
		return 10;
	}
	return 0;
}

public double babyHealth() {
	return 10;
}

public double babyDamage() {
	if (this instanceof EntityZertum || this instanceof EntityRedZertum || this instanceof EntityMetalZertum) {
		return 2;
	}
	else if (this instanceof EntityIceZertum || this instanceof EntityForisZertum || this instanceof EntityDarkZertum) {
		return 4;
	}
	else if (this instanceof EntityDestroZertum) {
		return 3;
	}
	return 0;
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

  • Replies 105
  • Created
  • Last Reply

Top Posters In This Topic

applyEntityAttributes is called when the entity is first constructed (i.e. before NBT is read), so your entity does not yet know if it is a child or evolved or anything else.

 

You will need to update the attributes somewhere else, such as readFromNBT, onSpawnWithEgg, or better, when you set 'hasEvolved' or any other field that influences them.

 

The shared monster attributes are all saved, so if you set them once (such as from setEvolved() or whatever), they will retain the values you set when you reload the game.

Link to comment
Share on other sites

I noticed that and now I got it to work, I did the same thing that in the EntityWolf did: it overrided the default setTame method and added the attribute switches. Also I put these switches in my commands that switches the birth stage of the creatures.  I have another little issue though, the creature's stats are displayed in a GUI, the health and other stats are being updated but the damage and speed isn't changing when setting the creature to a baby (works when taming and evolving it, which ONLY changes the damage; but I have talents that changes the speed and damage). My code is on my Github: https://github.com/NovaViper/ZeroQuest/tree/master/src/main/java/common/zeroquest

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

Without searching through your entire code base for unnamed classes, the issue seems to simply be that damage / speed attributes are not automatically sent to the client, whereas health and others are. Are you using attribute modifiers for damage and speed also?

 

If you are not using attribute modifiers for the talent bonuses, then that is your solution. If you are, then the solution is either to send a packet to update the client whenever a talent changes or, if the code happens to run on both sides, just apply the talent on both sides. You'll probably still want to send a packet at some point to validate that the value is correct on the client.

 

Show me your 'talent' code that affects damage and speed, as well as where you apply them.

Link to comment
Share on other sites

Not exactly, the methods i'm using to get the values of the attributes are these

 

	@Override
public float getAIMoveSpeed() {
	double speed = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();

	speed += TalentHelper.addToMoveSpeed(this);

	if ((!(this.getAttackTarget() instanceof EntityZertumEntity) && !(this.getAttackTarget() instanceof EntityPlayer)) || this.riddenByEntity instanceof EntityPlayer) {
		if (this.levels.getLevel() == Constants.maxLevel && this.hasEvolved()) {
			speed += 1.0D;
		}
		else if (this.hasEvolved() && this.levels.getLevel() != Constants.maxLevel) {
			speed += 1.0D;
		}
	}

	if (this.riddenByEntity instanceof EntityPlayer) {
		speed /= 4;
	}

	return (float) speed;
}

public float getAIAttackDamage() { // TODO
	double damage = this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
	damage += TalentHelper.addToAttackDamage(this);

	if ((!(this.getAttackTarget() instanceof EntityZertumEntity) && !(this.getAttackTarget() instanceof EntityPlayer))) {
		if (this.levels.getLevel() == Constants.maxLevel && this.hasEvolved()) {
			damage += 2.0D;
		}
		else if (this.hasEvolved() && this.levels.getLevel() != Constants.maxLevel) {
			damage += 2.0D;
		}
	}

	return (float) damage;
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

Instead of TalentHelper and manually adding adjustments for being evolved, why not add speed modifier as part of the talent / when the entity evolves? Then the entity's speed will be adjusted automatically. Otherwise, you will need to send all of your talents and evolved statuses to the client for it to display the bonuses properly.

Link to comment
Share on other sites

The TalentHelper is for the talents, it adds onto the attribute when the level of the talent is increased. I have this method in the Dasher talent (which adds to the speed of the entity)

 

	@Override
public double addToMoveSpeed(EntityZertumEntity dog) {
	double speed = 0.0D;
	int level = dog.talents.getLevel(this);

	if ((!(dog.getAttackTarget() instanceof EntityZertumEntity) && !(dog.getAttackTarget() instanceof EntityPlayer)) || dog.riddenByEntity instanceof EntityPlayer) {
		if (level == 5) {
			speed += 0.04D;
		}
	}
	speed += 0.03D * level;
	return speed;
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

I realize what your TalentHelper is for, my point is why use it to directly modify the returned speed value when you could instead add an attribute modifier to speed each time your talent changes? This way, you don't have to do ANY calculations at all when returning speed - it is all handled automatically by the SharedMonsterAttribute / AttributeModifiers, which should also automatically be known by the client so you can display the appropriate speed value.

Link to comment
Share on other sites

Hey I fixed it, I added dog.updateEntityAttributes in the TalentHelper methods like so and got it working

 

	public static double addToMoveSpeed(EntityZertumEntity dog) {
	double total = 0;
	for (ITalent talent : TalentRegistry.getTalents()) {
		total += talent.addToMoveSpeed(dog);
		dog.updateEntityAttributes();
	}
	return total;
}

public static double addToAttackDamage(EntityZertumEntity dog) {
	double total = 0;
	for (ITalent talent : TalentRegistry.getTalents()) {
		total += talent.addToAttackDamage(dog);
		dog.updateEntityAttributes();
	}
	return total;
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

Oh hey, I have another issue relating to the GUI, the client keeps on crashing whenever I right click on an entity when I am logged in as a different user.

Crash Log

[21:26:53] [server thread/WARN]: Can't keep up! Did the system time change, or is the server overloaded? Running 2589ms behind, skipping 51 tick(s)
[21:31:16] [server thread/INFO]: Stopping server
[21:31:16] [server thread/INFO]: Saving players
[21:31:16] [server thread/INFO]: Saving worlds
[21:31:16] [server thread/INFO]: Saving chunks for level 'New World'/Overworld
[21:31:16] [server thread/INFO]: Saving chunks for level 'New World'/Nether
[21:31:16] [server thread/INFO]: Saving chunks for level 'New World'/The End
[21:31:16] [server thread/INFO]: Saving chunks for level 'New World'/Darkax
[21:31:16] [server thread/INFO]: Saving chunks for level 'New World'/Nillax
[21:31:17] [server thread/INFO] [FML]: Unloading dimension 0
[21:31:17] [server thread/INFO] [FML]: Unloading dimension -1
[21:31:17] [server thread/INFO] [FML]: Unloading dimension 1
[21:31:17] [server thread/INFO] [FML]: Unloading dimension 3
[21:31:17] [server thread/INFO] [FML]: Unloading dimension 2
[21:31:17] [server thread/INFO] [FML]: Applying holder lookups
[21:31:17] [server thread/INFO] [FML]: Holder lookups applied
[21:31:19] [Client thread/FATAL]: Reported exception thrown!
net.minecraft.util.ReportedException: Rendering screen
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1164) ~[EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1107) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_25]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
at GradleStart.main(Unknown Source) [start/:?]
Caused by: java.lang.NullPointerException
at common.zeroquest.client.gui.GuiDogInfo.drawScreen(GuiDogInfo.java:141) ~[GuiDogInfo.class:?]
at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:462) ~[ForgeHooksClient.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1134) ~[EntityRenderer.class:?]
... 11 more
[21:31:19] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:660]: ---- Minecraft Crash Report ----
// I feel sad now 

Time: 5/4/15 9:31 PM
Description: Rendering screen

java.lang.NullPointerException: Rendering screen
at common.zeroquest.client.gui.GuiDogInfo.drawScreen(GuiDogInfo.java:141)
at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:462)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1134)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1107)
at net.minecraft.client.Minecraft.run(Minecraft.java:376)
at net.minecraft.client.main.Main.main(Main.java:117)
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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)


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

-- Head --
Stacktrace:
at common.zeroquest.client.gui.GuiDogInfo.drawScreen(GuiDogInfo.java:141)
at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:462)

-- Screen render details --
Details:
Screen name: common.zeroquest.client.gui.GuiDogInfo
Mouse location: Scaled: (341, 176). Absolute: (683, 353)
Screen size: Scaled: (683, 353). Absolute: (1366, 706). Scale factor of 2

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityPlayerSP['Player785'/181, l='MpServer', x=-196.16, y=4.00, z=1167.38]]
Chunk stats: MultiplayerChunkCache: 440, 440
Level seed: 0
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options: 
Level spawn location: -138.00,4.00,1142.00 - World: (-138,4,1142), Chunk: (at 6,0,6 in -9,71; contains blocks -144,0,1136 to -129,255,1151), Region: (-1,2; contains chunks -32,64 to -1,95, blocks -512,0,1024 to -1,255,1535)
Level time: 40930 game time, 27144 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: 104 total; [EntityVillager['Villager'/17, l='MpServer', x=-273.44, y=5.00, z=1147.09], EntityVillager['Villager'/18, l='MpServer', x=-276.69, y=4.00, z=1145.91], EntityVillager['Villager'/19, l='MpServer', x=-273.09, y=6.00, z=1163.56], EntitySlime['Slime'/26, l='MpServer', x=-270.75, y=4.00, z=1240.66], EntitySlime['Slime'/29, l='MpServer', x=-262.50, y=4.00, z=1141.00], EntityVillager['Villager'/30, l='MpServer', x=-267.72, y=4.00, z=1142.53], EntityBat['Bat'/31, l='MpServer', x=-269.81, y=6.10, z=1148.38], EntityBat['Bat'/32, l='MpServer', x=-271.88, y=6.10, z=1157.19], EntityVillager['Villager'/33, l='MpServer', x=-269.81, y=4.00, z=1166.50], EntityVillager['Villager'/34, l='MpServer', x=-271.09, y=5.00, z=1160.94], EntitySlime['Slime'/35, l='MpServer', x=-258.19, y=5.16, z=1164.16], EntityVillager['Villager'/36, l='MpServer', x=-269.09, y=5.00, z=1163.50], EntitySlime['Slime'/37, l='MpServer', x=-261.50, y=4.00, z=1171.88], EntityVillager['Villager'/38, l='MpServer', x=-278.25, y=5.00, z=1159.50], EntityVillager['Villager'/39, l='MpServer', x=-256.22, y=5.00, z=1174.47], EntitySlime['Slime'/40, l='MpServer', x=-264.34, y=4.00, z=1227.03], EntityPig['Pig'/44, l='MpServer', x=-244.31, y=4.00, z=1093.09], EntityPig['Pig'/45, l='MpServer', x=-239.94, y=4.00, z=1103.09], EntityBat['Bat'/46, l='MpServer', x=-251.25, y=7.10, z=1166.31], EntitySlime['Slime'/47, l='MpServer', x=-251.91, y=4.00, z=1158.13], EntityItem['item.item.rottenFlesh'/48, l='MpServer', x=-240.75, y=4.00, z=1162.41], EntitySlime['Slime'/49, l='MpServer', x=-250.22, y=5.00, z=1155.22], EntityBat['Bat'/50, l='MpServer', x=-252.25, y=8.10, z=1164.25], EntityVillager['Villager'/51, l='MpServer', x=-236.84, y=5.00, z=1155.72], EntitySlime['Slime'/52, l='MpServer', x=-240.09, y=5.00, z=1153.63], EntityCreeper['Creeper'/53, l='MpServer', x=-257.03, y=5.00, z=1172.47], EntityItem['item.item.egg'/54, l='MpServer', x=-242.38, y=4.00, z=1168.91], EntityVillager['Villager'/55, l='MpServer', x=-251.66, y=5.00, z=1164.78], EntityVillager['Villager'/56, l='MpServer', x=-243.78, y=5.00, z=1180.31], EntityVillager['Villager'/57, l='MpServer', x=-247.56, y=6.00, z=1181.22], EntityVillager['Villager'/58, l='MpServer', x=-254.50, y=4.00, z=1186.28], EntitySlime['Slime'/59, l='MpServer', x=-248.19, y=4.00, z=1228.19], EntitySlime['Slime'/60, l='MpServer', x=-252.13, y=4.00, z=1235.25], EntityPig['Pig'/67, l='MpServer', x=-232.09, y=4.00, z=1096.97], EntityItem['item.item.wheat'/68, l='MpServer', x=-232.75, y=5.00, z=1158.88], EntityItem['item.item.seeds'/69, l='MpServer', x=-231.50, y=5.00, z=1158.97], EntityChicken['Chicken'/70, l='MpServer', x=-227.66, y=4.00, z=1182.34], EntitySlime['Slime'/71, l='MpServer', x=-233.53, y=4.00, z=1178.63], EntitySlime['Slime'/72, l='MpServer', x=-221.06, y=4.00, z=1220.75], EntityPig['Pig'/74, l='MpServer', x=-212.31, y=4.00, z=1093.56], EntityChicken['Chicken'/75, l='MpServer', x=-210.47, y=4.00, z=1106.13], EntityChicken['Chicken'/76, l='MpServer', x=-222.47, y=4.00, z=1113.31], EntityItem['item.item.bone'/77, l='MpServer', x=-216.16, y=4.00, z=1134.56], EntitySlime['Slime'/78, l='MpServer', x=-207.34, y=4.00, z=1123.38], EntityItem['item.item.arrow'/79, l='MpServer', x=-220.44, y=4.00, z=1125.66], EntityItem['item.item.bone'/80, l='MpServer', x=-219.94, y=4.00, z=1125.06], EntityItem['item.item.arrow'/81, l='MpServer', x=-216.28, y=4.00, z=1134.41], EntityChicken['Chicken'/82, l='MpServer', x=-212.34, y=4.00, z=1154.41], EntityItem['item.item.arrow'/83, l='MpServer', x=-217.78, y=4.00, z=1203.97], EntityItem['item.item.bone'/84, l='MpServer', x=-217.06, y=4.00, z=1203.53], EntityItem['item.item.arrow'/85, l='MpServer', x=-208.13, y=4.00, z=1210.44], EntityItem['item.item.arrow'/86, l='MpServer', x=-212.53, y=4.00, z=1202.25], EntitySlime['Slime'/87, l='MpServer', x=-209.34, y=4.75, z=1220.75], EntitySlime['Slime'/88, l='MpServer', x=-212.75, y=4.78, z=1243.69], EntitySlime['Slime'/90, l='MpServer', x=-220.34, y=4.00, z=1241.44], EntitySlime['Slime'/91, l='MpServer', x=-219.16, y=4.00, z=1247.97], EntitySlime['Slime'/97, l='MpServer', x=-210.09, y=4.47, z=1092.06], EntityChicken['Chicken'/99, l='MpServer', x=-200.41, y=4.00, z=1111.03], EntitySlime['Slime'/100, l='MpServer', x=-210.38, y=4.00, z=1108.03], EntityItem['item.item.egg'/101, l='MpServer', x=-205.97, y=4.00, z=1107.56], EntityChicken['Chicken'/102, l='MpServer', x=-198.44, y=4.00, z=1123.38], EntityCreeper['Creeper'/103, l='MpServer', x=-196.19, y=4.00, z=1128.59], EntitySlime['Slime'/104, l='MpServer', x=-202.22, y=5.16, z=1148.94], EntitySpider['Spider'/105, l='MpServer', x=-194.28, y=4.00, z=1155.66], EntitySlime['Slime'/106, l='MpServer', x=-202.59, y=4.02, z=1147.91], EntityItem['item.item.egg'/107, l='MpServer', x=-196.75, y=4.00, z=1159.19], EntityMetalZertum['Blast Max'/108, l='MpServer', x=-195.81, y=4.00, z=1170.22], EntityMetalZertum[''/109, l='MpServer', x=-192.66, y=4.00, z=1179.34], EntitySlime['Slime'/110, l='MpServer', x=-197.44, y=5.22, z=1165.75], EntityItem['item.item.bone'/111, l='MpServer', x=-207.81, y=4.00, z=1211.16], EntitySlime['Slime'/112, l='MpServer', x=-198.16, y=4.00, z=1229.84], EntitySpider['Spider'/113, l='MpServer', x=-207.00, y=4.00, z=1216.63], EntitySlime['Slime'/116, l='MpServer', x=-179.72, y=4.00, z=1158.66], EntityItem['item.item.bone'/117, l='MpServer', x=-183.38, y=4.00, z=1192.78], EntityPig['Pig'/118, l='MpServer', x=-190.84, y=4.00, z=1191.44], EntitySlime['Slime'/119, l='MpServer', x=-184.34, y=4.00, z=1236.69], EntityCow['Cow'/122, l='MpServer', x=-158.78, y=4.00, z=1088.88], EntityPig['Pig'/123, l='MpServer', x=-166.03, y=4.00, z=1142.97], EntityChicken['Chicken'/124, l='MpServer', x=-164.50, y=4.00, z=1165.03], EntitySlime['Slime'/125, l='MpServer', x=-158.50, y=4.00, z=1176.25], EntitySlime['Slime'/126, l='MpServer', x=-166.25, y=4.00, z=1177.78], EntitySlime['Slime'/127, l='MpServer', x=-162.84, y=4.00, z=1182.50], EntityItem['item.item.rottenFlesh'/128, l='MpServer', x=-160.78, y=4.00, z=1190.44], EntityItem['item.item.arrow'/129, l='MpServer', x=-166.56, y=4.00, z=1215.88], EntityCow['Cow'/133, l='MpServer', x=-158.00, y=4.00, z=1090.47], EntitySlime['Slime'/134, l='MpServer', x=-148.69, y=4.00, z=1169.56], EntitySlime['Slime'/135, l='MpServer', x=-150.94, y=4.00, z=1187.91], EntitySlime['Slime'/136, l='MpServer', x=-151.97, y=4.42, z=1191.66], EntitySlime['Slime'/137, l='MpServer', x=-151.00, y=5.00, z=1191.81], EntitySlime['Slime'/138, l='MpServer', x=-154.03, y=5.00, z=1187.69], EntityItem['item.item.rottenFlesh'/139, l='MpServer', x=-159.03, y=4.00, z=1202.56], EntityPig['Pig'/140, l='MpServer', x=-149.13, y=4.00, z=1201.31], EntitySlime['Slime'/145, l='MpServer', x=-146.84, y=4.47, z=1186.75], EntitySlime['Slime'/146, l='MpServer', x=-138.88, y=4.00, z=1198.03], EntitySlime['Slime'/147, l='MpServer', x=-139.66, y=4.00, z=1188.97], EntitySlime['Slime'/148, l='MpServer', x=-140.66, y=4.02, z=1193.66], EntitySlime['Slime'/149, l='MpServer', x=-130.66, y=4.75, z=1201.03], EntityPig['Pig'/150, l='MpServer', x=-143.13, y=4.00, z=1203.94], EntitySpider['Spider'/151, l='MpServer', x=-131.41, y=4.00, z=1236.84], EntitySlime['Slime'/154, l='MpServer', x=-128.22, y=4.42, z=1096.41], EntitySlime['Slime'/156, l='MpServer', x=-123.22, y=4.00, z=1180.28], EntitySlime['Slime'/158, l='MpServer', x=-117.16, y=5.16, z=1210.75], EntitySlime['Slime'/159, l='MpServer', x=-125.47, y=4.00, z=1218.63], EntityPlayerSP['Player785'/181, l='MpServer', x=-196.16, y=4.00, z=1167.38]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:392)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2606)
at net.minecraft.client.Minecraft.run(Minecraft.java:398)
at net.minecraft.client.main.Main.main(Main.java:117)
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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)

 

 

GUI code

package common.zeroquest.client.gui;

import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;

import org.apache.commons.lang3.StringUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import common.zeroquest.api.interfaces.ITalent;
import common.zeroquest.api.registry.TalentRegistry;
import common.zeroquest.entity.util.ModeUtil.EnumMode;
import common.zeroquest.entity.zertum.EntityZertumEntity;
import common.zeroquest.lib.Constants;
import common.zeroquest.network.PacketHandler;
import common.zeroquest.network.imessage.ZertumMode;
import common.zeroquest.network.imessage.ZertumName;
import common.zeroquest.network.imessage.ZertumObey;
import common.zeroquest.network.imessage.ZertumTalents;

/**
* @author ProPercivalalb
*/
public class GuiDogInfo extends GuiScreen {

public EntityZertumEntity dog;
public EntityPlayer player;
private ScaledResolution resolution;
private final List<GuiTextField> textfieldList = new ArrayList<GuiTextField>();
private GuiTextField nameTextField;
private int currentPage = 0;
private int maxPages = 1;
public int btnPerPages = 0;
private final DecimalFormat dfShort = new DecimalFormat("0.00");

public GuiDogInfo(EntityZertumEntity dog, EntityPlayer player) {
	this.dog = dog;
	this.player = player;
}

@Override
public void initGui() {
	super.initGui();
	this.buttonList.clear();
	this.labelList.clear();
	this.textfieldList.clear();
	this.resolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
	Keyboard.enableRepeatEvents(true);
	int topX = this.width / 2;
	int topY = this.height / 2;
	GuiTextField nameTextField = new GuiTextField(0, this.fontRendererObj, topX - 100, topY + 50, 200, 20) {
		@Override
		public boolean textboxKeyTyped(char character, int keyId) {
			boolean typed = super.textboxKeyTyped(character, keyId);
			if (typed) {
				PacketHandler.sendToServer(new ZertumName(dog.getEntityId(), this.getText()));
			}
			return typed;
		}
	};
	nameTextField.setFocused(false);
	nameTextField.setMaxStringLength(32);
	nameTextField.setText(this.dog.getZertumName());
	this.nameTextField = nameTextField;

	this.textfieldList.add(nameTextField);

	int size = TalentRegistry.getTalents().size();

	int temp = 0;
	while ((temp + 2) * 21 + 10 < this.resolution.getScaledHeight()) {
		temp += 1;
	}

	this.btnPerPages = temp;

	if (temp < size) {
		this.buttonList.add(new GuiButton(-1, 25, temp * 21 + 10, 20, 20, "<"));
		this.buttonList.add(new GuiButton(-2, 48, temp * 21 + 10, 20, 20, ">"));
	}

	if (this.btnPerPages < 1) {
		this.btnPerPages = 1;
	}

	this.maxPages = (int) Math.ceil((double) TalentRegistry.getTalents().size() / (double) this.btnPerPages);

	if (this.currentPage >= this.maxPages) {
		this.currentPage = 0;
	}

	for (int i = 0; i < this.btnPerPages; ++i) {
		if ((this.currentPage * this.btnPerPages + i) >= TalentRegistry.getTalents().size()) {
			continue;
		}
		this.buttonList.add(new GuiButton(1 + this.currentPage * this.btnPerPages + i, 25, 10 + i * 21, 20, 20, "+"));
	}
	if (this.dog.isOwner(this.player)) {
		this.buttonList.add(new GuiButton(-5, this.width - 64, topY + 65, 42, 20, String.valueOf(this.dog.willObeyOthers())));
	}

	this.buttonList.add(new GuiButton(-6, topX + 40, topY + 25, 60, 20, this.dog.mode.getMode().modeName()));
}

@Override
public void drawScreen(int xMouse, int yMouse, float partialTickTime) {
	this.drawDefaultBackground();
	// Background
	int topX = this.width / 2;
	int topY = this.height / 2;
	String health = dfShort.format(this.dog.getHealth());
	String healthMax = dfShort.format(this.dog.getMaxHealth());
	String healthRel = dfShort.format(this.dog.getHealthRelative() * 100);
	String healthState = health + "/" + healthMax + "(" + healthRel + "%)";
	String damageValue = dfShort.format(this.dog.getAIAttackDamage());
	String damageState = damageValue;
	String speedValue = dfShort.format(this.dog.getAIMoveSpeed());
	String speedState = speedValue;

	String tamedString = null;
	if (this.dog.isTamed()) {
		Entity player = this.dog.getOwner();
		if (player != null) {
			tamedString = "Yes (You)";
		}
		else {
			tamedString = "Yes (" + StringUtils.abbreviate(this.dog.getOwner().getName(), 22) + ")";
		}
	}

	String evoString = null;
	if (!this.dog.hasEvolved() && !this.dog.isChild() && this.dog.levels.getLevel() < Constants.maxLevel) {
		evoString = "Not at Alpha Level!";
	}
	else if (!this.dog.hasEvolved() && this.dog.isChild() && this.dog.levels.getLevel() < Constants.maxLevel) {
		evoString = "Too Young!";
	}
	else if (!this.dog.hasEvolved() && !this.dog.isChild() && this.dog.levels.getLevel() >= Constants.maxLevel) {
		evoString = "Ready!";
	}
	else if (this.dog.hasEvolved() && !this.dog.isChild()) {
		evoString = "Already Evolved!";
	}

	this.fontRendererObj.drawString("New name:", topX - 100, topY + 38, 4210752);
	this.fontRendererObj.drawString("Level: " + this.dog.levels.getLevel(), topX - 75, topY + 75, 0xFF10F9);
	this.fontRendererObj.drawString("Points Left: " + this.dog.spendablePoints(), topX, topY + 75, 0xFFFFFF);
	this.fontRendererObj.drawString("Health: " + healthState, topX + 190, topY - 170, 0xFFFFFF);
	this.fontRendererObj.drawString("Damage: " + damageState, topX + 190, topY - 160, 0xFFFFFF);
	this.fontRendererObj.drawString("Speed: " + speedState, topX + 190, topY - 150, 0xFFFFFF);
	this.fontRendererObj.drawString("Tamed: " + tamedString, topX + 190, topY - 140, 0xFFFFFF);
	this.fontRendererObj.drawString("State: " + evoString, topX + 190, topY - 130, 0xFFFFFF);
	if (this.dog.isOwner(this.player)) {
		this.fontRendererObj.drawString("Obey Others?", this.width - 76, topY + 55, 0xFFFFFF);
	}

	for (int i = 0; i < this.btnPerPages; ++i) {
		if ((this.currentPage * this.btnPerPages + i) >= TalentRegistry.getTalents().size()) {
			continue;
		}
		this.fontRendererObj.drawString(TalentRegistry.getTalent(this.currentPage * this.btnPerPages + i).getLocalisedName(), 50, 17 + i * 21, 0xFFFFFF);
	}

	for (GuiTextField field : this.textfieldList) {
		field.drawTextBox();
	}
	GL11.glDisable(GL12.GL_RESCALE_NORMAL);
	RenderHelper.disableStandardItemLighting();
	GL11.glDisable(GL11.GL_LIGHTING);
	GL11.glDisable(GL11.GL_DEPTH_TEST);
	super.drawScreen(xMouse, yMouse, partialTickTime);
	RenderHelper.enableGUIStandardItemLighting();

	// Foreground

	GL11.glPushMatrix();
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	for (int k = 0; k < this.buttonList.size(); ++k) {
		GuiButton button = (GuiButton) this.buttonList.get(k);
		if (button.mousePressed(this.mc, xMouse, yMouse)) {
			List list = new ArrayList();
			if (button.id >= 1 && button.id <= TalentRegistry.getTalents().size()) {
				ITalent talent = TalentRegistry.getTalent(button.id - 1);

				list.add(EnumChatFormatting.GREEN + talent.getLocalisedName());
				list.add("Level: " + this.dog.talents.getLevel(talent));
				list.add(EnumChatFormatting.GRAY + "--------------------------------");
				list.addAll(this.splitInto(talent.getLocalisedInfo(), 200, this.mc.fontRendererObj));
			}
			else if (button.id == -1) {
				list.add(EnumChatFormatting.ITALIC + "Previous Page");
			}
			else if (button.id == -2) {
				list.add(EnumChatFormatting.ITALIC + "Next Page");
			}
			else if (button.id == -6) {
				String str = StatCollector.translateToLocal("modeinfo." + button.displayString.toLowerCase());
				list.addAll(splitInto(str, 150, this.mc.fontRendererObj));
			}

			this.drawHoveringText(list, xMouse, yMouse, this.mc.fontRendererObj);
		}
	}
	GL11.glPopMatrix();
}

@Override
protected void actionPerformed(GuiButton button) {

	if (button.id >= 1 && button.id <= TalentRegistry.getTalents().size()) {
		ITalent talent = TalentRegistry.getTalent(button.id - 1);
		int level = this.dog.talents.getLevel(talent);

		if (level < talent.getHighestLevel(this.dog) && this.dog.spendablePoints() >= talent.getCost(this.dog, level + 1)) {
			PacketHandler.sendToServer(new ZertumTalents(this.dog.getEntityId(), TalentRegistry.getTalent(button.id - 1).getKey()));
		}

	}
	else if (button.id == -1) {
		if (this.currentPage > 0) {
			this.currentPage -= 1;
			this.initGui();
		}
	}
	else if (button.id == -2) {
		if (this.currentPage + 1 < this.maxPages) {
			this.currentPage += 1;
			this.initGui();
		}
	}
	if (button.id == -5) {
		if (!this.dog.willObeyOthers()) {
			button.displayString = "true";
			PacketHandler.sendToServer(new ZertumObey(this.dog.getEntityId(), true));

		}
		else {
			button.displayString = "false";
			PacketHandler.sendToServer(new ZertumObey(this.dog.getEntityId(), false));
		}
	}

	if (button.id == -6) {
		int newMode = (dog.mode.getMode().ordinal() + 1) % EnumMode.values().length;
		EnumMode mode = EnumMode.values()[newMode];
		button.displayString = mode.modeName();
		PacketHandler.sendToServer(new ZertumMode(this.dog.getEntityId(), newMode));
	}
}

@Override
public void updateScreen() {
	for (GuiTextField field : this.textfieldList) {
		field.updateCursorCounter();
	}
}

@Override
public void mouseClicked(int xMouse, int yMouse, int mouseButton) throws IOException {
	super.mouseClicked(xMouse, yMouse, mouseButton);
	for (GuiTextField field : this.textfieldList) {
		field.mouseClicked(xMouse, yMouse, mouseButton);
	}
}

@Override
public void keyTyped(char character, int keyId) {
	for (GuiTextField field : this.textfieldList) {
		field.textboxKeyTyped(character, keyId);
	}

	if (keyId == Keyboard.KEY_ESCAPE) {
		this.mc.thePlayer.closeScreen();
	}
}

@Override
public void onGuiClosed() {
	Keyboard.enableRepeatEvents(false);
}

@Override
public boolean doesGuiPauseGame() {
	return false;
}

public List splitInto(String text, int maxLength, FontRenderer font) {
	List list = new ArrayList();

	String temp = "";
	String[] split = text.split(" ");

	for (int i = 0; i < split.length; ++i) {
		String str = split[i];
		int length = font.getStringWidth(temp + str);

		if (length > maxLength) {
			list.add(temp);
			temp = "";
		}

		temp += str + " ";

		if (i == split.length - 1) {
			list.add(temp);
		}
	}

	return list;
}
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

When the dog entity is not tamed, tamedString remains null and makes crash.

You should initialize it to something other like "Not Tamed" instead of null.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Here

 this.fontRendererObj.drawString("Tamed: " + tamedString, topX + 190, topY - 140, 0xFFFFFF);

 

But its something associated with this

 String tamedString = null;
	if (this.dog.isTamed()) {
		Entity player = this.dog.getOwner();
		if (player != null) {
			tamedString = "Yes (You)";
		}
		else {
			tamedString = "Yes (" + StringUtils.abbreviate(this.dog.getOwner().getName(), 22) + ")";
		}
	}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

Here

 this.fontRendererObj.drawString("Tamed: " + tamedString, topX + 190, topY - 140, 0xFFFFFF);

Was that the answer to my question? If so, that is impossible. Nothing on that line can NPE (technically fontRenderObj could be null, but unless you really screwed up royally when opening your Gui this is not null).
Link to comment
Share on other sites

No. The tamedString is null.

I already said:

When the dog entity is not tamed, tamedString remains null and makes crash.

You should initialize it to something other like "Not Tamed" instead of null.

 

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

It is null when the dog is not tamed. See the code, all substitutions to tamedString is in if(this.dog.isTamed())

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

First: we don't have all the code.

Second: We have no clear answer on which line the error actually occurs.

But it is clear that the line

this.fontRendererObj.drawString("Tamed: " + tamedString, topX + 190, topY - 140, 0xFFFFFF);

can throw the NPE with tamedString. See the code in GuiDogInfo#drawScreen(int xMouse, int yMouse, float partialTickTime).

tamedString is local variable in the method, it is initialized as null,

and it is only substituted with valid value only if the dog is tamed. So it throws NPE otherwise.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

What I want it to do is say the entity's owner name when another player that does not know thr entity opens the Gui and say 'You' when the owner opens the GUI

There is nothing wrong with your logic, you should only take care of exceptions. You should initialize tamedString to valid String, not null. (Show it as 'Not Tamed', etc.)

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

But it is clear that the line

this.fontRendererObj.drawString("Tamed: " + tamedString, topX + 190, topY - 140, 0xFFFFFF);

can throw the NPE with tamedString.

This is wrong.

System.out.println("hello" + null); // prints "hellonull"

So it was not clear; I'm blind. Sorry for that.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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
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.

 Share




  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • It worked thanks a lot ❤️ I'm gonna paste all of my code for anyone in the future looking to do capabilities package com.chickenwand3.rpgmod.core.capabilities.entity; import javax.annotation.Nullable; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.CapabilityToken; import net.minecraftforge.common.capabilities.ICapabilityProvider; public class CapabilityMobLevel{ public static Capability<MobLevel> MOB_LEVEL_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() {}); public static void register() { CapabilityManager.INSTANCE.register(MobLevel.class); } } package com.chickenwand3.rpgmod.core.capabilities.entity; public class DefaultMobLevel implements MobLevel { public int mobLevel; public float mobMaxHealth; public float mobCurrentHealth; public boolean crazy; public boolean isCrazy() { return crazy; } public float getMaxHealth() { return mobMaxHealth; } public float getCurrentHealth() { return mobCurrentHealth; } } package com.chickenwand3.rpgmod.core.capabilities.entity; public interface MobLevel { } package com.chickenwand3.rpgmod.core.capabilities.entity; import com.chickenwand3.rpgmod.RPGMod; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.monster.Zombie; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber(modid = RPGMod.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class MobLevelEventHandler { @SubscribeEvent public static void onAttachCapabilitiesEvent(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof Mob && !event.getObject().getCommandSenderWorld().isClientSide) { MobLevelProvider providerMobLevel = new MobLevelProvider(); event.addCapability(new ResourceLocation(RPGMod.MODID, "moblevel"), providerMobLevel); event.addListener(providerMobLevel::invalidate); } } @SubscribeEvent public void registerCaps(RegisterCapabilitiesEvent event) { event.register(MobLevel.class); } @SubscribeEvent public static void OnSpawn(final EntityJoinWorldEvent event) { if (event.getEntity()instanceof Mob target && !event.getWorld().isClientSide) { target.getCapability(CapabilityMobLevel.MOB_LEVEL_CAPABILITY).ifPresent(mobLevel -> { DefaultMobLevel actualMobLevel = (DefaultMobLevel) mobLevel; if (actualMobLevel.mobLevel < 1) { actualMobLevel.mobLevel = (randomizeMobLevel()); } if (superCrazy(actualMobLevel.mobLevel)) { actualMobLevel.crazy = true; } if (actualMobLevel.crazy) { if (!target.getMainHandItem().isEmpty()) { target.getMainHandItem().enchant(Enchantments.FIRE_ASPECT, 1); } if (event.getEntity()instanceof Zombie zombie) { zombie.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).setBaseValue(0.99D); } System.out.println("Super Crazy " + target.getName() + " has spawned!"); } actualMobLevel.mobMaxHealth = (target.getMaxHealth() * actualMobLevel.mobLevel * 2); actualMobLevel.mobCurrentHealth = actualMobLevel.mobMaxHealth; target.getAttribute(Attributes.MOVEMENT_SPEED) .setBaseValue(target.getAttributeValue(Attributes.MOVEMENT_SPEED) * (1 + (actualMobLevel.mobLevel - 1.0) / 10.0)); if (target.getAttribute(Attributes.ATTACK_DAMAGE) != null) { target.getAttribute(Attributes.ATTACK_DAMAGE) .setBaseValue(target.getAttributeValue(Attributes.ATTACK_DAMAGE) * (1 + (actualMobLevel.mobLevel - 1.0) / 2.0)); } }); } } private static int randomizeMobLevel() { boolean roll = true; int level = 1; while (roll) { if (Math.random() > .5) { level += 1; roll = true; } else { roll = false; } } return level; } private static boolean superCrazy(int level) { boolean result = false; if (level >= 5) { if (Math.random() < .25) { result = true; } else result = false; } return result; } } package com.chickenwand3.rpgmod.core.capabilities.entity; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.common.util.LazyOptional; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class MobLevelProvider implements ICapabilitySerializable<CompoundTag> { private final DefaultMobLevel mobLevel = new DefaultMobLevel(); private final LazyOptional<MobLevel> mobLevelOptional = LazyOptional.of(() -> mobLevel); public void invalidate() { mobLevelOptional.invalidate(); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { return mobLevelOptional.cast(); } @Override public CompoundTag serializeNBT() { System.out.println("It serialized"); if (CapabilityMobLevel.MOB_LEVEL_CAPABILITY == null) { System.out.println("It made a new compound"); return new CompoundTag(); } else { System.out.println("It serialized the values"); CompoundTag compoundNBT = new CompoundTag(); compoundNBT.putInt("mobLevel", mobLevel.mobLevel); compoundNBT.putFloat("mobCurrentHealth", mobLevel.mobCurrentHealth); compoundNBT.putFloat("mobMaxHealth", mobLevel.mobMaxHealth); compoundNBT.putBoolean("crazy", mobLevel.crazy); return compoundNBT; } } @Override public void deserializeNBT(CompoundTag nbt) { System.out.println("It deserialized"); if (CapabilityMobLevel.MOB_LEVEL_CAPABILITY != null) { System.out.println("It deserialized the values"); mobLevel.mobLevel = (nbt.getInt("mobLevel")); float mobCurrentHealth = nbt.getFloat("mobCurrentHealth"); mobLevel.mobCurrentHealth = (mobCurrentHealth); float mobMaxHealth = nbt.getFloat("mobMaxHealth"); mobLevel.mobMaxHealth = (mobMaxHealth); boolean crazy = nbt.getBoolean("crazy"); mobLevel.crazy = (crazy); } } }  
    • Just uploaded the correct installer from win machine to ubuntu via winscp. Sorry, didn't check the checksum. Very strange behavior :( Thank you!
    • I just tried it with both 36.2.0 and 36.2.19 using wget and the direct downloads. Both worked fine for me, giving me the correct MD5 sum. This is something on your machine.
    • And it's very strange, that if I try to download several times, this md5sum stays the same (6ecbb611d38ecd2c7bed8e1900e5dfc7).  
    • Wow! md5sum forge-1.16.5-36.2.0-installer.jar 6ecbb611d38ecd2c7bed8e1900e5dfc7  forge-1.16.5-36.2.0-installer.jar which doesn't align with original f2e0b8b9c7634fc854ce566f392dcded *forge-1.16.5-36.2.0-installer.jar and which is in my win download... Can you suggest what to use instead of wget?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.