-
Posts
54 -
Joined
-
Last visited
-
Days Won
2
Everything posted by chxr
-
[1.20.4] Apply nausea wobble effect to the screen outside Nausea effect
chxr replied to chxr's topic in Modder Support
Yeah i had something similar and the same problem is happening:It only triggers when in a gui (pause menu, inventory etc) is on the screen. So that was my main need of help. Do i need to make "a class to render the effect on", if that makes sense? Thanks for the render code though, with a few tweaks it will look amazing. EDIT: If im not mistaken that's the expected result of the event used? But as I said this is my first time tinkering with player-side rendering. -
So i know for a fact this has been asked before but Render stuff troubles me a little and i didnt find any answer for recent version. I have a custom nausea effect. Currently i add both my nausea effect and the vanilla one for the effect. But the problem is that when I open the inventory, both are listed, while I'd only want mine to show up (both in the inv and on the GUI) I've arrived to the GameRender (on joined/net/minecraft/client) and also found shaders on client-extra/assets/minecraft/shaders/post and client-extra/assets/minecraft/shaders/program but I'm lost. I understand that its like a regular screen, where I'd render stuff "over" the game depending on data on the server, but If someone could point to the right client and server classes that i can read to see how i can manage this or any tip would be apreciated
-
WIthout entering on menu class and capability shenanigans, in the load method try calling the super.load(nbt) before doing anything else. It might not be it, but that's really the only difference i can see with the very basic be i have. If you have a repo i can make a clone of to take a quick look at the whole thing on I'll maybe help you out quicker
-
Made it work. As a note, one of the times it didn't recognize the recipe cause the MOD_ID constant I was using somewhere was NOT referencing my MOD_ID but rather another static variable with the same name. Maybe OP is having a similar problem
-
Yeah sorry i just managed to make it now, i shouldn't have tried to make it work in my head yesterday late at night. It correctly is recognizing the recipe. Im running on some other errors but they are now due to my recipe's inner workings and not the game not recognizing the recipe itself
-
It does but I'm struggling to see how to make it work in my recipe? (Its structure is the same as OP's, with a serializer subclass)
-
Pretty much, although all the recipes im planning to make on it are shapeless. The idea is that the chamber uses energy to "fuse" the items in each of the center slots together, in this case an ingot. The two slots at the sides are fuel. (A special kind of wood in this case). Here is an image of the interface just for reference (The center slot is the output) As for the code- Can you elaborate a little bit on it? Seeing three different record classes has confused me a lot. (Elaborate as in why make them in three different records. I understand the code itself more or less)
-
Funny enough, Chatgpt is confusing me even more. My BE works like a furnace, you need 8 items and two fuel to make a third item. Here is an example recipe. In this case, 8 aberrant shards, each one in one slot, and two of aberrant fuel, each one on one slot for a total of 10 slots. Supposedly any block with the tag aberrant_fuel should be accepted but im not sure this is how the json should look: { "type": "relativedimensions:particle_rebound", "inputItem": [ { "item": "relativedimensions:aberrant_shard" } ], "fuelItem": [ { "tag": "relativedimensions:block/aberrant_fuel" } ], "output": { "Count": 1, "id": "relativedimensions:aberrant_ingot" } }
-
I'm struggling to guess what on earth are you trying to achieve, or what do you want cause your post is a lil bit wonky, but the BlockEntity class has methods like SaveAdditional(CompoundTag) and load(CompoundTag) that should manage serialization and deserialization of your block entity NBT data for most cases and that you can override. If you mean reading NBT data of things "Inside" your BE, (in a slot) I'm pretty sure you can get an ItemStack out of any slot inside your BE from which to acess NBT data of the item in the slot. If you need the NBT data of a specific block entity you can call ServerLevel.getBlockEntity() Blocks don't have NBT data iirc. It would help to get an explanation on what is that your BE does and whats the current look of your BE class.
-
Im running on a similar problem. Codecs are hurting my head more than they should
-
You would do good posting some code. I'm not expert, but I guess I would start by overriding the use() method of the item (or something equivalent, i really dont remember if use() was a thing on 1.16 anymore). Then youll there have to check if whatever it clicked is the entity you want (Wolf) and im pretty sure the wolf, as a tameable entity, has a getOwner() method or something similar EDIT: Use() cant be used to get an entity it interacted with but something like interactLivingEntity() does and im pretty sure it did exist back in 1.16.5
-
Ok so in the end it was that I did not understand how the tags on the item and entity worked. I was trying to bulk add all the tags (including item id and stack count) directly to the rocket. but turns out that the fireworks go on the rocket item and the extra lifetime tag goes on the entity, if I understood correctly. So it ends up looking something like this: ListTag explosionsList = new ListTag(); CompoundTag explosionsTag = new CompoundTag(); explosionsTag.putByte("Type", (byte) 3); explosionsTag.putByte("Flicker", (byte) 0); explosionsTag.putByte("Trail", (byte) 1); explosionsTag.putIntArray("Colors", new int[] {5635925}); explosionsTag.putIntArray("FadeColors", new int[] {11141120}); //List of explosion parameters (I just copied from a /summon example to test it) explosionsList.add(explosionsTag); //There might be multiple customized explosions, so they go in a list CompoundTag fireworksTag = new CompoundTag(); fireworksTag.putInt("Flight", 2); fireworksTag.put("Explosions", explosionsList); // Flight:2,Explosions:[{Type:3,Flicker:0,Trail:1,Colors:[I;5635925],FadeColors:[I;11141120]}] //The whole firework data, including how high up will it go, go in a higher nested tag //NOW we create a rocket item stack and add ONLY the fireworks tag to it. The rest of the needed tags will be read for the entity later ItemStack fireworkItem = new ItemStack(Items.FIREWORK_ROCKET); CompoundTag fireWorkitemTag = fireworkItem.getOrCreateTag(); fireWorkitemTag.put("Fireworks", fireworksTag); // (The full item tag will have the item id and the stack Count) Fireworks:{Flight:2,Explosions:[{Type:3,Flicker:0,Trail:1,Colors:[I;5635925],FadeColors:[I;11141120]}]} // Create and spawn the firework rocket entity double x = pos.getX() + (new Random().nextDouble() * 20 - 10); double z = pos.getZ() + (new Random().nextDouble() * 20 - 10); BlockPos ypos = new BlockPos(x, 350, z); while (ypos.getY() > -64 && world.isEmptyBlock(ypos)) { ypos = ypos.below(); } double y = ypos.above().getY(); //Here we use the already crated rocket itemstsack to feed the entity: It will read all the tags (Including the needed ID and stackcount from the stack itself) Lastly, we also specify the lifetime of the rocket. This goes directly before the item data. FireworkRocketEntity rocket = new FireworkRocketEntity(world, x, y, z, fireworkItem); CompoundTag fireworkEntityTag = new CompoundTag(); fireworkEntityTag.putInt("LifeTime", 40); rocket.addAdditionalSaveData(fireworkEntityTag); // LifeTime:40,FireworksItem:{id:firework_rocket,Count:1,tag:{Fireworks:{Flight:2,Explosions:[{Type:3,Flicker:0,Trail:1,Colors:[I;5635925],FadeColors:[I;11141120]}]}}} This is what the full /summon command looks like and how the order of the tags ends up looking like (I think) world.addFreshEntity(rocket); //Spawn the rocket entity
-
I think you may still need to register the method itself in the bus or specify it in the decorator.
-
So is it the load what I'm missing? Now the rockets wont spawn hmm. I'll keep trying and report back if I get something
-
For anyone wondering - it was the networking fault. As i was rendering all the GUI on the same block of code, the render failed when getting the information from the packets and stopped, and since it didn't reach the popStack at the end of the code block, the rest of the GUI just stayed with the same modified scale.
-
I'm having a tiny bit of trouble getting rockets around the player to just... well go off and explode I don't exactly know if the rendering of the explosion is exclusively client-side or if I'm not understanding the tags correctly As far as I understand, there is a tag containing all the data for the explosion, then the rest of the tags are added. There is also the FIREWORK_STAR but I don't know if I should take it into account. I've been looking in the Rocket Recipe and and Entity as well as the item but I'm not getting anything clear out of it. I have this code now (which is obviously bad-) Any tips on how to move forward? ItemStack itemstack = new ItemStack(Items.FIREWORK_ROCKET); CompoundTag compoundtag = itemstack.getOrCreateTagElement("Fireworks"); ListTag listtag = new ListTag(); ItemStack itemstack2 = new ItemStack(Items.FIREWORK_STAR); CompoundTag compoundtag1 = itemstack2.getTagElement("Explosion"); listtag.add(compoundtag1); itemstack2.setTag(compoundtag1); compoundtag.putByte("Flight", (byte)1); compoundtag.put("Explosions", listtag); itemstack.setTag(compoundtag); itemstack.setTag(compoundtag1); // Create and spawn the firework rocket entity double x = pos.getX() + (new Random().nextDouble() * 20 - 10); double z = pos.getZ() + (new Random().nextDouble() * 20 - 10); BlockPos ypos = new BlockPos(x, 350, z); while (ypos.getY() > -64 && world.isEmptyBlock(ypos)) { ypos = ypos.below(); } double y = ypos.above().getY(); FireworkRocketEntity rocket = new FireworkRocketEntity(world, x, y, z, ItemStack.EMPTY); world.addFreshEntity(rocket);
-
@HipposgrummFunnily enough, this is the tutorial I was using on my other post, which just reinforces the fact I'm missing something stupidly obvious. I'll check it all again.
-
Okay so since my other post I've seen some other posts and videos. My custom GUI now extends Screen, so I have a couple of questions I'm not quite getting: 1) Does the code that renders image, text and other elements be on a render() mehtod? on an init() method? 2) How do I register the GUI? Some other answers I've seen are for GUIS inside buttons, or items, but mine needs to be visible while the player moves (like the hotbar, for example) and I haven't found any good examples. Where in the vanilla code can I see where the vanilla GUIs are registred?
-
Yeah, I had already scouted through it before (though I didn't see that clearly what I could use, so I'll check on your tip later). My main problem (the reason why I'm scaling the GUI in the first place) is that I can't find a way to scale the text itself, that's why I resorted to scale the whole thin Also, why is the client behaving differently on the SDK vs the regular client? (This is more out of curiosity really, i don't know if the reason is in my code or somewhere else)
-
So, I'm preparing a little HUD for an event I'm going to do with some friends. It all works fine in the client executed when running ./gradlew runClient. It's the expected result: But the problem comes when I either open the Forge SDK world to LAN OR load the mod to a separate Forge server instance, both needing the packed .jar made via ./gradlew build: As you can see, it drags the whole pause GUI with it. Of the four text lines, only one is seen. I use both scale and translate methods, and this exact thing happened on the SDK client too, but I fixed it using pushpose and poppose methods initially. The timer updates via network packets and works fine, as I said, on the Forge SDK instance of the client. The packets also work fine on their own, I only changed it so it would update the text in the GUI instead of outputting directly to the game chat. Here is the code of the GUI I made: public class PVPStateOverlay{ //if you need custom textures they should be placed unde resources/assets/yourmodid/textures/gui (gui interchangable with other folders) //https://www.youtube.com/watch?v=J3a7JT0rxTM //Refer to ClientEvents.java for the gui registration private static final ResourceLocation TEXTURE = new ResourceLocation(MOD_ID, "textures/mainvisor/fhcmclogo.png"); public static final IGuiOverlay HUD_MAINOVERLAY = ((gui, poseStack, partialTick, width, height) -> { int x = width / 2; int y = height; int logoxoffset = 145; int logoyoffset = -225; int rextanglexstart= -35; int rextangleystart = 13; int rextanglexend= 60; int rextangleyend = 70; int textxoffset = 12; int textyoffset = 20; //Push the matrix to the stack, so that the scale and translation don't affect other elements //At the end, pop the matrix from the stack so that subsequent renders aren't affected! poseStack.pushPose(); poseStack.pushPose(); final double scaled = (1.f / gui.getMinecraft().getWindow().getGuiScale()) * 3; final float scale = (float) scaled; poseStack.scale(scale, scale, scale); poseStack.translate(175F, 75F, 0F); // Draw semi-transparent grey rectangle RenderSystem.setShader(GameRenderer::getPositionColorShader); RenderSystem.setShaderColor(0.5F, 0.5F, 0.5F, 0.5F); GuiComponent.fill(poseStack,x + logoxoffset + rextanglexstart, y + logoyoffset + rextangleystart, x + logoxoffset + rextanglexend, y + logoyoffset + rextangleyend,0xFFFFFFFF);//Pos and then scale // Draw "Time remaining" text Minecraft minecraft = Minecraft.getInstance(); Font font = minecraft.font; String timeRemaining = "Tiempo restante:"; int textWidth = font.width(timeRemaining); int textX = (x + logoxoffset + textxoffset - textWidth / 2); int textY =(y + logoyoffset + textyoffset); GuiComponent.drawString(poseStack, font, timeRemaining, textX, textY, 0xFFFFFFFF); // Draw "HH:MM:SS" text PlayerTimeTracker trckr = PlayerTimeManager.getTracker(gui.getMinecraft().player.getUUID()); LocalTime remainingTimeLT = LocalTime.ofSecondOfDay(PlayerTimeManager.getDailyTimeLimit() - trckr.getSecsPlayed()); String remainingTime = remainingTimeLT.format(DateTimeFormatter.ofPattern("HH:mm:ss")).toString(); textWidth = font.width(remainingTime); textX = x + logoxoffset + textxoffset - textWidth / 2; textY += font.lineHeight + 2; // add some space between the two lines of text font.draw(poseStack, remainingTime, textX, textY, 0xFFFFFFFF); // Draw PVP State text String pvpstate = "PVP:"; // replace with your logic to get the remaining time textWidth = font.width(pvpstate); textX = x + logoxoffset + textxoffset - textWidth / 2; textY += font.lineHeight + 8; // add some space between the two lines of text GuiComponent.drawString(poseStack, font, pvpstate, textX, textY, 0xFFFFFFFF); // Draw "OFF/ON/HARDCORE" text String statePVP = "ULTRA"; // replace with your logic to get the remaining time textWidth = font.width(statePVP); textX = x + logoxoffset + textxoffset - textWidth / 2; textY += font.lineHeight + 2; // add some space between the two lines of text font.draw(poseStack, statePVP, textX, textY, 0xFFFFFFFF); //Render the logo RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderTexture(0, TEXTURE); GuiComponent.blit(poseStack, x + logoxoffset, y + logoyoffset, 0, 0, 25, 25, 25, 25); poseStack.popPose(); poseStack.popPose(); }); } And it is registered on a separate class: @SubscribeEvent public static void registerGuiOverlays(RegisterGuiOverlaysEvent event) { event.registerAboveAll("mainoverlayid", PVPStateOverlay.HUD_MAINOVERLAY); } Any insights? I'm really scratching my head right now
-
[1.19.3] Little help regarding sides (and possibly networking)
chxr replied to chxr's topic in Modder Support
You mean CompoundTag, right? I was under the impression that they need to be synchronized manually too. I will try and get back here if i need any more help -
[1.19.3] Little help regarding sides (and possibly networking)
chxr posted a topic in Modder Support
So, I'm making a custom compass item that points to a player on the same team as the player. The problem comes in the following part of the code: int teamSize = stringTeamPlayers.size(); if (!currentWorld.isClientSide()) { //Null pointer excepction. GetPlayerList only works server side? if (teamSize == 1) { nearestPlayer = currentWorld.getServer().getPlayerList().getPlayerByName(listTeamPlayers.get(0)); } else { Random rand = new Random(); nearestPlayer = currentWorld.getServer().getPlayerList().getPlayerByName(listTeamPlayers.get(rand.nextInt(teamSize))); } distanceToItemUser = userPlayer.distanceTo(nearestPlayer); } else { //Distance and nearestPlayer are still wrongly defined on client side distanceToItemUser = 1; } So the initial problem (before I had the outermost if that makes the code only execute server-side) the session would crash with a Nullpointerexception. I guessed that getPlayerList would only work server-side and the error disappeared. The problem now is that, while the calculation is done server-side, client-side still has undefined (or rather incorrect) result for the distance and NearestPlayer. It looks like it works because I choose a value for the client-side that enters a block of code that deletes the object once the player approaches the targeted player: if (distanceToItemUser < 5) { if (!currentWorld.isClientSide()) { //Delete the item from the inventory once you approach to 5 blocks or less from the tracked player if (currentWorld.isClientSide()) { userPlayer.sendSystemMessage(Component.literal(String.format("poof"))); } Inventory inv = userPlayer.getInventory(); inv.removeItem(itemStack); } }else{ //Code that calculates the angle and changes the texture goes here } That's why it "flickers" (The animation for when the item is deleted is played, as it f it was about to be deleted but the server keeps it from doing so since it has the actual updated info) Obviously, if i change the value to something higher than 5 and let it go to the else it will throw a NullPointerException since it needs data it's only available in the server-only code. Any idea of how can I proceed with this? The main idea I have is to use packets but I'm really lost with that and I don't know if there's a simpler solution to this problem -
Textures not recognized after upgrading from 1.19.2 to 1.19.3
chxr replied to chxr's topic in Modder Support
That's where they are now, inside resources/assets/mod_id/ (unless I did not understand soomething in which case sorry) I tried changing the name from plural to singular (textures->texture, blocks->block) but still does not recognize the textures EDIT: Okay that was the error. I have come back to my mod after a month and I forgot I had to change the texture json file from plural to singular too, so you're right