Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Anrza

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by Anrza

  1. I must've struck gold if the recommendation is to use access transformers. Thanks.
  2. Hello! I want to add tilted ears to some animals. Under ideal circumstances, I'd just modelPart.zRot = t. However, the rotation around the z axis is applied before the other rotations, which makes a big mess of everything. As far as I can tell, transformation of the matrix M represented by the PoseStack to the result R depending on the rotation matrices X, Y, Z and the translation matrix P is applied as such: R=XYZPM. My solution prior to 1.17 was to extend ModelRenderer and apply the transformations in the order ZXYPM - solving the problem very simply. But since ModelPart - the 1.17 counterpart to the old ModelRenderer - is final, I see no such simple solution. I see two possible approaches: Denote T=XYZP. Apply T^-1(ZXYP) to the PoseStack before I ModelPart#render. The ModelPart will then apply T, resulting in my desired ZXYP transformation. No problem in theory, but quite convoluted in practice. Consider Z(z)X(x)Y(y). Do some linear algebra and trigonometry to find out (s,t,u) such that X(s)Y(t)Z(u)=Z(z)X(x)Y(y), then ModelPart#setRotation(s,t,u). I haven't done the math on this, so I'm not sure how feasible this is. Anyone got a simpler solution? Or should I rather do a feature request to make ModelPart not final?
  3. @Alpvax Thanks for your answers! For the record, I'm not listening for any sleep events. Since AFAIK it's not fired if time is set by a command, I'm using a more general approach. @poopoodice Thanks for your reply! I am indeed looking to use an offset variable. It's a good point that I shouldn't have to store any other time variable, and I'll look into that.
  4. Hello! I am looking to have a global time variable that ticks up with the normal gameTick but skips forward when you use the time command or skip the night by sleeping, in order to simulate the time that has passed. Quite confident with the logical part of it, but I have a few questions regarding how to save/sync and properly update every tick: What is the proper way to run code every tick? I've looked at listening for TickEvent or ClientTickEvent and ServerTickEvent. Would it be sensible to use them? How do I save global data on the server? The documentation is somewhat useful, but it's outdated and I haven't found a way to save global data. How do I conveniently send time data from server to client? Should I use my own packets? Can I include the numbers when sending initial world data to the client? Can I count on World#getGameTime and World#getDayTime to stay in sync between server and client? If so, I should be able to just execute the same code every tick on both client and server to keep them in sync. Can I count on World#getGameTime and World#getDayTime to be equal across different worlds on the server? From my testing, they seem to be the same regardless of which world you call the method from. Thanks in advance for any answers to my questions!
  5. @Draco18s Thank you, that was useful.
  6. Thanks for the information, however, it doesn't help me with my problem. What do you mean by "evaporates"? To be clear: the issue I have is not that it disappears gradually, as flowing water usually behaves in MC. As I said, "it does not flow". It simply disappears after about half a second. Flowing water can exist in the world without a source block. If you want to see what I mean, create a 1x2x1 space in the world and place water in the upper of those blocks, that is then a source block, while the block below becomes flowing water. Then remove the source block, and the flowing water block below will not disappear instantly, but gradually. I'm looking to create such a block, that - is not a "source block" - does not disappear instantly, but gradually
  7. Hey! I'm trying to place flowing water in the world. I do this: world.setBlockState(pos, Fluids.FLOWING_WATER.getDefaultState().getBlockState()); I can place it, and it appears. Using World#getFluidState and World#getBlockState indicates that it has worked. It seems to happen on both the client and the server side. However, it does not flow and disappears almost instantly after being placed. Interestingly, it behaves as expected if I place two blocks next to each other rapidly. Can anyone help me?
  8. Hello! I'm rendering a model with a TileEntityRenderer. The rendering works fine apart from the texture, which looks like all textures in MC pasted together. I've tried to use TextureManager#bindTexture(ResourceLocation), but it doesn't affect the rendering at all. package net.anju.larus.renderer; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import net.anju.larus.LarusMod; import net.anju.larus.block.CrucibleBlock; import net.anju.larus.block.LarusBlocks; import net.anju.larus.tileentity.CrucibleTileEntity; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.model.ModelRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Vector3f; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.ParametersAreNonnullByDefault; @OnlyIn(Dist.CLIENT) public class CrucibleTER extends TileEntityRenderer<CrucibleTileEntity> { private final CrucibleModel crucible; private final ResourceLocation resourceLocation = new ResourceLocation(LarusMod.MODID, "textures/block/crucible/crucible.png"); public CrucibleTER(TileEntityRendererDispatcher rendererDispatcherIn) { super(rendererDispatcherIn); this.crucible = new CrucibleModel(); } @Override @ParametersAreNonnullByDefault public void render(CrucibleTileEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { World world = tileEntityIn.getWorld(); boolean flag = world != null; BlockState blockState = flag ? tileEntityIn.getBlockState() : LarusBlocks.CRUCIBLE.get().getDefaultState(); if (blockState.get(CrucibleBlock.TILTING)) { matrixStackIn.push(); float rotation = blockState.get(CrucibleBlock.FACING).getHorizontalAngle(); boolean warm = blockState.get(CrucibleBlock.WARM); matrixStackIn.translate(0.5D, 0.5D, 0.5D); matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-rotation)); matrixStackIn.rotate(Vector3f.XP.rotationDegrees(50F * tileEntityIn.getCrucibleAngle(partialTicks))); matrixStackIn.translate(-0.5D, -0.5D, -0.5D); IVertexBuilder iVertexBuilder = bufferIn.getBuffer(RenderType.getSolid()); /*float angle = tileEntityIn.getCrucibleAngle(partialTicks); angle = 1.0F - angle; angle = 1.0F - angle * angle * angle; angle = -(angle * ((float) Math.PI / 2F));*/ crucible.render(matrixStackIn, iVertexBuilder, combinedLightIn, combinedOverlayIn, tileEntityIn.getContentLevel()); matrixStackIn.pop(); //Anrza: you must #push() before you pop, or it will crash } } private class CrucibleModel { private final ModelRenderer bottom; private final ModelRenderer front; private final ModelRenderer back; private final ModelRenderer right; private final ModelRenderer left; private final ModelRenderer level_1; private final ModelRenderer level_2; private final ModelRenderer level_3; public CrucibleModel() { int twi = 48; int thi = 16; //Bottom this.bottom = new ModelRenderer(twi, thi, 0, 0); this.bottom.addBox(2, 3, 2, 12, 1, 12, 0); //Front this.front = new ModelRenderer(twi, thi, 0, 0); this.front.addBox(2, 4, 12, 12, 12, 2); //Back this.back = new ModelRenderer(twi, thi, 0, 0); this.back.addBox(2, 4, 2, 12, 12, 2); //Left this.left = new ModelRenderer(twi, thi, 0, 0); this.left.addBox(2, 4, 4, 2, 12, 8); //Right this.right = new ModelRenderer(twi, thi, 0, 0); this.right.addBox(12, 4, 4, 2, 12, 8); //Levels this.level_1 = new ModelRenderer(twi, thi, 0, 0); this.level_1.addBox(4, 4, 4, 8, 2, 8); //Levels this.level_2 = new ModelRenderer(twi, thi, 0, 0); this.level_2.addBox(4, 4, 4, 8, 6, 8); //Levels this.level_3 = new ModelRenderer(twi, thi, 0, 0); this.level_3.addBox(4, 4, 4, 8, 11, 8); } public void render(MatrixStack matrixStackIn, IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, int level) { renderDispatcher.textureManager.bindTexture(resourceLocation); this.bottom.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); this.front.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); this.back.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); this.left.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); this.right.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); switch (level) { case 1: { level_1.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); break; } case 2: { level_2.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); break; } case 3: { level_3.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn); break; } } } } }
  9. Using a normal TER is a bit clumsy for my purposes. I've found TileEntityRendererAnimation that is supposed to work with the Forge model system and animations. It seems to depend on the block's IModelData having the Properties.AnimationProperty IBakedModel model = blockRenderer.getBlockModelShapes().getModel(state); IModelData data = model.getModelData(world, pos, state, ModelDataManager.getModelData(te.getWorld(), pos)); if (data.hasProperty(Properties.AnimationProperty)) //do animations but I haven't been able to find a way to add the AnimationProperty. I found an old post describing how to do it a few updates back, but some of the method it depends on no longer exist.
  10. Hey! I'm new to modding with Forge. I'm trying to animate a block and I'm following the documentation but I can't seem to find the class AnimationTESR. I assume this is because it has been removed in 1.16 and replaced with something else. Can anyone point me toward it or some update notes?
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.