Java Code Examples for net.minecraft.entity.LivingEntity#hasStatusEffect()
The following examples show how to use
net.minecraft.entity.LivingEntity#hasStatusEffect() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IForgeBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 6 votes |
/** * Use this to change the fog color used when the entity is "inside" a material. * {@link Vec3d} is used here as "r/g/b" 0 - 1 values. * * @param state The state at the entity viewport. * @param world The world. * @param pos The position at the entity viewport. * @param entity the entity * @param originalColor The current fog color, You are not expected to use this, Return as the default if applicable. * @return The new fog color. */ @Environment(EnvType.CLIENT) default Vec3d getFogColor(BlockState state, CollisionView world, BlockPos pos, Entity entity, Vec3d originalColor, float partialTicks) { if (state.getMaterial() == Material.WATER) { float visibility = 0.0F; if (entity instanceof LivingEntity) { LivingEntity ent = (LivingEntity) entity; visibility = (float) EnchantmentHelper.getRespiration(ent) * 0.2F; if (ent.hasStatusEffect(StatusEffects.WATER_BREATHING)) { visibility = visibility * 0.3F + 0.6F; } } return new Vec3d(0.02F + visibility, 0.02F + visibility, 0.2F + visibility); } else if (state.getMaterial() == Material.LAVA) { return new Vec3d(0.6F, 0.1F, 0.0F); } return originalColor; }
Example 2
Source File: BackgroundRendererMixin.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z", ordinal = 0), method = { "render(Lnet/minecraft/client/render/Camera;FLnet/minecraft/client/world/ClientWorld;IF)V", "applyFog(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/BackgroundRenderer$FogType;FZ)V"}) private static boolean wurstHasStatusEffect(LivingEntity entity, StatusEffect effect) { if(effect == StatusEffects.BLINDNESS && WurstClient.INSTANCE.getHax().antiBlindHack.isEnabled()) return false; return entity.hasStatusEffect(effect); }
Example 3
Source File: DamageReporter.java From fabric-carpet with MIT License | 5 votes |
public static void register_damage(LivingEntity target, DamageSource source, float amount) { if (!LoggerRegistry.__damage) return; if (source.isFire() && (target.isFireImmune() || target.hasStatusEffect(StatusEffects.FIRE_RESISTANCE))) return; LoggerRegistry.getLogger("damage").log( (option, player)-> verifyAndProduceMessage(option, player, source.getSource(), target, () -> Messenger.c(target.getDisplayName(), "g receiving ", String.format("r %.2f", amount), String.format("g points of damage from %s", source.getName())) ) ); }
Example 4
Source File: DamageReporter.java From fabric-carpet with MIT License | 5 votes |
public static void modify_damage(LivingEntity target, DamageSource source, float previous_amount, float final_amount, String component) { if (!LoggerRegistry.__damage) return; if (previous_amount == final_amount) return; if (source.isFire() && (target.isFireImmune() || target.hasStatusEffect(StatusEffects.FIRE_RESISTANCE))) return; LoggerRegistry.getLogger("damage").log( (option, player)-> verifyAndProduceMessage(option, player, source.getSource(), target, () -> { if (final_amount == 0.0f) { return Messenger.c("g - reduced to ","r 0.0","g due to: "+component); } else if (previous_amount > final_amount) { float reduction = previous_amount-final_amount; return Messenger.c("g - reduced to ", String.format("l %.2f",final_amount), String.format("g by %.2f (%.1f%% less) due to: %s",reduction,100.0*reduction/previous_amount, component)); } else { float increase = final_amount-previous_amount; return Messenger.c("g - increased to ", String.format("r %.2f",final_amount), String.format("g by %.2f (%.1f%% more) due to: %s",increase,100.0*increase/previous_amount, component)); } } ) ); }