net.minecraft.entity.LivingEntity Java Examples

The following examples show how to use net.minecraft.entity.LivingEntity. 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: CmdEntityStats.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCommand(String command, String[] args) throws Exception {
    if (mc.player.getVehicle() != null) {
        if     (mc.player.getVehicle() instanceof HorseEntity ||
                mc.player.getVehicle() instanceof DonkeyEntity ||
                mc.player.getVehicle() instanceof LlamaEntity ||
                mc.player.getVehicle() instanceof MuleEntity) {
            HorseBaseEntity h = (HorseBaseEntity) mc.player.getVehicle();
            maxHealth = h.getMaximumHealth() + " §2HP";
            speed = round(43.17 * h.getMovementSpeed(), 2) + " §2m/s";
            jumpHeight = round(-0.1817584952 * Math.pow(h.getJumpStrength(), 3) + 3.689713992 * Math.pow(h.getJumpStrength(), 2) + 2.128599134 * h.getJumpStrength() - 0.343930367, 4) + " §2m";
            BleachLogger.infoMessage("\n§6Entity Stats:\n§cMax Health: §b" + maxHealth + "\n§cSpeed: §b" + speed + "\n§cJump: §b" + jumpHeight);
        } else if (mc.player.getVehicle() instanceof LivingEntity) {
            LivingEntity l = (LivingEntity) mc.player.getVehicle();
            maxHealth = l.getMaximumHealth() + " §2HP";
            speed = round(43.17 * l.getMovementSpeed(), 2) + " §2m/s";
            BleachLogger.infoMessage("\n§6Entity Stats:\n§cMax Health: §b" + maxHealth + "\n§cSpeed: §b" + speed);
        }
    } else {
        BleachLogger.errorMessage("Not riding a living entity.");
    }
}
 
Example #2
Source File: Pony.java    From MineLittlePony with MIT License 6 votes vote down vote up
@Override
public Vec3d getAbsoluteRidingOffset(LivingEntity entity) {
    IPony ridingPony = getMountedPony(entity);

    if (ridingPony != null) {
        LivingEntity ridee = (LivingEntity)entity.getVehicle();

        Vec3d offset = PonyTransformation.forSize(ridingPony.getMetadata().getSize()).getRiderOffset();
        float scale = ridingPony.getMetadata().getSize().getScaleFactor();

        return ridingPony.getAbsoluteRidingOffset(ridee)
                .add(0, offset.y - ridee.getHeight() * 1/scale, 0);
    }

    float delta = MinecraftClient.getInstance().getTickDelta();

    return new Vec3d(
            MathHelper.lerp(delta, entity.prevX, entity.getX()),
            MathHelper.lerp(delta, entity.prevY, entity.getY()),
            MathHelper.lerp(delta, entity.prevZ, entity.getZ())
    );
}
 
Example #3
Source File: ScytheItem.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity user) {
	if (!target.isAlive()) {
		if (target instanceof PlayerEntity) {
			// give player soul
		} else if (target instanceof WitherEntity) {
			// give withered soul
		} else {
			EntityCategory category = target.getType().getCategory();
			switch (category) {
				case MONSTER:
					// give monster soul
					break;
				case CREATURE:
				case WATER_CREATURE:
				case AMBIENT:
					// give creature soul
					break;
				default:
					break;
			}
		}
	}
	return super.postHit(stack, target, user);
}
 
Example #4
Source File: ArmourFeature.java    From MineLittlePony with MIT License 6 votes vote down vote up
private static <T extends LivingEntity, V extends BipedEntityModel<T> & IArmour> void renderArmourPart(
        MatrixStack matrices, VertexConsumerProvider provider,
        int light, boolean glint, V model, float r, float g, float b, IArmourTextureResolver<T> resolver, ArmourLayer layer, Identifier texture) {

    VertexConsumer vertices = ItemRenderer.method_27952(provider, RenderLayer.getArmorCutoutNoCull(texture), false, glint);

    model.setVariant(resolver.getArmourVariant(layer, texture));
    model.render(matrices, vertices, light, OverlayTexture.DEFAULT_UV, r, g, b, 1);
}
 
Example #5
Source File: RemoteViewHack.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onUpdate()
{
	// validate entity
	if(entity.removed || ((LivingEntity)entity).getHealth() <= 0)
	{
		setEnabled(false);
		return;
	}
	
	// update position, rotation, etc.
	MC.player.copyPositionAndRotation(entity);
	MC.player.resetPosition(entity.getX(),
		entity.getY() - MC.player.getEyeHeight(MC.player.getPose())
			+ entity.getEyeHeight(entity.getPose()),
		entity.getZ());
	MC.player.setVelocity(Vec3d.ZERO);
	
	// set entity invisible
	entity.setInvisible(true);
}
 
Example #6
Source File: CmdEntityStats.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCommand(String command, String[] args) throws Exception {
    if (mc.player.getVehicle() != null) {
        if     (mc.player.getVehicle() instanceof HorseEntity ||
                mc.player.getVehicle() instanceof DonkeyEntity ||
                mc.player.getVehicle() instanceof LlamaEntity ||
                mc.player.getVehicle() instanceof MuleEntity) {
            HorseBaseEntity h = (HorseBaseEntity) mc.player.getVehicle();
            maxHealth = h.getHealthMaximum() + " §2HP";
            speed = round(43.17 * h.getMovementSpeed(), 2) + " §2m/s";
            jumpHeight = round(-0.1817584952 * Math.pow(h.getJumpStrength(), 3) + 3.689713992 * Math.pow(h.getJumpStrength(), 2) + 2.128599134 * h.getJumpStrength() - 0.343930367, 4) + " §2m";
            BleachLogger.infoMessage("\n§6Entity Stats:\n§cMax Health: §b" + maxHealth + "\n§cSpeed: §b" + speed + "\n§cJump: §b" + jumpHeight);
        } else if (mc.player.getVehicle() instanceof LivingEntity) {
            LivingEntity l = (LivingEntity) mc.player.getVehicle();
            maxHealth = l.getHealthMaximum() + " §2HP";
            speed = round(43.17 * l.getMovementSpeed(), 2) + " §2m/s";
            BleachLogger.infoMessage("\n§6Entity Stats:\n§cMax Health: §b" + maxHealth + "\n§cSpeed: §b" + speed);
        }
    } else {
        BleachLogger.errorMessage("Not riding a living entity.");
    }
}
 
Example #7
Source File: CCBakeryModel.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public ItemOverrideList getOverrides() {
    return new ItemOverrideList() {
        @Override
        public IBakedModel getModelWithOverrides(IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity) {
            IBakedModel model = ModelBakery.getCachedItemModel(stack);
            if (model == null) {
                return originalModel;
            }
            return model;
        }
    };
}
 
Example #8
Source File: Pony.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public IPony getMountedPony(LivingEntity entity) {
    if (entity.hasVehicle() && entity.getVehicle() instanceof LivingEntity) {
        LivingEntity mount = (LivingEntity) entity.getVehicle();

        IPonyRenderContext<LivingEntity, ?> render = PonyRenderDispatcher.getInstance().getPonyRenderer(mount);

        return render == null ? null : render.getEntityPony(mount);
    }
    return null;
}
 
Example #9
Source File: MixinShearsItem.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean useOnEntity(ItemStack stack, PlayerEntity playerIn, LivingEntity entity, Hand hand) {
	if (entity.world.isClient) {
		return false;
	}

	// Avoid duplicating vanilla interactions
	if (this == Items.SHEARS) {
		EntityType<?> type = entity.getType();

		if (type == EntityType.MOOSHROOM || type == EntityType.SHEEP || type == EntityType.SNOW_GOLEM) {
			return false;
		}
	}

	if (entity instanceof IShearable) {
		IShearable target = (IShearable) entity;
		BlockPos pos = entity.getBlockPos();

		if (target.isShearable(stack, entity.world, pos)) {
			Shearables.shearEntity(stack, entity.world, pos, target);
		}

		return true;
	}

	return false;
}
 
Example #10
Source File: MixinOtherClientPlayerEntity.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
private void hookDamage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> callback) {
	LivingEntity entity = (LivingEntity) (Object) this;

	if (EntityEvents.onLivingAttack(entity, source, amount)) {
		callback.setReturnValue(false);
	}
}
 
Example #11
Source File: GalacticraftItems.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public boolean postMine(ItemStack stack, World world, BlockState blockState, BlockPos blockPos, LivingEntity entityLiving) {
    //Stronger than vanilla
    if (blockState.getHardness(null, blockPos) > 0.2001F) {
        stack.damage(2, entityLiving, (livingEntity) -> livingEntity.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));
    }
    return true;
}
 
Example #12
Source File: MiningGadget.java    From MiningGadgets with MIT License 5 votes vote down vote up
@OnlyIn(Dist.CLIENT)
public void playLoopSound(LivingEntity player, ItemStack stack) {
    float volume = MiningProperties.getVolume(stack);
    PlayerEntity myplayer = Minecraft.getInstance().player;
    if (myplayer.equals(player)) {
        if (volume != 0.0f) {
            if (laserLoopSound == null) {
                laserLoopSound = new LaserLoopSound((PlayerEntity) player, volume);
                Minecraft.getInstance().getSoundHandler().play(laserLoopSound);
            }
        }
    }
}
 
Example #13
Source File: LivingDropsEvent.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
public LivingDropsEvent(LivingEntity entity, DamageSource source, Collection<ItemEntity> drops, int lootingLevel, boolean recentlyHit) {
	super(entity);
	this.source = source;
	this.drops = drops;
	this.lootingLevel = lootingLevel;
	this.recentlyHit = recentlyHit;
}
 
Example #14
Source File: PonyRenderDispatcher.java    From MineLittlePony with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Nullable
public <T extends LivingEntity, M extends EntityModel<T> & IPonyModel<T>> IPonyRenderContext<T, M> getPonyRenderer(@Nullable T entity) {
    if (entity == null) {
        return null;
    }

    EntityRenderer<?> renderer = MinecraftClient.getInstance().getEntityRenderManager().getRenderer(entity);

    if (renderer instanceof IPonyRenderContext) {
        return (IPonyRenderContext<T, M>) renderer;
    }

    return null;
}
 
Example #15
Source File: Pony.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public boolean isCrouching(LivingEntity entity) {

    boolean isSneak = entity.isInSneakingPose();
    boolean isFlying = isFlying(entity);
    boolean isSwimming = isSwimming(entity);

    return !isPerformingRainboom(entity) && !isSwimming && isSneak && !isFlying;
}
 
Example #16
Source File: BlockWrapper.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onPlaced(World world_1, BlockPos blockPos_1, BlockState blockState_1, @Nullable LivingEntity livingEntity_1, net.minecraft.item.ItemStack itemStack_1) {
    block.onBlockPlaced(
            (org.sandboxpowered.sandbox.api.world.World) world_1,
            (Position) blockPos_1,
            (org.sandboxpowered.sandbox.api.state.BlockState) blockState_1,
            (Entity) livingEntity_1,
            WrappingUtil.cast(itemStack_1, ItemStack.class)
    );
}
 
Example #17
Source File: IPonyRenderContext.java    From MineLittlePony with MIT License 5 votes vote down vote up
/**
 * Called by riders to have their transportation adjust their position.
 */
default void translateRider(T entity, IPony entityPony, LivingEntity passenger, IPony passengerPony, MatrixStack stack, float ticks) {
    if (!passengerPony.getRace(false).isHuman()) {
        float yaw = MathUtil.interpolateDegress((float)entity.prevY, (float)entity.getY(), ticks);

        getModelWrapper().apply(entityPony.getMetadata());
        M model = getModelWrapper().getBody();

        model.transform(BodyPart.BACK, stack);

        getInternalRenderer().applyPostureRiding(entity, stack, yaw, ticks);
    }
}
 
Example #18
Source File: DamageReporter.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static void register_final_damage(LivingEntity target, DamageSource source, float amount)
{
    if (!LoggerRegistry.__damage) return;
    LoggerRegistry.getLogger("damage").log( (option, player)->
        verifyAndProduceMessage(option, player, source.getSource(), target, () ->
            Messenger.c("g  - total received ",
                    String.format("r %.2f", amount),
                    "g  points of damage")
        )
    );
}
 
Example #19
Source File: ItemUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static boolean isPlayerHolding(LivingEntity entity, Predicate<Item> predicate) {
    for (Hand hand : Hand.values()) {
        ItemStack stack = entity.getHeldItem(hand);
        if (!stack.isEmpty()) {
            if (predicate.test(stack.getItem())) {
                return true;
            }
        }
    }
    return false;
}
 
Example #20
Source File: MixinLivingEntity.java    From multiconnect with MIT License 5 votes vote down vote up
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isSprinting()Z", ordinal = 0))
private boolean modifySwimSprintSpeed(LivingEntity self) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_12_2) {
        return false;
    }
    return self.isSprinting();
}
 
Example #21
Source File: Protocol_1_14_4.java    From multiconnect with MIT License 5 votes vote down vote up
@Override
public boolean acceptEntityData(Class<? extends Entity> clazz, TrackedData<?> data) {
    if (clazz == LivingEntity.class && data == LivingEntityAccessor.getStingerCount())
        return false;
    if (clazz == TridentEntity.class && data == TridentEntityAccessor.getHasEnchantmentGlint())
        return false;
    if (clazz == WolfEntity.class && data == WolfEntityAccessor.getBegging())
        DataTrackerManager.registerOldTrackedData(WolfEntity.class, OLD_WOLF_HEALTH, 20f, LivingEntity::setHealth);
    if (clazz == EndermanEntity.class && data == EndermanEntityAccessor.getProvoked())
        return false;

    return super.acceptEntityData(clazz, data);
}
 
Example #22
Source File: BackgroundRendererMixin.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Redirect(at = @At(value = "INVOKE",
	target = "Lnet/minecraft/entity/LivingEntity;hasStatusEffect(Lnet/minecraft/entity/effect/StatusEffect;)Z",
	ordinal = 0),
	method = {
		"render(Lnet/minecraft/client/render/Camera;FLnet/minecraft/client/world/ClientWorld;IF)V",
		"applyFog(Lnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/BackgroundRenderer$FogType;FZ)V"})
private static boolean wurstHasStatusEffect(LivingEntity entity,
	StatusEffect effect)
{
	if(effect == StatusEffects.BLINDNESS
		&& WurstClient.INSTANCE.getHax().antiBlindHack.isEnabled())
		return false;
	
	return entity.hasStatusEffect(effect);
}
 
Example #23
Source File: LivingEntityRendererMixin.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Redirect(at = @At(value = "INVOKE",
	target = "Lnet/minecraft/entity/LivingEntity;isInvisibleTo(Lnet/minecraft/entity/player/PlayerEntity;)Z",
	ordinal = 0),
	method = {
		"render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"})
private boolean canWurstSeePlayer(LivingEntity e, PlayerEntity player)
{
	if(WurstClient.INSTANCE.getHax().trueSightHack.isEnabled())
		return false;
	
	return e.isInvisibleTo(player);
}
 
Example #24
Source File: RadarHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUpdate()
{
	ClientPlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	entities.clear();
	Stream<Entity> stream =
		StreamSupport.stream(world.getEntities().spliterator(), true)
			.filter(e -> !e.removed && e != player)
			.filter(e -> !(e instanceof FakePlayerEntity))
			.filter(e -> e instanceof LivingEntity)
			.filter(e -> ((LivingEntity)e).getHealth() > 0);
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity
			&& ((PlayerEntity)e).isSleeping()));
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof Monster));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(
			e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	entities.addAll(stream.collect(Collectors.toList()));
}
 
Example #25
Source File: Rotation.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @param entity The placing entity, used for obtaining the look vector
 * @return The side towards which the entity is most directly looking.
 */
public static int getSideFromLookAngle(LivingEntity entity) {
    Vector3 look = new Vector3(entity.getLook(1));
    double max = 0;
    int maxs = 0;
    for (int s = 0; s < 6; s++) {
        double d = look.scalarProject(axes[s]);
        if (d > max) {
            max = d;
            maxs = s;
        }
    }
    return maxs;
}
 
Example #26
Source File: FollowCmd.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void call(String[] args) throws CmdException
{
	if(args.length != 1)
		throw new CmdSyntaxError();
	
	FollowHack followHack = WURST.getHax().followHack;
	
	if(followHack.isEnabled())
		followHack.setEnabled(false);
	
	Entity entity = StreamSupport
		.stream(MC.world.getEntities().spliterator(), true)
		.filter(e -> e instanceof LivingEntity)
		.filter(e -> !e.removed && ((LivingEntity)e).getHealth() > 0)
		.filter(e -> e != MC.player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> args[0].equalsIgnoreCase(e.getName().getString()))
		.min(
			Comparator.comparingDouble(e -> MC.player.squaredDistanceTo(e)))
		.orElse(null);
	
	if(entity == null)
		throw new CmdError(
			"Entity \"" + args[0] + "\" could not be found.");
	
	followHack.setEntity(entity);
	followHack.setEnabled(true);
}
 
Example #27
Source File: HealthTagsHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
public String addHealth(LivingEntity entity, String nametag)
{
	if(!isEnabled())
		return nametag;
	
	int health = (int)entity.getHealth();
	return nametag + " " + getColor(health) + health;
}
 
Example #28
Source File: ProtectCmd.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void call(String[] args) throws CmdException
{
	if(args.length != 1)
		throw new CmdSyntaxError();
	
	ProtectHack protectHack = WURST.getHax().protectHack;
	
	if(protectHack.isEnabled())
		protectHack.setEnabled(false);
	
	Entity entity = StreamSupport
		.stream(MC.world.getEntities().spliterator(), true)
		.filter(e -> e instanceof LivingEntity)
		.filter(e -> !e.removed && ((LivingEntity)e).getHealth() > 0)
		.filter(e -> e != MC.player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> args[0].equalsIgnoreCase(e.getName().getString()))
		.min(
			Comparator.comparingDouble(e -> MC.player.squaredDistanceTo(e)))
		.orElse(null);
	
	if(entity == null)
		throw new CmdError(
			"Entity \"" + args[0] + "\" could not be found.");
	
	protectHack.setFriend(entity);
	protectHack.setEnabled(true);
}
 
Example #29
Source File: TntEntityMixin.java    From fabric-carpet with MIT License 5 votes vote down vote up
@Inject(method = "<init>(Lnet/minecraft/world/World;DDDLnet/minecraft/entity/LivingEntity;)V",
            at = @At("RETURN"))
private void modifyTNTAngle(World world, double x, double y, double z, LivingEntity entity, CallbackInfo ci)
{
    if (CarpetSettings.hardcodeTNTangle != -1.0D)
        setVelocity(-Math.sin(CarpetSettings.hardcodeTNTangle) * 0.02, 0.2, -Math.cos(CarpetSettings.hardcodeTNTangle) * 0.02);
}
 
Example #30
Source File: MixinLivingEntity.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
private void hookDamage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> callback) {
	LivingEntity entity = (LivingEntity) (Object) this;

	if (EntityEvents.onLivingAttack(entity, source, amount)) {
		callback.setReturnValue(false);
	}
}