Jump to content

bradsk88

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by bradsk88

  1. Bumping this. I've tried to solve it a few times, but I can't find anything that looks wrong
  2. I have a mob that uses the HumanoidMobRenderer. It is meant to look like another player. public class VisitorMobRenderer extends HumanoidMobRenderer<VisitorMobEntity, PlayerModel<VisitorMobEntity>> { I have basically no custom rendering code. Just some logic for loading custom skins. https://github.com/bradsk88/Questown/blob/0d913c9bf06bb6b2de981717d2a38e182d9669ca/src/main/java/ca/bradj/questown/mobs/visitor/VisitorMobRenderer.java#L14 I've tried to call the "swing" method from the server side, which should publish a message to the client side. But I'm not seeing any animation. ((LivingEntity)mcExtra.entity()).swing(InteractionHand.MAIN_HAND); https://github.com/bradsk88/Questown/blob/0770d0d161a92d69f0749832552671b781360a64/src/main/java/ca/bradj/questown/jobs/declarative/RealtimeWorldInteraction.java#L284 Any suggestions to get my mob's arm swinging?
  3. Ah, perfect. Thanks
  4. I'm trying to implement a custom item that can be used on doors. But, the `useOn` function does not fire when clicking on doors. It fires when you click on any normal block, but it seems like the door is consuming the click event before my item can do something. Any suggestions? Thanks.
  5. Turns out the order of calls in the chain is important. I had to update my calls to vertex to be in the same order as `VertexFormat BLOCK` VertexConsumer vertex = vc.vertex(matrix4f, f3, f1, f2); vertex = vertex.color(r, g2, b2, a); vertex = vertex.uv(0, 0); vertex = vertex.uv2(0, 0); vertex = vertex.normal(matrix3f, 1.0F, 0.0F, 0.0F); vertex.endVertex();
  6. Hello all, I have a mod that renders a cube the size of a chunk to simulate a "rain"-like effect. This worked well in 1.18.2 using borrowed code from the vanilla rain rendering. That stopped working, so I'm trying to actually understand the rendering process, rather than just copy-paste-praying. I copied the code from `LevelRenderer.renderLineBox` which worked perfectly in a `RenderLevelStageEvent` handler, but only rendered lines. I switched the RenderType to translucent and now I'm getting an IllegalStateException with the message "Not filled all elements of the vertex". I understand this means I am missing a value from the vertex builder chain, but I'm not sure what I'm missing here. The DefaultVertexFormat for "block" (used by RenderType.transparent) specifies that it needs 6 values: position, color, uv0, uv2, normal, and padding. public static final VertexFormat BLOCK = new VertexFormat(ImmutableMap.<String, VertexFormatElement>builder().put("Position", ELEMENT_POSITION).put("Color", ELEMENT_COLOR).put("UV0", ELEMENT_UV0).put("UV2", ELEMENT_UV2).put("Normal", ELEMENT_NORMAL).put("Padding", ELEMENT_PADDING).build()); In my code, I am providing 6 values: vertex, color, uv, uv2, normal, and I believe padding is automatically implied. VertexConsumer vertex = vc.vertex(matrix4f, f3, f1, f2); vertex = vertex.color(r, g2, b2, a); vertex = vertex.normal(matrix3f, 1.0F, 0.0F, 0.0F); vertex = vertex.uv(0, 0); vertex = vertex.uv2(0, 0); vertex.endVertex(); But my "elementIndex" ends up being "4", causing the exception. Here is the link to the entire file: - https://github.com/bradsk88/EurekaCraft/blob/c4a3eb76468fef861fbcfbe7423f59683f9537ec/src/main/java/ca/bradj/eurekacraft/client/ChunkStormCubeForgeRendering.java#L99 Can anyone spot what I'm doing wrong here?
  7. Rendering the level solved the problem for me in 1.18.2 But it looks like it causes an infinite recursion in 1.19. at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) at TRANSFORMER/[email protected]/net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(ForgeHooksClient.java:280) at TRANSFORMER/[email protected]/net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(ForgeHooksClient.java:288) at TRANSFORMER/[email protected]/net.minecraft.client.renderer.LevelRenderer.renderChunkLayer(LevelRenderer.java:1550) at TRANSFORMER/[email protected]/net.minecraft.client.renderer.LevelRenderer.renderLevel(LevelRenderer.java:1379) at TRANSFORMER/[email protected]/ca.bradj.eurekacraft.client.ChunkWavesForgeRendering.handleRenderEvent(ChunkWavesForgeRendering.java:60) at TRANSFORMER/[email protected]/ca.bradj.eurekacraft.client.__ChunkWavesForgeRendering_handleRenderEvent_RenderLevelStageEvent.invoke(.dynamic) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) at TRANSFORMER/[email protected]/net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(ForgeHooksClient.java:280) at TRANSFORMER/[email protected]/net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(ForgeHooksClient.java:288) at TRANSFORMER/[email protected]/net.minecraft.client.renderer.LevelRenderer.renderChunkLayer(LevelRenderer.java:1550) at TRANSFORMER/[email protected]/net.minecraft.client.renderer.LevelRenderer.renderLevel(LevelRenderer.java:1379) at TRANSFORMER/[email protected]/ca.bradj.eurekacraft.client.ChunkWavesForgeRendering.handleRenderEvent(ChunkWavesForgeRendering.java:60) at TRANSFORMER/[email protected]/ca.bradj.eurekacraft.client.__ChunkWavesForgeRendering_handleRenderEvent_RenderLevelStageEvent.invoke(.dynamic) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) at TRANSFORMER/[email protected]/net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(ForgeHooksClient.java:280) at TRANSFORMER/[email protected]/net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(ForgeHooksClient.java:288) at TRANSFORMER/[email protected]/net.minecraft.client.renderer.LevelRenderer.renderChunkLayer(LevelRenderer.java:1550) at TRANSFORMER/[email protected]/net.minecraft.client.renderer.LevelRenderer.renderLevel(LevelRenderer.java:1379) at TRANSFORMER/[email protected]/ca.bradj.eurekacraft.client.ChunkWavesForgeRendering.handleRenderEvent(ChunkWavesForgeRendering.java:60) at TRANSFORMER/[email protected]/ca.bradj.eurekacraft.client.__ChunkWavesForgeRendering_handleRenderEvent_RenderLevelStageEvent.invoke(.dynamic) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) at TRANSFORMER/[email protected]/net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(ForgeHooksClient.java:280) at TRANSFORMER/[email protected]/net.minecraftforge.client.ForgeHooksClient.dispatchRenderStage(ForgeHooksClient.java:288) at TRANSFORMER/[email protected]/net.minecraft.client.renderer.LevelRenderer.renderChunkLayer(LevelRenderer.java:1550) at TRANSFORMER/[email protected]/net.minecraft.client.renderer.LevelRenderer.renderLevel(LevelRenderer.java:1379) at TRANSFORMER/[email protected]/ca.bradj.eurekacraft.client.ChunkWavesForgeRendering.handleRenderEvent(ChunkWavesForgeRendering.java:60) ... etc forever ...
  8. I'm trying to build a similar functionality. Do you have code in a repo somewhere? I'm curious where you got the value of originPos from.
  9. Updating this as I was able to solve the problem on my own. TL;DR: I switched the `-1.0F` here to `1.0F` (for each box) VoxelShapes.texOffs(0, 0).addBox(0.0F, 0.0F, -4.0F, 15.0F, -1.0F, 8.0F); --- Here's why I think this was necessary. The -1.0F value represents the "Y dimension" of a CubeDefinition that is used to create a set of BakedQuad's for the entity model. Minecraft uses "BakedQuads" to render models. Those are 4-pointed shapes with a bit of additional metadata. Each cube is made up of six quads. One piece of metadata on a BakedQuad is "direction". I suspect minecraft uses that direction for shading purposes. Direction.UP gets shaded bright (due to sunlight) and Direction.DOWN gets shaded dark because it is in the shadows. By setting my Y dimension to negative, the "up" quad of the cube is actually baked and labeled as the "down" side of the cube. And vice versa of course. For more complex models, it might require a more comprehensive solution. But since my shape was only 1 "unit" thick, inverting the 1 worked out nicely. Result: https://imgur.com/a/JTi0oYt
  10. Don't be this guy! https://xkcd.com/979/ What was the problem?
  11. Nothing obvious in the trace. If you're running a mod pack, contact the makers of the pack to report the bug. If you're running your own collection of mods. Remove them one by one until it starts working. Then, report the bug to the creator of the mod that is broken.
  12. It's probably this line ``` RenderType layer = RenderType.entityTranslucentCull(texture); ``` Try a different render type.
  13. GitHub: https://github.com/bradsk88/EurekaCraft Problem: For some reason, the top of my model is darker than the bottom. IMO it would make sense for the "sunny" side to be brighter, but I'm not sure how to fix that. Image/Video of the problem: https://imgur.com/a/hAqpqcy Player Rendering Code: @SubscribeEvent public static void playerRender(final RenderPlayerEvent.Pre event) { PlayerDeployedBoardProvider.getBoardTypeFor(event.getPlayer()).ifPresent( (PlayerDeployedBoard.ColoredBoard bt) -> renderPlayerWithBoard(event, bt) ); } private static void renderPlayerWithBoard(final RenderPlayerEvent.Pre event, PlayerDeployedBoard.ColoredBoard bt) { if (BoardType.NONE.equals(bt.boardType)) { return; } AbstractBoardModel model = ModelsInit.getModel(bt.boardType, bt.r, bt.g, bt.b); PoseStack matrixStack = event.getPoseStack(); matrixStack.mulPose(Vector3f.YP.rotationDegrees(90)); LivingEntity living = event.getEntityLiving(); living.animationSpeed = 0; living.yHeadRot = living.yBodyRot + 90; float newYRot = (float) Math.toRadians(-living.yBodyRot); VertexConsumer ivertexbuilder = event.getMultiBufferSource().getBuffer(model.getRenderType()); model.getModelRenderer().yRot = newYRot; model.renderToBuffer( matrixStack, ivertexbuilder, event.getPackedLight(), OverlayTexture.WHITE_OVERLAY_V, 1.0F, 1.0F, 1.0F, 1.0F ); } Board Model Code: public abstract class AbstractBoardModel<M extends AbstractBoardModel<M>> extends EntityModel<Entity> { private final ModelPart VoxelShapes; private final ResourceLocation texture; protected float r; protected float g; protected float b; protected AbstractBoardModel() { this(1, 1, 1); } public AbstractBoardModel(float r, float g, float b) { this.VoxelShapes = this.build(); this.texture = this.getTexture(); this.r = r; this.g = g; this.b = b; } @Override public void setupAnim(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){ //previously the render function, render code was moved to a method below } @Override public void renderToBuffer(PoseStack matrixStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){ VoxelShapes.render( matrixStack, buffer, packedLight, packedOverlay, red * this.r, green * this.g, blue * this.b, alpha ); } public ModelPart getModelRenderer() { return VoxelShapes; } public void setRotationAngle(ModelPart modelRenderer, float x, float y, float z) { modelRenderer.xRot = x; modelRenderer.yRot = y; modelRenderer.zRot = z; } protected abstract ModelPart build(); public RenderType getRenderType() { return this.renderType(this.texture); } } Edit: And the baked model: @Override protected ModelPart build() { CubeListBuilder VoxelShapes = CubeListBuilder.create(); VoxelShapes.texOffs(0, 0).addBox(0.0F, 0.0F, -4.0F, 15.0F, -1.0F, 8.0F); VoxelShapes.texOffs(0, 0).addBox(-2.0F, 0.0F, -5.0F, 2.0F, -1.0F, 10.0F); VoxelShapes.texOffs(0, 0).addBox(-8.0F, 0.0F, -6.0F, 6.0F, -1.0F, 12.0F); VoxelShapes.texOffs(0, 0).addBox(-10.0F, 0.0F, -5.0F, 2.0F, -1.0F, 10.0F); VoxelShapes.texOffs(0, 0).addBox(-12.0F, 0.0F, -4.0F, 2.0F, -1.0F, 8.0F); VoxelShapes.texOffs(0, 0).addBox(-14.0F, 0.0F, -3.0F, 2.0F, -1.0F, 6.0F); VoxelShapes.texOffs(0, 0).addBox(5.0F, 0.0F, -5.0F, 6.0F, -1.0F, 10.0F); VoxelShapes.texOffs(0, 0).addBox(8.0F, 1.0F, -2.0F, 5.0F, -1.0F, 1.0F); VoxelShapes.texOffs(0, 0).addBox(7.0F, 2.0F, -2.0F, 5.0F, -1.0F, 1.0F); VoxelShapes.texOffs(0, 0).addBox(8.0F, 1.0F, 1.0F, 5.0F, -1.0F, 1.0F); VoxelShapes.texOffs(0, 0).addBox(7.0F, 2.0F, 1.0F, 5.0F, -1.0F, 1.0F); VoxelShapes.texOffs(0, 0).addBox(-10.0F, 1.0F, -2.0F, 5.0F, -1.0F, 4.0F); VoxelShapes.texOffs(0, 0).addBox(-10.0F, 2.0F, -1.0F, 3.0F, -1.0F, 2.0F); MeshDefinition meshdefinition = new MeshDefinition(); PartDefinition partdefinition = meshdefinition.getRoot(); partdefinition.addOrReplaceChild("board", VoxelShapes, PartPose.rotation( (float) Math.PI, 0, 0)); return LayerDefinition.create(meshdefinition, 0, 0).bakeRoot(); } Thanks for any help you can provide!
  14. I would imagine yBodyRoyO probably only gets update each tick. So if you're linear interpolating from yBodyRotO to yBodyRot more than once a tick, it would cause it to "rewind" and "replay" rapidly.
  15. Figured it out. TLDR Enqueue work in FMLClientSetupEvent In that work, grab the Overworld's DimensionRenderInfo and call setWeatherRenderHandler on it with your custom renderer. In the renderer, copy the minecraft rain code and: Provide your own ResourceLocation for RAIN_LOCATION Remove the "-" from f3 value (I also multiplied it by 0.2 to slow down the rain) Source https://github.com/bradsk88/EurekaCraft/compare/4cfd071e8f5079184fb9be6a69b4316ce76c2d46...d13be10e423955eb4341f05ec94d46865adb1436
  16. For my mod, there is a clump of blocks that can only be seen when the player is wearing a certain item. I have succeeded in implementing that part: However, I would also like these block clumps to be "lit up" under any lighting conditions. I have tried setting properties on the block itself, but they don't seem to make any difference to the blocks rendered by the TileEntityRenderer: public static final Properties PROPS = Properties. copy(Blocks.AIR). noOcclusion(). lightLevel((BlockState bs) -> 10). emissiveRendering( (BlockState bs, IBlockReader r, BlockPos p) -> true ); Here's my TileEntityRenderer code (source): @Override public void render( TraparWaveBlock.TileEntity te, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn ) { ClientPlayerEntity player = mc.player; ItemStack helmet = player.getItemBySlot(EquipmentSlotType.HEAD); if (helmet.isEmpty()) { return; } for (BlockPos p : te.getShape().getAsRelativeBlockPositions()) { renderBlock(p, matrixStackIn, bufferIn, 1.0f); } } private void renderBlock(Vector3i translation, MatrixStack matrixStack, IRenderTypeBuffer buffer, float scale) { matrixStack.pushPose(); matrixStack.translate( translation.getX(), translation.getY(), translation.getZ() ); matrixStack.scale(scale, scale, scale); BlockState bs = BlocksInit.TRAPAR_WAVE_CHILD_BLOCK.get(). defaultBlockState(); mc.getBlockRenderer().renderBlock( bs, matrixStack, buffer, Integer.MAX_VALUE, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE ); matrixStack.popPose(); } I have also tried calling `RenderHelper.turnOff()` and `RenderHelper.turnBackOn()` wrapped around the "renderBlock" code. No joy. Can anyone help me out? I'd like these blocks to be "full bright" at all times. Thanks.
  17. Hello, For my mod, I'm interested in adding a custom type of "storm". It would purely be a visual effect and does not need to impose any of the other effects that come from rain (e.g. putting out fires). What would be the best option? I haven't found any other examples of this online. My current approach is to spawn a bunch of Minecraft "RAIN" particle in a radius around the player - but to create an effective result I feel I will need to add a large number of particles and worry that would introduce lag. Thanks for any help. My current experimental implementation piggybacks off one of my crop entities to spawn particles around each player in the world - but I'm still just testing things out. @Override public void animateTick(BlockState p_180655_1_, World world, BlockPos p_180655_3_, Random p_180655_4_) { super.animateTick(p_180655_1_, world, p_180655_3_, p_180655_4_); for (PlayerEntity p : world.players()) { Vector3d position = p.getPosition(0); BlockPos blockPos = new BlockPos(position); // Instead of using directions, randomly spawn particles in a zone around the player for (Direction dir : Direction.values()) { BlockPos bpO = blockPos.relative(dir); for (Direction d2 : Direction.values()) { BlockPos bp = bpO.relative(d2); world.addParticle(ParticleTypes.RAIN, bp.getX(), bp.getY() + 1, bp.getZ(), 0.0D, 0.0D, 0.0D); } } } }
×
×
  • Create New...

Important Information

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