make PlayerLog render nametags
All checks were successful
/ Build BaseBand DSM & Broadway (push) Successful in 2m22s
All checks were successful
/ Build BaseBand DSM & Broadway (push) Successful in 2m22s
This commit is contained in:
parent
f52123cf98
commit
e55ce809e7
1 changed files with 21 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
|||
package de.com.baseband.client.feature.modules.render;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import de.com.baseband.client.event.events.PlayerJoinedEvent;
|
||||
import de.com.baseband.client.event.events.PlayerLeftEvent;
|
||||
import de.com.baseband.client.event.events.PlayerLeftViewEvent;
|
||||
import de.com.baseband.client.feature.Feature;
|
||||
|
@ -12,14 +14,16 @@ import de.com.baseband.client.util.adapt.Marker;
|
|||
import de.com.baseband.client.util.render.Pixels;
|
||||
import de.com.baseband.client.util.render.SimpleRender;
|
||||
import de.tudbut.tools.Lock;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
@ -40,9 +44,11 @@ public class PlayerLog extends Feature {
|
|||
@Gate(1)
|
||||
public float opacity = 0.1f;
|
||||
|
||||
@Config("Remove on rejoin")
|
||||
public boolean removeOnRejoin = true;
|
||||
|
||||
HashMap<UUID, Pair<Lock, EntityPlayer>> originalPlayers = new HashMap<>();
|
||||
ArrayList<AxisAlignedBB> boxes = new ArrayList<>();
|
||||
HashMap<GameProfile, AxisAlignedBB> boxes = new HashMap<>();
|
||||
|
||||
public void onPlayerLeaveView(PlayerLeftViewEvent event) {
|
||||
Lock lock = new Lock();
|
||||
|
@ -53,10 +59,15 @@ public class PlayerLog extends Feature {
|
|||
public void onPlayerLeave(PlayerLeftEvent event) {
|
||||
Pair<Lock, EntityPlayer> pair = originalPlayers.get(event.playerInfo.getGameProfile().getId());
|
||||
if(pair != null) {
|
||||
boxes.add(pair.getRight().getEntityBoundingBox());
|
||||
boxes.put(pair.getRight().getGameProfile(), pair.getRight().getEntityBoundingBox());
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerJoin(PlayerJoinedEvent event) {
|
||||
if(removeOnRejoin)
|
||||
boxes.remove(event.playerInfo.getGameProfile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
if(originalPlayers.isEmpty())
|
||||
|
@ -76,17 +87,23 @@ public class PlayerLog extends Feature {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onRender(RenderWorldLastEvent event) {
|
||||
RenderManager renderManager = mc.getRenderManager();
|
||||
Vec3d eyePos = mc.getRenderViewEntity().getPositionEyes(event.getPartialTicks()).add(0, -mc.getRenderViewEntity().getEyeHeight(), 0);
|
||||
SimpleRender render = new SimpleRender(event.getPartialTicks());
|
||||
int c = Features.getFeature(Client.class).theme.getRedColor() | 0xff000000;
|
||||
if(wireframe)
|
||||
renderOn(render.color(c).lines()).end();
|
||||
if(fill)
|
||||
renderOn(render.color(Pixels.mulTransparency(c, opacity)).quadsFill()).end();
|
||||
for (Map.Entry<GameProfile, AxisAlignedBB> entry : boxes.entrySet()) {
|
||||
Vec3d center = entry.getValue().getCenter().subtract(eyePos);
|
||||
EntityRenderer.drawNameplate(mc.fontRenderer, entry.getKey().getName(), (float) center.x, (float) center.y, (float) center.z, 0, renderManager.playerViewX, renderManager.playerViewY, false, false);
|
||||
}
|
||||
render.finish();
|
||||
}
|
||||
|
||||
private SimpleRender.SimpleRenderBackend renderOn(SimpleRender.SimpleRenderBackend backend) {
|
||||
for (AxisAlignedBB box : boxes) {
|
||||
for (AxisAlignedBB box : boxes.values()) {
|
||||
backend.aabb(box);
|
||||
}
|
||||
return backend;
|
||||
|
|
Loading…
Add table
Reference in a new issue