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.

TheRedWaffle

Members
  • Joined

  • Last visited

Everything posted by TheRedWaffle

  1. Have you registered the Recipe/RecipeSerializer?
  2. Ok so everything works in game but the effect display doesn't visibly show the duration changing could this be because I instantly remove and change the effect? Here's the code if (!worldIn.isRemote) { if (!entityLiving.getActivePotionEffects().isEmpty()) { Iterator<EffectInstance> itr = entityLiving.getActivePotionEffects().stream().iterator(); do { EffectInstance effectInstance = itr.next(); int duration = effectInstance.getDuration(); int amplifier = effectInstance.getAmplifier(); duration -= 600; Effect effectPotion = effectInstance.getPotion(); entityLiving.removeActivePotionEffect(effectPotion); entityLiving.addPotionEffect(new EffectInstance(effectPotion, duration, amplifier)); } while (itr.hasNext()); } }
  3. You should be able to use the 'getStateForPlacement' method found in Block.java to set the life value. This is the code I used for setting the direction of a block public BlockState getStateForPlacement(BlockItemUseContext context) { return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite()); } For your second problem maybe try using the 'interactWith' method which is found in the AbstractFurnaceBlock.java This is the code I have for a TileEntity I created protected void interactWith(World worldIn, BlockPos pos, PlayerEntity player) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof BrewerTileEntity) { player.openContainer((INamedContainerProvider)tileentity); player.addStat(Stats.INTERACT_WITH_FURNACE); } }
  4. Ugh I should have thought of that, sorry.
  5. Sweet thanks for the help. Do I need to make my own 'shouldRemove()' method? I have this right now but shouldRemove isn't a real method if (!worldIn.isRemote) { if (!entityLiving.getActivePotionEffects().isEmpty()) { Iterator<EffectInstance> itr = entityLiving.getActivePotionEffects().iterator(); do { EffectInstance effectInstance = itr.next(); int duration = effectInstance.getDuration(); int amplifier = effectInstance.getAmplifier(); duration -= 600; Effect effectPotion = effectInstance.getPotion(); if(shouldRemove(effectInstance)) { entityLiving.removeActivePotionEffect(effectPotion); entityLiving.addPotionEffect(new EffectInstance(effectPotion, duration, amplifier)); } } while (itr.hasNext()); } } Let me know if I have something wrong.
  6. Here's the error if any of you need it.
  7. So basically I am trying to make a Mug of Milk remove 30seconds(600ticks) off of every potion effect the player has. Though this causes a crash when I drink the item. (The code is located in the onItemUseFinish function) if (!worldIn.isRemote) { entityLiving.getActivePotionEffects().stream().map(EffectInstance::getEffectInstance).forEach(effect -> { int duration = effect.getDuration(); int amplifier = effect.getAmplifier(); duration -= 600; Effect effectPotion = effect.getPotion(); entityLiving.removeActivePotionEffect(effectPotion); entityLiving.addPotionEffect(new EffectInstance(effectPotion, duration, amplifier)); }); } I looked it up already and it is because in my code I remove the potion effect and then try to access it. Does anyone know a way around this?

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.