Skip to content

Commit

Permalink
refactor: make more classes package-private
Browse files Browse the repository at this point in the history
An added benefit of partitioning everything by feature.
  • Loading branch information
raoulvdberge committed Nov 1, 2023
1 parent d109b09 commit dc0224f
Show file tree
Hide file tree
Showing 110 changed files with 286 additions and 295 deletions.

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 @@ -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)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import com.refinedmods.refinedstorage2.api.storage.channel.StorageChannel;
import com.refinedmods.refinedstorage2.platform.api.storage.channel.FuzzyStorageChannel;

public class FuzzyDetectorAmountStrategy extends AbstractDetectorAmountStrategy {
class FuzzyDetectorAmountStrategy extends AbstractDetectorAmountStrategy {
private final DetectorAmountStrategy fallback;

public FuzzyDetectorAmountStrategy(final DetectorAmountStrategy fallback) {
FuzzyDetectorAmountStrategy(final DetectorAmountStrategy fallback) {
this.fallback = fallback;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import net.minecraft.world.inventory.ResultContainer;
import net.minecraft.world.item.ItemStack;

public class ClientCraftingGridSource implements CraftingGridSource {
class ClientCraftingGridSource implements CraftingGridSource {
private final CraftingMatrix craftingMatrix;
private final ResultContainer craftingResult;

public ClientCraftingGridSource() {
ClientCraftingGridSource() {
this.craftingMatrix = new CraftingMatrix(null);
this.craftingResult = new ResultContainer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

public interface CraftingGridRefillContext extends AutoCloseable {
interface CraftingGridRefillContext extends AutoCloseable {
boolean extract(ItemResource resource, Player player);

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

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

public class CraftingGridRefillContextImpl implements CraftingGridRefillContext {
class CraftingGridRefillContextImpl implements CraftingGridRefillContext {
private final CraftingGridBlockEntity blockEntity;

public CraftingGridRefillContextImpl(final CraftingGridBlockEntity blockEntity) {
CraftingGridRefillContextImpl(final CraftingGridBlockEntity blockEntity) {
this.blockEntity = blockEntity;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.minecraft.world.inventory.ResultContainer;
import net.minecraft.world.item.ItemStack;

public interface CraftingGridSource {
interface CraftingGridSource {
CraftingMatrix getCraftingMatrix();

ResultContainer getCraftingResult();
Expand Down
Loading

0 comments on commit dc0224f

Please sign in to comment.