mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-22 13:10:10 +00:00
Removed Block & Entity accessor and replaced it with the Common accessor.
Added a split in the line regexp for the icon. Created a icon renderer. Old waila Icon nomenclature is now turned into the proper renderer. Removed some empty methods in Tooltip.
This commit is contained in:
1 parent
9050654e42
commit
f9f2c4041e
16 files changed
+144
-347
No files matched your search
@@ -18,7 +18,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
*
|
||||
*/
|
||||
|
||||
public interface IWailaDataAccessor {
|
||||
public interface IWailaDataAccessor{
|
||||
|
||||
World getWorld();
|
||||
EntityPlayer getPlayer();
|
||||
|
||||
@@ -51,5 +51,5 @@ public class SpecialChars {
|
||||
public static final Pattern patternRight = Pattern.compile("(?i)" + ALIGNRIGHT);
|
||||
public static final Pattern patternCenter = Pattern.compile("(?i)" + ALIGNCENTER);
|
||||
public static final Pattern patternIcon = Pattern.compile("(?i)(" + WailaStyle + WailaIcon + "(?<type>[0-9A-Z]))");
|
||||
public static final Pattern patternLineSplit = Pattern.compile("(?i)(" + WailaStyle + WailaStyle + "[^" + WailaStyle + "]+|" + WailaStyle + WailaRenderer + "a\\{([^,}]*),?([^}]*)\\}|[^" + WailaStyle + "]+)");
|
||||
public static final Pattern patternLineSplit = Pattern.compile("(?i)(" + WailaStyle + WailaStyle + "[^" + WailaStyle + "]+|" + WailaStyle + WailaIcon + "[0-9A-Z]|" + WailaStyle + WailaRenderer + "a\\{([^,}]*),?([^}]*)\\}|[^" + WailaStyle + "]+)");
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorBlock implements IWailaDataAccessor {
|
||||
|
||||
World world;
|
||||
EntityPlayer player;
|
||||
MovingObjectPosition mop;
|
||||
Vec3 renderingvec = null;
|
||||
Block block;
|
||||
int blockID;
|
||||
int metadata;
|
||||
TileEntity entity;
|
||||
NBTTagCompound remoteNbt = null;
|
||||
long timeLastUpdate = System.currentTimeMillis();
|
||||
double partialFrame;
|
||||
ItemStack stack;
|
||||
|
||||
public static DataAccessorBlock instance = new DataAccessorBlock();
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
|
||||
this.set(_world, _player, _mop, null, 0.0);
|
||||
}
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, EntityLivingBase viewEntity, double partialTicks) {
|
||||
this.world = _world;
|
||||
this.player = _player;
|
||||
this.mop = _mop;
|
||||
//this.blockID = world.getBlockId(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
//this.block = Block.blocksList[this.blockID];
|
||||
this.block = world.getBlock(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.metadata = world.getBlockMetadata(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.entity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
try{ this.stack = new ItemStack(this.block, 1, this.metadata); } catch (Exception e) {}
|
||||
|
||||
|
||||
if (viewEntity != null){
|
||||
double px = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
|
||||
double py = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks;
|
||||
double pz = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks;
|
||||
this.renderingvec = Vec3.createVectorHelper(_mop.blockX - px, _mop.blockY - py, _mop.blockZ - pz);
|
||||
this.partialFrame = partialTicks;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return this.block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockID() {
|
||||
return this.blockID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata() {
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
public void setBlock(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public void setBlockID(int val) {
|
||||
this.blockID = val;
|
||||
}
|
||||
|
||||
public void setMetadata(int val) {
|
||||
this.metadata = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getPosition() {
|
||||
return this.mop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData() {
|
||||
if (this.entity == null) return null;
|
||||
|
||||
if (this.isTagCorrect(this.remoteNbt))
|
||||
return this.remoteNbt;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
try{
|
||||
this.entity.writeToNBT(tag);
|
||||
} catch (Exception e){}
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setNBTData(NBTTagCompound tag){
|
||||
this.remoteNbt = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNBTInteger(NBTTagCompound tag, String keyname){
|
||||
return NBTUtil.getNBTInteger(tag, keyname);
|
||||
}
|
||||
|
||||
private boolean isTagCorrect(NBTTagCompound tag){
|
||||
if (tag == null){
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int x = tag.getInteger("WailaX");
|
||||
int y = tag.getInteger("WailaY");
|
||||
int z = tag.getInteger("WailaZ");
|
||||
|
||||
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ)
|
||||
return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getRenderingPosition() {
|
||||
return this.renderingvec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPartialFrame() {
|
||||
return this.partialFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getSide(){
|
||||
return ForgeDirection.getOrientation(this.getPosition().sideHit);
|
||||
}
|
||||
|
||||
public boolean isTimeElapsed(long time){
|
||||
return System.currentTimeMillis() - this.timeLastUpdate >= time;
|
||||
}
|
||||
|
||||
public void resetTimer(){
|
||||
this.timeLastUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaEntityAccessor;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAccessor, IWailaEntityAccessor{
|
||||
|
||||
@@ -44,14 +45,18 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
|
||||
this.mop = _mop;
|
||||
|
||||
if (this.mop.typeOfHit == MovingObjectType.BLOCK){
|
||||
//this.blockID = world.getBlockId(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
//this.block = Block.blocksList[this.blockID];
|
||||
this.block = world.getBlock(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.metadata = world.getBlockMetadata(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.tileEntity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
|
||||
this.entity = null;
|
||||
try{ this.stack = new ItemStack(this.block, 1, this.metadata); } catch (Exception e) {}
|
||||
|
||||
} else if (this.mop.typeOfHit == MovingObjectType.ENTITY){
|
||||
this.entity = _mop.entityHit;
|
||||
this.block = null;
|
||||
this.metadata = -1;
|
||||
this.tileEntity = null;
|
||||
this.stack = null;
|
||||
this.entity = _mop.entityHit;
|
||||
}
|
||||
|
||||
if (viewEntity != null){
|
||||
@@ -64,45 +69,121 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {return null;}
|
||||
public World getWorld() {return this.world;}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {return null;}
|
||||
public EntityPlayer getPlayer() {return this.player;}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {return null;}
|
||||
public Block getBlock() {return this.block;}
|
||||
|
||||
@Override
|
||||
public int getBlockID() {return 0;}
|
||||
public int getBlockID() {return this.blockID;}
|
||||
|
||||
@Override
|
||||
public int getMetadata() {return 0;}
|
||||
public int getMetadata() {return this.metadata;}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity() {return null;}
|
||||
public TileEntity getTileEntity() { return this.tileEntity;}
|
||||
|
||||
@Override
|
||||
public Entity getEntity() {return null;}
|
||||
public Entity getEntity() {return this.entity;}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getPosition() {return null;}
|
||||
public MovingObjectPosition getPosition() {return this.mop;}
|
||||
|
||||
@Override
|
||||
public Vec3 getRenderingPosition() {return null;}
|
||||
public Vec3 getRenderingPosition() {return this.renderingvec;}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData() {return null;}
|
||||
public NBTTagCompound getNBTData() {
|
||||
if ((this.tileEntity != null) && this.isTagCorrectTileEntity(this.remoteNbt))
|
||||
return remoteNbt;
|
||||
|
||||
if ((this.entity != null) && this.isTagCorrectEntity(this.remoteNbt))
|
||||
return remoteNbt;
|
||||
|
||||
if (this.tileEntity != null){
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
try{
|
||||
this.tileEntity.writeToNBT(tag);
|
||||
} catch (Exception e){}
|
||||
return tag;
|
||||
}
|
||||
|
||||
if (this.entity != null){
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.entity.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setNBTData(NBTTagCompound tag){
|
||||
this.remoteNbt = tag;
|
||||
}
|
||||
|
||||
private boolean isTagCorrectTileEntity(NBTTagCompound tag){
|
||||
if (tag == null || !tag.hasKey("WailaX")){
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int x = tag.getInteger("WailaX");
|
||||
int y = tag.getInteger("WailaY");
|
||||
int z = tag.getInteger("WailaZ");
|
||||
|
||||
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ)
|
||||
return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isTagCorrectEntity(NBTTagCompound tag){
|
||||
if (tag == null || !tag.hasKey("WailaEntityID")){
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int id = tag.getInteger("WailaEntityID");
|
||||
|
||||
if (id == this.entity.getEntityId())
|
||||
return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNBTInteger(NBTTagCompound tag, String keyname) {
|
||||
return NBTUtil.getNBTInteger(tag, keyname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNBTInteger(NBTTagCompound tag, String keyname) {return 0;}
|
||||
public double getPartialFrame() {
|
||||
return this.partialFrame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPartialFrame() {return 0;}
|
||||
public ForgeDirection getSide() {
|
||||
return ForgeDirection.getOrientation(this.getPosition().sideHit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getSide() {return null;}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {return null;}
|
||||
public ItemStack getStack() {
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
public boolean isTimeElapsed(long time){
|
||||
return System.currentTimeMillis() - this.timeLastUpdate >= time;
|
||||
}
|
||||
|
||||
public void resetTimer(){
|
||||
this.timeLastUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
package mcp.mobius.waila.api.impl;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import mcp.mobius.waila.api.IWailaEntityAccessor;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorEntity implements IWailaEntityAccessor {
|
||||
|
||||
World world;
|
||||
EntityPlayer player;
|
||||
MovingObjectPosition mop;
|
||||
Vec3 renderingvec = null;
|
||||
Entity entity;
|
||||
NBTTagCompound remoteNbt = null;
|
||||
long timeLastUpdate = System.currentTimeMillis();
|
||||
double partialFrame;
|
||||
|
||||
public static DataAccessorEntity instance = new DataAccessorEntity();
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop) {
|
||||
this.set(_world, _player, _mop, null, 0.0);
|
||||
}
|
||||
|
||||
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, EntityLivingBase viewEntity, double partialTicks) {
|
||||
this.world = _world;
|
||||
this.player = _player;
|
||||
this.mop = _mop;
|
||||
this.entity = _mop.entityHit;
|
||||
|
||||
if (viewEntity != null){
|
||||
double px = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
|
||||
double py = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks;
|
||||
double pz = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks;
|
||||
this.renderingvec = Vec3.createVectorHelper(_mop.blockX - px, _mop.blockY - py, _mop.blockZ - pz);
|
||||
this.partialFrame = partialTicks;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getPosition() {
|
||||
return this.mop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData() {
|
||||
if (this.entity == null) return null;
|
||||
|
||||
if (this.isTagCorrect(this.remoteNbt))
|
||||
return this.remoteNbt;
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.entity.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
private boolean isTagCorrect(NBTTagCompound tag){
|
||||
if (tag == null){
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
|
||||
int x = tag.getInteger("x");
|
||||
int y = tag.getInteger("y");
|
||||
int z = tag.getInteger("z");
|
||||
|
||||
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ)
|
||||
return true;
|
||||
else {
|
||||
this.timeLastUpdate = System.currentTimeMillis() - 250;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNBTInteger(NBTTagCompound tag, String keyname){
|
||||
return NBTUtil.getNBTInteger(tag, keyname);
|
||||
}
|
||||
|
||||
public void setNBTData(NBTTagCompound tag){
|
||||
this.remoteNbt = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getRenderingPosition() {
|
||||
return this.renderingvec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPartialFrame() {
|
||||
return this.partialFrame;
|
||||
}
|
||||
|
||||
public boolean isTimeElapsed(long time){
|
||||
return System.currentTimeMillis() - this.timeLastUpdate >= time;
|
||||
}
|
||||
|
||||
public void resetTimer(){
|
||||
this.timeLastUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class MetaDataProvider{
|
||||
private Class prevBlock = null;
|
||||
private Class prevTile = null;
|
||||
|
||||
public ItemStack identifyBlockHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorBlock accessor) {
|
||||
public ItemStack identifyBlockHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorCommon accessor) {
|
||||
Block block = accessor.getBlock();
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
@@ -61,7 +61,7 @@ public class MetaDataProvider{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> handleBlockTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorBlock accessor, List<String> currenttip, Layout layout) {
|
||||
public List<String> handleBlockTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorCommon accessor, List<String> currenttip, Layout layout) {
|
||||
Block block = accessor.getBlock();
|
||||
|
||||
if (accessor.getTileEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250)){
|
||||
@@ -164,7 +164,7 @@ public class MetaDataProvider{
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
public List<String> handleEntityTextData(Entity entity, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorEntity accessor, List<String> currenttip, Layout layout) {
|
||||
public List<String> handleEntityTextData(Entity entity, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorCommon accessor, List<String> currenttip, Layout layout) {
|
||||
|
||||
if (accessor.getEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250)){
|
||||
accessor.resetTimer();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -34,7 +34,7 @@ public class Message0x02TENBTData extends SimpleChannelInboundHandler<Message0x0
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, Message0x02TENBTData msg) throws Exception {
|
||||
DataAccessorBlock.instance.setNBTData(msg.tag);
|
||||
DataAccessorCommon.instance.setNBTData(msg.tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ public class Message0x03EntRequest extends SimpleChannelInboundHandler<Message0x
|
||||
entity.writeToNBT(tag);
|
||||
tag = NBTUtil.createTag(tag, msg.keys);
|
||||
}
|
||||
|
||||
tag.setInteger("WailaEntityID", entity.getEntityId());
|
||||
|
||||
ctx.writeAndFlush(new Message0x04EntNBTData(tag)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}catch(Throwable e){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package mcp.mobius.waila.network;
|
||||
|
||||
import mcp.mobius.waila.api.impl.DataAccessorEntity;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -33,7 +33,7 @@ public class Message0x04EntNBTData extends SimpleChannelInboundHandler<Message0x
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, Message0x04EntNBTData msg) throws Exception {
|
||||
DataAccessorEntity.instance.setNBTData(msg.tag);
|
||||
DataAccessorCommon.instance.setNBTData(msg.tag);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mcp.mobius.waila.api.IWailaBlockDecorator;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -26,7 +26,7 @@ public class DecoratorRenderer {
|
||||
|
||||
double partialTicks = event.partialTicks;
|
||||
|
||||
DataAccessorBlock accessor = DataAccessorBlock.instance;
|
||||
DataAccessorCommon accessor = DataAccessorCommon.instance;
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
EntityLivingBase viewEntity = Minecraft.getMinecraft().renderViewEntity;
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.regex.Pattern;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -67,11 +67,9 @@ public class OverlayRenderer {
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
tooltip.drawStrings();
|
||||
tooltip.draw();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
tooltip.drawIcons();
|
||||
|
||||
if (tooltip.hasIcon)
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorEntity;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -114,7 +113,7 @@ public class RayTracing {
|
||||
return null;
|
||||
|
||||
if (ModuleRegistrar.instance().hasOverrideEntityProviders(this.target.entityHit))
|
||||
ents.add(ModuleRegistrar.instance().getOverrideEntityProviders(this.target.entityHit).get(0).getWailaOverride(DataAccessorEntity.instance, ConfigHandler.instance()));
|
||||
ents.add(ModuleRegistrar.instance().getOverrideEntityProviders(this.target.entityHit).get(0).getWailaOverride(DataAccessorCommon.instance, ConfigHandler.instance()));
|
||||
|
||||
if(ents.size() > 0)
|
||||
return ents.get(0);
|
||||
@@ -142,13 +141,13 @@ public class RayTracing {
|
||||
if (mouseoverBlock == null) return items;
|
||||
|
||||
if (ModuleRegistrar.instance().hasStackProviders(mouseoverBlock)){
|
||||
ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(mouseoverBlock).get(0).getWailaStack(DataAccessorBlock.instance, ConfigHandler.instance());
|
||||
ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(mouseoverBlock).get(0).getWailaStack(DataAccessorCommon.instance, ConfigHandler.instance());
|
||||
if (providerStack != null)
|
||||
items.add(providerStack);
|
||||
}
|
||||
|
||||
if (tileEntity != null && ModuleRegistrar.instance().hasStackProviders(tileEntity)){
|
||||
ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(tileEntity).get(0).getWailaStack(DataAccessorBlock.instance, ConfigHandler.instance());
|
||||
ItemStack providerStack = ModuleRegistrar.instance().getStackProviders(tileEntity).get(0).getWailaStack(DataAccessorCommon.instance, ConfigHandler.instance());
|
||||
if (providerStack != null)
|
||||
items.add(providerStack);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderIcon;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderString;
|
||||
import mcp.mobius.waila.utils.Constants;
|
||||
import static mcp.mobius.waila.api.SpecialChars.*;
|
||||
@@ -91,6 +91,7 @@ public class Tooltip {
|
||||
columnsPos.add(0);
|
||||
|
||||
for (String s : textData){
|
||||
|
||||
ArrayList<String> line = new ArrayList(Arrays.asList(patternTab.split(s)));
|
||||
ArrayList<Integer> size = new ArrayList<Integer>();
|
||||
for (String ss : line)
|
||||
@@ -138,6 +139,7 @@ public class Tooltip {
|
||||
String cs = lineMatcher.group();
|
||||
Renderable renderable = null;
|
||||
Matcher renderMatcher = patternRender.matcher(cs); //We keep a matcher here to be able to check if we have a Renderer. Might be better to do a startWith + full matcher init after the check
|
||||
Matcher iconMatcher = patternIcon.matcher(cs);
|
||||
|
||||
if (renderMatcher.find()){
|
||||
String renderName = renderMatcher.group("name");
|
||||
@@ -146,7 +148,8 @@ public class Tooltip {
|
||||
if (renderer != null){
|
||||
renderable = new Renderable(renderer, new Point(offsetX, offsetY), renderMatcher.group("args").split(","));
|
||||
}
|
||||
|
||||
} else if (iconMatcher.find()){
|
||||
renderable = new Renderable(new TTRenderIcon(iconMatcher.group("type")), new Point(offsetX, offsetY));
|
||||
} else {
|
||||
// Todo : The added offset should be based on the remaining of the column, not just the current string !
|
||||
if (cs.startsWith(ALIGNRIGHT))
|
||||
@@ -196,13 +199,13 @@ public class Tooltip {
|
||||
ty = (h - this.getRenderableTotalHeight())/2;
|
||||
}
|
||||
|
||||
public void drawStrings(){
|
||||
public void draw(){
|
||||
for (Renderable r : this.elements)
|
||||
r.draw(accessor, x + offsetX, y + ty);
|
||||
}
|
||||
|
||||
public void drawIcons(){
|
||||
|
||||
/*
|
||||
public void drawIcons(){
|
||||
for (int i = 0; i < lines.size(); i++){
|
||||
for (int c = 0; c < lines.get(i).ncolumns; c++){
|
||||
int offX = 0;
|
||||
@@ -222,6 +225,6 @@ public class Tooltip {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -5,8 +5,7 @@ import java.util.List;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorBlock;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorEntity;
|
||||
import mcp.mobius.waila.api.impl.DataAccessorCommon;
|
||||
import mcp.mobius.waila.api.impl.MetaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.TipList;
|
||||
import mcp.mobius.waila.client.KeyEvent;
|
||||
@@ -71,7 +70,7 @@ public class WailaTickHandler{
|
||||
MovingObjectPosition target = RayTracing.instance().getTarget();
|
||||
|
||||
if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){
|
||||
DataAccessorBlock accessor = DataAccessorBlock.instance;
|
||||
DataAccessorCommon accessor = DataAccessorCommon.instance;
|
||||
accessor.set(world, player, target);
|
||||
ItemStack targetStack = RayTracing.instance().getTargetStack(); // Here we get either the proper stack or the override
|
||||
|
||||
@@ -100,7 +99,7 @@ public class WailaTickHandler{
|
||||
}
|
||||
}
|
||||
else if (target != null && target.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY){
|
||||
DataAccessorEntity accessor = DataAccessorEntity.instance;
|
||||
DataAccessorCommon accessor = DataAccessorCommon.instance;
|
||||
accessor.set(world, player, target);
|
||||
|
||||
Entity targetEnt = RayTracing.instance().getTargetEntity(); // This need to be replaced by the override check.
|
||||
|
||||
@@ -2,19 +2,31 @@ package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.overlay.OverlayRenderer;
|
||||
import mcp.mobius.waila.overlay.IconUI;
|
||||
|
||||
public class TTRenderIcon implements IWailaTooltipRenderer {
|
||||
|
||||
final String type;
|
||||
final int IconSize = 8;
|
||||
|
||||
public TTRenderIcon(String type){
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
return null;
|
||||
return new Dimension(IconSize, IconSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor, int x, int y) {
|
||||
OverlayRenderer.renderIcon(x, y, IconSize, IconSize, IconUI.bySymbol(type));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user