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.

Featured Replies

Posted

Hello, I'm trying to add configurable join effects to give to a player when he joins a world. This is my class:

@EventBusSubscriber
public class JoinEvent {

	@SubscribeEvent
	public static void onJoin(PlayerLoggedInEvent event) {
		EntityPlayer player = event.player;
		World world = player.world;
		String[] effects = ConfigHandler.joinpotions.effects;
		if (WorldHelper.isServer(world)) {
			if (effects.length > 0) {
				for (String effect : effects) {
					try {
						player.addPotionEffect(new PotionEffect(
								Potion.getPotionFromResourceLocation(effect.toUpperCase().split(",")[0]),
								Integer.valueOf(effect.split(",")[1]).intValue() * 20,
								Integer.valueOf(effect.split(",")[2]).intValue() * 20));
					} catch (NullPointerException e) {
						Messages.serverLog(Main.logger,
								"The effect \"" + effect.toLowerCase().split(",")[0] + "\" doesn't exists", 3);
					}
				}
			}
		}
	}
}

I dont know why you would be but if you want to know what is the Messages.serverLog then:

public static String serverLog(Logger logger, String message, Integer level) {
		if (level == 0) {
			logger.info(message);
		} else if (level == 1) {
			logger.warn(message);
		} else if (level == 2) {
			logger.error(message);
		} else if (level == 3) {
			logger.fatal(message);
		} else {
			logger.fatal("The error level (" + level
					+ ") selected is not recognized, You can select:\n0: Info\n1: Warn\n2: Error\n3: Fatal");
		}
		return message;
	}

 

My default effects are:

public String[] effects = { "minecraft:regeneration,60,1", "minecraft:resistance,60,1" };

and it works but when I try to add something like: (is an example)

notminecraft:notregeneration

The error that says that the effect doesn't exist works but after the game crash with

[09:12:15] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Ticking player
	at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:212) ~[NetworkSystem.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865) ~[MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) ~[MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) ~[IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_221]
Caused by: java.lang.NullPointerException
	at net.minecraft.potion.PotionEffect.onUpdate(PotionEffect.java:127) ~[PotionEffect.class:?]
	at net.minecraft.entity.EntityLivingBase.updatePotionEffects(EntityLivingBase.java:688) ~[EntityLivingBase.class:?]
	at net.minecraft.entity.EntityLivingBase.onEntityUpdate(EntityLivingBase.java:406) ~[EntityLivingBase.class:?]
	at net.minecraft.entity.Entity.onUpdate(Entity.java:466) ~[Entity.class:?]
	at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2315) ~[EntityLivingBase.class:?]
	at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:272) ~[EntityPlayer.class:?]
	at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423) ~[EntityPlayerMP.class:?]
	at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185) ~[NetHandlerPlayServer.class:?]
	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212) ~[NetworkDispatcher$1.class:?]
	at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307) ~[NetworkManager.class:?]
	at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197) ~[NetworkSystem.class:?]
	... 5 more
[09:12:15] [Server thread/ERROR] [minecraft/MinecraftServer]: This crash report has been saved to: C:\Users\cpiva\Documents\GitHub\CrisCore\run\.\crash-reports\crash-2019-11-13_09.12.15-server.txt
[09:12:15] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server
[09:12:15] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players
[09:12:15] [Server thread/ERROR] [minecraft/MinecraftServer]: Exception stopping the server
net.minecraft.util.ReportedException: Saving entity NBT
	at net.minecraft.entity.Entity.writeToNBT(Entity.java:1988) ~[Entity.class:?]
	at net.minecraft.server.integrated.IntegratedPlayerList.writePlayerData(IntegratedPlayerList.java:30) ~[IntegratedPlayerList.class:?]
	at net.minecraft.server.management.PlayerList.saveAllPlayerData(PlayerList.java:1000) ~[PlayerList.class:?]
	at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:493) ~[MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:413) ~[IntegratedServer.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:645) [MinecraftServer.class:?]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_221]
Caused by: java.lang.NullPointerException
	at net.minecraft.potion.PotionEffect.getCurativeItems(PotionEffect.java:286) ~[PotionEffect.class:?]
	at net.minecraft.potion.PotionEffect.writeCurativeItems(PotionEffect.java:333) ~[PotionEffect.class:?]
	at net.minecraft.potion.PotionEffect.writeCustomPotionEffectToNBT(PotionEffect.java:219) ~[PotionEffect.class:?]
	at net.minecraft.entity.EntityLivingBase.writeEntityToNBT(EntityLivingBase.java:614) ~[EntityLivingBase.class:?]
	at net.minecraft.entity.player.EntityPlayer.writeEntityToNBT(EntityPlayer.java:1021) ~[EntityPlayer.class:?]
	at net.minecraft.entity.player.EntityPlayerMP.writeEntityToNBT(EntityPlayerMP.java:275) ~[EntityPlayerMP.class:?]
	at net.minecraft.entity.Entity.writeToNBT(Entity.java:1959) ~[Entity.class:?]
	... 6 more
[09:12:16] [Server thread/INFO] [FML]: Applying holder lookups
[09:12:16] [Server thread/INFO] [FML]: Holder lookups appliedjava.lang.NullPointerException: Ticking player
	at net.minecraft.potion.PotionEffect.onUpdate(PotionEffect.java:127)
	at net.minecraft.entity.EntityLivingBase.updatePotionEffects(EntityLivingBase.java:688)
	at net.minecraft.entity.EntityLivingBase.onEntityUpdate(EntityLivingBase.java:406)
	at net.minecraft.entity.Entity.onUpdate(Entity.java:466)
	at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2315)
	at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:272)
	at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423)
	at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185)
	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212)
	at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307)
	at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197)
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592)
	at java.lang.Thread.run(Unknown Source)

 

Edited by NoHaxJustLegit

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.