Renames and general code improvements
This commit is contained in:
@@ -40,8 +40,7 @@ public abstract class BlockBase extends Block {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,11 +5,10 @@ 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 refinedstorage.tile.TileController;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.tile.TileMachine;
|
||||
|
||||
public class BlockCable extends BlockBase {
|
||||
@@ -28,8 +27,7 @@ public class BlockCable extends BlockBase {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
NORTH,
|
||||
EAST,
|
||||
@@ -54,13 +52,7 @@ 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
|
||||
|
||||
@@ -38,8 +38,7 @@ public class BlockController extends BlockBase {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
TYPE,
|
||||
ENERGY
|
||||
|
||||
@@ -25,8 +25,7 @@ public class BlockDetector extends BlockMachine {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
CONNECTED,
|
||||
POWERED
|
||||
|
||||
@@ -40,8 +40,7 @@ public class BlockGrid extends BlockMachine {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
CONNECTED,
|
||||
TYPE
|
||||
|
||||
@@ -22,8 +22,7 @@ public abstract class BlockMachine extends BlockBase {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
CONNECTED
|
||||
});
|
||||
|
||||
@@ -41,8 +41,7 @@ public class BlockStorage extends BlockMachine {
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, new IProperty[]
|
||||
{
|
||||
return new BlockStateContainer(this, new IProperty[]{
|
||||
DIRECTION,
|
||||
CONNECTED,
|
||||
TYPE
|
||||
@@ -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);
|
||||
|
||||
@@ -43,7 +43,6 @@ public enum EnumStorageType implements IStringSerializable {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return TYPE_1K;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ public class ContainerGrid extends ContainerBase {
|
||||
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) {
|
||||
|
||||
@@ -19,7 +19,7 @@ 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.grid.IGrid;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
@@ -31,7 +31,7 @@ public class GuiGrid extends GuiBase {
|
||||
private ContainerGrid container;
|
||||
private IGrid grid;
|
||||
|
||||
private List<StorageItem> items = new ArrayList<StorageItem>();
|
||||
private List<ItemGroup> items = new ArrayList<ItemGroup>();
|
||||
|
||||
private GuiTextField searchField;
|
||||
|
||||
@@ -77,10 +77,10 @@ public class GuiGrid extends GuiBase {
|
||||
items.addAll(grid.getController().getItems());
|
||||
|
||||
if (!searchField.getText().trim().isEmpty()) {
|
||||
Iterator<StorageItem> t = items.iterator();
|
||||
Iterator<ItemGroup> t = items.iterator();
|
||||
|
||||
while (t.hasNext()) {
|
||||
StorageItem item = t.next();
|
||||
ItemGroup item = t.next();
|
||||
|
||||
if (!item.toItemStack().getDisplayName().toLowerCase().contains(searchField.getText().toLowerCase())) {
|
||||
t.remove();
|
||||
@@ -88,9 +88,9 @@ public class GuiGrid extends GuiBase {
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(items, new Comparator<StorageItem>() {
|
||||
Collections.sort(items, new Comparator<ItemGroup>() {
|
||||
@Override
|
||||
public int compare(StorageItem o1, StorageItem o2) {
|
||||
public int compare(ItemGroup o1, ItemGroup o2) {
|
||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||
return o2.toItemStack().getDisplayName().compareTo(o1.toItemStack().getDisplayName());
|
||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||
@@ -102,9 +102,9 @@ public class GuiGrid extends GuiBase {
|
||||
});
|
||||
|
||||
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) {
|
||||
public int compare(ItemGroup o1, ItemGroup o2) {
|
||||
if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_ASCENDING) {
|
||||
return Integer.valueOf(o2.getQuantity()).compareTo(o1.getQuantity());
|
||||
} else if (grid.getSortingDirection() == TileGrid.SORTING_DIRECTION_DESCENDING) {
|
||||
@@ -187,7 +187,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();
|
||||
}
|
||||
|
||||
@@ -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,15 +4,15 @@ 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;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SideButtonCompare extends SideButton {
|
||||
|
||||
builder.append(TextFormatting.YELLOW).append(gui.t("sidebutton.refinedstorage:compare." + mask)).append(TextFormatting.RESET).append("\n");
|
||||
|
||||
if ((setting.getCompare() & mask) == mask) {
|
||||
if ((config.getCompare() & mask) == mask) {
|
||||
builder.append(gui.t("misc.refinedstorage:yes"));
|
||||
} else {
|
||||
builder.append(gui.t("misc.refinedstorage:no"));
|
||||
@@ -43,13 +43,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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageCompareUpdate(setting, setting.getCompare() ^ mask));
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageCompareUpdate(config, config.getCompare() ^ mask));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ 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
|
||||
@@ -18,7 +18,7 @@ public class SideButtonMode extends SideButton {
|
||||
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")));
|
||||
builder.append(gui.t("sidebutton.refinedstorage:mode." + (config.isWhitelist() ? "whitelist" : "blacklist")));
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
@@ -29,9 +29,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 +40,6 @@ public class SideButtonMode extends SideButton {
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageModeToggle(mode));
|
||||
RefinedStorage.NETWORK.sendToServer(new MessageModeToggle(config));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ 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
|
||||
@@ -18,7 +18,7 @@ public class SideButtonRedstoneMode extends SideButton {
|
||||
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));
|
||||
builder.append(gui.t("sidebutton.refinedstorage:redstone_mode." + config.getRedstoneMode().id));
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
@@ -26,11 +26,11 @@ public class SideButtonRedstoneMode extends SideButton {
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -29,16 +29,20 @@ public class ItemStorageDisk extends ItemBase {
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
list.add(NBTStorage.initNBT(new ItemStack(item, 1, i)));
|
||||
ItemStack disk = new ItemStack(item, 1, i);
|
||||
disk.setTagCompound(NBTStorage.getBaseNBT());
|
||||
list.add(disk);
|
||||
}
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +50,6 @@ public class ItemStorageDisk extends ItemBase {
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player) {
|
||||
super.onCreated(stack, world, player);
|
||||
|
||||
NBTStorage.initNBT(stack);
|
||||
stack.setTagCompound(NBTStorage.getBaseNBT());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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.item.ItemWirelessGrid;
|
||||
import refinedstorage.storage.StorageItem;
|
||||
import refinedstorage.storage.ItemGroup;
|
||||
import refinedstorage.tile.TileController;
|
||||
|
||||
public class MessageStoragePull extends MessageHandlerPlayerToServer<MessageStoragePull> implements IMessage {
|
||||
@@ -70,7 +70,7 @@ public class MessageStoragePull extends MessageHandlerPlayerToServer<MessageStor
|
||||
TileController controller = (TileController) tile;
|
||||
|
||||
if (message.id < controller.getItems().size()) {
|
||||
StorageItem item = controller.getItems().get(message.id);
|
||||
ItemGroup item = controller.getItems().get(message.id);
|
||||
|
||||
int quantity = 64;
|
||||
|
||||
@@ -83,7 +83,7 @@ public class MessageStoragePull extends MessageHandlerPlayerToServer<MessageStor
|
||||
} else if (message.isPullingOne()) {
|
||||
quantity = 1;
|
||||
} else if (message.isPullingWithShift()) {
|
||||
// NO OP, the default quantity (64) will be fine
|
||||
// NO OP, the quantity already set (64) is needed for shift
|
||||
}
|
||||
|
||||
if (quantity > item.getType().getItemStackLimit(item.toItemStack())) {
|
||||
|
||||
@@ -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,7 +27,7 @@ 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) {
|
||||
@@ -44,7 +44,7 @@ public class NBTStorage implements IStorage {
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||
|
||||
StorageItem item = createItemFromNBT(tag);
|
||||
ItemGroup item = createItemFromNBT(tag);
|
||||
|
||||
if (item.compareNoQuantity(stack)) {
|
||||
tag.setInteger(NBT_ITEM_QUANTITY, item.getQuantity() + stack.stackSize);
|
||||
@@ -75,7 +75,7 @@ public class NBTStorage implements IStorage {
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||
|
||||
StorageItem item = createItemFromNBT(tag);
|
||||
ItemGroup item = createItemFromNBT(tag);
|
||||
|
||||
if (item.compare(stack, flags)) {
|
||||
if (quantity > item.getQuantity()) {
|
||||
@@ -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 createItemFromNBT(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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -19,17 +19,17 @@ import refinedstorage.block.EnumControllerType;
|
||||
import refinedstorage.item.ItemWirelessGrid;
|
||||
import refinedstorage.storage.IStorage;
|
||||
import refinedstorage.storage.IStorageProvider;
|
||||
import refinedstorage.storage.StorageItem;
|
||||
import refinedstorage.storage.ItemGroup;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
import refinedstorage.tile.config.RedstoneMode;
|
||||
import refinedstorage.tile.grid.WirelessGridConsumer;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.settings.RedstoneMode;
|
||||
import refinedstorage.util.HandUtils;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
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> items = new ArrayList<ItemGroup>();
|
||||
private List<IStorage> storages = new ArrayList<IStorage>();
|
||||
private List<WirelessGridConsumer> wirelessGridConsumers = new ArrayList<WirelessGridConsumer>();
|
||||
private List<WirelessGridConsumer> wirelessGridConsumersMarkedForRemoval = new ArrayList<WirelessGridConsumer>();
|
||||
@@ -84,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
return machines;
|
||||
}
|
||||
|
||||
public List<StorageItem> getItems() {
|
||||
public List<ItemGroup> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -184,14 +184,14 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
continue;
|
||||
}
|
||||
|
||||
StorageItem item = items.get(i);
|
||||
ItemGroup item = items.get(i);
|
||||
|
||||
for (int j = i + 1; j < items.size(); ++j) {
|
||||
if (markedIndexes.contains(j)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
StorageItem other = items.get(j);
|
||||
ItemGroup other = items.get(j);
|
||||
|
||||
if (item.compareNoQuantity(other)) {
|
||||
item.setQuantity(item.getQuantity() + other.getQuantity());
|
||||
@@ -201,7 +201,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
}
|
||||
}
|
||||
|
||||
List<StorageItem> markedItems = new ArrayList<StorageItem>();
|
||||
List<ItemGroup> markedItems = new ArrayList<ItemGroup>();
|
||||
|
||||
for (int i : markedIndexes) {
|
||||
markedItems.add(items.get(i));
|
||||
@@ -411,7 +411,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
int size = buf.readInt();
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
items.add(new StorageItem(buf));
|
||||
items.add(new ItemGroup(buf));
|
||||
}
|
||||
|
||||
machines.clear();
|
||||
@@ -438,7 +438,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
|
||||
buf.writeInt(items.size());
|
||||
|
||||
for (StorageItem item : items) {
|
||||
for (ItemGroup item : items) {
|
||||
item.toBytes(buf, items.indexOf(item));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,14 @@ 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";
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TileDestructor extends TileMachine implements ICompareSetting, IMod
|
||||
Block frontBlock = frontBlockState.getBlock();
|
||||
|
||||
if (Item.getItemFromBlock(frontBlock) != null && !frontBlock.isAir(frontBlockState, worldObj, front)) {
|
||||
if (ModeSettingUtils.doesNotViolateMode(inventory, this, compare, new ItemStack(frontBlock, 1, frontBlock.getMetaFromState(frontBlockState)))) {
|
||||
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,7 +50,7 @@ public class TileDetector extends TileMachine implements ICompareSetting {
|
||||
if (slot != null) {
|
||||
boolean foundAny = false;
|
||||
|
||||
for (StorageItem item : getController().getItems()) {
|
||||
for (ItemGroup item : getController().getItems()) {
|
||||
if (item.compare(slot, compare)) {
|
||||
foundAny = true;
|
||||
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,8 +1,8 @@
|
||||
package refinedstorage.tile.settings;
|
||||
package refinedstorage.tile.config;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IModeSetting {
|
||||
public interface IModeConfig {
|
||||
boolean isWhitelist();
|
||||
|
||||
boolean isBlacklist();
|
||||
@@ -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,11 +1,11 @@
|
||||
package refinedstorage.tile.settings;
|
||||
package refinedstorage.tile.config;
|
||||
|
||||
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) {
|
||||
public class ModeConfigUtils {
|
||||
public static boolean doesNotViolateMode(IInventory inventory, IModeConfig mode, int compare, ItemStack stack) {
|
||||
if (mode.isWhitelist()) {
|
||||
int slots = 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package refinedstorage.tile.settings;
|
||||
package refinedstorage.tile.config;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -2,7 +2,7 @@ package refinedstorage.tile.grid;
|
||||
|
||||
import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.tile.TileController;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
|
||||
public interface IGrid {
|
||||
EnumGridType getType();
|
||||
@@ -21,7 +21,7 @@ public interface IGrid {
|
||||
|
||||
void onSearchBoxModeChanged(int searchBoxMode);
|
||||
|
||||
IRedstoneModeSetting getRedstoneModeSetting();
|
||||
IRedstoneModeConfig getRedstoneModeSetting();
|
||||
|
||||
boolean isConnected();
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import refinedstorage.container.ContainerGrid;
|
||||
import refinedstorage.inventory.InventorySimple;
|
||||
import refinedstorage.network.MessageGridSettingsUpdate;
|
||||
import refinedstorage.tile.TileMachine;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
import refinedstorage.util.InventoryUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -205,7 +205,7 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneModeSetting getRedstoneModeSetting() {
|
||||
public IRedstoneModeConfig getRedstoneModeSetting() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import refinedstorage.block.EnumGridType;
|
||||
import refinedstorage.item.ItemWirelessGrid;
|
||||
import refinedstorage.network.MessageWirelessGridSettingsUpdate;
|
||||
import refinedstorage.tile.TileController;
|
||||
import refinedstorage.tile.settings.IRedstoneModeSetting;
|
||||
import refinedstorage.tile.config.IRedstoneModeConfig;
|
||||
|
||||
public class WirelessGrid implements IGrid {
|
||||
private ItemStack stack;
|
||||
@@ -75,7 +75,7 @@ public class WirelessGrid implements IGrid {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneModeSetting getRedstoneModeSetting() {
|
||||
public IRedstoneModeConfig getRedstoneModeSetting() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user