Implement the Crafting Grid
This commit is contained in:
@@ -27,6 +27,7 @@ sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = co
|
|||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'snapshot', version: '20190719-1.14.3'
|
mappings channel: 'snapshot', version: '20190719-1.14.3'
|
||||||
|
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||||
import net.minecraftforge.client.model.ModelLoader;
|
import net.minecraftforge.client.model.ModelLoader;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
|
||||||
@@ -38,6 +39,11 @@ public class ClientSetup {
|
|||||||
new ResourceLocation(RS.ID, "block/grid/cutouts/front_connected")
|
new ResourceLocation(RS.ID, "block/grid/cutouts/front_connected")
|
||||||
));
|
));
|
||||||
|
|
||||||
|
bakedModelOverrideRegistry.add(new ResourceLocation(RS.ID, "crafting_grid"), (base, registry) -> new FullbrightBakedModel(
|
||||||
|
base,
|
||||||
|
new ResourceLocation(RS.ID, "block/grid/cutouts/crafting_front_connected")
|
||||||
|
));
|
||||||
|
|
||||||
bakedModelOverrideRegistry.add(new ResourceLocation(RS.ID, "disk_drive"), (base, registry) -> new FullbrightBakedModel(
|
bakedModelOverrideRegistry.add(new ResourceLocation(RS.ID, "disk_drive"), (base, registry) -> new FullbrightBakedModel(
|
||||||
new DiskDriveBakedModel(
|
new DiskDriveBakedModel(
|
||||||
base,
|
base,
|
||||||
@@ -65,7 +71,8 @@ public class ClientSetup {
|
|||||||
ScreenManager.registerFactory(RSContainers.DISK_DRIVE, DiskDriveScreen::new);
|
ScreenManager.registerFactory(RSContainers.DISK_DRIVE, DiskDriveScreen::new);
|
||||||
ScreenManager.registerFactory(RSContainers.GRID, new GridScreenFactory());
|
ScreenManager.registerFactory(RSContainers.GRID, new GridScreenFactory());
|
||||||
|
|
||||||
RSKeyBindings.init();
|
ClientRegistry.registerKeyBinding(RSKeyBindings.FOCUS_SEARCH_BAR);
|
||||||
|
ClientRegistry.registerKeyBinding(RSKeyBindings.CLEAR_GRID_CRAFTING_MATRIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
|||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeListener;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeListener;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.GridFactoryGridBlock;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.factory.GridBlockGridFactory;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.CableNetworkNode;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.CableNetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||||
@@ -94,8 +94,9 @@ public final class RS {
|
|||||||
API.instance().getNetworkNodeRegistry().add(DiskDriveNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new DiskDriveNetworkNode(world, pos)));
|
API.instance().getNetworkNodeRegistry().add(DiskDriveNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new DiskDriveNetworkNode(world, pos)));
|
||||||
API.instance().getNetworkNodeRegistry().add(CableNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new CableNetworkNode(world, pos)));
|
API.instance().getNetworkNodeRegistry().add(CableNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new CableNetworkNode(world, pos)));
|
||||||
API.instance().getNetworkNodeRegistry().add(GridNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new GridNetworkNode(world, pos, GridType.NORMAL)));
|
API.instance().getNetworkNodeRegistry().add(GridNetworkNode.ID, (tag, world, pos) -> readAndReturn(tag, new GridNetworkNode(world, pos, GridType.NORMAL)));
|
||||||
|
API.instance().getNetworkNodeRegistry().add(GridNetworkNode.CRAFTING_ID, (tag, world, pos) -> readAndReturn(tag, new GridNetworkNode(world, pos, GridType.CRAFTING)));
|
||||||
|
|
||||||
API.instance().getGridManager().add(GridFactoryGridBlock.ID, new GridFactoryGridBlock());
|
API.instance().getGridManager().add(GridBlockGridFactory.ID, new GridBlockGridFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
private INetworkNode readAndReturn(CompoundNBT tag, NetworkNode node) {
|
private INetworkNode readAndReturn(CompoundNBT tag, NetworkNode node) {
|
||||||
@@ -118,26 +119,17 @@ public final class RS {
|
|||||||
e.getRegistry().register(new CableBlock());
|
e.getRegistry().register(new CableBlock());
|
||||||
e.getRegistry().register(new DiskDriveBlock());
|
e.getRegistry().register(new DiskDriveBlock());
|
||||||
e.getRegistry().register(new GridBlock(GridType.NORMAL));
|
e.getRegistry().register(new GridBlock(GridType.NORMAL));
|
||||||
|
e.getRegistry().register(new GridBlock(GridType.CRAFTING));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRegisterTiles(RegistryEvent.Register<TileEntityType<?>> e) {
|
public void onRegisterTiles(RegistryEvent.Register<TileEntityType<?>> e) {
|
||||||
e.getRegistry().register(registerTileDataParameters(
|
e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(() -> new ControllerTile(ControllerBlock.Type.NORMAL), RSBlocks.CONTROLLER).build(null).setRegistryName(RS.ID, "controller")));
|
||||||
TileEntityType.Builder.create(() -> new ControllerTile(ControllerBlock.Type.NORMAL), RSBlocks.CONTROLLER).build(null).setRegistryName(RS.ID, "controller")
|
e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(() -> new ControllerTile(ControllerBlock.Type.CREATIVE), RSBlocks.CREATIVE_CONTROLLER).build(null).setRegistryName(RS.ID, "creative_controller")));
|
||||||
));
|
|
||||||
|
|
||||||
e.getRegistry().register(registerTileDataParameters(
|
|
||||||
TileEntityType.Builder.create(() -> new ControllerTile(ControllerBlock.Type.CREATIVE), RSBlocks.CREATIVE_CONTROLLER).build(null).setRegistryName(RS.ID, "creative_controller")
|
|
||||||
));
|
|
||||||
|
|
||||||
e.getRegistry().register(TileEntityType.Builder.create(CableTile::new, RSBlocks.CABLE).build(null).setRegistryName(RS.ID, "cable"));
|
e.getRegistry().register(TileEntityType.Builder.create(CableTile::new, RSBlocks.CABLE).build(null).setRegistryName(RS.ID, "cable"));
|
||||||
e.getRegistry().register(registerTileDataParameters(
|
e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(DiskDriveTile::new, RSBlocks.DISK_DRIVE).build(null).setRegistryName(RS.ID, "disk_drive")));
|
||||||
TileEntityType.Builder.create(DiskDriveTile::new, RSBlocks.DISK_DRIVE).build(null).setRegistryName(RS.ID, "disk_drive")
|
e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(() -> new GridTile(GridType.NORMAL), RSBlocks.GRID).build(null).setRegistryName(RS.ID, "grid")));
|
||||||
));
|
e.getRegistry().register(registerTileDataParameters(TileEntityType.Builder.create(() -> new GridTile(GridType.CRAFTING), RSBlocks.CRAFTING_GRID).build(null).setRegistryName(RS.ID, "crafting_grid")));
|
||||||
|
|
||||||
e.getRegistry().register(registerTileDataParameters(
|
|
||||||
TileEntityType.Builder.create(() -> new GridTile(GridType.NORMAL), RSBlocks.GRID).build(null).setRegistryName(RS.ID, "grid")
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends TileEntity> TileEntityType<T> registerTileDataParameters(TileEntityType<T> t) {
|
private <T extends TileEntity> TileEntityType<T> registerTileDataParameters(TileEntityType<T> t) {
|
||||||
@@ -206,6 +198,7 @@ public final class RS {
|
|||||||
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.CABLE));
|
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.CABLE));
|
||||||
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.DISK_DRIVE));
|
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.DISK_DRIVE));
|
||||||
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.GRID));
|
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.GRID));
|
||||||
|
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.CRAFTING_GRID));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO
|
/* TODO
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ public final class RSBlocks {
|
|||||||
|
|
||||||
@ObjectHolder(RS.ID + ":grid")
|
@ObjectHolder(RS.ID + ":grid")
|
||||||
public static final GridBlock GRID = null;
|
public static final GridBlock GRID = null;
|
||||||
|
@ObjectHolder(RS.ID + ":crafting_grid")
|
||||||
|
public static final GridBlock CRAFTING_GRID = null;
|
||||||
|
|
||||||
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();
|
||||||
|
|||||||
@@ -3,28 +3,37 @@ package com.raoulvdberge.refinedstorage;
|
|||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.client.util.InputMappings;
|
import net.minecraft.client.util.InputMappings;
|
||||||
import net.minecraftforge.client.settings.KeyConflictContext;
|
import net.minecraftforge.client.settings.KeyConflictContext;
|
||||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
import net.minecraftforge.client.settings.KeyModifier;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public final class RSKeyBindings {
|
public final class RSKeyBindings {
|
||||||
/*
|
/*
|
||||||
public static final KeyBinding CLEAR_GRID_CRAFTING_MATRIX = new KeyBinding("key.refinedstorage.clearGridCraftingMatrix", KeyConflictContext.GUI, KeyModifier.CONTROL, Keyboard.KEY_X, "Refined Storage");
|
|
||||||
public static final KeyBinding OPEN_WIRELESS_GRID = new KeyBinding("key.refinedstorage.openWirelessGrid", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
public static final KeyBinding OPEN_WIRELESS_GRID = new KeyBinding("key.refinedstorage.openWirelessGrid", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
||||||
public static final KeyBinding OPEN_WIRELESS_FLUID_GRID = new KeyBinding("key.refinedstorage.openWirelessFluidGrid", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
public static final KeyBinding OPEN_WIRELESS_FLUID_GRID = new KeyBinding("key.refinedstorage.openWirelessFluidGrid", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
||||||
public static final KeyBinding OPEN_PORTABLE_GRID = new KeyBinding("key.refinedstorage.openPortableGrid", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
public static final KeyBinding OPEN_PORTABLE_GRID = new KeyBinding("key.refinedstorage.openPortableGrid", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
||||||
public static final KeyBinding OPEN_WIRELESS_CRAFTING_MONITOR = new KeyBinding("key.refinedstorage.openWirelessCraftingMonitor", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
public static final KeyBinding OPEN_WIRELESS_CRAFTING_MONITOR = new KeyBinding("key.refinedstorage.openWirelessCraftingMonitor", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
ClientRegistry.registerKeyBinding(CLEAR_GRID_CRAFTING_MATRIX);
|
|
||||||
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_GRID);
|
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_GRID);
|
||||||
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_FLUID_GRID);
|
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_FLUID_GRID);
|
||||||
ClientRegistry.registerKeyBinding(OPEN_PORTABLE_GRID);
|
ClientRegistry.registerKeyBinding(OPEN_PORTABLE_GRID);
|
||||||
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_CRAFTING_MONITOR);
|
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_CRAFTING_MONITOR);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
public static final KeyBinding FOCUS_SEARCH_BAR = new KeyBinding("key.refinedstorage.focusSearchBar", KeyConflictContext.GUI, InputMappings.Type.KEYSYM, GLFW.GLFW_KEY_TAB, "Refined Storage");
|
public static final KeyBinding FOCUS_SEARCH_BAR = new KeyBinding(
|
||||||
|
"key.refinedstorage.focusSearchBar",
|
||||||
|
KeyConflictContext.GUI,
|
||||||
|
InputMappings.Type.KEYSYM,
|
||||||
|
GLFW.GLFW_KEY_TAB,
|
||||||
|
"Refined Storage"
|
||||||
|
);
|
||||||
|
|
||||||
public static void init() {
|
public static final KeyBinding CLEAR_GRID_CRAFTING_MATRIX = new KeyBinding(
|
||||||
ClientRegistry.registerKeyBinding(FOCUS_SEARCH_BAR);
|
"key.refinedstorage.clearGridCraftingMatrix",
|
||||||
}
|
KeyConflictContext.GUI,
|
||||||
|
KeyModifier.CONTROL,
|
||||||
|
InputMappings.Type.KEYSYM,
|
||||||
|
GLFW.GLFW_KEY_X,
|
||||||
|
"Refined Storage"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,6 @@ public class RSOldConfig {
|
|||||||
public int storageUsage;
|
public int storageUsage;
|
||||||
public int fluidStorageUsage;
|
public int fluidStorageUsage;
|
||||||
public int wirelessTransmitterUsage;
|
public int wirelessTransmitterUsage;
|
||||||
public int craftingGridUsage;
|
|
||||||
public int patternGridUsage;
|
public int patternGridUsage;
|
||||||
public int fluidGridUsage;
|
public int fluidGridUsage;
|
||||||
public int networkTransmitterUsage;
|
public int networkTransmitterUsage;
|
||||||
@@ -111,7 +110,6 @@ public class RSOldConfig {
|
|||||||
storageUsage = config.getInt("storage", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Storage Blocks");
|
storageUsage = config.getInt("storage", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Storage Blocks");
|
||||||
fluidStorageUsage = config.getInt("fluidStorage", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Fluid Storage Blocks");
|
fluidStorageUsage = config.getInt("fluidStorage", ENERGY, 1, 0, Integer.MAX_VALUE, "The energy used by Fluid Storage Blocks");
|
||||||
wirelessTransmitterUsage = config.getInt("wirelessTransmitter", ENERGY, 8, 0, Integer.MAX_VALUE, "The energy used by Wireless Transmitters");
|
wirelessTransmitterUsage = config.getInt("wirelessTransmitter", ENERGY, 8, 0, Integer.MAX_VALUE, "The energy used by Wireless Transmitters");
|
||||||
craftingGridUsage = config.getInt("craftingGrid", ENERGY, 4, 0, Integer.MAX_VALUE, "The energy used by Crafting Grids");
|
|
||||||
patternGridUsage = config.getInt("patternGrid", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Pattern Grids");
|
patternGridUsage = config.getInt("patternGrid", ENERGY, 3, 0, Integer.MAX_VALUE, "The energy used by Pattern Grids");
|
||||||
fluidGridUsage = config.getInt("fluidGrid", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Fluid Grids");
|
fluidGridUsage = config.getInt("fluidGrid", ENERGY, 2, 0, Integer.MAX_VALUE, "The energy used by Fluid Grids");
|
||||||
networkTransmitterUsage = config.getInt("networkTransmitter", ENERGY, 64, 0, Integer.MAX_VALUE, "The energy used by Network Transmitters");
|
networkTransmitterUsage = config.getInt("networkTransmitter", ENERGY, 64, 0, Integer.MAX_VALUE, "The energy used by Network Transmitters");
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ public class RSTiles {
|
|||||||
|
|
||||||
@ObjectHolder(RS.ID + ":grid")
|
@ObjectHolder(RS.ID + ":grid")
|
||||||
public static final TileEntityType<GridTile> GRID = null;
|
public static final TileEntityType<GridTile> GRID = null;
|
||||||
|
@ObjectHolder(RS.ID + ":crafting_grid")
|
||||||
|
public static final TileEntityType<GridTile> CRAFTING_GRID = null;
|
||||||
|
|
||||||
//@ObjectHolder(RS.ID + ":importer")
|
//@ObjectHolder(RS.ID + ":importer")
|
||||||
public static final TileEntityType<TileImporter> IMPORTER = null;
|
public static final TileEntityType<TileImporter> IMPORTER = null;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskRe
|
|||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.grid.ICraftingGridBehavior;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridManager;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGridManager;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
||||||
@@ -121,6 +122,12 @@ public interface IRSAPI {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
IGridManager getGridManager();
|
IGridManager getGridManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the default crafting grid behavior
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
ICraftingGridBehavior getCraftingGridBehavior();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the storage disk registry
|
* @return the storage disk registry
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.api.network.grid;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines default behavior of crafting grids.
|
||||||
|
*/
|
||||||
|
public interface ICraftingGridBehavior {
|
||||||
|
/**
|
||||||
|
* Default logic for regular crafting.
|
||||||
|
*
|
||||||
|
* @param grid the grid
|
||||||
|
* @param recipe the recipe
|
||||||
|
* @param player the player
|
||||||
|
*/
|
||||||
|
void onCrafted(IGridNetworkAware grid, ICraftingRecipe recipe, PlayerEntity player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default logic for crafting with shift click (mass crafting).
|
||||||
|
*
|
||||||
|
* @param grid the grid
|
||||||
|
* @param player the layer
|
||||||
|
*/
|
||||||
|
void onCraftedShift(IGridNetworkAware grid, PlayerEntity player);
|
||||||
|
}
|
||||||
@@ -3,10 +3,11 @@ package com.raoulvdberge.refinedstorage.api.network.grid;
|
|||||||
/**
|
/**
|
||||||
* A crafting listener for the grid.
|
* A crafting listener for the grid.
|
||||||
*/
|
*/
|
||||||
public interface IGridCraftingListener {
|
public interface ICraftingGridListener {
|
||||||
/**
|
/**
|
||||||
* Called when the crafting matrix was changed.
|
* Called when the crafting matrix was changed.
|
||||||
* Usually you'd send slot updates for the crafting slots (and output slot) here, so that all clients get an actual view.
|
* Usually you'd send slot updates for the crafting slots (and output slot) here, so that all clients get an actual view.
|
||||||
|
* This listener exists so the crafting result slot is only calculated on the server.
|
||||||
*/
|
*/
|
||||||
void onCraftingMatrixChanged();
|
void onCraftingMatrixChanged();
|
||||||
}
|
}
|
||||||
@@ -77,13 +77,13 @@ public interface IGrid {
|
|||||||
/**
|
/**
|
||||||
* @param listener the listener
|
* @param listener the listener
|
||||||
*/
|
*/
|
||||||
default void addCraftingListener(IGridCraftingListener listener) {
|
default void addCraftingListener(ICraftingGridListener listener) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param listener the listener
|
* @param listener the listener
|
||||||
*/
|
*/
|
||||||
default void removeCraftingListener(IGridCraftingListener listener) {
|
default void removeCraftingListener(ICraftingGridListener listener) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -205,6 +205,11 @@ public interface IGrid {
|
|||||||
*/
|
*/
|
||||||
void onCrafted(PlayerEntity player);
|
void onCrafted(PlayerEntity player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the clear button is pressed in the pattern grid or crafting grid.
|
||||||
|
*/
|
||||||
|
void onClear(PlayerEntity player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an item is crafted with shift click (up to 64 items) in a crafting grid.
|
* Called when an item is crafted with shift click (up to 64 items) in a crafting grid.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.registry.ICraftingTaskRe
|
|||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadException;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.grid.ICraftingGridBehavior;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridManager;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGridManager;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
||||||
@@ -33,6 +34,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPrev
|
|||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.registry.CraftingTaskRegistry;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.registry.CraftingTaskRegistry;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeManager;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeManager;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeRegistry;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeRegistry;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.CraftingGridBehavior;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.GridManager;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.GridManager;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterChannel;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterChannel;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterHandlerRegistry;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter.ReaderWriterHandlerRegistry;
|
||||||
@@ -60,18 +62,19 @@ import java.util.*;
|
|||||||
public class API implements IRSAPI {
|
public class API implements IRSAPI {
|
||||||
private static final IRSAPI INSTANCE = new API();
|
private static final IRSAPI INSTANCE = new API();
|
||||||
|
|
||||||
private IComparer comparer = new Comparer();
|
private final IComparer comparer = new Comparer();
|
||||||
private IQuantityFormatter quantityFormatter = new QuantityFormatter();
|
private final IQuantityFormatter quantityFormatter = new QuantityFormatter();
|
||||||
private INetworkNodeRegistry networkNodeRegistry = new NetworkNodeRegistry();
|
private final INetworkNodeRegistry networkNodeRegistry = new NetworkNodeRegistry();
|
||||||
private ICraftingTaskRegistry craftingTaskRegistry = new CraftingTaskRegistry();
|
private final ICraftingTaskRegistry craftingTaskRegistry = new CraftingTaskRegistry();
|
||||||
private ICraftingMonitorElementRegistry craftingMonitorElementRegistry = new CraftingMonitorElementRegistry();
|
private final ICraftingMonitorElementRegistry craftingMonitorElementRegistry = new CraftingMonitorElementRegistry();
|
||||||
private ICraftingPreviewElementRegistry craftingPreviewElementRegistry = new CraftingPreviewElementRegistry();
|
private final ICraftingPreviewElementRegistry craftingPreviewElementRegistry = new CraftingPreviewElementRegistry();
|
||||||
private IReaderWriterHandlerRegistry readerWriterHandlerRegistry = new ReaderWriterHandlerRegistry();
|
private final IReaderWriterHandlerRegistry readerWriterHandlerRegistry = new ReaderWriterHandlerRegistry();
|
||||||
private IGridManager gridManager = new GridManager();
|
private final IGridManager gridManager = new GridManager();
|
||||||
private IStorageDiskRegistry storageDiskRegistry = new StorageDiskRegistry();
|
private final ICraftingGridBehavior craftingGridBehavior = new CraftingGridBehavior();
|
||||||
private IStorageDiskSync storageDiskSync = new StorageDiskSync();
|
private final IStorageDiskRegistry storageDiskRegistry = new StorageDiskRegistry();
|
||||||
private Map<StorageType, TreeSet<IExternalStorageProvider>> externalStorageProviders = new HashMap<>();
|
private final IStorageDiskSync storageDiskSync = new StorageDiskSync();
|
||||||
private List<ICraftingPatternRenderHandler> patternRenderHandlers = new LinkedList<>();
|
private final Map<StorageType, TreeSet<IExternalStorageProvider>> externalStorageProviders = new HashMap<>();
|
||||||
|
private final List<ICraftingPatternRenderHandler> patternRenderHandlers = new LinkedList<>();
|
||||||
|
|
||||||
public static IRSAPI instance() {
|
public static IRSAPI instance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
@@ -175,6 +178,12 @@ public class API implements IRSAPI {
|
|||||||
return gridManager;
|
return gridManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public ICraftingGridBehavior getCraftingGridBehavior() {
|
||||||
|
return craftingGridBehavior;
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public IStorageDiskRegistry getStorageDiskRegistry() {
|
public IStorageDiskRegistry getStorageDiskRegistry() {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import net.minecraft.inventory.CraftingInventory;
|
|||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.ICraftingRecipe;
|
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
|
||||||
import net.minecraft.item.crafting.IRecipeType;
|
import net.minecraft.item.crafting.IRecipeType;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
@@ -20,6 +19,7 @@ import net.minecraftforge.fluids.FluidStack;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class CraftingPattern implements ICraftingPattern {
|
public class CraftingPattern implements ICraftingPattern {
|
||||||
private ICraftingPatternContainer container;
|
private ICraftingPatternContainer container;
|
||||||
@@ -27,7 +27,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
private boolean processing;
|
private boolean processing;
|
||||||
private boolean oredict;
|
private boolean oredict;
|
||||||
private boolean valid;
|
private boolean valid;
|
||||||
private IRecipe recipe;
|
private ICraftingRecipe recipe;
|
||||||
private List<NonNullList<ItemStack>> inputs = new ArrayList<>();
|
private List<NonNullList<ItemStack>> inputs = new ArrayList<>();
|
||||||
private NonNullList<ItemStack> outputs = NonNullList.create();
|
private NonNullList<ItemStack> outputs = NonNullList.create();
|
||||||
private NonNullList<ItemStack> byproducts = NonNullList.create();
|
private NonNullList<ItemStack> byproducts = NonNullList.create();
|
||||||
@@ -108,10 +108,9 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: better way of collecting recipes
|
Optional<ICraftingRecipe> potentialRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, inv, world);
|
||||||
for (ICraftingRecipe r : world.getRecipeManager().getRecipes(IRecipeType.CRAFTING, inv, world)) {
|
if (potentialRecipe.isPresent()) {
|
||||||
if (r.matches(inv, world)) {
|
this.recipe = potentialRecipe.get();
|
||||||
this.recipe = r;
|
|
||||||
|
|
||||||
this.byproducts = recipe.getRemainingItems(inv);
|
this.byproducts = recipe.getRemainingItems(inv);
|
||||||
|
|
||||||
@@ -134,9 +133,6 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.apiimpl.network.grid;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.grid.ICraftingGridBehavior;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGridNetworkAware;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||||
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
|
import net.minecraft.inventory.InventoryHelper;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
|
import net.minecraftforge.fml.hooks.BasicEventHooks;
|
||||||
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||||
|
@Override
|
||||||
|
public void onCrafted(IGridNetworkAware grid, ICraftingRecipe recipe, PlayerEntity player) {
|
||||||
|
NonNullList<ItemStack> remainder = recipe.getRemainingItems(grid.getCraftingMatrix());
|
||||||
|
|
||||||
|
INetwork network = grid.getNetwork();
|
||||||
|
|
||||||
|
CraftingInventory matrix = grid.getCraftingMatrix();
|
||||||
|
|
||||||
|
for (int i = 0; i < grid.getCraftingMatrix().getSizeInventory(); ++i) {
|
||||||
|
ItemStack slot = matrix.getStackInSlot(i);
|
||||||
|
|
||||||
|
// Do we have a remainder?
|
||||||
|
if (i < remainder.size() && !remainder.get(i).isEmpty()) {
|
||||||
|
// If there is no space for the remainder, dump it in the player inventory.
|
||||||
|
if (!slot.isEmpty() && slot.getCount() > 1) {
|
||||||
|
if (!player.inventory.addItemStackToInventory(remainder.get(i).copy())) { // If there is no space in the player inventory, try to dump it in the network.
|
||||||
|
ItemStack remainderStack = network == null ? remainder.get(i).copy() : network.insertItem(remainder.get(i).copy(), remainder.get(i).getCount(), Action.PERFORM);
|
||||||
|
|
||||||
|
// If there is no space in the network, just dump it in the world.
|
||||||
|
if (remainderStack != null) {
|
||||||
|
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), remainderStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
matrix.decrStackSize(i, 1);
|
||||||
|
} else {
|
||||||
|
matrix.setInventorySlotContents(i, remainder.get(i).copy());
|
||||||
|
}
|
||||||
|
} else if (!slot.isEmpty()) { // We don't have a remainder, but the slot is not empty.
|
||||||
|
if (slot.getCount() == 1 && network != null) { // Attempt to refill the slot with the same item from the network, only if we have a network and only if it's the last item.
|
||||||
|
ItemStack refill = StackUtils.nullToEmpty(network.extractItem(slot, 1, Action.PERFORM));
|
||||||
|
|
||||||
|
matrix.setInventorySlotContents(i, refill);
|
||||||
|
|
||||||
|
if (!refill.isEmpty()) {
|
||||||
|
network.getItemStorageTracker().changed(player, refill.copy());
|
||||||
|
}
|
||||||
|
} else { // We don't have a network, or, the slot still has more than 1 items in it. Just decrement then.
|
||||||
|
matrix.decrStackSize(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grid.onCraftingMatrixChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCraftedShift(IGridNetworkAware grid, PlayerEntity player) {
|
||||||
|
List<ItemStack> craftedItemsList = new ArrayList<>();
|
||||||
|
int amountCrafted = 0;
|
||||||
|
ItemStack crafted = grid.getCraftingResult().getStackInSlot(0);
|
||||||
|
|
||||||
|
// Do while the item is still craftable (aka is the result slot still the same as the original item?) and we don't exceed the max stack size.
|
||||||
|
do {
|
||||||
|
grid.onCrafted(player);
|
||||||
|
|
||||||
|
craftedItemsList.add(crafted.copy());
|
||||||
|
|
||||||
|
amountCrafted += crafted.getCount();
|
||||||
|
} while (API.instance().getComparer().isEqual(crafted, grid.getCraftingResult().getStackInSlot(0)) && amountCrafted + crafted.getCount() < crafted.getMaxStackSize());
|
||||||
|
|
||||||
|
INetwork network = grid.getNetwork();
|
||||||
|
|
||||||
|
for (ItemStack craftedItem : craftedItemsList) {
|
||||||
|
if (!player.inventory.addItemStackToInventory(craftedItem.copy())) {
|
||||||
|
ItemStack remainder = network == null ? craftedItem : network.insertItem(craftedItem, craftedItem.getCount(), Action.PERFORM);
|
||||||
|
|
||||||
|
if (remainder != null) {
|
||||||
|
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), remainder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Volatile: This is some logic copied from CraftingResultSlot#onCrafting. We call this manually for shift clicking because
|
||||||
|
// otherwise it's not being called.
|
||||||
|
// For regular crafting, this is already called in ResultCraftingGridSlot#onTake -> onCrafting(stack)
|
||||||
|
crafted.onCrafting(player.world, player, amountCrafted);
|
||||||
|
BasicEventHooks.firePlayerCraftingEvent(player, ItemHandlerHelper.copyStackWithSize(crafted, amountCrafted), grid.getCraftingMatrix());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.network.grid;
|
package com.raoulvdberge.refinedstorage.apiimpl.network.grid.factory;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
||||||
@@ -14,7 +14,7 @@ import net.minecraft.world.World;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class GridFactoryGridBlock implements IGridFactory {
|
public class GridBlockGridFactory implements IGridFactory {
|
||||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "grid");
|
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "grid");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.network.grid;
|
package com.raoulvdberge.refinedstorage.apiimpl.network.grid.factory;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
@@ -12,7 +12,7 @@ import net.minecraft.world.World;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class GridFactoryPortableGridBlock implements IGridFactory {
|
public class PortableGridBlockGridFactory implements IGridFactory {
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.network.grid;
|
package com.raoulvdberge.refinedstorage.apiimpl.network.grid.factory;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
@@ -12,7 +12,7 @@ import net.minecraft.world.World;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class GridFactoryPortableGrid implements IGridFactory {
|
public class PortableGridGridFactory implements IGridFactory {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.network.grid;
|
package com.raoulvdberge.refinedstorage.apiimpl.network.grid.factory;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
@@ -12,7 +12,7 @@ import net.minecraft.world.World;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class GridFactoryWirelessFluidGrid implements IGridFactory {
|
public class WirelessFluidGridGridFactory implements IGridFactory {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.network.grid;
|
package com.raoulvdberge.refinedstorage.apiimpl.network.grid.factory;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
@@ -12,7 +12,7 @@ import net.minecraft.world.World;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class GridFactoryWirelessGrid implements IGridFactory {
|
public class WirelessGridGridFactory implements IGridFactory {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
||||||
@@ -19,10 +19,10 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class FluidGridHandlerPortable implements IFluidGridHandler {
|
public class PortableFluidGridHandler implements IFluidGridHandler {
|
||||||
private IPortableGrid portableGrid;
|
private IPortableGrid portableGrid;
|
||||||
|
|
||||||
public FluidGridHandlerPortable(IPortableGrid portableGrid) {
|
public PortableFluidGridHandler(IPortableGrid portableGrid) {
|
||||||
this.portableGrid = portableGrid;
|
this.portableGrid = portableGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,11 +18,11 @@ import net.minecraftforge.items.ItemHandlerHelper;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ItemGridHandlerPortable implements IItemGridHandler {
|
public class PortableItemGridHandler implements IItemGridHandler {
|
||||||
private IPortableGrid portableGrid;
|
private IPortableGrid portableGrid;
|
||||||
private IGrid grid;
|
private IGrid grid;
|
||||||
|
|
||||||
public ItemGridHandlerPortable(IPortableGrid portableGrid, IGrid grid) {
|
public PortableItemGridHandler(IPortableGrid portableGrid, IGrid grid) {
|
||||||
this.portableGrid = portableGrid;
|
this.portableGrid = portableGrid;
|
||||||
this.grid = grid;
|
this.grid = grid;
|
||||||
}
|
}
|
||||||
@@ -31,14 +31,12 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
|||||||
import net.minecraft.inventory.CraftResultInventory;
|
import net.minecraft.inventory.CraftResultInventory;
|
||||||
import net.minecraft.inventory.CraftingInventory;
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.InventoryHelper;
|
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.ContainerType;
|
import net.minecraft.inventory.container.ContainerType;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||||
import net.minecraft.item.crafting.IRecipeType;
|
import net.minecraft.item.crafting.IRecipeType;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
@@ -61,6 +59,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, IType {
|
public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, IType {
|
||||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "grid");
|
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "grid");
|
||||||
|
public static final ResourceLocation CRAFTING_ID = new ResourceLocation(RS.ID, "crafting_grid");
|
||||||
|
|
||||||
public static final String NBT_VIEW_TYPE = "ViewType";
|
public static final String NBT_VIEW_TYPE = "ViewType";
|
||||||
public static final String NBT_SORTING_DIRECTION = "SortingDirection";
|
public static final String NBT_SORTING_DIRECTION = "SortingDirection";
|
||||||
@@ -87,13 +86,13 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private IRecipe currentRecipe;
|
private ICraftingRecipe currentRecipe;
|
||||||
private CraftingInventory matrix = new CraftingInventory(craftingContainer, 3, 3);
|
private CraftingInventory matrix = new CraftingInventory(craftingContainer, 3, 3);
|
||||||
private CraftResultInventory result = new CraftResultInventory();
|
private CraftResultInventory result = new CraftResultInventory();
|
||||||
private ItemHandlerBase processingMatrix = new ItemHandlerBase(9 * 2, new ListenerNetworkNode(this));
|
private ItemHandlerBase processingMatrix = new ItemHandlerBase(9 * 2, new ListenerNetworkNode(this));
|
||||||
private FluidInventory processingMatrixFluids = new FluidInventory(9 * 2, FluidAttributes.BUCKET_VOLUME * 64, new ListenerNetworkNode(this));
|
private FluidInventory processingMatrixFluids = new FluidInventory(9 * 2, FluidAttributes.BUCKET_VOLUME * 64, new ListenerNetworkNode(this));
|
||||||
|
|
||||||
private Set<IGridCraftingListener> craftingListeners = new HashSet<>();
|
private Set<ICraftingGridListener> craftingListeners = new HashSet<>();
|
||||||
|
|
||||||
private ItemHandlerBase patterns = new ItemHandlerBase(2, new ListenerNetworkNode(this), new ItemValidatorBasic(RSItems.PATTERN)) {
|
private ItemHandlerBase patterns = new ItemHandlerBase(2, new ListenerNetworkNode(this), new ItemValidatorBasic(RSItems.PATTERN)) {
|
||||||
@Override
|
@Override
|
||||||
@@ -146,7 +145,7 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
|||||||
private List<IGridTab> tabs = new ArrayList<>();
|
private List<IGridTab> tabs = new ArrayList<>();
|
||||||
private ItemHandlerFilter filter = new ItemHandlerFilter(filters, tabs, new ListenerNetworkNode(this));
|
private ItemHandlerFilter filter = new ItemHandlerFilter(filters, tabs, new ListenerNetworkNode(this));
|
||||||
|
|
||||||
private GridType type;
|
private final GridType type;
|
||||||
|
|
||||||
private int viewType = VIEW_TYPE_NORMAL;
|
private int viewType = VIEW_TYPE_NORMAL;
|
||||||
private int sortingDirection = SORTING_DIRECTION_DESCENDING;
|
private int sortingDirection = SORTING_DIRECTION_DESCENDING;
|
||||||
@@ -161,21 +160,19 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
|||||||
private boolean processingPattern = false;
|
private boolean processingPattern = false;
|
||||||
private int processingType = IType.ITEMS;
|
private int processingType = IType.ITEMS;
|
||||||
|
|
||||||
private final GridType gridType;
|
public GridNetworkNode(World world, BlockPos pos, GridType type) {
|
||||||
|
|
||||||
public GridNetworkNode(World world, BlockPos pos, GridType gridType) {
|
|
||||||
super(world, pos);
|
super(world, pos);
|
||||||
|
|
||||||
this.gridType = gridType;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage() {
|
public int getEnergyUsage() {
|
||||||
switch (getGridType()) {
|
switch (type) {
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
return RS.SERVER_CONFIG.getGrid().getUsage();
|
return RS.SERVER_CONFIG.getGrid().getGridUsage();
|
||||||
case CRAFTING:
|
case CRAFTING:
|
||||||
return 0;
|
return RS.SERVER_CONFIG.getGrid().getCraftingGridUsage();
|
||||||
case PATTERN:
|
case PATTERN:
|
||||||
return 0;
|
return 0;
|
||||||
case FLUID:
|
case FLUID:
|
||||||
@@ -231,18 +228,18 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GridType getGridType() {
|
public GridType getGridType() {
|
||||||
return gridType;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IStorageCacheListener createListener(ServerPlayerEntity player) {
|
public IStorageCacheListener createListener(ServerPlayerEntity player) {
|
||||||
return getGridType() == GridType.FLUID ? new FluidGridStorageCacheListener(player, network) : new ItemGridStorageCacheListener(player, network);
|
return type == GridType.FLUID ? new FluidGridStorageCacheListener(player, network) : new ItemGridStorageCacheListener(player, network);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public IStorageCache getStorageCache() {
|
public IStorageCache getStorageCache() {
|
||||||
return network != null ? (getGridType() == GridType.FLUID ? network.getFluidStorageCache() : network.getItemStorageCache()) : null;
|
return network != null ? (type == GridType.FLUID ? network.getFluidStorageCache() : network.getItemStorageCache()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -258,19 +255,17 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCraftingListener(IGridCraftingListener listener) {
|
public void addCraftingListener(ICraftingGridListener listener) {
|
||||||
craftingListeners.add(listener);
|
craftingListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeCraftingListener(IGridCraftingListener listener) {
|
public void removeCraftingListener(ICraftingGridListener listener) {
|
||||||
craftingListeners.remove(listener);
|
craftingListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITextComponent getTitle() {
|
public ITextComponent getTitle() {
|
||||||
GridType type = getGridType();
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CRAFTING:
|
case CRAFTING:
|
||||||
return new TranslationTextComponent("gui.refinedstorage.crafting_grid");
|
return new TranslationTextComponent("gui.refinedstorage.crafting_grid");
|
||||||
@@ -323,7 +318,7 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
|||||||
@Override
|
@Override
|
||||||
public void onCraftingMatrixChanged() {
|
public void onCraftingMatrixChanged() {
|
||||||
if (currentRecipe == null || !currentRecipe.matches(matrix, world)) {
|
if (currentRecipe == null || !currentRecipe.matches(matrix, world)) {
|
||||||
currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, matrix, world).orElse(null); // TODO: does this work?
|
currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, matrix, world).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentRecipe == null) {
|
if (currentRecipe == null) {
|
||||||
@@ -332,7 +327,7 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
|||||||
result.setInventorySlotContents(0, currentRecipe.getCraftingResult(matrix));
|
result.setInventorySlotContents(0, currentRecipe.getCraftingResult(matrix));
|
||||||
}
|
}
|
||||||
|
|
||||||
craftingListeners.forEach(IGridCraftingListener::onCraftingMatrixChanged);
|
craftingListeners.forEach(ICraftingGridListener::onCraftingMatrixChanged);
|
||||||
|
|
||||||
markDirty();
|
markDirty();
|
||||||
}
|
}
|
||||||
@@ -457,88 +452,29 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCrafted(PlayerEntity player) {
|
public void onCrafted(PlayerEntity player) {
|
||||||
onCrafted(this, world, player);
|
API.instance().getCraftingGridBehavior().onCrafted(this, currentRecipe, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onCrafted(IGridNetworkAware grid, World world, PlayerEntity player) {
|
@Override
|
||||||
// TODO: NonNullList<ItemStack> remainder = CraftingManager.getRemainingItems(grid.getCraftingMatrix(), world);
|
public void onClear(PlayerEntity player) {
|
||||||
NonNullList<ItemStack> remainder = NonNullList.create();
|
if (type == GridType.CRAFTING && network != null && network.getSecurityManager().hasPermission(Permission.INSERT, player)) {
|
||||||
|
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
|
||||||
INetwork network = grid.getNetwork();
|
|
||||||
|
|
||||||
CraftingInventory matrix = grid.getCraftingMatrix();
|
|
||||||
|
|
||||||
for (int i = 0; i < grid.getCraftingMatrix().getSizeInventory(); ++i) {
|
|
||||||
ItemStack slot = matrix.getStackInSlot(i);
|
ItemStack slot = matrix.getStackInSlot(i);
|
||||||
|
|
||||||
if (i < remainder.size() && !remainder.get(i).isEmpty()) {
|
if (!slot.isEmpty()) {
|
||||||
// If there is no space for the remainder, dump it in the player inventory
|
matrix.setInventorySlotContents(i, StackUtils.nullToEmpty(network.insertItem(slot, slot.getCount(), Action.PERFORM)));
|
||||||
if (!slot.isEmpty() && slot.getCount() > 1) {
|
|
||||||
if (!player.inventory.addItemStackToInventory(remainder.get(i).copy())) {
|
|
||||||
ItemStack remainderStack = network == null ? remainder.get(i).copy() : network.insertItem(remainder.get(i).copy(), remainder.get(i).getCount(), Action.PERFORM);
|
|
||||||
|
|
||||||
if (remainderStack != null) {
|
network.getItemStorageTracker().changed(player, slot.copy());
|
||||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), remainderStack);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (type == GridType.PATTERN) {
|
||||||
matrix.decrStackSize(i, 1);
|
clearMatrix();
|
||||||
} else {
|
|
||||||
matrix.setInventorySlotContents(i, remainder.get(i).copy());
|
|
||||||
}
|
}
|
||||||
} else if (!slot.isEmpty()) {
|
|
||||||
if (slot.getCount() == 1 && network != null) {
|
|
||||||
ItemStack refill = StackUtils.nullToEmpty(network.extractItem(slot, 1, Action.PERFORM));
|
|
||||||
|
|
||||||
matrix.setInventorySlotContents(i, refill);
|
|
||||||
|
|
||||||
if (!refill.isEmpty()) {
|
|
||||||
network.getItemStorageTracker().changed(player, refill.copy());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
matrix.decrStackSize(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
grid.onCraftingMatrixChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCraftedShift(PlayerEntity player) {
|
public void onCraftedShift(PlayerEntity player) {
|
||||||
onCraftedShift(this, player);
|
API.instance().getCraftingGridBehavior().onCraftedShift(this, player);
|
||||||
}
|
|
||||||
|
|
||||||
public static void onCraftedShift(IGridNetworkAware grid, PlayerEntity player) {
|
|
||||||
List<ItemStack> craftedItemsList = new ArrayList<>();
|
|
||||||
int craftedItems = 0;
|
|
||||||
ItemStack crafted = grid.getCraftingResult().getStackInSlot(0);
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
grid.onCrafted(player);
|
|
||||||
|
|
||||||
craftedItemsList.add(crafted.copy());
|
|
||||||
|
|
||||||
craftedItems += crafted.getCount();
|
|
||||||
|
|
||||||
if (!API.instance().getComparer().isEqual(crafted, grid.getCraftingResult().getStackInSlot(0)) || craftedItems + crafted.getCount() > crafted.getMaxStackSize()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
INetwork network = grid.getNetwork();
|
|
||||||
|
|
||||||
for (ItemStack craftedItem : craftedItemsList) {
|
|
||||||
if (!player.inventory.addItemStackToInventory(craftedItem.copy())) {
|
|
||||||
ItemStack remainder = network == null ? craftedItem : network.insertItem(craftedItem, craftedItem.getCount(), Action.PERFORM);
|
|
||||||
|
|
||||||
if (remainder != null) {
|
|
||||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), remainder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO FMLCommonHandler.instance().firePlayerCraftingEvent(player, ItemHandlerHelper.copyStackWithSize(crafted, craftedItems), grid.getCraftingMatrix());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCreatePattern() {
|
public void onCreatePattern() {
|
||||||
@@ -753,7 +689,7 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getId() {
|
public ResourceLocation getId() {
|
||||||
return ID;
|
return type == GridType.NORMAL ? ID : CRAFTING_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -828,7 +764,7 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IItemHandler getDrops() {
|
public IItemHandler getDrops() {
|
||||||
switch (getGridType()) {
|
switch (type) {
|
||||||
case CRAFTING:
|
case CRAFTING:
|
||||||
return new CombinedInvWrapper(filter, new InvWrapper(matrix));
|
return new CombinedInvWrapper(filter, new InvWrapper(matrix));
|
||||||
case PATTERN:
|
case PATTERN:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.block;
|
|||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.GridFactoryGridBlock;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.factory.GridBlockGridFactory;
|
||||||
import com.raoulvdberge.refinedstorage.block.info.BlockDirection;
|
import com.raoulvdberge.refinedstorage.block.info.BlockDirection;
|
||||||
import com.raoulvdberge.refinedstorage.tile.grid.GridTile;
|
import com.raoulvdberge.refinedstorage.tile.grid.GridTile;
|
||||||
import com.raoulvdberge.refinedstorage.util.BlockUtils;
|
import com.raoulvdberge.refinedstorage.util.BlockUtils;
|
||||||
@@ -62,7 +62,7 @@ public class GridBlock extends NodeBlock {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||||
if (!worldIn.isRemote) {
|
if (!worldIn.isRemote) {
|
||||||
return NetworkUtils.attemptModify(worldIn, pos, hit.getFace(), player, () -> API.instance().getGridManager().openGrid(GridFactoryGridBlock.ID, (ServerPlayerEntity) player, pos));
|
return NetworkUtils.attemptModify(worldIn, pos, hit.getFace(), player, () -> API.instance().getGridManager().openGrid(GridBlockGridFactory.ID, (ServerPlayerEntity) player, pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -119,18 +119,24 @@ public class ServerConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class Grid {
|
public class Grid {
|
||||||
private final ForgeConfigSpec.IntValue usage;
|
private final ForgeConfigSpec.IntValue gridUsage;
|
||||||
|
private final ForgeConfigSpec.IntValue craftingGridUsage;
|
||||||
|
|
||||||
public Grid() {
|
public Grid() {
|
||||||
builder.push("grid");
|
builder.push("grid");
|
||||||
|
|
||||||
usage = builder.comment("The energy used by Grids").defineInRange("usage", 2, 0, Integer.MAX_VALUE);
|
gridUsage = builder.comment("The energy used by Grids").defineInRange("gridUsage", 2, 0, Integer.MAX_VALUE);
|
||||||
|
craftingGridUsage = builder.comment("The energy used by Crafting Grids").defineInRange("craftingGridUsage", 4, 0, Integer.MAX_VALUE);
|
||||||
|
|
||||||
builder.pop();
|
builder.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUsage() {
|
public int getGridUsage() {
|
||||||
return usage.get();
|
return gridUsage.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCraftingGridUsage() {
|
||||||
|
return craftingGridUsage.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.raoulvdberge.refinedstorage.container;
|
|||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RSContainers;
|
import com.raoulvdberge.refinedstorage.RSContainers;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.grid.ICraftingGridListener;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridCraftingListener;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
import com.raoulvdberge.refinedstorage.api.storage.cache.IStorageCache;
|
||||||
@@ -31,9 +31,8 @@ import net.minecraft.network.play.server.SSetSlotPacket;
|
|||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class GridContainer extends BaseContainer implements IGridCraftingListener {
|
public class GridContainer extends BaseContainer implements ICraftingGridListener {
|
||||||
private IGrid grid;
|
private IGrid grid;
|
||||||
private IStorageCache cache;
|
private IStorageCache cache;
|
||||||
private IStorageCacheListener listener;
|
private IStorageCacheListener listener;
|
||||||
@@ -56,7 +55,7 @@ public class GridContainer extends BaseContainer implements IGridCraftingListene
|
|||||||
|
|
||||||
public void initSlots() {
|
public void initSlots() {
|
||||||
this.inventorySlots.clear();
|
this.inventorySlots.clear();
|
||||||
// this.inventoryItemStacks.clear(); // TODO at
|
this.inventoryItemStacks.clear();
|
||||||
|
|
||||||
this.transferManager.clearTransfers();
|
this.transferManager.clearTransfers();
|
||||||
|
|
||||||
@@ -215,8 +214,8 @@ public class GridContainer extends BaseContainer implements IGridCraftingListene
|
|||||||
Slot slot = inventorySlots.get(i);
|
Slot slot = inventorySlots.get(i);
|
||||||
|
|
||||||
if (slot instanceof CraftingGridSlot || slot == craftingResultSlot || slot == patternResultSlot) {
|
if (slot instanceof CraftingGridSlot || slot == craftingResultSlot || slot == patternResultSlot) {
|
||||||
for (IContainerListener listener : new ArrayList<IContainerListener>()) { // TODO AT for listeners
|
for (IContainerListener listener : listeners) {
|
||||||
// @Volatile: We can't use IContainerListener#sendSlotContents since ServerPlayerEntity blocks SlotCrafting changes...
|
// @Volatile: We can't use IContainerListener#sendSlotContents since ServerPlayerEntity blocks CraftingResultSlot changes...
|
||||||
if (listener instanceof ServerPlayerEntity) {
|
if (listener instanceof ServerPlayerEntity) {
|
||||||
((ServerPlayerEntity) listener).connection.sendPacket(new SSetSlotPacket(windowId, i, slot.getStack()));
|
((ServerPlayerEntity) listener).connection.sendPacket(new SSetSlotPacket(windowId, i, slot.getStack()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public class ResultCraftingGridSlot extends CraftingResultSlot {
|
|||||||
this.grid = grid;
|
this.grid = grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Volatile: Overriding logic from the super onTake method for Grid behaviors like refilling stacks from the network
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public ItemStack onTake(PlayerEntity player, @Nonnull ItemStack stack) {
|
public ItemStack onTake(PlayerEntity player, @Nonnull ItemStack stack) {
|
||||||
|
|||||||
@@ -42,17 +42,18 @@ public class FilterUpdateMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void handle(FilterUpdateMessage message, Supplier<NetworkEvent.Context> ctx) {
|
public static void handle(FilterUpdateMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
ctx.get().enqueueWork(() -> {
|
|
||||||
PlayerEntity player = ctx.get().getSender();
|
PlayerEntity player = ctx.get().getSender();
|
||||||
|
|
||||||
if (player != null && player.openContainer instanceof FilterContainer) {
|
if (player != null && player.openContainer instanceof FilterContainer) {
|
||||||
|
ctx.get().enqueueWork(() -> {
|
||||||
FilterItem.setCompare(((FilterContainer) player.openContainer).getStack(), message.compare);
|
FilterItem.setCompare(((FilterContainer) player.openContainer).getStack(), message.compare);
|
||||||
FilterItem.setMode(((FilterContainer) player.openContainer).getStack(), message.mode);
|
FilterItem.setMode(((FilterContainer) player.openContainer).getStack(), message.mode);
|
||||||
FilterItem.setModFilter(((FilterContainer) player.openContainer).getStack(), message.modFilter);
|
FilterItem.setModFilter(((FilterContainer) player.openContainer).getStack(), message.modFilter);
|
||||||
FilterItem.setName(((FilterContainer) player.openContainer).getStack(), message.name);
|
FilterItem.setName(((FilterContainer) player.openContainer).getStack(), message.name);
|
||||||
FilterItem.setType(((FilterContainer) player.openContainer).getStack(), message.type);
|
FilterItem.setType(((FilterContainer) player.openContainer).getStack(), message.type);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ctx.get().setPacketHandled(true);
|
ctx.get().setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.network;
|
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridNetworkAware;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
|
|
||||||
import com.raoulvdberge.refinedstorage.container.GridContainer;
|
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|
||||||
|
|
||||||
public class MessageGridClear extends MessageHandlerPlayerToServer<MessageGridClear> implements IMessage {
|
|
||||||
public MessageGridClear() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes(ByteBuf buf) {
|
|
||||||
// NO OP
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes(ByteBuf buf) {
|
|
||||||
// NO OP
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(MessageGridClear message, ServerPlayerEntity player) {
|
|
||||||
Container container = player.openContainer;
|
|
||||||
|
|
||||||
if (container instanceof ContainerGrid && ((ContainerGrid) container).getGrid() instanceof IGridNetworkAware) {
|
|
||||||
IGridNetworkAware grid = (IGridNetworkAware) ((ContainerGrid) container).getGrid();
|
|
||||||
|
|
||||||
if (grid.getGridType() == GridType.CRAFTING && grid.getNetwork() != null && grid.getNetwork().getSecurityManager().hasPermission(Permission.INSERT, player)) {
|
|
||||||
InventoryCrafting matrix = grid.getCraftingMatrix();
|
|
||||||
|
|
||||||
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
|
|
||||||
ItemStack slot = matrix.getStackInSlot(i);
|
|
||||||
|
|
||||||
if (!slot.isEmpty()) {
|
|
||||||
matrix.setInventorySlotContents(i, StackUtils.nullToEmpty(grid.getNetwork().insertItem(slot, slot.getCount(), Action.PERFORM)));
|
|
||||||
|
|
||||||
grid.getNetwork().getItemStorageTracker().changed(player, slot.copy());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (grid.getGridType() == GridType.PATTERN) {
|
|
||||||
((NetworkNodeGrid) grid).clearMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,10 +3,7 @@ package com.raoulvdberge.refinedstorage.network;
|
|||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.network.disk.StorageDiskSizeRequestMessage;
|
import com.raoulvdberge.refinedstorage.network.disk.StorageDiskSizeRequestMessage;
|
||||||
import com.raoulvdberge.refinedstorage.network.disk.StorageDiskSizeResponseMessage;
|
import com.raoulvdberge.refinedstorage.network.disk.StorageDiskSizeResponseMessage;
|
||||||
import com.raoulvdberge.refinedstorage.network.grid.GridItemDeltaMessage;
|
import com.raoulvdberge.refinedstorage.network.grid.*;
|
||||||
import com.raoulvdberge.refinedstorage.network.grid.GridItemInsertHeldMessage;
|
|
||||||
import com.raoulvdberge.refinedstorage.network.grid.GridItemPullMessage;
|
|
||||||
import com.raoulvdberge.refinedstorage.network.grid.GridItemUpdateMessage;
|
|
||||||
import com.raoulvdberge.refinedstorage.network.tiledata.TileDataParameterMessage;
|
import com.raoulvdberge.refinedstorage.network.tiledata.TileDataParameterMessage;
|
||||||
import com.raoulvdberge.refinedstorage.network.tiledata.TileDataParameterUpdateMessage;
|
import com.raoulvdberge.refinedstorage.network.tiledata.TileDataParameterUpdateMessage;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
@@ -38,6 +35,7 @@ public class NetworkHandler {
|
|||||||
handler.registerMessage(id++, GridItemDeltaMessage.class, GridItemDeltaMessage::encode, GridItemDeltaMessage::decode, GridItemDeltaMessage::handle);
|
handler.registerMessage(id++, GridItemDeltaMessage.class, GridItemDeltaMessage::encode, GridItemDeltaMessage::decode, GridItemDeltaMessage::handle);
|
||||||
handler.registerMessage(id++, GridItemPullMessage.class, GridItemPullMessage::encode, GridItemPullMessage::decode, GridItemPullMessage::handle);
|
handler.registerMessage(id++, GridItemPullMessage.class, GridItemPullMessage::encode, GridItemPullMessage::decode, GridItemPullMessage::handle);
|
||||||
handler.registerMessage(id++, GridItemInsertHeldMessage.class, GridItemInsertHeldMessage::encode, GridItemInsertHeldMessage::decode, GridItemInsertHeldMessage::handle);
|
handler.registerMessage(id++, GridItemInsertHeldMessage.class, GridItemInsertHeldMessage::encode, GridItemInsertHeldMessage::decode, GridItemInsertHeldMessage::handle);
|
||||||
|
handler.registerMessage(id++, GridClearMessage.class, GridClearMessage::encode, GridClearMessage::decode, GridClearMessage::handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToServer(Object message) {
|
public void sendToServer(Object message) {
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage.network.grid;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.container.GridContainer;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class GridClearMessage {
|
||||||
|
public static GridClearMessage decode(PacketBuffer buf) {
|
||||||
|
return new GridClearMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void encode(GridClearMessage message, PacketBuffer buf) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handle(GridClearMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
|
PlayerEntity player = ctx.get().getSender();
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
ctx.get().enqueueWork(() -> {
|
||||||
|
Container container = player.openContainer;
|
||||||
|
|
||||||
|
if (container instanceof GridContainer) {
|
||||||
|
((GridContainer) container).getGrid().onClear(player);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.get().setPacketHandled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,8 +27,8 @@ public class GridItemInsertHeldMessage {
|
|||||||
public static void handle(GridItemInsertHeldMessage message, Supplier<NetworkEvent.Context> ctx) {
|
public static void handle(GridItemInsertHeldMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
ServerPlayerEntity player = ctx.get().getSender();
|
ServerPlayerEntity player = ctx.get().getSender();
|
||||||
|
|
||||||
ctx.get().enqueueWork(() -> {
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
ctx.get().enqueueWork(() -> {
|
||||||
Container container = player.openContainer;
|
Container container = player.openContainer;
|
||||||
|
|
||||||
if (container instanceof GridContainer) {
|
if (container instanceof GridContainer) {
|
||||||
@@ -38,8 +38,8 @@ public class GridItemInsertHeldMessage {
|
|||||||
grid.getItemHandler().onInsertHeldItem(player, message.single);
|
grid.getItemHandler().onInsertHeldItem(player, message.single);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ctx.get().setPacketHandled(true);
|
ctx.get().setPacketHandled(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ public class GridItemPullMessage {
|
|||||||
public static void handle(GridItemPullMessage message, Supplier<NetworkEvent.Context> ctx) {
|
public static void handle(GridItemPullMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
ServerPlayerEntity player = ctx.get().getSender();
|
ServerPlayerEntity player = ctx.get().getSender();
|
||||||
|
|
||||||
ctx.get().enqueueWork(() -> {
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
ctx.get().enqueueWork(() -> {
|
||||||
Container container = player.openContainer;
|
Container container = player.openContainer;
|
||||||
|
|
||||||
if (container instanceof GridContainer) {
|
if (container instanceof GridContainer) {
|
||||||
@@ -42,8 +42,9 @@ public class GridItemPullMessage {
|
|||||||
grid.getItemHandler().onExtract(player, message.id, message.flags);
|
grid.getItemHandler().onExtract(player, message.id, message.flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ctx.get().setPacketHandled(true);
|
ctx.get().setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,12 @@ import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
|||||||
import com.raoulvdberge.refinedstorage.screen.widget.CheckBoxWidget;
|
import com.raoulvdberge.refinedstorage.screen.widget.CheckBoxWidget;
|
||||||
import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.SideButton;
|
import com.raoulvdberge.refinedstorage.screen.widget.sidebutton.SideButton;
|
||||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
import net.minecraft.client.gui.widget.Widget;
|
import net.minecraft.client.gui.widget.Widget;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
|
import net.minecraft.client.util.InputMappings;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.container.Container;
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
@@ -324,6 +327,12 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
|||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isKeyDown(KeyBinding keybinding) {
|
||||||
|
return InputMappings.isKeyDown(Minecraft.getInstance().mainWindow.getHandle(), keybinding.getKey().getKeyCode()) &&
|
||||||
|
keybinding.getKeyConflictContext().isActive() &&
|
||||||
|
keybinding.getKeyModifier().isActive(keybinding.getKeyConflictContext());
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void onPostInit(int x, int y);
|
public abstract void onPostInit(int x, int y);
|
||||||
|
|
||||||
public abstract void tick(int x, int y);
|
public abstract void tick(int x, int y);
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ public class FilterScreen extends BaseScreen<FilterContainer> {
|
|||||||
public boolean keyPressed(int key, int scanCode, int modifiers) {
|
public boolean keyPressed(int key, int scanCode, int modifiers) {
|
||||||
if (key == GLFW.GLFW_KEY_ESCAPE) {
|
if (key == GLFW.GLFW_KEY_ESCAPE) {
|
||||||
minecraft.player.closeScreen();
|
minecraft.player.closeScreen();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nameField.keyPressed(key, scanCode, modifiers) || nameField.func_212955_f()) {
|
if (nameField.keyPressed(key, scanCode, modifiers) || nameField.func_212955_f()) {
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class GuiCrafterManager extends BaseScreen<CrafterManagerContainer> imple
|
|||||||
|
|
||||||
if (searchField == null) {
|
if (searchField == null) {
|
||||||
searchField = new SearchWidget(font, sx, sy, 88 - 6);
|
searchField = new SearchWidget(font, sx, sy, 88 - 6);
|
||||||
searchField.addListener(() -> container.initSlots(null));
|
searchField.func_212954_a(value -> container.initSlots(null));
|
||||||
searchField.setMode(crafterManager.getSearchBoxMode());
|
searchField.setMode(crafterManager.getSearchBoxMode());
|
||||||
} else {
|
} else {
|
||||||
searchField.x = sx;
|
searchField.x = sx;
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ package com.raoulvdberge.refinedstorage.screen.grid;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
|
import com.raoulvdberge.refinedstorage.RSKeyBindings;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridNetworkAware;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.render.ElementDrawers;
|
import com.raoulvdberge.refinedstorage.apiimpl.render.ElementDrawers;
|
||||||
import com.raoulvdberge.refinedstorage.container.GridContainer;
|
import com.raoulvdberge.refinedstorage.container.GridContainer;
|
||||||
|
import com.raoulvdberge.refinedstorage.network.grid.GridClearMessage;
|
||||||
import com.raoulvdberge.refinedstorage.network.grid.GridItemInsertHeldMessage;
|
import com.raoulvdberge.refinedstorage.network.grid.GridItemInsertHeldMessage;
|
||||||
import com.raoulvdberge.refinedstorage.network.grid.GridItemPullMessage;
|
import com.raoulvdberge.refinedstorage.network.grid.GridItemPullMessage;
|
||||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||||
@@ -40,6 +41,7 @@ import net.minecraft.util.SoundEvents;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -104,7 +106,7 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
|
|
||||||
if (searchField == null) {
|
if (searchField == null) {
|
||||||
searchField = new SearchWidget(font, sx, sy, 88 - 6);
|
searchField = new SearchWidget(font, sx, sy, 88 - 6);
|
||||||
searchField.addListener(() -> {
|
searchField.func_212954_a(value -> {
|
||||||
this.getView().sort(); // Use getter since this view can be replaced.
|
this.getView().sort(); // Use getter since this view can be replaced.
|
||||||
});
|
});
|
||||||
searchField.setMode(grid.getSearchBoxMode());
|
searchField.setMode(grid.getSearchBoxMode());
|
||||||
@@ -171,6 +173,10 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
view.sort();
|
view.sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isKeyDown(RSKeyBindings.CLEAR_GRID_CRAFTING_MATRIX)) {
|
||||||
|
RS.NETWORK_HANDLER.sendToServer(new GridClearMessage());
|
||||||
|
}
|
||||||
|
|
||||||
tabs.update();
|
tabs.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,12 +435,16 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
if (clickedCreatePattern) {
|
if (clickedCreatePattern) {
|
||||||
BlockPos gridPos = ((GridNetworkNode) grid).getPos();
|
BlockPos gridPos = ((GridNetworkNode) grid).getPos();
|
||||||
|
|
||||||
|
minecraft.getSoundHandler().play(SimpleSound.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
|
|
||||||
// @TODO RS.INSTANCE.network.sendToServer(new MessageGridPatternCreate(gridPos.getX(), gridPos.getY(), gridPos.getZ()));
|
// @TODO RS.INSTANCE.network.sendToServer(new MessageGridPatternCreate(gridPos.getX(), gridPos.getY(), gridPos.getZ()));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (grid.isActive()) {
|
} else if (grid.isActive()) {
|
||||||
if (clickedClear && grid instanceof IGridNetworkAware) {
|
if (clickedClear) {
|
||||||
// @TODO RS.INSTANCE.network.sendToServer(new MessageGridClear());
|
RS.NETWORK_HANDLER.sendToServer(new GridClearMessage());
|
||||||
|
|
||||||
|
minecraft.getSoundHandler().play(SimpleSound.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -442,10 +452,10 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
ItemStack held = container.getPlayer().inventory.getItemStack();
|
ItemStack held = container.getPlayer().inventory.getItemStack();
|
||||||
|
|
||||||
if (isOverSlotArea(mouseX - guiLeft, mouseY - guiTop) && !held.isEmpty() && (clickedButton == 0 || clickedButton == 1)) {
|
if (isOverSlotArea(mouseX - guiLeft, mouseY - guiTop) && !held.isEmpty() && (clickedButton == 0 || clickedButton == 1)) {
|
||||||
if (grid.getGridType() == GridType.NORMAL) {
|
if (grid.getGridType() == GridType.FLUID) {
|
||||||
RS.NETWORK_HANDLER.sendToServer(new GridItemInsertHeldMessage(clickedButton == 1));
|
|
||||||
} else if (grid.getGridType() == GridType.FLUID) {
|
|
||||||
// @TODO RS.INSTANCE.network.sendToServer(new MessageGridFluidInsertHeld());
|
// @TODO RS.INSTANCE.network.sendToServer(new MessageGridFluidInsertHeld());
|
||||||
|
} else {
|
||||||
|
RS.NETWORK_HANDLER.sendToServer(new GridItemInsertHeldMessage(clickedButton == 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -485,12 +495,6 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clickedClear || clickedCreatePattern) {
|
|
||||||
minecraft.getSoundHandler().play(SimpleSound.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.mouseClicked(mouseX, mouseY, clickedButton);
|
return super.mouseClicked(mouseX, mouseY, clickedButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,8 +515,23 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
return this.scrollbar.mouseScrolled(x, y, delta) || super.mouseScrolled(x, y, delta);
|
return this.scrollbar.mouseScrolled(x, y, delta) || super.mouseScrolled(x, y, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean charTyped(char p_charTyped_1_, int p_charTyped_2_) {
|
||||||
|
if (searchField.charTyped(p_charTyped_1_, p_charTyped_2_)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.charTyped(p_charTyped_1_, p_charTyped_2_);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int key, int scanCode, int modifiers) {
|
public boolean keyPressed(int key, int scanCode, int modifiers) {
|
||||||
|
if (key == GLFW.GLFW_KEY_ESCAPE) {
|
||||||
|
minecraft.player.closeScreen();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (searchField.keyPressed(key, scanCode, modifiers) || searchField.func_212955_f()) {
|
if (searchField.keyPressed(key, scanCode, modifiers) || searchField.func_212955_f()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -520,16 +539,6 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
return super.keyPressed(key, scanCode, modifiers);
|
return super.keyPressed(key, scanCode, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO
|
|
||||||
@Override
|
|
||||||
protected void keyTyped(char character, int keyCode) throws IOException {
|
|
||||||
if (keyCode == RSKeyBindings.CLEAR_GRID_CRAFTING_MATRIX.getKeyCode()) {
|
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridClear());
|
|
||||||
} else {
|
|
||||||
super.keyTyped(character, keyCode);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public SearchWidget getSearchField() {
|
public SearchWidget getSearchField() {
|
||||||
return searchField;
|
return searchField;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,12 @@ package com.raoulvdberge.refinedstorage.screen.widget;
|
|||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RSKeyBindings;
|
import com.raoulvdberge.refinedstorage.RSKeyBindings;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
|
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SearchWidget extends TextFieldWidget {
|
public class SearchWidget extends TextFieldWidget {
|
||||||
@@ -17,8 +16,6 @@ public class SearchWidget extends TextFieldWidget {
|
|||||||
private int mode;
|
private int mode;
|
||||||
private int historyIndex = -1;
|
private int historyIndex = -1;
|
||||||
|
|
||||||
private List<Runnable> listeners = new LinkedList<>();
|
|
||||||
|
|
||||||
public SearchWidget(FontRenderer fontRenderer, int x, int y, int width) {
|
public SearchWidget(FontRenderer fontRenderer, int x, int y, int width) {
|
||||||
super(fontRenderer, x, y, width, fontRenderer.FONT_HEIGHT, "");
|
super(fontRenderer, x, y, width, fontRenderer.FONT_HEIGHT, "");
|
||||||
|
|
||||||
@@ -33,23 +30,17 @@ public class SearchWidget extends TextFieldWidget {
|
|||||||
});*/
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(Runnable listener) {
|
|
||||||
listeners.add(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
||||||
boolean wasFocused = isFocused();
|
boolean wasFocused = isFocused();
|
||||||
|
|
||||||
boolean result = super.mouseClicked(mouseX, mouseY, mouseButton);
|
boolean result = super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
boolean flag = mouseX >= this.x && mouseX < this.x + this.width && mouseY >= this.y && mouseY < this.y + this.height;
|
boolean clickedWidget = mouseX >= this.x && mouseX < this.x + this.width && mouseY >= this.y && mouseY < this.y + this.height;
|
||||||
|
|
||||||
if (flag && mouseButton == 1) {
|
if (clickedWidget && mouseButton == 1) {
|
||||||
setText("");
|
setText("");
|
||||||
setFocused(true);
|
setFocused(true);
|
||||||
|
|
||||||
listeners.forEach(Runnable::run);
|
|
||||||
} else if (wasFocused != isFocused()) {
|
} else if (wasFocused != isFocused()) {
|
||||||
saveHistory();
|
saveHistory();
|
||||||
}
|
}
|
||||||
@@ -59,17 +50,15 @@ public class SearchWidget extends TextFieldWidget {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int keyCode, int scanCode, int modifier) {
|
public boolean keyPressed(int keyCode, int scanCode, int modifier) {
|
||||||
@SuppressWarnings("deprecation") boolean canLoseFocus = ObfuscationReflectionHelper.getPrivateValue(TextFieldWidget.class, this, 6);
|
|
||||||
|
|
||||||
boolean result = super.keyPressed(keyCode, scanCode, modifier);
|
boolean result = super.keyPressed(keyCode, scanCode, modifier);
|
||||||
|
|
||||||
if (isFocused()) {
|
if (isFocused()) {
|
||||||
if (keyCode == GLFW.GLFW_KEY_UP) {
|
if (keyCode == GLFW.GLFW_KEY_UP) {
|
||||||
updateSearchHistory(-1);
|
updateHistory(-1);
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
} else if (keyCode == GLFW.GLFW_KEY_DOWN) {
|
} else if (keyCode == GLFW.GLFW_KEY_DOWN) {
|
||||||
updateSearchHistory(1);
|
updateHistory(1);
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
} else if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) {
|
} else if (keyCode == GLFW.GLFW_KEY_ENTER || keyCode == GLFW.GLFW_KEY_KP_ENTER) {
|
||||||
@@ -83,7 +72,7 @@ public class SearchWidget extends TextFieldWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyCode == RSKeyBindings.FOCUS_SEARCH_BAR.getKey().getKeyCode() && canLoseFocus) {
|
if (BaseScreen.isKeyDown(RSKeyBindings.FOCUS_SEARCH_BAR) && canLoseFocus) {
|
||||||
setFocused(!isFocused());
|
setFocused(!isFocused());
|
||||||
|
|
||||||
saveHistory();
|
saveHistory();
|
||||||
@@ -91,14 +80,10 @@ public class SearchWidget extends TextFieldWidget {
|
|||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
|
||||||
listeners.forEach(Runnable::run);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSearchHistory(int delta) {
|
private void updateHistory(int delta) {
|
||||||
if (HISTORY.isEmpty()) {
|
if (HISTORY.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -117,15 +102,11 @@ public class SearchWidget extends TextFieldWidget {
|
|||||||
if (delta == 1) {
|
if (delta == 1) {
|
||||||
setText("");
|
setText("");
|
||||||
|
|
||||||
listeners.forEach(Runnable::run);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setText(HISTORY.get(historyIndex));
|
setText(HISTORY.get(historyIndex));
|
||||||
|
|
||||||
listeners.forEach(Runnable::run);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveHistory() {
|
private void saveHistory() {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class GridTile extends NetworkNodeTile<GridNetworkNode> {
|
|||||||
private final GridType gridType;
|
private final GridType gridType;
|
||||||
|
|
||||||
public GridTile(GridType gridType) {
|
public GridTile(GridType gridType) {
|
||||||
super(RSTiles.GRID);
|
super(gridType == GridType.NORMAL ? RSTiles.GRID : RSTiles.CRAFTING_GRID);
|
||||||
|
|
||||||
this.gridType = gridType;
|
this.gridType = gridType;
|
||||||
|
|
||||||
|
|||||||
@@ -130,12 +130,12 @@ public class WirelessFluidGrid implements IGridNetworkAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCraftingListener(IGridCraftingListener listener) {
|
public void addCraftingListener(ICraftingGridListener listener) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeCraftingListener(IGridCraftingListener listener) {
|
public void removeCraftingListener(ICraftingGridListener listener) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,6 +278,11 @@ public class WirelessFluidGrid implements IGridNetworkAware {
|
|||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClear(PlayerEntity player) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCraftedShift(PlayerEntity player) {
|
public void onCraftedShift(PlayerEntity player) {
|
||||||
// NO OP
|
// NO OP
|
||||||
|
|||||||
@@ -131,12 +131,12 @@ public class WirelessGrid implements IGridNetworkAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCraftingListener(IGridCraftingListener listener) {
|
public void addCraftingListener(ICraftingGridListener listener) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeCraftingListener(IGridCraftingListener listener) {
|
public void removeCraftingListener(ICraftingGridListener listener) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,6 +283,11 @@ public class WirelessGrid implements IGridNetworkAware {
|
|||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClear(PlayerEntity player) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCraftedShift(PlayerEntity player) {
|
public void onCraftedShift(PlayerEntity player) {
|
||||||
// NO OP
|
// NO OP
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package com.raoulvdberge.refinedstorage.tile.grid.portable;
|
|||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.grid.ICraftingGridListener;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridCraftingListener;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridTab;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGridTab;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
||||||
@@ -16,8 +16,8 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerCon
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.FluidGridHandlerPortable;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.PortableFluidGridHandler;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.ItemGridHandlerPortable;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.PortableItemGridHandler;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.PortableFluidStorageCache;
|
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.PortableFluidStorageCache;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.PortableItemStorageCache;
|
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.PortableItemStorageCache;
|
||||||
@@ -61,8 +61,8 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
@Nullable
|
@Nullable
|
||||||
private IStorageCache cache;
|
private IStorageCache cache;
|
||||||
|
|
||||||
private ItemGridHandlerPortable itemHandler = new ItemGridHandlerPortable(this, this);
|
private PortableItemGridHandler itemHandler = new PortableItemGridHandler(this, this);
|
||||||
private FluidGridHandlerPortable fluidHandler = new FluidGridHandlerPortable(this);
|
private PortableFluidGridHandler fluidHandler = new PortableFluidGridHandler(this);
|
||||||
|
|
||||||
private PlayerEntity player;
|
private PlayerEntity player;
|
||||||
private ItemStack stack;
|
private ItemStack stack;
|
||||||
@@ -240,12 +240,12 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCraftingListener(IGridCraftingListener listener) {
|
public void addCraftingListener(ICraftingGridListener listener) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeCraftingListener(IGridCraftingListener listener) {
|
public void removeCraftingListener(ICraftingGridListener listener) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,6 +398,11 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClear(PlayerEntity player) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCraftedShift(PlayerEntity player) {
|
public void onCraftedShift(PlayerEntity player) {
|
||||||
// NO OP
|
// NO OP
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import com.raoulvdberge.refinedstorage.RS;
|
|||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
|
import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||||
import com.raoulvdberge.refinedstorage.RSTiles;
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.network.grid.ICraftingGridListener;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridCraftingListener;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridTab;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGridTab;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler;
|
||||||
@@ -19,8 +19,8 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
|
|||||||
import com.raoulvdberge.refinedstorage.api.storage.tracker.IStorageTracker;
|
import com.raoulvdberge.refinedstorage.api.storage.tracker.IStorageTracker;
|
||||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.FluidGridHandlerPortable;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.PortableFluidGridHandler;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.ItemGridHandlerPortable;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.handler.PortableItemGridHandler;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.DiskDriveNetworkNode;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.PortableFluidStorageCache;
|
import com.raoulvdberge.refinedstorage.apiimpl.storage.cache.PortableFluidStorageCache;
|
||||||
@@ -155,8 +155,8 @@ public class TilePortableGrid extends BaseTile implements IGrid, IPortableGrid,
|
|||||||
@Nullable
|
@Nullable
|
||||||
private IStorageCache cache;
|
private IStorageCache cache;
|
||||||
|
|
||||||
private ItemGridHandlerPortable itemHandler = new ItemGridHandlerPortable(this, this);
|
private PortableItemGridHandler itemHandler = new PortableItemGridHandler(this, this);
|
||||||
private FluidGridHandlerPortable fluidHandler = new FluidGridHandlerPortable(this);
|
private PortableFluidGridHandler fluidHandler = new PortableFluidGridHandler(this);
|
||||||
private PortableGridDiskState diskState = PortableGridDiskState.NONE;
|
private PortableGridDiskState diskState = PortableGridDiskState.NONE;
|
||||||
private boolean connected;
|
private boolean connected;
|
||||||
|
|
||||||
@@ -344,12 +344,12 @@ public class TilePortableGrid extends BaseTile implements IGrid, IPortableGrid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCraftingListener(IGridCraftingListener listener) {
|
public void addCraftingListener(ICraftingGridListener listener) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeCraftingListener(IGridCraftingListener listener) {
|
public void removeCraftingListener(ICraftingGridListener listener) {
|
||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,6 +504,11 @@ public class TilePortableGrid extends BaseTile implements IGrid, IPortableGrid,
|
|||||||
// NO OP
|
// NO OP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClear(PlayerEntity player) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCraftedShift(PlayerEntity player) {
|
public void onCraftedShift(PlayerEntity player) {
|
||||||
// NO OP
|
// NO OP
|
||||||
|
|||||||
3
src/main/resources/META-INF/accesstransformer.cfg
Normal file
3
src/main/resources/META-INF/accesstransformer.cfg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
protected net.minecraft.inventory.container.Container field_75153_a # inventoryItemStacks
|
||||||
|
protected net.minecraft.inventory.container.Container field_75149_d # listeners
|
||||||
|
protected net.minecraft.client.gui.widget.TextFieldWidget field_146212_n # canLoseFocus
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"connected=true,direction=north": {
|
||||||
|
"model": "refinedstorage:block/grid/crafting/connected",
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"connected=true,direction=east": {
|
||||||
|
"model": "refinedstorage:block/grid/crafting/connected",
|
||||||
|
"y": 90
|
||||||
|
},
|
||||||
|
"connected=true,direction=south": {
|
||||||
|
"model": "refinedstorage:block/grid/crafting/connected",
|
||||||
|
"y": 180
|
||||||
|
},
|
||||||
|
"connected=true,direction=west": {
|
||||||
|
"model": "refinedstorage:block/grid/crafting/connected",
|
||||||
|
"y": 270
|
||||||
|
},
|
||||||
|
"connected=false,direction=north": {
|
||||||
|
"model": "refinedstorage:block/grid/crafting/disconnected",
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"connected=false,direction=east": {
|
||||||
|
"model": "refinedstorage:block/grid/crafting/disconnected",
|
||||||
|
"y": 90
|
||||||
|
},
|
||||||
|
"connected=false,direction=south": {
|
||||||
|
"model": "refinedstorage:block/grid/crafting/disconnected",
|
||||||
|
"y": 180
|
||||||
|
},
|
||||||
|
"connected=false,direction=west": {
|
||||||
|
"model": "refinedstorage:block/grid/crafting/disconnected",
|
||||||
|
"y": 270
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"parent": "refinedstorage:block/cube_north_cutout",
|
||||||
|
"textures": {
|
||||||
|
"particle": "refinedstorage:block/side",
|
||||||
|
"east": "refinedstorage:block/grid/left",
|
||||||
|
"south": "refinedstorage:block/grid/back",
|
||||||
|
"west": "refinedstorage:block/grid/right",
|
||||||
|
"up": "refinedstorage:block/grid/top",
|
||||||
|
"down": "refinedstorage:block/bottom",
|
||||||
|
"north": "refinedstorage:block/grid/front",
|
||||||
|
"cutout": "refinedstorage:block/grid/cutouts/crafting_front_connected"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"parent": "refinedstorage:block/cube_north_cutout",
|
||||||
|
"textures": {
|
||||||
|
"particle": "refinedstorage:block/side",
|
||||||
|
"east": "refinedstorage:block/grid/left",
|
||||||
|
"south": "refinedstorage:block/grid/back",
|
||||||
|
"west": "refinedstorage:block/grid/right",
|
||||||
|
"up": "refinedstorage:block/grid/top",
|
||||||
|
"down": "refinedstorage:block/bottom",
|
||||||
|
"north": "refinedstorage:block/grid/front",
|
||||||
|
"cutout": "refinedstorage:block/grid/cutouts/crafting_front_disconnected"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"parent": "refinedstorage:block/grid/crafting/disconnected"
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "forge:ore_shapeless",
|
|
||||||
"ingredients": [
|
|
||||||
{
|
|
||||||
"item": "refinedstorage:grid",
|
|
||||||
"data": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"item": "#advanced_processor"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "forge:ore_dict",
|
|
||||||
"ore": "workbench"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"result": {
|
|
||||||
"item": "refinedstorage:grid",
|
|
||||||
"data": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"rolls": 1,
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "refinedstorage:crafting_grid"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"condition": "minecraft:survives_explosion"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"rolls": 1,
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "refinedstorage:grid"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"condition": "minecraft:survives_explosion"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shapeless",
|
||||||
|
"ingredients": [
|
||||||
|
{
|
||||||
|
"item": "refinedstorage:grid"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"item": "refinedstorage:advanced_processor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "refinedstorage:crafting_tables"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"item": "refinedstorage:crafting_grid"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user