Merge pull request #28 from TheRealM18/1.20.1

1.20.1 Pushing all of Perkins changes + extras
This commit is contained in:
Jackson Abney
2025-02-21 13:24:08 -09:00
committed by GitHub
743 changed files with 7636 additions and 2781 deletions

View File

@@ -39,7 +39,7 @@ If applicable, add screenshots to help explain your problem.
**Versions (please complete the following information):**
- Minecraft: [e.g. 1.18.2]
- Forge: [e.g. 40.0.40]
- oc2r: [e.g. 0.1.7]
- oc2: [e.g. 0.1.7]
**Additional context**
Add any other context about the problem here.

2
.gitignore vendored
View File

@@ -34,5 +34,7 @@ forge*changelog.txt
#vscode
.vscode
libs/
# Don't ignore bin from scripts
!/src/main/scripts/bin/

View File

@@ -26,13 +26,13 @@ The original section that was found here is preserved below, however it should b
~~While the mod isn't quite yet ready for release due to some remaining technical and usability issues, the API should be mostly stable at this point. For most people the high level device API will be sufficient, and is much more accessible. It centers around the [`RPCDevice`][RPC Device]. For a sample block implementation, see the [redstone interface]. For a sample item implementation, see the [sound card]. If you wish to dive deeper, and provide emulated hardware that requires a Linux driver, this centers around the [`VMDevice`][VM Device]. For a sample block implementation, see the [disk drive]. For a sample item implementation, see the [network card].~~
[OpenComputers]: https://github.com/MightyPirates/OpenComputers
[RPC Device]: src/main/java/li/cil/oc2r/api/bus/device/rpc/RPCDevice.java
[redstone interface]: src/main/java/li/cil/oc2r/common/blockentity/RedstoneInterfaceBlockEntity.java
[sound card]: src/main/java/li/cil/oc2r/common/bus/device/rpc/item/SoundCardItemDevice.java
[VM Device]: src/main/java/li/cil/oc2r/api/bus/device/vm/VMDevice.java
[disk drive]: src/main/java/li/cil/oc2r/common/blockentity/DiskDriveBlockEntity.java
[network card]: src/main/java/li/cil/oc2r/common/bus/device/vm/item/NetworkInterfaceCardDevice.java
[documentation]: src/main/resources/assets/oc2r/doc/en_us/index.md
[RPC Device]: src/main/java/li/cil/oc2/api/bus/device/rpc/RPCDevice.java
[redstone interface]: src/main/java/li/cil/oc2/common/blockentity/RedstoneInterfaceBlockEntity.java
[sound card]: src/main/java/li/cil/oc2/common/bus/device/rpc/item/SoundCardItemDevice.java
[VM Device]: src/main/java/li/cil/oc2/api/bus/device/vm/VMDevice.java
[disk drive]: src/main/java/li/cil/oc2/common/blockentity/DiskDriveBlockEntity.java
[network card]: src/main/java/li/cil/oc2/common/bus/device/vm/item/NetworkInterfaceCardDevice.java
[documentation]: src/main/resources/assets/oc2/doc/en_us/index.md
[GithubPackagesGradle]: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry
[Sangar (fnuecke)]: https://github.com/fnuecke
[Sedna]: https://github.com/fnuecke/sedna

View File

@@ -8,6 +8,8 @@ plugins {
apply plugin: 'org.spongepowered.mixin'
apply from: "minecraft.gradle"
apply plugin: "java"
jarJar.enable()
allprojects {
gradle.projectsEvaluated {
@@ -71,6 +73,10 @@ repositories {
}
}
}
flatDir {
dirs("libs")
}
}
dependencies {
@@ -86,7 +92,8 @@ dependencies {
compileOnly "li.cil.sedna:sedna:2.0.8"
compileOnly "li.cil.sedna:sedna-buildroot:0.0.8"
}
implementation "curse.maven:sedna-511276:3885542"
implementation fileTree(dir: 'libs', include: '*.jar')
// implementation "curse.maven:sedna-511276:3885542"
minecraftLibrary "org.apache.commons:commons-collections4:4.4"
implementation fg.deobf("curse.maven:markdownmanual-502485:4873115")
@@ -121,13 +128,16 @@ dependencies {
testImplementation "org.mockito:mockito-inline:4.3.1"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.2"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.2"
jarJar(group: 'libs', name: 'sedna', version: '[]') {
jarJar.pin(it, "")
}
}
System.setProperty("line.separator", "\n")
task packageScripts(type: Zip) {
archiveFileName = "scripts.zip"
destinationDirectory = file("$buildDir/resources/main/data/oc2r/file_systems")
destinationDirectory = file("$buildDir/resources/main/data/oc2/file_systems")
from "src/main/scripts"
filter { line -> line }
}
@@ -141,6 +151,9 @@ task copyLicensesToResources(type: Copy) {
processResources.dependsOn(packageScripts)
processResources.dependsOn(copyLicensesToResources)
tasks.named('jarJar'){
}
minecraft {
mappings channel: "official", version: minecraft_version
@@ -152,7 +165,7 @@ minecraft {
property "forge.logging.console.level", "debug"
mods {
oc2r {
oc2 {
source sourceSets.main
}
}
@@ -232,6 +245,7 @@ publishing {
version = semver
artifact jar
artifact apiJar
jarJar.component(it)
}
}
repositories {
@@ -274,3 +288,7 @@ idea {
test {
useJUnitPlatform()
}
compileJava {
options.encoding = "UTF-8"
}

View File

@@ -5,7 +5,7 @@ org.gradle.daemon=false
forge_version=47.2.32
semver=1.1.0
semver=1.3.1
curse_project_id=1037738

View File

@@ -1,11 +1,11 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api;
package li.cil.oc2.api;
import com.google.gson.GsonBuilder;
import li.cil.oc2r.api.bus.device.object.Callback;
import li.cil.oc2r.api.bus.device.rpc.RPCMethod;
import li.cil.oc2r.api.imc.RPCMethodParameterTypeAdapter;
import li.cil.oc2.api.bus.device.object.Callback;
import li.cil.oc2.api.bus.device.rpc.RPCMethod;
import li.cil.oc2.api.imc.RPCMethodParameterTypeAdapter;
import java.lang.reflect.Type;

View File

@@ -1,6 +1,6 @@
# The OpenComputer II API
Welcome to the API of `oc2r`, fellow developer! This document will hopefully provide a sufficient overview of what
Welcome to the API of `oc2`, fellow developer! This document will hopefully provide a sufficient overview of what
integrations this API allows, and how to best implement them. The primary purpose of the API is to allow other mods to
implement their own devices, to be used by the computers in this mod.
@@ -150,15 +150,15 @@ In this example, a device is made available for a custom `BlockEntity`.
Using capabilities:
```java
import li.cil.oc2r.api.bus.device.object.Callback;
import li.cil.oc2r.api.bus.device.object.ObjectDevice;
import li.cil.oc2r.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.object.Callback;
import li.cil.oc2.api.bus.device.object.ObjectDevice;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.ModList;
import li.cil.oc2r.api.bus.device.Device;
import li.cil.oc2.api.bus.device.Device;
class ModBlockEntity extends BlockEntity {
public int getMagicValue() {
@@ -167,7 +167,7 @@ class ModBlockEntity extends BlockEntity {
@Override
public <T> LazyOptional<T> getCapability(Capability<T> cap, @Nullable Direction side) {
if (ModList.get().isLoaded("oc2r")) {
if (ModList.get().isLoaded("oc2")) {
// Note: you can also store this and invalidate the capability to remove the
// device/trigger the device bus to scan for changes in available devices.
LazyOptional<T> device = getDeviceCapability();
@@ -212,7 +212,7 @@ class Integration {
Using the `Callback` annotation in the `BlockEntity` (hard dependency):
```java
import li.cil.oc2r.api.bus.device.object.Callback;
import li.cil.oc2.api.bus.device.object.Callback;
import net.minecraft.world.level.block.entity.BlockEntity;
class ModBlockEntity extends BlockEntity {
@@ -229,14 +229,14 @@ devices to third-party `BlockEntities`.
### Block Device for a Third-Party `BlockEntity`
In this example, a simple device providing a single method, `squareRoot`, is made available for the `FurnaceBlockEntity`
. As long as the registration of the `BlockDeviceProvider` is gated behind a check, whether `oc2r` is present, this is a
. As long as the registration of the `BlockDeviceProvider` is gated behind a check, whether `oc2` is present, this is a
soft dependency.
Using `ObjectDevice`:
```java
import li.cil.oc2r.api.bus.device.object.Callback;
import li.cil.oc2r.api.bus.device.object.ObjectDevice;
import li.cil.oc2.api.bus.device.object.Callback;
import li.cil.oc2.api.bus.device.object.ObjectDevice;
import net.minecraft.world.level.block.entity.BlockEntity;
class MyCalculatorDevice {
@@ -264,14 +264,14 @@ class ModDeviceProvider extends ForgeRegistryEntry<BlockDeviceProvider> implemen
Using the `RPCDevice` and `RPCMethods` interfaces directly:
```java
import li.cil.oc2r.api.bus.device.Device;
import li.cil.oc2r.api.bus.device.provider.BlockDeviceProvider;
import li.cil.oc2r.api.bus.device.provider.BlockDeviceQuery;
import li.cil.oc2r.api.bus.device.rpc.RPCDevice;
import li.cil.oc2r.api.bus.device.rpc.RPCMethod;
import li.cil.oc2r.api.bus.device.rpc.RPCMethodGroup;
import li.cil.oc2r.api.bus.device.rpc.RPCParameter;
import li.cil.oc2r.api.util.Invalidatable;
import li.cil.oc2.api.bus.device.Device;
import li.cil.oc2.api.bus.device.provider.BlockDeviceProvider;
import li.cil.oc2.api.bus.device.provider.BlockDeviceQuery;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.rpc.RPCMethod;
import li.cil.oc2.api.bus.device.rpc.RPCMethodGroup;
import li.cil.oc2.api.bus.device.rpc.RPCParameter;
import li.cil.oc2.api.util.Invalidatable;
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
import java.util.Collections;
@@ -333,7 +333,7 @@ class ModDeviceProvider extends ForgeRegistryEntry<BlockDeviceProvider> implemen
Shared device provider registration:
```java
import li.cil.oc2r.api.bus.device.provider.BlockDeviceProvider;
import li.cil.oc2.api.bus.device.provider.BlockDeviceProvider;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
@@ -341,7 +341,7 @@ class Providers {
static final DeferredRegister<BlockDeviceProvider> BLOCK_DEVICE_PROVIDERS =
DeferredRegister.create(BlockDeviceProvider.class, "my_mod_id");
// Called from mod initialization, if oc2r is present.
// Called from mod initialization, if oc2 is present.
static void initialize() {
BLOCK_DEVICE_PROVIDERS.register("my_calculator_device", ModDeviceProvider::new);

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus;
package li.cil.oc2.api.bus;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelAccessor;

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus;
package li.cil.oc2.api.bus;
import li.cil.oc2r.api.bus.device.Device;
import li.cil.oc2.api.bus.device.Device;
import java.util.Collection;

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus;
package li.cil.oc2.api.bus;
import li.cil.oc2r.api.bus.device.Device;
import li.cil.oc2.api.bus.device.Device;
import java.util.Set;
import java.util.UUID;

View File

@@ -1,9 +1,9 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus;
package li.cil.oc2.api.bus;
import li.cil.oc2r.api.bus.device.Device;
import li.cil.oc2r.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.Device;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import net.minecraftforge.common.util.LazyOptional;
import java.util.Collection;

View File

@@ -1,9 +1,9 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device;
package li.cil.oc2.api.bus.device;
import li.cil.oc2r.api.bus.DeviceBus;
import li.cil.oc2r.api.bus.DeviceBusController;
import li.cil.oc2.api.bus.DeviceBus;
import li.cil.oc2.api.bus.DeviceBusController;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device;
package li.cil.oc2.api.bus.device;
import li.cil.oc2r.api.API;
import li.cil.oc2.api.API;
import net.minecraft.core.Registry;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device;
package li.cil.oc2.api.bus.device;
import li.cil.oc2r.api.API;
import li.cil.oc2.api.API;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.RegistryObject;

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device;
package li.cil.oc2.api.bus.device;
import li.cil.oc2r.api.bus.device.provider.ItemDeviceProvider;
import li.cil.oc2.api.bus.device.provider.ItemDeviceProvider;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.data;
package li.cil.oc2.api.bus.device.data;
import li.cil.sedna.api.device.BlockDevice;
import net.minecraft.network.chat.Component;
@@ -13,15 +13,15 @@ import net.minecraft.network.chat.Component;
* This is used for the built-in Linux root file-system, for example.
* <p>
* To make use of registered implementations, a hard drive item with the
* string tag {@code oc2r.base} referencing the implementation's registry id
* string tag {@code oc2.base} referencing the implementation's registry id
* must be created. For example, if the implementation's registry name is
* {@code my_mod:my_block_device}:
* <pre>
* /give ? oc2r:hard_drive{oc2r:{data:"my_mod:my_block_device"}}
* /give ? oc2:hard_drive{oc2:{data:"my_mod:my_block_device"}}
* </pre>
* The drive can be made readonly by also specifying the {@code readonly} tag:
* <pre>
* /give ? oc2r:hard_drive{oc2r:{data:"my_mod:my_block_device",readonly:true}}
* /give ? oc2:hard_drive{oc2:{data:"my_mod:my_block_device",readonly:true}}
* </pre>
*/
public interface BlockDeviceData {

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.data;
package li.cil.oc2.api.bus.device.data;
import li.cil.sedna.api.memory.MemoryMap;
import net.minecraft.network.chat.Component;
@@ -12,11 +12,11 @@ import net.minecraft.network.chat.Component;
* This is used for the built-in OpenSBI firmware and Linux kernel, for example.
* <p>
* To make use of registered implementations, a flash memory item with the
* string tag {@code oc2r.firmware} referencing the implementation's registry name
* string tag {@code oc2.firmware} referencing the implementation's registry name
* must be created. For example, if the implementation's registry name is
* {@code my_mod:my_firmware}:
* <pre>
* /give &#64;p oc2r:flash_memory{oc2r:{firmware:"my_mod:my_firmware"}}
* /give &#64;p oc2:flash_memory{oc2:{firmware:"my_mod:my_firmware"}}
* </pre>
*/
public interface Firmware {

View File

@@ -2,7 +2,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2r.api.bus.device.rpc;
package li.cil.oc2.api.bus.device.data;
import net.minecraft.MethodsReturnNonnullByDefault;

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.object;
package li.cil.oc2.api.bus.device.object;
import li.cil.oc2r.api.bus.device.rpc.RPCMethod;
import li.cil.oc2.api.bus.device.rpc.RPCMethod;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -17,7 +17,7 @@ import java.lang.annotation.Target;
* <p>
* Method parameters are serialized and deserialized using Gson. When using custom
* parameter types it may be necessary to register a custom type adapter for them
* via {@link li.cil.oc2r.api.API#IMC_ADD_RPC_METHOD_PARAMETER_TYPE_ADAPTER}.
* via {@link li.cil.oc2.api.API#IMC_ADD_RPC_METHOD_PARAMETER_TYPE_ADAPTER}.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)

View File

@@ -1,11 +1,11 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.object;
package li.cil.oc2.api.bus.device.object;
import li.cil.oc2r.api.bus.device.rpc.AbstractRPCMethod;
import li.cil.oc2r.api.bus.device.rpc.RPCMethod;
import li.cil.oc2r.api.bus.device.rpc.RPCMethodGroup;
import li.cil.oc2r.api.bus.device.rpc.RPCParameter;
import li.cil.oc2.api.bus.device.rpc.AbstractRPCMethod;
import li.cil.oc2.api.bus.device.rpc.RPCMethod;
import li.cil.oc2.api.bus.device.rpc.RPCMethodGroup;
import li.cil.oc2.api.bus.device.rpc.RPCParameter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.Strings;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.object;
package li.cil.oc2.api.bus.device.object;
/**
* This interface is used to declare callback documentation on targets of an {@link ObjectDevice}.

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.object;
package li.cil.oc2.api.bus.device.object;
import li.cil.oc2r.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.entity.BlockEntity;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.object;
package li.cil.oc2.api.bus.device.object;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;

View File

@@ -1,11 +1,12 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.object;
package li.cil.oc2.api.bus.device.object;
import li.cil.oc2r.api.bus.device.ItemDevice;
import li.cil.oc2r.api.bus.device.rpc.RPCDevice;
import li.cil.oc2r.api.bus.device.rpc.RPCMethod;
import li.cil.oc2r.api.bus.device.rpc.RPCMethodGroup;
import li.cil.oc2.api.bus.device.ItemDevice;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.rpc.RPCMethod;
import li.cil.oc2.api.bus.device.rpc.RPCMethodGroup;
import li.cil.oc2.api.bus.device.rpc.RPCEventSource;
import javax.annotation.Nullable;
import java.util.ArrayList;
@@ -83,6 +84,12 @@ public final class ObjectDevice implements RPCDevice, ItemDevice {
}
///////////////////////////////////////////////////////////////////
public RPCEventSource asEventSource() {
if (object instanceof RPCEventSource res) {
return res;
}
return null;
}
@Override
public List<String> getTypeNames() {

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.object;
package li.cil.oc2.api.bus.device.object;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@@ -0,0 +1,9 @@
/* SPDX-License-Identifier: MIT */
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2.api.bus.device.object;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -0,0 +1,9 @@
/* SPDX-License-Identifier: MIT */
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2.api.bus.device;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -1,11 +1,11 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.provider;
package li.cil.oc2.api.bus.device.provider;
import li.cil.oc2r.api.bus.device.Device;
import li.cil.oc2r.api.bus.device.rpc.RPCDevice;
import li.cil.oc2r.api.bus.device.vm.VMDevice;
import li.cil.oc2r.api.util.Invalidatable;
import li.cil.oc2.api.bus.device.Device;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.vm.VMDevice;
import li.cil.oc2.api.util.Invalidatable;
import net.minecraft.nbt.CompoundTag;
/**
@@ -21,7 +21,7 @@ import net.minecraft.nbt.CompoundTag;
* previous scan.
* <p>
* This is also required to avoid device duplication when a device is connected to a
* {@link li.cil.oc2r.api.bus.DeviceBus} more than once. An example where this can occur are
* {@link li.cil.oc2.api.bus.DeviceBus} more than once. An example where this can occur are
* blocks that expose the same device on all sides having connected cabling adjacent to more
* than one face.
* <p>
@@ -39,9 +39,9 @@ import net.minecraft.nbt.CompoundTag;
* }
* </pre>
*
* @see li.cil.oc2r.api.bus.device.rpc.RPCDevice
* @see li.cil.oc2r.api.bus.device.object.ObjectDevice
* @see li.cil.oc2r.api.bus.device.vm.VMDevice
* @see li.cil.oc2.api.bus.device.rpc.RPCDevice
* @see li.cil.oc2.api.bus.device.object.ObjectDevice
* @see li.cil.oc2.api.bus.device.vm.VMDevice
* @see BlockDeviceQuery
*/
public interface BlockDeviceProvider {

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.provider;
package li.cil.oc2.api.bus.device.provider;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View File

@@ -1,10 +1,10 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.provider;
package li.cil.oc2.api.bus.device.provider;
import li.cil.oc2r.api.bus.device.ItemDevice;
import li.cil.oc2r.api.bus.device.rpc.RPCDevice;
import li.cil.oc2r.api.bus.device.vm.VMDevice;
import li.cil.oc2.api.bus.device.ItemDevice;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.vm.VMDevice;
import net.minecraft.nbt.CompoundTag;
import javax.annotation.Nullable;
@@ -36,9 +36,9 @@ import java.util.Optional;
* }
* </pre>
*
* @see li.cil.oc2r.api.bus.device.rpc.RPCDevice
* @see li.cil.oc2r.api.bus.device.object.ObjectDevice
* @see li.cil.oc2r.api.bus.device.vm.VMDevice
* @see li.cil.oc2.api.bus.device.rpc.RPCDevice
* @see li.cil.oc2.api.bus.device.object.ObjectDevice
* @see li.cil.oc2.api.bus.device.vm.VMDevice
* @see ItemDeviceQuery
*/
public interface ItemDeviceProvider {

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.provider;
package li.cil.oc2.api.bus.device.provider;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;

View File

@@ -0,0 +1,9 @@
/* SPDX-License-Identifier: MIT */
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2.api.bus.device.provider;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.rpc;
package li.cil.oc2.api.bus.device.rpc;
import javax.annotation.Nullable;

View File

@@ -0,0 +1,14 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2.api.bus.device.rpc;
import com.google.gson.JsonElement;
import java.util.UUID;
/**
* This interface handles events coming from RPCEventSources.
* RPCDeviceBusAdapter implements this to relay events via the built in serial
*/
public interface IEventSink {
void postEvent(UUID sourceid, JsonElement msg);
}

View File

@@ -1,10 +1,10 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.rpc;
package li.cil.oc2.api.bus.device.rpc;
import li.cil.oc2r.api.bus.DeviceBus;
import li.cil.oc2r.api.bus.device.Device;
import li.cil.oc2r.api.bus.device.object.ObjectDevice;
import li.cil.oc2.api.bus.DeviceBus;
import li.cil.oc2.api.bus.device.Device;
import li.cil.oc2.api.bus.device.object.ObjectDevice;
import java.util.List;
@@ -47,8 +47,8 @@ import java.util.List;
* </pre>
*
* @see ObjectDevice
* @see li.cil.oc2r.api.bus.device.provider.BlockDeviceProvider
* @see li.cil.oc2r.api.bus.device.provider.ItemDeviceProvider
* @see li.cil.oc2.api.bus.device.provider.BlockDeviceProvider
* @see li.cil.oc2.api.bus.device.provider.ItemDeviceProvider
*/
public interface RPCDevice extends Device {
/**

View File

@@ -0,0 +1,24 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2.api.bus.device.rpc;
import java.util.*;
/**
* Provides an interface for an RPC event source. Blocks which whish to provide
* push notifications via the /dev/hvc0 serial devices should implement this.
* It is generally recommended to *also* provide documentation and a list of
* events by implementing DocumentedDevice and providing a listEvents() callback
* <p>
*/
public interface RPCEventSource {
/**
* Called to add a {@link IEventSink} to the list of consumers.
*/
void subscribe(IEventSink dba, UUID sourceid);
/**
* Called to remove a specific {@link IEventSink} from the list of consumers.
*/
void unsubscribe(IEventSink dba);
}

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.rpc;
package li.cil.oc2.api.bus.device.rpc;
import com.google.gson.Gson;
import com.google.gson.JsonArray;

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.rpc;
package li.cil.oc2.api.bus.device.rpc;
import li.cil.oc2r.api.bus.device.object.ObjectDevice;
import li.cil.oc2.api.bus.device.object.ObjectDevice;
import javax.annotation.Nullable;
import java.util.Collections;
@@ -17,7 +17,7 @@ import java.util.Set;
* <p>
* Method parameters are serialized and deserialized using Gson. When using custom
* parameter types it may be necessary to register a custom type adapter for them
* via {@link li.cil.oc2r.api.API#IMC_ADD_RPC_METHOD_PARAMETER_TYPE_ADAPTER}.
* via {@link li.cil.oc2.api.API#IMC_ADD_RPC_METHOD_PARAMETER_TYPE_ADAPTER}.
*
* @see ObjectDevice
*/

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.rpc;
package li.cil.oc2.api.bus.device.rpc;
import li.cil.oc2r.api.bus.DeviceBusController;
import li.cil.oc2.api.bus.DeviceBusController;
import java.util.Collections;
import java.util.Optional;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.rpc;
package li.cil.oc2.api.bus.device.rpc;
import java.util.Optional;

View File

@@ -2,7 +2,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2r.api.bus.device.vm;
package li.cil.oc2.api.bus.device.rpc;
import net.minecraft.MethodsReturnNonnullByDefault;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm;
package li.cil.oc2.api.bus.device.vm;
/**
* This interface serves as a marker for devices that load firmware.

View File

@@ -1,12 +1,12 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm;
package li.cil.oc2.api.bus.device.vm;
import li.cil.oc2r.api.bus.DeviceBus;
import li.cil.oc2r.api.bus.device.Device;
import li.cil.oc2r.api.bus.device.rpc.RPCDevice;
import li.cil.oc2r.api.bus.device.vm.context.InterruptAllocator;
import li.cil.oc2r.api.bus.device.vm.context.VMContext;
import li.cil.oc2.api.bus.DeviceBus;
import li.cil.oc2.api.bus.device.Device;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.vm.context.InterruptAllocator;
import li.cil.oc2.api.bus.device.vm.context.VMContext;
import li.cil.sedna.api.device.MemoryMappedDevice;
/**
@@ -47,8 +47,8 @@ import li.cil.sedna.api.device.MemoryMappedDevice;
* Note that if any other {@link VMDevice} fails mounting, all mounted devices
* will immediately unmounted and disposed.
*
* @see li.cil.oc2r.api.bus.device.provider.BlockDeviceProvider
* @see li.cil.oc2r.api.bus.device.provider.ItemDeviceProvider
* @see li.cil.oc2.api.bus.device.provider.BlockDeviceProvider
* @see li.cil.oc2.api.bus.device.provider.ItemDeviceProvider
*/
public interface VMDevice extends Device {
/**

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm;
package li.cil.oc2.api.bus.device.vm;
import li.cil.oc2r.api.bus.device.vm.context.VMContext;
import li.cil.oc2.api.bus.device.vm.context.VMContext;
import net.minecraft.network.chat.Component;
import javax.annotation.Nullable;

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm.context;
package li.cil.oc2.api.bus.device.vm.context;
import li.cil.oc2r.api.bus.device.vm.VMDevice;
import li.cil.oc2.api.bus.device.vm.VMDevice;
import java.util.Optional;
import java.util.OptionalInt;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm.context;
package li.cil.oc2.api.bus.device.vm.context;
/**
* A memory allocator used to ensure sandbox limits when loading devices.

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm.context;
package li.cil.oc2.api.bus.device.vm.context;
import li.cil.oc2r.api.bus.device.vm.VMDevice;
import li.cil.oc2.api.bus.device.vm.VMDevice;
import li.cil.sedna.api.device.MemoryMappedDevice;
import java.util.OptionalLong;

View File

@@ -1,9 +1,9 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm.context;
package li.cil.oc2.api.bus.device.vm.context;
import li.cil.oc2r.api.bus.DeviceBus;
import li.cil.oc2r.api.bus.device.vm.VMDevice;
import li.cil.oc2.api.bus.DeviceBus;
import li.cil.oc2.api.bus.device.vm.VMDevice;
import li.cil.sedna.api.device.InterruptController;
import li.cil.sedna.api.device.MemoryMappedDevice;
import li.cil.sedna.api.memory.MemoryMap;

View File

@@ -1,13 +1,13 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm.context;
package li.cil.oc2.api.bus.device.vm.context;
/**
* Allows registering for VM lifecycle events.
*
* @see li.cil.oc2r.api.bus.device.vm.event.VMInitializingEvent
* @see li.cil.oc2r.api.bus.device.vm.event.VMSynchronizeEvent
* @see li.cil.oc2r.api.bus.device.vm.event.VMResumedRunningEvent
* @see li.cil.oc2.api.bus.device.vm.event.VMInitializingEvent
* @see li.cil.oc2.api.bus.device.vm.event.VMSynchronizeEvent
* @see li.cil.oc2.api.bus.device.vm.event.VMResumedRunningEvent
*/
public interface VMLifecycleEventBus {
/**

View File

@@ -0,0 +1,9 @@
/* SPDX-License-Identifier: MIT */
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2.api.bus.device.vm.context;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm.event;
package li.cil.oc2.api.bus.device.vm.event;
import net.minecraft.network.chat.Component;

View File

@@ -1,9 +1,9 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm.event;
package li.cil.oc2.api.bus.device.vm.event;
import li.cil.oc2r.api.bus.device.vm.VMDevice;
import li.cil.oc2r.api.bus.device.vm.context.VMContext;
import li.cil.oc2.api.bus.device.vm.VMDevice;
import li.cil.oc2.api.bus.device.vm.context.VMContext;
/**
* Fired exactly once, when the VM first starts running.

View File

@@ -1,9 +1,9 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm.event;
package li.cil.oc2.api.bus.device.vm.event;
import li.cil.oc2r.api.bus.device.vm.VMDevice;
import li.cil.oc2r.api.bus.device.vm.context.VMContext;
import li.cil.oc2.api.bus.device.vm.VMDevice;
import li.cil.oc2.api.bus.device.vm.context.VMContext;
/**
* Fired when the VM resumed running, either when first starting up, when resuming after

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.bus.device.vm.event;
package li.cil.oc2.api.bus.device.vm.event;
/**
* Fired when the VM is paused, typically before state is persisted.

View File

@@ -0,0 +1,9 @@
/* SPDX-License-Identifier: MIT */
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2.api.bus.device.vm.event;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -2,7 +2,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2r.api.capabilities;
package li.cil.oc2.api.bus.device.vm;
import net.minecraft.MethodsReturnNonnullByDefault;

View File

@@ -3,29 +3,29 @@
/**
* The device bus is the glue that connects devices and VMs.
* <p>
* A bus must always be managed by a {@link li.cil.oc2r.api.bus.DeviceBusController}.
* A bus must always be managed by a {@link li.cil.oc2.api.bus.DeviceBusController}.
* If there is no controller, there is no (connected) bus.
* <p>
* When a controller performs a scan, it collects a list of connected
* {@link li.cil.oc2r.api.bus.DeviceBusElement}s thus defining a
* {@link li.cil.oc2r.api.bus.DeviceBus}.
* {@link li.cil.oc2.api.bus.DeviceBusElement}s thus defining a
* {@link li.cil.oc2.api.bus.DeviceBus}.
* How the controller scans for elements depends on the implementation.
* One example is a block-based controller which scans adjacent blocks
* in a recursive manner -- usually up to some maximum bus complexity.
* <p>
* {@link li.cil.oc2r.api.bus.DeviceBusElement}s are responsible for
* {@link li.cil.oc2.api.bus.DeviceBusElement}s are responsible for
* providing a list of devices connected to them. Whether they play an
* active role and seek out devices, or passively expect devices to be
* registered with them depends on the implementation.
* <p>
* After a scan {@link li.cil.oc2r.api.bus.DeviceBusController}s then
* After a scan {@link li.cil.oc2.api.bus.DeviceBusController}s then
* collect all devices from all bus elements to build a global set
* of devices on the bus.
* <p>
* There can be various types of devices on a bus, but which types are
* supported will depend on the context of the controller. Currently, two
* types of devices are defined in this API, {@link li.cil.oc2r.api.bus.device.rpc.RPCDevice}
* and {@link li.cil.oc2r.api.bus.device.vm.VMDevice}.
* types of devices are defined in this API, {@link li.cil.oc2.api.bus.device.rpc.RPCDevice}
* and {@link li.cil.oc2.api.bus.device.vm.VMDevice}.
* <ul>
* <li>
* RPC devices are a high-level system for providing VMs with means of
@@ -42,7 +42,7 @@
*/
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2r.api.bus;
package li.cil.oc2.api.bus;
import net.minecraft.MethodsReturnNonnullByDefault;

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.capabilities;
package li.cil.oc2.api.capabilities;
import li.cil.oc2r.api.bus.device.ItemDevice;
import li.cil.oc2.api.bus.device.ItemDevice;
import javax.annotation.Nullable;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.capabilities;
package li.cil.oc2.api.capabilities;
/**
* This interface may be provided as a capability by item components to signal

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.capabilities;
package li.cil.oc2.api.capabilities;
import net.minecraftforge.items.ItemStackHandler;

View File

@@ -1,9 +1,9 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.capabilities;
package li.cil.oc2.api.capabilities;
import li.cil.oc2r.api.bus.device.provider.BlockDeviceQuery;
import li.cil.oc2r.api.bus.device.provider.ItemDeviceQuery;
import li.cil.oc2.api.bus.device.provider.BlockDeviceQuery;
import li.cil.oc2.api.bus.device.provider.ItemDeviceQuery;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.entity.BlockEntity;

View File

@@ -0,0 +1,9 @@
/* SPDX-License-Identifier: MIT */
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2.api.capabilities;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -1,10 +1,10 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.imc;
package li.cil.oc2.api.imc;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import li.cil.oc2r.api.bus.device.rpc.RPCDevice;
import li.cil.oc2.api.bus.device.rpc.RPCDevice;
import java.lang.reflect.Type;

View File

@@ -2,7 +2,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2r.client;
package li.cil.oc2.api.imc;
import net.minecraft.MethodsReturnNonnullByDefault;

View File

@@ -0,0 +1,12 @@
package li.cil.oc2.api.inet;
import net.minecraft.nbt.Tag;
import java.util.Optional;
public interface InternetDeviceLifecycle {
default Optional<Tag> onSave() {
return Optional.empty();
}
default void onStop() {}
}

View File

@@ -0,0 +1,10 @@
package li.cil.oc2.api.inet;
public interface InternetManager {
Task runOnInternetThreadTick(Runnable action);
interface Task {
void close();
}
}

View File

@@ -0,0 +1,10 @@
package li.cil.oc2.api.inet;
import net.minecraft.nbt.Tag;
import java.util.Optional;
public interface LayerParameters {
Optional<Tag> getSavedState();
InternetManager getInternetManager();
}

View File

@@ -0,0 +1,185 @@
package li.cil.oc2.api.inet;
import li.cil.oc2.api.inet.layer.NetworkLayer;
import li.cil.oc2.common.inet.InetUtils;
import java.net.InetAddress;
import java.nio.ByteBuffer;
/**
* Reusable data object, that contains information about transport layer message that makes sense both for
* transport and network layer.
*/
public final class TransportMessage {
private static final byte DEFAULT_TTL = 64;
///////////////////////////////////////////////////////////////////////
private short networkProtocolNumber = -1;
private long srcIpAddressMost = -1;
private long srcIpAddressLeast = -1;
private long dstIpAddressMost = -1;
private long dstIpAddressLeast = -1;
private byte ttl = -1;
private ByteBuffer data = null;
///////////////////////////////////////////////////////////////////////
/**
* Network layer should provide byte buffer for transport layer via this method.
*
* @param data byte buffer for transport layer data
*/
public void initializeBuffer(final ByteBuffer data) {
this.data = data;
}
/**
* Updates network layer parameters for current transport message.
*
* @param networkProtocolNumber chosen network protocol number (use {@link NetworkLayer#PROTOCOL_IPv4} or
* {@link NetworkLayer#PROTOCOL_IPv6} values)
* @param srcIpAddressMost part of a source IP address
* @param srcIpAddressLeast part of a source IP address
* @param dstIpAddressMost part of a destination IP address
* @param dstIpAddressLeast part of a destination IP address
* @param ttl time to live value (for tracert functionality)
*/
public void update(
final short networkProtocolNumber,
final long srcIpAddressMost,
final long srcIpAddressLeast,
final long dstIpAddressMost,
final long dstIpAddressLeast,
final byte ttl
) {
this.networkProtocolNumber = networkProtocolNumber;
this.srcIpAddressMost = srcIpAddressMost;
this.srcIpAddressLeast = srcIpAddressLeast;
this.dstIpAddressMost = dstIpAddressMost;
this.dstIpAddressLeast = dstIpAddressLeast;
this.ttl = ttl;
}
/**
* Updates network layer parameters for current transport message assuming IPv4 network protocol.
*
* @param srcIpAddress source IP address
* @param dstIpAddress destination IP address
* @param ttl time to live value (for tracert functionality)
*/
public void updateIpv4(
final int srcIpAddress,
final int dstIpAddress,
final byte ttl
) {
update(NetworkLayer.PROTOCOL_IPv4, 0, srcIpAddress, 0, dstIpAddress, ttl);
}
/**
* Updates network layer parameters for current transport message and sets the default TTL value assuming IPv4
* network protocol.
*
* @param srcIpAddress source IP address
* @param dstIpAddress destination IP address
*/
public void updateIpv4(
final int srcIpAddress,
final int dstIpAddress
) {
updateIpv4(srcIpAddress, dstIpAddress, DEFAULT_TTL);
}
/**
* Gets stored TTL value.
*
* @return TTL value
*/
public byte getTtl() {
return ttl;
}
/**
* Gets stored source IPv4 address.
*
* @return IPv4 source address
*/
public int getSrcIpv4Address() {
return (int) srcIpAddressLeast;
}
/**
* Gets stored destination IPv4 address.
*
* @return IPv4 destination address
*/
public int getDstIpv4Address() {
return (int) dstIpAddressLeast;
}
/**
* Gets stored source IP address as {@link InetAddress} object.
*
* @return IPv4 source address
*/
public InetAddress getSrcAddress() {
return switch (networkProtocolNumber) {
case NetworkLayer.PROTOCOL_IPv4 -> InetUtils.toJavaInetAddress(getSrcIpv4Address());
case NetworkLayer.PROTOCOL_IPv6 -> InetUtils.toJavaInetAddress(srcIpAddressMost, srcIpAddressLeast);
default -> throw new IllegalStateException();
};
}
/**
* Gets stored destination IP address as {@link InetAddress} object.
*
* @return IPv4 destination address
*/
public InetAddress getDstAddress() {
return switch (networkProtocolNumber) {
case NetworkLayer.PROTOCOL_IPv4 -> InetUtils.toJavaInetAddress(getDstIpv4Address());
case NetworkLayer.PROTOCOL_IPv6 -> InetUtils.toJavaInetAddress(dstIpAddressMost, dstIpAddressLeast);
default -> throw new IllegalStateException();
};
}
/**
* Gets transport layer data buffer
*
* @return transport layer data buffer
*/
public ByteBuffer getData() {
if (data == null) {
throw new IllegalStateException();
}
return data;
}
/**
* Gets network protocol number
*
* @return network protocol number
*/
public short getNetworkProtocolNumber() {
return networkProtocolNumber;
}
/**
* Checks if an IPv4 transport message stored in this object.
*
* @return true only if it is an IPv4 message
*/
public boolean isIpv4() {
return networkProtocolNumber == NetworkLayer.PROTOCOL_IPv4;
}
/**
* Checks if an IPv6 transport message stored in this object.
*
* @return true only if it is an IPv6 message
*/
public boolean isIpv6() {
return networkProtocolNumber == NetworkLayer.PROTOCOL_IPv6;
}
}

View File

@@ -0,0 +1,54 @@
package li.cil.oc2.api.inet.layer;
import li.cil.oc2.api.inet.InternetDeviceLifecycle;
import li.cil.oc2.api.inet.provider.NetworkLayerInternetProvider;
import java.nio.ByteBuffer;
/**
* Link local or channel TCP/IP layer interface.
* <p>
* There is a default link local layer implementation that uses provided {@link NetworkLayer} implementation
* (see {@link NetworkLayerInternetProvider} for more information).
*/
public interface LinkLocalLayer extends InternetDeviceLifecycle {
/**
* Ethernet frame header size. Consists of two ethernet (MAC) addresses and protocol number.
*/
int FRAME_HEADER_SIZE = 14;
/**
* Default ethernet frame body size that is used in Linux.
*/
int DEFAULT_MTU = 1500;
/**
* Default ethernet frame size.
*/
int FRAME_SIZE = FRAME_HEADER_SIZE + DEFAULT_MTU;
String LAYER_NAME = "LinkLocal";
////////////////////////////////////////////////////////////////////
/**
* Tries to get the next ethernet frame to send it to virtual computer later.
* <p>
* Normally, this method is invoked every game tick in the Internet thread.
*
* @param frame byte buffer where frame body should be put
* @return should return false, if no ethernet frame were gathered, and true otherwise
*/
default boolean receiveEthernetFrame(final ByteBuffer frame) {
return false;
}
/**
* Sends an ethernet frame from virtual computer.
*
* @param frame byte buffer filled with ethernet frame data
*/
default void sendEthernetFrame(final ByteBuffer frame) {
}
}

View File

@@ -0,0 +1,70 @@
package li.cil.oc2.api.inet.layer;
import li.cil.oc2.api.inet.InternetDeviceLifecycle;
import li.cil.oc2.api.inet.provider.TransportLayerInternetProvider;
import java.nio.ByteBuffer;
/**
* Network TCP/IP layer interface.
* <p>
* There is a default network layer implementation that uses provided {@link TransportLayer} implementation
* (see {@link TransportLayerInternetProvider} for more information).
*/
public interface NetworkLayer extends InternetDeviceLifecycle {
/**
* The value of this constant should be returned by {@link NetworkLayer#receivePacket(ByteBuffer)} method if no
* data is arrived.
*/
short PROTOCOL_NONE = 0;
/**
* The value of this constant should be returned by {@link NetworkLayer#receivePacket(ByteBuffer)} method if IPv4
* packet is arrived.
*/
short PROTOCOL_IPv4 = 0x0800;
/**
* The value of this constant should be returned by {@link NetworkLayer#receivePacket(ByteBuffer)} method if any IP
* packet is arrived (can be either IPv4 packet or IPv6 packet).
* <p>
* Normally, this value should be returned if any data is arrived.
*/
short PROTOCOL_IP = PROTOCOL_IPv4;
/**
* The value of this constant should be returned by {@link NetworkLayer#receivePacket(ByteBuffer)} method if IPv6
* packet is arrived.
*/
short PROTOCOL_IPv6 = (short) 0x86dd;
String LAYER_NAME = "Network";
////////////////////////////////////////////////////////////////////////////////////
/**
* Tries to get the next IP paket to wrap it into an ethernet frame and send it to virtual computer later.
* <p>
* Normally, this method is invoked every game tick in the Internet thread.
*
* @param packet byte buffer where IP packet body should be put
* @return protocol number of received data (either {@link NetworkLayer#PROTOCOL_IP},
* {@link NetworkLayer#PROTOCOL_IPv4} or {@link NetworkLayer#PROTOCOL_IPv6}) or
* {@link NetworkLayer#PROTOCOL_NONE}, if no new data has arrived
*/
default short receivePacket(final ByteBuffer packet) {
return PROTOCOL_NONE;
}
/**
* Sends an IP packet extracted from an ethernet frame that sent virtual computer.
*
* @param protocol protocol number of arrived message; normally, should be either
* {@link NetworkLayer::PROTOCOL_IPv4} or {@link NetworkLayer::PROTOCOL_IPv6}
* @param packet arrived data
*/
default void sendPacket(final short protocol, final ByteBuffer packet) {
}
}

View File

@@ -0,0 +1,29 @@
package li.cil.oc2.api.inet.layer;
import li.cil.oc2.api.inet.InternetDeviceLifecycle;
import li.cil.oc2.api.inet.session.Session;
import javax.annotation.Nullable;
import java.nio.ByteBuffer;
/**
* A session layer interface of TCP/IP stack.
*/
public interface SessionLayer extends InternetDeviceLifecycle {
String LAYER_NAME = "Session";
////////////////////////////////////////////////////////////////////////////////////
default void receiveSession(final Receiver receiver) {
}
default void sendSession(final Session session, @Nullable final ByteBuffer data) {
session.close();
}
interface Receiver {
@Nullable
ByteBuffer receive(Session session);
}
}

View File

@@ -0,0 +1,66 @@
package li.cil.oc2.api.inet.layer;
import li.cil.oc2.api.inet.InternetDeviceLifecycle;
import li.cil.oc2.api.inet.TransportMessage;
import li.cil.oc2.api.inet.provider.SessionLayerInternetProvider;
/**
* Transport TCP/IP layer interface.
* <p>
* There is a default transport layer implementation that uses provided {@link SessionLayer} implementation
* (see {@link SessionLayerInternetProvider} for more information).
*/
public interface TransportLayer extends InternetDeviceLifecycle {
/**
* The value of this constant should be returned by {@link TransportLayer#receiveTransportMessage(TransportMessage)}
* method if no data is arrived.
*/
byte PROTOCOL_NONE = 0;
/**
* The value of this constant should be returned by {@link TransportLayer#receiveTransportMessage(TransportMessage)}
* method if an ICMP message is arrived.
*/
byte PROTOCOL_ICMP = 1;
/**
* The value of this constant should be returned by {@link TransportLayer#receiveTransportMessage(TransportMessage)}
* method if a TCP packet is arrived.
*/
byte PROTOCOL_TCP = 6;
/**
* The value of this constant should be returned by {@link TransportLayer#receiveTransportMessage(TransportMessage)}
* method if a UDP message is arrived.
*/
byte PROTOCOL_UDP = 17;
String LAYER_NAME = "Transport";
////////////////////////////////////////////////////////////////////////////////////
/**
* Tries to get the next transport message to wrap it into an IP packet and send it to virtual computer later.
* <p>
* Normally, this method is invoked every game tick in the Internet thread.
*
* @param message transport message object that should be filled with arrived data
* @return protocol number of received data (can be, for example, {@link TransportLayer#PROTOCOL_ICMP},
* {@link TransportLayer#PROTOCOL_TCP} or {@link TransportLayer#PROTOCOL_UDP}) or
* {@link TransportLayer#PROTOCOL_NONE}, if no new data has arrived
*/
default byte receiveTransportMessage(final TransportMessage message) {
return PROTOCOL_NONE;
}
/**
* Sends a transport message extracted from an IP packet that sent virtual computer.
*
* @param protocol protocol number of arrived message
* @param message arrived transport message
*/
default void sendTransportMessage(byte protocol, final TransportMessage message) {
}
}

View File

@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2.api.inet.layer;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2.api.inet;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -0,0 +1,38 @@
package li.cil.oc2.api.inet.provider;
import li.cil.oc2.api.inet.LayerParameters;
import li.cil.oc2.api.inet.layer.LinkLocalLayer;
/**
* Internet access provider for oc2:internet-card item.
* At initialization phase one implementation of this interface will be loaded via {@link java.util.ServiceLoader}.
* If no implementation is found, then the default one will be used instead.
* <p>
* It is recommended to not implement this interface directly.
* There are several abstract classes for several levels of TCP/IP stack:
*
* <ul>
* <li>{@link LinkLocalLayerInternetProvider}</li>
* <li>{@link NetworkLayerInternetProvider}</li>
* <li>{@link TransportLayerInternetProvider}</li>
* <li>{@link SessionLayerInternetProvider}</li>
* </ul>
* <p>
* Each of these classes implements {@link InternetProvider} and
* asks you to provide an implementation of corresponding TCP/IP layer.
*
* @see LinkLocalLayerInternetProvider
* @see NetworkLayerInternetProvider
* @see TransportLayerInternetProvider
* @see SessionLayerInternetProvider
*/
public interface InternetProvider {
/**
* This method should provide an implementation of {@link LinkLocalLayer} interface.
* It will be called once for each loaded internet card.
*
* @return an implementation of {@link LinkLocalLayer} interface
*/
LinkLocalLayer provideInternet(LayerParameters layerParameters);
}

View File

@@ -0,0 +1,39 @@
package li.cil.oc2.api.inet.provider;
import li.cil.oc2.api.inet.LayerParameters;
import li.cil.oc2.api.inet.layer.LinkLocalLayer;
import li.cil.oc2.api.inet.layer.NetworkLayer;
import li.cil.oc2.common.inet.*;
/**
* An {@link InternetProvider} partial implementation that expects an {@link LinkLocalLayer} implementation from
* protected method {@link LinkLocalLayerInternetProvider#provideLinkLocalLayer(LayerParameters)}.
*
* @see InternetProvider
* @see LinkLocalLayer
*/
public abstract class LinkLocalLayerInternetProvider implements InternetProvider {
protected static LinkLocalLayer nullLinkLocalLayer() {
return NullLayer.INSTANCE;
}
protected static LinkLocalLayer defaultLinkLocalLayer(final LayerParameters layerParameters) {
final LayerParameters networkParameters = InetUtils.nextLayerParameters(layerParameters, NetworkLayer.LAYER_NAME);
final NetworkLayer networkLayer = NetworkLayerInternetProvider.defaultNetworkLayer(networkParameters);
return new DefaultLinkLocalLayer(layerParameters, networkLayer);
}
/**
* This method is called from {@link LinkLocalLayerInternetProvider#provideInternet(LayerParameters)} in order to get an
* {@link LinkLocalLayer} implementation.
*
* @return an implementation of link local TCP/IP layer for internet cards
*/
protected abstract LinkLocalLayer provideLinkLocalLayer(LayerParameters layerParameters);
@Override
public final LinkLocalLayer provideInternet(final LayerParameters layerParameters) {
return provideLinkLocalLayer(InetUtils.nextLayerParameters(layerParameters, LinkLocalLayer.LAYER_NAME));
}
}

View File

@@ -0,0 +1,47 @@
package li.cil.oc2.api.inet.provider;
import li.cil.oc2.api.inet.LayerParameters;
import li.cil.oc2.api.inet.layer.LinkLocalLayer;
import li.cil.oc2.api.inet.layer.NetworkLayer;
import li.cil.oc2.api.inet.layer.TransportLayer;
import li.cil.oc2.common.inet.DefaultLinkLocalLayer;
import li.cil.oc2.common.inet.DefaultNetworkLayer;
import li.cil.oc2.common.inet.InetUtils;
import li.cil.oc2.common.inet.NullLayer;
/**
* An {@link InternetProvider} partial implementation that expects an {@link NetworkLayer} implementation from
* protected method {@link NetworkLayerInternetProvider#provideNetworkLayer(LayerParameters)}.
*
* @see InternetProvider
* @see NetworkLayer
*/
public abstract class NetworkLayerInternetProvider extends LinkLocalLayerInternetProvider {
protected static NetworkLayer nullNetworkLayer() {
return NullLayer.INSTANCE;
}
protected static NetworkLayer defaultNetworkLayer(final LayerParameters layerParameters) {
final LayerParameters transportParameters = InetUtils.nextLayerParameters(layerParameters, TransportLayer.LAYER_NAME);
final TransportLayer transportLayer = TransportLayerInternetProvider.defaultTransportLayer(transportParameters);
return new DefaultNetworkLayer(layerParameters, transportLayer);
}
/**
* This method is called from {@link NetworkLayerInternetProvider#provideLinkLocalLayer(LayerParameters)} in order to get a
* {@link NetworkLayer} implementation.
* Retrieved {@link NetworkLayer} implementation will be wrapped with internal {@link LinkLocalLayer}
* implementation.
*
* @return an implementation of network TCP/IP layer for internet cards
*/
protected abstract NetworkLayer provideNetworkLayer(LayerParameters layerParameters);
@Override
protected final LinkLocalLayer provideLinkLocalLayer(final LayerParameters layerParameters) {
final LayerParameters networkParameters = InetUtils.nextLayerParameters(layerParameters, NetworkLayer.LAYER_NAME);
final NetworkLayer networkLayer = provideNetworkLayer(networkParameters);
return InetUtils.createLayerIfNotStub(networkLayer, layer -> new DefaultLinkLocalLayer(layerParameters, networkLayer));
}
}

View File

@@ -0,0 +1,44 @@
package li.cil.oc2.api.inet.provider;
import li.cil.oc2.api.inet.LayerParameters;
import li.cil.oc2.api.inet.layer.SessionLayer;
import li.cil.oc2.api.inet.layer.TransportLayer;
import li.cil.oc2.common.inet.DefaultSessionLayer;
import li.cil.oc2.common.inet.DefaultTransportLayer;
import li.cil.oc2.common.inet.InetUtils;
import li.cil.oc2.common.inet.NullLayer;
/**
* An {@link InternetProvider} partial implementation that expects an {@link SessionLayer} implementation from
* protected method {@link SessionLayerInternetProvider#provideSessionLayer(LayerParameters)}.
*
* @see InternetProvider
* @see SessionLayer
*/
public abstract class SessionLayerInternetProvider extends TransportLayerInternetProvider {
protected static SessionLayer nullSessionLayer() {
return NullLayer.INSTANCE;
}
protected static SessionLayer defaultSessionLayer(final LayerParameters layerParameters) {
return new DefaultSessionLayer(layerParameters);
}
/**
* This method is called from {@link SessionLayerInternetProvider#provideTransportLayer(LayerParameters)} in order to get a
* {@link SessionLayer} implementation.
* Retrieved {@link SessionLayer} implementation will be wrapped with internal {@link TransportLayer}
* implementation.
*
* @return an implementation of session TCP/IP layer for internet cards
*/
protected abstract SessionLayer provideSessionLayer(LayerParameters layerParameters);
@Override
protected final TransportLayer provideTransportLayer(final LayerParameters layerParameters) {
final LayerParameters sessionParameters = InetUtils.nextLayerParameters(layerParameters, SessionLayer.LAYER_NAME);
final SessionLayer sessionLayer = provideSessionLayer(sessionParameters);
return InetUtils.createLayerIfNotStub(sessionLayer, DefaultTransportLayer::new);
}
}

View File

@@ -0,0 +1,47 @@
package li.cil.oc2.api.inet.provider;
import li.cil.oc2.api.inet.LayerParameters;
import li.cil.oc2.api.inet.layer.NetworkLayer;
import li.cil.oc2.api.inet.layer.SessionLayer;
import li.cil.oc2.api.inet.layer.TransportLayer;
import li.cil.oc2.common.inet.DefaultNetworkLayer;
import li.cil.oc2.common.inet.DefaultTransportLayer;
import li.cil.oc2.common.inet.InetUtils;
import li.cil.oc2.common.inet.NullLayer;
/**
* An {@link InternetProvider} partial implementation that expects an {@link TransportLayer} implementation from
* protected method {@link TransportLayerInternetProvider#provideTransportLayer(LayerParameters)}.
*
* @see InternetProvider
* @see TransportLayer
*/
public abstract class TransportLayerInternetProvider extends NetworkLayerInternetProvider {
protected static TransportLayer nullTransportLayer() {
return NullLayer.INSTANCE;
}
protected static TransportLayer defaultTransportLayer(final LayerParameters layerParameters) {
final LayerParameters sessionParameters = InetUtils.nextLayerParameters(layerParameters, SessionLayer.LAYER_NAME);
final SessionLayer sessionLayer = SessionLayerInternetProvider.defaultSessionLayer(sessionParameters);
return new DefaultTransportLayer(sessionLayer);
}
/**
* This method is called from {@link TransportLayerInternetProvider#provideNetworkLayer(LayerParameters)} in order to get a
* {@link TransportLayer} implementation.
* Retrieved {@link TransportLayer} implementation will be wrapped with internal {@link NetworkLayer}
* implementation.
*
* @return an implementation of transport TCP/IP layer for internet cards
*/
protected abstract TransportLayer provideTransportLayer(LayerParameters layerParameters);
@Override
protected final NetworkLayer provideNetworkLayer(final LayerParameters layerParameters) {
final LayerParameters transportParameters = InetUtils.nextLayerParameters(layerParameters, TransportLayer.LAYER_NAME);
final TransportLayer transportLayer = provideTransportLayer(transportParameters);
return InetUtils.createLayerIfNotStub(transportLayer, layer -> new DefaultNetworkLayer(layerParameters, layer));
}
}

View File

@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2.api.inet.provider;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -0,0 +1,4 @@
package li.cil.oc2.api.inet.session;
public interface DatagramSession extends Session {
}

View File

@@ -0,0 +1,7 @@
package li.cil.oc2.api.inet.session;
public interface EchoSession extends Session {
int getSequenceNumber();
int getTtl();
}

View File

@@ -0,0 +1,33 @@
package li.cil.oc2.api.inet.session;
import javax.annotation.Nullable;
import java.net.InetSocketAddress;
import java.time.Instant;
public interface Session {
long getId();
void close();
States getState();
@Nullable
Object getAttachment();
void setAttachment(@Nullable final Object userdata);
InetSocketAddress getDestination();
Instant getLastUpdateTime();
default boolean isClosed() {
return switch (getState()) {
case FINISH, REJECT, EXPIRED -> true;
default -> false;
};
}
enum States {
NEW, ESTABLISHED, FINISH, REJECT, EXPIRED
}
}

View File

@@ -0,0 +1,10 @@
package li.cil.oc2.api.inet.session;
import java.nio.ByteBuffer;
public interface StreamSession extends Session {
ByteBuffer getSendBuffer();
ByteBuffer getReceiveBuffer();
void connect();
}

View File

@@ -2,7 +2,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2r.api;
package li.cil.oc2.api;
import net.minecraft.MethodsReturnNonnullByDefault;

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.util;
package li.cil.oc2.api.util;
import li.cil.oc2r.common.util.RunnableUtils;
import li.cil.oc2.common.util.RunnableUtils;
import java.util.ArrayList;
import java.util.List;
@@ -11,7 +11,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
/**
* Wrapper for objects which may become invalid, such as {@link li.cil.oc2r.api.bus.device.Device}s.
* Wrapper for objects which may become invalid, such as {@link li.cil.oc2.api.bus.device.Device}s.
* <p>
* This implementation allows listeners added via {@link #addListener(Consumer)} to be removed again
* using the returned token. This allows avoiding memory leaks due to inversion of reference ownership,

View File

@@ -1,12 +1,12 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.util;
package li.cil.oc2.api.util;
import li.cil.oc2r.api.API;
import li.cil.oc2r.api.bus.device.data.BlockDeviceData;
import li.cil.oc2r.api.bus.device.data.Firmware;
import li.cil.oc2r.api.bus.device.provider.BlockDeviceProvider;
import li.cil.oc2r.api.bus.device.provider.ItemDeviceProvider;
import li.cil.oc2.api.API;
import li.cil.oc2.api.bus.device.data.BlockDeviceData;
import li.cil.oc2.api.bus.device.data.Firmware;
import li.cil.oc2.api.bus.device.provider.BlockDeviceProvider;
import li.cil.oc2.api.bus.device.provider.ItemDeviceProvider;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.util;
package li.cil.oc2.api.util;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.Entity;

View File

@@ -1,15 +1,16 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.api.util;
package li.cil.oc2.api.util;
import net.minecraft.core.Direction;
import net.minecraft.core.BlockPos;
import javax.annotation.Nullable;
/**
* This enum indicates a side of a block device.
* <p>
* It is intended to be used by {@link li.cil.oc2r.api.bus.device.rpc.RPCDevice} APIs,
* It is intended to be used by {@link li.cil.oc2.api.bus.device.rpc.RPCDevice} APIs,
* providing both convenience for the caller by providing a range of aliases, and also
* stability, in case Mojang decide to rename the enum fields of the {@link Direction}
* enum at some time in the future.
@@ -73,4 +74,34 @@ public enum Side {
public String toString() {
return base != null ? base.toString() : super.toString();
}
public static Direction relativeDirection(BlockPos from, BlockPos to) {
int dx = to.getX() - from.getX();
int dy = to.getY() - from.getY();
int dz = to.getZ() - from.getZ();
if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > Math.abs(dz)) {
if (dx > 0) {
return Direction.EAST;
}
else {
return Direction.WEST;
}
}
else if (Math.abs(dy) > Math.abs(dx) && Math.abs(dy) > Math.abs(dz)) {
if (dy > 0) {
return Direction.UP;
}
else {
return Direction.DOWN;
}
}
else {
if (dz > 0) {
return Direction.SOUTH;
}
else {
return Direction.NORTH;
}
}
}
}

View File

@@ -2,7 +2,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2r.api.imc;
package li.cil.oc2.api.util;
import net.minecraft.MethodsReturnNonnullByDefault;

View File

@@ -1,21 +1,21 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.client;
package li.cil.oc2.client;
import li.cil.oc2r.client.gui.*;
import li.cil.oc2r.client.item.CustomItemColors;
import li.cil.oc2r.client.item.CustomItemModelProperties;
import li.cil.oc2r.client.model.BusCableModelLoader;
import li.cil.oc2r.client.renderer.BusInterfaceNameRenderer;
import li.cil.oc2r.client.renderer.ProjectorDepthRenderer;
import li.cil.oc2r.client.renderer.blockentity.*;
import li.cil.oc2r.client.renderer.color.BusCableBlockColor;
import li.cil.oc2r.client.renderer.entity.RobotRenderer;
import li.cil.oc2r.client.renderer.entity.model.RobotModel;
import li.cil.oc2r.common.block.Blocks;
import li.cil.oc2r.common.blockentity.BlockEntities;
import li.cil.oc2r.common.container.Containers;
import li.cil.oc2r.common.entity.Entities;
import li.cil.oc2.client.gui.*;
import li.cil.oc2.client.item.CustomItemColors;
import li.cil.oc2.client.item.CustomItemModelProperties;
import li.cil.oc2.client.model.BusCableModelLoader;
import li.cil.oc2.client.renderer.BusInterfaceNameRenderer;
import li.cil.oc2.client.renderer.ProjectorDepthRenderer;
import li.cil.oc2.client.renderer.blockentity.*;
import li.cil.oc2.client.renderer.color.BusCableBlockColor;
import li.cil.oc2.client.renderer.entity.RobotRenderer;
import li.cil.oc2.client.renderer.entity.model.RobotModel;
import li.cil.oc2.common.block.Blocks;
import li.cil.oc2.common.blockentity.BlockEntities;
import li.cil.oc2.common.container.Containers;
import li.cil.oc2.common.entity.Entities;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
@@ -38,6 +38,7 @@ public final class ClientSetup {
BlockEntityRenderers.register(BlockEntities.DISK_DRIVE.get(), DiskDriveRenderer::new);
BlockEntityRenderers.register(BlockEntities.CHARGER.get(), ChargerRenderer::new);
BlockEntityRenderers.register(BlockEntities.PROJECTOR.get(), ProjectorRenderer::new);
BlockEntityRenderers.register(BlockEntities.INTERNET_GATEWAY.get(), InternetGateWayRenderer::new);
event.enqueueWork(() -> {
CustomItemModelProperties.initialize();

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.client.audio;
package li.cil.oc2.client.audio;
import li.cil.oc2r.common.util.TickUtils;
import li.cil.oc2.common.util.TickUtils;
import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.client.audio;
package li.cil.oc2.client.audio;
import net.minecraft.client.Minecraft;
import net.minecraft.sounds.SoundEvent;

View File

@@ -0,0 +1,9 @@
/* SPDX-License-Identifier: MIT */
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.oc2.client.audio;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View File

@@ -1,15 +1,15 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.client.gui;
package li.cil.oc2.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import li.cil.oc2r.api.bus.device.DeviceTypes;
import li.cil.oc2r.client.gui.util.GuiUtils;
import li.cil.oc2r.client.gui.widget.ImageButton;
import li.cil.oc2r.client.gui.widget.ToggleImageButton;
import li.cil.oc2r.common.Constants;
import li.cil.oc2r.common.container.AbstractMachineTerminalContainer;
import li.cil.oc2r.common.util.TooltipUtils;
import li.cil.oc2.api.bus.device.DeviceTypes;
import li.cil.oc2.client.gui.util.GuiUtils;
import li.cil.oc2.client.gui.widget.ImageButton;
import li.cil.oc2.client.gui.widget.ToggleImageButton;
import li.cil.oc2.common.Constants;
import li.cil.oc2.common.container.AbstractMachineTerminalContainer;
import li.cil.oc2.common.util.TooltipUtils;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.narration.NarrationElementOutput;
@@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List;
import static java.util.Arrays.asList;
import static li.cil.oc2r.common.util.TextFormatUtils.withFormat;
import static li.cil.oc2.common.util.TextFormatUtils.withFormat;
@OnlyIn(Dist.CLIENT)
public abstract class AbstractMachineInventoryScreen<T extends AbstractMachineTerminalContainer> extends AbstractModContainerScreen<T> {

View File

@@ -1,13 +1,13 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.client.gui;
package li.cil.oc2.client.gui;
import com.mojang.blaze3d.platform.InputConstants;
import li.cil.oc2r.client.gui.widget.ImageButton;
import li.cil.oc2r.client.gui.widget.ToggleImageButton;
import li.cil.oc2r.common.Constants;
import li.cil.oc2r.common.container.AbstractMachineTerminalContainer;
import li.cil.oc2r.common.util.TooltipUtils;
import li.cil.oc2.client.gui.widget.ImageButton;
import li.cil.oc2.client.gui.widget.ToggleImageButton;
import li.cil.oc2.common.Constants;
import li.cil.oc2.common.container.AbstractMachineTerminalContainer;
import li.cil.oc2.common.util.TooltipUtils;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.EditBox;
@@ -23,7 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import static java.util.Arrays.asList;
import static li.cil.oc2r.common.util.TextFormatUtils.withFormat;
import static li.cil.oc2.common.util.TextFormatUtils.withFormat;
@OnlyIn(Dist.CLIENT)
public abstract class AbstractMachineTerminalScreen<T extends AbstractMachineTerminalContainer> extends AbstractModContainerScreen<T> {

View File

@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.client.gui;
package li.cil.oc2.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;

View File

@@ -1,13 +1,13 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.client.gui;
package li.cil.oc2.client.gui;
import com.mojang.blaze3d.platform.InputConstants;
import li.cil.oc2r.client.gui.widget.ToggleImageButton;
import li.cil.oc2r.common.Config;
import li.cil.oc2r.common.Constants;
import li.cil.oc2r.common.container.AbstractMonitorContainer;
import li.cil.oc2r.common.util.TooltipUtils;
import li.cil.oc2.client.gui.widget.ToggleImageButton;
import li.cil.oc2.common.Config;
import li.cil.oc2.common.Constants;
import li.cil.oc2.common.container.AbstractMonitorContainer;
import li.cil.oc2.common.util.TooltipUtils;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.EditBox;
@@ -21,7 +21,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.List;
import static java.util.Arrays.asList;
import static li.cil.oc2r.common.util.TextFormatUtils.withFormat;
import static li.cil.oc2.common.util.TextFormatUtils.withFormat;
@OnlyIn(Dist.CLIENT)
public abstract class AbstractMonitorDisplayScreen<T extends AbstractMonitorContainer> extends AbstractModContainerScreen<T> {

View File

@@ -1,14 +1,14 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.client.gui;
package li.cil.oc2.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import li.cil.oc2r.client.gui.widget.ImageButton;
import li.cil.oc2r.common.Constants;
import li.cil.oc2r.common.blockentity.BusCableBlockEntity;
import li.cil.oc2r.common.item.Items;
import li.cil.oc2r.common.network.Network;
import li.cil.oc2r.common.network.message.BusInterfaceNameMessage;
import li.cil.oc2.client.gui.widget.ImageButton;
import li.cil.oc2.common.Constants;
import li.cil.oc2.common.blockentity.BusCableBlockEntity;
import li.cil.oc2.common.item.Items;
import li.cil.oc2.common.network.Network;
import li.cil.oc2.common.network.message.BusInterfaceNameMessage;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.narration.NarrationElementOutput;
@@ -18,7 +18,7 @@ import net.minecraft.network.chat.Component;
import net.minecraft.world.phys.Vec3;
import org.lwjgl.glfw.GLFW;
import static li.cil.oc2r.common.util.TranslationUtils.text;
import static li.cil.oc2.common.util.TranslationUtils.text;
public final class BusInterfaceScreen extends Screen {
private static final int TEXT_LEFT = 9;

View File

@@ -1,8 +1,8 @@
/* SPDX-License-Identifier: MIT */
package li.cil.oc2r.client.gui;
package li.cil.oc2.client.gui;
import li.cil.oc2r.common.container.ComputerInventoryContainer;
import li.cil.oc2.common.container.ComputerInventoryContainer;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Inventory;

Some files were not shown because too many files have changed in this diff Show More