net.minecraft.client.network.AbstractClientPlayerEntity Java Examples

The following examples show how to use net.minecraft.client.network.AbstractClientPlayerEntity. 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: SkirtCostumeItem.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
@Environment(EnvType.CLIENT)
public void render(String slot, MatrixStack matrix, VertexConsumerProvider vertexConsumer, int light, PlayerEntityModel<AbstractClientPlayerEntity> model, AbstractClientPlayerEntity player, float headYaw, float headPitch) {
	ItemRenderer renderer = MinecraftClient.getInstance().getItemRenderer();
	matrix.push();
	translateToChest(model, player, headYaw, headPitch, matrix); //TODO switch back to trinkets version once it's fixed
	matrix.push();
	matrix.translate(0.25, 0.65, 0);
	matrix.scale(0.5F, 0.5F, 0.5F);
	matrix.multiply(ROTATION_CONSTANT);
	renderer.renderItem(new ItemStack(Items.BLAZE_ROD), ModelTransformation.Mode.FIXED, light, OverlayTexture.DEFAULT_UV, matrix, vertexConsumer);
	matrix.pop();
	matrix.push();
	matrix.translate(-0.25, 0.65, 0);
	matrix.scale(0.5F, 0.5F, 0.5F);
	matrix.multiply(ROTATION_CONSTANT);
	renderer.renderItem(new ItemStack(Items.BLAZE_ROD), ModelTransformation.Mode.FIXED, light, OverlayTexture.DEFAULT_UV, matrix, vertexConsumer);
	matrix.pop();
	matrix.push();
	matrix.translate(0, 0.65, 0.325);
	matrix.scale(0.5F, 0.5F, 0.5F);
	matrix.multiply(ROTATION_CONSTANT);
	renderer.renderItem(new ItemStack(Items.BLAZE_ROD), ModelTransformation.Mode.FIXED, light, OverlayTexture.DEFAULT_UV, matrix, vertexConsumer);
	matrix.pop();
	matrix.pop();
}
 
Example #2
Source File: PlayerSeaponyRenderer.java    From MineLittlePony with MIT License 6 votes vote down vote up
@Override
public IPony getEntityPony(AbstractClientPlayerEntity player) {
    IPony pony = super.getEntityPony(player);

    boolean wet = pony.isPartiallySubmerged(player);

    model = manager.setModel(wet ? seapony : normalPony).getBody();

    float state = wet ? 100 : 0;
    float interpolated = pony.getMetadata().getInterpolator(player.getUuid()).interpolate("seapony_state", state, 5);

    if (!MathUtil.compareFloats(interpolated, state)) {
        double x = player.getX() + (player.getEntityWorld().getRandom().nextFloat() * 2) - 1;
        double y = player.getY() + (player.getEntityWorld().getRandom().nextFloat() * 2);
        double z = player.getZ() + (player.getEntityWorld().getRandom().nextFloat() * 2) - 1;

        player.getEntityWorld().addParticle(ParticleTypes.END_ROD, x, y, z, 0, 0, 0);
    }

    return pony;
}
 
Example #3
Source File: PlayerEspHack.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onUpdate()
{
	PlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	players.clear();
	Stream<AbstractClientPlayerEntity> stream = world.getPlayers()
		.parallelStream().filter(e -> !e.removed && e.getHealth() > 0)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> Math.abs(e.getY() - MC.player.getY()) <= 1e6);
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !e.isSleeping());
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	players.addAll(stream.collect(Collectors.toList()));
}
 
Example #4
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 6 votes vote down vote up
protected void renderArm(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, Arm side) {
    manager.updateModel(player, Mode.FIRST_PERSON);

    stack.push();
    float reflect = side == Arm.LEFT ? 1 : -1;

    stack.translate(reflect * 0.1F, -0.54F, 0);

    if (side == Arm.LEFT) {
        super.renderLeftArm(stack, renderContext, lightUv, player);
    } else {
        super.renderRightArm(stack, renderContext, lightUv, player);
    }

    stack.pop();
}
 
Example #5
Source File: CopyItemCmd.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private ItemStack getItem(AbstractClientPlayerEntity player, String slot)
	throws CmdSyntaxError
{
	switch(slot.toLowerCase())
	{
		case "hand":
		return player.inventory.getMainHandStack();
		
		case "head":
		return player.inventory.getArmorStack(3);
		
		case "chest":
		return player.inventory.getArmorStack(2);
		
		case "legs":
		return player.inventory.getArmorStack(1);
		
		case "feet":
		return player.inventory.getArmorStack(0);
		
		default:
		throw new CmdSyntaxError();
	}
}
 
Example #6
Source File: AltRenderer.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private static void bindSkinTexture(String name)
{
	Identifier location = AbstractClientPlayerEntity.getSkinId(name);
	
	if(loadedSkins.contains(name))
	{
		mc.getTextureManager().bindTexture(location);
		return;
	}
	
	try
	{
		PlayerSkinTexture img =
			AbstractClientPlayerEntity.loadSkin(location, name);
		img.load(mc.getResourceManager());
		
	}catch(IOException e)
	{
		e.printStackTrace();
	}
	
	mc.getTextureManager().bindTexture(location);
	loadedSkins.add(name);
}
 
Example #7
Source File: ElytraFeature.java    From MineLittlePony with MIT License 6 votes vote down vote up
protected Identifier getElytraTexture(T entity) {
    if (entity instanceof AbstractClientPlayerEntity) {
        AbstractClientPlayerEntity player = (AbstractClientPlayerEntity) entity;

        Identifier result;

        if (player.hasSkinTexture()) {
            result = player.getElytraTexture();

            if (result != null) return result;
        }

        if (player.hasSkinTexture() && player.isPartVisible(PlayerModelPart.CAPE)) {
            result = player.getCapeTexture();

            if (result != null) return result;
        }
    }

    return TEXTURE_ELYTRA;
}
 
Example #8
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 6 votes vote down vote up
@Override
public void render(AbstractClientPlayerEntity entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) {
    shadowRadius = manager.getShadowScale();
    super.render(entity, entityYaw, tickDelta, stack, renderContext, lightUv);
    DebugBoundingBoxRenderer.render(manager.getPony(entity), this, entity, stack, renderContext, tickDelta);

    // Translate the shadow position after everything is done
    // (shadows are drawn after us)
    if (!entity.hasVehicle() && !entity.isSleeping()) {
        float yaw = MathHelper.lerpAngleDegrees(tickDelta, entity.prevBodyYaw, entity.bodyYaw);
        float l = entity.getWidth() / 2 * manager.getPony(entity).getMetadata().getSize().getScaleFactor();

        stack.multiply(Vector3f.NEGATIVE_Y.getDegreesQuaternion(yaw));
        stack.translate(0, 0, -l);
    }
}
 
Example #9
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
protected void setupTransforms(AbstractClientPlayerEntity entity, MatrixStack stack, float ageInTicks, float rotationYaw, float partialTicks) {
    manager.preRenderCallback(entity, stack, partialTicks);
    rotationYaw = manager.getRenderYaw(entity, rotationYaw, partialTicks);
    super.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);

    manager.applyPostureTransform(entity, stack, rotationYaw, partialTicks);
}
 
Example #10
Source File: MixinEntityRenderDispatcher.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Redirect(
        method = "getRenderer(Lnet/minecraft/entity/Entity;)Lnet/minecraft/client/render/entity/EntityRenderer;",
        at = @At(
                value = "INVOKE",
                target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;getModel()Ljava/lang/String;"))
private String getPlayerModel(AbstractClientPlayerEntity player, Entity entity) {
    return PlayerModels.forRace(MineLittlePony.getInstance().getManager()
            .getPony(player)
            .getRace(false))
            .getId(player.getModel().contains("slim"));
}
 
Example #11
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public Identifier getDefaultTexture(AbstractClientPlayerEntity entity, Wearable wearable) {
    if (wearable == Wearable.SADDLE_BAGS) {
        if (getInternalRenderer().getModel().getMetadata().getRace() == Race.BATPONY) {
            return SaddleBags.TEXTURE;
        }
    }

    return IPonyRenderContext.super.getDefaultTexture(entity, wearable);
}
 
Example #12
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
protected void renderLabelIfPresent(AbstractClientPlayerEntity entity, Text name, MatrixStack stack, VertexConsumerProvider renderContext, int maxDistance) {
    stack.push();

    if (entity.isSleeping()) {
        if (entity.getSleepingPosition().isPresent() && entity.getEntityWorld().getBlockState(entity.getSleepingPosition().get()).getBlock() instanceof BedBlock) {
            double bedRad = Math.toRadians(entity.getSleepingDirection().asRotation());

            stack.translate(Math.cos(bedRad), 0, -Math.sin(bedRad));
        }
    }
    stack.translate(0, manager.getNamePlateYOffset(entity), 0);
    super.renderLabelIfPresent(entity, name, stack, renderContext, maxDistance);
    stack.pop();
}
 
Example #13
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public boolean shouldRender(AbstractClientPlayerEntity entity, Frustum camera, double camX, double camY, double camZ) {
    if (entity.isSleeping() && entity == MinecraftClient.getInstance().player) {
        return MinecraftClient.getInstance().options.perspective != 0
                && super.shouldRender(entity, camera, camX, camY, camZ);
    }
    return super.shouldRender(entity, manager.getFrustrum(entity, camera), camX, camY, camZ);
}
 
Example #14
Source File: HallowCharmItem.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public void render(String slot, MatrixStack matrix, VertexConsumerProvider vertexConsumer, int light, PlayerEntityModel<AbstractClientPlayerEntity> model, AbstractClientPlayerEntity player, float headYaw, float headPitch) {
	ItemRenderer renderer = MinecraftClient.getInstance().getItemRenderer();
	matrix.push();
	translateToChest(model, player, headYaw, headPitch, matrix); //TODO switch back to trinkets version once it's fixed
	matrix.translate(0, -0.15, 0);
	matrix.scale(0.5F, 0.5F, 0.5F);
	matrix.multiply(ROTATION_CONSTANT);
	renderer.renderItem(new ItemStack(HallowedItems.HALLOW_CHARM), ModelTransformation.Mode.FIXED, light, OverlayTexture.DEFAULT_UV, matrix, vertexConsumer);
	matrix.pop();
}
 
Example #15
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
protected void scale(AbstractClientPlayerEntity entity, MatrixStack stack, float tickDelta) {
    if (getModel() instanceof PlayerEntityModel) {
        ((PlayerEntityModel<?>)getModel()).setVisible(true);
    }

    if (manager.getModel().getAttributes().isSitting) {
        stack.translate(0, entity.getHeightOffset(), 0);
    }
}
 
Example #16
Source File: HallowCharmItem.java    From the-hallow with MIT License 5 votes vote down vote up
public static void translateToChest(PlayerEntityModel<AbstractClientPlayerEntity> model, AbstractClientPlayerEntity player, float headYaw, float headPitch, MatrixStack matrix) {
	if (player.isInSneakingPose() && !model.riding && !player.isSwimming()) {
		matrix.translate(0, 0.2, 0);
		matrix.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(model.torso.pitch * 57.5f));
	}
	matrix.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(model.torso.yaw * 57.5f));
	matrix.translate(0, 0.4, -0.16);
}
 
Example #17
Source File: CapeFeature.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public void render(MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, AbstractClientPlayerEntity player, float limbDistance, float limbAngle, float tickDelta, float age, float headYaw, float headPitch) {
    M model = getContextModel();

    if (player.hasSkinTexture() && !player.isInvisible()
            && player.isPartVisible(PlayerModelPart.CAPE) && player.getCapeTexture() != null
            && player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) {

        stack.push();

        model.transform(BodyPart.BODY, stack);
        stack.translate(0, 0.24F, 0);
        model.getBodyPart(BodyPart.BODY).rotate(stack);

        double capeX = MathHelper.lerp(tickDelta, player.capeX, player.prevCapeX) - MathHelper.lerp(tickDelta, player.prevX, player.getX());
        double capeY = MathHelper.lerp(tickDelta, player.capeY, player.prevCapeY) - MathHelper.lerp(tickDelta, player.prevY, player.getY());
        double capeZ = MathHelper.lerp(tickDelta, player.capeZ, player.prevCapeZ) - MathHelper.lerp(tickDelta, player.prevZ, player.getZ());

        float motionYaw = player.prevBodyYaw + (player.bodyYaw - player.prevBodyYaw);

        double sin = MathHelper.sin(motionYaw * PI / 180);
        double cos = (-MathHelper.cos(motionYaw * PI / 180));

        float capeMotionY = (float) capeY * 10;

        if (capeMotionY < -6) capeMotionY = -6;
        if (capeMotionY > 32) capeMotionY = 32;

        float capeMotionX = (float) (capeX * sin + capeZ * cos) * 100;

        float diagMotion =  (float) (capeX * cos - capeZ * sin) * 100;

        if (capeMotionX < 0) capeMotionX = 0;

        float camera = MathHelper.lerp(tickDelta, player.prevStrideDistance, player.strideDistance);
        capeMotionY += MathHelper.sin(MathHelper.lerp(tickDelta, player.prevHorizontalSpeed, player.horizontalSpeed) * 6) * 32 * camera;

        stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(2 + capeMotionX / 12 + capeMotionY));
        stack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion( diagMotion / 2));
        stack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-diagMotion / 2));
        stack.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(180));
        stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90));

        VertexConsumer vertices = renderContext.getBuffer(RenderLayer.getEntitySolid(player.getCapeTexture()));
        model.renderCape(stack, vertices, lightUv, OverlayTexture.DEFAULT_UV);
        stack.pop();
    }
}
 
Example #18
Source File: PonyManager.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Nullable
private Identifier getSkin(PlayerEntity player) {
    if (player instanceof AbstractClientPlayerEntity) {
        return ((AbstractClientPlayerEntity)player).getSkinTexture();
    }

    return null;
}
 
Example #19
Source File: MixinPlayerEntityRenderer.java    From multiconnect with MIT License 5 votes vote down vote up
@Inject(method = "getPositionOffset", at = @At("RETURN"), cancellable = true)
private void injectSleepingOffset(AbstractClientPlayerEntity player, float delta, CallbackInfoReturnable<Vec3d> ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_13_2) {
        Direction sleepingDir = player.getSleepingDirection();
        if (sleepingDir != null) {
            ci.setReturnValue(ci.getReturnValue().subtract(sleepingDir.getOffsetX() * 0.4, 0, sleepingDir.getOffsetZ() * 0.4));
        }
    }
}
 
Example #20
Source File: CopyItemCmd.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private AbstractClientPlayerEntity getPlayer(String name) throws CmdError
{
	for(AbstractClientPlayerEntity player : MC.world.getPlayers())
	{
		if(!player.getEntityName().equalsIgnoreCase(name))
			continue;
		
		return player;
	}
	
	throw new CmdError("Player \"" + name + "\" could not be found.");
}
 
Example #21
Source File: SkirtCostumeItem.java    From the-hallow with MIT License 5 votes vote down vote up
public static void translateToChest(PlayerEntityModel<AbstractClientPlayerEntity> model, AbstractClientPlayerEntity player, float headYaw, float headPitch, MatrixStack matrix) {
	if (player.isInSneakingPose() && !model.riding && !player.isSwimming()) {
		matrix.translate(0, 0.2, 0);
		matrix.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(model.torso.pitch * 57.5f));
	}
	matrix.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(model.torso.yaw * 57.5f));
	matrix.translate(0, 0.4, -0.16);
}
 
Example #22
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
public ModelWrapper<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> getModelWrapper() {
    return manager.playerModel;
}
 
Example #23
Source File: PlayerModelKey.java    From MineLittlePony with MIT License 4 votes vote down vote up
PlayerEntityRenderer create(
        EntityRenderDispatcher dispatcher,
        boolean slim,
        ModelKey<? extends ClientPonyModel<AbstractClientPlayerEntity>> key
);
 
Example #24
Source File: PlayerModelKey.java    From MineLittlePony with MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public Function<EntityRenderDispatcher, PlayerEntityRenderer> getRendererFactory(boolean slimArms) {
    return d -> rendererFactory.create(d, slimArms, (ModelKey<? extends ClientPonyModel<AbstractClientPlayerEntity>>)getKey(slimArms));
}
 
Example #25
Source File: PonyElytra.java    From MineLittlePony with MIT License 4 votes vote down vote up
/**
 * Sets the model's various rotation angles.
 *
 * See {@link AbstractPonyModel.setRotationAngles} for an explanation of the various parameters.
 */
@Override
public void setAngles(T entity, float limbDistance, float limbAngle, float age, float headYaw, float headPitch) {
    float rotateX = PI / 2;
    float rotateY = PI / 8;
    float rotateZ = PI / 12;

    float rpY = BODY_RP_Y_NOTSNEAK;

    if (entity.isFallFlying()) {
        float velY = 1;

        Vec3d motion = entity.getVelocity();
        if (motion.y < 0) {
            velY = 1 - (float) Math.pow(-motion.normalize().y, 1.5);
        }

        rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX;
        rotateY = velY * (PI / 2) + (1 - velY) * rotateY;
    } else if (isSneaking) {
        rotateX = PI * 1.175F;
        rotateY = PI / 2;
        rotateZ = PI / 4;
        rpY = BODY_RP_Y_SNEAK;
    }

    leftWing.pivotX = 5;
    leftWing.pivotY = rpY;

    if (entity instanceof AbstractClientPlayerEntity) {
        AbstractClientPlayerEntity player = (AbstractClientPlayerEntity) entity;

        player.elytraPitch += (rotateX - player.elytraPitch) / 10;
        player.elytraYaw += (rotateY - player.elytraYaw) / 10;
        player.elytraRoll += (rotateZ - player.elytraRoll) / 10;

        leftWing.pitch = player.elytraPitch;
        leftWing.yaw = player.elytraYaw;
        leftWing.roll = player.elytraRoll;
    } else {
        leftWing.pitch = rotateX;
        leftWing.yaw = rotateZ;
        leftWing.roll = rotateY;
    }

    rightWing.pivotX = -leftWing.pivotX;
    rightWing.pivotY = leftWing.pivotY;
    rightWing.pitch = leftWing.pitch;
    rightWing.yaw = -leftWing.yaw;
    rightWing.roll = -leftWing.roll;
}
 
Example #26
Source File: PlayerSeaponyRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
public PlayerSeaponyRenderer(EntityRenderDispatcher manager, boolean slim, ModelKey<? extends ClientPonyModel<AbstractClientPlayerEntity>> key) {
    super(manager, slim, key);

    normalPony = new ModelWrapper<>(ModelType.<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>>getPlayerModel(Race.UNICORN).getKey(slim));
    seapony = this.manager.getModelWrapper();
}
 
Example #27
Source File: FirstPersonRendererMixin.java    From the-hallow with MIT License 4 votes vote down vote up
@Inject(method = "renderFirstPersonItem(Lnet/minecraft/client/network/AbstractClientPlayerEntity;FFLnet/minecraft/util/Hand;FLnet/minecraft/item/ItemStack;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"), cancellable = true)
private void dontRenderOffHandItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float f, ItemStack item, float equipProgress, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo info) {
	if(hand == Hand.OFF_HAND && player.getStackInHand(Hand.MAIN_HAND).getItem() instanceof ClubItem) {
		info.cancel();
	}
}
 
Example #28
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
public IPony getEntityPony(AbstractClientPlayerEntity entity) {
    return MineLittlePony.getInstance().getManager().getPony(entity);
}
 
Example #29
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
public Identifier findTexture(AbstractClientPlayerEntity entity) {
    return getTexture(entity);
}
 
Example #30
Source File: PlayerPonyRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
public EquineRenderManager<AbstractClientPlayerEntity, ClientPonyModel<AbstractClientPlayerEntity>> getInternalRenderer() {
    return manager;
}