Jump to content

Recommended Posts

Posted (edited)

I have a tile entity that, for now, stores a set of coordinates which are set in a GUI. The coordinates are stored in an int array called coords, but the value of this array is inconsistent throughout the code.

To be honest, I'm not entirely sure what's causing this problem. I set up debug statements throughout to attempt to triangulate the cause, but I honestly have no idea. I'm new to this, so it's entirely possible that it's something dumb that I'm missing, but I've spent six hours or so trying to figure it out to no avail.

Here's my code (TeleporterTE.java):

package name.kolbly.testmod.blocks;

import javax.annotation.Nullable;

import name.kolbly.testmod.TestMod;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class TeleporterTE extends TileEntity {
	
	private int[] coords;
	
	public void onLoad() {
		if (this.coords == null) {
			this.setCoords(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
			TestMod.logger.info("Resetting coords to tile entity coordinates, value: {}", this.coords);
		}
	}

	@Override
	public NBTTagCompound writeToNBT(NBTTagCompound compound) {
		super.writeToNBT(compound);
		TestMod.logger.info("Before writing to NBT, value: {}", this.coords);
		compound.setIntArray("coords", this.coords);
		TestMod.logger.info("Wrote to NBT, value: {}", this.coords);
		return compound;
	}
	
	@Override
	public void readFromNBT(NBTTagCompound compound) {
		super.readFromNBT(compound);
		
		int[] tmp_coords = compound.getIntArray("coords");
		
		TestMod.logger.info("Before reading from NBT, value: {}", this.coords);
		
		TestMod.logger.info("Read temporary from NBT, value: {}", tmp_coords);
		
		if (tmp_coords.length == 3) {
			this.coords = tmp_coords;
			TestMod.logger.info("Temporary meets requirements for replacing coords.");
		}
		
		TestMod.logger.info("Read from NBT, value: {}", this.coords);
	}
	
	public void setCoords(int x, int y, int z) {
		this.coords = new int[] {x, y, z};
		markDirty();
		TestMod.logger.info("Changed tile entity data, value: {}", this.coords);
	}
	
	public int getX() {
		return this.coords[0];
	}
	
	public int getY() {
		return this.coords[1];
	}
	
	public int getZ() {
		return this.coords[2];
	}
	
	public int[] getCoords() {
		return this.coords;
	}
}

 

When I run this mod, my debug statements print the following:

[19:10:15] [Server thread/INFO] [testmod]: Before reading from NBT, value: null
[19:10:15] [Server thread/INFO] [testmod]: Read temporary from NBT, value: [569, 80, -230]
[19:10:15] [Server thread/INFO] [testmod]: Temporary meets requirements for replacing coords.
[19:10:15] [Server thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:10:15] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:10:15] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]
[19:10:15] [Client thread/INFO] [testmod]: Changed tile entity data, value: [569, 80, -230]
[19:10:15] [Client thread/INFO] [testmod]: Resetting coords to tile entity coordinates, value: [569, 80, -230]
[19:10:15] [Client thread/INFO] [testmod]: Before reading from NBT, value: [569, 80, -230]
[19:10:15] [Client thread/INFO] [testmod]: Read temporary from NBT, value: []
[19:10:15] [Client thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:10:16] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:10:16] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]
[19:11:14] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:11:14] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]

 

Then I close the world and reopen it:

[19:11:34] [Server thread/INFO] [testmod]: Before reading from NBT, value: null
[19:11:34] [Server thread/INFO] [testmod]: Read temporary from NBT, value: [569, 80, -230]
[19:11:34] [Server thread/INFO] [testmod]: Temporary meets requirements for replacing coords.
[19:11:34] [Server thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:11:34] [Client thread/INFO] [testmod]: Changed tile entity data, value: [569, 80, -230]
[19:11:34] [Client thread/INFO] [testmod]: Resetting coords to tile entity coordinates, value: [569, 80, -230]
[19:11:34] [Client thread/INFO] [testmod]: Before reading from NBT, value: [569, 80, -230]
[19:11:34] [Client thread/INFO] [testmod]: Read temporary from NBT, value: []
[19:11:34] [Client thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:11:38] [Client thread/INFO] [testmod]: Changed tile entity data, value: [569, 90, -230]
[19:11:38] [Client thread/INFO] [testmod]: In TeleporterGUI, y-value: 90
[19:11:39] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:11:39] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]

 

Once again, I close and reopen the world:

[19:11:47] [Server thread/INFO] [testmod]: Before reading from NBT, value: null
[19:11:47] [Server thread/INFO] [testmod]: Read temporary from NBT, value: [569, 80, -230]
[19:11:47] [Server thread/INFO] [testmod]: Temporary meets requirements for replacing coords.
[19:11:47] [Server thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:11:47] [Client thread/INFO] [testmod]: Changed tile entity data, value: [569, 80, -230]
[19:11:47] [Client thread/INFO] [testmod]: Resetting coords to tile entity coordinates, value: [569, 80, -230]
[19:11:47] [Client thread/INFO] [testmod]: Before reading from NBT, value: [569, 80, -230]
[19:11:47] [Client thread/INFO] [testmod]: Read temporary from NBT, value: []
[19:11:47] [Client thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:11:47] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:11:47] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]
[19:11:55] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:11:55] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]

 

This confuses me for a multitude of reasons.

  1. It looks like tmp_coords is sometimes null because it's being called on both the client and the server. If that's true, is there a better way to fix it than my workaround of making sure it was an array of the right length?

  2. The second time I was in the world, I tried editing the coords and it worked (the second number, the y-value, went up to 90 at 19:11:38 and was still at 90 when queried from the TeleporterGUI class at 19:11:38), but then when in writeToNBT, the coords were reset back to what they were before. What caused them to reset? I only ever edit the value in TeleporterGUI and TeleporterTE.

 

If needed, here is the full, unedited thread:

[19:09:48] [main/INFO] [GradleStart]: Extra: []
[19:09:48] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/jason/.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]
[19:09:48] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[19:09:48] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[19:09:48] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[19:09:48] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[19:09:48] [main/INFO] [FML]: Forge Mod Loader version 14.23.5.2847 for Minecraft 1.12.2 loading
[19:09:48] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_251, running on Windows 10:amd64:10.0, installed at C:\Program Files\Java\jre1.8.0_251
[19:09:48] [main/ERROR] [FML]: Apache Maven library folder was not in the format expected. Using default libraries directory.
[19:09:48] [main/ERROR] [FML]: Full: C:\Users\jason\.gradle\caches\modules-2\files-2.1\org.apache.maven\maven-artifact\3.5.3\7dc72b6d6d8a6dced3d294ed54c2cc3515ade9f4\maven-artifact-3.5.3.jar
[19:09:48] [main/ERROR] [FML]: Trimmed: c:/users/jason/.gradle/caches/modules-2/files-2.1/org.apache.maven/maven-artifact/3.5.3/
[19:09:48] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[19:09:48] [main/INFO] [FML]: Detected deobfuscated environment, loading log configs for colored console logs.
2020-04-16 19:09:49,838 main WARN Disabling terminal, you're running in an unsupported environment.
[19:09:49] [main/INFO] [FML]: Ignoring missing certificate for coremod FMLCorePlugin (net.minecraftforge.fml.relauncher.FMLCorePlugin), we are in deobf and it's a forge core plugin
[19:09:49] [main/INFO] [FML]: Ignoring missing certificate for coremod FMLForgePlugin (net.minecraftforge.classloading.FMLForgePlugin), we are in deobf and it's a forge core plugin
[19:09:49] [main/INFO] [FML]: Searching C:\Users\jason\Documents\MinecraftModding\FirstMod\run\.\mods for mods
[19:09:49] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
[19:09:49] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
[19:09:49] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
[19:09:49] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[19:09:49] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[19:09:49] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[19:09:49] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[19:09:49] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[19:09:49] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[19:09:51] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[19:09:51] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[19:09:51] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[19:09:51] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[19:09:51] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[19:09:51] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[19:09:51] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[19:09:52] [Client thread/INFO] [minecraft/Minecraft]: Setting user: Player859
[19:09:54] [Client thread/WARN] [minecraft/GameSettings]: Skipping bad option: lastServer:
[19:09:54] [Client thread/INFO] [minecraft/Minecraft]: LWJGL Version: 2.9.4
[19:09:55] [Client thread/INFO] [FML]: -- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_251, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 849744856 bytes (810 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 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: '4.6.0 - Build 26.20.100.7926' Renderer: 'Intel(R) UHD Graphics 620'
[19:09:55] [Client thread/INFO] [FML]: MinecraftForge v14.23.5.2847 Initialized
[19:09:55] [Client thread/INFO] [FML]: Starts to replace vanilla recipe ingredients with ore ingredients.
[19:09:55] [Client thread/INFO] [FML]: Invalid recipe found with multiple oredict ingredients in the same ingredient...
[19:09:55] [Client thread/INFO] [FML]: Replaced 1227 ore ingredients
[19:09:56] [Client thread/INFO] [FML]: Searching C:\Users\jason\Documents\MinecraftModding\FirstMod\run\.\mods for mods
[19:09:57] [Client thread/INFO] [FML]: Forge Mod Loader has identified 5 mods to load
[19:09:57] [Client thread/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, testmod] at CLIENT
[19:09:57] [Client thread/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, testmod] at SERVER
[19:09:57] [Thread-3/INFO] [FML]: Using sync timing. 200 frames of Display.update took 79618800 nanos
[19:09:57] [Client thread/INFO] [minecraft/SimpleReloadableResourceManager]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Jason's First Mod (For Testing)
[19:09:58] [Client thread/INFO] [FML]: Processing ObjectHolder annotations
[19:09:58] [Client thread/INFO] [FML]: Found 1172 ObjectHolder annotations
[19:09:58] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations
[19:09:58] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations
[19:09:58] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0
[19:09:58] [Forge Version Check/INFO] [forge.VersionCheck]: [forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[19:09:58] [Client thread/INFO] [FML]: Applying holder lookups
[19:09:58] [Client thread/INFO] [FML]: Holder lookups applied
[19:09:58] [Client thread/INFO] [FML]: Applying holder lookups
[19:09:58] [Client thread/INFO] [FML]: Holder lookups applied
[19:09:58] [Client thread/INFO] [FML]: Applying holder lookups
[19:09:58] [Client thread/INFO] [FML]: Holder lookups applied
[19:09:58] [Client thread/INFO] [FML]: Applying holder lookups
[19:09:58] [Client thread/INFO] [FML]: Holder lookups applied
[19:09:58] [Client thread/INFO] [FML]: Injecting itemstacks
[19:09:58] [Client thread/INFO] [FML]: Itemstack injection complete
[19:09:58] [Forge Version Check/INFO] [forge.VersionCheck]: [forge] Found status: AHEAD Target: null
[19:10:00] [Sound Library Loader/INFO] [minecraft/SoundManager]: Starting up SoundSystem...
[19:10:01] [Thread-5/INFO] [minecraft/SoundManager]: Initializing LWJGL OpenAL
[19:10:01] [Thread-5/INFO] [minecraft/SoundManager]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[19:10:01] [Thread-5/INFO] [minecraft/SoundManager]: OpenAL initialized.
[19:10:01] [Sound Library Loader/INFO] [minecraft/SoundManager]: Sound engine started
[19:10:06] [Client thread/INFO] [FML]: Max texture size: 8192
[19:10:06] [Client thread/INFO] [minecraft/TextureMap]: Created: 512x512 textures-atlas
[19:10:08] [Client thread/INFO] [FML]: Applying holder lookups
[19:10:08] [Client thread/INFO] [FML]: Holder lookups applied
[19:10:08] [Client thread/INFO] [FML]: Injecting itemstacks
[19:10:08] [Client thread/INFO] [FML]: Itemstack injection complete
[19:10:08] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 5 mods
[19:10:08] [Client thread/WARN] [minecraft/GameSettings]: Skipping bad option: lastServer:
[19:10:08] [Client thread/INFO] [mojang/NarratorWindows]: Narrator library for x64 successfully loaded
[19:10:09] [Realms Notification Availability checker #1/INFO] [mojang/RealmsClient]: Could not authorize you against Realms server: Invalid session id
[19:10:10] [Server thread/INFO] [minecraft/IntegratedServer]: Starting integrated minecraft server version 1.12.2
[19:10:10] [Server thread/INFO] [minecraft/IntegratedServer]: Generating keypair
[19:10:10] [Server thread/INFO] [FML]: Injecting existing registry data into this server instance
[19:10:11] [Server thread/INFO] [FML]: Applying holder lookups
[19:10:11] [Server thread/INFO] [FML]: Holder lookups applied
[19:10:11] [Server thread/INFO] [FML]: Loading dimension 0 (Test) (net.minecraft.server.integrated.IntegratedServer@68b15d61)
[19:10:11] [Server thread/INFO] [minecraft/AdvancementList]: Loaded 488 advancements
[19:10:11] [Server thread/INFO] [FML]: Loading dimension -1 (Test) (net.minecraft.server.integrated.IntegratedServer@68b15d61)
[19:10:11] [Server thread/INFO] [FML]: Loading dimension 1 (Test) (net.minecraft.server.integrated.IntegratedServer@68b15d61)
[19:10:11] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing start region for level 0
[19:10:12] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing spawn area: 60%
[19:10:13] [Server thread/INFO] [FML]: Unloading dimension -1
[19:10:13] [Server thread/INFO] [FML]: Unloading dimension 1
[19:10:13] [Server thread/INFO] [minecraft/IntegratedServer]: Changing view distance to 7, from 10
[19:10:14] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 2
[19:10:14] [Netty Server IO #1/INFO] [FML]: Client protocol version 2
[19:10:14] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 5 mods : [email protected],[email protected],[email protected],[email protected],[email protected]
[19:10:14] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established
[19:10:14] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established
[19:10:15] [Server thread/INFO] [minecraft/PlayerList]: Player859[local:E:40be9790] logged in with entity id 161 at (569.986475673182, 81.11650136792812, -232.3122268726715)
[19:10:15] [Server thread/INFO] [minecraft/MinecraftServer]: Player859 joined the game
[19:10:15] [Server thread/INFO] [testmod]: Before reading from NBT, value: null
[19:10:15] [Server thread/INFO] [testmod]: Read temporary from NBT, value: [569, 80, -230]
[19:10:15] [Server thread/INFO] [testmod]: Temporary meets requirements for replacing coords.
[19:10:15] [Server thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:10:15] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game...
[19:10:15] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test'/overworld
[19:10:15] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:10:15] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]
[19:10:15] [pool-2-thread-1/WARN] [mojang/YggdrasilMinecraftSessionService]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@4881e7f6[id=bd11acc2-8e1a-348b-89a6-a309159aa437,name=Player859,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:3182) [Minecraft.class:?]
	at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:138) [SkinManager$3.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_251]
	at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_251]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_251]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_251]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]
[19:10:15] [Client thread/INFO] [testmod]: Changed tile entity data, value: [569, 80, -230]
[19:10:15] [Client thread/INFO] [testmod]: Resetting coords to tile entity coordinates, value: [569, 80, -230]
[19:10:15] [Client thread/INFO] [testmod]: Before reading from NBT, value: [569, 80, -230]
[19:10:15] [Client thread/INFO] [testmod]: Read temporary from NBT, value: []
[19:10:15] [Client thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:10:15] [Client thread/INFO] [minecraft/AdvancementList]: Loaded 6 advancements
[19:10:16] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game...
[19:10:16] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test'/overworld
[19:10:16] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:10:16] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]
[19:11:14] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game...
[19:11:14] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test'/overworld
[19:11:14] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:11:14] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]
[19:11:31] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server
[19:11:31] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players
[19:11:31] [Server thread/INFO] [minecraft/NetHandlerPlayServer]: Player859 lost connection: Disconnected
[19:11:31] [Server thread/INFO] [minecraft/MinecraftServer]: Player859 left the game
[19:11:31] [Server thread/INFO] [minecraft/NetHandlerPlayServer]: Stopping singleplayer server as player logged out
[19:11:31] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds
[19:11:31] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test'/overworld
[19:11:31] [Server thread/INFO] [FML]: Unloading dimension 0
[19:11:31] [Server thread/INFO] [FML]: Applying holder lookups
[19:11:31] [Server thread/INFO] [FML]: Holder lookups applied
[19:11:32] [Server thread/INFO] [minecraft/IntegratedServer]: Starting integrated minecraft server version 1.12.2
[19:11:32] [Server thread/INFO] [minecraft/IntegratedServer]: Generating keypair
[19:11:32] [Server thread/INFO] [FML]: Injecting existing registry data into this server instance
[19:11:33] [Server thread/INFO] [FML]: Applying holder lookups
[19:11:33] [Server thread/INFO] [FML]: Holder lookups applied
[19:11:33] [Server thread/INFO] [FML]: Loading dimension 0 (Test) (net.minecraft.server.integrated.IntegratedServer@7c272192)
[19:11:33] [Server thread/INFO] [minecraft/AdvancementList]: Loaded 488 advancements
[19:11:33] [Server thread/INFO] [FML]: Loading dimension -1 (Test) (net.minecraft.server.integrated.IntegratedServer@7c272192)
[19:11:33] [Server thread/INFO] [FML]: Loading dimension 1 (Test) (net.minecraft.server.integrated.IntegratedServer@7c272192)
[19:11:33] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing start region for level 0
[19:11:34] [Server thread/INFO] [FML]: Unloading dimension -1
[19:11:34] [Server thread/INFO] [FML]: Unloading dimension 1
[19:11:34] [Server thread/INFO] [minecraft/IntegratedServer]: Changing view distance to 7, from 10
[19:11:34] [Netty Local Client IO #1/INFO] [FML]: Server protocol version 2
[19:11:34] [Netty Server IO #3/INFO] [FML]: Client protocol version 2
[19:11:34] [Netty Server IO #3/INFO] [FML]: Client attempting to join with 5 mods : [email protected],[email protected],[email protected],[email protected],[email protected]
[19:11:34] [Netty Local Client IO #1/INFO] [FML]: [Netty Local Client IO #1] Client side modded connection established
[19:11:34] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established
[19:11:34] [Server thread/INFO] [minecraft/PlayerList]: Player859[local:E:14857183] logged in with entity id 553 at (570.8044004143898, 81.11650136792812, -232.62607233048033)
[19:11:34] [Server thread/INFO] [minecraft/MinecraftServer]: Player859 joined the game
[19:11:34] [Server thread/INFO] [testmod]: Before reading from NBT, value: null
[19:11:34] [Server thread/INFO] [testmod]: Read temporary from NBT, value: [569, 80, -230]
[19:11:34] [Server thread/INFO] [testmod]: Temporary meets requirements for replacing coords.
[19:11:34] [Server thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:11:34] [Client thread/INFO] [minecraft/AdvancementList]: Loaded 6 advancements
[19:11:34] [Client thread/INFO] [testmod]: Changed tile entity data, value: [569, 80, -230]
[19:11:34] [Client thread/INFO] [testmod]: Resetting coords to tile entity coordinates, value: [569, 80, -230]
[19:11:34] [Client thread/INFO] [testmod]: Before reading from NBT, value: [569, 80, -230]
[19:11:34] [Client thread/INFO] [testmod]: Read temporary from NBT, value: []
[19:11:34] [Client thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:11:38] [Client thread/INFO] [testmod]: Changed tile entity data, value: [569, 90, -230]
[19:11:38] [Client thread/INFO] [testmod]: In TeleporterGUI, y-value: 90
[19:11:39] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game...
[19:11:39] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test'/overworld
[19:11:39] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:11:39] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]
[19:11:40] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server
[19:11:40] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players
[19:11:40] [Server thread/INFO] [minecraft/NetHandlerPlayServer]: Player859 lost connection: Disconnected
[19:11:40] [Server thread/INFO] [minecraft/MinecraftServer]: Player859 left the game
[19:11:40] [Server thread/INFO] [minecraft/NetHandlerPlayServer]: Stopping singleplayer server as player logged out
[19:11:40] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds
[19:11:40] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test'/overworld
[19:11:40] [Server thread/INFO] [FML]: Unloading dimension 0
[19:11:40] [Server thread/INFO] [FML]: Applying holder lookups
[19:11:40] [Server thread/INFO] [FML]: Holder lookups applied
[19:11:45] [Server thread/INFO] [minecraft/IntegratedServer]: Starting integrated minecraft server version 1.12.2
[19:11:45] [Server thread/INFO] [minecraft/IntegratedServer]: Generating keypair
[19:11:45] [Server thread/INFO] [FML]: Injecting existing registry data into this server instance
[19:11:46] [Server thread/INFO] [FML]: Applying holder lookups
[19:11:46] [Server thread/INFO] [FML]: Holder lookups applied
[19:11:46] [Server thread/INFO] [FML]: Loading dimension 0 (Test) (net.minecraft.server.integrated.IntegratedServer@759e47e1)
[19:11:46] [Server thread/INFO] [minecraft/AdvancementList]: Loaded 488 advancements
[19:11:46] [Server thread/INFO] [FML]: Loading dimension -1 (Test) (net.minecraft.server.integrated.IntegratedServer@759e47e1)
[19:11:46] [Server thread/INFO] [FML]: Loading dimension 1 (Test) (net.minecraft.server.integrated.IntegratedServer@759e47e1)
[19:11:46] [Server thread/INFO] [minecraft/MinecraftServer]: Preparing start region for level 0
[19:11:46] [Server thread/INFO] [FML]: Unloading dimension -1
[19:11:46] [Server thread/INFO] [FML]: Unloading dimension 1
[19:11:47] [Server thread/INFO] [minecraft/IntegratedServer]: Changing view distance to 7, from 10
[19:11:47] [Netty Local Client IO #2/INFO] [FML]: Server protocol version 2
[19:11:47] [Netty Server IO #5/INFO] [FML]: Client protocol version 2
[19:11:47] [Netty Server IO #5/INFO] [FML]: Client attempting to join with 5 mods : [email protected],[email protected],[email protected],[email protected],[email protected]
[19:11:47] [Netty Local Client IO #2/INFO] [FML]: [Netty Local Client IO #2] Client side modded connection established
[19:11:47] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established
[19:11:47] [Server thread/INFO] [minecraft/PlayerList]: Player859[local:E:3184ed8f] logged in with entity id 947 at (570.8044004143898, 81.11650136792812, -232.62607233048033)
[19:11:47] [Server thread/INFO] [minecraft/MinecraftServer]: Player859 joined the game
[19:11:47] [Server thread/INFO] [testmod]: Before reading from NBT, value: null
[19:11:47] [Server thread/INFO] [testmod]: Read temporary from NBT, value: [569, 80, -230]
[19:11:47] [Server thread/INFO] [testmod]: Temporary meets requirements for replacing coords.
[19:11:47] [Server thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:11:47] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game...
[19:11:47] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test'/overworld
[19:11:47] [Client thread/INFO] [testmod]: Changed tile entity data, value: [569, 80, -230]
[19:11:47] [Client thread/INFO] [testmod]: Resetting coords to tile entity coordinates, value: [569, 80, -230]
[19:11:47] [Client thread/INFO] [testmod]: Before reading from NBT, value: [569, 80, -230]
[19:11:47] [Client thread/INFO] [testmod]: Read temporary from NBT, value: []
[19:11:47] [Client thread/INFO] [testmod]: Read from NBT, value: [569, 80, -230]
[19:11:47] [Client thread/INFO] [minecraft/AdvancementList]: Loaded 6 advancements
[19:11:47] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:11:47] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]
[19:11:55] [Server thread/INFO] [minecraft/IntegratedServer]: Saving and pausing game...
[19:11:55] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test'/overworld
[19:11:55] [Server thread/INFO] [testmod]: Before writing to NBT, value: [569, 80, -230]
[19:11:55] [Server thread/INFO] [testmod]: Wrote to NBT, value: [569, 80, -230]
[19:11:57] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server
[19:11:57] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players
[19:11:57] [Server thread/INFO] [minecraft/NetHandlerPlayServer]: Player859 lost connection: Disconnected
[19:11:57] [Server thread/INFO] [minecraft/MinecraftServer]: Player859 left the game
[19:11:57] [Server thread/INFO] [minecraft/NetHandlerPlayServer]: Stopping singleplayer server as player logged out
[19:11:57] [Server thread/INFO] [minecraft/MinecraftServer]: Saving worlds
[19:11:57] [Server thread/INFO] [minecraft/MinecraftServer]: Saving chunks for level 'Test'/overworld
[19:11:57] [Server thread/INFO] [FML]: Unloading dimension 0
[19:11:57] [Server thread/INFO] [FML]: Applying holder lookups
[19:11:57] [Server thread/INFO] [FML]: Holder lookups applied
[19:11:57] [Client thread/INFO] [minecraft/Minecraft]: Stopping!
[19:11:57] [Client thread/INFO] [minecraft/SoundManager]: SoundSystem shutting down...
[19:11:58] [Client thread/WARN] [minecraft/SoundManager]: Author: Paul Lamb, www.paulscode.com
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

 

And here is TeleporterGUI.java:

package name.kolbly.testmod.guis;

import java.io.IOException;

import name.kolbly.testmod.TestMod;
import name.kolbly.testmod.blocks.TeleporterTE;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;

public class TeleporterGUI extends GuiScreen {
	public static int ID = 0;

	private GuiButton plusX;
	private GuiButton minusX;
	private GuiButton plusY;
	private GuiButton minusY;
	private GuiButton plusZ;
	private GuiButton minusZ;
	
	private GuiTextField xField;
	private GuiTextField yField;
	private GuiTextField zField;
	
	private GuiButton done;
	private GuiButton cancel;
	
	private final TeleporterTE teleporter;
	
	private int x;
	private int y;
	private int z;
	
	public TeleporterGUI(TeleporterTE teleporterTE) {
		this.teleporter = teleporterTE;
	}

	public void initGui() {
		
		this.buttonList.clear();
		
		this.plusX = this.addButton(new GuiButton(0, this.width / 2 - 35, this.height / 2 - 35, 20, 20, "+"));
		this.xField = new GuiTextField(1, this.fontRenderer, this.width / 2 - 35, this.height / 2 - 10, 20, 20);
		this.minusX = this.addButton(new GuiButton(2, this.width / 2 - 35, this.height / 2 + 15, 20, 20, "-"));
		
		this.plusY = this.addButton(new GuiButton(3, this.width / 2 - 10, this.height / 2 - 35, 20, 20, "+"));
		this.yField = new GuiTextField(4, this.fontRenderer, this.width / 2 - 10, this.height / 2 - 10, 20, 20);
		this.minusY = this.addButton(new GuiButton(5, this.width / 2 - 10, this.height / 2 + 15, 20, 20, "-"));
		
		this.plusZ = this.addButton(new GuiButton(6, this.width / 2 + 15, this.height / 2 - 35, 20, 20, "+"));
		this.zField = new GuiTextField(7, this.fontRenderer, this.width / 2 + 15, this.height / 2 - 10, 20, 20);
		this.minusZ = this.addButton(new GuiButton(8, this.width / 2 + 15, this.height / 2 + 15, 20, 20, "-"));
		
		this.done = this.addButton(new GuiButton(9, this.width / 2 - 155, this.height / 2 + 40, 150, 20, I18n.format("gui.done")));
		this.cancel = this.addButton(new GuiButton(10, this.width / 2 + 5, this.height / 2 + 40, 150, 20, I18n.format("gui.cancel")));
		
		this.x = teleporter.getX();
		this.y = teleporter.getY();
		this.z = teleporter.getZ();
				
		drawIntFields();
	}
	
	public boolean doesGuiPauseGame()
    {
        return false;
    }
	
	public void drawScreen(int mouseX, int mouseY, float partialTicks) {
		this.drawDefaultBackground();
		
		this.xField.drawTextBox();
		this.yField.drawTextBox();
		this.zField.drawTextBox();
		
		super.drawScreen(mouseX, mouseY, partialTicks);
	}
	
	protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
		super.mouseClicked(mouseX, mouseY, mouseButton);
		this.xField.mouseClicked(mouseX, mouseY, mouseButton);
		this.yField.mouseClicked(mouseX, mouseY, mouseButton);
		this.zField.mouseClicked(mouseX, mouseY, mouseButton);
	}
	
	protected void actionPerformed(GuiButton button) throws IOException {
		if (button.enabled) {
			switch (button.id) {
				case 0:
					this.x++;
					break;
				case 2:
					this.x--;
					break;
				case 3:
					this.y++;
					break;
				case 5:
					this.y--;
					break;
				case 6:
					this.z++;
					break;
				case 8:
					this.z--;
					break;
				case 9:
					mc.player.closeScreen();
					this.teleporter.setCoords(this.x, this.y, this.z);
					TestMod.logger.info("In TeleporterGUI, y-value: {}", this.teleporter.getY());
					break;
				case 10:
					mc.player.closeScreen();
					break;
			}
			drawIntFields();
		}
	}
		
	private void drawIntFields() {
		this.xField.setText(Integer.toString(this.x));
		this.yField.setText(Integer.toString(this.y));
		this.zField.setText(Integer.toString(this.z));
	}
	
}

 

EDIT: I'm using Forge 14.23.5.2847 with Minecraft 1.12.2

Edited by jkolbly
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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