Search in sources :

Example 66 with Vec3

use of net.minecraft.world.phys.Vec3 in project TinkersConstruct by SlimeKnights.

the class SlurpingModifier method addFluidParticles.

/**
 * Adds the given number of fluid particles
 */
private static void addFluidParticles(Player player, FluidStack fluid, int count) {
    for (int i = 0; i < count; ++i) {
        Vec3 motion = new Vec3((RANDOM.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
        motion = motion.xRot(-player.getXRot() * DEGREE_TO_RADIANS);
        motion = motion.yRot(-player.getYRot() * DEGREE_TO_RADIANS);
        Vec3 position = new Vec3((RANDOM.nextFloat() - 0.5D) * 0.3D, (-RANDOM.nextFloat()) * 0.6D - 0.3D, 0.6D);
        position = position.xRot(-player.getXRot() * DEGREE_TO_RADIANS);
        position = position.yRot(-player.getYRot() * DEGREE_TO_RADIANS);
        position = position.add(player.getX(), player.getEyeY(), player.getZ());
        FluidParticleData data = new FluidParticleData(TinkerCommons.fluidParticle.get(), fluid);
        if (player.level instanceof ServerLevel) {
            ((ServerLevel) player.level).sendParticles(data, position.x, position.y, position.z, 1, motion.x, motion.y + 0.05D, motion.z, 0.0D);
        } else {
            player.level.addParticle(data, position.x, position.y, position.z, motion.x, motion.y + 0.05D, motion.z);
        }
    }
}
Also used : FluidParticleData(slimeknights.tconstruct.shared.particle.FluidParticleData) ServerLevel(net.minecraft.server.level.ServerLevel) Vec3(net.minecraft.world.phys.Vec3)

Example 67 with Vec3

use of net.minecraft.world.phys.Vec3 in project TinkersConstruct by SlimeKnights.

the class LightspeedArmorModifier method onWalk.

@Override
public void onWalk(IToolStackView tool, int level, LivingEntity living, BlockPos prevPos, BlockPos newPos) {
    // no point trying if not on the ground
    if (tool.isBroken() || !living.isOnGround() || living.level.isClientSide) {
        return;
    }
    // must have speed
    AttributeInstance attribute = living.getAttribute(Attributes.MOVEMENT_SPEED);
    if (attribute == null) {
        return;
    }
    // start by removing the attribute, we are likely going to give it a new number
    if (attribute.getModifier(ATTRIBUTE_BONUS) != null) {
        attribute.removeModifier(ATTRIBUTE_BONUS);
    }
    // not above air
    Vec3 vecPos = living.position();
    BlockPos pos = new BlockPos(vecPos.x, vecPos.y + 0.5f, vecPos.z);
    int light = living.level.getBrightness(LightLayer.BLOCK, pos);
    if (light > 5) {
        int scaledLight = light - 5;
        attribute.addTransientModifier(new AttributeModifier(ATTRIBUTE_BONUS, "tconstruct.modifier.lightspeed", scaledLight * 0.0015f * getScaledLevel(tool, level), Operation.ADDITION));
        // damage boots
        if (RANDOM.nextFloat() < (0.005f * scaledLight)) {
            ToolDamageUtil.damageAnimated(tool, 1, living, EquipmentSlot.FEET);
        }
    }
}
Also used : AttributeInstance(net.minecraft.world.entity.ai.attributes.AttributeInstance) Vec3(net.minecraft.world.phys.Vec3) BlockPos(net.minecraft.core.BlockPos) AttributeModifier(net.minecraft.world.entity.ai.attributes.AttributeModifier)

Example 68 with Vec3

use of net.minecraft.world.phys.Vec3 in project TinkersConstruct by SlimeKnights.

the class SoulSpeedModifier method onWalk.

@Override
public void onWalk(IToolStackView tool, int level, LivingEntity living, BlockPos prevPos, BlockPos newPos) {
    // no point trying if not on the ground
    if (tool.isBroken() || !living.isOnGround() || living.level.isClientSide) {
        return;
    }
    // must have speed
    AttributeInstance attribute = living.getAttribute(Attributes.MOVEMENT_SPEED);
    if (attribute == null) {
        return;
    }
    // not above air
    BlockPos belowPos = getOnPosition(living);
    BlockState below = living.level.getBlockState(belowPos);
    if (below.isAir()) {
        return;
    }
    // start by removing the attribute, we are likely going to give it a new number
    if (attribute.getModifier(ATTRIBUTE_BONUS) != null) {
        attribute.removeModifier(ATTRIBUTE_BONUS);
    }
    // add back speed boost if above a soul speed block and not flying
    if (!living.isFallFlying() && below.is(BlockTags.SOUL_SPEED_BLOCKS)) {
        Random rand = living.getRandom();
        // boost speed
        float boost = (0.03f + level * 0.0105f);
        float speedFactor = below.getBlock().getSpeedFactor();
        if (speedFactor != 1.0f) {
            boost *= (1 / speedFactor);
        }
        attribute.addTransientModifier(new AttributeModifier(ATTRIBUTE_BONUS, "tconstruct.modifier.soul_speed", boost, Operation.ADDITION));
        // damage boots
        if (rand.nextFloat() < 0.04F) {
            ToolDamageUtil.damageAnimated(tool, 1, living, EquipmentSlot.FEET);
        }
        // particles and sounds
        Vec3 motion = living.getDeltaMovement();
        if (living.level instanceof ServerLevel) {
            ((ServerLevel) living.level).sendParticles(ParticleTypes.SOUL, living.getX() + (rand.nextDouble() - 0.5) * living.getBbWidth(), living.getY() + 0.1, living.getZ() + (rand.nextDouble() - 0.5) * living.getBbWidth(), 0, motion.x * -0.2, 0.1, motion.z * -0.2, 1);
        }
        living.level.playSound(null, living.getX(), living.getY(), living.getZ(), SoundEvents.SOUL_ESCAPE, living.getSoundSource(), rand.nextFloat() * 0.4f + rand.nextFloat() > 0.9f ? 0.6f : 0.0f, 0.6f + rand.nextFloat() * 0.4f);
    }
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) BlockState(net.minecraft.world.level.block.state.BlockState) Random(java.util.Random) AttributeInstance(net.minecraft.world.entity.ai.attributes.AttributeInstance) Vec3(net.minecraft.world.phys.Vec3) BlockPos(net.minecraft.core.BlockPos) AttributeModifier(net.minecraft.world.entity.ai.attributes.AttributeModifier)

Example 69 with Vec3

use of net.minecraft.world.phys.Vec3 in project BurnutsPlusTNTandDisparityMod by Team-Burnuts.

the class CarminiteCannonFlyingEntity method registerGoals.

@Override
protected void registerGoals() {
    super.registerGoals();
    this.goalSelector.addGoal(1, new RandomStrollGoal(this, 1, 20) {

        @Override
        protected Vec3 getPosition() {
            Random random = CarminiteCannonFlyingEntity.this.getRandom();
            double dir_x = CarminiteCannonFlyingEntity.this.getX() + ((random.nextFloat() * 2 - 1) * 16);
            double dir_y = CarminiteCannonFlyingEntity.this.getY() + ((random.nextFloat() * 2 - 1) * 16);
            double dir_z = CarminiteCannonFlyingEntity.this.getZ() + ((random.nextFloat() * 2 - 1) * 16);
            return new Vec3(dir_x, dir_y, dir_z);
        }
    });
    this.goalSelector.addGoal(2, new RandomLookAroundGoal(this));
    this.goalSelector.addGoal(3, new LookAtPlayerGoal(this, Player.class, (float) 128));
    this.goalSelector.addGoal(4, new LookAtPlayerGoal(this, Villager.class, (float) 128));
    this.goalSelector.addGoal(5, new LookAtPlayerGoal(this, IronGolem.class, (float) 128));
    this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, SnowGolem.class, (float) 128));
    this.goalSelector.addGoal(7, new LookAtPlayerGoal(this, StickmanEntity.class, (float) 128));
    this.goalSelector.addGoal(8, new FollowMobGoal(this, (float) 2, 16, 128));
    this.goalSelector.addGoal(9, new AvoidEntityGoal<>(this, Player.class, (float) 6, 1, 2));
    this.goalSelector.addGoal(10, new AvoidEntityGoal<>(this, Villager.class, (float) 6, 1, 2));
    this.goalSelector.addGoal(11, new AvoidEntityGoal<>(this, IronGolem.class, (float) 6, 1, 2));
    this.goalSelector.addGoal(12, new AvoidEntityGoal<>(this, SnowGolem.class, (float) 6, 1, 2));
    this.goalSelector.addGoal(13, new AvoidEntityGoal<>(this, StickmanEntity.class, (float) 6, 1, 2));
    this.targetSelector.addGoal(14, new NearestAttackableTargetGoal(this, Player.class, false, false));
    this.targetSelector.addGoal(15, new NearestAttackableTargetGoal(this, Villager.class, false, false));
    this.targetSelector.addGoal(16, new NearestAttackableTargetGoal(this, IronGolem.class, false, false));
    this.targetSelector.addGoal(17, new NearestAttackableTargetGoal(this, SnowGolem.class, false, false));
    this.targetSelector.addGoal(18, new NearestAttackableTargetGoal(this, StickmanEntity.class, false, false));
    this.targetSelector.addGoal(19, new HurtByTargetGoal(this).setAlertOthers(this.getClass()));
    this.goalSelector.addGoal(1, new RangedAttackGoal(this, 0D, 10, 20, 128.0F) {

        @Override
        public boolean canContinueToUse() {
            return this.canUse();
        }
    });
}
Also used : Player(net.minecraft.world.entity.player.Player) HurtByTargetGoal(net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal) IronGolem(net.minecraft.world.entity.animal.IronGolem) NearestAttackableTargetGoal(net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal) RangedAttackGoal(net.minecraft.world.entity.ai.goal.RangedAttackGoal) RandomLookAroundGoal(net.minecraft.world.entity.ai.goal.RandomLookAroundGoal) Random(java.util.Random) LookAtPlayerGoal(net.minecraft.world.entity.ai.goal.LookAtPlayerGoal) Vec3(net.minecraft.world.phys.Vec3) Villager(net.minecraft.world.entity.npc.Villager) FollowMobGoal(net.minecraft.world.entity.ai.goal.FollowMobGoal) SnowGolem(net.minecraft.world.entity.animal.SnowGolem) RandomStrollGoal(net.minecraft.world.entity.ai.goal.RandomStrollGoal)

Example 70 with Vec3

use of net.minecraft.world.phys.Vec3 in project Botania by VazkiiMods.

the class FabricMixinEnderMan method checkForVincs.

@Unique
private void checkForVincs(Args args) {
    double x = args.get(0);
    double y = args.get(1);
    double z = args.get(2);
    Vec3 vincPos = SubTileVinculotus.onEndermanTeleport((EnderMan) (Object) this, x, y, z);
    if (vincPos != null) {
        args.set(0, vincPos.x());
        args.set(1, vincPos.y());
        args.set(2, vincPos.z());
    }
}
Also used : Vec3(net.minecraft.world.phys.Vec3) Unique(org.spongepowered.asm.mixin.Unique)

Aggregations

Vec3 (net.minecraft.world.phys.Vec3)1357 BlockPos (net.minecraft.core.BlockPos)401 ItemStack (net.minecraft.world.item.ItemStack)214 Entity (net.minecraft.world.entity.Entity)161 Direction (net.minecraft.core.Direction)155 AABB (net.minecraft.world.phys.AABB)148 LivingEntity (net.minecraft.world.entity.LivingEntity)144 BlockState (net.minecraft.world.level.block.state.BlockState)133 Player (net.minecraft.world.entity.player.Player)111 BlockHitResult (net.minecraft.world.phys.BlockHitResult)104 Level (net.minecraft.world.level.Level)103 ServerLevel (net.minecraft.server.level.ServerLevel)91 ItemEntity (net.minecraft.world.entity.item.ItemEntity)78 ClipContext (net.minecraft.world.level.ClipContext)71 ServerPlayer (net.minecraft.server.level.ServerPlayer)63 InputWindowElement (com.simibubi.create.foundation.ponder.element.InputWindowElement)61 HitResult (net.minecraft.world.phys.HitResult)59 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)54 Selection (com.simibubi.create.foundation.ponder.Selection)53 CompoundTag (net.minecraft.nbt.CompoundTag)46