net.minecraft.entity.effect.StatusEffectInstance Java Examples

The following examples show how to use net.minecraft.entity.effect.StatusEffectInstance. 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: CrudeOilBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
public void onEntityCollision(BlockState blockState, World world, BlockPos blockPos, Entity entity) {
    if (entity instanceof LivingEntity && this.getFluidState(blockState).getFluid().isStill(this.getFluidState(blockState))) {
        if (entity instanceof PlayerEntity) {
            if (((PlayerEntity) entity).isCreative()) {
                return;
            }
        }
        ((LivingEntity) entity).addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 6 * 20));
    }
}
 
Example #2
Source File: AutoEatHack.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private boolean isAllowedFood(FoodComponent food)
{
	if(!allowChorus.isChecked() && food == FoodComponents.CHORUS_FRUIT)
		return false;
	
	for(Pair<StatusEffectInstance, Float> pair : food.getStatusEffects())
	{
		StatusEffect effect = pair.getFirst().getEffectType();
		
		if(!allowHunger.isChecked() && effect == StatusEffects.HUNGER)
			return false;
		
		if(!allowPoison.isChecked() && effect == StatusEffects.POISON)
			return false;
	}
	
	return true;
}
 
Example #3
Source File: PotionCmd.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private ListTag convertEffectsToNbt(ItemStack stack)
{
	ListTag nbt = new ListTag();
	List<StatusEffectInstance> effects =
		PotionUtil.getCustomPotionEffects(stack);
	
	for(StatusEffectInstance effect : effects)
	{
		CompoundTag tag = new CompoundTag();
		
		int id = StatusEffect.getRawId(effect.getEffectType());
		tag.putInt("Id", id);
		tag.putInt("Amplifier", effect.getAmplifier());
		tag.putInt("Duration", effect.getDuration());
		
		nbt.add(tag);
	}
	
	return nbt;
}
 
Example #4
Source File: WitchWaterBlock.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public void onEntityCollision(BlockState blockState, World world, BlockPos pos, Entity entity) {
	if(!world.isClient) {
		if (entity instanceof LivingEntity) {
			LivingEntity livingEntity = (LivingEntity) entity;
			if (!livingEntity.isUndead() && !(livingEntity instanceof PumpcownEntity) && !(livingEntity instanceof WitchEntity)) {
				livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, 100));
				livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 100));
				livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 100));
			}
			if (pos.equals(entity.getBlockPos())) {
				if (entity.getType() == EntityType.SKELETON) {
					WitherSkeletonEntity witherSkeletonEntity = new WitherSkeletonEntity(EntityType.WITHER_SKELETON, world);
					witherSkeletonEntity.copyPositionAndRotation(entity);
					entity.remove();

					world.spawnEntity(witherSkeletonEntity);
				} else if (entity.getType() == EntityType.SPIDER) {
					CaveSpiderEntity caveSpiderEntity = new CaveSpiderEntity(EntityType.CAVE_SPIDER, world);
					caveSpiderEntity.copyPositionAndRotation(entity);
					entity.remove();

					world.spawnEntity(caveSpiderEntity);
				} else if (entity.getType() == EntityType.COW) {
					PumpcownEntity pumpcownEntity = new PumpcownEntity(HallowedEntities.PUMPCOWN, world);
					pumpcownEntity.copyPositionAndRotation(entity);
					entity.remove();

					world.spawnEntity(pumpcownEntity);
				} else if (entity.getType() == EntityType.VILLAGER && world.getDifficulty() != Difficulty.PEACEFUL) {
					WitchEntity witchEntity = new WitchEntity(EntityType.WITCH, world);
					witchEntity.copyPositionAndRotation(entity);
					entity.remove();

					world.spawnEntity(witchEntity);
				}
			}
		}
	}

	super.onEntityCollision(blockState, world, pos, entity);
}
 
Example #5
Source File: CameraModeCommand.java    From fabric-carpet with MIT License 5 votes vote down vote up
private static int cameraMode(ServerCommandSource source, ServerPlayerEntity player)
{
    if (!(iCanHasPermissions(source, player))) return 0;
    player.setGameMode(GameMode.SPECTATOR);
    player.addVelocity(0,0.1,0);
    player.networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(player));
    player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 999999, 0, false, false));
    player.addStatusEffect(new StatusEffectInstance(StatusEffects.CONDUIT_POWER, 999999, 0, false, false));
    return 1;
}
 
Example #6
Source File: Fullbright.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (getSettings().get(0).toMode().mode == 0) {
		if (mc.options.gamma < 16) mc.options.gamma += 1.2;
	} else if (getSettings().get(0).toMode().mode == 1) {
		mc.player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 1, 5));
	}/* else if (getSettings().get(0).toMode().mode == 2) {
		for (int i = 0; i < 16; i++) {
			if (mc.world.dimension.getLightLevelToBrightness()[i] != 1) {
				mc.world.dimension.getLightLevelToBrightness()[i] = 1;
			}
		}
	}*/
}
 
Example #7
Source File: Fullbright.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (getSettings().get(0).toMode().mode == 0) {
		if (mc.options.gamma < 16) mc.options.gamma += 1.2;
	} else if (getSettings().get(0).toMode().mode == 1) {
		mc.player.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 1, 5));
	}/* else if (getSettings().get(0).toMode().mode == 2) {
		for (int i = 0; i < 16; i++) {
			if (mc.world.dimension.getLightLevelToBrightness()[i] != 1) {
				mc.world.dimension.getLightLevelToBrightness()[i] = 1;
			}
		}
	}*/
}
 
Example #8
Source File: Fullbright.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (getSettings().get(0).toMode().mode == 0) {
		if (mc.options.gamma < 16) mc.options.gamma += 1.2;
	} else if (getSettings().get(0).toMode().mode == 1) {
		mc.player.addPotionEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 1, 5));
	} else if (getSettings().get(0).toMode().mode == 2) {
		for (int i = 0; i < 16; i++) {
			if (mc.world.dimension.getLightLevelToBrightness()[i] != 1) {
				mc.world.dimension.getLightLevelToBrightness()[i] = 1;
			}
		}
	}
}
 
Example #9
Source File: PotionCmd.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private void remove(ItemStack stack, String[] args) throws CmdSyntaxError
{
	if(args.length != 2)
		throw new CmdSyntaxError();
	
	int id = parseEffectId(args[1]);
	
	List<StatusEffectInstance> oldEffects =
		PotionUtil.getCustomPotionEffects(stack);
	
	ListTag newEffects = new ListTag();
	for(StatusEffectInstance oldEffect : oldEffects)
	{
		int oldId = StatusEffect.getRawId(oldEffect.getEffectType());
		
		if(oldId == id)
			continue;
		
		CompoundTag effect = new CompoundTag();
		effect.putInt("Id", oldId);
		effect.putInt("Amplifier", oldEffect.getAmplifier());
		effect.putInt("Duration", oldEffect.getDuration());
		newEffects.add(effect);
	}
	
	CompoundTag nbt = new CompoundTag();
	nbt.put("CustomPotionEffects", newEffects);
	stack.setTag(nbt);
	ChatUtils.message("Effect removed.");
}
 
Example #10
Source File: AutoPotionHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private boolean hasEffect(ItemStack stack, StatusEffect effect)
{
	for(StatusEffectInstance effectInstance : PotionUtil
		.getPotionEffects(stack))
	{
		if(effectInstance.getEffectType() != effect)
			continue;
		
		return true;
	}
	
	return false;
}
 
Example #11
Source File: SpeedMine.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (this.getSettings().get(0).toMode().mode == 0) {
		mc.player.addPotionEffect(new StatusEffectInstance(StatusEffects.HASTE, 1, (int) getSettings().get(1).toSlider().getValue()));
	}
}
 
Example #12
Source File: SpeedMine.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (this.getSettings().get(0).toMode().mode == 0) {
		mc.player.addStatusEffect(new StatusEffectInstance(StatusEffects.HASTE, 1, (int) getSettings().get(1).toSlider().getValue()));
	}
}
 
Example #13
Source File: SpeedMine.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
@Subscribe
public void onTick(EventTick event) {
	if (this.getSettings().get(0).toMode().mode == 0) {
		mc.player.addStatusEffect(new StatusEffectInstance(StatusEffects.HASTE, 1, (int) getSettings().get(1).toSlider().getValue()));
	}
}
 
Example #14
Source File: FullbrightHack.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
private void applyNightVision()
{
	MC.player.addStatusEffect(new StatusEffectInstance(
		StatusEffects.NIGHT_VISION, 16360, 0, false, false));
	hasAppliedNightVision = true;
}
 
Example #15
Source File: IForgeEffect.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns true if the {@link StatusEffectInstance} text (name and duration) should be drawn when this {@link StatusEffect} is active.
 *
 * @param effect the active {@link StatusEffectInstance}
 * @return true to draw the standard text
 */
default boolean shouldRenderInvText(StatusEffectInstance effect) {
	return true;
}
 
Example #16
Source File: IForgeEffect.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns true if the {@link StatusEffectInstance} should be displayed in the player's {@link net.minecraft.client.gui.hud.InGameHud}.
 *
 * @param effect the active {@link StatusEffectInstance}
 * @return true to display it (default), false to hide it.
 */
default boolean shouldRenderHUD(StatusEffectInstance effect) {
	return true;
}
 
Example #17
Source File: IForgeEffect.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Called to draw the {@link StatusEffectInstance} onto the player's inventory when it's active.
 * This can be used to e.g. render {@link StatusEffect} icons from your own texture.
 *
 * @param effect the active {@link StatusEffectInstance}
 * @param gui    the gui instance
 * @param x      the x coordinate
 * @param y      the y coordinate
 * @param z      the z level
 */
@Environment(EnvType.CLIENT)
default void renderInventoryEffect(StatusEffectInstance effect, AbstractInventoryScreen<?> gui, int x, int y, float z) {
}
 
Example #18
Source File: IForgeEffect.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Used for determining {@link StatusEffectInstance} sort order in GUIs.
 * Defaults to the {@link StatusEffectInstance}'s liquid color.
 *
 * @param effect the {@link StatusEffectInstance} containing the {@link StatusEffect}
 * @return a value used to sort {@link StatusEffectInstance}s in GUIs
 */
default int getGuiSortColor(StatusEffectInstance effect) {
	return getEffect().getColor();
}
 
Example #19
Source File: IForgeEffect.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Returns true if the {@link StatusEffectInstance} should be displayed in the player's inventory.
 *
 * @param effect the active {@link StatusEffectInstance}
 * @return true to display it (default), false to hide it.
 */
default boolean shouldRender(StatusEffectInstance effect) {
	return true;
}
 
Example #20
Source File: IForgeEffect.java    From patchwork-api with GNU Lesser General Public License v2.1 1 votes vote down vote up
/**
 * Called to draw the {@link StatusEffectInstance} onto the player's {@link net.minecraft.client.gui.hud.InGameHud} when it's active.
 * This can be used to e.g. render {@link StatusEffect} icons from your own texture.
 *
 * @param effect the active {@link StatusEffectInstance}
 * @param gui    the gui instance
 * @param x      the x coordinate
 * @param y      the y coordinate
 * @param z      the z level
 * @param alpha  the alpha value, blinks when the {@link StatusEffect} is about to run out
 */
@Environment(EnvType.CLIENT)
default void renderHUDEffect(StatusEffectInstance effect, DrawableHelper gui, int x, int y, float z, float alpha) {
}