Compare commits
No commits in common. "master" and "0.0.1b" have entirely different histories.
|
@ -1,7 +0,0 @@
|
||||||
<?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>
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?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,7 +5,6 @@
|
||||||
<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$" />
|
||||||
|
|
|
@ -36,30 +36,5 @@
|
||||||
<option name="name" value="maven" />
|
<option name="name" value="maven" />
|
||||||
<option name="url" value="https://maven.tterrag.com/releases" />
|
<option name="url" value="https://maven.tterrag.com/releases" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="maven2" />
|
|
||||||
<option name="name" value="maven2" />
|
|
||||||
<option name="url" value="https://squiddev.cc/maven/" />
|
|
||||||
</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>
|
|
@ -1,22 +0,0 @@
|
||||||
<?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>
|
|
|
@ -21,7 +21,7 @@
|
||||||
<option name="mappingFile" value="$MODULE_DIR$/../../build/createMcpToSrg/output.tsrg" />
|
<option name="mappingFile" value="$MODULE_DIR$/../../build/createMcpToSrg/output.tsrg" />
|
||||||
<option name="mcpVersion" value="official_1.20.1" />
|
<option name="mcpVersion" value="official_1.20.1" />
|
||||||
<option name="minecraftVersion" value="1.20.1" />
|
<option name="minecraftVersion" value="1.20.1" />
|
||||||
<option name="platformVersion" value="47.3.5" />
|
<option name="platformVersion" value="47.4.1" />
|
||||||
<option name="srgType" value="TSRG" />
|
<option name="srgType" value="TSRG" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -16,7 +16,7 @@
|
||||||
<option name="mappingFile" value="$MODULE_DIR$/../../build/createMcpToSrg/output.tsrg" />
|
<option name="mappingFile" value="$MODULE_DIR$/../../build/createMcpToSrg/output.tsrg" />
|
||||||
<option name="mcpVersion" value="official_1.20.1" />
|
<option name="mcpVersion" value="official_1.20.1" />
|
||||||
<option name="minecraftVersion" value="1.20.1" />
|
<option name="minecraftVersion" value="1.20.1" />
|
||||||
<option name="platformVersion" value="47.3.5" />
|
<option name="platformVersion" value="47.4.1" />
|
||||||
<option name="srgType" value="TSRG" />
|
<option name="srgType" value="TSRG" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -153,23 +153,6 @@ repositories {
|
||||||
maven {
|
maven {
|
||||||
url = uri("https://maven.tterrag.com/releases")
|
url = uri("https://maven.tterrag.com/releases")
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -191,27 +174,12 @@ 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'
|
||||||
|
@ -222,15 +190,10 @@ dependencies {
|
||||||
jarJar.ranged(it, "[0.4.1,)")
|
jarJar.ranged(it, "[0.4.1,)")
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation fg.deobf("libs:cc-tweaked:1.20.1-forge-1.113.1")
|
implementation fg.deobf(files("./libs/drivebywire-1.20.1-0.0.10.jar"))
|
||||||
|
|
||||||
|
|
||||||
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"))
|
||||||
|
|
||||||
|
@ -243,8 +206,6 @@ 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")
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,9 +237,7 @@ 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
|
||||||
|
|
|
@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
minecraft_version=1.20.1
|
minecraft_version=1.20.1
|
||||||
minecraft_version_range=[1.20.1,1.21)
|
minecraft_version_range=[1.20.1,1.21)
|
||||||
forge_version=47.3.5
|
forge_version=47.4.1
|
||||||
forge_version_range=[47,)
|
forge_version_range=[47,)
|
||||||
loader_version_range=[47,)
|
loader_version_range=[47,)
|
||||||
mapping_channel=official
|
mapping_channel=official
|
||||||
|
@ -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.2b
|
mod_version=0.0.1b
|
||||||
mod_group_id=io.p2vman
|
mod_group_id=space.eptaproject
|
||||||
mod_authors=p2vman
|
mod_authors=p2vman
|
||||||
mod_description=
|
mod_description=
|
||||||
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
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() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,139 +0,0 @@
|
||||||
package io.p2vman.vmodextras;
|
|
||||||
|
|
||||||
import com.google.common.base.VerifyException;
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import com.mojang.logging.LogUtils;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.Font;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
|
||||||
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.event.entity.player.PlayerInteractEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
|
||||||
import net.minecraftforge.fml.ModLoadingException;
|
|
||||||
import net.minecraftforge.fml.ModLoadingStage;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
|
||||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|
||||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import io.p2vman.vmodextras.compact.Compact;
|
|
||||||
import io.p2vman.vmodextras.util.ModRegistry;
|
|
||||||
|
|
||||||
@Mod(VmodExtras.MODID)
|
|
||||||
public class VmodExtras {
|
|
||||||
public static final String MODID = "vmodextras";
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
|
||||||
|
|
||||||
public static final ModRegistry REGISTRY;
|
|
||||||
|
|
||||||
static {
|
|
||||||
REGISTRY = new ModRegistry(MODID);
|
|
||||||
|
|
||||||
new Compact((registry, builder) -> {
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String MIN_FORGE_VERSION = "47.3.5";
|
|
||||||
|
|
||||||
public VmodExtras() {
|
|
||||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
|
||||||
|
|
||||||
modEventBus.addListener(this::commonSetup);
|
|
||||||
REGISTRY.register(modEventBus);
|
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_CONFIG);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void commonSetup(final FMLCommonSetupEvent event) {
|
|
||||||
GameRulesBlat.init();
|
|
||||||
|
|
||||||
String currentVersion = ForgeVersion.getVersion();
|
|
||||||
if (compareVersion(currentVersion, MIN_FORGE_VERSION) < 0) {
|
|
||||||
throw new ModLoadingException(
|
|
||||||
ModLoadingContext.get().getActiveContainer().getModInfo(),
|
|
||||||
ModLoadingStage.ERROR,
|
|
||||||
"VModExras requires Forge " + MIN_FORGE_VERSION + " or higher, but found " + currentVersion,
|
|
||||||
new VerifyException("VModExras requires Forge " + MIN_FORGE_VERSION + " or higher, but found " + currentVersion)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static int compareVersion(String v1, String v2) {
|
|
||||||
if (v1 == null || v2 == null) {
|
|
||||||
throw new IllegalArgumentException("Version strings must not be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] parts1 = v1.split("[.-]");
|
|
||||||
String[] parts2 = v2.split("[.-]");
|
|
||||||
|
|
||||||
int maxLength = Math.max(parts1.length, parts2.length);
|
|
||||||
|
|
||||||
for (int i = 0; i < maxLength; i++) {
|
|
||||||
String s1 = i < parts1.length ? parts1[i] : "0";
|
|
||||||
String s2 = i < parts2.length ? parts2[i] : "0";
|
|
||||||
try {
|
|
||||||
int n1 = Integer.parseInt(s1);
|
|
||||||
int n2 = Integer.parseInt(s2);
|
|
||||||
if (n1 != n2) {
|
|
||||||
return Integer.compare(n1, n2);
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
int cmp = s1.compareTo(s2);
|
|
||||||
if (cmp != 0) {
|
|
||||||
return cmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
|
||||||
public static class ModConfigHandler {
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onConfigReload(ModConfigEvent event) {
|
|
||||||
if (event.getConfig().getSpec() == Config.COMMON_CONFIG) {
|
|
||||||
Config.bake();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.DEDICATED_SERVER)
|
|
||||||
public static class InteractionHandler {
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
|
|
||||||
if (Config.contains(event.getItemStack())) {
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) {
|
|
||||||
if (Config.contains(event.getItemStack())) {
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event) {
|
|
||||||
if (Config.contains(event.getItemStack())) {
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
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)));
|
|
||||||
//});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,127 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
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_);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,140 +0,0 @@
|
||||||
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,43 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.block.entity;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import io.p2vman.vmodextras.cc.ComputerCraftCompact;
|
|
||||||
import io.p2vman.vmodextras.cc.peripheral.TrackWorkControllerPeripheral;
|
|
||||||
|
|
||||||
import static dan200.computercraft.shared.Capabilities.CAPABILITY_PERIPHERAL;
|
|
||||||
|
|
||||||
public class TrackWorkControllerEntity extends BlockEntity {
|
|
||||||
public TrackWorkControllerEntity(BlockPos p_155229_, BlockState p_155230_) {
|
|
||||||
super(ComputerCraftCompact.TRACK_WORK_CONTROLLER_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TrackWorkControllerPeripheral peripheral = new TrackWorkControllerPeripheral(this);
|
|
||||||
private LazyOptional<IPeripheral> peripheralCap;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@NotNull
|
|
||||||
public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, Direction direction) {
|
|
||||||
if (cap == CAPABILITY_PERIPHERAL) {
|
|
||||||
if (peripheralCap == null) {
|
|
||||||
peripheralCap = LazyOptional.of(() -> peripheral);
|
|
||||||
}
|
|
||||||
return peripheralCap.cast();
|
|
||||||
}
|
|
||||||
return super.getCapability(cap, direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invalidateCaps() {
|
|
||||||
super.invalidateCaps();
|
|
||||||
if (peripheralCap != null) {
|
|
||||||
peripheralCap.invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.net;
|
|
||||||
|
|
||||||
public interface IDomainNameHandler {
|
|
||||||
int find(String domain);
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
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 );
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.net;
|
|
||||||
|
|
||||||
|
|
||||||
public record NetworkPacket(int channel,
|
|
||||||
int replyChannel,
|
|
||||||
Object payload,
|
|
||||||
IPacketSender sender) {
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
package io.p2vman.vmodextras.cc.peripheral;
|
|
||||||
|
|
||||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
|
||||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PeripheralBase implements IPeripheral {
|
|
||||||
@Getter
|
|
||||||
protected final List<IComputerAccess> connectedComputers = new ObjectArrayList<>();
|
|
||||||
protected final String type;
|
|
||||||
public PeripheralBase(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void detach(@Nullable IComputerAccess computer) {
|
|
||||||
connectedComputers.remove(computer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void attach(@Nonnull IComputerAccess computer) {
|
|
||||||
connectedComputers.add(computer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull String getType() {
|
|
||||||
return this.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(IPeripheral iPeripheral) {
|
|
||||||
return this == iPeripheral;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,122 +0,0 @@
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,174 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
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.Items;
|
|
||||||
import net.minecraftforge.registries.RegistryObject;
|
|
||||||
import io.p2vman.vmodextras.VmodExtras;
|
|
||||||
import io.p2vman.vmodextras.util.ModRegistry;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
public class Compact {
|
|
||||||
public static RegistryObject<CreativeModeTab> COMPACT_TAB;
|
|
||||||
|
|
||||||
public Compact(BiConsumer<ModRegistry, ModRegistry.TabBuilder> consumer) {
|
|
||||||
ModRegistry REGISTRY = VmodExtras.REGISTRY;
|
|
||||||
ModRegistry.TabBuilder builder = REGISTRY.TabBuilder();
|
|
||||||
|
|
||||||
Utils.executeIsModEnable("computercraft", () -> {
|
|
||||||
ComputerCraftCompact.init(REGISTRY, builder);
|
|
||||||
});
|
|
||||||
|
|
||||||
Utils.executeIsModEnable("trackwork", () -> {
|
|
||||||
TrackWorkCompact.init(REGISTRY, builder);
|
|
||||||
});
|
|
||||||
|
|
||||||
consumer.accept(REGISTRY, builder);
|
|
||||||
|
|
||||||
COMPACT_TAB = builder.build("vmodextras", Items.PAPER.getDefaultInstance());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
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"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
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,25 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
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 {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
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) {
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package io.p2vman.vmodextras.serialization;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface Decode<T> {
|
|
||||||
T decode(CompoundTag root, T obj, Context context);
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package io.p2vman.vmodextras.serialization;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface Encode<T> {
|
|
||||||
CompoundTag encode(T input, Context context);
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork;
|
|
||||||
|
|
||||||
import io.p2vman.vmodextras.mixins.trackwork.PhysicsTrackControllerAccessor;
|
|
||||||
|
|
||||||
public interface IPhysicsTrackController extends PhysicsTrackControllerAccessor, IController {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork;
|
|
||||||
|
|
||||||
import io.p2vman.vmodextras.mixins.trackwork.SimpleWheelControllerAccessor;
|
|
||||||
|
|
||||||
public interface ISimpleWheelController extends SimpleWheelControllerAccessor, IController {
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
package io.p2vman.vmodextras.trackwork;
|
|
||||||
|
|
||||||
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.trackwork.block.CompactBackupBlock;
|
|
||||||
import io.p2vman.vmodextras.trackwork.block.TrackBackupBlock;
|
|
||||||
import io.p2vman.vmodextras.trackwork.block.entity.CompactBackupBlockEntity;
|
|
||||||
import io.p2vman.vmodextras.trackwork.block.entity.TrackBackupBlockEntity;
|
|
||||||
import io.p2vman.vmodextras.util.ModRegistry;
|
|
||||||
|
|
||||||
public class TrackWorkCompact
|
|
||||||
{
|
|
||||||
public static RegistryObject<Block> SHIP_VOID_BLOCK;
|
|
||||||
public static RegistryObject<Block> TRAK_BUK;
|
|
||||||
public static RegistryObject<Block> COMPACT_BACKUP;
|
|
||||||
|
|
||||||
public static RegistryObject<BlockEntityType<TrackBackupBlockEntity>> MY_BLOCK_ENTITY;
|
|
||||||
public static RegistryObject<BlockEntityType<CompactBackupBlockEntity>> COMPACT_BACKUP_BLOCK_ENTITY;
|
|
||||||
|
|
||||||
public static RegistryObject<Item> MY_BLOCK_ITEM;
|
|
||||||
public static RegistryObject<Item> SHIP_VOID_ITEM;
|
|
||||||
public static RegistryObject<Item> COMPACT_BACKUP_ITEM;
|
|
||||||
|
|
||||||
|
|
||||||
public static void init(ModRegistry REGISTRY, ModRegistry.TabBuilder builder) {
|
|
||||||
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)));
|
|
||||||
COMPACT_BACKUP = REGISTRY.BLOCKS.register("compact_backup", () -> new CompactBackupBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
|
||||||
|
|
||||||
MY_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("track_backup", () -> BlockEntityType.Builder.of(TrackBackupBlockEntity::new, TRAK_BUK.get()).build(null));
|
|
||||||
COMPACT_BACKUP_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("compact_backup", () -> BlockEntityType.Builder.of(CompactBackupBlockEntity::new, COMPACT_BACKUP.get()).build(null));
|
|
||||||
|
|
||||||
builder.push((registry) -> {
|
|
||||||
MY_BLOCK_ITEM = registry.register("track_backup", () -> new BlockItem(TRAK_BUK.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
|
||||||
SHIP_VOID_ITEM = registry.register("ship_void", () -> new BlockItem(SHIP_VOID_BLOCK.get(), new Item.Properties()));
|
|
||||||
COMPACT_BACKUP_ITEM = registry.register("compact_backup", () -> new BlockItem(COMPACT_BACKUP.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
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_);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,193 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
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,9 +0,0 @@
|
||||||
package io.p2vman.vmodextras.util;
|
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
|
|
||||||
public class ResourceLocationUtil {
|
|
||||||
public static ResourceLocation fromNamespaceAndPath(String namespace, String path) {
|
|
||||||
return new ResourceLocation(namespace, path);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
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) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
69
src/main/java/io/p2vman/vmodextras/Config.java → src/main/java/space/eptaproject/vmodextras/Config.java
Executable file → Normal file
69
src/main/java/io/p2vman/vmodextras/Config.java → src/main/java/space/eptaproject/vmodextras/Config.java
Executable file → Normal file
|
@ -1,11 +1,8 @@
|
||||||
package io.p2vman.vmodextras;
|
package space.eptaproject.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;
|
||||||
|
@ -13,28 +10,6 @@ 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;
|
||||||
|
@ -43,31 +18,13 @@ public class Config {
|
||||||
public static final ForgeConfigSpec.ConfigValue<Integer> Suspension_Stiffness_LIMIT;
|
public static final ForgeConfigSpec.ConfigValue<Integer> Suspension_Stiffness_LIMIT;
|
||||||
public static final ForgeConfigSpec.ConfigValue<Double> Suspension_Stiffness_delta;
|
public static final ForgeConfigSpec.ConfigValue<Double> Suspension_Stiffness_delta;
|
||||||
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<Boolean> Schematic_Blocked_Blocks;
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<Boolean> Inventory_Blocked_Blocks;
|
|
||||||
|
|
||||||
public static List<ResourceLocation> parsedList = new ObjectArrayList<>();
|
public static List<ResourceLocation> parsedList = new ObjectArrayList<>();
|
||||||
private static List<Map.Entry<Integer, ResourceLocation>> ITEM = new ObjectImmutableList<>(new ArrayList<>());
|
private static List<Map.Entry<Integer, ResourceLocation>> ITEM = new ObjectImmutableList<>(new ArrayList<>());
|
||||||
public static ResourceLocation replace = Validator.RB;
|
public static ResourceLocation replace = Validator.RB;
|
||||||
public static boolean Inventory_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
|
||||||
|
@ -85,9 +42,6 @@ public class Config {
|
||||||
Validator.RB.toString()
|
Validator.RB.toString()
|
||||||
);
|
);
|
||||||
|
|
||||||
Schematic_Blocked_Blocks = builder
|
|
||||||
.define("enable", false);
|
|
||||||
|
|
||||||
|
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
|
@ -101,9 +55,6 @@ public class Config {
|
||||||
obj -> obj instanceof String && ResourceLocation.isValidResourceLocation((String) obj)
|
obj -> obj instanceof String && ResourceLocation.isValidResourceLocation((String) obj)
|
||||||
);
|
);
|
||||||
|
|
||||||
Inventory_Blocked_Blocks = builder
|
|
||||||
.define("enable", false);
|
|
||||||
|
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
builder.push("TrackWork");
|
builder.push("TrackWork");
|
||||||
|
@ -123,14 +74,20 @@ public class Config {
|
||||||
|
|
||||||
public static void bake() {
|
public static void bake() {
|
||||||
parsedList = RESOURCE_LOCATION_LIST.get().stream()
|
parsedList = RESOURCE_LOCATION_LIST.get().stream()
|
||||||
.map(ResourceLocation::tryParse)
|
.map(s -> {
|
||||||
|
try {
|
||||||
|
return ResourceLocation.parse(s);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
ITEM = new ObjectImmutableList(ITEM_BLACK_LIST.get().stream()
|
ITEM = new ObjectImmutableList(ITEM_BLACK_LIST.get().stream()
|
||||||
.map(s -> {
|
.map(s -> {
|
||||||
try {
|
try {
|
||||||
ResourceLocation location = ResourceLocation.tryParse(s);
|
ResourceLocation location = ResourceLocation.parse(s);
|
||||||
return new AbstractMap.SimpleEntry<Integer, ResourceLocation>(location.hashCode(), location);
|
return new AbstractMap.SimpleEntry<Integer, ResourceLocation>(location.hashCode(), location);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -139,19 +96,15 @@ public class Config {
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.toList());
|
.toList());
|
||||||
try {
|
try {
|
||||||
replace = new ResourceLocation(RESOURCE_LOCATION.get());
|
replace = ResourceLocation.parse(RESOURCE_LOCATION.get());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
replace = Validator.RB;
|
replace = Validator.RB;
|
||||||
}
|
}
|
||||||
|
|
||||||
Inventory_Blocked_Blocks_Enable = Inventory_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) {
|
||||||
if (stack.isEmpty() || !Inventory_Blocked_Blocks_Enable) return false;
|
if (stack.isEmpty()) return false;
|
||||||
ResourceLocation id = ForgeRegistries.ITEMS.getKey(stack.getItem());
|
ResourceLocation id = ForgeRegistries.ITEMS.getKey(stack.getItem());
|
||||||
if (id == null) return false;
|
if (id == null) return false;
|
||||||
|
|
2
src/main/java/io/p2vman/vmodextras/IValidator.java → src/main/java/space/eptaproject/vmodextras/IValidator.java
Executable file → Normal file
2
src/main/java/io/p2vman/vmodextras/IValidator.java → src/main/java/space/eptaproject/vmodextras/IValidator.java
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
||||||
package io.p2vman.vmodextras;
|
package space.eptaproject.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;
|
8
src/main/java/io/p2vman/vmodextras/Validator.java → src/main/java/space/eptaproject/vmodextras/Validator.java
Executable file → Normal file
8
src/main/java/io/p2vman/vmodextras/Validator.java → src/main/java/space/eptaproject/vmodextras/Validator.java
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
||||||
package io.p2vman.vmodextras;
|
package space.eptaproject.vmodextras;
|
||||||
|
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -8,12 +8,11 @@ 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 io.p2vman.vmodextras.util.ResourceLocationUtil;
|
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
public class Validator implements IValidator {
|
public class Validator implements IValidator {
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger("Validator");
|
public static final Logger LOGGER = LoggerFactory.getLogger("Validator");
|
||||||
public static ResourceLocation RB = ResourceLocationUtil.fromNamespaceAndPath(VmodExtras.MODID, "example_block");
|
public static ResourceLocation RB = ResourceLocation.fromNamespaceAndPath(VmodExtras.MODID, "example_block");
|
||||||
|
|
||||||
public Validator() {
|
public Validator() {
|
||||||
|
|
||||||
|
@ -21,7 +20,8 @@ public class Validator implements IValidator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valid(Block block, ResourceLocation location, CallbackInfoReturnable<BlockState> info) {
|
public void valid(Block block, ResourceLocation location, CallbackInfoReturnable<BlockState> info) {
|
||||||
if (Config.parsedList.contains(location) && Config.Schematic_Blocked_Blocks_Enable) {
|
LOGGER.info(location.toString());
|
||||||
|
if (Config.parsedList.contains(location)) {
|
||||||
Block replacement = ForgeRegistries.BLOCKS.getValue(Config.replace);
|
Block replacement = ForgeRegistries.BLOCKS.getValue(Config.replace);
|
||||||
if (replacement != null) {
|
if (replacement != null) {
|
||||||
info.setReturnValue(replacement.defaultBlockState());
|
info.setReturnValue(replacement.defaultBlockState());
|
|
@ -0,0 +1,127 @@
|
||||||
|
package space.eptaproject.vmodextras;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.item.*;
|
||||||
|
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.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
|
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
import net.minecraftforge.registries.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import space.eptaproject.vmodextras.block.CompactBackupBlock;
|
||||||
|
import space.eptaproject.vmodextras.block.CompactBackupBlockEntity;
|
||||||
|
import space.eptaproject.vmodextras.block.TrackBackupBlock;
|
||||||
|
import space.eptaproject.vmodextras.block.TrackBackupBlockEntity;
|
||||||
|
import space.eptaproject.vmodextras.util.ModRegistry;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Mod(VmodExtras.MODID)
|
||||||
|
public class VmodExtras {
|
||||||
|
public static final String MODID = "vmodextras";
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
|
|
||||||
|
public static final RegistryObject<Block> SHIP_VOID_BLOCK;
|
||||||
|
public static final RegistryObject<Block> TRAK_BUK;
|
||||||
|
public static final RegistryObject<Block> COMPACT_BACKUP;
|
||||||
|
|
||||||
|
public static final RegistryObject<BlockEntityType<TrackBackupBlockEntity>> MY_BLOCK_ENTITY;
|
||||||
|
public static final RegistryObject<BlockEntityType<CompactBackupBlockEntity>> COMPACT_BACKUP_BLOCK_ENTITY;
|
||||||
|
|
||||||
|
public static RegistryObject<Item> MY_BLOCK_ITEM;
|
||||||
|
public static RegistryObject<Item> SHIP_VOID_ITEM;
|
||||||
|
public static RegistryObject<Item> COMPACT_BACKUP_ITEM;
|
||||||
|
|
||||||
|
|
||||||
|
public static final ModRegistry REGISTRY;
|
||||||
|
|
||||||
|
public static final RegistryObject<CreativeModeTab> EXAMPLE_TAB;
|
||||||
|
|
||||||
|
static {
|
||||||
|
REGISTRY = new ModRegistry(MODID);
|
||||||
|
|
||||||
|
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)));
|
||||||
|
COMPACT_BACKUP = REGISTRY.BLOCKS.register("compact_backup", () -> new CompactBackupBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||||
|
|
||||||
|
MY_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("track_backup", () -> BlockEntityType.Builder.of(TrackBackupBlockEntity::new, TRAK_BUK.get()).build(null));
|
||||||
|
COMPACT_BACKUP_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("compact_backup", () -> BlockEntityType.Builder.of(CompactBackupBlockEntity::new, COMPACT_BACKUP.get()).build(null));
|
||||||
|
|
||||||
|
EXAMPLE_TAB = REGISTRY.TabBuilder()
|
||||||
|
.push((registry) -> {
|
||||||
|
MY_BLOCK_ITEM = registry.register("track_backup", () -> new BlockItem(TRAK_BUK.get(), new Item.Properties()));
|
||||||
|
SHIP_VOID_ITEM = registry.register("ship_void", () -> new BlockItem(SHIP_VOID_BLOCK.get(), new Item.Properties()));
|
||||||
|
COMPACT_BACKUP_ITEM = registry.register("compact_backup", () -> new BlockItem(COMPACT_BACKUP.get(), new Item.Properties()));
|
||||||
|
})
|
||||||
|
.build("vmodetras", Items.BEDROCK.getDefaultInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
public VmodExtras() {
|
||||||
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
|
||||||
|
modEventBus.addListener(this::commonSetup);
|
||||||
|
|
||||||
|
REGISTRY.register(modEventBus);
|
||||||
|
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_CONFIG);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void commonSetup(final FMLCommonSetupEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
|
public static class ModConfigHandler {
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onConfigReload(ModConfigEvent event) {
|
||||||
|
if (event.getConfig().getSpec() == Config.COMMON_CONFIG) {
|
||||||
|
Config.bake();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||||
|
public static class InteractionHandler {
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
|
||||||
|
if (Config.contains(event.getItemStack())) {
|
||||||
|
event.setCanceled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) {
|
||||||
|
if (Config.contains(event.getItemStack())) {
|
||||||
|
event.setCanceled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event) {
|
||||||
|
if (Config.contains(event.getItemStack())) {
|
||||||
|
event.setCanceled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
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 space.eptaproject.vmodextras.VmodExtras;
|
||||||
|
|
||||||
|
public class CompactBackupBlock extends Block implements IBE<CompactBackupBlockEntity> {
|
||||||
|
|
||||||
|
public CompactBackupBlock(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockEntityType<? extends CompactBackupBlockEntity> getBlockEntityType() {
|
||||||
|
return VmodExtras.COMPACT_BACKUP_BLOCK_ENTITY.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<CompactBackupBlockEntity> getBlockEntityClass() {
|
||||||
|
return CompactBackupBlockEntity.class;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,138 @@
|
||||||
|
package space.eptaproject.vmodextras.block;
|
||||||
|
|
||||||
|
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.world.level.block.Rotation;
|
||||||
|
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.mod.common.VSGameUtilsKt;
|
||||||
|
import space.eptaproject.vmodextras.trackwork.IPhysicsTrackController;
|
||||||
|
import space.eptaproject.vmodextras.trackwork.ISimpleWheelController;
|
||||||
|
import space.eptaproject.vmodextras.VmodExtras;
|
||||||
|
|
||||||
|
|
||||||
|
public class CompactBackupBlockEntity extends BlockEntity {
|
||||||
|
private CompoundTag pendingBackupData;
|
||||||
|
|
||||||
|
public CompactBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
||||||
|
super(VmodExtras.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);
|
||||||
|
IPhysicsTrackController controller = (IPhysicsTrackController) physicsTrackController;
|
||||||
|
if (physicsTrackController != null) {
|
||||||
|
CompoundTag PhysicsTrackControllerTag = new CompoundTag();
|
||||||
|
|
||||||
|
PhysicsTrackControllerTag.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());
|
||||||
|
|
||||||
|
PhysicsTrackControllerTag.put("suspensionAdjust", suspensionAdjust);
|
||||||
|
}
|
||||||
|
|
||||||
|
tag.put("PhysicsTrackController", PhysicsTrackControllerTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SimpleWheelController simpleWheelController = ship.getAttachment(SimpleWheelController.class);
|
||||||
|
ISimpleWheelController controller = (ISimpleWheelController) simpleWheelController;
|
||||||
|
if (simpleWheelController != null) {
|
||||||
|
CompoundTag SimpleWheelControllerTag = new CompoundTag();
|
||||||
|
|
||||||
|
SimpleWheelControllerTag.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());
|
||||||
|
|
||||||
|
SimpleWheelControllerTag.put("suspensionAdjust", suspensionAdjust);
|
||||||
|
}
|
||||||
|
|
||||||
|
tag.put("SimpleWheelController", SimpleWheelControllerTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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")) {
|
||||||
|
CompoundTag L = tag.getCompound("SimpleWheelController");
|
||||||
|
SimpleWheelController controller2 = SimpleWheelController.getOrCreate(ship);
|
||||||
|
if (L.contains("SuspensionStiffness")) {
|
||||||
|
((ISimpleWheelController) controller2).setSuspensionStiffness(L.getFloat("SuspensionStiffness"));
|
||||||
|
}
|
||||||
|
if (L.contains("suspensionAdjust")) {
|
||||||
|
CompoundTag suspensionAdjust = L.getCompound("suspensionAdjust");
|
||||||
|
|
||||||
|
((ISimpleWheelController) controller2).setSuspensionAdjust(new Vector3d(new Vector3d(suspensionAdjust.getDouble("x"), suspensionAdjust.getDouble("y"), suspensionAdjust.getDouble("z"))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.contains("PhysicsTrackController")) {
|
||||||
|
CompoundTag L = tag.getCompound("PhysicsTrackController");
|
||||||
|
PhysicsTrackController controller = PhysicsTrackController.getOrCreate(ship);
|
||||||
|
if (L.contains("SuspensionStiffness")) {
|
||||||
|
((IPhysicsTrackController) controller).setSuspensionStiffness(L.getFloat("SuspensionStiffness"));
|
||||||
|
}
|
||||||
|
if (L.contains("suspensionAdjust")) {
|
||||||
|
CompoundTag suspensionAdjust = L.getCompound("suspensionAdjust");
|
||||||
|
|
||||||
|
|
||||||
|
((IPhysicsTrackController) controller).setSuspensionAdjust(new Vector3d(suspensionAdjust.getDouble("x"), suspensionAdjust.getDouble("y"), suspensionAdjust.getDouble("z")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
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 space.eptaproject.vmodextras.VmodExtras;
|
||||||
|
|
||||||
|
public class TrackBackupBlock extends Block implements IBE<TrackBackupBlockEntity> {
|
||||||
|
|
||||||
|
public TrackBackupBlock(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockEntityType<? extends TrackBackupBlockEntity> getBlockEntityType() {
|
||||||
|
return VmodExtras.MY_BLOCK_ENTITY.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<TrackBackupBlockEntity> getBlockEntityClass() {
|
||||||
|
return TrackBackupBlockEntity.class;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
package space.eptaproject.vmodextras.block;
|
||||||
|
|
||||||
|
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.trackwork.IPhysicsTrackController;
|
||||||
|
import space.eptaproject.vmodextras.trackwork.ISimpleWheelController;
|
||||||
|
import space.eptaproject.vmodextras.VmodExtras;
|
||||||
|
import space.eptaproject.vmodextras.util.IBlockEntityClear;
|
||||||
|
|
||||||
|
public class TrackBackupBlockEntity extends BlockEntity implements IBlockEntityClear {
|
||||||
|
public TrackBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
||||||
|
super(VmodExtras.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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
src/main/java/io/p2vman/vmodextras/mixin/MixinPlugin.java → src/main/java/space/eptaproject/vmodextras/mixin/MixinPlugin.java
Executable file → Normal file
10
src/main/java/io/p2vman/vmodextras/mixin/MixinPlugin.java → src/main/java/space/eptaproject/vmodextras/mixin/MixinPlugin.java
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
||||||
package io.p2vman.vmodextras.mixin;
|
package space.eptaproject.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;
|
||||||
|
@ -30,7 +30,13 @@ public class MixinPlugin implements IMixinConfigPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getMixins() {
|
public List<String> getMixins() {
|
||||||
return List.of();
|
return List.of(
|
||||||
|
"BlockPaletteHashMapV1Mixin",
|
||||||
|
"PhysicsTrackControllerAccessor",
|
||||||
|
"PhysicsTrackControllerMixin",
|
||||||
|
"SimpleWheelControllerAccessor",
|
||||||
|
"SimpleWheelControllerMixin"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
2
src/main/java/io/p2vman/vmodextras/mixin/package-info.java → src/main/java/space/eptaproject/vmodextras/mixin/package-info.java
Executable file → Normal file
2
src/main/java/io/p2vman/vmodextras/mixin/package-info.java → src/main/java/space/eptaproject/vmodextras/mixin/package-info.java
Executable file → Normal file
|
@ -1,4 +1,4 @@
|
||||||
@ApiStatus.Experimental
|
@ApiStatus.Experimental
|
||||||
package io.p2vman.vmodextras.mixin;
|
package space.eptaproject.vmodextras.mixin;
|
||||||
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
|
@ -1,4 +1,4 @@
|
||||||
package io.p2vman.vmodextras.mixins.vmod;
|
package space.eptaproject.vmodextras.mixins;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap;
|
import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap;
|
||||||
|
@ -13,20 +13,20 @@ 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 io.p2vman.vmodextras.IValidator;
|
import space.eptaproject.vmodextras.IValidator;
|
||||||
import io.p2vman.vmodextras.Validator;
|
import space.eptaproject.vmodextras.Validator;
|
||||||
|
|
||||||
@Mixin(BlockPaletteHashMapV1.class)
|
@Mixin(BlockPaletteHashMapV1.class)
|
||||||
public class BlockPaletteHashMapV1Mixin {
|
public class BlockPaletteHashMapV1Mixin {
|
||||||
@Unique
|
@Unique
|
||||||
public final IValidator vmodextras$validator = new Validator();
|
public final IValidator validator = new Validator();
|
||||||
|
|
||||||
@Shadow(remap = false)
|
@Shadow
|
||||||
private @Mutable CrudeIncrementalIntIdentityHashBiMap<BlockState> statePaletteMap;
|
private @Mutable CrudeIncrementalIntIdentityHashBiMap statePaletteMap;
|
||||||
|
|
||||||
@Inject(method = "fromId", at = @At("RETURN"), remap = false, cancellable = true)
|
@Inject(method = "fromId", at = @At("RETURN"), remap = false, cancellable = true)
|
||||||
private void vmodaddon$fromId(int id, CallbackInfoReturnable<BlockState> cir) {
|
private void vmodaddon$fromId(int id, CallbackInfoReturnable<BlockState> cir) {
|
||||||
BlockState blockState = this.statePaletteMap.byId(id);
|
BlockState blockState = (BlockState)this.statePaletteMap.byId(id);
|
||||||
if (blockState == null || blockState.isAir()) {
|
if (blockState == null || blockState.isAir()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public class BlockPaletteHashMapV1Mixin {
|
||||||
ResourceLocation location = ForgeRegistries.BLOCKS.getKey(block);
|
ResourceLocation location = ForgeRegistries.BLOCKS.getKey(block);
|
||||||
CallbackInfoReturnable<BlockState> info = new CallbackInfoReturnable<>("blockstate-validator", true);
|
CallbackInfoReturnable<BlockState> info = new CallbackInfoReturnable<>("blockstate-validator", true);
|
||||||
try {
|
try {
|
||||||
vmodextras$validator.valid(block, location, info);
|
validator.valid(block, location, info);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Validator.LOGGER.error("Error validating: {}", location, e);
|
Validator.LOGGER.error("Error validating: {}", location, e);
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package io.p2vman.vmodextras.mixins.trackwork;
|
package space.eptaproject.vmodextras.mixins;
|
||||||
|
|
||||||
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 io.p2vman.vmodextras.mixins.trackwork;
|
package space.eptaproject.vmodextras.mixins;
|
||||||
|
|
||||||
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,13 +6,13 @@ 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 io.p2vman.vmodextras.Config;
|
import space.eptaproject.vmodextras.Config;
|
||||||
import io.p2vman.vmodextras.trackwork.IPhysicsTrackController;
|
import space.eptaproject.vmodextras.trackwork.IPhysicsTrackController;
|
||||||
|
|
||||||
@Mixin(PhysicsTrackController.class)
|
@Mixin(PhysicsTrackController.class)
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public abstract class PhysicsTrackControllerMixin implements IPhysicsTrackController {
|
public abstract class PhysicsTrackControllerMixin implements IPhysicsTrackController {
|
||||||
@Shadow(remap = false) private volatile float suspensionStiffness;
|
@Shadow private volatile float suspensionStiffness;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author
|
* @author
|
|
@ -1,4 +1,4 @@
|
||||||
package io.p2vman.vmodextras.mixins.trackwork;
|
package space.eptaproject.vmodextras.mixins;
|
||||||
|
|
||||||
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 io.p2vman.vmodextras.mixins.trackwork;
|
package space.eptaproject.vmodextras.mixins;
|
||||||
|
|
||||||
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,13 +6,13 @@ 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 io.p2vman.vmodextras.Config;
|
import space.eptaproject.vmodextras.Config;
|
||||||
import io.p2vman.vmodextras.trackwork.ISimpleWheelController;
|
import space.eptaproject.vmodextras.trackwork.ISimpleWheelController;
|
||||||
|
|
||||||
@Mixin(SimpleWheelController.class)
|
@Mixin(SimpleWheelController.class)
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public abstract class SimpleWheelControllerMixin implements ISimpleWheelController {
|
public abstract class SimpleWheelControllerMixin implements ISimpleWheelController {
|
||||||
@Shadow(remap = false) private volatile float suspensionStiffness;
|
@Shadow private volatile float suspensionStiffness;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author
|
* @author
|
|
@ -1,4 +1,4 @@
|
||||||
package io.p2vman.vmodextras.mixins.trackwork;
|
package space.eptaproject.vmodextras.mixins;
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.items.TrackToolkit;
|
import edn.stratodonut.trackwork.items.TrackToolkit;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
|
@ -0,0 +1,39 @@
|
||||||
|
package space.eptaproject.vmodextras.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")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package space.eptaproject.vmodextras.trackwork;
|
||||||
|
|
||||||
|
import space.eptaproject.vmodextras.mixins.PhysicsTrackControllerAccessor;
|
||||||
|
|
||||||
|
public interface IPhysicsTrackController extends PhysicsTrackControllerAccessor, IController {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package space.eptaproject.vmodextras.trackwork;
|
||||||
|
|
||||||
|
import space.eptaproject.vmodextras.mixins.SimpleWheelControllerAccessor;
|
||||||
|
|
||||||
|
public interface ISimpleWheelController extends SimpleWheelControllerAccessor, IController {
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package space.eptaproject.vmodextras.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 +1,4 @@
|
||||||
package io.p2vman.vmodextras.trackwork;
|
package space.eptaproject.vmodextras.util;
|
||||||
|
|
||||||
public interface IBlockEntityClear {
|
public interface IBlockEntityClear {
|
||||||
boolean clear();
|
boolean clear();
|
|
@ -0,0 +1,77 @@
|
||||||
|
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,6 +1,3 @@
|
||||||
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 = "BOTH"
|
side = "SERVER"
|
||||||
[[dependencies."${mod_id}"]]
|
[[dependencies."${mod_id}"]]
|
||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
mandatory = true
|
mandatory = true
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"variants": {
|
|
||||||
"": { "model": "vmodextras:block/compact_backup" }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"variants": {
|
|
||||||
"": { "model": "vmodextras:block/track_work_controller" }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": {
|
|
||||||
"all": "vmodextras:block/compact_backup"
|
|
||||||
}
|
|
||||||
}
|
|
51
src/main/resources/assets/vmodextras/models/block/track_backup.json
Executable file → Normal file
51
src/main/resources/assets/vmodextras/models/block/track_backup.json
Executable file → Normal file
|
@ -1,6 +1,53 @@
|
||||||
{
|
{
|
||||||
"parent": "block/cube_all",
|
"credit": "Made with Blockbench",
|
||||||
|
"texture_size": [64, 64],
|
||||||
"textures": {
|
"textures": {
|
||||||
"all": "vmodextras:block/track_backup"
|
"1": "vmodextras:block/track_backup",
|
||||||
|
"particle": "vmodextras:block/track_backup"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"from": [0, 0, 0],
|
||||||
|
"to": [16, 16, 16],
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [4, 0, 8, 4], "texture": "#1"},
|
||||||
|
"east": {"uv": [4, 0, 8, 4], "texture": "#1"},
|
||||||
|
"south": {"uv": [4, 0, 8, 4], "texture": "#1"},
|
||||||
|
"west": {"uv": [4, 0, 8, 4], "texture": "#1"},
|
||||||
|
"up": {"uv": [8, 4, 4, 0], "texture": "#1"},
|
||||||
|
"down": {"uv": [8, 0, 4, 4], "texture": "#1"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"display": {
|
||||||
|
"thirdperson_righthand": {
|
||||||
|
"rotation": [75, 45, 0],
|
||||||
|
"translation": [0, 2.5, 0],
|
||||||
|
"scale": [0.375, 0.375, 0.375]
|
||||||
|
},
|
||||||
|
"thirdperson_lefthand": {
|
||||||
|
"rotation": [75, 45, 0],
|
||||||
|
"translation": [0, 2.5, 0],
|
||||||
|
"scale": [0.375, 0.375, 0.375]
|
||||||
|
},
|
||||||
|
"firstperson_righthand": {
|
||||||
|
"rotation": [0, 45, 0],
|
||||||
|
"scale": [0.4, 0.4, 0.4]
|
||||||
|
},
|
||||||
|
"firstperson_lefthand": {
|
||||||
|
"rotation": [0, 225, 0],
|
||||||
|
"scale": [0.4, 0.4, 0.4]
|
||||||
|
},
|
||||||
|
"ground": {
|
||||||
|
"translation": [0, 3, 0],
|
||||||
|
"scale": [0.25, 0.25, 0.25]
|
||||||
|
},
|
||||||
|
"gui": {
|
||||||
|
"rotation": [30, 225, 0],
|
||||||
|
"scale": [0.625, 0.625, 0.625]
|
||||||
|
},
|
||||||
|
"fixed": {
|
||||||
|
"scale": [0.5, 0.5, 0.5]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": {
|
|
||||||
"all": "vmodextras:block/track_work_controller"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": {
|
|
||||||
"all": "vmodextras:block/compact_backup"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,53 @@
|
||||||
{
|
{
|
||||||
"parent": "block/cube_all",
|
"credit": "Made with Blockbench",
|
||||||
|
"texture_size": [64, 64],
|
||||||
"textures": {
|
"textures": {
|
||||||
"all": "vmodextras:block/track_backup"
|
"1": "vmodextras:block/track_backup",
|
||||||
|
"particle": "vmodextras:block/track_backup"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"from": [0, 0, 0],
|
||||||
|
"to": [16, 16, 16],
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [4, 0, 8, 4], "texture": "#1"},
|
||||||
|
"east": {"uv": [4, 0, 8, 4], "texture": "#1"},
|
||||||
|
"south": {"uv": [4, 0, 8, 4], "texture": "#1"},
|
||||||
|
"west": {"uv": [4, 0, 8, 4], "texture": "#1"},
|
||||||
|
"up": {"uv": [8, 4, 4, 0], "texture": "#1"},
|
||||||
|
"down": {"uv": [8, 0, 4, 4], "texture": "#1"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"display": {
|
||||||
|
"thirdperson_righthand": {
|
||||||
|
"rotation": [75, 45, 0],
|
||||||
|
"translation": [0, 2.5, 0],
|
||||||
|
"scale": [0.375, 0.375, 0.375]
|
||||||
|
},
|
||||||
|
"thirdperson_lefthand": {
|
||||||
|
"rotation": [75, 45, 0],
|
||||||
|
"translation": [0, 2.5, 0],
|
||||||
|
"scale": [0.375, 0.375, 0.375]
|
||||||
|
},
|
||||||
|
"firstperson_righthand": {
|
||||||
|
"rotation": [0, 45, 0],
|
||||||
|
"scale": [0.4, 0.4, 0.4]
|
||||||
|
},
|
||||||
|
"firstperson_lefthand": {
|
||||||
|
"rotation": [0, 225, 0],
|
||||||
|
"scale": [0.4, 0.4, 0.4]
|
||||||
|
},
|
||||||
|
"ground": {
|
||||||
|
"translation": [0, 3, 0],
|
||||||
|
"scale": [0.25, 0.25, 0.25]
|
||||||
|
},
|
||||||
|
"gui": {
|
||||||
|
"rotation": [30, 225, 0],
|
||||||
|
"scale": [0.625, 0.625, 0.625]
|
||||||
|
},
|
||||||
|
"fixed": {
|
||||||
|
"scale": [0.5, 0.5, 0.5]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"parent": "block/cube_all",
|
|
||||||
"textures": {
|
|
||||||
"all": "vmodextras:block/track_work_controller"
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 170 B |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue