mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 13:10:13 +00:00
Item rendering now shows fill bar. Added recipes and deprecated old block.
This commit is contained in:
1 parent
ae1de3b182
commit
ab55afbc59
13 files changed
+171
-41
No files matched your search
@@ -1,7 +1,5 @@
|
||||
package crazypants.enderio.machine;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import crazypants.util.Lang;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -12,8 +10,10 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.RecipeSorter.Category;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
public class ClearConfigRecipe implements IRecipe{
|
||||
public class ClearConfigRecipe implements IRecipe {
|
||||
|
||||
static {
|
||||
RecipeSorter.register("EnderIO:clearConfig", ClearConfigRecipe.class, Category.SHAPELESS, "after:minecraft:shapeless");
|
||||
@@ -39,9 +39,9 @@ public class ClearConfigRecipe implements IRecipe{
|
||||
out.stackTagCompound = new NBTTagCompound();
|
||||
out.stackTagCompound.setBoolean("clearedConfig", true);
|
||||
out.stackSize = 1;
|
||||
this.output = out;
|
||||
output = out;
|
||||
} else {
|
||||
this.output = null;
|
||||
output = null;
|
||||
}
|
||||
|
||||
return count == 1 && output != null;
|
||||
@@ -64,7 +64,7 @@ public class ClearConfigRecipe implements IRecipe{
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTooltip(ItemTooltipEvent event) {
|
||||
if (this.output != null && ItemStack.areItemStacksEqual(output, event.itemStack)) {
|
||||
if (output != null && ItemStack.areItemStacksEqual(output, event.itemStack)) {
|
||||
event.toolTip.add(EnumChatFormatting.RED.toString() + EnumChatFormatting.ITALIC + Lang.localize("machine.tooltip.clearConfig", true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.skull.BlockEndermanSkull;
|
||||
import crazypants.enderio.machine.capbank.CapBankType;
|
||||
import crazypants.enderio.machine.capbank.ConvertOldRecipe;
|
||||
import crazypants.enderio.machine.light.BlockItemElectricLight;
|
||||
import crazypants.enderio.material.Alloy;
|
||||
import crazypants.enderio.material.FrankenSkull;
|
||||
@@ -129,13 +131,22 @@ public class MachineRecipes {
|
||||
GameRegistry.addShapedRecipe(still, "eve", "tmt", "efe", 'v', Items.cauldron, 'm', machineChassi, 'e', electricSteel, 'f', Blocks.furnace, 't', basicTank);
|
||||
|
||||
//capacitor bank
|
||||
ItemStack capacitorBank = new ItemStack(EnderIO.blockCapacitorBank, 1, 0);
|
||||
if(Config.useHardRecipes) {
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(capacitorBank, "rcr", "ccc", "rMr", 'm', electricSteel, 'c', capacitor2, 'r', Blocks.redstone_block, 'M',
|
||||
machineChassi));
|
||||
} else {
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(capacitorBank, "mcm", "crc", "mcm", 'm', electricSteel, 'c', capacitor2, 'r', Blocks.redstone_block));
|
||||
}
|
||||
// ItemStack capacitorBank = new ItemStack(EnderIO.blockCapacitorBank, 1, 0);
|
||||
// if(Config.useHardRecipes) {
|
||||
// GameRegistry.addRecipe(new ShapedOreRecipe(capacitorBank, "rcr", "ccc", "rMr", 'm', electricSteel, 'c', capacitor2, 'r', Blocks.redstone_block, 'M',
|
||||
// machineChassi));
|
||||
// } else {
|
||||
// GameRegistry.addRecipe(new ShapedOreRecipe(capacitorBank, "mcm", "crc", "mcm", 'm', electricSteel, 'c', capacitor2, 'r', Blocks.redstone_block));
|
||||
// }
|
||||
ItemStack capBank = new ItemStack(EnderIO.blockCapBank, 1, CapBankType.getMetaFromType(CapBankType.SIMPLE));
|
||||
GameRegistry.addShapedRecipe(capBank, "bcb", "cmc", "bcb", 'b', Items.iron_ingot, 'c', capacitor, 'm', Blocks.redstone_block);
|
||||
capBank = new ItemStack(EnderIO.blockCapBank, 1, CapBankType.getMetaFromType(CapBankType.ACTIVATED));
|
||||
GameRegistry.addShapedRecipe(capBank, "bcb", "cmc", "bcb", 'b', electricSteel, 'c', capacitor2, 'm', Blocks.redstone_block);
|
||||
capBank = new ItemStack(EnderIO.blockCapBank, 1, CapBankType.getMetaFromType(CapBankType.VIBRANT));
|
||||
GameRegistry.addShapedRecipe(capBank, "bcb", "cmc", "bcb", 'b', electricSteel, 'c', capacitor3, 'm', vibCry);
|
||||
|
||||
ConvertOldRecipe convertRecipe = new ConvertOldRecipe();
|
||||
GameRegistry.addRecipe(convertRecipe);
|
||||
|
||||
//painter
|
||||
ItemStack painter = new ItemStack(EnderIO.blockPainter, 1, 0);
|
||||
|
||||
@@ -9,24 +9,24 @@ import crazypants.enderio.config.Config;
|
||||
|
||||
public class CapBankType {
|
||||
|
||||
private static final CapBankType CREATIVE = new CapBankType("CREATIVE", "tile.blockCapBank.creative", 500000, Config.capacitorBankTierTwoMaxStorageRF, false,
|
||||
public static final CapBankType CREATIVE = new CapBankType("CREATIVE", "tile.blockCapBank.creative", 500000, Config.capacitorBankTierTwoMaxStorageRF, false,
|
||||
true,
|
||||
"enderio:capacitorBank", "enderio:capacitorBankCreativeBorder", "enderio:capacitorBankInput", "enderio:capacitorBankOutput",
|
||||
"enderio:capacitorBankLocked");
|
||||
|
||||
private static final CapBankType SIMPLE = new CapBankType("SIMPLE", "tile.blockCapBank.simple", Config.capacitorBankTierOneMaxIoRF,
|
||||
public static final CapBankType SIMPLE = new CapBankType("SIMPLE", "tile.blockCapBank.simple", Config.capacitorBankTierOneMaxIoRF,
|
||||
Config.capacitorBankTierOneMaxStorageRF,
|
||||
true,
|
||||
false, "enderio:capacitorBank", "enderio:capacitorBankSimpleBorder", "enderio:capacitorBankInput", "enderio:capacitorBankOutput",
|
||||
"enderio:capacitorBankLocked");
|
||||
|
||||
private static final CapBankType ACTIVATED = new CapBankType("ACTIVATED", "tile.blockCapBank.activated", Config.capacitorBankTierTwoMaxIoRF,
|
||||
public static final CapBankType ACTIVATED = new CapBankType("ACTIVATED", "tile.blockCapBank.activated", Config.capacitorBankTierTwoMaxIoRF,
|
||||
Config.capacitorBankTierTwoMaxStorageRF,
|
||||
true,
|
||||
false, "enderio:capacitorBank", "enderio:capacitorBankActivatedBorder", "enderio:capacitorBankInput", "enderio:capacitorBankOutput",
|
||||
"enderio:capacitorBankLocked");
|
||||
|
||||
private static final CapBankType VIBRANT = new CapBankType("VIBRANT", "tile.blockCapBank.vibrant", Config.capacitorBankTierThreeMaxIoRF,
|
||||
public static final CapBankType VIBRANT = new CapBankType("VIBRANT", "tile.blockCapBank.vibrant", Config.capacitorBankTierThreeMaxIoRF,
|
||||
Config.capacitorBankTierThreeMaxStorageRF,
|
||||
true, false, "enderio:capacitorBank", "enderio:capacitorBankVibrantBorder", "enderio:capacitorBankInput", "enderio:capacitorBankOutput",
|
||||
"enderio:capacitorBankLocked");
|
||||
@@ -44,6 +44,15 @@ public class CapBankType {
|
||||
return TYPES;
|
||||
}
|
||||
|
||||
public static int getMetaFromType(CapBankType type) {
|
||||
for (int i = 0; i < TYPES.size(); i++) {
|
||||
if(TYPES.get(i) == type) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static CapBankType getTypeFromMeta(int meta) {
|
||||
meta = MathHelper.clamp_int(meta, 0, TYPES.size() - 1);
|
||||
return types().get(meta);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package crazypants.enderio.machine.capbank;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.RecipeSorter.Category;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
|
||||
public class ConvertOldRecipe implements IRecipe {
|
||||
|
||||
static {
|
||||
RecipeSorter.register("EnderIO:convertOldCapBankRecipe", ConvertOldRecipe.class, Category.SHAPELESS, "after:minecraft:shapeless");
|
||||
}
|
||||
|
||||
private ItemStack output;
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World world) {
|
||||
ItemStack input = null;
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack checkStack = inv.getStackInSlot(i);
|
||||
if(checkStack != null) {
|
||||
if(input != null) {
|
||||
return false;
|
||||
}
|
||||
if(Block.getBlockFromItem(checkStack.getItem()) == EnderIO.blockCapacitorBank) {
|
||||
input = checkStack;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(input == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
output = new ItemStack(EnderIO.blockCapBank, 1, CapBankType.getMetaFromType(CapBankType.ACTIVATED));
|
||||
PowerHandlerUtil.setStoredEnergyForItem(output, PowerHandlerUtil.getStoredEnergyForItem(input));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -113,6 +113,10 @@ public class CapBankClientNetwork implements ICapBankNetwork {
|
||||
return maxEnergyStored;
|
||||
}
|
||||
|
||||
public void setMaxEnergyStoredL(long maxEnergyStored) {
|
||||
this.maxEnergyStored = maxEnergyStored;
|
||||
}
|
||||
|
||||
public void setEnergyStored(long energyStored) {
|
||||
this.energyStored = energyStored;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@ import crazypants.enderio.machine.capbank.BlockCapBank;
|
||||
import crazypants.enderio.machine.capbank.CapBankType;
|
||||
import crazypants.enderio.machine.capbank.InfoDisplayType;
|
||||
import crazypants.enderio.machine.capbank.TileCapBank;
|
||||
import crazypants.enderio.machine.capbank.network.CapBankClientNetwork;
|
||||
import crazypants.enderio.machine.capbank.render.FillGauge.GaugeInfo;
|
||||
import crazypants.enderio.machine.capbank.render.FillGauge.GaugeKey;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.render.ConnectedTextureRenderer;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.CustomCubeRenderer;
|
||||
@@ -33,12 +37,14 @@ public class CapBankRenderer extends TileEntitySpecialRenderer implements ISimpl
|
||||
private ConnectedTextureRenderer connectedTexRenderer;
|
||||
|
||||
private Map<InfoDisplayType, IInfoRenderer> infoRenderers;
|
||||
private FillGauge fillGaugeRenderer;
|
||||
|
||||
public CapBankRenderer() {
|
||||
connectedTexRenderer = new ConnectedTextureRenderer();
|
||||
connectedTexRenderer.setMatchMeta(true);
|
||||
fillGaugeRenderer = new FillGauge();
|
||||
infoRenderers = new HashMap<InfoDisplayType, IInfoRenderer>();
|
||||
infoRenderers.put(InfoDisplayType.LEVEL_BAR, new FillGauge());
|
||||
infoRenderers.put(InfoDisplayType.LEVEL_BAR, fillGaugeRenderer);
|
||||
infoRenderers.put(InfoDisplayType.IO, new IoDisplay());
|
||||
|
||||
}
|
||||
@@ -106,6 +112,17 @@ public class CapBankRenderer extends TileEntitySpecialRenderer implements ISimpl
|
||||
|
||||
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
|
||||
CapBankClientNetwork nw = new CapBankClientNetwork(-1);
|
||||
nw.setMaxEnergyStoredL(CapBankType.getTypeFromMeta(item.getItemDamage()).getMaxEnergyStored());
|
||||
nw.setEnergyStored(PowerHandlerUtil.getStoredEnergyForItem(item));
|
||||
|
||||
GaugeInfo gi = new GaugeInfo(1, 0);
|
||||
GaugeKey key = new GaugeKey(ForgeDirection.SOUTH, FillGauge.Type.SINGLE);
|
||||
fillGaugeRenderer.doRender(nw, RenderUtil.BRIGHTNESS_MAX, gi, key);
|
||||
// key = new GaugeKey(ForgeDirection.EAST, FillGauge.Type.SINGLE);
|
||||
// fillGaugeRenderer.doRender(nw, RenderUtil.BRIGHTNESS_MAX, gi, key);
|
||||
|
||||
}
|
||||
|
||||
private void renderBorder(IBlockAccess blockAccess, int x, int y, int z, int meta) {
|
||||
|
||||
@@ -50,33 +50,33 @@ public class FillGauge implements IInfoRenderer {
|
||||
|
||||
@Override
|
||||
public void render(TileCapBank cb, ForgeDirection dir, double x, double y, double z, float partialTick) {
|
||||
if(gaugeVertexCache == null) {
|
||||
createVertexCache();
|
||||
}
|
||||
|
||||
CapBankClientNetwork nw = null;
|
||||
if(cb.getNetwork() != null) {
|
||||
nw = (CapBankClientNetwork) cb.getNetwork();
|
||||
nw.requestPowerUpdate(cb, 20);
|
||||
}
|
||||
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
|
||||
int brightness = cb.getWorldObj().getLightBrightnessForSkyBlocks(cb.xCoord + dir.offsetX, cb.yCoord + dir.offsetY, cb.zCoord + dir.offsetZ, 0);
|
||||
GaugeInfo info = getGaugeInfo(cb, dir);
|
||||
GaugeKey key = new GaugeKey(dir, info.type);
|
||||
doRender(nw, brightness, info, key);
|
||||
|
||||
}
|
||||
|
||||
public void doRender(CapBankClientNetwork nw, int brightness, GaugeInfo info, GaugeKey key) {
|
||||
if(gaugeVertexCache == null) {
|
||||
createVertexCache();
|
||||
}
|
||||
RenderUtil.bindBlockTexture();
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.startDrawingQuads();
|
||||
tes.setBrightness(brightness);
|
||||
tes.setColorOpaque_F(1, 1, 1);
|
||||
|
||||
GaugeInfo info = getGaugeInfo(cb, dir);
|
||||
GaugeKey key = new GaugeKey(dir, info.type);
|
||||
List<Vertex> verts = gaugeVertexCache.get(key);
|
||||
RenderUtil.addVerticesToTessellator(verts, Tessellator.instance);
|
||||
renderFillBar(key, nw, info);
|
||||
|
||||
tes.draw();
|
||||
|
||||
}
|
||||
|
||||
private void renderFillBar(GaugeKey key, CapBankClientNetwork nw, GaugeInfo info) {
|
||||
@@ -222,7 +222,7 @@ public class FillGauge implements IInfoRenderer {
|
||||
return res;
|
||||
}
|
||||
|
||||
private static class GaugeInfo {
|
||||
static class GaugeInfo {
|
||||
|
||||
int height;
|
||||
int yPosition;
|
||||
@@ -249,12 +249,12 @@ public class FillGauge implements IInfoRenderer {
|
||||
|
||||
}
|
||||
|
||||
private static class GaugeKey {
|
||||
static class GaugeKey {
|
||||
|
||||
ForgeDirection dir;
|
||||
Type type;
|
||||
|
||||
public GaugeKey(ForgeDirection dir, Type type) {
|
||||
GaugeKey(ForgeDirection dir, Type type) {
|
||||
this.dir = dir;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
|
||||
protected BlockCapacitorBank() {
|
||||
super(ModObject.blockCapacitorBank.unlocalisedName, TileCapacitorBank.class);
|
||||
setHardness(2.0F);
|
||||
setCreativeTab(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -397,6 +398,7 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
|
||||
tooltip.add(String.format("%s : %s%s%sRF/t ", Lang.localize("capbank.maxIO"), format, fmt.format(cap.getMaxIO()), Util.TAB + Util.ALIGNRIGHT));
|
||||
tooltip.add(String.format("%s : %s%s%sRF/t ", Lang.localize("capbank.maxIn"), format, fmt.format(cap.getMaxInput()), Util.TAB + Util.ALIGNRIGHT));
|
||||
tooltip.add(String.format("%s : %s%s%sRF/t ", Lang.localize("capbank.maxOut"), format, fmt.format(cap.getMaxOutput()), Util.TAB + Util.ALIGNRIGHT));
|
||||
tooltip.add("Deprecated. Convert by placing in crafting grid");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
package crazypants.render;
|
||||
|
||||
import static net.minecraftforge.common.util.ForgeDirection.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.DOWN;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.EAST;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.NORTH;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.UP;
|
||||
import static net.minecraftforge.common.util.ForgeDirection.WEST;
|
||||
import static org.lwjgl.opengl.GL11.GL_ALL_ATTRIB_BITS;
|
||||
import static org.lwjgl.opengl.GL11.GL_ALPHA_TEST;
|
||||
import static org.lwjgl.opengl.GL11.GL_BLEND;
|
||||
import static org.lwjgl.opengl.GL11.GL_CULL_FACE;
|
||||
import static org.lwjgl.opengl.GL11.GL_ONE;
|
||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL11.GL_SMOOTH;
|
||||
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
||||
import static org.lwjgl.opengl.GL11.GL_ZERO;
|
||||
import static org.lwjgl.opengl.GL11.glDepthMask;
|
||||
import static org.lwjgl.opengl.GL11.glDisable;
|
||||
import static org.lwjgl.opengl.GL11.glEnable;
|
||||
import static org.lwjgl.opengl.GL11.glPopAttrib;
|
||||
import static org.lwjgl.opengl.GL11.glPushAttrib;
|
||||
import static org.lwjgl.opengl.GL11.glRotatef;
|
||||
import static org.lwjgl.opengl.GL11.glShadeModel;
|
||||
import static org.lwjgl.opengl.GL11.glTranslatef;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.ArrayList;
|
||||
@@ -61,6 +83,8 @@ public class RenderUtil {
|
||||
|
||||
public static final ResourceLocation GLINT_TEX = new ResourceLocation("textures/misc/enchanted_item_glint.png");
|
||||
|
||||
public static int BRIGHTNESS_MAX = 15 << 20 | 15 << 4;
|
||||
|
||||
public static void loadMatrix(Matrix4d mat) {
|
||||
MATRIX_BUFFER.rewind();
|
||||
MATRIX_BUFFER.put((float) mat.m00);
|
||||
@@ -598,8 +622,8 @@ public class RenderUtil {
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
OpenGlHelper.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); // stop random disappearing
|
||||
|
||||
float width = (float) fnt.getStringWidth(toRender);
|
||||
float height = (float) fnt.FONT_HEIGHT;
|
||||
float width = fnt.getStringWidth(toRender);
|
||||
float height = fnt.FONT_HEIGHT;
|
||||
float padding = 2f;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
Reference in new issue
Block a user