improve overlay, fix spawner
This commit is contained in:
parent
330ee75a27
commit
81355293e3
5 changed files with 50 additions and 39 deletions
|
@ -101,6 +101,7 @@ import client.world.ChunkClient;
|
|||
import client.world.ChunkEmpty;
|
||||
import common.Version;
|
||||
import common.block.Block;
|
||||
import common.block.liquid.BlockLiquid;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.collect.Sets;
|
||||
|
@ -127,6 +128,7 @@ import common.init.SoundEvent;
|
|||
import common.item.Item;
|
||||
import common.item.ItemControl;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemBucket;
|
||||
import common.log.Log;
|
||||
import common.log.LogLevel;
|
||||
import common.net.bootstrap.Bootstrap;
|
||||
|
@ -510,6 +512,7 @@ public class Client implements IThreadListener {
|
|||
public World world;
|
||||
public EntityNPC player;
|
||||
public HitPosition pointed;
|
||||
public BlockPos pointedLiquid;
|
||||
public DisplayMode vidMode;
|
||||
public String dimensionName;
|
||||
public String message;
|
||||
|
@ -1170,19 +1173,21 @@ public class Client implements IThreadListener {
|
|||
String desc = null;
|
||||
String line1 = null;
|
||||
String line2 = null;
|
||||
if(this.pointed != null && this.pointed.type == ObjectType.BLOCK && this.pointed.block != null) {
|
||||
State state = this.world.getState(this.pointed.block);
|
||||
if((this.pointed != null && this.pointed.type == ObjectType.BLOCK && this.pointed.block != null) || this.pointedLiquid != null) {
|
||||
BlockPos pos = this.pointedLiquid != null ? this.pointedLiquid : this.pointed.block;
|
||||
State state = this.world.getState(pos);
|
||||
Block block = state.getBlock();
|
||||
if(block != Blocks.air) {
|
||||
if(this.pointedLiquid != null ? block.getMaterial().isLiquid() : block != Blocks.air) {
|
||||
desc = block.getDisplay();
|
||||
line1 = block.getInfo(this.world, this.pointed.block, state, this.player);
|
||||
line1 = block.getInfo(this.world, pos, state, this.player);
|
||||
boolean toolReq = block.getMaterial().isToolRequired();
|
||||
boolean harvestable = this.player.canHarvestBlock(block);
|
||||
line2 = Color.BLUE + "Werkzeug" + Color.DARK_GRAY + ": " + (block.getMiningTool() != null ? (block.getMaterial().isToolRequired() ? (harvestable ? Color.GREEN : Color.RED) : Color.LIGHT_GRAY) + block.getMiningTool().getDisplay() + (block.getMiningTool().isLevelled() ? (harvestable ? Color.ORK : Color.CRIMSON) + " Level " + (harvestable ? Color.DARK_GREEN : Color.DARK_RED) + (block.getMiningLevel() + 1) : "") : Color.GRAY + "Keins");
|
||||
line2 = Color.BLUE + "Werkzeug" + Color.DARK_GRAY + ": " + (block.getMiningTool() != null ? (toolReq ? (harvestable ? Color.GREEN : Color.RED) : Color.LIGHT_GRAY) + block.getMiningTool().getDisplay() + (block.getMiningTool().isLevelled() ? (toolReq ? (harvestable ? Color.ORK : Color.CRIMSON) : Color.DARK_GRAY) + " Level " + (toolReq ? (harvestable ? Color.DARK_GREEN : Color.DARK_RED) : Color.GRAY) + (block.getMiningLevel() + 1) : "") : Color.GRAY + "Keins");
|
||||
}
|
||||
}
|
||||
else if(this.pointed != null && this.pointed.type == ObjectType.ENTITY && this.pointed.entity != null) {
|
||||
Entity entity = this.pointed.entity;
|
||||
desc = entity.getName();
|
||||
desc = (entity instanceof EntityNPC npc ? (!npc.canCounter(this.player) ? Color.GREEN : (npc.canAttack(this.player) ? Color.RED : Color.BLUE)) : Color.LIGHT_GRAY) + entity.getCommandName();
|
||||
line1 = entity.getInfo(this.player);
|
||||
line2 = Color.CYAN + EntityRegistry.getEntityName(EntityRegistry.getEntityString(entity));
|
||||
}
|
||||
|
@ -1219,8 +1224,8 @@ public class Client implements IThreadListener {
|
|||
|
||||
if(this.infoOverlay) {
|
||||
Item item = null;
|
||||
if(this.pointed != null && this.pointed.type == ObjectType.BLOCK && this.pointed.block != null)
|
||||
item = this.world.getState(this.pointed.block).getBlock().getItem();
|
||||
if((this.pointed != null && this.pointed.type == ObjectType.BLOCK && this.pointed.block != null) || this.pointedLiquid != null)
|
||||
item = this.pointedLiquid != null ? (this.world.getState(this.pointedLiquid).getBlock() instanceof BlockLiquid liquid ? ItemBucket.getByFluid(liquid) : null) : this.world.getState(this.pointed.block).getBlock().getItem();
|
||||
else if(this.pointed != null && this.pointed.type == ObjectType.ENTITY && this.pointed.entity != null)
|
||||
item = this.pointed.entity.getItem();
|
||||
if(item != null) {
|
||||
|
@ -1901,29 +1906,34 @@ public class Client implements IThreadListener {
|
|||
;
|
||||
}
|
||||
|
||||
private String formatState(BlockPos pos, String desc) {
|
||||
State block = this.world.getState(pos);
|
||||
|
||||
if(!this.debugWorld) {
|
||||
block = block.getBlock().getState(block, this.world, pos);
|
||||
}
|
||||
|
||||
StringBuilder str = new StringBuilder(
|
||||
desc + ": " + BlockRegistry.getName(block.getBlock()) + "\n" +
|
||||
String.format("Position: %d %d %d", pos.getX(), pos.getY(), pos.getZ())
|
||||
);
|
||||
for(Entry<Property, Comparable> entry : block.getProperties().entrySet()) {
|
||||
str.append("\n" + (block.getBlock().getSavedProperties().contains(entry.getKey()) ? Color.NEON : Color.LIGHT_GRAY) + entry.getKey().getName() + Color.RESET + ": " + (entry.getValue() instanceof Boolean bool ? (bool ? Color.GREEN : Color.RED) + "" + entry.getValue() + Color.RESET : entry.getValue()));
|
||||
}
|
||||
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
public String getRight(boolean showPlayerInfo) {
|
||||
if(this.world == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!showPlayerInfo && this.pointed != null && this.pointed.type == HitPosition.ObjectType.BLOCK
|
||||
&& this.pointed.block != null) {
|
||||
BlockPos pos = this.pointed.block;
|
||||
State block = this.world.getState(pos);
|
||||
|
||||
if(!this.debugWorld) {
|
||||
block = block.getBlock().getState(block, this.world, pos);
|
||||
}
|
||||
|
||||
StringBuilder str = new StringBuilder(
|
||||
"Schaue auf: " + BlockRegistry.getName(block.getBlock()) + "\n" +
|
||||
String.format("Position: %d %d %d", pos.getX(), pos.getY(), pos.getZ())
|
||||
);
|
||||
for(Entry<Property, Comparable> entry : block.getProperties().entrySet()) {
|
||||
str.append("\n" + (block.getBlock().getSavedProperties().contains(entry.getKey()) ? Color.NEON : Color.LIGHT_GRAY) + entry.getKey().getName() + Color.RESET + ": " + (entry.getValue() instanceof Boolean bool ? (bool ? Color.GREEN : Color.RED) + "" + entry.getValue() + Color.RESET : entry.getValue()));
|
||||
}
|
||||
|
||||
return str.toString();
|
||||
if(!showPlayerInfo && ((this.pointed != null && this.pointed.type == HitPosition.ObjectType.BLOCK
|
||||
&& this.pointed.block != null) || this.pointedLiquid != null)) {
|
||||
return (this.pointed != null && this.pointed.type == HitPosition.ObjectType.BLOCK
|
||||
&& this.pointed.block != null ? this.formatState(this.pointed.block, "Schaue auf") : "") + (this.pointed != null && this.pointed.type == HitPosition.ObjectType.BLOCK
|
||||
&& this.pointed.block != null && this.pointedLiquid != null ? "\n" : "") + (this.pointedLiquid != null ? this.formatState(this.pointedLiquid, "Flüssigkeit") : "");
|
||||
}
|
||||
else if((this.pointed != null && this.pointed.type == HitPosition.ObjectType.ENTITY && this.pointed.entity != null) || showPlayerInfo) {
|
||||
Entity entity = showPlayerInfo ? this.player : this.pointed.entity;
|
||||
|
|
|
@ -29,6 +29,7 @@ import common.util.BlockPos;
|
|||
import common.util.BoundingBox;
|
||||
import common.util.ExtMath;
|
||||
import common.util.HitPosition;
|
||||
import common.util.HitPosition.ObjectType;
|
||||
import common.util.ParticleType;
|
||||
import common.util.Vec3;
|
||||
import common.world.World;
|
||||
|
@ -193,7 +194,7 @@ public class EntityRenderer {
|
|||
{
|
||||
this.gm.setPointedEntity(null);
|
||||
double max = this.gm.player != null ? this.gm.player.getReachDistance() : 5.0;
|
||||
this.gm.pointed = entity.rayTrace(max, partialTicks);
|
||||
this.gm.pointed = entity.rayTrace(max, partialTicks, false);
|
||||
double dist = max;
|
||||
Vec3 eye = entity.getPositionEyes(partialTicks);
|
||||
// boolean far = false;
|
||||
|
@ -286,6 +287,13 @@ public class EntityRenderer {
|
|||
this.gm.setPointedEntity(this.pointedEntity);
|
||||
}
|
||||
}
|
||||
|
||||
this.gm.pointedLiquid = null;
|
||||
if(this.gm.pointed.type != ObjectType.ENTITY) {
|
||||
HitPosition liquid = entity.rayTrace(max, partialTicks, true);
|
||||
if(liquid != null && liquid.type == ObjectType.BLOCK && liquid.block != null && this.gm.world.getState(liquid.block).getBlock().getMaterial().isLiquid())
|
||||
this.gm.pointedLiquid = liquid.block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1368,12 +1368,12 @@ public abstract class Entity
|
|||
}
|
||||
}
|
||||
|
||||
public HitPosition rayTrace(double blockReachDistance, float partialTicks)
|
||||
public HitPosition rayTrace(double blockReachDistance, float partialTicks, boolean liquid)
|
||||
{
|
||||
Vec3 vec3 = this.getPositionEyes(partialTicks);
|
||||
Vec3 vec31 = this.getLook(partialTicks);
|
||||
Vec3 vec32 = vec3.addVector(vec31.xCoord * blockReachDistance, vec31.yCoord * blockReachDistance, vec31.zCoord * blockReachDistance);
|
||||
return this.worldObj.rayTraceBlocks(vec3, vec32, false, false, true);
|
||||
return this.worldObj.rayTraceBlocks(vec3, vec32, liquid, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3391,6 +3391,8 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
public void onDataWatcherUpdate(int data) {
|
||||
if(this.isPlayer() && data == 11) // (data == 29 || data == 11)) // && this.worldObj.client)
|
||||
this.updateSize();
|
||||
else if(data == 8 && this.worldObj.client)
|
||||
this.alignment = this.getAlignment();
|
||||
}
|
||||
|
||||
private void updateSize() {
|
||||
|
|
|
@ -3008,7 +3008,7 @@ public abstract class EntityLiving extends Entity
|
|||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemMobTemplate)
|
||||
{
|
||||
if (!this.worldObj.client)
|
||||
if (!this.worldObj.client && player.connection.isAdmin())
|
||||
{
|
||||
// Class <? extends Entity > oclass = EntityRegistry.getClassFromName(((ItemMonsterPlacer)itemstack.getItem())
|
||||
// .getSpawnedId());
|
||||
|
@ -3028,15 +3028,6 @@ public abstract class EntityLiving extends Entity
|
|||
{
|
||||
child.setCustomNameTag(itemstack.getDisplayName());
|
||||
}
|
||||
|
||||
// if (!player.creative)
|
||||
// {
|
||||
|
||||
if (itemstack.decrSize())
|
||||
{
|
||||
player.setHeldItem(null);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue