Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

sirfredrick

Members
  • Joined

  • Last visited

  1. The ItemStack is always an Air ItemStack unless I access it with armorItemInStack() instead of getStackInSlot() from the player inventory. If the capability is empty or not there it doesn't get added. I just need to know a way to grab the ItemStacks in the Armor Slots from the Player's Inventory that is not a Client Only method.
  2. I've added the orElseThrow and it throws an exception when player.inventory.getStackInSlot() is called instead of player.inventory.armorItemInSlot(). What are the armor slotIds when accessing player.inventory? I've tried both 5-8 and 100-103 but both return Air ItemStacks.
  3. I'm trying to check a player's armor inventory to see if my custom Armor currently has a capability attached to it. If it does in another event I give the player an effect. This works fine in SInglePlayer. However, when I run it in a Dedicated Server, the events are out of sync so the Client Player can see the armor and get the capabilities but the Server Player just returns 0. Is there a better way to get the Player's Armor as an ItemStack? I've tried packets but there's no simple way to return them and putting the information in the Player's Persistent Data causes worse desync problems. I know that player.inventory.armorItemInSlot() can only be run on Client but when I use player.inventory.armorInventory.get() or player.inventory.getStackInSlot() instead it doesn't work on Server. public double getPlayerGemStrength(PlayerEntity player, String attribute) { double fullStrength = 0; for (int i = 0; i < 4; i++) { ItemStack armor; armor = player.inventory.armorItemInSlot(3 - i); LazyOptional<ISlottedArmor> armorCapability = armor.getCapability(SlottedArmorProvider.ARMOR_CAPABILITY); ISlottedArmor armorInstance = armorCapability.orElse(new SlottedArmorInstance()); ItemStack gem = armorInstance.getGem(); if (gem != null) { LazyOptional<IGem> gemCapability = gem.getCapability(GemProvider.GEM_CAPABILITY); IGem gemInstance = gemCapability.orElse(new GemInstance()); String gemAttribute = gemInstance.getAttribute(); double strength = gemInstance.getStrength(); if (gemAttribute != null && !gemAttribute.equals("")) { if (gemAttribute.equals(attribute)) { fullStrength += strength; } } } } return fullStrength; } Here is an example effect: @SubscribeEvent public void giveEffects(PlayerEvent event) { if (event.getPlayer() != null) { PlayerEntity player = event.getPlayer(); double fullStrength = getPlayerGemStrength(player, "HP Up"); if (fullStrength > 0) { MaxHealthHandler.updateHealthModifier(player, fullStrength); } else { MaxHealthHandler.updateHealthModifier(player, 0); } } }
  4. Thanks I just needed someone else to check it! I was using a Docker container to run it before. I ran a fresh server and it worked perfectly! It must have been something with the Docker container or a setting in the config file! Thanks for helping!
  5. I am trying to use World Capabilities to save data for all Players. It is currently working fine on the Client side. However, when I run it on a Dedicated Server, the event is never called. I even put a print statement to make sure that the event wasn't running. Is there another event I should use? How should I go about this? @SubscribeEvent public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) { System.out.println("Player Logged in"); ServerPlayerEntity player = (ServerPlayerEntity) event.getPlayer(); ServerWorld world = player.getServerWorld(); LazyOptional<ICrystalLevel> crystalLevelCapability = world.getCapability(CrystalLevelProvider.CRYSTAL_LEVEL_CAPABILITY); ICrystalLevel crystalLevelInstance = crystalLevelCapability.orElse(new CrystalLevelInstance()); crystalLevelInstance.setCrystalLevel(crystalLevel); player.getPersistentData().putInt("crystal_level", crystalLevel); SendAffinityToClientPlayer msg = new SendAffinityToClientPlayer(player.getUniqueID().toString(), crystalLevel); EtherGems.simpleChannel.send(PacketDistributor.PLAYER.with(() -> player), msg); }

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.