fix: two EMC tooltips with ProjectE
This commit is contained in:
parent
bc94be6316
commit
e5a39ff8fd
2 changed files with 56 additions and 61 deletions
|
@ -13,6 +13,8 @@ import com.pahimar.ee3.inventory.ContainerTransmutationTablet;
|
||||||
import com.pahimar.ee3.reference.Messages;
|
import com.pahimar.ee3.reference.Messages;
|
||||||
import com.pahimar.ee3.util.IOwnable;
|
import com.pahimar.ee3.util.IOwnable;
|
||||||
import com.pahimar.ee3.util.ItemStackUtils;
|
import com.pahimar.ee3.util.ItemStackUtils;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -25,63 +27,60 @@ import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class ItemTooltipEventHandler {
|
public class ItemTooltipEventHandler {
|
||||||
|
|
||||||
|
boolean projecte;
|
||||||
|
|
||||||
|
public ItemTooltipEventHandler(boolean projecte) {
|
||||||
|
this.projecte = projecte;
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void handleItemTooltipEvent(ItemTooltipEvent event) {
|
public void handleItemTooltipEvent(ItemTooltipEvent event) {
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)
|
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)
|
||||||
|| Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)
|
|| Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)
|
||||||
|| (event.entityPlayer != null
|
|| (event.entityPlayer != null
|
||||||
&& (event.entityPlayer.openContainer instanceof ContainerAlchenomicon
|
&& (event.entityPlayer.openContainer instanceof ContainerAlchenomicon
|
||||||
|| event.entityPlayer.openContainer
|
|| event.entityPlayer.openContainer instanceof ContainerTransmutationTablet))) {
|
||||||
instanceof ContainerTransmutationTablet))) {
|
|
||||||
WrappedStack wrappedItemStack = WrappedStack.wrap(event.itemStack);
|
WrappedStack wrappedItemStack = WrappedStack.wrap(event.itemStack);
|
||||||
EnergyValue energyValue
|
if (!projecte) {
|
||||||
= EnergyValueRegistryProxy.getEnergyValue(wrappedItemStack);
|
EnergyValue energyValue = EnergyValueRegistryProxy.getEnergyValue(wrappedItemStack);
|
||||||
EnergyValue stackEnergyValue
|
EnergyValue stackEnergyValue = EnergyValueRegistryProxy.getEnergyValueForStack(wrappedItemStack);
|
||||||
= EnergyValueRegistryProxy.getEnergyValueForStack(wrappedItemStack);
|
|
||||||
|
|
||||||
if (energyValue != null) {
|
if (energyValue != null) {
|
||||||
if (wrappedItemStack.getStackSize() > 1) {
|
if (wrappedItemStack.getStackSize() > 1) {
|
||||||
event.toolTip.add(
|
event.toolTip.add(
|
||||||
String.format("Exchange Energy (Item): %s", energyValue)
|
String.format("Exchange Energy (Item): %s", energyValue)); // TODO Localize
|
||||||
); // TODO Localize
|
|
||||||
event.toolTip.add(String.format(
|
event.toolTip.add(String.format(
|
||||||
"Exchange Energy (Stack of %s): %s",
|
"Exchange Energy (Stack of %s): %s",
|
||||||
event.itemStack.stackSize,
|
event.itemStack.stackSize,
|
||||||
stackEnergyValue
|
stackEnergyValue)); // TODO Localize
|
||||||
)); // TODO Localize
|
|
||||||
} else {
|
} else {
|
||||||
event.toolTip.add(
|
event.toolTip.add(
|
||||||
String.format("Exchange Energy: %s", stackEnergyValue)
|
String.format("Exchange Energy: %s", stackEnergyValue)); // TODO Localize
|
||||||
); // TODO Localize
|
|
||||||
|
|
||||||
if (FluidContainerRegistry.getFluidForFilledItem(event.itemStack)
|
if (FluidContainerRegistry.getFluidForFilledItem(event.itemStack) != null) {
|
||||||
!= null) {
|
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(event.itemStack);
|
||||||
FluidStack fluidStack
|
EnergyValue fluidStackEnergyValue = EnergyValueRegistryProxy
|
||||||
= FluidContainerRegistry.getFluidForFilledItem(event.itemStack
|
.getEnergyValueForStack(fluidStack);
|
||||||
);
|
|
||||||
EnergyValue fluidStackEnergyValue
|
|
||||||
= EnergyValueRegistryProxy.getEnergyValueForStack(fluidStack);
|
|
||||||
|
|
||||||
if (fluidStackEnergyValue != null) {
|
if (fluidStackEnergyValue != null) {
|
||||||
event.toolTip.add(String.format(
|
event.toolTip.add(String.format(
|
||||||
" - Exchange Energy (%smB of %s): %s",
|
" - Exchange Energy (%smB of %s): %s",
|
||||||
fluidStack.amount,
|
fluidStack.amount,
|
||||||
fluidStack.getLocalizedName(),
|
fluidStack.getLocalizedName(),
|
||||||
fluidStackEnergyValue
|
fluidStackEnergyValue)); // TODO Localize
|
||||||
)); // TODO Localize
|
|
||||||
event.toolTip.add(String.format(
|
event.toolTip.add(String.format(
|
||||||
" - Exchange Energy (Container): %s",
|
" - Exchange Energy (Container): %s",
|
||||||
new EnergyValue(
|
new EnergyValue(
|
||||||
energyValue.getValue()
|
energyValue.getValue()
|
||||||
- fluidStackEnergyValue.getValue()
|
- fluidStackEnergyValue.getValue()))); // TODO Localize
|
||||||
)
|
|
||||||
)); // TODO Localize
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
event.toolTip.add("No Exchange Energy value"); // TODO Localize
|
event.toolTip.add("No Exchange Energy value"); // TODO Localize
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!BlacklistRegistryProxy.isLearnable(wrappedItemStack)) {
|
if (!BlacklistRegistryProxy.isLearnable(wrappedItemStack)) {
|
||||||
event.toolTip.add("Not learnable"); // TODO Localize
|
event.toolTip.add("Not learnable"); // TODO Localize
|
||||||
|
@ -95,13 +94,10 @@ public class ItemTooltipEventHandler {
|
||||||
if (((Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)
|
if (((Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)
|
||||||
|| Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
|
|| Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
|
||||||
&& (event.entityPlayer != null
|
&& (event.entityPlayer != null
|
||||||
&& event.entityPlayer.openContainer instanceof ContainerResearchStation)
|
&& event.entityPlayer.openContainer instanceof ContainerResearchStation))) {
|
||||||
)) {
|
|
||||||
if (PlayerKnowledgeRegistryProxy.doesPlayerKnow(
|
if (PlayerKnowledgeRegistryProxy.doesPlayerKnow(
|
||||||
event.entityPlayer, event.itemStack
|
event.entityPlayer, event.itemStack)) {
|
||||||
)) {
|
event.toolTip.add("You know how to transmute this"); // TODO Localize with better phrasing
|
||||||
event.toolTip.add("You know how to transmute this"
|
|
||||||
); // TODO Localize with better phrasing
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,13 +107,11 @@ public class ItemTooltipEventHandler {
|
||||||
if (playerUUID != null && UsernameCache.containsUUID(playerUUID)) {
|
if (playerUUID != null && UsernameCache.containsUUID(playerUUID)) {
|
||||||
event.toolTip.add(StatCollector.translateToLocalFormatted(
|
event.toolTip.add(StatCollector.translateToLocalFormatted(
|
||||||
Messages.Tooltips.ITEM_BELONGS_TO,
|
Messages.Tooltips.ITEM_BELONGS_TO,
|
||||||
UsernameCache.getLastKnownUsername(playerUUID)
|
UsernameCache.getLastKnownUsername(playerUUID)));
|
||||||
));
|
|
||||||
} else if (ItemStackUtils.getOwnerName(event.itemStack) != null) {
|
} else if (ItemStackUtils.getOwnerName(event.itemStack) != null) {
|
||||||
event.toolTip.add(StatCollector.translateToLocalFormatted(
|
event.toolTip.add(StatCollector.translateToLocalFormatted(
|
||||||
Messages.Tooltips.ITEM_BELONGS_TO,
|
Messages.Tooltips.ITEM_BELONGS_TO,
|
||||||
ItemStackUtils.getOwnerName(event.itemStack)
|
ItemStackUtils.getOwnerName(event.itemStack)));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import com.pahimar.ee3.util.TransmutationHelper;
|
||||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -36,7 +37,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
super.registerEventHandlers();
|
super.registerEventHandlers();
|
||||||
FMLCommonHandler.instance().bus().register(new KeyInputEventHandler());
|
FMLCommonHandler.instance().bus().register(new KeyInputEventHandler());
|
||||||
FMLCommonHandler.instance().bus().register(new HUDTickHandler());
|
FMLCommonHandler.instance().bus().register(new HUDTickHandler());
|
||||||
MinecraftForge.EVENT_BUS.register(new ItemTooltipEventHandler());
|
MinecraftForge.EVENT_BUS.register(new ItemTooltipEventHandler(Loader.isModLoaded("ProjectE")));
|
||||||
MinecraftForge.EVENT_BUS.register(new DrawBlockHighlightEventHandler());
|
MinecraftForge.EVENT_BUS.register(new DrawBlockHighlightEventHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue