15
CHANGELOG.md
15
CHANGELOG.md
@@ -4,13 +4,14 @@
|
||||
**Bugfixes**
|
||||
- Fixed clicking sound in Grid
|
||||
- Fixed a bunch of crashes
|
||||
- Fixed exporter not exporting is some cases
|
||||
- Fixed importer not importing in some cases
|
||||
- Fixed controller drawing RF every 20 ticks instead of every tick
|
||||
- Fixed Exporter not exporting is some cases
|
||||
- Fixed Importer not importing in some cases
|
||||
- Fixed Controller drawing RF every 20 ticks instead of every tick
|
||||
- Fixed not being able to shift click from Crafting Grid crafting slots
|
||||
- Fixed new items inserted after crafting in Grid being laggy
|
||||
- Fixed flickering of items in Grid
|
||||
- Fixed getting a stack of unstackable stuff from Grid
|
||||
- Fixed getting a stack of unstackable items from Grid
|
||||
- Fixed Cable not having a collision box
|
||||
- Check if the Constructor can actually place said block in the world
|
||||
|
||||
**Features**
|
||||
@@ -18,6 +19,8 @@
|
||||
- Updated to the latest Forge and JEI
|
||||
- Renamed Drives to Disk Drives
|
||||
- Renamed Storage Cells to Storage Disks
|
||||
- Removed Wireless Transmitters
|
||||
- Wireless Grid is now bound to a Controller instead of a Grid
|
||||
- Drives have a better interface and there are now blacklist and whitelist filters for the Storage Disks in it too.
|
||||
- Destructors have the ability to whitelist and blacklist certain items now
|
||||
- Shift clicking stuff in the Interface
|
||||
@@ -29,6 +32,10 @@
|
||||
- Made the amount text in the Grid for items smaller
|
||||
- Nice formatting for items >= 1K (pressing shift while hovering over an item will still display the real item count)
|
||||
- When placing Importer, Exporter or External Storage with SHIFT, it will have the opposite direction. This is for easy placement behind other blocks (furnaces for example)
|
||||
- Added mass crafting of items with shift in Crafting Grid
|
||||
- Added JEI recipe transfering in Crafting Grid
|
||||
- Grid can synchronize with JEI
|
||||
- Side buttons in machine GUIs are now left, not right
|
||||
|
||||
### 0.4.1
|
||||
**Bugfixes**
|
||||
|
||||
12
build.gradle
12
build.gradle
@@ -17,20 +17,20 @@ group = "refinedstorage"
|
||||
archivesBaseName = "refinedstorage"
|
||||
|
||||
minecraft {
|
||||
version = "1.9-12.16.0.1811-1.9"
|
||||
version = "1.9-12.16.0.1826-1.9"
|
||||
runDir = "run"
|
||||
useDepAts = true
|
||||
mappings = "snapshot_20160312"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
maven {
|
||||
url "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile "mezz.jei:jei_1.9:3.1.+"
|
||||
deobfCompile "mezz.jei:jei_1.9:3.2.+"
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -40,7 +40,7 @@ processResources {
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
expand 'version': project.version, 'mcversion': project.minecraft.version
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
|
||||
@@ -13,4 +13,5 @@ public final class RefinedStorageGui {
|
||||
public static final int STORAGE = 11;
|
||||
public static final int RELAY = 12;
|
||||
public static final int INTERFACE = 13;
|
||||
public static final int WIRELESS_GRID = 14;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -16,6 +17,7 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.item.ItemBlockBase;
|
||||
import refinedstorage.tile.TileBase;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
@@ -30,6 +32,7 @@ public abstract class BlockBase extends Block {
|
||||
this.name = name;
|
||||
|
||||
setHardness(0.6F);
|
||||
setRegistryName(RefinedStorage.ID, name);
|
||||
setCreativeTab(RefinedStorage.TAB);
|
||||
}
|
||||
|
||||
@@ -40,10 +43,9 @@ public abstract class BlockBase extends Block {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
DIRECTION,
|
||||
});
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,4 +126,8 @@ public abstract class BlockBase extends Block {
|
||||
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
public Item createItemForBlock() {
|
||||
return new ItemBlockBase(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,15 @@ import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.tile.TileController;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.tile.TileMachine;
|
||||
|
||||
public class BlockCable extends BlockBase {
|
||||
public static final AxisAlignedBB CABLE_AABB = new AxisAlignedBB(4 * (1F / 16F), 4 * (1F / 16F), 4 * (1F / 16F), 1 - 4 * (1F / 16F), 1 - 4 * (1F / 16F), 1 - 4 * (1F / 16F));
|
||||
|
||||
public static final PropertyBool NORTH = PropertyBool.create("north");
|
||||
public static final PropertyBool EAST = PropertyBool.create("east");
|
||||
public static final PropertyBool SOUTH = PropertyBool.create("south");
|
||||
@@ -27,16 +27,15 @@ public class BlockCable extends BlockBase {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
DIRECTION,
|
||||
NORTH,
|
||||
EAST,
|
||||
SOUTH,
|
||||
WEST,
|
||||
UP,
|
||||
DOWN,
|
||||
});
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
NORTH,
|
||||
EAST,
|
||||
SOUTH,
|
||||
WEST,
|
||||
UP,
|
||||
DOWN,
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,25 +52,12 @@ public class BlockCable extends BlockBase {
|
||||
public static boolean hasConnectionWith(IBlockAccess world, BlockPos pos) {
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
|
||||
if (block instanceof BlockCable) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
return tile instanceof TileMachine || tile instanceof TileController;
|
||||
return (block == RefinedStorageBlocks.CABLE || block == RefinedStorageBlocks.CONTROLLER) || world.getTileEntity(pos) instanceof TileMachine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
float pixel = 1F / 16F;
|
||||
|
||||
return new AxisAlignedBB(4 * pixel, 4 * pixel, 4 * pixel, 1 - 4 * pixel, 1 - 4 * pixel, 1 - 4 * pixel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World world, BlockPos pos) {
|
||||
return getBoundingBox(state, world, pos);
|
||||
return CABLE_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageGui;
|
||||
import refinedstorage.item.ItemBlockBase;
|
||||
import refinedstorage.tile.TileController;
|
||||
|
||||
import java.util.List;
|
||||
@@ -38,12 +39,11 @@ public class BlockController extends BlockBase {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
DIRECTION,
|
||||
TYPE,
|
||||
ENERGY
|
||||
});
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
TYPE,
|
||||
ENERGY
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,4 +97,9 @@ public class BlockController extends BlockBase {
|
||||
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
|
||||
return ((TileController) world.getTileEntity(pos)).getEnergyScaled(15);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item createItemForBlock() {
|
||||
return new ItemBlockBase(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,12 +25,11 @@ public class BlockDetector extends BlockMachine {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
DIRECTION,
|
||||
CONNECTED,
|
||||
POWERED
|
||||
});
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
CONNECTED,
|
||||
POWERED
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageGui;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
import refinedstorage.item.ItemBlockBase;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -40,12 +41,11 @@ public class BlockGrid extends BlockMachine {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
DIRECTION,
|
||||
CONNECTED,
|
||||
TYPE
|
||||
});
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
CONNECTED,
|
||||
TYPE
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,4 +66,9 @@ public class BlockGrid extends BlockMachine {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item createItemForBlock() {
|
||||
return new ItemBlockBase(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,10 @@ public abstract class BlockMachine extends BlockBase {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
DIRECTION,
|
||||
CONNECTED
|
||||
});
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
CONNECTED
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,19 +34,18 @@ public class BlockStorage extends BlockMachine {
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List subItems) {
|
||||
for (int i = 0; i <= 4; i++) {
|
||||
for (int i = 0; i <= 4; ++i) {
|
||||
subItems.add(ItemBlockStorage.initNBT(new ItemStack(item, 1, i)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
DIRECTION,
|
||||
CONNECTED,
|
||||
TYPE
|
||||
});
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
CONNECTED,
|
||||
TYPE
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,9 +90,7 @@ public class BlockStorage extends BlockMachine {
|
||||
ItemStack stack = new ItemStack(RefinedStorageBlocks.STORAGE, 1, RefinedStorageBlocks.STORAGE.getMetaFromState(state));
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
tag.setTag(TileStorage.NBT_STORAGE, ((TileStorage) world.getTileEntity(pos)).getStorageTag());
|
||||
|
||||
stack.setTagCompound(tag);
|
||||
|
||||
drops.add(stack);
|
||||
@@ -116,4 +113,9 @@ public class BlockStorage extends BlockMachine {
|
||||
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item createItemForBlock() {
|
||||
return new ItemBlockStorage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,5 +27,4 @@ public enum EnumGridType implements IStringSerializable {
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ public enum EnumStorageType implements IStringSerializable {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return TYPE_1K;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,10 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.container.slot.SlotGridCraftingResult;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
import refinedstorage.tile.TileController;
|
||||
import refinedstorage.tile.grid.IGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
import refinedstorage.tile.grid.WirelessGrid;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -14,9 +17,9 @@ import java.util.List;
|
||||
public class ContainerGrid extends ContainerBase {
|
||||
private List<Slot> craftingSlots = new ArrayList<Slot>();
|
||||
|
||||
private TileGrid grid;
|
||||
private IGrid grid;
|
||||
|
||||
public ContainerGrid(EntityPlayer player, TileGrid grid) {
|
||||
public ContainerGrid(EntityPlayer player, IGrid grid) {
|
||||
super(player);
|
||||
|
||||
this.grid = grid;
|
||||
@@ -28,7 +31,7 @@ public class ContainerGrid extends ContainerBase {
|
||||
int y = 106;
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
Slot slot = new Slot(grid.getCraftingInventory(), i, x, y);
|
||||
Slot slot = new Slot(((TileGrid) grid).getCraftingInventory(), i, x, y);
|
||||
|
||||
craftingSlots.add(slot);
|
||||
|
||||
@@ -42,23 +45,23 @@ public class ContainerGrid extends ContainerBase {
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotGridCraftingResult(this, player, grid.getCraftingInventory(), grid.getCraftingResultInventory(), grid, 0, 133 + 4, 120 + 4));
|
||||
addSlotToContainer(new SlotGridCraftingResult(this, player, ((TileGrid) grid).getCraftingInventory(), ((TileGrid) grid).getCraftingResultInventory(), (TileGrid) grid, 0, 133 + 4, 120 + 4));
|
||||
}
|
||||
}
|
||||
|
||||
public TileGrid getGrid() {
|
||||
return grid;
|
||||
return (TileGrid) grid;
|
||||
}
|
||||
|
||||
public List<Slot> getCraftingSlots() {
|
||||
return craftingSlots;
|
||||
}
|
||||
|
||||
// I'm overriding detectAndSendChanges() here because the default check
|
||||
// checks if the item stacks are equal, and if so, then it will only send the new slot contents.
|
||||
// The thing is though, when the grid replaces the slots with new items from the storage
|
||||
// system, the item stack replaced WILL be the same and thus changes will not be sent!
|
||||
// That is why we override here to get rid of the check and ALWAYS send slot changes.
|
||||
/* I'm overriding detectAndSendChanges() here because the default check
|
||||
checks if the item stacks are equal, and if so, then it will only send the new slot contents.
|
||||
The thing is though, when the grid replaces the slots with new items from the storage
|
||||
system, the item stack replaced WILL be the same and thus changes will not be sent!
|
||||
That is why we override here to get rid of the check and ALWAYS send slot changes. */
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
for (int i = 0; i < this.inventorySlots.size(); ++i) {
|
||||
@@ -73,4 +76,13 @@ public class ContainerGrid extends ContainerBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
|
||||
if (grid instanceof WirelessGrid && ((WirelessGrid) grid).getBoundTile() instanceof TileController) {
|
||||
grid.getController().onCloseWirelessGrid(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import refinedstorage.container.ContainerGrid;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class SlotGridCraftingResult extends SlotCrafting {
|
||||
private ContainerGrid container;
|
||||
|
||||
@@ -24,6 +24,7 @@ public abstract class GuiBase extends GuiContainer {
|
||||
|
||||
private int lastButtonId = 0;
|
||||
private int lastSideButtonY = 6;
|
||||
private String sideButtonTooltip;
|
||||
|
||||
protected int width;
|
||||
protected int height;
|
||||
@@ -78,17 +79,21 @@ public abstract class GuiBase extends GuiContainer {
|
||||
mouseX -= guiLeft;
|
||||
mouseY -= guiTop;
|
||||
|
||||
sideButtonTooltip = null;
|
||||
|
||||
for (SideButton sideButton : sideButtons) {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
sideButton.draw(this, sideButton.getX() + 2, sideButton.getY() + 1);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
if (inBounds(sideButton.getX(), sideButton.getY(), SIDE_BUTTON_WIDTH, SIDE_BUTTON_HEIGHT, mouseX, mouseY)) {
|
||||
drawTooltip(mouseX, mouseY, sideButton.getTooltip(this));
|
||||
sideButtonTooltip = sideButton.getTooltip(this);
|
||||
}
|
||||
}
|
||||
|
||||
drawForeground(mouseX, mouseY);
|
||||
|
||||
if (sideButtonTooltip != null) {
|
||||
drawTooltip(mouseX, mouseY, sideButtonTooltip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,7 +120,7 @@ public abstract class GuiBase extends GuiContainer {
|
||||
}
|
||||
|
||||
public void addSideButton(SideButton button) {
|
||||
button.setX(xSize - 1);
|
||||
button.setX(-SIDE_BUTTON_WIDTH + 1);
|
||||
button.setY(lastSideButtonY);
|
||||
button.setId(addButton(guiLeft + button.getX(), guiTop + button.getY(), SIDE_BUTTON_WIDTH, SIDE_BUTTON_HEIGHT).id);
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class GuiController extends GuiBase {
|
||||
TileMachine machineHovering = null;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (slot < machines.size()) {
|
||||
if (slot < machines.size() && machines.get(slot) != null && machines.get(slot).getWorld() != null) {
|
||||
TileMachine machine = machines.get(slot);
|
||||
IBlockState machineState = machine.getWorld().getBlockState(machine.getPos());
|
||||
Block machineBlock = machineState.getBlock();
|
||||
@@ -119,7 +119,10 @@ public class GuiController extends GuiBase {
|
||||
}
|
||||
|
||||
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY)) {
|
||||
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:energy_usage", controller.getEnergyUsage()) + "\n" + t("misc.refinedstorage:energy_stored", controller.getEnergyStored(null), controller.getMaxEnergyStored(null)));
|
||||
String message = t("misc.refinedstorage:energy_usage", controller.isActiveClientSide() ? controller.getEnergyUsage() : 0);
|
||||
message += "\n" + t("misc.refinedstorage:energy_stored", controller.getEnergyStored(null), controller.getMaxEnergyStored(null));
|
||||
|
||||
drawTooltip(mouseX, mouseY, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,25 +10,29 @@ import net.minecraft.inventory.Slot;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.container.ContainerGrid;
|
||||
import refinedstorage.gui.sidebutton.SideButtonGridSearchBoxMode;
|
||||
import refinedstorage.gui.sidebutton.SideButtonGridSortingDirection;
|
||||
import refinedstorage.gui.sidebutton.SideButtonGridSortingType;
|
||||
import refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||
import refinedstorage.jei.PluginRefinedStorage;
|
||||
import refinedstorage.network.MessageGridCraftingClear;
|
||||
import refinedstorage.network.MessageGridCraftingPush;
|
||||
import refinedstorage.network.MessageStoragePull;
|
||||
import refinedstorage.network.MessageStoragePush;
|
||||
import refinedstorage.storage.StorageItem;
|
||||
import refinedstorage.storage.ItemGroup;
|
||||
import refinedstorage.tile.TileController;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
import refinedstorage.tile.grid.IGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
import refinedstorage.tile.grid.WirelessGrid;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class GuiGrid extends GuiBase {
|
||||
private ContainerGrid container;
|
||||
private TileGrid grid;
|
||||
private IGrid grid;
|
||||
|
||||
private List<StorageItem> items = new ArrayList<StorageItem>();
|
||||
private List<ItemGroup> items = new ArrayList<ItemGroup>();
|
||||
|
||||
private GuiTextField searchField;
|
||||
|
||||
@@ -37,7 +41,7 @@ public class GuiGrid extends GuiBase {
|
||||
|
||||
private Scrollbar scrollbar;
|
||||
|
||||
public GuiGrid(ContainerGrid container, TileGrid grid) {
|
||||
public GuiGrid(ContainerGrid container, IGrid grid) {
|
||||
super(container, 193, grid.getType() == EnumGridType.CRAFTING ? 256 : 208);
|
||||
|
||||
this.container = container;
|
||||
@@ -47,11 +51,17 @@ public class GuiGrid extends GuiBase {
|
||||
|
||||
@Override
|
||||
public void init(int x, int y) {
|
||||
addSideButton(new SideButtonRedstoneMode(grid));
|
||||
if (grid.getRedstoneModeSetting() != null) {
|
||||
addSideButton(new SideButtonRedstoneMode(grid.getRedstoneModeSetting()));
|
||||
}
|
||||
|
||||
addSideButton(new SideButtonGridSortingDirection(grid));
|
||||
addSideButton(new SideButtonGridSortingType(grid));
|
||||
|
||||
if (PluginRefinedStorage.isJeiLoaded()) {
|
||||
addSideButton(new SideButtonGridSearchBoxMode(grid));
|
||||
}
|
||||
|
||||
searchField = new GuiTextField(0, fontRendererObj, x + 80 + 1, y + 6 + 1, 88 - 6, fontRendererObj.FONT_HEIGHT);
|
||||
searchField.setEnableBackgroundDrawing(false);
|
||||
searchField.setVisible(true);
|
||||
@@ -65,42 +75,42 @@ public class GuiGrid extends GuiBase {
|
||||
items.clear();
|
||||
|
||||
if (grid.isConnected()) {
|
||||
items.addAll(grid.getController().getItems());
|
||||
items.addAll(grid.getController().getItemGroups());
|
||||
|
||||
if (!searchField.getText().trim().isEmpty()) {
|
||||
Iterator<StorageItem> t = items.iterator();
|
||||
Iterator<ItemGroup> t = items.iterator();
|
||||
|
||||
while (t.hasNext()) {
|
||||
StorageItem item = t.next();
|
||||
ItemGroup group = t.next();
|
||||
|
||||
if (!item.toItemStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) {
|
||||
if (!group.toItemStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) {
|
||||
t.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(items, new Comparator<StorageItem>() {
|
||||
Collections.sort(items, new Comparator<ItemGroup>() {
|
||||
@Override
|
||||
public int compare(StorageItem o1, StorageItem o2) {
|
||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||
return o2.toItemStack().getDisplayName().compareTo(o1.toItemStack().getDisplayName());
|
||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||
return o1.toItemStack().getDisplayName().compareTo(o2.toItemStack().getDisplayName());
|
||||
}
|
||||
public int compare(ItemGroup left, ItemGroup right) {
|
||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||
return right.toItemStack().getDisplayName().compareTo(left.toItemStack().getDisplayName());
|
||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||
return left.toItemStack().getDisplayName().compareTo(right.toItemStack().getDisplayName());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
if (grid.getSortingType() == TileGrid.SORTING_TYPE_QUANTITY) {
|
||||
Collections.sort(items, new Comparator<StorageItem>() {
|
||||
Collections.sort(items, new Comparator<ItemGroup>() {
|
||||
@Override
|
||||
public int compare(StorageItem o1, StorageItem o2) {
|
||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||
return Integer.valueOf(o2.getQuantity()).compareTo(o1.getQuantity());
|
||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||
return Integer.valueOf(o1.getQuantity()).compareTo(o2.getQuantity());
|
||||
}
|
||||
public int compare(ItemGroup left, ItemGroup right) {
|
||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||
return Integer.valueOf(right.getQuantity()).compareTo(left.getQuantity());
|
||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||
return Integer.valueOf(left.getQuantity()).compareTo(right.getQuantity());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -156,7 +166,7 @@ public class GuiGrid extends GuiBase {
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
scrollbar.update(this, mouseX, mouseY);
|
||||
|
||||
drawString(7, 7, t("gui.refinedstorage:grid"));
|
||||
drawString(7, 7, t(grid instanceof WirelessGrid ? "gui.refinedstorage:wireless_grid" : "gui.refinedstorage:grid"));
|
||||
|
||||
if (grid.getType() == EnumGridType.CRAFTING) {
|
||||
drawString(7, 94, t("container.crafting"));
|
||||
@@ -178,7 +188,7 @@ public class GuiGrid extends GuiBase {
|
||||
hoveringSlot = slot;
|
||||
|
||||
if (slot < items.size()) {
|
||||
// We need to use the ID, because if we filter, the client-side index will change
|
||||
// we need to use the ID, because if we filter, the client-side index will change
|
||||
// while the server-side's index will still be the same.
|
||||
hoveringItemId = items.get(slot).getId();
|
||||
}
|
||||
@@ -251,13 +261,23 @@ public class GuiGrid extends GuiBase {
|
||||
if (isHoveringOverSlot() && container.getPlayer().inventory.getItemStack() != null && (clickedButton == 0 || clickedButton == 1)) {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageStoragePush(controller.getPos().getX(), controller.getPos().getY(), controller.getPos().getZ(), -1, clickedButton == 1));
|
||||
} else if (isHoveringOverItemInSlot() && container.getPlayer().inventory.getItemStack() == null) {
|
||||
boolean half = clickedButton == 1;
|
||||
boolean shift = GuiScreen.isShiftKeyDown();
|
||||
boolean one = clickedButton == 2;
|
||||
int flags = 0;
|
||||
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageStoragePull(controller.getPos().getX(), controller.getPos().getY(), controller.getPos().getZ(), hoveringItemId, half, one, shift));
|
||||
if (clickedButton == 1) {
|
||||
flags |= MessageStoragePull.PULL_HALF;
|
||||
}
|
||||
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
flags |= MessageStoragePull.PULL_SHIFT;
|
||||
}
|
||||
|
||||
if (clickedButton == 2) {
|
||||
flags |= MessageStoragePull.PULL_ONE;
|
||||
}
|
||||
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageStoragePull(controller.getPos().getX(), controller.getPos().getY(), controller.getPos().getZ(), hoveringItemId, flags));
|
||||
} else if (clickedClear) {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridCraftingClear(grid));
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridCraftingClear((TileGrid) grid));
|
||||
} else {
|
||||
for (Slot slot : container.getPlayerInventorySlots()) {
|
||||
if (inBounds(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX - guiLeft, mouseY - guiTop)) {
|
||||
@@ -271,7 +291,7 @@ public class GuiGrid extends GuiBase {
|
||||
for (Slot slot : container.getCraftingSlots()) {
|
||||
if (inBounds(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX - guiLeft, mouseY - guiTop)) {
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridCraftingPush(grid, slot.getSlotIndex()));
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridCraftingPush((TileGrid) grid, slot.getSlotIndex()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,6 +307,9 @@ public class GuiGrid extends GuiBase {
|
||||
@Override
|
||||
protected void keyTyped(char character, int keyCode) throws IOException {
|
||||
if (!checkHotbarKeys(keyCode) && searchField.textboxKeyTyped(character, keyCode)) {
|
||||
if (PluginRefinedStorage.isJeiLoaded() && grid.getSearchBoxMode() == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED) {
|
||||
PluginRefinedStorage.INSTANCE.getRuntime().getItemListOverlay().setFilterText(searchField.getText());
|
||||
}
|
||||
} else {
|
||||
super.keyTyped(character, keyCode);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ import refinedstorage.RefinedStorageGui;
|
||||
import refinedstorage.container.*;
|
||||
import refinedstorage.storage.IStorageGui;
|
||||
import refinedstorage.tile.*;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
import refinedstorage.tile.grid.WirelessGrid;
|
||||
import refinedstorage.util.HandUtils;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
private Container getContainer(int ID, EntityPlayer player, TileEntity tile) {
|
||||
@@ -45,9 +48,29 @@ public class GuiHandler implements IGuiHandler {
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (ID == RefinedStorageGui.WIRELESS_GRID) {
|
||||
return getWirelessGridContainer(world, player, x);
|
||||
}
|
||||
|
||||
return getContainer(ID, player, world.getTileEntity(new BlockPos(x, y, z)));
|
||||
}
|
||||
|
||||
private WirelessGrid getWirelessGrid(World world, EntityPlayer player, int hand) {
|
||||
return new WirelessGrid(player.getHeldItem(HandUtils.getHandById(hand)), HandUtils.getHandById(hand), world);
|
||||
}
|
||||
|
||||
private ContainerGrid getWirelessGridContainer(World world, EntityPlayer player, int hand) {
|
||||
WirelessGrid wirelessGrid = getWirelessGrid(world, player, hand);
|
||||
|
||||
return new ContainerGrid(player, wirelessGrid);
|
||||
}
|
||||
|
||||
private GuiGrid getWirelessGridGui(World world, EntityPlayer player, int hand) {
|
||||
WirelessGrid wirelessGrid = getWirelessGrid(world, player, hand);
|
||||
|
||||
return new GuiGrid(new ContainerGrid(player, wirelessGrid), wirelessGrid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
|
||||
@@ -57,6 +80,8 @@ public class GuiHandler implements IGuiHandler {
|
||||
return new GuiController((ContainerController) getContainer(ID, player, tile), (TileController) tile);
|
||||
case RefinedStorageGui.GRID:
|
||||
return new GuiGrid((ContainerGrid) getContainer(ID, player, tile), (TileGrid) tile);
|
||||
case RefinedStorageGui.WIRELESS_GRID:
|
||||
return getWirelessGridGui(world, player, x);
|
||||
case RefinedStorageGui.DISK_DRIVE:
|
||||
return new GuiStorage((ContainerStorage) getContainer(ID, player, tile), (IStorageGui) tile, "gui/disk_drive.png");
|
||||
case RefinedStorageGui.IMPORTER:
|
||||
|
||||
@@ -35,17 +35,17 @@ public class GuiStorage extends GuiBase {
|
||||
|
||||
@Override
|
||||
public void init(int x, int y) {
|
||||
if (gui.getRedstoneModeSetting() != null) {
|
||||
addSideButton(new SideButtonRedstoneMode(gui.getRedstoneModeSetting()));
|
||||
if (gui.getRedstoneModeConfig() != null) {
|
||||
addSideButton(new SideButtonRedstoneMode(gui.getRedstoneModeConfig()));
|
||||
}
|
||||
|
||||
if (gui.getModeSetting() != null) {
|
||||
addSideButton(new SideButtonMode(gui.getModeSetting()));
|
||||
if (gui.getModeConfig() != null) {
|
||||
addSideButton(new SideButtonMode(gui.getModeConfig()));
|
||||
}
|
||||
|
||||
if (gui.getCompareSetting() != null) {
|
||||
addSideButton(new SideButtonCompare(gui.getCompareSetting(), InventoryUtils.COMPARE_DAMAGE));
|
||||
addSideButton(new SideButtonCompare(gui.getCompareSetting(), InventoryUtils.COMPARE_NBT));
|
||||
if (gui.getCompareConfig() != null) {
|
||||
addSideButton(new SideButtonCompare(gui.getCompareConfig(), InventoryUtils.COMPARE_DAMAGE));
|
||||
addSideButton(new SideButtonCompare(gui.getCompareConfig(), InventoryUtils.COMPARE_NBT));
|
||||
}
|
||||
|
||||
priorityField = new GuiTextField(0, fontRendererObj, x + 98 + 1, y + 54 + 1, 25, fontRendererObj.FONT_HEIGHT);
|
||||
|
||||
@@ -4,31 +4,29 @@ import net.minecraft.util.text.TextFormatting;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.gui.GuiBase;
|
||||
import refinedstorage.network.MessageCompareUpdate;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class SideButtonCompare extends SideButton {
|
||||
private ICompareSetting setting;
|
||||
private ICompareConfig config;
|
||||
private int mask;
|
||||
|
||||
public SideButtonCompare(ICompareSetting setting, int mask) {
|
||||
this.setting = setting;
|
||||
public SideButtonCompare(ICompareConfig config, int mask) {
|
||||
this.config = config;
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip(GuiBase gui) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String tooltip = TextFormatting.YELLOW + gui.t("sidebutton.refinedstorage:compare." + mask) + TextFormatting.RESET + "\n";
|
||||
|
||||
builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:compare." + mask)).append(TextFormatting.RESET).append("\n");
|
||||
|
||||
if ((setting.getCompare() & mask) == mask) {
|
||||
builder.append(gui.t("misc.refinedstorage:yes"));
|
||||
if ((config.getCompare() & mask) == mask) {
|
||||
tooltip += gui.t("misc.refinedstorage:yes");
|
||||
} else {
|
||||
builder.append(gui.t("misc.refinedstorage:no"));
|
||||
tooltip += gui.t("misc.refinedstorage:no");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,13 +41,13 @@ public class SideButtonCompare extends SideButton {
|
||||
ty = 48;
|
||||
}
|
||||
|
||||
int tx = (setting.getCompare() & mask) == mask ? 0 : 16;
|
||||
int tx = (config.getCompare() & mask) == mask ? 0 : 16;
|
||||
|
||||
gui.drawTexture(x, y + 2, tx, ty, 16, 16);
|
||||
gui.drawTexture(x, y + 1, tx, ty, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageCompareUpdate(setting, setting.getCompare() ^ mask));
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageCompareUpdate(config, config.getCompare() ^ mask));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,7 @@ public class SideButtonDetectorMode extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip(GuiBase gui) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(TextFormatting.GREEN).append(gui.t("sidebutton.refinedstorage:detector.mode")).append(TextFormatting.RESET).append("\n");
|
||||
builder.append(gui.t("sidebutton.refinedstorage:detector.mode." + detector.getMode()));
|
||||
|
||||
return builder.toString();
|
||||
return TextFormatting.GREEN + gui.t("sidebutton.refinedstorage:detector.mode") + TextFormatting.RESET + "\n" + gui.t("sidebutton.refinedstorage:detector.mode." + detector.getMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
38
src/main/java/refinedstorage/gui/sidebutton/SideButtonGridSearchBoxMode.java
Executable file
38
src/main/java/refinedstorage/gui/sidebutton/SideButtonGridSearchBoxMode.java
Executable file
@@ -0,0 +1,38 @@
|
||||
package refinedstorage.gui.sidebutton;
|
||||
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import refinedstorage.gui.GuiBase;
|
||||
import refinedstorage.tile.grid.IGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class SideButtonGridSearchBoxMode extends SideButton {
|
||||
private IGrid grid;
|
||||
|
||||
public SideButtonGridSearchBoxMode(IGrid grid) {
|
||||
this.grid = grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip(GuiBase gui) {
|
||||
return TextFormatting.YELLOW + gui.t("sidebutton.refinedstorage:grid.search_box_mode") + TextFormatting.RESET + "\n" + gui.t("sidebutton.refinedstorage:grid.search_box_mode." + grid.getSearchBoxMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui, int x, int y) {
|
||||
gui.bindTexture("icons.png");
|
||||
gui.drawTexture(x, y + 2 - 1, 0, 96, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
int mode = grid.getSearchBoxMode();
|
||||
|
||||
if (mode == TileGrid.SEARCH_BOX_MODE_NORMAL) {
|
||||
mode = TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED;
|
||||
} else if (mode == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED) {
|
||||
mode = TileGrid.SEARCH_BOX_MODE_NORMAL;
|
||||
}
|
||||
|
||||
grid.onSearchBoxModeChanged(mode);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,20 @@
|
||||
package refinedstorage.gui.sidebutton;
|
||||
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.gui.GuiBase;
|
||||
import refinedstorage.network.MessageGridSortingUpdate;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
import refinedstorage.tile.grid.IGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class SideButtonGridSortingDirection extends SideButton {
|
||||
private TileGrid grid;
|
||||
private IGrid grid;
|
||||
|
||||
public SideButtonGridSortingDirection(TileGrid grid) {
|
||||
public SideButtonGridSortingDirection(IGrid grid) {
|
||||
this.grid = grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip(GuiBase gui) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:sorting.direction")).append(TextFormatting.RESET).append("\n");
|
||||
builder.append(gui.t("sidebutton.refinedstorage:sorting.direction." + grid.getSortingDirection()));
|
||||
|
||||
return builder.toString();
|
||||
return TextFormatting.YELLOW + gui.t("sidebutton.refinedstorage:grid.sorting.direction") + TextFormatting.RESET + "\n" + gui.t("sidebutton.refinedstorage:grid.sorting.direction." + grid.getSortingDirection());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,6 +33,6 @@ public class SideButtonGridSortingDirection extends SideButton {
|
||||
dir = TileGrid.SORTING_DIRECTION_ASCENDING;
|
||||
}
|
||||
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridSortingUpdate(grid, dir, grid.getSortingType()));
|
||||
grid.onSortingDirectionChanged(dir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
package refinedstorage.gui.sidebutton;
|
||||
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.gui.GuiBase;
|
||||
import refinedstorage.network.MessageGridSortingUpdate;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
import refinedstorage.tile.grid.IGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class SideButtonGridSortingType extends SideButton {
|
||||
private TileGrid grid;
|
||||
private IGrid grid;
|
||||
|
||||
public SideButtonGridSortingType(TileGrid grid) {
|
||||
public SideButtonGridSortingType(IGrid grid) {
|
||||
this.grid = grid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip(GuiBase gui) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:sorting.type")).append(TextFormatting.RESET).append("\n");
|
||||
builder.append(gui.t("sidebutton.refinedstorage:sorting.type." + grid.getSortingType()));
|
||||
|
||||
return builder.toString();
|
||||
return TextFormatting.YELLOW + gui.t("sidebutton.refinedstorage:grid.sorting.type") + TextFormatting.RESET + "\n" + gui.t("sidebutton.refinedstorage:grid.sorting.type." + grid.getSortingType());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,6 +33,6 @@ public class SideButtonGridSortingType extends SideButton {
|
||||
type = TileGrid.SORTING_TYPE_QUANTITY;
|
||||
}
|
||||
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridSortingUpdate(grid, grid.getSortingDirection(), type));
|
||||
grid.onSortingTypeChanged(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,23 +4,18 @@ import net.minecraft.util.text.TextFormatting;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.gui.GuiBase;
|
||||
import refinedstorage.network.MessageModeToggle;
|
||||
import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.config.IModeConfig;
|
||||
|
||||
public class SideButtonMode extends SideButton {
|
||||
private IModeSetting mode;
|
||||
private IModeConfig config;
|
||||
|
||||
public SideButtonMode(IModeSetting mode) {
|
||||
this.mode = mode;
|
||||
public SideButtonMode(IModeConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip(GuiBase gui) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(TextFormatting.GREEN).append(gui.t("sidebutton.refinedstorage:mode")).append(TextFormatting.RESET).append("\n");
|
||||
builder.append(gui.t("sidebutton.refinedstorage:mode." + (mode.isWhitelist() ? "whitelist" : "blacklist")));
|
||||
|
||||
return builder.toString();
|
||||
return TextFormatting.GREEN + gui.t("sidebutton.refinedstorage:mode") + TextFormatting.RESET + "\n" + gui.t("sidebutton.refinedstorage:mode." + (config.isWhitelist() ? "whitelist" : "blacklist"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,9 +24,9 @@ public class SideButtonMode extends SideButton {
|
||||
|
||||
int tx = 0;
|
||||
|
||||
if (mode.isWhitelist()) {
|
||||
if (config.isWhitelist()) {
|
||||
tx = 0;
|
||||
} else if (mode.isBlacklist()) {
|
||||
} else if (config.isBlacklist()) {
|
||||
tx = 16;
|
||||
}
|
||||
|
||||
@@ -40,6 +35,6 @@ public class SideButtonMode extends SideButton {
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageModeToggle(mode));
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageModeToggle(config));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,33 +4,28 @@ import net.minecraft.util.text.TextFormatting;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.gui.GuiBase;
|
||||
import refinedstorage.network.MessageRedstoneModeUpdate;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
|
||||
public class SideButtonRedstoneMode extends SideButton {
|
||||
private IRedstoneModeSetting setting;
|
||||
private IRedstoneModeConfig config;
|
||||
|
||||
public SideButtonRedstoneMode(IRedstoneModeSetting setting) {
|
||||
this.setting = setting;
|
||||
public SideButtonRedstoneMode(IRedstoneModeConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip(GuiBase gui) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append(TextFormatting.RED).append(gui.t("sidebutton.refinedstorage:redstone_mode")).append(TextFormatting.RESET).append("\n");
|
||||
builder.append(gui.t("sidebutton.refinedstorage:redstone_mode." + setting.getRedstoneMode().id));
|
||||
|
||||
return builder.toString();
|
||||
return TextFormatting.RED + gui.t("sidebutton.refinedstorage:redstone_mode") + TextFormatting.RESET + "\n" + gui.t("sidebutton.refinedstorage:redstone_mode." + config.getRedstoneMode().id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui, int x, int y) {
|
||||
gui.bindTexture("icons.png");
|
||||
gui.drawTexture(x, y + 1, setting.getRedstoneMode().id * 16, 0, 16, 16);
|
||||
gui.drawTexture(x, y + 1, config.getRedstoneMode().id * 16, 0, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageRedstoneModeUpdate(setting));
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageRedstoneModeUpdate(config));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ public abstract class ItemBase extends Item {
|
||||
public ItemBase(String name) {
|
||||
this.name = name;
|
||||
|
||||
setRegistryName(RefinedStorage.ID, name);
|
||||
setCreativeTab(RefinedStorage.TAB);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,32 @@
|
||||
package refinedstorage.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemColored;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class ItemBlockBase extends ItemColored {
|
||||
public ItemBlockBase(Block block) {
|
||||
super(block, true);
|
||||
public class ItemBlockBase extends ItemBlock {
|
||||
public ItemBlockBase(Block block, boolean subtypes) {
|
||||
super(block);
|
||||
|
||||
setRegistryName(block.getRegistryName());
|
||||
|
||||
if (subtypes) {
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return getUnlocalizedName() + "." + stack.getItemDamage();
|
||||
if (getHasSubtypes()) {
|
||||
return getUnlocalizedName() + "." + stack.getItemDamage();
|
||||
}
|
||||
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package refinedstorage.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class ItemBlockController extends ItemBlockBase {
|
||||
public ItemBlockController(Block block) {
|
||||
super(block);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package refinedstorage.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class ItemBlockGrid extends ItemBlockBase {
|
||||
public ItemBlockGrid(Block block) {
|
||||
super(block);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package refinedstorage.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.block.EnumStorageType;
|
||||
import refinedstorage.storage.NBTStorage;
|
||||
import refinedstorage.tile.TileStorage;
|
||||
@@ -13,8 +13,8 @@ import refinedstorage.tile.TileStorage;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBlockStorage extends ItemBlockBase {
|
||||
public ItemBlockStorage(Block block) {
|
||||
super(block);
|
||||
public ItemBlockStorage() {
|
||||
super(RefinedStorageBlocks.STORAGE, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,11 +41,8 @@ public class ItemBlockStorage extends ItemBlockBase {
|
||||
|
||||
public static ItemStack initNBT(ItemStack stack) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
tag.setTag(TileStorage.NBT_STORAGE, NBTStorage.getBaseNBT());
|
||||
|
||||
stack.setTagCompound(tag);
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.storage.DiskStorage;
|
||||
import refinedstorage.block.EnumStorageType;
|
||||
import refinedstorage.storage.NBTStorage;
|
||||
|
||||
import java.util.List;
|
||||
@@ -35,10 +35,12 @@ public class ItemStorageDisk extends ItemBase {
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack disk, EntityPlayer player, List list, boolean b) {
|
||||
if (DiskStorage.getCapacity(disk) == -1) {
|
||||
int capacity = EnumStorageType.getById(disk.getItemDamage()).getCapacity();
|
||||
|
||||
if (capacity == -1) {
|
||||
list.add(String.format(I18n.translateToLocal("misc.refinedstorage:storage.stored"), NBTStorage.getStored(disk.getTagCompound())));
|
||||
} else {
|
||||
list.add(String.format(I18n.translateToLocal("misc.refinedstorage:storage.stored_capacity"), NBTStorage.getStored(disk.getTagCompound()), DiskStorage.getCapacity(disk)));
|
||||
list.add(String.format(I18n.translateToLocal("misc.refinedstorage:storage.stored_capacity"), NBTStorage.getStored(disk.getTagCompound()), capacity));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,39 +1,96 @@
|
||||
package refinedstorage.item;
|
||||
|
||||
import cofh.api.energy.ItemEnergyContainer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.IItemPropertyGetter;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.RefinedStorageGui;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
import refinedstorage.tile.TileController;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemWirelessGrid extends ItemBase {
|
||||
public static final String NBT_GRID_X = "GridX";
|
||||
public static final String NBT_GRID_Y = "GridY";
|
||||
public static final String NBT_GRID_Z = "GridZ";
|
||||
public class ItemWirelessGrid extends ItemEnergyContainer {
|
||||
public static final String NBT_CONTROLLER_X = "ControllerX";
|
||||
public static final String NBT_CONTROLLER_Y = "ControllerY";
|
||||
public static final String NBT_CONTROLLER_Z = "ControllerZ";
|
||||
public static final String NBT_DIMENSION_ID = "DimensionID";
|
||||
public static final String NBT_SORTING_TYPE = "SortingType";
|
||||
public static final String NBT_SORTING_DIRECTION = "SortingDirection";
|
||||
public static final String NBT_SEARCH_BOX_MODE = "SearchBoxMode";
|
||||
|
||||
public static final int RANGE = 64;
|
||||
|
||||
public static final int USAGE_OPEN = 30;
|
||||
public static final int USAGE_PULL = 3;
|
||||
public static final int USAGE_PUSH = 3;
|
||||
|
||||
public ItemWirelessGrid() {
|
||||
super("wireless_grid");
|
||||
super(3200);
|
||||
|
||||
addPropertyOverride(new ResourceLocation("connected"), new IItemPropertyGetter() {
|
||||
@Override
|
||||
public float apply(ItemStack stack, World world, EntityLivingBase entity) {
|
||||
return canOpenWirelessGrid(world, entity, stack) ? 1.0f : 0.0f;
|
||||
}
|
||||
});
|
||||
|
||||
setRegistryName(RefinedStorage.ID, "wireless_grid");
|
||||
setMaxDamage(3200);
|
||||
setMaxStackSize(1);
|
||||
setHasSubtypes(false);
|
||||
setCreativeTab(RefinedStorage.TAB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamageable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
return 1d - ((double) getEnergyStored(stack) / (double) getMaxEnergyStored(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamaged(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDamage(ItemStack stack, int damage) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
list.add(new ItemStack(item));
|
||||
|
||||
ItemStack fullyCharged = new ItemStack(item);
|
||||
receiveEnergy(fullyCharged, getMaxEnergyStored(fullyCharged), false);
|
||||
list.add(fullyCharged);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean b) {
|
||||
if (isValid(stack)) {
|
||||
list.add(I18n.translateToLocalFormatted("misc.refinedstorage:energy_stored", getEnergyStored(stack), getMaxEnergyStored(stack)));
|
||||
|
||||
if (canOpenWirelessGrid(player.worldObj, player, stack)) {
|
||||
list.add(I18n.translateToLocalFormatted("misc.refinedstorage:wireless_grid.tooltip.0", getX(stack)));
|
||||
list.add(I18n.translateToLocalFormatted("misc.refinedstorage:wireless_grid.tooltip.1", getY(stack)));
|
||||
list.add(I18n.translateToLocalFormatted("misc.refinedstorage:wireless_grid.tooltip.2", getZ(stack)));
|
||||
@@ -41,15 +98,23 @@ public class ItemWirelessGrid extends ItemBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
Block block = worldIn.getBlockState(pos).getBlock();
|
||||
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
|
||||
if (block == RefinedStorageBlocks.GRID) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
if (block == RefinedStorageBlocks.CONTROLLER) {
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setInteger(NBT_GRID_X, pos.getX());
|
||||
tag.setInteger(NBT_GRID_Y, pos.getY());
|
||||
tag.setInteger(NBT_GRID_Z, pos.getZ());
|
||||
if (tag == null) {
|
||||
tag = new NBTTagCompound();
|
||||
}
|
||||
|
||||
tag.setInteger(NBT_CONTROLLER_X, pos.getX());
|
||||
tag.setInteger(NBT_CONTROLLER_Y, pos.getY());
|
||||
tag.setInteger(NBT_CONTROLLER_Z, pos.getZ());
|
||||
tag.setInteger(NBT_DIMENSION_ID, player.dimension);
|
||||
tag.setInteger(NBT_SORTING_DIRECTION, TileGrid.SORTING_DIRECTION_DESCENDING);
|
||||
tag.setInteger(NBT_SORTING_TYPE, TileGrid.SORTING_TYPE_NAME);
|
||||
tag.setInteger(NBT_SEARCH_BOX_MODE, TileGrid.SEARCH_BOX_MODE_NORMAL);
|
||||
|
||||
stack.setTagCompound(tag);
|
||||
|
||||
@@ -61,48 +126,84 @@ public class ItemWirelessGrid extends ItemBase {
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
|
||||
if (!world.isRemote) {
|
||||
if (isValid(stack)) {
|
||||
if (isInRange(stack, player)) {
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(getX(stack), getY(stack), getZ(stack)));
|
||||
if (!world.isRemote && canOpenWirelessGrid(world, player, stack)) {
|
||||
TileController tile = (TileController) world.getTileEntity(new BlockPos(getX(stack), getY(stack), getZ(stack)));
|
||||
|
||||
if (tile instanceof TileGrid) {
|
||||
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.GRID, world, tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ());
|
||||
tile.onOpenWirelessGrid(player, hand);
|
||||
|
||||
return new ActionResult(EnumActionResult.PASS, stack);
|
||||
} else {
|
||||
player.addChatComponentMessage(new TextComponentString(I18n.translateToLocal("misc.refinedstorage:wireless_grid.not_found")));
|
||||
}
|
||||
} else {
|
||||
player.addChatComponentMessage(new TextComponentString(I18n.translateToLocal("misc.refinedstorage:wireless_grid.out_of_range")));
|
||||
}
|
||||
} else {
|
||||
player.addChatComponentMessage(new TextComponentString(I18n.translateToLocal("misc.refinedstorage:wireless_grid.not_found")));
|
||||
}
|
||||
|
||||
return new ActionResult(EnumActionResult.FAIL, stack);
|
||||
} else {
|
||||
return new ActionResult(EnumActionResult.PASS, stack);
|
||||
return new ActionResult(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
|
||||
return new ActionResult(EnumActionResult.PASS, stack);
|
||||
}
|
||||
|
||||
public static int getDimensionId(ItemStack stack) {
|
||||
return stack.getTagCompound().getInteger(NBT_DIMENSION_ID);
|
||||
}
|
||||
|
||||
public static int getX(ItemStack stack) {
|
||||
return stack.getTagCompound().getInteger(NBT_GRID_X);
|
||||
return stack.getTagCompound().getInteger(NBT_CONTROLLER_X);
|
||||
}
|
||||
|
||||
public static int getY(ItemStack stack) {
|
||||
return stack.getTagCompound().getInteger(NBT_GRID_Y);
|
||||
return stack.getTagCompound().getInteger(NBT_CONTROLLER_Y);
|
||||
}
|
||||
|
||||
public static int getZ(ItemStack stack) {
|
||||
return stack.getTagCompound().getInteger(NBT_GRID_Z);
|
||||
return stack.getTagCompound().getInteger(NBT_CONTROLLER_Z);
|
||||
}
|
||||
|
||||
public static boolean isInRange(ItemStack stack, EntityPlayer player) {
|
||||
return (int) Math.sqrt(Math.pow(getX(stack) - player.posX, 2) + Math.pow(getY(stack) - player.posY, 2) + Math.pow(getZ(stack) - player.posZ, 2)) < 64;
|
||||
public static int getSortingType(ItemStack stack) {
|
||||
return stack.getTagCompound().getInteger(NBT_SORTING_TYPE);
|
||||
}
|
||||
|
||||
public static boolean isValid(ItemStack stack) {
|
||||
return stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_GRID_X) && stack.getTagCompound().hasKey(NBT_GRID_Y) && stack.getTagCompound().hasKey(NBT_GRID_Z);
|
||||
public static int getSortingDirection(ItemStack stack) {
|
||||
return stack.getTagCompound().getInteger(NBT_SORTING_DIRECTION);
|
||||
}
|
||||
|
||||
public static int getSearchBoxMode(ItemStack stack) {
|
||||
return stack.getTagCompound().getInteger(NBT_SEARCH_BOX_MODE);
|
||||
}
|
||||
|
||||
public static boolean isInRange(ItemStack stack, EntityLivingBase entity) {
|
||||
return (int) Math.sqrt(Math.pow(getX(stack) - entity.posX, 2) + Math.pow(getY(stack) - entity.posY, 2) + Math.pow(getZ(stack) - entity.posZ, 2)) < RANGE;
|
||||
}
|
||||
|
||||
public static boolean canOpenWirelessGrid(World world, EntityLivingBase entity, ItemStack stack) {
|
||||
if (entity != null && stack.hasTagCompound()
|
||||
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_X)
|
||||
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_Y)
|
||||
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_Z)
|
||||
&& stack.getTagCompound().hasKey(NBT_DIMENSION_ID)
|
||||
&& stack.getTagCompound().hasKey(NBT_SORTING_DIRECTION)
|
||||
&& stack.getTagCompound().hasKey(NBT_SORTING_TYPE)
|
||||
&& stack.getTagCompound().hasKey(NBT_SEARCH_BOX_MODE)) {
|
||||
if (world == null) {
|
||||
world = entity.worldObj;
|
||||
}
|
||||
|
||||
int x = getX(stack);
|
||||
int y = getY(stack);
|
||||
int z = getZ(stack);
|
||||
|
||||
return isInRange(stack, entity) && getDimensionId(stack) == entity.dimension && world.getTileEntity(new BlockPos(x, y, z)) instanceof TileController;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return slotChanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
return "item." + RefinedStorage.ID + ":wireless_grid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import refinedstorage.network.MessageGridCraftingTransfer;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// Thanks to https://github.com/zerofall/EZStorage/blob/master/src/main/java/com/zerofall/ezstorage/jei/RecipeTransferHandler.java
|
||||
// https://github.com/zerofall/EZStorage/blob/master/src/main/java/com/zerofall/ezstorage/jei/RecipeTransferHandler.java
|
||||
public class GridRecipeTransferHandler implements IRecipeTransferHandler {
|
||||
@Override
|
||||
public Class<? extends Container> getContainerClass() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package refinedstorage.jei;
|
||||
|
||||
import mezz.jei.api.BlankModPlugin;
|
||||
import mezz.jei.api.IJeiRuntime;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -10,9 +11,15 @@ import refinedstorage.storage.DiskStorage;
|
||||
import refinedstorage.tile.TileStorage;
|
||||
|
||||
@JEIPlugin
|
||||
public class PluginRefinedStorage extends BlankModPlugin {
|
||||
public class PluginRefinedStorage implements IModPlugin {
|
||||
public static PluginRefinedStorage INSTANCE;
|
||||
|
||||
private IJeiRuntime runtime;
|
||||
|
||||
@Override
|
||||
public void register(IModRegistry registry) {
|
||||
INSTANCE = this;
|
||||
|
||||
registry.getRecipeTransferRegistry().addRecipeTransferHandler(new GridRecipeTransferHandler());
|
||||
|
||||
registry.addRecipeCategories(new SoldererRecipeCategory(registry.getJeiHelpers().getGuiHelper()));
|
||||
@@ -24,4 +31,17 @@ public class PluginRefinedStorage extends BlankModPlugin {
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(RefinedStorageItems.STORAGE_DISK, DiskStorage.NBT_ITEMS, DiskStorage.NBT_STORED);
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(RefinedStorageBlocks.STORAGE), TileStorage.NBT_STORAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime runtime) {
|
||||
this.runtime = runtime;
|
||||
}
|
||||
|
||||
public IJeiRuntime getRuntime() {
|
||||
return runtime;
|
||||
}
|
||||
|
||||
public static boolean isJeiLoaded() {
|
||||
return INSTANCE != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package refinedstorage.jei;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import mezz.jei.plugins.vanilla.VanillaRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -8,25 +7,12 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SoldererRecipeWrapper extends VanillaRecipeWrapper {
|
||||
private int hashCode;
|
||||
private List<ItemStack> inputs;
|
||||
private ItemStack output;
|
||||
|
||||
public SoldererRecipeWrapper(List<ItemStack> inputs, ItemStack output) {
|
||||
this.inputs = inputs;
|
||||
this.output = output;
|
||||
|
||||
int available = 0;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (inputs.get(i) != null) {
|
||||
available = i;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
hashCode = Objects.hashCode(inputs.get(available), output);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,11 +42,6 @@ public class SoldererRecipeWrapper extends VanillaRecipeWrapper {
|
||||
return ItemStack.areItemStacksEqual(output, other.output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return inputs + " = " + output;
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
|
||||
public class MessageCompareUpdate extends MessageHandlerPlayerToServer<MessageCompareUpdate> implements IMessage {
|
||||
private int x;
|
||||
@@ -16,7 +16,7 @@ public class MessageCompareUpdate extends MessageHandlerPlayerToServer<MessageCo
|
||||
public MessageCompareUpdate() {
|
||||
}
|
||||
|
||||
public MessageCompareUpdate(ICompareSetting setting, int compare) {
|
||||
public MessageCompareUpdate(ICompareConfig setting, int compare) {
|
||||
this.x = setting.getMachinePos().getX();
|
||||
this.y = setting.getMachinePos().getY();
|
||||
this.z = setting.getMachinePos().getZ();
|
||||
@@ -43,8 +43,8 @@ public class MessageCompareUpdate extends MessageHandlerPlayerToServer<MessageCo
|
||||
public void handle(MessageCompareUpdate message, EntityPlayerMP player) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||
|
||||
if (tile instanceof ICompareSetting) {
|
||||
((ICompareSetting) tile).setCompare(message.compare);
|
||||
if (tile instanceof ICompareConfig) {
|
||||
((ICompareConfig) tile).setCompare(message.compare);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class MessageGridCraftingClear extends MessageHandlerPlayerToServer<MessageGridCraftingClear> implements IMessage {
|
||||
private int x;
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class MessageGridCraftingPush extends MessageHandlerPlayerToServer<MessageGridCraftingPush> implements IMessage {
|
||||
private int x;
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.container.ContainerGrid;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class MessageGridCraftingTransfer extends MessageHandlerPlayerToServer<MessageGridCraftingTransfer> implements IMessage {
|
||||
private NBTTagCompound recipe;
|
||||
|
||||
@@ -1,60 +1,68 @@
|
||||
package refinedstorage.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.tile.TileGrid;
|
||||
|
||||
public class MessageGridSortingUpdate extends MessageHandlerPlayerToServer<MessageGridSortingUpdate> implements IMessage {
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int sortingDirection;
|
||||
private int sortingType;
|
||||
|
||||
public MessageGridSortingUpdate() {
|
||||
}
|
||||
|
||||
public MessageGridSortingUpdate(TileGrid grid, int sortingDirection, int sortingType) {
|
||||
this.x = grid.getPos().getX();
|
||||
this.y = grid.getPos().getY();
|
||||
this.z = grid.getPos().getZ();
|
||||
this.sortingDirection = sortingDirection;
|
||||
this.sortingType = sortingType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
sortingDirection = buf.readInt();
|
||||
sortingType = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(sortingDirection);
|
||||
buf.writeInt(sortingType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(MessageGridSortingUpdate message, EntityPlayerMP player) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||
|
||||
if (tile instanceof TileGrid) {
|
||||
if (message.sortingDirection == TileGrid.SORTING_DIRECTION_ASCENDING || message.sortingDirection == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||
((TileGrid) tile).setSortingDirection(message.sortingDirection);
|
||||
}
|
||||
|
||||
if (message.sortingType == TileGrid.SORTING_TYPE_QUANTITY || message.sortingType == TileGrid.SORTING_TYPE_NAME) {
|
||||
((TileGrid) tile).setSortingType(message.sortingType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package refinedstorage.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class MessageGridSettingsUpdate extends MessageHandlerPlayerToServer<MessageGridSettingsUpdate> implements IMessage {
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int sortingDirection;
|
||||
private int sortingType;
|
||||
private int searchBoxMode;
|
||||
|
||||
public MessageGridSettingsUpdate() {
|
||||
}
|
||||
|
||||
public MessageGridSettingsUpdate(TileGrid grid, int sortingDirection, int sortingType, int searchBoxMode) {
|
||||
this.x = grid.getPos().getX();
|
||||
this.y = grid.getPos().getY();
|
||||
this.z = grid.getPos().getZ();
|
||||
this.sortingDirection = sortingDirection;
|
||||
this.sortingType = sortingType;
|
||||
this.searchBoxMode = searchBoxMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
sortingDirection = buf.readInt();
|
||||
sortingType = buf.readInt();
|
||||
searchBoxMode = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(sortingDirection);
|
||||
buf.writeInt(sortingType);
|
||||
buf.writeInt(searchBoxMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(MessageGridSettingsUpdate message, EntityPlayerMP player) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||
|
||||
if (tile instanceof TileGrid) {
|
||||
if (message.sortingDirection == TileGrid.SORTING_DIRECTION_ASCENDING || message.sortingDirection == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||
((TileGrid) tile).setSortingDirection(message.sortingDirection);
|
||||
}
|
||||
|
||||
if (message.sortingType == TileGrid.SORTING_TYPE_QUANTITY || message.sortingType == TileGrid.SORTING_TYPE_NAME) {
|
||||
((TileGrid) tile).setSortingType(message.sortingType);
|
||||
}
|
||||
|
||||
if (message.searchBoxMode == TileGrid.SEARCH_BOX_MODE_NORMAL || message.searchBoxMode == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED) {
|
||||
((TileGrid) tile).setSearchBoxMode(message.searchBoxMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.config.IModeConfig;
|
||||
|
||||
public class MessageModeToggle extends MessageHandlerPlayerToServer<MessageModeToggle> implements IMessage {
|
||||
private int x;
|
||||
@@ -15,7 +15,7 @@ public class MessageModeToggle extends MessageHandlerPlayerToServer<MessageModeT
|
||||
public MessageModeToggle() {
|
||||
}
|
||||
|
||||
public MessageModeToggle(IModeSetting mode) {
|
||||
public MessageModeToggle(IModeConfig mode) {
|
||||
this.x = mode.getMachinePos().getX();
|
||||
this.y = mode.getMachinePos().getY();
|
||||
this.z = mode.getMachinePos().getZ();
|
||||
@@ -39,8 +39,8 @@ public class MessageModeToggle extends MessageHandlerPlayerToServer<MessageModeT
|
||||
public void handle(MessageModeToggle message, EntityPlayerMP player) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||
|
||||
if (tile instanceof IModeSetting) {
|
||||
IModeSetting mode = (IModeSetting) tile;
|
||||
if (tile instanceof IModeConfig) {
|
||||
IModeConfig mode = (IModeConfig) tile;
|
||||
|
||||
if (mode.isWhitelist()) {
|
||||
mode.setToBlacklist();
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
|
||||
public class MessageRedstoneModeUpdate extends MessageHandlerPlayerToServer<MessageRedstoneModeUpdate> implements IMessage {
|
||||
private int x;
|
||||
@@ -15,7 +15,7 @@ public class MessageRedstoneModeUpdate extends MessageHandlerPlayerToServer<Mess
|
||||
public MessageRedstoneModeUpdate() {
|
||||
}
|
||||
|
||||
public MessageRedstoneModeUpdate(IRedstoneModeSetting setting) {
|
||||
public MessageRedstoneModeUpdate(IRedstoneModeConfig setting) {
|
||||
this.x = setting.getMachinePos().getX();
|
||||
this.y = setting.getMachinePos().getY();
|
||||
this.z = setting.getMachinePos().getZ();
|
||||
@@ -39,8 +39,8 @@ public class MessageRedstoneModeUpdate extends MessageHandlerPlayerToServer<Mess
|
||||
public void handle(MessageRedstoneModeUpdate message, EntityPlayerMP player) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||
|
||||
if (tile instanceof IRedstoneModeSetting) {
|
||||
IRedstoneModeSetting setting = (IRedstoneModeSetting) tile;
|
||||
if (tile instanceof IRedstoneModeConfig) {
|
||||
IRedstoneModeConfig setting = (IRedstoneModeConfig) tile;
|
||||
|
||||
setting.setRedstoneMode(setting.getRedstoneMode().next());
|
||||
}
|
||||
|
||||
@@ -6,29 +6,30 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.storage.StorageItem;
|
||||
import refinedstorage.item.ItemWirelessGrid;
|
||||
import refinedstorage.storage.ItemGroup;
|
||||
import refinedstorage.tile.TileController;
|
||||
|
||||
public class MessageStoragePull extends MessageHandlerPlayerToServer<MessageStoragePull> implements IMessage {
|
||||
public static final int PULL_HALF = 1;
|
||||
public static final int PULL_ONE = 2;
|
||||
public static final int PULL_SHIFT = 4;
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int id;
|
||||
private boolean half;
|
||||
private boolean one;
|
||||
private boolean shift;
|
||||
private int flags;
|
||||
|
||||
public MessageStoragePull() {
|
||||
}
|
||||
|
||||
public MessageStoragePull(int x, int y, int z, int id, boolean half, boolean one, boolean shift) {
|
||||
public MessageStoragePull(int x, int y, int z, int id, int flags) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.id = id;
|
||||
this.half = half;
|
||||
this.one = one;
|
||||
this.shift = shift;
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,9 +38,7 @@ public class MessageStoragePull extends MessageHandlerPlayerToServer<MessageStor
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
id = buf.readInt();
|
||||
half = buf.readBoolean();
|
||||
one = buf.readBoolean();
|
||||
shift = buf.readBoolean();
|
||||
flags = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,41 +47,53 @@ public class MessageStoragePull extends MessageHandlerPlayerToServer<MessageStor
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(id);
|
||||
buf.writeBoolean(half);
|
||||
buf.writeBoolean(one);
|
||||
buf.writeBoolean(shift);
|
||||
buf.writeInt(flags);
|
||||
}
|
||||
|
||||
public boolean isPullingHalf() {
|
||||
return (flags & PULL_HALF) == PULL_HALF;
|
||||
}
|
||||
|
||||
public boolean isPullingOne() {
|
||||
return (flags & PULL_ONE) == PULL_ONE;
|
||||
}
|
||||
|
||||
public boolean isPullingWithShift() {
|
||||
return (flags & PULL_SHIFT) == PULL_SHIFT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(MessageStoragePull message, EntityPlayerMP player) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||
|
||||
if (tile instanceof TileController) {
|
||||
if (tile instanceof TileController && ((TileController) tile).isActive()) {
|
||||
TileController controller = (TileController) tile;
|
||||
|
||||
if (message.id < controller.getItems().size()) {
|
||||
StorageItem item = controller.getItems().get(message.id);
|
||||
if (message.id < controller.getItemGroups().size()) {
|
||||
ItemGroup group = controller.getItemGroups().get(message.id);
|
||||
|
||||
int quantity = 64;
|
||||
|
||||
if (message.half && item.getQuantity() > 1) {
|
||||
quantity = item.getQuantity() / 2;
|
||||
if (message.isPullingHalf() && group.getQuantity() > 1) {
|
||||
quantity = group.getQuantity() / 2;
|
||||
|
||||
if (quantity > 32) {
|
||||
quantity = 32;
|
||||
}
|
||||
} else if (message.one) {
|
||||
} else if (message.isPullingOne()) {
|
||||
quantity = 1;
|
||||
} else if (message.isPullingWithShift()) {
|
||||
// NO OP, the quantity already set (64) is needed for shift
|
||||
}
|
||||
|
||||
if (quantity > item.getType().getItemStackLimit(item.toItemStack())) {
|
||||
quantity = item.getType().getItemStackLimit(item.toItemStack());
|
||||
if (quantity > group.getType().getItemStackLimit(group.toItemStack())) {
|
||||
quantity = group.getType().getItemStackLimit(group.toItemStack());
|
||||
}
|
||||
|
||||
ItemStack took = controller.take(item.copy(quantity).toItemStack());
|
||||
ItemStack took = controller.take(group.copy(quantity).toItemStack());
|
||||
|
||||
if (took != null) {
|
||||
if (message.shift) {
|
||||
if (message.isPullingWithShift()) {
|
||||
if (!player.inventory.addItemStackToInventory(took.copy())) {
|
||||
controller.push(took);
|
||||
}
|
||||
@@ -90,6 +101,8 @@ public class MessageStoragePull extends MessageHandlerPlayerToServer<MessageStor
|
||||
player.inventory.setItemStack(took);
|
||||
player.updateHeldItem();
|
||||
}
|
||||
|
||||
controller.drainEnergyFromWirelessGrid(player, ItemWirelessGrid.USAGE_PULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.item.ItemWirelessGrid;
|
||||
import refinedstorage.tile.TileController;
|
||||
|
||||
public class MessageStoragePush extends MessageHandlerPlayerToServer<MessageStoragePush> implements IMessage {
|
||||
@@ -48,7 +49,7 @@ public class MessageStoragePush extends MessageHandlerPlayerToServer<MessageStor
|
||||
public void handle(MessageStoragePush message, EntityPlayerMP player) {
|
||||
TileEntity tile = player.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||
|
||||
if (tile instanceof TileController) {
|
||||
if (tile instanceof TileController && ((TileController) tile).isActive()) {
|
||||
TileController controller = (TileController) tile;
|
||||
|
||||
ItemStack stack;
|
||||
@@ -83,6 +84,8 @@ public class MessageStoragePush extends MessageHandlerPlayerToServer<MessageStor
|
||||
player.inventory.setInventorySlotContents(message.slot, null);
|
||||
}
|
||||
}
|
||||
|
||||
controller.drainEnergyFromWirelessGrid(player, ItemWirelessGrid.USAGE_PUSH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
62
src/main/java/refinedstorage/network/MessageWirelessGridSettingsUpdate.java
Executable file
62
src/main/java/refinedstorage/network/MessageWirelessGridSettingsUpdate.java
Executable file
@@ -0,0 +1,62 @@
|
||||
package refinedstorage.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.item.ItemWirelessGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
import refinedstorage.util.HandUtils;
|
||||
|
||||
public class MessageWirelessGridSettingsUpdate extends MessageHandlerPlayerToServer<MessageWirelessGridSettingsUpdate> implements IMessage {
|
||||
private int hand;
|
||||
private int sortingDirection;
|
||||
private int sortingType;
|
||||
private int searchBoxMode;
|
||||
|
||||
public MessageWirelessGridSettingsUpdate() {
|
||||
}
|
||||
|
||||
public MessageWirelessGridSettingsUpdate(int hand, int sortingDirection, int sortingType, int searchBoxMode) {
|
||||
this.hand = hand;
|
||||
this.sortingDirection = sortingDirection;
|
||||
this.sortingType = sortingType;
|
||||
this.searchBoxMode = searchBoxMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
hand = buf.readInt();
|
||||
sortingDirection = buf.readInt();
|
||||
sortingType = buf.readInt();
|
||||
searchBoxMode = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(hand);
|
||||
buf.writeInt(sortingDirection);
|
||||
buf.writeInt(sortingType);
|
||||
buf.writeInt(searchBoxMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(MessageWirelessGridSettingsUpdate message, EntityPlayerMP player) {
|
||||
ItemStack held = player.getHeldItem(HandUtils.getHandById(message.hand));
|
||||
|
||||
if (held != null && held.getItem() == RefinedStorageItems.WIRELESS_GRID && held.getTagCompound() != null) {
|
||||
if (message.sortingDirection == TileGrid.SORTING_DIRECTION_ASCENDING || message.sortingDirection == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||
held.getTagCompound().setInteger(ItemWirelessGrid.NBT_SORTING_DIRECTION, message.sortingDirection);
|
||||
}
|
||||
|
||||
if (message.sortingType == TileGrid.SORTING_TYPE_QUANTITY || message.sortingType == TileGrid.SORTING_TYPE_NAME) {
|
||||
held.getTagCompound().setInteger(ItemWirelessGrid.NBT_SORTING_TYPE, message.sortingType);
|
||||
}
|
||||
|
||||
if (message.searchBoxMode == TileGrid.SEARCH_BOX_MODE_NORMAL || message.searchBoxMode == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED) {
|
||||
held.getTagCompound().setInteger(ItemWirelessGrid.NBT_SEARCH_BOX_MODE, message.searchBoxMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package refinedstorage.proxy;
|
||||
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
@@ -14,7 +12,10 @@ import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.block.EnumControllerType;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.block.EnumStorageType;
|
||||
import refinedstorage.item.*;
|
||||
import refinedstorage.item.ItemCore;
|
||||
import refinedstorage.item.ItemProcessor;
|
||||
import refinedstorage.item.ItemStorageDisk;
|
||||
import refinedstorage.item.ItemStoragePart;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
@Override
|
||||
@@ -52,11 +53,6 @@ public class ClientProxy extends CommonProxy {
|
||||
new ResourceLocation("refinedstorage:destruction_core")
|
||||
);
|
||||
|
||||
ModelBakery.registerItemVariants(RefinedStorageItems.WIRELESS_GRID,
|
||||
new ResourceLocation("refinedstorage:wireless_grid_connected"),
|
||||
new ResourceLocation("refinedstorage:wireless_grid_disconnected")
|
||||
);
|
||||
|
||||
// Items
|
||||
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.STORAGE_DISK, ItemStorageDisk.TYPE_1K, new ModelResourceLocation("refinedstorage:1k_storage_disk", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.STORAGE_DISK, ItemStorageDisk.TYPE_4K, new ModelResourceLocation("refinedstorage:4k_storage_disk", "inventory"));
|
||||
@@ -84,16 +80,7 @@ public class ClientProxy extends CommonProxy {
|
||||
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.CORE, ItemCore.TYPE_CONSTRUCTION, new ModelResourceLocation("refinedstorage:construction_core", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.CORE, ItemCore.TYPE_DESTRUCTION, new ModelResourceLocation("refinedstorage:destruction_core", "inventory"));
|
||||
|
||||
ModelLoader.setCustomMeshDefinition(RefinedStorageItems.WIRELESS_GRID, new ItemMeshDefinition() {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
if (ItemWirelessGrid.isValid(stack)) {
|
||||
return new ModelResourceLocation("refinedstorage:wireless_grid_connected", "inventory");
|
||||
} else {
|
||||
return new ModelResourceLocation("refinedstorage:wireless_grid_disconnected", "inventory");
|
||||
}
|
||||
}
|
||||
});
|
||||
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.WIRELESS_GRID, 0, new ModelResourceLocation("refinedstorage:wireless_grid", "inventory"));
|
||||
|
||||
// Blocks
|
||||
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RefinedStorageBlocks.CABLE), 0, new ModelResourceLocation("refinedstorage:cable", "inventory"));
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package refinedstorage.proxy;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
@@ -12,14 +14,19 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.block.BlockBase;
|
||||
import refinedstorage.block.EnumControllerType;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.block.EnumStorageType;
|
||||
import refinedstorage.gui.GuiHandler;
|
||||
import refinedstorage.item.*;
|
||||
import refinedstorage.item.ItemCore;
|
||||
import refinedstorage.item.ItemProcessor;
|
||||
import refinedstorage.item.ItemStorageDisk;
|
||||
import refinedstorage.item.ItemStoragePart;
|
||||
import refinedstorage.network.*;
|
||||
import refinedstorage.storage.NBTStorage;
|
||||
import refinedstorage.tile.*;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
import refinedstorage.tile.solderer.*;
|
||||
|
||||
import static refinedstorage.RefinedStorage.ID;
|
||||
@@ -36,9 +43,10 @@ public class CommonProxy {
|
||||
RefinedStorage.NETWORK.registerMessage(MessageDetectorAmountUpdate.class, MessageDetectorAmountUpdate.class, 7, Side.SERVER);
|
||||
RefinedStorage.NETWORK.registerMessage(MessageGridCraftingClear.class, MessageGridCraftingClear.class, 9, Side.SERVER);
|
||||
RefinedStorage.NETWORK.registerMessage(MessagePriorityUpdate.class, MessagePriorityUpdate.class, 10, Side.SERVER);
|
||||
RefinedStorage.NETWORK.registerMessage(MessageGridSortingUpdate.class, MessageGridSortingUpdate.class, 11, Side.SERVER);
|
||||
RefinedStorage.NETWORK.registerMessage(MessageGridSettingsUpdate.class, MessageGridSettingsUpdate.class, 11, Side.SERVER);
|
||||
RefinedStorage.NETWORK.registerMessage(MessageGridCraftingPush.class, MessageGridCraftingPush.class, 12, Side.SERVER);
|
||||
RefinedStorage.NETWORK.registerMessage(MessageGridCraftingTransfer.class, MessageGridCraftingTransfer.class, 13, Side.SERVER);
|
||||
RefinedStorage.NETWORK.registerMessage(MessageWirelessGridSettingsUpdate.class, MessageWirelessGridSettingsUpdate.class, 14, Side.SERVER);
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(RefinedStorage.INSTANCE, new GuiHandler());
|
||||
|
||||
@@ -56,29 +64,29 @@ public class CommonProxy {
|
||||
GameRegistry.registerTileEntity(TileRelay.class, ID + ":relay");
|
||||
GameRegistry.registerTileEntity(TileInterface.class, ID + ":interface");
|
||||
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.CONTROLLER, ItemBlockController.class, ID + ":controller");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.CABLE, ID + ":cable");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.GRID, ItemBlockGrid.class, ID + ":grid");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.DISK_DRIVE, ID + ":disk_drive");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.EXTERNAL_STORAGE, ID + ":external_storage");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.IMPORTER, ID + ":importer");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.EXPORTER, ID + ":exporter");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.DETECTOR, ID + ":detector");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.MACHINE_CASING, ID + ":machine_casing");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.SOLDERER, ID + ":solderer");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.DESTRUCTOR, ID + ":destructor");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.CONSTRUCTOR, ID + ":constructor");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.STORAGE, ItemBlockStorage.class, ID + ":storage");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.RELAY, ID + ":relay");
|
||||
GameRegistry.registerBlock(RefinedStorageBlocks.INTERFACE, ID + ":interface");
|
||||
registerBlock(RefinedStorageBlocks.CONTROLLER);
|
||||
registerBlock(RefinedStorageBlocks.CABLE);
|
||||
registerBlock(RefinedStorageBlocks.GRID);
|
||||
registerBlock(RefinedStorageBlocks.DISK_DRIVE);
|
||||
registerBlock(RefinedStorageBlocks.EXTERNAL_STORAGE);
|
||||
registerBlock(RefinedStorageBlocks.IMPORTER);
|
||||
registerBlock(RefinedStorageBlocks.EXPORTER);
|
||||
registerBlock(RefinedStorageBlocks.DETECTOR);
|
||||
registerBlock(RefinedStorageBlocks.MACHINE_CASING);
|
||||
registerBlock(RefinedStorageBlocks.SOLDERER);
|
||||
registerBlock(RefinedStorageBlocks.DESTRUCTOR);
|
||||
registerBlock(RefinedStorageBlocks.CONSTRUCTOR);
|
||||
registerBlock(RefinedStorageBlocks.STORAGE);
|
||||
registerBlock(RefinedStorageBlocks.RELAY);
|
||||
registerBlock(RefinedStorageBlocks.INTERFACE);
|
||||
|
||||
GameRegistry.registerItem(RefinedStorageItems.STORAGE_DISK, ID + ":storage_disk");
|
||||
GameRegistry.registerItem(RefinedStorageItems.WIRELESS_GRID, ID + ":wireless_grid");
|
||||
GameRegistry.registerItem(RefinedStorageItems.QUARTZ_ENRICHED_IRON, ID + ":quartz_enriched_iron");
|
||||
GameRegistry.registerItem(RefinedStorageItems.CORE, ID + ":core");
|
||||
GameRegistry.registerItem(RefinedStorageItems.SILICON, ID + ":silicon");
|
||||
GameRegistry.registerItem(RefinedStorageItems.PROCESSOR, ID + ":processor");
|
||||
GameRegistry.registerItem(RefinedStorageItems.STORAGE_PART, ID + ":storage_part");
|
||||
registerItem(RefinedStorageItems.STORAGE_DISK);
|
||||
registerItem(RefinedStorageItems.WIRELESS_GRID);
|
||||
registerItem(RefinedStorageItems.QUARTZ_ENRICHED_IRON);
|
||||
registerItem(RefinedStorageItems.CORE);
|
||||
registerItem(RefinedStorageItems.SILICON);
|
||||
registerItem(RefinedStorageItems.PROCESSOR);
|
||||
registerItem(RefinedStorageItems.STORAGE_PART);
|
||||
|
||||
// Processors
|
||||
SoldererRegistry.addRecipe(new SoldererRecipePrintedProcessor(ItemProcessor.TYPE_PRINTED_BASIC));
|
||||
@@ -348,4 +356,13 @@ public class CommonProxy {
|
||||
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
}
|
||||
|
||||
private void registerBlock(BlockBase block) {
|
||||
GameRegistry.<Block>register(block);
|
||||
GameRegistry.register(block.createItemForBlock());
|
||||
}
|
||||
|
||||
private void registerItem(Item item) {
|
||||
GameRegistry.register(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,25 @@
|
||||
package refinedstorage.storage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.item.ItemStorageDisk;
|
||||
import refinedstorage.block.EnumStorageType;
|
||||
import refinedstorage.tile.TileDiskDrive;
|
||||
import refinedstorage.tile.settings.ModeSettingUtils;
|
||||
import refinedstorage.tile.config.ModeConfigUtils;
|
||||
|
||||
public class DiskStorage extends NBTStorage {
|
||||
private TileDiskDrive diskDrive;
|
||||
|
||||
public DiskStorage(ItemStack disk, TileDiskDrive diskDrive) {
|
||||
super(disk.getTagCompound(), getCapacity(disk), diskDrive.getPriority());
|
||||
super(disk.getTagCompound(), EnumStorageType.getById(disk.getItemDamage()).getCapacity(), diskDrive.getPriority());
|
||||
|
||||
this.diskDrive = diskDrive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPush(ItemStack stack) {
|
||||
if (ModeSettingUtils.doesNotViolateMode(diskDrive.getInventory(), diskDrive.getModeSetting(), diskDrive.getCompare(), stack)) {
|
||||
if (ModeConfigUtils.doesNotViolateMode(diskDrive.getInventory(), diskDrive.getModeConfig(), diskDrive.getCompare(), stack)) {
|
||||
return super.canPush(stack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getCapacity(ItemStack disk) {
|
||||
switch (disk.getItemDamage()) {
|
||||
case ItemStorageDisk.TYPE_1K:
|
||||
return 1000;
|
||||
case ItemStorageDisk.TYPE_4K:
|
||||
return 4000;
|
||||
case ItemStorageDisk.TYPE_16K:
|
||||
return 16000;
|
||||
case ItemStorageDisk.TYPE_64K:
|
||||
return 64000;
|
||||
case ItemStorageDisk.TYPE_CREATIVE:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack;
|
||||
import java.util.List;
|
||||
|
||||
public interface IStorage {
|
||||
void addItems(List<StorageItem> items);
|
||||
void addItems(List<ItemGroup> items);
|
||||
|
||||
void push(ItemStack stack);
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package refinedstorage.storage;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.tile.config.IModeConfig;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
|
||||
public interface IStorageGui {
|
||||
String getName();
|
||||
@@ -14,11 +14,11 @@ public interface IStorageGui {
|
||||
|
||||
IInventory getInventory();
|
||||
|
||||
IRedstoneModeSetting getRedstoneModeSetting();
|
||||
IRedstoneModeConfig getRedstoneModeConfig();
|
||||
|
||||
ICompareSetting getCompareSetting();
|
||||
ICompareConfig getCompareConfig();
|
||||
|
||||
IModeSetting getModeSetting();
|
||||
IModeConfig getModeConfig();
|
||||
|
||||
int getStored();
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@ package refinedstorage.storage;
|
||||
import java.util.List;
|
||||
|
||||
public interface IStorageProvider {
|
||||
void addStorages(List<IStorage> storages);
|
||||
void provide(List<IStorage> storages);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class StorageItem {
|
||||
public class ItemGroup {
|
||||
private Item type;
|
||||
private int quantity;
|
||||
private int damage;
|
||||
@@ -17,7 +17,7 @@ public class StorageItem {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private int id;
|
||||
|
||||
public StorageItem(ByteBuf buf) {
|
||||
public ItemGroup(ByteBuf buf) {
|
||||
this.id = buf.readInt();
|
||||
this.type = Item.getItemById(buf.readInt());
|
||||
this.quantity = buf.readInt();
|
||||
@@ -25,20 +25,14 @@ public class StorageItem {
|
||||
this.tag = buf.readBoolean() ? ByteBufUtils.readTag(buf) : null;
|
||||
}
|
||||
|
||||
public StorageItem(Item type, int quantity, int damage, NBTTagCompound tag) {
|
||||
public ItemGroup(Item type, int quantity, int damage, NBTTagCompound tag) {
|
||||
this.type = type;
|
||||
this.quantity = quantity;
|
||||
this.damage = damage;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public StorageItem(Item type, int quantity, int damage, NBTTagCompound tag, int id) {
|
||||
this(type, quantity, damage, tag);
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public StorageItem(ItemStack stack) {
|
||||
public ItemGroup(ItemStack stack) {
|
||||
this(stack.getItem(), stack.stackSize, stack.getItemDamage(), stack.getTagCompound());
|
||||
}
|
||||
|
||||
@@ -87,12 +81,12 @@ public class StorageItem {
|
||||
return id;
|
||||
}
|
||||
|
||||
public StorageItem copy() {
|
||||
public ItemGroup copy() {
|
||||
return copy(quantity);
|
||||
}
|
||||
|
||||
public StorageItem copy(int newQuantity) {
|
||||
return new StorageItem(type, newQuantity, damage, tag);
|
||||
public ItemGroup copy(int newQuantity) {
|
||||
return new ItemGroup(type, newQuantity, damage, tag);
|
||||
}
|
||||
|
||||
public ItemStack toItemStack() {
|
||||
@@ -103,7 +97,7 @@ public class StorageItem {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public boolean compare(StorageItem other, int flags) {
|
||||
public boolean compare(ItemGroup other, int flags) {
|
||||
if ((flags & InventoryUtils.COMPARE_DAMAGE) == InventoryUtils.COMPARE_DAMAGE) {
|
||||
if (damage != other.getDamage()) {
|
||||
return false;
|
||||
@@ -159,7 +153,7 @@ public class StorageItem {
|
||||
return type == stack.getItem();
|
||||
}
|
||||
|
||||
public boolean compareNoQuantity(StorageItem other) {
|
||||
public boolean compareNoQuantity(ItemGroup other) {
|
||||
return compare(other, InventoryUtils.COMPARE_NBT | InventoryUtils.COMPARE_DAMAGE);
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ public class NBTStorage implements IStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItems(List<StorageItem> items) {
|
||||
public void addItems(List<ItemGroup> items) {
|
||||
NBTTagList list = (NBTTagList) nbtTag.getTag(NBT_ITEMS);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
items.add(createItemFromNBT(list.getCompoundTagAt(i)));
|
||||
items.add(createItemGroupFromNBT(list.getCompoundTagAt(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,10 +44,10 @@ public class NBTStorage implements IStorage {
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||
|
||||
StorageItem item = createItemFromNBT(tag);
|
||||
ItemGroup group = createItemGroupFromNBT(tag);
|
||||
|
||||
if (item.compareNoQuantity(stack)) {
|
||||
tag.setInteger(NBT_ITEM_QUANTITY, item.getQuantity() + stack.stackSize);
|
||||
if (group.compareNoQuantity(stack)) {
|
||||
tag.setInteger(NBT_ITEM_QUANTITY, group.getQuantity() + stack.stackSize);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -75,22 +75,22 @@ public class NBTStorage implements IStorage {
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||
|
||||
StorageItem item = createItemFromNBT(tag);
|
||||
ItemGroup group = createItemGroupFromNBT(tag);
|
||||
|
||||
if (item.compare(stack, flags)) {
|
||||
if (quantity > item.getQuantity()) {
|
||||
quantity = item.getQuantity();
|
||||
if (group.compare(stack, flags)) {
|
||||
if (quantity > group.getQuantity()) {
|
||||
quantity = group.getQuantity();
|
||||
}
|
||||
|
||||
tag.setInteger(NBT_ITEM_QUANTITY, item.getQuantity() - quantity);
|
||||
tag.setInteger(NBT_ITEM_QUANTITY, group.getQuantity() - quantity);
|
||||
|
||||
if (item.getQuantity() - quantity == 0) {
|
||||
if (group.getQuantity() - quantity == 0) {
|
||||
list.removeTag(i);
|
||||
}
|
||||
|
||||
nbtTag.setInteger(NBT_STORED, getStored(nbtTag) - quantity);
|
||||
|
||||
ItemStack newItem = item.toItemStack();
|
||||
ItemStack newItem = group.toItemStack();
|
||||
|
||||
newItem.stackSize = quantity;
|
||||
|
||||
@@ -115,8 +115,8 @@ public class NBTStorage implements IStorage {
|
||||
return priority;
|
||||
}
|
||||
|
||||
private StorageItem createItemFromNBT(NBTTagCompound tag) {
|
||||
return new StorageItem(Item.getItemById(tag.getInteger(NBT_ITEM_TYPE)), tag.getInteger(NBT_ITEM_QUANTITY), tag.getInteger(NBT_ITEM_DAMAGE), tag.hasKey(NBT_ITEM_NBT) ? ((NBTTagCompound) tag.getTag(NBT_ITEM_NBT)) : null);
|
||||
private ItemGroup createItemGroupFromNBT(NBTTagCompound tag) {
|
||||
return new ItemGroup(Item.getItemById(tag.getInteger(NBT_ITEM_TYPE)), tag.getInteger(NBT_ITEM_QUANTITY), tag.getInteger(NBT_ITEM_DAMAGE), tag.hasKey(NBT_ITEM_NBT) ? ((NBTTagCompound) tag.getTag(NBT_ITEM_NBT)) : null);
|
||||
}
|
||||
|
||||
public static int getStored(NBTTagCompound tag) {
|
||||
@@ -133,8 +133,7 @@ public class NBTStorage implements IStorage {
|
||||
}
|
||||
|
||||
public static ItemStack initNBT(ItemStack stack) {
|
||||
stack.setTagCompound(NBTStorage.getBaseNBT());
|
||||
|
||||
stack.setTagCompound(getBaseNBT());
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
package refinedstorage.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface INetworkTile {
|
||||
void fromBytes(ByteBuf buf);
|
||||
|
||||
void toBytes(ByteBuf buf);
|
||||
|
||||
BlockPos getTilePos();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class MachineSearcher {
|
||||
if (machine.getRedstoneMode().isEnabled(controller.getWorld(), tile.getPos())) {
|
||||
machines.add(machine);
|
||||
} else if (machine instanceof TileRelay) {
|
||||
// If the relay is disabled we can't search any further
|
||||
// if the relay is disabled we can't search any further
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class TileConstructor extends TileMachine implements ICompareSetting {
|
||||
public class TileConstructor extends TileMachine implements ICompareConfig {
|
||||
public static final int SPEED = 10;
|
||||
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
|
||||
@@ -3,29 +3,36 @@ package refinedstorage.tile;
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.RefinedStorageGui;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.block.BlockController;
|
||||
import refinedstorage.block.EnumControllerType;
|
||||
import refinedstorage.item.ItemWirelessGrid;
|
||||
import refinedstorage.storage.IStorage;
|
||||
import refinedstorage.storage.IStorageProvider;
|
||||
import refinedstorage.storage.StorageItem;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.settings.RedstoneMode;
|
||||
import refinedstorage.storage.ItemGroup;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
import refinedstorage.tile.config.RedstoneMode;
|
||||
import refinedstorage.tile.grid.WirelessGridConsumer;
|
||||
import refinedstorage.util.HandUtils;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class TileController extends TileBase implements IEnergyReceiver, INetworkTile, IRedstoneModeSetting {
|
||||
private List<StorageItem> items = new ArrayList<StorageItem>();
|
||||
public class TileController extends TileBase implements IEnergyReceiver, INetworkTile, IRedstoneModeConfig {
|
||||
private List<ItemGroup> itemGroups = new ArrayList<ItemGroup>();
|
||||
private List<IStorage> storages = new ArrayList<IStorage>();
|
||||
private List<WirelessGridConsumer> wirelessGridConsumers = new ArrayList<WirelessGridConsumer>();
|
||||
private List<WirelessGridConsumer> wirelessGridConsumersMarkedForRemoval = new ArrayList<WirelessGridConsumer>();
|
||||
|
||||
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||
|
||||
@@ -36,6 +43,8 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
private EnergyStorage energy = new EnergyStorage(32000);
|
||||
private int energyUsage;
|
||||
|
||||
private boolean activeClientSide;
|
||||
|
||||
private boolean destroyed = false;
|
||||
|
||||
@Override
|
||||
@@ -75,7 +84,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
|
||||
for (TileMachine machine : machines) {
|
||||
if (machine instanceof IStorageProvider) {
|
||||
((IStorageProvider) machine).addStorages(storages);
|
||||
((IStorageProvider) machine).provide(storages);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +116,20 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
}
|
||||
}
|
||||
|
||||
wirelessGridConsumers.removeAll(wirelessGridConsumersMarkedForRemoval);
|
||||
wirelessGridConsumersMarkedForRemoval.clear();
|
||||
|
||||
Iterator<WirelessGridConsumer> it = wirelessGridConsumers.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
WirelessGridConsumer consumer = it.next();
|
||||
|
||||
if (!InventoryUtils.compareStack(consumer.getWirelessGrid(), consumer.getPlayer().getHeldItem(consumer.getHand()))) {
|
||||
onCloseWirelessGrid(consumer.getPlayer());
|
||||
consumer.getPlayer().closeScreen();
|
||||
}
|
||||
}
|
||||
|
||||
if (lastEnergy != energy.getEnergyStored()) {
|
||||
worldObj.updateComparatorOutputLevel(pos, RefinedStorageBlocks.CONTROLLER);
|
||||
}
|
||||
@@ -139,15 +162,15 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
return machines;
|
||||
}
|
||||
|
||||
public List<StorageItem> getItems() {
|
||||
return items;
|
||||
public List<ItemGroup> getItemGroups() {
|
||||
return itemGroups;
|
||||
}
|
||||
|
||||
private void syncItems() {
|
||||
items.clear();
|
||||
itemGroups.clear();
|
||||
|
||||
for (IStorage storage : storages) {
|
||||
storage.addItems(items);
|
||||
storage.addItems(itemGroups);
|
||||
}
|
||||
|
||||
combineItems();
|
||||
@@ -156,35 +179,35 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
private void combineItems() {
|
||||
List<Integer> markedIndexes = new ArrayList<Integer>();
|
||||
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
for (int i = 0; i < itemGroups.size(); ++i) {
|
||||
if (markedIndexes.contains(i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
StorageItem item = items.get(i);
|
||||
ItemGroup group = itemGroups.get(i);
|
||||
|
||||
for (int j = i + 1; j < items.size(); ++j) {
|
||||
for (int j = i + 1; j < itemGroups.size(); ++j) {
|
||||
if (markedIndexes.contains(j)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
StorageItem other = items.get(j);
|
||||
ItemGroup otherGroup = itemGroups.get(j);
|
||||
|
||||
if (item.compareNoQuantity(other)) {
|
||||
item.setQuantity(item.getQuantity() + other.getQuantity());
|
||||
if (group.compareNoQuantity(otherGroup)) {
|
||||
group.setQuantity(group.getQuantity() + otherGroup.getQuantity());
|
||||
|
||||
markedIndexes.add(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<StorageItem> markedItems = new ArrayList<StorageItem>();
|
||||
List<ItemGroup> markedItems = new ArrayList<ItemGroup>();
|
||||
|
||||
for (int i : markedIndexes) {
|
||||
markedItems.add(items.get(i));
|
||||
markedItems.add(itemGroups.get(i));
|
||||
}
|
||||
|
||||
items.removeAll(markedItems);
|
||||
itemGroups.removeAll(markedItems);
|
||||
}
|
||||
|
||||
public boolean push(ItemStack stack) {
|
||||
@@ -248,6 +271,52 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
return newStack;
|
||||
}
|
||||
|
||||
public void onOpenWirelessGrid(EntityPlayer player, EnumHand hand) {
|
||||
wirelessGridConsumers.add(new WirelessGridConsumer(player, hand, player.getHeldItem(hand)));
|
||||
|
||||
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.WIRELESS_GRID, worldObj, HandUtils.getIdFromHand(hand), 0, 0);
|
||||
|
||||
drainEnergyFromWirelessGrid(player, ItemWirelessGrid.USAGE_OPEN);
|
||||
}
|
||||
|
||||
public void onCloseWirelessGrid(EntityPlayer player) {
|
||||
WirelessGridConsumer consumer = getWirelessGridConsumer(player);
|
||||
|
||||
if (consumer != null) {
|
||||
wirelessGridConsumersMarkedForRemoval.add(consumer);
|
||||
}
|
||||
}
|
||||
|
||||
public void drainEnergyFromWirelessGrid(EntityPlayer player, int energy) {
|
||||
WirelessGridConsumer consumer = getWirelessGridConsumer(player);
|
||||
|
||||
if (consumer != null) {
|
||||
ItemWirelessGrid item = RefinedStorageItems.WIRELESS_GRID;
|
||||
ItemStack held = consumer.getPlayer().getHeldItem(consumer.getHand());
|
||||
|
||||
item.extractEnergy(held, energy, false);
|
||||
|
||||
if (item.getEnergyStored(held) <= 0) {
|
||||
onCloseWirelessGrid(player);
|
||||
consumer.getPlayer().closeScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public WirelessGridConsumer getWirelessGridConsumer(EntityPlayer player) {
|
||||
Iterator<WirelessGridConsumer> it = wirelessGridConsumers.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
WirelessGridConsumer consumer = it.next();
|
||||
|
||||
if (consumer.getPlayer() == player) {
|
||||
return consumer;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
@@ -300,6 +369,10 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
return energy.getEnergyStored() >= getEnergyUsage() && redstoneMode.isEnabled(worldObj, pos);
|
||||
}
|
||||
|
||||
public boolean isActiveClientSide() {
|
||||
return activeClientSide;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneMode getRedstoneMode() {
|
||||
return redstoneMode;
|
||||
@@ -312,11 +385,6 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
this.redstoneMode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getTilePos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getMachinePos() {
|
||||
return pos;
|
||||
@@ -324,6 +392,8 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
activeClientSide = buf.readBoolean();
|
||||
|
||||
int lastEnergy = energy.getEnergyStored();
|
||||
|
||||
energy.setEnergyStored(buf.readInt());
|
||||
@@ -336,12 +406,12 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
|
||||
redstoneMode = RedstoneMode.getById(buf.readInt());
|
||||
|
||||
items.clear();
|
||||
itemGroups.clear();
|
||||
|
||||
int size = buf.readInt();
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
items.add(new StorageItem(buf));
|
||||
itemGroups.add(new ItemGroup(buf));
|
||||
}
|
||||
|
||||
machines.clear();
|
||||
@@ -359,15 +429,17 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeBoolean(isActive());
|
||||
|
||||
buf.writeInt(energy.getEnergyStored());
|
||||
buf.writeInt(isActive() ? energyUsage : 0);
|
||||
buf.writeInt(energyUsage);
|
||||
|
||||
buf.writeInt(redstoneMode.id);
|
||||
|
||||
buf.writeInt(items.size());
|
||||
buf.writeInt(itemGroups.size());
|
||||
|
||||
for (StorageItem item : items) {
|
||||
item.toBytes(buf, items.indexOf(item));
|
||||
for (ItemGroup group : itemGroups) {
|
||||
group.toBytes(buf, itemGroups.indexOf(group));
|
||||
}
|
||||
|
||||
buf.writeInt(machines.size());
|
||||
|
||||
@@ -4,18 +4,19 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.settings.ModeSettingUtils;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.tile.config.IModeConfig;
|
||||
import refinedstorage.tile.config.ModeConfigUtils;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileDestructor extends TileMachine implements ICompareSetting, IModeSetting {
|
||||
public class TileDestructor extends TileMachine implements ICompareConfig, IModeConfig {
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
public static final String NBT_MODE = "Mode";
|
||||
|
||||
@@ -39,8 +40,8 @@ public class TileDestructor extends TileMachine implements ICompareSetting, IMod
|
||||
IBlockState frontBlockState = worldObj.getBlockState(front);
|
||||
Block frontBlock = frontBlockState.getBlock();
|
||||
|
||||
if (!frontBlock.isAir(frontBlockState, worldObj, front)) {
|
||||
if (ModeSettingUtils.doesNotViolateMode(inventory, this, compare, new ItemStack(frontBlock, 1, frontBlock.getMetaFromState(frontBlockState)))) {
|
||||
if (Item.getItemFromBlock(frontBlock) != null && !frontBlock.isAir(frontBlockState, worldObj, front)) {
|
||||
if (ModeConfigUtils.doesNotViolateMode(inventory, this, compare, new ItemStack(frontBlock, 1, frontBlock.getMetaFromState(frontBlockState)))) {
|
||||
List<ItemStack> drops = frontBlock.getDrops(worldObj, front, frontBlockState, 0);
|
||||
|
||||
worldObj.setBlockToAir(front);
|
||||
|
||||
@@ -6,12 +6,12 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.storage.StorageItem;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.settings.RedstoneMode;
|
||||
import refinedstorage.storage.ItemGroup;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.tile.config.RedstoneMode;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class TileDetector extends TileMachine implements ICompareSetting {
|
||||
public class TileDetector extends TileMachine implements ICompareConfig {
|
||||
public static final int MODE_UNDER = 0;
|
||||
public static final int MODE_EQUAL = 1;
|
||||
public static final int MODE_ABOVE = 2;
|
||||
@@ -50,19 +50,19 @@ public class TileDetector extends TileMachine implements ICompareSetting {
|
||||
if (slot != null) {
|
||||
boolean foundAny = false;
|
||||
|
||||
for (StorageItem item : getController().getItems()) {
|
||||
if (item.compare(slot, compare)) {
|
||||
for (ItemGroup group : getController().getItemGroups()) {
|
||||
if (group.compare(slot, compare)) {
|
||||
foundAny = true;
|
||||
|
||||
switch (mode) {
|
||||
case MODE_UNDER:
|
||||
powered = item.getQuantity() < amount;
|
||||
powered = group.getQuantity() < amount;
|
||||
break;
|
||||
case MODE_EQUAL:
|
||||
powered = item.getQuantity() == amount;
|
||||
powered = group.getQuantity() == amount;
|
||||
break;
|
||||
case MODE_ABOVE:
|
||||
powered = item.getQuantity() > amount;
|
||||
powered = group.getQuantity() > amount;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,17 +7,18 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.block.EnumStorageType;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.network.MessagePriorityUpdate;
|
||||
import refinedstorage.storage.*;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.tile.config.IModeConfig;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileDiskDrive extends TileMachine implements IStorageProvider, IStorageGui, ICompareSetting, IModeSetting, IInventory {
|
||||
public class TileDiskDrive extends TileMachine implements IStorageProvider, IStorageGui, ICompareConfig, IModeConfig, IInventory {
|
||||
public static final String NBT_PRIORITY = "Priority";
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
public static final String NBT_MODE = "Mode";
|
||||
@@ -47,7 +48,7 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorages(List<IStorage> storages) {
|
||||
public void provide(List<IStorage> storages) {
|
||||
for (int i = 0; i < getSizeInventory(); ++i) {
|
||||
if (getStackInSlot(i) != null) {
|
||||
storages.add(new DiskStorage(getStackInSlot(i), this));
|
||||
@@ -152,17 +153,17 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneModeSetting getRedstoneModeSetting() {
|
||||
public IRedstoneModeConfig getRedstoneModeConfig() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICompareSetting getCompareSetting() {
|
||||
public ICompareConfig getCompareConfig() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModeSetting getModeSetting() {
|
||||
public IModeConfig getModeConfig() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -205,7 +206,7 @@ public class TileDiskDrive extends TileMachine implements IStorageProvider, ISto
|
||||
ItemStack stack = getStackInSlot(i);
|
||||
|
||||
if (stack != null) {
|
||||
int diskCapacity = DiskStorage.getCapacity(stack);
|
||||
int diskCapacity = EnumStorageType.getById(stack.getItemDamage()).getCapacity();
|
||||
|
||||
if (diskCapacity == -1) {
|
||||
return -1;
|
||||
|
||||
@@ -7,10 +7,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityHopper;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class TileExporter extends TileMachine implements ICompareSetting {
|
||||
public class TileExporter extends TileMachine implements ICompareConfig {
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
|
||||
public static final int SPEED = 3;
|
||||
|
||||
@@ -12,16 +12,16 @@ import refinedstorage.network.MessagePriorityUpdate;
|
||||
import refinedstorage.storage.IStorage;
|
||||
import refinedstorage.storage.IStorageGui;
|
||||
import refinedstorage.storage.IStorageProvider;
|
||||
import refinedstorage.storage.StorageItem;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.settings.ModeSettingUtils;
|
||||
import refinedstorage.storage.ItemGroup;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.tile.config.IModeConfig;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
import refinedstorage.tile.config.ModeConfigUtils;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileExternalStorage extends TileMachine implements IStorageProvider, IStorage, IStorageGui, ICompareSetting, IModeSetting {
|
||||
public class TileExternalStorage extends TileMachine implements IStorageProvider, IStorage, IStorageGui, ICompareConfig, IModeConfig {
|
||||
public static final String NBT_PRIORITY = "Priority";
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
public static final String NBT_MODE = "Mode";
|
||||
@@ -44,7 +44,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItems(List<StorageItem> items) {
|
||||
public void addItems(List<ItemGroup> items) {
|
||||
TileEntity connectedTile = getConnectedTile();
|
||||
|
||||
if (connectedTile instanceof IDeepStorageUnit) {
|
||||
@@ -54,7 +54,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
ItemStack stack = deep.getStoredItemType().copy();
|
||||
|
||||
while (stack.stackSize > 0) {
|
||||
items.add(new StorageItem(stack.splitStack(Math.min(stack.getMaxStackSize(), stack.stackSize))));
|
||||
items.add(new ItemGroup(stack.splitStack(Math.min(stack.getMaxStackSize(), stack.stackSize))));
|
||||
}
|
||||
}
|
||||
} else if (connectedTile instanceof IInventory) {
|
||||
@@ -62,7 +62,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
if (inventory.getStackInSlot(i) != null) {
|
||||
items.add(new StorageItem(inventory.getStackInSlot(i)));
|
||||
items.add(new ItemGroup(inventory.getStackInSlot(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
|
||||
@Override
|
||||
public boolean canPush(ItemStack stack) {
|
||||
if (ModeSettingUtils.doesNotViolateMode(inventory, this, compare, stack)) {
|
||||
if (ModeConfigUtils.doesNotViolateMode(inventory, this, compare, stack)) {
|
||||
TileEntity connectedTile = getConnectedTile();
|
||||
|
||||
if (connectedTile instanceof IDeepStorageUnit) {
|
||||
@@ -284,7 +284,7 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorages(List<IStorage> storages) {
|
||||
public void provide(List<IStorage> storages) {
|
||||
storages.add(this);
|
||||
}
|
||||
|
||||
@@ -294,17 +294,17 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneModeSetting getRedstoneModeSetting() {
|
||||
public IRedstoneModeConfig getRedstoneModeConfig() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICompareSetting getCompareSetting() {
|
||||
public ICompareConfig getCompareConfig() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModeSetting getModeSetting() {
|
||||
public IModeConfig getModeConfig() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.tile.config.IModeConfig;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class TileImporter extends TileMachine implements ICompareSetting, IModeSetting {
|
||||
public class TileImporter extends TileMachine implements ICompareConfig, IModeConfig {
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
public static final String NBT_MODE = "Mode";
|
||||
|
||||
@@ -60,7 +60,7 @@ public class TileImporter extends TileMachine implements ICompareSetting, IModeS
|
||||
sided.markDirty();
|
||||
}
|
||||
} else {
|
||||
// If we can't import and/ or extract, move on (otherwise we stay on the same slot forever)
|
||||
// if we can't import and/or extract, move on (otherwise we stay on the same slot forever)
|
||||
currentSlot++;
|
||||
}
|
||||
}
|
||||
@@ -80,11 +80,16 @@ public class TileImporter extends TileMachine implements ICompareSetting, IModeS
|
||||
ItemStack toTake = stack.copy();
|
||||
toTake.stackSize = 1;
|
||||
|
||||
// If we can't import and/ or push, move on (otherwise we stay on the same slot forever)
|
||||
if (canImport(toTake)) {
|
||||
if (getController().push(toTake)) {
|
||||
inventory.decrStackSize(currentSlot, 1);
|
||||
inventory.markDirty();
|
||||
} else {
|
||||
currentSlot++;
|
||||
}
|
||||
} else {
|
||||
currentSlot++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -9,10 +9,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class TileInterface extends TileMachine implements ICompareSetting, ISidedInventory {
|
||||
public class TileInterface extends TileMachine implements ICompareConfig, ISidedInventory {
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
|
||||
public static final int SPEED = 3;
|
||||
|
||||
@@ -5,12 +5,11 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import refinedstorage.block.BlockMachine;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.settings.RedstoneMode;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
import refinedstorage.tile.config.RedstoneMode;
|
||||
|
||||
public abstract class TileMachine extends TileBase implements INetworkTile, IRedstoneModeSetting {
|
||||
public abstract class TileMachine extends TileBase implements INetworkTile, IRedstoneModeConfig {
|
||||
protected boolean connected = false;
|
||||
|
||||
protected RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||
|
||||
private BlockPos controllerPosition;
|
||||
@@ -78,11 +77,6 @@ public abstract class TileMachine extends TileBase implements INetworkTile, IRed
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getTilePos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public TileController getController() {
|
||||
return (TileController) worldObj.getTileEntity(controllerPosition);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package refinedstorage.tile;
|
||||
|
||||
import refinedstorage.tile.settings.RedstoneMode;
|
||||
import refinedstorage.tile.config.RedstoneMode;
|
||||
|
||||
public class TileRelay extends TileMachine {
|
||||
public TileRelay() {
|
||||
|
||||
@@ -13,15 +13,15 @@ import refinedstorage.block.EnumStorageType;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.network.MessagePriorityUpdate;
|
||||
import refinedstorage.storage.*;
|
||||
import refinedstorage.tile.settings.ICompareSetting;
|
||||
import refinedstorage.tile.settings.IModeSetting;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.settings.ModeSettingUtils;
|
||||
import refinedstorage.tile.config.ICompareConfig;
|
||||
import refinedstorage.tile.config.IModeConfig;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
import refinedstorage.tile.config.ModeConfigUtils;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileStorage extends TileMachine implements IStorageProvider, IStorage, IStorageGui, ICompareSetting, IModeSetting {
|
||||
public class TileStorage extends TileMachine implements IStorageProvider, IStorage, IStorageGui, ICompareConfig, IModeConfig {
|
||||
public static final String NBT_STORAGE = "Storage";
|
||||
public static final String NBT_PRIORITY = "Priority";
|
||||
public static final String NBT_COMPARE = "Compare";
|
||||
@@ -34,7 +34,6 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
private int priority = 0;
|
||||
private int compare = 0;
|
||||
private int mode = 0;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private int stored;
|
||||
|
||||
@@ -48,7 +47,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorages(List<IStorage> storages) {
|
||||
public void provide(List<IStorage> storages) {
|
||||
storages.add(this);
|
||||
}
|
||||
|
||||
@@ -116,7 +115,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItems(List<StorageItem> items) {
|
||||
public void addItems(List<ItemGroup> items) {
|
||||
getStorage().addItems(items);
|
||||
|
||||
markDirty();
|
||||
@@ -140,7 +139,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
|
||||
@Override
|
||||
public boolean canPush(ItemStack stack) {
|
||||
return ModeSettingUtils.doesNotViolateMode(inventory, this, compare, stack) && getStorage().canPush(stack);
|
||||
return ModeConfigUtils.doesNotViolateMode(inventory, this, compare, stack) && getStorage().canPush(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -190,17 +189,17 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneModeSetting getRedstoneModeSetting() {
|
||||
public IRedstoneModeConfig getRedstoneModeConfig() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICompareSetting getCompareSetting() {
|
||||
public ICompareConfig getCompareConfig() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModeSetting getModeSetting() {
|
||||
public IModeConfig getModeConfig() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -239,14 +238,6 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
||||
return stored;
|
||||
}
|
||||
|
||||
public int getStoredScaled(int scale) {
|
||||
if (getType() == EnumStorageType.TYPE_CREATIVE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) ((float) getStored() / (float) getCapacity() * (float) scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return getType().getCapacity();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package refinedstorage.tile.settings;
|
||||
package refinedstorage.tile.config;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface ICompareSetting {
|
||||
public interface ICompareConfig {
|
||||
int getCompare();
|
||||
|
||||
void setCompare(int compare);
|
||||
@@ -1,15 +1,15 @@
|
||||
package refinedstorage.tile.settings;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IModeSetting {
|
||||
boolean isWhitelist();
|
||||
|
||||
boolean isBlacklist();
|
||||
|
||||
void setToWhitelist();
|
||||
|
||||
void setToBlacklist();
|
||||
|
||||
BlockPos getMachinePos();
|
||||
}
|
||||
package refinedstorage.tile.config;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IModeConfig {
|
||||
boolean isWhitelist();
|
||||
|
||||
boolean isBlacklist();
|
||||
|
||||
void setToWhitelist();
|
||||
|
||||
void setToBlacklist();
|
||||
|
||||
BlockPos getMachinePos();
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package refinedstorage.tile.settings;
|
||||
package refinedstorage.tile.config;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IRedstoneModeSetting {
|
||||
public interface IRedstoneModeConfig {
|
||||
RedstoneMode getRedstoneMode();
|
||||
|
||||
void setRedstoneMode(RedstoneMode mode);
|
||||
@@ -1,39 +1,39 @@
|
||||
package refinedstorage.tile.settings;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class ModeSettingUtils {
|
||||
public static boolean doesNotViolateMode(IInventory inventory, IModeSetting mode, int compare, ItemStack stack) {
|
||||
if (mode.isWhitelist()) {
|
||||
int slots = 0;
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
|
||||
if (slot != null) {
|
||||
slots++;
|
||||
|
||||
if (InventoryUtils.compareStack(slot, stack, compare)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return slots == 0;
|
||||
} else if (mode.isBlacklist()) {
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
|
||||
if (slot != null && InventoryUtils.compareStack(slot, stack, compare)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
package refinedstorage.tile.config;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
public class ModeConfigUtils {
|
||||
public static boolean doesNotViolateMode(IInventory inventory, IModeConfig mode, int compare, ItemStack stack) {
|
||||
if (mode.isWhitelist()) {
|
||||
int slots = 0;
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
|
||||
if (slot != null) {
|
||||
slots++;
|
||||
|
||||
if (InventoryUtils.compareStack(slot, stack, compare)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return slots == 0;
|
||||
} else if (mode.isBlacklist()) {
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
|
||||
if (slot != null && InventoryUtils.compareStack(slot, stack, compare)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package refinedstorage.tile.settings;
|
||||
package refinedstorage.tile.config;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
27
src/main/java/refinedstorage/tile/grid/IGrid.java
Executable file
27
src/main/java/refinedstorage/tile/grid/IGrid.java
Executable file
@@ -0,0 +1,27 @@
|
||||
package refinedstorage.tile.grid;
|
||||
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.tile.TileController;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
|
||||
public interface IGrid {
|
||||
EnumGridType getType();
|
||||
|
||||
TileController getController();
|
||||
|
||||
int getSortingType();
|
||||
|
||||
int getSortingDirection();
|
||||
|
||||
int getSearchBoxMode();
|
||||
|
||||
void onSortingTypeChanged(int type);
|
||||
|
||||
void onSortingDirectionChanged(int direction);
|
||||
|
||||
void onSearchBoxModeChanged(int searchBoxMode);
|
||||
|
||||
IRedstoneModeConfig getRedstoneModeSetting();
|
||||
|
||||
boolean isConnected();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package refinedstorage.tile;
|
||||
package refinedstorage.tile.grid;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -8,19 +8,24 @@ import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.block.BlockGrid;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.container.ContainerGrid;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.network.MessageGridSettingsUpdate;
|
||||
import refinedstorage.tile.TileMachine;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileGrid extends TileMachine {
|
||||
public class TileGrid extends TileMachine implements IGrid {
|
||||
public static final String NBT_SORTING_DIRECTION = "SortingDirection";
|
||||
public static final String NBT_SORTING_TYPE = "SortingType";
|
||||
public static final String NBT_SEARCH_BOX_MODE = "SearchBoxMode";
|
||||
|
||||
public static final int SORTING_DIRECTION_ASCENDING = 0;
|
||||
public static final int SORTING_DIRECTION_DESCENDING = 1;
|
||||
@@ -28,6 +33,9 @@ public class TileGrid extends TileMachine {
|
||||
public static final int SORTING_TYPE_QUANTITY = 0;
|
||||
public static final int SORTING_TYPE_NAME = 1;
|
||||
|
||||
public static final int SEARCH_BOX_MODE_NORMAL = 0;
|
||||
public static final int SEARCH_BOX_MODE_JEI_SYNCHRONIZED = 1;
|
||||
|
||||
private Container craftingContainer = new Container() {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
@@ -44,6 +52,7 @@ public class TileGrid extends TileMachine {
|
||||
|
||||
private int sortingDirection = SORTING_DIRECTION_DESCENDING;
|
||||
private int sortingType = SORTING_TYPE_NAME;
|
||||
private int searchBoxMode = SEARCH_BOX_MODE_NORMAL;
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
@@ -176,6 +185,34 @@ public class TileGrid extends TileMachine {
|
||||
this.sortingType = sortingType;
|
||||
}
|
||||
|
||||
public int getSearchBoxMode() {
|
||||
return searchBoxMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSortingTypeChanged(int type) {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridSettingsUpdate(this, sortingDirection, type, searchBoxMode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSortingDirectionChanged(int direction) {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridSettingsUpdate(this, direction, sortingType, searchBoxMode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSearchBoxModeChanged(int searchBoxMode) {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageGridSettingsUpdate(this, sortingDirection, sortingType, searchBoxMode));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneModeConfig getRedstoneModeSetting() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setSearchBoxMode(int searchBoxMode) {
|
||||
this.searchBoxMode = searchBoxMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
@@ -189,6 +226,10 @@ public class TileGrid extends TileMachine {
|
||||
if (nbt.hasKey(NBT_SORTING_TYPE)) {
|
||||
sortingType = nbt.getInteger(NBT_SORTING_TYPE);
|
||||
}
|
||||
|
||||
if (nbt.hasKey(NBT_SEARCH_BOX_MODE)) {
|
||||
searchBoxMode = nbt.getInteger(NBT_SEARCH_BOX_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -199,6 +240,7 @@ public class TileGrid extends TileMachine {
|
||||
|
||||
nbt.setInteger(NBT_SORTING_DIRECTION, sortingDirection);
|
||||
nbt.setInteger(NBT_SORTING_TYPE, sortingType);
|
||||
nbt.setInteger(NBT_SEARCH_BOX_MODE, searchBoxMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,6 +249,7 @@ public class TileGrid extends TileMachine {
|
||||
|
||||
buf.writeInt(sortingDirection);
|
||||
buf.writeInt(sortingType);
|
||||
buf.writeInt(searchBoxMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,6 +258,7 @@ public class TileGrid extends TileMachine {
|
||||
|
||||
sortingDirection = buf.readInt();
|
||||
sortingType = buf.readInt();
|
||||
searchBoxMode = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
91
src/main/java/refinedstorage/tile/grid/WirelessGrid.java
Executable file
91
src/main/java/refinedstorage/tile/grid/WirelessGrid.java
Executable file
@@ -0,0 +1,91 @@
|
||||
package refinedstorage.tile.grid;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.item.ItemWirelessGrid;
|
||||
import refinedstorage.network.MessageWirelessGridSettingsUpdate;
|
||||
import refinedstorage.tile.TileController;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
|
||||
public class WirelessGrid implements IGrid {
|
||||
private ItemStack stack;
|
||||
private EnumHand hand;
|
||||
private World world;
|
||||
private int sortingType;
|
||||
private int sortingDirection;
|
||||
private int searchBoxMode;
|
||||
|
||||
public WirelessGrid(ItemStack stack, EnumHand hand, World world) {
|
||||
this.stack = stack;
|
||||
this.hand = hand;
|
||||
this.world = world;
|
||||
this.sortingType = ItemWirelessGrid.getSortingType(stack);
|
||||
this.sortingDirection = ItemWirelessGrid.getSortingDirection(stack);
|
||||
this.searchBoxMode = ItemWirelessGrid.getSearchBoxMode(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumGridType getType() {
|
||||
return EnumGridType.NORMAL;
|
||||
}
|
||||
|
||||
public TileEntity getBoundTile() {
|
||||
return world.getTileEntity(new BlockPos(ItemWirelessGrid.getX(stack), ItemWirelessGrid.getY(stack), ItemWirelessGrid.getZ(stack)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileController getController() {
|
||||
return (TileController) getBoundTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSortingType() {
|
||||
return sortingType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSortingDirection() {
|
||||
return sortingDirection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSearchBoxMode() {
|
||||
return searchBoxMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSortingTypeChanged(int type) {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageWirelessGridSettingsUpdate(hand == EnumHand.OFF_HAND ? 1 : 0, getSortingDirection(), type, getSearchBoxMode()));
|
||||
|
||||
this.sortingType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSortingDirectionChanged(int direction) {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageWirelessGridSettingsUpdate(hand == EnumHand.OFF_HAND ? 1 : 0, direction, getSortingType(), getSearchBoxMode()));
|
||||
|
||||
this.sortingDirection = direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSearchBoxModeChanged(int searchBoxMode) {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageWirelessGridSettingsUpdate(hand == EnumHand.OFF_HAND ? 1 : 0, getSortingDirection(), getSortingType(), searchBoxMode));
|
||||
|
||||
this.searchBoxMode = searchBoxMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneModeConfig getRedstoneModeSetting() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return getBoundTile() instanceof TileController && getController().isActiveClientSide();
|
||||
}
|
||||
}
|
||||
29
src/main/java/refinedstorage/tile/grid/WirelessGridConsumer.java
Executable file
29
src/main/java/refinedstorage/tile/grid/WirelessGridConsumer.java
Executable file
@@ -0,0 +1,29 @@
|
||||
package refinedstorage.tile.grid;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
public class WirelessGridConsumer {
|
||||
private EntityPlayer player;
|
||||
private EnumHand hand;
|
||||
private ItemStack wirelessGrid;
|
||||
|
||||
public WirelessGridConsumer(EntityPlayer player, EnumHand hand, ItemStack wirelessGrid) {
|
||||
this.player = player;
|
||||
this.hand = hand;
|
||||
this.wirelessGrid = wirelessGrid;
|
||||
}
|
||||
|
||||
public ItemStack getWirelessGrid() {
|
||||
return wirelessGrid;
|
||||
}
|
||||
|
||||
public EnumHand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
27
src/main/java/refinedstorage/util/HandUtils.java
Executable file
27
src/main/java/refinedstorage/util/HandUtils.java
Executable file
@@ -0,0 +1,27 @@
|
||||
package refinedstorage.util;
|
||||
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
||||
public class HandUtils {
|
||||
public static EnumHand getHandById(int id) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
return EnumHand.MAIN_HAND;
|
||||
case 1:
|
||||
return EnumHand.OFF_HAND;
|
||||
}
|
||||
|
||||
return EnumHand.MAIN_HAND;
|
||||
}
|
||||
|
||||
public static int getIdFromHand(EnumHand hand) {
|
||||
switch (hand) {
|
||||
case MAIN_HAND:
|
||||
return 0;
|
||||
case OFF_HAND:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -88,30 +88,6 @@ public class InventoryUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void pushToInventorySlot(IInventory inventory, int i, ItemStack stack) {
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
|
||||
if (slot == null) {
|
||||
inventory.setInventorySlotContents(i, stack);
|
||||
} else if (compareStackNoQuantity(slot, stack)) {
|
||||
slot.stackSize += stack.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canPushToInventorySlot(IInventory inventory, int i, ItemStack stack) {
|
||||
ItemStack slot = inventory.getStackInSlot(i);
|
||||
|
||||
if (slot == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!compareStackNoQuantity(slot, stack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return slot.stackSize + stack.stackSize < slot.getMaxStackSize();
|
||||
}
|
||||
|
||||
public static void pushToInventory(IInventory inventory, ItemStack stack) {
|
||||
int toGo = stack.stackSize;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ gui.refinedstorage:controller.machine_position.x=X: %d
|
||||
gui.refinedstorage:controller.machine_position.y=Y: %d
|
||||
gui.refinedstorage:controller.machine_position.z=Z: %d
|
||||
gui.refinedstorage:grid=Grid
|
||||
gui.refinedstorage:wireless_grid=Wireless Grid
|
||||
gui.refinedstorage:disk_drive=Drive
|
||||
gui.refinedstorage:external_storage=External Storage
|
||||
gui.refinedstorage:importer=Importer
|
||||
@@ -31,8 +32,8 @@ misc.refinedstorage:storage.full=%d%% full
|
||||
misc.refinedstorage:wireless_grid.tooltip.0=X: %d
|
||||
misc.refinedstorage:wireless_grid.tooltip.1=Y: %d
|
||||
misc.refinedstorage:wireless_grid.tooltip.2=Z: %d
|
||||
misc.refinedstorage:wireless_grid.out_of_range=Grid out of range.
|
||||
misc.refinedstorage:wireless_grid.not_found=Grid not found.
|
||||
misc.refinedstorage:wireless_grid.out_of_range=Controller out of range.
|
||||
misc.refinedstorage:wireless_grid.not_found=Controller not found.
|
||||
|
||||
misc.refinedstorage:yes=Yes
|
||||
misc.refinedstorage:no=No
|
||||
@@ -47,13 +48,15 @@ sidebutton.refinedstorage:redstone_mode.0=Ignore redstone signal
|
||||
sidebutton.refinedstorage:redstone_mode.1=Only work with redstone signal
|
||||
sidebutton.refinedstorage:redstone_mode.2=Only work without redstone signal
|
||||
|
||||
sidebutton.refinedstorage:sorting.direction=Sorting Direction
|
||||
sidebutton.refinedstorage:sorting.direction.0=Ascending
|
||||
sidebutton.refinedstorage:sorting.direction.1=Descending
|
||||
|
||||
sidebutton.refinedstorage:sorting.type=Sorting Type
|
||||
sidebutton.refinedstorage:sorting.type.0=Quantity
|
||||
sidebutton.refinedstorage:sorting.type.1=Name
|
||||
sidebutton.refinedstorage:grid.sorting.direction=Sorting Direction
|
||||
sidebutton.refinedstorage:grid.sorting.direction.0=Ascending
|
||||
sidebutton.refinedstorage:grid.sorting.direction.1=Descending
|
||||
sidebutton.refinedstorage:grid.sorting.type=Sorting Type
|
||||
sidebutton.refinedstorage:grid.sorting.type.0=Quantity
|
||||
sidebutton.refinedstorage:grid.sorting.type.1=Name
|
||||
sidebutton.refinedstorage:grid.search_box_mode=Search Box Mode
|
||||
sidebutton.refinedstorage:grid.search_box_mode.0=Normal
|
||||
sidebutton.refinedstorage:grid.search_box_mode.1=JEI synchronized
|
||||
|
||||
sidebutton.refinedstorage:mode=Mode
|
||||
sidebutton.refinedstorage:mode.whitelist=Whitelist
|
||||
|
||||
@@ -6,6 +6,7 @@ gui.refinedstorage:controller.machine_position.x=X: %d
|
||||
gui.refinedstorage:controller.machine_position.y=Y: %d
|
||||
gui.refinedstorage:controller.machine_position.z=Z: %d
|
||||
gui.refinedstorage:grid=Rooster
|
||||
gui.refinedstorage:wireless_grid=Draadloos Rooster
|
||||
gui.refinedstorage:disk_drive=Schijf
|
||||
gui.refinedstorage:external_storage=Externe Opslag
|
||||
gui.refinedstorage:importer=Importeur
|
||||
@@ -31,8 +32,8 @@ misc.refinedstorage:storage.full=%d%% vol
|
||||
misc.refinedstorage:wireless_grid.tooltip.0=X: %d
|
||||
misc.refinedstorage:wireless_grid.tooltip.1=Y: %d
|
||||
misc.refinedstorage:wireless_grid.tooltip.2=Z: %d
|
||||
misc.refinedstorage:wireless_grid.out_of_range=Rooster buiten bereik.
|
||||
misc.refinedstorage:wireless_grid.not_found=Rooster werd niet gevonden.
|
||||
misc.refinedstorage:wireless_grid.out_of_range=Controller buiten bereik.
|
||||
misc.refinedstorage:wireless_grid.not_found=Controller werd niet gevonden.
|
||||
|
||||
misc.refinedstorage:yes=Ja
|
||||
misc.refinedstorage:no=Nee
|
||||
@@ -47,13 +48,15 @@ sidebutton.refinedstorage:redstone_mode.0=Redstone negeren
|
||||
sidebutton.refinedstorage:redstone_mode.1=Alleen werken met redstone signaal
|
||||
sidebutton.refinedstorage:redstone_mode.2=Alleen werken zonder redstone signaal
|
||||
|
||||
sidebutton.refinedstorage:sorting.direction=Sorteer Richting
|
||||
sidebutton.refinedstorage:sorting.direction.0=Oplopend
|
||||
sidebutton.refinedstorage:sorting.direction.1=Aflopend
|
||||
|
||||
sidebutton.refinedstorage:sorting.type=Sorteer Type
|
||||
sidebutton.refinedstorage:sorting.type.0=Hoeveelheid
|
||||
sidebutton.refinedstorage:sorting.type.1=Naam
|
||||
sidebutton.refinedstorage:grid.sorting.direction=Sorteer Richting
|
||||
sidebutton.refinedstorage:grid.sorting.direction.0=Oplopend
|
||||
sidebutton.refinedstorage:grid.sorting.direction.1=Aflopend
|
||||
sidebutton.refinedstorage:grid.sorting.type=Sorteer Type
|
||||
sidebutton.refinedstorage:grid.sorting.type.0=Hoeveelheid
|
||||
sidebutton.refinedstorage:grid.sorting.type.1=Naam
|
||||
sidebutton.refinedstorage:grid.search_box_mode=Zoekbalk Mode
|
||||
sidebutton.refinedstorage:grid.search_box_mode.0=Normaal
|
||||
sidebutton.refinedstorage:grid.search_box_mode.1=JEI gesynchroniseerd
|
||||
|
||||
sidebutton.refinedstorage:mode=Mode
|
||||
sidebutton.refinedstorage:mode.whitelist=Whitelist
|
||||
@@ -91,7 +94,7 @@ item.refinedstorage:storage_disk.1.name=4k Opslagschijf
|
||||
item.refinedstorage:storage_disk.2.name=16k Opslagschijf
|
||||
item.refinedstorage:storage_disk.3.name=64k Opslagschijf
|
||||
item.refinedstorage:storage_disk.4.name=Creative Opslagschijf
|
||||
item.refinedstorage:wireless_grid.name=Draadloze Rooster
|
||||
item.refinedstorage:wireless_grid.name=Draadloos Rooster
|
||||
item.refinedstorage:quartz_enriched_iron.name=Quartz Verrijkt Iron
|
||||
item.refinedstorage:core.0.name=Constructie Core
|
||||
item.refinedstorage:core.1.name=Destructie Core
|
||||
|
||||
20
src/main/resources/assets/refinedstorage/models/item/wireless_grid.json
Executable file
20
src/main/resources/assets/refinedstorage/models/item/wireless_grid.json
Executable file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "refinedstorage:items/wireless_grid_disconnected"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"predicate": {
|
||||
"connected": 0
|
||||
},
|
||||
"model": "refinedstorage:item/wireless_grid_disconnected"
|
||||
},
|
||||
{
|
||||
"predicate": {
|
||||
"connected": 1
|
||||
},
|
||||
"model": "refinedstorage:item/wireless_grid_connected"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Reference in New Issue
Block a user