Search in sources :

Example 1 with AbstractMinecartEntity

use of net.minecraft.entity.vehicle.AbstractMinecartEntity in project Wurst7 by Wurst-Imperium.

the class FollowHack method onEnable.

@Override
public void onEnable() {
    WURST.getHax().fightBotHack.setEnabled(false);
    WURST.getHax().protectHack.setEnabled(false);
    WURST.getHax().tunnellerHack.setEnabled(false);
    if (entity == null) {
        Stream<Entity> stream = StreamSupport.stream(MC.world.getEntities().spliterator(), true).filter(e -> !e.isRemoved()).filter(e -> e instanceof LivingEntity && ((LivingEntity) e).getHealth() > 0 || e instanceof AbstractMinecartEntity).filter(e -> e != MC.player).filter(e -> !(e instanceof FakePlayerEntity));
        if (filterPlayers.isChecked())
            stream = stream.filter(e -> !(e instanceof PlayerEntity));
        if (filterSleeping.isChecked())
            stream = stream.filter(e -> !(e instanceof PlayerEntity && ((PlayerEntity) e).isSleeping()));
        if (filterFlying.getValue() > 0)
            stream = stream.filter(e -> {
                if (!(e instanceof PlayerEntity))
                    return true;
                Box box = e.getBoundingBox();
                box = box.union(box.offset(0, -filterFlying.getValue(), 0));
                return !MC.world.isSpaceEmpty(box);
            });
        if (filterMonsters.isChecked())
            stream = stream.filter(e -> !(e instanceof Monster));
        if (filterPigmen.isChecked())
            stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
        if (filterEndermen.isChecked())
            stream = stream.filter(e -> !(e instanceof EndermanEntity));
        if (filterAnimals.isChecked())
            stream = stream.filter(e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity || e instanceof WaterCreatureEntity));
        if (filterBabies.isChecked())
            stream = stream.filter(e -> !(e instanceof PassiveEntity && ((PassiveEntity) e).isBaby()));
        if (filterPets.isChecked())
            stream = stream.filter(e -> !(e instanceof TameableEntity && ((TameableEntity) e).isTamed())).filter(e -> !(e instanceof HorseBaseEntity && ((HorseBaseEntity) e).isTame()));
        if (filterTraders.isChecked())
            stream = stream.filter(e -> !(e instanceof MerchantEntity));
        if (filterGolems.isChecked())
            stream = stream.filter(e -> !(e instanceof GolemEntity));
        if (filterInvisible.isChecked())
            stream = stream.filter(e -> !e.isInvisible());
        if (filterStands.isChecked())
            stream = stream.filter(e -> !(e instanceof ArmorStandEntity));
        if (filterCarts.isChecked())
            stream = stream.filter(e -> !(e instanceof AbstractMinecartEntity));
        entity = stream.min(Comparator.comparingDouble(e -> MC.player.squaredDistanceTo(e))).orElse(null);
        if (entity == null) {
            ChatUtils.error("Could not find a valid entity.");
            setEnabled(false);
            return;
        }
    }
    pathFinder = new EntityPathFinder();
    EVENTS.add(UpdateListener.class, this);
    EVENTS.add(RenderListener.class, this);
    ChatUtils.message("Now following " + entity.getName().getString());
}
Also used : Category(net.wurstclient.Category) GolemEntity(net.minecraft.entity.passive.GolemEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) ChatUtils(net.wurstclient.util.ChatUtils) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) ArrayList(java.util.ArrayList) ValueDisplay(net.wurstclient.settings.SliderSetting.ValueDisplay) Vec3d(net.minecraft.util.math.Vec3d) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity) StreamSupport(java.util.stream.StreamSupport) RenderListener(net.wurstclient.events.RenderListener) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Entity(net.minecraft.entity.Entity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) PathFinder(net.wurstclient.ai.PathFinder) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) Box(net.minecraft.util.math.Box) GameRenderer(net.minecraft.client.render.GameRenderer) MatrixStack(net.minecraft.client.util.math.MatrixStack) BlockPos(net.minecraft.util.math.BlockPos) Hack(net.wurstclient.hack.Hack) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) PathCmd(net.wurstclient.commands.PathCmd) SliderSetting(net.wurstclient.settings.SliderSetting) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) PathPos(net.wurstclient.ai.PathPos) Stream(java.util.stream.Stream) CheckboxSetting(net.wurstclient.settings.CheckboxSetting) Monster(net.minecraft.entity.mob.Monster) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) PathProcessor(net.wurstclient.ai.PathProcessor) UpdateListener(net.wurstclient.events.UpdateListener) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) DontSaveState(net.wurstclient.hack.DontSaveState) Comparator(java.util.Comparator) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) GolemEntity(net.minecraft.entity.passive.GolemEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Entity(net.minecraft.entity.Entity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Box(net.minecraft.util.math.Box) GolemEntity(net.minecraft.entity.passive.GolemEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) Monster(net.minecraft.entity.mob.Monster) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity)

Example 2 with AbstractMinecartEntity

use of net.minecraft.entity.vehicle.AbstractMinecartEntity in project carpet-extra by gnembon.

the class FillMinecartDispenserBehavior method dispenseSilently.

@Override
protected ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) {
    this.setSuccess(true);
    ServerWorld world = pointer.getWorld();
    BlockPos frontBlockPos = pointer.getPos().offset(pointer.getBlockState().get(DispenserBlock.FACING));
    Box frontBlockBox = new Box(frontBlockPos);
    // get non-mounted minecarts in front of dispenser
    List<MinecartEntity> minecarts = world.getEntitiesByType(EntityType.MINECART, frontBlockBox, EntityPredicates.NOT_MOUNTED);
    if (!minecarts.isEmpty()) {
        // choose a random minecart in front of dispenser to fill
        MinecartEntity oldMinecart = minecarts.get(world.random.nextInt(minecarts.size()));
        AbstractMinecartEntity newMinecart = AbstractMinecartEntity.create(world, oldMinecart.getX(), oldMinecart.getY(), oldMinecart.getZ(), this.MINECART_TYPE);
        // Copy data from original minecart to new minecart
        // Possibly missing some things to copy here. Add more if needed
        newMinecart.setVelocity(oldMinecart.getVelocity());
        newMinecart.setPitch(oldMinecart.getPitch());
        newMinecart.setYaw(oldMinecart.getYaw());
        newMinecart.setCustomName(oldMinecart.getCustomName());
        newMinecart.setFireTicks(oldMinecart.getFireTicks());
        // remove old minecart, spawn new minecart
        oldMinecart.discard();
        world.spawnEntity(newMinecart);
        // decrement item and return
        stack.decrement(1);
        return stack;
    }
    // fail to dispense
    this.setSuccess(false);
    return stack;
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) MinecartEntity(net.minecraft.entity.vehicle.MinecartEntity) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity) BlockPos(net.minecraft.util.math.BlockPos) Box(net.minecraft.util.math.Box) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity)

Example 3 with AbstractMinecartEntity

use of net.minecraft.entity.vehicle.AbstractMinecartEntity in project Flan by Flemmli97.

the class EntityInteractEvents method useEntity.

public static ActionResult useEntity(PlayerEntity p, World world, Hand hand, Entity entity) {
    if (p.world.isClient || p.isSpectator() || canInteract(entity))
        return ActionResult.PASS;
    ServerPlayerEntity player = (ServerPlayerEntity) p;
    ClaimStorage storage = ClaimStorage.get((ServerWorld) world);
    BlockPos pos = entity.getBlockPos();
    IPermissionContainer claim = storage.getForPermissionCheck(pos);
    if (claim != null) {
        if (entity instanceof BoatEntity)
            return claim.canInteract(player, PermissionRegistry.BOAT, pos, true) ? ActionResult.PASS : ActionResult.FAIL;
        if (entity instanceof AbstractMinecartEntity) {
            if (entity instanceof StorageMinecartEntity)
                return claim.canInteract(player, PermissionRegistry.OPENCONTAINER, pos, true) ? ActionResult.PASS : ActionResult.FAIL;
            return claim.canInteract(player, PermissionRegistry.MINECART, pos, true) ? ActionResult.PASS : ActionResult.FAIL;
        }
        if (entity instanceof VillagerEntity)
            return claim.canInteract(player, PermissionRegistry.TRADING, pos, true) ? ActionResult.PASS : ActionResult.FAIL;
        if (entity instanceof ItemFrameEntity)
            return claim.canInteract(player, PermissionRegistry.ITEMFRAMEROTATE, pos, true) ? ActionResult.PASS : ActionResult.FAIL;
        if (entity instanceof TameableEntity) {
            TameableEntity tame = (TameableEntity) entity;
            if (tame.isOwner(player))
                return ActionResult.PASS;
        }
        return claim.canInteract(player, PermissionRegistry.ANIMALINTERACT, pos, true) ? ActionResult.PASS : ActionResult.FAIL;
    }
    return ActionResult.PASS;
}
Also used : VillagerEntity(net.minecraft.entity.passive.VillagerEntity) BoatEntity(net.minecraft.entity.vehicle.BoatEntity) StorageMinecartEntity(net.minecraft.entity.vehicle.StorageMinecartEntity) ItemFrameEntity(net.minecraft.entity.decoration.ItemFrameEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) ClaimStorage(io.github.flemmli97.flan.claim.ClaimStorage) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) BlockPos(net.minecraft.util.math.BlockPos) IPermissionContainer(io.github.flemmli97.flan.claim.IPermissionContainer) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity)

Example 4 with AbstractMinecartEntity

use of net.minecraft.entity.vehicle.AbstractMinecartEntity in project TaterCart by Patbox.

the class AbstractMinecartEntityMixin method tatercart_onCreate.

@Inject(method = "create", at = @At("HEAD"), cancellable = true)
private static void tatercart_onCreate(World world, double x, double y, double z, AbstractMinecartEntity.Type type, CallbackInfoReturnable<AbstractMinecartEntity> cir) {
    var dyeColor = CustomMinecartType.COLORED.inverse().getOrDefault(type, null);
    AbstractMinecartEntity entity;
    if (dyeColor != null) {
        entity = new ColoredMinecartEntity(TcEntities.COLORED_MINECART.get(dyeColor), world);
    } else if (type == CustomMinecartType.SLIME) {
        entity = new SlimeMinecartEntity(TcEntities.SLIME_MINECART, world);
    } else if (type == CustomMinecartType.BARREL) {
        entity = new BarrelMinecartEntity(TcEntities.BARREL_MINECART, world);
    } else if (type == CustomMinecartType.SHULKER) {
        entity = new ShulkerMinecartEntity(TcEntities.SHULKER_MINECART, world);
    } else if (type == CustomMinecartType.DISPENSER) {
        entity = new DispenserMinecartEntity(TcEntities.DISPENSER_MINECART, world);
    } else if (type == CustomMinecartType.DROPPER) {
        entity = new DropperMinecartEntity(TcEntities.DROPPER_MINECART, world);
    } else {
        entity = null;
    }
    if (entity != null) {
        entity.setPosition(x, y, z);
        cir.setReturnValue(entity);
    }
}
Also used : ShulkerMinecartEntity(eu.pb4.tatercart.entity.minecart.storage.ShulkerMinecartEntity) ColoredMinecartEntity(eu.pb4.tatercart.entity.minecart.other.ColoredMinecartEntity) BarrelMinecartEntity(eu.pb4.tatercart.entity.minecart.storage.BarrelMinecartEntity) DropperMinecartEntity(eu.pb4.tatercart.entity.minecart.storage.DropperMinecartEntity) SlimeMinecartEntity(eu.pb4.tatercart.entity.minecart.other.SlimeMinecartEntity) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity) DispenserMinecartEntity(eu.pb4.tatercart.entity.minecart.storage.DispenserMinecartEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with AbstractMinecartEntity

use of net.minecraft.entity.vehicle.AbstractMinecartEntity in project BigRat by ZimnyCat.

the class Tracers method onRender.

@Subscribe
public void onRender(EventWorldRender event) {
    final float thick = (float) getSetting(6).asSlider().getValue();
    for (Entity e : mc.world.getEntities()) {
        Vec3d vec = e.getPos();
        Vec3d vec2 = new Vec3d(0, 0, 75).rotateX(-(float) Math.toRadians(mc.cameraEntity.pitch)).rotateY(-(float) Math.toRadians(mc.cameraEntity.yaw)).add(mc.cameraEntity.getPos().add(0, mc.cameraEntity.getEyeHeight(mc.cameraEntity.getPose()), 0));
        float[] col = null;
        if (e instanceof PlayerEntity && e != mc.player && e != mc.cameraEntity && getSetting(0).asToggle().state) {
            col = getSetting(0).asToggle().getChild(BleachHack.friendMang.has(e.getName().asString()) ? 1 : 0).asColor().getRGBFloat();
        } else if (e instanceof Monster && getSetting(1).asToggle().state) {
            col = getSetting(1).asToggle().getChild(0).asColor().getRGBFloat();
        } else if (EntityUtils.isAnimal(e) && getSetting(2).asToggle().state) {
            col = getSetting(2).asToggle().getChild(0).asColor().getRGBFloat();
        } else if (e instanceof ItemEntity && getSetting(3).asToggle().state) {
            col = getSetting(3).asToggle().getChild(0).asColor().getRGBFloat();
        } else if (e instanceof EndCrystalEntity && getSetting(4).asToggle().state) {
            col = getSetting(4).asToggle().getChild(0).asColor().getRGBFloat();
        } else if ((e instanceof BoatEntity || e instanceof AbstractMinecartEntity) && getSetting(5).asToggle().state) {
            col = getSetting(5).asToggle().getChild(0).asColor().getRGBFloat();
        }
        if (col != null) {
            RenderUtils.drawLine(vec2.x, vec2.y, vec2.z, vec.x, vec.y, vec.z, col[0], col[1], col[2], thick);
            RenderUtils.drawLine(vec.x, vec.y, vec.z, vec.x, vec.y + (e.getHeight() / 1.1), vec.z, col[0], col[1], col[2], thick);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) BoatEntity(net.minecraft.entity.vehicle.BoatEntity) ItemEntity(net.minecraft.entity.ItemEntity) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) BoatEntity(net.minecraft.entity.vehicle.BoatEntity) ItemEntity(net.minecraft.entity.ItemEntity) Monster(net.minecraft.entity.mob.Monster) Vec3d(net.minecraft.util.math.Vec3d) AbstractMinecartEntity(net.minecraft.entity.vehicle.AbstractMinecartEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

AbstractMinecartEntity (net.minecraft.entity.vehicle.AbstractMinecartEntity)5 BlockPos (net.minecraft.util.math.BlockPos)3 Entity (net.minecraft.entity.Entity)2 Monster (net.minecraft.entity.mob.Monster)2 TameableEntity (net.minecraft.entity.passive.TameableEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 BoatEntity (net.minecraft.entity.vehicle.BoatEntity)2 Box (net.minecraft.util.math.Box)2 Vec3d (net.minecraft.util.math.Vec3d)2 Subscribe (com.google.common.eventbus.Subscribe)1 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 ColoredMinecartEntity (eu.pb4.tatercart.entity.minecart.other.ColoredMinecartEntity)1 SlimeMinecartEntity (eu.pb4.tatercart.entity.minecart.other.SlimeMinecartEntity)1 BarrelMinecartEntity (eu.pb4.tatercart.entity.minecart.storage.BarrelMinecartEntity)1 DispenserMinecartEntity (eu.pb4.tatercart.entity.minecart.storage.DispenserMinecartEntity)1 DropperMinecartEntity (eu.pb4.tatercart.entity.minecart.storage.DropperMinecartEntity)1 ShulkerMinecartEntity (eu.pb4.tatercart.entity.minecart.storage.ShulkerMinecartEntity)1 ClaimStorage (io.github.flemmli97.flan.claim.ClaimStorage)1 IPermissionContainer (io.github.flemmli97.flan.claim.IPermissionContainer)1 ArrayList (java.util.ArrayList)1