fixes
- remove ImporterMode, just use an int - make some classes abstract - made range on TE's bigger
This commit is contained in:
@@ -13,7 +13,7 @@ import storagecraft.StorageCraft;
|
|||||||
import storagecraft.tile.TileBase;
|
import storagecraft.tile.TileBase;
|
||||||
import storagecraft.util.InventoryUtils;
|
import storagecraft.util.InventoryUtils;
|
||||||
|
|
||||||
public class BlockBase extends Block {
|
public abstract class BlockBase extends Block {
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public BlockBase(String name) {
|
public BlockBase(String name) {
|
||||||
|
@@ -6,7 +6,7 @@ import net.minecraft.inventory.Slot;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import storagecraft.container.slot.SlotSpecimen;
|
import storagecraft.container.slot.SlotSpecimen;
|
||||||
|
|
||||||
public class ContainerBase extends Container {
|
public abstract class ContainerBase extends Container {
|
||||||
private EntityPlayer player;
|
private EntityPlayer player;
|
||||||
|
|
||||||
public ContainerBase(EntityPlayer player) {
|
public ContainerBase(EntityPlayer player) {
|
||||||
|
@@ -49,14 +49,6 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
drawForeground(mouseX - guiLeft, mouseY - guiTop);
|
drawForeground(mouseX - guiLeft, mouseY - guiTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void init(int x, int y);
|
|
||||||
|
|
||||||
public abstract void update(int x, int y);
|
|
||||||
|
|
||||||
public abstract void drawBackground(int x, int y, int mouseX, int mouseY);
|
|
||||||
|
|
||||||
public abstract void drawForeground(int mouseX, int mouseY);
|
|
||||||
|
|
||||||
protected boolean inBounds(int x, int y, int w, int h, int ox, int oy) {
|
protected boolean inBounds(int x, int y, int w, int h, int ox, int oy) {
|
||||||
return ox >= x && ox <= x + w && oy >= y && oy <= y + h;
|
return ox >= x && ox <= x + w && oy >= y && oy <= y + h;
|
||||||
}
|
}
|
||||||
@@ -204,4 +196,12 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
protected String t(String name, Object... format) {
|
protected String t(String name, Object... format) {
|
||||||
return StatCollector.translateToLocalFormatted(name, format);
|
return StatCollector.translateToLocalFormatted(name, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void init(int x, int y);
|
||||||
|
|
||||||
|
public abstract void update(int x, int y);
|
||||||
|
|
||||||
|
public abstract void drawBackground(int x, int y, int mouseX, int mouseY);
|
||||||
|
|
||||||
|
public abstract void drawForeground(int mouseX, int mouseY);
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ public class GuiImporter extends GuiMachine {
|
|||||||
compareDamage.displayString = t("misc.storagecraft:compareDamage") + ": ";
|
compareDamage.displayString = t("misc.storagecraft:compareDamage") + ": ";
|
||||||
compareDamage.displayString += t("misc.storagecraft:" + ((importer.getCompareFlags() & InventoryUtils.COMPARE_DAMAGE) == InventoryUtils.COMPARE_DAMAGE ? "on" : "off"));
|
compareDamage.displayString += t("misc.storagecraft:" + ((importer.getCompareFlags() & InventoryUtils.COMPARE_DAMAGE) == InventoryUtils.COMPARE_DAMAGE ? "on" : "off"));
|
||||||
|
|
||||||
mode.displayString = t("misc.storagecraft:importer.mode." + importer.getMode().id);
|
mode.displayString = t("misc.storagecraft:importer.mode." + importer.getMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -4,7 +4,7 @@ import net.minecraft.item.Item;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import storagecraft.StorageCraft;
|
import storagecraft.StorageCraft;
|
||||||
|
|
||||||
public class ItemBase extends Item {
|
public abstract class ItemBase extends Item {
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public ItemBase(String name) {
|
public ItemBase(String name) {
|
||||||
|
@@ -4,7 +4,7 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.item.ItemBlockWithMetadata;
|
import net.minecraft.item.ItemBlockWithMetadata;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class ItemBlockBase extends ItemBlockWithMetadata {
|
public abstract class ItemBlockBase extends ItemBlockWithMetadata {
|
||||||
public ItemBlockBase(Block block) {
|
public ItemBlockBase(Block block) {
|
||||||
super(block, block);
|
super(block, block);
|
||||||
}
|
}
|
||||||
|
@@ -56,7 +56,7 @@ public class MessageImporterUpdate implements IMessage, IMessageHandler<MessageI
|
|||||||
importer.setCompareFlags(message.compareFlags);
|
importer.setCompareFlags(message.compareFlags);
|
||||||
|
|
||||||
if (message.nextMode) {
|
if (message.nextMode) {
|
||||||
importer.setMode(importer.getMode().next());
|
importer.setMode(importer.getMode() == TileImporter.MODE_WHITELIST ? TileImporter.MODE_BLACKLIST : TileImporter.MODE_WHITELIST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,31 +0,0 @@
|
|||||||
package storagecraft.tile;
|
|
||||||
|
|
||||||
public enum ImporterMode {
|
|
||||||
WHITELIST(0), BLACKLIST(1);
|
|
||||||
|
|
||||||
public final int id;
|
|
||||||
|
|
||||||
ImporterMode(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImporterMode next() {
|
|
||||||
ImporterMode next = getById(id + 1);
|
|
||||||
|
|
||||||
if (next == null) {
|
|
||||||
return getById(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return next;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ImporterMode getById(int id) {
|
|
||||||
for (ImporterMode mode : values()) {
|
|
||||||
if (mode.id == id) {
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -10,8 +10,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
import storagecraft.StorageCraft;
|
import storagecraft.StorageCraft;
|
||||||
import storagecraft.network.MessageTileUpdate;
|
import storagecraft.network.MessageTileUpdate;
|
||||||
|
|
||||||
public class TileBase extends TileEntity {
|
public abstract class TileBase extends TileEntity {
|
||||||
public static final int UPDATE_RANGE = 64;
|
public static final int UPDATE_RANGE = 256;
|
||||||
|
|
||||||
private ForgeDirection direction = ForgeDirection.UNKNOWN;
|
private ForgeDirection direction = ForgeDirection.UNKNOWN;
|
||||||
|
|
||||||
|
@@ -11,13 +11,16 @@ import storagecraft.inventory.InventorySimple;
|
|||||||
import storagecraft.util.InventoryUtils;
|
import storagecraft.util.InventoryUtils;
|
||||||
|
|
||||||
public class TileImporter extends TileMachine implements IInventory, ISidedInventory {
|
public class TileImporter extends TileMachine implements IInventory, ISidedInventory {
|
||||||
|
public static final int MODE_WHITELIST = 0;
|
||||||
|
public static final int MODE_BLACKLIST = 1;
|
||||||
|
|
||||||
public static final String NBT_COMPARE_FLAGS = "CompareFlags";
|
public static final String NBT_COMPARE_FLAGS = "CompareFlags";
|
||||||
public static final String NBT_MODE = "Mode";
|
public static final String NBT_MODE = "Mode";
|
||||||
|
|
||||||
private InventorySimple inventory = new InventorySimple("importer", 9);
|
private InventorySimple inventory = new InventorySimple("importer", 9);
|
||||||
|
|
||||||
private int compareFlags = 0;
|
private int compareFlags = 0;
|
||||||
private ImporterMode mode = ImporterMode.WHITELIST;
|
private int mode = MODE_WHITELIST;
|
||||||
|
|
||||||
private int currentSlot = 0;
|
private int currentSlot = 0;
|
||||||
|
|
||||||
@@ -79,16 +82,16 @@ public class TileImporter extends TileMachine implements IInventory, ISidedInven
|
|||||||
slots++;
|
slots++;
|
||||||
|
|
||||||
if (InventoryUtils.compareStack(stack, slot, compareFlags)) {
|
if (InventoryUtils.compareStack(stack, slot, compareFlags)) {
|
||||||
if (mode == ImporterMode.WHITELIST) {
|
if (mode == MODE_WHITELIST) {
|
||||||
return true;
|
return true;
|
||||||
} else if (mode == ImporterMode.BLACKLIST) {
|
} else if (mode == MODE_BLACKLIST) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == ImporterMode.WHITELIST) {
|
if (mode == MODE_WHITELIST) {
|
||||||
return slots == 0;
|
return slots == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,11 +106,11 @@ public class TileImporter extends TileMachine implements IInventory, ISidedInven
|
|||||||
this.compareFlags = flags;
|
this.compareFlags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImporterMode getMode() {
|
public int getMode() {
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMode(ImporterMode mode) {
|
public void setMode(int mode) {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +198,7 @@ public class TileImporter extends TileMachine implements IInventory, ISidedInven
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nbt.hasKey(NBT_MODE)) {
|
if (nbt.hasKey(NBT_MODE)) {
|
||||||
mode = ImporterMode.getById(nbt.getInteger(NBT_MODE));
|
mode = nbt.getInteger(NBT_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
InventoryUtils.restoreInventory(this, nbt);
|
InventoryUtils.restoreInventory(this, nbt);
|
||||||
@@ -206,7 +209,7 @@ public class TileImporter extends TileMachine implements IInventory, ISidedInven
|
|||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
nbt.setInteger(NBT_COMPARE_FLAGS, compareFlags);
|
nbt.setInteger(NBT_COMPARE_FLAGS, compareFlags);
|
||||||
nbt.setInteger(NBT_MODE, mode.id);
|
nbt.setInteger(NBT_MODE, mode);
|
||||||
|
|
||||||
InventoryUtils.saveInventory(this, nbt);
|
InventoryUtils.saveInventory(this, nbt);
|
||||||
}
|
}
|
||||||
@@ -216,7 +219,7 @@ public class TileImporter extends TileMachine implements IInventory, ISidedInven
|
|||||||
super.fromBytes(buf);
|
super.fromBytes(buf);
|
||||||
|
|
||||||
compareFlags = buf.readInt();
|
compareFlags = buf.readInt();
|
||||||
mode = ImporterMode.getById(buf.readInt());
|
mode = buf.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -224,6 +227,6 @@ public class TileImporter extends TileMachine implements IInventory, ISidedInven
|
|||||||
super.toBytes(buf);
|
super.toBytes(buf);
|
||||||
|
|
||||||
buf.writeInt(compareFlags);
|
buf.writeInt(compareFlags);
|
||||||
buf.writeInt(mode.id);
|
buf.writeInt(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user