stepsword
Members-
Posts
81 -
Joined
-
Last visited
Everything posted by stepsword
-
I have a string like this: "key.abc, key.def!!!" In the lang file, I have key.abc=Hello key.def=World How do I get this to show Hello, World!!! when printed? I tried doing "" + new TextComponentTranslation("key.abc") + new TextComponentTranslation("key.def") + "!!!" with no luck. Sadly those objects when printed just give an overview of the object rather than the actual translation. Is there a built-in way to get the translation?
-
Thanks! This pointed me to one of your other posts here which lists the packets. Thank you!
-
Is there a way to specifically load a faraway chunk on the client? I read the thread about Looking Glass but it's for 1.7.10 and I was wondering if there's a better way now than putting a camera in the place you want to chunk load. Specifically, I'm trying to get a single entity for the client by its entityId, given the chunk X and Z coordinates the entity is in. When the chunk is unloaded on the client you can't get any entities. I'm guessing Forge Tickets are server only - is there a client side version of this?
-
As an update: something I think wasn't immediately clear to me is that forceChunk seems to be only for chunks which are already loaded? i.e. if you call forceChunk on an unloaded chunk, nothing happens - you have to load it, then call forceChunk to keep it loaded. I haven't done a lot of testing of this theory to confirm if it's true, but based on the usage of getPersistentChunks() by Forge, I think it's true. This is in the "unload chunks" method. I guess this probably isn't a problem for most people but in case someone stumbles on this later looking for why their forceChunks on a remote location isn't working, it could be because forceChunks only prevents loaded things from being unloaded, so they have to be loaded first for forceChunks to actually work. if (!this.droppedChunksSet.isEmpty()) { for (ChunkPos forced : this.world.getPersistentChunks().keySet()) {
-
Haha - I learned that the hard way actually, while trying to get the Chunk to check isLoaded() I called getChunkAt().. which loads the chunk. That said, I do have one command planned where it would be useful to keep the chunk loaded so I'm trying to get it working with tickets for this one which will be simpler to test than the other one.
-
Still working on that load chunk -> teleport entity bit. I wanted to make sure the chunk was loaded and also have access to the variables in the function that loads the chunk. Maybe its possible without the next-tick bit though, couldn't really find information on whether forceChunk happens right away or queues the chunk up for loading
-
Ahh, thanks so much. I was already trying to come up with silly workarounds like recursively adding tasks til it gets called on the server.
-
I read on one of these threads to use addScheduledTask to do things "next tick". I call it on the server side, and it seems like the Runnable I give it only gets called on the client. Is this normal?
-
The inevitable help topic after my other thread - when I want to request tickets, if I'm requesting player tickets do I have to request them at world load? Or can I request tickets when I need them? If I request a ticket for the same player more than once will I start approaching some limit? Should I store the ticket forever once I've received it for a player? This link's advice seems to be to do it when the world loads, but that was for non-player tickets. A quick search of ForgeChunkManager.requestPlayerTicket shows some people requesting tickets in "onBlockPlacedBy" - is it ok to do that? Edit: Just found out you can "release tickets" back to the system - if I like request a ticket, hold it for a few seconds while I use it and then release it is that fine/encouraged? Edit: Also, this loading call back is a bit confusing - setForcedChunkLoadingCallback says it's "the code to call back when chunks are loaded", but the descriptions of the LoadingCallback say its "when tickets are loaded". Which is it? Do I use these as both ticket loaded callbacks AND forced chunk callbacks?
-
Yea, I think it will be not intensive based on the little I've read of chunk loading - I'm not planning to have many commands, just one or two (like teleport and blow up the nearest creature) and they're going to be very simple things that wouldn't be used in quick succession. I wasn't planning to give the player full control of the pet like "move to XYZ" or anything that would require micromanaging.
-
Even if it's just the chunk the entity is in when a player wants to give a command? I figured one chunk extra per player wouldn't be too bad since like 400 chunks are loaded for each player at a given time anyway.
-
As an update to this I think what I will do is force load the chunk of the user's stored pet when I'm issuing commands, and then replace the stored pet with the one with a matching UUID loaded in the chunk - I think that solves the major issues since I won't be teleporting things out of unloaded chunks anymore.
-
That's a good point, thanks.. Hadn't considered that. Maybe I'll add to the player capability a "last known position" for their pet and just delete it if it's not within a few blocks on the EntityJoinEvent. They're meant to be expendable anyway
-
Thanks, that makes sense - I never thought of making my own UUID and saving it. I'm trying to create behavior for a summoned pet, but I also wanted to make it possible to give the pet commands remotely, so the chunk might be unloaded when the command is given. I hadn't actually started coding anything for it cause I wanted to understand the limitations before I jumped in. I was planning to have most commands just fail for unloaded chunks, but a teleport command would be the exception for that, so I'll probably delete the entity when it joins the world if it's got a duplicate UUID of another entity. Thanks again!
-
Thanks - a couple follow ups (and yes, I did mean an instance of an Entity): If I teleport the entity out of an unloaded chunk, does the chunk automatically remove it from its "saved" data? Is there a right way to keep track of entities that may be in unloaded chunks? I was under the impression that there's no world-wide "get Entity by UUID" and the getEntityById method requires an AABB. Mainly if I have an instance of Entity *now* and I want to sync it up with the instance of Entity when the chunk is loaded later, is there a right way to do that?
-
If there's an Entity in some chunk and the chunk gets unloaded, but I'm storing a reference to the "Entity" object somewhere, what happens to the object? Can I still teleport the entity and do other entity things with it?
-
Nevermind I'm stupid and forgot to @Override to make sure the parameters are right Edit: updated code - in my defense I wrote this class when I was just starting to mod so I didn't really understand what these functions did at all. Surprised it even worked in the first place @Override public NBTTagCompound getNBTShareTag(ItemStack stack) { IScrollMahou scrollMahou = stack.getCapability(ScrollMahouProvider.MAHOU, null); NBTBase nbt = ScrollMahouProvider.MAHOU.getStorage().writeNBT(ScrollMahouProvider.MAHOU, scrollMahou, null); NBTTagCompound ret = stack.getTagCompound(); if (ret == null) ret = new NBTTagCompound(); if (nbt != null) ret.setTag("mahouCaster", nbt); return ret; } @Override public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { super.addInformation(stack, worldIn, tooltip, flagIn); IScrollMahou scrollMahou; Item item = stack.getItem(); if (item instanceof SpellScroll && stack.hasCapability(ScrollMahouProvider.MAHOU, null)) { scrollMahou = stack.getCapability(ScrollMahouProvider.MAHOU, null); if (scrollMahou != null) { String name = scrollMahou.getCasterName(); if (name != null && !name.isEmpty()) { tooltip.add("Bound to " + name); } else { tooltip.add("Bound to: ???"); } } } } @Override public void readNBTShareTag(ItemStack stack, NBTTagCompound nbtt) { IScrollMahou scrollMahou = stack.getCapability(ScrollMahouProvider.MAHOU, null); IScrollMahou serverScrollMahou = new ScrollMahou(); if (nbtt != null && nbtt.hasKey("mahouCaster")) { ScrollMahouProvider.MAHOU.getStorage().readNBT(ScrollMahouProvider.MAHOU, serverScrollMahou, null, nbtt.getTag("mahouCaster")); if (scrollMahou != null) { scrollMahou.setCasterUUID(serverScrollMahou.getCasterUUID()); scrollMahou.setCasterName(serverScrollMahou.getCasterName()); } } }
-
Creating the item: if (!world.isRemote) { ItemStack stack = getItemToGive(); if (stack != null && caster != null && caster.getUniqueID().equals(getCasterUUID())) { stack.setCount(1); //put the item in user's inventory if (stack.getItem() instanceof SpellScroll) { ((SpellScroll) stack.getItem()).getCapability(stack).setCasterUUID(caster.getUniqueID()); ((SpellScroll) stack.getItem()).getCapability(stack).setCasterName(caster.getName()); } //EntityItem itemDrop = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), stack); Block.spawnAsEntity(world, pos, stack); world.setBlockState(pos, Blocks.AIR.getDefaultState(), 3); } } NBTShareTag and tooltip: @Override public NBTTagCompound getNBTShareTag(ItemStack stack) { IScrollMahou scrollMahou = stack.getCapability(ScrollMahouProvider.MAHOU, null); NBTBase nbt = ScrollMahouProvider.MAHOU.getStorage().writeNBT(ScrollMahouProvider.MAHOU, scrollMahou, null); if (nbt == null) nbt = new NBTTagCompound(); if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound()); NBTTagCompound ret = stack.getTagCompound(); if (ret == null) ret = new NBTTagCompound(); ret.setTag("mahouCaster", nbt); return ret; } @Override public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { super.addInformation(stack, worldIn, tooltip, flagIn); IScrollMahou scrollMahou; Item item = stack.getItem(); if (item instanceof SpellScroll && stack.hasCapability(ScrollMahouProvider.MAHOU, null)) { scrollMahou = stack.getCapability(ScrollMahouProvider.MAHOU, null); if (scrollMahou != null) { String name = scrollMahou.getCasterName(); if (name != null && !name.isEmpty()) { tooltip.add("Bound to " + name); } else { tooltip.add("Bound to: ???"); } } } } public void readNBTShareTag(ItemStack stack) { if (stack.hasTagCompound()) { NBTTagCompound nbt = stack.getTagCompound(); if (nbt == null) nbt = new NBTTagCompound(); IScrollMahou scrollMahou = stack.getCapability(ScrollMahouProvider.MAHOU, null); IScrollMahou serverScrollMahou = new ScrollMahou(); if (nbt.hasKey("mahouCaster")) { ScrollMahouProvider.MAHOU.getStorage().readNBT(ScrollMahouProvider.MAHOU, serverScrollMahou, null, nbt.getTag("mahouCaster")); if (scrollMahou != null) { scrollMahou.setCasterUUID(serverScrollMahou.getCasterUUID()); scrollMahou.setCasterName(serverScrollMahou.getCasterName()); } } } }
-
[1.14.4][SOLVED] capability resets server side
stepsword replied to andGarrett's topic in Modder Support
Remote means the client - I think you are only supposed to set capability values on the server. So use !isRemote when you want to set capability values. -
I have an item capability and I'm trying to get one of the values to display on the client, in the tooltip. To do this, I overrode getNBTShareTag and readNBTShareTag to save the NBT from the capability, and this works to an extent. But when testing in LAN multiplayer, players other than the world's hosting player don't seem to have the value available to them in the tooltip, even if they create the item. Any ideas? Is NBTsharetag sufficient for this? If I put the item in a chest, it simultaneously renders properly for the host player and does not render the value for the other player. I do set the values of the capability on the server side.
-
Thanks - there was a checkbox in Run > Edit Configurations called "Allow parallel run" that fixed it
-
It just closes the one I have open and reopens Minecraft - maybe I have some setting that's wrong, I'll go check it out. Thanks