use of net.minecraft.client.network.ClientPlayerEntity in project Terracraft by SimplyCmd.
the class MirrorItem method use.
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
if (// Get server player
playerEntity instanceof ServerPlayerEntity)
// Get server player
player = (ServerPlayerEntity) playerEntity;
else // Get client player
if (playerEntity instanceof ClientPlayerEntity)
clientPlayer = (ClientPlayerEntity) playerEntity;
if (!tick) {
final MinecraftClient client = MinecraftClient.getInstance();
client.particleManager.addEmitter(clientPlayer, ParticleTypes.END_ROD, 30);
client.gameRenderer.showFloatingItem(this.getDefaultStack());
player.getWorld().playSound(playerEntity, playerEntity.getBlockPos(), SoundRegistry.ITEM_MAGIC_MIRROR_USE_EVENT, SoundCategory.PLAYERS, 1f, 1f);
tick = true;
return TypedActionResult.success(playerEntity.getStackInHand(hand));
} else {
return TypedActionResult.fail(playerEntity.getStackInHand(hand));
}
}
use of net.minecraft.client.network.ClientPlayerEntity in project Client by MatHax.
the class DropCommand method drop.
private int drop(PlayerConsumer consumer) throws CommandSyntaxException {
ClientPlayerEntity player = mc.player;
assert player != null;
if (player.isSpectator())
throw NOT_SPECTATOR.create();
consumer.accept(player);
return SINGLE_SUCCESS;
}
use of net.minecraft.client.network.ClientPlayerEntity in project Skyblocker by LifeIsAParadox.
the class ChatHudListenerMixin method onMessage.
@Inject(method = "onChatMessage", at = @At("HEAD"), cancellable = true)
public void onMessage(MessageType messageType, Text message, UUID senderUuid, CallbackInfo ci) {
if (!Utils.isOnSkyblock)
return;
String asString = message.getString();
ChatFilterResult result = ChatMessageListener.EVENT.invoker().onMessage(message, asString);
switch(result) {
case ACTION_BAR:
ClientPlayerEntity player = client.player;
// Couldn't have received original message if client was null
assert player != null;
player.sendMessage(message, true);
case FILTER:
ci.cancel();
}
}
use of net.minecraft.client.network.ClientPlayerEntity in project Insane by 16underscore.
the class Killaura method lookAtTarget.
private void lookAtTarget(LivingEntity le) {
ClientPlayerEntity p = mc.player;
Vec3d pPos = p.getPos(), lePos = le.getPos();
double deltaX = lePos.getX() - pPos.getX(), deltaY = (lePos.getY() + le.getEyeHeight(le.getPose())) - (pPos.getY() + p.getEyeHeight(p.getPose())), deltaZ = lePos.getZ() - pPos.getZ(), distanceXZ = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
float pitch = MathHelper.wrapDegrees((float) Math.toDegrees(-MathHelper.atan2(deltaY, distanceXZ))), yaw = MathHelper.wrapDegrees((float) Math.toDegrees(MathHelper.atan2(deltaZ, deltaX)) - 90F);
p.setPitch(pitch);
p.setYaw(yaw);
mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(yaw, pitch, p.isOnGround()));
mc.cameraEntity.setPitch(p.prevPitch);
mc.cameraEntity.setYaw(p.prevYaw);
}
use of net.minecraft.client.network.ClientPlayerEntity in project Skyblocker by SkyblockerMod.
the class StatusBarTracker method updateHealth.
private void updateHealth(Matcher m) {
int value = parseInt(m, 1);
int max = parseInt(m, 2);
int overflow = 0;
ClientPlayerEntity player = null;
try {
player = MinecraftClient.getInstance().player;
}// Is triggered by tests. Couldn't come up with a better solution.
catch (NullPointerException ignored) {
}
if (player != null) {
int hp = (int) (player.getHealth() * max / player.getMaxHealth());
overflow = value - hp;
value = hp;
} else if (value > max) {
overflow = value - max;
value = max;
}
if (overflow > max)
overflow = max;
this.health = new Resource(value, max, overflow);
}
Aggregations