Simple fluid interface block & gui
This commit is contained in:
@@ -25,4 +25,5 @@ public final class RefinedStorageBlocks {
|
|||||||
public static final BlockNetworkTransmitter NETWORK_TRANSMITTER = new BlockNetworkTransmitter();
|
public static final BlockNetworkTransmitter NETWORK_TRANSMITTER = new BlockNetworkTransmitter();
|
||||||
public static final BlockNetworkReceiver NETWORK_RECEIVER = new BlockNetworkReceiver();
|
public static final BlockNetworkReceiver NETWORK_RECEIVER = new BlockNetworkReceiver();
|
||||||
public static final BlockFluidDiskDrive FLUID_DISK_DRIVE = new BlockFluidDiskDrive();
|
public static final BlockFluidDiskDrive FLUID_DISK_DRIVE = new BlockFluidDiskDrive();
|
||||||
|
public static final BlockFluidInterface FLUID_INTERFACE = new BlockFluidInterface();
|
||||||
}
|
}
|
||||||
@@ -21,4 +21,5 @@ public final class RefinedStorageGui {
|
|||||||
public static final int GRID_FILTER = 17;
|
public static final int GRID_FILTER = 17;
|
||||||
public static final int NETWORK_TRANSMITTER = 18;
|
public static final int NETWORK_TRANSMITTER = 18;
|
||||||
public static final int FLUID_DISK_DRIVE = 19;
|
public static final int FLUID_DISK_DRIVE = 19;
|
||||||
|
public static final int FLUID_INTERFACE = 20;
|
||||||
}
|
}
|
||||||
|
|||||||
43
src/main/java/refinedstorage/block/BlockFluidInterface.java
Executable file
43
src/main/java/refinedstorage/block/BlockFluidInterface.java
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
package refinedstorage.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import refinedstorage.RefinedStorage;
|
||||||
|
import refinedstorage.RefinedStorageGui;
|
||||||
|
import refinedstorage.tile.TileFluidInterface;
|
||||||
|
|
||||||
|
public class BlockFluidInterface extends BlockNode {
|
||||||
|
public BlockFluidInterface() {
|
||||||
|
super("fluid_interface");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||||
|
return new TileFluidInterface();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
|
if (!world.isRemote) {
|
||||||
|
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.FLUID_INTERFACE, world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasConnectivityState() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumPlacementType getPlacementType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/main/java/refinedstorage/container/ContainerFluidInterface.java
Executable file
20
src/main/java/refinedstorage/container/ContainerFluidInterface.java
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
package refinedstorage.container;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
import refinedstorage.tile.TileFluidInterface;
|
||||||
|
|
||||||
|
public class ContainerFluidInterface extends ContainerBase {
|
||||||
|
public ContainerFluidInterface(TileFluidInterface fluidInterface, EntityPlayer player) {
|
||||||
|
super(fluidInterface, player);
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
addSlotToContainer(new SlotItemHandler(fluidInterface.getUpgrades(), i, 187, 6 + (i * 18)));
|
||||||
|
}
|
||||||
|
|
||||||
|
addSlotToContainer(new SlotItemHandler(fluidInterface.getBuckets(), 0, 44, 32));
|
||||||
|
addSlotToContainer(new SlotItemHandler(fluidInterface.getBuckets(), 1, 116, 32));
|
||||||
|
|
||||||
|
addPlayerInventory(8, 122);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
src/main/java/refinedstorage/gui/GuiFluidInterface.java
Executable file
35
src/main/java/refinedstorage/gui/GuiFluidInterface.java
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
package refinedstorage.gui;
|
||||||
|
|
||||||
|
import refinedstorage.container.ContainerFluidInterface;
|
||||||
|
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||||
|
import refinedstorage.tile.TileFluidInterface;
|
||||||
|
|
||||||
|
public class GuiFluidInterface extends GuiBase {
|
||||||
|
public GuiFluidInterface(ContainerFluidInterface container) {
|
||||||
|
super(container, 211, 204);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(int x, int y) {
|
||||||
|
addSideButton(new SideButtonRedstoneMode(TileFluidInterface.REDSTONE_MODE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(int x, int y) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||||
|
bindTexture("gui/fluid_interface.png");
|
||||||
|
|
||||||
|
drawTexture(x, y, 0, 0, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawForeground(int mouseX, int mouseY) {
|
||||||
|
drawString(7, 7, t("gui.refinedstorage:fluid_interface"));
|
||||||
|
drawString(43 + 4, 20, t("gui.refinedstorage:fluid_interface.in"));
|
||||||
|
drawString(115 + 1, 20, t("gui.refinedstorage:fluid_interface.out"));
|
||||||
|
drawString(7, 111, t("container.inventory"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,6 +53,8 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
return new ContainerNetworkTransmitter((TileNetworkTransmitter) tile, player);
|
return new ContainerNetworkTransmitter((TileNetworkTransmitter) tile, player);
|
||||||
case RefinedStorageGui.FLUID_DISK_DRIVE:
|
case RefinedStorageGui.FLUID_DISK_DRIVE:
|
||||||
return new ContainerFluidDiskDrive((TileFluidDiskDrive) tile, player);
|
return new ContainerFluidDiskDrive((TileFluidDiskDrive) tile, player);
|
||||||
|
case RefinedStorageGui.FLUID_INTERFACE:
|
||||||
|
return new ContainerFluidInterface((TileFluidInterface) tile, player);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -126,6 +128,8 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
return new GuiNetworkTransmitter((ContainerNetworkTransmitter) getContainer(ID, player, tile), (TileNetworkTransmitter) tile);
|
return new GuiNetworkTransmitter((ContainerNetworkTransmitter) getContainer(ID, player, tile), (TileNetworkTransmitter) tile);
|
||||||
case RefinedStorageGui.FLUID_DISK_DRIVE:
|
case RefinedStorageGui.FLUID_DISK_DRIVE:
|
||||||
return new GuiStorage((ContainerFluidDiskDrive) getContainer(ID, player, tile), (IStorageGui) tile, "gui/disk_drive.png");
|
return new GuiStorage((ContainerFluidDiskDrive) getContainer(ID, player, tile), (IStorageGui) tile, "gui/disk_drive.png");
|
||||||
|
case RefinedStorageGui.FLUID_INTERFACE:
|
||||||
|
return new GuiFluidInterface((ContainerFluidInterface) getContainer(ID, player, tile));
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public class CommonProxy {
|
|||||||
registerTile(TileNetworkReceiver.class, "network_receiver");
|
registerTile(TileNetworkReceiver.class, "network_receiver");
|
||||||
registerTile(TileNetworkTransmitter.class, "network_transmitter");
|
registerTile(TileNetworkTransmitter.class, "network_transmitter");
|
||||||
registerTile(TileFluidDiskDrive.class, "fluid_disk_drive");
|
registerTile(TileFluidDiskDrive.class, "fluid_disk_drive");
|
||||||
|
registerTile(TileFluidInterface.class, "fluid_interface");
|
||||||
|
|
||||||
registerBlock(RefinedStorageBlocks.CONTROLLER);
|
registerBlock(RefinedStorageBlocks.CONTROLLER);
|
||||||
registerBlock(RefinedStorageBlocks.GRID);
|
registerBlock(RefinedStorageBlocks.GRID);
|
||||||
@@ -109,6 +110,7 @@ public class CommonProxy {
|
|||||||
registerBlock(RefinedStorageBlocks.NETWORK_TRANSMITTER);
|
registerBlock(RefinedStorageBlocks.NETWORK_TRANSMITTER);
|
||||||
registerBlock(RefinedStorageBlocks.NETWORK_RECEIVER);
|
registerBlock(RefinedStorageBlocks.NETWORK_RECEIVER);
|
||||||
registerBlock(RefinedStorageBlocks.FLUID_DISK_DRIVE);
|
registerBlock(RefinedStorageBlocks.FLUID_DISK_DRIVE);
|
||||||
|
registerBlock(RefinedStorageBlocks.FLUID_INTERFACE);
|
||||||
|
|
||||||
registerItem(RefinedStorageItems.QUARTZ_ENRICHED_IRON);
|
registerItem(RefinedStorageItems.QUARTZ_ENRICHED_IRON);
|
||||||
registerItem(RefinedStorageItems.STORAGE_DISK);
|
registerItem(RefinedStorageItems.STORAGE_DISK);
|
||||||
@@ -561,6 +563,15 @@ public class CommonProxy {
|
|||||||
new ItemStack(RefinedStorageBlocks.EXPORTER)
|
new ItemStack(RefinedStorageBlocks.EXPORTER)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Fluid Interface
|
||||||
|
RefinedStorageAPI.SOLDERER_REGISTRY.addRecipe(new SoldererRecipeBasic(
|
||||||
|
new ItemStack(RefinedStorageBlocks.FLUID_INTERFACE),
|
||||||
|
200,
|
||||||
|
new ItemStack(Items.BUCKET),
|
||||||
|
new ItemStack(RefinedStorageBlocks.INTERFACE),
|
||||||
|
new ItemStack(Items.BUCKET)
|
||||||
|
));
|
||||||
|
|
||||||
// Grid Filter
|
// Grid Filter
|
||||||
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageItems.GRID_FILTER),
|
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageItems.GRID_FILTER),
|
||||||
"EPE",
|
"EPE",
|
||||||
|
|||||||
106
src/main/java/refinedstorage/tile/TileFluidInterface.java
Executable file
106
src/main/java/refinedstorage/tile/TileFluidInterface.java
Executable file
@@ -0,0 +1,106 @@
|
|||||||
|
package refinedstorage.tile;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
import net.minecraftforge.fluids.FluidTank;
|
||||||
|
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||||
|
import refinedstorage.inventory.ItemHandlerBasic;
|
||||||
|
import refinedstorage.inventory.ItemHandlerUpgrade;
|
||||||
|
import refinedstorage.item.ItemUpgrade;
|
||||||
|
|
||||||
|
public class TileFluidInterface extends TileNode {
|
||||||
|
private static final String NBT_TANK_IN = "TankIn";
|
||||||
|
private static final String NBT_TANK_OUT = "TankOut";
|
||||||
|
|
||||||
|
private FluidTank tankIn = new FluidTank(16000) {
|
||||||
|
@Override
|
||||||
|
protected void onContentsChanged() {
|
||||||
|
super.onContentsChanged();
|
||||||
|
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private FluidTank tankOut = new FluidTank(16000) {
|
||||||
|
@Override
|
||||||
|
protected void onContentsChanged() {
|
||||||
|
super.onContentsChanged();
|
||||||
|
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private ItemHandlerBasic buckets = new ItemHandlerBasic(2, this);
|
||||||
|
|
||||||
|
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, this, ItemUpgrade.TYPE_SPEED);
|
||||||
|
|
||||||
|
public TileFluidInterface() {
|
||||||
|
tankIn.setCanDrain(false);
|
||||||
|
tankIn.setCanFill(true);
|
||||||
|
|
||||||
|
tankOut.setCanDrain(true);
|
||||||
|
tankOut.setCanFill(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound write(NBTTagCompound tag) {
|
||||||
|
super.write(tag);
|
||||||
|
|
||||||
|
writeItems(upgrades, 0, tag);
|
||||||
|
writeItems(buckets, 1, tag);
|
||||||
|
|
||||||
|
tag.setTag(NBT_TANK_IN, tankIn.writeToNBT(new NBTTagCompound()));
|
||||||
|
tag.setTag(NBT_TANK_OUT, tankOut.writeToNBT(new NBTTagCompound()));
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(NBTTagCompound tag) {
|
||||||
|
super.read(tag);
|
||||||
|
|
||||||
|
readItems(upgrades, 0, tag);
|
||||||
|
readItems(buckets, 1, tag);
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_TANK_IN)) {
|
||||||
|
tankIn.readFromNBT(tag.getCompoundTag(NBT_TANK_IN));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_TANK_OUT)) {
|
||||||
|
tankOut.readFromNBT(tag.getCompoundTag(NBT_TANK_OUT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemHandlerUpgrade getUpgrades() {
|
||||||
|
return upgrades;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemHandlerBasic getBuckets() {
|
||||||
|
return buckets;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||||
|
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||||
|
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||||
|
return facing == EnumFacing.DOWN ? (T) tankOut : (T) tankIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getCapability(capability, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateNode() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEnergyUsage() {
|
||||||
|
return 0; // @TODO: x
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,6 +40,9 @@ gui.refinedstorage:network_transmitter.dimension=Dimension %d
|
|||||||
gui.refinedstorage:network_transmitter.missing_card=Missing Network Card
|
gui.refinedstorage:network_transmitter.missing_card=Missing Network Card
|
||||||
gui.refinedstorage:network_transmitter.missing_upgrade=Insert upgrade
|
gui.refinedstorage:network_transmitter.missing_upgrade=Insert upgrade
|
||||||
gui.refinedstorage:fluid_disk_drive=Fluid Disk Drive
|
gui.refinedstorage:fluid_disk_drive=Fluid Disk Drive
|
||||||
|
gui.refinedstorage:fluid_interface=Fluid Interface
|
||||||
|
gui.refinedstorage:fluid_interface.in=In
|
||||||
|
gui.refinedstorage:fluid_interface.out=Out
|
||||||
|
|
||||||
misc.refinedstorage:energy_stored=%d / %d RS
|
misc.refinedstorage:energy_stored=%d / %d RS
|
||||||
misc.refinedstorage:energy_usage=Usage: %d RS/t
|
misc.refinedstorage:energy_usage=Usage: %d RS/t
|
||||||
@@ -132,6 +135,7 @@ block.refinedstorage:processing_pattern_encoder.name=Processing Pattern Encoder
|
|||||||
block.refinedstorage:network_receiver.name=Network Receiver
|
block.refinedstorage:network_receiver.name=Network Receiver
|
||||||
block.refinedstorage:network_transmitter.name=Network Transmitter
|
block.refinedstorage:network_transmitter.name=Network Transmitter
|
||||||
block.refinedstorage:fluid_disk_drive.name=Fluid Disk Drive
|
block.refinedstorage:fluid_disk_drive.name=Fluid Disk Drive
|
||||||
|
block.refinedstorage:fluid_interface.name=Fluid Interface
|
||||||
|
|
||||||
item.refinedstorage:storage_disk.0.name=1k Storage Disk
|
item.refinedstorage:storage_disk.0.name=1k Storage Disk
|
||||||
item.refinedstorage:storage_disk.1.name=4k Storage Disk
|
item.refinedstorage:storage_disk.1.name=4k Storage Disk
|
||||||
|
|||||||
Reference in New Issue
Block a user