Added security manager
This commit is contained in:
@@ -29,4 +29,5 @@ public final class RSBlocks {
|
|||||||
public static final BlockDiskManipulator DISK_MANIPULATOR = new BlockDiskManipulator();
|
public static final BlockDiskManipulator DISK_MANIPULATOR = new BlockDiskManipulator();
|
||||||
public static final BlockReader READER = new BlockReader();
|
public static final BlockReader READER = new BlockReader();
|
||||||
public static final BlockWriter WRITER = new BlockWriter();
|
public static final BlockWriter WRITER = new BlockWriter();
|
||||||
|
public static final BlockSecurityManager SECURITY_MANAGER = new BlockSecurityManager();
|
||||||
}
|
}
|
||||||
@@ -46,6 +46,8 @@ public final class RSConfig {
|
|||||||
public int diskManipulatorUsage;
|
public int diskManipulatorUsage;
|
||||||
public int readerUsage;
|
public int readerUsage;
|
||||||
public int writerUsage;
|
public int writerUsage;
|
||||||
|
public int securityManagerUsage;
|
||||||
|
public int securityManagerPerSecurityCardUsage;
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region Controller
|
//region Controller
|
||||||
@@ -149,6 +151,8 @@ public final class RSConfig {
|
|||||||
diskManipulatorUsage = config.getInt("diskManipulator", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Disk Manipulators");
|
diskManipulatorUsage = config.getInt("diskManipulator", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Disk Manipulators");
|
||||||
readerUsage = config.getInt("reader", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Readers");
|
readerUsage = config.getInt("reader", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Readers");
|
||||||
writerUsage = config.getInt("writer", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Writers");
|
writerUsage = config.getInt("writer", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Writers");
|
||||||
|
securityManagerUsage = config.getInt("securityManager", ENERGY, 4, 0, Integer.MAX_VALUE, "The base energy used by Security Managers");
|
||||||
|
securityManagerPerSecurityCardUsage = config.getInt("securityManagerPerSecurityCard", ENERGY, 10, 0, Integer.MAX_VALUE, "The additional energy used by Security Cards in Security Managers");
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region Controller
|
//region Controller
|
||||||
|
|||||||
@@ -26,4 +26,5 @@ public final class RSGui {
|
|||||||
public static final int DISK_MANIPULATOR = 22;
|
public static final int DISK_MANIPULATOR = 22;
|
||||||
public static final int WIRELESS_CRAFTING_MONITOR = 23;
|
public static final int WIRELESS_CRAFTING_MONITOR = 23;
|
||||||
public static final int READER_WRITER = 24;
|
public static final int READER_WRITER = 24;
|
||||||
|
public static final int SECURITY_MANAGER = 25;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.block;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSGui;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.Permission;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.TileSecurityManager;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class BlockSecurityManager extends BlockNode {
|
||||||
|
public BlockSecurityManager() {
|
||||||
|
super("security_manager");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||||
|
return new TileSecurityManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
|
if (!world.isRemote) {
|
||||||
|
tryOpenNetworkGui(RSGui.SECURITY_MANAGER, player, world, pos, side, Permission.MODIFY, Permission.SECURITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.TileSecurityManager;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
|
public class ContainerSecurityManager extends ContainerBase {
|
||||||
|
public ContainerSecurityManager(TileSecurityManager tile, EntityPlayer player) {
|
||||||
|
super(tile, player);
|
||||||
|
|
||||||
|
int x = 8;
|
||||||
|
int y = 20;
|
||||||
|
|
||||||
|
for (int i = 0; i < 9 * 2; ++i) {
|
||||||
|
addSlotToContainer(new SlotItemHandler(tile.getCards(), i, x, y));
|
||||||
|
|
||||||
|
if (((i + 1) % 9) == 0) {
|
||||||
|
x = 8;
|
||||||
|
y += 18;
|
||||||
|
} else {
|
||||||
|
x += 18;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addSlotToContainer(new SlotItemHandler(tile.getEditCard(), 0, 80, 70));
|
||||||
|
|
||||||
|
addPlayerInventory(8, 127);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||||
|
ItemStack stack = ItemStack.EMPTY;
|
||||||
|
|
||||||
|
Slot slot = getSlot(index);
|
||||||
|
|
||||||
|
if (slot.getHasStack()) {
|
||||||
|
stack = slot.getStack();
|
||||||
|
|
||||||
|
if (index < (9 * 2) + 1) {
|
||||||
|
if (!mergeItemStack(stack, (9 * 2) + 1, inventorySlots.size(), false)) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
} else if (!mergeItemStack(stack, 0, 9 * 2, false)) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.getCount() == 0) {
|
||||||
|
slot.putStack(ItemStack.EMPTY);
|
||||||
|
} else {
|
||||||
|
slot.onSlotChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,6 +65,8 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
return new ContainerDiskManipulator((TileDiskManipulator) tile, player);
|
return new ContainerDiskManipulator((TileDiskManipulator) tile, player);
|
||||||
case RSGui.READER_WRITER:
|
case RSGui.READER_WRITER:
|
||||||
return new ContainerReaderWriter((IReaderWriter) tile, player);
|
return new ContainerReaderWriter((IReaderWriter) tile, player);
|
||||||
|
case RSGui.SECURITY_MANAGER:
|
||||||
|
return new ContainerSecurityManager((TileSecurityManager) tile, player);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -140,6 +142,8 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
return getWirelessCraftingMonitorGui(player, x, y);
|
return getWirelessCraftingMonitorGui(player, x, y);
|
||||||
case RSGui.READER_WRITER:
|
case RSGui.READER_WRITER:
|
||||||
return new GuiReaderWriter((ContainerReaderWriter) getContainer(ID, player, tile), (IReaderWriter) tile);
|
return new GuiReaderWriter((ContainerReaderWriter) getContainer(ID, player, tile), (IReaderWriter) tile);
|
||||||
|
case RSGui.SECURITY_MANAGER:
|
||||||
|
return new GuiSecurityManager((ContainerSecurityManager) getContainer(ID, player, tile));
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
31
src/main/java/com/raoulvdberge/refinedstorage/gui/GuiSecurityManager.java
Executable file
31
src/main/java/com/raoulvdberge/refinedstorage/gui/GuiSecurityManager.java
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.gui;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.container.ContainerSecurityManager;
|
||||||
|
|
||||||
|
public class GuiSecurityManager extends GuiBase {
|
||||||
|
public GuiSecurityManager(ContainerSecurityManager container) {
|
||||||
|
super(container, 176, 209);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(int x, int y) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(int x, int y) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||||
|
bindTexture("gui/security_manager.png");
|
||||||
|
|
||||||
|
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawForeground(int mouseX, int mouseY) {
|
||||||
|
drawString(7, 7, t("gui.refinedstorage:security_manager"));
|
||||||
|
drawString(7, 59, t("gui.refinedstorage:security_manager.configure"));
|
||||||
|
drawString(7, 115, t("container.inventory"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,8 @@ public class ItemSecurityCard extends ItemBase {
|
|||||||
|
|
||||||
public ItemSecurityCard() {
|
public ItemSecurityCard() {
|
||||||
super("security_card");
|
super("security_card");
|
||||||
|
|
||||||
|
setMaxStackSize(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ public class ProxyCommon {
|
|||||||
registerTile(TileFluidInterface.class, "fluid_interface");
|
registerTile(TileFluidInterface.class, "fluid_interface");
|
||||||
registerTile(TileFluidStorage.class, "fluid_storage");
|
registerTile(TileFluidStorage.class, "fluid_storage");
|
||||||
registerTile(TileDiskManipulator.class, "disk_manipulator");
|
registerTile(TileDiskManipulator.class, "disk_manipulator");
|
||||||
|
registerTile(TileSecurityManager.class, "security_manager");
|
||||||
|
|
||||||
if (READER_WRITER_ENABLED) {
|
if (READER_WRITER_ENABLED) {
|
||||||
registerTile(TileReader.class, "reader");
|
registerTile(TileReader.class, "reader");
|
||||||
@@ -170,6 +171,7 @@ public class ProxyCommon {
|
|||||||
registerBlock(RSBlocks.EXTERNAL_STORAGE);
|
registerBlock(RSBlocks.EXTERNAL_STORAGE);
|
||||||
registerBlock(RSBlocks.CONSTRUCTOR);
|
registerBlock(RSBlocks.CONSTRUCTOR);
|
||||||
registerBlock(RSBlocks.DESTRUCTOR);
|
registerBlock(RSBlocks.DESTRUCTOR);
|
||||||
|
registerBlock(RSBlocks.SECURITY_MANAGER);
|
||||||
|
|
||||||
if (READER_WRITER_ENABLED) {
|
if (READER_WRITER_ENABLED) {
|
||||||
registerBlock(RSBlocks.READER);
|
registerBlock(RSBlocks.READER);
|
||||||
|
|||||||
57
src/main/java/com/raoulvdberge/refinedstorage/tile/TileSecurityManager.java
Executable file
57
src/main/java/com/raoulvdberge/refinedstorage/tile/TileSecurityManager.java
Executable file
@@ -0,0 +1,57 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
|
import com.raoulvdberge.refinedstorage.RSItems;
|
||||||
|
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||||
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBasic;
|
||||||
|
import com.raoulvdberge.refinedstorage.inventory.ItemValidatorBasic;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
public class TileSecurityManager extends TileNode {
|
||||||
|
private ItemHandlerBasic cards = new ItemHandlerBasic(9 * 2, this, new ItemValidatorBasic(RSItems.SECURITY_CARD));
|
||||||
|
private ItemHandlerBasic editCard = new ItemHandlerBasic(1, this, new ItemValidatorBasic(RSItems.SECURITY_CARD));
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEnergyUsage() {
|
||||||
|
int usage = RS.INSTANCE.config.securityManagerUsage;
|
||||||
|
|
||||||
|
for (int i = 0; i < cards.getSlots(); ++i) {
|
||||||
|
if (!cards.getStackInSlot(i).isEmpty()) {
|
||||||
|
usage += RS.INSTANCE.config.securityManagerPerSecurityCardUsage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return usage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateNode() {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(NBTTagCompound tag) {
|
||||||
|
super.read(tag);
|
||||||
|
|
||||||
|
RSUtils.readItems(cards, 0, tag);
|
||||||
|
RSUtils.readItems(editCard, 1, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound write(NBTTagCompound tag) {
|
||||||
|
super.write(tag);
|
||||||
|
|
||||||
|
RSUtils.writeItems(cards, 0, tag);
|
||||||
|
RSUtils.writeItems(editCard, 1, tag);
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemHandlerBasic getCards() {
|
||||||
|
return cards;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemHandlerBasic getEditCard() {
|
||||||
|
return editCard;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,6 +56,8 @@ gui.refinedstorage:crafting_preview.loop=Loop in processing...
|
|||||||
gui.refinedstorage:crafting_preview.force_start=Press CTRL + SHIFT to start anyway
|
gui.refinedstorage:crafting_preview.force_start=Press CTRL + SHIFT to start anyway
|
||||||
gui.refinedstorage:reader=Reader
|
gui.refinedstorage:reader=Reader
|
||||||
gui.refinedstorage:writer=Writer
|
gui.refinedstorage:writer=Writer
|
||||||
|
gui.refinedstorage:security_manager=Security Manager
|
||||||
|
gui.refinedstorage:security_manager.configure=Configure
|
||||||
|
|
||||||
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
|
||||||
@@ -191,6 +193,7 @@ block.refinedstorage:fluid_storage.3.name=512k Fluid Storage Block
|
|||||||
block.refinedstorage:fluid_storage.4.name=Creative Fluid Storage Block
|
block.refinedstorage:fluid_storage.4.name=Creative Fluid Storage Block
|
||||||
block.refinedstorage:reader.name=Reader
|
block.refinedstorage:reader.name=Reader
|
||||||
block.refinedstorage:writer.name=Writer
|
block.refinedstorage:writer.name=Writer
|
||||||
|
block.refinedstorage:security_manager.name=Security Manager
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
BIN
src/main/resources/assets/refinedstorage/textures/gui/security_manager.png
Executable file
BIN
src/main/resources/assets/refinedstorage/textures/gui/security_manager.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Reference in New Issue
Block a user