mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 04:32:18 +00:00
Add basic WAILA plugin. Needs more content but system is in place.
This commit is contained in:
1 parent
76a71821c2
commit
955cb07ba8
9 files changed
+206
-18
No files matched your search
@@ -28,6 +28,7 @@ import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.block.BlockDarkSteelPressurePlate;
|
||||
import crazypants.enderio.block.BlockReinforcedObsidian;
|
||||
import crazypants.enderio.compat.waila.WailaCompat;
|
||||
import crazypants.enderio.conduit.BlockConduitBundle;
|
||||
import crazypants.enderio.conduit.ConduitRecipes;
|
||||
import crazypants.enderio.conduit.facade.BlockConduitFacade;
|
||||
@@ -395,6 +396,7 @@ public class EnderIO {
|
||||
EntityRegistry.registerGlobalEntityID(SoundEntity.class, "soundEntity", entityID);
|
||||
EntityRegistry.registerModEntity(SoundEntity.class, "soundEntity", entityID, this, 0, 0, false);
|
||||
|
||||
FMLInterModComms.sendMessage("Waila", "register", WailaCompat.class.getName() + ".load");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
package crazypants.enderio.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.compat.waila.IWailaInfoProvider;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.machine.painter.TileEntityPaintedBlock;
|
||||
import crazypants.enderio.material.BlockFusedQuartz;
|
||||
|
||||
public class BlockReinforcedObsidian extends BlockEio implements IResourceTooltipProvider {
|
||||
public class BlockReinforcedObsidian extends BlockEio implements IResourceTooltipProvider, IWailaInfoProvider {
|
||||
|
||||
public static BlockReinforcedObsidian create() {
|
||||
BlockReinforcedObsidian result = new BlockReinforcedObsidian();
|
||||
@@ -57,4 +56,12 @@ public class BlockReinforcedObsidian extends BlockEio implements IResourceToolti
|
||||
public String getUnlocalizedNameForTooltip(ItemStack itemStack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWailaInfo(List<String> tooltip, World world, int x, int y, int z) {}
|
||||
|
||||
@Override
|
||||
public int getDefaultDisplayMask(World world, int x, int y, int z) {
|
||||
return IWailaInfoProvider.BIT_BASIC;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package crazypants.enderio.compat.waila;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IWailaInfoProvider {
|
||||
|
||||
public static final int BIT_BASIC = 0x1;
|
||||
public static final int BIT_COMMON = 0x2;
|
||||
public static final int BIT_DETAILED = 0x4;
|
||||
public static final int ALL_BITS = BIT_BASIC | BIT_COMMON | BIT_DETAILED;
|
||||
|
||||
/**
|
||||
* Adds the block's info to the WAILA information
|
||||
* @param tooltip - current list of strings in the WAILA body
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*/
|
||||
public void getWailaInfo(List<String> tooltip, World world, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* A bitmask for the default tooltips to show, use static ints in {@link IWailaInfoProvider}
|
||||
* <p>
|
||||
* Unneded if your block doesn't implement {@link IAdvancedTooltipProvider}
|
||||
*
|
||||
* @return Bits enabled corresponding to the tooltip sections you want displayed.
|
||||
* <p>
|
||||
* Should be returned in the format bit | otherbit (ex. <code> BIT_BASIC | BIT_COMMON</code>). Return <code>ALL_BITS</code> to show all, or 0 to show none.
|
||||
*/
|
||||
public int getDefaultDisplayMask(World world, int x, int y, int z);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package crazypants.enderio.compat.waila;
|
||||
|
||||
import static crazypants.enderio.compat.waila.IWailaInfoProvider.*;
|
||||
|
||||
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.api.IWailaRegistrar;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.gui.TooltipAddera;
|
||||
|
||||
public class WailaCompat implements IWailaDataProvider {
|
||||
|
||||
public static final WailaCompat INSTANCE = new WailaCompat();
|
||||
|
||||
public static void load(IWailaRegistrar registrar) {
|
||||
registrar.registerHeadProvider(INSTANCE, Block.class);
|
||||
registrar.registerBodyProvider(INSTANCE, Block.class);
|
||||
registrar.registerTailProvider(INSTANCE, Block.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
|
||||
Block block = accessor.getBlock();
|
||||
Item item = Item.getItemFromBlock(block);
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
if(block instanceof IWailaInfoProvider) {
|
||||
IWailaInfoProvider info = (IWailaInfoProvider) block;
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
MovingObjectPosition pos = accessor.getPosition();
|
||||
|
||||
if(block instanceof IAdvancedTooltipProvider) {
|
||||
int mask = info.getDefaultDisplayMask(world, pos.blockX, pos.blockY, pos.blockZ);
|
||||
boolean basic = (mask & BIT_BASIC) == BIT_BASIC;
|
||||
boolean common = (mask & BIT_COMMON) == BIT_COMMON;
|
||||
boolean detailed = (mask & BIT_DETAILED) == BIT_DETAILED;
|
||||
|
||||
IAdvancedTooltipProvider adv = (IAdvancedTooltipProvider) block;
|
||||
|
||||
if(common) {
|
||||
adv.addCommonEntries(itemStack, player, currenttip, false);
|
||||
}
|
||||
|
||||
if(TooltipAddera.showAdvancedTooltips() && detailed) {
|
||||
adv.addDetailedEntries(itemStack, player, currenttip, false);
|
||||
} else if(detailed) { // show "<Hold Shift>"
|
||||
TooltipAddera.addShowDetailsTooltip(currenttip);
|
||||
}
|
||||
|
||||
if(!TooltipAddera.showAdvancedTooltips() && basic) {
|
||||
adv.addBasicEntries(itemStack, player, currenttip, false);
|
||||
}
|
||||
} else if(block instanceof IResourceTooltipProvider) {
|
||||
TooltipAddera.addInformation((IResourceTooltipProvider) block, itemStack, Minecraft.getMinecraft().thePlayer, currenttip);
|
||||
}
|
||||
|
||||
info.getWailaInfo(currenttip, world, pos.blockX, pos.blockY, pos.blockZ);
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
if(block instanceof IAdvancedTooltipProvider) {
|
||||
TooltipAddera.addInformation((IAdvancedTooltipProvider) block, itemStack, Minecraft.getMinecraft().thePlayer, currenttip, false);
|
||||
} else if(item instanceof IAdvancedTooltipProvider) {
|
||||
TooltipAddera.addInformation((IAdvancedTooltipProvider) item, itemStack, Minecraft.getMinecraft().thePlayer, currenttip, false);
|
||||
} else if(block instanceof IResourceTooltipProvider) {
|
||||
TooltipAddera.addInformation((IResourceTooltipProvider) block, itemStack, Minecraft.getMinecraft().thePlayer, currenttip);
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
||||
return currenttip;
|
||||
}
|
||||
}
|
||||
@@ -125,16 +125,19 @@ public class TooltipAddera {
|
||||
}
|
||||
|
||||
public static void addInformation(IResourceTooltipProvider item, ItemTooltipEvent evt) {
|
||||
String name = item.getUnlocalizedNameForTooltip(evt.itemStack);
|
||||
addInformation(item, evt.itemStack, evt.entityPlayer, evt.toolTip);
|
||||
}
|
||||
|
||||
public static void addInformation(IResourceTooltipProvider tt, ItemStack itemstack, EntityPlayer entityplayer, List list) {
|
||||
String name = tt.getUnlocalizedNameForTooltip(itemstack);
|
||||
if(showAdvancedTooltips()) {
|
||||
addCommonTooltipFromResources(evt.toolTip, name);
|
||||
addDetailedTooltipFromResources(evt.toolTip, name);
|
||||
addCommonTooltipFromResources(list, name);
|
||||
addDetailedTooltipFromResources(list, name);
|
||||
} else {
|
||||
addBasicTooltipFromResources(evt.toolTip, name);
|
||||
addCommonTooltipFromResources(evt.toolTip, name);
|
||||
addShowDetailsTooltip(evt.toolTip);
|
||||
addBasicTooltipFromResources(list, name);
|
||||
addCommonTooltipFromResources(list, name);
|
||||
addShowDetailsTooltip(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void addInformation(IAdvancedTooltipProvider tt, ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -28,11 +29,13 @@ import crazypants.enderio.ClientProxy;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.compat.waila.IWailaInfoProvider;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
|
||||
public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> extends BlockContainer implements IGuiHandler, IResourceTooltipProvider {
|
||||
public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> extends BlockContainer implements IGuiHandler, IResourceTooltipProvider, IWailaInfoProvider {
|
||||
|
||||
public static int renderId;
|
||||
|
||||
@@ -335,5 +338,12 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getWailaInfo(List<String> tooltip, World world, int x, int y, int z) {}
|
||||
|
||||
@Override
|
||||
public int getDefaultDisplayMask(World world, int x, int y, int z) {
|
||||
return IWailaInfoProvider.ALL_BITS;
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,17 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -25,6 +29,8 @@ import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.MachineRecipeInput;
|
||||
import crazypants.enderio.machine.MachineRecipeRegistry;
|
||||
import crazypants.util.Lang;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class BlockPaintedGlowstone extends Block implements ITileEntityProvider {
|
||||
|
||||
@@ -233,6 +239,7 @@ public class BlockPaintedGlowstone extends Block implements ITileEntityProvider
|
||||
|
||||
public PainterTemplate(Block paintedGlowstone) {
|
||||
super(Blocks.glowstone, paintedGlowstone);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,10 +248,25 @@ public class BlockPaintedGlowstone extends Block implements ITileEntityProvider
|
||||
if(paintSource == null) {
|
||||
return new ResultStack[0];
|
||||
}
|
||||
|
||||
if (paintSource.getItem() == Item.getItemFromBlock(Blocks.glowstone)) {
|
||||
ItemStack stack = new ItemStack(Blocks.glowstone);
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
String tagName = "wasPainted";
|
||||
stack.stackTagCompound.setBoolean(tagName, true);
|
||||
return new ResultStack[] { new ResultStack(stack) };
|
||||
}
|
||||
|
||||
return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) };
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTooltip(ItemTooltipEvent event) {
|
||||
if (event.itemStack != null && Block.getBlockFromItem(event.itemStack.getItem()) == Blocks.glowstone && event.itemStack.stackTagCompound != null) {
|
||||
if (event.itemStack.stackTagCompound.getBoolean("wasPainted")) {
|
||||
event.toolTip.add(Lang.localize("painter.tooltip.wasPainted"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import crazypants.enderio.BlockEio;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.compat.waila.IWailaInfoProvider;
|
||||
import crazypants.enderio.conduit.ConduitUtil;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.gui.TooltipAddera;
|
||||
@@ -37,7 +38,7 @@ import crazypants.util.BlockCoord;
|
||||
import crazypants.util.Util;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvancedTooltipProvider {
|
||||
public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvancedTooltipProvider, IWailaInfoProvider {
|
||||
|
||||
public static int renderId = -1;
|
||||
|
||||
@@ -364,4 +365,12 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
|
||||
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWailaInfo(List<String> tooltip, World world, int x, int y, int z) {}
|
||||
|
||||
@Override
|
||||
public int getDefaultDisplayMask(World world, int x, int y, int z) {
|
||||
return IWailaInfoProvider.BIT_DETAILED;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user