Is there a list of minecraft server native code anywhere? Or can anyone at least direct me to a commented entity thing? I've been trying to override mob classes and I can't get mob speed to change, but I'm not even sure if I'm overriding the right method. I also randomly get error Code: 2012-11-24 23:26:49 [SEVERE] java.lang.NoSuchMethodException: com.gmail.babmush.Adventurer.mobs.mehZomboids.<init>(net.minecraft.server.World) 2012-11-24 23:26:49 [SEVERE]at java.lang.Class.getConstructor0(Unknown Source) 2012-11-24 23:26:49 [SEVERE]at java.lang.Class.getConstructor(Unknown Source) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.EntityTypes.a(SourceFile:117) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.ChunkRegionLoader.a(ChunkRegionLoader.java:279) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.ChunkRegionLoader.a(ChunkRegionLoader.java:62) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.ChunkRegionLoader.a(ChunkRegionLoader.java:51) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.ChunkProviderServer.loadChunk(ChunkProviderServer.java:155) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:90) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.PlayerInstance.<init>(PlayerInstance.java:22) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.PlayerManager.a(PlayerManager.java:68) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.PlayerManager.addPlayer(PlayerManager.java:103) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.ServerConfigurationManagerAbstract.a(ServerConfigurationManagerAbstract.java:124) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.ServerConfigurationManagerAbstract.c(ServerConfigurationManagerAbstract.java:164) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.ServerConfigurationManagerAbstract.a(ServerConfigurationManagerAbstract.java:93) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.NetLoginHandler.d(NetLoginHandler.java:132) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.NetLoginHandler.c(NetLoginHandler.java:45) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.DedicatedServerConnectionThread.a(DedicatedServerConnectionThread.java:44) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.DedicatedServerConnection.b(SourceFile:29) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.MinecraftServer.r(MinecraftServer.java:595) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.DedicatedServer.r(DedicatedServer.java:222) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:493) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:426) 2012-11-24 23:26:49 [SEVERE]at net.minecraft.server.ThreadServerApplication.run(SourceFile:856) 2012-11-24 23:26:49 [INFO] Skipping Entity with id Zombie when a player logs on, but its random. And while it doesnt do anything harmful it lags server Below is where I iniatilize my custom mob Code:java try {@SuppressWarnings("rawtypes")Class[] args = new Class[3];args[0] = Class.class;args[1] = String.class;args[2] = int.class; Method a = net.minecraft.server.EntityTypes.class.getDeclaredMethod("a", args);a.setAccessible(true); a.invoke(a, mehZomboids.class, "Zombie", 54);} catch (Exception e) {e.printStackTrace();this.setEnabled(false);}} And below is my zombie class - which is using two constructors based on if I want specific hp or scaled on distance Code:java public class mehZomboids extends net.minecraft.server.EntityZombie {Location loc;public int cHealth = -543543;int mHealth;public mehZomboids(World world, Location location) { super(world); loc = location;mHealth = (int) loc.distance(new Location(loc.getWorld(),0,64,0))/5 + 30;cHealth = mHealth; }public mehZomboids(World world, int hp) { super(world);mHealth = hp;cHealth = mHealth; }@Overridepublic int getMaxHealth(){return 10000;}public int realHealth(){return mHealth;}public int currentHealth(){return cHealth;}public void ondamage(int dmg){cHealth = cHealth - dmg;}}
can you give me the full code for MehZomboids (including imports) https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/EntityZombie.java Just to make it clear for you, Zombies are spawned with a net.minecraft.server.World object only, so both constructors have the wrong argument count
So I have to spawn zombies with only 1 constructor?.... And I was thinking I had found a good solution to scaling hp ): Also thank you for source code I spent awhile looking for that.
If you override the original Zombie, yes there is only 1 constructor for that (sadly enough) but you could implement a setHealth method and use that to scale its health :3
Okay, that makes me sad but I guess it could be worse. One last question, do I have to invoke again for every new Entity I make or can I just add Code: a.invoke(a, mehZomboids.class, "Zombie", 54); a.invoke(a, mehSkeles.class, "Skeleton", (a #)); a.invoke(a, mehSpiders.class, "Spider", (a #)); ? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
K thanks for all your help! Wait... nvm I'm getting this error now Code: 2012-11-25 11:33:46 [SEVERE] Could not pass event EntityDamageByEntityEvent to Adventurer v1.0 org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:341) at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477) at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462) at org.bukkit.craftbukkit.event.CraftEventFactory.callEvent(CraftEventFactory.java:80) at org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDamageEvent(CraftEventFactory.java:364) at org.bukkit.craftbukkit.event.CraftEventFactory.handleEntityDamageEvent(CraftEventFactory.java:386) at net.minecraft.server.EntityLiving.damageEntity(EntityLiving.java:658) at net.minecraft.server.EntityMonster.damageEntity(EntityMonster.java:39) at net.minecraft.server.EntityHuman.attack(EntityHuman.java:794) at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:1056) at net.minecraft.server.Packet7UseEntity.handle(SourceFile:36) at net.minecraft.server.NetworkManager.b(NetworkManager.java:290) at net.minecraft.server.NetServerHandler.d(NetServerHandler.java:112) at net.minecraft.server.ServerConnection.b(SourceFile:39) at net.minecraft.server.DedicatedServerConnection.b(SourceFile:30) at net.minecraft.server.MinecraftServer.r(MinecraftServer.java:595) at net.minecraft.server.DedicatedServer.r(DedicatedServer.java:222) at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:493) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:426) at net.minecraft.server.ThreadServerApplication.run(SourceFile:856) Caused by: java.lang.ClassCastException: com.gmail.babmush.Adventurer.mobs.mehZomboids cannot be cast to com.gmail.babmush.Adventurer.mobs.mehSkeles at com.gmail.babmush.Adventurer.DamageHandler.applyDmg(DamageHandler.java:89) at com.gmail.babmush.Adventurer.onDamage.damaged(onDamage.java:59) at sun.reflect.GeneratedMethodAccessor223.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:339) ... 20 more which Code: Caused by: java.lang.ClassCastException: com.gmail.babmush.Adventurer.mobs.mehZomboids cannot be cast to com.gmail.babmush.Adventurer.mobs.mehSkeles is the error but I'm never casting my zombies to my skeles? below is damagehandler 77-98 Code: public void applyDmg(Entity entity, int damage) { switch (entity.getType().getTypeId()) { case 54: mehZomboids yourZombie = (mehZomboids)((CraftEntity) entity).getHandle(); yourZombie.ondamage(damage); if (yourZombie.getRealHealth() <= 0) { entity.getWorld().spawnEntity(entity.getLocation(), EntityType.EXPERIENCE_ORB); ItemStack i = new ItemStack(Material.BEACON,27); entity.getWorld().dropItem(entity.getLocation(),i ); yourZombie.setHealth(0); } case 51: mehSkeles yourSkele = (mehSkeles)((CraftEntity) entity).getHandle(); yourSkele.ondamage(damage); if (yourSkele.getRealHealth() <= 0) { entity.getWorld().spawnEntity(entity.getLocation(), EntityType.EXPERIENCE_ORB); ItemStack i = new ItemStack(Material.BEACON,27); entity.getWorld().dropItem(entity.getLocation(),i ); yourSkele.setHealth(0); } } } So then where is the error? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
You forgot the break; after the cases Code:java public void applyDmg(Entity entity, int damage) { switch (entity.getType().getTypeId()) { case 54: mehZomboids yourZombie = (mehZomboids)((CraftEntity) entity).getHandle(); yourZombie.ondamage(damage); if (yourZombie.getRealHealth() <= 0) { entity.getWorld().spawnEntity(entity.getLocation(), EntityType.EXPERIENCE_ORB); ItemStack i = new ItemStack(Material.BEACON,27); entity.getWorld().dropItem(entity.getLocation(),i ); yourZombie.setHealth(0); } break; // BRRREEEAAAAAAK case 51: mehSkeles yourSkele = (mehSkeles)((CraftEntity) entity).getHandle(); yourSkele.ondamage(damage); if (yourSkele.getRealHealth() <= 0) { entity.getWorld().spawnEntity(entity.getLocation(), EntityType.EXPERIENCE_ORB); ItemStack i = new ItemStack(Material.BEACON,27); entity.getWorld().dropItem(entity.getLocation(),i ); yourSkele.setHealth(0); } break; // BRRREEEAAAAKKK, not really neccesary as it is the last case }}
fireblast709 Code:java package com.gmail.babmush.Adventurer.mobs; import net.minecraft.server.World; public class mehSkeles extends net.minecraft.server.EntitySkeleton{private int cHealth= 1;public mehSkeles(World world) {super(world); }@Overridepublic int getMaxHealth(){return 10000;}public int getRealHealth(){return cHealth;}public void setRealHealth(int i){cHealth = i;}public void ondamage(int dmg){cHealth = cHealth -dmg;} } Ah, also I screwed up skeleton AI i think... they don't carry bows and if you get close melee u but still act like they can shoot you ... Yeah I make alot of mistakes /sigh
try this: Code:java public mehSkeles(World world) { super(world); this.setEquipment(0, CraftItemStack.createNMSItemStack(new ItemStack(Material.BOW, 1)));}
So just giving them bows lets the shoot? Interesting and thank you for responding to my multiple help threads