diff --git a/src/main/java/thebetweenlands/client/gui/GuiFishStaminaBar.java b/src/main/java/thebetweenlands/client/gui/GuiFishStaminaBar.java index 4c08e7a1c..5570e7ac7 100644 --- a/src/main/java/thebetweenlands/client/gui/GuiFishStaminaBar.java +++ b/src/main/java/thebetweenlands/client/gui/GuiFishStaminaBar.java @@ -28,39 +28,45 @@ public class GuiFishStaminaBar extends Gui { @SubscribeEvent public void onRenderHUD(RenderGameOverlayEvent.Post event) { Minecraft mc = Minecraft.getMinecraft(); - if (event.getType().equals(RenderGameOverlayEvent.ElementType.HOTBAR)) { - EntityPlayerSP player = mc.player; - if (player != null && player.fishEntity != null && player.fishEntity instanceof EntityBLFishHook) { - if (player.fishEntity.isRiding() && player.fishEntity.getRidingEntity() instanceof EntityAnadia) { + if (!event.getType().equals(RenderGameOverlayEvent.ElementType.HOTBAR)) { + return; + } + + EntityPlayerSP player = mc.player; + if (player == null || player.fishEntity == null || player.fishEntity instanceof EntityBLFishHook == false) { + return; + } + + if (player.fishEntity.isRiding() && player.fishEntity.getRidingEntity() instanceof EntityAnadia) { + + final EntityAnadia fish = ((EntityAnadia) player.fishEntity.getRidingEntity()); - int fishpos = ((EntityAnadia) player.fishEntity.getRidingEntity()).getStaminaTicks() * 256 / 180; - int escapepos = ((EntityAnadia) player.fishEntity.getRidingEntity()).getEscapeTicks() * 256 / 1024; - int helpMe = (int) ((EntityAnadia) player.fishEntity.getRidingEntity()).getStaminaMods() * 30; - int escapeDelay = ((EntityAnadia) player.fishEntity.getRidingEntity()).getEscapeDelay(); - int obstructpos1 = ((EntityAnadia) player.fishEntity.getRidingEntity()).getObstruction1Ticks(); - int obstructpos2 = ((EntityAnadia) player.fishEntity.getRidingEntity()).getObstruction2Ticks(); - int obstructpos3 = ((EntityAnadia) player.fishEntity.getRidingEntity()).getObstruction3Ticks(); - int obstructpos4 = ((EntityAnadia) player.fishEntity.getRidingEntity()).getObstruction4Ticks() * 256 / 512; - int treasurePos = ((EntityAnadia) player.fishEntity.getRidingEntity()).getTreasureTicks() * 256 / 1024; - boolean showTreasure = ((EntityAnadia) player.fishEntity.getRidingEntity()).isTreasureFish(); - boolean treasureUnlocked = ((EntityAnadia) player.fishEntity.getRidingEntity()).getTreasureUnlocked(); - int aniFrame = ((EntityAnadia) player.fishEntity.getRidingEntity()).animationFrame; - int aniFrameCrab = ((EntityAnadia) player.fishEntity.getRidingEntity()).animationFrameCrab; - - mc.renderEngine.bindTexture(GUI_TEXTURE); - - GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); - GlStateManager.enableAlpha(); - GlStateManager.enableBlend(); - GlStateManager.color(1F, 1F, 1F, 1F); - - ScaledResolution res = new ScaledResolution(mc); - if(((EntityAnadia) player.fishEntity.getRidingEntity()).getStaminaTicks() <= 0) - renderNetBar((float)res.getScaledWidth() * 0.5F - 128F, (float)res.getScaledHeight() * 0.5F - 120F, 240, 4, aniFrame); - else - renderStaminaBar(-256 + fishpos, -256 + Math.min(256, escapepos), escapeDelay < 10 ? escapeDelay: 10, 0 - obstructpos1, 0 - obstructpos2, 0 - obstructpos3, 0 - obstructpos4, 0 - treasurePos, showTreasure, treasureUnlocked, (float)res.getScaledWidth() * 0.5F - 128F, (float)res.getScaledHeight() * 0.5F - 120F, aniFrame, aniFrameCrab); - } - } + int fishpos = fish.getStaminaTicks() * 256 / 180; + int escapepos = fish.getEscapeTicks() * 256 / 1024; + int helpMe = (int) fish.getStaminaMods() * 30; + int escapeDelay = fish.getEscapeDelay(); + int obstructpos1 = fish.getObstruction1Ticks(); + int obstructpos2 = fish.getObstruction2Ticks(); + int obstructpos3 = fish.getObstruction3Ticks(); + int obstructpos4 = fish.getObstruction4Ticks() * 256 / 512; + int treasurePos = fish.getTreasureTicks() * 256 / 1024; + boolean showTreasure = fish.isTreasureFish(); + boolean treasureUnlocked = fish.getTreasureUnlocked(); + int aniFrame = fish.animationFrame; + int aniFrameCrab = fish.animationFrameCrab; + + mc.renderEngine.bindTexture(GUI_TEXTURE); + + GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + GlStateManager.enableAlpha(); + GlStateManager.enableBlend(); + GlStateManager.color(1F, 1F, 1F, 1F); + + ScaledResolution res = new ScaledResolution(mc); + if(fish.getStaminaTicks() <= 0) + renderNetBar((float)res.getScaledWidth() * 0.5F - 128F, (float)res.getScaledHeight() * 0.5F - 120F, 240, 4, aniFrame); + else + renderStaminaBar(-256 + fishpos, -256 + Math.min(256, escapepos), escapeDelay < 10 ? escapeDelay: 10, 0 - obstructpos1, 0 - obstructpos2, 0 - obstructpos3, 0 - obstructpos4, 0 - treasurePos, showTreasure, treasureUnlocked, (float)res.getScaledWidth() * 0.5F - 128F, (float)res.getScaledHeight() * 0.5F - 120F, aniFrame, aniFrameCrab); } } diff --git a/src/main/java/thebetweenlands/common/entity/mobs/EntityDreadfulMummy.java b/src/main/java/thebetweenlands/common/entity/mobs/EntityDreadfulMummy.java index cfa49e11b..779672ef4 100644 --- a/src/main/java/thebetweenlands/common/entity/mobs/EntityDreadfulMummy.java +++ b/src/main/java/thebetweenlands/common/entity/mobs/EntityDreadfulMummy.java @@ -343,67 +343,78 @@ protected boolean isBridgableSpot(BlockPos pos) { protected void placeBridge() { Path path = this.getNavigator().getPath(); - if(path != null && path.getCurrentPathIndex() < path.getCurrentPathLength()) { - PathPoint nextPoint = path.getPathPointFromIndex(path.getCurrentPathIndex()); - - if(nextPoint.y == MathHelper.floor(this.posY + 0.5f)) { - BlockPos pos = new BlockPos(this); - pos = pos.add(0, nextPoint.y - pos.getY() - 1, 0); - - if(this.getDistanceSq(pos) <= 2 && this.isBridgableSpot(pos)) { - if(ForgeEventFactory.getMobGriefingEvent(this.world, this)) { - - int nx = -2; - int nz = -2; - - if(path.getCurrentPathIndex() < path.getCurrentPathLength() - 1) { - PathPoint secondNextPoint = path.getPathPointFromIndex(path.getCurrentPathIndex() + 1); - nx = MathHelper.clamp(secondNextPoint.x - nextPoint.x, -1, 1); - nz = MathHelper.clamp(secondNextPoint.z - nextPoint.z, -1, 1); - if(nx == 0) nx = -2; - if(nz == 0) nz = -2; - } - - for(int xo = -1; xo <= 1; xo++) { - for(int zo = -1; zo <= 1; zo++) { - if(xo != nx && zo != nz) { - BlockPos offsetPos = pos.add(xo, 0, zo); - - if(this.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(offsetPos), e -> e != this).isEmpty() && this.isBridgableSpot(offsetPos)) { + if(path == null || path.getCurrentPathIndex() >= path.getCurrentPathLength()) { + return; + } + + PathPoint nextPoint = path.getPathPointFromIndex(path.getCurrentPathIndex()); + if(nextPoint.y != MathHelper.floor(this.posY + 0.5f)) { + return; + } + + + BlockPos pos = new BlockPos(this); + pos = pos.add(0, nextPoint.y - pos.getY() - 1, 0); - boolean canReplace = false; + if(this.getDistanceSq(pos) > 2 || !this.isBridgableSpot(pos)) { + return; + } + + if(!ForgeEventFactory.getMobGriefingEvent(this.world, this)) { + return; + } + + int nx = -2; + int nz = -2; + + if(path.getCurrentPathIndex() < path.getCurrentPathLength() - 1) { + PathPoint secondNextPoint = path.getPathPointFromIndex(path.getCurrentPathIndex() + 1); + nx = MathHelper.clamp(secondNextPoint.x - nextPoint.x, -1, 1); + nz = MathHelper.clamp(secondNextPoint.z - nextPoint.z, -1, 1); + if(nx == 0) nx = -2; + if(nz == 0) nz = -2; + } - if(this.world.getBlockState(offsetPos).getBlock().isReplaceable(this.world, offsetPos)) { - canReplace = true; - } else { - IBlockState hitState = this.world.getBlockState(offsetPos); - float hardness = hitState.getBlockHardness(this.world, offsetPos); + for(int xo = -1; xo <= 1; xo++) { + for(int zo = -1; zo <= 1; zo++) { + if(xo == nx || zo == nz) { + continue; + } + + + BlockPos offsetPos = pos.add(xo, 0, zo); - if(hardness >= 0 - && hitState.getBlock().canEntityDestroy(hitState, this.world, offsetPos, this) - && ForgeEventFactory.onEntityDestroyBlock(this, offsetPos, hitState)) { + if(!(this.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(offsetPos), e -> e != this).isEmpty()) || !this.isBridgableSpot(offsetPos)) { + continue; + } + + boolean canReplace = false; - canReplace = true; - if(!hitState.getMaterial().isLiquid() && hitState.getCollisionBoundingBox(this.world, pos) != null) { - this.world.playEvent(2001, offsetPos, Block.getStateId(hitState)); - } - this.world.setBlockToAir(offsetPos); - } - } + if(this.world.getBlockState(offsetPos).getBlock().isReplaceable(this.world, offsetPos)) { + canReplace = true; + } else { + IBlockState hitState = this.world.getBlockState(offsetPos); + float hardness = hitState.getBlockHardness(this.world, offsetPos); - if(canReplace) { - this.world.setBlockState(offsetPos, BlockRegistry.PEAT.getDefaultState()); - } + if(hardness >= 0 + && hitState.getBlock().canEntityDestroy(hitState, this.world, offsetPos, this) + && ForgeEventFactory.onEntityDestroyBlock(this, offsetPos, hitState)) { - } - } - } + canReplace = true; + if(!hitState.getMaterial().isLiquid() && hitState.getCollisionBoundingBox(this.world, pos) != null) { + this.world.playEvent(2001, offsetPos, Block.getStateId(hitState)); } - + this.world.setBlockToAir(offsetPos); } } + + if(canReplace) { + this.world.setBlockState(offsetPos, BlockRegistry.PEAT.getDefaultState()); + } } } + + } @Override @@ -1081,4 +1092,4 @@ public int getMusicLayer(EntityPlayer listener) { public UUID getBossInfoUuid() { return dataManager.get(BOSSINFO_ID).or(new UUID(0, 0)); } -} \ No newline at end of file +} diff --git a/src/main/java/thebetweenlands/common/entity/mobs/EntityJellyfishCave.java b/src/main/java/thebetweenlands/common/entity/mobs/EntityJellyfishCave.java index 8d7a9b7f8..7b0bb26ad 100644 --- a/src/main/java/thebetweenlands/common/entity/mobs/EntityJellyfishCave.java +++ b/src/main/java/thebetweenlands/common/entity/mobs/EntityJellyfishCave.java @@ -43,31 +43,41 @@ protected void checkAndPerformAttack(EntityLivingBase enemy, double distToEnemyS this.tasks.addTask(2, new EntityAIWander(this, 0.5D, 20)); this.targetTasks.addTask(0, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, true)); } + + private void tryDamagingTarget() { + if(this.world.getDifficulty() == EnumDifficulty.PEACEFUL) { + return; + } + + EntityLivingBase target = this.getAttackTarget(); - @Override - public void onUpdate() { - super.onUpdate(); - - if(this.world.getDifficulty() != EnumDifficulty.PEACEFUL) { - EntityLivingBase target = this.getAttackTarget(); - - if(target != null) { - double dst = this.getDistance(target); + if(target == null) { + return; + } + + double dst = this.getDistance(target); - if(dst < 6.0f && this.world.rand.nextInt(20) == 0) { - this.world.setEntityState(this, EVENT_SPARK); - } + if(dst < 6.0f && this.world.rand.nextInt(20) == 0) { + this.world.setEntityState(this, EVENT_SPARK); + } - if(dst < 3.0f && this.ticksExisted % 20 == 0) { - if(canEntityBeSeen(target) && target.isInWater()) { - this.world.spawnEntity(new EntityShock(this.world, this, this, (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.75f, true)); - getEntityWorld().playSound(null, getPosition(), SoundRegistry.JELLYFISH_ZAP, SoundCategory.HOSTILE, 1F, 0.8F + rand.nextFloat()); - } - } + if(dst < 3.0f && this.ticksExisted % 20 == 0) { + if(canEntityBeSeen(target) && target.isInWater()) { + this.world.spawnEntity(new EntityShock(this.world, this, this, (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.75f, true)); + getEntityWorld().playSound(null, getPosition(), SoundRegistry.JELLYFISH_ZAP, SoundCategory.HOSTILE, 1F, 0.8F + rand.nextFloat()); } } } + @Override + public void onUpdate() { + super.onUpdate(); + + tryDamagingTarget(); + + //other AI goes here + } + @SideOnly(Side.CLIENT) @Override public void handleStatusUpdate(byte id) { @@ -81,18 +91,21 @@ public void handleStatusUpdate(byte id) { @SideOnly(Side.CLIENT) private void spawnLightningArcs() { Entity view = Minecraft.getMinecraft().getRenderViewEntity(); - if(view != null && view.getDistance(this) < 16) { - float ox = this.world.rand.nextFloat() - 0.5f + (float)this.motionX; - float oy = this.world.rand.nextFloat() - 0.5f + (float)this.motionY; - float oz = this.world.rand.nextFloat() - 0.5f + (float)this.motionZ; + if(view == null || view.getDistance(this) > 16) { + return; + } + + + float ox = this.world.rand.nextFloat() - 0.5f + (float)this.motionX; + float oy = this.world.rand.nextFloat() - 0.5f + (float)this.motionY; + float oz = this.world.rand.nextFloat() - 0.5f + (float)this.motionZ; - Particle particle = BLParticles.LIGHTNING_ARC.create(this.world, this.posX, this.posY + this.height * 0.5f, this.posZ, - ParticleArgs.get() - .withMotion(this.motionX, this.motionY, this.motionZ) - .withColor(0.3f, 0.5f, 1.0f, 0.9f) - .withData(new Vec3d(this.posX + ox, this.posY + this.height * 0.5f + oy, this.posZ + oz))); + Particle particle = BLParticles.LIGHTNING_ARC.create(this.world, this.posX, this.posY + this.height * 0.5f, this.posZ, + ParticleArgs.get() + .withMotion(this.motionX, this.motionY, this.motionZ) + .withColor(0.3f, 0.5f, 1.0f, 0.9f) + .withData(new Vec3d(this.posX + ox, this.posY + this.height * 0.5f + oy, this.posZ + oz))); - BatchedParticleRenderer.INSTANCE.addParticle(DefaultParticleBatches.BEAM, particle); - } + BatchedParticleRenderer.INSTANCE.addParticle(DefaultParticleBatches.BEAM, particle); } } diff --git a/src/main/java/thebetweenlands/common/handler/FoodSicknessHandler.java b/src/main/java/thebetweenlands/common/handler/FoodSicknessHandler.java index 6f167678d..42382cd22 100644 --- a/src/main/java/thebetweenlands/common/handler/FoodSicknessHandler.java +++ b/src/main/java/thebetweenlands/common/handler/FoodSicknessHandler.java @@ -1,5 +1,7 @@ package thebetweenlands.common.handler; +import javax.annotation.Nullable; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; @@ -46,6 +48,16 @@ public static boolean isFoodSicknessEnabled(World world) { return false; } + public static @Nullable IFoodSicknessCapability getCapabilityIfValid(@Nullable EntityPlayer player, @Nullable ItemStack itemStack) { + //if valid, return capability + if (player != null && itemStack != null && !itemStack.isEmpty() && FoodSicknessHandler.isFoodSicknessEnabled(event.getEntity().getEntityWorld()) && itemStack.getItem() instanceof IFoodSicknessItem && ((IFoodSicknessItem)itemStack.getItem()).canGetSickOf(player, itemStack)) { + //If null, well, it returns null, otherwise return the capability + return player.getCapability(CapabilityRegistry.CAPABILITY_FOOD_SICKNESS, null); + } + //return null if invalid + return null; + } + @SideOnly(Side.CLIENT) @SubscribeEvent public static void onClientTick(ClientTickEvent event) { @@ -72,15 +84,13 @@ public static void onStartItemUse(LivingEntityUseItemEvent.Start event) { EntityPlayer player = event.getEntity() instanceof EntityPlayer ? (EntityPlayer) event.getEntity() : null; ItemStack itemStack = event.getItem(); - if (player != null && !itemStack.isEmpty() && FoodSicknessHandler.isFoodSicknessEnabled(event.getEntity().getEntityWorld()) && itemStack.getItem() instanceof IFoodSicknessItem && ((IFoodSicknessItem)itemStack.getItem()).canGetSickOf(player, itemStack)) { - IFoodSicknessCapability cap = player.getCapability(CapabilityRegistry.CAPABILITY_FOOD_SICKNESS, null); - if(cap != null) { - Item item = itemStack.getItem(); - FoodSickness sickness = cap.getSickness(item); + IFoodSicknessCapability cap = FoodSicknessHandler.getCapabilityIfValid(player, itemStack); + if(cap != null) { + Item item = itemStack.getItem(); + FoodSickness sickness = cap.getSickness(item); - if(player.world.isRemote && sickness == FoodSickness.SICK) { - addSicknessMessage(player, itemStack, sickness); - } + if(player.world.isRemote && sickness == FoodSickness.SICK) { + addSicknessMessage(player, itemStack, sickness); } } } @@ -88,80 +98,84 @@ public static void onStartItemUse(LivingEntityUseItemEvent.Start event) { @SubscribeEvent(priority = EventPriority.LOW) public static void onUseItemTick(LivingEntityUseItemEvent.Tick event) { //Check if item will be consumed this tick - if(!event.getEntityLiving().getEntityWorld().isRemote && event.getDuration() <= 1) { - EntityPlayer player = event.getEntity() instanceof EntityPlayer ? (EntityPlayer) event.getEntity() : null; - ItemStack itemStack = event.getItem(); + if(event.getEntityLiving().getEntityWorld().isRemote || event.getDuration() > 1) { + return; + } + + EntityPlayer player = event.getEntity() instanceof EntityPlayer ? (EntityPlayer) event.getEntity() : null; + ItemStack itemStack = event.getItem(); - if (player != null && !itemStack.isEmpty() && FoodSicknessHandler.isFoodSicknessEnabled(event.getEntity().getEntityWorld()) && itemStack.getItem() instanceof IFoodSicknessItem && ((IFoodSicknessItem)itemStack.getItem()).canGetSickOf(player, itemStack)) { - IFoodSicknessCapability cap = player.getCapability(CapabilityRegistry.CAPABILITY_FOOD_SICKNESS, null); - if(cap != null) { - Item item = itemStack.getItem(); + IFoodSicknessCapability cap = FoodSicknessHandler.getCapabilityIfValid(player, itemStack); + if(cap == null) { + return; + } - FoodSickness lastSickness = cap.getLastSickness(); - int prevFoodHatred = cap.getFoodHatred(item); - FoodSickness currentSickness = cap.getSickness(item); + Item item = itemStack.getItem(); - if(player.world.isRemote) { - if(currentSickness != lastSickness && lastSickness == FoodSickness.SICK) { - addSicknessMessage(player, itemStack, currentSickness); - } - } + FoodSickness lastSickness = cap.getLastSickness(); + + int prevFoodHatred = cap.getFoodHatred(item); + FoodSickness currentSickness = cap.getSickness(item); + + if(player.world.isRemote) { + if(currentSickness != lastSickness && lastSickness == FoodSickness.SICK) { + addSicknessMessage(player, itemStack, currentSickness); + } + } + + int sicknessIncrease = 5; - int sicknessIncrease = 5; - - if(currentSickness == FoodSickness.SICK) { - if(item instanceof ItemFood) { - int foodLevel = ((ItemFood)itemStack.getItem()).getHealAmount(itemStack); - double foodLoss = 1.0D / 3.0D * 2.0; - - if(player.world.isRemote) { - //Remove all gained food on client side and wait for sync - player.getFoodStats().addStats(-Math.min(MathHelper.ceil(foodLevel * foodLoss), foodLevel), 0.0F); - } else { - int minFoodGain = player.world.rand.nextInt(4) == 0 ? 1 : 0; - player.getFoodStats().addStats(-Math.min(MathHelper.ceil(foodLevel * foodLoss), Math.max(foodLevel - minFoodGain, 0)), 0.0F); - } - } - - DecayFoodStats decayFoodStats = OverworldItemHandler.getDecayFoodStats(itemStack); - if(decayFoodStats != null) { - IDecayCapability decayCap = player.getCapability(CapabilityRegistry.CAPABILITY_DECAY, null); - if(decayCap != null) { - int decayLevel = decayFoodStats.decay; - DecayStats decayStats = decayCap.getDecayStats(); - double decayLoss = 1.0D / 3.0D * 2.0; - - if (player.world.isRemote) { - //Remove all gained decay on client side and wait for sync - decayStats.addStats(-Math.min(MathHelper.ceil(decayLevel * decayLoss), decayLevel), 0.0F); - } else { - int minDecayGain = player.world.rand.nextInt(4) == 0 ? 1 : 0; - decayStats.addStats(-Math.min(MathHelper.ceil(decayLevel * decayLoss), Math.max(decayLevel - minDecayGain, 0)), 0.0F); - } - } - } - - if(!player.world.isRemote) { - cap.increaseFoodHatred(item, sicknessIncrease, 0); - } + //Nerf food if you're fully sick of it + if(currentSickness == FoodSickness.SICK) { + if(item instanceof ItemFood) { + int foodLevel = ((ItemFood)itemStack.getItem()).getHealAmount(itemStack); + double foodLoss = 2.0D / 3.0D; + + if(player.world.isRemote) { + //Remove all gained food on client side and wait for sync + player.getFoodStats().addStats(-Math.min(MathHelper.ceil(foodLevel * foodLoss), foodLevel), 0.0F); + } else { + int minFoodGain = player.world.rand.nextInt(4) == 0 ? 1 : 0; + player.getFoodStats().addStats(-Math.min(MathHelper.ceil(foodLevel * foodLoss), Math.max(foodLevel - minFoodGain, 0)), 0.0F); + } + } + + DecayFoodStats decayFoodStats = OverworldItemHandler.getDecayFoodStats(itemStack); + if(decayFoodStats != null) { + IDecayCapability decayCap = player.getCapability(CapabilityRegistry.CAPABILITY_DECAY, null); + if(decayCap != null) { + int decayLevel = decayFoodStats.decay; + DecayStats decayStats = decayCap.getDecayStats(); + double decayLoss = 2.0D / 3.0D; + + if (player.world.isRemote) { + //Remove all gained decay on client side and wait for sync + decayStats.addStats(-Math.min(MathHelper.ceil(decayLevel * decayLoss), decayLevel), 0.0F); } else { - if(!player.world.isRemote) { - cap.increaseFoodHatred(item, sicknessIncrease, prevFoodHatred <= 2 * 5 ? 4 : 3); - } + int minDecayGain = player.world.rand.nextInt(4) == 0 ? 1 : 0; + decayStats.addStats(-Math.min(MathHelper.ceil(decayLevel * decayLoss), Math.max(decayLevel - minDecayGain, 0)), 0.0F); } + } + } - FoodSickness newSickness = cap.getSickness(item); + if(!player.world.isRemote) { + cap.increaseFoodHatred(item, sicknessIncrease, 0); + } + } else { + if(!player.world.isRemote) { + cap.increaseFoodHatred(item, sicknessIncrease, prevFoodHatred <= 2 * 5 ? 4 : 3); + } + } - if(!player.world.isRemote && player instanceof EntityPlayerMP) { - if(newSickness != lastSickness) { - TheBetweenlands.networkWrapper.sendTo(new MessageShowFoodSicknessLine(itemStack, newSickness), (EntityPlayerMP) player); - } - } + FoodSickness newSickness = cap.getSickness(item); - cap.setLastSickness(newSickness); - } + if(!player.world.isRemote && player instanceof EntityPlayerMP) { + if(newSickness != lastSickness) { + TheBetweenlands.networkWrapper.sendTo(new MessageShowFoodSicknessLine(itemStack, newSickness), (EntityPlayerMP) player); } } + + cap.setLastSickness(newSickness); } }