Porting 3
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package com.refinedmods.refinedstorage.api.network;
|
||||
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Represents a node that can send a wireless signal.
|
||||
@@ -20,5 +21,5 @@ public interface IWirelessTransmitter {
|
||||
/**
|
||||
* @return the dimension in which the transmitter is
|
||||
*/
|
||||
DimensionType getDimension();
|
||||
RegistryKey<World> getDimension();
|
||||
}
|
||||
|
@@ -43,7 +43,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
@@ -126,16 +125,12 @@ public class API implements IRSAPI {
|
||||
|
||||
@Override
|
||||
public INetworkNodeManager getNetworkNodeManager(ServerWorld world) {
|
||||
String name = world.getDimension().getType().getRegistryName().getNamespace() + "_" + world.getDimension().getType().getRegistryName().getPath() + "_" + NetworkNodeManager.NAME;
|
||||
|
||||
return world.getSavedData().getOrCreate(() -> new NetworkNodeManager(name, world), name);
|
||||
return world.getSavedData().getOrCreate(() -> new NetworkNodeManager("network_nodes", world), "network_nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public INetworkManager getNetworkManager(ServerWorld world) {
|
||||
String name = world.getDimension().getType().getRegistryName().getNamespace() + "_" + world.getDimension().getType().getRegistryName().getPath() + "_" + NetworkManager.NAME;
|
||||
|
||||
return world.getSavedData().getOrCreate(() -> new NetworkManager(name, world), name);
|
||||
return world.getSavedData().getOrCreate(() -> new NetworkManager("networks", world), "networks");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,7 +190,7 @@ public class API implements IRSAPI {
|
||||
@Nonnull
|
||||
@Override
|
||||
public IStorageDiskManager getStorageDiskManager(ServerWorld anyWorld) {
|
||||
ServerWorld world = anyWorld.getServer().getWorld(DimensionType.OVERWORLD);
|
||||
ServerWorld world = anyWorld.getServer().func_241755_D_(); // Get the overworld
|
||||
|
||||
return world.getSavedData().getOrCreate(() -> new StorageDiskManager(StorageDiskManager.NAME, world), StorageDiskManager.NAME);
|
||||
}
|
||||
@@ -317,7 +312,7 @@ public class API implements IRSAPI {
|
||||
@Override
|
||||
public int getNetworkNodeHashCode(INetworkNode node) {
|
||||
int result = node.getPos().hashCode();
|
||||
result = 31 * result + node.getWorld().getDimension().getType().getId();
|
||||
result = 31 * result + node.getWorld().func_234923_W_().hashCode(); // TODO check
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -334,7 +329,7 @@ public class API implements IRSAPI {
|
||||
|
||||
INetworkNode rightNode = (INetworkNode) right;
|
||||
|
||||
if (left.getWorld().getDimension().getType().getId() != rightNode.getWorld().getDimension().getType().getId()) {
|
||||
if (left.getWorld().func_234923_W_() != rightNode.getWorld().func_234923_W_()) { // TODO check
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,7 @@ public class NetworkItemManager implements INetworkItemManager {
|
||||
if (node instanceof IWirelessTransmitter &&
|
||||
network.canRun() &&
|
||||
node.isActive() &&
|
||||
((IWirelessTransmitter) node).getDimension() == player.dimension) {
|
||||
((IWirelessTransmitter) node).getDimension() == player.getEntityWorld().func_234923_W_()) {
|
||||
IWirelessTransmitter transmitter = (IWirelessTransmitter) node;
|
||||
|
||||
Vector3d pos = player.getPositionVec();
|
||||
|
@@ -11,10 +11,10 @@ import com.refinedmods.refinedstorage.item.NetworkCardItem;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -42,7 +42,7 @@ public class NetworkTransmitterNetworkNode extends NetworkNode {
|
||||
});
|
||||
|
||||
private BlockPos receiver;
|
||||
private DimensionType receiverDimension;
|
||||
private RegistryKey<World> receiverDimension;
|
||||
|
||||
public NetworkTransmitterNetworkNode(World world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
@@ -89,7 +89,7 @@ public class NetworkTransmitterNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public DimensionType getReceiverDimension() {
|
||||
public RegistryKey<World> getReceiverDimension() {
|
||||
return receiverDimension;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class NetworkTransmitterNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
public boolean isSameDimension() {
|
||||
return world.getDimension().getType() == receiverDimension;
|
||||
return world.func_234923_W_() == receiverDimension;
|
||||
}
|
||||
|
||||
private boolean canTransmit() {
|
||||
|
@@ -9,10 +9,10 @@ import com.refinedmods.refinedstorage.item.UpgradeItem;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -63,8 +63,8 @@ public class WirelessTransmitterNetworkNode extends NetworkNode implements IWire
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionType getDimension() {
|
||||
return world.getDimension().getType();
|
||||
public RegistryKey<World> getDimension() {
|
||||
return world.func_234923_W_();
|
||||
}
|
||||
|
||||
public BaseItemHandler getUpgrades() {
|
||||
|
@@ -10,12 +10,13 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
@@ -42,7 +43,7 @@ public class NetworkCardItem extends Item {
|
||||
tag.putInt(NBT_RECEIVER_X, ctx.getPos().getX());
|
||||
tag.putInt(NBT_RECEIVER_Y, ctx.getPos().getY());
|
||||
tag.putInt(NBT_RECEIVER_Z, ctx.getPos().getZ());
|
||||
tag.putString(NBT_DIMENSION, DimensionType.getKey(ctx.getWorld().getDimension().getType()).toString());
|
||||
tag.putString(NBT_DIMENSION, ctx.getWorld().func_234923_W_().func_240901_a_().toString());
|
||||
|
||||
ctx.getPlayer().getHeldItem(ctx.getHand()).setTag(tag);
|
||||
|
||||
@@ -57,7 +58,7 @@ public class NetworkCardItem extends Item {
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
|
||||
BlockPos pos = getReceiver(stack);
|
||||
DimensionType type = getDimension(stack);
|
||||
RegistryKey<World> type = getDimension(stack);
|
||||
|
||||
if (pos != null && type != null) {
|
||||
tooltip.add(new TranslationTextComponent(
|
||||
@@ -65,8 +66,8 @@ public class NetworkCardItem extends Item {
|
||||
pos.getX(),
|
||||
pos.getY(),
|
||||
pos.getZ(),
|
||||
type.getRegistryName().toString()
|
||||
).setStyle(Styles.GRAY));
|
||||
type.func_240901_a_().toString() // TODO check
|
||||
).func_230530_a_(Styles.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,14 +88,14 @@ public class NetworkCardItem extends Item {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static DimensionType getDimension(ItemStack stack) {
|
||||
public static RegistryKey<World> getDimension(ItemStack stack) {
|
||||
if (stack.hasTag() && stack.getTag().contains(NBT_DIMENSION)) {
|
||||
ResourceLocation name = ResourceLocation.tryCreate(stack.getTag().getString(NBT_DIMENSION));
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return DimensionType.byName(name);
|
||||
return RegistryKey.func_240903_a_(Registry.WORLD_KEY, name);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@@ -12,16 +12,12 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
@@ -59,13 +55,13 @@ public abstract class NetworkItem extends EnergyItem implements INetworkItemProv
|
||||
return;
|
||||
}
|
||||
|
||||
DimensionType dimension = getDimension(stack);
|
||||
RegistryKey<World> dimension = getDimension(stack);
|
||||
if (dimension == null) {
|
||||
onError.accept(notFound);
|
||||
return;
|
||||
}
|
||||
|
||||
World nodeWorld = DimensionManager.getWorld(server, dimension, true, true);
|
||||
World nodeWorld = server.getWorld(dimension);
|
||||
if (nodeWorld == null) {
|
||||
onError.accept(notFound);
|
||||
return;
|
||||
@@ -104,7 +100,7 @@ public abstract class NetworkItem extends EnergyItem implements INetworkItemProv
|
||||
tag.putInt(NBT_NODE_X, network.getPosition().getX());
|
||||
tag.putInt(NBT_NODE_Y, network.getPosition().getY());
|
||||
tag.putInt(NBT_NODE_Z, network.getPosition().getZ());
|
||||
tag.putString(NBT_DIMENSION, DimensionType.getKey(ctx.getWorld().getDimension().getType()).toString());
|
||||
tag.putString(NBT_DIMENSION, ctx.getWorld().func_234923_W_().func_240901_a_().toString());
|
||||
|
||||
stack.setTag(tag);
|
||||
|
||||
@@ -115,14 +111,14 @@ public abstract class NetworkItem extends EnergyItem implements INetworkItemProv
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static DimensionType getDimension(ItemStack stack) {
|
||||
public static RegistryKey<World> getDimension(ItemStack stack) {
|
||||
if (stack.hasTag() && stack.getTag().contains(NBT_DIMENSION)) {
|
||||
ResourceLocation name = ResourceLocation.tryCreate(stack.getTag().getString(NBT_DIMENSION));
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return DimensionType.byName(name);
|
||||
return RegistryKey.func_240903_a_(Registry.WORLD_KEY, name);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@@ -22,7 +22,7 @@ public class NetworkTransmitterTile extends NetworkNodeTile<NetworkTransmitterNe
|
||||
public static final TileDataParameter<Integer, NetworkTransmitterTile> DISTANCE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getDistance());
|
||||
public static final TileDataParameter<Optional<ResourceLocation>, NetworkTransmitterTile> RECEIVER_DIMENSION = new TileDataParameter<>(RSSerializers.OPTIONAL_RESOURCE_LOCATION_SERIALIZER, Optional.empty(), t -> {
|
||||
if (t.getNode().getReceiverDimension() != null) {
|
||||
return Optional.of(t.getNode().getReceiverDimension().getRegistryName());
|
||||
return Optional.of(t.getNode().getReceiverDimension().func_240901_a_()); // TODO check
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
|
@@ -12,12 +12,11 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
@@ -29,7 +28,7 @@ public class WirelessCraftingMonitor implements ICraftingMonitor {
|
||||
private final ItemStack stack;
|
||||
@Nullable
|
||||
private final MinecraftServer server;
|
||||
private final DimensionType nodeDimension;
|
||||
private final RegistryKey<World> nodeDimension;
|
||||
private final BlockPos nodePos;
|
||||
private int tabPage;
|
||||
private Optional<UUID> tabSelected;
|
||||
@@ -97,8 +96,7 @@ public class WirelessCraftingMonitor implements ICraftingMonitor {
|
||||
}
|
||||
|
||||
private INetwork getNetwork() {
|
||||
World world = DimensionManager.getWorld(server, nodeDimension, true, true);
|
||||
|
||||
World world = server.getWorld(nodeDimension);
|
||||
if (world != null) {
|
||||
return NetworkUtils.getNetworkFromNode(NetworkUtils.getNodeFromTile(world.getTileEntity(nodePos)));
|
||||
}
|
||||
|
@@ -24,12 +24,11 @@ import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -40,7 +39,7 @@ public class WirelessFluidGrid implements INetworkAwareGrid {
|
||||
private ItemStack stack;
|
||||
@Nullable
|
||||
private final MinecraftServer server;
|
||||
private final DimensionType nodeDimension;
|
||||
private final RegistryKey<World> nodeDimension;
|
||||
private final BlockPos nodePos;
|
||||
private final int slotId;
|
||||
|
||||
@@ -93,8 +92,7 @@ public class WirelessFluidGrid implements INetworkAwareGrid {
|
||||
@Override
|
||||
@Nullable
|
||||
public INetwork getNetwork() {
|
||||
World world = DimensionManager.getWorld(server, nodeDimension, true, true);
|
||||
|
||||
World world = server.getWorld(nodeDimension);
|
||||
if (world != null) {
|
||||
return NetworkUtils.getNetworkFromNode(NetworkUtils.getNodeFromTile(world.getTileEntity(nodePos)));
|
||||
}
|
||||
|
@@ -24,12 +24,11 @@ import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -40,7 +39,7 @@ public class WirelessGrid implements INetworkAwareGrid {
|
||||
private ItemStack stack;
|
||||
@Nullable
|
||||
private final MinecraftServer server;
|
||||
private final DimensionType nodeDimension;
|
||||
private final RegistryKey<World> nodeDimension;
|
||||
private final BlockPos nodePos;
|
||||
private final int slotId;
|
||||
|
||||
@@ -95,8 +94,7 @@ public class WirelessGrid implements INetworkAwareGrid {
|
||||
@Override
|
||||
@Nullable
|
||||
public INetwork getNetwork() {
|
||||
World world = DimensionManager.getWorld(server, nodeDimension, true, true);
|
||||
|
||||
World world = server.getWorld(nodeDimension);
|
||||
if (world != null) {
|
||||
return NetworkUtils.getNetworkFromNode(NetworkUtils.getNodeFromTile(world.getTileEntity(nodePos)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user