Fixed Refinery GUI. Thanks Tommy!

Closes #1066
Closes #1062
This commit is contained in:
CovertJaguar 2013-07-28 15:34:39 -07:00
parent ab64958955
commit 0a81c8fca7
5 changed files with 46 additions and 20 deletions

View file

@ -1,11 +1,13 @@
package buildcraft.core.gui;
import buildcraft.core.render.FluidRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import org.lwjgl.opengl.GL11;
@ -28,10 +30,14 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
return "";
}
public Icon getTexture() {
public Icon getIcon() {
return null;
}
public ResourceLocation getTexture() {
return TextureMap.field_110576_c;
}
public ItemStack getItemStack() {
return null;
}
@ -46,10 +52,10 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
if (getItemStack() != null) {
drawStack(getItemStack());
} else if (getTexture() != null) {
mc.renderEngine.func_110577_a(TextureMap.field_110576_c);
//System.out.printf("Drawing advanced sprite %s (%d,%d) at %d %d\n", getTexture().getIconName(), getTexture().getOriginX(),getTexture().getOriginY(),cornerX + x, cornerY + y);
drawTexturedModelRectFromIcon(cornerX + x, cornerY + y, getTexture(), 16, 16);
} else if (getIcon() != null) {
mc.renderEngine.func_110577_a(getTexture());
//System.out.printf("Drawing advanced sprite %s (%d,%d) at %d %d\n", getIcon().getIconName(), getIcon().getOriginX(),getIcon().getOriginY(),cornerX + x, cornerY + y);
drawTexturedModelRectFromIcon(cornerX + x, cornerY + y, getIcon(), 16, 16);
}
}
@ -82,7 +88,8 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
}
/**
* More dynamic slot displaying an inventory fluid at specified position in the passed IInventory
* More dynamic slot displaying an inventory fluid at specified position in
* the passed IInventory
*/
public class IInventorySlot extends AdvancedSlot {
@ -99,9 +106,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
public ItemStack getItemStack() {
return tile.getStackInSlot(slot);
}
}
public AdvancedSlot[] slots;
public GuiAdvancedInterface(BuildCraftContainer container, IInventory inventory) {
@ -176,5 +181,15 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
public FluidSlot(int x, int y) {
super(x, y);
}
@Override
public Icon getIcon() {
return FluidRenderer.getFluidTexture(fluid, false);
}
@Override
public ResourceLocation getTexture() {
return FluidRenderer.getFluidSheet(fluid);
}
}
}

View file

@ -35,17 +35,16 @@ public class FluidRenderer {
public static class MissingFluidTextureException extends RuntimeException {
private final FluidStack fluidStack;
private final Fluid fluid;
public MissingFluidTextureException(FluidStack fluidStack) {
public MissingFluidTextureException(Fluid fluid) {
super();
this.fluidStack = fluidStack;
this.fluid = fluid;
}
@Override
public String getMessage() {
String fluidName = FluidRegistry.getFluidName(fluidStack);
return String.format("Fluid %s has no icon. Please contact the author of the mod the fluid came from.", fluidName);
return String.format("Fluid %s has no icon. Please contact the author of the mod the fluid came from.", fluid.getName());
}
}
@ -53,15 +52,27 @@ public class FluidRenderer {
if (fluidStack == null) {
return null;
}
Fluid fluid = fluidStack.getFluid();
return getFluidTexture(fluidStack.getFluid(), flowing);
}
public static Icon getFluidTexture(Fluid fluid, boolean flowing) {
if (fluid == null) {
return null;
}
Icon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon();
if (icon == null) {
throw new MissingFluidTextureException(fluidStack);
throw new MissingFluidTextureException(fluid);
}
return icon;
}
public static ResourceLocation getFluidSheet(FluidStack liquid) {
if (liquid == null)
return BLOCK_TEXTURE;
return getFluidSheet(liquid.getFluid());
}
public static ResourceLocation getFluidSheet(Fluid liquid) {
return BLOCK_TEXTURE;
}

View file

@ -23,6 +23,7 @@ public class ItemBucketBuildcraft extends ItemBucket {
public ItemBucketBuildcraft(int i, int blockId) {
super(i, blockId);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
setContainerItem(Item.bucketEmpty);
}
@Override

View file

@ -45,7 +45,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.ForgeDirection;
public class PipeTransportItems extends PipeTransport {
@ -92,7 +91,7 @@ public class PipeTransportItems extends PipeTransport {
}
private void scheduleLoad(TravelingItem item) {
delay = 2;
delay = 10;
toLoad.add(item);
}

View file

@ -56,7 +56,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
@SideOnly(Side.CLIENT)
@Override
public Icon getTexture() {
public Icon getIcon() {
ITrigger trigger = pipe.gate.getTrigger(slot);
if (trigger != null)
return trigger.getIcon();
@ -97,7 +97,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
@SideOnly(Side.CLIENT)
@Override
public Icon getTexture() {
public Icon getIcon() {
IAction action = pipe.gate.getAction(slot);
if (action != null)
return action.getIcon();