Jump to content

Bektor

Forge Modder
  • Posts

    852
  • Joined

  • Last visited

Everything posted by Bektor

  1. Everything is performed server-side.
  2. Even with the values 20 for velocity updates and 80 for tracking range it is so "laggy".
  3. EntityRegistry.registerModEntity(EntityMy.class, "My", 0, PrimevalForest.instance, 150, 3, true, 0x000001, 0x00ff0f); EntityMy extends Entity Oh and it's not moving really fast. I can move faster.
  4. Hi, I've got some huge problems with my entity. It just "lags" when moving. So you can see that it moves, stops and then starts moving again. EntityMy my= (EntityMy ) entity; double speed = (double)((this.getSize() + my.getSize()) * 5.5f); if(distanceSqrt < speed && distanceSqrt > .1d) { this.motionX += -moveX / distanceSqrt / (double) speed * (my.getSize() / 75.d); this.motionY += -moveY / distanceSqrt / (double) speed * (my.getSize() / 75.d); this.motionZ += -moveZ / distanceSqrt / (double) speed * (my.getSize() / 75.d); } This is the code for the movement. It is part of the moveNearbyEntity() method which handles all movement of surrounding entities and the entity itself. And in the update method I'm calling this: this.moveNearbyEntity(); if(this.motionX != .0d || this.motionY != .0d || this.motionZ != .0d) { this.motionX *= .6d; this.motionY *= .6d; this.motionZ *= .6d; super.moveEntity(this.motionX, this.motionY, this.motionZ); } Here is the part where I get the moveXYZ and distanceSqr values: double moveX = (this.posX + .5d) - (entity.posX + .5d); double moveY = (this.posY + .5d) - (entity.posY + .5d); double moveZ = (this.posZ + .5d) - (entity.posZ + .5d); double distanceSqrt = Math.sqrt(moveX * moveX + moveY * moveY + moveZ * moveZ); It is done with the entity object and not the my object because it's used for all movement. And modifying the movement of other entities works fine with that code. So what am I doing wrong? Thx in advance. Bektor
  5. I'm not quite sure if it is a good idea to use Minecraft#thePlayer because it returns EntityPlayerSP and the mod should work in multiplayer worlds also. (well, the client will recieve the packet, but I'm not sure if this makes a difference)
  6. Well, what I want is to move the player to my entity. So my entity is basically like a black hole. It gets everything nearby and pulls them to my entity. So I'm now wondering what the most performant way is. (oh and with some mods with add more motion then my entity it should be possible to get away from my entity). And how do I get the player?
  7. Ok, I've got now a packet which should be send to the client: public class PacketPortal implements IMessage, IMessageHandler<PacketPortal , IMessage>{ private double motionX; private double motionY; private double motionZ; public PacketPortal (double motionX, double motionY, double motionZ) { this.motionX = motionX; this.motionY = motionY; this.motionZ = motionZ; } @Override public IMessage onMessage(PacketPortal message, MessageContext ctx) { return message; } @Override public void fromBytes(ByteBuf buf) { this.motionX = buf.readDouble(); this.motionY = buf.readDouble(); this.motionZ = buf.readDouble(); } @Override public void toBytes(ByteBuf buf) { buf.writeDouble(this.motionX); buf.writeDouble(this.motionY); buf.writeDouble(this.motionZ); } } So what do I need to put into onMessage to let the player move into that direction and also to check if the player does the right thing. And what is better? Do it that way or use the start and end positions? And if using them, how do I have to modify my packet and my other code which calles the packet (which is in the entity update).
  8. So how can I effect it then?
  9. Ok, the thing with exclude is working... just got a typo in the parameter list. But for some reason, the code which calls the method does not affect the player, but it does effect all other entities. (I'm in survival) The list tells me also that there was one entity found (the player), but it does not move the player. Iterator<Entity> i = this.nearby.iterator(); while(i.hasNext()) { Entity entity = (Entity) i.next(); if(entity == null || entity.isDead) return; double moveX = (this.posX + .5d) - (entity.posX + .5d); double moveY = (this.posY + .5d) - (entity.posY + .5d); double moveZ = (this.posZ + .5d) - (entity.posZ + .5d); double distanceSqrt = Math.sqrt(moveX * moveX + moveY * moveY + moveZ * moveZ); entity.motionX += moveX / distanceSqrt * .5f; entity.motionY += moveY / distanceSqrt * .5f; entity.motionZ += moveZ / distanceSqrt * .5f; } So what is wrong there? nearby is the list which calls getEntitiesInRange.
  10. Ok, so what is the first predicate for? And what is an predicate? The problem is: exclude cannot be resolved to a variable This happens even when I'm copying our code. Ok, nevermind, figured it out myself and thanks for the help.
  11. Ok, but the exclude thing is not working and could you explain the code?
  12. Hi, I've got some code to get the nearby entity but for some reason it never adds the player to the list and only adds stuff to the list when I am in survival mode. When I'm in creative mode it can't find any animals nearby or does not add them to the list. What should the code do? 1. Find all nearby entities 2. Add all nearby entities except for spectator and creative players 3. Should ignore the searching entity The code: ArrayList<Entity> output = new ArrayList<Entity>(); List<Entity> foundOnes = worldIn.getEntitiesWithinAABB(clazz, new AxisAlignedBB(pos).expand(range, range, range)); if(foundOnes.size() > 0) { for(Object e : foundOnes) { Entity result = (Entity) e; if(result != null && result.getEntityId() != entity.getEntityId()) { if(result instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) result; if(!player.isSpectator() && !player.isCreative()) output.add(result); } else output.add(result); } } } return output; Method header: public static ArrayList<Entity> getEntitiesInRange(World worldIn, Entity entity, Class<? extends Entity> clazz, BlockPos pos, int range) { Get's called by this: getEntitiesInRange(this.worldObj, this, Entity.class, this.getPosition(), 20); So what am I doing wrong and is so much code required or is there something else I could use to do the same? Thx in advance. Bektor
  13. Ah, ok. Thx. This explains a lot. ^^
  14. Just overlooked the "." because I'm used to the ":" So the summon command is now working, but the spawn egg still does not work! EDIT: There is even no console output which tells me that there is something wrong when trying to use the spawn egg. Just nothing happens and nothing will be shown in the console.
  15. Which RenderTest::new is. @Bektor: The ID for your entity will be "<modID>.Test", not "Test". So I have to type in /summon primevalforest:Test ~ ~ ~? Even that results in this: EDIT: Just overlooked the "." because I'm used to the ":" So the summon command is now working, but the spawn egg still does not work!
  16. It supposed to be RenderTest.class instead of RenderTest::new Edit: you actually suppose to create a IRenderFactory implementation for your class That's what RenderTest::new does. Just shortens that stuff with some smooth Java 8.
  17. Well, my entity has the public constructor: public EntityTest(World worldIn) { In the Client Proxy is also this method: RenderingRegistry.registerEntityRenderingHandler(EntityTest.class, RenderTest::new); The Render code does nothing yet. It just prints out a message, so I know it's working. But even that does not happen and the summon command is also not working and the spawn egg which gets created seems also to do nothing. When I put in /summon Test ~ ~ ~ it gives me that out:
  18. Hi, I've created a small test entity which basically does nothing and registered it, but it does not show up ingame. I've got a spawn egg, but when using it, nothing happens and when using the summon command I'm getting the message: Unable to summon entity. So what am I doing wrong? @Override public void preInit() { EntityRegistry.registerModEntity(EntityTest.class, "Test", 0, PrimevalForest.getInstance(), 128, 3, true, 0x000000, 0x00ff00); } This is the code for registering the entity. It is called at the end of the preInit. The method is in the ServerProxy/CommonProxy. public class EntityTest extends Entity { Thx in advance. Bektor EDIT: Log:
  19. Ok, thx. I'll look into it.
  20. Hi, I'm wondering how to render a 3D model as an item in Minecraft. I've got a .obj file and a .mtl file and an item which should use these files- So how can I do this with Forge 1.9.4? Thx in advance. Bektor
  21. Well, there was no releaseJars task before. Even in the up-to-date 1.9.4 buid.gradle file is no releaseJars task.
  22. Well, there was no releaseJars task before. Even in the up-to-date 1.9.4 buid.gradle file is no releaseJars task.
  23. Well, but it does not: As you can see there, in the inventory it's rendering a missing texture thing as a block. But it should not be a block and not be a missing texture thing. And for some reason, I commented out the json file loading, but it's still rendering the chest. And the 3d model itself is rendered in black instead of using the texture. And no, the texture is not black.
  24. Well, but it does not: As you can see there, in the inventory it's rendering a missing texture thing as a block. But it should not be a block and not be a missing texture thing. And for some reason, I commented out the json file loading, but it's still rendering the chest. And the 3d model itself is rendered in black instead of using the texture. And no, the texture is not black.
×
×
  • Create New...

Important Information

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