Skip to content

Commit

Permalink
refactor: move ClientProxy to forge layer
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Nov 3, 2023
1 parent e3c4298 commit 82658d8
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import com.refinedmods.refinedstorage2.platform.api.support.AmountFormatting;
import com.refinedmods.refinedstorage2.platform.api.support.resource.ItemResource;
import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceRendering;
import com.refinedmods.refinedstorage2.platform.common.util.ClientProxy;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -50,10 +48,10 @@ public Component getDisplayName(final ItemResource resource) {
@Override
public List<Component> getTooltip(final ItemResource resource) {
final Minecraft minecraft = Minecraft.getInstance();
return ClientProxy.getPlayer().map(player -> getStack(resource).getTooltipLines(
player,
return getStack(resource).getTooltipLines(
minecraft.player,
minecraft.options.advancedItemTooltips ? TooltipFlag.ADVANCED : TooltipFlag.NORMAL
)).orElse(Collections.emptyList());
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.refinedmods.refinedstorage2.platform.common.util;
package com.refinedmods.refinedstorage2.platform.forge.packet.s2c;

import java.util.Optional;

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

public final class ClientProxy {
final class ClientProxy {
private ClientProxy() {
}

// This method exists to avoid classloading errors on LocalPlayer.
public static Optional<Player> getPlayer() {
static Optional<Player> getPlayer() {
return Optional.ofNullable(Minecraft.getInstance().player);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.refinedmods.refinedstorage2.platform.forge.packet.s2c;

import com.refinedmods.refinedstorage2.platform.common.controller.ControllerContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.util.ClientProxy;

import java.util.function.Supplier;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.refinedmods.refinedstorage2.platform.forge.packet.s2c;

import com.refinedmods.refinedstorage2.api.grid.GridWatcher;
import com.refinedmods.refinedstorage2.platform.common.util.ClientProxy;

import java.util.function.Supplier;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.refinedmods.refinedstorage2.platform.forge.packet.s2c;

import com.refinedmods.refinedstorage2.platform.common.grid.AbstractGridContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.util.ClientProxy;

import java.util.function.Supplier;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.refinedmods.refinedstorage2.platform.api.PlatformApi;
import com.refinedmods.refinedstorage2.platform.api.storage.channel.PlatformStorageChannelType;
import com.refinedmods.refinedstorage2.platform.common.grid.AbstractGridContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.util.ClientProxy;
import com.refinedmods.refinedstorage2.platform.common.util.PacketUtil;

import java.util.function.Supplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.refinedmods.refinedstorage2.platform.api.storage.channel.PlatformStorageChannelType;
import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceAmountTemplate;
import com.refinedmods.refinedstorage2.platform.common.support.containermenu.AbstractResourceContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.util.ClientProxy;

import java.util.function.Supplier;
import javax.annotation.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.refinedmods.refinedstorage2.platform.api.PlatformApi;
import com.refinedmods.refinedstorage2.platform.common.storage.ClientStorageRepository;
import com.refinedmods.refinedstorage2.platform.common.util.ClientProxy;

import java.util.UUID;
import java.util.function.Supplier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.refinedmods.refinedstorage2.platform.forge.packet.s2c;

import com.refinedmods.refinedstorage2.platform.common.util.ClientProxy;
import com.refinedmods.refinedstorage2.platform.common.wirelesstransmitter.WirelessTransmitterContainerMenu;

import java.util.function.Supplier;
Expand Down

0 comments on commit 82658d8

Please sign in to comment.