mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-15 09:34:53 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16eeb90243 | ||
|
|
3dcc754fb0 | ||
|
|
511aae0e52 | ||
|
|
f998f9ebfe | ||
|
|
6d0f162453 | ||
|
|
9e3ef39e30 |
No files matched your search
+1
-1
@@ -20,5 +20,5 @@ dependencies {
|
||||
runtimeOnlyNonPublishable(deobfCurse('thermal-expansion-69163:2388759'))
|
||||
runtimeOnlyNonPublishable(deobfCurse('thermal-dynamics-227443:2388756'))
|
||||
implementation(deobfCurse('cofh-core-69162:2388751'))
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.9.54:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.11.37:dev")
|
||||
}
|
||||
@@ -2,21 +2,29 @@ package mcp.mobius.waila.addons.vanillamc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderStack;
|
||||
import mcp.mobius.waila.utils.ColorUtils;
|
||||
|
||||
public class HUDHandlerFurnace implements IWailaDataProvider {
|
||||
|
||||
static Block furanace = Blocks.furnace;
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
@@ -31,45 +39,68 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
int cookTime = accessor.getNBTData().getShort("CookTime");
|
||||
NBTTagList tag = accessor.getNBTData().getTagList("Items", 10);
|
||||
NBTTagCompound tag = accessor.getNBTData();
|
||||
NBTTagList items = accessor.getNBTData().getTagList("Items", 10);
|
||||
String itemsText = "";
|
||||
ItemStack inputStack = null;
|
||||
ItemStack fuelStack = null;
|
||||
ItemStack outputStack = null;
|
||||
|
||||
String renderStr = "";
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(0));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
name,
|
||||
String.valueOf(stack.stackSize),
|
||||
String.valueOf(stack.getItemDamage()));
|
||||
}
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(1));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
name,
|
||||
String.valueOf(stack.stackSize),
|
||||
String.valueOf(stack.getItemDamage()));
|
||||
int smeltTime = tag.getInteger("Smelt");
|
||||
int fuelTime = tag.getInteger("Fuel");
|
||||
int maxFuelTime = tag.getInteger("MaxFuel");
|
||||
|
||||
double smeltProgress = (double) smeltTime / 200;
|
||||
double fuelProgress = (double) fuelTime / maxFuelTime;
|
||||
|
||||
for (int i = 0; i < items.tagCount(); i++) {
|
||||
NBTTagCompound itemTag = items.getCompoundTagAt(i);
|
||||
byte slot = itemTag.getByte("Slot");
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(itemTag);
|
||||
|
||||
if (slot == 0) {
|
||||
inputStack = stack;
|
||||
} else if (slot == 1) {
|
||||
fuelStack = stack;
|
||||
} else if (slot == 2) {
|
||||
outputStack = stack;
|
||||
}
|
||||
}
|
||||
|
||||
renderStr += SpecialChars.getRenderString("waila.progress", String.valueOf(cookTime), String.valueOf(200));
|
||||
|
||||
{
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(2));
|
||||
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
|
||||
renderStr += SpecialChars.getRenderString(
|
||||
"waila.stack",
|
||||
"1",
|
||||
name,
|
||||
String.valueOf(stack.stackSize),
|
||||
String.valueOf(stack.getItemDamage()));
|
||||
if (fuelProgress > 0) {
|
||||
String fuelBar = TTRenderBar.create(
|
||||
String.format("Fuel %ds / %ds", (maxFuelTime - fuelTime) / 20, maxFuelTime / 20),
|
||||
ColorUtils.fuelFurnaceBarTop.getColor(),
|
||||
ColorUtils.fuelFurnaceBarBottom.getColor(),
|
||||
1.0 - fuelProgress);
|
||||
currenttip.add(fuelBar);
|
||||
}
|
||||
|
||||
currenttip.add(renderStr);
|
||||
if (smeltProgress > 0) {
|
||||
String cookBar = TTRenderBar.create(
|
||||
String.format("Smelt %ds / %ds", smeltTime / 20, 200 / 20),
|
||||
ColorUtils.progressBarTop.getColor(),
|
||||
ColorUtils.progressBarBottom.getColor(),
|
||||
smeltProgress);
|
||||
currenttip.add(cookBar);
|
||||
}
|
||||
|
||||
if (inputStack != null) {
|
||||
itemsText += TTRenderStack.create(inputStack, inputStack.stackSize);
|
||||
}
|
||||
|
||||
if (fuelStack != null) {
|
||||
itemsText += TTRenderStack.create(fuelStack, fuelStack.stackSize);
|
||||
}
|
||||
|
||||
if (outputStack != null) {
|
||||
if (inputStack != null || fuelStack != null) {
|
||||
itemsText += TTRenderProgressBar.create(0, 1);
|
||||
}
|
||||
itemsText += TTRenderStack.create(outputStack, outputStack.stackSize);
|
||||
}
|
||||
|
||||
currenttip.add(itemsText);
|
||||
|
||||
return currenttip;
|
||||
}
|
||||
@@ -83,9 +114,19 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
if (te != null) te.writeToNBT(tag);
|
||||
if (te instanceof TileEntityFurnace furnace) {
|
||||
tag.setInteger("Smelt", furnace.furnaceCookTime);
|
||||
tag.setInteger("Fuel", furnace.furnaceBurnTime);
|
||||
tag.setInteger("MaxFuel", furnace.currentItemBurnTime);
|
||||
te.writeToNBT(tag);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static void register() {}
|
||||
public static void register() {
|
||||
IWailaDataProvider provider = new HUDHandlerFurnace();
|
||||
|
||||
ModuleRegistrar.instance().registerBodyProvider(provider, furanace.getClass());
|
||||
ModuleRegistrar.instance().registerNBTProvider(provider, furanace.getClass());
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import cpw.mods.fml.common.registry.GameData;
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaEntityAccessor;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerInventory;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
|
||||
public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAccessor, IWailaEntityAccessor {
|
||||
@@ -123,9 +124,23 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData() {
|
||||
if ((this.tileEntity != null) && this.isTagCorrectTileEntity(this.remoteNbt)) return remoteNbt;
|
||||
if ((this.tileEntity != null) && this.isTagCorrectTileEntity(this.remoteNbt)) {
|
||||
if (!remoteNbt.getBoolean(HUDHandlerInventory.TAG_SUMMARY_ONLY)) return remoteNbt;
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
try {
|
||||
this.tileEntity.writeToNBT(tag);
|
||||
} catch (Exception ignored) {}
|
||||
return HUDHandlerInventory.mergeSummary(remoteNbt, tag);
|
||||
}
|
||||
|
||||
if ((this.entity != null) && this.isTagCorrectEntity(this.remoteNbt)) return remoteNbt;
|
||||
if ((this.entity != null) && this.isTagCorrectEntity(this.remoteNbt)) {
|
||||
if (!remoteNbt.getBoolean(HUDHandlerInventory.TAG_SUMMARY_ONLY)) return remoteNbt;
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
try {
|
||||
this.entity.writeToNBT(tag);
|
||||
} catch (Exception ignored) {}
|
||||
return HUDHandlerInventory.mergeSummary(remoteNbt, tag);
|
||||
}
|
||||
|
||||
if (this.tileEntity != null) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
@@ -21,6 +21,7 @@ import mcp.mobius.waila.api.IWailaEntityProvider;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.cbcore.Layout;
|
||||
import mcp.mobius.waila.client.KeyEvent;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerInventory;
|
||||
import mcp.mobius.waila.network.Message0x01TERequest;
|
||||
import mcp.mobius.waila.network.Message0x03EntRequest;
|
||||
import mcp.mobius.waila.network.WailaPacketHandler;
|
||||
@@ -80,7 +81,8 @@ public class MetaDataProvider {
|
||||
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(accessor.getTileEntity()));
|
||||
|
||||
if (!keys.isEmpty() || ModuleRegistrar.instance().hasNBTProviders(block)
|
||||
|| ModuleRegistrar.instance().hasNBTProviders(accessor.getTileEntity()))
|
||||
|| ModuleRegistrar.instance().hasNBTProviders(accessor.getTileEntity())
|
||||
|| HUDHandlerInventory.shouldRequest(accessor.getTileEntity()))
|
||||
WailaPacketHandler.INSTANCE.sendToServer(new Message0x01TERequest(accessor.getTileEntity(), keys));
|
||||
|
||||
} else if (accessor.getTileEntity() != null && !Waila.instance.serverPresent
|
||||
@@ -193,7 +195,8 @@ public class MetaDataProvider {
|
||||
if (ModuleRegistrar.instance().hasSyncedNBTKeys(accessor.getEntity()))
|
||||
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(accessor.getEntity()));
|
||||
|
||||
if (!keys.isEmpty() || ModuleRegistrar.instance().hasNBTEntityProviders(accessor.getEntity()))
|
||||
if (!keys.isEmpty() || ModuleRegistrar.instance().hasNBTEntityProviders(accessor.getEntity())
|
||||
|| HUDHandlerInventory.shouldRequest(accessor.getEntity()))
|
||||
WailaPacketHandler.INSTANCE.sendToServer(new Message0x03EntRequest(accessor.getEntity(), keys));
|
||||
|
||||
} else if (accessor.getEntity() != null && !Waila.instance.serverPresent && accessor.isTimeElapsed(250)) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import mcp.mobius.waila.handlers.HUDHandlerEntities;
|
||||
import mcp.mobius.waila.handlers.VanillaTooltipHandler;
|
||||
import mcp.mobius.waila.handlers.nei.NEIHandler;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderAspectString;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderFluidBar;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderHealth;
|
||||
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
|
||||
@@ -55,6 +56,7 @@ public class ProxyClient extends ProxyServer {
|
||||
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.health", new TTRenderHealth());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.stack", new TTRenderStack());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.bar", new TTRenderBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.progress", new TTRenderProgressBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.fluid", new TTRenderFluidBar());
|
||||
ModuleRegistrar.instance().registerTooltipRenderer("waila.rfenergy", new TTRenderRFBar());
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
package mcp.mobius.waila.handlers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryLargeChest;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaEntityAccessor;
|
||||
import mcp.mobius.waila.api.IWailaEntityProvider;
|
||||
import mcp.mobius.waila.api.impl.ConfigHandler;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.cbcore.LangUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
|
||||
/**
|
||||
* Shows "X items in Y of Z slots" for every block and entity that is an {@link IInventory}.
|
||||
* <p>
|
||||
* The server always adds the summary to the NBT answer of a {@link IInventory} target (see
|
||||
* {@link #writeSummary(Object, World, int, int, int, NBTTagCompound)}). This is not done with an NBT provider, because
|
||||
* an NBT provider would stop the synced NBT keys of other mods for all inventories.
|
||||
* <p>
|
||||
* If the client only asked because of the summary, the answer has only the summary and {@link #TAG_SUMMARY_ONLY}. The
|
||||
* client then adds the summary to its own NBT of the target, so that other mods still get the same NBT as before.
|
||||
*/
|
||||
public class HUDHandlerInventory implements IWailaDataProvider, IWailaEntityProvider {
|
||||
|
||||
public static final String CFG_SHOW = "general.showinventory";
|
||||
|
||||
private static final String TAG_ITEMS = "WailaInvItems";
|
||||
private static final String TAG_USED = "WailaInvUsed";
|
||||
private static final String TAG_SLOTS = "WailaInvSlots";
|
||||
public static final String TAG_SUMMARY_ONLY = "WailaInvOnly";
|
||||
|
||||
/**
|
||||
* @return true if the client must ask the server for the summary of this target.
|
||||
*/
|
||||
public static boolean shouldRequest(Object target) {
|
||||
// Players implement IInventory, so this also summarises player inventories. Test instanceof EntityPlayer to
|
||||
// skip.
|
||||
return target instanceof IInventory && ConfigHandler.instance().getConfig(CFG_SHOW, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Server side: adds the item count, the used slots and the total slots of the target to the tag.
|
||||
*/
|
||||
public static void writeSummary(Object target, NBTTagCompound tag) {
|
||||
if (!(target instanceof IInventory)) return;
|
||||
try {
|
||||
IInventory inv = (IInventory) target;
|
||||
|
||||
// Count both halves of a double chest. The chest updates its neighbours every tick.
|
||||
if (target instanceof TileEntityChest chest) {
|
||||
TileEntityChest other = chest.adjacentChestXNeg != null ? chest.adjacentChestXNeg
|
||||
: chest.adjacentChestXPos != null ? chest.adjacentChestXPos
|
||||
: chest.adjacentChestZNeg != null ? chest.adjacentChestZNeg : chest.adjacentChestZPos;
|
||||
if (other != null) inv = new InventoryLargeChest("", chest, other);
|
||||
}
|
||||
|
||||
long items = 0;
|
||||
int used = 0;
|
||||
int slots = inv.getSizeInventory();
|
||||
for (int i = 0; i < slots; i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack == null || stack.getItem() == null || stack.stackSize <= 0) continue;
|
||||
items += stack.stackSize;
|
||||
used++;
|
||||
}
|
||||
|
||||
tag.setLong(TAG_ITEMS, items);
|
||||
tag.setInteger(TAG_USED, used);
|
||||
tag.setInteger(TAG_SLOTS, slots);
|
||||
} catch (Exception e) {
|
||||
// Do not lose the data of the other providers because of one bad inventory
|
||||
WailaExceptionHandler.handleErr(e, "HUDHandlerInventory | " + target.getClass().getName(), null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Client side: adds the values of a summary only answer to the local NBT of the target.
|
||||
*/
|
||||
public static NBTTagCompound mergeSummary(NBTTagCompound remote, NBTTagCompound local) {
|
||||
for (String key : new String[] { TAG_ITEMS, TAG_USED, TAG_SLOTS }) {
|
||||
NBTBase tag = remote.getTag(key);
|
||||
if (tag != null) local.setTag(key, tag.copy());
|
||||
}
|
||||
return local;
|
||||
}
|
||||
|
||||
private static void addLine(NBTTagCompound tag, List<String> currenttip, IWailaConfigHandler config) {
|
||||
if (tag == null || !config.getConfig(CFG_SHOW, true) || !tag.hasKey(TAG_SLOTS)) return;
|
||||
int slots = tag.getInteger(TAG_SLOTS);
|
||||
if (slots <= 0) return;
|
||||
long items = tag.getLong(TAG_ITEMS);
|
||||
int used = tag.getInteger(TAG_USED);
|
||||
String key = items == 1 ? "hud.msg.inventory.single" : "hud.msg.inventory";
|
||||
currenttip.add(String.format(LangUtil.translateG(key), items, used, slots));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
addLine(accessor.getNBTData(), currenttip, config);
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x,
|
||||
int y, int z) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
addLine(accessor.getNBTData(), currenttip, config);
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor,
|
||||
IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(EntityPlayerMP player, Entity ent, NBTTagCompound tag, World world) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
HUDHandlerInventory provider = new HUDHandlerInventory();
|
||||
ModuleRegistrar.instance().addConfig("General", CFG_SHOW, true);
|
||||
ModuleRegistrar.instance().registerBodyProvider((IWailaDataProvider) provider, IInventory.class);
|
||||
ModuleRegistrar.instance().registerBodyProvider((IWailaEntityProvider) provider, IInventory.class);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataProvider;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerInventory;
|
||||
import mcp.mobius.waila.utils.AccessHelper;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
@@ -125,11 +126,16 @@ public class Message0x01TERequest extends SimpleChannelInboundHandler<Message0x0
|
||||
}
|
||||
}
|
||||
|
||||
} else if (msg.keys.isEmpty()) {
|
||||
// The client asked only for the inventory summary
|
||||
tag.setBoolean(HUDHandlerInventory.TAG_SUMMARY_ONLY, true);
|
||||
} else {
|
||||
entity.writeToNBT(tag);
|
||||
tag = NBTUtil.createTag(tag, msg.keys);
|
||||
}
|
||||
|
||||
HUDHandlerInventory.writeSummary(entity, tag);
|
||||
|
||||
tag.setInteger("WailaX", msg.posX);
|
||||
tag.setInteger("WailaY", msg.posY);
|
||||
tag.setInteger("WailaZ", msg.posZ);
|
||||
|
||||
@@ -16,6 +16,7 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import mcp.mobius.waila.api.IWailaEntityProvider;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerInventory;
|
||||
import mcp.mobius.waila.utils.AccessHelper;
|
||||
import mcp.mobius.waila.utils.NBTUtil;
|
||||
import mcp.mobius.waila.utils.WailaExceptionHandler;
|
||||
@@ -83,11 +84,16 @@ public class Message0x03EntRequest extends SimpleChannelInboundHandler<Message0x
|
||||
}
|
||||
}
|
||||
|
||||
} else if (msg.keys.isEmpty()) {
|
||||
// The client asked only for the inventory summary
|
||||
tag.setBoolean(HUDHandlerInventory.TAG_SUMMARY_ONLY, true);
|
||||
} else {
|
||||
entity.writeToNBT(tag);
|
||||
tag = NBTUtil.createTag(tag, msg.keys);
|
||||
}
|
||||
|
||||
HUDHandlerInventory.writeSummary(entity, tag);
|
||||
|
||||
tag.setInteger("WailaEntityID", entity.getEntityId());
|
||||
|
||||
WailaPacketHandler.INSTANCE.sendTo(new Message0x04EntNBTData(tag), WailaPacketHandler.getPlayer(ctx));
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package mcp.mobius.waila.overlay.tooltiprenderers;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import net.minecraft.client.gui.Gui;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaVariableWidthTooltipRenderer;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
|
||||
public class TTRenderBar implements IWailaVariableWidthTooltipRenderer {
|
||||
|
||||
private int maxStringW;
|
||||
private static final int HEIGHT = 12;
|
||||
|
||||
@Override
|
||||
public Dimension getSize(String[] params, IWailaCommonAccessor accessor) {
|
||||
String text = params[0];
|
||||
|
||||
int displayWidth = DisplayUtil.getDisplayWidth(text);
|
||||
|
||||
return new Dimension(displayWidth + 4, HEIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(String[] params, IWailaCommonAccessor accessor) {
|
||||
String text = params[0];
|
||||
int topColor = 0xFFFFEE55;
|
||||
int bottomColor = 0xFFFFA500;
|
||||
int fillWidth = maxStringW - 2;
|
||||
|
||||
if (params.length > 2) {
|
||||
try {
|
||||
topColor = Integer.parseInt(params[1]);
|
||||
bottomColor = Integer.parseInt(params[2]);
|
||||
|
||||
} catch (NumberFormatException ignored) {}
|
||||
}
|
||||
|
||||
if (params.length > 3) {
|
||||
try {
|
||||
double ratio = Double.parseDouble(params[3]);
|
||||
ratio = Math.max(0.0, Math.min(1.0, ratio));
|
||||
fillWidth = (int) ((maxStringW - 2) * ratio);
|
||||
} catch (NumberFormatException ignored) {}
|
||||
}
|
||||
|
||||
drawVerticalGradient(maxStringW - 1, 0xFF2A2A2A, 0xFF111111);
|
||||
|
||||
if (fillWidth > 0) {
|
||||
drawVerticalGradient(1 + fillWidth, topColor, bottomColor);
|
||||
}
|
||||
|
||||
DisplayUtil.drawThickBeveledBox(0, 0, maxStringW, HEIGHT, 1, 0xFF505050, 0xFF505050, -1);
|
||||
DisplayUtil.drawString(text, 2, 2, 0xFFFFFFFF, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxLineWidth(int width) {
|
||||
maxStringW = width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLineWidth() {
|
||||
return maxStringW;
|
||||
}
|
||||
|
||||
private void drawVerticalGradient(int x2, int topColor, int bottomColor) {
|
||||
int h = 11;
|
||||
if (x2 <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < h; i++) {
|
||||
float ratio = (float) i / (float) h;
|
||||
int color = blendColors(topColor, bottomColor, ratio);
|
||||
Gui.drawRect(1, i, x2, i + 1, color);
|
||||
}
|
||||
}
|
||||
|
||||
private int blendColors(int c1, int c2, float ratio) {
|
||||
int a1 = (c1 >> 24 & 0xFF), r1 = (c1 >> 16 & 0xFF), g1 = (c1 >> 8 & 0xFF), b1 = (c1 & 0xFF);
|
||||
int a2 = (c2 >> 24 & 0xFF), r2 = (c2 >> 16 & 0xFF), g2 = (c2 >> 8 & 0xFF), b2 = (c2 & 0xFF);
|
||||
|
||||
int a = (int) (a1 + (a2 - a1) * ratio);
|
||||
int r = (int) (r1 + (r2 - r1) * ratio);
|
||||
int g = (int) (g1 + (g2 - g1) * ratio);
|
||||
int b = (int) (b1 + (b2 - b1) * ratio);
|
||||
|
||||
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
public static String create(String text, int topColor, int bottomColor, double progress) {
|
||||
return SpecialChars.getRenderString(
|
||||
"waila.bar",
|
||||
text,
|
||||
String.valueOf(topColor),
|
||||
String.valueOf(bottomColor),
|
||||
String.valueOf(progress));
|
||||
}
|
||||
|
||||
public static String create(String text, int color, double progress) {
|
||||
return create(text, color, color, progress);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import mcp.mobius.waila.api.IWailaCommonAccessor;
|
||||
import mcp.mobius.waila.api.IWailaTooltipRenderer;
|
||||
import mcp.mobius.waila.api.SpecialChars;
|
||||
import mcp.mobius.waila.overlay.DisplayUtil;
|
||||
|
||||
public class TTRenderProgressBar implements IWailaTooltipRenderer {
|
||||
@@ -33,4 +34,8 @@ public class TTRenderProgressBar implements IWailaTooltipRenderer {
|
||||
|
||||
}
|
||||
|
||||
public static String create(int currentValue, int maxValue) {
|
||||
return SpecialChars.getRenderString("waila.progress", String.valueOf(currentValue), String.valueOf(maxValue));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class TTRenderStack implements IWailaTooltipRenderer {
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glScaled(scale, scale, 1.0f);
|
||||
|
||||
DisplayUtil.renderStack(0, 0, stack);
|
||||
DisplayUtil.renderStack(0, -1, stack);
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
@@ -69,4 +69,12 @@ public class TTRenderStack implements IWailaTooltipRenderer {
|
||||
public static String create(ItemStack itemStack, boolean small) {
|
||||
return create(itemStack, 1, small);
|
||||
}
|
||||
|
||||
public static String create(ItemStack itemStack) {
|
||||
return create(itemStack, false);
|
||||
}
|
||||
|
||||
public static String create(ItemStack itemStack, int amount) {
|
||||
return create(itemStack, amount, false);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import mcp.mobius.waila.api.IWailaRegistrar;
|
||||
import mcp.mobius.waila.api.impl.ModuleRegistrar;
|
||||
import mcp.mobius.waila.handlers.DecoratorFMP;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerFMP;
|
||||
import mcp.mobius.waila.handlers.HUDHandlerInventory;
|
||||
import mcp.mobius.waila.utils.LoadedMods;
|
||||
|
||||
public class ProxyServer {
|
||||
@@ -41,6 +42,7 @@ public class ProxyServer {
|
||||
|
||||
HUDHandlerVanilla.register();
|
||||
HUDHandlerFurnace.register();
|
||||
HUDHandlerInventory.register();
|
||||
|
||||
/* BUILDCRAFT */
|
||||
BCModule.register();
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package mcp.mobius.waila.utils;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.color.ColorResource;
|
||||
|
||||
public class ColorUtils {
|
||||
|
||||
private static final ColorResource.Factory color = new ColorResource.Factory("waila");
|
||||
|
||||
public static final ColorResource
|
||||
// spotless:off
|
||||
fuelFurnaceBarTop = color.argb("fuelFurnaceBarTop", "0xFFFF8800"),
|
||||
fuelFurnaceBarBottom = color.argb("fuelFurnaceBarBottom", "0xFFFFCC00"),
|
||||
progressBarTop = color.argb("progressBarTop", "0xFFFF0000"),
|
||||
progressBarBottom = color.argb("progressBarBottom", "0xFF8B0000");
|
||||
// spotless:on
|
||||
|
||||
}
|
||||
@@ -43,6 +43,8 @@ client.msg.nousage=No usage found.
|
||||
hud.msg.holdkeymoreinfo=Hold %s for more info
|
||||
|
||||
hud.msg.empty=Empty
|
||||
hud.msg.inventory=%d items in %d of %d slots
|
||||
hud.msg.inventory.single=%d item in %d of %d slots
|
||||
hud.msg.output=Output
|
||||
hud.msg.input=Input
|
||||
hud.msg.out=Out
|
||||
@@ -153,6 +155,7 @@ option.stevescarts.shifttoggle=Shift toggle
|
||||
option.general.showents=Show entities
|
||||
option.general.showhp=Show entities health
|
||||
option.general.showcrop=Show crop growth
|
||||
option.general.showinventory=Show inventory summary
|
||||
option.thaumcraft.aspects=Show aspects
|
||||
|
||||
nei.options.keys.showenchant=Show enchanting values
|
||||
Reference in new issue
Block a user