mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-25 22:44:24 +00:00
Thaumcraft integration (aspect labels!)
This commit is contained in:
1 parent
7b1a82ee89
commit
cdd6eb5517
19 files changed
+374
-16
No files matched your search
@@ -116,4 +116,5 @@ storageDrawers.config.integration=Integration
|
||||
storageDrawers.config.integration.tooltip=Configure integration with other mods.
|
||||
|
||||
storageDrawers.config.integration.enableAE2=Enable Applied Energistics 2 Integration
|
||||
storageDrawers.config.integration.enableWaila=Enable WAILA Integration
|
||||
storageDrawers.config.integration.enableWaila=Enable WAILA Integration
|
||||
storageDrawers.config.integration.enableThaumcraft=Enable Thaumcraft Integration
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.jaquadro.minecraft.storagedrawers;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.config.CompTierRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.OreDictRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.RecipeHandlerRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.config.*;
|
||||
import com.jaquadro.minecraft.storagedrawers.core.*;
|
||||
import com.jaquadro.minecraft.storagedrawers.integration.IntegrationRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage;
|
||||
@@ -42,7 +39,10 @@ public class StorageDrawers
|
||||
public static ConfigManager config;
|
||||
public static CompTierRegistry compRegistry;
|
||||
public static OreDictRegistry oreDictRegistry;
|
||||
|
||||
public static RecipeHandlerRegistry recipeHandlerRegistry;
|
||||
public static RenderRegistry renderRegistry;
|
||||
public static WailaRegistry wailaRegistry;
|
||||
|
||||
@Mod.Instance(MOD_ID)
|
||||
public static StorageDrawers instance;
|
||||
@@ -69,6 +69,8 @@ public class StorageDrawers
|
||||
compRegistry = new CompTierRegistry();
|
||||
oreDictRegistry = new OreDictRegistry();
|
||||
recipeHandlerRegistry = new RecipeHandlerRegistry();
|
||||
renderRegistry = new RenderRegistry();
|
||||
wailaRegistry = new WailaRegistry();
|
||||
|
||||
blocks.init();
|
||||
items.init();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IRecipeHandlerRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IRenderRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaRegistry;
|
||||
|
||||
public interface IStorageDrawersApi
|
||||
{
|
||||
@@ -8,4 +10,8 @@ public interface IStorageDrawersApi
|
||||
* Recipe handlers are used to make custom recipes compatible with compacting drawers.
|
||||
*/
|
||||
IRecipeHandlerRegistry recipeHandlerRegistry ();
|
||||
|
||||
IRenderRegistry renderRegistry ();
|
||||
|
||||
IWailaRegistry wailaRegistry ();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.event;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
/**
|
||||
* This event is called when a drawer has been bound to a new item. This is
|
||||
* and opportunity for mods to cache extended data with the drawer.
|
||||
*
|
||||
* This event is also called when the drawer is changed to empty.
|
||||
*/
|
||||
public class DrawerPopulatedEvent extends Event
|
||||
{
|
||||
public final IDrawer drawer;
|
||||
|
||||
public DrawerPopulatedEvent (IDrawer drawer) {
|
||||
this.drawer = drawer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.registry;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.render.IRenderLabel;
|
||||
|
||||
public interface IRenderRegistry
|
||||
{
|
||||
void registerPreLabelRenderHandler (IRenderLabel renderHandler);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.registry;
|
||||
|
||||
public interface IWailaRegistry
|
||||
{
|
||||
void registerTooltipHandler (IWailaTooltipHandler handler);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.registry;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
|
||||
public interface IWailaTooltipHandler
|
||||
{
|
||||
String transformItemName (IDrawer drawer, String defaultName);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.api.render;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public interface IRenderLabel
|
||||
{
|
||||
void render (TileEntity tileEntity, IDrawerGroup drawerGroup, int slot, float brightness, float partialTickTime);
|
||||
}
|
||||
@@ -81,6 +81,21 @@ public interface IDrawer
|
||||
*/
|
||||
boolean isEmpty ();
|
||||
|
||||
/**
|
||||
* Gets auxiliary data that has been associated with this drawer.
|
||||
*
|
||||
* @param key The key used to identify the data.
|
||||
* @return An opaque object that was previously stored.
|
||||
*/
|
||||
Object getExtendedData (String key);
|
||||
|
||||
/**
|
||||
* Stores auxiliary data with this drawer, mainly for use in integration.
|
||||
* @param key The key to identify the data with.
|
||||
* @param data The data to store.
|
||||
*/
|
||||
void setExtendedData (String key, Object data);
|
||||
|
||||
void writeToNBT (NBTTagCompound tag);
|
||||
|
||||
void readFromNBT (NBTTagCompound tag);
|
||||
|
||||
+20
-9
@@ -1,6 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.client.renderer;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.render.IRenderLabel;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
|
||||
@@ -27,6 +28,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -101,6 +103,8 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
|
||||
if (renderEffect && itemStack.hasEffect(i))
|
||||
renderEffect(texManager, x, y);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -222,6 +226,8 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
|
||||
private static int[] glLightRender = { GL11.GL_LIGHT0, GL11.GL_LIGHT1, GL11.GL_COLOR_MATERIAL, GL12.GL_RESCALE_NORMAL };
|
||||
private List<int[]> savedGLLightRender = GLUtil.makeGLState(glLightRender);
|
||||
|
||||
private List<IRenderLabel> preLabelRenderHandlers = new ArrayList<IRenderLabel>();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt (TileEntity tile, double x, double y, double z, float partialTickTime) {
|
||||
TileEntityDrawers tileDrawers = (TileEntityDrawers) tile;
|
||||
@@ -256,16 +262,16 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
|
||||
mc.gameSettings.fancyGraphics = true;
|
||||
|
||||
if (StorageDrawers.config.isFancyItemRenderEnabled())
|
||||
renderFancyItemSet(tileDrawers, side, depth);
|
||||
renderFancyItemSet(tileDrawers, side, depth, partialTickTime);
|
||||
else
|
||||
renderFastItemSet(tileDrawers, side, depth);
|
||||
renderFastItemSet(tileDrawers, side, depth, partialTickTime);
|
||||
|
||||
mc.gameSettings.fancyGraphics = cache;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void renderFancyItemSet (TileEntityDrawers tile, ForgeDirection side, float depth) {
|
||||
private void renderFancyItemSet (TileEntityDrawers tile, ForgeDirection side, float depth, float partialTickTime) {
|
||||
boolean restoreGLState = false;
|
||||
int drawerCount = tile.getDrawerCount();
|
||||
|
||||
@@ -283,7 +289,7 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
|
||||
GLUtil.saveGLState(savedGLStateRender, glStateRender);
|
||||
}
|
||||
|
||||
renderFancyItem(itemStack, tile, i, side, depth);
|
||||
renderFancyItem(itemStack, tile, i, side, depth, partialTickTime);
|
||||
}
|
||||
|
||||
if (restoreGLState)
|
||||
@@ -293,7 +299,7 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
|
||||
private boolean[] renderAsBlock = new boolean[4];
|
||||
private ItemStack[] renderStacks = new ItemStack[4];
|
||||
|
||||
private void renderFastItemSet (TileEntityDrawers tile, ForgeDirection side, float depth) {
|
||||
private void renderFastItemSet (TileEntityDrawers tile, ForgeDirection side, float depth, float partialTickTime) {
|
||||
int drawerCount = tile.getDrawerCount();
|
||||
boolean restoreItemState = false;
|
||||
boolean restoreBlockState = false;
|
||||
@@ -322,7 +328,7 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
|
||||
|
||||
for (int i = 0; i < drawerCount; i++) {
|
||||
if (renderStacks[i] != null && !renderAsBlock[i])
|
||||
renderFastItem(renderStacks[i], tile, i, side, depth);
|
||||
renderFastItem(renderStacks[i], tile, i, side, depth, partialTickTime);
|
||||
}
|
||||
|
||||
if (restoreBlockState) {
|
||||
@@ -332,7 +338,7 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
|
||||
|
||||
for (int i = 0; i < drawerCount; i++) {
|
||||
if (renderStacks[i] != null && renderAsBlock[i])
|
||||
renderFastItem(renderStacks[i], tile, i, side, depth);
|
||||
renderFastItem(renderStacks[i], tile, i, side, depth, partialTickTime);
|
||||
}
|
||||
|
||||
if (restoreBlockState) {
|
||||
@@ -344,7 +350,7 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
|
||||
GLUtil.restoreGLState(savedGLStateItemRender);
|
||||
}
|
||||
|
||||
private void renderFancyItem (ItemStack itemStack, TileEntityDrawers tile, int slot, ForgeDirection side, float depth) {
|
||||
private void renderFancyItem (ItemStack itemStack, TileEntityDrawers tile, int slot, ForgeDirection side, float depth, float partialTickTime) {
|
||||
int drawerCount = tile.getDrawerCount();
|
||||
boolean isBlockType = isItemBlockType(itemStack);
|
||||
|
||||
@@ -417,7 +423,7 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void renderFastItem (ItemStack itemStack, TileEntityDrawers tile, int slot, ForgeDirection side, float depth) {
|
||||
private void renderFastItem (ItemStack itemStack, TileEntityDrawers tile, int slot, ForgeDirection side, float depth, float partialTickTime) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
int drawerCount = tile.getDrawerCount();
|
||||
float xunit = getXOffset(drawerCount, slot);
|
||||
@@ -431,6 +437,11 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
|
||||
alignRendering(side);
|
||||
moveRendering(size, getOffsetXForSide(side, xunit) * 16 - (8 * size), 12.25f - yunit, .999f - depth + block.trimDepth);
|
||||
|
||||
List<IRenderLabel> renderHandlers = StorageDrawers.renderRegistry.getRenderHandlers();
|
||||
for (int i = 0, n = renderHandlers.size(); i < n; i++) {
|
||||
renderHandlers.get(i).render(tile, tile, slot, brightness, partialTickTime);
|
||||
}
|
||||
|
||||
if (!ForgeHooksClient.renderInventoryItem(this.renderBlocks, mc.renderEngine, itemStack, true, 0, 0, 0))
|
||||
itemRenderer.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, itemStack, 0, 0, true);
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public class ConfigManager
|
||||
public boolean enableSidedOutput;
|
||||
public boolean enableWailaIntegration;
|
||||
public boolean enableAE2Integration;
|
||||
public boolean enableThaumcraftIntegration;
|
||||
public boolean invertShift;
|
||||
public boolean debugTrace;
|
||||
|
||||
@@ -130,6 +131,7 @@ public class ConfigManager
|
||||
|
||||
cache.enableAE2Integration = config.get(sectionIntegration.getQualifiedName(), "enableAE2", true).setLanguageKey(LANG_PREFIX + "integration.enableAE2").setRequiresMcRestart(true).getBoolean();
|
||||
cache.enableWailaIntegration = config.get(sectionIntegration.getQualifiedName(), "enableWaila", true).setLanguageKey(LANG_PREFIX + "integration.enableWaila").setRequiresMcRestart(true).getBoolean();
|
||||
cache.enableThaumcraftIntegration = config.get(sectionIntegration.getQualifiedName(), "enableThaumcraft", true).setLanguageKey(LANG_PREFIX + "integration.enableThaumcraft").setRequiresMcRestart(true).getBoolean();
|
||||
|
||||
config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true);
|
||||
config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "baseStorage", 32).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.config;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IRenderRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.render.IRenderLabel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RenderRegistry implements IRenderRegistry
|
||||
{
|
||||
private List<IRenderLabel> registry = new ArrayList<IRenderLabel>();
|
||||
|
||||
@Override
|
||||
public void registerPreLabelRenderHandler (IRenderLabel renderHandler) {
|
||||
registry.add(renderHandler);
|
||||
}
|
||||
|
||||
public List<IRenderLabel> getRenderHandlers () {
|
||||
return registry;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.config;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaTooltipHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WailaRegistry implements IWailaRegistry
|
||||
{
|
||||
private List<IWailaTooltipHandler> registry = new ArrayList<IWailaTooltipHandler>();
|
||||
|
||||
@Override
|
||||
public void registerTooltipHandler (IWailaTooltipHandler handler) {
|
||||
registry.add(handler);
|
||||
}
|
||||
|
||||
public List<IWailaTooltipHandler> getTooltipHandlers () {
|
||||
return registry;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.jaquadro.minecraft.storagedrawers.core;
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.IStorageDrawersApi;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IRecipeHandlerRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IRenderRegistry;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaRegistry;
|
||||
|
||||
public class Api implements IStorageDrawersApi
|
||||
{
|
||||
@@ -16,4 +18,14 @@ public class Api implements IStorageDrawersApi
|
||||
public IRecipeHandlerRegistry recipeHandlerRegistry () {
|
||||
return StorageDrawers.recipeHandlerRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRenderRegistry renderRegistry () {
|
||||
return StorageDrawers.renderRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWailaRegistry wailaRegistry () {
|
||||
return StorageDrawers.wailaRegistry;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ public class IntegrationRegistry
|
||||
reg.add(new AppliedEnergistics());
|
||||
if (Loader.isModLoaded("Waila") && StorageDrawers.config.cache.enableWailaIntegration)
|
||||
reg.add(new Waila());
|
||||
if (Loader.isModLoaded("Thaumcraft") && StorageDrawers.config.cache.enableThaumcraftIntegration)
|
||||
reg.add(new Thaumcraft());
|
||||
}
|
||||
|
||||
private IntegrationRegistry () {
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.event.DrawerPopulatedEvent;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaTooltipHandler;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.render.IRenderLabel;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
|
||||
public class Thaumcraft extends IntegrationModule
|
||||
{
|
||||
private Item[] aspectItems;
|
||||
|
||||
@Override
|
||||
public String getModID () {
|
||||
return "Thaumcraft";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init () throws Throwable {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
aspectItems = new Item[] {
|
||||
GameRegistry.findItem(getModID(), "ItemEssence"),
|
||||
GameRegistry.findItem(getModID(), "ItemWispEssence"),
|
||||
GameRegistry.findItem(getModID(), "ItemCrystalEssence"),
|
||||
GameRegistry.findItem(getModID(), "BlockJarFilledItem"),
|
||||
GameRegistry.findItem(getModID(), "ItemManaBean"),
|
||||
};
|
||||
|
||||
StorageDrawersApi.instance().renderRegistry().registerPreLabelRenderHandler(new LabelRenderHandler());
|
||||
StorageDrawersApi.instance().wailaRegistry().registerTooltipHandler(new WailaTooltipHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit () {
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDrawerPopulated (DrawerPopulatedEvent event) {
|
||||
IDrawer drawer = event.drawer;
|
||||
if (drawer.isEmpty()) {
|
||||
drawer.setExtendedData("aspect", null);
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack protoStack = drawer.getStoredItemPrototype();
|
||||
for (Item item : aspectItems) {
|
||||
if (item == protoStack.getItem()) {
|
||||
setDrawerAspect(drawer, protoStack);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setDrawerAspect (IDrawer drawer, ItemStack itemStack) {
|
||||
NBTTagList tagAspects = itemStack.getTagCompound().getTagList("Aspects", Constants.NBT.TAG_COMPOUND);
|
||||
if (tagAspects == null || tagAspects.tagCount() == 0)
|
||||
return;
|
||||
|
||||
NBTTagCompound tagAspect = tagAspects.getCompoundTagAt(0);
|
||||
if (tagAspect == null || !tagAspect.hasKey("key"))
|
||||
return;
|
||||
|
||||
String key = tagAspect.getString("key");
|
||||
AspectList allAspects = ThaumcraftApiHelper.getAllAspects(1);
|
||||
for (Aspect a : allAspects.aspects.keySet()) {
|
||||
if (a.getTag().equals(key)) {
|
||||
drawer.setExtendedData("aspect", a);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class WailaTooltipHandler implements IWailaTooltipHandler {
|
||||
|
||||
@Override
|
||||
public String transformItemName (IDrawer drawer, String defaultName) {
|
||||
Object aspectObj = drawer.getExtendedData("aspect");
|
||||
if (!(aspectObj instanceof Aspect))
|
||||
return defaultName;
|
||||
|
||||
Aspect aspect = (Aspect)aspectObj;
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
if (!ThaumcraftApiHelper.hasDiscoveredAspect(player.getDisplayName(), aspect))
|
||||
return defaultName + " (???)";
|
||||
|
||||
return defaultName + " (" + aspect.getName() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
private class LabelRenderHandler implements IRenderLabel {
|
||||
|
||||
@Override
|
||||
public void render (TileEntity tileEntity, IDrawerGroup drawerGroup, int slot, float brightness, float partialTickTime) {
|
||||
IDrawer drawer = drawerGroup.getDrawer(slot);
|
||||
if (drawer == null)
|
||||
return;
|
||||
|
||||
Object aspectObj = drawer.getExtendedData("aspect");
|
||||
if (!(aspectObj instanceof Aspect))
|
||||
return;
|
||||
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
Vec3 blockPos = Vec3.createVectorHelper(tileEntity.xCoord + .5, tileEntity.yCoord + .5, tileEntity.zCoord + .5);
|
||||
double distance = blockPos.distanceTo(player.getPosition(partialTickTime));
|
||||
|
||||
if (distance > 10)
|
||||
return;
|
||||
|
||||
Aspect aspect = (Aspect)aspectObj;
|
||||
if (!ThaumcraftApiHelper.hasDiscoveredAspect(player.getDisplayName(), aspect))
|
||||
return;
|
||||
|
||||
int x = -4;
|
||||
int y = -4;
|
||||
int w = 8;
|
||||
int h = 8;
|
||||
|
||||
if (drawerGroup.getDrawerCount() == 2) {
|
||||
x = -16;
|
||||
y = 0;
|
||||
w = 16;
|
||||
h = 16;
|
||||
}
|
||||
|
||||
float alpha = 1;
|
||||
if (distance > 3)
|
||||
alpha = 1f - (float)((distance - 3) / 7);
|
||||
|
||||
int color = aspect.getColor();
|
||||
float r = (float)(color >> 16 & 255) / 255.0F;
|
||||
float g = (float)(color >> 8 & 255) / 255.0F;
|
||||
float b = (float)(color & 255) / 255.0F;
|
||||
GL11.glColor4f(r * brightness, g * brightness, b * brightness, alpha);
|
||||
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
ResourceLocation aspectResource = aspect.getImage();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(aspectResource);
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(x, y + h, 0, 0, 1);
|
||||
tessellator.addVertexWithUV(x + w, y + h, 0, 1, 1);
|
||||
tessellator.addVertexWithUV(x + w, y, 0, 1, 0);
|
||||
tessellator.addVertexWithUV(x, y, 0, 0, 0);
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.integration;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaTooltipHandler;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers;
|
||||
@@ -64,10 +65,15 @@ public class Waila extends IntegrationModule
|
||||
IDrawer drawer = tile.getDrawer(i);
|
||||
ItemStack stack = drawer.getStoredItemPrototype();
|
||||
if (stack != null && stack.getItem() != null) {
|
||||
String stackName = stack.getDisplayName();
|
||||
List<IWailaTooltipHandler> handlers = StorageDrawers.wailaRegistry.getTooltipHandlers();
|
||||
for (int j = 0, n = handlers.size(); j < n; j++)
|
||||
stackName = handlers.get(j).transformItemName(drawer, stackName);
|
||||
|
||||
if (tile instanceof TileEntityDrawersComp)
|
||||
name = stack.getDisplayName() + ((i == 0) ? " [" : " [+") + ((TileEntityDrawersComp) tile).getStoredItemRemainder(i) + "]";
|
||||
name = stackName + ((i == 0) ? " [" : " [+") + ((TileEntityDrawersComp) tile).getStoredItemRemainder(i) + "]";
|
||||
else
|
||||
name = stack.getDisplayName() + " [" + drawer.getStoredItemCount() + "]";
|
||||
name = stackName + " [" + drawer.getStoredItemCount() + "]";
|
||||
}
|
||||
currenttip.add(StatCollector.translateToLocalFormatted("storageDrawers.waila.drawer", i + 1, name));
|
||||
}
|
||||
|
||||
@@ -9,12 +9,15 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class BaseDrawerData implements IDrawer, IInventoryAdapter
|
||||
{
|
||||
protected InventoryStack inventoryStack;
|
||||
private List<ItemStack> oreDictMatches;
|
||||
private Map<String, Object> auxData;
|
||||
|
||||
protected BaseDrawerData () {
|
||||
inventoryStack = new DrawerInventoryStack();
|
||||
@@ -89,6 +92,22 @@ public abstract class BaseDrawerData implements IDrawer, IInventoryAdapter
|
||||
return inventoryStack.markDirtyIfNeeded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getExtendedData (String key) {
|
||||
if (auxData == null || !auxData.containsKey(key))
|
||||
return null;
|
||||
|
||||
return auxData.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExtendedData (String key, Object data) {
|
||||
if (auxData == null)
|
||||
auxData = new HashMap<String, Object>();
|
||||
|
||||
auxData.put(key, data);
|
||||
}
|
||||
|
||||
public static boolean areItemsEqual (ItemStack stack1, ItemStack stack2) {
|
||||
if (stack1 == null || stack2 == null)
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.storage;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.event.DrawerPopulatedEvent;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.inventory.IInventoryAdapter;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.inventory.SlotType;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
|
||||
@@ -8,6 +9,7 @@ import com.jaquadro.minecraft.storagedrawers.inventory.InventoryStack;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -50,6 +52,9 @@ public class DrawerData extends BaseDrawerData
|
||||
protoStack = nullStack;
|
||||
inventoryStack.reset();
|
||||
|
||||
DrawerPopulatedEvent event = new DrawerPopulatedEvent(this);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (mark)
|
||||
storageProvider.markDirty(slot);
|
||||
return;
|
||||
@@ -62,6 +67,9 @@ public class DrawerData extends BaseDrawerData
|
||||
setStoredItemCount(amount, mark, false);
|
||||
inventoryStack.reset();
|
||||
|
||||
DrawerPopulatedEvent event = new DrawerPopulatedEvent(this);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (mark)
|
||||
storageProvider.markDirty(slot);
|
||||
}
|
||||
@@ -164,6 +172,9 @@ public class DrawerData extends BaseDrawerData
|
||||
protected void reset () {
|
||||
protoStack = nullStack;
|
||||
super.reset();
|
||||
|
||||
DrawerPopulatedEvent event = new DrawerPopulatedEvent(this);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user