Rename world -> level
This commit is contained in:
@@ -57,20 +57,20 @@ public interface IRSAPI {
|
||||
INetworkNodeRegistry getNetworkNodeRegistry();
|
||||
|
||||
/**
|
||||
* Gets a network node manager for a given world.
|
||||
* Gets a network node manager for a given level.
|
||||
*
|
||||
* @param world world
|
||||
* @return the network node manager for a given world
|
||||
* @param level level
|
||||
* @return the network node manager for a given level
|
||||
*/
|
||||
INetworkNodeManager getNetworkNodeManager(ServerLevel world);
|
||||
INetworkNodeManager getNetworkNodeManager(ServerLevel level);
|
||||
|
||||
/**
|
||||
* Gets a network manager for a given world.
|
||||
* Gets a network manager for a given level.
|
||||
*
|
||||
* @param world world
|
||||
* @return the network manager for a given world
|
||||
* @param level level
|
||||
* @return the network manager for a given level
|
||||
*/
|
||||
INetworkManager getNetworkManager(ServerLevel world);
|
||||
INetworkManager getNetworkManager(ServerLevel level);
|
||||
|
||||
/**
|
||||
* @return the crafting task registry
|
||||
@@ -127,11 +127,11 @@ public interface IRSAPI {
|
||||
IStorageDiskRegistry getStorageDiskRegistry();
|
||||
|
||||
/**
|
||||
* @param anyWorld any world associated with the server
|
||||
* @param level any level associated with the server
|
||||
* @return the storage disk manager
|
||||
*/
|
||||
@Nonnull
|
||||
IStorageDiskManager getStorageDiskManager(ServerLevel anyWorld);
|
||||
IStorageDiskManager getStorageDiskManager(ServerLevel level);
|
||||
|
||||
/**
|
||||
* @return the storage disk sync manager
|
||||
@@ -143,7 +143,7 @@ public interface IRSAPI {
|
||||
* @return the storage tracker manager
|
||||
*/
|
||||
@Nonnull
|
||||
IStorageTrackerManager getStorageTrackerManager(ServerLevel anyWorld);
|
||||
IStorageTrackerManager getStorageTrackerManager(ServerLevel level);
|
||||
|
||||
/**
|
||||
* Adds an external storage provider for the given storage type.
|
||||
@@ -160,22 +160,22 @@ public interface IRSAPI {
|
||||
<T> Set<IExternalStorageProvider<T>> getExternalStorageProviders(StorageType type);
|
||||
|
||||
/**
|
||||
* @param world the world
|
||||
* @param level the level
|
||||
* @param capacity the capacity
|
||||
* @param owner the owner or null if no owner
|
||||
* @return a storage disk
|
||||
*/
|
||||
@Nonnull
|
||||
IStorageDisk<ItemStack> createDefaultItemDisk(ServerLevel world, int capacity, @Nullable Player owner);
|
||||
IStorageDisk<ItemStack> createDefaultItemDisk(ServerLevel level, int capacity, @Nullable Player owner);
|
||||
|
||||
/**
|
||||
* @param world the world
|
||||
* @param level the level
|
||||
* @param capacity the capacity in mB
|
||||
* @param owner the owner or null if no owner
|
||||
* @return a fluid storage disk
|
||||
*/
|
||||
@Nonnull
|
||||
IStorageDisk<FluidStack> createDefaultFluidDisk(ServerLevel world, int capacity, @Nullable Player owner);
|
||||
IStorageDisk<FluidStack> createDefaultFluidDisk(ServerLevel level, int capacity, @Nullable Player owner);
|
||||
|
||||
/**
|
||||
* Creates crafting request info for an item.
|
||||
|
@@ -13,11 +13,11 @@ public interface ICraftingPatternProvider {
|
||||
/**
|
||||
* Creates a crafting pattern.
|
||||
*
|
||||
* @param world the world
|
||||
* @param level the level
|
||||
* @param stack the pattern stack, the implementor needs to copy it
|
||||
* @param container the {@link ICraftingPatternContainer} where the pattern is in
|
||||
* @return the crafting pattern
|
||||
*/
|
||||
@Nonnull
|
||||
ICraftingPattern create(Level world, ItemStack stack, ICraftingPatternContainer container);
|
||||
ICraftingPattern create(Level level, ItemStack stack, ICraftingPatternContainer container);
|
||||
}
|
||||
|
@@ -242,12 +242,12 @@ public interface INetwork {
|
||||
IStorageTracker<FluidStack> getFluidStorageTracker();
|
||||
|
||||
/**
|
||||
* @return the world where this network is in
|
||||
* @return the level where this network is in
|
||||
*/
|
||||
Level getWorld();
|
||||
Level getLevel();
|
||||
|
||||
/**
|
||||
* @return the position of this network in the world
|
||||
* @return the position of this network in the level
|
||||
*/
|
||||
BlockPos getPosition();
|
||||
|
||||
|
@@ -6,7 +6,7 @@ import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* This is a registry for network nodes in the world.
|
||||
* This is a registry for network nodes in the level.
|
||||
*/
|
||||
public interface INetworkManager {
|
||||
/**
|
||||
|
@@ -15,10 +15,10 @@ public interface INetworkNodeGraph {
|
||||
* Rebuilds the network graph.
|
||||
*
|
||||
* @param action whether to perform or simulate
|
||||
* @param world the origin world
|
||||
* @param level the origin level
|
||||
* @param origin the origin, usually the network position
|
||||
*/
|
||||
void invalidate(Action action, Level world, BlockPos origin);
|
||||
void invalidate(Action action, Level level, BlockPos origin);
|
||||
|
||||
/**
|
||||
* Runs an action on the network.
|
||||
|
@@ -23,15 +23,15 @@ public interface INetworkNodeVisitor {
|
||||
*/
|
||||
interface Operator {
|
||||
/**
|
||||
* Calling this method in {@link #visit(Operator)} will make the network graph scan the given world and position.
|
||||
* Calling this method in {@link #visit(Operator)} will make the network graph scan the given level and position.
|
||||
* If there is another {@link INetworkNodeVisitor} at that position, it will call that visitor.
|
||||
* If there is no {@link INetworkNodeVisitor} at that position, it will use a default implementation which scans neighbors.
|
||||
*
|
||||
* @param world the world
|
||||
* @param level the level
|
||||
* @param pos the position
|
||||
* @param side the side
|
||||
*/
|
||||
void apply(Level world, BlockPos pos, @Nullable Direction side);
|
||||
void apply(Level level, BlockPos pos, @Nullable Direction side);
|
||||
|
||||
/**
|
||||
* Returns whether the network graph is scanning in simulation mode.
|
||||
|
@@ -37,12 +37,12 @@ public interface IGridFactory {
|
||||
/**
|
||||
* Returns a possible tile for this grid if {@link #getType()} is BLOCK.
|
||||
*
|
||||
* @param world the world
|
||||
* @param level the level
|
||||
* @param pos the position
|
||||
* @return the tile, or null if no tile is required
|
||||
*/
|
||||
@Nullable
|
||||
BlockEntity getRelevantTile(Level world, BlockPos pos);
|
||||
BlockEntity getRelevantTile(Level level, BlockPos pos);
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
|
@@ -78,9 +78,9 @@ public interface INetworkNode {
|
||||
BlockPos getPos();
|
||||
|
||||
/**
|
||||
* @return the world of this network node
|
||||
* @return the level of this network node
|
||||
*/
|
||||
Level getWorld();
|
||||
Level getLevel();
|
||||
|
||||
/**
|
||||
* Marks this node as dirty for saving.
|
||||
|
@@ -14,10 +14,10 @@ public interface INetworkNodeFactory {
|
||||
* Creates a network node.
|
||||
*
|
||||
* @param tag the tag on disk
|
||||
* @param world the world
|
||||
* @param level the level
|
||||
* @param pos the pos
|
||||
* @return the network node
|
||||
*/
|
||||
@Nonnull
|
||||
INetworkNode create(CompoundTag tag, Level world, BlockPos pos);
|
||||
INetworkNode create(CompoundTag tag, Level level, BlockPos pos);
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* This is a registry for network nodes in the world.
|
||||
* This is a registry for network nodes in the level.
|
||||
*/
|
||||
public interface INetworkNodeManager {
|
||||
/**
|
||||
|
@@ -16,11 +16,11 @@ public interface IStorageDiskFactory<T> {
|
||||
/**
|
||||
* Creates a storage disk based on NBT.
|
||||
*
|
||||
* @param world the world
|
||||
* @param level the level
|
||||
* @param tag the tag
|
||||
* @return the storage disk
|
||||
*/
|
||||
IStorageDisk<T> createFromNbt(ServerLevel world, CompoundTag tag);
|
||||
IStorageDisk<T> createFromNbt(ServerLevel level, CompoundTag tag);
|
||||
|
||||
/**
|
||||
* Creates a storage disk item based on ID.
|
||||
@@ -34,10 +34,10 @@ public interface IStorageDiskFactory<T> {
|
||||
/**
|
||||
* Creates a storage disk on-demand.
|
||||
*
|
||||
* @param world the world
|
||||
* @param level the level
|
||||
* @param capacity the capacity
|
||||
* @param owner the owner, or null if no owner
|
||||
* @return the storage disk
|
||||
*/
|
||||
IStorageDisk<T> create(ServerLevel world, int capacity, @Nullable UUID owner);
|
||||
IStorageDisk<T> create(ServerLevel level, int capacity, @Nullable UUID owner);
|
||||
}
|
||||
|
@@ -128,21 +128,21 @@ public class API implements IRSAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public INetworkNodeManager getNetworkNodeManager(ServerLevel world) {
|
||||
return world.getDataStorage().computeIfAbsent(tag -> {
|
||||
NetworkNodeManager manager = new NetworkNodeManager( world);
|
||||
public INetworkNodeManager getNetworkNodeManager(ServerLevel level) {
|
||||
return level.getDataStorage().computeIfAbsent(tag -> {
|
||||
NetworkNodeManager manager = new NetworkNodeManager(level);
|
||||
manager.load(tag);
|
||||
return manager;
|
||||
}, () -> new NetworkNodeManager(world), NetworkNodeManager.NAME);
|
||||
}, () -> new NetworkNodeManager(level), NetworkNodeManager.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public INetworkManager getNetworkManager(ServerLevel world) {
|
||||
return world.getDataStorage().computeIfAbsent(tag -> {
|
||||
NetworkManager manager = new NetworkManager(world);
|
||||
public INetworkManager getNetworkManager(ServerLevel level) {
|
||||
return level.getDataStorage().computeIfAbsent(tag -> {
|
||||
NetworkManager manager = new NetworkManager(level);
|
||||
manager.load(tag);
|
||||
return manager;
|
||||
}, () -> new NetworkManager(world), NetworkManager.NAME);
|
||||
}, () -> new NetworkManager(level), NetworkManager.NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -201,14 +201,14 @@ public class API implements IRSAPI {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IStorageDiskManager getStorageDiskManager(ServerLevel anyWorld) {
|
||||
ServerLevel world = anyWorld.getServer().overworld(); // Get the overworld
|
||||
public IStorageDiskManager getStorageDiskManager(ServerLevel level) {
|
||||
ServerLevel overworld = level.getServer().overworld(); // Get the overworld
|
||||
|
||||
return world.getDataStorage().computeIfAbsent(tag -> {
|
||||
StorageDiskManager manager = new StorageDiskManager(world);
|
||||
return overworld.getDataStorage().computeIfAbsent(tag -> {
|
||||
StorageDiskManager manager = new StorageDiskManager(overworld);
|
||||
manager.load(tag);
|
||||
return manager;
|
||||
}, () -> new StorageDiskManager( world), StorageDiskManager.NAME);
|
||||
}, () -> new StorageDiskManager(overworld), StorageDiskManager.NAME);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -219,10 +219,10 @@ public class API implements IRSAPI {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IStorageTrackerManager getStorageTrackerManager(ServerLevel anyWorld) {
|
||||
ServerLevel world = anyWorld.getServer().overworld(); // Get the overworld
|
||||
public IStorageTrackerManager getStorageTrackerManager(ServerLevel level) {
|
||||
ServerLevel overworld = level.getServer().overworld(); // Get the overworld
|
||||
|
||||
return world.getDataStorage().computeIfAbsent(tag -> {
|
||||
return overworld.getDataStorage().computeIfAbsent(tag -> {
|
||||
StorageTrackerManager manager = new StorageTrackerManager();
|
||||
manager.load(tag);
|
||||
return manager;
|
||||
@@ -243,22 +243,22 @@ public class API implements IRSAPI {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IStorageDisk<ItemStack> createDefaultItemDisk(ServerLevel world, int capacity, @Nullable Player owner) {
|
||||
if (world == null) {
|
||||
public IStorageDisk<ItemStack> createDefaultItemDisk(ServerLevel level, int capacity, @Nullable Player owner) {
|
||||
if (level == null) {
|
||||
throw new IllegalArgumentException("World cannot be null");
|
||||
}
|
||||
|
||||
return new ItemStorageDisk(world, capacity, owner == null ? null : owner.getGameProfile().getId());
|
||||
return new ItemStorageDisk(level, capacity, owner == null ? null : owner.getGameProfile().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IStorageDisk<FluidStack> createDefaultFluidDisk(ServerLevel world, int capacity, @Nullable Player owner) {
|
||||
if (world == null) {
|
||||
public IStorageDisk<FluidStack> createDefaultFluidDisk(ServerLevel level, int capacity, @Nullable Player owner) {
|
||||
if (level == null) {
|
||||
throw new IllegalArgumentException("World cannot be null");
|
||||
}
|
||||
|
||||
return new FluidStorageDisk(world, capacity, owner == null ? null : owner.getGameProfile().getId());
|
||||
return new FluidStorageDisk(level, capacity, owner == null ? null : owner.getGameProfile().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -12,10 +12,10 @@ import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.calculator.CalculationResult;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
@@ -24,7 +24,7 @@ import java.util.*;
|
||||
public class CraftingPatternFactory {
|
||||
public static final CraftingPatternFactory INSTANCE = new CraftingPatternFactory();
|
||||
|
||||
public ICraftingPattern create(Level world, ICraftingPatternContainer container, ItemStack stack) {
|
||||
public ICraftingPattern create(Level level, ICraftingPatternContainer container, ItemStack stack) {
|
||||
CraftingPatternContext context = new CraftingPatternContext(container, stack);
|
||||
|
||||
boolean processing = PatternItem.isProcessing(stack);
|
||||
@@ -55,7 +55,7 @@ public class CraftingPatternFactory {
|
||||
fillCraftingInputs(inv, stack, inputs, i);
|
||||
}
|
||||
|
||||
Optional<CraftingRecipe> foundRecipe = world.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inv, world);
|
||||
Optional<CraftingRecipe> foundRecipe = level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inv, level);
|
||||
if (foundRecipe.isPresent()) {
|
||||
recipe = foundRecipe.get();
|
||||
|
||||
|
@@ -22,8 +22,8 @@ import com.refinedmods.refinedstorage.apiimpl.storage.disk.factory.FluidStorageD
|
||||
import com.refinedmods.refinedstorage.apiimpl.storage.disk.factory.ItemStorageDiskFactory;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -89,7 +89,7 @@ public class CraftingTask implements ICraftingTask, NodeListener {
|
||||
|
||||
this.requested = API.instance().createCraftingRequestInfo(tag.getCompound(NBT_REQUESTED));
|
||||
this.quantity = tag.getInt(NBT_QUANTITY);
|
||||
this.pattern = SerializationUtil.readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.getWorld());
|
||||
this.pattern = SerializationUtil.readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.getLevel());
|
||||
this.id = tag.getUUID(NBT_ID);
|
||||
this.nodes = new NodeList();
|
||||
|
||||
|
@@ -85,16 +85,16 @@ public class SerializationUtil {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static ICraftingPattern readPatternFromNbt(CompoundTag tag, Level world) throws CraftingTaskReadException {
|
||||
public static ICraftingPattern readPatternFromNbt(CompoundTag tag, Level level) throws CraftingTaskReadException {
|
||||
BlockPos containerPos = BlockPos.of(tag.getLong(NBT_PATTERN_CONTAINER_POS));
|
||||
|
||||
INetworkNode node = API.instance().getNetworkNodeManager((ServerLevel) world).getNode(containerPos);
|
||||
INetworkNode node = API.instance().getNetworkNodeManager((ServerLevel) level).getNode(containerPos);
|
||||
|
||||
if (node instanceof ICraftingPatternContainer) {
|
||||
ItemStack stack = ItemStack.of(tag.getCompound(NBT_PATTERN_STACK));
|
||||
|
||||
if (stack.getItem() instanceof ICraftingPatternProvider) {
|
||||
return ((ICraftingPatternProvider) stack.getItem()).create(world, stack, (ICraftingPatternContainer) node);
|
||||
return ((ICraftingPatternProvider) stack.getItem()).create(level, stack, (ICraftingPatternContainer) node);
|
||||
} else {
|
||||
throw new CraftingTaskReadException("Pattern stack is not a crafting pattern provider");
|
||||
}
|
||||
|
@@ -11,8 +11,8 @@ import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class CraftingNode extends Node {
|
||||
|
@@ -29,7 +29,7 @@ public abstract class Node {
|
||||
protected Node(INetwork network, CompoundTag tag) throws CraftingTaskReadException {
|
||||
this.quantity = tag.getInt(NBT_QUANTITY);
|
||||
this.totalQuantity = tag.getInt(NBT_QUANTITY_TOTAL);
|
||||
this.pattern = SerializationUtil.readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.getWorld());
|
||||
this.pattern = SerializationUtil.readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.getLevel());
|
||||
this.root = tag.getBoolean(NBT_ROOT);
|
||||
this.requirements.readFromNbt(tag);
|
||||
}
|
||||
|
@@ -12,8 +12,8 @@ import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.IoUtil;
|
||||
import com.refinedmods.refinedstorage.apiimpl.autocrafting.task.v6.SerializationUtil;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class ProcessingNode extends Node {
|
||||
|
@@ -74,7 +74,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
private final BaseEnergyStorage energy = new BaseEnergyStorage(RS.SERVER_CONFIG.getController().getCapacity(), RS.SERVER_CONFIG.getController().getMaxTransfer(), 0);
|
||||
private final RootNetworkNode root;
|
||||
private final BlockPos pos;
|
||||
private final Level world;
|
||||
private final Level level;
|
||||
private final NetworkType type;
|
||||
private ItemStorageTracker itemStorageTracker;
|
||||
private UUID itemStorageTrackerId;
|
||||
@@ -93,13 +93,13 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
private long[] tickTimes = new long[100];
|
||||
private int tickCounter = 0;
|
||||
|
||||
public Network(Level world, BlockPos pos, NetworkType type) {
|
||||
public Network(Level level, BlockPos pos, NetworkType type) {
|
||||
this.pos = pos;
|
||||
this.world = world;
|
||||
this.level = level;
|
||||
this.type = type;
|
||||
this.root = new RootNetworkNode(this, world, pos);
|
||||
this.root = new RootNetworkNode(this, level, pos);
|
||||
this.nodeGraph.addListener(() -> {
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
|
||||
if (tile instanceof ControllerTile) {
|
||||
((ControllerTile) tile).getDataManager().sendParameterToWatchers(ControllerTile.NODES);
|
||||
@@ -160,16 +160,16 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!world.isClientSide) {
|
||||
if (!level.isClientSide) {
|
||||
long tickStart = Util.getNanos();
|
||||
|
||||
if (ticks == 0) {
|
||||
redstonePowered = world.hasNeighborSignal(pos);
|
||||
redstonePowered = level.hasNeighborSignal(pos);
|
||||
}
|
||||
|
||||
++ticks;
|
||||
|
||||
amILoaded = world.isLoaded(pos);
|
||||
amILoaded = level.isLoaded(pos);
|
||||
|
||||
updateEnergyUsage();
|
||||
|
||||
@@ -203,7 +203,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
|
||||
LOGGER.debug("Network at position {} changed running state to {}, causing an invalidation of the node graph", pos, couldRun);
|
||||
|
||||
nodeGraph.invalidate(Action.PERFORM, world, pos);
|
||||
nodeGraph.invalidate(Action.PERFORM, level, pos);
|
||||
securityManager.invalidate();
|
||||
}
|
||||
} else {
|
||||
@@ -215,9 +215,9 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
if (lastEnergyType != energyType) {
|
||||
lastEnergyType = energyType;
|
||||
|
||||
BlockState state = world.getBlockState(pos);
|
||||
BlockState state = level.getBlockState(pos);
|
||||
if (state.getBlock() instanceof ControllerBlock) {
|
||||
world.setBlockAndUpdate(pos, state.setValue(ControllerBlock.ENERGY_TYPE, energyType));
|
||||
level.setBlockAndUpdate(pos, state.setValue(ControllerBlock.ENERGY_TYPE, energyType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,8 +248,8 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
}
|
||||
|
||||
nodeGraph.disconnectAll();
|
||||
API.instance().getStorageTrackerManager((ServerLevel) getWorld()).remove(itemStorageTrackerId);
|
||||
API.instance().getStorageTrackerManager((ServerLevel) getWorld()).remove(fluidStorageTrackerId);
|
||||
API.instance().getStorageTrackerManager((ServerLevel) getLevel()).remove(itemStorageTrackerId);
|
||||
API.instance().getStorageTrackerManager((ServerLevel) getLevel()).remove(fluidStorageTrackerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -483,7 +483,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
this.itemStorageTrackerId = UUID.randomUUID();
|
||||
}
|
||||
|
||||
this.itemStorageTracker = (ItemStorageTracker) API.instance().getStorageTrackerManager((ServerLevel) world).getOrCreate(itemStorageTrackerId, StorageType.ITEM);
|
||||
this.itemStorageTracker = (ItemStorageTracker) API.instance().getStorageTrackerManager((ServerLevel) level).getOrCreate(itemStorageTrackerId, StorageType.ITEM);
|
||||
}
|
||||
|
||||
return itemStorageTracker;
|
||||
@@ -496,15 +496,15 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
this.fluidStorageTrackerId = UUID.randomUUID();
|
||||
}
|
||||
|
||||
this.fluidStorageTracker = (FluidStorageTracker) API.instance().getStorageTrackerManager((ServerLevel) world).getOrCreate(fluidStorageTrackerId, StorageType.FLUID);
|
||||
this.fluidStorageTracker = (FluidStorageTracker) API.instance().getStorageTrackerManager((ServerLevel) level).getOrCreate(fluidStorageTrackerId, StorageType.FLUID);
|
||||
}
|
||||
|
||||
return fluidStorageTracker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Level getWorld() {
|
||||
return world;
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -553,7 +553,7 @@ public class Network implements INetwork, IRedstoneConfigurable {
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
API.instance().getNetworkManager((ServerLevel) world).markForSaving();
|
||||
API.instance().getNetworkManager((ServerLevel) level).markForSaving();
|
||||
}
|
||||
|
||||
public ControllerBlock.EnergyType getEnergyType() {
|
||||
|
@@ -24,14 +24,14 @@ public class NetworkManager extends RSWorldSavedData implements INetworkManager
|
||||
private static final String NBT_DATA = "Data";
|
||||
private static final String NBT_POS = "Pos";
|
||||
|
||||
private final Level world;
|
||||
private final Level level;
|
||||
|
||||
private final Logger logger = LogManager.getLogger(getClass());
|
||||
|
||||
private final ConcurrentHashMap<BlockPos, INetwork> networks = new ConcurrentHashMap<>();
|
||||
|
||||
public NetworkManager(Level world) {
|
||||
this.world = world;
|
||||
public NetworkManager(Level level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +48,7 @@ public class NetworkManager extends RSWorldSavedData implements INetworkManager
|
||||
BlockPos pos = BlockPos.of(networkTag.getLong(NBT_POS));
|
||||
int type = networkTag.getInt(NBT_TYPE);
|
||||
|
||||
INetwork network = new Network(world, pos, NetworkType.values()[type]);
|
||||
INetwork network = new Network(level, pos, NetworkType.values()[type]);
|
||||
|
||||
try {
|
||||
network = network.readFromNbt(data);
|
||||
|
@@ -27,12 +27,12 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(Action action, Level world, BlockPos origin) {
|
||||
public void invalidate(Action action, Level level, BlockPos origin) {
|
||||
this.invalidating = true;
|
||||
|
||||
Operator operator = new Operator(action);
|
||||
|
||||
INetworkNode originNode = NetworkUtils.getNodeFromTile(world.getBlockEntity(origin));
|
||||
INetworkNode originNode = NetworkUtils.getNodeFromTile(level.getBlockEntity(origin));
|
||||
if (originNode instanceof INetworkNodeVisitor) {
|
||||
((INetworkNodeVisitor) originNode).visit(operator);
|
||||
}
|
||||
@@ -92,19 +92,19 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
}
|
||||
|
||||
protected Level getWorld() {
|
||||
return network.getWorld();
|
||||
return network.getLevel();
|
||||
}
|
||||
|
||||
private static class Visitor implements INetworkNodeVisitor {
|
||||
private final INetworkNode node;
|
||||
private final Level world;
|
||||
private final Level level;
|
||||
private final BlockPos pos;
|
||||
private final Direction side;
|
||||
private final BlockEntity tile;
|
||||
|
||||
Visitor(INetworkNode node, Level world, BlockPos pos, Direction side, BlockEntity tile) {
|
||||
Visitor(INetworkNode node, Level level, BlockPos pos, Direction side, BlockEntity tile) {
|
||||
this.node = node;
|
||||
this.world = world;
|
||||
this.level = level;
|
||||
this.pos = pos;
|
||||
this.side = side;
|
||||
this.tile = tile;
|
||||
@@ -120,7 +120,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
INetworkNode nodeOnSide = NetworkUtils.getNodeFromTile(tile);
|
||||
|
||||
if (nodeOnSide == node) {
|
||||
operator.apply(world, pos.relative(checkSide), checkSide.getOpposite());
|
||||
operator.apply(level, pos.relative(checkSide), checkSide.getOpposite());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,8 +143,8 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Level world, BlockPos pos, @Nullable Direction side) {
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
public void apply(Level level, BlockPos pos, @Nullable Direction side) {
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
|
||||
INetworkNode otherNode = NetworkUtils.getNodeFromTile(tile);
|
||||
if (otherNode != null) {
|
||||
@@ -152,7 +152,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
|
||||
if (otherNode.getNetwork() != null && !otherNode.getNetwork().equals(network)) {
|
||||
if (action == Action.PERFORM) {
|
||||
dropConflictingBlock(world, pos);
|
||||
dropConflictingBlock(level, pos);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -168,16 +168,15 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
|
||||
previousEntries.remove(otherNodeItem);
|
||||
|
||||
toCheck.add(new Visitor(otherNode, world, pos, side, tile));
|
||||
toCheck.add(new Visitor(otherNode, level, pos, side, tile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dropConflictingBlock(Level world, BlockPos pos) {
|
||||
private void dropConflictingBlock(Level level, BlockPos pos) {
|
||||
if (!network.getPosition().equals(pos)) {
|
||||
Block.dropResources(world.getBlockState(pos), world, pos, world.getBlockEntity(pos));
|
||||
|
||||
world.removeBlock(pos, false);
|
||||
Block.dropResources(level.getBlockState(pos), level, pos, level.getBlockEntity(pos));
|
||||
level.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ public class NetworkNodeGraphEntry implements INetworkNodeGraphEntry {
|
||||
|
||||
NetworkNodeGraphEntry otherItem = (NetworkNodeGraphEntry) other;
|
||||
|
||||
if (node.getWorld().dimension() != otherItem.node.getWorld().dimension()) {
|
||||
if (node.getLevel().dimension() != otherItem.node.getLevel().dimension()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class NetworkNodeGraphEntry implements INetworkNodeGraphEntry {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = node.getPos().hashCode();
|
||||
result = 31 * result + node.getWorld().dimension().hashCode();
|
||||
result = 31 * result + node.getLevel().dimension().hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ public class NetworkNodeListener {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(world.getBlockEntity(pos.relative(facing)));
|
||||
|
||||
if (node != null && node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().getWorld(), node.getNetwork().getPosition());
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().getLevel(), node.getNetwork().getPosition());
|
||||
|
||||
return;
|
||||
}
|
||||
|
@@ -8,9 +8,9 @@ import com.refinedmods.refinedstorage.apiimpl.util.RSWorldSavedData;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -26,14 +26,14 @@ public class NetworkNodeManager extends RSWorldSavedData implements INetworkNode
|
||||
private static final String NBT_NODE_DATA = "Data";
|
||||
private static final String NBT_NODE_POS = "Pos";
|
||||
|
||||
private final Level world;
|
||||
private final Level level;
|
||||
|
||||
private final Logger logger = LogManager.getLogger(getClass());
|
||||
|
||||
private final ConcurrentHashMap<BlockPos, INetworkNode> nodes = new ConcurrentHashMap<>();
|
||||
|
||||
public NetworkNodeManager(Level world) {
|
||||
this.world = world;
|
||||
public NetworkNodeManager(Level level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,7 +56,7 @@ public class NetworkNodeManager extends RSWorldSavedData implements INetworkNode
|
||||
INetworkNode node = null;
|
||||
|
||||
try {
|
||||
node = factory.create(data, world, pos);
|
||||
node = factory.create(data, level, pos);
|
||||
} catch (Throwable t) {
|
||||
logger.error("Could not read network node", t);
|
||||
}
|
||||
|
@@ -287,7 +287,7 @@ public class CraftingGridBehavior implements ICraftingGridBehavior {
|
||||
ItemStack inventoryStack = player.getInventory().getItem(j);
|
||||
|
||||
if (inventoryStack.getItem() instanceof ICraftingPatternProvider) {
|
||||
ICraftingPattern pattern = PatternItem.fromCache(network.getWorld(), inventoryStack);
|
||||
ICraftingPattern pattern = PatternItem.fromCache(network.getLevel(), inventoryStack);
|
||||
if (pattern.isValid()) {
|
||||
for (ItemStack stack : pattern.getOutputs()) {
|
||||
if (!stack.isEmpty()) {
|
||||
|
@@ -38,8 +38,8 @@ public class GridBlockGridFactory implements IGridFactory {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity getRelevantTile(Level world, BlockPos pos) {
|
||||
return world.getBlockEntity(pos);
|
||||
public BlockEntity getRelevantTile(Level level, BlockPos pos) {
|
||||
return level.getBlockEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -38,8 +38,8 @@ public class PortableGridBlockGridFactory implements IGridFactory {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity getRelevantTile(Level world, BlockPos pos) {
|
||||
return world.getBlockEntity(pos);
|
||||
public BlockEntity getRelevantTile(Level level, BlockPos pos) {
|
||||
return level.getBlockEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -36,7 +36,7 @@ public class PortableGridGridFactory implements IGridFactory {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity getRelevantTile(Level world, BlockPos pos) {
|
||||
public BlockEntity getRelevantTile(Level level, BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ public class WirelessFluidGridGridFactory implements IGridFactory {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity getRelevantTile(Level world, BlockPos pos) {
|
||||
public BlockEntity getRelevantTile(Level level, BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ public class WirelessGridGridFactory implements IGridFactory {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity getRelevantTile(Level world, BlockPos pos) {
|
||||
public BlockEntity getRelevantTile(Level level, BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -15,8 +15,8 @@ public class CableNetworkNode extends NetworkNode implements ICoverable {
|
||||
|
||||
private final CoverManager coverManager;
|
||||
|
||||
public CableNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public CableNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
this.coverManager = new CoverManager(this);
|
||||
}
|
||||
|
||||
|
@@ -66,8 +66,8 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
private int type = IType.ITEMS;
|
||||
private boolean drop = false;
|
||||
|
||||
public ConstructorNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public ConstructorNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
this.coverManager = new CoverManager(this);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (canUpdate() && ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0 && world.isLoaded(pos)) {
|
||||
if (canUpdate() && ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0 && level.isLoaded(pos)) {
|
||||
if (type == IType.ITEMS && !itemFilters.getStackInSlot(0).isEmpty()) {
|
||||
ItemStack stack = itemFilters.getStackInSlot(0);
|
||||
|
||||
@@ -104,8 +104,8 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
if (upgrades.hasUpgrade(UpgradeItem.Type.CRAFTING)) {
|
||||
network.getCraftingManager().request(this, stack, FluidAttributes.BUCKET_VOLUME);
|
||||
}
|
||||
} else if (!world.getBlockState(front).getFluidState().isSource()) {
|
||||
FluidUtil.tryPlaceFluid(WorldUtils.getFakePlayer((ServerLevel) world, getOwner()), world, InteractionHand.MAIN_HAND, front, new NetworkFluidHandler(StackUtils.copy(stack, FluidAttributes.BUCKET_VOLUME)), stack);
|
||||
} else if (!level.getBlockState(front).getFluidState().isSource()) {
|
||||
FluidUtil.tryPlaceFluid(WorldUtils.getFakePlayer((ServerLevel) level, getOwner()), level, InteractionHand.MAIN_HAND, front, new NetworkFluidHandler(StackUtils.copy(stack, FluidAttributes.BUCKET_VOLUME)), stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,8 +113,8 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
ItemStack took = network.extractItem(stack, 1, compare, Action.SIMULATE);
|
||||
if (!took.isEmpty()) {
|
||||
BlockPlaceContext ctx = new ConstructorBlockItemUseContext(
|
||||
world,
|
||||
WorldUtils.getFakePlayer((ServerLevel) world, getOwner()),
|
||||
level,
|
||||
WorldUtils.getFakePlayer((ServerLevel) level, getOwner()),
|
||||
InteractionHand.MAIN_HAND,
|
||||
took,
|
||||
new BlockHitResult(Vec3.ZERO, getDirection(), pos, false)
|
||||
@@ -135,7 +135,7 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
ItemStack took = network.extractItem(stack, upgrades.getStackInteractCount(), compare, Action.PERFORM);
|
||||
|
||||
if (!took.isEmpty()) {
|
||||
DefaultDispenseItemBehavior.spawnItem(world, took, 6, getDirection(), new PositionImpl(getDispensePositionX(), getDispensePositionY(), getDispensePositionZ()));
|
||||
DefaultDispenseItemBehavior.spawnItem(level, took, 6, getDirection(), new PositionImpl(getDispensePositionX(), getDispensePositionY(), getDispensePositionZ()));
|
||||
} else if (upgrades.hasUpgrade(UpgradeItem.Type.CRAFTING)) {
|
||||
network.getCraftingManager().request(this, stack, 1);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
ItemStack took = network.extractItem(stack, 1, compare, Action.PERFORM);
|
||||
|
||||
if (!took.isEmpty()) {
|
||||
world.addFreshEntity(new FireworkRocketEntity(world, getDispensePositionX(), getDispensePositionY(), getDispensePositionZ(), took));
|
||||
level.addFreshEntity(new FireworkRocketEntity(level, getDispensePositionX(), getDispensePositionY(), getDispensePositionZ(), took));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isClientSide ? ConstructorTile.TYPE.getValue() : type;
|
||||
return level.isClientSide ? ConstructorTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -283,8 +283,8 @@ public class ConstructorNetworkNode extends NetworkNode implements IComparable,
|
||||
}
|
||||
|
||||
private static class ConstructorBlockItemUseContext extends BlockPlaceContext {
|
||||
public ConstructorBlockItemUseContext(Level world, @Nullable Player player, InteractionHand hand, ItemStack stack, BlockHitResult rayTraceResult) {
|
||||
super(world, player, hand, stack, rayTraceResult);
|
||||
public ConstructorBlockItemUseContext(Level level, @Nullable Player player, InteractionHand hand, ItemStack stack, BlockHitResult rayTraceResult) {
|
||||
super(level, player, hand, stack, rayTraceResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,8 +20,8 @@ public class CrafterManagerNetworkNode extends NetworkNode {
|
||||
private int size = IGrid.SIZE_STRETCH;
|
||||
private int searchBoxMode = IGrid.SEARCH_BOX_MODE_NORMAL;
|
||||
|
||||
public CrafterManagerNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public CrafterManagerNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,7 +35,7 @@ public class CrafterManagerNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return world.isClientSide ? CrafterManagerTile.SIZE.getValue() : size;
|
||||
return level.isClientSide ? CrafterManagerTile.SIZE.getValue() : size;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
@@ -66,7 +66,7 @@ public class CrafterManagerNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
public int getSearchBoxMode() {
|
||||
return world.isClientSide ? CrafterManagerTile.SEARCH_BOX_MODE.getValue() : searchBoxMode;
|
||||
return level.isClientSide ? CrafterManagerTile.SEARCH_BOX_MODE.getValue() : searchBoxMode;
|
||||
}
|
||||
|
||||
public void setSearchBoxMode(int searchBoxMode) {
|
||||
@@ -74,7 +74,7 @@ public class CrafterManagerNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
public boolean isActiveOnClient() {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
BlockState state = level.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof CrafterManagerBlock) {
|
||||
return state.getValue(NetworkNodeBlock.CONNECTED);
|
||||
|
@@ -48,7 +48,9 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
private static final String NBT_WAS_POWERED = "WasPowered";
|
||||
private final List<ICraftingPattern> patterns = new ArrayList<>();
|
||||
private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.SPEED)
|
||||
.addListener(new NetworkNodeInventoryListener(this)); private final BaseItemHandler patternsInventory = new BaseItemHandler(9) {
|
||||
.addListener(new NetworkNodeInventoryListener(this));
|
||||
// Used to prevent infinite recursion on getRootContainer() when there's e.g. two crafters facing each other.
|
||||
private boolean visited = false; private final BaseItemHandler patternsInventory = new BaseItemHandler(9) {
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return 1;
|
||||
@@ -64,11 +66,11 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
return super.insertItem(slot, stack, simulate);
|
||||
}
|
||||
}
|
||||
.addValidator(new PatternItemValidator(world))
|
||||
.addValidator(new PatternItemValidator(level))
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!reading) {
|
||||
if (!world.isClientSide) {
|
||||
if (!level.isClientSide) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@@ -77,8 +79,6 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
}
|
||||
}
|
||||
});
|
||||
// Used to prevent infinite recursion on getRootContainer() when there's e.g. two crafters facing each other.
|
||||
private boolean visited = false;
|
||||
private CrafterMode mode = CrafterMode.IGNORE;
|
||||
private boolean locked = false;
|
||||
private boolean wasPowered;
|
||||
@@ -86,9 +86,8 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
private Component displayName;
|
||||
@Nullable
|
||||
private UUID uuid = null;
|
||||
|
||||
public CrafterNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public CrafterNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
private void invalidate() {
|
||||
@@ -98,7 +97,7 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
ItemStack patternStack = patternsInventory.getStackInSlot(i);
|
||||
|
||||
if (!patternStack.isEmpty()) {
|
||||
ICraftingPattern pattern = ((ICraftingPatternProvider) patternStack.getItem()).create(world, patternStack, this);
|
||||
ICraftingPattern pattern = ((ICraftingPatternProvider) patternStack.getItem()).create(level, patternStack, this);
|
||||
|
||||
if (pattern.isValid()) {
|
||||
patterns.add(pattern);
|
||||
@@ -120,8 +119,8 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
invalidate();
|
||||
}
|
||||
|
||||
if (mode == CrafterMode.PULSE_INSERTS_NEXT_SET && world.isLoaded(pos)) {
|
||||
if (world.hasNeighborSignal(pos)) {
|
||||
if (mode == CrafterMode.PULSE_INSERTS_NEXT_SET && level.isLoaded(pos)) {
|
||||
if (level.hasNeighborSignal(pos)) {
|
||||
this.wasPowered = true;
|
||||
|
||||
markDirty();
|
||||
@@ -290,11 +289,11 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
@Override
|
||||
public BlockEntity getFacingTile() {
|
||||
BlockPos facingPos = pos.relative(getDirection());
|
||||
if (!world.isLoaded(facingPos)) {
|
||||
if (!level.isLoaded(facingPos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return world.getBlockEntity(facingPos);
|
||||
return level.getBlockEntity(facingPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -321,7 +320,7 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
}
|
||||
|
||||
if (facing != null) {
|
||||
return new TranslatableComponent(world.getBlockState(facing.getBlockPos()).getBlock().getDescriptionId());
|
||||
return new TranslatableComponent(level.getBlockState(facing.getBlockPos()).getBlock().getDescriptionId());
|
||||
}
|
||||
|
||||
return DEFAULT_NAME;
|
||||
@@ -369,7 +368,7 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
return null;
|
||||
}
|
||||
|
||||
INetworkNode facing = API.instance().getNetworkNodeManager((ServerLevel) world).getNode(pos.relative(getDirection()));
|
||||
INetworkNode facing = API.instance().getNetworkNodeManager((ServerLevel) level).getNode(pos.relative(getDirection()));
|
||||
if (!(facing instanceof ICraftingPatternContainer) || facing.getNetwork() != network) {
|
||||
return this;
|
||||
}
|
||||
@@ -413,9 +412,9 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
case IGNORE:
|
||||
return false;
|
||||
case SIGNAL_LOCKS_AUTOCRAFTING:
|
||||
return world.hasNeighborSignal(pos);
|
||||
return level.hasNeighborSignal(pos);
|
||||
case SIGNAL_UNLOCKS_AUTOCRAFTING:
|
||||
return !world.hasNeighborSignal(pos);
|
||||
return !level.hasNeighborSignal(pos);
|
||||
case PULSE_INSERTS_NEXT_SET:
|
||||
return locked;
|
||||
default:
|
||||
@@ -461,4 +460,5 @@ public class CrafterNetworkNode extends NetworkNode implements ICraftingPatternC
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -35,8 +35,8 @@ public class CraftingMonitorNetworkNode extends NetworkNode implements ICrafting
|
||||
private Optional<UUID> tabSelected = Optional.empty();
|
||||
private int tabPage;
|
||||
|
||||
public CraftingMonitorNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public CraftingMonitorNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +79,7 @@ public class CraftingMonitorNetworkNode extends NetworkNode implements ICrafting
|
||||
|
||||
@Override
|
||||
public boolean isActiveOnClient() {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
BlockState state = level.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof CraftingMonitorBlock) {
|
||||
return state.getValue(NetworkNodeBlock.CONNECTED);
|
||||
@@ -119,7 +119,7 @@ public class CraftingMonitorNetworkNode extends NetworkNode implements ICrafting
|
||||
|
||||
@Override
|
||||
public Optional<UUID> getTabSelected() {
|
||||
return world.isClientSide ? CraftingMonitorTile.TAB_SELECTED.getValue() : tabSelected;
|
||||
return level.isClientSide ? CraftingMonitorTile.TAB_SELECTED.getValue() : tabSelected;
|
||||
}
|
||||
|
||||
public void setTabSelected(Optional<UUID> tabSelected) {
|
||||
@@ -128,7 +128,7 @@ public class CraftingMonitorNetworkNode extends NetworkNode implements ICrafting
|
||||
|
||||
@Override
|
||||
public int getTabPage() {
|
||||
return world.isClientSide ? CraftingMonitorTile.TAB_PAGE.getValue() : tabPage;
|
||||
return level.isClientSide ? CraftingMonitorTile.TAB_PAGE.getValue() : tabPage;
|
||||
}
|
||||
|
||||
public void setTabPage(int tabPage) {
|
||||
|
@@ -61,21 +61,17 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
private final BaseItemHandler itemFilters = new BaseItemHandler(9).addListener(new NetworkNodeInventoryListener(this));
|
||||
private final FluidInventory fluidFilters = new FluidInventory(9).addListener(new NetworkNodeFluidInventoryListener(this));
|
||||
private final CoverManager coverManager;
|
||||
private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.SPEED, UpgradeItem.Type.SILK_TOUCH, UpgradeItem.Type.FORTUNE_1, UpgradeItem.Type.FORTUNE_2, UpgradeItem.Type.FORTUNE_3)
|
||||
private int compare = IComparer.COMPARE_NBT; private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.SPEED, UpgradeItem.Type.SILK_TOUCH, UpgradeItem.Type.FORTUNE_1, UpgradeItem.Type.FORTUNE_2, UpgradeItem.Type.FORTUNE_3)
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> tool = createTool());
|
||||
private int compare = IComparer.COMPARE_NBT;
|
||||
private int mode = IWhitelistBlacklist.BLACKLIST;
|
||||
private int type = IType.ITEMS;
|
||||
private boolean pickupItem = false;
|
||||
|
||||
public DestructorNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public DestructorNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
this.coverManager = new CoverManager(this);
|
||||
}
|
||||
|
||||
private ItemStack tool = createTool();
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return RS.SERVER_CONFIG.getDestructor().getUsage() + upgrades.getEnergyUsage();
|
||||
@@ -85,7 +81,7 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (canUpdate() && ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0 && world.isLoaded(pos)) {
|
||||
if (canUpdate() && ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0 && level.isLoaded(pos)) {
|
||||
if (type == IType.ITEMS) {
|
||||
if (pickupItem) {
|
||||
pickupItems();
|
||||
@@ -96,12 +92,12 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
breakFluid();
|
||||
}
|
||||
}
|
||||
}
|
||||
} private ItemStack tool = createTool();
|
||||
|
||||
private void pickupItems() {
|
||||
BlockPos front = pos.relative(getDirection());
|
||||
|
||||
List<ItemEntity> droppedItems = world.getEntitiesOfClass(ItemEntity.class, new AABB(front));
|
||||
List<ItemEntity> droppedItems = level.getEntitiesOfClass(ItemEntity.class, new AABB(front));
|
||||
|
||||
for (ItemEntity entity : droppedItems) {
|
||||
ItemStack droppedItem = ((ItemEntity) entity).getItem();
|
||||
@@ -119,25 +115,25 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
|
||||
private void breakBlock() {
|
||||
BlockPos front = pos.relative(getDirection());
|
||||
BlockState frontBlockState = world.getBlockState(front);
|
||||
BlockState frontBlockState = level.getBlockState(front);
|
||||
Block frontBlock = frontBlockState.getBlock();
|
||||
ItemStack frontStack = frontBlock.getCloneItemStack(
|
||||
frontBlockState,
|
||||
new BlockHitResult(Vec3.ZERO, getDirection().getOpposite(), front, false),
|
||||
world,
|
||||
level,
|
||||
front,
|
||||
WorldUtils.getFakePlayer((ServerLevel) world, getOwner())
|
||||
WorldUtils.getFakePlayer((ServerLevel) level, getOwner())
|
||||
);
|
||||
|
||||
if (!frontStack.isEmpty() &&
|
||||
IWhitelistBlacklist.acceptsItem(itemFilters, mode, compare, frontStack) &&
|
||||
frontBlockState.getDestroySpeed(world, front) != -1.0) {
|
||||
frontBlockState.getDestroySpeed(level, front) != -1.0) {
|
||||
List<ItemStack> drops = Block.getDrops(
|
||||
frontBlockState,
|
||||
(ServerLevel) world,
|
||||
(ServerLevel) level,
|
||||
front,
|
||||
world.getBlockEntity(front),
|
||||
WorldUtils.getFakePlayer((ServerLevel) world, getOwner()),
|
||||
level.getBlockEntity(front),
|
||||
WorldUtils.getFakePlayer((ServerLevel) level, getOwner()),
|
||||
tool
|
||||
);
|
||||
|
||||
@@ -147,18 +143,18 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
}
|
||||
}
|
||||
|
||||
BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(world, front, frontBlockState, WorldUtils.getFakePlayer((ServerLevel) world, getOwner()));
|
||||
BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(level, front, frontBlockState, WorldUtils.getFakePlayer((ServerLevel) level, getOwner()));
|
||||
|
||||
if (!MinecraftForge.EVENT_BUS.post(e)) {
|
||||
frontBlock.playerWillDestroy(world, front, frontBlockState, WorldUtils.getFakePlayer((ServerLevel) world, getOwner()));
|
||||
frontBlock.playerWillDestroy(level, front, frontBlockState, WorldUtils.getFakePlayer((ServerLevel) level, getOwner()));
|
||||
|
||||
world.removeBlock(front, false);
|
||||
level.removeBlock(front, false);
|
||||
|
||||
for (ItemStack drop : drops) {
|
||||
// We check if the controller isn't null here because when a destructor faces a node and removes it
|
||||
// it will essentially remove this block itself from the network without knowing
|
||||
if (network == null) {
|
||||
Containers.dropItemStack(world, front.getX(), front.getY(), front.getZ(), drop);
|
||||
Containers.dropItemStack(level, front.getX(), front.getY(), front.getZ(), drop);
|
||||
} else {
|
||||
network.insertItemTracked(drop, drop.getCount());
|
||||
}
|
||||
@@ -169,7 +165,7 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
|
||||
private void breakFluid() {
|
||||
BlockPos front = pos.relative(getDirection());
|
||||
BlockState frontBlockState = world.getBlockState(front);
|
||||
BlockState frontBlockState = level.getBlockState(front);
|
||||
Block frontBlock = frontBlockState.getBlock();
|
||||
|
||||
if (frontBlock instanceof LiquidBlock) {
|
||||
@@ -183,18 +179,18 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
network.insertFluid(stack, stack.getAmount(), Action.SIMULATE).isEmpty()) {
|
||||
network.insertFluidTracked(stack, stack.getAmount());
|
||||
|
||||
world.setBlock(front, Blocks.AIR.defaultBlockState(), 11);
|
||||
level.setBlock(front, Blocks.AIR.defaultBlockState(), 11);
|
||||
}
|
||||
}
|
||||
} else if (frontBlock instanceof IFluidBlock) {
|
||||
IFluidBlock fluidBlock = (IFluidBlock) frontBlock;
|
||||
|
||||
if (fluidBlock.canDrain(world, front)) {
|
||||
FluidStack simulatedDrain = fluidBlock.drain(world, front, IFluidHandler.FluidAction.SIMULATE);
|
||||
if (fluidBlock.canDrain(level, front)) {
|
||||
FluidStack simulatedDrain = fluidBlock.drain(level, front, IFluidHandler.FluidAction.SIMULATE);
|
||||
|
||||
if (IWhitelistBlacklist.acceptsFluid(fluidFilters, mode, compare, simulatedDrain) &&
|
||||
network.insertFluid(simulatedDrain, simulatedDrain.getAmount(), Action.SIMULATE).isEmpty()) {
|
||||
FluidStack drained = fluidBlock.drain(world, front, IFluidHandler.FluidAction.EXECUTE);
|
||||
FluidStack drained = fluidBlock.drain(level, front, IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
network.insertFluidTracked(drained, drained.getAmount());
|
||||
}
|
||||
@@ -323,7 +319,7 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isClientSide ? DestructorTile.TYPE.getValue() : type;
|
||||
return level.isClientSide ? DestructorTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -357,4 +353,8 @@ public class DestructorNetworkNode extends NetworkNode implements IComparable, I
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -46,8 +46,8 @@ public class DetectorNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
private boolean powered = false;
|
||||
private boolean wasPowered;
|
||||
|
||||
public DetectorNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public DetectorNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,11 +59,11 @@ public class DetectorNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (powered != wasPowered && world.isLoaded(pos)) {
|
||||
if (powered != wasPowered && level.isLoaded(pos)) {
|
||||
wasPowered = powered;
|
||||
|
||||
world.setBlockAndUpdate(pos, world.getBlockState(pos).setValue(DetectorBlock.POWERED, powered));
|
||||
world.updateNeighborsAt(pos, world.getBlockState(pos).getBlock());
|
||||
level.setBlockAndUpdate(pos, level.getBlockState(pos).setValue(DetectorBlock.POWERED, powered));
|
||||
level.updateNeighborsAt(pos, level.getBlockState(pos).getBlock());
|
||||
}
|
||||
|
||||
if (canUpdate() && ticks % SPEED == 0) {
|
||||
@@ -212,7 +212,7 @@ public class DetectorNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isClientSide ? DetectorTile.TYPE.getValue() : type;
|
||||
return level.isClientSide ? DetectorTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -38,7 +38,8 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
|
||||
private final BaseItemHandler itemFilters = new BaseItemHandler(9).addListener(new NetworkNodeInventoryListener(this));
|
||||
private final FluidInventory fluidFilters = new FluidInventory(9).addListener(new NetworkNodeFluidInventoryListener(this));
|
||||
private final CoverManager coverManager; private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.SPEED, UpgradeItem.Type.CRAFTING, UpgradeItem.Type.STACK, UpgradeItem.Type.REGULATOR)
|
||||
private final CoverManager coverManager;
|
||||
private int compare = IComparer.COMPARE_NBT; private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.SPEED, UpgradeItem.Type.CRAFTING, UpgradeItem.Type.STACK, UpgradeItem.Type.REGULATOR)
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!reading && !getUpgrades().hasUpgrade(UpgradeItem.Type.REGULATOR)) {
|
||||
@@ -67,13 +68,11 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
}
|
||||
}
|
||||
});
|
||||
private int compare = IComparer.COMPARE_NBT;
|
||||
private int type = IType.ITEMS;
|
||||
|
||||
private int filterSlot;
|
||||
|
||||
public ExporterNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public ExporterNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
this.coverManager = new CoverManager(this);
|
||||
}
|
||||
|
||||
@@ -86,7 +85,7 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (canUpdate() && ticks % upgrades.getSpeed() == 0 && world.isLoaded(pos)) {
|
||||
if (canUpdate() && ticks % upgrades.getSpeed() == 0 && level.isLoaded(pos)) {
|
||||
if (type == IType.ITEMS) {
|
||||
IItemHandler handler = WorldUtils.getItemHandler(getFacingTile(), getDirection().getOpposite());
|
||||
|
||||
@@ -307,7 +306,7 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isClientSide ? ExporterTile.TYPE.getValue() : type;
|
||||
return level.isClientSide ? ExporterTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -333,4 +332,6 @@ public class ExporterNetworkNode extends NetworkNode implements IComparable, ITy
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -64,8 +64,8 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
||||
private AccessType accessType = AccessType.INSERT_EXTRACT;
|
||||
private int networkTicks;
|
||||
|
||||
public ExternalStorageNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public ExternalStorageNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
this.coverManager = new CoverManager(this);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (canUpdate() && world.isLoaded(pos)) {
|
||||
if (canUpdate() && level.isLoaded(pos)) {
|
||||
if (networkTicks++ == 0) {
|
||||
updateStorage(network, InvalidateCause.INITIAL_TICK_INVALIDATION);
|
||||
|
||||
@@ -290,7 +290,7 @@ public class ExternalStorageNetworkNode extends NetworkNode implements IStorageP
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isClientSide ? ExternalStorageTile.TYPE.getValue() : type;
|
||||
return level.isClientSide ? ExternalStorageTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -45,8 +45,8 @@ public class FluidInterfaceNetworkNode extends NetworkNode {
|
||||
protected void onContentsChanged() {
|
||||
super.onContentsChanged();
|
||||
|
||||
if (!world.isClientSide) {
|
||||
((FluidInterfaceTile) world.getBlockEntity(pos)).getDataManager().sendParameterToWatchers(FluidInterfaceTile.TANK_IN);
|
||||
if (!level.isClientSide) {
|
||||
((FluidInterfaceTile) level.getBlockEntity(pos)).getDataManager().sendParameterToWatchers(FluidInterfaceTile.TANK_IN);
|
||||
}
|
||||
|
||||
markDirty();
|
||||
@@ -61,8 +61,8 @@ public class FluidInterfaceNetworkNode extends NetworkNode {
|
||||
|
||||
private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.SPEED, UpgradeItem.Type.STACK, UpgradeItem.Type.CRAFTING).addListener(new NetworkNodeInventoryListener(this));
|
||||
|
||||
public FluidInterfaceNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public FluidInterfaceNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,7 +155,7 @@ public class FluidInterfaceNetworkNode extends NetworkNode {
|
||||
|
||||
private boolean isActingAsStorage() {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerLevel) world).getNode(pos.relative(facing));
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerLevel) level).getNode(pos.relative(facing));
|
||||
|
||||
if (facingNode instanceof ExternalStorageNetworkNode &&
|
||||
facingNode.isActive() &&
|
||||
@@ -250,8 +250,8 @@ public class FluidInterfaceNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
private void onTankOutChanged() {
|
||||
if (!world.isClientSide && world.isLoaded(pos)) {
|
||||
((FluidInterfaceTile) world.getBlockEntity(pos)).getDataManager().sendParameterToWatchers(FluidInterfaceTile.TANK_OUT);
|
||||
if (!level.isClientSide && level.isLoaded(pos)) {
|
||||
((FluidInterfaceTile) level.getBlockEntity(pos)).getDataManager().sendParameterToWatchers(FluidInterfaceTile.TANK_OUT);
|
||||
}
|
||||
|
||||
markDirty();
|
||||
|
@@ -80,7 +80,14 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
private static final String NBT_PROCESSING_MATRIX_FLUIDS = "ProcessingMatrixFluids";
|
||||
private static final String NBT_ALLOWED_TAGS = "AllowedTags";
|
||||
private final AllowedTagList allowedTagList = new AllowedTagList(this::updateAllowedTags, PROCESSING_MATRIX_SIZE);
|
||||
private final ResultContainer result = new ResultContainer(); private final AbstractContainerMenu craftingContainer = new AbstractContainerMenu(MenuType.CRAFTING, 0) {
|
||||
private final ResultContainer result = new ResultContainer();
|
||||
private final BaseItemHandler processingMatrix = new BaseItemHandler(PROCESSING_MATRIX_SIZE * 2)
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!reading && slot < PROCESSING_MATRIX_SIZE) {
|
||||
allowedTagList.clearItemTags(slot);
|
||||
}
|
||||
}); private final AbstractContainerMenu craftingContainer = new AbstractContainerMenu(MenuType.CRAFTING, 0) {
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return false;
|
||||
@@ -88,31 +95,27 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public void slotsChanged(Container inventory) {
|
||||
if (!world.isClientSide) {
|
||||
if (!level.isClientSide) {
|
||||
onCraftingMatrixChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
private final BaseItemHandler processingMatrix = new BaseItemHandler(PROCESSING_MATRIX_SIZE * 2)
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!reading && slot < PROCESSING_MATRIX_SIZE) {
|
||||
allowedTagList.clearItemTags(slot);
|
||||
}
|
||||
});
|
||||
private final FluidInventory processingMatrixFluids = new FluidInventory(PROCESSING_MATRIX_SIZE * 2, FluidAttributes.BUCKET_VOLUME * 64)
|
||||
.addListener(new NetworkNodeFluidInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!reading && slot < PROCESSING_MATRIX_SIZE) {
|
||||
allowedTagList.clearFluidTags(slot);
|
||||
}
|
||||
}); private final CraftingContainer matrix = new CraftingContainer(craftingContainer, 3, 3);
|
||||
});
|
||||
private final Set<ICraftingGridListener> craftingListeners = new HashSet<>();
|
||||
private final List<IFilter> filters = new ArrayList<>();
|
||||
private final List<IFilter> filters = new ArrayList<>(); private final CraftingContainer matrix = new CraftingContainer(craftingContainer, 3, 3);
|
||||
private final List<IGridTab> tabs = new ArrayList<>();
|
||||
private final FilterItemHandler filter = (FilterItemHandler) new FilterItemHandler(filters, tabs).addListener(new NetworkNodeInventoryListener(this));
|
||||
private final GridType type;
|
||||
private CraftingRecipe currentRecipe; private final BaseItemHandler patterns = new BaseItemHandler(2) {
|
||||
private CraftingRecipe currentRecipe;
|
||||
private boolean readingInventory;
|
||||
private int viewType = VIEW_TYPE_NORMAL;
|
||||
private int sortingDirection = SORTING_DIRECTION_DESCENDING; private final BaseItemHandler patterns = new BaseItemHandler(2) {
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return slot == 1 ? 1 : super.getSlotLimit(slot);
|
||||
@@ -165,9 +168,6 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
markDirty();
|
||||
}
|
||||
}));
|
||||
private boolean readingInventory;
|
||||
private int viewType = VIEW_TYPE_NORMAL;
|
||||
private int sortingDirection = SORTING_DIRECTION_DESCENDING;
|
||||
private int sortingType = SORTING_TYPE_QUANTITY;
|
||||
private int searchBoxMode = SEARCH_BOX_MODE_NORMAL;
|
||||
private int size = SIZE_STRETCH;
|
||||
@@ -176,9 +176,8 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
private boolean exactPattern = true;
|
||||
private boolean processingPattern = false;
|
||||
private int processingType = IType.ITEMS;
|
||||
|
||||
public GridNetworkNode(Level world, BlockPos pos, GridType type) {
|
||||
super(world, pos);
|
||||
public GridNetworkNode(Level level, BlockPos pos, GridType type) {
|
||||
super(level, pos);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
@@ -205,7 +204,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
private void updateAllowedTags() {
|
||||
markDirty();
|
||||
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
|
||||
if (tile instanceof GridTile) {
|
||||
((GridTile) tile).getDataManager().sendParameterToWatchers(GridTile.ALLOWED_ITEM_TAGS);
|
||||
@@ -238,7 +237,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
}
|
||||
|
||||
public boolean isProcessingPattern() {
|
||||
return world.isClientSide ? GridTile.PROCESSING_PATTERN.getValue() : processingPattern;
|
||||
return level.isClientSide ? GridTile.PROCESSING_PATTERN.getValue() : processingPattern;
|
||||
}
|
||||
|
||||
public void setProcessingPattern(boolean processingPattern) {
|
||||
@@ -340,8 +339,8 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public void onCraftingMatrixChanged() {
|
||||
if (currentRecipe == null || !currentRecipe.matches(matrix, world)) {
|
||||
currentRecipe = world.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, matrix, world).orElse(null);
|
||||
if (currentRecipe == null || !currentRecipe.matches(matrix, level)) {
|
||||
currentRecipe = level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, matrix, level).orElse(null);
|
||||
}
|
||||
|
||||
if (currentRecipe == null) {
|
||||
@@ -383,7 +382,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public boolean isGridActive() {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
BlockState state = level.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof GridBlock) {
|
||||
return state.getValue(NetworkNodeBlock.CONNECTED);
|
||||
@@ -528,7 +527,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public int getViewType() {
|
||||
return world.isClientSide ? GridTile.VIEW_TYPE.getValue() : viewType;
|
||||
return level.isClientSide ? GridTile.VIEW_TYPE.getValue() : viewType;
|
||||
}
|
||||
|
||||
public void setViewType(int viewType) {
|
||||
@@ -537,7 +536,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public int getSortingDirection() {
|
||||
return world.isClientSide ? GridTile.SORTING_DIRECTION.getValue() : sortingDirection;
|
||||
return level.isClientSide ? GridTile.SORTING_DIRECTION.getValue() : sortingDirection;
|
||||
}
|
||||
|
||||
public void setSortingDirection(int sortingDirection) {
|
||||
@@ -546,7 +545,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public int getSortingType() {
|
||||
return world.isClientSide ? GridTile.SORTING_TYPE.getValue() : sortingType;
|
||||
return level.isClientSide ? GridTile.SORTING_TYPE.getValue() : sortingType;
|
||||
}
|
||||
|
||||
public void setSortingType(int sortingType) {
|
||||
@@ -555,7 +554,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public int getSearchBoxMode() {
|
||||
return world.isClientSide ? GridTile.SEARCH_BOX_MODE.getValue() : searchBoxMode;
|
||||
return level.isClientSide ? GridTile.SEARCH_BOX_MODE.getValue() : searchBoxMode;
|
||||
}
|
||||
|
||||
public void setSearchBoxMode(int searchBoxMode) {
|
||||
@@ -564,7 +563,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return world.isClientSide ? GridTile.SIZE.getValue() : size;
|
||||
return level.isClientSide ? GridTile.SIZE.getValue() : size;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
@@ -573,7 +572,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public int getTabSelected() {
|
||||
return world.isClientSide ? GridTile.TAB_SELECTED.getValue() : tabSelected;
|
||||
return level.isClientSide ? GridTile.TAB_SELECTED.getValue() : tabSelected;
|
||||
}
|
||||
|
||||
public void setTabSelected(int tabSelected) {
|
||||
@@ -582,7 +581,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public int getTabPage() {
|
||||
return world.isClientSide ? GridTile.TAB_PAGE.getValue() : Math.min(tabPage, getTotalTabPages());
|
||||
return level.isClientSide ? GridTile.TAB_PAGE.getValue() : Math.min(tabPage, getTotalTabPages());
|
||||
}
|
||||
|
||||
public void setTabPage(int page) {
|
||||
@@ -633,7 +632,7 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isClientSide ? GridTile.PROCESSING_TYPE.getValue() : processingType;
|
||||
return level.isClientSide ? GridTile.PROCESSING_TYPE.getValue() : processingType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -777,4 +776,6 @@ public class GridNetworkNode extends NetworkNode implements INetworkAwareGrid, I
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -48,8 +48,8 @@ public class ImporterNetworkNode extends NetworkNode implements IComparable, IWh
|
||||
private int type = IType.ITEMS;
|
||||
private int currentSlot;
|
||||
|
||||
public ImporterNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public ImporterNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
this.coverManager = new CoverManager(this);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ImporterNetworkNode extends NetworkNode implements IComparable, IWh
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (!canUpdate() || !world.isLoaded(pos)) {
|
||||
if (!canUpdate() || !level.isLoaded(pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ public class ImporterNetworkNode extends NetworkNode implements IComparable, IWh
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isClientSide ? ImporterTile.TYPE.getValue() : type;
|
||||
return level.isClientSide ? ImporterTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -43,8 +43,8 @@ public class InterfaceNetworkNode extends NetworkNode implements IComparable {
|
||||
|
||||
private int currentSlot = 0;
|
||||
|
||||
public InterfaceNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public InterfaceNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,7 +129,7 @@ public class InterfaceNetworkNode extends NetworkNode implements IComparable {
|
||||
|
||||
private boolean isActingAsStorage() {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerLevel) world).getNode(pos.relative(facing));
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerLevel) level).getNode(pos.relative(facing));
|
||||
|
||||
if (facingNode instanceof ExternalStorageNetworkNode &&
|
||||
facingNode.isActive() &&
|
||||
|
@@ -41,7 +41,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
// new instances of network nodes will be created when the world refreshes (causing this field to be different too).
|
||||
// However, network nodes in the network graph *AREN'T* recreated when the world refreshes, causing the graph to have the incorrect instance, and even worse,
|
||||
// having multiple different instances of the same network node.
|
||||
protected Level world;
|
||||
protected Level level;
|
||||
protected BlockPos pos;
|
||||
protected int ticks;
|
||||
protected RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||
@@ -61,12 +61,12 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
private boolean couldUpdate;
|
||||
private int ticksSinceUpdateChanged;
|
||||
|
||||
protected NetworkNode(Level world, BlockPos pos) {
|
||||
if (world == null) {
|
||||
protected NetworkNode(Level level, BlockPos pos) {
|
||||
if (level == null) {
|
||||
throw new IllegalArgumentException("World cannot be null");
|
||||
}
|
||||
|
||||
this.world = world;
|
||||
this.level = level;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return new ItemStack(Item.BY_BLOCK.get(world.getBlockState(pos).getBlock()), 1);
|
||||
return new ItemStack(Item.BY_BLOCK.get(level.getBlockState(pos).getBlock()), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,8 +106,8 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
if (!world.isClientSide) {
|
||||
API.instance().getNetworkNodeManager((ServerLevel) world).markForSaving();
|
||||
if (!level.isClientSide) {
|
||||
API.instance().getNetworkNodeManager((ServerLevel) level).markForSaving();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
@Override
|
||||
public void update() {
|
||||
if (ticks == 0) {
|
||||
redstonePowered = world.hasNeighborSignal(pos);
|
||||
redstonePowered = level.hasNeighborSignal(pos);
|
||||
}
|
||||
|
||||
++ticks;
|
||||
@@ -154,17 +154,17 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
couldUpdate = canUpdate;
|
||||
throttlingDisabled = false;
|
||||
|
||||
BlockState blockState = world.getBlockState(pos);
|
||||
BlockState blockState = level.getBlockState(pos);
|
||||
|
||||
if (blockState.getBlock() instanceof NetworkNodeBlock && ((NetworkNodeBlock) blockState.getBlock()).hasConnectedState()) {
|
||||
world.setBlockAndUpdate(pos, world.getBlockState(pos).setValue(NetworkNodeBlock.CONNECTED, canUpdate));
|
||||
level.setBlockAndUpdate(pos, level.getBlockState(pos).setValue(NetworkNodeBlock.CONNECTED, canUpdate));
|
||||
}
|
||||
|
||||
if (network != null) {
|
||||
onConnectedStateChange(network, canUpdate, ConnectivityStateChangeCause.REDSTONE_MODE_OR_NETWORK_ENERGY_CHANGE);
|
||||
|
||||
if (shouldRebuildGraphOnChange()) {
|
||||
network.getNodeGraph().invalidate(Action.PERFORM, network.getWorld(), network.getPosition());
|
||||
network.getNodeGraph().invalidate(Action.PERFORM, network.getLevel(), network.getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,11 +220,10 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Level getWorld() {
|
||||
return world;
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canConduct(Direction direction) {
|
||||
return true;
|
||||
@@ -233,24 +232,24 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
@Override
|
||||
public void visit(Operator operator) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode oppositeNode = NetworkUtils.getNodeFromTile(world.getBlockEntity(pos.relative(facing)));
|
||||
INetworkNode oppositeNode = NetworkUtils.getNodeFromTile(level.getBlockEntity(pos.relative(facing)));
|
||||
if (oppositeNode == null) {
|
||||
continue;
|
||||
}
|
||||
if (canConduct(facing) && oppositeNode.canReceive(facing.getOpposite())) {
|
||||
operator.apply(world, pos.relative(facing), facing.getOpposite());
|
||||
operator.apply(level, pos.relative(facing), facing.getOpposite());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockEntity getFacingTile() {
|
||||
return world.getBlockEntity(pos.relative(getDirection()));
|
||||
return level.getBlockEntity(pos.relative(getDirection()));
|
||||
}
|
||||
|
||||
public Direction getDirection() {
|
||||
if (direction == null) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
BlockState state = level.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof BaseBlock) {
|
||||
direction = state.getValue(((BaseBlock) state.getBlock()).getDirection().getProperty());
|
||||
|
@@ -8,8 +8,8 @@ import net.minecraft.world.level.Level;
|
||||
public class NetworkReceiverNetworkNode extends NetworkNode {
|
||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "network_receiver");
|
||||
|
||||
public NetworkReceiverNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public NetworkReceiverNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -39,12 +39,12 @@ public class NetworkTransmitterNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
if (network != null) {
|
||||
network.getNodeGraph().invalidate(Action.PERFORM, network.getWorld(), network.getPosition());
|
||||
network.getNodeGraph().invalidate(Action.PERFORM, network.getLevel(), network.getPosition());
|
||||
}
|
||||
});
|
||||
|
||||
public NetworkTransmitterNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public NetworkTransmitterNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,7 +96,7 @@ public class NetworkTransmitterNetworkNode extends NetworkNode {
|
||||
}
|
||||
|
||||
public boolean isSameDimension() {
|
||||
return world.dimension() == receiverDimension;
|
||||
return level.dimension() == receiverDimension;
|
||||
}
|
||||
|
||||
private boolean canTransmit() {
|
||||
@@ -114,14 +114,14 @@ public class NetworkTransmitterNetworkNode extends NetworkNode {
|
||||
|
||||
if (canTransmit()) {
|
||||
if (!isSameDimension()) {
|
||||
Level dimensionWorld = world.getServer().getLevel(receiverDimension);
|
||||
Level dimensionWorld = level.getServer().getLevel(receiverDimension);
|
||||
|
||||
if (dimensionWorld != null && dimensionWorld.getBlockEntity(receiver) instanceof NetworkReceiverTile) {
|
||||
operator.apply(dimensionWorld, receiver, null);
|
||||
}
|
||||
} else {
|
||||
if (world.getBlockEntity(receiver) instanceof NetworkReceiverTile) {
|
||||
operator.apply(world, receiver, null);
|
||||
if (level.getBlockEntity(receiver) instanceof NetworkReceiverTile) {
|
||||
operator.apply(level, receiver, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,9 +10,8 @@ import net.minecraft.world.level.Level;
|
||||
public class RelayNetworkNode extends NetworkNode {
|
||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "relay");
|
||||
|
||||
public RelayNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
|
||||
public RelayNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
this.redstoneMode = RedstoneMode.LOW;
|
||||
}
|
||||
|
||||
|
@@ -18,12 +18,12 @@ import java.util.UUID;
|
||||
|
||||
public class RootNetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
private final INetwork network;
|
||||
private final Level world;
|
||||
private final Level level;
|
||||
private final BlockPos pos;
|
||||
|
||||
public RootNetworkNode(INetwork network, Level world, BlockPos pos) {
|
||||
public RootNetworkNode(INetwork network, Level level, BlockPos pos) {
|
||||
this.network = network;
|
||||
this.world = world;
|
||||
this.level = level;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class RootNetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
BlockState state = level.getBlockState(pos);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Item item = Item.byBlock(state.getBlock());
|
||||
@@ -95,8 +95,8 @@ public class RootNetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Level getWorld() {
|
||||
return world;
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,7 +107,7 @@ public class RootNetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
@Override
|
||||
public void visit(Operator operator) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
operator.apply(world, pos.relative(facing), facing.getOpposite());
|
||||
operator.apply(level, pos.relative(facing), facing.getOpposite());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,11 +32,14 @@ public class SecurityManagerNetworkNode extends NetworkNode implements ISecurity
|
||||
private final BaseItemHandler editCard = new BaseItemHandler(1)
|
||||
.addValidator(new ItemValidator(RSItems.SECURITY_CARD.get()))
|
||||
.addListener(new NetworkNodeInventoryListener(this));
|
||||
private ISecurityCard globalCard; private final BaseItemHandler cardsInv = new BaseItemHandler(9 * 2)
|
||||
private ISecurityCard globalCard;
|
||||
public SecurityManagerNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
} private final BaseItemHandler cardsInv = new BaseItemHandler(9 * 2)
|
||||
.addValidator(new ItemValidator(RSItems.SECURITY_CARD.get()))
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener(((handler, slot, reading) -> {
|
||||
if (!world.isClientSide) {
|
||||
if (!level.isClientSide) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@@ -45,10 +48,6 @@ public class SecurityManagerNetworkNode extends NetworkNode implements ISecurity
|
||||
}
|
||||
}));
|
||||
|
||||
public SecurityManagerNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
int usage = RS.SERVER_CONFIG.getSecurityManager().getUsage();
|
||||
@@ -165,4 +164,6 @@ public class SecurityManagerNetworkNode extends NetworkNode implements ISecurity
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -46,14 +46,14 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!reading) {
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
WorldUtils.updateBlock(level, pos);
|
||||
}
|
||||
});
|
||||
|
||||
private final FluidInventory fluidFilter = new FluidInventory(1, FluidAttributes.BUCKET_VOLUME)
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!reading) {
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
WorldUtils.updateBlock(level, pos);
|
||||
}
|
||||
});
|
||||
private final Map<String, Pair<ItemStack, Long>> deposits = new HashMap<>();
|
||||
@@ -63,8 +63,8 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
|
||||
private int oldAmount = -1;
|
||||
|
||||
public StorageMonitorNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public StorageMonitorNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,7 +82,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
} else if (oldAmount != newAmount) {
|
||||
oldAmount = newAmount;
|
||||
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
WorldUtils.updateBlock(level, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
ItemStack result = network.extractItem(filter, toExtract, compare, Action.PERFORM);
|
||||
|
||||
if (!result.isEmpty() && !player.getInventory().add(result.copy())) {
|
||||
Containers.dropItemStack(world, player.getX(), player.getY(), player.getZ(), result);
|
||||
Containers.dropItemStack(level, player.getX(), player.getY(), player.getZ(), result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,7 +249,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
public void setCompare(int compare) {
|
||||
this.compare = compare;
|
||||
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
WorldUtils.updateBlock(level, pos);
|
||||
|
||||
markDirty();
|
||||
}
|
||||
@@ -318,14 +318,14 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isClientSide ? StorageMonitorTile.TYPE.getValue() : type;
|
||||
return level.isClientSide ? StorageMonitorTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
WorldUtils.updateBlock(level, pos);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
|
@@ -20,8 +20,8 @@ public class WirelessTransmitterNetworkNode extends NetworkNode implements IWire
|
||||
|
||||
private final UpgradeItemHandler upgrades = (UpgradeItemHandler) new UpgradeItemHandler(4, UpgradeItem.Type.RANGE).addListener(new NetworkNodeInventoryListener(this));
|
||||
|
||||
public WirelessTransmitterNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public WirelessTransmitterNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,7 +62,7 @@ public class WirelessTransmitterNetworkNode extends NetworkNode implements IWire
|
||||
|
||||
@Override
|
||||
public ResourceKey<Level> getDimension() {
|
||||
return world.dimension();
|
||||
return level.dimension();
|
||||
}
|
||||
|
||||
public BaseItemHandler getUpgrades() {
|
||||
@@ -81,6 +81,6 @@ public class WirelessTransmitterNetworkNode extends NetworkNode implements IWire
|
||||
|
||||
@Override
|
||||
public void visit(Operator operator) {
|
||||
operator.apply(world, pos.relative(Direction.DOWN), Direction.UP);
|
||||
operator.apply(level, pos.relative(Direction.DOWN), Direction.UP);
|
||||
}
|
||||
}
|
||||
|
@@ -113,7 +113,7 @@ public class CoverManager {
|
||||
node.markDirty();
|
||||
|
||||
if (node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().getWorld(), node.getNetwork().getPosition());
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().getLevel(), node.getNetwork().getPosition());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -130,7 +130,7 @@ public class CoverManager {
|
||||
node.markDirty();
|
||||
|
||||
if (node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().getWorld(), node.getNetwork().getPosition());
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().getLevel(), node.getNetwork().getPosition());
|
||||
}
|
||||
|
||||
return cover;
|
||||
|
@@ -58,9 +58,9 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
||||
.addValidator(new StorageDiskItemValidator())
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!world.isClientSide) {
|
||||
if (!level.isClientSide) {
|
||||
StackUtils.createStorages(
|
||||
(ServerLevel) world,
|
||||
(ServerLevel) level,
|
||||
handler.getStackInSlot(slot),
|
||||
slot,
|
||||
itemDisks,
|
||||
@@ -75,7 +75,7 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
||||
}
|
||||
|
||||
if (!reading) {
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
WorldUtils.updateBlock(level, pos);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -87,8 +87,8 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
||||
private int mode = IWhitelistBlacklist.BLACKLIST;
|
||||
private int type = IType.ITEMS;
|
||||
|
||||
public DiskDriveNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public DiskDriveNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
public IStorageDisk[] getItemDisks() {
|
||||
@@ -125,7 +125,7 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
||||
++ticksSinceBlockUpdateRequested;
|
||||
|
||||
if (ticksSinceBlockUpdateRequested > DISK_STATE_UPDATE_THROTTLE) {
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
WorldUtils.updateBlock(level, pos);
|
||||
|
||||
this.blockUpdateRequested = false;
|
||||
this.ticksSinceBlockUpdateRequested = 0;
|
||||
@@ -148,7 +148,7 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
||||
network.getNodeGraph().runActionWhenPossible(ItemStorageCache.INVALIDATE_ACTION.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
||||
network.getNodeGraph().runActionWhenPossible(FluidStorageCache.INVALIDATE_ACTION.apply(InvalidateCause.CONNECTED_STATE_CHANGED));
|
||||
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
WorldUtils.updateBlock(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -323,7 +323,7 @@ public class DiskDriveNetworkNode extends NetworkNode implements IStorageProvide
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isClientSide ? DiskDriveTile.TYPE.getValue() : type;
|
||||
return level.isClientSide ? DiskDriveTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -56,9 +56,9 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
||||
.addValidator(new StorageDiskItemValidator())
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener((handler, slot, reading) -> {
|
||||
if (!world.isClientSide) {
|
||||
if (!level.isClientSide) {
|
||||
StackUtils.createStorages(
|
||||
(ServerLevel) world,
|
||||
(ServerLevel) level,
|
||||
handler.getStackInSlot(slot),
|
||||
slot,
|
||||
itemDisks,
|
||||
@@ -68,7 +68,7 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
||||
);
|
||||
|
||||
if (!reading) {
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
WorldUtils.updateBlock(level, pos);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -76,9 +76,9 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
||||
.addValidator(new StorageDiskItemValidator())
|
||||
.addListener(new NetworkNodeInventoryListener(this))
|
||||
.addListener(((handler, slot, reading) -> {
|
||||
if (!world.isClientSide) {
|
||||
if (!level.isClientSide) {
|
||||
StackUtils.createStorages(
|
||||
(ServerLevel) world,
|
||||
(ServerLevel) level,
|
||||
handler.getStackInSlot(slot),
|
||||
3 + slot,
|
||||
itemDisks,
|
||||
@@ -88,7 +88,7 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
||||
);
|
||||
|
||||
if (!reading) {
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
WorldUtils.updateBlock(level, pos);
|
||||
}
|
||||
}
|
||||
}));
|
||||
@@ -112,8 +112,8 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
||||
}.addListener(new NetworkNodeInventoryListener(this));
|
||||
private int ioMode = IO_MODE_INSERT;
|
||||
|
||||
public DiskManipulatorNetworkNode(Level world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
public DiskManipulatorNetworkNode(Level level, BlockPos pos) {
|
||||
super(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -413,7 +413,7 @@ public class DiskManipulatorNetworkNode extends NetworkNode implements IComparab
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return world.isClientSide ? DiskManipulatorTile.TYPE.getValue() : type;
|
||||
return level.isClientSide ? DiskManipulatorTile.TYPE.getValue() : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -33,7 +33,7 @@ public class StorageDiskFluidManipulatorWrapper implements IStorageDisk<FluidSta
|
||||
if (lastState != currentState) {
|
||||
lastState = currentState;
|
||||
|
||||
WorldUtils.updateBlock(diskManipulator.getWorld(), diskManipulator.getPos());
|
||||
WorldUtils.updateBlock(diskManipulator.getLevel(), diskManipulator.getPos());
|
||||
}
|
||||
},
|
||||
diskManipulator
|
||||
|
@@ -33,7 +33,7 @@ public class StorageDiskItemManipulatorWrapper implements IStorageDisk<ItemStack
|
||||
if (lastState != currentState) {
|
||||
lastState = currentState;
|
||||
|
||||
WorldUtils.updateBlock(diskManipulator.getWorld(), diskManipulator.getPos());
|
||||
WorldUtils.updateBlock(diskManipulator.getLevel(), diskManipulator.getPos());
|
||||
}
|
||||
},
|
||||
diskManipulator
|
||||
|
@@ -64,8 +64,8 @@ public class FluidStorageNetworkNode extends NetworkNode implements IStorageScre
|
||||
private UUID storageId = UUID.randomUUID();
|
||||
private IStorageDisk<FluidStack> storage;
|
||||
|
||||
public FluidStorageNetworkNode(Level world, BlockPos pos, FluidStorageType type) {
|
||||
super(world, pos);
|
||||
public FluidStorageNetworkNode(Level level, BlockPos pos, FluidStorageType type) {
|
||||
super(level, pos);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
@@ -154,13 +154,13 @@ public class FluidStorageNetworkNode extends NetworkNode implements IStorageScre
|
||||
}
|
||||
|
||||
public void loadStorage(@Nullable Player owner) {
|
||||
IStorageDisk disk = API.instance().getStorageDiskManager((ServerLevel) world).get(storageId);
|
||||
IStorageDisk disk = API.instance().getStorageDiskManager((ServerLevel) level).get(storageId);
|
||||
|
||||
if (disk == null) {
|
||||
disk = API.instance().createDefaultFluidDisk((ServerLevel) world, type.getCapacity(), owner);
|
||||
disk = API.instance().createDefaultFluidDisk((ServerLevel) level, type.getCapacity(), owner);
|
||||
|
||||
API.instance().getStorageDiskManager((ServerLevel) world).set(storageId, disk);
|
||||
API.instance().getStorageDiskManager((ServerLevel) world).markForSaving();
|
||||
API.instance().getStorageDiskManager((ServerLevel) level).set(storageId, disk);
|
||||
API.instance().getStorageDiskManager((ServerLevel) level).markForSaving();
|
||||
}
|
||||
|
||||
this.storage = new FluidStorageWrapperStorageDisk(this, disk);
|
||||
|
@@ -64,8 +64,8 @@ public class StorageNetworkNode extends NetworkNode implements IStorageScreen, I
|
||||
private UUID storageId = UUID.randomUUID();
|
||||
private IStorageDisk<ItemStack> storage;
|
||||
|
||||
public StorageNetworkNode(Level world, BlockPos pos, ItemStorageType type) {
|
||||
super(world, pos);
|
||||
public StorageNetworkNode(Level level, BlockPos pos, ItemStorageType type) {
|
||||
super(level, pos);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
@@ -154,13 +154,13 @@ public class StorageNetworkNode extends NetworkNode implements IStorageScreen, I
|
||||
}
|
||||
|
||||
public void loadStorage(@Nullable Player owner) {
|
||||
IStorageDisk disk = API.instance().getStorageDiskManager((ServerLevel) world).get(storageId);
|
||||
IStorageDisk disk = API.instance().getStorageDiskManager((ServerLevel) level).get(storageId);
|
||||
|
||||
if (disk == null) {
|
||||
disk = API.instance().createDefaultItemDisk((ServerLevel) world, type.getCapacity(), owner);
|
||||
disk = API.instance().createDefaultItemDisk((ServerLevel) level, type.getCapacity(), owner);
|
||||
|
||||
API.instance().getStorageDiskManager((ServerLevel) world).set(storageId, disk);
|
||||
API.instance().getStorageDiskManager((ServerLevel) world).markForSaving();
|
||||
API.instance().getStorageDiskManager((ServerLevel) level).set(storageId, disk);
|
||||
API.instance().getStorageDiskManager((ServerLevel) level).markForSaving();
|
||||
}
|
||||
|
||||
this.storage = new ItemStorageWrapperStorageDisk(this, disk);
|
||||
|
@@ -30,7 +30,7 @@ public class FluidStorageDisk implements IStorageDisk<FluidStack> {
|
||||
public static final int VERSION = 1;
|
||||
|
||||
@Nullable
|
||||
private final ServerLevel world;
|
||||
private final ServerLevel level;
|
||||
private final int capacity;
|
||||
private final Multimap<Fluid, FluidStack> stacks = ArrayListMultimap.create();
|
||||
private final UUID owner;
|
||||
@@ -39,8 +39,8 @@ public class FluidStorageDisk implements IStorageDisk<FluidStack> {
|
||||
private IStorageDiskListener listener;
|
||||
private IStorageDiskContainerContext context;
|
||||
|
||||
public FluidStorageDisk(@Nullable ServerLevel world, int capacity, @Nullable UUID owner) {
|
||||
this.world = world;
|
||||
public FluidStorageDisk(@Nullable ServerLevel level, int capacity, @Nullable UUID owner) {
|
||||
this.level = level;
|
||||
this.capacity = capacity;
|
||||
this.owner = owner;
|
||||
}
|
||||
@@ -216,8 +216,8 @@ public class FluidStorageDisk implements IStorageDisk<FluidStack> {
|
||||
listener.onChanged();
|
||||
}
|
||||
|
||||
if (world != null) {
|
||||
API.instance().getStorageDiskManager(world).markForSaving();
|
||||
if (level != null) {
|
||||
API.instance().getStorageDiskManager(level).markForSaving();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public class ItemStorageDisk implements IStorageDisk<ItemStack> {
|
||||
public static final int VERSION = 1;
|
||||
|
||||
@Nullable
|
||||
private final ServerLevel world;
|
||||
private final ServerLevel level;
|
||||
private final int capacity;
|
||||
private final Multimap<Item, ItemStack> stacks = ArrayListMultimap.create();
|
||||
private final UUID owner;
|
||||
@@ -41,8 +41,8 @@ public class ItemStorageDisk implements IStorageDisk<ItemStack> {
|
||||
private IStorageDiskListener listener;
|
||||
private IStorageDiskContainerContext context;
|
||||
|
||||
public ItemStorageDisk(@Nullable ServerLevel world, int capacity, @Nullable UUID owner) {
|
||||
this.world = world;
|
||||
public ItemStorageDisk(@Nullable ServerLevel level, int capacity, @Nullable UUID owner) {
|
||||
this.level = level;
|
||||
this.capacity = capacity;
|
||||
this.owner = owner;
|
||||
}
|
||||
@@ -222,8 +222,8 @@ public class ItemStorageDisk implements IStorageDisk<ItemStack> {
|
||||
listener.onChanged();
|
||||
}
|
||||
|
||||
if (world != null) {
|
||||
API.instance().getStorageDiskManager(world).markForSaving();
|
||||
if (level != null) {
|
||||
API.instance().getStorageDiskManager(level).markForSaving();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,10 +8,10 @@ import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.util.RSWorldSavedData;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
@@ -27,10 +27,10 @@ public class StorageDiskManager extends RSWorldSavedData implements IStorageDisk
|
||||
private static final String NBT_DISK_DATA = "Data";
|
||||
|
||||
private final Map<UUID, IStorageDisk> disks = new HashMap<>();
|
||||
private final ServerLevel world;
|
||||
private final ServerLevel level;
|
||||
|
||||
public StorageDiskManager(ServerLevel world) {
|
||||
this.world = world;
|
||||
public StorageDiskManager(ServerLevel level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,7 +105,7 @@ public class StorageDiskManager extends RSWorldSavedData implements IStorageDisk
|
||||
|
||||
IStorageDiskFactory factory = API.instance().getStorageDiskRegistry().get(new ResourceLocation(type));
|
||||
if (factory != null) {
|
||||
disks.put(id, factory.createFromNbt(world, data));
|
||||
disks.put(id, factory.createFromNbt(level, data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@ import com.refinedmods.refinedstorage.apiimpl.storage.disk.FluidStorageDisk;
|
||||
import com.refinedmods.refinedstorage.item.FluidStorageDiskItem;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -22,9 +22,9 @@ public class FluidStorageDiskFactory implements IStorageDiskFactory<FluidStack>
|
||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "fluid");
|
||||
|
||||
@Override
|
||||
public IStorageDisk<FluidStack> createFromNbt(ServerLevel world, CompoundTag tag) {
|
||||
public IStorageDisk<FluidStack> createFromNbt(ServerLevel level, CompoundTag tag) {
|
||||
FluidStorageDisk disk = new FluidStorageDisk(
|
||||
world,
|
||||
level,
|
||||
tag.getInt(FluidStorageDisk.NBT_CAPACITY),
|
||||
tag.contains(FluidStorageDisk.NBT_OWNER) ? tag.getUUID(FluidStorageDisk.NBT_OWNER) : null
|
||||
);
|
||||
@@ -69,7 +69,7 @@ public class FluidStorageDiskFactory implements IStorageDiskFactory<FluidStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageDisk<FluidStack> create(ServerLevel world, int capacity, @Nullable UUID owner) {
|
||||
return new FluidStorageDisk(world, capacity, owner);
|
||||
public IStorageDisk<FluidStack> create(ServerLevel level, int capacity, @Nullable UUID owner) {
|
||||
return new FluidStorageDisk(level, capacity, owner);
|
||||
}
|
||||
}
|
||||
|
@@ -10,10 +10,10 @@ import com.refinedmods.refinedstorage.item.StorageDiskItem;
|
||||
import com.refinedmods.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
@@ -22,9 +22,9 @@ public class ItemStorageDiskFactory implements IStorageDiskFactory<ItemStack> {
|
||||
public static final ResourceLocation ID = new ResourceLocation(RS.ID, "item");
|
||||
|
||||
@Override
|
||||
public IStorageDisk<ItemStack> createFromNbt(ServerLevel world, CompoundTag tag) {
|
||||
public IStorageDisk<ItemStack> createFromNbt(ServerLevel level, CompoundTag tag) {
|
||||
ItemStorageDisk disk = new ItemStorageDisk(
|
||||
world,
|
||||
level,
|
||||
tag.getInt(ItemStorageDisk.NBT_CAPACITY),
|
||||
tag.contains(ItemStorageDisk.NBT_OWNER) ? tag.getUUID(ItemStorageDisk.NBT_OWNER) : null
|
||||
);
|
||||
@@ -71,7 +71,7 @@ public class ItemStorageDiskFactory implements IStorageDiskFactory<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageDisk<ItemStack> create(ServerLevel world, int capacity, @Nullable UUID owner) {
|
||||
return new ItemStorageDisk(world, capacity, owner);
|
||||
public IStorageDisk<ItemStack> create(ServerLevel level, int capacity, @Nullable UUID owner) {
|
||||
return new ItemStorageDisk(level, capacity, owner);
|
||||
}
|
||||
}
|
||||
|
@@ -30,23 +30,23 @@ public abstract class BaseBlock extends Block {
|
||||
return super.rotate(state, rot);
|
||||
}
|
||||
|
||||
protected void onDirectionChanged(Level world, BlockPos pos, Direction newDirection) {
|
||||
protected void onDirectionChanged(Level level, BlockPos pos, Direction newDirection) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
super.onRemove(state, world, pos, newState, isMoving);
|
||||
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
super.onRemove(state, level, pos, newState, isMoving);
|
||||
|
||||
checkIfDirectionHasChanged(state, world, pos, newState);
|
||||
checkIfDirectionHasChanged(state, level, pos, newState);
|
||||
}
|
||||
|
||||
protected void checkIfDirectionHasChanged(BlockState state, Level world, BlockPos pos, BlockState newState) {
|
||||
protected void checkIfDirectionHasChanged(BlockState state, Level level, BlockPos pos, BlockState newState) {
|
||||
if (getDirection() != BlockDirection.NONE &&
|
||||
state.getBlock() == newState.getBlock() &&
|
||||
state.getValue(getDirection().getProperty()) != newState.getValue(getDirection().getProperty())) {
|
||||
onDirectionChanged(world, pos, newState.getValue(getDirection().getProperty()));
|
||||
onDirectionChanged(level, pos, newState.getValue(getDirection().getProperty()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,6 @@ import com.refinedmods.refinedstorage.block.shape.ShapeCache;
|
||||
import com.refinedmods.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.refinedmods.refinedstorage.render.ConstantsCable;
|
||||
import com.refinedmods.refinedstorage.tile.CableTile;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -134,7 +133,7 @@ public class CableBlock extends NetworkNodeBlock implements SimpleWaterloggedBlo
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDirectionChanged(Level world, BlockPos pos, Direction newDirection) {
|
||||
protected void onDirectionChanged(Level level, BlockPos pos, Direction newDirection) {
|
||||
// rotate() in BaseBlock "stupidly" changes the direction without checking if our cable connections are still valid.
|
||||
// You'd expect that cable connections are not changing when simply changing the direction.
|
||||
// But they need to. For example, when rotating a constructor to connect to a neighboring cable, the connection to that neighbor
|
||||
@@ -142,25 +141,25 @@ public class CableBlock extends NetworkNodeBlock implements SimpleWaterloggedBlo
|
||||
// This is already checked in hasNode().
|
||||
// But since rotate() doesn't invalidate that connection, we need to do it here.
|
||||
// Ideally, this code would be in rotate(). But rotate() doesn't have any data about the position and world, so we need to do it here.
|
||||
world.setBlockAndUpdate(pos, getState(world.getBlockState(pos), world, pos));
|
||||
level.setBlockAndUpdate(pos, getState(level.getBlockState(pos), level, pos));
|
||||
|
||||
|
||||
//when rotating skip rotations blocked by covers
|
||||
BlockDirection dir = getDirection();
|
||||
if (dir != BlockDirection.NONE) {
|
||||
if (isSideCovered(world.getBlockEntity(pos), newDirection)) {
|
||||
BlockState newState = rotate(world.getBlockState(pos), Rotation.CLOCKWISE_90);
|
||||
world.setBlockAndUpdate(pos, newState);
|
||||
if (isSideCovered(level.getBlockEntity(pos), newDirection)) {
|
||||
BlockState newState = rotate(level.getBlockState(pos), Rotation.CLOCKWISE_90);
|
||||
level.setBlockAndUpdate(pos, newState);
|
||||
}
|
||||
}
|
||||
|
||||
super.onDirectionChanged(world, pos, newDirection);
|
||||
super.onDirectionChanged(level, pos, newDirection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, world, pos, blockIn, fromPos, isMoving);
|
||||
world.setBlockAndUpdate(pos, getState(world.getBlockState(pos), world, pos));
|
||||
public void neighborChanged(BlockState state, Level level, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, level, pos, blockIn, fromPos, isMoving);
|
||||
level.setBlockAndUpdate(pos, getState(level.getBlockState(pos), level, pos));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@@ -11,11 +11,11 @@ public abstract class ColoredNetworkBlock extends NetworkNodeBlock {
|
||||
|
||||
// Don't do block drops if we change the color.
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock().getClass().equals(newState.getBlock().getClass())) {
|
||||
checkIfDirectionHasChanged(state, world, pos, newState);
|
||||
checkIfDirectionHasChanged(state, level, pos, newState);
|
||||
} else {
|
||||
super.onRemove(state, world, pos, newState, isMoving);
|
||||
super.onRemove(state, level, pos, newState, isMoving);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -25,8 +25,6 @@ import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ConstructorBlock extends CableBlock {
|
||||
private static final VoxelShape HEAD_NORTH = Shapes.or(box(2, 2, 0, 14, 14, 2), HOLDER_NORTH);
|
||||
private static final VoxelShape HEAD_EAST = Shapes.or(box(14, 2, 2, 16, 14, 14), HOLDER_EAST);
|
||||
@@ -92,9 +90,9 @@ public class ConstructorBlock extends CableBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!world.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<ConstructorTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.constructor"),
|
||||
|
@@ -61,12 +61,12 @@ public class ControllerBlock extends BaseBlock implements EntityBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack stack) {
|
||||
super.setPlacedBy(world, pos, state, entity, stack);
|
||||
public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack stack) {
|
||||
super.setPlacedBy(level, pos, state, entity, stack);
|
||||
|
||||
if (!world.isClientSide) {
|
||||
if (!level.isClientSide) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyFromStack -> {
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
|
||||
if (tile != null) {
|
||||
tile.getCapability(CapabilityEnergy.ENERGY).ifPresent(energyFromTile -> energyFromTile.receiveEnergy(energyFromStack.getEnergyStored(), false));
|
||||
@@ -77,21 +77,21 @@ public class ControllerBlock extends BaseBlock implements EntityBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, world, pos, blockIn, fromPos, isMoving);
|
||||
public void neighborChanged(BlockState state, Level level, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, level, pos, blockIn, fromPos, isMoving);
|
||||
|
||||
if (!world.isClientSide) {
|
||||
INetwork network = API.instance().getNetworkManager((ServerLevel) world).getNetwork(pos);
|
||||
if (!level.isClientSide) {
|
||||
INetwork network = API.instance().getNetworkManager((ServerLevel) level).getNetwork(pos);
|
||||
if (network instanceof Network) {
|
||||
((Network) network).setRedstonePowered(world.hasNeighborSignal(pos));
|
||||
((Network) network).setRedstonePowered(level.hasNeighborSignal(pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = super.use(state, world, pos, player, hand, hit);
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = super.use(state, level, pos, player, hand, hit);
|
||||
if (result != InteractionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
@@ -102,11 +102,11 @@ public class ControllerBlock extends BaseBlock implements EntityBlock {
|
||||
if (color != null && !state.getBlock().equals(colorMap.get(color).get())) {
|
||||
BlockState newState = colorMap.get(color).get().defaultBlockState().setValue(ENERGY_TYPE, state.getValue(ENERGY_TYPE));
|
||||
|
||||
return RSBlocks.CONTROLLER.setBlockState(newState, player.getItemInHand(hand), world, pos, player);
|
||||
return RSBlocks.CONTROLLER.setBlockState(newState, player.getItemInHand(hand), level, pos, player);
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new MenuProvider() {
|
||||
@Override
|
||||
@@ -116,7 +116,7 @@ public class ControllerBlock extends BaseBlock implements EntityBlock {
|
||||
|
||||
@Override
|
||||
public AbstractContainerMenu createMenu(int i, Inventory playerInventory, Player player) {
|
||||
return new ControllerContainer((ControllerTile) world.getBlockEntity(pos), player, i);
|
||||
return new ControllerContainer((ControllerTile) level.getBlockEntity(pos), player, i);
|
||||
}
|
||||
},
|
||||
pos
|
||||
@@ -127,11 +127,11 @@ public class ControllerBlock extends BaseBlock implements EntityBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (newState.getBlock() instanceof ControllerBlock) {
|
||||
return;
|
||||
}
|
||||
super.onRemove(state, world, pos, newState, isMoving);
|
||||
super.onRemove(state, level, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -33,11 +33,11 @@ public class CrafterBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
super.setPlacedBy(world, pos, state, placer, stack);
|
||||
public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
super.setPlacedBy(level, pos, state, placer, stack);
|
||||
|
||||
if (!world.isClientSide) {
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
if (!level.isClientSide) {
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
|
||||
if (tile instanceof CrafterTile && stack.hasCustomHoverName()) {
|
||||
((CrafterTile) tile).getNode().setDisplayName(stack.getHoverName());
|
||||
@@ -48,17 +48,17 @@ public class CrafterBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.CRAFTER.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.CRAFTER.changeBlockColor(state, player.getItemInHand(hand), level, pos, player);
|
||||
if (result != InteractionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attempt(world, pos, player, () -> NetworkHooks.openGui(
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<CrafterTile>(
|
||||
((CrafterTile) world.getBlockEntity(pos)).getNode().getName(),
|
||||
((CrafterTile) level.getBlockEntity(pos)).getNode().getName(),
|
||||
(tile, windowId, inventory, p) -> new CrafterContainer(tile, player, windowId),
|
||||
pos
|
||||
),
|
||||
|
@@ -34,17 +34,17 @@ public class CrafterManagerBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.CRAFTER_MANAGER.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.CRAFTER_MANAGER.changeBlockColor(state, player.getItemInHand(hand), level, pos, player);
|
||||
if (result != InteractionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attempt(world, pos, player, () -> NetworkHooks.openGui(
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new CrafterManagerContainerProvider((CrafterManagerTile) world.getBlockEntity(pos)),
|
||||
buf -> CrafterManagerContainerProvider.writeToBuffer(buf, world, pos)
|
||||
new CrafterManagerContainerProvider((CrafterManagerTile) level.getBlockEntity(pos)),
|
||||
buf -> CrafterManagerContainerProvider.writeToBuffer(buf, level, pos)
|
||||
), Permission.MODIFY, Permission.AUTOCRAFTING);
|
||||
}
|
||||
|
||||
|
@@ -35,16 +35,16 @@ public class CraftingMonitorBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.CRAFTING_MONITOR.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.CRAFTING_MONITOR.changeBlockColor(state, player.getItemInHand(hand), level, pos, player);
|
||||
if (result != InteractionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
CraftingMonitorTile tile = (CraftingMonitorTile) world.getBlockEntity(pos);
|
||||
if (!level.isClientSide) {
|
||||
CraftingMonitorTile tile = (CraftingMonitorTile) level.getBlockEntity(pos);
|
||||
|
||||
return NetworkUtils.attempt(world, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new CraftingMonitorContainerProvider(RSContainers.CRAFTING_MONITOR, tile.getNode(), tile),
|
||||
pos
|
||||
|
@@ -90,9 +90,9 @@ public class DestructorBlock extends CableBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!world.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!level.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<DestructorTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.destructor"),
|
||||
|
@@ -3,7 +3,6 @@ package com.refinedmods.refinedstorage.block;
|
||||
import com.refinedmods.refinedstorage.RSBlocks;
|
||||
import com.refinedmods.refinedstorage.container.DetectorContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.DetectorTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.ColorMap;
|
||||
@@ -28,8 +27,6 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DetectorBlock extends ColoredNetworkBlock {
|
||||
public static final BooleanProperty POWERED = BooleanProperty.create("powered");
|
||||
|
||||
@@ -70,18 +67,18 @@ public class DetectorBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
ColorMap<DetectorBlock> colorMap = RSBlocks.DETECTOR;
|
||||
DyeColor color = DyeColor.getColor(player.getItemInHand(hand));
|
||||
|
||||
if (color != null && !state.getBlock().equals(colorMap.get(color).get())) {
|
||||
BlockState newState = colorMap.get(color).get().defaultBlockState().setValue(POWERED, state.getValue(POWERED));
|
||||
|
||||
return RSBlocks.DETECTOR.setBlockState(newState, player.getItemInHand(hand), world, pos, player);
|
||||
return RSBlocks.DETECTOR.setBlockState(newState, player.getItemInHand(hand), level, pos, player);
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<DetectorTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.detector"),
|
||||
|
@@ -2,7 +2,6 @@ package com.refinedmods.refinedstorage.block;
|
||||
|
||||
import com.refinedmods.refinedstorage.container.DiskDriveContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.DiskDriveTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
@@ -12,15 +11,12 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DiskDriveBlock extends NetworkNodeBlock {
|
||||
public DiskDriveBlock() {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
@@ -38,9 +34,9 @@ public class DiskDriveBlock extends NetworkNodeBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult rayTraceResult) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult rayTraceResult) {
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<DiskDriveTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.disk_drive"),
|
||||
|
@@ -3,7 +3,6 @@ package com.refinedmods.refinedstorage.block;
|
||||
import com.refinedmods.refinedstorage.RSBlocks;
|
||||
import com.refinedmods.refinedstorage.container.DiskManipulatorContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.DiskManipulatorTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
@@ -13,15 +12,12 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DiskManipulatorBlock extends ColoredNetworkBlock {
|
||||
public DiskManipulatorBlock() {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
@@ -34,14 +30,14 @@ public class DiskManipulatorBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult rayTraceResult) {
|
||||
InteractionResult result = RSBlocks.DISK_MANIPULATOR.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult rayTraceResult) {
|
||||
InteractionResult result = RSBlocks.DISK_MANIPULATOR.changeBlockColor(state, player.getItemInHand(hand), level, pos, player);
|
||||
if (result != InteractionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<DiskManipulatorTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.disk_manipulator"),
|
||||
|
@@ -114,9 +114,9 @@ public class ExporterBlock extends CableBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!world.isClientSide && CollisionUtils.isInBounds(getLineShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide && CollisionUtils.isInBounds(getLineShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<ExporterTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.exporter"),
|
||||
|
@@ -7,7 +7,6 @@ import com.refinedmods.refinedstorage.block.shape.ShapeCache;
|
||||
import com.refinedmods.refinedstorage.container.ExternalStorageContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.render.ConstantsCable;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.ExternalStorageTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
@@ -30,8 +29,6 @@ import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ExternalStorageBlock extends CableBlock {
|
||||
private static final VoxelShape HEAD_NORTH = Shapes.or(box(3, 3, 0, 13, 13, 2), HOLDER_NORTH);
|
||||
private static final VoxelShape HEAD_EAST = Shapes.or(box(14, 3, 3, 16, 13, 13), HOLDER_EAST);
|
||||
@@ -97,9 +94,9 @@ public class ExternalStorageBlock extends CableBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!world.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide && CollisionUtils.isInBounds(getHeadShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<ExternalStorageTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.external_storage"),
|
||||
@@ -115,11 +112,11 @@ public class ExternalStorageBlock extends CableBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, world, pos, block, fromPos, isMoving);
|
||||
public void neighborChanged(BlockState state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, level, pos, block, fromPos, isMoving);
|
||||
|
||||
if (!world.isClientSide) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(world.getBlockEntity(pos));
|
||||
if (!level.isClientSide) {
|
||||
INetworkNode node = NetworkUtils.getNodeFromTile(level.getBlockEntity(pos));
|
||||
|
||||
if (node instanceof ExternalStorageNetworkNode &&
|
||||
node.getNetwork() != null &&
|
||||
|
@@ -3,7 +3,6 @@ package com.refinedmods.refinedstorage.block;
|
||||
import com.refinedmods.refinedstorage.api.network.security.Permission;
|
||||
import com.refinedmods.refinedstorage.container.FluidInterfaceContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.FluidInterfaceTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
@@ -13,15 +12,12 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FluidInterfaceBlock extends NetworkNodeBlock {
|
||||
public FluidInterfaceBlock() {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
@@ -34,9 +30,9 @@ public class FluidInterfaceBlock extends NetworkNodeBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attempt(world, pos, player, () -> NetworkHooks.openGui(
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<FluidInterfaceTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.fluid_interface"),
|
||||
|
@@ -34,9 +34,9 @@ public class FluidStorageBlock extends NetworkNodeBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity player, ItemStack stack) {
|
||||
if (!world.isClientSide) {
|
||||
FluidStorageNetworkNode storage = ((FluidStorageTile) world.getBlockEntity(pos)).getNode();
|
||||
public void setPlacedBy(Level level, BlockPos pos, BlockState state, LivingEntity player, ItemStack stack) {
|
||||
if (!level.isClientSide) {
|
||||
FluidStorageNetworkNode storage = ((FluidStorageTile) level.getBlockEntity(pos)).getNode();
|
||||
|
||||
if (stack.hasTag() && stack.getTag().hasUUID(FluidStorageNetworkNode.NBT_ID)) {
|
||||
storage.setStorageId(stack.getTag().getUUID(FluidStorageNetworkNode.NBT_ID));
|
||||
@@ -46,7 +46,7 @@ public class FluidStorageBlock extends NetworkNodeBlock {
|
||||
}
|
||||
|
||||
// Call this after loading the storage, so the network discovery can use the loaded storage.
|
||||
super.setPlacedBy(world, pos, state, player, stack);
|
||||
super.setPlacedBy(level, pos, state, player, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,10 +56,10 @@ public class FluidStorageBlock extends NetworkNodeBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui((ServerPlayer) player, new PositionalTileContainerProvider<FluidStorageTile>(
|
||||
((FluidStorageTile) world.getBlockEntity(pos)).getNode().getTitle(),
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui((ServerPlayer) player, new PositionalTileContainerProvider<FluidStorageTile>(
|
||||
((FluidStorageTile) level.getBlockEntity(pos)).getNode().getTitle(),
|
||||
(tile, windowId, inventory, p) -> new FluidStorageContainer(tile, player, windowId),
|
||||
pos
|
||||
), pos));
|
||||
|
@@ -4,7 +4,6 @@ import com.refinedmods.refinedstorage.RSBlocks;
|
||||
import com.refinedmods.refinedstorage.api.network.grid.GridType;
|
||||
import com.refinedmods.refinedstorage.apiimpl.API;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.grid.factory.GridBlockGridFactory;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.grid.GridTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.ColorMap;
|
||||
@@ -14,14 +13,11 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class GridBlock extends ColoredNetworkBlock {
|
||||
private final GridType type;
|
||||
|
||||
@@ -48,7 +44,7 @@ public class GridBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
ColorMap<GridBlock> map;
|
||||
switch (type) {
|
||||
case FLUID:
|
||||
@@ -67,13 +63,13 @@ public class GridBlock extends ColoredNetworkBlock {
|
||||
throw new IllegalStateException("Unexpected value: " + type);
|
||||
}
|
||||
|
||||
InteractionResult result = map.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
InteractionResult result = map.changeBlockColor(state, player.getItemInHand(hand), level, pos, player);
|
||||
if (result != InteractionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> API.instance().getGridManager().openGrid(GridBlockGridFactory.ID, (ServerPlayer) player, pos));
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> API.instance().getGridManager().openGrid(GridBlockGridFactory.ID, (ServerPlayer) player, pos));
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
|
@@ -4,7 +4,6 @@ import com.refinedmods.refinedstorage.block.shape.ShapeCache;
|
||||
import com.refinedmods.refinedstorage.container.ImporterContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.render.ConstantsCable;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.ImporterTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.CollisionUtils;
|
||||
@@ -26,8 +25,6 @@ import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ImporterBlock extends CableBlock {
|
||||
private static final VoxelShape LINE_NORTH_1 = box(6, 6, 4, 10, 10, 6);
|
||||
private static final VoxelShape LINE_NORTH_2 = box(5, 5, 2, 11, 11, 4);
|
||||
@@ -116,9 +113,9 @@ public class ImporterBlock extends CableBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!world.isClientSide && CollisionUtils.isInBounds(getLineShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide && CollisionUtils.isInBounds(getLineShape(state), pos, hit.getLocation())) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<ImporterTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.importer"),
|
||||
|
@@ -3,7 +3,6 @@ package com.refinedmods.refinedstorage.block;
|
||||
import com.refinedmods.refinedstorage.api.network.security.Permission;
|
||||
import com.refinedmods.refinedstorage.container.InterfaceContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.InterfaceTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
@@ -13,15 +12,12 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class InterfaceBlock extends NetworkNodeBlock {
|
||||
public InterfaceBlock() {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
@@ -34,9 +30,9 @@ public class InterfaceBlock extends NetworkNodeBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attempt(world, pos, player, () -> NetworkHooks.openGui(
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attempt(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<InterfaceTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.interface"),
|
||||
|
@@ -34,22 +34,22 @@ public abstract class NetworkNodeBlock extends BaseBlock implements EntityBlock
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, world, pos, blockIn, fromPos, isMoving);
|
||||
public void neighborChanged(BlockState state, Level level, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
super.neighborChanged(state, level, pos, blockIn, fromPos, isMoving);
|
||||
|
||||
if (!world.isClientSide) {
|
||||
INetworkNode node = API.instance().getNetworkNodeManager((ServerLevel) world).getNode(pos);
|
||||
if (!level.isClientSide) {
|
||||
INetworkNode node = API.instance().getNetworkNodeManager((ServerLevel) level).getNode(pos);
|
||||
if (node instanceof NetworkNode) {
|
||||
((NetworkNode) node).setRedstonePowered(world.hasNeighborSignal(pos));
|
||||
((NetworkNode) node).setRedstonePowered(level.hasNeighborSignal(pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state.getBlock() != newState.getBlock()) {
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
|
||||
if (tile instanceof NetworkNodeTile) {
|
||||
IItemHandler handler = ((NetworkNodeTile) tile).getNode().getDrops();
|
||||
@@ -61,20 +61,20 @@ public abstract class NetworkNodeBlock extends BaseBlock implements EntityBlock
|
||||
drops.add(handler.getStackInSlot(i));
|
||||
}
|
||||
|
||||
Containers.dropContents(world, pos, drops);
|
||||
Containers.dropContents(level, pos, drops);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Call onReplaced after the drops check so the tile still exists
|
||||
super.onRemove(state, world, pos, newState, isMoving);
|
||||
super.onRemove(state, level, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDirectionChanged(Level world, BlockPos pos, Direction newDirection) {
|
||||
super.onDirectionChanged(world, pos, newDirection);
|
||||
protected void onDirectionChanged(Level level, BlockPos pos, Direction newDirection) {
|
||||
super.onDirectionChanged(level, pos, newDirection);
|
||||
|
||||
BlockEntity tile = world.getBlockEntity(pos);
|
||||
BlockEntity tile = level.getBlockEntity(pos);
|
||||
if (tile instanceof INetworkNodeProxy) {
|
||||
INetworkNode node = ((INetworkNodeProxy) tile).getNode();
|
||||
|
||||
|
@@ -1,21 +1,17 @@
|
||||
package com.refinedmods.refinedstorage.block;
|
||||
|
||||
import com.refinedmods.refinedstorage.RSBlocks;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.NetworkReceiverTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class NetworkReceiverBlock extends ColoredNetworkBlock {
|
||||
public NetworkReceiverBlock() {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
@@ -32,7 +28,8 @@ public class NetworkReceiverBlock extends ColoredNetworkBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
return RSBlocks.NETWORK_RECEIVER.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
return RSBlocks.NETWORK_RECEIVER.changeBlockColor(state, player.getItemInHand(hand), level, pos, player);
|
||||
}
|
||||
}
|
||||
|
@@ -30,14 +30,14 @@ public class NetworkTransmitterBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.NETWORK_TRANSMITTER.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.NETWORK_TRANSMITTER.changeBlockColor(state, player.getItemInHand(hand), level, pos, player);
|
||||
if (result != InteractionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<NetworkTransmitterTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.network_transmitter"),
|
||||
|
@@ -83,23 +83,23 @@ public class PortableGridBlock extends BaseBlock implements EntityBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!world.isClientSide) {
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
if (!level.isClientSide) {
|
||||
API.instance().getGridManager().openGrid(PortableGridBlockGridFactory.ID, (ServerPlayer) player, pos);
|
||||
|
||||
((PortableGridTile) world.getBlockEntity(pos)).onOpened();
|
||||
((PortableGridTile) level.getBlockEntity(pos)).onOpened();
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
super.setPlacedBy(world, pos, state, placer, stack);
|
||||
public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) {
|
||||
super.setPlacedBy(level, pos, state, placer, stack);
|
||||
|
||||
if (!world.isClientSide) {
|
||||
((PortableGridTile) world.getBlockEntity(pos)).applyDataFromItemToTile(stack);
|
||||
((PortableGridTile) world.getBlockEntity(pos)).updateState();
|
||||
if (!level.isClientSide) {
|
||||
((PortableGridTile) level.getBlockEntity(pos)).applyDataFromItemToTile(stack);
|
||||
((PortableGridTile) level.getBlockEntity(pos)).updateState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package com.refinedmods.refinedstorage.block;
|
||||
import com.refinedmods.refinedstorage.RSBlocks;
|
||||
import com.refinedmods.refinedstorage.container.RelayContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.RelayTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
@@ -13,15 +12,12 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class RelayBlock extends ColoredNetworkBlock {
|
||||
public RelayBlock() {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
@@ -34,14 +30,14 @@ public class RelayBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.RELAY.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.RELAY.changeBlockColor(state, player.getItemInHand(hand), level, pos, player);
|
||||
if (result != InteractionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<RelayTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.relay"),
|
||||
|
@@ -31,13 +31,13 @@ public class SecurityManagerBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.SECURITY_MANAGER.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.SECURITY_MANAGER.changeBlockColor(state, player.getItemInHand(hand), level, pos, player);
|
||||
if (result != InteractionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
if (!level.isClientSide) {
|
||||
Runnable action = () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<SecurityManagerTile>(
|
||||
@@ -48,10 +48,10 @@ public class SecurityManagerBlock extends ColoredNetworkBlock {
|
||||
pos
|
||||
);
|
||||
|
||||
if (player.getGameProfile().getId().equals(((SecurityManagerTile) world.getBlockEntity(pos)).getNode().getOwner())) {
|
||||
if (player.getGameProfile().getId().equals(((SecurityManagerTile) level.getBlockEntity(pos)).getNode().getOwner())) {
|
||||
action.run();
|
||||
} else {
|
||||
return NetworkUtils.attempt(world, pos, player, action, Permission.MODIFY, Permission.SECURITY);
|
||||
return NetworkUtils.attempt(level, pos, player, action, Permission.MODIFY, Permission.SECURITY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,6 @@ import com.refinedmods.refinedstorage.apiimpl.network.node.storage.StorageNetwor
|
||||
import com.refinedmods.refinedstorage.apiimpl.storage.ItemStorageType;
|
||||
import com.refinedmods.refinedstorage.container.StorageContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.StorageTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
@@ -15,7 +14,6 @@ import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -38,9 +36,9 @@ public class StorageBlock extends NetworkNodeBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack stack) {
|
||||
if (!world.isClientSide) {
|
||||
StorageNetworkNode storage = ((StorageTile) world.getBlockEntity(pos)).getNode();
|
||||
public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack stack) {
|
||||
if (!level.isClientSide) {
|
||||
StorageNetworkNode storage = ((StorageTile) level.getBlockEntity(pos)).getNode();
|
||||
|
||||
if (stack.hasTag() && stack.getTag().hasUUID(StorageNetworkNode.NBT_ID)) {
|
||||
storage.setStorageId(stack.getTag().getUUID(StorageNetworkNode.NBT_ID));
|
||||
@@ -50,7 +48,7 @@ public class StorageBlock extends NetworkNodeBlock {
|
||||
}
|
||||
|
||||
// Call this after loading the storage, so the network discovery can use the loaded storage.
|
||||
super.setPlacedBy(world, pos, state, entity, stack);
|
||||
super.setPlacedBy(level, pos, state, entity, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,10 +58,10 @@ public class StorageBlock extends NetworkNodeBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui((ServerPlayer) player, new PositionalTileContainerProvider<StorageTile>(
|
||||
((StorageTile) world.getBlockEntity(pos)).getNode().getTitle(),
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui((ServerPlayer) player, new PositionalTileContainerProvider<StorageTile>(
|
||||
((StorageTile) level.getBlockEntity(pos)).getNode().getTitle(),
|
||||
(tile, windowId, inventory, p) -> new StorageContainer(tile, player, windowId),
|
||||
pos
|
||||
), pos));
|
||||
|
@@ -3,7 +3,6 @@ package com.refinedmods.refinedstorage.block;
|
||||
import com.refinedmods.refinedstorage.apiimpl.network.node.StorageMonitorNetworkNode;
|
||||
import com.refinedmods.refinedstorage.container.StorageMonitorContainer;
|
||||
import com.refinedmods.refinedstorage.container.factory.PositionalTileContainerProvider;
|
||||
import com.refinedmods.refinedstorage.tile.CrafterTile;
|
||||
import com.refinedmods.refinedstorage.tile.StorageMonitorTile;
|
||||
import com.refinedmods.refinedstorage.util.BlockUtils;
|
||||
import com.refinedmods.refinedstorage.util.NetworkUtils;
|
||||
@@ -15,7 +14,6 @@ import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -23,8 +21,6 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class StorageMonitorBlock extends NetworkNodeBlock {
|
||||
public StorageMonitorBlock() {
|
||||
super(BlockUtils.DEFAULT_ROCK_PROPERTIES);
|
||||
@@ -42,12 +38,12 @@ public class StorageMonitorBlock extends NetworkNodeBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!world.isClientSide) {
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
||||
if (!level.isClientSide) {
|
||||
ItemStack held = player.containerMenu.getCarried();
|
||||
|
||||
if (player.isCrouching()) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<StorageMonitorTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.storage_monitor"),
|
||||
@@ -57,7 +53,7 @@ public class StorageMonitorBlock extends NetworkNodeBlock {
|
||||
pos
|
||||
));
|
||||
} else {
|
||||
StorageMonitorNetworkNode storageMonitor = ((StorageMonitorTile) world.getBlockEntity(pos)).getNode();
|
||||
StorageMonitorNetworkNode storageMonitor = ((StorageMonitorTile) level.getBlockEntity(pos)).getNode();
|
||||
|
||||
if (!held.isEmpty()) {
|
||||
return storageMonitor.deposit(player, held);
|
||||
@@ -72,17 +68,17 @@ public class StorageMonitorBlock extends NetworkNodeBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void attack(BlockState state, Level world, BlockPos pos, Player player) {
|
||||
super.attack(state, world, pos, player);
|
||||
public void attack(BlockState state, Level level, BlockPos pos, Player player) {
|
||||
super.attack(state, level, pos, player);
|
||||
|
||||
if (!world.isClientSide) {
|
||||
HitResult result = WorldUtils.rayTracePlayer(world, player);
|
||||
if (!level.isClientSide) {
|
||||
HitResult result = WorldUtils.rayTracePlayer(level, player);
|
||||
|
||||
if (!(result instanceof BlockHitResult)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((StorageMonitorTile) world.getBlockEntity(pos)).getNode().extract(player, ((BlockHitResult) result).getDirection());
|
||||
((StorageMonitorTile) level.getBlockEntity(pos)).getNode().extract(player, ((BlockHitResult) result).getDirection());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -72,14 +72,14 @@ public class WirelessTransmitterBlock extends ColoredNetworkBlock {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.WIRELESS_TRANSMITTER.changeBlockColor(state, player.getItemInHand(hand), world, pos, player);
|
||||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||
InteractionResult result = RSBlocks.WIRELESS_TRANSMITTER.changeBlockColor(state, player.getItemInHand(hand), level, pos, player);
|
||||
if (result != InteractionResult.PASS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!world.isClientSide) {
|
||||
return NetworkUtils.attemptModify(world, pos, player, () -> NetworkHooks.openGui(
|
||||
if (!level.isClientSide) {
|
||||
return NetworkUtils.attemptModify(level, pos, player, () -> NetworkHooks.openGui(
|
||||
(ServerPlayer) player,
|
||||
new PositionalTileContainerProvider<WirelessTransmitterTile>(
|
||||
new TranslatableComponent("gui.refinedstorage.wireless_transmitter"),
|
||||
|
@@ -60,9 +60,9 @@ public class ListNetworkCommand implements Command<CommandSourceStack> {
|
||||
|
||||
@Override
|
||||
public int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerLevel world = DimensionArgument.getDimension(context, "dimension");
|
||||
ServerLevel level = DimensionArgument.getDimension(context, "dimension");
|
||||
|
||||
API.instance().getNetworkManager(world)
|
||||
API.instance().getNetworkManager(level)
|
||||
.all()
|
||||
.stream()
|
||||
.map(NetworkInList::new)
|
||||
|
@@ -15,10 +15,10 @@ import net.minecraft.server.level.ServerLevel;
|
||||
public abstract class NetworkCommand implements Command<CommandSourceStack> {
|
||||
@Override
|
||||
public int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
|
||||
ServerLevel world = DimensionArgument.getDimension(context, "dimension");
|
||||
ServerLevel level = DimensionArgument.getDimension(context, "dimension");
|
||||
BlockPos pos = BlockPosArgument.getLoadedBlockPos(context, "pos");
|
||||
|
||||
INetwork network = API.instance().getNetworkManager(world).getNetwork(pos);
|
||||
INetwork network = API.instance().getNetworkManager(level).getNetwork(pos);
|
||||
|
||||
if (network == null) {
|
||||
context.getSource().sendFailure(new TranslatableComponent("commands.refinedstorage.network.get.error.not_found"));
|
||||
|
@@ -15,9 +15,9 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class NetworkPositionSuggestionProvider implements SuggestionProvider<CommandSourceStack> {
|
||||
@Override
|
||||
public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandSourceStack> context, SuggestionsBuilder builder) throws CommandSyntaxException {
|
||||
ServerLevel world = DimensionArgument.getDimension(context, "dimension");
|
||||
ServerLevel level = DimensionArgument.getDimension(context, "dimension");
|
||||
|
||||
API.instance().getNetworkManager(world).all().forEach(network -> builder.suggest(network.getPosition().getX() + " " + network.getPosition().getY() + " " + network.getPosition().getZ()));
|
||||
API.instance().getNetworkManager(level).all().forEach(network -> builder.suggest(network.getPosition().getX() + " " + network.getPosition().getY() + " " + network.getPosition().getZ()));
|
||||
|
||||
return builder.buildFuture();
|
||||
}
|
||||
|
@@ -18,9 +18,9 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class AutocraftingIdSuggestionProvider implements SuggestionProvider<CommandSourceStack> {
|
||||
@Override
|
||||
public CompletableFuture<Suggestions> getSuggestions(CommandContext<CommandSourceStack> context, SuggestionsBuilder builder) throws CommandSyntaxException {
|
||||
ServerLevel world = DimensionArgument.getDimension(context, "dimension");
|
||||
ServerLevel level = DimensionArgument.getDimension(context, "dimension");
|
||||
BlockPos pos = BlockPosArgument.getLoadedBlockPos(context, "pos");
|
||||
INetwork network = API.instance().getNetworkManager(world).getNetwork(pos);
|
||||
INetwork network = API.instance().getNetworkManager(level).getNetwork(pos);
|
||||
|
||||
if (network != null) {
|
||||
network.getCraftingManager().getTasks().forEach(task -> builder.suggest(task.getId().toString()));
|
||||
|
@@ -116,7 +116,7 @@ public class CrafterManagerContainer extends BaseContainer {
|
||||
if (stack.isEmpty()) {
|
||||
visible = false;
|
||||
} else {
|
||||
ICraftingPattern pattern = PatternItem.fromCache(crafterManager.getWorld(), stack);
|
||||
ICraftingPattern pattern = PatternItem.fromCache(crafterManager.getLevel(), stack);
|
||||
|
||||
visible = false;
|
||||
|
||||
|
@@ -20,7 +20,6 @@ import com.refinedmods.refinedstorage.screen.IScreenInfoProvider;
|
||||
import com.refinedmods.refinedstorage.tile.BaseTile;
|
||||
import com.refinedmods.refinedstorage.tile.config.IType;
|
||||
import com.refinedmods.refinedstorage.tile.grid.portable.IPortableGrid;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@@ -6,7 +6,7 @@ import com.refinedmods.refinedstorage.tile.CrafterManagerTile;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraftforge.network.IContainerFactory;
|
||||
import net.minecraftforge.network.IContainerFactory;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
@@ -25,10 +25,10 @@ public class CrafterManagerContainerProvider implements MenuProvider {
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
public static void writeToBuffer(FriendlyByteBuf buf, Level world, BlockPos pos) {
|
||||
public static void writeToBuffer(FriendlyByteBuf buf, Level level, BlockPos pos) {
|
||||
buf.writeBlockPos(pos);
|
||||
|
||||
Map<Component, List<IItemHandlerModifiable>> containerData = ((CrafterManagerTile) world.getBlockEntity(pos)).getNode().getNetwork().getCraftingManager().getNamedContainers();
|
||||
Map<Component, List<IItemHandlerModifiable>> containerData = ((CrafterManagerTile) level.getBlockEntity(pos)).getNode().getNetwork().getCraftingManager().getNamedContainers();
|
||||
|
||||
buf.writeInt(containerData.size());
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user