Compare commits

...
12 Commits
Author SHA1 Message Date
Thomas Guimbretiere e9c1cca8d5 Fixed null state and pos.
Fixed top layer of the double grass showing improperly.
Temporary removal of the metadata display while thinking of something.
Bumped the API version because deletions and stuff.
2015-12-13 17:45:59 +01:00
Girafi 6befca5ca5 Updated to FG 2.0 Snapshot, since it's stable now.
Removed the sourceJar task, since it's runned by default on gradlew build.
2015-10-13 02:24:37 +02:00
Girafi 764294df5e Changed back to FG 1.2. FG 2.0 is apparently still a bit broken 2015-09-11 22:59:39 +02:00
Girafi 3bfcf9361a Changed build.gradle to add supoort for Forge Gradle 2.0 2015-09-02 09:13:06 +02:00
Girafi d3533af13e Removed IWailaBlock 2015-08-17 01:55:22 +02:00
Girafi 6c4203cfa7 Fixed blocks turning white in the nether, when looking at them 2015-08-12 08:12:23 +02:00
Girafi 6b61229d58 And the rest of it.. 2015-08-12 06:03:36 +02:00
Girafi 1b3919aa57 Basic cleanup of the API 2015-08-12 05:54:47 +02:00
Girafi ecb2651017 Fixed HandlerEnchants 2015-08-11 11:30:27 +02:00
Girafi 57deccab0c Made the overlay show the mod name, instead of the mod ID 2015-08-10 20:58:17 +02:00
Girafi c1a3006344 Fixed a few issues that I left in 2015-08-06 01:40:09 +02:00
Girafi ee38010fa5 Intial 1.8 work 2015-08-06 00:28:10 +02:00
90 changed files with 995 additions and 1149 deletions

No files matched your search

+5 -10
View File
@@ -11,7 +11,7 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
}
}
@@ -32,10 +32,10 @@ repositories {
}
apply plugin: 'java'
apply plugin: 'forge'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'maven'
version = "1.5.11-RC3_1.7.10"
version = "1.5.11-RC3_1.8"
group= "mcp.mobius.waila" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Waila"
@@ -57,7 +57,8 @@ dependencies {
}
minecraft {
version = "1.7.10-${config.forge_version}-1.7.10"
version = "1.8-${config.forge_version}"
mappings = "snapshot_20141130"
runDir = "eclipse"
}
@@ -114,12 +115,6 @@ jar {
// }
}
task sourceJar(type: Jar) {
from sourceSets.main.java
from new File(root, "dev")
classifier = 'sources'
}
task devJar(type: Jar) {
from sourceSets.main.output
classifier = 'dev'
+6 -6
View File
@@ -1,7 +1,7 @@
mc_version=1.7.10
forge_version=10.13.4.1448
ccl_version=1.1.3.138
ccc_version=1.0.7.+
nei_version=1.0.5.+
mc_version=1.8
forge_version=11.14.3.1521
ccl_version=1.1.2.139
ccc_version=1.0.5.36
nei_version=1.0.5.82
mod_version=1.0
waila_version=1.5.2a
waila_version=1.5.2a
+22 -38
View File
@@ -1,50 +1,34 @@
package mcp.mobius.waila;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.network.NetworkHandler;
import mcp.mobius.waila.network.WailaPacketHandler;
import mcp.mobius.waila.overlay.OverlayConfig;
import mcp.mobius.waila.overlay.DecoratorRenderer;
import mcp.mobius.waila.overlay.WailaTickHandler;
import mcp.mobius.waila.server.ProxyServer;
import mcp.mobius.waila.utils.Constants;
import mcp.mobius.waila.utils.ModIdentification;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLModContainer;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.client.KeyEvent;
import mcp.mobius.waila.commands.CommandDumpHandlers;
import mcp.mobius.waila.network.NetworkHandler;
import mcp.mobius.waila.network.WailaPacketHandler;
import mcp.mobius.waila.overlay.DecoratorRenderer;
import mcp.mobius.waila.overlay.OverlayConfig;
import mcp.mobius.waila.overlay.WailaTickHandler;
import mcp.mobius.waila.server.ProxyServer;
import mcp.mobius.waila.utils.ModIdentification;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.FMLModContainer;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.*;
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
import net.minecraftforge.fml.relauncher.Side;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@Mod(modid="Waila", name="Waila", version="1.5.11", dependencies="after:NotEnoughItems@[1.0.4.0,)", acceptableRemoteVersions="*")
import java.lang.reflect.Field;
@Mod(modid="Waila", name="Waila", version="1.5.11", dependencies="after:NotEnoughItems@[1.0.5.0,)", acceptableRemoteVersions="*")
/*
@NetworkMod(channels = {"Waila"},clientSideRequired=false, serverSideRequired=false, connectionHandler = WailaConnectionHandler.class,
packetHandler = WailaPacketHandler.class, versionBounds="[1.5.0,)")
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -44,7 +45,7 @@ public class HUDHandlerCrop implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
return tag;
}
@@ -2,9 +2,9 @@ package mcp.mobius.waila.addons.buildcraft;
import java.lang.reflect.Method;
import net.minecraft.util.EnumFacing;
import org.apache.logging.log4j.Level;
import net.minecraftforge.common.util.ForgeDirection;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
@@ -23,7 +23,7 @@ public class BCModule {
public static void register(){
try{
TileTank = Class.forName("buildcraft.factory.TileTank");
TileTank_getTankInfo = TileTank.getMethod("getTankInfo", ForgeDirection.class);
TileTank_getTankInfo = TileTank.getMethod("getTankInfo", EnumFacing.class);
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tankamount");
ModuleRegistrar.instance().addConfig("Buildcraft", "bc.tanktype");
@@ -4,9 +4,9 @@ import java.util.List;
//import buildcraft.factory.TileTank;
import net.minecraft.client.renderer.EnumFaceDirection;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import org.apache.logging.log4j.Level;
import mcp.mobius.waila.Waila;
@@ -19,7 +19,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import mcp.mobius.waila.cbcore.LangUtil;
@@ -67,7 +66,7 @@ public class HUDHandlerBCTanks implements IWailaDataProvider {
public FluidTankInfo getTank(IWailaDataAccessor accessor){
FluidTankInfo tank = null;
try{
tank = ((FluidTankInfo[])BCModule.TileTank_getTankInfo.invoke(BCModule.TileTank.cast(accessor.getTileEntity()), ForgeDirection.UNKNOWN))[0];
tank = ((FluidTankInfo[])BCModule.TileTank_getTankInfo.invoke(BCModule.TileTank.cast(accessor.getTileEntity()), EnumFacing.DOWN))[0];
} catch (Exception e){
Waila.log.log(Level.ERROR, "[BC] Unhandled exception trying to access a tank for display !.\n" + String.valueOf(e));
return null;
@@ -76,7 +75,7 @@ public class HUDHandlerBCTanks implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
return tag;
}
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -57,7 +58,7 @@ public class HUDCarpentersBlocksTE implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -66,7 +67,7 @@ public class HUDHandlerCapacitor implements IWailaDataProvider{
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -70,7 +71,7 @@ public class HUDHandlerTesseract implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -75,7 +76,7 @@ public class HUDHandlerStorage implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -1,18 +1,19 @@
package mcp.mobius.waila.addons.etb;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import java.util.List;
public class HUDHandlerSocket implements IWailaDataProvider {
@@ -46,7 +47,7 @@ public class HUDHandlerSocket implements IWailaDataProvider {
ItemStack stack = new ItemStack(module, 1, sides[s]);
String tipstr = String.format("%-5s : %s ", ForgeDirection.getOrientation(s), stack.getDisplayName());
String tipstr = String.format("%-5s : %s ", EnumFacing.values()[s], stack.getDisplayName());
String configstr = "[ ";
@@ -105,7 +106,7 @@ public class HUDHandlerSocket implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -6,8 +6,9 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import mcp.mobius.waila.api.IWailaConfigHandler;
@@ -40,7 +41,7 @@ public class HUDHandlerDrum implements IWailaDataProvider {
IFluidHandler handler = (IFluidHandler)accessor.getTileEntity();
if (handler == null) return currenttip;
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
FluidTankInfo[] tanks = handler.getTankInfo(EnumFacing.DOWN);
if (tanks.length != 1) return currenttip;
currenttip.add(String.format("%d / %d mB", amount, tanks[0].capacity));
@@ -54,7 +55,7 @@ public class HUDHandlerDrum implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -34,7 +35,7 @@ public class HUDHandlerGravestone implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -46,7 +47,7 @@ public class HUDHandlerPamCrop implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
@@ -61,7 +62,7 @@ public class HUDHandlerTEGenerator implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
try{
double storage = -1;
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -44,7 +45,7 @@ public class HUDHandlerMagicalCrops implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -6,8 +6,9 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
@@ -30,7 +31,7 @@ public class HUDHandlerTank implements IWailaDataProvider {
IFluidHandler handler = (IFluidHandler)accessor.getTileEntity();
if (handler == null) return currenttip;
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
FluidTankInfo[] tanks = handler.getTankInfo(EnumFacing.DOWN);
if (tanks.length != 1) return currenttip;
FluidStack fluid = tanks[0].fluid;
@@ -54,7 +55,7 @@ public class HUDHandlerTank implements IWailaDataProvider {
IFluidHandler handler = (IFluidHandler)accessor.getTileEntity();
if (handler == null) return currenttip;
FluidTankInfo[] tanks = handler.getTankInfo(ForgeDirection.UNKNOWN);
FluidTankInfo[] tanks = handler.getTankInfo(EnumFacing.DOWN);
if (tanks.length != 1) return currenttip;
if(tanks[0].fluid != null)
@@ -71,7 +72,7 @@ public class HUDHandlerTank implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -1,12 +1,12 @@
package mcp.mobius.waila.addons.projectred;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaFMPAccessor;
import mcp.mobius.waila.api.IWailaFMPDecorator;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.utils.NBTUtil;
import net.minecraft.util.EnumFacing;
public class HUDDecoratorRsGateLogic implements IWailaFMPDecorator {
@@ -44,14 +44,14 @@ public class HUDDecoratorRsGateLogic implements IWailaFMPDecorator {
//orient = orient - ((orient & 0x10) + (orient & 0x8) + (orient & 0x4));
int hOrient = orient & 0x3;
ForgeDirection vOrient = ForgeDirection.getOrientation((orient - (orient & 0x3)) >> 2);
EnumFacing vOrient = EnumFacing.values()[(orient - (orient & 0x3)) >> 2];
//System.out.printf("%s\n", ForgeDirection.getOrientation(vOrient));
if (vOrient == ForgeDirection.EAST)
if (vOrient == EnumFacing.EAST)
hOrient -= 1;
if (vOrient == ForgeDirection.WEST)
if (vOrient == EnumFacing.WEST)
hOrient += 1;
if (hOrient == -1)
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
@@ -75,7 +76,7 @@ public class HUDHandlerTank implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -91,7 +92,7 @@ public class HUDTileEntityCamo implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -25,7 +26,7 @@ public class HUDHandlerStatues implements IWailaDataProvider {
try {
String skinName = (String)StatuesModule.skinName.get(accessor.getTileEntity());
if (skinName.equals("")){
TileEntity belowEnt = accessor.getWorld().getTileEntity(accessor.getPosition().blockX, accessor.getPosition().blockY - 1, accessor.getPosition().blockZ);
TileEntity belowEnt = accessor.getWorld().getTileEntity(new BlockPos(accessor.getPosition().getX(), accessor.getPosition().down().getY(), accessor.getPosition().getZ()));
if (StatuesModule.TileEntityStatue.isInstance(belowEnt))
skinName = (String)StatuesModule.skinName.get(belowEnt);
}
@@ -69,7 +70,7 @@ public class HUDHandlerStatues implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -150,7 +151,7 @@ public class HUDCargoManager implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -78,7 +79,7 @@ public class HUDCartAssembler implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -127,7 +128,7 @@ public class HUDLiquidManager implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -63,7 +64,7 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider{
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
try{
tag.setTag("Aspects", new NBTTagList());
@@ -75,7 +76,7 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider{
if (!hasReveal) return tag;
HashMap knownAspects = (HashMap) ThaumcraftModule.CommonProxy_getKnownAspects.invoke(ThaumcraftModule.Thaumcraft_proxy.get(null));
LinkedHashMap playerAspects = (LinkedHashMap) ThaumcraftModule.AspectList_aspects.get(knownAspects.get(player.getCommandSenderName()));
LinkedHashMap playerAspects = (LinkedHashMap) ThaumcraftModule.AspectList_aspects.get(knownAspects.get(player.getName()));
LinkedHashMap tileAspects = new LinkedHashMap();
if (ThaumcraftModule.IAspectContainer.isInstance(te)){
@@ -8,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
@@ -62,7 +63,7 @@ public class HUDHandlerDuct implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -1,6 +1,7 @@
package mcp.mobius.waila.addons.thermalexpansion;
import cpw.mods.fml.common.registry.GameData;
import net.minecraft.util.BlockPos;
import net.minecraftforge.fml.common.registry.GameData;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
@@ -36,7 +37,7 @@ public class HUDHandlerCache implements IWailaDataProvider {
color = name.substring(0, 2);
if(storedItem != null) {
String namex = GameData.getItemRegistry().getNameForObject(storedItem.getItem());
String namex = String.valueOf(GameData.getItemRegistry().getNameForObject(storedItem.getItem()));
name += String.format(" < " + SpecialChars.getRenderString("waila.stack", "1", namex, "0", String.valueOf(storedItem.getItemDamage())) + color + " %s >", storedItem.getDisplayName());
}
else
@@ -83,7 +84,7 @@ public class HUDHandlerCache implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if(te != null)
te.writeToNBT(tag);
try {
@@ -102,7 +103,7 @@ public class HUDHandlerCache implements IWailaDataProvider {
is.stackSize = tag.getInteger("Count");
is.setItemDamage(Math.max(0, tag.getShort("Damage")));
if (tag.hasKey("tag", 10)) {
is.stackTagCompound = tag.getCompoundTag("tag");
//is.stackTagCompound = tag.getCompoundTag("tag"); //TODO
}
return is;
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -42,7 +43,7 @@ public class HUDHandlerEnergyCell implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
try {
int recv = ThermalExpansionModule.TileEnergyCell_Recv.getInt(te);
int send = ThermalExpansionModule.TileEnergyCell_Send.getInt(te);
@@ -8,9 +8,9 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
@@ -38,11 +38,11 @@ public class HUDHandlerIBlockInfo implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
try{
List info = new ArrayList();
Block block = world.getBlock(x, y, z);
ThermalExpansionModule.IBlockInfo_getBlockInfo.invoke(block, world, x, y, z, ForgeDirection.UNKNOWN, player, info, false);
Block block = world.getBlockState(pos).getBlock();
ThermalExpansionModule.IBlockInfo_getBlockInfo.invoke(block, world, pos, EnumFacing.DOWN, player, info, false);
for (Object i : info){
System.out.printf("%s\n", i);
@@ -6,8 +6,9 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
@@ -51,7 +52,7 @@ public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
try{
Integer energy = -1;
Integer maxsto = -1;
@@ -59,11 +60,11 @@ public class HUDHandlerIEnergyHandler implements IWailaDataProvider {
energy = (Integer) ThermalExpansionModule.IEnergyInfo_getCurStorage.invoke(te);
maxsto = (Integer) ThermalExpansionModule.IEnergyInfo_getMaxStorage.invoke(te);
} else if (ThermalExpansionModule.IEnergyProvider.isInstance(te)){
energy = (Integer) ThermalExpansionModule.IEnergyProvider_getCurStorage.invoke(te, ForgeDirection.UNKNOWN);
maxsto = (Integer) ThermalExpansionModule.IEnergyProvider_getMaxStorage.invoke(te, ForgeDirection.UNKNOWN);
energy = (Integer) ThermalExpansionModule.IEnergyProvider_getCurStorage.invoke(te, EnumFacing.DOWN);
maxsto = (Integer) ThermalExpansionModule.IEnergyProvider_getMaxStorage.invoke(te, EnumFacing.DOWN);
} else if (ThermalExpansionModule.IEnergyReceiver.isInstance(te)){
energy = (Integer) ThermalExpansionModule.IEnergyReceiver_getCurStorage.invoke(te, ForgeDirection.UNKNOWN);
maxsto = (Integer) ThermalExpansionModule.IEnergyReceiver_getMaxStorage.invoke(te, ForgeDirection.UNKNOWN);
energy = (Integer) ThermalExpansionModule.IEnergyReceiver_getCurStorage.invoke(te, EnumFacing.DOWN);
maxsto = (Integer) ThermalExpansionModule.IEnergyReceiver_getMaxStorage.invoke(te, EnumFacing.DOWN);
}
tag.setInteger("Energy", energy);
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -62,7 +63,7 @@ public class HUDHandlerISecureTile implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
try {
String owner = (String) ThermalExpansionModule.ISecureTile_getOwnerName.invoke(te);
int access = ((Enum) ThermalExpansionModule.ISecureTile_getAccess.invoke(te)).ordinal();
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import mcp.mobius.waila.api.IWailaConfigHandler;
@@ -83,7 +84,7 @@ public class HUDHandlerTank implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
try {
int amount = (Integer) ThermalExpansionModule.TileTank_getTankAmount.invoke(te);
tag.setInteger("Amount", amount);
@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -93,7 +94,7 @@ public class HUDHandlerTesseract implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
try {
byte modeItem = ThermalExpansionModule.TileTesseract_Item.getByte(te);
byte modeFluid = ThermalExpansionModule.TileTesseract_Fluid.getByte(te);
@@ -2,7 +2,7 @@ package mcp.mobius.waila.addons.thermalexpansion;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.util.EnumFacing;
import org.apache.logging.log4j.Level;
import java.lang.reflect.Field;
@@ -55,12 +55,12 @@ public class ThermalExpansionModule {
// XXX : We register the Energy interface first
try{
IEnergyProvider = Class.forName("cofh.api.energy.IEnergyProvider");
IEnergyProvider_getMaxStorage = IEnergyProvider.getMethod("getMaxEnergyStored", ForgeDirection.class);
IEnergyProvider_getCurStorage = IEnergyProvider.getMethod("getEnergyStored", ForgeDirection.class);
IEnergyProvider_getMaxStorage = IEnergyProvider.getMethod("getMaxEnergyStored", EnumFacing.class);
IEnergyProvider_getCurStorage = IEnergyProvider.getMethod("getEnergyStored", EnumFacing.class);
IEnergyReceiver = Class.forName("cofh.api.energy.IEnergyReceiver");
IEnergyReceiver_getMaxStorage = IEnergyReceiver.getMethod("getMaxEnergyStored", ForgeDirection.class);
IEnergyReceiver_getCurStorage = IEnergyReceiver.getMethod("getEnergyStored", ForgeDirection.class);
IEnergyReceiver_getMaxStorage = IEnergyReceiver.getMethod("getMaxEnergyStored", EnumFacing.class);
IEnergyReceiver_getCurStorage = IEnergyReceiver.getMethod("getEnergyStored", EnumFacing.class);
IEnergyInfo = Class.forName("cofh.api.tileentity.IEnergyInfo");
IEnergyInfo_getMaxStorage = IEnergyInfo.getMethod("getInfoMaxEnergyStored");
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
@@ -34,7 +35,7 @@ public class TwilightForestGenericOverride implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
return tag;
}
}
@@ -1,6 +1,7 @@
package mcp.mobius.waila.addons.vanillamc;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.api.IWailaBlockDecorator;
import mcp.mobius.waila.api.IWailaConfigHandler;
@@ -12,68 +13,69 @@ public class HUDDecoratorVanilla implements IWailaBlockDecorator {
@Override
public void decorateBlock(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
Tessellator tessellator = Tessellator.instance;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer t = tessellator.getWorldRenderer();
//UIHelper.drawBillboardText(itemStack.getDisplayName(), accessor.getRenderingPosition(), 0.5F, 1.5F, 0.5F, accessor.getPartialFrame());
UIHelper.drawFloatingText("IN", accessor.getRenderingPosition(), 0.5F, 0.2F, -0.2F, 90F, 0F, 0F);
UIHelper.drawFloatingText("OUT", accessor.getRenderingPosition(), -0.2F, 0.2F, 0.5F, 90F, 90F, 0F);
UIHelper.drawFloatingText("OUT", accessor.getRenderingPosition(), 1.2F, 0.2F, 0.5F, 90F, -90F, 0F);
UIHelper.drawFloatingText("OUT", accessor.getRenderingPosition(), 0.5F, 0.2F, 1.2F, 90F, -180F, 0F);
double offset = 0.1;
double delta = 1 + 2 * offset;
double x = accessor.getRenderingPosition().xCoord - offset;
double y = accessor.getRenderingPosition().yCoord - offset;
double z = accessor.getRenderingPosition().zCoord - offset;
tessellator.startDrawingQuads();
tessellator.setColorRGBA(255, 255, 255, 150);
t.startDrawingQuads();
tessellator.addVertex(x, y + 0.2 , z);
tessellator.addVertex(x, y + 0.2 , z + delta/2 - 0.1);
tessellator.addVertex(x + offset, y + 0.2, z + delta/2 - 0.1);
tessellator.addVertex(x + offset, y + 0.2, z);
t.setColorRGBA(255, 255, 255, 150);
tessellator.addVertex(x, y + 0.2 , z + delta/2 + 0.1);
tessellator.addVertex(x, y + 0.2 , z + delta);
tessellator.addVertex(x + offset, y + 0.2, z + delta);
tessellator.addVertex(x + offset, y + 0.2, z + delta/2 + 0.1);
t.addVertex(x, y + 0.2 , z);
t.addVertex(x, y + 0.2 , z + delta/2 - 0.1);
t.addVertex(x + offset, y + 0.2, z + delta/2 - 0.1);
t.addVertex(x + offset, y + 0.2, z);
tessellator.addVertex(x + delta - 0.1, y + 0.2 , z + 0.1);
tessellator.addVertex(x + delta - 0.1, y + 0.2 , z + delta/2 - 0.1);
tessellator.addVertex(x + delta + offset - 0.1, y + 0.2, z + delta/2 - 0.1);
tessellator.addVertex(x + delta + offset - 0.1, y + 0.2, z + 0.1);
t.addVertex(x, y + 0.2 , z + delta/2 + 0.1);
t.addVertex(x, y + 0.2 , z + delta);
t.addVertex(x + offset, y + 0.2, z + delta);
t.addVertex(x + offset, y + 0.2, z + delta/2 + 0.1);
tessellator.addVertex(x + delta - 0.1, y + 0.2 , z + delta/2 + 0.1);
tessellator.addVertex(x + delta - 0.1, y + 0.2 , z + delta);
tessellator.addVertex(x + delta + offset - 0.1, y + 0.2, z + delta);
tessellator.addVertex(x + delta + offset - 0.1, y + 0.2, z + delta/2 + 0.1);
t.addVertex(x + delta - 0.1, y + 0.2 , z + 0.1);
t.addVertex(x + delta - 0.1, y + 0.2 , z + delta/2 - 0.1);
t.addVertex(x + delta + offset - 0.1, y + 0.2, z + delta/2 - 0.1);
t.addVertex(x + delta + offset - 0.1, y + 0.2, z + 0.1);
tessellator.addVertex(x+ 0.1, y + 0.2, z);
tessellator.addVertex(x+ 0.1, y + 0.2, z+ offset);
tessellator.addVertex(x+ delta/2 - 0.1, y + 0.2, z+ offset);
tessellator.addVertex(x+ delta/2 - 0.1, y + 0.2, z);
t.addVertex(x + delta - 0.1, y + 0.2 , z + delta/2 + 0.1);
t.addVertex(x + delta - 0.1, y + 0.2 , z + delta);
t.addVertex(x + delta + offset - 0.1, y + 0.2, z + delta);
t.addVertex(x + delta + offset - 0.1, y + 0.2, z + delta/2 + 0.1);
tessellator.addVertex(x+ delta/2 + 0.1, y + 0.2, z);
tessellator.addVertex(x+ delta/2 + 0.1, y + 0.2, z+ offset);
tessellator.addVertex(x+ delta, y + 0.2, z+ offset);
tessellator.addVertex(x+ delta, y + 0.2, z);
tessellator.addVertex(x + 0.1, y + 0.2, z+ delta - 0.1);
tessellator.addVertex(x + 0.1, y + 0.2, z+ offset+ delta - 0.1);
tessellator.addVertex(x+ delta/2 - 0.1, y + 0.2, z+ offset+ delta - 0.1);
tessellator.addVertex(x+ delta/2 - 0.1, y + 0.2, z+ delta - 0.1);
t.addVertex(x+ 0.1, y + 0.2, z);
t.addVertex(x+ 0.1, y + 0.2, z+ offset);
t.addVertex(x+ delta/2 - 0.1, y + 0.2, z+ offset);
t.addVertex(x+ delta/2 - 0.1, y + 0.2, z);
t.addVertex(x+ delta/2 + 0.1, y + 0.2, z);
t.addVertex(x+ delta/2 + 0.1, y + 0.2, z+ offset);
t.addVertex(x+ delta, y + 0.2, z+ offset);
t.addVertex(x+ delta, y + 0.2, z);
t.addVertex(x + 0.1, y + 0.2, z+ delta - 0.1);
t.addVertex(x + 0.1, y + 0.2, z+ offset+ delta - 0.1);
t.addVertex(x+ delta/2 - 0.1, y + 0.2, z+ offset+ delta - 0.1);
t.addVertex(x+ delta/2 - 0.1, y + 0.2, z+ delta - 0.1);
t.addVertex(x+ delta/2 + 0.1, y + 0.2, z+ delta - 0.1);
t.addVertex(x+ delta/2 + 0.1, y + 0.2, z+ offset+ delta - 0.1);
t.addVertex(x+ delta - 0.1, y + 0.2, z+ offset+ delta - 0.1);
t.addVertex(x+ delta - 0.1, y + 0.2, z+ delta - 0.1);
tessellator.draw();
tessellator.addVertex(x+ delta/2 + 0.1, y + 0.2, z+ delta - 0.1);
tessellator.addVertex(x+ delta/2 + 0.1, y + 0.2, z+ offset+ delta - 0.1);
tessellator.addVertex(x+ delta - 0.1, y + 0.2, z+ offset+ delta - 0.1);
tessellator.addVertex(x+ delta - 0.1, y + 0.2, z+ delta - 0.1);
tessellator.draw();
}
}
@@ -1,21 +1,21 @@
package mcp.mobius.waila.addons.vanillamc;
import java.util.List;
import cpw.mods.fml.common.registry.GameData;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.ISidedInventory;
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 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 net.minecraft.entity.player.EntityPlayerMP;
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.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameData;
import java.util.List;
public class HUDHandlerFurnace implements IWailaDataProvider {
@@ -37,12 +37,12 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
String renderStr = "";
{
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(0));
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
String name = String.valueOf(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());
String name = String.valueOf(GameData.getItemRegistry().getNameForObject(stack.getItem()));
renderStr += SpecialChars.getRenderString("waila.stack", "1", name, String.valueOf(stack.stackSize), String.valueOf(stack.getItemDamage()));
}
@@ -50,7 +50,7 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
{
ItemStack stack = ItemStack.loadItemStackFromNBT(tag.getCompoundTagAt(2));
String name = GameData.getItemRegistry().getNameForObject(stack.getItem());
String name = String.valueOf(GameData.getItemRegistry().getNameForObject(stack.getItem()));
renderStr += SpecialChars.getRenderString("waila.stack", "1", name, String.valueOf(stack.stackSize), String.valueOf(stack.getItemDamage()));
}
@@ -65,7 +65,7 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -73,6 +73,6 @@ public class HUDHandlerFurnace implements IWailaDataProvider {
public static void register(){
//ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerFurnace(), TileEntityFurnace.class);
//ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerFurnace(), TileEntityFurnace.class);
//ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerFurnace(), TileEntityFurnace.class);
}
}
@@ -1,28 +1,34 @@
package mcp.mobius.waila.addons.vanillamc;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneOre;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityMobSpawner;
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.SpecialChars;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
import mcp.mobius.waila.cbcore.LangUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneOre;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import java.util.List;
public class HUDHandlerVanilla implements IWailaDataProvider {
static Block mobSpawner = Blocks.mob_spawner;
static Block crops = Blocks.wheat;
static Block farmland = Blocks.farmland;
static Block melonStem = Blocks.melon_stem;
static Block pumpkinStem = Blocks.pumpkin_stem;
static Block carrot = Blocks.carrots;
@@ -65,28 +71,31 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
if (block == redstone){
return new ItemStack(Items.redstone);
}
if (block == doubleplant && (accessor.getMetadata() & 8) != 0){
int x = accessor.getPosition().blockX;
int y = accessor.getPosition().blockY - 1;
int z = accessor.getPosition().blockZ;
int meta = accessor.getWorld().getBlockMetadata(x, y, z);
return new ItemStack(doubleplant, 0, meta);
}
if (block == doubleplant && (accessor.getMetadata() & 8) != 0) {
int x = accessor.getPosition().getX();
int y = accessor.getPosition().getY() - 1;
int z = accessor.getPosition().getZ();
int meta = doubleplant.getMetaFromState(accessor.getWorld().getBlockState(new BlockPos(x, y, z)));
return new ItemStack(doubleplant, 1, meta);
}
if (block instanceof BlockRedstoneOre){
return new ItemStack(Blocks.redstone_ore);
}
if (block == crops ){
if (block == crops){
return new ItemStack(Items.wheat);
}
if (block == farmland){
return new ItemStack(Blocks.farmland);
}
if ((block == leave || block == leave2) && (accessor.getMetadata() > 3)){
if ((block == leave || block == leave2) && (accessor.getMetadata() > 3)) {
return new ItemStack(block, 1, accessor.getMetadata() - 4);
}
if (block == log || block == log2){
return new ItemStack(block, 1, accessor.getMetadata()%4);
}
@@ -103,11 +112,11 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
Block block = accessor.getBlock();
/* Mob spawner handler */
if (block == mobSpawner && accessor.getTileEntity() instanceof TileEntityMobSpawner && config.getConfig("vanilla.spawntype")){
//Mob spawner handler
if (block == mobSpawner && accessor.getTileEntity() instanceof TileEntityMobSpawner && config.getConfig("vanilla.spawntype")) {
String name = currenttip.get(0);
String mobname = ((TileEntityMobSpawner)accessor.getTileEntity()).func_145881_a().getEntityNameToSpawn();
currenttip.set(0, String.format("%s (%s)", name, mobname));
String mobname = ((TileEntityMobSpawner)accessor.getTileEntity()).getSpawnerBaseLogic().func_180612_a(accessor.getWorld()).getName();
currenttip.set(0, String.format( "%s (%s)", name, mobname));
}
if (block == redstone){
@@ -121,7 +130,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
if (block == pumpkinStem){
currenttip.set(0, SpecialChars.WHITE + "Pumpkin stem");
}
}
return currenttip;
}
@@ -139,18 +148,18 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
else
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.growth"), LangUtil.translateG("hud.msg.mature")));
return currenttip;
}
}
if (block == cocoa && config.getConfig("general.showcrop")){
float growthValue = ((accessor.getMetadata() >> 2) / 2.0F) * 100.0F;
if (growthValue < 100.0)
currenttip.add(String.format("%s : %.0f %%", LangUtil.translateG("hud.msg.growth"), growthValue));
else
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.growth"), LangUtil.translateG("hud.msg.mature")));
return currenttip;
}
}
if (block == netherwart && config.getConfig("general.showcrop")){
float growthValue = (accessor.getMetadata() / 3.0F) * 100.0F;
if (growthValue < 100.0)
@@ -158,14 +167,14 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
else
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.growth"), LangUtil.translateG("hud.msg.mature")));
return currenttip;
}
}
if (config.getConfig("vanilla.leverstate"))
if (block == lever){
String redstoneOn = (accessor.getMetadata() & 8) == 0 ? LangUtil.translateG("hud.msg.off") : LangUtil.translateG("hud.msg.on");
currenttip.add(String.format("%s : %s", LangUtil.translateG("hud.msg.state"), redstoneOn));
return currenttip;
}
return currenttip;
}
if (config.getConfig("vanilla.repeater"))
if ((block == repeaterIdle) ||(block == repeaterActv)){
@@ -174,8 +183,8 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
currenttip.add(String.format("%s : %s tick", LangUtil.translateG("hud.msg.delay"), tick));
else
currenttip.add(String.format("%s : %s ticks", LangUtil.translateG("hud.msg.delay"), tick));
return currenttip;
}
return currenttip;
}
if (config.getConfig("vanilla.comparator"))
if ((block == comparatorIdl) ||(block == comparatorAct)){
@@ -183,31 +192,28 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
//int outputSignal = ((TileEntityComparator)entity).func_96100_a();
currenttip.add("Mode : " + mode);
//currenttip.add(String.format("Out : %s", outputSignal));
return currenttip;
}
return currenttip;
}
if (config.getConfig("vanilla.redstone"))
if (block == redstone){
currenttip.add(String.format("%s : %s" , LangUtil.translateG("hud.msg.power"), accessor.getMetadata()));
return currenttip;
}
/*
return currenttip;
}
if (config.getConfig("vanilla.jukebox"))
if (block == jukebox){
NBTTagCompound tag = accessor.getNBTData();
Item record = null;
if (tag.hasKey("Record")){
record = Item.itemsList[accessor.getNBTInteger(tag, "Record")];
currenttip.add(((ItemRecord)record).getRecordTitle());
if (tag.hasKey("RecordItem", 10)) {
Item record = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("RecordItem")).getItem();
currenttip.add(LangUtil.translateG("record.nowPlaying").replace("%s", ((ItemRecord) record).getRecordNameLocal()));
} else {
currenttip.add(LangUtil.translateG("hud.msg.empty"));
}
}
*/
return currenttip;
}
}
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
@@ -215,7 +221,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -229,7 +235,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.redstone");
ModuleRegistrar.instance().addConfig("VanillaMC", "vanilla.silverfish");
ModuleRegistrar.instance().addConfigRemote("VanillaMC", "vanilla.jukebox");
IWailaDataProvider provider = new HUDHandlerVanilla();
ModuleRegistrar.instance().registerStackProvider(provider, silverfish.getClass());
@@ -237,6 +243,7 @@ public class HUDHandlerVanilla implements IWailaDataProvider {
ModuleRegistrar.instance().registerStackProvider(provider, doubleplant.getClass());
ModuleRegistrar.instance().registerStackProvider(provider, BlockRedstoneOre.class);
ModuleRegistrar.instance().registerStackProvider(provider, crops.getClass());
ModuleRegistrar.instance().registerStackProvider(provider, farmland.getClass());
ModuleRegistrar.instance().registerStackProvider(provider, leave.getClass());
ModuleRegistrar.instance().registerStackProvider(provider, leave2.getClass());
ModuleRegistrar.instance().registerStackProvider(provider, log.getClass());
@@ -1,10 +1,8 @@
package mcp.mobius.waila.api;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Map.Entry;
public interface ITaggedList<E, T> extends List<E> {
public boolean add(E e, T tag);
@@ -1,34 +0,0 @@
package mcp.mobius.waila.api;
import java.util.List;
import net.minecraft.item.ItemStack;
@Deprecated
public interface IWailaBlock {
/*
* Use this method to return an item stack in case the default lookup system fails.
* Return null if you want to use the default lookup system.
* You get the world, the player and the location of the block. With that, it is easy to gather information & tile entities
*/
ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config);
/* Waila HUD is divided into 3 zones. The head corresponds to the item name,
* body to where you mostly want to put informations, and I reserve the tail for modname display
*/
/* Those 2 methods works exactly the same way, except they are related to a different zone in Waila HUD.
* You get in input world, player and the block location. You also get the itemstack as returned by the default lookup system or getWailaStack().
* ConfigHandler provides the current Waila config state so you can show/hide elements depending on the configuration. Refer the ConfigHandler class for more info.
* currenttip represents the current list of text lines in the tooltip zone.
* For example, getWailaHead() will have the current item name as currenttip.
* You can modify the tips, add more, remove some, etc.
* When you are done, just returns the currenttip and it will display in Waila.
*
* Always return the currenttip is you don't want to modify the current zone.
*/
List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config);
}
@@ -6,10 +6,11 @@ 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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/**
* The Accessor is used to get some basic data out of the game without having to request direct access to the game engine.<br>
@@ -27,11 +28,11 @@ public interface IWailaCommonAccessor {
int getMetadata();
TileEntity getTileEntity();
Entity getEntity();
MovingObjectPosition getPosition();
BlockPos getPosition();
Vec3 getRenderingPosition();
NBTTagCompound getNBTData();
int getNBTInteger(NBTTagCompound tag, String keyname);
double getPartialFrame();
ForgeDirection getSide();
EnumFacing getSide();
ItemStack getStack();
}
@@ -1,14 +1,16 @@
package mcp.mobius.waila.api;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/**
* The Accessor is used to get some basic data out of the game without having to request direct access to the game engine.<br>
@@ -19,19 +21,19 @@ import net.minecraftforge.common.util.ForgeDirection;
*/
public interface IWailaDataAccessor{
World getWorld();
EntityPlayer getPlayer();
Block getBlock();
int getBlockID();
String getBlockQualifiedName();
int getMetadata();
//int getBlockID();
int getMetadata();
IBlockState getBlockState();
TileEntity getTileEntity();
MovingObjectPosition getPosition();
MovingObjectPosition getMOP();
BlockPos getPosition();
Vec3 getRenderingPosition();
NBTTagCompound getNBTData();
int getNBTInteger(NBTTagCompound tag, String keyname);
double getPartialFrame();
ForgeDirection getSide();
EnumFacing getSide();
ItemStack getStack();
}
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
/**
@@ -74,10 +75,8 @@ public interface IWailaDataProvider{
* @param te The TileEntity targeted for synchronization.
* @param tag Current synchronization tag (might have been processed by other providers and might be processed by other providers).
* @param world TileEntity's World.
* @param x X position of the TileEntity.
* @param y Y position of the TileEntity.
* @param z Z position of the TileEntity.
* @param pos Position of the TileEntity.
* @return Modified input NBTTagCompound tag.
*/
NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z);
NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos);
}
@@ -19,7 +19,7 @@ public interface IWailaEntityAccessor {
World getWorld();
EntityPlayer getPlayer();
Entity getEntity();
MovingObjectPosition getPosition();
MovingObjectPosition getMOP();
Vec3 getRenderingPosition();
NBTTagCompound getNBTData();
int getNBTInteger(NBTTagCompound tag, String keyname);
@@ -55,19 +55,7 @@ public interface IWailaRegistrar {
/* The block decorators */
public void registerDecorator (IWailaBlockDecorator decorator, Class block);
public void registerDecorator (IWailaFMPDecorator decorator, String name);
/* Selective NBT key syncing. Will register a key to sync over the network for the given class (block, te or ent).
* Accept * as a ending wildcard
* registerNBTKey("bob.*", MyBlock.class)
* registerNBTKey("data.life", MyEntity.class)
* registerNBTKey("*", MyTileEntity.class) will reproduce the full tag syncing from 1.4.5
*
* This registration method is deprecated in favor to registerNBTProvider.
* It will be removed in MC 1.8 !!!
* */
@Deprecated
public void registerSyncedNBTKey(String key, Class target);
public void registerDecorator (IWailaFMPDecorator decorator, String name);
public void registerTooltipRenderer(String name, IWailaTooltipRenderer renderer);
@@ -1,9 +1,9 @@
package mcp.mobius.waila.api;
import java.util.LinkedHashMap;
import net.minecraft.item.ItemStack;
import java.util.LinkedHashMap;
public interface IWailaSummaryProvider {
/* This interface is used to control the display data in the description screen */
@@ -1,7 +1,6 @@
package mcp.mobius.waila.api;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.*;
public interface IWailaTooltipRenderer {
@@ -1,8 +1,5 @@
package mcp.mobius.waila.api;
import static mcp.mobius.waila.api.SpecialChars.RENDER;
import static mcp.mobius.waila.api.SpecialChars.WailaStyle;
import java.util.regex.Pattern;
public class SpecialChars {
@@ -5,7 +5,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Set;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.handlers.HUDHandlerEntities;
@@ -1,22 +1,24 @@
package mcp.mobius.waila.api.impl;
import cpw.mods.fml.common.registry.GameData;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
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.MovingObjectPosition.MovingObjectType;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
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;
import net.minecraft.block.Block;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
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.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameData;
public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAccessor, IWailaEntityAccessor{
@@ -25,6 +27,8 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
public MovingObjectPosition mop;
public Vec3 renderingvec = null;
public Block block;
public IBlockState state;
public BlockPos pos;
public int blockID;
public String blockResource;
public int metadata;
@@ -41,21 +45,25 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
this.set(_world, _player, _mop, null, 0.0);
}
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, EntityLivingBase viewEntity, double partialTicks) {
public void set(World _world, EntityPlayer _player, MovingObjectPosition _mop, Entity viewEntity, double partialTicks) {
this.world = _world;
this.player = _player;
this.mop = _mop;
if (this.mop.typeOfHit == MovingObjectType.BLOCK){
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.pos = _mop.getBlockPos();
this.state = world.getBlockState(this.pos);
this.block = this.state.getBlock();
this.metadata = this.state.getBlock().getMetaFromState(this.state);
this.tileEntity = world.getTileEntity(this.pos);
this.entity = null;
this.blockID = Block.getIdFromBlock(this.block);
this.blockResource = GameData.getBlockRegistry().getNameForObject(this.block);
this.blockResource = String.valueOf(GameData.getBlockRegistry().getNameForObject(this.block));
try{ this.stack = new ItemStack(this.block, 1, this.metadata); } catch (Exception e) {}
} else if (this.mop.typeOfHit == MovingObjectType.ENTITY){
this.pos = new BlockPos(_mop.entityHit);
this.state = null;
this.block = null;
this.metadata = -1;
this.tileEntity = null;
@@ -66,8 +74,8 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
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);
double pz = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks;
this.renderingvec = new Vec3(this.pos.getX() - px, this.pos.getY() - py, this.pos.getZ() - pz);
this.partialFrame = partialTicks;
}
}
@@ -87,6 +95,11 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
@Override
public int getMetadata() {return this.metadata;}
@Override
public IBlockState getBlockState() {
return this.state;
}
@Override
public TileEntity getTileEntity() { return this.tileEntity;}
@@ -94,7 +107,12 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
public Entity getEntity() {return this.entity;}
@Override
public MovingObjectPosition getPosition() {return this.mop;}
public BlockPos getPosition() {
return this.pos;
}
@Override
public MovingObjectPosition getMOP() {return this.mop;}
@Override
public Vec3 getRenderingPosition() {return this.renderingvec;}
@@ -138,7 +156,7 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
int y = tag.getInteger("WailaY");
int z = tag.getInteger("WailaZ");
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ)
if (x == this.mop.getBlockPos().getX() && y == this.mop.getBlockPos().getY() && z == this.mop.getBlockPos().getZ())
return true;
else {
this.timeLastUpdate = System.currentTimeMillis() - 250;
@@ -173,8 +191,8 @@ public class DataAccessorCommon implements IWailaCommonAccessor, IWailaDataAcces
}
@Override
public ForgeDirection getSide() {
return ForgeDirection.getOrientation(this.getPosition().sideHit);
public EnumFacing getSide() {
return this.getMOP().sideHit;
}
@Override
@@ -1,13 +1,13 @@
package mcp.mobius.waila.api.impl;
import mcp.mobius.waila.api.IWailaFMPAccessor;
import mcp.mobius.waila.utils.NBTUtil;
import net.minecraft.entity.player.EntityPlayer;
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 mcp.mobius.waila.api.IWailaFMPAccessor;
import mcp.mobius.waila.utils.NBTUtil;
public class DataAccessorFMP implements IWailaFMPAccessor {
@@ -32,7 +32,7 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
this.world = _world;
this.player = _player;
this.mop = _mop;
this.entity = world.getTileEntity(_mop.blockX, _mop.blockY, _mop.blockZ);
this.entity = world.getTileEntity(_mop.getBlockPos());
this.partialNBT = _partialNBT;
this.id = id;
this.renderingvec = renderVec;
@@ -106,7 +106,7 @@ public class DataAccessorFMP implements IWailaFMPAccessor {
int y = tag.getInteger("y");
int z = tag.getInteger("z");
if (x == this.mop.blockX && y == this.mop.blockY && z == this.mop.blockZ)
if (x == this.mop.getBlockPos().getX() && y == this.mop.getBlockPos().getY() && z == this.mop.getBlockPos().getZ())
return true;
else {
this.timeLastUpdate = System.currentTimeMillis() - 250;
@@ -1,20 +1,12 @@
package mcp.mobius.waila.api.impl;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaBlock;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaEntityProvider;
import mcp.mobius.waila.cbcore.Layout;
import mcp.mobius.waila.network.Message0x01TERequest;
import mcp.mobius.waila.network.Message0x03EntRequest;
import mcp.mobius.waila.network.WailaPacketHandler;
import mcp.mobius.waila.utils.Constants;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
@@ -24,7 +16,11 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.config.Configuration;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public class MetaDataProvider{
@@ -42,14 +38,6 @@ public class MetaDataProvider{
public ItemStack identifyBlockHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessorCommon accessor) {
Block block = accessor.getBlock();
int blockID = accessor.getBlockID();
if (IWailaBlock.class.isInstance(block)){
try{
return ((IWailaBlock)block).getWailaStack(accessor, ConfigHandler.instance());
}catch (Throwable e){
WailaExceptionHandler.handleErr(e, block.getClass().toString(), null);
}
}
if(ModuleRegistrar.instance().hasStackProviders(block)){
for (List<IWailaDataProvider> providerList : ModuleRegistrar.instance().getStackProviders(block).values()){
@@ -74,12 +62,6 @@ public class MetaDataProvider{
accessor.resetTimer();
HashSet<String> keys = new HashSet<String>();
if (ModuleRegistrar.instance().hasSyncedNBTKeys(block))
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(block));
if (ModuleRegistrar.instance().hasSyncedNBTKeys(accessor.getTileEntity()))
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(accessor.getTileEntity()));
if (keys.size() != 0 || ModuleRegistrar.instance().hasNBTProviders(block) || ModuleRegistrar.instance().hasNBTProviders(accessor.getTileEntity()))
WailaPacketHandler.INSTANCE.sendToServer(new Message0x01TERequest(accessor.getTileEntity(), keys));
@@ -94,29 +76,6 @@ public class MetaDataProvider{
}
}
/* Interface IWailaBlock */
if (IWailaBlock.class.isInstance(block)){
TileEntity entity = world.getTileEntity(mop.blockX, mop.blockY, mop.blockZ);
if (layout == Layout.HEADER)
try{
return ((IWailaBlock)block).getWailaHead(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
}
else if (layout == Layout.BODY)
try{
return ((IWailaBlock)block).getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
}
else if (layout == Layout.FOOTER)
try{
return ((IWailaBlock)block).getWailaTail(itemStack, currenttip, accessor, ConfigHandler.instance());
} catch (Throwable e){
return WailaExceptionHandler.handleErr(e, block.getClass().toString(), currenttip);
}
}
headBlockProviders.clear();
bodyBlockProviders.clear();
tailBlockProviders.clear();
@@ -178,13 +137,6 @@ public class MetaDataProvider{
if (accessor.getEntity() != null && Waila.instance.serverPresent && accessor.isTimeElapsed(250)){
accessor.resetTimer();
HashSet<String> keys = new HashSet<String>();
if (ModuleRegistrar.instance().hasSyncedNBTKeys(accessor.getEntity()))
keys.addAll(ModuleRegistrar.instance().getSyncedNBTKeys(accessor.getEntity()));
if (keys.size() != 0 || ModuleRegistrar.instance().hasNBTEntityProviders(accessor.getEntity()))
WailaPacketHandler.INSTANCE.sendToServer(new Message0x03EntRequest(accessor.getEntity(), keys));
} else if (accessor.getEntity() != null && !Waila.instance.serverPresent && accessor.isTimeElapsed(250)) {
@@ -51,9 +51,7 @@ public class ModuleRegistrar implements IWailaRegistrar {
public LinkedHashMap<String, ArrayList<IWailaFMPProvider>> tailFMPProviders = new LinkedHashMap<String, ArrayList<IWailaFMPProvider>>();
public LinkedHashMap<String, ArrayList<IWailaFMPDecorator>> FMPClassDecorators = new LinkedHashMap<String, ArrayList<IWailaFMPDecorator>>();
public LinkedHashMap<Class, HashSet<String>> syncedNBTKeys = new LinkedHashMap<Class, HashSet<String>>();
public LinkedHashMap<String, LinkedHashMap <String, LinkedHashMap <String, String>>> wikiDescriptions = new LinkedHashMap<String, LinkedHashMap <String, LinkedHashMap <String, String>>>();
public LinkedHashMap<Class, ArrayList<IWailaSummaryProvider>> summaryProviders = new LinkedHashMap<Class, ArrayList<IWailaSummaryProvider>>();
@@ -212,16 +210,7 @@ public class ModuleRegistrar implements IWailaRegistrar {
if (providers.contains(dataProvider)) return;
target.get(clazz).add(dataProvider);
}
@Deprecated
@Override
public void registerSyncedNBTKey(String key, Class target){
if (!this.syncedNBTKeys.containsKey(target))
this.syncedNBTKeys.put(target, new HashSet<String>());
this.syncedNBTKeys.get(target).add(key);
}
}
@Override
public void registerTooltipRenderer(String name, IWailaTooltipRenderer renderer){
@@ -319,16 +308,6 @@ public class ModuleRegistrar implements IWailaRegistrar {
Map<Integer, List<T>> returnList = new TreeMap<Integer, List<T>>();
returnList.put(0, target.get(name));
return returnList;
}
@Deprecated
public HashSet<String> getSyncedNBTKeys(Object target){
HashSet<String> returnList = new HashSet<String>();
for (Class clazz : this.syncedNBTKeys.keySet())
if (clazz.isInstance(target))
returnList.addAll(this.syncedNBTKeys.get(clazz));
return returnList;
}
/* HAS METHODS */
@@ -406,15 +385,7 @@ public class ModuleRegistrar implements IWailaRegistrar {
public boolean hasSummaryProvider(Class item){
return this.summaryProviders.containsKey(item);
}
@Deprecated
public boolean hasSyncedNBTKeys(Object target){
for (Class clazz : this.syncedNBTKeys.keySet())
if (clazz.isInstance(target))
return true;
return false;
}
}
/* ----------------- */
/*
@@ -1,3 +1,3 @@
@API(apiVersion="1.2",owner="Waila",provides="WailaAPI")
@API(apiVersion="1.3",owner="Waila",provides="WailaAPI")
package mcp.mobius.waila.api;
import cpw.mods.fml.common.API;
import net.minecraftforge.fml.common.API;
@@ -12,9 +12,9 @@ import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.common.registry.LanguageRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
/**
* Easy localisation access.
@@ -1,26 +1,16 @@
package mcp.mobius.waila.client;
import java.util.List;
import org.lwjgl.input.Keyboard;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.gui.screens.config.ScreenConfig;
import mcp.mobius.waila.overlay.RayTracing;
import mcp.mobius.waila.utils.Constants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
import org.lwjgl.input.Keyboard;
public class KeyEvent {
public static KeyBinding key_cfg;
@@ -10,14 +10,12 @@ import mcp.mobius.waila.handlers.VanillaTooltipHandler;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderHealth;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderProgressBar;
import mcp.mobius.waila.overlay.tooltiprenderers.TTRenderStack;
//import mcp.mobius.waila.handlers.SummaryProviderDefault;
import mcp.mobius.waila.server.ProxyServer;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import net.minecraftforge.fml.common.Loader;
import mcp.mobius.waila.cbcore.LangUtil;
public class ProxyClient extends ProxyServer {
@@ -9,7 +9,7 @@ import net.minecraft.command.ICommandSender;
public class CommandDumpHandlers extends CommandBase {
@Override
public String getCommandName() {
public String getName() {
return "dumphandlers";
}
@@ -19,7 +19,7 @@ public class CommandDumpHandlers extends CommandBase {
}
@Override
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
public void execute(ICommandSender sender, String[] string) {
System.out.printf("\n\n== HEAD BLOCK PROVIDERS ==\n");
for (Class clazz : ModuleRegistrar.instance().headBlockProviders.keySet()){
@@ -99,9 +99,9 @@ public class CommandDumpHandlers extends CommandBase {
public int getRequiredPermissionLevel(){ return 3; }
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender){
public boolean canCommandSenderUse(ICommandSender sender){
//if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true;
return super.canCommandSenderUseCommand(sender);
}
return super.canCommandSenderUse(sender);
}
}
@@ -1,5 +1,7 @@
package mcp.mobius.waila.gui.helpers;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
@@ -19,14 +21,15 @@ public class UIHelper {
{
float zLevel = 0.0F;
float f = 0.00390625F;
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
tess.addVertexWithUV((double)(posX + 0), (double)(posY + sizeY), (double)zLevel, texU*f, (texV + texSizeV)*f);
tess.addVertexWithUV((double)(posX + sizeX), (double)(posY + sizeY), (double)zLevel, (texU + texSizeU)*f, (texV + texSizeV)*f);
tess.addVertexWithUV((double)(posX + sizeX), (double)(posY + 0), (double)zLevel, (texU + texSizeU)*f, texV*f);
tess.addVertexWithUV((double)(posX + 0), (double)(posY + 0), (double)zLevel, texU*f, texV*f);
tess.draw();
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer t = tessellator.getWorldRenderer();
t.startDrawingQuads();
t.addVertexWithUV((double)(posX + 0), (double)(posY + sizeY), (double)zLevel, texU*f, (texV + texSizeV)*f);
t.addVertexWithUV((double) (posX + sizeX), (double) (posY + sizeY), (double) zLevel, (texU + texSizeU) * f, (texV + texSizeV) * f);
t.addVertexWithUV((double)(posX + sizeX), (double)(posY + 0), (double)zLevel, (texU + texSizeU)*f, texV*f);
t.addVertexWithUV((double)(posX + 0), (double)(posY + 0), (double)zLevel, texU*f, texV*f);
tessellator.draw();
}
public static void drawGradientRect(int minx, int miny, int maxx, int maxy, int zlevel, int color1, int color2)
@@ -44,14 +47,15 @@ public class UIHelper {
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glShadeModel(GL11.GL_SMOOTH);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(red1, green1, blue1, alpha1);
tessellator.addVertex((double)maxx, (double)miny, (double)zlevel);
tessellator.addVertex((double)minx, (double)miny, (double)zlevel);
tessellator.setColorRGBA_F(red2, green2, blue2, alpha2);
tessellator.addVertex((double)minx, (double)maxy, (double)zlevel);
tessellator.addVertex((double)maxx, (double)maxy, (double)zlevel);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer t = tessellator.getWorldRenderer();
t.startDrawingQuads();
t.setColorRGBA_F(red1, green1, blue1, alpha1);
t.addVertex((double)maxx, (double)miny, (double)zlevel);
t.addVertex((double)minx, (double)miny, (double)zlevel);
t.setColorRGBA_F(red2, green2, blue2, alpha2);
t.addVertex((double)minx, (double)maxy, (double)zlevel);
t.addVertex((double)maxx, (double)maxy, (double)zlevel);
tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
@@ -64,7 +68,7 @@ public class UIHelper {
}
public static void drawBillboard(float posX, float posY, float posZ, float offX, float offY, float offZ, double x1, double y1, double x2, double y2, int r, int g, int b, int a, double partialFrame){
EntityLivingBase player = Minecraft.getMinecraft().renderViewEntity;
Entity player = Minecraft.getMinecraft().getRenderViewEntity();
float playerViewY = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * (float)partialFrame;
float playerViewX = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * (float)partialFrame;
@@ -96,14 +100,12 @@ public class UIHelper {
GL11.glPopMatrix();
}
public static void drawBillboardText(String text, Vec3 pos, float offX, float offY, float offZ, double partialFrame){
UIHelper.drawBillboardText(text, (float)pos.xCoord, (float)pos.yCoord, (float)pos.zCoord, offX, offY, offZ, partialFrame);
}
public static void drawBillboardText(String text, float posX, float posY, float posZ, float offX, float offY, float offZ, double partialFrame){
EntityLivingBase player = Minecraft.getMinecraft().renderViewEntity;
Entity player = Minecraft.getMinecraft().getRenderViewEntity();
float playerViewY = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * (float)partialFrame;
float playerViewX = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * (float)partialFrame;
@@ -118,12 +120,11 @@ public class UIHelper {
if (text.isEmpty()) return;
FontRenderer fontrenderer = Minecraft.getMinecraft().fontRenderer;
FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
float f = 1.6F;
float f1 = 0.016666668F * f;
GL11.glPushMatrix();
//GL11.glTranslatef((float)accessor.getPosition().blockX + 0.0F, (float)accessor.getPosition().blockY + 0.5F, (float)accessor.getPosition().blockZ);
GL11.glTranslatef(posX + offX, posY + offY, posZ + offZ);
@@ -144,14 +145,14 @@ public class UIHelper {
byte b0 = 0;
GL11.glDisable(GL11.GL_TEXTURE_2D);
int j = fontrenderer.getStringWidth(text) / 2;
int j = fontRendererObj.getStringWidth(text) / 2;
drawRectangle((double)(-j - 1), (double)(8 + b0), 0.0, (double)(j + 1), (double)(-1 + b0), 0.0, 0, 0, 0, 64);
GL11.glEnable(GL11.GL_TEXTURE_2D);
fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, b0, 553648127);
fontRendererObj.drawString(text, -fontRendererObj.getStringWidth(text) / 2, b0, 553648127);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, b0, -1);
fontRendererObj.drawString(text, -fontRendererObj.getStringWidth(text) / 2, b0, -1);
//GL11.glEnable(GL11.GL_LIGHTING);
//GL11.glDisable(GL11.GL_BLEND);
//GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
@@ -161,30 +162,32 @@ public class UIHelper {
}
public static void drawRectangle(double x1, double y1, double z1, double x2, double y2, double z2, int r, int g, int b, int a){
Tessellator tessellator = Tessellator.instance;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer t = tessellator.getWorldRenderer();
tessellator.startDrawingQuads();
tessellator.setColorRGBA(r, g, b, a);
t.startDrawingQuads();
t.setColorRGBA(r, g, b, a);
tessellator.addVertex(x1, y2, z1);
tessellator.addVertex(x1, y1, z2);
tessellator.addVertex(x2, y1, z2);
tessellator.addVertex(x2, y2, z1);
t.addVertex(x1, y2, z1);
t.addVertex(x1, y1, z2);
t.addVertex(x2, y1, z2);
t.addVertex(x2, y2, z1);
tessellator.draw();
}
public static void drawRectangleEW(double x1, double y1, double z1, double x2, double y2, double z2, int r, int g, int b, int a){
Tessellator tessellator = Tessellator.instance;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer t = tessellator.getWorldRenderer();
tessellator.startDrawingQuads();
tessellator.setColorRGBA(r, g, b, a);
t.startDrawingQuads();
t.setColorRGBA(r, g, b, a);
tessellator.addVertex(x1, y1, z1);
tessellator.addVertex(x1, y1, z2);
tessellator.addVertex(x2, y2, z2);
tessellator.addVertex(x2, y2, z1);
t.addVertex(x1, y1, z1);
t.addVertex(x1, y1, z2);
t.addVertex(x2, y2, z2);
t.addVertex(x2, y2, z1);
tessellator.draw();
}
@@ -1,16 +1,12 @@
package mcp.mobius.waila.gui.screens.info;
import mcp.mobius.waila.cbcore.LangUtil;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.WAlign;
import mcp.mobius.waila.gui.screens.ScreenBase;
import mcp.mobius.waila.gui.widgets.ItemStackDisplay;
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
import mcp.mobius.waila.gui.widgets.LayoutBase;
import mcp.mobius.waila.gui.widgets.ViewTable;
import mcp.mobius.waila.gui.widgets.WidgetGeometry;
import mcp.mobius.waila.gui.widgets.*;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
public class ScreenEnchants extends ScreenBase {
@@ -1,10 +1,12 @@
package mcp.mobius.waila.gui.truetyper;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
@@ -14,18 +16,6 @@ import java.nio.ByteOrder;
import java.nio.IntBuffer;
import java.util.HashMap;
import java.util.Map;
import java.awt.GraphicsEnvironment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.settings.GameSettings;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL30;
import org.lwjgl.util.glu.GLU;
/**
* TrueTyper: Open Source TTF implementation for Minecraft.
@@ -243,8 +233,9 @@ public class TrueTypeFont {
float SrcWidth = srcX2 - srcX;
float SrcHeight = srcY2 - srcY;
float RenderWidth = (SrcWidth / textureWidth);
float RenderHeight = (SrcHeight / textureHeight);
Tessellator t = Tessellator.instance;
float RenderHeight = (SrcHeight / textureHeight);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer t = tessellator.getWorldRenderer();
//t.setColorRGBA_F(0f, 0f, 0f, 1f);
@@ -360,7 +351,8 @@ public class TrueTypeFont {
}
GL11.glBindTexture(GL11.GL_TEXTURE_2D, fontTextureID);
Tessellator t = Tessellator.instance;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer t = tessellator.getWorldRenderer();
t.startDrawingQuads();
// GL11.glBegin(GL11.GL_QUADS);
if(rgba.length == 4)
@@ -409,7 +401,7 @@ public class TrueTypeFont {
}
}
t.draw();
tessellator.draw();
// GL11.glEnd();
GL11.glPopMatrix();
@@ -1,15 +1,10 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.gui.interfaces.CType;
import mcp.mobius.waila.gui.interfaces.IWidget;
import mcp.mobius.waila.gui.interfaces.Signal;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.util.Point;
import mcp.mobius.waila.cbcore.LangUtil;
public class LabelFixedFont extends WidgetBase {
protected String text = "";
@@ -47,14 +42,13 @@ public class LabelFixedFont extends WidgetBase {
if (this.geom == null)
this.geom = new WidgetGeometry(0,0,50,50, CType.ABSXY, CType.ABSXY);
this.geom = new WidgetGeometry(this.geom.x, this.geom.y, this.mc.fontRenderer.getStringWidth(this.text), 8, this.geom.posType, CType.ABSXY, this.geom.alignX, this.geom.alignY);
this.geom = new WidgetGeometry(this.geom.x, this.geom.y, this.mc.fontRendererObj.getStringWidth(this.text), 8, this.geom.posType, CType.ABSXY, this.geom.alignX, this.geom.alignY);
}
@Override
public void draw(Point pos) {
this.saveGLState();
this.mc.fontRenderer.drawString(this.text, pos.getX(), pos.getY(), this.color);
//this.mc.fontRenderer.drawString(this.text, pos.getX(), pos.getY(), this.color);
this.mc.fontRendererObj.drawString(this.text, pos.getX(), pos.getY(), this.color);
this.loadGLState();
}
}
@@ -1,9 +1,7 @@
package mcp.mobius.waila.gui.widgets;
import mcp.mobius.waila.gui.events.MouseEvent;
import mcp.mobius.waila.gui.helpers.UIHelper;
import mcp.mobius.waila.gui.interfaces.IWidget;
import org.lwjgl.util.Point;
public class LayoutBase extends WidgetBase {
@@ -248,7 +248,6 @@ public abstract class WidgetBase implements IWidget {
protected void saveGLState(){
hasBlending = GL11.glGetBoolean(GL11.GL_BLEND);
hasLight = GL11.glGetBoolean(GL11.GL_LIGHTING);
boundTexIndex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
GL11.glPushMatrix();
}
@@ -256,10 +255,8 @@ public abstract class WidgetBase implements IWidget {
protected void loadGLState(){
if (hasBlending) GL11.glEnable(GL11.GL_BLEND); else GL11.glDisable(GL11.GL_BLEND);
if (hasLight) GL11.glEnable(GL11.GL_LIGHTING); else GL11.glDisable(GL11.GL_LIGHTING);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, boundTexIndex);
GL11.glPopMatrix();
GL11.glPopAttrib();
//GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
@Override
@@ -67,7 +67,7 @@ public abstract class ButtonBase extends WidgetBase {
@Override
public void onMouseClick(MouseEvent event){
if (event.button == 0)
this.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
this.mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
this.emit(Signal.CLICKED, event.button);
}
@@ -25,7 +25,7 @@ public class DecoratorFMP implements IWailaBlockDecorator {
String id = subtag.getString("id");
if (ModuleRegistrar.instance().hasFMPDecorator(id)){
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id, accessor.getRenderingPosition(), accessor.getPartialFrame());
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getMOP(), subtag, id, accessor.getRenderingPosition(), accessor.getPartialFrame());
for (List<IWailaFMPDecorator> providersList : ModuleRegistrar.instance().getFMPDecorators(id).values())
for (IWailaFMPDecorator provider : providersList)
@@ -1,9 +1,5 @@
package mcp.mobius.waila.handlers;
import java.util.List;
import cpw.mods.fml.common.registry.GameData;
import static mcp.mobius.waila.api.SpecialChars.*;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
@@ -11,17 +7,19 @@ import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.overlay.DisplayUtil;
import mcp.mobius.waila.utils.Constants;
import mcp.mobius.waila.utils.ModIdentification;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.config.Configuration;
import java.util.List;
import static mcp.mobius.waila.api.SpecialChars.*;
public class HUDHandlerBlocks implements IWailaDataProvider {
@Override
@@ -59,7 +57,8 @@ public class HUDHandlerBlocks implements IWailaDataProvider {
currenttip.add("< Unnamed >");
else{
if (ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_METADATA, true)){
currenttip.add(String.format(ITALIC + "[%d:%d] | %s", accessor.getBlockID(), accessor.getMetadata(), accessor.getBlockQualifiedName()));
currenttip.add(String.format(ITALIC + "< Unimplemented >"));
//currenttip.add(String.format(ITALIC + "[%s:%d] | %s", accessor.getBlock().getStateId(accessor.getBlockState()), accessor.getMetadata()/*, accessor.getBlockQualifiedName()*/));
}
}
return currenttip;
@@ -90,7 +89,7 @@ public class HUDHandlerBlocks implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
return tag;
}
}
@@ -2,9 +2,9 @@ package mcp.mobius.waila.handlers;
import java.util.List;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry.EntityRegistration;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -20,7 +20,7 @@ public class HUDHandlerEntities implements IWailaEntityProvider {
public static int nhearts = 20;
public static float maxhpfortext = 40.0f;
@Override
public Entity getWailaOverride(IWailaEntityAccessor accessor, IWailaConfigHandler config) {
return null;
@@ -28,42 +28,42 @@ public class HUDHandlerEntities implements IWailaEntityProvider {
@Override
public List<String> getWailaHead(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
try{
currenttip.add(WHITE + entity.getCommandSenderName());
} catch (Exception e){
try {
currenttip.add(WHITE + entity.getName());
} catch (Exception e) {
currenttip.add(WHITE + "Unknown");
}
}
return currenttip;
}
@Override
public List<String> getWailaBody(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
if (!config.getConfig("general.showhp")) return currenttip;
if (entity instanceof EntityLivingBase){
if (entity instanceof EntityLivingBase) {
String hptip = "";
nhearts = nhearts <= 0 ? 20 : nhearts;
float health = ((EntityLivingBase)entity).getHealth() / 2.0f;
float maxhp = ((EntityLivingBase)entity).getMaxHealth() / 2.0f;
if (((EntityLivingBase)entity).getMaxHealth() > maxhpfortext)
currenttip.add(String.format("HP : " + WHITE + "%.0f" + GRAY + " / " + WHITE + "%.0f", ((EntityLivingBase)entity).getHealth(), ((EntityLivingBase)entity).getMaxHealth()));
else{
float health = ((EntityLivingBase) entity).getHealth() / 2.0f;
float maxhp = ((EntityLivingBase) entity).getMaxHealth() / 2.0f;
if (((EntityLivingBase) entity).getMaxHealth() > maxhpfortext)
currenttip.add(String.format("HP : " + WHITE + "%.0f" + GRAY + " / " + WHITE + "%.0f", ((EntityLivingBase) entity).getHealth(), ((EntityLivingBase) entity).getMaxHealth()));
else {
currenttip.add(getRenderString("waila.health", String.valueOf(nhearts), String.valueOf(health), String.valueOf(maxhp)));
}
}
}
return currenttip;
return currenttip;
}
@Override
public List<String> getWailaTail(Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) {
try{
try {
currenttip.add(BLUE + ITALIC + getEntityMod(entity));
} catch (Exception e){
} catch (Exception e) {
currenttip.add(BLUE + ITALIC + "Unknown");
}
return currenttip;
@@ -72,18 +72,17 @@ public class HUDHandlerEntities implements IWailaEntityProvider {
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, Entity te, NBTTagCompound tag, World world) {
return tag;
}
private static String getEntityMod(Entity entity){
String modName = "";
try{
EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), true);
ModContainer modC = er.getContainer();
modName = modC.getName();
} catch (NullPointerException e){
modName = "Minecraft";
}
return modName;
}
}
}
private static String getEntityMod(Entity entity) {
String modName = "";
try {
EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), true);
ModContainer modC = er.getContainer();
modName = modC.getName();
} catch (NullPointerException e) {
modName = "Minecraft";
}
return modName;
}
}
@@ -2,6 +2,7 @@ package mcp.mobius.waila.handlers;
import java.util.List;
import net.minecraft.util.BlockPos;
import org.apache.logging.log4j.Level;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -34,7 +35,7 @@ public class HUDHandlerFMP implements IWailaDataProvider {
String id = subtag.getString("id");
if (ModuleRegistrar.instance().hasHeadFMPProviders(id)){
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id);
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getMOP(), subtag, id);
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getHeadFMPProviders(id).values()){
for (IWailaFMPProvider provider : providersList)
@@ -54,7 +55,7 @@ public class HUDHandlerFMP implements IWailaDataProvider {
String id = subtag.getString("id");
if (ModuleRegistrar.instance().hasBodyFMPProviders(id)){
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id);
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getMOP(), subtag, id);
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getBodyFMPProviders(id).values()){
for (IWailaFMPProvider provider : providersList)
@@ -74,7 +75,7 @@ public class HUDHandlerFMP implements IWailaDataProvider {
String id = subtag.getString("id");
if (ModuleRegistrar.instance().hasTailFMPProviders(id)){
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getPosition(), subtag, id);
DataAccessorFMP.instance.set(accessor.getWorld(), accessor.getPlayer(), accessor.getMOP(), subtag, id);
for (List<IWailaFMPProvider> providersList : ModuleRegistrar.instance().getTailFMPProviders(id).values()){
for (IWailaFMPProvider provider : providersList)
@@ -87,7 +88,7 @@ public class HUDHandlerFMP implements IWailaDataProvider {
}
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) {
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
if (te != null)
te.writeToNBT(tag);
return tag;
@@ -2,9 +2,9 @@ package mcp.mobius.waila.handlers;
import mcp.mobius.waila.utils.ModIdentification;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class VanillaTooltipHandler {
@SubscribeEvent
@@ -12,6 +12,6 @@ public class VanillaTooltipHandler {
public void tooltipEvent(ItemTooltipEvent event) {
String canonicalName = ModIdentification.nameFromStack(event.itemStack);
if (canonicalName != null && !canonicalName.equals(""))
event.toolTip.add("\u00a79\u00a7o" + canonicalName);
event.toolTip.add("\u00a79\u00a7o" + canonicalName);
}
}
@@ -1,7 +1,9 @@
package mcp.mobius.waila.handlers.nei;
import java.util.Map;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerInputHandler;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.gui.screens.info.ScreenEnchants;
import mcp.mobius.waila.utils.Constants;
import mcp.mobius.waila.utils.ModIdentification;
@@ -11,132 +13,122 @@ import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.guihook.IContainerInputHandler;
import org.apache.logging.log4j.Level;
import java.util.Locale;
import java.util.Map;
public class HandlerEnchants implements IContainerInputHandler {
@Override
public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) { return false; }
@Override
public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) { }
@Override
public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyID) {
GuiContainerManager.getManager();
ItemStack stackover = GuiContainerManager.getStackMouseOver(gui);
if(stackover == null)
return false;
if(keyID == NEIClientConfig.getKeyBinding(Constants.BIND_SCREEN_ENCH)){
//try{
int itemEnchantability = stackover.getItem().getItemEnchantability();
if (itemEnchantability == 0){return false;}
Minecraft mc = Minecraft.getMinecraft();
ScreenEnchants screen = new ScreenEnchants(mc.currentScreen);
screen.setStack(stackover);
screen.setName(stackover.getDisplayName());
screen.setEnchantability(String.valueOf(itemEnchantability));
Enchantment[] enchants = null;
if (stackover.getItem() == Items.book)
enchants = Enchantment.enchantmentsBookList;
else
enchants = Enchantment.enchantmentsList;
for(Enchantment enchant : enchants){
boolean isCompatible = true;
int level = 0;
boolean isApplied = false;
if (enchant == null){continue;}
if (enchant.canApplyAtEnchantingTable(stackover) || stackover.getItem() == Items.book){
if (stackover.isItemEnchanted()){
Map stackenchants = EnchantmentHelper.getEnchantments(stackover);
for (Object id : stackenchants.keySet()){
if (!enchant.canApplyTogether(Enchantment.enchantmentsList[(Integer)id]))
isCompatible = false;
if ((Integer)id == enchant.effectId){
isApplied = true;
level = (Integer)stackenchants.get(id);
}
}
}
for (int lvl = enchant.getMinLevel(); lvl <= enchant.getMaxLevel(); lvl++){
int minEnchantEnchantability = enchant.getMinEnchantability(lvl);
int maxEnchantEnchantability = enchant.getMaxEnchantability(lvl);
int minItemEnchantability = 1;
int meanItemEnchantability = 1 + itemEnchantability/4;
int maxItemEnchantability = 1 + itemEnchantability/2;
int minModifiedEnchantability = (int)(0.85*minItemEnchantability + 0.5);
int meanModifiedEnchantability = (int)(1.00*meanItemEnchantability + 0.5);
int maxModifiedEnchantability = (int)(1.15*maxItemEnchantability + 0.5);
int minLevel = (int) ((minEnchantEnchantability - minModifiedEnchantability)/1.15);
int maxLevel = (int) ((maxEnchantEnchantability - maxModifiedEnchantability)/0.85);
int meanMinLevel = (int) ((minEnchantEnchantability - meanModifiedEnchantability)/1.0);
int meanMaxLevel = (int) ((maxEnchantEnchantability - meanModifiedEnchantability)/1.0);
String colorcode = isCompatible ? "\u00a7f" : "\u00a7c";
if (isApplied && lvl == level)
colorcode = "\u00a7e";
screen.addRow(colorcode + enchant.getTranslatedName(lvl),
colorcode + String.valueOf(minLevel),
colorcode + String.valueOf(maxLevel),
colorcode + String.valueOf(enchant.getWeight()),
"\u00a79\u00a7o"+ ModIdentification.nameFromObject(enchant));
}
}
}
mc.displayGuiScreen(screen);
}
public boolean keyTyped(GuiContainer guiContainer, char keyChar, int keyCode) {
return false;
}
@Override
public void onKeyTyped(GuiContainer guiContainer, char keyChar, int keyID) {
}
@Override
public boolean lastKeyTyped(GuiContainer guiContainer, char keyChar, int keyID) {
GuiContainerManager.getManager();
ItemStack stackover = GuiContainerManager.getStackMouseOver(guiContainer);
if (stackover == null)
return false;
if (keyID == NEIClientConfig.getKeyBinding(Constants.BIND_SCREEN_ENCH)) {
int itemEnchantability = stackover.getItem().getItemEnchantability();
if (itemEnchantability == 0) {
return false;
}
Minecraft mc = Minecraft.getMinecraft();
ScreenEnchants screen = new ScreenEnchants(mc.currentScreen);
screen.setStack(stackover);
screen.setName(stackover.getDisplayName());
screen.setEnchantability(String.valueOf(itemEnchantability));
Enchantment[] enchants = null;
if (stackover.getItem() == Items.book)
enchants = Enchantment.enchantmentsBookList;
else
enchants = Enchantment.enchantmentsBookList;
for (Enchantment enchant : enchants) {
boolean isCompatible = true;
int level = 0;
boolean isApplied = false;
if (enchant == null) {
continue;
}
if (enchant.canApplyAtEnchantingTable(stackover) || stackover.getItem() == Items.book) {
if (stackover.isItemEnchanted()) {
Map stackenchants = EnchantmentHelper.getEnchantments(stackover);
for (Object id : stackenchants.keySet()) {
if (!enchant.canApplyTogether(Enchantment.getEnchantmentById((Integer) id)))
isCompatible = false;
if ((Integer) id == enchant.effectId) {
isApplied = true;
level = (Integer) stackenchants.get(id);
}
}
}
for (int lvl = enchant.getMinLevel(); lvl <= enchant.getMaxLevel(); lvl++) {
String colorcode = isCompatible ? "\u00a7f" : "\u00a7c";
if (isApplied && lvl == level)
colorcode = "\u00a7e";
String enchantModName = getEnchantModName(enchant);
if (enchantModName == null) {
enchantModName = "Minecraft";
}
screen.addRow(colorcode + enchant.getTranslatedName(lvl),
colorcode + String.valueOf(enchant.getMinLevel()),
colorcode + String.valueOf(enchant.getMaxLevel()),
colorcode + String.valueOf(enchant.getWeight()),
"\u00a79\u00a7o" + enchantModName);
}
}
}
mc.displayGuiScreen(screen);
}
return false;
}
/*
public String getEnchantModName(Enchantment enchant){
String enchantPath = enchant.getClass().getProtectionDomain().getCodeSource().getLocation().toString();
//mod_Waila.log.log(Level.INFO, enchantPath);
Waila.log.log(Level.DEBUG, enchantPath);
String enchantModName = "<Unknown>";
for (String s: mod_Waila.instance.modSourceList.keySet())
if (enchantPath.contains(s))
enchantModName = mod_Waila.instance.modSourceList.get(s);
if (enchantModName.equals("Minecraft Coder Pack"))
enchantModName = "Minecraft";
return enchantModName;
for (String s: ModIdentification.modSource_ID.keySet())
if (enchantPath.toLowerCase(Locale.US).contains(s.toLowerCase(Locale.US)))
return enchantModName = ModIdentification.modSource_ID.get(s);
return null;
}
*/
@Override
public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) { return false; }
@Override
public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) { }
public boolean mouseClicked(GuiContainer guiContainer, int mouseX, int mouseY, int button) { return false; }
@Override
public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) { }
public void onMouseClicked(GuiContainer guiContainer, int mouseX, int mouseY, int button) {}
@Override
public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { return false; }
public void onMouseUp(GuiContainer guiContainer, int mouseX, int mouseY, int button) {}
@Override
public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { }
public boolean mouseScrolled(GuiContainer guiContainer, int mouseX, int mouseY, int scrolled) { return false; }
@Override
public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) { }
public void onMouseScrolled(GuiContainer guiContainer, int mouseX, int mouseY, int scrolled) {}
}
@Override
public void onMouseDragged(GuiContainer guiContainer, int mouseX, int mouseY, int button, long heldTime) {}
}
@@ -3,6 +3,7 @@ package mcp.mobius.waila.handlers.nei;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@@ -39,7 +40,7 @@ public class ModNameFilter implements ISearchProvider{
@Override
public boolean matches(ItemStack itemstack) {
return this.pattern.matcher(ModIdentification.nameFromStack(itemstack).toLowerCase()).find();
return this.pattern.matcher(ModIdentification.nameFromStack(itemstack).toLowerCase(Locale.US)).find();
}
}
@@ -1,5 +1,6 @@
package mcp.mobius.waila.handlers.nei;
import java.util.Locale;
import java.util.regex.Pattern;
import net.minecraft.item.ItemStack;
@@ -35,7 +36,7 @@ public class OreDictFilter implements ISearchProvider{
int[] ids = OreDictionary.getOreIDs(itemstack);
boolean found = false;
for (int id : ids){
if (pattern.matcher(OreDictionary.getOreName(id).toLowerCase()).find()){
if (pattern.matcher(OreDictionary.getOreName(id).toLowerCase(Locale.US)).find()){
found = true;
}
}
@@ -1,7 +1,8 @@
package mcp.mobius.waila.network;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraft.util.BlockPos;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
@@ -47,16 +48,16 @@ public class Message0x01TERequest extends SimpleChannelInboundHandler<Message0x0
public int dim;
public int posX;
public int posY;
public int posZ;
public int posZ;
public HashSet<String> keys = new HashSet<String> ();
public Message0x01TERequest(){}
public Message0x01TERequest(TileEntity ent, HashSet<String> keys){
this.dim = ent.getWorldObj().provider.dimensionId;
this.posX = ent.xCoord;
this.posY = ent.yCoord;
this.posZ = ent.zCoord;
this.dim = ent.getWorld().provider.getDimensionId();
this.posX = ent.getPos().getX();
this.posY = ent.getPos().getY();
this.posZ = ent.getPos().getZ();
this.keys = keys;
}
@@ -95,8 +96,9 @@ public class Message0x01TERequest extends SimpleChannelInboundHandler<Message0x0
protected void channelRead0(ChannelHandlerContext ctx, Message0x01TERequest msg) throws Exception {
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
World world = DimensionManager.getWorld(msg.dim);
TileEntity entity = world.getTileEntity(msg.posX, msg.posY, msg.posZ);
Block block = world.getBlock(msg.posX, msg.posY, msg.posZ);
BlockPos pos = new BlockPos(msg.posX, msg.posY, msg.posZ);
TileEntity entity = world.getTileEntity(pos);
Block block = world.getBlockState(pos).getBlock();
if (entity != null){
try{
@@ -115,7 +117,7 @@ public class Message0x01TERequest extends SimpleChannelInboundHandler<Message0x0
for (List<IWailaDataProvider> providersList : ModuleRegistrar.instance().getNBTProviders(block).values()){
for (IWailaDataProvider provider : providersList){
try{
tag = provider.getNBTData(player, entity, tag, world, msg.posX, msg.posY, msg.posZ);
tag = provider.getNBTData(player, entity, tag, world, new BlockPos(msg.posX, msg.posY, msg.posZ));
} catch (AbstractMethodError ame){
tag = AccessHelper.getNBTData(provider, entity, tag, world, msg.posX, msg.posY, msg.posZ);
} catch (NoSuchMethodError nsm){
@@ -128,7 +130,7 @@ public class Message0x01TERequest extends SimpleChannelInboundHandler<Message0x0
for (List<IWailaDataProvider> providersList : ModuleRegistrar.instance().getNBTProviders(entity).values()){
for (IWailaDataProvider provider : providersList){
try{
tag = provider.getNBTData(player, entity, tag, world, msg.posX, msg.posY, msg.posZ);
tag = provider.getNBTData(player, entity, tag, world, new BlockPos(msg.posX, msg.posY, msg.posZ));
} catch (AbstractMethodError ame){
tag = AccessHelper.getNBTData(provider, entity, tag, world, msg.posX, msg.posY, msg.posZ);
} catch (NoSuchMethodError nsm){
@@ -1,7 +1,7 @@
package mcp.mobius.waila.network;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
@@ -30,7 +30,7 @@ public class Message0x03EntRequest extends SimpleChannelInboundHandler<Message0x
public Message0x03EntRequest(){}
public Message0x03EntRequest(Entity ent, HashSet<String> keys){
this.dim = ent.worldObj.provider.dimensionId;
this.dim = ent.worldObj.provider.getDimensionId();
this.id = ent.getEntityId();
this.keys = keys;
}
@@ -2,8 +2,8 @@ package mcp.mobius.waila.network;
import mcp.mobius.waila.Waila;
import net.minecraft.entity.player.EntityPlayerMP;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
public class NetworkHandler {
@SubscribeEvent
@@ -1,12 +1,14 @@
package mcp.mobius.waila.network;
import com.google.common.base.Charsets;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
import cpw.mods.fml.common.network.FMLOutboundHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.FMLEmbeddedChannel;
import net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec;
import net.minecraftforge.fml.common.network.FMLOutboundHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
@@ -90,23 +92,19 @@ public enum WailaPacketHandler {
public void writeNBT(ByteBuf target, NBTTagCompound tag) throws IOException{
if (tag == null)
target.writeShort(-1);
else{
byte[] abyte = CompressedStreamTools.compress(tag);
target.writeShort((short)abyte.length);
target.writeBytes(abyte);
else {
target.writeShort(0);
CompressedStreamTools.writeCompressed(tag, new ByteBufOutputStream(target));
}
}
public NBTTagCompound readNBT(ByteBuf dat) throws IOException
{
short short1 = dat.readShort();
if (short1 < 0)
return null;
else{
byte[] abyte = new byte[short1];
dat.readBytes(abyte);
return CompressedStreamTools.func_152457_a(abyte, NBTSizeTracker.field_152451_a);
return CompressedStreamTools.readCompressed(new ByteBufInputStream(dat));
}
}
@@ -2,11 +2,12 @@ package mcp.mobius.waila.overlay;
import java.util.List;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import mcp.mobius.waila.api.IWailaBlockDecorator;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.api.impl.DataAccessorCommon;
@@ -31,7 +32,7 @@ public class DecoratorRenderer {
DataAccessorCommon accessor = DataAccessorCommon.instance;
World world = Minecraft.getMinecraft().theWorld;
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
EntityLivingBase viewEntity = Minecraft.getMinecraft().renderViewEntity;
Entity viewEntity = Minecraft.getMinecraft().getRenderViewEntity();
if (world == null || player == null || viewEntity == null) return;
@@ -1,15 +1,5 @@
package mcp.mobius.waila.overlay;
import static mcp.mobius.waila.api.SpecialChars.*;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.lwjgl.opengl.GL11;
import mcp.mobius.waila.api.IWailaTooltipRenderer;
import mcp.mobius.waila.api.impl.DataAccessorCommon;
import mcp.mobius.waila.api.impl.ModuleRegistrar;
@@ -20,103 +10,109 @@ import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import static mcp.mobius.waila.api.SpecialChars.*;
public class DisplayUtil {
private static FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
private static TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
private static RenderItem renderItem = new RenderItem();
public static int getDisplayWidth(String s) {
if (s == null || s.equals(""))
return 0;
int width = 0;
Matcher renderMatcher = patternRender.matcher(s);
while (renderMatcher.find()){
IWailaTooltipRenderer renderer = ModuleRegistrar.instance().getTooltipRenderer(renderMatcher.group("name"));
if (renderer != null)
width += renderer.getSize(renderMatcher.group("args").split(","), DataAccessorCommon.instance).width;
}
Matcher iconMatcher = patternIcon.matcher(s);
while (iconMatcher.find())
width += 8;
width += fontRenderer.getStringWidth(stripSymbols(s));
return width;
}
public static Dimension displaySize() {
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
return new Dimension(res.getScaledWidth(), res.getScaledHeight());
}
public static String stripSymbols(String s){
String result = patternRender.matcher(s).replaceAll("");
result = patternMinecraft.matcher(result).replaceAll("");
result = patternWaila.matcher(result).replaceAll("");
return result;
}
public static String stripWailaSymbols(String s){
String result = patternRender.matcher(s).replaceAll("");
result = patternWaila.matcher(result).replaceAll("");
return result;
}
public static void renderStack(int x, int y, ItemStack stack){
enable3DRender();
try{
renderItem.renderItemAndEffectIntoGUI(fontRenderer, textureManager, stack, x, y);
renderItem.renderItemOverlayIntoGUI(fontRenderer, textureManager, stack, x, y);
} catch (Exception e){
String stackStr = stack != null ? stack.toString() : "NullStack";
WailaExceptionHandler.handleErr(e, "renderStack | " + stackStr, null);
}
enable2DRender();
}
public static void enable3DRender() {
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
public static void enable2DRender() {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
}
private static FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
protected static RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
public static void drawGradientRect(int x, int y, int w, int h, int grad1, int grad2)
{
public static int getDisplayWidth(String s) {
if (s == null || s.equals(""))
return 0;
int width = 0;
Matcher renderMatcher = patternRender.matcher(s);
while (renderMatcher.find()) {
IWailaTooltipRenderer renderer = ModuleRegistrar.instance().getTooltipRenderer(renderMatcher.group("name"));
if (renderer != null)
width += renderer.getSize(renderMatcher.group("args").split(","), DataAccessorCommon.instance).width;
}
Matcher iconMatcher = patternIcon.matcher(s);
while (iconMatcher.find())
width += 8;
width += fontRendererObj.getStringWidth(stripSymbols(s));
return width;
}
public static Dimension displaySize() {
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
return new Dimension(res.getScaledWidth(), res.getScaledHeight());
}
public static String stripSymbols(String s) {
String result = patternRender.matcher(s).replaceAll("");
result = patternMinecraft.matcher(result).replaceAll("");
result = patternWaila.matcher(result).replaceAll("");
return result;
}
public static String stripWailaSymbols(String s) {
String result = patternRender.matcher(s).replaceAll("");
result = patternWaila.matcher(result).replaceAll("");
return result;
}
public static void renderStack(int x, int y, ItemStack stack) {
enable3DRender();
try {
renderItem.renderItemAndEffectIntoGUI(stack, x, y);
renderItem.renderItemOverlayIntoGUI(fontRendererObj, stack, x, y, null);
} catch (Exception e) {
String stackStr = stack != null ? stack.toString() : "NullStack";
WailaExceptionHandler.handleErr(e, "renderStack | " + stackStr, null);
}
enable2DRender();
}
public static void enable3DRender() {
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
public static void enable2DRender() {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
}
public static void drawGradientRect(int x, int y, int w, int h, int grad1, int grad2) {
float zLevel = 0.0f;
float f = (float)(grad1 >> 24 & 255) / 255.0F;
float f1 = (float)(grad1 >> 16 & 255) / 255.0F;
float f2 = (float)(grad1 >> 8 & 255) / 255.0F;
float f3 = (float)(grad1 & 255) / 255.0F;
float f4 = (float)(grad2 >> 24 & 255) / 255.0F;
float f5 = (float)(grad2 >> 16 & 255) / 255.0F;
float f6 = (float)(grad2 >> 8 & 255) / 255.0F;
float f7 = (float)(grad2 & 255) / 255.0F;
float f = (float) (grad1 >> 24 & 255) / 255.0F;
float f1 = (float) (grad1 >> 16 & 255) / 255.0F;
float f2 = (float) (grad1 >> 8 & 255) / 255.0F;
float f3 = (float) (grad1 & 255) / 255.0F;
float f4 = (float) (grad2 >> 24 & 255) / 255.0F;
float f5 = (float) (grad2 >> 16 & 255) / 255.0F;
float f6 = (float) (grad2 >> 8 & 255) / 255.0F;
float f7 = (float) (grad2 & 255) / 255.0F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(f1, f2, f3, f);
tessellator.addVertex((double)(x+w), (double)y, (double)zLevel);
tessellator.addVertex((double)x, (double)y, (double)zLevel);
tessellator.setColorRGBA_F(f5, f6, f7, f4);
tessellator.addVertex((double)x, (double)(y+h), (double)zLevel);
tessellator.addVertex((double)(x+w), (double)(y+h), (double)zLevel);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer t = tessellator.getWorldRenderer();
t.startDrawingQuads();
t.setColorRGBA_F(f1, f2, f3, f);
t.addVertex((double) (x + w), (double) y, (double) zLevel);
t.addVertex((double) x, (double) y, (double) zLevel);
t.setColorRGBA_F(f5, f6, f7, f4);
t.addVertex((double) x, (double) (y + h), (double) zLevel);
t.addVertex((double) (x + w), (double) (y + h), (double) zLevel);
tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
@@ -124,64 +120,64 @@ public class DisplayUtil {
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
public static void drawTexturedModalRect(int x, int y, int u, int v, int w, int h, int tw, int th)
{
float f = 0.00390625F;
float f1 = 0.00390625F;
float zLevel = 0.0F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorOpaque_F(1, 1, 1);
tessellator.addVertexWithUV(x + 0, y + h, zLevel, (u + 0) * f, (v + th) * f1);
tessellator.addVertexWithUV(x + w, y + h, zLevel, (u + tw) * f, (v + th) * f1);
tessellator.addVertexWithUV(x + w, y + 0, zLevel, (u + tw) * f, (v + 0) * f1);
tessellator.addVertexWithUV(x + 0, y + 0, zLevel, (u + 0) * f, (v + 0) * f1);
tessellator.draw();
}
public static void drawTexturedModalRect(int x, int y, int u, int v, int w, int h, int tw, int th) {
float f = 0.00390625F;
float f1 = 0.00390625F;
float zLevel = 0.0F;
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer t = tessellator.getWorldRenderer();
t.startDrawingQuads();
t.setColorOpaque_F(1, 1, 1);
t.addVertexWithUV(x + 0, y + h, zLevel, (u + 0) * f, (v + th) * f1);
t.addVertexWithUV(x + w, y + h, zLevel, (u + tw) * f, (v + th) * f1);
t.addVertexWithUV(x + w, y + 0, zLevel, (u + tw) * f, (v + 0) * f1);
t.addVertexWithUV(x + 0, y + 0, zLevel, (u + 0) * f, (v + 0) * f1);
tessellator.draw();
}
public static void drawString(String text, int x, int y, int colour, boolean shadow) {
if (shadow)
fontRenderer.drawStringWithShadow(text, x, y, colour);
fontRendererObj.drawStringWithShadow(text, x, y, colour);
else
fontRenderer.drawString(text, x, y, colour);
}
fontRendererObj.drawString(text, x, y, colour);
}
public static List<String> itemDisplayNameMultiline(ItemStack itemstack) {
List<String> namelist = null;
try {
namelist = itemstack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
} catch (Throwable ignored) {}
} catch (Throwable ignored) {
}
if (namelist == null)
namelist = new ArrayList<String>();
if (namelist.size() == 0)
namelist.add("Unnamed");
if (namelist.get(0) == null || namelist.get(0).equals(""))
namelist.set(0, "Unnamed");
namelist.set(0, itemstack.getRarity().rarityColor.toString() + namelist.get(0));
for (int i = 1; i < namelist.size(); i++)
namelist.set(i, "\u00a77" + namelist.get(i));
return namelist;
}
public static String itemDisplayNameShort(ItemStack itemstack) {
List<String> list = itemDisplayNameMultiline(itemstack);
return list.get(0);
}
public static void renderIcon(int x, int y, int sx, int sy, IconUI icon){
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.icons);
if (icon == null)
return;
if (icon.bu != -1)
DisplayUtil.drawTexturedModalRect(x, y, icon.bu, icon.bv, sx, sy, icon.bsu, icon.bsv);
DisplayUtil.drawTexturedModalRect(x, y, icon.u, icon.v, sx, sy, icon.su, icon.sv);
}
}
public static void renderIcon(int x, int y, int sx, int sy, IconUI icon) {
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.icons);
if (icon == null)
return;
if (icon.bu != -1)
DisplayUtil.drawTexturedModalRect(x, y, icon.bu, icon.bv, sx, sy, icon.bsu, icon.bsv);
DisplayUtil.drawTexturedModalRect(x, y, icon.u, icon.v, sx, sy, icon.su, icon.sv);
}
}
@@ -1,40 +1,35 @@
package mcp.mobius.waila.overlay;
import mcp.mobius.waila.api.impl.ConfigHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.util.MovingObjectPosition;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import mcp.mobius.waila.api.impl.ConfigHandler;
import mcp.mobius.waila.utils.Constants;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraftforge.common.config.Configuration;
import net.minecraft.util.MovingObjectPosition;
public class OverlayRenderer {
protected static boolean hasBlending;
protected static boolean hasLight;
protected static boolean hasDepthTest;
protected static boolean hasLight0;
protected static boolean hasLight1;
protected static boolean hasRescaleNormal;
protected static boolean hasColorMaterial;
protected static int boundTexIndex;
protected static boolean hasBlending;
protected static boolean hasLight;
protected static boolean hasDepthTest;
protected static boolean hasLight0;
protected static boolean hasLight1;
protected static boolean hasRescaleNormal;
protected static boolean hasColorMaterial;
protected static int boundTexIndex;
public static void renderOverlay()
{
Minecraft mc = Minecraft.getMinecraft();
if(!(mc.currentScreen == null &&
mc.theWorld != null &&
Minecraft.isGuiEnabled() &&
!mc.gameSettings.keyBindPlayerList.getIsKeyPressed() &&
ConfigHandler.instance().showTooltip() &&
RayTracing.instance().getTarget() != null))
return;
mc.theWorld != null &&
Minecraft.isGuiEnabled() &&
!mc.gameSettings.keyBindPlayerList.isKeyDown() &&
ConfigHandler.instance().showTooltip() &&
RayTracing.instance().getTarget() != null))
return;
if (RayTracing.instance().getTarget().typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && RayTracing.instance().getTargetStack() != null)
{
renderOverlay(WailaTickHandler.instance().tooltip);
@@ -42,87 +37,86 @@ public class OverlayRenderer {
if (RayTracing.instance().getTarget().typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && ConfigHandler.instance().getConfig("general.showents"))
{
renderOverlay(WailaTickHandler.instance().tooltip);
renderOverlay(WailaTickHandler.instance().tooltip);
}
}
}
public static void renderOverlay(Tooltip tooltip)
{
//TrueTypeFont font = (TrueTypeFont)mod_Waila.proxy.getFont();
GL11.glPushMatrix();
saveGLState();
GL11.glScalef(OverlayConfig.scale, OverlayConfig.scale, 1.0f);
//TrueTypeFont font = (TrueTypeFont)mod_Waila.proxy.getFont();
GL11.glPushMatrix();
saveGLState();
GL11.glScalef(OverlayConfig.scale, OverlayConfig.scale, 1.0f);
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
drawTooltipBox(tooltip.x, tooltip.y, tooltip.w, tooltip.h, OverlayConfig.bgcolor, OverlayConfig.gradient1, OverlayConfig.gradient2);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
tooltip.draw();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
tooltip.draw();
GL11.glDisable(GL11.GL_BLEND);
tooltip.draw2nd();
if (tooltip.hasIcon)
RenderHelper.enableGUIStandardItemLighting();
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
if (tooltip.hasIcon && tooltip.stack != null && tooltip.stack.getItem() != null)
DisplayUtil.renderStack(tooltip.x+5, tooltip.y+tooltip.h/2-8, tooltip.stack);
loadGLState();
GL11.glPopMatrix();
}
public static void saveGLState(){
hasBlending = GL11.glGetBoolean(GL11.GL_BLEND);
hasLight = GL11.glGetBoolean(GL11.GL_LIGHTING);
//hasLight0 = GL11.glGetBoolean(GL11.GL_LIGHT0);
//hasLight1 = GL11.glGetBoolean(GL11.GL_LIGHT1);
hasDepthTest = GL11.glGetBoolean(GL11.GL_DEPTH_TEST);
//hasRescaleNormal = GL11.glGetBoolean(GL12.GL_RESCALE_NORMAL);
//hasColorMaterial = GL11.glGetBoolean(GL11.GL_COLOR_MATERIAL);
boundTexIndex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
GL11.glPopMatrix();
}
public static void saveGLState(){
//hasBlending = GL11.glGetBoolean(GL11.GL_BLEND);
hasLight = GL11.glGetBoolean(GL11.GL_LIGHTING);
//hasLight0 = GL11.glGetBoolean(GL11.GL_LIGHT0);
//hasLight1 = GL11.glGetBoolean(GL11.GL_LIGHT1);
hasDepthTest = GL11.glGetBoolean(GL11.GL_DEPTH_TEST);
//hasRescaleNormal = GL11.glGetBoolean(GL12.GL_RESCALE_NORMAL);
//hasColorMaterial = GL11.glGetBoolean(GL11.GL_COLOR_MATERIAL);
//boundTexIndex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
}
public static void loadGLState(){
if (hasBlending) GL11.glEnable(GL11.GL_BLEND); else GL11.glDisable(GL11.GL_BLEND);
//if (hasLight) GL11.glEnable(GL11.GL_LIGHTING); else GL11.glDisable(GL11.GL_LIGHTING);
//if (hasLight0) GL11.glEnable(GL11.GL_LIGHT0); else GL11.glDisable(GL11.GL_LIGHT0);
if (hasLight1) GL11.glEnable(GL11.GL_LIGHT1); else GL11.glDisable(GL11.GL_LIGHT1);
if (hasDepthTest) GL11.glEnable(GL11.GL_DEPTH_TEST); else GL11.glDisable(GL11.GL_DEPTH_TEST);
//if (hasRescaleNormal) GL11.glEnable(GL12.GL_RESCALE_NORMAL); else GL11.glDisable(GL12.GL_RESCALE_NORMAL);
//if (hasColorMaterial) GL11.glEnable(GL11.GL_COLOR_MATERIAL); else GL11.glDisable(GL11.GL_COLOR_MATERIAL);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, boundTexIndex);
GL11.glPopAttrib();
//GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
//if (hasBlending) GL11.glEnable(GL11.GL_BLEND); else GL11.glDisable(GL11.GL_BLEND);
if (hasLight) GL11.glEnable(GL11.GL_LIGHTING); else GL11.glDisable(GL11.GL_LIGHTING);
//if (hasLight0) GL11.glEnable(GL11.GL_LIGHT0); else GL11.glDisable(GL11.GL_LIGHT0);
//if (hasLight1) GL11.glEnable(GL11.GL_LIGHT1); else GL11.glDisable(GL11.GL_LIGHT1);
if (hasDepthTest) GL11.glEnable(GL11.GL_DEPTH_TEST); else GL11.glDisable(GL11.GL_DEPTH_TEST);
//if (hasRescaleNormal) GL11.glEnable(GL12.GL_RESCALE_NORMAL); else GL11.glDisable(GL12.GL_RESCALE_NORMAL);
//if (hasColorMaterial) GL11.glEnable(GL11.GL_COLOR_MATERIAL); else GL11.glDisable(GL11.GL_COLOR_MATERIAL);
//GL11.glBindTexture(GL11.GL_TEXTURE_2D, boundTexIndex);
GL11.glPopAttrib();
//GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
public static void drawTooltipBox(int x, int y, int w, int h, int bg, int grad1, int grad2)
{
//int bg = 0xf0100010;
DisplayUtil.drawGradientRect(x + 1, y, w - 1, 1, bg, bg);
DisplayUtil.drawGradientRect(x + 1, y + h, w - 1, 1, bg, bg);
DisplayUtil.drawGradientRect(x + 1, y + 1, w - 1, h - 1, bg, bg);//center
DisplayUtil.drawGradientRect(x, y + 1, 1, h - 1, bg, bg);
DisplayUtil.drawGradientRect(x + w, y + 1, 1, h - 1, bg, bg);
DisplayUtil.drawGradientRect(x + 1, y, w - 1, 1, bg, bg);
DisplayUtil.drawGradientRect(x + 1, y + h, w - 1, 1, bg, bg);
DisplayUtil.drawGradientRect(x + 1, y + 1, w - 1, h - 1, bg, bg);//center
DisplayUtil.drawGradientRect(x, y + 1, 1, h - 1, bg, bg);
DisplayUtil.drawGradientRect(x + w, y + 1, 1, h - 1, bg, bg);
//int grad1 = 0x505000ff;
//int grad2 = 0x5028007F;
DisplayUtil.drawGradientRect(x + 1, y + 2, 1, h - 3, grad1, grad2);
DisplayUtil.drawGradientRect(x + w - 1, y + 2, 1, h - 3, grad1, grad2);
DisplayUtil.drawGradientRect(x + 1, y + 1, w - 1, 1, grad1, grad1);
DisplayUtil.drawGradientRect(x + 1, y + h - 1, w - 1, 1, grad2, grad2);
}
}
DisplayUtil.drawGradientRect(x + 1, y + 2, 1, h - 3, grad1, grad2);
DisplayUtil.drawGradientRect(x + w - 1, y + 2, 1, h - 3, grad1, grad2);
DisplayUtil.drawGradientRect(x + 1, y + 1, w - 1, 1, grad1, grad1);
DisplayUtil.drawGradientRect(x + 1, y + h - 1, w - 1, 1, grad2, grad2);
}
}
@@ -21,6 +21,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
@@ -49,7 +50,7 @@ public class RayTracing {
return;
}
EntityLivingBase viewpoint = mc.renderViewEntity;
Entity viewpoint = mc.getRenderViewEntity();
if (viewpoint == null) return;
this.target = this.rayTrace(viewpoint, mc.playerController.getBlockReachDistance(), 0);
@@ -79,9 +80,9 @@ public class RayTracing {
return this.targetEntity;
}
public MovingObjectPosition rayTrace(EntityLivingBase entity, double par1, float par3)
public MovingObjectPosition rayTrace(Entity entity, double par1, float par3)
{
Vec3 vec3 = entity.getPosition(par3);
Vec3 vec3 = entity.getPositionEyes(par3);
Vec3 vec31 = entity.getLook(par3);
Vec3 vec32 = vec3.addVector(vec31.xCoord * par1, vec31.yCoord * par1, vec31.zCoord * par1);
@@ -139,15 +140,13 @@ public class RayTracing {
return items;
EntityPlayer player = mc.thePlayer;
World world = mc.theWorld;
int x = this.target.blockX;
int y = this.target.blockY;
int z = this.target.blockZ;
World world = mc.theWorld;
BlockPos pos = target.getBlockPos();
//int blockID = world.getBlockId(x, y, z);
//Block mouseoverBlock = Block.blocksList[blockID];
Block mouseoverBlock = world.getBlock(x, y, z);
TileEntity tileEntity = world.getTileEntity(x, y, z);
Block mouseoverBlock = world.getBlockState(pos).getBlock();
TileEntity tileEntity = world.getTileEntity(pos);
if (mouseoverBlock == null) return items;
if (ModuleRegistrar.instance().hasStackProviders(mouseoverBlock)){
@@ -184,9 +183,9 @@ public class RayTracing {
if(items.size() > 0)
return items;
if (world.getTileEntity(x, y, z) == null){
if (world.getTileEntity(pos) == null){
try{
ItemStack block = new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z));
ItemStack block = new ItemStack(mouseoverBlock, 1, mouseoverBlock.getMetaFromState(world.getBlockState(pos)));
//System.out.printf("%s %s %s\n", block, block.getDisplayName(), block.getItemDamage());
@@ -206,7 +205,7 @@ public class RayTracing {
return items;
try{
ItemStack pick = mouseoverBlock.getPickBlock(this.target, world, x, y, z);
ItemStack pick = mouseoverBlock.getPickBlock(this.target, world, pos);
if(pick != null)
items.add(pick);
}catch(Exception e){}
@@ -228,14 +227,14 @@ public class RayTracing {
if(mouseoverBlock instanceof IShearable)
{
IShearable shearable = (IShearable)mouseoverBlock;
if(shearable.isShearable(new ItemStack(Items.shears), world, x, y, z))
if(shearable.isShearable(new ItemStack(Items.shears), world, pos))
{
items.addAll(shearable.onSheared(new ItemStack(Items.shears), world, x, y, z, 0));
items.addAll(shearable.onSheared(new ItemStack(Items.shears), world, pos, 0));
}
}
if(items.size() == 0)
items.add(0, new ItemStack(mouseoverBlock, 1, world.getBlockMetadata(x, y, z)));
items.add(0, new ItemStack(mouseoverBlock, 1, mouseoverBlock.getMetaFromState(world.getBlockState(pos))));
return items;
}
@@ -1,57 +1,53 @@
package mcp.mobius.waila.overlay;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.awt.Dimension;
import java.awt.Point;
import org.lwjgl.opengl.GL11;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
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.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.overlay.tooltiprenderers.TTRenderTrueTyper;
import mcp.mobius.waila.utils.Constants;
import mcp.mobius.waila.utils.WailaExceptionHandler;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import static mcp.mobius.waila.api.SpecialChars.*;
public class Tooltip {
public static int TabSpacing = 8;
public static int IconSize = 8;
public static int IconSize = 8;
ArrayList<ArrayList<String>> lines = new ArrayList<ArrayList<String>>();
ArrayList<ArrayList<Integer>> sizes = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> columnsWidth = new ArrayList<Integer>();
ArrayList<Integer> columnsPos = new ArrayList<Integer>();
ArrayList<Integer> columnsPos = new ArrayList<Integer>();
ArrayList<Renderable> elements = new ArrayList<Renderable>();
ArrayList<Renderable> elements2nd = new ArrayList<Renderable>();
int w,h,x,y,ty;
int offsetX;
int maxStringW;
Point pos;
boolean hasIcon = false;
ItemStack stack;
IWailaCommonAccessor accessor = DataAccessorCommon.instance;
/////////////////////////////////////Renderable///////////////////////////////////////
private class Renderable{
final IWailaTooltipRenderer renderer;
final Point pos;
final String[] params;
public Renderable(IWailaTooltipRenderer renderer, Point pos, String[] params){
this.renderer = renderer;
this.pos = pos;
@@ -60,58 +56,58 @@ public class Tooltip {
public Renderable(IWailaTooltipRenderer renderer, Point pos){
this(renderer, pos, new String[]{});
}
}
public Point getPos(){
return this.pos;
}
public Dimension getSize(IWailaCommonAccessor accessor) {
Dimension dim = new Dimension(0,0);
try {
dim = this.renderer.getSize(this.params, accessor);
} catch (Throwable e){
WailaExceptionHandler.handleErr(e, this.renderer.getClass().getName() + ".getSize()", null);
WailaExceptionHandler.handleErr(e, this.renderer.getClass().getName() + ".getSize()", null);
}
return dim;
return dim;
}
public void draw(IWailaCommonAccessor accessor, int x, int y) {
GL11.glPushMatrix();
GL11.glTranslatef(x + this.pos.x, y + this.pos.y, 0);
try{
this.renderer.draw(this.params, accessor);
} catch (Throwable e){
WailaExceptionHandler.handleErr(e, this.renderer.getClass().getName() + ".draw()", null);
WailaExceptionHandler.handleErr(e, this.renderer.getClass().getName() + ".draw()", null);
}
GL11.glPopMatrix();
}
@Override
public String toString(){
return String.format("Renderable@[%d,%d] | %s", pos.x, pos.y, renderer);
}
}
////////////////////////////////////////////////////////////////////////////
public Tooltip(List<String> textData, ItemStack stack){
this(textData, true);
this.stack = stack;
}
public Tooltip(List<String> textData, boolean hasIcon){
columnsWidth.add(0); // Small init of the arrays to have at least one element
columnsPos.add(0);
columnsPos.add(0);
for (String s : textData){
ArrayList<String> line = new ArrayList<String>(Arrays.asList(patternTab.split(s)));
ArrayList<Integer> size = new ArrayList<Integer>();
for (String ss : line)
size.add(DisplayUtil.getDisplayWidth(ss));
// This line.size() > 1 is to prevent columns to align on lines without column (ie : the name & modid)
if (line.size() > 1){
while (columnsWidth.size() < line.size()){
@@ -122,25 +118,25 @@ public class Tooltip {
for (int i = 0; i < line.size(); i++)
columnsWidth.set(i, Math.max(columnsWidth.get(i), size.get(i)));
}
maxStringW = Math.max(maxStringW, DisplayUtil.getDisplayWidth(s) + TabSpacing * (line.size() - 1));
lines.add(line);
sizes.add(size);
}
// We correct if we only have one column
if (columnsWidth.size() == 1)
columnsWidth.set(0, maxStringW);
// We compute the position of the columns to be able to align the renderable later on
for (int i = 1; i < columnsWidth.size(); i++)
columnsPos.set(i, columnsWidth.get(i - 1) + columnsPos.get(i - 1) + TabSpacing);
this.computeRenderables();
this.computePositionAndSize(hasIcon);
}
private void computeRenderables(){
int offsetY = 0;
for (int i = 0; i < lines.size(); i++){ // We check all the lines, one by one
@@ -149,36 +145,36 @@ public class Tooltip {
offsetX = columnsPos.get(c); // We move the "cursor" to the current column
String currentLine = lines.get(i).get(c);
Matcher lineMatcher = patternLineSplit.matcher(currentLine);
while (lineMatcher.find()){
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");
IWailaTooltipRenderer renderer = ModuleRegistrar.instance().getTooltipRenderer(renderName);
if (renderer != null){
renderable = new Renderable(renderer, new Point(offsetX, offsetY), renderMatcher.group("args").split(","));
this.elements2nd.add(renderable);
this.elements2nd.add(renderable);
}
} else if (iconMatcher.find()){
renderable = new Renderable(new TTRenderIcon(iconMatcher.group("type")), new Point(offsetX, offsetY));
this.elements2nd.add(renderable);
this.elements2nd.add(renderable);
} else {
if (cs.startsWith(ALIGNRIGHT))
offsetX += columnsWidth.get(c) - DisplayUtil.getDisplayWidth(currentLine.substring(lineMatcher.start()));
if (cs.startsWith(ALIGNCENTER))
offsetX += (columnsWidth.get(c) - DisplayUtil.getDisplayWidth(currentLine.substring(lineMatcher.start()))) / 2;
renderable = new Renderable(new TTRenderString(DisplayUtil.stripWailaSymbols(cs)), new Point(offsetX, offsetY));
//renderable = new Renderable(new TTRenderTrueTyper(DisplayUtil.stripWailaSymbols(cs)), new Point(offsetX, offsetY));
this.elements.add(renderable);
}
if (renderable != null){
offsetX += renderable.getSize(accessor).width;
maxHeight = Math.max(maxHeight, renderable.getSize(accessor).height + 2);
@@ -188,34 +184,34 @@ public class Tooltip {
offsetY += maxHeight;
}
}
private int getRenderableTotalHeight(){
int result = 0;
for (Renderable r : this.elements)
result = Math.max(r.getPos().y + r.getSize(accessor).height + 2, result);
return result;
}
private void computePositionAndSize(boolean hasIcon){
this.pos = new Point(ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX,0),
this.pos = new Point(ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSX,0),
ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_POSY,0));
this.hasIcon = hasIcon;
int paddingW = hasIcon ? 29 : 13;
int paddingH = hasIcon ? 24 : 0;
int paddingH = hasIcon ? 24 : 0;
offsetX = hasIcon ? 24 : 6;
w = maxStringW + paddingW;
h = Math.max(paddingH, this.getRenderableTotalHeight() + 8);
Dimension size = DisplayUtil.displaySize();
x = ((int)(size.width / OverlayConfig.scale)-w-1)*pos.x/10000;
y = ((int)(size.height / OverlayConfig.scale)-h-1)*pos.y/10000;
y = ((int)(size.height / OverlayConfig.scale)-h-1)*pos.y/10000;
ty = (h - this.getRenderableTotalHeight())/2 + 1;
}
public void draw(){
for (Renderable r : this.elements)
r.draw(accessor, x + offsetX, y + ty);
@@ -224,5 +220,5 @@ public class Tooltip {
public void draw2nd(){
for (Renderable r : this.elements2nd)
r.draw(accessor, x + offsetX, y + ty);
}
}
}
@@ -20,10 +20,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import static mcp.mobius.waila.api.SpecialChars.*;
public class WailaTickHandler{
@@ -31,7 +31,7 @@ public class WailaTickHandler{
//public static LangUtil lang = LangUtil.loadLangDir("waila");
private int ticks = 0;
public ItemStack identifiedHighlight = new ItemStack(Blocks.dirt);
//public ItemStack identifiedHighlight = new ItemStack(Blocks.dirt);
private List<String> currenttip = new TipList<String, String>();
private List<String> currenttipHead = new TipList<String, String>();
private List<String> currenttipBody = new TipList<String, String>();
@@ -1,19 +1,15 @@
package mcp.mobius.waila.overlay.tooltiprenderers;
import mcp.mobius.waila.api.IWailaCommonAccessor;
import mcp.mobius.waila.api.IWailaTooltipRenderer;
import mcp.mobius.waila.overlay.DisplayUtil;
import mcp.mobius.waila.overlay.IconUI;
import java.awt.*;
import static mcp.mobius.waila.api.SpecialChars.WailaIcon;
import static mcp.mobius.waila.api.SpecialChars.WailaStyle;
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.DisplayUtil;
import mcp.mobius.waila.overlay.OverlayRenderer;
import mcp.mobius.waila.overlay.IconUI;
public class TTRenderIcon implements IWailaTooltipRenderer {
final String type;
@@ -1,6 +1,6 @@
package mcp.mobius.waila.server;
import cpw.mods.fml.common.Loader;
import net.minecraftforge.fml.common.Loader;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.addons.agriculture.AgricultureModule;
import mcp.mobius.waila.addons.buildcraft.BCModule;
@@ -42,64 +42,64 @@ public class ProxyServer {
HUDHandlerFurnace.register();
/* BUILDCRAFT */
BCModule.register();
//BCModule.register();
/* INDUSTRIALCRAFT2 */
IC2Module.register();
//IC2Module.register();
/*Thaumcraft*/
ThaumcraftModule.register();
//ThaumcraftModule.register();
/*EnderStorage*/
EnderStorageModule.register();
//EnderStorageModule.register();
/*Gravestone*/
GravestoneModule.register();
//GravestoneModule.register();
/*Twilight forest*/
TwilightForestModule.register();
//TwilightForestModule.register();
/* Thermal Expansion */
ThermalExpansionModule.register();
//ThermalExpansionModule.register();
/* Thermal Dynamics */
ThermalDynamicsModule.register();
//ThermalDynamicsModule.register();
/* ETB */
ETBModule.register();
//ETBModule.register();
/* EnderIO */
//EnderIOModule.register();
/* ProjectRed API */
ProjectRedModule.register();
//ProjectRedModule.register();
/* ExtraUtilities */
ExtraUtilitiesModule.register();
//ExtraUtilitiesModule.register();
/* OpenBlocks */
OpenBlocksModule.register();
//OpenBlocksModule.register();
/* Railcraft */
RailcraftModule.register();
//RailcraftModule.register();
/* Steve's Carts */
StevesCartsModule.register();
//StevesCartsModule.register();
/* Secret Rooms */
//SecretRoomsModule.register();
/* Carpenter's Blocks */
CarpentersModule.register();
//CarpentersModule.register();
/* Pam's HarvestCraft */
HarvestcraftModule.register();
//HarvestcraftModule.register();
/* Magical crops */
MagicalCropsModule.register();
//MagicalCropsModule.register();
/* Statues */
StatuesModule.register();
//StatuesModule.register();
/* Agriculture */
AgricultureModule.register();
@@ -1,56 +1,61 @@
package mcp.mobius.waila.utils;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.registry.GameData;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.registry.GameData;
import java.util.Locale;
public class ModIdentification {
public static HashMap<String, String> modSource_Name = new HashMap<String, String>();
public static HashMap<String, String> modSource_ID = new HashMap<String, String>();
public static HashMap<Integer, String> itemMap = new HashMap<Integer, String>();
public static HashMap<String, String> keyhandlerStrings = new HashMap<String, String>();
public static void init(){
public static HashMap<String, String> modSource_Name = new HashMap<String, String>();
public static HashMap<String, String> modSource_ID = new HashMap<String, String>();
public static HashMap<Integer, String> itemMap = new HashMap<Integer, String>();
public static HashMap<String, String> keyhandlerStrings = new HashMap<String, String>();
public static void init() {
//TODO : Redo this for the new frameworkn (1.7.2)
/*
NBTTagList itemDataList = new NBTTagList();
GameData.writeItemData(itemDataList);
for(int i = 0; i < itemDataList.tagCount(); i++)
{
ItemData itemData = new ItemData((NBTTagCompound) itemDataList.tagAt(i));
itemMap.put(itemData.getItemId(), itemData.getModId());
}
}
*/
for (ModContainer mod : Loader.instance().getModList()){
modSource_Name.put(mod.getSource().getName(), mod.getName());
modSource_ID.put(mod.getSource().getName(), mod.getModId());
for (ModContainer mod : Loader.instance().getModList()) {
modSource_Name.put(mod.getSource().getName(), mod.getName());
modSource_ID.put(mod.getSource().getName(), mod.getModId());
}
//TODO : Update this to match new version (1.7.2)
modSource_Name.put("1.6.2.jar", "Minecraft");
modSource_Name.put("1.6.3.jar", "Minecraft");
modSource_Name.put("1.6.3.jar", "Minecraft");
modSource_Name.put("1.6.4.jar", "Minecraft");
modSource_Name.put("1.7.2.jar", "Minecraft");
modSource_Name.put("Forge", "Minecraft");
modSource_Name.put("1.8.0.jar", "Minecraft");
modSource_Name.put("Forge", "Minecraft");
modSource_ID.put("1.6.2.jar", "Minecraft");
modSource_ID.put("1.6.3.jar", "Minecraft");
modSource_ID.put("1.6.3.jar", "Minecraft");
modSource_ID.put("1.6.4.jar", "Minecraft");
modSource_ID.put("1.7.2.jar", "Minecraft");
modSource_ID.put("Forge", "Minecraft");
modSource_ID.put("1.8.0.jar", "Minecraft");
modSource_ID.put("Forge", "Minecraft");
// for (String s : this.modSourceList.keySet())
// if (this.modSourceList.get(s) == "Minecraft Coder Pack")
// this.modSourceList.put(s, "Minecraft");
// Code to retrieve all the registered keybindings along with the mod adding them.
/*
Field keyHandlers_Field = AccessHelper.getDeclaredField("cpw.mods.fml.client.registry.KeyBindingRegistry", "keyHandlers");
@@ -65,31 +70,30 @@ public class ModIdentification {
e.printStackTrace();
}
*/
}
public static String nameFromObject(Object obj){
String objPath = obj.getClass().getProtectionDomain().getCodeSource().getLocation().toString();
try {
objPath = URLDecoder.decode(objPath, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String modName = "<Unknown>";
for (String s: modSource_Name.keySet())
if (objPath.contains(s)){
modName = modSource_Name.get(s);
break;
}
if (modName.equals("Minecraft Coder Pack"))
modName = "Minecraft";
return modName;
}
}
public static String nameFromObject(Object obj) {
String objPath = obj.getClass().getProtectionDomain().getCodeSource().getLocation().toString();
try {
objPath = URLDecoder.decode(objPath, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String modName = "<Unknown>";
for (String s : modSource_Name.keySet())
if (objPath.contains(s)) {
modName = modSource_Name.get(s);
break;
}
if (modName.equals("Minecraft Coder Pack"))
modName = "Minecraft";
return modName;
}
/*
public static String idFromObject(Object obj){
String objPath = obj.getClass().getProtectionDomain().getCodeSource().getLocation().toString();
@@ -112,30 +116,24 @@ public class ModIdentification {
modName = "Minecraft";
return modName;
}
*/
public static String nameFromStack(ItemStack stack){
try{
//String modID = itemMap.get(itemstack.itemID);
//ModContainer mod = ModIdentification.findModContainer(modID);
ModContainer mod = GameData.findModOwner(GameData.itemRegistry.getNameForObject(stack.getItem()));
String modname = mod == null ? "Minecraft" : mod.getName();
return modname;
} catch (NullPointerException e){
//System.out.printf("NPE : %s\n",itemstack.toString());
return "";
}
}
*/
/*
public static ModContainer findModContainer(String modID)
{
for(ModContainer mc : Loader.instance().getModList())
if(modID.equals(mc.getModId()))
public static String nameFromStack(ItemStack stack) {
try {
ResourceLocation resource = (ResourceLocation) GameData.getItemRegistry().getNameForObject(stack.getItem());
ModContainer mod = ModIdentification.findModContainer(resource.getResourceDomain());
String modName = mod == null ? "Minecraft" : mod.getName();
return modName;
} catch (NullPointerException e) {
return "";
}
}
public static ModContainer findModContainer(String modID) {
for (ModContainer mc : Loader.instance().getModList())
if (modID.toLowerCase(Locale.US).equals(mc.getModId().toLowerCase(Locale.US)))
return mc;
return null;
}
*/
}
}
@@ -66,7 +66,7 @@ public class NBTUtil {
return outTag;
}
public static void writeNBTTagCompound(NBTTagCompound par0NBTTagCompound, DataOutputStream par1DataOutputStream) throws IOException
/* public static void writeNBTTagCompound(NBTTagCompound par0NBTTagCompound, DataOutputStream par1DataOutputStream) throws IOException
{
if (par0NBTTagCompound == null)
{
@@ -74,8 +74,8 @@ public class NBTUtil {
}
else
{
byte[] abyte = CompressedStreamTools.compress(par0NBTTagCompound);
byte[] abyte = CompressedStreamTools.(par0NBTTagCompound);
if (abyte.length > 32000)
par1DataOutputStream.writeShort(-1);
else{
@@ -83,9 +83,9 @@ public class NBTUtil {
par1DataOutputStream.write(abyte);
}
}
}
} */
public static NBTTagCompound readNBTTagCompound(DataInputStream par0DataInputStream) throws IOException
/* public static NBTTagCompound readNBTTagCompound(DataInputStream par0DataInputStream) throws IOException
{
short short1 = par0DataInputStream.readShort();
@@ -99,7 +99,7 @@ public class NBTUtil {
par0DataInputStream.readFully(abyte);
return CompressedStreamTools.func_152457_a(abyte, NBTSizeTracker.field_152451_a);
}
}
} */
public static int getNBTInteger(NBTTagCompound tag, String keyname){
NBTBase subtag = tag.getTag(keyname);
@@ -2,7 +2,7 @@ package mcp.mobius.wailacore.asm;
import java.io.IOException;
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
import net.minecraftforge.fml.common.asm.transformers.AccessTransformer;
public class CoreAccessTransformer extends AccessTransformer {
@@ -4,9 +4,9 @@ import java.util.Arrays;
import com.google.common.eventbus.EventBus;
import cpw.mods.fml.common.DummyModContainer;
import cpw.mods.fml.common.LoadController;
import cpw.mods.fml.common.ModMetadata;
import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.LoadController;
import net.minecraftforge.fml.common.ModMetadata;
public class CoreContainer extends DummyModContainer {
@@ -6,7 +6,7 @@ import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
@IFMLLoadingPlugin.TransformerExclusions("mcp.mobius.wailacore.asm")
public class CoreDescription implements IFMLLoadingPlugin {