This commit is contained in:
2025-06-24 10:35:46 +03:00
parent 0e57b3e1bb
commit 3fa2d6d48c
12 changed files with 413 additions and 16 deletions

1
.idea/gradle.xml generated
View File

@ -14,5 +14,6 @@
<option name="resolveExternalAnnotations" value="true" />
</GradleProjectSettings>
</option>
<option name="parallelModelFetch" value="true" />
</component>
</project>

View File

@ -143,6 +143,7 @@ repositories {
flatDir {
dirs("libs")
}
maven {
@ -207,7 +208,7 @@ dependencies {
// jarJar.ranged(it, "[0.2.0-beta.6,)")
//}
implementation fg.deobf("libs:clockworkadditions:1.20.1-0.0.6")
//implementation fg.deobf("libs:clockworkadditions:1.20.1-0.0.6")
implementation(files("./libs/cobalt-0.9.3.jar"))
@ -229,8 +230,6 @@ dependencies {
implementation(fg.deobf("com.simibubi.create:create-1.20.1:0.5.1.j"))
implementation fg.deobf(files("./libs/api-1.1.0+b19b27c4a4.jar"))
implementation fg.deobf(files("./libs/WariumVS 0.0.4.jar"))
//implementation fg.deobf("maven.modrinth:create-copies-cats:0.0.1-1.20.1")
//implementation fg.deobf(files("./libs/framed/FramedBlocks-9.3.0.jar"))

View File

@ -1,5 +1,3 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
minecraft_version=1.20.1
minecraft_version_range=[1.20.1,1.21)
forge_version=47.3.5
@ -16,4 +14,13 @@ mod_authors=p2vman
mod_description=
the_vmod_version = 1.2.2
valkyrien_ship_schematics_version = 1.0
valkyrien_ship_schematics_version = 1.0
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.caching=true
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
systemProp.sun.net.client.defaultConnectTimeout=200
systemProp.sun.net.client.defaultReadTimeout=200

234
gradlew vendored Executable file
View File

@ -0,0 +1,234 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@ -1,16 +1,25 @@
package io.p2vman.vmodextras.cc;
import dan200.computercraft.api.pocket.IPocketUpgrade;
import dan200.computercraft.api.pocket.PocketUpgradeSerialiser;
import dan200.computercraft.api.turtle.TurtleUpgradeSerialiser;
import dan200.computercraft.shared.pocket.peripherals.PocketModem;
import io.p2vman.vmodextras.VmodExtras;
import io.p2vman.vmodextras.cc.block.BlockNetworkModem;
import io.p2vman.vmodextras.cc.block.WireNetworkHubBlock;
import io.p2vman.vmodextras.cc.block.entity.NetworkModemEntity;
import io.p2vman.vmodextras.cc.peripheral.net.PocketNetworkModem;
import io.p2vman.vmodextras.util.HoverBlockItem;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.MapColor;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;
import io.p2vman.vmodextras.cc.block.TrackWorkController;
import io.p2vman.vmodextras.cc.block.entity.TrackWorkControllerEntity;
@ -24,8 +33,11 @@ public class ComputerCraftCompact {
public static RegistryObject<Block> TRACK_WORK_CONTROLLER_BLOCK;
public static RegistryObject<Item> TRACK_WORK_CONTROLLER_ITEM;
public static RegistryObject<Block> WIRE_NETWORK_HUB_BLOCK;
public static RegistryObject<Item> WIRE_NETWORK_HUB_ITEM;
//public static RegistryObject<Block> WIRE_NETWORK_HUB_BLOCK;
//public static RegistryObject<Item> WIRE_NETWORK_HUB_ITEM;
public static final DeferredRegister<TurtleUpgradeSerialiser<?>> TURTLE_SERIALIZER = DeferredRegister.create(TurtleUpgradeSerialiser.registryId(), VmodExtras.MODID);
public static final DeferredRegister<PocketUpgradeSerialiser<?>> POCKET_SERIALIZER = DeferredRegister.create(PocketUpgradeSerialiser.registryId(), VmodExtras.MODID);
public static void init(ModRegistry REGISTRY, ModRegistry.TabBuilder builder) {
@ -55,5 +67,17 @@ public class ComputerCraftCompact {
// WIRE_NETWORK_HUB_ITEM = registry.register("wire_network_hub", () -> new BlockItem(WIRE_NETWORK_HUB_BLOCK.get(), new Item.Properties().rarity(Rarity.EPIC)));
//});
});
POCKET_SERIALIZER.register("network_modem", () ->
PocketUpgradeSerialiser.simpleWithCustomItem(
(i,n) -> new PocketNetworkModem(
new ResourceLocation(VmodExtras.MODID, "network_modem"),
new ItemStack(NETWORK_MODEM.getItem().get())
)
)
);
REGISTRY.register(TURTLE_SERIALIZER);
REGISTRY.register(POCKET_SERIALIZER);
}
}

View File

@ -47,6 +47,10 @@ public class ModemState {
}
}
public boolean isOpen() {
return this.open;
}
public void open(int channel) throws LuaException
{
synchronized(channels)

View File

@ -50,9 +50,9 @@ public class TrackWorkControllerPeripheral extends PeripheralBase {
if (controller != null) {
controller.setSuspensionAdjust(new Vector3d(
Math.max(Math.min(arguments.getDouble(1), 1d), 0d),
Math.max(Math.min(arguments.getDouble(1), 1d), -1d),
Math.max(Math.min(arguments.getDouble(2), 1.3d), 0.5d),
Math.max(Math.min(arguments.getDouble(3), 1d), 0d)
Math.max(Math.min(arguments.getDouble(3), 1d), -1d)
));
}
}

View File

@ -0,0 +1,33 @@
package io.p2vman.vmodextras.cc.peripheral.net;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.pocket.AbstractPocketUpgrade;
import dan200.computercraft.api.pocket.IPocketAccess;
import io.p2vman.vmodextras.cc.net.ModemState;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nullable;
public class PocketNetworkModem extends AbstractPocketUpgrade {
public PocketNetworkModem(ResourceLocation id, ItemStack stack) {
super(id,"upgrade.vmodextras.network_modem.adjective", stack);
}
@Nullable
public IPeripheral createPeripheral(IPocketAccess access) {
return new PocketNetworkModemPeripheral(access);
}
public void update(IPocketAccess access, @Nullable IPeripheral peripheral) {
if (peripheral instanceof PocketNetworkModemPeripheral modem) {
ModemState state = modem.getModemState();
if (state.pollChanged()) {
access.setLight(state.isOpen() ? 12189696 : -1);
}
}
}
}

View File

@ -0,0 +1,37 @@
package io.p2vman.vmodextras.cc.peripheral.net;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.pocket.IPocketAccess;
import dan200.computercraft.shared.pocket.peripherals.PocketModemPeripheral;
import io.p2vman.vmodextras.cc.net.INetwork;
import io.p2vman.vmodextras.cc.net.ModemState;
import io.p2vman.vmodextras.cc.net.Network;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import javax.annotation.Nullable;
public class PocketNetworkModemPeripheral extends NetworkModemPeripheral {
private final IPocketAccess access;
public PocketNetworkModemPeripheral(IPocketAccess access) {
super(new ModemState());
this.access = access;
}
public Level getLevel() {
return this.access.getLevel();
}
public Vec3 getPosition() {
return this.access.getPosition();
}
public boolean equals(@Nullable IPeripheral other) {
return other instanceof PocketModemPeripheral;
}
@Override
protected INetwork getNetwork() {
return Network.getUniversal();
}
}

View File

@ -4,9 +4,9 @@ import it.unimi.dsi.fastutil.Pair;
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectObjectImmutablePair;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import lombok.Getter;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
@ -33,6 +33,8 @@ public class ModRegistry {
public final Map<RegistryObject<CreativeModeTab>, DeferredRegister<Item>> ITEMS;
public final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS;
private final Set<Consumer<IEventBus>> hoosk = new ObjectOpenHashSet<>();
public ModRegistry(String modid) {
this.modid = modid;
this.BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, modid);
@ -45,13 +47,24 @@ public class ModRegistry {
return new TabBuilder(this);
}
public void register(IEventBus bus) {
this.BLOCKS.register(bus);
this.BLOCK_ENTITIES.register(bus);
this.CREATIVE_MODE_TABS.register(bus);
for (DeferredRegister<Item> registry : ITEMS.values()) {
registry.register(bus);
}
this.CREATIVE_MODE_TABS.register(bus);
hoosk.forEach((i -> i.accept(bus)));
}
public void register(Consumer<IEventBus> hook) {
this.hoosk.add(hook);
}
public void register(DeferredRegister<?> reg) {
register(reg::register);
}
@ -89,12 +102,22 @@ public class ModRegistry {
BLOCK_ENTITY
}
public enum RegistryState {
BUILDING, REGISTERED
}
public static class RegistryContainer implements Iterable<Pair<RegistryEntryType, Object>> {
private Object[] suppilers;
private final Object[] values;
@Getter
private final String id;
@Getter
private RegistryState state;
public RegistryContainer(String id) {
this.values = new Object[RegistryEntryType.values().length];
this.suppilers = new Object[RegistryEntryType.values().length];
this.id = id;
this.state = RegistryState.BUILDING;
}
public Object get(RegistryEntryType key) {
@ -114,6 +137,7 @@ public class ModRegistry {
}
public <T> T getG(RegistryEntryType key) {
if (this.state != RegistryState.REGISTERED) throw new RuntimeException();
return (T) values[key.ordinal()];
}
@ -144,7 +168,8 @@ public class ModRegistry {
}
public void put(RegistryEntryType key, Object value) {
values[key.ordinal()] = value;
if (this.state != RegistryState.BUILDING) throw new RuntimeException();
suppilers[key.ordinal()] = value;
}
@ -174,18 +199,26 @@ public class ModRegistry {
}
public RegistryContainer register(ModRegistry registry) {
if (containsKey(RegistryEntryType.BLOCK)) put(RegistryEntryType.BLOCK, registry.BLOCKS.register(id, (Supplier<? extends Block>) get(RegistryEntryType.BLOCK)));
if (containsKey(RegistryEntryType.BLOCK_ENTITY)) put(RegistryEntryType.BLOCK_ENTITY, registry.BLOCK_ENTITIES.register(id, (Supplier<? extends BlockEntityType<? extends BlockEntity>>) get(RegistryEntryType.BLOCK_ENTITY)));
if (suppilers != null && suppilers[RegistryEntryType.BLOCK.ordinal()] != null)
put(RegistryEntryType.BLOCK, registry.BLOCKS.register(id, (Supplier<? extends Block>) suppilers[RegistryEntryType.BLOCK.ordinal()]));
if (suppilers != null && suppilers[RegistryEntryType.BLOCK_ENTITY.ordinal()] != null)
put(RegistryEntryType.BLOCK_ENTITY, registry.BLOCK_ENTITIES.register(id, (Supplier<? extends BlockEntityType<? extends BlockEntity>>) suppilers[RegistryEntryType.BLOCK_ENTITY.ordinal()]));
post();
return this;
}
public RegistryContainer register(TabBuilder builder) {
if (containsKey(RegistryEntryType.ITEM)) put(RegistryEntryType.ITEM, builder.ITEMS.register(id, (Supplier<? extends Item>) get(RegistryEntryType.ITEM)));
if (suppilers != null && suppilers[RegistryEntryType.ITEM.ordinal()] != null) put(RegistryEntryType.ITEM, builder.ITEMS.register(id, (Supplier<? extends Item>) suppilers[RegistryEntryType.ITEM.ordinal()]));
return this;
}
public void post() {
this.state = RegistryState.REGISTERED;
this.suppilers = null;
}
public static RegistryContainer create(String id) {
return new RegistryContainer(id);
}

View File

@ -0,0 +1,20 @@
[org 0x7C00]
mov si, message
.print_char:
lodsb
or al, al
jz .hang
mov ah, 0x0E
int 0x10
jmp .print_char
.hang:
cli
hlt
jmp .hang
message db "Hello from boot!", 0
times 510 - ($ - $$) db 0 ;
dw 0xAA55

View File

@ -13,5 +13,10 @@
"block": "vmodextras:compact_backup",
"mass": 120.0,
"friction": 0.0
},
{
"block": "vmodextras:network_modem",
"mass": 120.0,
"friction": 0.0
}
]