Jump to content

chxr

Members
  • Posts

    56
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by chxr

  1. 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
  2. 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
  3. So, after reading all the "debacle" happening with the support for both minor versions, I decided to upgrade my project to 1.19.3 I managed to fix everything after upgrading forge and the mappings, everything works now except not a single texture gets recognized. This is the error it gives for all items and blocks: [00:12:28] [Worker-Main-11/WARN] [minecraft/ModelManager]: Missing textures in model chrmscmds:testitem1#inventory: minecraft:textures/atlas/blocks.png:chrmscmds:items/testitem1 I used both addcreative and buildcontents to make and use a custom creative tab (which is working) Everything else is as its supposed to work on 1.19.2 with the jsons under resources/assets/mod_id, the models themselves being recognized and blockstates working as they're supposed to. I also have stumbled upon ResourceLocation but I'm not sure if that's the way to go. Has anything changed on .3 in regard to resource locating or I'm just dumb? Thanks
  4. So, I'm having an idea which involves having a vehicle going "automatically" (no user control needed) over a rail, pretty much like the regular minecart (But mostly similar/inspired by Black Mesa Transit System from the game Half-Life) I have been searching around but I don't seem to find any useful information. Like the last question, if anyone could point me into the right direction, what should I look for or tinker with, maybe some tutorials if anybody knows some, it would be highly appreciated!
  5. Thanks for mentioning capabilites, I will definitely need it somewhere down the line. I managed to get a tickevent working after having squeezed my head for these last days. It turns out I was having problems understanding how to register the event handler using and so I was trailing off searching for other unrelated things. All I needed was to MinecraftForge.EVENT_BUS.register(this); in the item constructor instead of going around all the mumbo jumbo I was trying to make. Since the handler itself was correctly constructed and with the correct decorator, it worked immediately. I still need to figure out some other things but I think the info you provided should suffice, so thanks!
  6. Okay so, this is not an specific coding question, but rather a probably rather basic question: I'm fairly new to the minecraft modding scene. I've started to tinker around with Forge for Minecraft 1.19.2 and so right now I'm playing with items and such, and while making some random ideas I've come to a point where I want to just wait for some moments (around a sec or two) after a player has used an item. (Right now I'm doing everything on public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand){...} ) After trying thin gs like "K let's put the thread to sleep", and "What IF i create A NEW THREAD and put that to sleep" which were the easy thing to do and, obviously wrong, I find myself searching about events, and ticks and tick handlers, and while I'm familiar with the concept due to having played with datapacks and command blocks before, I'm going in blindly with Forge. If someone could point into the right direction, what should I research about, what things I could try, (maybe even point me to sources to better learn about Forge in general) that'd be greatly appreciated.
×
×
  • Create New...

Important Information

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