Grid Filter item and GUI
This commit is contained in:
@@ -18,4 +18,5 @@ public final class RefinedStorageGui {
|
||||
public static final int WIRELESS_TRANSMITTER = 14;
|
||||
public static final int CRAFTER = 15;
|
||||
public static final int PROCESSING_PATTERN_ENCODER = 16;
|
||||
public static final int GRID_FILTER = 17;
|
||||
}
|
||||
|
||||
@@ -13,4 +13,5 @@ public final class RefinedStorageItems {
|
||||
public static final ItemPattern PATTERN = new ItemPattern();
|
||||
public static final ItemUpgrade UPGRADE = new ItemUpgrade();
|
||||
public static final ItemStorageHousing STORAGE_HOUSING = new ItemStorageHousing();
|
||||
public static final ItemGridFilter GRID_FILTER = new ItemGridFilter();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,14 @@ public abstract class ContainerBase extends Container {
|
||||
int id = 0;
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
addSlotToContainer(new Slot(player.inventory, id, xInventory + i * 18, yInventory + 4 + (3 * 18)));
|
||||
int x = xInventory + i * 18;
|
||||
int y = yInventory + 4 + (3 * 18);
|
||||
|
||||
if (ContainerBase.this instanceof ContainerGridFilter && i == ((ContainerGridFilter) ContainerBase.this).slot) {
|
||||
addSlotToContainer(new SlotDisabled(player.inventory, id, x, y));
|
||||
} else {
|
||||
addSlotToContainer(new Slot(player.inventory, id, x, y));
|
||||
}
|
||||
|
||||
id++;
|
||||
}
|
||||
|
||||
55
src/main/java/refinedstorage/container/ContainerGridFilter.java
Executable file
55
src/main/java/refinedstorage/container/ContainerGridFilter.java
Executable file
@@ -0,0 +1,55 @@
|
||||
package refinedstorage.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.container.slot.SlotSpecimen;
|
||||
import refinedstorage.inventory.GridFilterItemHandler;
|
||||
|
||||
public class ContainerGridFilter extends ContainerBase {
|
||||
private GridFilterItemHandler itemHandler;
|
||||
|
||||
protected int slot;
|
||||
|
||||
public ContainerGridFilter(EntityPlayer player, ItemStack gridFilter, int slot) {
|
||||
super(player);
|
||||
|
||||
this.slot = slot;
|
||||
this.itemHandler = new GridFilterItemHandler(gridFilter);
|
||||
|
||||
int x = 8;
|
||||
int y = 20;
|
||||
|
||||
for (int i = 0; i < 9 * 3; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(itemHandler, i, x, y));
|
||||
|
||||
if ((i + 1) % 9 == 0) {
|
||||
y += 18;
|
||||
x = 8;
|
||||
} else {
|
||||
x += 18;
|
||||
}
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 91);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
ItemStack stack = null;
|
||||
|
||||
Slot slot = getSlot(index);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
stack = slot.getStack();
|
||||
|
||||
if (index > (9 * 3) - 1) {
|
||||
return mergeItemStackToSpecimen(stack, 0, 9 * 3);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
30
src/main/java/refinedstorage/gui/GuiGridFilter.java
Executable file
30
src/main/java/refinedstorage/gui/GuiGridFilter.java
Executable file
@@ -0,0 +1,30 @@
|
||||
package refinedstorage.gui;
|
||||
|
||||
import refinedstorage.container.ContainerGridFilter;
|
||||
|
||||
public class GuiGridFilter extends GuiBase {
|
||||
public GuiGridFilter(ContainerGridFilter container) {
|
||||
super(container, 176, 183);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/grid_filter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:grid_filter"));
|
||||
drawString(7, 79, t("container.inventory"));
|
||||
}
|
||||
}
|
||||
@@ -59,11 +59,17 @@ public class GuiHandler implements IGuiHandler {
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (ID == RefinedStorageGui.WIRELESS_GRID) {
|
||||
return getWirelessGridContainer(player, x);
|
||||
} else if (ID == RefinedStorageGui.GRID_FILTER) {
|
||||
return getGridFilterContainer(player, x);
|
||||
}
|
||||
|
||||
return getContainer(ID, player, world.getTileEntity(new BlockPos(x, y, z)));
|
||||
}
|
||||
|
||||
private ContainerGridFilter getGridFilterContainer(EntityPlayer player, int hand) {
|
||||
return new ContainerGridFilter(player, player.getHeldItem(EnumHand.values()[hand]), player.inventory.currentItem);
|
||||
}
|
||||
|
||||
private WirelessGrid getWirelessGrid(EntityPlayer player, int hand) {
|
||||
return new WirelessGrid(player.worldObj, player.getHeldItem(EnumHand.values()[hand]), EnumHand.values()[hand]);
|
||||
}
|
||||
@@ -119,6 +125,8 @@ public class GuiHandler implements IGuiHandler {
|
||||
return new GuiCrafter((ContainerCrafter) getContainer(ID, player, tile), (TileCrafter) tile);
|
||||
case RefinedStorageGui.PROCESSING_PATTERN_ENCODER:
|
||||
return new GuiProcessingPatternEncoder((ContainerProcessingPatternEncoder) getContainer(ID, player, tile), (TileProcessingPatternEncoder) tile);
|
||||
case RefinedStorageGui.GRID_FILTER:
|
||||
return new GuiGridFilter(getGridFilterContainer(player, x));
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
31
src/main/java/refinedstorage/inventory/GridFilterItemHandler.java
Executable file
31
src/main/java/refinedstorage/inventory/GridFilterItemHandler.java
Executable file
@@ -0,0 +1,31 @@
|
||||
package refinedstorage.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import refinedstorage.tile.TileBase;
|
||||
|
||||
public class GridFilterItemHandler extends ItemStackHandler {
|
||||
private ItemStack filter;
|
||||
|
||||
public GridFilterItemHandler(ItemStack filter) {
|
||||
super(9 * 3);
|
||||
|
||||
this.filter = filter;
|
||||
|
||||
if (filter.hasTagCompound()) {
|
||||
TileBase.readItems(this, 0, filter.getTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onContentsChanged(int slot) {
|
||||
super.onContentsChanged(slot);
|
||||
|
||||
if (!filter.hasTagCompound()) {
|
||||
filter.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
TileBase.writeItems(this, 0, filter.getTagCompound());
|
||||
}
|
||||
}
|
||||
29
src/main/java/refinedstorage/item/ItemGridFilter.java
Executable file
29
src/main/java/refinedstorage/item/ItemGridFilter.java
Executable file
@@ -0,0 +1,29 @@
|
||||
package refinedstorage.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageGui;
|
||||
|
||||
public class ItemGridFilter extends ItemBase {
|
||||
public ItemGridFilter() {
|
||||
super("grid_filter");
|
||||
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
|
||||
if (!world.isRemote) {
|
||||
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.GRID_FILTER, world, hand.ordinal(), 0, 0);
|
||||
|
||||
return new ActionResult(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
|
||||
return new ActionResult(EnumActionResult.PASS, stack);
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,7 @@ public class ClientProxy extends CommonProxy {
|
||||
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.WIRELESS_GRID, 0, new ModelResourceLocation("refinedstorage:wireless_grid", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.PATTERN, 0, new ModelResourceLocation("refinedstorage:pattern", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.STORAGE_HOUSING, 0, new ModelResourceLocation("refinedstorage:storage_housing", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.GRID_FILTER, 0, new ModelResourceLocation("refinedstorage:grid_filter", "inventory"));
|
||||
|
||||
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.UPGRADE, 0, new ModelResourceLocation("refinedstorage:upgrade", "inventory"));
|
||||
ModelLoader.setCustomModelResourceLocation(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_RANGE, new ModelResourceLocation("refinedstorage:range_upgrade", "inventory"));
|
||||
|
||||
@@ -110,6 +110,7 @@ public class CommonProxy {
|
||||
registerItem(RefinedStorageItems.CORE);
|
||||
registerItem(RefinedStorageItems.SILICON);
|
||||
registerItem(RefinedStorageItems.UPGRADE);
|
||||
registerItem(RefinedStorageItems.GRID_FILTER);
|
||||
|
||||
OreDictionary.registerOre("itemSilicon", RefinedStorageItems.SILICON);
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ public abstract class TileBase extends TileEntity implements ITickable {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void writeItems(IItemHandler handler, int id, NBTTagCompound nbt) {
|
||||
public static void writeItems(IItemHandler handler, int id, NBTTagCompound nbt) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
@@ -152,7 +152,7 @@ public abstract class TileBase extends TileEntity implements ITickable {
|
||||
nbt.setTag(String.format(NBT_INVENTORY, id), tagList);
|
||||
}
|
||||
|
||||
protected void readItems(IItemHandler handler, int id, NBTTagCompound nbt) {
|
||||
public static void readItems(IItemHandler handler, int id, NBTTagCompound nbt) {
|
||||
String name = String.format(NBT_INVENTORY, id);
|
||||
|
||||
if (nbt.hasKey(name)) {
|
||||
@@ -168,7 +168,7 @@ public abstract class TileBase extends TileEntity implements ITickable {
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeItemsLegacy(IInventory inventory, int id, NBTTagCompound nbt) {
|
||||
public static void writeItemsLegacy(IInventory inventory, int id, NBTTagCompound nbt) {
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
@@ -186,7 +186,7 @@ public abstract class TileBase extends TileEntity implements ITickable {
|
||||
nbt.setTag(String.format(NBT_INVENTORY, id), tagList);
|
||||
}
|
||||
|
||||
protected void readItemsLegacy(IInventory inventory, int id, NBTTagCompound nbt) {
|
||||
public static void readItemsLegacy(IInventory inventory, int id, NBTTagCompound nbt) {
|
||||
String name = String.format(NBT_INVENTORY, id);
|
||||
|
||||
if (nbt.hasKey(name)) {
|
||||
|
||||
@@ -30,6 +30,7 @@ gui.refinedstorage:crafter=Crafter
|
||||
gui.refinedstorage:crafter.processing=Processing
|
||||
gui.refinedstorage:processing_pattern_encoder=Processing Pattern Encoder
|
||||
gui.refinedstorage:processing_pattern_encoder.pattern_create=Create Pattern
|
||||
gui.refinedstorage:grid_filter=Grid Filter
|
||||
|
||||
misc.refinedstorage:energy_stored=%d / %d RS
|
||||
misc.refinedstorage:energy_usage=Usage: %d RS/t
|
||||
@@ -145,3 +146,4 @@ item.refinedstorage:upgrade.2.name=Speed Upgrade
|
||||
item.refinedstorage:upgrade.3.name=Crafting Upgrade
|
||||
item.refinedstorage:upgrade.4.name=Stack Upgrade
|
||||
item.refinedstorage:storage_housing.name=Storage Housing
|
||||
item.refinedstorage:grid_filter.name=Grid Filter
|
||||
@@ -30,6 +30,7 @@ gui.refinedstorage:crafter=Crafter
|
||||
gui.refinedstorage:crafter.processing=Verwerking
|
||||
gui.refinedstorage:processing_pattern_encoder=Verwerkingspatroon Codeerder
|
||||
gui.refinedstorage:processing_pattern_encoder.pattern_create=Patroon maken
|
||||
gui.refinedstorage:grid_filter=Rooster Filter
|
||||
|
||||
misc.refinedstorage:energy_stored=%d / %d RS
|
||||
misc.refinedstorage:energy_usage=Vebruik: %d RS/t
|
||||
@@ -145,3 +146,4 @@ item.refinedstorage:upgrade.2.name=Snelheid Upgrade
|
||||
item.refinedstorage:upgrade.3.name=Crafting Upgrade
|
||||
item.refinedstorage:upgrade.4.name=Stack Upgrade
|
||||
item.refinedstorage:storage_housing.name=Opslagomhulsel
|
||||
item.refinedstorage:grid_filter.name=Rooster Filter
|
||||
6
src/main/resources/assets/refinedstorage/models/item/grid_filter.json
Executable file
6
src/main/resources/assets/refinedstorage/models/item/grid_filter.json
Executable file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "refinedstorage:items/grid_filter"
|
||||
}
|
||||
}
|
||||
BIN
src/main/resources/assets/refinedstorage/textures/gui/grid_filter.png
Executable file
BIN
src/main/resources/assets/refinedstorage/textures/gui/grid_filter.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
src/main/resources/assets/refinedstorage/textures/items/grid_filter.png
Executable file
BIN
src/main/resources/assets/refinedstorage/textures/items/grid_filter.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 232 B |
Reference in New Issue
Block a user