Fluid Destructor
This commit is contained in:
@@ -49,6 +49,7 @@ public final class RefinedStorage {
|
||||
public int crafterPerPatternUsage;
|
||||
public int craftingMonitorUsage;
|
||||
public int destructorUsage;
|
||||
public int fluidDestructorUsage;
|
||||
public int detectorUsage;
|
||||
public int diskDriveUsage;
|
||||
public int diskDrivePerDiskUsage;
|
||||
@@ -97,6 +98,7 @@ public final class RefinedStorage {
|
||||
crafterPerPatternUsage = config.getInt("crafterPerPattern", "energy", 1, 0, Integer.MAX_VALUE, "The additional energy used per Pattern in a Crafter");
|
||||
craftingMonitorUsage = config.getInt("craftingMonitor", "energy", 2, 0, Integer.MAX_VALUE, "The energy used by Crafting Monitors");
|
||||
destructorUsage = config.getInt("destructor", "energy", 1, 0, Integer.MAX_VALUE, "The energy used by Destructors");
|
||||
fluidDestructorUsage = config.getInt("fluidDestructor", "energy", 1, 0, Integer.MAX_VALUE, "The energy used by Fluid Destructors");
|
||||
detectorUsage = config.getInt("detector", "energy", 2, 0, Integer.MAX_VALUE, "The energy used by Detectors");
|
||||
diskDriveUsage = config.getInt("diskDrive", "energy", 0, 0, Integer.MAX_VALUE, "The base energy used by Disk Drives");
|
||||
diskDrivePerDiskUsage = config.getInt("diskDrivePerDisk", "energy", 1, 0, Integer.MAX_VALUE, "The additional energy used by Storage Disks in Disk Drives");
|
||||
|
||||
@@ -26,4 +26,5 @@ public final class RefinedStorageBlocks {
|
||||
public static final BlockNetworkReceiver NETWORK_RECEIVER = new BlockNetworkReceiver();
|
||||
public static final BlockFluidDiskDrive FLUID_DISK_DRIVE = new BlockFluidDiskDrive();
|
||||
public static final BlockFluidConstructor FLUID_CONSTRUCTOR = new BlockFluidConstructor();
|
||||
public static final BlockFluidDestructor FLUID_DESTRUCTOR = new BlockFluidDestructor();
|
||||
}
|
||||
@@ -22,4 +22,5 @@ public final class RefinedStorageGui {
|
||||
public static final int NETWORK_TRANSMITTER = 18;
|
||||
public static final int FLUID_DISK_DRIVE = 19;
|
||||
public static final int FLUID_CONSTRUCTOR = 20;
|
||||
public static final int FLUID_DESTRUCTOR = 21;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,12 @@ import refinedstorage.tile.TileDestructor;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockDestructor extends BlockCable {
|
||||
public BlockDestructor(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public BlockDestructor() {
|
||||
super("destructor");
|
||||
this("destructor");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
37
src/main/java/refinedstorage/block/BlockFluidDestructor.java
Executable file
37
src/main/java/refinedstorage/block/BlockFluidDestructor.java
Executable file
@@ -0,0 +1,37 @@
|
||||
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.TileFluidDestructor;
|
||||
|
||||
public class BlockFluidDestructor extends BlockDestructor {
|
||||
public BlockFluidDestructor() {
|
||||
super("fluid_destructor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||
return new TileFluidDestructor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (hitCablePart(state, world, pos, hitX, hitY, hitZ)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.FLUID_DESTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
51
src/main/java/refinedstorage/container/ContainerFluidDestructor.java
Executable file
51
src/main/java/refinedstorage/container/ContainerFluidDestructor.java
Executable file
@@ -0,0 +1,51 @@
|
||||
package refinedstorage.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.container.slot.SlotSpecimenFluid;
|
||||
import refinedstorage.tile.TileFluidDestructor;
|
||||
|
||||
public class ContainerFluidDestructor extends ContainerBase {
|
||||
public ContainerFluidDestructor(TileFluidDestructor fluidDestructor, EntityPlayer player) {
|
||||
super(fluidDestructor, player);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotItemHandler(fluidDestructor.getUpgrades(), i, 187, 6 + (i * 18)));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotSpecimenFluid(!fluidDestructor.getWorld().isRemote, fluidDestructor.getInventory(), i, 8 + (18 * i), 20));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 55);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
ItemStack stack = null;
|
||||
|
||||
Slot slot = getSlot(index);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
stack = slot.getStack();
|
||||
|
||||
if (index < 4) {
|
||||
if (!mergeItemStack(stack, 4 + 9, inventorySlots.size(), false)) {
|
||||
return null;
|
||||
}
|
||||
} else if (!mergeItemStack(stack, 0, 4, false)) {
|
||||
return mergeItemStackToSpecimen(stack, 4, 4 + 9);
|
||||
}
|
||||
|
||||
if (stack.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
40
src/main/java/refinedstorage/gui/GuiFluidDestructor.java
Executable file
40
src/main/java/refinedstorage/gui/GuiFluidDestructor.java
Executable file
@@ -0,0 +1,40 @@
|
||||
package refinedstorage.gui;
|
||||
|
||||
import refinedstorage.api.storage.CompareUtils;
|
||||
import refinedstorage.container.ContainerFluidDestructor;
|
||||
import refinedstorage.gui.sidebutton.SideButtonCompare;
|
||||
import refinedstorage.gui.sidebutton.SideButtonMode;
|
||||
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||
import refinedstorage.tile.TileFluidDestructor;
|
||||
|
||||
public class GuiFluidDestructor extends GuiBase {
|
||||
public GuiFluidDestructor(ContainerFluidDestructor container) {
|
||||
super(container, 211, 137);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(int x, int y) {
|
||||
addSideButton(new SideButtonRedstoneMode(TileFluidDestructor.REDSTONE_MODE));
|
||||
|
||||
addSideButton(new SideButtonMode(TileFluidDestructor.MODE));
|
||||
|
||||
addSideButton(new SideButtonCompare(TileFluidDestructor.COMPARE, CompareUtils.COMPARE_NBT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/destructor.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:fluid_destructor"));
|
||||
drawString(7, 43, t("container.inventory"));
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,8 @@ public class GuiHandler implements IGuiHandler {
|
||||
return new ContainerFluidDiskDrive((TileFluidDiskDrive) tile, player);
|
||||
case RefinedStorageGui.FLUID_CONSTRUCTOR:
|
||||
return new ContainerFluidConstructor((TileFluidConstructor) tile, player);
|
||||
case RefinedStorageGui.FLUID_DESTRUCTOR:
|
||||
return new ContainerFluidDestructor((TileFluidDestructor) tile, player);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -130,6 +132,8 @@ public class GuiHandler implements IGuiHandler {
|
||||
return new GuiStorage((ContainerFluidDiskDrive) getContainer(ID, player, tile), (IStorageGui) tile, "gui/disk_drive.png");
|
||||
case RefinedStorageGui.FLUID_CONSTRUCTOR:
|
||||
return new GuiFluidConstructor((ContainerFluidConstructor) getContainer(ID, player, tile));
|
||||
case RefinedStorageGui.FLUID_DESTRUCTOR:
|
||||
return new GuiFluidDestructor((ContainerFluidDestructor) getContainer(ID, player, tile));
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -259,5 +259,6 @@ public class ClientProxy extends CommonProxy {
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.STORAGE), EnumItemStorageType.TYPE_CREATIVE.getId(), new ModelResourceLocation("refinedstorage:storage", "type=creative"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.FLUID_DISK_DRIVE), 0, new ModelResourceLocation("refinedstorage:disk_drive", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.FLUID_CONSTRUCTOR), 0, new ModelResourceLocation("refinedstorage:fluid_constructor", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.FLUID_DESTRUCTOR), 0, new ModelResourceLocation("refinedstorage:fluid_destructor", "inventory"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ public class CommonProxy {
|
||||
registerTile(TileNetworkTransmitter.class, "network_transmitter");
|
||||
registerTile(TileFluidDiskDrive.class, "fluid_disk_drive");
|
||||
registerTile(TileFluidConstructor.class, "fluid_constructor");
|
||||
registerTile(TileFluidDestructor.class, "fluid_destructor");
|
||||
|
||||
registerBlock(RefinedStorageBlocks.CONTROLLER);
|
||||
registerBlock(RefinedStorageBlocks.GRID);
|
||||
@@ -111,6 +112,7 @@ public class CommonProxy {
|
||||
registerBlock(RefinedStorageBlocks.NETWORK_RECEIVER);
|
||||
registerBlock(RefinedStorageBlocks.FLUID_DISK_DRIVE);
|
||||
registerBlock(RefinedStorageBlocks.FLUID_CONSTRUCTOR);
|
||||
registerBlock(RefinedStorageBlocks.FLUID_DESTRUCTOR);
|
||||
|
||||
registerItem(RefinedStorageItems.QUARTZ_ENRICHED_IRON);
|
||||
registerItem(RefinedStorageItems.STORAGE_DISK);
|
||||
@@ -348,6 +350,18 @@ public class CommonProxy {
|
||||
'I', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
||||
);
|
||||
|
||||
// Fluid Destructor
|
||||
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.DESTRUCTOR),
|
||||
"EDE",
|
||||
"RMR",
|
||||
"EIE",
|
||||
'E', new ItemStack(RefinedStorageItems.QUARTZ_ENRICHED_IRON),
|
||||
'D', new ItemStack(RefinedStorageItems.CORE, 1, ItemCore.TYPE_DESTRUCTION),
|
||||
'R', new ItemStack(Items.BUCKET),
|
||||
'M', new ItemStack(RefinedStorageBlocks.CABLE),
|
||||
'I', new ItemStack(RefinedStorageItems.PROCESSOR, 1, ItemProcessor.TYPE_IMPROVED)
|
||||
);
|
||||
|
||||
// Constructor
|
||||
GameRegistry.addShapedRecipe(new ItemStack(RefinedStorageBlocks.CONSTRUCTOR),
|
||||
"ECE",
|
||||
|
||||
162
src/main/java/refinedstorage/tile/TileFluidDestructor.java
Executable file
162
src/main/java/refinedstorage/tile/TileFluidDestructor.java
Executable file
@@ -0,0 +1,162 @@
|
||||
package refinedstorage.tile;
|
||||
|
||||
import mcmultipart.microblock.IMicroblock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.wrappers.BlockLiquidWrapper;
|
||||
import net.minecraftforge.fluids.capability.wrappers.FluidBlockWrapper;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.inventory.ItemHandlerFluid;
|
||||
import refinedstorage.inventory.ItemHandlerUpgrade;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.config.IComparable;
|
||||
import refinedstorage.tile.config.IFilterable;
|
||||
import refinedstorage.tile.data.TileDataParameter;
|
||||
|
||||
public class TileFluidDestructor extends TileMultipartNode implements IComparable, IFilterable {
|
||||
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
||||
|
||||
private static final String NBT_COMPARE = "Compare";
|
||||
private static final String NBT_MODE = "Mode";
|
||||
|
||||
private static final int BASE_SPEED = 20;
|
||||
|
||||
private ItemHandlerFluid filters = new ItemHandlerFluid(9, this);
|
||||
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, this, ItemUpgrade.TYPE_SPEED);
|
||||
|
||||
private int compare = 0;
|
||||
private int mode = IFilterable.WHITELIST;
|
||||
|
||||
public TileFluidDestructor() {
|
||||
dataManager.addWatchedParameter(COMPARE);
|
||||
dataManager.addWatchedParameter(MODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddMicroblock(IMicroblock microblock) {
|
||||
return !isBlockingMicroblock(microblock, getDirection());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return RefinedStorage.INSTANCE.fluidDestructorUsage + upgrades.getEnergyUsage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNode() {
|
||||
if (ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0) {
|
||||
BlockPos front = pos.offset(getDirection());
|
||||
|
||||
Block frontBlock = worldObj.getBlockState(front).getBlock();
|
||||
|
||||
IFluidHandler handler = null;
|
||||
|
||||
if (frontBlock instanceof BlockLiquid) {
|
||||
handler = new BlockLiquidWrapper((BlockLiquid) frontBlock, worldObj, front);
|
||||
} else if (frontBlock instanceof IFluidBlock) {
|
||||
handler = new FluidBlockWrapper((IFluidBlock) frontBlock, worldObj, front);
|
||||
}
|
||||
|
||||
if (handler != null) {
|
||||
FluidStack stack = handler.drain(Fluid.BUCKET_VOLUME, false);
|
||||
|
||||
if (IFilterable.canTakeFluids(filters, mode, compare, stack) && network.insertFluid(stack, stack.amount, true) == null) {
|
||||
FluidStack drained = handler.drain(Fluid.BUCKET_VOLUME, true);
|
||||
|
||||
network.insertFluid(drained, drained.amount, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCompare() {
|
||||
return compare;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompare(int compare) {
|
||||
this.compare = compare;
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMode(int mode) {
|
||||
this.mode = mode;
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
super.read(tag);
|
||||
|
||||
if (tag.hasKey(NBT_COMPARE)) {
|
||||
compare = tag.getInteger(NBT_COMPARE);
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_MODE)) {
|
||||
mode = tag.getInteger(NBT_MODE);
|
||||
}
|
||||
|
||||
readItems(filters, 0, tag);
|
||||
readItems(upgrades, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
|
||||
writeItems(filters, 0, tag);
|
||||
writeItems(upgrades, 1, tag);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public IItemHandler getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
public IItemHandler getInventory() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getDrops() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return (T) upgrades;
|
||||
}
|
||||
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user