use of net.minecraft.client.entity.EntityPlayerSP in project malmo by Microsoft.
the class HumanLevelCommandsImplementation method onRenderTick.
/**
* Called for each screen redraw - approximately three times as often as the other tick events,
* under normal conditions.<br>
* This is where we want to update our yaw/pitch, in order to get smooth panning etc
* (which is how Minecraft itself does it).
* The speed of the render ticks is not guaranteed, and can vary from machine to machine, so
* we try to account for this in the calculations.
* @param ev the RenderTickEvent object for this tick
*/
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev) {
if (ev.phase == Phase.START && this.isOverriding()) {
// Track average fps:
this.renderTickMonitor.beat();
if (this.isOverriding()) {
EntityPlayerSP player = Minecraft.getMinecraft().player;
if (player != null) {
if (this.targetPitchDelta != 0 || this.targetYawDelta != 0) {
player.turn(this.targetYawDeltaDelta, this.targetPitchDeltaDelta);
this.targetYawDelta -= this.targetYawDeltaDelta;
this.targetPitchDelta -= this.targetPitchDeltaDelta;
if (this.targetYawDelta / this.targetYawDeltaDelta < 1.0)
this.targetYawDeltaDelta = this.targetYawDelta;
if (this.targetPitchDelta / this.targetPitchDeltaDelta < 1.0)
this.targetPitchDeltaDelta = this.targetPitchDelta;
}
}
}
}
}
use of net.minecraft.client.entity.EntityPlayerSP in project Almura by AlmuraDev.
the class ClientboundNucleusNameChangeMappingPacketHandler method handleMessage.
@Override
public void handleMessage(final ClientboundNucleusNameChangeMappingPacket message, final RemoteConnection connection, final Platform.Type side) {
if (side.isClient()) {
final Minecraft client = Minecraft.getMinecraft();
if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
final UUID entityUniqueId = message.uuid;
final Text nickname = message.text;
this.nickManager.put(entityUniqueId, nickname);
final World world = client.world;
if (world != null) {
final EntityPlayer player = world.getPlayerEntityByUUID(entityUniqueId);
if (player != null) {
final String newNick = ForgeEventFactory.getPlayerDisplayName(player, TextSerializers.LEGACY_FORMATTING_CODE.serialize(nickname));
this.nickManager.put(entityUniqueId, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(newNick));
try {
this.nickManager.adjustPlayerNickname(player, newNick);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
// queue an update of the tab list display names (Vanilla may change the displayname in the PlayerListPacket)
client.addScheduledTask(() -> {
final EntityPlayerSP player = client.player;
if (player != null && player.connection != null) {
final NetworkPlayerInfo info = player.connection.getPlayerInfo(entityUniqueId);
if (info != null) {
info.setDisplayName(SpongeTexts.toComponent(nickname));
}
}
});
}
}
}
use of net.minecraft.client.entity.EntityPlayerSP in project Almura by AlmuraDev.
the class ClientboundNucleusNameMappingsPacketHandler method handleMessage.
@Override
public void handleMessage(final ClientboundNucleusNameMappingsPacket message, final RemoteConnection connection, final Platform.Type side) {
if (side.isClient()) {
final Minecraft client = Minecraft.getMinecraft();
if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
final Map<UUID, Text> nicknames = message.nicknames;
this.nickManager.putAll(nicknames);
final World world = client.world;
if (world != null) {
message.nicknames.forEach((uniqueId, nickname) -> {
final EntityPlayer player = world.getPlayerEntityByUUID(uniqueId);
if (player != null) {
final String newNick = ForgeEventFactory.getPlayerDisplayName(player, TextSerializers.LEGACY_FORMATTING_CODE.serialize(nickname));
this.nickManager.put(player.getUniqueID(), TextSerializers.LEGACY_FORMATTING_CODE.deserialize(newNick));
try {
this.nickManager.adjustPlayerNickname(player, newNick);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
});
}
client.addScheduledTask(() -> {
final EntityPlayerSP player = client.player;
if (player != null && player.connection != null) {
message.nicknames.forEach((uniqueId, nickname) -> {
final NetworkPlayerInfo info = player.connection.getPlayerInfo(uniqueId);
if (info != null) {
info.setDisplayName(SpongeTexts.toComponent(nickname));
}
});
}
});
}
}
}
use of net.minecraft.client.entity.EntityPlayerSP in project Almura by AlmuraDev.
the class MixinRenderPlayer method canRenderName.
/**
* @author Zidane
* @reason To have titles render under the nameplate
*/
/*
@Overwrite
protected void renderEntityName(AbstractClientPlayer entityIn, double x, double y, double z, String name, double distanceSq) {
if (distanceSq < 100.0D) {
// Draw bottom-up
Scoreboard scoreboard = entityIn.getWorldScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjectiveInDisplaySlot(2);
if (scoreobjective != null) {
Score score = scoreboard.getOrCreateScore(entityIn.getName(), scoreobjective);
this.renderLivingLabel(entityIn, score.getScorePoints() + " " + scoreobjective.getDisplayName(), x, y, z, 64);
y += (double) ((float) this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * 0.025F);
}
// Nickname
// Title
// Scoreboard
final String title = manager.getTitle(entityIn.getUniqueID());
if (title != null) {
this.renderLivingLabel(entityIn, title, x, y, z, 128);
y += (double) ((float) this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * 0.025F);
}
}
super.renderEntityName(entityIn, x, y, z, name, distanceSq);
} */
/**
* @author Dockter
* @reason Helps display name and title when in 3rd person view.
*/
@Override
protected boolean canRenderName(AbstractClientPlayer entity) {
EntityPlayerSP entityplayersp = Minecraft.getMinecraft().player;
boolean flag = !entity.isInvisibleToPlayer(entityplayersp);
Team team = entity.getTeam();
Team team1 = entityplayersp.getTeam();
if (team != null) {
Team.EnumVisible team$enumvisible = team.getNameTagVisibility();
switch(team$enumvisible) {
case ALWAYS:
return flag;
case NEVER:
return false;
case HIDE_FOR_OTHER_TEAMS:
return team1 == null ? flag : team.isSameTeam(team1) && (team.getSeeFriendlyInvisiblesEnabled() || flag);
case HIDE_FOR_OWN_TEAM:
return team1 == null ? flag : !team.isSameTeam(team1) && flag;
default:
return true;
}
}
return Minecraft.isGuiEnabled() && flag && !entity.isBeingRidden();
}
Aggregations