Skip to content

Commit

Permalink
refactor: more package private classes in platform modules
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Nov 3, 2023
1 parent d0ccbba commit d325cae
Show file tree
Hide file tree
Showing 55 changed files with 160 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public void setPlacedBy(final Level level,
@Nullable final LivingEntity entity,
final ItemStack stack) {
super.setPlacedBy(level, pos, state, entity, stack);
if (entity instanceof Player player && level.getBlockEntity(pos) instanceof PlayerAware playerAware) {
if (entity instanceof Player player
&& level.getBlockEntity(pos) instanceof PlayerAwareBlockEntity playerAware) {
playerAware.setPlacedBy(player.getGameProfile().getId());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import java.util.UUID;

public interface PlayerAware {
public interface PlayerAwareBlockEntity {
void setPlacedBy(UUID playerId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import net.minecraft.world.item.ItemStack;

public record ResourceInventoryDestination(AbstractResourceContainerMenu destination)
implements TransferDestination {
record ResourceInventoryDestination(AbstractResourceContainerMenu destination) implements TransferDestination {
@Override
public ItemStack transfer(final ItemStack stack) {
destination.addToResourceSlotIfNotExisting(stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public TransferManager(final AbstractContainerMenu containerMenu,
this.destinationFactory = destinationFactory;
}


public void addTransfer(final Container from, final Container to) {
addTransfer(
destinationFactory.apply(from),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.refinedmods.refinedstorage2.api.network.node.AbstractNetworkNode;
import com.refinedmods.refinedstorage2.platform.api.configurationcard.ConfigurationCardTarget;
import com.refinedmods.refinedstorage2.platform.common.Platform;
import com.refinedmods.refinedstorage2.platform.common.support.PlayerAware;
import com.refinedmods.refinedstorage2.platform.common.support.PlayerAwareBlockEntity;
import com.refinedmods.refinedstorage2.platform.common.support.RedstoneMode;
import com.refinedmods.refinedstorage2.platform.common.support.RedstoneModeSettings;

Expand All @@ -21,7 +21,7 @@
import net.minecraft.world.level.block.state.BlockState;

public abstract class AbstractRedstoneModeNetworkNodeContainerBlockEntity<T extends AbstractNetworkNode>
extends NetworkNodeContainerBlockEntityImpl<T> implements PlayerAware, ConfigurationCardTarget {
extends NetworkNodeContainerBlockEntityImpl<T> implements PlayerAwareBlockEntity, ConfigurationCardTarget {
private static final String TAG_REDSTONE_MODE = "rm";
private static final String TAG_PLACED_BY_PLAYER_ID = "pbpid";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public final class InventorySlotReference implements SlotReference {
private final int slotIndex;

public InventorySlotReference(final int slotIndex) {
InventorySlotReference(final int slotIndex) {
this.slotIndex = slotIndex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ public void drainEnergy(final long amount) {
);
}

public record NetworkReference(ResourceKey<Level> dimensionKey, BlockPos pos) {
record NetworkReference(ResourceKey<Level> dimensionKey, BlockPos pos) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;

public abstract class AbstractResourceContainerContainerAdapter implements Container {
abstract class AbstractResourceContainerContainerAdapter implements Container {
private final ResourceContainer container;

protected AbstractResourceContainerContainerAdapter(final ResourceContainer container) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ public final class SmallText {
private SmallText() {
}

public static float getScale() {
static float getScale() {
return Minecraft.getInstance().isEnforceUnicode() ? 1F : 0.7F;
}

public static void render(final Font font,
final FormattedCharSequence text,
final int x,
final int y,
final float scale,
final Matrix4f pose,
final MultiBufferSource.BufferSource buffer) {
static void render(final Font font,
final FormattedCharSequence text,
final int x,
final int y,
final float scale,
final Matrix4f pose,
final MultiBufferSource.BufferSource buffer) {
final Matrix4f scaled = new Matrix4f(pose);
scaled.scale(scale, scale, 1);
font.drawInBatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import com.refinedmods.refinedstorage2.platform.common.support.AbstractBaseBlock;
import com.refinedmods.refinedstorage2.platform.common.upgrade.RegulatorUpgradeItem;
import com.refinedmods.refinedstorage2.platform.common.util.ServerEventQueue;
import com.refinedmods.refinedstorage2.platform.fabric.exporter.StorageExporterTransferStrategyFactory;
import com.refinedmods.refinedstorage2.platform.fabric.exporter.FabricStorageExporterTransferStrategyFactory;
import com.refinedmods.refinedstorage2.platform.fabric.grid.strategy.FluidGridExtractionStrategy;
import com.refinedmods.refinedstorage2.platform.fabric.grid.strategy.FluidGridInsertionStrategy;
import com.refinedmods.refinedstorage2.platform.fabric.grid.strategy.ItemGridExtractionStrategy;
import com.refinedmods.refinedstorage2.platform.fabric.grid.strategy.ItemGridScrollingStrategy;
import com.refinedmods.refinedstorage2.platform.fabric.importer.StorageImporterTransferStrategyFactory;
import com.refinedmods.refinedstorage2.platform.fabric.importer.FabricStorageImporterTransferStrategyFactory;
import com.refinedmods.refinedstorage2.platform.fabric.packet.PacketIds;
import com.refinedmods.refinedstorage2.platform.fabric.packet.c2s.CraftingGridClearPacket;
import com.refinedmods.refinedstorage2.platform.fabric.packet.c2s.CraftingGridRecipeTransferPacket;
Expand All @@ -41,10 +41,10 @@
import com.refinedmods.refinedstorage2.platform.fabric.packet.c2s.StorageInfoRequestPacket;
import com.refinedmods.refinedstorage2.platform.fabric.packet.c2s.UseNetworkBoundItemPacket;
import com.refinedmods.refinedstorage2.platform.fabric.storage.diskdrive.FabricDiskDriveBlockEntity;
import com.refinedmods.refinedstorage2.platform.fabric.storage.externalstorage.StoragePlatformExternalStorageProviderFactory;
import com.refinedmods.refinedstorage2.platform.fabric.storage.externalstorage.FabricStoragePlatformExternalStorageProviderFactory;
import com.refinedmods.refinedstorage2.platform.fabric.support.energy.EnergyStorageAdapter;
import com.refinedmods.refinedstorage2.platform.fabric.support.networkbounditem.TrinketsSlotReferenceFactory;
import com.refinedmods.refinedstorage2.platform.fabric.support.networkbounditem.TrinketsSlotReferenceProvider;
import com.refinedmods.refinedstorage2.platform.fabric.support.network.bounditem.TrinketsSlotReferenceFactory;
import com.refinedmods.refinedstorage2.platform.fabric.support.network.bounditem.TrinketsSlotReferenceProvider;
import com.refinedmods.refinedstorage2.platform.fabric.support.resource.ResourceContainerFluidStorageAdapter;
import com.refinedmods.refinedstorage2.platform.fabric.support.resource.VariantUtil;

Expand Down Expand Up @@ -136,7 +136,7 @@ private void registerGridScrollingStrategyFactories() {
private void registerImporterTransferStrategyFactories() {
PlatformApi.INSTANCE.getImporterTransferStrategyRegistry().register(
createIdentifier("item"),
new StorageImporterTransferStrategyFactory<>(
new FabricStorageImporterTransferStrategyFactory<>(
ItemStorage.SIDED,
StorageChannelTypes.ITEM,
VariantUtil::ofItemVariant,
Expand All @@ -146,7 +146,7 @@ private void registerImporterTransferStrategyFactories() {
);
PlatformApi.INSTANCE.getImporterTransferStrategyRegistry().register(
createIdentifier("fluid"),
new StorageImporterTransferStrategyFactory<>(
new FabricStorageImporterTransferStrategyFactory<>(
FluidStorage.SIDED,
StorageChannelTypes.FLUID,
VariantUtil::ofFluidVariant,
Expand All @@ -159,7 +159,7 @@ private void registerImporterTransferStrategyFactories() {
private void registerExporterTransferStrategyFactories() {
PlatformApi.INSTANCE.getExporterTransferStrategyRegistry().register(
createIdentifier("item"),
new StorageExporterTransferStrategyFactory<>(
new FabricStorageExporterTransferStrategyFactory<>(
ItemStorage.SIDED,
StorageChannelTypes.ITEM,
resource -> resource instanceof ItemResource itemResource
Expand All @@ -171,7 +171,7 @@ private void registerExporterTransferStrategyFactories() {
);
PlatformApi.INSTANCE.getExporterTransferStrategyRegistry().register(
createIdentifier("fluid"),
new StorageExporterTransferStrategyFactory<>(
new FabricStorageExporterTransferStrategyFactory<>(
FluidStorage.SIDED,
StorageChannelTypes.FLUID,
resource -> resource instanceof FluidResource fluidResource
Expand All @@ -185,18 +185,20 @@ private void registerExporterTransferStrategyFactories() {

private void registerExternalStorageProviderFactories() {
PlatformApi.INSTANCE.addExternalStorageProviderFactory(new InterfacePlatformExternalStorageProviderFactory());
PlatformApi.INSTANCE.addExternalStorageProviderFactory(new StoragePlatformExternalStorageProviderFactory<>(
StorageChannelTypes.ITEM,
ItemStorage.SIDED,
VariantUtil::ofItemVariant,
VariantUtil::toItemVariant
));
PlatformApi.INSTANCE.addExternalStorageProviderFactory(new StoragePlatformExternalStorageProviderFactory<>(
StorageChannelTypes.FLUID,
FluidStorage.SIDED,
VariantUtil::ofFluidVariant,
VariantUtil::toFluidVariant
));
PlatformApi.INSTANCE.addExternalStorageProviderFactory(
new FabricStoragePlatformExternalStorageProviderFactory<>(
StorageChannelTypes.ITEM,
ItemStorage.SIDED,
VariantUtil::ofItemVariant,
VariantUtil::toItemVariant
));
PlatformApi.INSTANCE.addExternalStorageProviderFactory(
new FabricStoragePlatformExternalStorageProviderFactory<>(
StorageChannelTypes.FLUID,
FluidStorage.SIDED,
VariantUtil::ofFluidVariant,
VariantUtil::toFluidVariant
));
}

private void registerContent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;

public class StorageExporterTransferStrategyFactory<T, P> implements ExporterTransferStrategyFactory {
public class FabricStorageExporterTransferStrategyFactory<T, P> implements ExporterTransferStrategyFactory {
private final BlockApiLookup<Storage<P>, Direction> lookup;
private final StorageChannelType<T> storageChannelType;
private final Function<T, P> toPlatformMapper;
private final Function<Object, Optional<T>> mapper;
private final long singleAmount;

public StorageExporterTransferStrategyFactory(final BlockApiLookup<Storage<P>, Direction> lookup,
final StorageChannelType<T> storageChannelType,
final Function<Object, Optional<T>> mapper,
final Function<T, P> toPlatformMapper,
final long singleAmount) {
public FabricStorageExporterTransferStrategyFactory(final BlockApiLookup<Storage<P>, Direction> lookup,
final StorageChannelType<T> storageChannelType,
final Function<Object, Optional<T>> mapper,
final Function<T, P> toPlatformMapper,
final long singleAmount) {
this.lookup = lookup;
this.storageChannelType = storageChannelType;
this.mapper = mapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
import static com.google.common.collect.Iterators.filter;
import static com.google.common.collect.Iterators.transform;

public class StorageImporterSource<T, P> implements ImporterSource<T> {
class FabricStorageImporterSource<T, P> implements ImporterSource<T> {
private final BlockApiCache<Storage<P>, Direction> cache;
private final Function<P, T> fromPlatformMapper;
private final FabricStorageInsertableStorage<T, P> insertTarget;
private final FabricStorageExtractableStorage<T, P> extractTarget;
private final Direction direction;

public StorageImporterSource(final BlockApiLookup<Storage<P>, Direction> lookup,
final Function<P, T> fromPlatformMapper,
final Function<T, P> toPlatformMapper,
final ServerLevel serverLevel,
final BlockPos pos,
final Direction direction,
final AmountOverride amountOverride) {
FabricStorageImporterSource(final BlockApiLookup<Storage<P>, Direction> lookup,
final Function<P, T> fromPlatformMapper,
final Function<T, P> toPlatformMapper,
final ServerLevel serverLevel,
final BlockPos pos,
final Direction direction,
final AmountOverride amountOverride) {
this.cache = BlockApiCache.create(lookup, serverLevel, pos);
this.fromPlatformMapper = fromPlatformMapper;
this.insertTarget = new FabricStorageInsertableStorage<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;

public class StorageImporterTransferStrategyFactory<T, P> implements ImporterTransferStrategyFactory {
public class FabricStorageImporterTransferStrategyFactory<T, P> implements ImporterTransferStrategyFactory {
private final BlockApiLookup<Storage<P>, Direction> lookup;
private final StorageChannelType<T> storageChannelType;
private final Function<P, T> fromPlatformMapper;
private final Function<T, P> toPlatformMapper;
private final long singleAmount;

public StorageImporterTransferStrategyFactory(final BlockApiLookup<Storage<P>, Direction> lookup,
final StorageChannelType<T> storageChannelType,
final Function<P, T> fromPlatformMapper,
final Function<T, P> toPlatformMapper,
final long singleAmount) {
public FabricStorageImporterTransferStrategyFactory(final BlockApiLookup<Storage<P>, Direction> lookup,
final StorageChannelType<T> storageChannelType,
final Function<P, T> fromPlatformMapper,
final Function<T, P> toPlatformMapper,
final long singleAmount) {
this.lookup = lookup;
this.storageChannelType = storageChannelType;
this.fromPlatformMapper = fromPlatformMapper;
Expand All @@ -42,7 +42,7 @@ public ImporterTransferStrategy create(final ServerLevel level,
final Direction direction,
final UpgradeState upgradeState,
final AmountOverride amountOverride) {
final ImporterSource<T> source = new StorageImporterSource<>(
final ImporterSource<T> source = new FabricStorageImporterSource<>(
lookup,
fromPlatformMapper,
toPlatformMapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.world.item.ItemStack;

public class CraftingGridTransferHandler implements TransferHandler {
class CraftingGridTransferHandler implements TransferHandler {
private static final Color MISSING_COLOR = new Color(1.0f, 0.0f, 0.0f, 0.4f);
private static final CategoryIdentifier<?> CRAFTING = CategoryIdentifier.of("minecraft", "plugins/crafting");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import me.shedaniel.rei.api.client.gui.drag.DraggingContext;
import net.minecraft.client.gui.screens.Screen;

public class DraggableStackVisitorImpl
class DraggableStackVisitorImpl
implements DraggableStackVisitor<AbstractBaseScreen<? extends AbstractResourceContainerMenu>> {
private final IngredientConverter ingredientConverter;

public DraggableStackVisitorImpl(final IngredientConverter ingredientConverter) {
DraggableStackVisitorImpl(final IngredientConverter ingredientConverter) {
this.ingredientConverter = ingredientConverter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.registry.screen.ExclusionZonesProvider;

public class ExclusionZonesProviderImpl implements ExclusionZonesProvider<AbstractBaseScreen<?>> {
class ExclusionZonesProviderImpl implements ExclusionZonesProvider<AbstractBaseScreen<?>> {
@Override
public Collection<Rectangle> provide(final AbstractBaseScreen<?> screen) {
return screen.getExclusionZones().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import me.shedaniel.rei.api.common.entry.EntryStack;
import net.minecraft.client.gui.screens.Screen;

public class GridFocusedStackProvider implements FocusedStackProvider {
class GridFocusedStackProvider implements FocusedStackProvider {
private final IngredientConverter converter;

public GridFocusedStackProvider(final IngredientConverter converter) {
GridFocusedStackProvider(final IngredientConverter converter) {
this.converter = converter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import dev.architectury.fluid.FluidStack;
import me.shedaniel.rei.api.common.util.EntryStacks;

public class GridResourceIngredientConverter implements IngredientConverter {
class GridResourceIngredientConverter implements IngredientConverter {
@Override
public Optional<ResourceTemplate<?>> convertToResource(final Object ingredient) {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
import it.unimi.dsi.fastutil.ints.IntSet;
import me.shedaniel.rei.api.common.entry.EntryIngredient;

public class MissingIngredients {
class MissingIngredients {
private final List<EntryIngredient> ingredients = new ArrayList<>();
private final IntSet indices = new IntOpenHashSet();

public boolean isEmpty() {
boolean isEmpty() {
return indices.isEmpty();
}

public void addIngredient(final EntryIngredient ingredient, final int slotIndex) {
void addIngredient(final EntryIngredient ingredient, final int slotIndex) {
ingredients.add(ingredient);
indices.add(slotIndex);
}

public List<EntryIngredient> getIngredients() {
List<EntryIngredient> getIngredients() {
return ingredients;
}

public boolean isMissing(final int slotIndex) {
boolean isMissing(final int slotIndex) {
return indices.contains(slotIndex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import me.shedaniel.rei.api.common.entry.EntryStack;
import net.minecraft.client.gui.screens.Screen;

public class ResourceFocusedStackProvider implements FocusedStackProvider {
class ResourceFocusedStackProvider implements FocusedStackProvider {
private final IngredientConverter converter;

public ResourceFocusedStackProvider(final IngredientConverter converter) {
ResourceFocusedStackProvider(final IngredientConverter converter) {
this.converter = converter;
}

Expand Down
Loading

0 comments on commit d325cae

Please sign in to comment.