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());
}
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;
}
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;
}
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);
}
}
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);
}
}
}
Aggregations