Jump to content

[1.15.2] Quarry Tile Entity Not Saving Time Ticked When Leaving World


foonicular

Recommended Posts

The quarry tile entity I made is not saving the ticked time when you leave the world. I have an NBT helper class that contains read and write functions for my tile entity. I believe that it is because I am missing TileEntity#markDirty(), and if it is, do I put that in my tile entity class? Also, is there anything else that I am missing? Thanks in advance to those who help.

 

GitHub: http://github.com/foonicular/AMCMod

Edited by foonicular
Link to comment
Share on other sites

8 hours ago, foonicular said:

The quarry tile entity I made is not saving the ticked time when you leave the world. I have an NBT helper class that contains read and write functions for my tile entity. I believe that it is because I am missing TileEntity#markDirty(), and if it is, do I put that in my tile entity class? Also, is there anything else that I am missing? Thanks in advance to those who help.

 

GitHub: http://github.com/foonicular/AMCMod

@Override
	public void read(CompoundNBT compound) {
		super.read(compound);
		CompoundNBT initValues = compound.getCompound("initvalues");
		if(initValues != null) {
			this.x = initValues.getInt("x");
			this.y = initValues.getInt("y");
			this.z = initValues.getInt("z");
			this.tick = 0;
			initialized = true;
			return;
		}
		init();
	}

You are hard setting the tick field to 0 every time your tileEntity reads the saved NBT data

Link to comment
Share on other sites

11 minutes ago, foonicular said:

how would I store the time the ticks between logins?

the game doesn't really tick when the game isn't running

but you can call Instant.now().getEpochSecond() to get the current time as a long. you could get this value whenever it unloaded (you can override onChunkUnloaded for instance) and save it in a nbt for instance. then when it loaded back again you could get the current time as a long again and calculated the difference. Then you'd have the elapsed time in seconds.

 

(also: you're not being a jerk, don't worry)

Edited by kiou.23
Link to comment
Share on other sites

48 minutes ago, kiou.23 said:

the game doesn't really tick when the game isn't running

but you can call Instant.now().getEpochSecond() to get the current time as a long. you could get this value whenever it unloaded (you can override onChunkUnloaded for instance) and save it in a nbt for instance. then when it loaded back again you could get the current time as a long again and calculated the difference. Then you'd have the elapsed time in seconds.

Where should this go? Within the tile entity class? Also, how would I go about storing the value in an NBT, I have barely any knowledge on NBT currently

Edited by foonicular
Link to comment
Share on other sites

9 hours ago, foonicular said:

Where should this go? Within the tile entity class? Also, how would I go about storing the value in an NBT, I have barely any knowledge on NBT currently

I'm not 100% sure, as I'm also new to modding. but I think you can do this in the write and read methods. In the write method you can save the current time to the nbt.

and in the read method you can get the difference between the current time and the saved time

Link to comment
Share on other sites

So something along the lines of this would work? Create a variable that stores the seconds ticked, when the chunk is unloaded write the seconds ticked variable to it. Then when the chunk is loaded, multiply the seconds ticked variable by 20 (because it is in seconds) set ticks = to seconds ticked and change the 'if ticks = 60000' to 'if ticks >= 60000' to prevent it from breaking?

Link to comment
Share on other sites

2 hours ago, foonicular said:

So something along the lines of this would work? Create a variable that stores the seconds ticked, when the chunk is unloaded write the seconds ticked variable to it. Then when the chunk is loaded, multiply the seconds ticked variable by 20 (because it is in seconds) set ticks = to seconds ticked and change the 'if ticks = 60000' to 'if ticks >= 60000' to prevent it from breaking?

when the chunk is loaded, calculate the difference between the current time, and the time you stored, and then multiply it by 20.

but then I think you would want to divide by 60,000 to know how many times it should have executed?

 

It depends, do you want it to behave as if if it was executing while the game wasn't loaded? so it behaves in "real time"

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • The game crashed whilst unexpected error Error: java.lang.NullPointerException: Unexpected error ---- Minecraft Crash Report ---- WARNING: coremods are present:   llibrary (llibrary-core-1.0.11-1.12.2.jar)   TransformLoader (DynamicSurroundings-1.12.2-3.6.1.0.jar)   Inventory Tweaks Coremod (InventoryTweaks-1.63.jar)   XaeroWorldMapPlugin (XaerosWorldMap_1.29.2_Forge_1.12.jar)   OpenModsCorePlugin (OpenModsLib-1.12.2-0.12.2.jar)   LoadingPlugin (ResourceLoader-MC1.12.1-1.5.3.jar)   CTMCorePlugin (CTM-MC1.12.2-1.0.2.31.jar)   XaeroMinimapPlugin (Xaeros_Minimap_23.2.0_Forge_1.12.jar) Contact their authors BEFORE contacting forge // I feel sad now :( Time: 3/25/23 2:27 PM Description: Unexpected error java.lang.NullPointerException: Unexpected error     at xaero.map.core.XaeroWorldMapCore.onMinecraftRunTick(XaeroWorldMapCore.java:192)     at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1073)     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398)     at net.minecraft.client.main.Main.main(SourceFile:123)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:497)     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)     at net.minecraft.launchwrapper.Launch.main(Launch.java:28) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details:     Minecraft Version: 1.12.2     Operating System: Windows 10 (amd64) version 10.0     Java Version: 1.8.0_51, Oracle Corporation     Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation     Memory: 464818384 bytes (443 MB) / 1073741824 bytes (1024 MB) up to 8589934592 bytes (8192 MB)     JVM Flags: 8 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx8G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0     FML: MCP 9.42 Powered by Forge 14.23.5.2859 43 mods loaded, 43 mods active     States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored     | State | ID                 | Version                  | Source                                        | Signature                                |     |:----- |:------------------ |:------------------------ |:--------------------------------------------- |:---------------------------------------- |     | L     | minecraft          | 1.12.2                   | minecraft.jar                                 | None                                     |     | L     | mcp                | 9.42                     | minecraft.jar                                 | None                                     |     | L     | FML                | 8.0.99.99                | forge-1.12.2-14.23.5.2859.jar                 | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | L     | forge              | 14.23.5.2859             | forge-1.12.2-14.23.5.2859.jar                 | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | L     | xaerominimap_core  | 1.12.2-1.0               | minecraft.jar                                 | None                                     |     | L     | xaeroworldmap_core | 1.12.2-1.0               | minecraft.jar                                 | None                                     |     | L     | openmodscore       | 0.12.2                   | minecraft.jar                                 | None                                     |     | L     | ambientenvironment | 1.0.1                    | AmbientEnvironment-1.0.2.jar                  | None                                     |     | L     | appleskin          | 1.0.14                   | AppleSkin-mc1.12-1.0.14.jar                   | None                                     |     | L     | biomesoplenty      | 7.0.1.2445               | BiomesOPlenty-1.12.2-7.0.1.2445-universal.jar | None                                     |     | L     | chameleon          | 1.12-4.1.3               | Chameleon-1.12-4.1.3.jar                      | None                                     |     | L     | clumps             | 3.1.2                    | Clumps-3.1.2.jar                              | None                                     |     | L     | collective         | 3.0                      | collective-1.12.2-3.0.jar                     | None                                     |     | L     | ctm                | MC1.12.2-1.0.2.31        | CTM-MC1.12.2-1.0.2.31.jar                     | None                                     |     | L     | customspawner      | 3.11.4                   | CustomMobSpawner-3.11.5.jar                   | None                                     |     | L     | mocreatures        | 12.0.5                   | DrZharks MoCreatures Mod-12.0.5.jar           | None                                     |     | L     | dsurround          | 3.6.1.0                  | DynamicSurroundings-1.12.2-3.6.1.0.jar        | None                                     |     | L     | fastleafdecay      | v14                      | FastLeafDecay-v14.jar                         | None                                     |     | L     | fastbench          | 1.7.4                    | FastWorkbench-1.12.2-1.7.4.jar                | None                                     |     | L     | fossil             | 8.0.5                    | fossilsarcheology-8.0.6.jar                   | None                                     |     | L     | cfm                | 6.3.0                    | furniture-6.3.2-1.12.2.jar                    | None                                     |     | L     | hats               | 7.1.1                    | Hats-1.12.2-7.1.1.jar                         | None                                     |     | L     | waila              | 1.8.26                   | Hwyla-1.8.26-B41_1.12.2.jar                   | None                                     |     | L     | ichunutil          | 7.2.2                    | iChunUtil-1.12.2-7.2.2.jar                    | None                                     |     | L     | inventorypets      | 2.0.15                   | inventorypets-1.12-2.0.15.jar                 | None                                     |     | L     | inventorytweaks    | 1.63+release.109.220f184 | InventoryTweaks-1.63.jar                      | None                                     |     | L     | jei                | 4.16.1.1001              | jei_1.12.2-4.16.1.1001.jar                    | None                                     |     | L     | mantle             | 1.12-1.3.3.55            | Mantle-1.12-1.3.3.55.jar                      | None                                     |     | L     | mca                | 6.1.0                    | MCA-1.12.2-6.1.0-universal.jar                | None                                     |     | L     | openblocks         | 1.8.1                    | OpenBlocks-1.12.2-1.8.1.jar                   | None                                     |     | L     | openmods           | 0.12.2                   | OpenModsLib-1.12.2-0.12.2.jar                 | None                                     |     | L     | harvestcraft       | 1.12.2zb                 | Pam's+HarvestCraft+1.12.2zg.jar               | None                                     |     | L     | simplerecipes      | 1.12.2c                  | Pam's+Simple+Recipes+1.12.2c.jar              | None                                     |     | L     | reskin             | 1.2.0                    | reskin-1.2.0.jar                              | None                                     |     | L     | resourceloader     | 1.5.3                    | ResourceLoader-MC1.12.1-1.5.3.jar             | None                                     |     | L     | simpleminingdrills | 1.4.0                    | simpleminingdrills+1.12.2.jar                 | None                                     |     | L     | tconstruct         | 1.12.2-2.13.0.183        | TConstruct-1.12.2-2.13.0.183.jar              | None                                     |     | L     | tinkersjei         | 1.2                      | tinkersjei-1.2.jar                            | None                                     |     | L     | travelersbackpack  | 1.0.35                   | TravelersBackpack-1.12.2-1.0.35.jar           | None                                     |     | L     | twilightforest     | 3.11.1021                | twilightforest-1.12.2-3.11.1021-universal.jar | None                                     |     | L     | xaerominimap       | 23.2.0                   | Xaeros_Minimap_23.2.0_Forge_1.12.jar          | None                                     |     | L     | xaeroworldmap      | 1.29.2                   | XaerosWorldMap_1.29.2_Forge_1.12.jar          | None                                     |     | L     | llibrary           | 1.7.20                   | llibrary-1.7.20-1.12.2.jar                    | None                                     |     Loaded coremods (and transformers):  llibrary (llibrary-core-1.0.11-1.12.2.jar)   net.ilexiconn.llibrary.server.core.plugin.LLibraryTransformer   net.ilexiconn.llibrary.server.core.patcher.LLibraryRuntimePatcher TransformLoader (DynamicSurroundings-1.12.2-3.6.1.0.jar)    Inventory Tweaks Coremod (InventoryTweaks-1.63.jar)   invtweaks.forge.asm.ContainerTransformer XaeroWorldMapPlugin (XaerosWorldMap_1.29.2_Forge_1.12.jar)   xaero.map.core.transformer.ChunkTransformer   xaero.map.core.transformer.NetHandlerPlayClientTransformer   xaero.map.core.transformer.EntityPlayerTransformer   xaero.map.core.transformer.AbstractClientPlayerTransformer   xaero.map.core.transformer.WorldClientTransformer   xaero.map.core.transformer.PlayerListTransformer   xaero.map.core.transformer.SaveFormatTransformer   xaero.map.core.transformer.BiomeColorHelperTransformer   xaero.map.core.transformer.MinecraftTransformer OpenModsCorePlugin (OpenModsLib-1.12.2-0.12.2.jar)   openmods.core.OpenModsClassTransformer LoadingPlugin (ResourceLoader-MC1.12.1-1.5.3.jar)   lumien.resourceloader.asm.ClassTransformer CTMCorePlugin (CTM-MC1.12.2-1.0.2.31.jar)   team.chisel.ctm.client.asm.CTMTransformer XaeroMinimapPlugin (Xaeros_Minimap_23.2.0_Forge_1.12.jar)   xaero.common.core.transformer.ChunkTransformer   xaero.common.core.transformer.NetHandlerPlayClientTransformer   xaero.common.core.transformer.EntityPlayerTransformer   xaero.common.core.transformer.AbstractClientPlayerTransformer   xaero.common.core.transformer.WorldClientTransformer   xaero.common.core.transformer.EntityPlayerSPTransformer   xaero.common.core.transformer.PlayerListTransformer   xaero.common.core.transformer.SaveFormatTransformer   xaero.common.core.transformer.GuiIngameForgeTransformer   xaero.common.core.transformer.GuiBossOverlayTransformer   xaero.common.core.transformer.ModelRendererTransformer     GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.6.0 Compatibility Profile Context 23.3.2.230315' Renderer: 'Radeon RX 560 Series'     Launched Version: 1.12.2-forge-14.23.5.2859     LWJGL: 2.9.4     OpenGL: Radeon RX 560 Series GL version 4.6.0 Compatibility Profile Context 23.3.2.230315, ATI Technologies Inc.     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: 12x Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz Idk what to do pls help
    • Hi I’m running same mod on a server and realized they are spawning in chests which I don’t want, if I were to edit this data pack to disable them spawning in chests how would I do that? Explain to me like I’m 8
    • every time i use play forge in the launcher it says game crashed unexpected issuse and when i use curseforge it also doesn't work
    • I've attempted to use Jarfix as well. I tried running a previous version (18.2) of Minecraft and added a few random popular mods and the crashing is persistent among the servers. 
  • Topics

×
×
  • Create New...

Important Information

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