-
[1.8] [SOLVED] Set maximum number of entities
LivingSpawnEvent.CheckSpawn was exactly what I needed! Thank you!
-
[1.8] [SOLVED] Set maximum number of entities
Thanks for the reply. I've checked in debug mode and the code is firing. It seems this sets a limit to spawn per chunk, while I'm looking for a limit for the entire world, like there being only one persistent EnderDragon
-
[1.8] [SOLVED] Set maximum number of entities
Hi, I'm trying to set a maximum spawn limit to an entity, here's my code but I can't seem to get it to work. The event handler is registered in the main mod class. @SubscribeEvent public void maxNessieSpawn(LivingPackSizeEvent event){ if(event.entityLiving instanceof EntityNessie){ event.maxPackSize = 1; event.setResult(Result.ALLOW); } }
-
[1.7.10] Throwable Entity owner = null
Thanks! By removing the Client only code and implementing IEntityAdditionalSpawnData the problem was fixed! Thank you so much!
-
[1.7.10] Throwable Entity owner = null
I've not been able to figure out what's causing my throwable entity to lose the player as the owner. AFAIK I'm doing it all correctly. Here's the code: EntityRegistration EntityRegistry.registerModEntity(EntityWebString.class, "Web String", webStringID, this, 128, 10, true); EntityThrowable public class EntityWebString extends EntityThrowable{ public EntityPlayer spiderMan; public EntityWebString(World world){ super(world); this.spiderMan = (EntityPlayer) this.getThrower(); } public EntityWebString(World world, EntityLivingBase throwingEntity) { super(world, throwingEntity); this.spiderMan = (EntityPlayer) throwingEntity; this.ignoreFrustumCheck = true; this.setSize(0.1F, 0.1F); this.motionX *= 2F; this.motionZ *= 2F; this.motionY *= 2F; SuperHeroLogger.debug("Spawned String with owner:" + spiderMan); } @Override protected float getGravityVelocity() { return 0.03F; } @Override public void onUpdate() { super.onUpdate(); } protected void onImpact(MovingObjectPosition hitPos) { SuperHeroLogger.debug("Object String: " + hitPos.hitInfo); SuperHeroLogger.debug("Owner is: " + this.spiderMan); SuperHeroLogger.debug("Owner is: " + this.getThrower()); if(hitPos.typeOfHit == MovingObjectType.ENTITY){ SuperHeroLogger.debug("Object Hit by String: " + hitPos.entityHit.toString()); hitPos.entityHit.motionX = -0.75F * this.motionX; hitPos.entityHit.motionZ = -0.75F * this.motionZ; hitPos.entityHit.motionY += 0.5F; this.setDead(); } else if(hitPos.typeOfHit == MovingObjectType.BLOCK){ if(!Keyboard.isKeyDown(42)){ try{ SuperHeroLogger.debug("Block Hit by String: " + hitPos.blockX + "x, " + hitPos.blockZ + "z, " + hitPos.blockY + "y"); this.spiderMan.motionX = 2F * this.motionX; this.spiderMan.motionZ = 2F * this.motionZ; this.spiderMan.motionY = (double)(4.0F * -MathHelper.sin(this.spiderMan.rotationPitch / 180.0F * (float)Math.PI)); } catch(NullPointerException e){ SuperHeroLogger.error(e.getMessage()); e.printStackTrace(); } } this.setDead(); } } } Item Right click code @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { EntityWebString string = new EntityWebString(world, player); switch (shotType){ case 0: if(player.inventory.hasItem(SpiderMan.webString)){ if(!world.isRemote){ world.spawnEntityInWorld(string); } player.inventory.consumeInventoryItem(SpiderMan.webString); } break; case 1: if (player.inventory.hasItem(SpiderMan.webBall)){ if(!world.isRemote){ world.spawnEntityInWorld(new EntityWebBallNew(world, player)); } player.inventory.consumeInventoryItem(SpiderMan.webBall); } break; } return super.onItemRightClick(itemStack, world, player); } Log Output [15:06:30] [Client thread/ERROR] [dg_shc]: Spawned String with owner:EntityClientPlayerMP['rara_avia'/268, l='MpServer', x=-260.85, y=68.62, z=226.77] [15:06:30] [server thread/ERROR] [dg_shc]: Spawned String with owner:EntityPlayerMP['rara_avia'/268, l='New World', x=-260.85, y=67.00, z=226.77] [15:06:30] [Client thread/ERROR] [dg_shc]: Owner is: null [15:06:30] [Client thread/ERROR] [dg_shc]: Owner is: null [15:06:30] [Client thread/ERROR] [dg_shc]: null [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: java.lang.NullPointerException [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.dudgames.spiderman.entities.EntityWebString.onImpact(EntityWebString.java:64) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.entity.projectile.EntityThrowable.onUpdate(EntityThrowable.java:229) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.dudgames.spiderman.entities.EntityWebString.onUpdate(EntityWebString.java:45) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.world.World.updateEntity(World.java:2258) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.world.World.updateEntities(World.java:2108) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.Minecraft.runTick(Minecraft.java:2097) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.Minecraft.run(Minecraft.java:962) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.client.main.Main.main(Main.java:164) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.reflect.Method.invoke(Unknown Source) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [15:06:30] [Client thread/INFO] [sTDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at GradleStart.main(Unknown Source) [15:06:30] [server thread/ERROR] [dg_shc]: Owner is: EntityPlayerMP['rara_avia'/268, l='New World', x=-260.85, y=67.00, z=226.77] [15:06:30] [server thread/ERROR] [dg_shc]: Owner is: EntityPlayerMP['rara_avia'/268, l='New World', x=-260.85, y=67.00, z=226.77]
-
[1.8] Custom Fishing loses player for rendering fishing line
I'm having a similar problem, have you ever found a solution?
-
Problem creating custom fishing rod.
If you're using 1.6.2 then "rayTraceBlocks" is now "clip" Try that now.
-
Changeable name tag render distance
Nevermind found it! Just had to call renderplayer.name_tag_range = blah blah
-
[FIXED][1.4.2] [6.0.1] Custom pickaxe refuses to break obsidian
I have a 5 on one of my items and it works, so it must be the maxstacksize!
-
Changeable name tag render distance
Hi, I'm working on an SMP mod in which I want to disable the username render tag distance for anyone wearing a certain armour. Now, I was leafing throught the Minecraft Forge github and saw a "Changeable name tag render distance " commit, but didn't understand the code... could anyone explain to me how I could use this?
-
Dyable Armor using a filter?
Would that change the colour of both the icon for the Armor and the armor itself or is it just one of them? Also wouldn't the custom renderer then have to override the base one?
-
Lagging Custom Entity AI
Oooh that sounds like a good plan! Thanks! I'll try it out next time I get the chance and tell you if it worked!
-
Lagging Custom Entity AI
Oh right, that sounds like a plausible plan! I'm crap at that kinda stuff though, any example as to what code/ methods to use?
-
Lagging Custom Entity AI
I found the problem, I had certain code in the Entity AI file that used rayTrace to see if the entity was in the field of view of the player. I wanna keep that, does anyone think I could move that method into the client tick handler or some other handler and still get it to work? If yes, then any ideas as to how?...
-
How I can know which block I'm pointing with the mouse?
var3.rayTrace(200, 1.0F).blockX var3 is entityplayer 200 is "reach" so if you want you can have the raytrace work for let's say 100 blocks, change that to 100 edit: I'm awful at explaining, so here's my code, it's easy to figure out (I'm telling minecraft to send a packet to the location I'm looking at with the variables positionx positiony positionz and strength) if (var2.currentScreen == null && !Keyboard.isKeyDown(pulseboltKey) && pulseboltKeyDown) { this.sendExplosion((int)var3.rayTrace(200, 1.0F).blockX, (int)var3.rayTrace(200, 1.0F).blockY, (int)var3.rayTrace(200, 1.0F).blockZ, 6); this.explosionTimer = 0; }
IPS spam blocked by CleanTalk.