Jump to content

NoHaxJustLegit

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by NoHaxJustLegit

  1. 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)
  2. I know, I wanted to add how much saturation a food gives based on 20 food level (max) like AppleSkin does with the yellow food level border when food is held. If it's useless then I'll just add the food level
  3. Just to be sure, you know I want to know how much saturation a food gives right? like AppleSkin does Example: If a cooked beef gives you 3 saturation points (1.5 as hunger shanks) it should say 1.5
  4. But the value is private Tried this but public static final Field saturationLevel = ReflectionHelper.findField(FoodStats.class, "field_75125_b", "foodSaturationLevel"); try { tooltip.add("§2Saturation level: §a" + saturationLevel.getFloat("foodSaturationLevel"))); } catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } java.lang.IllegalArgumentException: Can not set float field net.minecraft.util.FoodStats.foodSaturationLevel to java.lang.String
  5. tooltip.add("§2Saturation level: §a"+ Math.min(5F + heal * saturation * 2.0F, heal)); 5F is from foodSaturationLevel inside FoodStats class, is it correct?
  6. Hello, I'm trying to add the saturation level and the food heal that a fooditem gives. @SideOnly(Side.CLIENT) public class FoodNutrition { private static final KeyBinding keyBindSneak = Minecraft.getMinecraft().gameSettings.keyBindSneak; @SubscribeEvent public void onTooltipDisplayed(ItemTooltipEvent event) { if (event.getEntityPlayer() == null) { return; } if (!event.getItemStack().isEmpty() && event.getItemStack().getItem() instanceof ItemFood) { Item item = event.getItemStack().getItem(); ItemStack stack = event.getItemStack(); final List<String> tooltip = event.getToolTip(); float heal = ((ItemFood) item).getHealAmount(stack); float saturation = ((ItemFood) item).getSaturationModifier(stack); System.out.print("\nSat: " + event.getEntityPlayer().getFoodStats().getSaturationLevel() + "\nFood: " + event.getEntityPlayer().getFoodStats().getFoodLevel()); if (GameSettings.isKeyDown(keyBindSneak)) { tooltip.add("&2Food level: &a" + (heal / 2)); tooltip.add("&2Saturation level: &a"+ saturation); } else { tooltip.add(Messages.color("Press shift")); } } } } The cooked chicken gives Food Level: 6.0 restoring 6 points and its correct and Saturation level gives me 0.6 and the print gives: Sat: 6.0 Food: 6 is there a better way to get/show how many heal points (not hearts) and saturation points a food gives? I think my only problem is Saturation level which gives me a 0.x number
  7. I've tried to set the base value to 50 like this: player.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).setBaseValue(50); (default is 4) but the player dig/attack like if has 4
  8. Hello, I'm creating a helmet that gives the same effect that gives haste without adding haste (I don't like to see it) but using: @SubscribeEvent public static void onUse(PlayerTickEvent event) { EntityPlayer player = (EntityPlayer) event.player; World world = player.world; ItemStack head = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); double speed = player.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).getBaseValue(); if (!world.isRemote) { player.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).setBaseValue(speed + 0.321903904932D); //as test } } But obviously, after some time, it prints "Infinity" and the attack speed doesn't change
×
×
  • Create New...

Important Information

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