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.

1.12 how to spawn a potion with effect (regeneration/fire resistance/ect)

Featured Replies

Posted

Hello, I'm trying to spawn a Potion EntityItem with 

EntityItem potion1 = new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(),
						new PotionUtils().addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.WATER));
worldIn.spawnEntity(potion1);

But every time I perform the action that should drop me the potion I get this error:

[16:16:52] [Server thread/FATAL] [net.minecraft.server.MinecraftServer]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: net.minecraft.potion.PotionUtils: method <init>()V not found
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_222]
	at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_222]
	at net.minecraft.util.Util.func_181617_a(SourceFile:47) [h.class:?]
	at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:723) [MinecraftServer.class:?]
	at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397) [nz.class:?]
	at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) [MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
Caused by: java.lang.NoSuchMethodError: net.minecraft.potion.PotionUtils: method <init>()V not found
	at com.environment.randomdrops.events.RandomDrops.Drops(RandomDrops.java:512) ~[RandomDrops.class:?]
	at net.minecraft.block.Block.removedByPlayer(Block.java:1178) ~[aow.class:?]
	at net.minecraft.server.management.PlayerInteractionManager.removeBlock(PlayerInteractionManager.java:271) ~[or.class:?]
	at net.minecraft.server.management.PlayerInteractionManager.func_180237_b(PlayerInteractionManager.java:324) ~[or.class:?]
	at net.minecraft.server.management.PlayerInteractionManager.func_180785_a(PlayerInteractionManager.java:244) ~[or.class:?]
	at net.minecraft.network.NetHandlerPlayServer.func_147345_a(NetHandlerPlayServer.java:704) ~[pa.class:?]
	at net.minecraft.network.play.client.CPacketPlayerDigging.func_148833_a(SourceFile:40) ~[lp.class:?]
	at net.minecraft.network.play.client.CPacketPlayerDigging.func_148833_a(SourceFile:10) ~[lp.class:?]
	at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) ~[hv$1.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_222]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_222]
	at net.minecraft.util.Util.func_181617_a(SourceFile:46) ~[h.class:?]
	... 5 more

 

The 

if (!entity.world.isRemote)

exists already

  • Author
37 minutes ago, diesieben07 said:

PotionUtils.addPotionToItemStack is a static method (in fact all methods in PotionUtils are static). Why are you calling it as if it were an instance method? Your IDE should warn you about this, too.

I need it to add some potion effects to a potion itemstack for a little block that drops few items when broken for a minigame I'm creating.

if this is wrong how can I add it?

  • Author
1 hour ago, diesieben07 said:

Did you read what I said? Do you know basic Java (difference between static and instance methods)?

Oh sorry, I had the suppress warning and I didn't notice it

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.