use of net.minecraft.entity.effect.StatusEffectInstance in project artifality by PinkGoosik.
the class HandFanItem method use.
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
int tier = TiersUtils.getTier(user.getStackInHand(hand));
user.getItemCooldownManager().set(this, (14 - 3 * tier) * 20);
double radius = 6.0 + (2.0 * tier);
int x1 = MathHelper.floor(user.getPos().x - radius);
int y1 = MathHelper.floor(user.getPos().y - radius);
int z1 = MathHelper.floor(user.getPos().z - radius);
int x2 = MathHelper.floor(user.getPos().x + radius);
int y2 = MathHelper.floor(user.getPos().y + radius);
int z2 = MathHelper.floor(user.getPos().z + radius);
List<Entity> list = world.getOtherEntities(user, new Box(x1, y1, z1, x2, y2, z2));
Vec3d vec3d = new Vec3d(user.getPos().x, user.getPos().y, user.getPos().z);
for (Entity entity : list) {
double w = Math.sqrt(entity.squaredDistanceTo(vec3d)) / radius;
if (w <= 1.0) {
double x = entity.getX() - user.getPos().x;
double y = (entity instanceof TntEntity ? entity.getY() : entity.getEyeY()) - user.getPos().y;
double z = entity.getZ() - user.getPos().z;
double aa = Math.sqrt(x * x + y * y + z * z);
if (aa != 0.0) {
x /= aa;
y /= aa;
z /= aa;
double ab = Explosion.getExposure(vec3d, entity);
double ac = (1.5 - w) * ab;
entity.setVelocity(entity.getVelocity().add(x * ac, y * ac, z * ac));
}
}
}
user.fallDistance = 0.0F;
Vec3d userVec = user.getVelocity();
user.setVelocity(userVec.x, 1 + (0.25 * tier), userVec.z);
user.addStatusEffect(new StatusEffectInstance(ArtifalityEffects.FALL_DAMAGE_IMMUNITY, 80 + (20 * tier), 0, false, false));
return TypedActionResult.success(user.getStackInHand(hand));
}
use of net.minecraft.entity.effect.StatusEffectInstance in project artifality by PinkGoosik.
the class LunarWandItem method createCloudEffect.
public static void createCloudEffect(World world, LivingEntity entity, StatusEffect statusEffect, int durationInSec, float radius, int tier) {
AreaEffectCloudEntity cloud = new AreaEffectCloudEntity(world, entity.getX(), entity.getY(), entity.getZ());
cloud.setRadius(radius);
cloud.setRadiusOnUse(-0.5F);
cloud.setWaitTime(10);
cloud.setRadiusGrowth(-cloud.getRadius() / (float) cloud.getDuration());
int random = world.getRandom().nextInt(2);
int amplifier = tier == 1 ? random : tier - 1;
cloud.addEffect(new StatusEffectInstance(statusEffect, durationInSec * 20, amplifier));
world.spawnEntity(cloud);
}
use of net.minecraft.entity.effect.StatusEffectInstance in project Fabric-Course-118 by Kaupenjoe.
the class ModArmorItem method evaluateArmorEffects.
private void evaluateArmorEffects(PlayerEntity player) {
for (Map.Entry<ArmorMaterial, StatusEffectInstance> entry : MATERIAL_TO_EFFECT_MAP.entrySet()) {
ArmorMaterial mapArmorMaterial = entry.getKey();
StatusEffectInstance mapStatusEffect = entry.getValue();
if (hasCorrectArmorOn(mapArmorMaterial, player)) {
addStatusEffectForMaterial(player, mapArmorMaterial, mapStatusEffect);
}
}
}
use of net.minecraft.entity.effect.StatusEffectInstance in project Fabric-Course-118 by Kaupenjoe.
the class SpeedyBlock method onSteppedOn.
@Override
public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) {
if (!world.isClient()) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = ((LivingEntity) entity);
livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 200));
}
}
super.onSteppedOn(world, pos, state, entity);
}
use of net.minecraft.entity.effect.StatusEffectInstance in project Client by MatHax.
the class StatusEffectListSettingScreen method getPotionStack.
private ItemStack getPotionStack(StatusEffect effect) {
ItemStack potion = Items.POTION.getDefaultStack();
potion.getOrCreateNbt().putInt("CustomPotionColor", PotionUtil.getColor(new Potion(new StatusEffectInstance(effect))));
return potion;
}
Aggregations