...
This commit is contained in:
parent
5259407e37
commit
dd80dd5859
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DiscordProjectSettings">
|
||||||
|
<option name="show" value="PROJECT_FILES" />
|
||||||
|
<option name="description" value="" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="io.github.pandier.intellijdiscordrp.settings.project.DiscordProjectSettingsComponent">
|
||||||
|
<option name="displayMode" value="File" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -5,6 +5,7 @@
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="ms-17" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|
|
@ -41,5 +41,25 @@
|
||||||
<option name="name" value="maven2" />
|
<option name="name" value="maven2" />
|
||||||
<option name="url" value="https://squiddev.cc/maven/" />
|
<option name="url" value="https://squiddev.cc/maven/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven3" />
|
||||||
|
<option name="name" value="maven3" />
|
||||||
|
<option name="url" value="https://cursemaven.com" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="tterrag maven" />
|
||||||
|
<option name="name" value="tterrag maven" />
|
||||||
|
<option name="url" value="https://maven.tterrag.com/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven4" />
|
||||||
|
<option name="name" value="maven4" />
|
||||||
|
<option name="url" value="https://maven.minecraftforge.net" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven5" />
|
||||||
|
<option name="name" value="maven5" />
|
||||||
|
<option name="url" value="https://maven.bawnorton.com/releases" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="minecraft" name="Minecraft">
|
||||||
|
<configuration>
|
||||||
|
<autoDetectTypes>
|
||||||
|
<platformType>FORGE</platformType>
|
||||||
|
<platformType>MIXIN</platformType>
|
||||||
|
<platformType>MCP</platformType>
|
||||||
|
</autoDetectTypes>
|
||||||
|
<projectReimportVersion>1</projectReimportVersion>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
<component name="McpModuleSettings">
|
||||||
|
<option name="mappingFile" value="$MODULE_DIR$/../../build/createMcpToSrg/output.tsrg" />
|
||||||
|
<option name="mcpVersion" value="official_1.20.1" />
|
||||||
|
<option name="minecraftVersion" value="1.20.1" />
|
||||||
|
<option name="platformVersion" value="47.3.5" />
|
||||||
|
<option name="srgType" value="TSRG" />
|
||||||
|
</component>
|
||||||
|
</module>
|
|
@ -155,6 +155,21 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
maven { url 'https://squiddev.cc/maven/' }
|
maven { url 'https://squiddev.cc/maven/' }
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url "https://cursemaven.com"
|
||||||
|
content {
|
||||||
|
includeGroup "curse.maven"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
maven { url = 'https://maven.minecraftforge.net' }
|
||||||
|
maven {
|
||||||
|
name = 'tterrag maven'
|
||||||
|
url = 'https://maven.tterrag.com/'
|
||||||
|
}
|
||||||
|
|
||||||
|
maven { url = "https://maven.bawnorton.com/releases" }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -176,12 +191,27 @@ dependencies {
|
||||||
// The group id is ignored when searching -- in this case, it is "blank"
|
// The group id is ignored when searching -- in this case, it is "blank"
|
||||||
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
|
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
|
||||||
|
|
||||||
implementation fg.deobf(files("./libs/VMod-Forge-1.20.1-1.2.2.jar"))
|
implementation fg.deobf(files("./libs/vmod-forge-1.20.1-1.2.2.jar"))
|
||||||
implementation fg.deobf(files("./libs/valkyrien-ship-schematics-forge-1.20.1-1.1.jar"))
|
implementation fg.deobf(files("./libs/valkyrien-ship-schematics-forge-1.20.1-1.1.jar"))
|
||||||
implementation(fg.deobf(files("./libs/kotlinforforge-4.11.0-all.jar")))
|
implementation(fg.deobf(files("./libs/kotlinforforge-4.11.0-all.jar")))
|
||||||
implementation(fg.deobf(files("./libs/trackwork-1.20.1-1.1.1b.jar")))
|
implementation(fg.deobf(files("./libs/trackwork-1.20.1-1.1.1b.jar")))
|
||||||
implementation(fg.deobf("org.valkyrienskies:valkyrienskies-120:2.3.0-beta.7"))
|
implementation(fg.deobf("org.valkyrienskies:valkyrienskies-120:2.3.0-beta.7"))
|
||||||
|
|
||||||
|
implementation("org.joml:joml:1.10.4") { transitive = false }
|
||||||
|
implementation("org.joml:joml-primitives:1.10.0") { transitive = false }
|
||||||
|
|
||||||
|
implementation fg.deobf("curse.maven:create-tweaked-controllers-898849:5206625")
|
||||||
|
|
||||||
|
//compileOnly(annotationProcessor("com.bawnorton.mixinsquared:mixinsquared-common:0.2.0-beta.6"))
|
||||||
|
//implementation(jarJar("com.bawnorton.mixinsquared:mixinsquared-forge:0.2.0-beta.6")) {
|
||||||
|
// jarJar.ranged(it, "[0.2.0-beta.6,)")
|
||||||
|
//}
|
||||||
|
|
||||||
|
implementation fg.deobf("libs:clockworkadditions:1.20.1-0.0.6")
|
||||||
|
|
||||||
|
|
||||||
|
implementation(files("./libs/cobalt-0.9.3.jar"))
|
||||||
|
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.14.0'
|
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.14.0'
|
||||||
|
|
||||||
implementation 'net.minecraftforge:modlauncher:10.1.1'
|
implementation 'net.minecraftforge:modlauncher:10.1.1'
|
||||||
|
@ -192,10 +222,15 @@ dependencies {
|
||||||
jarJar.ranged(it, "[0.4.1,)")
|
jarJar.ranged(it, "[0.4.1,)")
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation fg.deobf(files("./libs/drivebywire-1.20.1-0.0.10.jar"))
|
implementation fg.deobf("libs:cc-tweaked:1.20.1-forge-1.113.1")
|
||||||
|
|
||||||
|
|
||||||
|
implementation fg.deobf("libs:drivebywire:1.20.1-0.0.10")
|
||||||
implementation(fg.deobf("com.simibubi.create:create-1.20.1:0.5.1.j"))
|
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/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("maven.modrinth:create-copies-cats:0.0.1-1.20.1")
|
||||||
//implementation fg.deobf(files("./libs/framed/FramedBlocks-9.3.0.jar"))
|
//implementation fg.deobf(files("./libs/framed/FramedBlocks-9.3.0.jar"))
|
||||||
|
|
||||||
|
@ -208,7 +243,7 @@ dependencies {
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.20'
|
compileOnly 'org.projectlombok:lombok:1.18.20'
|
||||||
annotationProcessor 'org.projectlombok:lombok:1.18.20'
|
annotationProcessor 'org.projectlombok:lombok:1.18.20'
|
||||||
|
|
||||||
implementation fg.deobf("org.squiddev:cc-tweaked-1.19.2:1.101.3")
|
//implementation fg.deobf("org.squiddev:cc-tweaked-1.19.2:1.101.3")
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -241,7 +276,9 @@ tasks.named('jar', Jar).configure {
|
||||||
"Implementation-Title" : project.name,
|
"Implementation-Title" : project.name,
|
||||||
"Implementation-Version" : project.jar.archiveVersion,
|
"Implementation-Version" : project.jar.archiveVersion,
|
||||||
"Implementation-Vendor" : mod_authors,
|
"Implementation-Vendor" : mod_authors,
|
||||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")])
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||||
|
"Main-Class" : "io.p2vman.vmodextras.main.Main"
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the preferred method to reobfuscate your jar file
|
// This is the preferred method to reobfuscate your jar file
|
||||||
|
|
|
@ -10,8 +10,8 @@ mapping_version=1.20.1
|
||||||
mod_id=vmodextras
|
mod_id=vmodextras
|
||||||
mod_name=VModExtras
|
mod_name=VModExtras
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
mod_version=0.0.1b
|
mod_version=0.0.2b
|
||||||
mod_group_id=space.eptaproject
|
mod_group_id=io.p2vman
|
||||||
mod_authors=p2vman
|
mod_authors=p2vman
|
||||||
mod_description=
|
mod_description=
|
||||||
|
|
||||||
|
|
42
src/main/java/space/eptaproject/vmodextras/Config.java → src/main/java/io/p2vman/vmodextras/Config.java
Normal file → Executable file
42
src/main/java/space/eptaproject/vmodextras/Config.java → src/main/java/io/p2vman/vmodextras/Config.java
Normal file → Executable file
|
@ -1,8 +1,11 @@
|
||||||
package space.eptaproject.vmodextras;
|
package io.p2vman.vmodextras;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
|
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
@ -10,6 +13,28 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class ClampContext {
|
||||||
|
private boolean enable;
|
||||||
|
private double min;
|
||||||
|
private double max;
|
||||||
|
|
||||||
|
private ForgeConfigSpec.ConfigValue<Double> _min;
|
||||||
|
private ForgeConfigSpec.ConfigValue<Double> _max;
|
||||||
|
private ForgeConfigSpec.ConfigValue<Boolean> _enable;
|
||||||
|
|
||||||
|
public double clamp(double input) {
|
||||||
|
if (!enable) return input;
|
||||||
|
return Math.max(Math.min(input, max), min);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
enable = _enable.get();
|
||||||
|
max = _max.get();
|
||||||
|
min = _min.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
public static final ForgeConfigSpec COMMON_CONFIG;
|
public static final ForgeConfigSpec COMMON_CONFIG;
|
||||||
public static final ForgeConfigSpec.ConfigValue<List<? extends String>> RESOURCE_LOCATION_LIST;
|
public static final ForgeConfigSpec.ConfigValue<List<? extends String>> RESOURCE_LOCATION_LIST;
|
||||||
public static final ForgeConfigSpec.ConfigValue<List<? extends String>> ITEM_BLACK_LIST;
|
public static final ForgeConfigSpec.ConfigValue<List<? extends String>> ITEM_BLACK_LIST;
|
||||||
|
@ -26,10 +51,23 @@ public class Config {
|
||||||
public static ResourceLocation replace = Validator.RB;
|
public static ResourceLocation replace = Validator.RB;
|
||||||
public static boolean Inventory_Blocked_Blocks_Enable = false;
|
public static boolean Inventory_Blocked_Blocks_Enable = false;
|
||||||
public static boolean Schematic_Blocked_Blocks_Enable = false;
|
public static boolean Schematic_Blocked_Blocks_Enable = false;
|
||||||
|
public static ClampContext SCALE_CLAMP;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
||||||
|
|
||||||
|
builder.push("ToolGun");
|
||||||
|
|
||||||
|
builder.push("scale_clamp");
|
||||||
|
SCALE_CLAMP = new ClampContext(false, 0, 0,
|
||||||
|
builder.defineInRange("min", 0.3d, 0.001d, 30d),
|
||||||
|
builder.defineInRange("max", 1.5d, 0.001d, 30d),
|
||||||
|
builder.define("enable", true)
|
||||||
|
);
|
||||||
|
builder.pop();
|
||||||
|
|
||||||
|
builder.pop();
|
||||||
|
|
||||||
builder.push("Schematic");
|
builder.push("Schematic");
|
||||||
|
|
||||||
RESOURCE_LOCATION_LIST = builder
|
RESOURCE_LOCATION_LIST = builder
|
||||||
|
@ -108,6 +146,8 @@ public class Config {
|
||||||
|
|
||||||
Inventory_Blocked_Blocks_Enable = Inventory_Blocked_Blocks.get();
|
Inventory_Blocked_Blocks_Enable = Inventory_Blocked_Blocks.get();
|
||||||
Schematic_Blocked_Blocks_Enable = Schematic_Blocked_Blocks.get();
|
Schematic_Blocked_Blocks_Enable = Schematic_Blocked_Blocks.get();
|
||||||
|
|
||||||
|
SCALE_CLAMP.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean contains(ItemStack stack) {
|
public static boolean contains(ItemStack stack) {
|
|
@ -0,0 +1,13 @@
|
||||||
|
package io.p2vman.vmodextras;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.GameRules;
|
||||||
|
|
||||||
|
public class GameRulesBlat {
|
||||||
|
public static final GameRules.Key<GameRules.BooleanValue> EX4 =
|
||||||
|
GameRules.register("vmodextras_ex4", GameRules.Category.PLAYER, GameRules.BooleanValue.create(true));
|
||||||
|
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
2
src/main/java/space/eptaproject/vmodextras/IValidator.java → src/main/java/io/p2vman/vmodextras/IValidator.java
Normal file → Executable file
2
src/main/java/space/eptaproject/vmodextras/IValidator.java → src/main/java/io/p2vman/vmodextras/IValidator.java
Normal file → Executable file
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras;
|
package io.p2vman.vmodextras;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
4
src/main/java/space/eptaproject/vmodextras/Validator.java → src/main/java/io/p2vman/vmodextras/Validator.java
Normal file → Executable file
4
src/main/java/space/eptaproject/vmodextras/Validator.java → src/main/java/io/p2vman/vmodextras/Validator.java
Normal file → Executable file
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras;
|
package io.p2vman.vmodextras;
|
||||||
|
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -8,7 +8,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import space.eptaproject.vmodextras.util.ResourceLocationUtil;
|
import io.p2vman.vmodextras.util.ResourceLocationUtil;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
public class Validator implements IValidator {
|
public class Validator implements IValidator {
|
33
src/main/java/space/eptaproject/vmodextras/VmodExtras.java → src/main/java/io/p2vman/vmodextras/VmodExtras.java
Normal file → Executable file
33
src/main/java/space/eptaproject/vmodextras/VmodExtras.java → src/main/java/io/p2vman/vmodextras/VmodExtras.java
Normal file → Executable file
|
@ -1,13 +1,15 @@
|
||||||
package space.eptaproject.vmodextras;
|
package io.p2vman.vmodextras;
|
||||||
|
|
||||||
import com.google.common.base.VerifyException;
|
import com.google.common.base.VerifyException;
|
||||||
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraft.world.item.*;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
||||||
import net.minecraft.world.level.material.MapColor;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
|
||||||
|
import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||||
|
import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
@ -20,12 +22,10 @@ import net.minecraftforge.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.minecraftforge.registries.*;
|
|
||||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import space.eptaproject.vmodextras.block.*;
|
import io.p2vman.vmodextras.compact.Compact;
|
||||||
import space.eptaproject.vmodextras.compact.Compact;
|
import io.p2vman.vmodextras.util.ModRegistry;
|
||||||
import space.eptaproject.vmodextras.util.ModRegistry;
|
|
||||||
|
|
||||||
@Mod(VmodExtras.MODID)
|
@Mod(VmodExtras.MODID)
|
||||||
public class VmodExtras {
|
public class VmodExtras {
|
||||||
|
@ -33,22 +33,13 @@ public class VmodExtras {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
public static RegistryObject<BlockEntityType<EntityBackupBlockEntity>> ENTITY_BACKUP_BLOCK_ENTITY;
|
|
||||||
public static RegistryObject<Block> ENTITY_BACKUP;
|
|
||||||
public static RegistryObject<Item> ENTITY_BACKUP_ITEM;
|
|
||||||
|
|
||||||
public static final ModRegistry REGISTRY;
|
public static final ModRegistry REGISTRY;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
REGISTRY = new ModRegistry(MODID);
|
REGISTRY = new ModRegistry(MODID);
|
||||||
|
|
||||||
ENTITY_BACKUP = REGISTRY.BLOCKS.register("entity_backup", () -> new EntityBackupBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
new Compact((registry, builder) -> {
|
||||||
ENTITY_BACKUP_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("entity_backup", () -> BlockEntityType.Builder.of(EntityBackupBlockEntity::new, ENTITY_BACKUP.get()).build(null));
|
|
||||||
|
|
||||||
new Compact((REGISTRY, builder) -> {
|
|
||||||
builder.push((registry) -> {
|
|
||||||
ENTITY_BACKUP_ITEM = registry.register("entity_backup", () -> new BlockItem(ENTITY_BACKUP.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +57,8 @@ public class VmodExtras {
|
||||||
|
|
||||||
|
|
||||||
private void commonSetup(final FMLCommonSetupEvent event) {
|
private void commonSetup(final FMLCommonSetupEvent event) {
|
||||||
|
GameRulesBlat.init();
|
||||||
|
|
||||||
String currentVersion = ForgeVersion.getVersion();
|
String currentVersion = ForgeVersion.getVersion();
|
||||||
if (compareVersion(currentVersion, MIN_FORGE_VERSION) < 0) {
|
if (compareVersion(currentVersion, MIN_FORGE_VERSION) < 0) {
|
||||||
throw new ModLoadingException(
|
throw new ModLoadingException(
|
|
@ -0,0 +1,58 @@
|
||||||
|
package io.p2vman.vmodextras.cc;
|
||||||
|
|
||||||
|
import io.p2vman.vmodextras.cc.block.BlockNetworkModem;
|
||||||
|
import io.p2vman.vmodextras.cc.block.WireNetworkHubBlock;
|
||||||
|
import io.p2vman.vmodextras.cc.block.entity.NetworkModemEntity;
|
||||||
|
import net.minecraft.world.item.BlockItem;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
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.RegistryObject;
|
||||||
|
import io.p2vman.vmodextras.cc.block.TrackWorkController;
|
||||||
|
import io.p2vman.vmodextras.cc.block.entity.TrackWorkControllerEntity;
|
||||||
|
import io.p2vman.vmodextras.util.ModRegistry;
|
||||||
|
import io.p2vman.vmodextras.util.Utils;
|
||||||
|
|
||||||
|
public class ComputerCraftCompact {
|
||||||
|
public static ModRegistry.RegistryContainer NETWORK_MODEM = ModRegistry.RegistryContainer.create("network_modem");
|
||||||
|
public static RegistryObject<BlockEntityType<TrackWorkControllerEntity>> TRACK_WORK_CONTROLLER_BLOCK_ENTITY;
|
||||||
|
|
||||||
|
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 void init(ModRegistry REGISTRY, ModRegistry.TabBuilder builder) {
|
||||||
|
|
||||||
|
NETWORK_MODEM.block(() -> new BlockNetworkModem(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||||
|
NETWORK_MODEM.entity(() -> BlockEntityType.Builder.of(NetworkModemEntity::new, NETWORK_MODEM.getBlock().get()).build(null));
|
||||||
|
NETWORK_MODEM.item(() -> new BlockItem(NETWORK_MODEM.getBlock().get(), new Item.Properties().rarity(Rarity.EPIC)));
|
||||||
|
|
||||||
|
Utils.executeIsModEnable("trackwork", () -> {
|
||||||
|
TRACK_WORK_CONTROLLER_BLOCK = REGISTRY.BLOCKS.register("track_work_controller", () -> new TrackWorkController(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||||
|
|
||||||
|
TRACK_WORK_CONTROLLER_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("track_work_controller", () -> BlockEntityType.Builder.of(TrackWorkControllerEntity::new, TRACK_WORK_CONTROLLER_BLOCK.get()).build(null));
|
||||||
|
});
|
||||||
|
|
||||||
|
//Utils.executeIsModEnable("drivebywire", () -> {
|
||||||
|
// WIRE_NETWORK_HUB_BLOCK = REGISTRY.BLOCKS.register("wire_network_hub", () -> new WireNetworkHubBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||||
|
//});
|
||||||
|
|
||||||
|
NETWORK_MODEM.register(REGISTRY);
|
||||||
|
NETWORK_MODEM.register(builder);
|
||||||
|
|
||||||
|
builder.push((registry) -> {
|
||||||
|
Utils.executeIsModEnable("trackwork", () -> {
|
||||||
|
TRACK_WORK_CONTROLLER_ITEM = registry.register("track_work_controller", () -> new BlockItem(TRACK_WORK_CONTROLLER_BLOCK.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
||||||
|
});
|
||||||
|
|
||||||
|
//Utils.executeIsModEnable("drivebywire", () -> {
|
||||||
|
// WIRE_NETWORK_HUB_ITEM = registry.register("wire_network_hub", () -> new BlockItem(WIRE_NETWORK_HUB_BLOCK.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
||||||
|
//});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
package io.p2vman.vmodextras.cc.block;
|
||||||
|
|
||||||
|
import dan200.computercraft.shared.peripheral.modem.ModemShapes;
|
||||||
|
import dan200.computercraft.shared.util.WaterloggableHelpers;
|
||||||
|
import io.p2vman.vmodextras.cc.ComputerCraftCompact;
|
||||||
|
import io.p2vman.vmodextras.cc.block.entity.NetworkModemEntity;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.util.RandomSource;
|
||||||
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
|
import net.minecraft.world.level.BlockGetter;
|
||||||
|
import net.minecraft.world.level.LevelAccessor;
|
||||||
|
import net.minecraft.world.level.LevelReader;
|
||||||
|
import net.minecraft.world.level.block.*;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||||
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
|
import net.minecraft.world.level.material.FluidState;
|
||||||
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import static dan200.computercraft.shared.util.WaterloggableHelpers.WATERLOGGED;
|
||||||
|
import static dan200.computercraft.shared.util.WaterloggableHelpers.getFluidStateForPlacement;
|
||||||
|
|
||||||
|
public class BlockNetworkModem extends DirectionalBlock implements SimpleWaterloggedBlock, EntityBlock
|
||||||
|
{
|
||||||
|
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||||
|
public static final BooleanProperty ON = BooleanProperty.create( "on" );
|
||||||
|
|
||||||
|
public BlockNetworkModem(Properties settings)
|
||||||
|
{
|
||||||
|
super(settings);
|
||||||
|
registerDefaultState( getStateDefinition().any()
|
||||||
|
.setValue( FACING, Direction.NORTH )
|
||||||
|
.setValue( ON, false )
|
||||||
|
.setValue( WATERLOGGED, false ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createBlockStateDefinition( StateDefinition.Builder<Block, BlockState> builder )
|
||||||
|
{
|
||||||
|
builder.add( FACING, ON, WATERLOGGED );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public VoxelShape getShape(BlockState blockState, @Nonnull BlockGetter blockView, @Nonnull BlockPos blockPos, @Nonnull CollisionContext context )
|
||||||
|
{
|
||||||
|
return ModemShapes.getBounds( blockState.getValue( FACING ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public FluidState getFluidState(@Nonnull BlockState state )
|
||||||
|
{
|
||||||
|
return WaterloggableHelpers.getFluidState( state );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public BlockState updateShape(@Nonnull BlockState state, @Nonnull Direction side, @Nonnull BlockState otherState, @Nonnull LevelAccessor world, @Nonnull BlockPos pos, @Nonnull BlockPos otherPos )
|
||||||
|
{
|
||||||
|
WaterloggableHelpers.updateShape( state, world, pos );
|
||||||
|
return side == state.getValue( FACING ) && !state.canSurvive( world, pos )
|
||||||
|
? state.getFluidState().createLegacyBlock()
|
||||||
|
: state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public boolean canSurvive(BlockState state, @Nonnull LevelReader world, BlockPos pos )
|
||||||
|
{
|
||||||
|
Direction facing = state.getValue( FACING );
|
||||||
|
return canSupportCenter( world, pos.relative( facing ), facing.getOpposite() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForPlacement( BlockPlaceContext placement )
|
||||||
|
{
|
||||||
|
return defaultBlockState()
|
||||||
|
.setValue( FACING, placement.getClickedFace().getOpposite() )
|
||||||
|
.setValue( WATERLOGGED, getFluidStateForPlacement( placement ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public BlockState mirror( BlockState state, Mirror mirrorIn )
|
||||||
|
{
|
||||||
|
return state.rotate( mirrorIn.getRotation( state.getValue( FACING ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public BlockState rotate( BlockState state, Rotation rot )
|
||||||
|
{
|
||||||
|
return state.setValue( FACING, rot.rotate( state.getValue( FACING ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@org.jetbrains.annotations.Nullable
|
||||||
|
@Override
|
||||||
|
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||||
|
return ComputerCraftCompact.NETWORK_MODEM.getEntity().get().create(blockPos, blockState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource rand) {
|
||||||
|
BlockEntity te = level.getBlockEntity(pos);
|
||||||
|
if (te instanceof NetworkModemEntity modem) {
|
||||||
|
modem.blockTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package io.p2vman.vmodextras.cc.block;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import io.p2vman.vmodextras.cc.ComputerCraftCompact;
|
||||||
|
import io.p2vman.vmodextras.cc.block.entity.TrackWorkControllerEntity;
|
||||||
|
import io.p2vman.vmodextras.util.IBlockEntity;
|
||||||
|
|
||||||
|
public class TrackWorkController extends Block implements IBlockEntity<TrackWorkControllerEntity> {
|
||||||
|
public TrackWorkController(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockEntityType<? extends TrackWorkControllerEntity> getBlockEntityType() {
|
||||||
|
return ComputerCraftCompact.TRACK_WORK_CONTROLLER_BLOCK_ENTITY.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level p_153212_, BlockState p_153213_, BlockEntityType<T> p_153214_) {
|
||||||
|
return IBlockEntity.super.getTicker(p_153212_, p_153213_, p_153214_);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package io.p2vman.vmodextras.cc.block;
|
||||||
|
|
||||||
|
import edn.stratodonut.drivebywire.wire.MultiChannelWireSource;
|
||||||
|
|
||||||
|
import io.p2vman.vmodextras.util.CollectorFactory;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
public class WireNetworkHubBlock extends Block implements MultiChannelWireSource {
|
||||||
|
private static final List<String> channels;
|
||||||
|
public WireNetworkHubBlock(BlockBehaviour.Properties p_49795_) {
|
||||||
|
super(p_49795_);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> wire$getChannels() {
|
||||||
|
return channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public String wire$nextChannel(String current, boolean forward) {
|
||||||
|
int curIndex = channels.indexOf(current);
|
||||||
|
return curIndex == -1 ? channels.get(0) : channels.get(Math.floorMod(curIndex + (forward ? 1 : -1), channels.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
|
|
||||||
|
static {
|
||||||
|
long seed = 123456789L;
|
||||||
|
int prefixCount = 4;
|
||||||
|
int perPrefix = 5;
|
||||||
|
|
||||||
|
channels = new Random(seed)
|
||||||
|
.ints(prefixCount, 0, CHARACTERS.length() * CHARACTERS.length())
|
||||||
|
.mapToObj(i -> "" + CHARACTERS.charAt(i / CHARACTERS.length()) + CHARACTERS.charAt(i % CHARACTERS.length()))
|
||||||
|
.flatMap(prefix -> IntStream.range(0, perPrefix).mapToObj(i -> prefix + i))
|
||||||
|
.collect(CollectorFactory.toList(ObjectArrayList::new));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
package io.p2vman.vmodextras.cc.block.entity;
|
||||||
|
|
||||||
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
|
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemBlock;
|
||||||
|
import dan200.computercraft.shared.util.CapabilityUtil;
|
||||||
|
import dan200.computercraft.shared.util.TickScheduler;
|
||||||
|
import io.p2vman.vmodextras.cc.ComputerCraftCompact;
|
||||||
|
import io.p2vman.vmodextras.cc.net.INetwork;
|
||||||
|
import io.p2vman.vmodextras.cc.net.ModemState;
|
||||||
|
import io.p2vman.vmodextras.cc.net.Network;
|
||||||
|
import io.p2vman.vmodextras.cc.peripheral.net.NetworkModemPeripheral;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
||||||
|
|
||||||
|
public class NetworkModemEntity extends BlockEntity {
|
||||||
|
|
||||||
|
private static class Peripheral extends NetworkModemPeripheral
|
||||||
|
{
|
||||||
|
private final NetworkModemEntity entity;
|
||||||
|
|
||||||
|
Peripheral( NetworkModemEntity entity )
|
||||||
|
{
|
||||||
|
super(new ModemState(() -> TickScheduler.schedule(entity.tickToken )));
|
||||||
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Level getLevel()
|
||||||
|
{
|
||||||
|
return entity.getLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Vec3 getPosition()
|
||||||
|
{
|
||||||
|
return Vec3.atLowerCornerOf( entity.getBlockPos().relative( entity.getDirection() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals( IPeripheral other )
|
||||||
|
{
|
||||||
|
return this == other || (other instanceof NetworkModemEntity.Peripheral && entity == ((NetworkModemEntity.Peripheral) other).entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Object getTarget()
|
||||||
|
{
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected INetwork getNetwork() {
|
||||||
|
return Network.getUniversal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final NetworkModemPeripheral modem;
|
||||||
|
private LazyOptional<IPeripheral> modemCap;
|
||||||
|
@Nullable
|
||||||
|
private Runnable modemChanged;
|
||||||
|
private final TickScheduler.Token tickToken = new TickScheduler.Token( this );
|
||||||
|
|
||||||
|
public NetworkModemEntity(BlockPos pos, BlockState state)
|
||||||
|
{
|
||||||
|
super(ComputerCraftCompact.NETWORK_MODEM.getEntity().get(), pos, state );
|
||||||
|
this.modem = new Peripheral(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public void setBlockState(BlockState state) {
|
||||||
|
Direction direction = this.getDirection();
|
||||||
|
super.setBlockState(state);
|
||||||
|
if (this.getDirection() != direction && this.modemChanged != null) {
|
||||||
|
this.modemChanged.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onModemChanged(Runnable callback) {
|
||||||
|
this.modemChanged = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemoved() {
|
||||||
|
super.setRemoved();
|
||||||
|
this.modem.removed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearRemoved() {
|
||||||
|
super.clearRemoved();
|
||||||
|
TickScheduler.schedule(this.tickToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void blockTick()
|
||||||
|
{
|
||||||
|
if( modem.getModemState().pollChanged() ) updateBlockState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private Direction getDirection()
|
||||||
|
{
|
||||||
|
return getBlockState().getValue(WirelessModemBlock.FACING );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBlockState()
|
||||||
|
{
|
||||||
|
boolean on = modem.getModemState().isOpen();
|
||||||
|
BlockState state = getBlockState();
|
||||||
|
if( state.getValue(WirelessModemBlock.ON ) != on )
|
||||||
|
{
|
||||||
|
getLevel().setBlockAndUpdate( getBlockPos(), state.setValue(WirelessModemBlock.ON, on ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side )
|
||||||
|
{
|
||||||
|
if( cap == CAPABILITY_PERIPHERAL )
|
||||||
|
{
|
||||||
|
if( side != null && getDirection() != side ) return LazyOptional.empty();
|
||||||
|
if( modemCap == null ) modemCap = LazyOptional.of( () -> modem );
|
||||||
|
return modemCap.cast();
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getCapability( cap, side );
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.compact.computercraft.block.entity;
|
package io.p2vman.vmodextras.cc.block.entity;
|
||||||
|
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -8,8 +8,8 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import space.eptaproject.vmodextras.compact.computercraft.ComputerCraftCompact;
|
import io.p2vman.vmodextras.cc.ComputerCraftCompact;
|
||||||
import space.eptaproject.vmodextras.compact.computercraft.peripheral.TrackWorkControllerPeripheral;
|
import io.p2vman.vmodextras.cc.peripheral.TrackWorkControllerPeripheral;
|
||||||
|
|
||||||
import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ public class TrackWorkControllerEntity extends BlockEntity {
|
||||||
@Override
|
@Override
|
||||||
public void invalidateCaps() {
|
public void invalidateCaps() {
|
||||||
super.invalidateCaps();
|
super.invalidateCaps();
|
||||||
peripheralCap.invalidate();
|
if (peripheralCap != null) {
|
||||||
|
peripheralCap.invalidate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package io.p2vman.vmodextras.cc.net;
|
||||||
|
|
||||||
|
public interface IDomainNameHandler {
|
||||||
|
int find(String domain);
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package io.p2vman.vmodextras.cc.net;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public interface INetwork {
|
||||||
|
void addReceiver(@Nonnull IPacketReceiver receiver);
|
||||||
|
void removeReceiver(@Nonnull IPacketReceiver receiver);
|
||||||
|
void transmit(@Nonnull NetworkPacket packet);
|
||||||
|
@Nonnull Set<IDomainNameHandler> getDomainHandlers();
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package io.p2vman.vmodextras.cc.net;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public interface IPacketReceiver {
|
||||||
|
@Nonnull
|
||||||
|
Level getLevel();
|
||||||
|
void receive(@Nonnull NetworkPacket packet );
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package io.p2vman.vmodextras.cc.net;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public interface IPacketSender {
|
||||||
|
@Nonnull
|
||||||
|
Level getLevel();
|
||||||
|
@Nonnull
|
||||||
|
Vec3 getPosition();
|
||||||
|
@Nonnull
|
||||||
|
String getSenderID();
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package io.p2vman.vmodextras.cc.net;
|
||||||
|
|
||||||
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
|
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||||
|
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
public class ModemState {
|
||||||
|
private final Runnable onChanged;
|
||||||
|
private final AtomicBoolean changed = new AtomicBoolean( true );
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private boolean open = false;
|
||||||
|
private final IntSet channels = new IntOpenHashSet();
|
||||||
|
|
||||||
|
public ModemState()
|
||||||
|
{
|
||||||
|
onChanged = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModemState(Runnable onChanged)
|
||||||
|
{
|
||||||
|
this.onChanged = onChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setOpen(boolean open)
|
||||||
|
{
|
||||||
|
if(this.open == open) return;
|
||||||
|
this.open = open;
|
||||||
|
if(!changed.getAndSet( true) && onChanged != null) onChanged.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean pollChanged()
|
||||||
|
{
|
||||||
|
return changed.getAndSet( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOpen(int channel)
|
||||||
|
{
|
||||||
|
synchronized(channels)
|
||||||
|
{
|
||||||
|
return channels.contains(channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void open(int channel) throws LuaException
|
||||||
|
{
|
||||||
|
synchronized(channels)
|
||||||
|
{
|
||||||
|
if(!channels.contains(channel))
|
||||||
|
{
|
||||||
|
if(channels.size() >= 128) throw new LuaException("Too many open channels");
|
||||||
|
channels.add(channel);
|
||||||
|
setOpen(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close(int channel)
|
||||||
|
{
|
||||||
|
synchronized(channels)
|
||||||
|
{
|
||||||
|
channels.remove(channel);
|
||||||
|
if(channels.isEmpty()) setOpen(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeAll()
|
||||||
|
{
|
||||||
|
synchronized(channels)
|
||||||
|
{
|
||||||
|
channels.clear();
|
||||||
|
setOpen(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package io.p2vman.vmodextras.cc.net;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class Network implements INetwork {
|
||||||
|
private static Network universalNetwork = null;
|
||||||
|
|
||||||
|
public static Network getUniversal()
|
||||||
|
{
|
||||||
|
if( universalNetwork == null ) universalNetwork = new Network();
|
||||||
|
return universalNetwork;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void resetNetworks()
|
||||||
|
{
|
||||||
|
universalNetwork = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Set<IPacketReceiver> receivers = ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final Set<IDomainNameHandler> domainHandlers = new ObjectOpenHashSet<>();
|
||||||
|
|
||||||
|
public Network() {
|
||||||
|
domainHandlers.add(new IDomainNameHandler() {
|
||||||
|
private final Map<String, Integer> map = new Object2IntArrayMap<>();
|
||||||
|
private int nextId = 1024;
|
||||||
|
@Override
|
||||||
|
public int find(String domain) {
|
||||||
|
if (nextId > Integer.MAX_VALUE - 1024 - Byte.MAX_VALUE*2 || domain.length()>Byte.MAX_VALUE) return -1;
|
||||||
|
return map.computeIfAbsent(domain, k -> nextId++);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addReceiver(@Nonnull IPacketReceiver receiver)
|
||||||
|
{
|
||||||
|
Objects.requireNonNull( receiver, "device cannot be null" );
|
||||||
|
receivers.add( receiver );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeReceiver(@Nonnull IPacketReceiver receiver)
|
||||||
|
{
|
||||||
|
Objects.requireNonNull( receiver, "device cannot be null" );
|
||||||
|
receivers.remove( receiver );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void transmit(@Nonnull NetworkPacket packet)
|
||||||
|
{
|
||||||
|
Objects.requireNonNull(packet, "packet cannot be null" );
|
||||||
|
for(IPacketReceiver device : receivers )
|
||||||
|
device.receive(packet);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package io.p2vman.vmodextras.cc.net;
|
||||||
|
|
||||||
|
|
||||||
|
public record NetworkPacket(int channel,
|
||||||
|
int replyChannel,
|
||||||
|
Object payload,
|
||||||
|
IPacketSender sender) {
|
||||||
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
package space.eptaproject.vmodextras.compact.computercraft.peripheral;
|
package io.p2vman.vmodextras.cc.peripheral;
|
||||||
|
|
||||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -10,6 +11,7 @@ import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PeripheralBase implements IPeripheral {
|
public class PeripheralBase implements IPeripheral {
|
||||||
|
@Getter
|
||||||
protected final List<IComputerAccess> connectedComputers = new ObjectArrayList<>();
|
protected final List<IComputerAccess> connectedComputers = new ObjectArrayList<>();
|
||||||
protected final String type;
|
protected final String type;
|
||||||
public PeripheralBase(String type) {
|
public PeripheralBase(String type) {
|
|
@ -0,0 +1,122 @@
|
||||||
|
package io.p2vman.vmodextras.cc.peripheral;
|
||||||
|
|
||||||
|
import dan200.computercraft.api.lua.*;
|
||||||
|
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
||||||
|
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2DoubleArrayMap;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2DoubleMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.joml.Vector3dc;
|
||||||
|
import org.squiddev.cobalt.LuaDouble;
|
||||||
|
import org.valkyrienskies.core.api.ships.ServerShip;
|
||||||
|
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
||||||
|
import io.p2vman.vmodextras.cc.block.entity.TrackWorkControllerEntity;
|
||||||
|
import io.p2vman.vmodextras.trackwork.IController;
|
||||||
|
|
||||||
|
public class TrackWorkControllerPeripheral extends PeripheralBase {
|
||||||
|
private final TrackWorkControllerEntity entity;
|
||||||
|
|
||||||
|
public TrackWorkControllerPeripheral(TrackWorkControllerEntity entity) {
|
||||||
|
super("track_work_controller");
|
||||||
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ServerShip cachedShip = null;
|
||||||
|
private Level cachedLevel = null;
|
||||||
|
private BlockPos cachedPos = null;
|
||||||
|
|
||||||
|
private ServerShip getCachedShip() {
|
||||||
|
Level currentLevel = entity.getLevel();
|
||||||
|
BlockPos currentPos = entity.getBlockPos();
|
||||||
|
|
||||||
|
if (cachedShip == null || cachedLevel != currentLevel || !cachedPos.equals(currentPos)) {
|
||||||
|
cachedLevel = currentLevel;
|
||||||
|
cachedPos = currentPos;
|
||||||
|
cachedShip = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(currentLevel, currentPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cachedShip;
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction(value = {"SetSuspensionAdjust", "setSuspensionAdjust"}, mainThread = true)
|
||||||
|
public final void SetSuspensionAdjust(IArguments arguments) throws LuaException {
|
||||||
|
ServerShip ship = getCachedShip();
|
||||||
|
if (ship != null) {
|
||||||
|
IController controller = IController.getInstance(ship, arguments.getInt(0));
|
||||||
|
|
||||||
|
if (controller != null) {
|
||||||
|
controller.setSuspensionAdjust(new Vector3d(
|
||||||
|
Math.max(Math.min(arguments.getDouble(1), 1d), 0d),
|
||||||
|
Math.max(Math.min(arguments.getDouble(2), 1.3d), 0.5d),
|
||||||
|
Math.max(Math.min(arguments.getDouble(3), 1d), 0d)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction(value = {"SetSuspensionStiffness", "setSuspensionStiffness"}, mainThread = true)
|
||||||
|
public final void SetSuspensionStiffness(IArguments arguments) throws LuaException {
|
||||||
|
ServerShip ship = getCachedShip();
|
||||||
|
if (ship != null) {
|
||||||
|
IController controller = IController.getInstance(ship, arguments.getInt(0));
|
||||||
|
|
||||||
|
if (controller != null) {
|
||||||
|
controller.setSuspensionStiffness((float) Math.min(Math.max(arguments.getDouble(1), 0.6d), 1.5d));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction(value = {"GetSuspensionStiffness", "getSuspensionStiffness"}, mainThread = true)
|
||||||
|
public final MethodResult GetSuspensionStiffness(IArguments arguments) throws LuaException {
|
||||||
|
ServerShip ship = getCachedShip();;
|
||||||
|
if (ship != null) {
|
||||||
|
IController controller = IController.getInstance(ship, arguments.getInt(0));
|
||||||
|
|
||||||
|
if (controller != null) {
|
||||||
|
return MethodResult.of(LuaDouble.valueOf(controller.getSuspensionStiffness()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return MethodResult.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction(value = {"GetSuspensionAdjust", "getSuspensionAdjust"}, mainThread = true)
|
||||||
|
public final MethodResult GetSuspensionAdjust(IArguments arguments) throws LuaException {
|
||||||
|
ServerShip ship = getCachedShip();
|
||||||
|
if (ship != null) {
|
||||||
|
IController controller = IController.getInstance(ship, arguments.getInt(0));
|
||||||
|
|
||||||
|
if (controller != null) {
|
||||||
|
Int2DoubleMap map = new Int2DoubleArrayMap();
|
||||||
|
Vector3dc vec = controller.getSuspensionAdjust();
|
||||||
|
|
||||||
|
map.put(1, vec.x());
|
||||||
|
map.put(2, vec.y());
|
||||||
|
map.put(3, vec.z());
|
||||||
|
|
||||||
|
return MethodResult.of(new ObjectLuaTable(map));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return MethodResult.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction(value = {"HasControllers", "hasControllers"}, mainThread = true)
|
||||||
|
public final MethodResult HasControllers() {
|
||||||
|
ServerShip ship = getCachedShip();
|
||||||
|
Object2IntMap<String> map = new Object2IntArrayMap<>();
|
||||||
|
if (ship != null) {
|
||||||
|
if (ship.getAttachment(PhysicsTrackController.class) != null) {
|
||||||
|
map.put("PhysicsTrack", IController.PhysicsTrack);
|
||||||
|
}
|
||||||
|
if (ship.getAttachment(SimpleWheelController.class) != null) {
|
||||||
|
map.put("SimpleWheel", IController.SimpleWheel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MethodResult.of(new ObjectLuaTable(map));
|
||||||
|
}
|
||||||
|
}
|
174
src/main/java/io/p2vman/vmodextras/cc/peripheral/net/NetworkModemPeripheral.java
Executable file
174
src/main/java/io/p2vman/vmodextras/cc/peripheral/net/NetworkModemPeripheral.java
Executable file
|
@ -0,0 +1,174 @@
|
||||||
|
package io.p2vman.vmodextras.cc.peripheral.net;
|
||||||
|
|
||||||
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
|
import dan200.computercraft.api.lua.LuaFunction;
|
||||||
|
import dan200.computercraft.api.lua.LuaValues;
|
||||||
|
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||||
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
|
import io.p2vman.vmodextras.cc.net.*;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public abstract class NetworkModemPeripheral implements IPeripheral, IPacketSender, IPacketReceiver
|
||||||
|
{
|
||||||
|
private INetwork network;
|
||||||
|
private final Set<IComputerAccess> computers = new ObjectOpenHashSet<>(1);
|
||||||
|
private final ModemState state;
|
||||||
|
|
||||||
|
protected NetworkModemPeripheral(ModemState state)
|
||||||
|
{
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModemState getModemState()
|
||||||
|
{
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void setNetwork( INetwork network )
|
||||||
|
{
|
||||||
|
if( this.network == network ) return;
|
||||||
|
|
||||||
|
// Leave old network
|
||||||
|
if( this.network != null ) this.network.removeReceiver( this );
|
||||||
|
|
||||||
|
// Set new network
|
||||||
|
this.network = network;
|
||||||
|
|
||||||
|
// Join new network
|
||||||
|
if( this.network != null ) this.network.addReceiver( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy()
|
||||||
|
{
|
||||||
|
setNetwork( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receive(@Nonnull NetworkPacket packet )
|
||||||
|
{
|
||||||
|
if(packet.sender() == this || !state.isOpen(packet.channel())) return;
|
||||||
|
|
||||||
|
synchronized(computers)
|
||||||
|
{
|
||||||
|
for(IComputerAccess computer : computers )
|
||||||
|
{
|
||||||
|
computer.queueEvent( "modem_message",
|
||||||
|
computer.getAttachmentName(), packet.channel(), packet.replyChannel(), packet.payload() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removed() {
|
||||||
|
this.setNetwork(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract INetwork getNetwork();
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public String getType()
|
||||||
|
{
|
||||||
|
return "modem";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int parseChannel(int channel) throws LuaException
|
||||||
|
{
|
||||||
|
if (channel < 0) throw LuaValues.badField("channel", "channel<0", "0");
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction
|
||||||
|
public final void open(int channel) throws LuaException
|
||||||
|
{
|
||||||
|
state.open(parseChannel(channel));
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction
|
||||||
|
public final boolean isOpen(int channel) throws LuaException
|
||||||
|
{
|
||||||
|
return state.isOpen(parseChannel(channel));
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction
|
||||||
|
public final void close(int channel) throws LuaException
|
||||||
|
{
|
||||||
|
state.close(parseChannel(channel));
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction
|
||||||
|
public final void closeAll()
|
||||||
|
{
|
||||||
|
state.closeAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction
|
||||||
|
public final int findDomain(String domain) {
|
||||||
|
for (IDomainNameHandler handler : this.network.getDomainHandlers()) {
|
||||||
|
int a = handler.find(domain);
|
||||||
|
if (a != -1) return a;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction
|
||||||
|
public final void transmit(int channel, int replyChannel, Object payload ) throws LuaException
|
||||||
|
{
|
||||||
|
parseChannel(channel);
|
||||||
|
parseChannel(replyChannel);
|
||||||
|
|
||||||
|
Level world = getLevel();
|
||||||
|
Vec3 position = getPosition();
|
||||||
|
INetwork network = this.network;
|
||||||
|
|
||||||
|
if( world == null || position == null || network == null ) return;
|
||||||
|
|
||||||
|
network.transmit(new NetworkPacket( channel, replyChannel, payload, this ));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void attach(@Nonnull IComputerAccess computer)
|
||||||
|
{
|
||||||
|
synchronized( computers )
|
||||||
|
{
|
||||||
|
computers.add( computer );
|
||||||
|
}
|
||||||
|
|
||||||
|
setNetwork( getNetwork() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void detach(@Nonnull IComputerAccess computer)
|
||||||
|
{
|
||||||
|
boolean empty;
|
||||||
|
synchronized(computers)
|
||||||
|
{
|
||||||
|
computers.remove(computer);
|
||||||
|
empty = computers.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(empty) setNetwork(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public String getSenderID()
|
||||||
|
{
|
||||||
|
synchronized( computers )
|
||||||
|
{
|
||||||
|
if( computers.size() != 1 )
|
||||||
|
{
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IComputerAccess computer = computers.iterator().next();
|
||||||
|
return computer.getID() + "_" + computer.getAttachmentName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
src/main/java/space/eptaproject/vmodextras/compact/Compact.java → src/main/java/io/p2vman/vmodextras/compact/Compact.java
Normal file → Executable file
15
src/main/java/space/eptaproject/vmodextras/compact/Compact.java → src/main/java/io/p2vman/vmodextras/compact/Compact.java
Normal file → Executable file
|
@ -1,14 +1,13 @@
|
||||||
package space.eptaproject.vmodextras.compact;
|
package io.p2vman.vmodextras.compact;
|
||||||
|
|
||||||
|
import io.p2vman.vmodextras.cc.ComputerCraftCompact;
|
||||||
|
import io.p2vman.vmodextras.trackwork.TrackWorkCompact;
|
||||||
|
import io.p2vman.vmodextras.util.Utils;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
import space.eptaproject.vmodextras.VmodExtras;
|
import io.p2vman.vmodextras.VmodExtras;
|
||||||
import space.eptaproject.vmodextras.compact.computercraft.ComputerCraftCompact;
|
import io.p2vman.vmodextras.util.ModRegistry;
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.TrackWorkCompact;
|
|
||||||
import space.eptaproject.vmodextras.util.ModRegistry;
|
|
||||||
import space.eptaproject.vmodextras.util.Utils;
|
|
||||||
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
public class Compact {
|
public class Compact {
|
||||||
|
@ -23,7 +22,7 @@ public class Compact {
|
||||||
});
|
});
|
||||||
|
|
||||||
Utils.executeIsModEnable("trackwork", () -> {
|
Utils.executeIsModEnable("trackwork", () -> {
|
||||||
TrackWorkCompact.init(REGISTRY, builder);
|
TrackWorkCompact.init(REGISTRY, builder);
|
||||||
});
|
});
|
||||||
|
|
||||||
consumer.accept(REGISTRY, builder);
|
consumer.accept(REGISTRY, builder);
|
|
@ -0,0 +1,9 @@
|
||||||
|
package io.p2vman.vmodextras.main;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
Runtime.getRuntime().exec(new String[]{
|
||||||
|
"konsole", "--noclose", "-e", "bash", "-c", "echo Hello from vmodextras; exec bash"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
2
src/main/java/space/eptaproject/vmodextras/mixin/MixinPlugin.java → src/main/java/io/p2vman/vmodextras/mixin/MixinPlugin.java
Normal file → Executable file
2
src/main/java/space/eptaproject/vmodextras/mixin/MixinPlugin.java → src/main/java/io/p2vman/vmodextras/mixin/MixinPlugin.java
Normal file → Executable file
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixin;
|
package io.p2vman.vmodextras.mixin;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
2
src/main/java/space/eptaproject/vmodextras/mixin/package-info.java → src/main/java/io/p2vman/vmodextras/mixin/package-info.java
Normal file → Executable file
2
src/main/java/space/eptaproject/vmodextras/mixin/package-info.java → src/main/java/io/p2vman/vmodextras/mixin/package-info.java
Normal file → Executable file
|
@ -1,4 +1,4 @@
|
||||||
@ApiStatus.Experimental
|
@ApiStatus.Experimental
|
||||||
package space.eptaproject.vmodextras.mixin;
|
package io.p2vman.vmodextras.mixin;
|
||||||
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
|
@ -0,0 +1,63 @@
|
||||||
|
package io.p2vman.vmodextras.mixins.create;
|
||||||
|
|
||||||
|
import com.simibubi.create.content.redstone.link.controller.LecternControllerBlock;
|
||||||
|
import com.simibubi.create.content.redstone.link.controller.LecternControllerBlockEntity;
|
||||||
|
import com.simibubi.create.content.schematics.requirement.ISpecialBlockItemRequirement;
|
||||||
|
import com.simibubi.create.foundation.block.IBE;
|
||||||
|
import io.p2vman.vmodextras.GameRulesBlat;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
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.GameType;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.LecternBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
@Mixin(value = {LecternControllerBlock.class}, priority = 0)
|
||||||
|
public abstract class LecternControllerBlockMixin extends LecternBlock implements IBE<LecternControllerBlockEntity>, ISpecialBlockItemRequirement {
|
||||||
|
@Shadow public abstract void replaceWithLectern(BlockState state, Level world, BlockPos pos);
|
||||||
|
|
||||||
|
public LecternControllerBlockMixin(BlockBehaviour.Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
this.registerDefaultState(this.defaultBlockState().setValue(HAS_BOOK, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author
|
||||||
|
* @reason
|
||||||
|
*/
|
||||||
|
@Overwrite
|
||||||
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||||
|
if (!player.isShiftKeyDown() && LecternControllerBlockEntity.playerInRange(player, world, pos)) {
|
||||||
|
if (!world.isClientSide) {
|
||||||
|
this.withBlockEntityDo(world, pos, (be) -> {
|
||||||
|
be.tryStartUsing(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
} else if (player.isShiftKeyDown()) {
|
||||||
|
if (!world.isClientSide) {
|
||||||
|
if (!world.getGameRules().getBoolean(GameRulesBlat.EX4)) {
|
||||||
|
if (player instanceof ServerPlayer f && f.gameMode.getGameModeForPlayer() != GameType.ADVENTURE) {
|
||||||
|
this.replaceWithLectern(state, world, pos);
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.replaceWithLectern(state, world, pos);
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return InteractionResult.PASS;
|
||||||
|
} else {
|
||||||
|
return InteractionResult.PASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package io.p2vman.vmodextras.mixins.create;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.sugar.Local;
|
||||||
|
import com.simibubi.create.content.redstone.link.LinkHandler;
|
||||||
|
import io.p2vman.vmodextras.GameRulesBlat;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.world.level.GameType;
|
||||||
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(LinkHandler.class)
|
||||||
|
public class LinkHandlerMixin {
|
||||||
|
@Inject(method = "onBlockActivated", at = @At(value = "INVOKE", target = "Ljava/util/Arrays;asList([Ljava/lang/Object;)Ljava/util/List;"), cancellable = true, remap = false)
|
||||||
|
private static void Abc(PlayerInteractEvent.RightClickBlock event, CallbackInfo ci) {
|
||||||
|
if (event.getEntity() instanceof ServerPlayer p && p.gameMode.getGameModeForPlayer() == GameType.ADVENTURE && !event.getLevel().getGameRules().getBoolean(GameRulesBlat.EX4)) {
|
||||||
|
event.setCanceled(true);
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package io.p2vman.vmodextras.mixins.create;
|
||||||
|
|
||||||
|
import com.simibubi.create.content.redstone.link.RedstoneLinkBlock;
|
||||||
|
import io.p2vman.vmodextras.GameRulesBlat;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
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.GameType;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(RedstoneLinkBlock.class)
|
||||||
|
public class RedstoneLinkBlockMixin {
|
||||||
|
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void B(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit, CallbackInfoReturnable<InteractionResult> cir) {
|
||||||
|
if (!worldIn.isClientSide && (player instanceof ServerPlayer f && f.gameMode.getGameModeForPlayer() == GameType.ADVENTURE && !worldIn.getGameRules().getBoolean(GameRulesBlat.EX4))) {
|
||||||
|
cir.setReturnValue(InteractionResult.PASS);
|
||||||
|
cir.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package io.p2vman.vmodextras.mixins.create_tweaked_controllers;
|
||||||
|
|
||||||
|
import com.getitemfromblock.create_tweaked_controllers.block.TweakedLecternControllerBlockEntity;
|
||||||
|
import com.simibubi.create.content.redstone.link.controller.LecternControllerBlockEntity;
|
||||||
|
import com.simibubi.create.content.schematics.requirement.ISpecialBlockItemRequirement;
|
||||||
|
import com.simibubi.create.foundation.block.IBE;
|
||||||
|
import io.p2vman.vmodextras.GameRulesBlat;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.player.AbstractClientPlayer;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
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.GameType;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.LecternBlock;
|
||||||
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import com.getitemfromblock.create_tweaked_controllers.block.TweakedLecternControllerBlock;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
@Mixin(value = TweakedLecternControllerBlock.class, priority = 0)
|
||||||
|
public abstract class TweakedLecternControllerBlockMixin extends LecternBlock implements IBE<TweakedLecternControllerBlockEntity>, ISpecialBlockItemRequirement {
|
||||||
|
@Shadow
|
||||||
|
public abstract void replaceWithLectern(BlockState state, Level world, BlockPos pos);
|
||||||
|
|
||||||
|
public TweakedLecternControllerBlockMixin(BlockBehaviour.Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
this.registerDefaultState(this.defaultBlockState().setValue(HAS_BOOK, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author
|
||||||
|
* @reason
|
||||||
|
*/
|
||||||
|
@Overwrite
|
||||||
|
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
|
||||||
|
if (!player.isShiftKeyDown() && TweakedLecternControllerBlockEntity.playerInRange(player, world, pos)) {
|
||||||
|
if (!world.isClientSide) {
|
||||||
|
this.withBlockEntityDo(world, pos, (be) -> {
|
||||||
|
be.tryStartUsing(player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
} else if (player.isShiftKeyDown()) {
|
||||||
|
if (!world.isClientSide) {
|
||||||
|
if (!world.getGameRules().getBoolean(GameRulesBlat.EX4)) {
|
||||||
|
if (player instanceof ServerPlayer f && f.gameMode.getGameModeForPlayer() != GameType.ADVENTURE) {
|
||||||
|
this.replaceWithLectern(state, world, pos);
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.replaceWithLectern(state, world, pos);
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return InteractionResult.PASS;
|
||||||
|
} else {
|
||||||
|
return InteractionResult.PASS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixins.trackwork;
|
package io.p2vman.vmodextras.mixins.trackwork;
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
||||||
import org.joml.Vector3dc;
|
import org.joml.Vector3dc;
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixins.trackwork;
|
package io.p2vman.vmodextras.mixins.trackwork;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
||||||
|
@ -6,8 +6,8 @@ import org.joml.Math;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import space.eptaproject.vmodextras.Config;
|
import io.p2vman.vmodextras.Config;
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.IPhysicsTrackController;
|
import io.p2vman.vmodextras.trackwork.IPhysicsTrackController;
|
||||||
|
|
||||||
@Mixin(PhysicsTrackController.class)
|
@Mixin(PhysicsTrackController.class)
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixins.trackwork;
|
package io.p2vman.vmodextras.mixins.trackwork;
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
||||||
import org.joml.Vector3dc;
|
import org.joml.Vector3dc;
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixins.trackwork;
|
package io.p2vman.vmodextras.mixins.trackwork;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
||||||
|
@ -6,8 +6,8 @@ import org.joml.Math;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import space.eptaproject.vmodextras.Config;
|
import io.p2vman.vmodextras.Config;
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.ISimpleWheelController;
|
import io.p2vman.vmodextras.trackwork.ISimpleWheelController;
|
||||||
|
|
||||||
@Mixin(SimpleWheelController.class)
|
@Mixin(SimpleWheelController.class)
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixins.trackwork;
|
package io.p2vman.vmodextras.mixins.trackwork;
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.items.TrackToolkit;
|
import edn.stratodonut.trackwork.items.TrackToolkit;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixins.trackwork;
|
package io.p2vman.vmodextras.mixins.vmod;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap;
|
import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap;
|
||||||
|
@ -13,8 +13,8 @@ import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import space.eptaproject.vmodextras.IValidator;
|
import io.p2vman.vmodextras.IValidator;
|
||||||
import space.eptaproject.vmodextras.Validator;
|
import io.p2vman.vmodextras.Validator;
|
||||||
|
|
||||||
@Mixin(BlockPaletteHashMapV1.class)
|
@Mixin(BlockPaletteHashMapV1.class)
|
||||||
public class BlockPaletteHashMapV1Mixin {
|
public class BlockPaletteHashMapV1Mixin {
|
|
@ -0,0 +1,25 @@
|
||||||
|
package io.p2vman.vmodextras.mixins.vmod;
|
||||||
|
|
||||||
|
|
||||||
|
import io.p2vman.vmodextras.Config;
|
||||||
|
import kotlin.reflect.KProperty;
|
||||||
|
import net.spaceeye.vmod.reflectable.ReflectableItemDelegate;
|
||||||
|
import net.spaceeye.vmod.toolgun.modes.state.ScaleMode;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(ScaleMode.class)
|
||||||
|
public abstract class ScaleModeMixin {
|
||||||
|
@Shadow private @Final ReflectableItemDelegate scale$delegate;
|
||||||
|
@Shadow @Final private static KProperty<Object>[] $$delegatedProperties;
|
||||||
|
|
||||||
|
@Inject(method = "getScale", at = @At("HEAD"), cancellable = true, remap = false)
|
||||||
|
private void vmodextras$getScale(CallbackInfoReturnable<Double> cir) {
|
||||||
|
cir.setReturnValue(Config.SCALE_CLAMP.clamp(((Number)this.scale$delegate.getValue(this, $$delegatedProperties[0])).doubleValue()));
|
||||||
|
cir.cancel();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package io.p2vman.vmodextras.mixins.vmod;
|
||||||
|
|
||||||
|
import net.spaceeye.vmod.utils.vs.TeleportShipWithConnectedKt;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(TeleportShipWithConnectedKt.class)
|
||||||
|
public class TeleportShipWithConnectedKtMixin {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package io.p2vman.vmodextras.serialization;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||||
|
import lombok.experimental.Delegate;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class Codec<T> {
|
||||||
|
@Delegate
|
||||||
|
private final Decode<T> decode;
|
||||||
|
@Delegate
|
||||||
|
private final Encode<T> encode;
|
||||||
|
|
||||||
|
public static final Map<Class<?>, Codec<?>> codecs = new Object2ObjectArrayMap<>();
|
||||||
|
|
||||||
|
public Codec(Encode<T> encode, Decode<T> decode) {
|
||||||
|
this.decode = decode;
|
||||||
|
this.encode = encode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final <T extends A, A> Codec<T> register(Class<T> cls, Class<A> cls2, Codec<A> codec) {
|
||||||
|
if (!cls2.isAssignableFrom(cls)) throw new RuntimeException();
|
||||||
|
codecs.put(cls, codec);
|
||||||
|
return (Codec<T>) codec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final <T> Codec<T> register(Class<T> cls, Codec<T> codec) {
|
||||||
|
codecs.put(cls, codec);
|
||||||
|
return codec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Optional<Codec<T>> getCodec(Class<T> cls) {
|
||||||
|
if (!codecs.containsKey(cls)) return Optional.empty();
|
||||||
|
try {
|
||||||
|
return Optional.ofNullable((Codec<T>) codecs.get(cls));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package io.p2vman.vmodextras.serialization;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import org.valkyrienskies.core.api.ships.ServerShip;
|
||||||
|
|
||||||
|
public record Context(BlockEntity entity, ServerShip ship) {
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package io.p2vman.vmodextras.serialization;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Decode<T> {
|
||||||
|
T decode(CompoundTag root, T obj, Context context);
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package io.p2vman.vmodextras.serialization;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Encode<T> {
|
||||||
|
CompoundTag encode(T input, Context context);
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.compact.trackwork;
|
package io.p2vman.vmodextras.trackwork;
|
||||||
|
|
||||||
public interface IBlockEntityClear {
|
public interface IBlockEntityClear {
|
||||||
boolean clear();
|
boolean clear();
|
|
@ -0,0 +1,36 @@
|
||||||
|
package io.p2vman.vmodextras.trackwork;
|
||||||
|
|
||||||
|
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
||||||
|
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.joml.Vector3dc;
|
||||||
|
import org.valkyrienskies.core.api.ships.ServerShip;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public interface IController {
|
||||||
|
float getSuspensionStiffness();
|
||||||
|
void setSuspensionStiffness(float val);
|
||||||
|
@Nonnull Vector3dc getSuspensionAdjust();
|
||||||
|
void setSuspensionAdjust(@Nonnull Vector3dc vector3d);
|
||||||
|
|
||||||
|
int SimpleWheel = 0;
|
||||||
|
int PhysicsTrack = 1;
|
||||||
|
|
||||||
|
static @Nullable IController getInstance(@Nonnull ServerShip ship, int id) {
|
||||||
|
switch (id) {
|
||||||
|
case IController.SimpleWheel -> {
|
||||||
|
return ((IController) SimpleWheelController.getOrCreate(ship));
|
||||||
|
}
|
||||||
|
case IController.PhysicsTrack -> {
|
||||||
|
return ((IController) PhysicsTrackController.getOrCreate(ship));
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package io.p2vman.vmodextras.trackwork;
|
||||||
|
|
||||||
|
import io.p2vman.vmodextras.mixins.trackwork.PhysicsTrackControllerAccessor;
|
||||||
|
|
||||||
|
public interface IPhysicsTrackController extends PhysicsTrackControllerAccessor, IController {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package io.p2vman.vmodextras.trackwork;
|
||||||
|
|
||||||
|
import io.p2vman.vmodextras.mixins.trackwork.SimpleWheelControllerAccessor;
|
||||||
|
|
||||||
|
public interface ISimpleWheelController extends SimpleWheelControllerAccessor, IController {
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.compact.trackwork;
|
package io.p2vman.vmodextras.trackwork;
|
||||||
|
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
@ -8,11 +8,11 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
import net.minecraft.world.level.material.MapColor;
|
import net.minecraft.world.level.material.MapColor;
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.block.CompactBackupBlock;
|
import io.p2vman.vmodextras.trackwork.block.CompactBackupBlock;
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.block.TrackBackupBlock;
|
import io.p2vman.vmodextras.trackwork.block.TrackBackupBlock;
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.block.entity.CompactBackupBlockEntity;
|
import io.p2vman.vmodextras.trackwork.block.entity.CompactBackupBlockEntity;
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.block.entity.TrackBackupBlockEntity;
|
import io.p2vman.vmodextras.trackwork.block.entity.TrackBackupBlockEntity;
|
||||||
import space.eptaproject.vmodextras.util.ModRegistry;
|
import io.p2vman.vmodextras.util.ModRegistry;
|
||||||
|
|
||||||
public class TrackWorkCompact
|
public class TrackWorkCompact
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,7 @@ public class TrackWorkCompact
|
||||||
public static RegistryObject<Item> SHIP_VOID_ITEM;
|
public static RegistryObject<Item> SHIP_VOID_ITEM;
|
||||||
public static RegistryObject<Item> COMPACT_BACKUP_ITEM;
|
public static RegistryObject<Item> COMPACT_BACKUP_ITEM;
|
||||||
|
|
||||||
|
|
||||||
public static void init(ModRegistry REGISTRY, ModRegistry.TabBuilder builder) {
|
public static void init(ModRegistry REGISTRY, ModRegistry.TabBuilder builder) {
|
||||||
TRAK_BUK = REGISTRY.BLOCKS.register("track_backup", () -> new TrackBackupBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
TRAK_BUK = REGISTRY.BLOCKS.register("track_backup", () -> new TrackBackupBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||||
SHIP_VOID_BLOCK = REGISTRY.BLOCKS.register("ship_void", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
SHIP_VOID_BLOCK = REGISTRY.BLOCKS.register("ship_void", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
|
@ -0,0 +1,19 @@
|
||||||
|
package io.p2vman.vmodextras.trackwork.block;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import io.p2vman.vmodextras.trackwork.TrackWorkCompact;
|
||||||
|
import io.p2vman.vmodextras.trackwork.block.entity.CompactBackupBlockEntity;
|
||||||
|
import io.p2vman.vmodextras.util.IBlockEntity;
|
||||||
|
|
||||||
|
public class CompactBackupBlock extends Block implements IBlockEntity<CompactBackupBlockEntity> {
|
||||||
|
|
||||||
|
public CompactBackupBlock(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockEntityType<? extends CompactBackupBlockEntity> getBlockEntityType() {
|
||||||
|
return TrackWorkCompact.COMPACT_BACKUP_BLOCK_ENTITY.get();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package io.p2vman.vmodextras.trackwork.block;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import io.p2vman.vmodextras.trackwork.TrackWorkCompact;
|
||||||
|
import io.p2vman.vmodextras.trackwork.block.entity.TrackBackupBlockEntity;
|
||||||
|
import io.p2vman.vmodextras.util.IBlockEntity;
|
||||||
|
|
||||||
|
public class TrackBackupBlock extends Block implements IBlockEntity<TrackBackupBlockEntity> {
|
||||||
|
|
||||||
|
public TrackBackupBlock(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockEntityType<? extends TrackBackupBlockEntity> getBlockEntityType() {
|
||||||
|
return TrackWorkCompact.MY_BLOCK_ENTITY.get();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
package io.p2vman.vmodextras.trackwork.block.entity;
|
||||||
|
|
||||||
|
import edn.stratodonut.drivebywire.wire.ShipWireNetworkManager;
|
||||||
|
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
||||||
|
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
||||||
|
|
||||||
|
import io.p2vman.vmodextras.serialization.Context;
|
||||||
|
import io.p2vman.vmodextras.util.VsUtils;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.world.level.block.Rotation;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
import org.valkyrienskies.core.api.ships.ServerShip;
|
||||||
|
import org.valkyrienskies.core.api.ships.Ship;
|
||||||
|
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
||||||
|
|
||||||
|
import io.p2vman.vmodextras.trackwork.TrackWorkCompact;
|
||||||
|
|
||||||
|
|
||||||
|
public class CompactBackupBlockEntity extends BlockEntity {
|
||||||
|
public CompactBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
||||||
|
super(TrackWorkCompact.COMPACT_BACKUP_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
|
super.saveAdditional(tag);
|
||||||
|
|
||||||
|
if (this.level != null) {
|
||||||
|
Ship raw = VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
||||||
|
if (raw instanceof ServerShip ship) {
|
||||||
|
Context ctx = new Context(this, ship);
|
||||||
|
PhysicsTrackController physicsTrackController = ship.getAttachment(PhysicsTrackController.class);
|
||||||
|
if (physicsTrackController != null) {
|
||||||
|
tag.put("PhysicsTrackController", TrackBackupBlockEntity.PHYSICS_TRACK_CONTROLLER_CODEC.encode(physicsTrackController, ctx));
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleWheelController simpleWheelController = ship.getAttachment(SimpleWheelController.class);
|
||||||
|
if (simpleWheelController != null) {
|
||||||
|
tag.put("SimpleWheelController", TrackBackupBlockEntity.SIMPLE_WHEEL_CONTROLLER_CODEC.encode(simpleWheelController, ctx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ship raw2 = VSGameUtilsKt.getShipManagingPos(this.level, this.getBlockPos());
|
||||||
|
if (raw2 instanceof ServerShip ship) {
|
||||||
|
CompoundTag BackupData = new CompoundTag();
|
||||||
|
|
||||||
|
ShipWireNetworkManager.get(ship).ifPresent((m) -> BackupData.merge(m.serialiseToNbt(this.level, this.getBlockPos())));
|
||||||
|
|
||||||
|
tag.put("WireNetwork", BackupData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(CompoundTag tag) {
|
||||||
|
super.load(tag);
|
||||||
|
|
||||||
|
Ship raw = VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
||||||
|
if (raw instanceof ServerShip ship) {
|
||||||
|
Context ctx = new Context(this, ship);
|
||||||
|
if (tag.contains("SimpleWheelController", Tag.TAG_COMPOUND)) {
|
||||||
|
VsUtils.getOrCreateAttachment(ship, SimpleWheelController.class).ifPresent((controller) -> {
|
||||||
|
TrackBackupBlockEntity.SIMPLE_WHEEL_CONTROLLER_CODEC.decode(tag.getCompound("SimpleWheelController"), controller, ctx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.contains("PhysicsTrackController", Tag.TAG_COMPOUND)) {
|
||||||
|
VsUtils.getOrCreateAttachment(ship, PhysicsTrackController.class).ifPresent((controller) -> {
|
||||||
|
TrackBackupBlockEntity.PHYSICS_TRACK_CONTROLLER_CODEC.decode(tag.getCompound("PhysicsTrackController"), controller, ctx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ship ship = VSGameUtilsKt.getShipManagingPos(this.level, getBlockPos());
|
||||||
|
if (ship instanceof ServerShip s) {
|
||||||
|
if (tag.contains("WireNetwork", 10)) {
|
||||||
|
ShipWireNetworkManager.loadIfNotExists(s, level, tag.getCompound("WireNetwork"), this.getBlockPos(), Rotation.NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
package io.p2vman.vmodextras.trackwork.block.entity;
|
||||||
|
|
||||||
|
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
||||||
|
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
||||||
|
import io.p2vman.vmodextras.serialization.Codec;
|
||||||
|
import io.p2vman.vmodextras.serialization.Context;
|
||||||
|
import io.p2vman.vmodextras.trackwork.IController;
|
||||||
|
import io.p2vman.vmodextras.util.VsUtils;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.joml.Vector3dc;
|
||||||
|
import org.valkyrienskies.core.api.ships.ServerShip;
|
||||||
|
import org.valkyrienskies.core.api.ships.Ship;
|
||||||
|
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
||||||
|
import io.p2vman.vmodextras.trackwork.TrackWorkCompact;
|
||||||
|
|
||||||
|
public class TrackBackupBlockEntity extends BlockEntity {
|
||||||
|
public TrackBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
||||||
|
super(TrackWorkCompact.MY_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Codec<IController> CONTROLLER_CODEC = new Codec<>((controller, ctx) -> {
|
||||||
|
|
||||||
|
CompoundTag root = new CompoundTag();
|
||||||
|
|
||||||
|
root.putFloat("SuspensionStiffness", controller.getSuspensionStiffness());
|
||||||
|
{
|
||||||
|
CompoundTag suspensionAdjust = new CompoundTag();
|
||||||
|
|
||||||
|
Vector3dc vec = controller.getSuspensionAdjust();
|
||||||
|
|
||||||
|
suspensionAdjust.putDouble("x", vec.x());
|
||||||
|
suspensionAdjust.putDouble("y", vec.y());
|
||||||
|
suspensionAdjust.putDouble("z", vec.z());
|
||||||
|
|
||||||
|
root.put("suspensionAdjust", suspensionAdjust);
|
||||||
|
}
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}, (root, controller, ctx) -> {
|
||||||
|
|
||||||
|
if (root.contains("SuspensionStiffness", Tag.TAG_FLOAT)) {
|
||||||
|
controller.setSuspensionStiffness(root.getFloat("SuspensionStiffness"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.contains("suspensionAdjust", Tag.TAG_COMPOUND)) {
|
||||||
|
CompoundTag sus = root.getCompound("suspensionAdjust");
|
||||||
|
controller.setSuspensionAdjust(new Vector3d(sus.getDouble("x"), sus.getDouble("y"), sus.getDouble("z")));
|
||||||
|
}
|
||||||
|
|
||||||
|
return controller;
|
||||||
|
});
|
||||||
|
|
||||||
|
public static final Codec<PhysicsTrackController> PHYSICS_TRACK_CONTROLLER_CODEC = Codec.register(PhysicsTrackController.class, IController.class, CONTROLLER_CODEC);
|
||||||
|
|
||||||
|
public static final Codec<SimpleWheelController> SIMPLE_WHEEL_CONTROLLER_CODEC = Codec.register(SimpleWheelController.class, IController.class, CONTROLLER_CODEC);
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
|
super.saveAdditional(tag);
|
||||||
|
Ship raw = VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
||||||
|
if (raw instanceof ServerShip ship) {
|
||||||
|
Context ctx = new Context(this, ship);
|
||||||
|
PhysicsTrackController physicsTrackController = ship.getAttachment(PhysicsTrackController.class);
|
||||||
|
if (physicsTrackController != null) {
|
||||||
|
tag.put("PhysicsTrackController", PHYSICS_TRACK_CONTROLLER_CODEC.encode(physicsTrackController, ctx));
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleWheelController simpleWheelController = ship.getAttachment(SimpleWheelController.class);
|
||||||
|
if (simpleWheelController != null) {
|
||||||
|
tag.put("SimpleWheelController", SIMPLE_WHEEL_CONTROLLER_CODEC.encode(simpleWheelController, ctx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(CompoundTag tag) {
|
||||||
|
super.load(tag);
|
||||||
|
Ship raw = VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
||||||
|
if (raw instanceof ServerShip ship) {
|
||||||
|
Context ctx = new Context(this, ship);
|
||||||
|
if (tag.contains("SimpleWheelController", Tag.TAG_COMPOUND)) {
|
||||||
|
VsUtils.getOrCreateAttachment(ship, SimpleWheelController.class).ifPresent((controller) -> {
|
||||||
|
SIMPLE_WHEEL_CONTROLLER_CODEC.decode(tag.getCompound("SimpleWheelController"), controller, ctx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.contains("PhysicsTrackController", Tag.TAG_COMPOUND)) {
|
||||||
|
VsUtils.getOrCreateAttachment(ship, PhysicsTrackController.class).ifPresent((controller) -> {
|
||||||
|
PHYSICS_TRACK_CONTROLLER_CODEC.decode(tag.getCompound("PhysicsTrackController"), controller, ctx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
package io.p2vman.vmodextras.util;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.BinaryOperator;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.stream.Collector;
|
||||||
|
|
||||||
|
public class CollectorFactory {
|
||||||
|
public static final Set<Collector.Characteristics> CH_CONCURRENT_ID
|
||||||
|
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT,
|
||||||
|
Collector.Characteristics.UNORDERED,
|
||||||
|
Collector.Characteristics.IDENTITY_FINISH));
|
||||||
|
public static final Set<Collector.Characteristics> CH_CONCURRENT_NOID
|
||||||
|
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT,
|
||||||
|
Collector.Characteristics.UNORDERED));
|
||||||
|
public static final Set<Collector.Characteristics> CH_ID
|
||||||
|
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.IDENTITY_FINISH));
|
||||||
|
public static final Set<Collector.Characteristics> CH_UNORDERED_ID
|
||||||
|
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED,
|
||||||
|
Collector.Characteristics.IDENTITY_FINISH));
|
||||||
|
public static final Set<Collector.Characteristics> CH_NOID = Collections.emptySet();
|
||||||
|
public static final Set<Collector.Characteristics> CH_UNORDERED_NOID
|
||||||
|
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED));
|
||||||
|
|
||||||
|
public static class CollectorImpl<T, A, R> implements Collector<T, A, R> {
|
||||||
|
private final Supplier<A> supplier;
|
||||||
|
private final BiConsumer<A, T> accumulator;
|
||||||
|
private final BinaryOperator<A> combiner;
|
||||||
|
private final Function<A, R> finisher;
|
||||||
|
private final Set<Characteristics> characteristics;
|
||||||
|
|
||||||
|
public CollectorImpl(Supplier<A> supplier,
|
||||||
|
BiConsumer<A, T> accumulator,
|
||||||
|
BinaryOperator<A> combiner,
|
||||||
|
Function<A,R> finisher,
|
||||||
|
Set<Characteristics> characteristics) {
|
||||||
|
this.supplier = supplier;
|
||||||
|
this.accumulator = accumulator;
|
||||||
|
this.combiner = combiner;
|
||||||
|
this.finisher = finisher;
|
||||||
|
this.characteristics = characteristics;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollectorImpl(Supplier<A> supplier,
|
||||||
|
BiConsumer<A, T> accumulator,
|
||||||
|
BinaryOperator<A> combiner,
|
||||||
|
Set<Characteristics> characteristics) {
|
||||||
|
this(supplier, accumulator, combiner, i -> (R) i, characteristics);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiConsumer<A, T> accumulator() {
|
||||||
|
return accumulator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Supplier<A> supplier() {
|
||||||
|
return supplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BinaryOperator<A> combiner() {
|
||||||
|
return combiner;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Function<A, R> finisher() {
|
||||||
|
return finisher;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Characteristics> characteristics() {
|
||||||
|
return characteristics;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, R extends List<T>> Collector<T, ?, List<T>> toList(Supplier<R> supplier) {
|
||||||
|
return new CollectorImpl<>(supplier, List::add, (left, right) -> { left.addAll(right); return left; }, CH_ID);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package io.p2vman.vmodextras.util;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.level.block.EntityBlock;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
public interface IBlockEntity<T extends BlockEntity> extends EntityBlock {
|
||||||
|
BlockEntityType<? extends T> getBlockEntityType();
|
||||||
|
|
||||||
|
default BlockEntity newBlockEntity(BlockPos p_153215_, BlockState p_153216_) {
|
||||||
|
return this.getBlockEntityType().create(p_153215_, p_153216_);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,193 @@
|
||||||
|
package io.p2vman.vmodextras.util;
|
||||||
|
|
||||||
|
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 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;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class ModRegistry {
|
||||||
|
@Getter
|
||||||
|
private final String modid;
|
||||||
|
|
||||||
|
public final DeferredRegister<Block> BLOCKS;
|
||||||
|
public final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES;
|
||||||
|
public final Map<RegistryObject<CreativeModeTab>, DeferredRegister<Item>> ITEMS;
|
||||||
|
public final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS;
|
||||||
|
|
||||||
|
public ModRegistry(String modid) {
|
||||||
|
this.modid = modid;
|
||||||
|
this.BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, modid);
|
||||||
|
this.BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, modid);
|
||||||
|
this.ITEMS = new Object2ObjectArrayMap<>();
|
||||||
|
this.CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, modid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TabBuilder TabBuilder() {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static class TabBuilder {
|
||||||
|
private final ModRegistry registry;
|
||||||
|
public final DeferredRegister<Item> ITEMS;
|
||||||
|
|
||||||
|
public TabBuilder(ModRegistry registry) {
|
||||||
|
this.registry = registry;
|
||||||
|
this.ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, registry.modid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TabBuilder push(Consumer<DeferredRegister<Item>> registry) {
|
||||||
|
registry.accept(ITEMS);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistryObject<CreativeModeTab> build(String name, ItemStack icon) {
|
||||||
|
RegistryObject<CreativeModeTab> tab = this.registry.CREATIVE_MODE_TABS.register(name, () -> CreativeModeTab.builder().withTabsBefore(CreativeModeTabs.COMBAT).icon(() -> icon).displayItems((parameters, output) -> {
|
||||||
|
for (RegistryObject<Item> object : ITEMS.getEntries()) {
|
||||||
|
output.accept(object.get());
|
||||||
|
}
|
||||||
|
}).build());
|
||||||
|
|
||||||
|
this.registry.ITEMS.put(tab, this.ITEMS);
|
||||||
|
return tab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum RegistryEntryType {
|
||||||
|
BLOCK,
|
||||||
|
ITEM,
|
||||||
|
BLOCK_ENTITY
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RegistryContainer implements Iterable<Pair<RegistryEntryType, Object>> {
|
||||||
|
private final Object[] values;
|
||||||
|
private final String id;
|
||||||
|
public RegistryContainer(String id) {
|
||||||
|
this.values = new Object[RegistryEntryType.values().length];
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object get(RegistryEntryType key) {
|
||||||
|
return values[key.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistryObject<? extends BlockEntityType<? extends BlockEntity>> getEntity() {
|
||||||
|
return getG(RegistryEntryType.BLOCK_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistryObject<? extends Block> getBlock() {
|
||||||
|
return getG(RegistryEntryType.BLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistryObject<? extends Item> getItem() {
|
||||||
|
return getG(RegistryEntryType.ITEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T getG(RegistryEntryType key) {
|
||||||
|
return (T) values[key.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean containsKey(RegistryEntryType key) {
|
||||||
|
return values[key.ordinal()] != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
int count = 0;
|
||||||
|
for (Object v : values) {
|
||||||
|
if (v != null) count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterable<RegistryEntryType> keys() {
|
||||||
|
RegistryEntryType[] keys = RegistryEntryType.values();
|
||||||
|
Set<RegistryEntryType> result = EnumSet.noneOf(RegistryEntryType.class);
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
if (values[i] != null) result.add(keys[i]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistryContainer register(Consumer<RegistryContainer> consumer) {
|
||||||
|
consumer.accept(this);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void put(RegistryEntryType key, Object value) {
|
||||||
|
values[key.ordinal()] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public RegistryContainer block(Supplier<Block> supplier) {
|
||||||
|
put(RegistryEntryType.BLOCK, supplier);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistryContainer entity(Supplier<BlockEntityType<? extends BlockEntity>> supplier) {
|
||||||
|
put(RegistryEntryType.BLOCK_ENTITY, supplier);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistryContainer item(Supplier<Item> supplier) {
|
||||||
|
put(RegistryEntryType.ITEM, supplier);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Iterator<Pair<RegistryEntryType, Object>> iterator() {
|
||||||
|
List<Pair<RegistryEntryType, Object>> list = new ObjectArrayList<>();
|
||||||
|
for (RegistryEntryType key : keys()) {
|
||||||
|
list.add(new ObjectObjectImmutablePair<>(key, get(key)));
|
||||||
|
}
|
||||||
|
return list.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
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)));
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistryContainer register(TabBuilder builder) {
|
||||||
|
if (containsKey(RegistryEntryType.ITEM)) put(RegistryEntryType.ITEM, builder.ITEMS.register(id, (Supplier<? extends Item>) get(RegistryEntryType.ITEM)));
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RegistryContainer create(String id) {
|
||||||
|
return new RegistryContainer(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package io.p2vman.vmodextras.util;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class ReflectionUtil {
|
||||||
|
public static <T> @Nonnull Optional<T> createInstance(@Nonnull Class<T> cls) {
|
||||||
|
try {
|
||||||
|
return Optional.of(cls.getDeclaredConstructor().newInstance());
|
||||||
|
} catch (Throwable t) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.util;
|
package io.p2vman.vmodextras.util;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package io.p2vman.vmodextras.util;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.ModList;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
public static void executeIsModEnable(String mod, Runnable runnable) {
|
||||||
|
if (ModList.get().isLoaded(mod)) {
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void executeIsModDisable(String mod, Runnable runnable) {
|
||||||
|
if (!ModList.get().isLoaded(mod)) {
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void executeIsModsEnable(Runnable runnable, String... mods) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void executeIsModsDisable(Runnable runnable, String... mods) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package io.p2vman.vmodextras.util;
|
||||||
|
|
||||||
|
import org.valkyrienskies.core.api.ships.ServerShip;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class VsUtils {
|
||||||
|
public static <T> @Nonnull Optional<T> getOrCreateAttachment(@Nonnull ServerShip ship, @Nonnull Class<T> cls) {
|
||||||
|
T obj = ship.getAttachment(cls);
|
||||||
|
if (obj != null) {
|
||||||
|
return Optional.of(obj);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Optional<T> ob = ReflectionUtil.createInstance(cls);
|
||||||
|
ob.ifPresent((j) -> ship.saveAttachment(cls, j));
|
||||||
|
return ob;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,23 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.block;
|
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.IBE;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
||||||
import space.eptaproject.vmodextras.VmodExtras;
|
|
||||||
|
|
||||||
public class EntityBackupBlock extends Block implements IBE<EntityBackupBlockEntity> {
|
|
||||||
public EntityBackupBlock(BlockBehaviour.Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockEntityType<? extends EntityBackupBlockEntity> getBlockEntityType() {
|
|
||||||
return VmodExtras.ENTITY_BACKUP_BLOCK_ENTITY.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<EntityBackupBlockEntity> getBlockEntityClass() {
|
|
||||||
return EntityBackupBlockEntity.class;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.block;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import org.valkyrienskies.core.api.ships.ServerShip;
|
|
||||||
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
|
||||||
import space.eptaproject.vmodextras.VmodExtras;
|
|
||||||
|
|
||||||
|
|
||||||
public class EntityBackupBlockEntity extends BlockEntity {
|
|
||||||
public EntityBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
|
||||||
super(VmodExtras.ENTITY_BACKUP_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load(CompoundTag tag) {
|
|
||||||
super.load(tag);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveAdditional(CompoundTag tag) {
|
|
||||||
super.saveAdditional(tag);
|
|
||||||
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipManagingPos(this.level, this.getBlockPos());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.compact.computercraft;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.BlockItem;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
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.RegistryObject;
|
|
||||||
import space.eptaproject.vmodextras.compact.computercraft.block.TrackWorkController;
|
|
||||||
import space.eptaproject.vmodextras.compact.computercraft.block.entity.TrackWorkControllerEntity;
|
|
||||||
import space.eptaproject.vmodextras.util.ModRegistry;
|
|
||||||
import space.eptaproject.vmodextras.util.Utils;
|
|
||||||
|
|
||||||
public class ComputerCraftCompact {
|
|
||||||
public static RegistryObject<BlockEntityType<TrackWorkControllerEntity>> TRACK_WORK_CONTROLLER_BLOCK_ENTITY;
|
|
||||||
|
|
||||||
public static RegistryObject<Block> TRACK_WORK_CONTROLLER_BLOCK;
|
|
||||||
public static RegistryObject<Item> TRACK_WORK_CONTROLLER_ITEM;
|
|
||||||
|
|
||||||
public static void init(ModRegistry REGISTRY, ModRegistry.TabBuilder builder) {
|
|
||||||
Utils.executeIsModEnable("trackwork", () -> {
|
|
||||||
TRACK_WORK_CONTROLLER_BLOCK = REGISTRY.BLOCKS.register("track_work_controller", () -> new TrackWorkController(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
|
||||||
TRACK_WORK_CONTROLLER_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("track_work_controller", () -> BlockEntityType.Builder.of(TrackWorkControllerEntity::new, TRACK_WORK_CONTROLLER_BLOCK.get()).build(null));
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.push((registry) -> {
|
|
||||||
Utils.executeIsModEnable("trackwork", () -> {
|
|
||||||
TRACK_WORK_CONTROLLER_ITEM = registry.register("track_work_controller", () -> new BlockItem(TRACK_WORK_CONTROLLER_BLOCK.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.compact.computercraft.block;
|
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.IBE;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import space.eptaproject.vmodextras.compact.computercraft.ComputerCraftCompact;
|
|
||||||
import space.eptaproject.vmodextras.compact.computercraft.block.entity.TrackWorkControllerEntity;
|
|
||||||
|
|
||||||
public class TrackWorkController extends Block implements IBE<TrackWorkControllerEntity> {
|
|
||||||
public TrackWorkController(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockEntityType<? extends TrackWorkControllerEntity> getBlockEntityType() {
|
|
||||||
return ComputerCraftCompact.TRACK_WORK_CONTROLLER_BLOCK_ENTITY.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<TrackWorkControllerEntity> getBlockEntityClass() {
|
|
||||||
return TrackWorkControllerEntity.class;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,84 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.compact.computercraft.peripheral;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.lua.*;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2DoubleArrayMap;
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2DoubleMap;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3dc;
|
|
||||||
import org.valkyrienskies.core.api.ships.ServerShip;
|
|
||||||
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
|
||||||
import space.eptaproject.vmodextras.compact.computercraft.block.entity.TrackWorkControllerEntity;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.ISimpleWheelController;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class TrackWorkControllerPeripheral extends PeripheralBase {
|
|
||||||
private TrackWorkControllerEntity entity;
|
|
||||||
|
|
||||||
public static class Controller<T> {
|
|
||||||
private final Class<T> contoller;
|
|
||||||
private Controller(Class<T> contoller) {
|
|
||||||
this.contoller = contoller;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<T> getContoller() {
|
|
||||||
return contoller;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T get(ServerShip ship) {
|
|
||||||
Objects.requireNonNull(ship);
|
|
||||||
T t = ship.getAttachment(contoller);
|
|
||||||
if (t == null) {
|
|
||||||
try {
|
|
||||||
t = contoller.getDeclaredConstructor().newInstance();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Objects.requireNonNull(t);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final List<Controller<?>> DEFS = new ObjectArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TrackWorkControllerPeripheral(TrackWorkControllerEntity entity) {
|
|
||||||
super("track_work_controller");
|
|
||||||
this.entity = entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction
|
|
||||||
public final void SetSuspensionAdjust(IArguments arguments) throws LuaException {
|
|
||||||
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(this.entity.getLevel(), this.entity.getBlockPos());
|
|
||||||
if (ship != null) {
|
|
||||||
((ISimpleWheelController) SimpleWheelController.getOrCreate(ship)).setSuspensionAdjust(new Vector3d(
|
|
||||||
Math.max(Math.min(arguments.getDouble(0), 1d), 0d),
|
|
||||||
Math.max(Math.min(arguments.getDouble(1), 1.3d), 0.5d),
|
|
||||||
Math.max(Math.min(arguments.getDouble(2), 1d), 0d)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction
|
|
||||||
public final MethodResult GetSuspensionAdjust(IArguments arguments) throws LuaException {
|
|
||||||
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(this.entity.getLevel(), this.entity.getBlockPos());
|
|
||||||
if (ship != null) {
|
|
||||||
Vector3dc vec =((ISimpleWheelController) SimpleWheelController.getOrCreate(ship)).getSuspensionAdjust();
|
|
||||||
Int2DoubleMap map = new Int2DoubleArrayMap();
|
|
||||||
map.put(1, vec.x());
|
|
||||||
map.put(2, vec.y());
|
|
||||||
map.put(3, vec.z());
|
|
||||||
return MethodResult.of(new ObjectLuaTable(map));
|
|
||||||
}
|
|
||||||
|
|
||||||
return MethodResult.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
@LuaFunction
|
|
||||||
public final MethodResult GetMeta(IArguments arguments) throws LuaException {
|
|
||||||
return MethodResult.of();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.compact.trackwork;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3dc;
|
|
||||||
|
|
||||||
public interface IController {
|
|
||||||
float getSuspensionStiffness();
|
|
||||||
void setSuspensionStiffness(float val);
|
|
||||||
Vector3dc getSuspensionAdjust();
|
|
||||||
void setSuspensionAdjust(Vector3dc vector3d);
|
|
||||||
|
|
||||||
default void encode(CompoundTag root) {
|
|
||||||
root.putFloat("SuspensionStiffness", this.getSuspensionStiffness());
|
|
||||||
{
|
|
||||||
CompoundTag suspensionAdjust = new CompoundTag();
|
|
||||||
|
|
||||||
Vector3dc vec = this.getSuspensionAdjust();
|
|
||||||
|
|
||||||
suspensionAdjust.putDouble("x", vec.x());
|
|
||||||
suspensionAdjust.putDouble("y", vec.y());
|
|
||||||
suspensionAdjust.putDouble("z", vec.z());
|
|
||||||
|
|
||||||
root.put("suspensionAdjust", suspensionAdjust);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default void decode(CompoundTag root) {
|
|
||||||
if (root.contains("SuspensionStiffness", Tag.TAG_FLOAT)) {
|
|
||||||
this.setSuspensionStiffness(root.getFloat("SuspensionStiffness"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root.contains("suspensionAdjust", Tag.TAG_COMPOUND)) {
|
|
||||||
CompoundTag sus = root.getCompound("suspensionAdjust");
|
|
||||||
this.setSuspensionAdjust(new Vector3d(sus.getDouble("x"), sus.getDouble("y"), sus.getDouble("z")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.compact.trackwork;
|
|
||||||
|
|
||||||
import space.eptaproject.vmodextras.mixins.trackwork.PhysicsTrackControllerAccessor;
|
|
||||||
|
|
||||||
public interface IPhysicsTrackController extends PhysicsTrackControllerAccessor, IController {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.compact.trackwork;
|
|
||||||
|
|
||||||
import space.eptaproject.vmodextras.mixins.trackwork.SimpleWheelControllerAccessor;
|
|
||||||
|
|
||||||
public interface ISimpleWheelController extends SimpleWheelControllerAccessor, IController {
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.compact.trackwork.block;
|
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.IBE;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.TrackWorkCompact;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.block.entity.CompactBackupBlockEntity;
|
|
||||||
|
|
||||||
public class CompactBackupBlock extends Block implements IBE<CompactBackupBlockEntity> {
|
|
||||||
|
|
||||||
public CompactBackupBlock(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockEntityType<? extends CompactBackupBlockEntity> getBlockEntityType() {
|
|
||||||
return TrackWorkCompact.COMPACT_BACKUP_BLOCK_ENTITY.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<CompactBackupBlockEntity> getBlockEntityClass() {
|
|
||||||
return CompactBackupBlockEntity.class;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.compact.trackwork.block;
|
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.IBE;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.TrackWorkCompact;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.block.entity.TrackBackupBlockEntity;
|
|
||||||
|
|
||||||
public class TrackBackupBlock extends Block implements IBE<TrackBackupBlockEntity> {
|
|
||||||
|
|
||||||
public TrackBackupBlock(Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockEntityType<? extends TrackBackupBlockEntity> getBlockEntityType() {
|
|
||||||
return TrackWorkCompact.MY_BLOCK_ENTITY.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<TrackBackupBlockEntity> getBlockEntityClass() {
|
|
||||||
return TrackBackupBlockEntity.class;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,97 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.compact.trackwork.block.entity;
|
|
||||||
|
|
||||||
import edn.stratodonut.drivebywire.wire.ShipWireNetworkManager;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import net.minecraft.world.level.block.Rotation;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
|
|
||||||
import org.valkyrienskies.core.api.ships.ServerShip;
|
|
||||||
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.TrackWorkCompact;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.IPhysicsTrackController;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.ISimpleWheelController;
|
|
||||||
|
|
||||||
|
|
||||||
public class CompactBackupBlockEntity extends BlockEntity {
|
|
||||||
private CompoundTag pendingBackupData;
|
|
||||||
|
|
||||||
public CompactBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
|
||||||
super(TrackWorkCompact.COMPACT_BACKUP_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
|
||||||
super.saveAdditional(tag);
|
|
||||||
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
|
||||||
if (ship != null) {
|
|
||||||
{
|
|
||||||
PhysicsTrackController physicsTrackController = ship.getAttachment(PhysicsTrackController.class);
|
|
||||||
if (physicsTrackController != null) {
|
|
||||||
IPhysicsTrackController controller = (IPhysicsTrackController) physicsTrackController;
|
|
||||||
CompoundTag local = new CompoundTag();
|
|
||||||
|
|
||||||
controller.encode(local);
|
|
||||||
|
|
||||||
tag.put("PhysicsTrackController", local);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
SimpleWheelController simpleWheelController = ship.getAttachment(SimpleWheelController.class);
|
|
||||||
if (simpleWheelController != null) {
|
|
||||||
ISimpleWheelController controller = (ISimpleWheelController) simpleWheelController;
|
|
||||||
CompoundTag local = new CompoundTag();
|
|
||||||
|
|
||||||
controller.encode(local);
|
|
||||||
|
|
||||||
tag.put("SimpleWheelController", local);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ship = (ServerShip) VSGameUtilsKt.getShipManagingPos(this.level, this.getBlockPos());
|
|
||||||
|
|
||||||
if (this.level != null) {
|
|
||||||
if (this.pendingBackupData == null) {
|
|
||||||
this.pendingBackupData = new CompoundTag();
|
|
||||||
}
|
|
||||||
|
|
||||||
ShipWireNetworkManager.get(ship).ifPresent((m) -> this.pendingBackupData.merge(m.serialiseToNbt(this.level, this.getBlockPos())));
|
|
||||||
|
|
||||||
if (this.pendingBackupData != null) {
|
|
||||||
tag.put("WireNetwork", this.pendingBackupData);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load(CompoundTag tag) {
|
|
||||||
super.load(tag);
|
|
||||||
|
|
||||||
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
|
||||||
if (ship != null) {
|
|
||||||
if (tag.contains("SimpleWheelController", Tag.TAG_COMPOUND)) {
|
|
||||||
((ISimpleWheelController) SimpleWheelController.getOrCreate(ship)).decode(tag.getCompound("SimpleWheelController"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tag.contains("PhysicsTrackController", Tag.TAG_COMPOUND)) {
|
|
||||||
((IPhysicsTrackController) PhysicsTrackController.getOrCreate(ship)).decode(tag.getCompound("PhysicsTrackController"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ship = (ServerShip) VSGameUtilsKt.getShipManagingPos(this.level, getBlockPos());
|
|
||||||
if (ship != null) {
|
|
||||||
if (tag.contains("WireNetwork", 10)) {
|
|
||||||
ShipWireNetworkManager.loadIfNotExists(ship, level, tag.getCompound("WireNetwork"), this.getBlockPos(), Rotation.NONE);
|
|
||||||
|
|
||||||
this.pendingBackupData = tag.getCompound("WireNetwork");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,115 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.compact.trackwork.block.entity;
|
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import org.valkyrienskies.core.api.ships.ServerShip;
|
|
||||||
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.TrackWorkCompact;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.IPhysicsTrackController;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.ISimpleWheelController;
|
|
||||||
import space.eptaproject.vmodextras.compact.trackwork.IBlockEntityClear;
|
|
||||||
|
|
||||||
public class TrackBackupBlockEntity extends BlockEntity implements IBlockEntityClear {
|
|
||||||
public TrackBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
|
||||||
super(TrackWorkCompact.MY_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompoundTag tag = new CompoundTag();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean clear() {
|
|
||||||
try {
|
|
||||||
CompoundTag local = tag.copy();
|
|
||||||
if (local.contains("SimpleWheelController")) {
|
|
||||||
CompoundTag SimpleWheelControllerTag = new CompoundTag();
|
|
||||||
|
|
||||||
SimpleWheelControllerTag.putFloat("SuspensionStiffness", 1);
|
|
||||||
{
|
|
||||||
CompoundTag suspensionAdjust = new CompoundTag();
|
|
||||||
|
|
||||||
suspensionAdjust.putDouble("x", 0);
|
|
||||||
suspensionAdjust.putDouble("y", 1);
|
|
||||||
suspensionAdjust.putDouble("z", 0);
|
|
||||||
|
|
||||||
SimpleWheelControllerTag.put("suspensionAdjust", suspensionAdjust);
|
|
||||||
}
|
|
||||||
|
|
||||||
tag.put("SimpleWheelController", SimpleWheelControllerTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (local.contains("PhysicsTrackController")) {
|
|
||||||
CompoundTag PhysicsTrackControllerTag = new CompoundTag();
|
|
||||||
|
|
||||||
PhysicsTrackControllerTag.putFloat("SuspensionStiffness", 1);
|
|
||||||
{
|
|
||||||
CompoundTag suspensionAdjust = new CompoundTag();
|
|
||||||
|
|
||||||
|
|
||||||
suspensionAdjust.putDouble("x", 0);
|
|
||||||
suspensionAdjust.putDouble("y", 1);
|
|
||||||
suspensionAdjust.putDouble("z", 0);
|
|
||||||
|
|
||||||
PhysicsTrackControllerTag.put("suspensionAdjust", suspensionAdjust);
|
|
||||||
}
|
|
||||||
|
|
||||||
tag.put("PhysicsTrackController", PhysicsTrackControllerTag);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void saveAdditional(CompoundTag tag) {
|
|
||||||
this.tag = tag;
|
|
||||||
super.saveAdditional(tag);
|
|
||||||
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
|
||||||
if (ship != null) {
|
|
||||||
{
|
|
||||||
PhysicsTrackController physicsTrackController = ship.getAttachment(PhysicsTrackController.class);
|
|
||||||
if (physicsTrackController != null) {
|
|
||||||
IPhysicsTrackController controller = (IPhysicsTrackController) physicsTrackController;
|
|
||||||
CompoundTag local = new CompoundTag();
|
|
||||||
|
|
||||||
controller.encode(local);
|
|
||||||
|
|
||||||
tag.put("PhysicsTrackController", local);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
SimpleWheelController simpleWheelController = ship.getAttachment(SimpleWheelController.class);
|
|
||||||
if (simpleWheelController != null) {
|
|
||||||
ISimpleWheelController controller = (ISimpleWheelController) simpleWheelController;
|
|
||||||
CompoundTag local = new CompoundTag();
|
|
||||||
|
|
||||||
controller.encode(local);
|
|
||||||
|
|
||||||
tag.put("SimpleWheelController", local);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load(CompoundTag tag) {
|
|
||||||
this.tag = tag;
|
|
||||||
super.load(tag);
|
|
||||||
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
|
||||||
if (ship != null) {
|
|
||||||
if (tag.contains("SimpleWheelController", Tag.TAG_COMPOUND)) {
|
|
||||||
((ISimpleWheelController) SimpleWheelController.getOrCreate(ship)).decode(tag.getCompound("SimpleWheelController"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tag.contains("PhysicsTrackController", Tag.TAG_COMPOUND)) {
|
|
||||||
((IPhysicsTrackController) PhysicsTrackController.getOrCreate(ship)).decode(tag.getCompound("PhysicsTrackController"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.compact.trackwork.item;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.world.InteractionResult;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
|
|
||||||
public class ToolKit extends Item {
|
|
||||||
public ToolKit(Item.Properties properties) {
|
|
||||||
super(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext context) {
|
|
||||||
Player player = context.getPlayer();
|
|
||||||
if (player != null && player.mayBuild()) {
|
|
||||||
Level level = context.getLevel();
|
|
||||||
BlockPos pos = context.getClickedPos();
|
|
||||||
CompoundTag nbt = stack.getTag();
|
|
||||||
|
|
||||||
return InteractionResult.PASS;
|
|
||||||
} else {
|
|
||||||
return InteractionResult.PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Mode {
|
|
||||||
CLEAR
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.mixins;
|
|
||||||
|
|
||||||
public class A {
|
|
||||||
}
|
|
|
@ -1,77 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.util;
|
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.minecraft.core.registries.Registries;
|
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
|
||||||
import net.minecraft.world.item.CreativeModeTabs;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class ModRegistry {
|
|
||||||
@Getter
|
|
||||||
private final String modid;
|
|
||||||
|
|
||||||
public final DeferredRegister<Block> BLOCKS;
|
|
||||||
public final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES;
|
|
||||||
public final Map<RegistryObject<CreativeModeTab>, DeferredRegister<Item>> ITEMS;
|
|
||||||
public final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS;
|
|
||||||
|
|
||||||
|
|
||||||
public ModRegistry(String modid) {
|
|
||||||
this.modid = modid;
|
|
||||||
this.BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, modid);
|
|
||||||
this.BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, modid);
|
|
||||||
this.ITEMS = new Object2ObjectArrayMap<>();
|
|
||||||
this.CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, modid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TabBuilder TabBuilder() {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static class TabBuilder {
|
|
||||||
private final ModRegistry registry;
|
|
||||||
public final DeferredRegister<Item> ITEMS;
|
|
||||||
|
|
||||||
public TabBuilder(ModRegistry registry) {
|
|
||||||
this.registry = registry;
|
|
||||||
this.ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, registry.modid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TabBuilder push(Consumer<DeferredRegister<Item>> registry) {
|
|
||||||
registry.accept(ITEMS);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RegistryObject<CreativeModeTab> build(String name, ItemStack icon) {
|
|
||||||
RegistryObject<CreativeModeTab> tab = this.registry.CREATIVE_MODE_TABS.register(name, () -> CreativeModeTab.builder().withTabsBefore(CreativeModeTabs.COMBAT).icon(() -> icon).displayItems((parameters, output) -> {
|
|
||||||
for (RegistryObject<Item> object : ITEMS.getEntries()) {
|
|
||||||
output.accept(object.get());
|
|
||||||
}
|
|
||||||
}).build());
|
|
||||||
|
|
||||||
this.registry.ITEMS.put(tab, this.ITEMS);
|
|
||||||
return tab;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.util;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.ModList;
|
|
||||||
|
|
||||||
public class Utils {
|
|
||||||
public static void executeIsModEnable(String mod,Runnable runnable) {
|
|
||||||
if (ModList.get().isLoaded(mod)) {
|
|
||||||
runnable.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void executeIsModDisable(String mod,Runnable runnable) {
|
|
||||||
if (!ModList.get().isLoaded(mod)) {
|
|
||||||
runnable.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +1,6 @@
|
||||||
public net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem
|
public net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem
|
||||||
public net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem placeChunk(Lnet/minecraft/server/level/ServerLevel;Ljava/util/Map;Lnet/spaceeye/valkyrien_ship_schematics/containers/v1/ChunkyBlockData;Lnet/spaceeye/valkyrien_ship_schematics/interfaces/IBlockStatePalette;Ljava/util/List;Lnet/spaceeye/vmod/utils/Vector3d;)V # placeChunk
|
public net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem placeChunk(Lnet/minecraft/server/level/ServerLevel;Ljava/util/Map;Lnet/spaceeye/valkyrien_ship_schematics/containers/v1/ChunkyBlockData;Lnet/spaceeye/valkyrien_ship_schematics/interfaces/IBlockStatePalette;Ljava/util/List;Lnet/spaceeye/vmod/utils/Vector3d;)V # placeChunk
|
||||||
public net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem place(JJ)Ljava/lang/Boolean; # place
|
public net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem place(JJ)Ljava/lang/Boolean; # place
|
||||||
|
public org.valkyrienskies.core.impl.game.ships.ShipData persistentAttachedData # persistentAttachedData
|
||||||
|
public edn.stratodonut.drivebywire.wire.ShipWireNetworkManager <init>(JJLjava/lang/String;)V # ShipWireNetworkManager
|
||||||
|
public edn.stratodonut.drivebywire.wire.ShipWireNetworkManager <init>()V # ShipWireNetworkManager
|
|
@ -12,7 +12,7 @@ modId = "forge"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
versionRange = "${forge_version_range}"
|
versionRange = "${forge_version_range}"
|
||||||
ordering = "NONE"
|
ordering = "NONE"
|
||||||
side = "SERVER"
|
side = "BOTH"
|
||||||
[[dependencies."${mod_id}"]]
|
[[dependencies."${mod_id}"]]
|
||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"": { "model": "vmodextras:block/compact_backup" }
|
||||||
|
}
|
||||||
|
}
|
0
src/main/resources/assets/vmodextras/blockstates/track_work_controller.json
Normal file → Executable file
0
src/main/resources/assets/vmodextras/blockstates/track_work_controller.json
Normal file → Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": {
|
||||||
|
"all": "vmodextras:block/compact_backup"
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue