Jump to content

Povstalec

Members
  • Posts

    20
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Povstalec's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Alright, so I have a Structure which generates exactly once per dimension (my custom modded Dimensions + Overworld) by having it always generate at the same coordinates. This structure is central to my mod, which is why I always need it to generate. The problem starts when my mod is used along with another mod that adds new biomes to the Overworld. Since those biomes may not always be listed within Forge/Vanilla tags I use to check whether my structure can generate or not, my structure sometimes does not generate. My initial idea was overriding the code that allows the structure to generate if the biome is valid and adding an OR option for when the Dimension is Overworld. However, when looking through the related Structure code, I've been unable to find any way to check what Dimension the Structure may be generating in. And so I would like to ask here. Is there anything I've missed or are there perhaps some other ways to make sure my Structure always generates?
  2. As the title says, AbstractTickableSoundInstance I made can be heard anywhere, not just in a radius around the BlockEntity. I might be blind, but I just can't find any value that would allow me to change that. Looking at other sounds that extend it didn't help me find anything either, so I'm most likely doing someting wrong. Can anyone help me find what it is I'm doing wrong? Sound: https://github.com/Povstalec/StargateJourney/blob/main/src/main/java/net/povstalec/sgjourney/client/sound/sounds/WormholeIdleSound.java BlockEntity that plays the sound: https://github.com/Povstalec/StargateJourney/blob/main/src/main/java/net/povstalec/sgjourney/common/block_entities/stargate/AbstractStargateEntity.java#L661
  3. Oh no, I don't want to do any lerping, I know it's just for client (though I can see why it may have sounded like I do, I should have worded it better). I was just commenting on how baffled I am by the fact that the old values are the same as the new values, since I was expecting them to be different (especially in the case of lerping). That's what I tried to do when I found out the old values and new values are idetical. Then after some more testing, I realized they're identical only on the server. In terms of syncing, I've found ClientboundSetEntityMotionPacket that does the job pretty well.
  4. Alright, so for a second I thought I had a solution when I remembered the old position Entities use for lerping is public public final Vec3 getPosition(float p_20319_) { double d0 = Mth.lerp((double)p_20319_, this.xo, this.getX()); double d1 = Mth.lerp((double)p_20319_, this.yo, this.getY()); double d2 = Mth.lerp((double)p_20319_, this.zo, this.getZ()); return new Vec3(d0, d1, d2); } and while I was able to get the position on server, I found out the old position is identical to the current position (both on client and server), which means if I subtract it from the current position, I still get 0.0, what's up with that? I how can the game lerp motion if the two positions are the same?
  5. I already know how to sync it to the Client from the Server, that's not a problem. But I can't get it to sync from the Client to Server with Entity#hurtMarked, that's the problem. If I try to get the delta movement on Server, the vector looks like this: (0.0, 0.0, 0.0) so saving it and then applying it to the Entity just makes it stop. Are there any other methods Minecraft uses for syncing to Server?
  6. So I've noticed that if I try to get Player's delta movement, it returns some values on Client, but on Server, the vector is just a bunch of zeros. I'm guessing this is because Player movement is mainly handled on Client, but I'd like to ask if there's any way to get Player's movement on Server (for example, if there was a block the Player could pass through only at a certain speed along one axis, or if the block would save Player momentum and then set that Player's momentum again when needed).
  7. So I've come to the conclusion that Packets simply aren't sending the info fast enough and removed the use of packets altogether. Instead I'm just doing the same thing on Client as I am on Server, which does result in a smooth animation, but I can't really control the animation, since most of the stuff the animation depends on is server only. Either way, thanks a lot for your help.
  8. Alright, I see what you mean. But there's a slight problem: I'm not doing any logic with the second renderer. I just made an arbitrary value that is raised by one at the end of each tick and gets sent to the client via a packet, nothing else. Any other ideas?
  9. Alright, so using the other renderer for printing out the values, I got this: Rotation: 16 P-Rotation: 17.39999 Tick: 131 P-Tick: 0.6999946 Rotation: 16 P-Rotation: 16.35999 Tick: 131 P-Tick: 0.17999458 Rotation: 18 P-Rotation: 19.319988 Tick: 132 P-Tick: 0.6599946 Rotation: 18 P-Rotation: 18.159988 Tick: 132 P-Tick: 0.07999456 Rotation: 20 P-Rotation: 21.19999 Tick: 133 P-Tick: 0.59999454 Rotation: 20 P-Rotation: 20.079988 Tick: 133 P-Tick: 0.03999448 Rotation is the progress of the block entity. P-Rotation is progress with partial ticks (multiplied by two) added. Tick is tick. P-Tick is partial tick. I can see a pattern of the partial ticks reaching value 1 before the tick ends, which means they go back down to 0 during the same tick and that causes the animation to stutter. EDIT: And this is how it looks after pausing the game a few times to get a smooth animation: Rotation: 182 P-Rotation: 182.12 Tick: 185 P-Tick: 0.060000777 Rotation: 182 P-Rotation: 182.76 Tick: 185 P-Tick: 0.38000077 Rotation: 182 P-Rotation: 183.44 Tick: 185 P-Tick: 0.72000074 Rotation: 184 P-Rotation: 184.12 Tick: 186 P-Tick: 0.060000777 Rotation: 184 P-Rotation: 184.76 Tick: 186 P-Tick: 0.38000077 Rotation: 184 P-Rotation: 185.44 Tick: 186 P-Tick: 0.72000074 Rotation: 186 P-Rotation: 186.12 Tick: 187 P-Tick: 0.060000777 Rotation: 186 P-Rotation: 186.76 Tick: 187 P-Tick: 0.38000077 Rotation: 186 P-Rotation: 187.44 Tick: 187 P-Tick: 0.72000074 I'm not sure why it prints 3 values when it was only able to print 2 values per tick just a few minutes ago.
  10. Alright, so for the sake of testing, I've made another renderer which adds progress in the render method itself and that animation is perfectly smooth (although the progress obviously doesn't stop when I pause the game). That means the problem really is in syncing. I'll try printing out the height like you suggested, but in the meanwhile, do you know how I could fix this? I'm fairly sure my packets are being sent properly and I can't really think of any other place in the code where desync could happen.
  11. I know it's a value between 0 and 1, that's why I'm multiplying it by four after adding the previous position to get my preffered outcome. As for the Mth#lerp I've essentially copied the code from that and changed it to fit me needs Mth#lerp code: public static float lerp(float partialTick, float progressOld, float progress) { return progressOld + partialTick * (progress - progressOld); } my code: ringHeight = (movingHeight + partialTicks) * 4; I just removed the initial multiplication of partialTicks by (progress - progressOld) because it always changes by 1 pixel anyway. The movingHeight corresponds to progressOld. Then I multiplied everything by 4 to make it go higher. Math#lerp has the same effect, I just removed it from my code so that I don't have to call the method every time. No other reason really. If it works sometimes and sometimes doesn't, I can't be using it completely incorrectly, right? Or is there perhaps something more Math#lerp does other than the lerping math?
  12. Alright, so I have a Block Entity renderer and I want it to have a smooth animation. My current animations work well, other than having a lower framerate, which is obvious. However, when I try interpolating using Partial Ticks, the results vary greatly. Sometimes the animation is perfectly smooth, other times it stutters a lot. From testing I know the varying results are caused by me pausing the game and coming back. When I pause the game, the rendering does indeed stop, but Partial Ticks still do their thing and when I unpause it, Partial Ticks are ahead/behind where they were, which causes the Block Entity animation to start stuttering. How do I get around this issue? Here's my code: (it's basically raising and then lowering five ring models one by one) public class TransportRingsRenderer implements BlockEntityRenderer<TransportRingsEntity> { private static final ResourceLocation TRANSPORT_RINGS_TEXTURE = new ResourceLocation(StargateJourney.MODID, "textures/block/transport_rings.png"); private final ModelPart first_ring; private final ModelPart second_ring; private final ModelPart third_ring; private final ModelPart fourth_ring; private final ModelPart fifth_ring; public TransportRingsRenderer(BlockEntityRendererProvider.Context p_173554_) { ModelPart modelpart = p_173554_.bakeLayer(LayerInit.TRANSPORT_RING_LAYER); this.first_ring = modelpart.getChild("first_ring"); this.second_ring = modelpart.getChild("second_ring"); this.third_ring = modelpart.getChild("third_ring"); this.fourth_ring = modelpart.getChild("fourth_ring"); this.fifth_ring = modelpart.getChild("fifth_ring"); } private float getHeight(int ringNumber, int emptySpace, int transportHeight, int ticks, int progress, float partialTicks) { float ringHeight = 0; int startTicks = 6 * (ringNumber - 1); int movingHeight = progress - 6 * (ringNumber - 1); int staticHeight = transportHeight - 2 * (ringNumber - 1); int stopHeight = transportHeight + 17 - 4 * (5 - ringNumber); if(ticks == progress && progress > startTicks && progress < stopHeight) ringHeight = (movingHeight + partialTicks) * 4; else if(progress >= stopHeight) ringHeight = staticHeight * 4; else if(ticks != progress && progress > startTicks && progress < stopHeight) ringHeight = (movingHeight - partialTicks) * 4; if(emptySpace > 0) return ringHeight; else if(emptySpace < 0) return -ringHeight; return 0; } @Override public void render(TransportRingsEntity rings, float partialTick, PoseStack stack, MultiBufferSource source, int combinedLight, int combinedOverlay) { VertexConsumer vertexconsumer = source.getBuffer(RenderType.entitySolid(TRANSPORT_RINGS_TEXTURE)); // It takes the rings 29 ticks to get into position if there is empty space right above them if(rings.progress > 0) { this.first_ring.y = getHeight(1, rings.emptySpace, rings.transportHeight, rings.ticks, rings.progress, partialTick); this.first_ring.render(stack, vertexconsumer, rings.transportLight, combinedOverlay); } if(rings.progress > 6) { this.second_ring.y = getHeight(2, rings.emptySpace, rings.transportHeight, rings.ticks, rings.progress, partialTick); this.second_ring.render(stack, vertexconsumer, rings.transportLight, combinedOverlay); } if(rings.progress > 12) { this.third_ring.y = getHeight(3, rings.emptySpace, rings.transportHeight, rings.ticks, rings.progress, partialTick); this.third_ring.render(stack, vertexconsumer, rings.transportLight, combinedOverlay); } if(rings.progress > 18) { this.fourth_ring.y = getHeight(4, rings.emptySpace, rings.transportHeight, rings.ticks, rings.progress, partialTick); this.fourth_ring.render(stack, vertexconsumer, rings.transportLight, combinedOverlay); } this.fifth_ring.y = getHeight(5, rings.emptySpace, rings.transportHeight, rings.ticks, rings.progress, partialTick); if(rings.progress <= 24) this.fifth_ring.render(stack, vertexconsumer, combinedLight, combinedOverlay); else this.fifth_ring.render(stack, vertexconsumer, rings.transportLight, combinedOverlay); } }
×
×
  • Create New...

Important Information

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