Jump to content

ElTotisPro50

Members
  • Posts

    266
  • Joined

  • Last visited

  • Days Won

    1

ElTotisPro50 last won the day on August 24

ElTotisPro50 had the most liked content!

Recent Profile Visitors

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

ElTotisPro50's Achievements

Diamond Finder

Diamond Finder (5/8)

2

Reputation

  1. whats your "CustomHandRenderer"?
  2. Hi, im making a BlockEntity that can contain fluids, and render them in the GUI, only one fluid works perfectly, I can fill or drain it, sync it to the client, and render it. The problem comes when i try to have two fluids in the same GUI, depending on what I delete or leave, the fluids act differently; for example, deleting both of them from "saveAdditional" and "load" methods makes that the fluids cannot render. Also, it can only render one fluid alone, or again, render one fluid, but twice (copies one fluid to the other one). FYI the left one is water, the right one is a red custom fluid. How can I fix this? BoilerBlockEntity: https://pastebin.com/e6b2U3sD BoilerMenu: https://pastebin.com/D375yCNr BoilerScreen: https://pastebin.com/WMrK83Du
  3. Im trying to render a simple line using the "RenderLevelStageEvent", for testing, i put the start position above a diamond block, and the end position 5 blocks above the diamond block; The line rendering is almost good, but for some reason, apart from the original line, its rendering a second line that kind of looks "fake", it moves along with the camera, its like a ghost line that should not exist. Here is an example video: https://imgur.com/a/GRkSLVX Renderer.java @SubscribeEvent public static void test(RenderLevelStageEvent event) { if(Minecraft.getInstance().player == null) return; Player player = Minecraft.getInstance().player; Vec3 proj = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); double vpX = proj.x; double vpY = proj.y; double vpZ = proj.z; drawLine(event.getPoseStack(), new Vec3(11 - vpX, -60 - vpY, 12 - vpZ), new Vec3(11 - vpX, -55 - vpY, 12 - vpZ), new Color(255,0,0), 255); } public static void drawLine(PoseStack stack, Vec3 start, Vec3 end, Color color, int alpha) { RenderType rtype = new NoDepthWrappedRenderLayer(TotisRenderType.createLinesRenderType(3.0D, 0)); Matrix4f m = stack.last().pose(); Matrix3f norm = stack.last().normal(); MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource(); VertexConsumer bb = buffer.getBuffer(rtype); bb.vertex(m,(float)start.x,(float)start.y,(float)start.z).color(color.getRed(),color.getGreen(),color.getBlue(), alpha).normal(norm, 1.0F, 0.0F, 0.0F).endVertex(); bb.vertex(m,(float)end.x,(float)start.y,(float)start.z).color(color.getRed(),color.getGreen(),color.getBlue(), alpha).normal(norm, 1.0F, 0.0F, 0.0F).endVertex(); bb.vertex(m,(float)start.x,(float)start.y,(float)start.z).color(color.getRed(),color.getGreen(),color.getBlue(), alpha).normal(norm, 0.0F, 1.0F, 0.0F).endVertex(); bb.vertex(m,(float)start.x,(float)end.y,(float)start.z).color(color.getRed(),color.getGreen(),color.getBlue(), alpha).normal(norm, 0.0F, 1.0F, 0.0F).endVertex(); buffer.endBatch(rtype); //Btw im rendering 4 vertex because only two draws a 2D line, which looks good from one side, but thinner from the other, so this renders a 3D line that looks fine from any perspective } TotisRenderType.java: public class TotisRenderType extends RenderType { public TotisRenderType(String nameIn, VertexFormat formatIn, VertexFormat.Mode drawModeIn, int bufferSizeIn, boolean useDelegateIn, boolean needsSortingIn, Runnable setupTaskIn, Runnable clearTaskIn) { super(nameIn, formatIn, drawModeIn, bufferSizeIn, useDelegateIn, needsSortingIn, setupTaskIn, clearTaskIn); } public static RenderType createLinesRenderType(double width, int index) { return create("totis_lines" + index, DefaultVertexFormat.POSITION_COLOR_NORMAL, VertexFormat.Mode.LINES, 256, false, false, CompositeState.builder().setLayeringState(VIEW_OFFSET_Z_LAYERING).setLineState(new LineStateShard(OptionalDouble.of(width))).setShaderState(RENDERTYPE_LINES_SHADER).setTextureState(RenderStateShard.NO_TEXTURE).setTransparencyState(TRANSLUCENT_TRANSPARENCY).setDepthTestState(RenderStateShard.NO_DEPTH_TEST).setCullState(NO_CULL).setWriteMaskState(RenderStateShard.COLOR_WRITE).setLightmapState(NO_LIGHTMAP).createCompositeState(false)); } } NoDepthWrappedRenderLayer.java: public class NoDepthWrappedRenderLayer extends RenderType { private final RenderType delegate; public NoDepthWrappedRenderLayer(RenderType delegate) { super(Constants.MOD_ID + "no_depth", delegate.format(), delegate.mode(), delegate.bufferSize(), true, delegate.isOutline(), () -> { delegate.setupRenderState(); RenderSystem.disableDepthTest(); }, () -> { RenderSystem.enableDepthTest(); delegate.clearRenderState(); }); this.delegate = delegate; } public Optional<RenderType> m_7280_() { return this.delegate.outline(); } public boolean equals(@Nullable Object other) { return other instanceof NoDepthWrappedRenderLayer && this.delegate.equals(((NoDepthWrappedRenderLayer)other).delegate); } public int hashCode() { return Objects.hash(new Object[]{this.delegate}); } }
  4. i actually wanted to do something similar, apply some rendering to the player to make something like a blur, im looking at some shaders with .frag and .vert, but i dont know how would I apply them, do you know something that may help me?
  5. In 1.18.2 version I managed to started creating mixins, but the build.gradle file changed a bit in 1.19.4, and i don't know where to put the mixins stuff to start creating them. -Here's my 1.18.2 build.gradle file, i left comments like this "--------------------------------------------" where i put the stuff for adding mixins: https://pastebin.com/Gcq7E1Bp -Here's the new build.gradle from 1.19.4: https://pastebin.com/V8hMqjCS Probably it's the same, but i want to be sure
  6. https://github.com/Totis22/Change-players-skin-1.18.2/tree/main Remember that in the main method for changing skin, it requires any boolean condition/s. If all conditions are true the skin changes, but if one condition is false, it changes you back to your original skin. If "start with random skin" means, change player's skin when they enter the world, just use the same ".renderSkin()" method in the RenderHandEvent, selecting a downloaded random skin from your mod, or interacting with a skins web page, then, when you hold the item, stop the .renderSkin something like this: @SubscribeEvent public static void randomSkinManagment(EntityJoinWorldEvent event) { if (event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); skin = skins.get(rand.nextInt(skins.size())); } } @SubscribeEvent public static void playerHoldSword(TickEvent.PlayerTickEvent event) { if(event.player == null) return; Player player = event.player; if(player.getMainHandItem().is(Items.DIAMOND_SWORD)) { //save NBT Data to player: player.somewhereinNBTDATA.heldSword = true; } } @SubscribeEvent public static void renderSkinEvent(RenderLivingEvent event) { TotisCustomSkinRenderer.renderSkin( new ResourceLocation(Constants.MOD_ID, "textures/skins/" + skin + ".png"), event, event.getEntity(), false, player.somewhereinNBTDATA.heldSword == true); }
  7. would you upload the full code here or to github? I have been having problems with this
  8. im trying to render a simple line (two vertex) in the world, so im using RenderLevelLastEvent, the problem is that, is not working (does not render anything), the game does not crash, or give errors, or anything, if you know a bit about this, can you help to solve this? thanks btw: the start and end Vecs are positions of 2 blocks on my world, I tripled checked them, the positions are correct, so the problem is not the start and end positions. @SubscribeEvent public static void test(RenderLevelLastEvent event) { if (mc.player != null && mc.player.isAlive()) { Player player = mc.player; Level level = player.level; PoseStack stack = event.getPoseStack(); Matrix4f matrix = stack.last().pose(); Tesselator tesselator = Tesselator.getInstance(); BufferBuilder buffer = tesselator.getBuilder(); Vec3 start = new Vec3(-74, -61 ,-39); Vec3 end = new Vec3(-74, -54 ,-39); RenderSystem.disableTexture(); RenderSystem.enableDepthTest(); RenderSystem.depthFunc(515); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.depthMask(false); drawLine(start,end, 1.0f); RenderSystem.enableCull(); RenderSystem.depthMask(true); RenderSystem.disableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.enableTexture(); } public static void drawLine(Vec3 start, Vec3 end, float alpha) { if(start == null || end == null) return; PoseStack stack = RenderSystem.getModelViewStack(); Matrix4f matrix = stack.last().pose(); Tesselator tes = Tesselator.getInstance(); BufferBuilder buffer = tes.getBuilder(); RenderSystem.setShader(GameRenderer::getPositionColorShader); RenderSystem.lineWidth(1); buffer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); buffer.vertex(matrix,(float)start.x,(float)start.y,(float)start.z).color(1.0f,1.0f,1.0f, alpha).endVertex(); buffer.vertex(matrix,(float)end.x,(float)end.y,(float)end.z).color(1.0f,1.0f,1.0f, alpha).endVertex(); tes.end(); }
  9. this things can be rendered from anywhere? or i have to use the "RenderLevelLastEvent"?
  10. So, i want to render complex visual effects in minecraft 1.18.2, from creating simple lines, to things more complicated, like ray beams, electricity/lightning, explosions, player rendering, etc. Im guessing i need the knowledge of Tesselator, BufferBuilder, OpenGL etc. Do you know where could i learn from almost 0 this things? I dont mean a tutorial for creating this effects, but something to get me started, and something to give me enough knowledge to start this renderings.
  11. You know how can i do this for 1.18.2? i mean if you updated the code i would like to see it, and modify it for other purposes
  12. menu.getBlockEntity().getBlockPos() is the default method that gets the worldposition of the block entity, i checked just in case, and the position is correct: player.sendMessage(new TextComponent(menu.getBlockEntity().getBlockPos().getX()+","+menu.getBlockEntity().getBlockPos().getY()+","+menu.getBlockEntity().getBlockPos().getZ()), player.getUUID()); with "The order you write the bytes must be the order your read them." you mean i have to order the readers and writers in the constructor's order? public PacketSyncTeleporter2S( int dest, int x,int y,int z, int selected, boolean exists, String dimension, String name, BlockPos pos) { this.blockPos = pos; this.exists = exists; this.name = name; this.dimension = dimension; this.dest = dest; this.x = x; this.y = y; this.z = z; this.selected = selected; } //read public PacketSyncTeleporter2S(FriendlyByteBuf buf) { this.dimension = buf.readUtf(); this.name = buf.readUtf(); this.blockPos = buf.readBlockPos(); this.x = buf.readInt(); this.y = buf.readInt(); this.z = buf.readInt(); this.exists = buf.readBoolean(); this.dest = buf.readInt(); this.selected = buf.readInt(); } //write public void toBytes(FriendlyByteBuf buf) { buf.writeInt(x); buf.writeInt(y); buf.writeInt(z); buf.writeInt(selected); buf.writeInt(dest); buf.writeUtf(dimension); buf.writeUtf(name); buf.writeBoolean(exists); buf.writeBlockPos(blockPos); }
  13. I still cant figure it out, im trying to pass the variables from the screen to the block entity, actually, if i pass the values without sending them to the server with a package, it works, but if i close the menu and open it again the information removes public void savePos(int q) { ItemStack item = menu.getBlockEntity().getItemFromSlot(0); CompoundTag tag = item.getTag(); if(tag != null && tag.contains("hasInfo")) { String name = (!item.hasCustomHoverName()) ? "" : TotisPlayerUtils.getItemDisplayName(item); //ModMessages.sendToServer(new PacketSyncTeleporter2S(q, tag.getInt("x"),tag.getInt("y"),tag.getInt("z"), q, true, tag.getString(Constants.DIMENSION), name, menu.getBlockEntity().getBlockPos())); menu.getBlockEntity().setPosX(tag.getInt("x"), q); menu.getBlockEntity().setPosY(tag.getInt("y"), q); menu.getBlockEntity().setPosZ(tag.getInt("z"), q); menu.getBlockEntity().setSelectedWheelPart(q); menu.getBlockEntity().setDestName(q,name); menu.getBlockEntity().setDestExists(q,true); menu.getBlockEntity().setDestDimension(q,tag.getString(Constants.DIMENSION)); player.sendMessage(new TextComponent("Saved position in space "+q), player.getUUID()); } }
  14. I solved that, but now, I can't send information from screen to blockentity, it doesnt crash or anything, it just doesnt send what i need TeleporterScreen: https://pastebin.com/Qbp4GKK0 WarpPipeBlockEntity: https://pastebin.com/s6dXa7EX PacketSyncTeleporter2S: https://pastebin.com/u0S1jDx8 PacketSyncTeleporterPosToClient: https://pastebin.com/7A0Wccfc
×
×
  • Create New...

Important Information

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