Jump to content

How to use Keyhandler value in Entity


dhtpdud528

Recommended Posts

Hi, i'm 'dhtpdud528' from Korea

 

i'm do not well English :(, so please understand

 

==

 

I try if i press the 'F', EntitiyBoom will be explotion but it wasn't

(use keyhandler)

 

it's crash like this

 

2013-12-08 21:13:37 [정보] [sTDERR] net.minecraft.util.ReportedException: Ticking entity
2013-12-08 21:13:37 [정보] [sTDERR] 	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:674)
2013-12-08 21:13:37 [정보] [sTDERR] 	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
2013-12-08 21:13:37 [정보] [sTDERR] 	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
2013-12-08 21:13:37 [정보] [sTDERR] 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)
2013-12-08 21:13:37 [정보] [sTDERR] 	at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
2013-12-08 21:13:37 [정보] [sTDERR] Caused by: java.lang.NullPointerException
2013-12-08 21:13:37 [정보] [sTDERR] 	at a_btoom.EntityTimerBIM.onUpdate(EntityTimerBIM.java:229)
2013-12-08 21:13:37 [정보] [sTDERR] 	at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2350)
2013-12-08 21:13:37 [정보] [sTDERR] 	at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:719)
2013-12-08 21:13:37 [정보] [sTDERR] 	at net.minecraft.world.World.updateEntity(World.java:2311)
2013-12-08 21:13:37 [정보] [sTDERR] 	at net.minecraft.world.World.updateEntities(World.java:2157)
2013-12-08 21:13:37 [정보] [sTDERR] 	at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:550)
2013-12-08 21:13:37 [정보] [sTDERR] 	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:668)
2013-12-08 21:13:37 [정보] [sTDERR] 	... 4 more
2013-12-08 21:13:37 [심각] [Minecraft-Server] Encountered an unexpected exception ReportedException
net.minecraft.util.ReportedException: Ticking entity
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:674)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)
at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
Caused by: java.lang.NullPointerException
at a_btoom.EntityTimerBIM.onUpdate(EntityTimerBIM.java:229)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2350)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:719)
at net.minecraft.world.World.updateEntity(World.java:2311)
at net.minecraft.world.World.updateEntities(World.java:2157)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:550)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:668)
... 4 more
2013-12-08 21:13:37 [심각] [Minecraft-Server] This crash report has been saved to: C:\Users\A50MS\Minecraft_mod\forge\mcp - btoom\jars\.\crash-reports\crash-2013-12-08_21.13.37-server.txt
2013-12-08 21:13:37 [정보] [Minecraft-Server] Stopping server
2013-12-08 21:13:37 [정보] [Minecraft-Server] Saving players
2013-12-08 21:13:37 [정보] [Minecraft-Server] Saving worlds
2013-12-08 21:13:37 [정보] [Minecraft-Server] Saving chunks for level 'New World'/Overworld
2013-12-08 21:13:37 [정보] [sTDOUT] ---- Minecraft Crash Report ----
2013-12-08 21:13:37 [정보] [sTDOUT] // Daisy, daisy...
2013-12-08 21:13:37 [정보] [sTDOUT] 
2013-12-08 21:13:37 [정보] [sTDOUT] Time: 13. 12. 8 오후 9:13
2013-12-08 21:13:37 [정보] [sTDOUT] Description: Ticking entity
2013-12-08 21:13:37 [정보] [sTDOUT] 
2013-12-08 21:13:37 [정보] [sTDOUT] java.lang.NullPointerException
2013-12-08 21:13:37 [정보] [sTDOUT] 	at a_btoom.EntityTimerBIM.onUpdate(EntityTimerBIM.java:229)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2350)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:719)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.world.World.updateEntity(World.java:2311)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.world.World.updateEntities(World.java:2157)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:550)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:668)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
2013-12-08 21:13:37 [정보] [sTDOUT] 
2013-12-08 21:13:37 [정보] [sTDOUT] 
2013-12-08 21:13:37 [정보] [sTDOUT] A detailed walkthrough of the error, its code path and all known details is as follows:
2013-12-08 21:13:37 [정보] [sTDOUT] ---------------------------------------------------------------------------------------
2013-12-08 21:13:37 [정보] [sTDOUT] 
2013-12-08 21:13:37 [정보] [sTDOUT] -- Head --
2013-12-08 21:13:37 [정보] [sTDOUT] Stacktrace:
2013-12-08 21:13:37 [정보] [sTDOUT] 	at a_btoom.EntityTimerBIM.onUpdate(EntityTimerBIM.java:229)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2350)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:719)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.world.World.updateEntity(World.java:2311)
2013-12-08 21:13:37 [정보] [sTDOUT] 
2013-12-08 21:13:37 [정보] [sTDOUT] -- Entity being ticked --
2013-12-08 21:13:37 [정보] [sTDOUT] Details:
2013-12-08 21:13:37 [정보] [sTDOUT] 	Entity Type: BtooomMod.Timer BIM (a_btoom.EntityTimerBIM)
2013-12-08 21:13:37 [정보] [sTDOUT] 	Entity ID: 4
2013-12-08 21:13:37 [정보] [sTDOUT] 	Entity Name: entity.BtooomMod.Timer BIM.name
2013-12-08 21:13:37 [정보] [sTDOUT] 	Entity's Exact location: -484.32, 4.02, 696.71
2013-12-08 21:13:37 [정보] [sTDOUT] 	Entity's Block location: World: (-485,4,696), Chunk: (at 11,0,8 in -31,43; contains blocks -496,0,688 to -481,255,703), Region: (-1,1; contains chunks -32,32 to -1,63, blocks -512,0,512 to -1,255,1023)
2013-12-08 21:13:37 [정보] [sTDOUT] 	Entity's Momentum: 0.28, -0.45, 0.71
2013-12-08 21:13:37 [정보] [sTDOUT] Stacktrace:
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.world.World.updateEntities(World.java:2157)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:550)
2013-12-08 21:13:37 [정보] [sTDOUT] 
2013-12-08 21:13:37 [정보] [sTDOUT] -- Affected level --
2013-12-08 21:13:37 [정보] [sTDOUT] Details:
2013-12-08 21:13:37 [정보] [sTDOUT] 	Level name: New World
2013-12-08 21:13:37 [정보] [sTDOUT] 	All players: 0 total; []
2013-12-08 21:13:37 [정보] [sTDOUT] 	Chunk stats: ServerChunkCache: 625 Drop: 0
2013-12-08 21:13:37 [정보] [sTDOUT] 	Level seed: -8861550202755443363
2013-12-08 21:13:37 [정보] [sTDOUT] 	Level generator: ID 01 - flat, ver 0. Features enabled: false
2013-12-08 21:13:37 [정보] [sTDOUT] 	Level generator options: 
2013-12-08 21:13:37 [정보] [sTDOUT] 	Level spawn location: World: (-496,4,691), Chunk: (at 0,0,3 in -31,43; contains blocks -496,0,688 to -481,255,703), Region: (-1,1; contains chunks -32,32 to -1,63, blocks -512,0,512 to -1,255,1023)
2013-12-08 21:13:37 [정보] [sTDOUT] 	Level time: 4521 game time, 4521 day time
2013-12-08 21:13:37 [정보] [sTDOUT] 	Level dimension: 0
2013-12-08 21:13:37 [정보] [sTDOUT] 	Level storage version: 0x04ABD - Anvil
2013-12-08 21:13:37 [정보] [sTDOUT] 	Level weather: Rain time: 52320 (now: false), thunder time: 91190 (now: false)
2013-12-08 21:13:37 [정보] [sTDOUT] 	Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
2013-12-08 21:13:37 [정보] [sTDOUT] Stacktrace:
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:668)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)
2013-12-08 21:13:37 [정보] [sTDOUT] 	at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
2013-12-08 21:13:37 [정보] [sTDOUT] 
2013-12-08 21:13:37 [정보] [sTDOUT] -- System Details --
2013-12-08 21:13:37 [정보] [sTDOUT] Details:
2013-12-08 21:13:37 [정보] [sTDOUT] 	Minecraft Version: 1.6.4
2013-12-08 21:13:37 [정보] [sTDOUT] 	Operating System: Windows 7 (x86) version 6.1
2013-12-08 21:13:37 [정보] [sTDOUT] 	Java Version: 1.7.0_45, Oracle Corporation
2013-12-08 21:13:37 [정보] [sTDOUT] 	Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
2013-12-08 21:13:37 [정보] [sTDOUT] 	Memory: 866363376 bytes (826 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)
2013-12-08 21:13:37 [정보] [sTDOUT] 	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
2013-12-08 21:13:37 [정보] [sTDOUT] 	AABB Pool Size: 84 (4704 bytes; 0 MB) allocated, 84 (4704 bytes; 0 MB) used
2013-12-08 21:13:37 [정보] [sTDOUT] 	Suspicious classes: FML and Forge are installed
2013-12-08 21:13:37 [정보] [sTDOUT] 	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
2013-12-08 21:13:37 [정보] [sTDOUT] 	FML: MCP v8.11 FML v6.4.45.953 Minecraft Forge 9.11.1.953 4 mods loaded, 4 mods active
2013-12-08 21:13:37 [정보] [sTDOUT] 	mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
2013-12-08 21:13:37 [정보] [sTDOUT] 	FML{6.4.45.953} [Forge Mod Loader] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
2013-12-08 21:13:37 [정보] [sTDOUT] 	Forge{9.11.1.953} [Minecraft Forge] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
2013-12-08 21:13:37 [정보] [sTDOUT] 	BtooomMod{1.6.4} [bTOOOM!] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
2013-12-08 21:13:37 [정보] [sTDOUT] 	Profiler Position: N/A (disabled)
2013-12-08 21:13:37 [정보] [sTDOUT] 	Vec3 Pool Size: 19 (1064 bytes; 0 MB) allocated, 19 (1064 bytes; 0 MB) used
2013-12-08 21:13:37 [정보] [sTDOUT] 	Player Count: 0 / 8; []
2013-12-08 21:13:37 [정보] [sTDOUT] 	Type: Integrated Server (map_client.txt)
2013-12-08 21:13:37 [정보] [sTDOUT] 	Is Modded: Definitely; Client brand changed to 'fml,forge'
2013-12-08 21:13:37 [정보] [sTDOUT] #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2013-12-08_21.13.37-server.txt

 

please help

 

 

KeyHandlerBTOOOM.java

 

package a_btoom;

import java.util.EnumSet;

import net.java.games.input.Keyboard;
import net.minecraft.client.settings.KeyBinding;
import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class KeyHandlerBTOOOM extends KeyHandler {
static KeyBinding kb1 = new KeyBinding("Timer", org.lwjgl.input.Keyboard.KEY_F);
public boolean timeron = false;
private int tick = 0;
public int timer = 10;

public KeyHandlerBTOOOM() {
	super(new KeyBinding[]{kb1}, new boolean[] {true});

}

@Override
public String getLabel() {

	return null;
}

@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb,
		boolean tickEnd, boolean isRepeat) {
	if(kb.keyCode == kb1.keyCode)
	{
		timeron = true;
		if(this.timeron)
		{
			++this.tick ;
			if(tick == 50)
			{
				this.tick = 0;
				System.out.println(timer);
				this.timer  -= 1;
			}
		}
	}
}

@Override
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {
	if(kb.keyCode == kb1.keyCode)
	{
		if(tickEnd)
		{
			System.out.println("up");
			this.timeron = false;
		}
	}

}

@Override
public EnumSet<TickType> ticks() {
	return EnumSet.of(TickType.CLIENT);
}

}

 

EntityTimerBIM.java

 

package a_btoom;

import java.util.List;
import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.enchantment.EnchantmentThorns;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.*;
import net.minecraft.entity.passive.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet70GameEvent;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSourceIndirect;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntityTimerBIM extends Entity implements IProjectile
{
KeyHandlerBTOOOM keyhandler;

.
.
.

public void onUpdate()
    {
        super.onUpdate();

.
.
.

        if(keyhandler.timer <=0)
        {
        	this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)this.power , flag);
            this.setDead();
        }

 

Link to comment
Share on other sites

Put the counter in the entity onUpdate().

Put a default constructor with World as parameter.

Use the keyhandler to send a packet to server side to start the entity counter.

You'll need a way to link the entity with a player...maybe his username when the entity is spawned ?

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • After uninstalling this mod, everything works! Thanks!
    • I had been playing on this fabric server for about a month with some friend and one day it just stopped starting, can anyone help me understand what the cause is? https://mclo.gs/2jop3r5    
    • The mobs are moving normally for a second, then freeze, then go back to normal, and this repeats. I describe this as mob lag, bc they stutter as if they were lagging. I don't have the best wifi, but that shouldn't matter since its 10mbps which is enough for a server. I have 8 gigs of ram for it, no optimizations have worked, if there is anything more you may need to help lmk, ill describe. The modlist is pretty hefty: VS_ClockworkSurvivalSupportV1.4 aether-1.20.1-1.2.0-neoforge.jar alexsdelight-1.5.jar alexsmobs-1.22.7.jar appleskin-forge-mc1.20.1-2.5.1.jar backpacked-forge-1.20.1-2.2.5.jar balm-forge-1.20.1-7.2.1.jar bettervillage-forge-1.20.1-3.2.0.jar BiomesOPlenty-1.20.1-18.0.0.598.jar botarium-forge-1.20.1-2.3.2.jar CGM-Unofficial-1.4.11+Forge+1.20.1.jar citadel-2.5.2-1.20.1.jar clockwork-1.20.1-0.1.2-forge-05f5d5fbbb.jar configured-forge-1.20.1-2.2.2.jar connectivity-1.20.1-4.9.jar create-1.20.1-0.5.1.f.jar create-new-age-forge-1.20.1-1.1.2.jar createarmoryv0.6.1n.jar createbigcannons-forge-1.20.1-0.5.3.b.jar createchunkloading-1.6.0-forge.jar createdeco-2.0.1-1.20.1-forge.jar createdieselgenerators-1.20.1-1.2h.jar createendertransmission-2.0.7-1.20.1.jar create_misc_and_things_ 1.20.1_4.0A.jar cristellib-1.1.5-forge.jar cupboard-1.20.1-2.3.jar curios-forge-5.7.0+1.20.1.jar destroy-1.20.1-0.8.jar Dungeon Crawl-1.20.1-2.3.14.jar FallingTree-1.20.1-4.3.4.jar FarmersDelight-1.20.1-1.2.4.jar framework-forge-1.20.1-0.6.26.jar geckolib-forge-1.20.1-4.4.2.jar InsaneLib-1.12.1-mc1.20.1.jar Jade-1.20.1-forge-11.8.0.jar jei-1.20.1-forge-15.3.0.4.jar journeymap-1.20.1-5.9.18-forge.jar JustEnoughResources-1.20.1-1.4.0.247.jar kotlinforforge-4.10.0-all.jar l2library-2.4.23.jar libraryferret-forge-1.20.1-4.0.0.jar macawsbridgesbop-1.20-1.1.jar mcw-bridges-2.1.0-mc1.20.4forge.jar moonlight-1.20-2.9.17-forge.jar morevillagers-forge-1.20.1-5.0.0.jar Mo_ZombiesWave-1.20.1-0.1.0-forge.jar NaturesCompass-1.20.1-1.11.2-forge.jar Placebo-1.20.1-8.6.1.jar refinedstorage-1.12.4.jar soundphysics-forge-1.20.1-1.1.2.jar spark-1.10.53-forge.jar stealing_villagers-forge-1.20.1-1.0.0.jar s_a_b-1.3.0_1.20.1.jar takesapillage-1.0.3-1.20.1.jar TerraBlender-forge-1.20.1-3.0.1.4.jar tombstone-1.20.1-8.6.2.jar Towns-and-Towers-1.12-Fabric+Forge.jar twilightforest-1.20.1-4.3.2145-universal.jar valkyrienskies-120-2.1.3-beta.1.jar veinmining-forge-1.3.0+1.20.1.jar waystones-forge-1.20-14.1.3.jar YungsApi-1.20-Forge-4.0.3.jar YungsBetterDesertTemples-1.20-Forge-3.0.3.jar YungsBetterDungeons-1.20-Forge-4.0.3.jar YungsBetterEndIsland-1.20-Forge-2.0.5.jar YungsBetterJungleTemples-1.20-Forge-2.0.4.jar YungsBetterMineshafts-1.20-Forge-4.0.4.jar YungsBetterNetherFortresses-1.20-Forge-2.0.5.jar YungsBetterOceanMonuments-1.20-Forge-3.0.4.jar YungsBetterStrongholds-1.20-Forge-4.0.3.jar YungsBetterWitchHuts-1.20-Forge-3.0.3.jar YungsBridges-1.20-Forge-4.0.3.jar zaynens_leather_from_rotten_flesh_mod_1.20.1.jar
    • Thank you so much! Unfortunately before reading this I reinstalled my java installer. Now when I try to open the forge installer I receive an error message stating 'Unable to install Java' even though I have definitely downloaded and installed the latest version. Any idea what this could be or how I could fix it?  
    • IT WORKED! THANK YOU!
  • Topics

×
×
  • Create New...

Important Information

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