Jump to content


  • Posts

  • 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. 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?
  2. 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
  3. 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); }
  4. would you upload the full code here or to github? I have been having problems with this
  5. 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(); }
  6. this things can be rendered from anywhere? or i have to use the "RenderLevelLastEvent"?
  7. 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.
  8. 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
  9. 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); }
  10. 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()); } }
  11. 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
  12. 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
  13. 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); } }
  14. I followed a tutorial on this(https://www.youtube.com/watch?v=My70x9LzeUM&t=297s) because i never had to use capabilities until now, the tutorial is for 1.19 but the process is exactly the same as 1.18.2. For testing, my capability is the same as the tutorial (thirst for players) but it's not working, when i press a key it removes 1 "thirst" and sends a message but nothing happens, no errors or crashes, i also tried to do the same but with a package sending it to the server just in case, but APPARENTLY AND FOR NOW, it has nothing to do with client and server. So maybe im attaching the capability to the player wrong? (BTW: the key pressing works correctly, so thats not the problem) public class PlayerThirstProvider implements ICapabilityProvider, INBTSerializable<CompoundTag> { public static Capability<PlayerThirst> CAPABILITY_PLAYER_DATA = CapabilityManager.get(new CapabilityToken<>() {}); private LazyOptional<PlayerThirst> optional = LazyOptional.of(this::create); PlayerThirst thirst = null; private PlayerThirst create() { if(this.thirst == null) { this.thirst = new PlayerThirst(); } return this.thirst; } @NotNull @Override public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) { if(cap == CAPABILITY_PLAYER_DATA) { return optional.cast(); } return LazyOptional.empty(); } @Override public CompoundTag serializeNBT() { CompoundTag tag = new CompoundTag(); create().save(tag); return tag; } @Override public void deserializeNBT(CompoundTag nbt) { create().load(nbt); } } public class PlayerThirst { private int thirst; public int getThirst() { return this.thirst; } public void addThirst(int thirst) { this.thirst = Math.min(this.thirst + thirst, 10); } public void subThirst(int thirst) { this.thirst = Math.max(this.thirst - thirst, 0); } public void copyFrom(PlayerThirst source) { this.thirst = source.thirst; } public void save(CompoundTag tag) { tag.putInt("thirst", this.thirst); } public void load(CompoundTag tag) { this.thirst = tag.getInt("thirst"); } } @Mod.EventBusSubscriber(modid = Constants.MOD_ID) public abstract class ClientEvents { @SubscribeEvent public static void keyPress2(InputEvent.KeyInputEvent event) { if(ModKeybinds.MY_KEY.consumeClick()) { //ModMessages.sendToServer(new PacketThirst()); mc.player.getCapability(PlayerThirstProvider.CAPABILITY_PLAYER_DATA).ifPresent(thirst -> { thirst.subThirst(1); mc.player.sendMessage(new TextComponent(""+thirst.getThirst()),mc.player.getUUID()); }); } } @SubscribeEvent public static void register(RegisterCapabilitiesEvent event) { event.register(PlayerThirst.class); } @SubscribeEvent public void attachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof Player) { if(!event.getObject().getCapability(PlayerThirstProvider.CAPABILITY_PLAYER_DATA).isPresent()) { event.addCapability(new ResourceLocation(Constants.MOD_ID, "playerdata"), new PlayerThirstProvider()); } } } @SubscribeEvent public static void onPlayerCloned(PlayerEvent.Clone event) { if (event.isWasDeath()) { event.getOriginal().getCapability(PlayerThirstProvider.CAPABILITY_PLAYER_DATA).ifPresent(oldStore -> { event.getPlayer().getCapability(PlayerThirstProvider.CAPABILITY_PLAYER_DATA).ifPresent(newStore -> { newStore.copyFrom(oldStore); }); }); } } } public class PacketThirst { public PacketThirst() { } // Read public PacketThirst(FriendlyByteBuf buf) { } public void write(FriendlyByteBuf buf) { } public boolean handle(Supplier<NetworkEvent.Context> ctx) { NetworkEvent.Context context = ctx.get(); context.enqueueWork(() -> { ServerPlayer serverPlayer = context.getSender(); serverPlayer.getCapability(PlayerThirstProvider.CAPABILITY_PLAYER_DATA).ifPresent(thirst -> { thirst.subThirst(1); serverPlayer.sendMessage(new TextComponent(""+thirst.getThirst()),serverPlayer.getUUID()); }); }); return true; } }
  15. So i created a custom model, and im rendering it to the player (im creating a hat) using the RenderLayer class, it renders correctly but it moves along with the body, not the head, it would be useful if im creating a backpack model but im not. So I have to make it rotate with the head like a normal hat would, i grabbed the rotation code from "Hats" mod by IChun (by now is just the pitch for testing) but is not working stack.rotate(Vector3f.XP.rotationDegrees(player.rotPitch)); //IChun solution This is how it looks in-game: https://imgur.com/a/lbV3VUk (The shape doesnt matter, is just a test) public class LivingEntityHatLayer<T extends LivingEntity> extends RenderLayer<T, EntityModel<T>> { private final List<HatData<T>> hats; public LivingEntityHatLayer(RenderLayerParent<T, EntityModel<T>> pRenderer, EntityModelSet modelSet) { super(pRenderer); hats = createHats(modelSet); } //This is the important part @Override public void render(PoseStack pose, MultiBufferSource pBuffer, int pPackedLight, T entity, float pLimbSwing, float pLimbSwingAmount, float pPartialTicks, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch) { for(var entry : hats) { if(entity instanceof Player player) { if(player.isInvisible()) return; EntityModel<T> model = entry.getModel(); VertexConsumer vertexConsumer = pBuffer.getBuffer(RenderType.entityCutout(entry.getModel().getTextureLocation())); pose.translate(entry.getTranslation().x(),entry.getTranslation().y(),entry.getTranslation().z()); pose.scale(entry.getScale().x(), entry.getScale().y(), entry.getScale().z()); pose.mulPose(Vector3f.XP.rotationDegrees(player.rotPitch)); //This is where i need help this.getParentModel().copyPropertiesTo(model); model.prepareMobModel(entity, pLimbSwing, pLimbSwingAmount, pPartialTicks); model.setupAnim(entity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch); model.renderToBuffer(pose, vertexConsumer, pPackedLight, LivingEntityRenderer.getOverlayCoords(entity, 0.0F), 1.0F, 1.0F, 1.0F, 1.0F); } } } private List<HatData<T>> createHats(EntityModelSet modelSet) { List<HatData<T>> list = new ArrayList<>(); list.add(new HatData<>("Dick", new DickHat<>(modelSet.bakeLayer(DickHat.LAYER_LOCATION)), new Vector3f(0,-1.65f,0),new Vector3f(0.75f,0.75f,0.75f),new Vector3f(0,0,0))); return list; } }
  • Create New...

Important Information

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