Skip to content

Commit

Permalink
Merge pull request #445 from refinedmods/feat/GH-95/network-card
Browse files Browse the repository at this point in the history
feat: network card
  • Loading branch information
raoulvdberge authored Nov 1, 2023
2 parents d109b09 + 60c0863 commit a8ef002
Show file tree
Hide file tree
Showing 124 changed files with 510 additions and 295 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Configuration Card. It copies device configurations and can transfer upgrades.
- Network Receiver
- Network Card

## [2.0.0-milestone.3.1] - 2023-10-30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.refinedmods.refinedstorage2.platform.common.importer.ImporterContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.misc.ProcessorItem;
import com.refinedmods.refinedstorage2.platform.common.misc.WrenchItem;
import com.refinedmods.refinedstorage2.platform.common.networking.NetworkCardItem;
import com.refinedmods.refinedstorage2.platform.common.storage.FluidStorageType;
import com.refinedmods.refinedstorage2.platform.common.storage.ItemStorageType;
import com.refinedmods.refinedstorage2.platform.common.storage.StorageTypes;
Expand Down Expand Up @@ -330,6 +331,7 @@ private void registerSimpleItems(final RegistryCallback<Item> callback) {
ContentIds.CONFIGURATION_CARD,
ConfigurationCardItem::new
));
Items.INSTANCE.setNetworkCard(callback.register(ContentIds.NETWORK_CARD, NetworkCardItem::new));
}

private void registerProcessor(final RegistryCallback<Item> callback, final ProcessorItem.Type type) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.refinedmods.refinedstorage2.api.core.Action;
import com.refinedmods.refinedstorage2.api.grid.view.GridResourceFactory;
import com.refinedmods.refinedstorage2.api.network.energy.EnergyStorage;
import com.refinedmods.refinedstorage2.api.resource.ResourceAmount;
import com.refinedmods.refinedstorage2.platform.api.grid.strategy.GridInsertionStrategyFactory;
import com.refinedmods.refinedstorage2.platform.api.support.resource.FluidResource;
import com.refinedmods.refinedstorage2.platform.api.support.resource.ItemResource;
Expand Down Expand Up @@ -119,4 +120,7 @@ List<ClientTooltipComponent> processTooltipComponents(
void renderTooltip(GuiGraphics graphics, List<ClientTooltipComponent> components, int x, int y);

Optional<EnergyStorage> getEnergyStorage(ItemStack stack);

record ContainedFluid(ItemStack remainderContainer, ResourceAmount<FluidResource> fluid) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
import com.refinedmods.refinedstorage2.platform.common.upgrade.BuiltinUpgradeDestinationsImpl;
import com.refinedmods.refinedstorage2.platform.common.upgrade.UpgradeRegistryImpl;
import com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil;
import com.refinedmods.refinedstorage2.platform.common.util.TickHandler;
import com.refinedmods.refinedstorage2.platform.common.util.ServerEventQueue;
import com.refinedmods.refinedstorage2.platform.common.wirelesstransmitter.CompositeWirelessTransmitterRangeModifier;

import java.util.ArrayList;
Expand Down Expand Up @@ -292,7 +292,7 @@ public void requestNetworkNodeInitialization(final NetworkNodeContainer containe
final Level level,
final Runnable callback) {
final LevelConnectionProvider connectionProvider = new LevelConnectionProvider(level);
TickHandler.runWhenReady(() -> {
ServerEventQueue.queue(() -> {
networkBuilder.initialize(container, connectionProvider);
callback.run();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;

public abstract class AbstractItemConstructorStrategy implements ConstructorStrategy {
abstract class AbstractItemConstructorStrategy implements ConstructorStrategy {
protected final ServerLevel level;
protected final BlockPos pos;
protected final Direction direction;

protected AbstractItemConstructorStrategy(final ServerLevel level, final BlockPos pos, final Direction direction) {
AbstractItemConstructorStrategy(final ServerLevel level, final BlockPos pos, final Direction direction) {
this.level = level;
this.pos = pos;
this.direction = direction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.state.BlockState;

public class BlockBreakDestructorStrategy implements DestructorStrategy {
class BlockBreakDestructorStrategy implements DestructorStrategy {
private final ServerLevel level;
private final BlockPos pos;
private final Direction direction;
private final ItemStack tool;

public BlockBreakDestructorStrategy(
BlockBreakDestructorStrategy(
final ServerLevel level,
final BlockPos pos,
final Direction direction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import net.minecraft.world.entity.player.Player;

public class CompositeConstructorStrategy implements ConstructorStrategy {
class CompositeConstructorStrategy implements ConstructorStrategy {
private final List<ConstructorStrategy> strategies;

public CompositeConstructorStrategy(final List<ConstructorStrategy> strategies) {
CompositeConstructorStrategy(final List<ConstructorStrategy> strategies) {
this.strategies = Collections.unmodifiableList(strategies);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

import net.minecraft.world.entity.player.Player;

public class CompositeDestructorStrategy implements DestructorStrategy {
class CompositeDestructorStrategy implements DestructorStrategy {
private final List<DestructorStrategy> strategies;

public CompositeDestructorStrategy(final List<DestructorStrategy> strategies) {
CompositeDestructorStrategy(final List<DestructorStrategy> strategies) {
this.strategies = Collections.unmodifiableList(strategies);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.refinedmods.refinedstorage2.platform.common.content.Menus;
import com.refinedmods.refinedstorage2.platform.common.support.containermenu.AbstractSchedulingContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ClientProperty;
import com.refinedmods.refinedstorage2.platform.common.support.containermenu.PropertyTypes;
import com.refinedmods.refinedstorage2.platform.common.support.containermenu.ServerProperty;
import com.refinedmods.refinedstorage2.platform.common.upgrade.UpgradeContainer;
import com.refinedmods.refinedstorage2.platform.common.upgrade.UpgradeDestinations;
Expand Down Expand Up @@ -49,14 +48,14 @@ public ConstructorContainerMenu(final int syncId,
@Override
protected void registerClientProperties() {
super.registerClientProperties();
registerProperty(new ClientProperty<>(PropertyTypes.CONSTRUCTOR_DROP_ITEMS, false));
registerProperty(new ClientProperty<>(ConstructorDestructorPropertyTypes.DROP_ITEMS, false));
}

@Override
protected void registerServerProperties(final ConstructorBlockEntity blockEntity) {
super.registerServerProperties(blockEntity);
registerProperty(new ServerProperty<>(
PropertyTypes.CONSTRUCTOR_DROP_ITEMS,
ConstructorDestructorPropertyTypes.DROP_ITEMS,
blockEntity::isDropItems,
blockEntity::setDropItems
));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.refinedmods.refinedstorage2.platform.common.constructordestructor;

import com.refinedmods.refinedstorage2.platform.common.support.containermenu.PropertyType;
import com.refinedmods.refinedstorage2.platform.common.support.containermenu.PropertyTypes;

import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier;

final class ConstructorDestructorPropertyTypes {
static final PropertyType<Boolean> PICKUP_ITEMS = PropertyTypes.createBooleanProperty(
createIdentifier("pickup_items")
);
static final PropertyType<Boolean> DROP_ITEMS = PropertyTypes.createBooleanProperty(
createIdentifier("drop_items")
);

private ConstructorDestructorPropertyTypes() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createTranslation;

public class ConstructorDropItemsSideButtonWidget extends AbstractYesNoSideButtonWidget {
public ConstructorDropItemsSideButtonWidget(final ClientProperty<Boolean> property) {
class ConstructorDropItemsSideButtonWidget extends AbstractYesNoSideButtonWidget {
ConstructorDropItemsSideButtonWidget(final ClientProperty<Boolean> property) {
super(property, createTranslation("gui", "constructor.drop_items"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected void init() {
));
addSideButton(new SchedulingModeSideButtonWidget(getMenu().getProperty(PropertyTypes.SCHEDULING_MODE)));
addSideButton(new ConstructorDropItemsSideButtonWidget(
getMenu().getProperty(PropertyTypes.CONSTRUCTOR_DROP_ITEMS)
getMenu().getProperty(ConstructorDestructorPropertyTypes.DROP_ITEMS)
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public DestructorContainerMenu(final int syncId,
protected void registerClientProperties() {
registerProperty(new ClientProperty<>(PropertyTypes.REDSTONE_MODE, RedstoneMode.IGNORE));
registerProperty(new ClientProperty<>(PropertyTypes.FILTER_MODE, FilterMode.BLOCK));
registerProperty(new ClientProperty<>(PropertyTypes.DESTRUCTOR_PICKUP_ITEMS, false));
registerProperty(new ClientProperty<>(ConstructorDestructorPropertyTypes.PICKUP_ITEMS, false));
}

@Override
Expand All @@ -68,7 +68,7 @@ protected void registerServerProperties(final DestructorBlockEntity blockEntity)
blockEntity::setFilterMode
));
registerProperty(new ServerProperty<>(
PropertyTypes.DESTRUCTOR_PICKUP_ITEMS,
ConstructorDestructorPropertyTypes.PICKUP_ITEMS,
blockEntity::isPickupItems,
blockEntity::setPickupItems
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createTranslation;

public class DestructorPickupItemsSideButtonWidget extends AbstractYesNoSideButtonWidget {
public DestructorPickupItemsSideButtonWidget(final ClientProperty<Boolean> property) {
class DestructorPickupItemsSideButtonWidget extends AbstractYesNoSideButtonWidget {
DestructorPickupItemsSideButtonWidget(final ClientProperty<Boolean> property) {
super(property, createTranslation("gui", "destructor.pickup_items"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected void init() {
createTranslation("gui", "destructor.filter_mode.block.help")
));
addSideButton(new DestructorPickupItemsSideButtonWidget(
getMenu().getProperty(PropertyTypes.DESTRUCTOR_PICKUP_ITEMS)
getMenu().getProperty(ConstructorDestructorPropertyTypes.PICKUP_ITEMS)
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.Fluid;

public class FluidBreakDestructorStrategy implements DestructorStrategy {
class FluidBreakDestructorStrategy implements DestructorStrategy {
private final ServerLevel level;
private final BlockPos pos;

public FluidBreakDestructorStrategy(final ServerLevel level, final BlockPos pos) {
FluidBreakDestructorStrategy(final ServerLevel level, final BlockPos pos) {
this.level = level;
this.pos = pos;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;

public class ItemDropConstructorStrategy extends AbstractItemConstructorStrategy {
class ItemDropConstructorStrategy extends AbstractItemConstructorStrategy {
private final long amount;

public ItemDropConstructorStrategy(
ItemDropConstructorStrategy(
final ServerLevel level,
final BlockPos pos,
final Direction direction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.AABB;

public class ItemPickupDestructorStrategy implements DestructorStrategy {
class ItemPickupDestructorStrategy implements DestructorStrategy {
private final ServerLevel level;
private final BlockPos pos;

public ItemPickupDestructorStrategy(final ServerLevel level, final BlockPos pos) {
ItemPickupDestructorStrategy(final ServerLevel level, final BlockPos pos) {
this.level = level;
this.pos = pos;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public final class ContentIds {
public static final ResourceLocation STORAGE_MONITOR = createIdentifier("storage_monitor");
public static final ResourceLocation CONFIGURATION_CARD = createIdentifier("configuration_card");
public static final ResourceLocation NETWORK_RECEIVER = createIdentifier("network_receiver");
public static final ResourceLocation NETWORK_CARD = createIdentifier("network_card");

private ContentIds() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@ private static void appendItems(final Consumer<ItemStack> consumer) {
consumer.accept(Items.INSTANCE.getWirelessGrid().createAtEnergyCapacity());
itemConsumer.accept(Items.INSTANCE.getCreativeWirelessGrid());
itemConsumer.accept(Items.INSTANCE.getConfigurationCard());
itemConsumer.accept(Items.INSTANCE.getNetworkCard());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public final class Items {
private Supplier<WirelessGridItem> creativeWirelessGrid;
@Nullable
private Supplier<Item> configurationCard;
@Nullable
private Supplier<Item> networkCard;

private Items() {
}
Expand Down Expand Up @@ -372,4 +374,12 @@ public void addNetworkReceiver(final Supplier<BlockItem> supplier) {
public List<Supplier<BlockItem>> getNetworkReceivers() {
return Collections.unmodifiableList(allNetworkReceivers);
}

public Item getNetworkCard() {
return Objects.requireNonNull(networkCard).get();
}

public void setNetworkCard(final Supplier<Item> supplier) {
this.networkCard = supplier;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createTranslation;

public class CreativeControllerBlockItem extends NamedBlockItem {
public CreativeControllerBlockItem(final Block block, final Component name) {
class CreativeControllerBlockItem extends NamedBlockItem {
CreativeControllerBlockItem(final Block block, final Component name) {
super(block, new Item.Properties().stacksTo(1), name, createTranslation("item", "creative_controller.help"));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class DetectorContainerMenu extends AbstractSingleAmountContainerMenu {
public DetectorContainerMenu(final int syncId, final Inventory playerInventory, final FriendlyByteBuf buf) {
super(Menus.INSTANCE.getDetector(), syncId, playerInventory, buf, FILTER_HELP);
registerProperty(new ClientProperty<>(PropertyTypes.FUZZY_MODE, false));
registerProperty(new ClientProperty<>(PropertyTypes.DETECTOR_MODE, DetectorMode.EQUAL));
registerProperty(new ClientProperty<>(DetectorPropertyTypes.MODE, DetectorMode.EQUAL));
}

public DetectorContainerMenu(final int syncId,
Expand All @@ -41,7 +41,7 @@ public DetectorContainerMenu(final int syncId,
detector::setFuzzyMode
));
registerProperty(new ServerProperty<>(
PropertyTypes.DETECTOR_MODE,
DetectorPropertyTypes.MODE,
detector::getMode,
detector::setMode
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.refinedmods.refinedstorage2.api.network.impl.node.detector.DetectorMode;

public final class DetectorModeSettings {
final class DetectorModeSettings {
private static final int UNDER = 0;
private static final int EQUAL = 1;
private static final int ABOVE = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createTranslation;

public class DetectorModeSideButtonWidget extends AbstractSideButtonWidget {
class DetectorModeSideButtonWidget extends AbstractSideButtonWidget {
private static final MutableComponent TITLE = createTranslation("gui", "detector.mode");
private static final MutableComponent SUBTEXT_EQUAL = createTranslation("gui", "detector.mode.equal");
private static final MutableComponent SUBTEXT_ABOVE = createTranslation("gui", "detector.mode.above");
private static final MutableComponent SUBTEXT_UNDER = createTranslation("gui", "detector.mode.under");

private final ClientProperty<DetectorMode> property;

public DetectorModeSideButtonWidget(final ClientProperty<DetectorMode> property) {
DetectorModeSideButtonWidget(final ClientProperty<DetectorMode> property) {
super(createPressAction(property));
this.property = property;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.refinedmods.refinedstorage2.platform.common.detector;

import com.refinedmods.refinedstorage2.api.network.impl.node.detector.DetectorMode;
import com.refinedmods.refinedstorage2.platform.common.support.containermenu.PropertyType;

import static com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil.createIdentifier;

final class DetectorPropertyTypes {
static final PropertyType<DetectorMode> MODE = new PropertyType<>(
createIdentifier("detector_mode"),
DetectorModeSettings::getDetectorMode,
DetectorModeSettings::getDetectorMode
);

private DetectorPropertyTypes() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ protected void init() {
getMenu().getProperty(PropertyTypes.FUZZY_MODE),
FuzzyModeSideButtonWidget.Type.GENERIC
));
addSideButton(new DetectorModeSideButtonWidget(getMenu().getProperty(PropertyTypes.DETECTOR_MODE)));
addSideButton(new DetectorModeSideButtonWidget(getMenu().getProperty(DetectorPropertyTypes.MODE)));
}
}
Loading

0 comments on commit a8ef002

Please sign in to comment.