Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.7.10] Minecraft Create World get: java.lang.NoSuchFieldException: sleepTimer

Featured Replies

Posted

My title is too long to say solved but this has been solved!

 

Here's a larger report

Description: Ticking entity

java.lang.RuntimeException: java.lang.NoSuchFieldException: sleepTimer
at com.google.common.base.Throwables.propagate(Throwables.java:160)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:144)
at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:345)
at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:220)
at net.minecraft.client.entity.EntityClientPlayerMP.func_70071_h_(SourceFile:63)
at net.minecraft.world.World.func_72866_a(World.java:2070)
at net.minecraft.world.World.func_72870_g(World.java:2034)
at net.minecraft.world.World.func_72939_s(World.java:1887)
at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1995)
at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:962)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:887)
at net.minecraft.client.main.Main.main(SourceFile:148)
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)
Caused by: java.lang.NoSuchFieldException: sleepTimer
at java.lang.Class.getDeclaredField(Unknown Source)
at wintercraft.helper.PlayerTickHandler.serverTick(PlayerTickHandler.java:33)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_7_PlayerTickHandler_serverTick_PlayerTickEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)
... 16 more


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

-- Head --
Stacktrace:
at com.google.common.base.Throwables.propagate(Throwables.java:160)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:144)
at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:345)
at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:220)
at net.minecraft.client.entity.EntityClientPlayerMP.func_70071_h_(SourceFile:63)
at net.minecraft.world.World.func_72866_a(World.java:2070)
at net.minecraft.world.World.func_72870_g(World.java:2034)

-- Entity being ticked --
Details:
Entity Type: null (net.minecraft.client.entity.EntityClientPlayerMP)
Entity ID: 156
Entity Name: gruntpie224
Entity's Exact location: 8.50, 66.62, 8.50
Entity's Block location: World: (8,66,, Chunk: (at 8,4,8 in 0,0; contains blocks 0,0,0 to 15,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Entity's Momentum: 0.00, 0.00, 0.00
Stacktrace:
at net.minecraft.world.World.func_72939_s(World.java:1887)

 

My mod works when it runs from eclipse just not when I use the gradlew build and then use the jar it puts out. The game starts up fine but when I try to create a new world I get that error. It may have something to do with this, more than likely, but I don't get why it works in eclipse:

@SubscribeEvent
public void serverTick(PlayerTickEvent event) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{	
	EntityPlayer player = event.player;
	Random generator = new Random();

	Field f = EntityPlayer.class.getDeclaredField("sleepTimer");
	f.setAccessible(true);//Very important, this allows the setting to work.
	int sleepTimer = (Integer) f.get(player);

	/////not relevant code/////
}

You have to use the srg name. You can find them in the gradle cache.

 

Also, you should the ReflectionHelper class, it makes code a lot cleaner. For example:

try
{
    Field field = SomeClass.class.getDeclaredField("someField");
    field.setAccessible(true);
    Object value = field.get(someClassInstance);
}
catch (ReflectiveOperationException e)
{
    //Repeat with srg name
}

 

Turns to:

Object value = ReflectionHelper.getPrivateValue(SomClass.class, someClassInstance, "someField", "srgName");

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.