Implement the Pattern Grid
This commit is contained in:
@@ -44,6 +44,11 @@ public class ClientSetup {
|
||||
new ResourceLocation(RS.ID, "block/grid/cutouts/crafting_front_connected")
|
||||
));
|
||||
|
||||
bakedModelOverrideRegistry.add(new ResourceLocation(RS.ID, "pattern_grid"), (base, registry) -> new FullbrightBakedModel(
|
||||
base,
|
||||
new ResourceLocation(RS.ID, "block/grid/cutouts/pattern_front_connected")
|
||||
));
|
||||
|
||||
bakedModelOverrideRegistry.add(new ResourceLocation(RS.ID, "disk_drive"), (base, registry) -> new FullbrightBakedModel(
|
||||
new DiskDriveBakedModel(
|
||||
base,
|
||||
|
||||
@@ -95,6 +95,7 @@ public final class RS {
|
||||
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.CRAFTING_ID, (tag, world, pos) -> readAndReturn(tag, new GridNetworkNode(world, pos, GridType.CRAFTING)));
|
||||
API.instance().getNetworkNodeRegistry().add(GridNetworkNode.PATTERN_ID, (tag, world, pos) -> readAndReturn(tag, new GridNetworkNode(world, pos, GridType.PATTERN)));
|
||||
|
||||
API.instance().getGridManager().add(GridBlockGridFactory.ID, new GridBlockGridFactory());
|
||||
}
|
||||
@@ -120,6 +121,7 @@ public final class RS {
|
||||
e.getRegistry().register(new DiskDriveBlock());
|
||||
e.getRegistry().register(new GridBlock(GridType.NORMAL));
|
||||
e.getRegistry().register(new GridBlock(GridType.CRAFTING));
|
||||
e.getRegistry().register(new GridBlock(GridType.PATTERN));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -130,6 +132,7 @@ public final class RS {
|
||||
e.getRegistry().register(registerTileDataParameters(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.PATTERN), RSBlocks.PATTERN_GRID).build(null).setRegistryName(RS.ID, "pattern_grid")));
|
||||
}
|
||||
|
||||
private <T extends TileEntity> TileEntityType<T> registerTileDataParameters(TileEntityType<T> t) {
|
||||
@@ -199,6 +202,7 @@ public final class RS {
|
||||
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.DISK_DRIVE));
|
||||
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.GRID));
|
||||
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.CRAFTING_GRID));
|
||||
e.getRegistry().register(BlockUtils.createBlockItemFor(RSBlocks.PATTERN_GRID));
|
||||
}
|
||||
|
||||
/* TODO
|
||||
|
||||
@@ -46,6 +46,8 @@ public final class RSBlocks {
|
||||
public static final GridBlock GRID = null;
|
||||
@ObjectHolder(RS.ID + ":crafting_grid")
|
||||
public static final GridBlock CRAFTING_GRID = null;
|
||||
@ObjectHolder(RS.ID + ":pattern_grid")
|
||||
public static final GridBlock PATTERN_GRID = null;
|
||||
|
||||
public static final BlockStorageMonitor STORAGE_MONITOR = new BlockStorageMonitor();
|
||||
public static final BlockPortableGrid PORTABLE_GRID = new BlockPortableGrid();
|
||||
|
||||
@@ -19,7 +19,6 @@ public class RSOldConfig {
|
||||
public int storageUsage;
|
||||
public int fluidStorageUsage;
|
||||
public int wirelessTransmitterUsage;
|
||||
public int patternGridUsage;
|
||||
public int fluidGridUsage;
|
||||
public int networkTransmitterUsage;
|
||||
public int networkReceiverUsage;
|
||||
@@ -110,7 +109,6 @@ public class RSOldConfig {
|
||||
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");
|
||||
wirelessTransmitterUsage = config.getInt("wirelessTransmitter", ENERGY, 8, 0, Integer.MAX_VALUE, "The energy used by Wireless Transmitters");
|
||||
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");
|
||||
networkTransmitterUsage = config.getInt("networkTransmitter", ENERGY, 64, 0, Integer.MAX_VALUE, "The energy used by Network Transmitters");
|
||||
networkReceiverUsage = config.getInt("networkReceiver", ENERGY, 0, 0, Integer.MAX_VALUE, "The energy used by Network Receivers");
|
||||
|
||||
@@ -46,6 +46,8 @@ public class RSTiles {
|
||||
public static final TileEntityType<GridTile> GRID = null;
|
||||
@ObjectHolder(RS.ID + ":crafting_grid")
|
||||
public static final TileEntityType<GridTile> CRAFTING_GRID = null;
|
||||
@ObjectHolder(RS.ID + ":pattern_grid")
|
||||
public static final TileEntityType<GridTile> PATTERN_GRID = null;
|
||||
|
||||
//@ObjectHolder(RS.ID + ":importer")
|
||||
public static final TileEntityType<TileImporter> IMPORTER = null;
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.raoulvdberge.refinedstorage.item.PatternItem;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.GridTile;
|
||||
import com.raoulvdberge.refinedstorage.util.GridUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
@@ -60,6 +61,7 @@ import java.util.Set;
|
||||
public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, IType {
|
||||
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 ResourceLocation PATTERN_ID = new ResourceLocation(RS.ID, "pattern_grid");
|
||||
|
||||
public static final String NBT_VIEW_TYPE = "ViewType";
|
||||
public static final String NBT_SORTING_DIRECTION = "SortingDirection";
|
||||
@@ -174,7 +176,7 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
||||
case CRAFTING:
|
||||
return RS.SERVER_CONFIG.getGrid().getCraftingGridUsage();
|
||||
case PATTERN:
|
||||
return 0;
|
||||
return RS.SERVER_CONFIG.getGrid().getPatternGridUsage();
|
||||
case FLUID:
|
||||
return 0;
|
||||
default:
|
||||
@@ -540,7 +542,7 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
||||
inputsFilled++;
|
||||
}
|
||||
|
||||
if (processingMatrixFluids.getFluid(i) != null) {
|
||||
if (!processingMatrixFluids.getFluid(i).isEmpty()) {
|
||||
inputsFilled++;
|
||||
}
|
||||
}
|
||||
@@ -550,7 +552,7 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
||||
outputsFilled++;
|
||||
}
|
||||
|
||||
if (processingMatrixFluids.getFluid(i) != null) {
|
||||
if (!processingMatrixFluids.getFluid(i).isEmpty()) {
|
||||
outputsFilled++;
|
||||
}
|
||||
}
|
||||
@@ -689,7 +691,7 @@ public class GridNetworkNode extends NetworkNode implements IGridNetworkAware, I
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return type == GridType.NORMAL ? ID : CRAFTING_ID;
|
||||
return GridUtils.getNetworkNodeId(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -72,13 +72,11 @@ public class GridBlock extends NodeBlock {
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(IModelRegistration modelRegistration) {
|
||||
modelRegistration.setModel(this, GridType.CRAFTING.getId(), new ModelResourceLocation(info.getId(), "connected=false,direction=north,type=crafting"));
|
||||
modelRegistration.setModel(this, GridType.PATTERN.getId(), new ModelResourceLocation(info.getId(), "connected=false,direction=north,type=pattern"));
|
||||
modelRegistration.setModel(this, GridType.FLUID.getId(), new ModelResourceLocation(info.getId(), "connected=false,direction=north,type=fluid"));
|
||||
|
||||
modelRegistration.addBakedModelOverride(info.getId(), base -> new BakedModelFullbright(
|
||||
base,
|
||||
RS.ID + ":blocks/grid/cutouts/crafting_front_connected",
|
||||
RS.ID + ":blocks/grid/cutouts/pattern_front_connected",
|
||||
RS.ID + ":blocks/grid/cutouts/fluid_front_connected"
|
||||
));
|
||||
|
||||
@@ -121,12 +121,14 @@ public class ServerConfig {
|
||||
public class Grid {
|
||||
private final ForgeConfigSpec.IntValue gridUsage;
|
||||
private final ForgeConfigSpec.IntValue craftingGridUsage;
|
||||
private final ForgeConfigSpec.IntValue patternGridUsage;
|
||||
|
||||
public Grid() {
|
||||
builder.push("grid");
|
||||
|
||||
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);
|
||||
patternGridUsage = builder.comment("The energy used by Pattern Grids").defineInRange("patternGridUsage", 3, 0, Integer.MAX_VALUE);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
@@ -138,6 +140,10 @@ public class ServerConfig {
|
||||
public int getCraftingGridUsage() {
|
||||
return craftingGridUsage.get();
|
||||
}
|
||||
|
||||
public int getPatternGridUsage() {
|
||||
return patternGridUsage.get();
|
||||
}
|
||||
}
|
||||
|
||||
public class Upgrades {
|
||||
|
||||
@@ -5,8 +5,8 @@ import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.FilterSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.DisabledLegacySlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.FilterLegacySlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.LegacyDisabledSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.LegacyFilterSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.transfer.TransferManager;
|
||||
import com.raoulvdberge.refinedstorage.network.FluidFilterSlotUpdateMessage;
|
||||
import com.raoulvdberge.refinedstorage.tile.BaseTile;
|
||||
@@ -65,7 +65,7 @@ public abstract class BaseContainer extends Container {
|
||||
int y = yInventory + 4 + (3 * 18);
|
||||
|
||||
if (isHeldItemDisabled() && i == player.inventory.currentItem) {
|
||||
addSlot(new DisabledLegacySlot(player.inventory, id, x, y));
|
||||
addSlot(new LegacyDisabledSlot(player.inventory, id, x, y));
|
||||
} else {
|
||||
addSlot(new Slot(player.inventory, id, x, y));
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public abstract class BaseContainer extends Container {
|
||||
}
|
||||
|
||||
return player.inventory.getItemStack();
|
||||
} else if (slot instanceof FilterLegacySlot) {
|
||||
} else if (slot instanceof LegacyFilterSlot) {
|
||||
if (player.inventory.getItemStack().isEmpty()) {
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
} else if (slot.isItemValid(player.inventory.getItemStack())) {
|
||||
@@ -131,7 +131,7 @@ public abstract class BaseContainer extends Container {
|
||||
}
|
||||
|
||||
return player.inventory.getItemStack();
|
||||
} else if (slot instanceof DisabledLegacySlot) {
|
||||
} else if (slot instanceof LegacyDisabledSlot) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public abstract class BaseContainer extends Container {
|
||||
|
||||
@Override
|
||||
public boolean canMergeSlot(ItemStack stack, Slot slot) {
|
||||
if (slot instanceof FilterSlot || slot instanceof FluidFilterSlot || slot instanceof FilterLegacySlot) {
|
||||
if (slot instanceof FilterSlot || slot instanceof FluidFilterSlot || slot instanceof LegacyFilterSlot) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ import com.raoulvdberge.refinedstorage.container.slot.filter.FilterSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.grid.CraftingGridSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.grid.ResultCraftingGridSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.BaseLegacySlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.DisabledLegacySlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.FilterLegacySlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.LegacyBaseSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.LegacyDisabledSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.LegacyFilterSlot;
|
||||
import com.raoulvdberge.refinedstorage.screen.IScreenInfoProvider;
|
||||
import com.raoulvdberge.refinedstorage.tile.BaseTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
@@ -39,7 +39,7 @@ public class GridContainer extends BaseContainer implements ICraftingGridListene
|
||||
private IScreenInfoProvider screenInfoProvider;
|
||||
|
||||
private ResultCraftingGridSlot craftingResultSlot;
|
||||
private BaseLegacySlot patternResultSlot;
|
||||
private LegacyBaseSlot patternResultSlot;
|
||||
|
||||
public GridContainer(IGrid grid, @Nullable BaseTile gridTile, PlayerEntity player, int windowId) {
|
||||
super(RSContainers.GRID, gridTile, player, windowId);
|
||||
@@ -191,7 +191,7 @@ public class GridContainer extends BaseContainer implements ICraftingGridListene
|
||||
y = headerAndSlots + 4;
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlot(new FilterLegacySlot(grid.getCraftingMatrix(), i, x, y).setEnableHandler(() -> !((GridNetworkNode) grid).isProcessingPattern()));
|
||||
addSlot(new LegacyFilterSlot(grid.getCraftingMatrix(), i, x, y).setEnableHandler(() -> !((GridNetworkNode) grid).isProcessingPattern()));
|
||||
|
||||
x += 18;
|
||||
|
||||
@@ -201,7 +201,7 @@ public class GridContainer extends BaseContainer implements ICraftingGridListene
|
||||
}
|
||||
}
|
||||
|
||||
addSlot(patternResultSlot = (new DisabledLegacySlot(grid.getCraftingResult(), 0, 134, headerAndSlots + 22).setEnableHandler(() -> !((GridNetworkNode) grid).isProcessingPattern())));
|
||||
addSlot(patternResultSlot = (new LegacyDisabledSlot(grid.getCraftingResult(), 0, 134, headerAndSlots + 22).setEnableHandler(() -> !((GridNetworkNode) grid).isProcessingPattern())));
|
||||
}
|
||||
|
||||
public IGrid getGrid() {
|
||||
|
||||
@@ -5,14 +5,14 @@ import net.minecraft.inventory.container.Slot;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BaseLegacySlot extends Slot {
|
||||
public class LegacyBaseSlot extends Slot {
|
||||
private Supplier<Boolean> enableHandler = () -> true;
|
||||
|
||||
public BaseLegacySlot(IInventory inventory, int inventoryIndex, int x, int y) {
|
||||
public LegacyBaseSlot(IInventory inventory, int inventoryIndex, int x, int y) {
|
||||
super(inventory, inventoryIndex, x, y);
|
||||
}
|
||||
|
||||
public BaseLegacySlot setEnableHandler(Supplier<Boolean> enableHandler) {
|
||||
public LegacyBaseSlot setEnableHandler(Supplier<Boolean> enableHandler) {
|
||||
this.enableHandler = enableHandler;
|
||||
|
||||
return this;
|
||||
@@ -5,8 +5,8 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class DisabledLegacySlot extends BaseLegacySlot {
|
||||
public DisabledLegacySlot(IInventory inventory, int inventoryIndex, int x, int y) {
|
||||
public class LegacyDisabledSlot extends LegacyBaseSlot {
|
||||
public LegacyDisabledSlot(IInventory inventory, int inventoryIndex, int x, int y) {
|
||||
super(inventory, inventoryIndex, x, y);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class FilterLegacySlot extends BaseLegacySlot {
|
||||
public FilterLegacySlot(IInventory inventory, int inventoryIndex, int x, int y) {
|
||||
public class LegacyFilterSlot extends LegacyBaseSlot {
|
||||
public LegacyFilterSlot(IInventory inventory, int inventoryIndex, int x, int y) {
|
||||
super(inventory, inventoryIndex, x, y);
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
public class MessageGridPatternCreate extends MessageHandlerPlayerToServer<MessageGridPatternCreate> implements IMessage {
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public MessageGridPatternCreate() {
|
||||
}
|
||||
|
||||
public MessageGridPatternCreate(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(MessageGridPatternCreate message, ServerPlayerEntity player) {
|
||||
TileEntity tile = player.getEntityWorld().getTileEntity(new BlockPos(message.x, message.y, message.z));
|
||||
|
||||
if (tile instanceof TileGrid && ((TileGrid) tile).getNode().getGridType() == GridType.PATTERN) {
|
||||
((TileGrid) tile).getNode().onCreatePattern();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot;
|
||||
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
|
||||
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.Slot;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
public class MessageSlotFilterFluidSetAmount extends MessageHandlerPlayerToServer<MessageSlotFilterFluidSetAmount> implements IMessage {
|
||||
private int containerSlot;
|
||||
private int amount;
|
||||
|
||||
public MessageSlotFilterFluidSetAmount(int containerSlot, int amount) {
|
||||
this.containerSlot = containerSlot;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public MessageSlotFilterFluidSetAmount() {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handle(MessageSlotFilterFluidSetAmount message, ServerPlayerEntity player) {
|
||||
Container container = player.openContainer;
|
||||
|
||||
if (container != null) {
|
||||
if (message.containerSlot >= 0 && message.containerSlot < container.inventorySlots.size()) {
|
||||
Slot slot = container.getSlot(message.containerSlot);
|
||||
|
||||
if (slot instanceof SlotFilterFluid) {
|
||||
FluidInventory inventory = ((SlotFilterFluid) slot).getFluidInventory();
|
||||
|
||||
FluidStack stack = inventory.getFluid(slot.getSlotIndex());
|
||||
|
||||
if (stack != null && message.amount > 0 && message.amount <= inventory.getMaxAmount()) {
|
||||
inventory.setFluid(slot.getSlotIndex(), StackUtils.copy(stack, message.amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
containerSlot = buf.readInt();
|
||||
amount = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(containerSlot);
|
||||
buf.writeInt(amount);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.FilterSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.FilterLegacySlot;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
public class MessageSlotFilterSet extends MessageHandlerPlayerToServer<MessageSlotFilterSet> implements IMessage {
|
||||
private int containerSlot;
|
||||
private ItemStack stack;
|
||||
|
||||
public MessageSlotFilterSet(int containerSlot, ItemStack stack) {
|
||||
this.containerSlot = containerSlot;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public MessageSlotFilterSet() {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handle(MessageSlotFilterSet message, ServerPlayerEntity player) {
|
||||
if (message.stack.isEmpty() || message.stack.getCount() > message.stack.getMaxStackSize()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Container container = player.openContainer;
|
||||
|
||||
if (container != null) {
|
||||
if (message.containerSlot >= 0 && message.containerSlot < container.inventorySlots.size()) {
|
||||
Slot slot = container.getSlot(message.containerSlot);
|
||||
|
||||
if (slot instanceof SlotFilter || slot instanceof SlotLegacyFilter) {
|
||||
slot.putStack(message.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
containerSlot = buf.readInt();
|
||||
stack = ByteBufUtils.readItemStack(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(containerSlot);
|
||||
ByteBufUtils.writeItemStack(buf, stack);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot;
|
||||
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.Slot;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
public class MessageSlotFilterSetFluid extends MessageHandlerPlayerToServer<MessageSlotFilterSetFluid> implements IMessage {
|
||||
private int containerSlot;
|
||||
private FluidStack stack;
|
||||
|
||||
public MessageSlotFilterSetFluid(int containerSlot, FluidStack stack) {
|
||||
this.containerSlot = containerSlot;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public MessageSlotFilterSetFluid() {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handle(MessageSlotFilterSetFluid message, ServerPlayerEntity player) {
|
||||
Container container = player.openContainer;
|
||||
|
||||
if (container != null) {
|
||||
if (message.containerSlot >= 0 && message.containerSlot < container.inventorySlots.size()) {
|
||||
Slot slot = container.getSlot(message.containerSlot);
|
||||
|
||||
if (slot instanceof SlotFilterFluid) {
|
||||
((SlotFilterFluid) slot).getFluidInventory().setFluid(slot.getSlotIndex(), message.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
containerSlot = buf.readInt();
|
||||
stack = StackUtils.readFluidStack(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(containerSlot);
|
||||
StackUtils.writeFluidStack(buf, stack);
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,9 @@ public class NetworkHandler {
|
||||
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++, GridClearMessage.class, GridClearMessage::encode, GridClearMessage::decode, GridClearMessage::handle);
|
||||
handler.registerMessage(id++, GridPatternCreateMessage.class, GridPatternCreateMessage::encode, GridPatternCreateMessage::decode, GridPatternCreateMessage::handle);
|
||||
handler.registerMessage(id++, SetFilterSlotMessage.class, SetFilterSlotMessage::encode, SetFilterSlotMessage::decode, SetFilterSlotMessage::handle);
|
||||
handler.registerMessage(id++, SetFluidFilterSlotMessage.class, SetFluidFilterSlotMessage::encode, SetFluidFilterSlotMessage::decode, SetFluidFilterSlotMessage::handle);
|
||||
}
|
||||
|
||||
public void sendToServer(Object message) {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.FilterSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.LegacyFilterSlot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class SetFilterSlotMessage {
|
||||
private int containerSlot;
|
||||
private ItemStack stack;
|
||||
|
||||
public SetFilterSlotMessage(int containerSlot, ItemStack stack) {
|
||||
this.containerSlot = containerSlot;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public static SetFilterSlotMessage decode(PacketBuffer buf) {
|
||||
return new SetFilterSlotMessage(buf.readInt(), buf.readItemStack());
|
||||
}
|
||||
|
||||
public static void encode(SetFilterSlotMessage message, PacketBuffer buf) {
|
||||
buf.writeInt(message.containerSlot);
|
||||
buf.writeItemStack(message.stack);
|
||||
}
|
||||
|
||||
public static void handle(SetFilterSlotMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||
if (!message.stack.isEmpty() && message.stack.getCount() <= message.stack.getMaxStackSize()) {
|
||||
PlayerEntity player = ctx.get().getSender();
|
||||
|
||||
if (player != null) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
Container container = player.openContainer;
|
||||
|
||||
if (container != null) {
|
||||
if (message.containerSlot >= 0 && message.containerSlot < container.inventorySlots.size()) {
|
||||
Slot slot = container.getSlot(message.containerSlot);
|
||||
|
||||
if (slot instanceof FilterSlot || slot instanceof LegacyFilterSlot) {
|
||||
slot.putStack(message.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class SetFluidFilterSlotMessage {
|
||||
private int containerSlot;
|
||||
private FluidStack stack;
|
||||
|
||||
public SetFluidFilterSlotMessage(int containerSlot, FluidStack stack) {
|
||||
this.containerSlot = containerSlot;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public static SetFluidFilterSlotMessage decode(PacketBuffer buf) {
|
||||
return new SetFluidFilterSlotMessage(buf.readInt(), FluidStack.readFromPacket(buf));
|
||||
}
|
||||
|
||||
public static void encode(SetFluidFilterSlotMessage message, PacketBuffer buf) {
|
||||
buf.writeInt(message.containerSlot);
|
||||
message.stack.writeToPacket(buf);
|
||||
}
|
||||
|
||||
public static void handle(SetFluidFilterSlotMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||
PlayerEntity player = ctx.get().getSender();
|
||||
|
||||
if (player != null) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
Container container = player.openContainer;
|
||||
|
||||
if (container != null) {
|
||||
if (message.containerSlot >= 0 && message.containerSlot < container.inventorySlots.size()) {
|
||||
Slot slot = container.getSlot(message.containerSlot);
|
||||
|
||||
if (slot instanceof FluidFilterSlot) {
|
||||
((FluidFilterSlot) slot).getFluidInventory().setFluid(slot.getSlotIndex(), message.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.raoulvdberge.refinedstorage.network.grid;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.GridTile;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class GridPatternCreateMessage {
|
||||
private BlockPos pos;
|
||||
|
||||
public GridPatternCreateMessage(BlockPos pos) {
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public static GridPatternCreateMessage decode(PacketBuffer buf) {
|
||||
return new GridPatternCreateMessage(buf.readBlockPos());
|
||||
}
|
||||
|
||||
public static void encode(GridPatternCreateMessage message, PacketBuffer buf) {
|
||||
buf.writeBlockPos(message.pos);
|
||||
}
|
||||
|
||||
public static void handle(GridPatternCreateMessage message, Supplier<NetworkEvent.Context> ctx) {
|
||||
PlayerEntity player = ctx.get().getSender();
|
||||
|
||||
if (player != null) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
TileEntity tile = player.getEntityWorld().getTileEntity(message.pos);
|
||||
|
||||
if (tile instanceof GridTile && ((GridTile) tile).getNode().getGridType() == GridType.PATTERN) {
|
||||
((GridTile) tile).getNode().onCreatePattern();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,21 @@
|
||||
package com.raoulvdberge.refinedstorage.screen;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.container.AmountContainer;
|
||||
import com.raoulvdberge.refinedstorage.network.SetFilterSlotMessage;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
public class GuiAmount extends AmountSpecifyingScreen<AmountContainer> {
|
||||
public class AmountScreen extends AmountSpecifyingScreen<AmountContainer> {
|
||||
private int containerSlot;
|
||||
private ItemStack stack;
|
||||
private int maxAmount;
|
||||
|
||||
public GuiAmount(BaseScreen parent, PlayerEntity player, int containerSlot, ItemStack stack, int maxAmount) {
|
||||
super(parent, new AmountContainer(player, stack), 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage:item_amount"));
|
||||
public AmountScreen(BaseScreen parent, PlayerEntity player, int containerSlot, ItemStack stack, int maxAmount) {
|
||||
super(parent, new AmountContainer(player, stack), 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage.item_amount"));
|
||||
|
||||
this.containerSlot = containerSlot;
|
||||
this.stack = stack;
|
||||
@@ -55,12 +57,14 @@ public class GuiAmount extends AmountSpecifyingScreen<AmountContainer> {
|
||||
|
||||
@Override
|
||||
protected void onOkButtonPressed(boolean shiftDown) {
|
||||
Integer amount = Ints.tryParse(amountField.getText());
|
||||
try {
|
||||
int amount = Integer.parseInt(amountField.getText());
|
||||
|
||||
if (amount != null) {
|
||||
// TODO RS.INSTANCE.network.sendToServer(new MessageSlotFilterSet(containerSlot, ItemHandlerHelper.copyStackWithSize(stack, amount)));
|
||||
RS.NETWORK_HANDLER.sendToServer(new SetFilterSlotMessage(containerSlot, ItemHandlerHelper.copyStackWithSize(stack, amount)));
|
||||
|
||||
close();
|
||||
} catch (NumberFormatException e) {
|
||||
// NO OP
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.util.text.ITextComponent;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
// TODO Fix focusing issues on textbox (using tab)
|
||||
public abstract class AmountSpecifyingScreen<T extends Container> extends BaseScreen<T> {
|
||||
private BaseScreen parent;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.screen;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.FilterSlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.FluidFilterSlot;
|
||||
import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
||||
import com.raoulvdberge.refinedstorage.screen.widget.CheckBoxWidget;
|
||||
@@ -15,6 +16,7 @@ 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.inventory.container.ClickType;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -157,31 +159,30 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO
|
||||
@Override
|
||||
protected void handleMouseClick(Slot slot, int slotId, int mouseButton, ClickType type) {
|
||||
boolean valid = type != ClickType.QUICK_MOVE && Minecraft.getMinecraft().player.inventory.getItemStack().isEmpty();
|
||||
boolean valid = type != ClickType.QUICK_MOVE && minecraft.player.inventory.getItemStack().isEmpty();
|
||||
|
||||
if (valid && slot instanceof SlotFilter && slot.isEnabled() && ((SlotFilter) slot).isSizeAllowed()) {
|
||||
if (valid && slot instanceof FilterSlot && slot.isEnabled() && ((FilterSlot) slot).isSizeAllowed()) {
|
||||
if (!slot.getStack().isEmpty()) {
|
||||
FMLClientHandler.instance().showGuiScreen(new GuiAmount(
|
||||
(GuiBase) Minecraft.getMinecraft().currentScreen,
|
||||
Minecraft.getMinecraft().player,
|
||||
minecraft.displayGuiScreen(new AmountScreen(
|
||||
this,
|
||||
minecraft.player,
|
||||
slot.slotNumber,
|
||||
slot.getStack(),
|
||||
slot.getSlotStackLimit()
|
||||
));
|
||||
}
|
||||
} else if (valid && slot instanceof SlotFilterFluid && slot.isEnabled() && ((SlotFilterFluid) slot).isSizeAllowed()) {
|
||||
FluidStack stack = ((SlotFilterFluid) slot).getFluidInventory().getFluid(slot.getSlotIndex());
|
||||
} else if (valid && slot instanceof FluidFilterSlot && slot.isEnabled() && ((FluidFilterSlot) slot).isSizeAllowed()) {
|
||||
FluidStack stack = ((FluidFilterSlot) slot).getFluidInventory().getFluid(slot.getSlotIndex());
|
||||
|
||||
if (stack != null) {
|
||||
FMLClientHandler.instance().showGuiScreen(new GuiFluidAmount(
|
||||
(GuiBase) Minecraft.getMinecraft().currentScreen,
|
||||
Minecraft.getMinecraft().player,
|
||||
if (!stack.isEmpty()) {
|
||||
minecraft.displayGuiScreen(new FluidAmountScreen(
|
||||
this,
|
||||
minecraft.player,
|
||||
slot.slotNumber,
|
||||
stack,
|
||||
((SlotFilterFluid) slot).getFluidInventory().getMaxAmount()
|
||||
((FluidFilterSlot) slot).getFluidInventory().getMaxAmount()
|
||||
));
|
||||
} else {
|
||||
super.handleMouseClick(slot, slotId, mouseButton, type);
|
||||
@@ -191,17 +192,6 @@ public abstract class BaseScreen<T extends Container> extends ContainerScreen<T>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() throws IOException {
|
||||
super.handleMouseInput();
|
||||
|
||||
int d = Mouse.getEventDWheel();
|
||||
|
||||
if (scrollbar != null && d != 0) {
|
||||
scrollbar.wheel(d);
|
||||
}
|
||||
}*/
|
||||
|
||||
public GuiCheckBox addCheckBox(int x, int y, String text, boolean checked, Button.IPressable onPress) {
|
||||
CheckBoxWidget checkBox = new CheckBoxWidget(x, y, text, checked, onPress);
|
||||
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
package com.raoulvdberge.refinedstorage.screen;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.container.FluidAmountContainer;
|
||||
import com.raoulvdberge.refinedstorage.network.SetFluidFilterSlotMessage;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class GuiFluidAmount extends AmountSpecifyingScreen<FluidAmountContainer> {
|
||||
public class FluidAmountScreen extends AmountSpecifyingScreen<FluidAmountContainer> {
|
||||
private int containerSlot;
|
||||
private FluidStack stack;
|
||||
private int maxAmount;
|
||||
|
||||
public GuiFluidAmount(BaseScreen parent, PlayerEntity player, int containerSlot, FluidStack stack, int maxAmount) {
|
||||
super(parent, new FluidAmountContainer(player, stack), 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage:fluid_amount"));
|
||||
public FluidAmountScreen(BaseScreen parent, PlayerEntity player, int containerSlot, FluidStack stack, int maxAmount) {
|
||||
super(parent, new FluidAmountContainer(player, stack), 172, 99, player.inventory, new TranslationTextComponent("gui.refinedstorage.fluid_amount"));
|
||||
|
||||
this.containerSlot = containerSlot;
|
||||
this.stack = stack;
|
||||
@@ -55,12 +57,14 @@ public class GuiFluidAmount extends AmountSpecifyingScreen<FluidAmountContainer>
|
||||
|
||||
@Override
|
||||
protected void onOkButtonPressed(boolean shiftDown) {
|
||||
Integer amount = Ints.tryParse(amountField.getText());
|
||||
try {
|
||||
int amount = Integer.parseInt(amountField.getText());
|
||||
|
||||
if (amount != null) {
|
||||
// TODO RS.INSTANCE.network.sendToServer(new MessageSlotFilterFluidSetAmount(containerSlot, amount));
|
||||
RS.NETWORK_HANDLER.sendToServer(new SetFluidFilterSlotMessage(containerSlot, StackUtils.copy(stack, amount)));
|
||||
|
||||
close();
|
||||
} catch (NumberFormatException e) {
|
||||
// NO OP
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ 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.GridItemPullMessage;
|
||||
import com.raoulvdberge.refinedstorage.network.grid.GridPatternCreateMessage;
|
||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||
import com.raoulvdberge.refinedstorage.screen.IScreenInfoProvider;
|
||||
import com.raoulvdberge.refinedstorage.screen.grid.sorting.*;
|
||||
@@ -38,7 +39,6 @@ import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -392,7 +392,7 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
}
|
||||
|
||||
if (isOverClear(mouseX, mouseY)) {
|
||||
renderTooltip(mouseX, mouseY, I18n.format("misc.refinedstorage:clear"));
|
||||
renderTooltip(mouseX, mouseY, I18n.format("misc.refinedstorage.clear"));
|
||||
}
|
||||
|
||||
if (isOverCreatePattern(mouseX, mouseY)) {
|
||||
@@ -407,7 +407,7 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
List<String> smallTextLines = Lists.newArrayList();
|
||||
|
||||
if (!gridStack.doesDisplayCraftText()) {
|
||||
smallTextLines.add(I18n.format("misc.refinedstorage:total", gridStack.getFormattedFullQuantity()));
|
||||
smallTextLines.add(I18n.format("misc.refinedstorage.total", gridStack.getFormattedFullQuantity()));
|
||||
}
|
||||
|
||||
if (gridStack.getTrackerEntry() != null) {
|
||||
@@ -433,19 +433,17 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
||||
boolean clickedCreatePattern = clickedButton == 0 && isOverCreatePattern(mouseX - guiLeft, mouseY - guiTop);
|
||||
|
||||
if (clickedCreatePattern) {
|
||||
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()));
|
||||
RS.NETWORK_HANDLER.sendToServer(new GridPatternCreateMessage(((GridNetworkNode) grid).getPos()));
|
||||
|
||||
return true;
|
||||
} else if (grid.isActive()) {
|
||||
if (clickedClear) {
|
||||
RS.NETWORK_HANDLER.sendToServer(new GridClearMessage());
|
||||
|
||||
minecraft.getSoundHandler().play(SimpleSound.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
||||
|
||||
RS.NETWORK_HANDLER.sendToServer(new GridClearMessage());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.raoulvdberge.refinedstorage.tile.grid;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||
@@ -9,6 +8,7 @@ import com.raoulvdberge.refinedstorage.screen.grid.GridScreen;
|
||||
import com.raoulvdberge.refinedstorage.tile.NetworkNodeTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import com.raoulvdberge.refinedstorage.util.GridUtils;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -73,12 +73,12 @@ public class GridTile extends NetworkNodeTile<GridNetworkNode> {
|
||||
}
|
||||
}
|
||||
|
||||
private final GridType gridType;
|
||||
private final GridType type;
|
||||
|
||||
public GridTile(GridType gridType) {
|
||||
super(gridType == GridType.NORMAL ? RSTiles.GRID : RSTiles.CRAFTING_GRID);
|
||||
public GridTile(GridType type) {
|
||||
super(GridUtils.getTileEntityType(type));
|
||||
|
||||
this.gridType = gridType;
|
||||
this.type = type;
|
||||
|
||||
dataManager.addWatchedParameter(VIEW_TYPE);
|
||||
dataManager.addWatchedParameter(SORTING_DIRECTION);
|
||||
@@ -95,7 +95,7 @@ public class GridTile extends NetworkNodeTile<GridNetworkNode> {
|
||||
@Override
|
||||
@Nonnull
|
||||
public GridNetworkNode createNode(World world, BlockPos pos) {
|
||||
return new GridNetworkNode(world, pos, gridType);
|
||||
return new GridNetworkNode(world, pos, type);
|
||||
}
|
||||
|
||||
/* TODO
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.raoulvdberge.refinedstorage.util;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.GridNetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.GridTile;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GridUtils {
|
||||
public static ResourceLocation getNetworkNodeId(GridType type) {
|
||||
switch (type) {
|
||||
case NORMAL:
|
||||
return GridNetworkNode.ID;
|
||||
case CRAFTING:
|
||||
return GridNetworkNode.CRAFTING_ID;
|
||||
case PATTERN:
|
||||
return GridNetworkNode.PATTERN_ID;
|
||||
case FLUID:
|
||||
return null;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown grid type " + type);
|
||||
}
|
||||
}
|
||||
|
||||
public static TileEntityType<GridTile> getTileEntityType(GridType type) {
|
||||
switch (type) {
|
||||
case NORMAL:
|
||||
return RSTiles.GRID;
|
||||
case CRAFTING:
|
||||
return RSTiles.CRAFTING_GRID;
|
||||
case PATTERN:
|
||||
return RSTiles.PATTERN_GRID;
|
||||
case FLUID:
|
||||
return null;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown grid type " + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"variants": {
|
||||
"connected=true,direction=north": {
|
||||
"model": "refinedstorage:block/grid/pattern/connected",
|
||||
"y": 0
|
||||
},
|
||||
"connected=true,direction=east": {
|
||||
"model": "refinedstorage:block/grid/pattern/connected",
|
||||
"y": 90
|
||||
},
|
||||
"connected=true,direction=south": {
|
||||
"model": "refinedstorage:block/grid/pattern/connected",
|
||||
"y": 180
|
||||
},
|
||||
"connected=true,direction=west": {
|
||||
"model": "refinedstorage:block/grid/pattern/connected",
|
||||
"y": 270
|
||||
},
|
||||
"connected=false,direction=north": {
|
||||
"model": "refinedstorage:block/grid/pattern/disconnected",
|
||||
"y": 0
|
||||
},
|
||||
"connected=false,direction=east": {
|
||||
"model": "refinedstorage:block/grid/pattern/disconnected",
|
||||
"y": 90
|
||||
},
|
||||
"connected=false,direction=south": {
|
||||
"model": "refinedstorage:block/grid/pattern/disconnected",
|
||||
"y": 180
|
||||
},
|
||||
"connected=false,direction=west": {
|
||||
"model": "refinedstorage:block/grid/pattern/disconnected",
|
||||
"y": 270
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,8 @@
|
||||
"gui.refinedstorage.grid.pattern_create": "Create",
|
||||
"gui.refinedstorage.fluid_grid": "Fluid Grid",
|
||||
"gui.refinedstorage.portable_grid": "Portable Grid",
|
||||
"gui.refinedstorage:item_amount": "Item amount",
|
||||
"gui.refinedstorage:fluid_amount": "Fluid amount in mB",
|
||||
"gui.refinedstorage.item_amount": "Item amount",
|
||||
"gui.refinedstorage.fluid_amount": "Fluid amount in mB",
|
||||
"gui.refinedstorage.disk_drive": "Disk Drive",
|
||||
"gui.refinedstorage.disk_drive.disks": "Disks",
|
||||
"gui.refinedstorage:external_storage": "External Storage",
|
||||
@@ -102,14 +102,14 @@
|
||||
"misc.refinedstorage.pattern.oredict": "Uses ore dictionary",
|
||||
"misc.refinedstorage:security.no_permission": "You have no permission to perform that action.",
|
||||
"misc.refinedstorage:start": "Start",
|
||||
"misc.refinedstorage:clear": "Clear",
|
||||
"misc.refinedstorage.clear": "Clear",
|
||||
"misc.refinedstorage.set": "Set",
|
||||
"misc.refinedstorage:cancel_all": "Cancel All",
|
||||
"misc.refinedstorage.priority": "Priority",
|
||||
"misc.refinedstorage:oredict": "Oredict",
|
||||
"misc.refinedstorage.processing": "Processing",
|
||||
"misc.refinedstorage:reader_writer.redstone": "Redstone strength: %d",
|
||||
"misc.refinedstorage:total": "%s total",
|
||||
"misc.refinedstorage.total": "%s total",
|
||||
"misc.refinedstorage.last_modified.just_now": "Last modified just now by %s",
|
||||
"misc.refinedstorage.last_modified.second": "Last modified %d second ago by %s",
|
||||
"misc.refinedstorage.last_modified.seconds": "Last modified %d seconds ago by %s",
|
||||
|
||||
@@ -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/pattern_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/pattern_front_disconnected"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"parent": "refinedstorage:block/grid/pattern/disconnected"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "refinedstorage:pattern_grid"
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,18 +2,16 @@
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "refinedstorage:grid",
|
||||
"data": 0
|
||||
"item": "refinedstorage:grid"
|
||||
},
|
||||
{
|
||||
"item": "#advanced_processor"
|
||||
"item": "refinedstorage:advanced_processor"
|
||||
},
|
||||
{
|
||||
"item": "refinedstorage:pattern"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "refinedstorage:grid",
|
||||
"data": 2
|
||||
"item": "refinedstorage:pattern_grid"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user