Added a GUI when shift-clicking pipes with a Spanner.
parent
0336f7127b
commit
fe29f822d3
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* This class was created by BrassGoggledCoders modding team.
|
||||
* This class is available as part of the BoilerCraft Mod for Minecraft.
|
||||
*
|
||||
* BoilerCraft is open-source and is distributed under the MMPL v1.0 License.
|
||||
* (http://www.mod-buildcraft.com/MMPL-1.0.txt)
|
||||
*
|
||||
*/
|
||||
package steamcraft.api.tile;
|
||||
|
||||
/**
|
||||
* @author decebaldecebal
|
||||
*
|
||||
*/
|
||||
public interface ISpannerTile
|
||||
{
|
||||
public void changeExtracting();
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* This class was created by BrassGoggledCoders modding team.
|
||||
* This class is available as part of the Steamcraft 2 Mod for Minecraft.
|
||||
*
|
||||
* Steamcraft 2 is open-source and is distributed under the MMPL v1.0 License.
|
||||
* (http://www.mod-buildcraft.com/MMPL-1.0.txt)
|
||||
*
|
||||
* Steamcraft 2 is based on the original Steamcraft Mod created by Proloe.
|
||||
* Steamcraft (c) Proloe 2011
|
||||
* (http://www.minecraftforum.net/topic/251532-181-steamcraft-source-code-releasedmlv054wip/)
|
||||
*
|
||||
*/
|
||||
package steamcraft.client.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import boilerplate.client.BaseContainerGui;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import steamcraft.common.lib.ModInfo;
|
||||
import steamcraft.common.tiles.TileCopperPipe;
|
||||
import steamcraft.common.tiles.container.ContainerPipeConnections;
|
||||
|
||||
/**
|
||||
* @author decebaldecebal
|
||||
*
|
||||
*/
|
||||
public class GuiPipeConnections extends BaseContainerGui
|
||||
{
|
||||
private static ResourceLocation guitexture = new ResourceLocation(ModInfo.PREFIX + "textures/gui/changeextractions.png");
|
||||
|
||||
private InventoryPlayer player;
|
||||
private TileCopperPipe tile;
|
||||
|
||||
public GuiPipeConnections(InventoryPlayer player, TileCopperPipe tile)
|
||||
{
|
||||
super(new ContainerPipeConnections(player));
|
||||
|
||||
this.xSize = 206;
|
||||
this.ySize = 196;
|
||||
this.player = player;
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
|
||||
{
|
||||
this.fontRendererObj.drawString("Change Extraction", 60, 6, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
this.mc.renderEngine.bindTexture(guitexture);
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
buttonList.clear();
|
||||
|
||||
buttonList.add(new GuiButton(0, guiLeft + 50, guiTop + 20, 40, 20, "North"));
|
||||
buttonList.add(new GuiButton(1, guiLeft + 50, guiTop + 80, 40, 20, "South"));
|
||||
buttonList.add(new GuiButton(2, guiLeft + 10, guiTop + 50, 40, 20, "East"));
|
||||
buttonList.add(new GuiButton(3, guiLeft + 90, guiTop + 50, 40, 20, "West"));
|
||||
buttonList.add(new GuiButton(4, guiLeft + 150, guiTop + 20, 40, 20, "Up"));
|
||||
buttonList.add(new GuiButton(5, guiLeft + 150, guiTop + 80, 40, 20, "Down"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button)
|
||||
{
|
||||
if (button.id == 0)
|
||||
System.out.println("Button 0 pressed");
|
||||
}
|
||||
}
|
|
@ -33,4 +33,6 @@ public class GuiIDs
|
|||
public static final int CAPACITOR = 12;
|
||||
public static final int LIQUID_BOILER = 13;
|
||||
public static final int INJECTOR = 14;
|
||||
|
||||
public static final int PIPES = 15;
|
||||
}
|
|
@ -12,24 +12,22 @@
|
|||
*/
|
||||
package steamcraft.common.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import boilerplate.api.IOpenableGUI;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import steamcraft.api.item.IUniversalWrench;
|
||||
import steamcraft.api.tile.ISpannerTile;
|
||||
import steamcraft.client.lib.GuiIDs;
|
||||
import steamcraft.common.Steamcraft;
|
||||
import steamcraft.common.init.InitBlocks;
|
||||
import steamcraft.common.lib.ModInfo;
|
||||
import steamcraft.common.tiles.TileCopperPipe;
|
||||
import steamcraft.common.tiles.energy.TileCopperWire;
|
||||
|
||||
/**
|
||||
* @author warlordjones
|
||||
|
@ -48,19 +46,19 @@ public class ItemSpanner extends BaseItem implements IUniversalWrench
|
|||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
Block block = world.getBlock(x, y, z);
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if ((block == InitBlocks.blockCopperPipe) || (block == InitBlocks.blockSteelPipe))
|
||||
if (tile instanceof ISpannerTile)
|
||||
{
|
||||
TileCopperPipe pipe = (TileCopperPipe) world.getTileEntity(x, y, z);
|
||||
ISpannerTile spannerTile = (ISpannerTile) tile;
|
||||
|
||||
pipe.changeExtracting();
|
||||
}
|
||||
else if ((block == InitBlocks.blockCopperWire) || (block == InitBlocks.blockSteelWire))
|
||||
{
|
||||
TileCopperWire wire = (TileCopperWire) world.getTileEntity(x, y, z);
|
||||
|
||||
wire.changeExtracting();
|
||||
if (player.isSneaking() && tile instanceof IOpenableGUI)
|
||||
{
|
||||
System.out.println("Opening GUI...");
|
||||
player.openGui(Steamcraft.instance, GuiIDs.PIPES, world, x, y, z);
|
||||
}
|
||||
else
|
||||
spannerTile.changeExtracting();
|
||||
}
|
||||
}
|
||||
player.swingItem();
|
||||
|
|
|
@ -14,6 +14,11 @@ package steamcraft.common.tiles;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import boilerplate.api.IOpenableGUI;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
|
@ -21,28 +26,25 @@ import net.minecraft.network.Packet;
|
|||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import steamcraft.api.tile.ISpannerTile;
|
||||
import steamcraft.client.gui.GuiPipeConnections;
|
||||
import steamcraft.common.init.InitBlocks;
|
||||
import steamcraft.common.init.InitPackets;
|
||||
import steamcraft.common.packets.CopperPipeFluidPacket;
|
||||
import steamcraft.common.packets.CopperPipePacket;
|
||||
import steamcraft.common.tiles.container.ContainerPipeConnections;
|
||||
|
||||
/**
|
||||
* @author decebaldecebal
|
||||
*
|
||||
*/
|
||||
public class TileCopperPipe extends TileEntity implements IFluidHandler
|
||||
public class TileCopperPipe extends TileEntity implements IFluidHandler, ISpannerTile, IOpenableGUI
|
||||
{
|
||||
private static int ticksTillFluidUpdate = 200; // update the fluid in pipe
|
||||
// every 10 seconds
|
||||
|
@ -233,6 +235,7 @@ public class TileCopperPipe extends TileEntity implements IFluidHandler
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeExtracting()
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
|
@ -678,6 +681,19 @@ public class TileCopperPipe extends TileEntity implements IFluidHandler
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
System.out.println("Gui returned.");
|
||||
return new GuiPipeConnections(player.inventory, (TileCopperPipe) world.getTileEntity(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
return new ContainerPipeConnections(player.inventory);
|
||||
}
|
||||
|
||||
public static class FluidNetwork
|
||||
{
|
||||
private int capacityPerPipe;
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* This class was created by BrassGoggledCoders modding team.
|
||||
* This class is available as part of the Steamcraft 2 Mod for Minecraft.
|
||||
*
|
||||
* Steamcraft 2 is open-source and is distributed under the MMPL v1.0 License.
|
||||
* (http://www.mod-buildcraft.com/MMPL-1.0.txt)
|
||||
*
|
||||
* Steamcraft 2 is based on the original Steamcraft Mod created by Proloe.
|
||||
* Steamcraft (c) Proloe 2011
|
||||
* (http://www.minecraftforum.net/topic/251532-181-steamcraft-source-code-releasedmlv054wip/)
|
||||
*
|
||||
*/
|
||||
package steamcraft.common.tiles.container;
|
||||
|
||||
import boilerplate.common.baseclasses.blocks.BaseContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
/**
|
||||
* @author decebaldecebal
|
||||
*
|
||||
*/
|
||||
public class ContainerPipeConnections extends BaseContainer
|
||||
{
|
||||
public ContainerPipeConnections(InventoryPlayer player)
|
||||
{
|
||||
int var3;
|
||||
|
||||
for (var3 = 0; var3 < 3; ++var3)
|
||||
for (int var4 = 0; var4 < 9; ++var4)
|
||||
this.addSlotToContainer(new Slot(player, var4 + (var3 * 9) + 9, 23 + (var4 * 18), 114 + (var3 * 18)));
|
||||
|
||||
for (var3 = 0; var3 < 9; ++var3)
|
||||
this.addSlotToContainer(new Slot(player, var3, 23 + (var3 * 18), 172));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer p_75145_1_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -14,6 +14,12 @@ package steamcraft.common.tiles.energy;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
|
@ -21,16 +27,8 @@ import net.minecraft.network.Packet;
|
|||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import steamcraft.api.tile.ISpannerTile;
|
||||
import steamcraft.common.init.InitBlocks;
|
||||
import steamcraft.common.init.InitPackets;
|
||||
import steamcraft.common.packets.WirePacket;
|
||||
|
@ -40,7 +38,7 @@ import steamcraft.common.tiles.TileCopperPipe.Coords;
|
|||
* @author decebaldecebal
|
||||
*
|
||||
*/
|
||||
public class TileCopperWire extends TileEntity implements IEnergyHandler
|
||||
public class TileCopperWire extends TileEntity implements IEnergyHandler, ISpannerTile
|
||||
{
|
||||
private static int copperWireCapacity = 5000;
|
||||
private static int copperWireTransfer = 1000;
|
||||
|
|
Loading…
Reference in New Issue