Crafter manager
This commit is contained in:
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage;
|
|||||||
import com.raoulvdberge.refinedstorage.block.*;
|
import com.raoulvdberge.refinedstorage.block.*;
|
||||||
|
|
||||||
public final class RSBlocks {
|
public final class RSBlocks {
|
||||||
|
// @todo: Switch to registry inject
|
||||||
public static final BlockController CONTROLLER = new BlockController();
|
public static final BlockController CONTROLLER = new BlockController();
|
||||||
public static final BlockCable CABLE = new BlockCable();
|
public static final BlockCable CABLE = new BlockCable();
|
||||||
public static final BlockGrid GRID = new BlockGrid();
|
public static final BlockGrid GRID = new BlockGrid();
|
||||||
@@ -32,4 +33,5 @@ public final class RSBlocks {
|
|||||||
public static final BlockQuartzEnrichedIron QUARTZ_ENRICHED_IRON = new BlockQuartzEnrichedIron();
|
public static final BlockQuartzEnrichedIron QUARTZ_ENRICHED_IRON = new BlockQuartzEnrichedIron();
|
||||||
public static final BlockStorageMonitor STORAGE_MONITOR = new BlockStorageMonitor();
|
public static final BlockStorageMonitor STORAGE_MONITOR = new BlockStorageMonitor();
|
||||||
public static final BlockPortableGrid PORTABLE_GRID = new BlockPortableGrid();
|
public static final BlockPortableGrid PORTABLE_GRID = new BlockPortableGrid();
|
||||||
|
public static final BlockCrafterManager CRAFTER_MANAGER = new BlockCrafterManager();
|
||||||
}
|
}
|
||||||
@@ -28,4 +28,5 @@ public final class RSGui {
|
|||||||
public static final int SECURITY_MANAGER = 24;
|
public static final int SECURITY_MANAGER = 24;
|
||||||
public static final int STORAGE_MONITOR = 25;
|
public static final int STORAGE_MONITOR = 25;
|
||||||
public static final int PORTABLE_GRID = 26;
|
public static final int PORTABLE_GRID = 26;
|
||||||
|
public static final int CRAFTER_MANAGER = 27;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,12 @@ import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
|||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The crafting manager handles the storing, updating, adding and deleting of crafting tasks in a network.
|
* The crafting manager handles the storing, updating, adding and deleting of crafting tasks in a network.
|
||||||
@@ -20,6 +22,16 @@ public interface ICraftingManager {
|
|||||||
*/
|
*/
|
||||||
List<ICraftingTask> getTasks();
|
List<ICraftingTask> getTasks();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return all the crafting pattern containers
|
||||||
|
*/
|
||||||
|
List<ICraftingPatternContainer> getContainers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return named crafting pattern containers
|
||||||
|
*/
|
||||||
|
Map<String, List<IItemHandlerModifiable>> getNamedContainers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a crafting task.
|
* Adds a crafting task.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.api.autocrafting;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -30,6 +31,16 @@ public interface ICraftingPatternContainer {
|
|||||||
*/
|
*/
|
||||||
List<ICraftingPattern> getPatterns();
|
List<ICraftingPattern> getPatterns();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the pattern inventory
|
||||||
|
*/
|
||||||
|
IItemHandlerModifiable getPatternInventory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of this container
|
||||||
|
*/
|
||||||
|
String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the position of this container
|
* @return the position of this container
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import net.minecraft.nbt.NBTTagList;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -33,6 +34,8 @@ public class CraftingManager implements ICraftingManager {
|
|||||||
|
|
||||||
private TileController network;
|
private TileController network;
|
||||||
|
|
||||||
|
private List<ICraftingPatternContainer> containers = new ArrayList<>();
|
||||||
|
private Map<String, List<IItemHandlerModifiable>> containerInventories = new LinkedHashMap<>();
|
||||||
private CraftingPatternChainList patterns = new CraftingPatternChainList();
|
private CraftingPatternChainList patterns = new CraftingPatternChainList();
|
||||||
|
|
||||||
private List<ICraftingTask> craftingTasks = new ArrayList<>();
|
private List<ICraftingTask> craftingTasks = new ArrayList<>();
|
||||||
@@ -54,6 +57,16 @@ public class CraftingManager implements ICraftingManager {
|
|||||||
return craftingTasks;
|
return craftingTasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ICraftingPatternContainer> getContainers() {
|
||||||
|
return containers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, List<IItemHandlerModifiable>> getNamedContainers() {
|
||||||
|
return containerInventories;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(@Nonnull ICraftingTask task) {
|
public void add(@Nonnull ICraftingTask task) {
|
||||||
craftingTasksToAdd.add(task);
|
craftingTasksToAdd.add(task);
|
||||||
@@ -281,10 +294,23 @@ public class CraftingManager implements ICraftingManager {
|
|||||||
@Override
|
@Override
|
||||||
public void rebuild() {
|
public void rebuild() {
|
||||||
patterns.clear();
|
patterns.clear();
|
||||||
|
containerInventories.clear();
|
||||||
|
|
||||||
for (INetworkNode node : network.getNodeGraph().all()) {
|
for (INetworkNode node : network.getNodeGraph().all()) {
|
||||||
if (node instanceof ICraftingPatternContainer && node.canUpdate()) {
|
if (node instanceof ICraftingPatternContainer && node.canUpdate()) {
|
||||||
patterns.addAll((((ICraftingPatternContainer) node).getPatterns()));
|
ICraftingPatternContainer container = (ICraftingPatternContainer) node;
|
||||||
|
|
||||||
|
patterns.addAll(container.getPatterns());
|
||||||
|
|
||||||
|
// @todo: ???
|
||||||
|
if (container.getPatternInventory().getSlots() == 9 || true) {
|
||||||
|
// @todo: Crafter first!
|
||||||
|
if (!containerInventories.containsKey(container.getName())) {
|
||||||
|
containerInventories.put(container.getName(), new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
containerInventories.get(container.getName()).add(container.getPatternInventory());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,18 +13,25 @@ import com.raoulvdberge.refinedstorage.util.StackUtils;
|
|||||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IWorldNameable;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternContainer {
|
public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternContainer {
|
||||||
public static final String ID = "crafter";
|
public static final String ID = "crafter";
|
||||||
|
|
||||||
|
public static final String DEFAULT_NAME = "gui.refinedstorage:crafter";
|
||||||
|
|
||||||
private static final String NBT_BLOCKED = "Blocked";
|
private static final String NBT_BLOCKED = "Blocked";
|
||||||
|
private static final String NBT_DISPLAY_NAME = "DisplayName";
|
||||||
|
|
||||||
private ItemHandlerBase patterns = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this), s -> s.getItem() instanceof ICraftingPatternProvider && ((ICraftingPatternProvider) s.getItem()).create(world, s, this).isValid()) {
|
private ItemHandlerBase patterns = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this), s -> s.getItem() instanceof ICraftingPatternProvider && ((ICraftingPatternProvider) s.getItem()).create(world, s, this).isValid()) {
|
||||||
@Override
|
@Override
|
||||||
@@ -52,6 +59,9 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
|
|||||||
|
|
||||||
private boolean blocked = false;
|
private boolean blocked = false;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String displayName;
|
||||||
|
|
||||||
public NetworkNodeCrafter(World world, BlockPos pos) {
|
public NetworkNodeCrafter(World world, BlockPos pos) {
|
||||||
super(world, pos);
|
super(world, pos);
|
||||||
}
|
}
|
||||||
@@ -109,6 +119,10 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
|
|||||||
if (tag.hasKey(NBT_BLOCKED)) {
|
if (tag.hasKey(NBT_BLOCKED)) {
|
||||||
blocked = tag.getBoolean(NBT_BLOCKED);
|
blocked = tag.getBoolean(NBT_BLOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_DISPLAY_NAME)) {
|
||||||
|
displayName = tag.getString(NBT_DISPLAY_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -125,6 +139,10 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
|
|||||||
|
|
||||||
tag.setBoolean(NBT_BLOCKED, blocked);
|
tag.setBoolean(NBT_BLOCKED, blocked);
|
||||||
|
|
||||||
|
if (displayName != null) {
|
||||||
|
tag.setString(NBT_DISPLAY_NAME, displayName);
|
||||||
|
}
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +161,35 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
|
|||||||
return actualPatterns;
|
return actualPatterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IItemHandlerModifiable getPatternInventory() {
|
||||||
|
return patterns;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
if (displayName != null) {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
TileEntity facing = getFacingTile();
|
||||||
|
|
||||||
|
if (facing instanceof IWorldNameable) {
|
||||||
|
return ((IWorldNameable) facing).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
return DEFAULT_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplayName(String displayName) {
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getDisplayName() {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockPos getPosition() {
|
public BlockPos getPosition() {
|
||||||
return pos;
|
return pos;
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
|
import com.raoulvdberge.refinedstorage.network.MessageCrafterManagerSlotSizes;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.TileCrafterManager;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class NetworkNodeCrafterManager extends NetworkNode {
|
||||||
|
public static final String ID = "crafter_manager";
|
||||||
|
|
||||||
|
private static final String NBT_SIZE = "Size";
|
||||||
|
|
||||||
|
private int size = IGrid.SIZE_STRETCH;
|
||||||
|
|
||||||
|
public NetworkNodeCrafterManager(World world, BlockPos pos) {
|
||||||
|
super(world, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEnergyUsage() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(EntityPlayerMP player) {
|
||||||
|
RS.INSTANCE.network.sendTo(new MessageCrafterManagerSlotSizes(network.getCraftingManager().getNamedContainers()), player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSize() {
|
||||||
|
return world.isRemote ? TileCrafterManager.SIZE.getValue() : size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(int size) {
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||||
|
super.writeConfiguration(tag);
|
||||||
|
|
||||||
|
tag.setInteger(NBT_SIZE, size);
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readConfiguration(NBTTagCompound tag) {
|
||||||
|
super.readConfiguration(tag);
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_SIZE)) {
|
||||||
|
size = tag.getInteger(NBT_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,19 @@
|
|||||||
package com.raoulvdberge.refinedstorage.block;
|
package com.raoulvdberge.refinedstorage.block;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||||
import com.raoulvdberge.refinedstorage.RSGui;
|
import com.raoulvdberge.refinedstorage.RSGui;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileCrafter;
|
import com.raoulvdberge.refinedstorage.tile.TileCrafter;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -22,6 +28,20 @@ public class BlockCrafter extends BlockNode {
|
|||||||
return new TileCrafter();
|
return new TileCrafter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||||
|
super.onBlockPlacedBy(world, pos, state, placer, stack);
|
||||||
|
|
||||||
|
if (!world.isRemote) {
|
||||||
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tile instanceof TileCrafter && stack.hasDisplayName()) {
|
||||||
|
((TileCrafter) tile).getNode().setDisplayName(stack.getDisplayName());
|
||||||
|
((TileCrafter) tile).getNode().markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
@@ -40,4 +60,19 @@ public class BlockCrafter extends BlockNode {
|
|||||||
public boolean hasConnectivityState() {
|
public boolean hasConnectivityState() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||||
|
super.getDrops(drops, world, pos, state, fortune);
|
||||||
|
|
||||||
|
String displayName = ((TileCrafter) world.getTileEntity(pos)).getNode().getDisplayName();
|
||||||
|
|
||||||
|
if (displayName != null) {
|
||||||
|
for (ItemStack drop : drops) {
|
||||||
|
if (drop.getItem() == Item.getItemFromBlock(RSBlocks.CRAFTER)) {
|
||||||
|
drop.setStackDisplayName(displayName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.block;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSGui;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.TileCrafterManager;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockCrafterManager extends BlockNode {
|
||||||
|
public BlockCrafterManager() {
|
||||||
|
super("crafter_manager");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||||
|
return new TileCrafterManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
|
if (!world.isRemote && tryOpenNetworkGui(RSGui.CRAFTER_MANAGER, player, world, pos, side, Permission.MODIFY, Permission.AUTOCRAFTING)) {
|
||||||
|
((TileCrafterManager) world.getTileEntity(pos)).getNode().send((EntityPlayerMP) player);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.container;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.grid.IGridDisplay;
|
||||||
|
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.TileCrafterManager;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.IContainerListener;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ContainerCrafterManager extends ContainerBase {
|
||||||
|
public class Listener implements IContainerListener {
|
||||||
|
private IContainerListener base;
|
||||||
|
private boolean receivedContainerData;
|
||||||
|
|
||||||
|
public Listener(IContainerListener base) {
|
||||||
|
this.base = base;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityPlayerMP getPlayer() {
|
||||||
|
return (EntityPlayerMP) base;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendAllContents(Container containerToSend, NonNullList<ItemStack> itemsList) {
|
||||||
|
if (receivedContainerData) {
|
||||||
|
base.sendAllContents(containerToSend, itemsList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack) {
|
||||||
|
if (receivedContainerData) {
|
||||||
|
base.sendSlotContents(containerToSend, slotInd, stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReceivedContainerData() {
|
||||||
|
receivedContainerData = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendWindowProperty(Container containerIn, int varToUpdate, int newValue) {
|
||||||
|
base.sendWindowProperty(containerIn, varToUpdate, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendAllWindowProperties(Container containerIn, IInventory inventory) {
|
||||||
|
base.sendAllWindowProperties(containerIn, inventory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SlotCrafterManager extends SlotItemHandler {
|
||||||
|
private boolean visible;
|
||||||
|
|
||||||
|
private SlotCrafterManager(IItemHandler itemHandler, int index, int xPosition, int yPosition, boolean visible) {
|
||||||
|
super(itemHandler, index, xPosition, yPosition);
|
||||||
|
|
||||||
|
this.visible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return yPos >= display.getHeader() && yPos < display.getHeader() + 18 * display.getVisibleRows() && visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IGridDisplay display;
|
||||||
|
private Map<String, Integer> containerData;
|
||||||
|
private Map<String, IItemHandlerModifiable> dummyInventories = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addListener(IContainerListener listener) {
|
||||||
|
super.addListener(new Listener(listener));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IContainerListener> getListeners() {
|
||||||
|
return listeners;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContainerCrafterManager(TileCrafterManager crafterManager, EntityPlayer player, IGridDisplay display) {
|
||||||
|
super(crafterManager, player);
|
||||||
|
|
||||||
|
this.display = display;
|
||||||
|
|
||||||
|
if (!player.world.isRemote) {
|
||||||
|
addPlayerInventory(8, display.getYPlayerInventory());
|
||||||
|
|
||||||
|
for (Map.Entry<String, List<IItemHandlerModifiable>> entry : crafterManager.getNode().getNetwork().getCraftingManager().getNamedContainers().entrySet()) {
|
||||||
|
for (IItemHandlerModifiable handler : entry.getValue()) {
|
||||||
|
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||||
|
addSlotToContainer(new SlotItemHandler(handler, i, 0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initSlots(@Nullable Map<String, Integer> newContainerData) {
|
||||||
|
if (newContainerData == null) { // We resized
|
||||||
|
if (containerData == null) { // No container data received yet, do nothing..
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
containerData = newContainerData; // Received container data
|
||||||
|
|
||||||
|
dummyInventories.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.inventorySlots.clear();
|
||||||
|
this.inventoryItemStacks.clear();
|
||||||
|
|
||||||
|
addPlayerInventory(8, display.getYPlayerInventory());
|
||||||
|
|
||||||
|
int y = 19 + 18 - display.getCurrentOffset() * 18;
|
||||||
|
|
||||||
|
for (Map.Entry<String, Integer> entry : containerData.entrySet()) {
|
||||||
|
boolean visible = entry.getKey().toLowerCase().contains(display.getSearchFieldText().toLowerCase());
|
||||||
|
|
||||||
|
for (int i = 0; i < entry.getValue(); ++i) {
|
||||||
|
IItemHandlerModifiable dummy;
|
||||||
|
|
||||||
|
if (newContainerData == null) { // We're only resizing, get the previous inventory...
|
||||||
|
dummy = dummyInventories.get(entry.getKey() + "," + i);
|
||||||
|
} else {
|
||||||
|
dummyInventories.put(entry.getKey() + "," + i, dummy = new ItemHandlerBase(9));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < 9; ++j) {
|
||||||
|
addSlotToContainer(new SlotCrafterManager(dummy, j, 8 + j * 18, y, visible));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visible) {
|
||||||
|
y += 18;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visible) {
|
||||||
|
y += 18;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Integer> getContainerData() {
|
||||||
|
return containerData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||||
|
ItemStack stack = ItemStack.EMPTY;
|
||||||
|
|
||||||
|
Slot slot = getSlot(index);
|
||||||
|
|
||||||
|
if (slot.getHasStack()) {
|
||||||
|
stack = slot.getStack();
|
||||||
|
|
||||||
|
if (index < 9 * 4) {
|
||||||
|
if (!mergeItemStack(stack, 9 * 4, inventorySlots.size(), false)) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
} else if (!mergeItemStack(stack, 0, 9 * 4, false)) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.getCount() == 0) {
|
||||||
|
slot.putStack(ItemStack.EMPTY);
|
||||||
|
} else {
|
||||||
|
slot.onSlotChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -67,6 +67,8 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
|
|
||||||
protected Scrollbar scrollbar;
|
protected Scrollbar scrollbar;
|
||||||
|
|
||||||
|
private boolean initializing;
|
||||||
|
|
||||||
public GuiBase(Container container, int screenWidth, int screenHeight) {
|
public GuiBase(Container container, int screenWidth, int screenHeight) {
|
||||||
super(container);
|
super(container);
|
||||||
|
|
||||||
@@ -92,6 +94,12 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
|
if (initializing) { // Fix double initialize because of runRunnables
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
initializing = true;
|
||||||
|
|
||||||
calcHeight();
|
calcHeight();
|
||||||
|
|
||||||
super.initGui();
|
super.initGui();
|
||||||
@@ -104,6 +112,8 @@ public abstract class GuiBase extends GuiContainer {
|
|||||||
runRunnables();
|
runRunnables();
|
||||||
|
|
||||||
init(guiLeft, guiTop);
|
init(guiLeft, guiTop);
|
||||||
|
|
||||||
|
initializing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void calcHeight() {
|
protected void calcHeight() {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.gui;
|
|||||||
import com.raoulvdberge.refinedstorage.container.ContainerCrafter;
|
import com.raoulvdberge.refinedstorage.container.ContainerCrafter;
|
||||||
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileCrafter;
|
import com.raoulvdberge.refinedstorage.tile.TileCrafter;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
|
||||||
public class GuiCrafter extends GuiBase {
|
public class GuiCrafter extends GuiBase {
|
||||||
public GuiCrafter(ContainerCrafter container) {
|
public GuiCrafter(ContainerCrafter container) {
|
||||||
@@ -27,7 +28,7 @@ public class GuiCrafter extends GuiBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawForeground(int mouseX, int mouseY) {
|
public void drawForeground(int mouseX, int mouseY) {
|
||||||
drawString(7, 7, t("gui.refinedstorage:crafter"));
|
drawString(7, 7, t(I18n.format(TileCrafter.NAME.getValue())));
|
||||||
drawString(7, 43, t("container.inventory"));
|
drawString(7, 43, t("container.inventory"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,212 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.gui;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafterManager;
|
||||||
|
import com.raoulvdberge.refinedstorage.container.ContainerCrafterManager;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.grid.IGridDisplay;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonGridSize;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.sidebutton.SideButtonRedstoneMode;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.TileCrafterManager;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class GuiCrafterManager extends GuiBase implements IGridDisplay {
|
||||||
|
private ContainerCrafterManager container;
|
||||||
|
private NetworkNodeCrafterManager crafterManager;
|
||||||
|
private GuiTextField searchField;
|
||||||
|
|
||||||
|
public GuiCrafterManager(NetworkNodeCrafterManager crafterManager) {
|
||||||
|
super(null, 193, 0);
|
||||||
|
|
||||||
|
this.crafterManager = crafterManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContainer(ContainerCrafterManager container) {
|
||||||
|
this.container = container;
|
||||||
|
this.inventorySlots = container;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void calcHeight() {
|
||||||
|
super.calcHeight();
|
||||||
|
|
||||||
|
this.ySize = getHeader() + getFooter() + (getVisibleRows() * 18);
|
||||||
|
this.screenHeight = ySize;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHeader() {
|
||||||
|
return 19;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFooter() {
|
||||||
|
return 99;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVisibleRows() {
|
||||||
|
switch (crafterManager.getSize()) {
|
||||||
|
case IGrid.SIZE_STRETCH:
|
||||||
|
int screenSpaceAvailable = height - getHeader() - getFooter();
|
||||||
|
|
||||||
|
return Math.max(3, Math.min((screenSpaceAvailable / 18) - 3, RS.INSTANCE.config.maxRowsStretch));
|
||||||
|
case IGrid.SIZE_SMALL:
|
||||||
|
return 3;
|
||||||
|
case IGrid.SIZE_MEDIUM:
|
||||||
|
return 5;
|
||||||
|
case IGrid.SIZE_LARGE:
|
||||||
|
return 8;
|
||||||
|
default:
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRows() {
|
||||||
|
if (container == null || container.getContainerData() == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rows = 0;
|
||||||
|
|
||||||
|
for (Map.Entry<String, Integer> containerData : container.getContainerData().entrySet()) {
|
||||||
|
if (containerData.getKey().toLowerCase().contains(getSearchFieldText().toLowerCase())) {
|
||||||
|
rows++;
|
||||||
|
rows += containerData.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCurrentOffset() {
|
||||||
|
return scrollbar == null ? 0 : scrollbar.getOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSearchFieldText() {
|
||||||
|
return searchField == null ? "" : searchField.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getYPlayerInventory() {
|
||||||
|
return getHeader() + (getVisibleRows() * 18) + 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(int x, int y) {
|
||||||
|
addSideButton(new SideButtonRedstoneMode(this, TileCrafterManager.REDSTONE_MODE));
|
||||||
|
addSideButton(new SideButtonGridSize(this, () -> crafterManager.getSize(), size -> TileDataManager.setParameter(TileCrafterManager.SIZE, size)));
|
||||||
|
|
||||||
|
this.scrollbar = new Scrollbar(174, getHeader(), 12, (getVisibleRows() * 18) - 2);
|
||||||
|
this.scrollbar.addListener((oldOffset, newOffset) -> {
|
||||||
|
if (container != null) {
|
||||||
|
container.initSlots(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
container.initSlots(null);
|
||||||
|
|
||||||
|
int sx = x + 97 + 1;
|
||||||
|
int sy = y + 6 + 1;
|
||||||
|
|
||||||
|
if (searchField == null) {
|
||||||
|
searchField = new GuiTextField(0, fontRenderer, sx, sy, 88 - 6, fontRenderer.FONT_HEIGHT);
|
||||||
|
searchField.setEnableBackgroundDrawing(false);
|
||||||
|
searchField.setVisible(true);
|
||||||
|
searchField.setTextColor(16777215);
|
||||||
|
} else {
|
||||||
|
searchField.x = sx;
|
||||||
|
searchField.y = sy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(int x, int y) {
|
||||||
|
scrollbar.setEnabled((getRows() - 1) >= getVisibleRows());
|
||||||
|
scrollbar.setMaxOffset(getRows() - getVisibleRows());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||||
|
bindTexture("gui/crafter_manager.png");
|
||||||
|
|
||||||
|
drawTexture(x, y, 0, 0, screenWidth, getHeader());
|
||||||
|
|
||||||
|
int rows = getVisibleRows();
|
||||||
|
|
||||||
|
for (int i = 0; i < rows; ++i) {
|
||||||
|
y += 18;
|
||||||
|
|
||||||
|
drawTexture(x, y, 0, getHeader() + (i > 0 ? (i == rows - 1 ? 18 * 2 : 18) : 0), screenWidth, 18);
|
||||||
|
}
|
||||||
|
|
||||||
|
y += 18;
|
||||||
|
|
||||||
|
drawTexture(x, y, 0, getHeader() + (18 * 3), screenWidth, getFooter());
|
||||||
|
|
||||||
|
if (searchField != null) {
|
||||||
|
searchField.drawTextBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(int mouseX, int mouseY, int clickedButton) throws IOException {
|
||||||
|
super.mouseClicked(mouseX, mouseY, clickedButton);
|
||||||
|
|
||||||
|
if (searchField != null) {
|
||||||
|
searchField.mouseClicked(mouseX, mouseY, clickedButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void keyTyped(char character, int keyCode) throws IOException {
|
||||||
|
if (searchField == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (checkHotbarKeys(keyCode)) {
|
||||||
|
// NO OP
|
||||||
|
} else if (searchField.textboxKeyTyped(character, keyCode)) {
|
||||||
|
container.initSlots(null);
|
||||||
|
} else {
|
||||||
|
super.keyTyped(character, keyCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawForeground(int mouseX, int mouseY) {
|
||||||
|
drawString(7, 7, t("gui.refinedstorage:crafter_manager"));
|
||||||
|
drawString(7, getYPlayerInventory() - 12, t("container.inventory"));
|
||||||
|
|
||||||
|
if (container != null) {
|
||||||
|
int x = 7;
|
||||||
|
int y = 18 - getCurrentOffset() * 18;
|
||||||
|
|
||||||
|
for (Map.Entry<String, Integer> entry : container.getContainerData().entrySet()) {
|
||||||
|
if (entry.getKey().toLowerCase().contains(getSearchFieldText().toLowerCase())) {
|
||||||
|
if (y >= getHeader() - 1 && y < getHeader() + getVisibleRows() * 18 - 1) {
|
||||||
|
GlStateManager.disableLighting();
|
||||||
|
GlStateManager.color(1, 1, 1);
|
||||||
|
|
||||||
|
bindTexture("gui/crafter_manager.png");
|
||||||
|
|
||||||
|
drawTexturedModalRect(x, y, 0, 174, 18 * 9, 18);
|
||||||
|
|
||||||
|
drawString(x + 4, y + 5, I18n.format(entry.getKey()));
|
||||||
|
}
|
||||||
|
|
||||||
|
y += (entry.getValue() + 1) * 18;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -73,6 +73,8 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
return new ContainerSecurityManager((TileSecurityManager) tile, player);
|
return new ContainerSecurityManager((TileSecurityManager) tile, player);
|
||||||
case RSGui.STORAGE_MONITOR:
|
case RSGui.STORAGE_MONITOR:
|
||||||
return new ContainerStorageMonitor((TileStorageMonitor) tile, player);
|
return new ContainerStorageMonitor((TileStorageMonitor) tile, player);
|
||||||
|
case RSGui.CRAFTER_MANAGER:
|
||||||
|
return new ContainerCrafterManager((TileCrafterManager) tile, player, new GridDisplayDummy());
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -152,6 +154,10 @@ public class GuiHandler implements IGuiHandler {
|
|||||||
return new GuiSecurityManager((ContainerSecurityManager) getContainer(ID, player, tile), (TileSecurityManager) tile);
|
return new GuiSecurityManager((ContainerSecurityManager) getContainer(ID, player, tile), (TileSecurityManager) tile);
|
||||||
case RSGui.STORAGE_MONITOR:
|
case RSGui.STORAGE_MONITOR:
|
||||||
return new GuiStorageMonitor((ContainerStorageMonitor) getContainer(ID, player, tile));
|
return new GuiStorageMonitor((ContainerStorageMonitor) getContainer(ID, player, tile));
|
||||||
|
case RSGui.CRAFTER_MANAGER:
|
||||||
|
GuiCrafterManager crafterManagerGui = new GuiCrafterManager(((TileCrafterManager) tile).getNode());
|
||||||
|
crafterManagerGui.setContainer(new ContainerCrafterManager((TileCrafterManager) tile, player, crafterManagerGui));
|
||||||
|
return crafterManagerGui;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,14 @@ package com.raoulvdberge.refinedstorage.gui;
|
|||||||
|
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Scrollbar {
|
public class Scrollbar {
|
||||||
|
public interface ScrollbarListener {
|
||||||
|
void onOffsetChanged(int oldOffset, int newOffset);
|
||||||
|
}
|
||||||
|
|
||||||
private static final int SCROLLER_HEIGHT = 15;
|
private static final int SCROLLER_HEIGHT = 15;
|
||||||
|
|
||||||
private int x;
|
private int x;
|
||||||
@@ -17,6 +24,8 @@ public class Scrollbar {
|
|||||||
private boolean wasClicking = false;
|
private boolean wasClicking = false;
|
||||||
private boolean isScrolling = false;
|
private boolean isScrolling = false;
|
||||||
|
|
||||||
|
private List<ScrollbarListener> listeners = new LinkedList<>();
|
||||||
|
|
||||||
public Scrollbar(int x, int y, int width, int height) {
|
public Scrollbar(int x, int y, int width, int height) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
@@ -24,6 +33,10 @@ public class Scrollbar {
|
|||||||
this.height = height;
|
this.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addListener(ScrollbarListener listener) {
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
@@ -87,8 +100,12 @@ public class Scrollbar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setOffset(int offset) {
|
public void setOffset(int offset) {
|
||||||
|
int oldOffset = this.offset;
|
||||||
|
|
||||||
if (offset >= 0 && offset <= maxOffset) {
|
if (offset >= 0 && offset <= maxOffset) {
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
|
|
||||||
|
listeners.forEach(l -> l.onOffsetChanged(oldOffset, offset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ public class GridDisplayDummy implements IGridDisplay {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCurrentOffset() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSearchFieldText() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeader() {
|
public int getHeader() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
|||||||
addSideButton(new SideButtonGridSortingDirection(this, grid));
|
addSideButton(new SideButtonGridSortingDirection(this, grid));
|
||||||
addSideButton(new SideButtonGridSortingType(this, grid));
|
addSideButton(new SideButtonGridSortingType(this, grid));
|
||||||
addSideButton(new SideButtonGridSearchBoxMode(this));
|
addSideButton(new SideButtonGridSearchBoxMode(this));
|
||||||
addSideButton(new SideButtonGridSize(this, grid));
|
addSideButton(new SideButtonGridSize(this, () -> grid.getSize(), size -> grid.onSizeChanged(size)));
|
||||||
|
|
||||||
view.sort();
|
view.sort();
|
||||||
}
|
}
|
||||||
@@ -215,6 +215,16 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
|||||||
return Math.max(0, (int) Math.ceil((float) view.getStacks().size() / 9F));
|
return Math.max(0, (int) Math.ceil((float) view.getStacks().size() / 9F));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCurrentOffset() {
|
||||||
|
return scrollbar.getOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSearchFieldText() {
|
||||||
|
return searchField == null ? "" : searchField.getText();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVisibleRows() {
|
public int getVisibleRows() {
|
||||||
switch (grid.getSize()) {
|
switch (grid.getSize()) {
|
||||||
@@ -799,6 +809,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @todo: Move logic to other class so we can reuse search field in crafter manager
|
||||||
public GuiTextField getSearchField() {
|
public GuiTextField getSearchField() {
|
||||||
return searchField;
|
return searchField;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ public interface IGridDisplay {
|
|||||||
|
|
||||||
int getRows();
|
int getRows();
|
||||||
|
|
||||||
|
int getCurrentOffset();
|
||||||
|
|
||||||
|
String getSearchFieldText();
|
||||||
|
|
||||||
int getHeader();
|
int getHeader();
|
||||||
|
|
||||||
int getFooter();
|
int getFooter();
|
||||||
|
|||||||
@@ -4,23 +4,27 @@ import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
|||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class SideButtonGridSize extends SideButton {
|
public class SideButtonGridSize extends SideButton {
|
||||||
private IGrid grid;
|
private Supplier<Integer> size;
|
||||||
|
private Consumer<Integer> handler;
|
||||||
|
|
||||||
public SideButtonGridSize(GuiBase gui, IGrid grid) {
|
public SideButtonGridSize(GuiBase gui, Supplier<Integer> size, Consumer<Integer> handler) {
|
||||||
super(gui);
|
super(gui);
|
||||||
|
this.size = size;
|
||||||
this.grid = grid;
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTooltip() {
|
public String getTooltip() {
|
||||||
return GuiBase.t("sidebutton.refinedstorage:grid.size") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:grid.size." + grid.getSize());
|
return GuiBase.t("sidebutton.refinedstorage:grid.size") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:grid.size." + this.size.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawButtonIcon(int x, int y) {
|
protected void drawButtonIcon(int x, int y) {
|
||||||
int size = grid.getSize();
|
int size = this.size.get();
|
||||||
|
|
||||||
int tx = 0;
|
int tx = 0;
|
||||||
|
|
||||||
@@ -39,7 +43,7 @@ public class SideButtonGridSize extends SideButton {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed() {
|
public void actionPerformed() {
|
||||||
int size = grid.getSize();
|
int size = this.size.get();
|
||||||
|
|
||||||
if (size == IGrid.SIZE_STRETCH) {
|
if (size == IGrid.SIZE_STRETCH) {
|
||||||
size = IGrid.SIZE_SMALL;
|
size = IGrid.SIZE_SMALL;
|
||||||
@@ -51,6 +55,6 @@ public class SideButtonGridSize extends SideButton {
|
|||||||
size = IGrid.SIZE_STRETCH;
|
size = IGrid.SIZE_STRETCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
grid.onSizeChanged(size);
|
this.handler.accept(size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.network;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.container.ContainerCrafterManager;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.inventory.IContainerListener;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
|
||||||
|
public class MessageCrafterManagerRequestSlotData extends MessageHandlerPlayerToServer<MessageCrafterManagerRequestSlotData> implements IMessage {
|
||||||
|
@Override
|
||||||
|
public void fromBytes(ByteBuf buf) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes(ByteBuf buf) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handle(MessageCrafterManagerRequestSlotData message, EntityPlayerMP player) {
|
||||||
|
if (player.openContainer instanceof ContainerCrafterManager) {
|
||||||
|
for (IContainerListener listener : ((ContainerCrafterManager) player.openContainer).getListeners()) {
|
||||||
|
ContainerCrafterManager.Listener crafterListener = (ContainerCrafterManager.Listener) listener;
|
||||||
|
|
||||||
|
if (crafterListener.getPlayer() == player) {
|
||||||
|
crafterListener.setReceivedContainerData();
|
||||||
|
crafterListener.sendAllContents(player.openContainer, player.openContainer.getInventory());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.network;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
|
import com.raoulvdberge.refinedstorage.container.ContainerCrafterManager;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.GuiCrafterManager;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MessageCrafterManagerSlotSizes implements IMessage, IMessageHandler<MessageCrafterManagerSlotSizes, IMessage> {
|
||||||
|
private Map<String, List<IItemHandlerModifiable>> containerData;
|
||||||
|
private Map<String, Integer> containerDataClient = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
public MessageCrafterManagerSlotSizes(Map<String, List<IItemHandlerModifiable>> containerData) {
|
||||||
|
this.containerData = containerData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageCrafterManagerSlotSizes() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromBytes(ByteBuf buf) {
|
||||||
|
int size = buf.readInt();
|
||||||
|
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
containerDataClient.put(ByteBufUtils.readUTF8String(buf), buf.readInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes(ByteBuf buf) {
|
||||||
|
buf.writeInt(containerData.size());
|
||||||
|
|
||||||
|
for (Map.Entry<String, List<IItemHandlerModifiable>> entry : containerData.entrySet()) {
|
||||||
|
ByteBufUtils.writeUTF8String(buf, entry.getKey());
|
||||||
|
buf.writeInt(entry.getValue().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMessage onMessage(MessageCrafterManagerSlotSizes message, MessageContext ctx) {
|
||||||
|
GuiBase.executeLater(GuiCrafterManager.class, crafterManager -> {
|
||||||
|
((ContainerCrafterManager) crafterManager.inventorySlots).initSlots(message.containerDataClient);
|
||||||
|
|
||||||
|
RS.INSTANCE.network.sendToServer(new MessageCrafterManagerRequestSlotData());
|
||||||
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,7 +71,7 @@ public class ProxyClient extends ProxyCommon {
|
|||||||
itemColors.registerItemColorHandler((stack, tintIndex) -> {
|
itemColors.registerItemColorHandler((stack, tintIndex) -> {
|
||||||
CraftingPattern pattern = ItemPattern.getPatternFromCache(Minecraft.getMinecraft().world, stack);
|
CraftingPattern pattern = ItemPattern.getPatternFromCache(Minecraft.getMinecraft().world, stack);
|
||||||
|
|
||||||
if (BakedModelPattern.canDisplayPatternOutput(pattern)) {
|
if (BakedModelPattern.canDisplayPatternOutput(stack, pattern)) {
|
||||||
int color = itemColors.colorMultiplier(pattern.getOutputs().get(0), tintIndex);
|
int color = itemColors.colorMultiplier(pattern.getOutputs().get(0), tintIndex);
|
||||||
|
|
||||||
if (color != -1) {
|
if (color != -1) {
|
||||||
|
|||||||
@@ -138,6 +138,8 @@ public class ProxyCommon {
|
|||||||
RS.INSTANCE.network.registerMessage(MessageSecurityManagerUpdate.class, MessageSecurityManagerUpdate.class, id++, Side.SERVER);
|
RS.INSTANCE.network.registerMessage(MessageSecurityManagerUpdate.class, MessageSecurityManagerUpdate.class, id++, Side.SERVER);
|
||||||
RS.INSTANCE.network.registerMessage(MessageWirelessFluidGridSettingsUpdate.class, MessageWirelessFluidGridSettingsUpdate.class, id++, Side.SERVER);
|
RS.INSTANCE.network.registerMessage(MessageWirelessFluidGridSettingsUpdate.class, MessageWirelessFluidGridSettingsUpdate.class, id++, Side.SERVER);
|
||||||
RS.INSTANCE.network.registerMessage(MessageWirelessCraftingMonitorViewAutomated.class, MessageWirelessCraftingMonitorViewAutomated.class, id++, Side.SERVER);
|
RS.INSTANCE.network.registerMessage(MessageWirelessCraftingMonitorViewAutomated.class, MessageWirelessCraftingMonitorViewAutomated.class, id++, Side.SERVER);
|
||||||
|
RS.INSTANCE.network.registerMessage(MessageCrafterManagerSlotSizes.class, MessageCrafterManagerSlotSizes.class, id++, Side.CLIENT);
|
||||||
|
RS.INSTANCE.network.registerMessage(MessageCrafterManagerRequestSlotData.class, MessageCrafterManagerRequestSlotData.class, id++, Side.SERVER);
|
||||||
|
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(RS.INSTANCE, new GuiHandler());
|
NetworkRegistry.INSTANCE.registerGuiHandler(RS.INSTANCE, new GuiHandler());
|
||||||
|
|
||||||
@@ -170,6 +172,7 @@ public class ProxyCommon {
|
|||||||
registerTile(TileWriter.class, "writer");
|
registerTile(TileWriter.class, "writer");
|
||||||
registerTile(TileStorageMonitor.class, "storage_monitor");
|
registerTile(TileStorageMonitor.class, "storage_monitor");
|
||||||
registerTile(TilePortableGrid.class, "portable_grid");
|
registerTile(TilePortableGrid.class, "portable_grid");
|
||||||
|
registerTile(TileCrafterManager.class, "crafter_manager");
|
||||||
|
|
||||||
registerBlock(RSBlocks.CONTROLLER);
|
registerBlock(RSBlocks.CONTROLLER);
|
||||||
registerBlock(RSBlocks.GRID);
|
registerBlock(RSBlocks.GRID);
|
||||||
@@ -200,6 +203,7 @@ public class ProxyCommon {
|
|||||||
registerBlock(RSBlocks.NETWORK_TRANSMITTER);
|
registerBlock(RSBlocks.NETWORK_TRANSMITTER);
|
||||||
registerBlock(RSBlocks.NETWORK_RECEIVER);
|
registerBlock(RSBlocks.NETWORK_RECEIVER);
|
||||||
registerBlock(RSBlocks.DISK_MANIPULATOR);
|
registerBlock(RSBlocks.DISK_MANIPULATOR);
|
||||||
|
registerBlock(RSBlocks.CRAFTER_MANAGER);
|
||||||
|
|
||||||
registerItem(RSItems.QUARTZ_ENRICHED_IRON);
|
registerItem(RSItems.QUARTZ_ENRICHED_IRON);
|
||||||
registerItem(RSItems.STORAGE_DISK);
|
registerItem(RSItems.STORAGE_DISK);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.raoulvdberge.refinedstorage.render;
|
package com.raoulvdberge.refinedstorage.render;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
||||||
|
import com.raoulvdberge.refinedstorage.container.ContainerCrafterManager;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemPattern;
|
import com.raoulvdberge.refinedstorage.item.ItemPattern;
|
||||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||||
@@ -12,6 +13,8 @@ import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
|||||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -74,7 +77,7 @@ public class BakedModelPattern implements IBakedModel {
|
|||||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
||||||
CraftingPattern pattern = ItemPattern.getPatternFromCache(world, stack);
|
CraftingPattern pattern = ItemPattern.getPatternFromCache(world, stack);
|
||||||
|
|
||||||
if (canDisplayPatternOutput(pattern)) {
|
if (canDisplayPatternOutput(stack, pattern)) {
|
||||||
return Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(pattern.getOutputs().get(0), world, entity);
|
return Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(pattern.getOutputs().get(0), world, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +86,21 @@ public class BakedModelPattern implements IBakedModel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canDisplayPatternOutput(CraftingPattern pattern) {
|
public static boolean canDisplayPatternOutput(ItemStack patternStack, CraftingPattern pattern) {
|
||||||
return GuiBase.isShiftKeyDown() && pattern.isValid() && pattern.getOutputs().size() == 1;
|
return (GuiBase.isShiftKeyDown() || isPatternInCrafterManagerSlot(patternStack)) && pattern.isValid() && pattern.getOutputs().size() == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPatternInCrafterManagerSlot(ItemStack stack) {
|
||||||
|
Container container = Minecraft.getMinecraft().player.openContainer;
|
||||||
|
|
||||||
|
if (container instanceof ContainerCrafterManager) {
|
||||||
|
for (Slot slot : container.inventorySlots) {
|
||||||
|
if (slot instanceof ContainerCrafterManager.SlotCrafterManager && slot.getStack() == stack) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafter;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafter;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -11,6 +13,12 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class TileCrafter extends TileNode<NetworkNodeCrafter> {
|
public class TileCrafter extends TileNode<NetworkNodeCrafter> {
|
||||||
|
public static final TileDataParameter<String, TileCrafter> NAME = new TileDataParameter<>(DataSerializers.STRING, NetworkNodeCrafter.DEFAULT_NAME, t -> t.getNode().getName());
|
||||||
|
|
||||||
|
public TileCrafter() {
|
||||||
|
dataManager.addWatchedParameter(NAME);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public NetworkNodeCrafter createNode(World world, BlockPos pos) {
|
public NetworkNodeCrafter createNode(World world, BlockPos pos) {
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafterManager;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
|
import com.raoulvdberge.refinedstorage.gui.GuiCrafterManager;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class TileCrafterManager extends TileNode<NetworkNodeCrafterManager> {
|
||||||
|
public static final TileDataParameter<Integer, TileCrafterManager> SIZE = new TileDataParameter<>(DataSerializers.VARINT, IGrid.SIZE_STRETCH, t -> t.getNode().getSize(), (t, v) -> {
|
||||||
|
if (IGrid.isValidSize(v)) {
|
||||||
|
t.getNode().setSize(v);
|
||||||
|
t.getNode().markDirty();
|
||||||
|
}
|
||||||
|
}, p -> GuiBase.executeLater(GuiCrafterManager.class, GuiBase::initGui));
|
||||||
|
|
||||||
|
public TileCrafterManager() {
|
||||||
|
dataManager.addWatchedParameter(SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NetworkNodeCrafterManager createNode(World world, BlockPos pos) {
|
||||||
|
return new NetworkNodeCrafterManager(world, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNodeId() {
|
||||||
|
return NetworkNodeCrafterManager.ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,6 @@ import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
|||||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -43,21 +42,13 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
|||||||
t.getNode().setSearchBoxMode(v);
|
t.getNode().setSearchBoxMode(v);
|
||||||
t.getNode().markDirty();
|
t.getNode().markDirty();
|
||||||
}
|
}
|
||||||
}, p -> {
|
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateSearchFieldFocus(p)));
|
||||||
if (Minecraft.getMinecraft().currentScreen instanceof GuiGrid) {
|
|
||||||
((GuiGrid) Minecraft.getMinecraft().currentScreen).updateSearchFieldFocus(p);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
public static final TileDataParameter<Integer, TileGrid> SIZE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getSize(), (t, v) -> {
|
public static final TileDataParameter<Integer, TileGrid> SIZE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getSize(), (t, v) -> {
|
||||||
if (IGrid.isValidSize(v)) {
|
if (IGrid.isValidSize(v)) {
|
||||||
t.getNode().setSize(v);
|
t.getNode().setSize(v);
|
||||||
t.getNode().markDirty();
|
t.getNode().markDirty();
|
||||||
}
|
}
|
||||||
}, p -> {
|
}, p -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
||||||
if (Minecraft.getMinecraft().currentScreen != null) {
|
|
||||||
Minecraft.getMinecraft().currentScreen.initGui();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
public static final TileDataParameter<Integer, TileGrid> TAB_SELECTED = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getTabSelected(), (t, v) -> {
|
public static final TileDataParameter<Integer, TileGrid> TAB_SELECTED = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getTabSelected(), (t, v) -> {
|
||||||
t.getNode().setTabSelected(v == t.getNode().getTabSelected() ? -1 : v);
|
t.getNode().setTabSelected(v == t.getNode().getTabSelected() ? -1 : v);
|
||||||
t.getNode().markDirty();
|
t.getNode().markDirty();
|
||||||
@@ -71,11 +62,7 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
|||||||
public static final TileDataParameter<Boolean, TileGrid> OREDICT_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isOredictPattern(), (t, v) -> {
|
public static final TileDataParameter<Boolean, TileGrid> OREDICT_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isOredictPattern(), (t, v) -> {
|
||||||
t.getNode().setOredictPattern(v);
|
t.getNode().setOredictPattern(v);
|
||||||
t.getNode().markDirty();
|
t.getNode().markDirty();
|
||||||
}, p -> {
|
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateOredictPattern(p)));
|
||||||
if (Minecraft.getMinecraft().currentScreen instanceof GuiGrid) {
|
|
||||||
((GuiGrid) Minecraft.getMinecraft().currentScreen).updateOredictPattern(p);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
public static final TileDataParameter<Boolean, TileGrid> PROCESSING_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isProcessingPattern(), (t, v) -> {
|
public static final TileDataParameter<Boolean, TileGrid> PROCESSING_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isProcessingPattern(), (t, v) -> {
|
||||||
t.getNode().setProcessingPattern(v);
|
t.getNode().setProcessingPattern(v);
|
||||||
t.getNode().markDirty();
|
t.getNode().markDirty();
|
||||||
@@ -88,19 +75,11 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
|||||||
((ContainerGrid) player.openContainer).initSlots();
|
((ContainerGrid) player.openContainer).initSlots();
|
||||||
((ContainerGrid) player.openContainer).sendAllSlots();
|
((ContainerGrid) player.openContainer).sendAllSlots();
|
||||||
});
|
});
|
||||||
}, p -> {
|
}, p -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
||||||
if (Minecraft.getMinecraft().currentScreen != null) {
|
|
||||||
Minecraft.getMinecraft().currentScreen.initGui();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
public static final TileDataParameter<Boolean, TileGrid> BLOCKING_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isBlockingPattern(), (t, v) -> {
|
public static final TileDataParameter<Boolean, TileGrid> BLOCKING_PATTERN = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isBlockingPattern(), (t, v) -> {
|
||||||
t.getNode().setBlockingPattern(v);
|
t.getNode().setBlockingPattern(v);
|
||||||
t.getNode().markDirty();
|
t.getNode().markDirty();
|
||||||
}, p -> {
|
}, p -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateBlockingPattern(p)));
|
||||||
if (Minecraft.getMinecraft().currentScreen instanceof GuiGrid) {
|
|
||||||
((GuiGrid) Minecraft.getMinecraft().currentScreen).updateBlockingPattern(p);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
public TileGrid() {
|
public TileGrid() {
|
||||||
dataManager.addWatchedParameter(VIEW_TYPE);
|
dataManager.addWatchedParameter(VIEW_TYPE);
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ gui.refinedstorage:security_manager.permission.5=Security
|
|||||||
gui.refinedstorage:security_manager.permission.5.tooltip=Ability to change security options
|
gui.refinedstorage:security_manager.permission.5.tooltip=Ability to change security options
|
||||||
gui.refinedstorage:storage_monitor=Storage Monitor
|
gui.refinedstorage:storage_monitor=Storage Monitor
|
||||||
gui.refinedstorage:portable_grid=Portable Grid
|
gui.refinedstorage:portable_grid=Portable Grid
|
||||||
|
gui.refinedstorage:crafter_manager=Crafter Manager
|
||||||
|
|
||||||
misc.refinedstorage:energy_stored=%d / %d FE
|
misc.refinedstorage:energy_stored=%d / %d FE
|
||||||
misc.refinedstorage:energy_usage=Usage: %d FE/t
|
misc.refinedstorage:energy_usage=Usage: %d FE/t
|
||||||
@@ -242,6 +243,7 @@ block.refinedstorage:storage_monitor.name=Storage Monitor
|
|||||||
block.refinedstorage:portable_grid.0.name=Portable Grid
|
block.refinedstorage:portable_grid.0.name=Portable Grid
|
||||||
block.refinedstorage:portable_grid.1.name=Creative Portable Grid
|
block.refinedstorage:portable_grid.1.name=Creative Portable Grid
|
||||||
block.refinedstorage:portable_grid.tooltip=Sneak to place in the world.
|
block.refinedstorage:portable_grid.tooltip=Sneak to place in the world.
|
||||||
|
block.refinedstorage:crafter_manager.name=Crafter Manager
|
||||||
|
|
||||||
item.refinedstorage:storage_disk.0.name=1k Storage Disk
|
item.refinedstorage:storage_disk.0.name=1k Storage Disk
|
||||||
item.refinedstorage:storage_disk.1.name=4k Storage Disk
|
item.refinedstorage:storage_disk.1.name=4k Storage Disk
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
Reference in New Issue
Block a user