Jump to content

Dzuchun

Members
  • Posts

    98
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Dzuchun

  1. I feel like a sitting player is not a separate model, but a usual model with different rotations. Check out PlayerModel#setRotationAngles.
  2. DeferredRegister is not new. It existed in 1.15 and was preferred way to register things. Old registration (through events) works at 1.16 as well.
  3. Look for ServerWorld#summonEntity Remember: summon entities only on server side.
  4. Please, specify your question.
  5. Check out net.minecraft.util.math.AxisAlignedBB class. You may take Player AABB and then use AxisAlignedBB#intersect method on blocks positioned at player's coordinates +1(-1). AABB has constructor AxisAlignedBB(BlockPos pos). Don't forget to check if block at selected BlockPos exists and is not air (optional)
  6. 1.12 is no longer supported at this forum.
  7. 1) Class names were decided to start from a capital letter. Please, change your mod class name to "Testmod". 2) If you found nothing in debug.txt it means, that forge does not recognize your mod at all, because at least 1 message you log in you mod class constructor. 3) You did not subscribe your mod class with Mod.EventBusSubscriber annotation. Put "@Mod.EventBusSubscriber(bus = Bus.MOD, modid = Testmod.MODID)" before your main class.
  8. I think this event is fired on client as well, isn't it?
  9. How do I set and get WorldSavedData in MC 1.16.1? I can't see methods mentioned in documentation. Is WorldSavedData outdated? Should I use Capability instead?
  10. Please, double-check everything writen in my post (because of my signachure).
  11. Actually, I have no certain idea how FoV works in Minecraft. But I if we assume, that it works like an optical camera, I may help you. Here you can see how world is projected to the screen (or matrix in camera). So, to negate FoV deformations you should (using spherical trigonometry) calculate angle distance to center of the screen and take a tangent of it - now you have pure coordinate - distance to target in radius of some sphere. To find a pure coordinate of screen border, you may take tan(FoV/2). Then using screen resolution calculate distance in pixels on screen between center and target. Then again using spherical trigonometry calculate angle between Center-Target and, for example, horizon line, understand that it is unchanged after projection, and get your result vector by this angle and that distance. But please, don't do that! I'm sure, more forge-like way exists to do what you want. For example, this: or net.minecraftforge.client.event.RenderWorldLastEvent.
  12. https://minecraft.gamepedia.com/Model#Block_states this may help you "A block with just one variant uses "" as a name for its variant." Ok, I got it, your file is fine
  13. I'm not sure, but it looks like minecraft is searching for modelblockstate variant "normal", but you do not specify it.
  14. I'm bad at JSONs, but as far as I see, here is no
  15. Why would you even need that? You need to draw something near a cow? You may use RenderLivingEvent (Post subclass, if you need to draw over the cow). About your own math - check if you're rotating your vector in correct directions. Actually, you need to turn -yaw and -pitch (I see, you did it ok), because initially your vector points target, but you need it to point your looking direction. Also your yaw and pitch should be actually a difference between camera yaw and entity relative yaw, I can't see you calculating it. At last, you may use Quaternions to make you code more readable - they are at package net.minecraft.util.math.vector.Quaternion, and Vector3f has useful methods, such as rotation(float) gives you a Quternion to rotate around axis collinear to vector and transform(Quternion) to transform current vector with specified Quaternion. Happy math-ing!
  16. @Override public void init(ChunkGenerator<?> generator, TemplateManager templateManagerIn, int chunkX, int chunkZ, Biome biomeIn) { int worldX = chunkX * 16; int worldZ = chunkZ * 16; BlockPos blockpos = new BlockPos(worldX + random.nextInt(15), 0, worldZ + random.nextInt(15)); this.components.add(new TestStructurePiece(templateManagerIn, TestMod.TEST_STRUCTURE_PIECE_LOCATION, blockpos, Rotation.randomRotation(random), 1)); this.recalculateStructureSize(); } Actually, here you have a absolute freedom of how will you generate structure. You may even call single block a structure piece and actually generate your structure block-by-block (please, don't do that, I'm sure, this can be done in more intelligent way).
  17. I just realized, that it is impossible to guarantee, that my entity ticks after it's owner, that's why I get it jumping. Is it possible, somehow, to guarantee that entity ticks after another entity?
  18. Code: if (owner.collidedVertically) { setMotion(owner.getMotion().add(MOTION_CONSTANT_1)); } else { setMotion(owner.getMotion()); } LOG.info("Set motion to entity {}, owner's motion: {}", getMotion(), owner.getMotion()); Output: Me: HMMMMMMMMM, Player's motion on server is 0? I swear, no changes were applied by my mod. Should I update owner field, probably? Like, every tick get owner by it's UUID? So that's why with my personal update message sent every tick, entity once in 3 ticks got teleported back.
  19. I can't: while standing still, entity falls underground and then jumps back. I've tried to check if player is collided vertically and if so, add this constant vector to result, but that didn't work - Entity.collidedVertically seemed to be false at any time.
  20. I want to assign the same speed to my entity, to achieve is being rendered as if it is glued to a player. I would like to see it in any perspective, so I can't just render it at RenderPlayerEvent.
  21. I'm trying to calculate owner's speed. getMotion() won't work because: Probably, I should use other fields? Should I store something manually?
  22. I'm sorry, but I can see here a setting of motion to a difference of two owner's positions.
  23. Yeah, now looks ok. Here is what i found in 5 seconds by typing "fileno" to search: Please, double-check your resources folder format, it is very strict.
  24. Sounds logical, I think I got the idea, and according to it I've updated my code. Now: Every tick, both on client and server, tick() method of my entity executes folowing: if (hasOwner()) { setPositionAndUpdate(owner.getPosX(), owner.getPosY(), owner.getPosZ()); setMotion(owner.getPosX()-owner.lastTickPosX, owner.getPosY()-owner.lastTickPosY, owner.getPosZ()-owner.lastTickPosZ); LOG.info("Setting motion {}", getMotion()); } I am sure, that hasOwner() returns true, and code is executed. Every frame, at render method I execute folowing: matrixStackIn.push(); matrixStackIn.translate(entityIn.getMotion().x*partialTicks, entityIn.getMotion().y*partialTicks, entityIn.getMotion().z*partialTicks); model.setRotationAngles(entityIn, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F); // TODO describe (does nothing yet) IVertexBuilder ivertexbuilder = bufferIn.getBuffer(model.getRenderType(this.getEntityTexture(entityIn))); model.render(matrixStackIn, ivertexbuilder, packedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F); matrixStackIn.pop(); super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn); But entity jumps like hell, now with any framerate setting. I'm sure that this render method is used - if change it, entity render changes as well. Super method is Entity#render, as I can see, It renders nameplate (as I can see), executing it before matrixStackIn.pop() changes nothing (tested). So, how exactly should I ? Am I doing it correctly?
  25. The problem is, position on client is updated not every tick, but once at ~3 ticks and this update is kinda laggy - breaks any algorythm I create. Here is how to prove once-at-3-ticks update: if (prevPos != entityIn.getPositionVec()) { Long currentTime = System.currentTimeMillis(); LOG.info("Render after {}ms at new position", currentTime-prevPosTime); prevPosTime = currentTime; prevPos = entityIn.getPositionVec(); } (placed in render method; prevPos and prevPosTime are fields; outputs ~150ms, which is ~3 ticks) So with suggested code in the article you will get a total hell - 3 times entity jumps back at one position, and this 6-7 times per second. What's interesting, same applies to PlayerEntity. That's why I am curious, why smooth render in minecraft is even possible. Actually, here I have approximately 6 unexpected jumps per second. Let me remind: my entity extends Entity class directly, so I checked BoatEntity class and renderer before writing all that.
×
×
  • Create New...

Important Information

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