Jump to content

[1.12.2]Entity NBT not saving


GiantNuker

Recommended Posts

I have two spell entities - one is a shield, the other is a disarming bullet.

NBT is not being saved. The caster is not saved for either and the size is not saved for the shield.

I know because all my shields are tiny on the client but react in a five block range, and neither recognize the caster.

Example: saying Expelliarmus while holding a wand shoots the spell, but not only does it launch the target, it launches you, because the client does not know who cast it, and therefore - who not to hit.

 

Shield Charm

@Override
	public void readFromNBT(NBTTagCompound nbt) {
		super.readFromNBT(nbt);
		this.size = nbt.getFloat("size");
		setSize(size, size);
		NBTTagList list = (NBTTagList) nbt.getTag("casters");
		List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, this.getEntityBoundingBox());
		for (NBTBase n : list) {
			String uuid = n.toString();
			for (Entity e : entities) {
				if (e.getPersistentID().toString() == uuid) caster.add(e);
			}
		}
	}
	@Override
	public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
		super.writeToNBT(nbt);
		nbt.setFloat("size", size);
		NBTTagList list = new NBTTagList();
		for (Entity e : caster) {
			list.appendTag(new NBTTagString(e.getPersistentID().toString()));
		}
		nbt.setTag("casters", list);
		return nbt;
	}

And the Disarming spell extends EntityThrowale so it should save the thrower flag.

 

In PreInit

EntityRegistry.registerModEntity(new ResourceLocation(WizardryMod.MODID, "entitySpellShield"), EntityShieldCharm.class, "shieldSpell", 998, this, 100, 1, false);
		EntityRegistry.registerModEntity(new ResourceLocation(WizardryMod.MODID, "entityDisarmShield"), EntityDisarmSpell.class, "disarmSpell", 999, this, 100, 6, true);

 

Edited by GiantNuker
Link to comment
Share on other sites

Well a few things. First of all you shouldn't have to guess whether the code is running -- you should either add console statements in the methods or you should set breakpoints and run the code in debug mode. For something like this I would use console statements because then you'd get a good sense of when it might be saving or not, and you can also print out the values of key fields at that point in the execution. That way you can figure out if the code simply isn't running, or if it running but the values loaded don't match for some reason. 

 

Secondly, it looks like you're saying that the NBT code is in the shield charm, but your title says "entity nbt". Which is it? Is that data for the shield item or for the entity? If it is for the shield item, at what point do you expect it to be saved?

 

Thirdly, most of these sorts of problems are confusion about how to sync the client and the server. There are vanilla processes to sync the vanilla stuff, and some ability to have extended data communicated, but you often have to make sure either by initiating packets (through share tag methods, send packet methods, or mark dirty methods depending on the thing you're trying to sync), or even going as far as sending custom packets if necessary.

 

Also, I've found there is some tricks about NBT used together with item capabilities. Not clear if you're using capabilities for this item, but if you are the order in which the initi capabilities happens versus the reading of the NBT data might have to be sorted out -- in other words sometimes the NBT data reads but then the capability can get initialized to overwrite it.

 

But my main point is add console statements so you can actually track the execution and then it should be really easy to see what is wrong.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

13 hours ago, jabelar said:

Well a few things. First of all you shouldn't have to guess whether the code is running -- you should either add console statements in the methods or you should set breakpoints and run the code in debug mode. For something like this I would use console statements because then you'd get a good sense of when it might be saving or not, and you can also print out the values of key fields at that point in the execution. That way you can figure out if the code simply isn't running, or if it running but the values loaded don't match for some reason. 

 

Secondly, it looks like you're saying that the NBT code is in the shield charm, but your title says "entity nbt". Which is it? Is that data for the shield item or for the entity? If it is for the shield item, at what point do you expect it to be saved?

 

Thirdly, most of these sorts of problems are confusion about how to sync the client and the server. There are vanilla processes to sync the vanilla stuff, and some ability to have extended data communicated, but you often have to make sure either by initiating packets (through share tag methods, send packet methods, or mark dirty methods depending on the thing you're trying to sync), or even going as far as sending custom packets if necessary.

 

Also, I've found there is some tricks about NBT used together with item capabilities. Not clear if you're using capabilities for this item, but if you are the order in which the initi capabilities happens versus the reading of the NBT data might have to be sorted out -- in other words sometimes the NBT data reads but then the capability can get initialized to overwrite it.

 

But my main point is add console statements so you can actually track the execution and then it should be really easy to see what is wrong.

It is a shield entity.  It is cast by a magic wand. The wand has no nbt/capabilities, It is all stored in the player's capability.

 

Also just did that

2017-10-10 10:07:12,594 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
[10:07:12] [main/INFO]: Extra: []
[10:07:12] [main/INFO]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/T902/.gradle/caches/minecraft/assets, --assetIndex, 1.12, --accessToken{REDACTED}, --version, 1.12.2, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
[10:07:13] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[10:07:13] [main/INFO]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[10:07:13] [main/INFO]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[10:07:13] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[10:07:13] [main/INFO]: Forge Mod Loader version 14.23.0.2494 for Minecraft 1.12.2 loading
[10:07:13] [main/INFO]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_144, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jre1.8.0_144
[10:07:13] [main/INFO]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[10:07:13] [main/INFO]: Ignoring missing certificate for coremod FMLCorePlugin (net.minecraftforge.fml.relauncher.FMLCorePlugin), we are in deobf and it's a forge core plugin
[10:07:13] [main/INFO]: Ignoring missing certificate for coremod FMLForgePlugin (net.minecraftforge.classloading.FMLForgePlugin), we are in deobf and it's a forge core plugin
[10:07:13] [main/INFO]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
[10:07:13] [main/INFO]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
[10:07:13] [main/INFO]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
[10:07:13] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[10:07:13] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[10:07:13] [main/INFO]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[10:07:13] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[10:07:13] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[10:07:13] [main/INFO]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
2017-10-10 10:07:14,085 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
2017-10-10 10:07:14,804 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream
[10:07:19] [main/ERROR]: FML appears to be missing any signature data. This is not a good thing
[10:07:19] [main/INFO]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[10:07:19] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[10:07:21] [main/INFO]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[10:07:21] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[10:07:21] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[10:07:21] [main/INFO]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[10:07:23] [main/INFO]: Setting user: Player327
[10:07:33] [main/WARN]: Skipping bad option: lastServer:
[10:07:33] [main/INFO]: LWJGL Version: 2.9.4
[10:07:35] [main/INFO]: -- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: Windows 7 (amd64) version 6.1
	Java Version: 1.8.0_144, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 752826728 bytes (717 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: 
	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'Intel' Version: '3.3.0 - Build 8.15.10.2696' Renderer: 'Intel(R) HD Graphics 4000'
[10:07:35] [main/INFO]: MinecraftForge v14.23.0.2494 Initialized
[10:07:35] [main/INFO]: Starts to replace vanilla recipe ingredients with ore ingredients.
[10:07:35] [main/INFO]: Replaced 1036 ore ingredients
[10:07:36] [main/INFO]: Found 0 mods from the command line. Injecting into mod discoverer
[10:07:36] [main/INFO]: Searching C:\Users\T902\Programming\Java\Minecraft\1.12\run\mods for mods
[10:07:38] [Thread-3/INFO]: Using sync timing. 200 frames of Display.update took 562921265 nanos
[10:07:40] [main/INFO]: Forge Mod Loader has identified 7 mods to load
[10:07:41] [main/INFO]: Attempting connection with missing mods [minecraft, mcp, FML, forge, backslash, giantwizardry, guideapi] at CLIENT
[10:07:41] [main/INFO]: Attempting connection with missing mods [minecraft, mcp, FML, forge, backslash, giantwizardry, guideapi] at SERVER
[10:07:42] [main/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:BackSlash API, FMLFileResourcePack:Giant's Wizardry, FMLFileResourcePack:Guide-API
[10:07:42] [main/INFO]: Processing ObjectHolder annotations
[10:07:42] [main/INFO]: Found 1168 ObjectHolder annotations
[10:07:42] [main/INFO]: Identifying ItemStackHolder annotations
[10:07:42] [main/INFO]: Found 0 ItemStackHolder annotations
[10:07:43] [main/INFO]: Configured a dormant chunk cache size of 0
[10:07:43] [Forge Version Check/INFO]: [forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[10:07:43] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: -----Starting Block Registration-----
[10:07:43] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: -----Finished Block Registration-----
[10:07:43] [main/INFO]: Applying holder lookups
[10:07:43] [main/INFO]: Holder lookups applied
[10:07:43] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: -----Starting Item Registration-----
[10:07:43] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: Registered Item "giantwizardry:wand" into forge registry
[10:07:43] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: -----Finished Item Registration-----
[10:07:43] [main/INFO]: Applying holder lookups
[10:07:43] [main/INFO]: Holder lookups applied
[10:07:43] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: -----Starting Potion Effect Registration-----
[10:07:43] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: -----Finished Potion Effect Registration-----
[10:07:43] [main/INFO]: Applying holder lookups
[10:07:43] [main/INFO]: Holder lookups applied
[10:07:43] [main/INFO]: Applying holder lookups
[10:07:43] [main/INFO]: Holder lookups applied
[10:07:43] [main/INFO]: Injecting itemstacks
[10:07:43] [main/INFO]: Itemstack injection complete
[10:07:44] [Forge Version Check/INFO]: [forge] Found status: OUTDATED Target: 14.23.0.2512
[10:07:55] [Sound Library Loader/INFO]: Starting up SoundSystem...
[10:07:55] [Thread-5/INFO]: Initializing LWJGL OpenAL
[10:07:55] [Thread-5/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[10:07:55] [Thread-5/INFO]: OpenAL initialized.
[10:07:56] [Sound Library Loader/INFO]: Sound engine started
[10:08:09] [main/INFO]: Max texture size: 8192
[10:08:10] [main/INFO]: Created: 512x512 textures-atlas
[10:08:14] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: ------------Registered Custom Recipes(0)
[10:08:14] [main/INFO]: Applying holder lookups
[10:08:14] [main/INFO]: Holder lookups applied
[10:08:14] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: -----Seting Up Renderer for following Items-----
[10:08:14] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: Render Set up for item "giantwizardry:wand" whith meta 1 as "giantwizardry:wandlit"
[10:08:14] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: Render Set up for item "giantwizardry:wand" whith meta 0 as "giantwizardry:wand"
[10:08:14] [main/INFO]: [mods.giantnuker.backslash.Logger:logMsg:15]: [BackSlash API]: -----Finished Setting Up Renders-----
[10:08:14] [main/INFO]: Injecting itemstacks
[10:08:14] [main/INFO]: Itemstack injection complete
[10:08:14] [main/INFO]: Forge Mod Loader has successfully loaded 7 mods
[10:08:14] [main/WARN]: Skipping bad option: lastServer:
[10:08:15] [main/INFO]: Narrator library for x64 successfully loaded
[10:08:18] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id
[10:08:39] [main/INFO]: Deleting level New World
[10:08:39] [main/INFO]: Attempt 1...
[10:08:45] [Server thread/INFO]: Starting integrated minecraft server version 1.12.2
[10:08:45] [Server thread/INFO]: Generating keypair
[10:08:45] [Server thread/INFO]: Injecting existing registry data into this server instance
[10:08:45] [Server thread/INFO]: Applying holder lookups
[10:08:45] [Server thread/INFO]: Holder lookups applied
[10:08:46] [Server thread/INFO]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@1ad5e160)
[10:08:47] [Server thread/INFO]: Loaded 488 advancements
[10:08:48] [Server thread/INFO]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@1ad5e160)
[10:08:48] [Server thread/INFO]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@1ad5e160)
[10:08:48] [Server thread/INFO]: Preparing start region for level 0
[10:08:49] [Server thread/INFO]: Preparing spawn area: 4%
[10:08:50] [Server thread/INFO]: Preparing spawn area: 7%
[10:08:51] [Server thread/INFO]: Preparing spawn area: 9%
[10:08:52] [Server thread/INFO]: Preparing spawn area: 13%
[10:08:53] [Server thread/INFO]: Preparing spawn area: 15%
[10:08:54] [Server thread/INFO]: Preparing spawn area: 20%
[10:08:55] [Server thread/INFO]: Preparing spawn area: 27%
[10:08:56] [Server thread/INFO]: Preparing spawn area: 36%
[10:08:57] [Server thread/INFO]: Preparing spawn area: 46%
[10:08:58] [Server thread/INFO]: Preparing spawn area: 55%
[10:08:59] [Server thread/INFO]: Preparing spawn area: 62%
[10:09:00] [Server thread/INFO]: Preparing spawn area: 68%
[10:09:01] [Server thread/INFO]: Preparing spawn area: 79%
[10:09:02] [Server thread/INFO]: Preparing spawn area: 92%
[10:09:03] [Server thread/INFO]: Changing view distance to 2, from 10
[10:09:06] [Server thread/WARN]: Can't keep up! Did the system time change, or is the server overloaded? Running 2441ms behind, skipping 48 tick(s)
[10:09:12] [Netty Local Client IO #0/INFO]: Server protocol version 2
[10:09:12] [Netty Server IO #1/INFO]: Client protocol version 2
[10:09:12] [Netty Server IO #1/INFO]: Client attempting to join with 7 mods : minecraft@1.12.2,guideapi@1.12-2.1.4-57,FML@8.0.99.99,giantwizardry@1.0.0-1.12.2,forge@14.23.0.2494,mcp@9.42,backslash@1.12-3.1.0
[10:09:12] [Server thread/INFO]: [Server thread] Server side modded connection established
[10:09:13] [Netty Local Client IO #0/INFO]: [Netty Local Client IO #0] Client side modded connection established
[10:09:13] [Server thread/INFO]: Player327[local:E:5752a670] logged in with entity id 2175 at (-83.5, 68.0, 256.5)
[10:09:13] [Server thread/INFO]: Player327 joined the game
7
0.01
[10:09:15] [Server thread/INFO]: Saving and pausing game...
[10:09:15] [Server thread/INFO]: Saving chunks for level 'New World'/overworld
[10:09:17] [Server thread/INFO]: Saving chunks for level 'New World'/the_nether
[10:09:17] [Server thread/INFO]: Saving chunks for level 'New World'/the_end
[10:09:17] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@5166b06b[id=29308414-ff71-3cdd-a4fa-c0ef7b0196d4,name=Player327,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:79) ~[YggdrasilAuthenticationService.class:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:180) [YggdrasilMinecraftSessionService.class:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:60) [YggdrasilMinecraftSessionService$1.class:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:57) [YggdrasilMinecraftSessionService$1.class:?]
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3716) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2424) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2298) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2211) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache.get(LocalCache.java:4154) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4158) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5147) [guava-21.0.jar:?]
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:5153) [guava-21.0.jar:?]
	at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:170) [YggdrasilMinecraftSessionService.class:?]
	at net.minecraft.client.Minecraft.getProfileProperties(Minecraft.java:3007) [Minecraft.class:?]
	at net.minecraft.client.resources.SkinManager$3.run(SourceFile:110) [SkinManager$3.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_144]
	at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_144]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_144]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_144]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_144]
[10:10:59] [Server thread/INFO]: [mods.giantnuker.wizardry.spell.SpellRegistry:getForIncantation:42]: inc
[10:10:59] [Server thread/INFO]: [mods.giantnuker.wizardry.spell.SpellRegistry:getForIncantation:42]: protego
[10:10:59] [Server thread/INFO]: <Player327> Protego
[10:10:59] [main/INFO]: [CHAT] <Player327> Protego
[10:11:02] [Server thread/INFO]: Saving and pausing game...
[10:11:02] [Server thread/INFO]: Saving chunks for level 'New World'/overworld
[10:11:02] [Server thread/INFO]: [mods.giantnuker.wizardry.spell.entity.EntityShieldCharm:writeToNBT:66]: --------------------------------------------------------------Writing NBT-------------------------------------------
[10:11:02] [Server thread/INFO]: Saving chunks for level 'New World'/the_nether
[10:11:02] [Server thread/INFO]: Saving chunks for level 'New World'/the_end
[10:11:27] [Server thread/INFO]: [Player327: Teleported Player327 to -84.18883450480062, 71.07840000152588, 258.2905688524473]
[10:11:27] [main/INFO]: [CHAT] Teleported Player327 to -84.18883450480062, 71.07840000152588, 258.2905688524473
[10:11:41] [Server thread/INFO]: [mods.giantnuker.wizardry.spell.entity.EntityShieldCharm:writeToNBT:66]: --------------------------------------------------------------Writing NBT-------------------------------------------
[10:11:51] [Server thread/INFO]: Saving and pausing game...
[10:11:51] [Server thread/INFO]: Saving chunks for level 'New World'/overworld
[10:11:51] [Server thread/INFO]: [mods.giantnuker.wizardry.spell.entity.EntityShieldCharm:writeToNBT:66]: --------------------------------------------------------------Writing NBT-------------------------------------------
[10:11:51] [Server thread/INFO]: Saving chunks for level 'New World'/the_nether
[10:11:51] [Server thread/INFO]: Saving chunks for level 'New World'/the_end
[10:11:55] [Server thread/INFO]: Saving and pausing game...
[10:11:55] [Server thread/INFO]: Saving chunks for level 'New World'/overworld
[10:11:55] [Server thread/INFO]: [mods.giantnuker.wizardry.spell.entity.EntityShieldCharm:writeToNBT:66]: --------------------------------------------------------------Writing NBT-------------------------------------------
[10:11:55] [Server thread/INFO]: Saving chunks for level 'New World'/the_nether
[10:11:55] [Server thread/INFO]: Saving chunks for level 'New World'/the_end
[10:12:11] [Server thread/INFO]: [mods.giantnuker.wizardry.spell.SpellRegistry:getForIncantation:42]: inc
[10:12:11] [Server thread/INFO]: [mods.giantnuker.wizardry.spell.SpellRegistry:getForIncantation:42]: protego
[10:12:11] [Server thread/INFO]: <Player327> Protego
[10:12:12] [main/INFO]: [CHAT] <Player327> Protego
[10:12:18] [Server thread/INFO]: Saving and pausing game...
[10:12:19] [Server thread/INFO]: Saving chunks for level 'New World'/overworld
[10:12:19] [Server thread/INFO]: [mods.giantnuker.wizardry.spell.entity.EntityShieldCharm:writeToNBT:66]: --------------------------------------------------------------Writing NBT-------------------------------------------
[10:12:19] [Server thread/INFO]: [mods.giantnuker.wizardry.spell.entity.EntityShieldCharm:writeToNBT:66]: --------------------------------------------------------------Writing NBT-------------------------------------------
[10:12:19] [Server thread/INFO]: Saving chunks for level 'New World'/the_nether
[10:12:19] [Server thread/INFO]: Saving chunks for level 'New World'/the_end

The NBT is never read. Do you know how I can fix this?

 

 

Edit: But someting's not right - It's position is saved, That requires NBT reading...

Edited by GiantNuker
Link to comment
Share on other sites

17 minutes ago, gummby8 said:

NBT is writing and reading from the disk. You shouldn't be reading from NBT unless you are loading an entity that was not already loaded. Like when you log into a world for the first time, or move into an entity load range. Also Reading and Writing to NBT is a server side method. So if you are hoping to get it to pass something to the client that won't happen. You can probably use IEntityAdditionalSpawnData if that is still a thing...I am stuck in 1.8 for now.

Well, none of my server-to-client data is saved, and I do not get an nbt reading message on world load.

Link to comment
Share on other sites

2 minutes ago, gummby8 said:

How long does the entity last? You only save to NBT when the chunk unloads. Like when you move far away, or leave the world, of gracefully shutdown a server. If the entity is gone before the chunk unloads, it will never save, and thus never need to load. 

 

read and write to NBT is only to be used to preserver vital entity data when the chunk unloads from the ram. It saves all that data to disk so when the chunk is loaded again, when a player walks close enough, then the entity is brought back into existence. 

 

Cast your charm, them before the entity dies, save and quit out of the world. Reload your world and see if you get an NBT read.

 

Many times I see a crash report because I derped up my NBT read and write on projectiles. So just in the off chance the client is closed while a projectile entity existed, it would safely die or reload when the client was re-opened. 

It is immobile & does not die, I have not made a replacemet for entityThrowable yet, it only extends it because it was the first class that came to mind.

Edited by GiantNuker
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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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