Jump to content

ElTotisPro50

Members
  • Posts

    264
  • Joined

  • Last visited

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)

1

Reputation

  1. 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}); } }
  2. 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?
  3. 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
  4. 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); }
  5. would you upload the full code here or to github? I have been having problems with this
  6. 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(); }
  7. this things can be rendered from anywhere? or i have to use the "RenderLevelLastEvent"?
  8. 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.
  9. 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
  10. 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); }
  11. 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()); } }
  12. 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
  13. When I say information i mean strings, booleans, integers; saved in the block entity I made a block entity that can teleport me to 8 different saved locations, but for some reason, the information that i put from the screen to the block entity synchronizes with other places block entities, if i place one, break it and place it again the information should remove, but it doesnt. And if i place 2 or more block entities and modify one of them, the other one modifies too, basically like an ender chest, they sync with each-other and that SHOULD NOT happen (Video: https://imgur.com/a/viFLTRy) I spent days looking at the code and i cant find the bug lol BTW: the code is not clean and obviously is bad written, but right now my priority is to solve this problem; later, i will clean the code WarpPipeBlockEntity: https://pastebin.com/mGCNHwwm TeleporterMenu: https://pastebin.com/ZdwJ8DvP TeleporterScreen: https://pastebin.com/HELZBAqQ TeleportCrystalItem: https://pastebin.com/8fD9wkdW PacketSyncTeleporterPosToClient: https://pastebin.com/RNyY1miv ModMessages: https://pastebin.com/Zw0ShuLs
  14. it didnt work: @Mod.EventBusSubscriber(modid = Constants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public abstract class ModBusClientEvents { @SubscribeEvent public static void register(RegisterCapabilitiesEvent event) { event.register(PlayerThirst.class); } }
×
×
  • Create New...

Important Information

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