mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-19 19:59:47 +00:00
Custom identifiers are now considered properly in the Tick handler
This commit is contained in:
1 parent
e62f26a0ee
commit
2777e0ea80
4 files changed
+37
-72
No files matched your search
@@ -26,9 +26,7 @@ public class HUDHandlerExternal{
|
||||
private Class prevBlock = null;
|
||||
private Class prevTile = null;
|
||||
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
|
||||
DataAccessor accessor = DataAccessor.instance;
|
||||
accessor.set(world, player, mop);
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop, DataAccessor accessor) {
|
||||
Block block = accessor.getBlock();
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
@@ -56,9 +54,7 @@ public class HUDHandlerExternal{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
|
||||
DataAccessor accessor = DataAccessor.instance;
|
||||
accessor.set(world, player, mop);
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, DataAccessor accessor, List<String> currenttip, Layout layout) {
|
||||
Block block = accessor.getBlock();
|
||||
int blockID = accessor.getBlockID();
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package mcp.mobius.waila.handlers.hud;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.overlay.WailaTickHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import codechicken.nei.api.IHighlightHandler;
|
||||
import codechicken.nei.api.ItemInfo.Layout;
|
||||
|
||||
public class HUDHandlerNEI implements IHighlightHandler {
|
||||
|
||||
@Override
|
||||
public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
|
||||
return WailaTickHandler.instance().identifiedHighlight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleTextData(ItemStack itemStack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, Layout layout) {
|
||||
if (layout == Layout.HEADER){
|
||||
currenttip.addAll(WailaTickHandler.instance().currenttipHEAD);
|
||||
}
|
||||
if (layout == Layout.BODY){
|
||||
currenttip.addAll(WailaTickHandler.instance().currenttipBODY);
|
||||
}
|
||||
if (layout == Layout.FOOTER){
|
||||
currenttip.addAll(WailaTickHandler.instance().currenttipTAIL);
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import codechicken.nei.api.IHighlightHandler;
|
||||
import codechicken.nei.api.ItemInfo;
|
||||
import mcp.mobius.waila.Constants;
|
||||
import mcp.mobius.waila.addons.ConfigHandler;
|
||||
import mcp.mobius.waila.addons.ExternalModulesHandler;
|
||||
import mcp.mobius.waila.handlers.DataAccessor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -47,11 +47,6 @@ public class RayTracing {
|
||||
this.target = this.rayTrace(viewpoint, 4.0, 0);
|
||||
|
||||
if (this.target == null) return;
|
||||
|
||||
if (this.target.typeOfHit == EnumMovingObjectType.TILE)
|
||||
this.targetStack = this.getIdentifierStack();
|
||||
else
|
||||
this.targetStack = null;
|
||||
}
|
||||
|
||||
public MovingObjectPosition getTarget(){
|
||||
@@ -59,6 +54,11 @@ public class RayTracing {
|
||||
}
|
||||
|
||||
public ItemStack getTargetStack(){
|
||||
if (this.target.typeOfHit == EnumMovingObjectType.TILE)
|
||||
this.targetStack = this.getIdentifierStack();
|
||||
else
|
||||
this.targetStack = null;
|
||||
|
||||
return this.targetStack;
|
||||
}
|
||||
|
||||
@@ -105,9 +105,12 @@ public class RayTracing {
|
||||
int x = this.target.blockX;
|
||||
int y = this.target.blockY;
|
||||
int z = this.target.blockZ;
|
||||
Block mouseoverBlock = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
Block mouseoverBlock = Block.blocksList[blockID];
|
||||
if (mouseoverBlock == null) return items;
|
||||
|
||||
// TODO This block need to be redone to handle Waila API
|
||||
/*
|
||||
ArrayList<IHighlightHandler> handlers = new ArrayList<IHighlightHandler>();
|
||||
if(ItemInfo.highlightIdentifiers.get(0) != null)
|
||||
handlers.addAll(ItemInfo.highlightIdentifiers.get(0));
|
||||
@@ -120,6 +123,10 @@ public class RayTracing {
|
||||
if(item != null)
|
||||
items.add(item);
|
||||
}
|
||||
*/
|
||||
|
||||
if (ExternalModulesHandler.instance().hasStackProviders(blockID))
|
||||
items.add(ExternalModulesHandler.instance().getStackProviders(blockID).get(0).getWailaStack(DataAccessor.instance, ConfigHandler.instance()));
|
||||
|
||||
if(items.size() > 0)
|
||||
return items;
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import mcp.mobius.waila.handlers.DataAccessor;
|
||||
import mcp.mobius.waila.handlers.hud.HUDHandlerExternal;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -21,12 +22,9 @@ public class WailaTickHandler implements ITickHandler {
|
||||
|
||||
private int ticks = 0;
|
||||
public ItemStack identifiedHighlight = new ItemStack(Block.dirt);
|
||||
public List<String> currenttipHEAD = new ArrayList<String>();
|
||||
public List<String> currenttipBODY = new ArrayList<String>();
|
||||
public List<String> currenttipTAIL = new ArrayList<String>();
|
||||
public List<String> currenttip = new ArrayList<String>();
|
||||
public HUDHandlerExternal handler = new HUDHandlerExternal();
|
||||
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
private static WailaTickHandler _instance;
|
||||
private WailaTickHandler(){}
|
||||
@@ -48,27 +46,25 @@ public class WailaTickHandler implements ITickHandler {
|
||||
}
|
||||
|
||||
if(type.contains(TickType.CLIENT)){
|
||||
RayTracing.instance().fire();
|
||||
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
ItemStack targetStack = RayTracing.instance().getTargetStack();
|
||||
MovingObjectPosition target = RayTracing.instance().getTarget();
|
||||
|
||||
if (world != null && player != null && target != null && targetStack != null){
|
||||
//this.currenttipHEAD.clear();
|
||||
//this.currenttipBODY.clear();
|
||||
//this.currenttipTAIL.clear();
|
||||
|
||||
this.identifiedHighlight = handler.identifyHighlight(world, player, target);
|
||||
this.currenttipHEAD = handler.handleTextData(targetStack, world, player, target, new ArrayList<String>(), Layout.HEADER);
|
||||
this.currenttipBODY = handler.handleTextData(targetStack, world, player, target, new ArrayList<String>(), Layout.BODY);
|
||||
this.currenttipTAIL = handler.handleTextData(targetStack, world, player, target, new ArrayList<String>(), Layout.FOOTER);
|
||||
World world = mc.theWorld;
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
if (world != null && player != null){
|
||||
RayTracing.instance().fire();
|
||||
MovingObjectPosition target = RayTracing.instance().getTarget();
|
||||
|
||||
this.currenttip.clear();
|
||||
this.currenttip.addAll(this.currenttipHEAD);
|
||||
this.currenttip.addAll(this.currenttipBODY);
|
||||
this.currenttip.addAll(this.currenttipTAIL);
|
||||
if (target != null){
|
||||
DataAccessor accessor = DataAccessor.instance;
|
||||
accessor.set(world, player, target);
|
||||
ItemStack targetStack = RayTracing.instance().getTargetStack();
|
||||
if (targetStack != null){
|
||||
this.currenttip.clear();
|
||||
|
||||
//this.identifiedHighlight = handler.identifyHighlight(world, player, target);
|
||||
this.currenttip = handler.handleTextData(targetStack, world, player, target, accessor, currenttip, Layout.HEADER);
|
||||
this.currenttip = handler.handleTextData(targetStack, world, player, target, accessor, currenttip, Layout.BODY);
|
||||
this.currenttip = handler.handleTextData(targetStack, world, player, target, accessor, currenttip, Layout.FOOTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user