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.

richaed

Members
  • Joined

  • Last visited

Everything posted by richaed

  1. Hello, im kind of a newbie on creating mods, and i been trying to make simples mods so far, Right now, i'm creating a mod which detect an specific type of mob and kill it if reach a certain number, by far the mod is detecting the mob and counting them but at the time it reach the limit number, it don't do anything. The Game don't tweak, don't crash, just i't don't run the method i call, which is kill(). public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) { final var TotalCows = pLevel.getNearbyEntities(Cow.class, TargetingConditions.forNonCombat(), pPlayer, pPlayer.getBoundingBox().inflate(5)); if(pLevel.isClientSide){ if(pPlayer.getItemInHand(InteractionHand.MAIN_HAND).getItem() == this.asItem()){ if(!TotalCows.isEmpty()){ if(TotalCows.get(0).isAlive()){ TotalCows.get(0).kill(); } }else{ pPlayer.sendSystemMessage(Component.literal("No hay vacas")); } } } The sendSystemMessage is get triggered, and when i change the method .kill() by any other like send a message it got called, can i get some tips, and a clue of what i'm missing
  2. Hi i have this custom item i made is simple, its just one that when u right-click on a mob it shows u his information, but there is two things i still didnt made up. First. When i right-click on a mob and the item is used the method is called twice occurring on a print duplication Second. I still didnt get chatFormatting Format that put my text on a column way. Here i leave my code to get helped, it just a simple one right now. public class Life_detector extends Item { public Life_detector(Properties pProperties) { super(pProperties); } @Override public boolean canAttackBlock(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer) { return false; } @Override public InteractionResult interactLivingEntity(ItemStack pStack, Player pPlayer, LivingEntity pInteractionTarget, InteractionHand pUsedHand) { if(pStack.getItem()==ModItems.LIFE_CHECKER.get()){ checkLife(pInteractionTarget,pPlayer); } return InteractionResult.SUCCESS; } private void checkLife(LivingEntity livingEntity, Player player){ if(livingEntity instanceof Mob mob){ player.sendSystemMessage(Component.literal("Name: "+mob.getName().getString()).withStyle(ChatFormatting.DARK_RED)); } } public void appendHoverText(ItemStack stack, Level world, List<Component> tooltip, TooltipFlag flag) { tooltip.add(Component.literal("Right-click to get the info of a mob").withStyle(ChatFormatting.GOLD)); super.appendHoverText(stack, world, tooltip, flag); } }

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.