Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
|
5259407e37 | |
|
8b9e20be2c |
|
@ -36,5 +36,10 @@
|
||||||
<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>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -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.4.1" />
|
<option name="platformVersion" value="47.3.5" />
|
||||||
<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.4.1" />
|
<option name="platformVersion" value="47.3.5" />
|
||||||
<option name="srgType" value="TSRG" />
|
<option name="srgType" value="TSRG" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -153,6 +153,8 @@ repositories {
|
||||||
maven {
|
maven {
|
||||||
url = uri("https://maven.tterrag.com/releases")
|
url = uri("https://maven.tterrag.com/releases")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maven { url 'https://squiddev.cc/maven/' }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -206,6 +208,8 @@ 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")
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.4.1
|
forge_version=47.3.5
|
||||||
forge_version_range=[47,)
|
forge_version_range=[47,)
|
||||||
loader_version_range=[47,)
|
loader_version_range=[47,)
|
||||||
mapping_channel=official
|
mapping_channel=official
|
||||||
|
|
|
@ -18,9 +18,14 @@ 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;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
||||||
|
@ -42,6 +47,9 @@ public class Config {
|
||||||
Validator.RB.toString()
|
Validator.RB.toString()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Schematic_Blocked_Blocks = builder
|
||||||
|
.define("enable", false);
|
||||||
|
|
||||||
|
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
|
@ -55,6 +63,9 @@ 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");
|
||||||
|
@ -74,20 +85,14 @@ public class Config {
|
||||||
|
|
||||||
public static void bake() {
|
public static void bake() {
|
||||||
parsedList = RESOURCE_LOCATION_LIST.get().stream()
|
parsedList = RESOURCE_LOCATION_LIST.get().stream()
|
||||||
.map(s -> {
|
.map(ResourceLocation::tryParse)
|
||||||
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.parse(s);
|
ResourceLocation location = ResourceLocation.tryParse(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;
|
||||||
|
@ -96,15 +101,17 @@ public class Config {
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.toList());
|
.toList());
|
||||||
try {
|
try {
|
||||||
replace = ResourceLocation.parse(RESOURCE_LOCATION.get());
|
replace = new ResourceLocation(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();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean contains(ItemStack stack) {
|
public static boolean contains(ItemStack stack) {
|
||||||
if (stack.isEmpty()) return false;
|
if (stack.isEmpty() || !Inventory_Blocked_Blocks_Enable) 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;
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,12 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
import space.eptaproject.vmodextras.util.ResourceLocationUtil;
|
||||||
|
|
||||||
@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 = ResourceLocation.fromNamespaceAndPath(VmodExtras.MODID, "example_block");
|
public static ResourceLocation RB = ResourceLocationUtil.fromNamespaceAndPath(VmodExtras.MODID, "example_block");
|
||||||
|
|
||||||
public Validator() {
|
public Validator() {
|
||||||
|
|
||||||
|
@ -20,8 +21,7 @@ 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) {
|
||||||
LOGGER.info(location.toString());
|
if (Config.parsedList.contains(location) && Config.Schematic_Blocked_Blocks_Enable) {
|
||||||
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());
|
||||||
|
|
|
@ -1,84 +1,63 @@
|
||||||
package space.eptaproject.vmodextras;
|
package space.eptaproject.vmodextras;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.common.base.VerifyException;
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.item.*;
|
import net.minecraft.world.item.*;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
import net.minecraft.world.level.material.MapColor;
|
import net.minecraft.world.level.material.MapColor;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
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.common.Mod;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.minecraftforge.registries.*;
|
import net.minecraftforge.registries.*;
|
||||||
|
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import space.eptaproject.vmodextras.block.CompactBackupBlock;
|
import space.eptaproject.vmodextras.block.*;
|
||||||
import space.eptaproject.vmodextras.block.CompactBackupBlockEntity;
|
import space.eptaproject.vmodextras.compact.Compact;
|
||||||
import space.eptaproject.vmodextras.block.TrackBackupBlock;
|
|
||||||
import space.eptaproject.vmodextras.block.TrackBackupBlockEntity;
|
|
||||||
import space.eptaproject.vmodextras.util.ModRegistry;
|
import space.eptaproject.vmodextras.util.ModRegistry;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Mod(VmodExtras.MODID)
|
@Mod(VmodExtras.MODID)
|
||||||
public class VmodExtras {
|
public class VmodExtras {
|
||||||
public static final String MODID = "vmodextras";
|
public static final String MODID = "vmodextras";
|
||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
|
public static RegistryObject<BlockEntityType<EntityBackupBlockEntity>> ENTITY_BACKUP_BLOCK_ENTITY;
|
||||||
public static final RegistryObject<Block> SHIP_VOID_BLOCK;
|
public static RegistryObject<Block> ENTITY_BACKUP;
|
||||||
public static final RegistryObject<Block> TRAK_BUK;
|
public static RegistryObject<Item> ENTITY_BACKUP_ITEM;
|
||||||
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 ModRegistry REGISTRY;
|
||||||
|
|
||||||
public static final RegistryObject<CreativeModeTab> EXAMPLE_TAB;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
REGISTRY = new ModRegistry(MODID);
|
REGISTRY = new ModRegistry(MODID);
|
||||||
|
|
||||||
TRAK_BUK = REGISTRY.BLOCKS.register("track_backup", () -> new TrackBackupBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
ENTITY_BACKUP = REGISTRY.BLOCKS.register("entity_backup", () -> new EntityBackupBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||||
SHIP_VOID_BLOCK = REGISTRY.BLOCKS.register("ship_void", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
ENTITY_BACKUP_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("entity_backup", () -> BlockEntityType.Builder.of(EntityBackupBlockEntity::new, ENTITY_BACKUP.get()).build(null));
|
||||||
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));
|
new Compact((REGISTRY, builder) -> {
|
||||||
COMPACT_BACKUP_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("compact_backup", () -> BlockEntityType.Builder.of(CompactBackupBlockEntity::new, COMPACT_BACKUP.get()).build(null));
|
builder.push((registry) -> {
|
||||||
|
ENTITY_BACKUP_ITEM = registry.register("entity_backup", () -> new BlockItem(ENTITY_BACKUP.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String MIN_FORGE_VERSION = "47.3.5";
|
||||||
|
|
||||||
public VmodExtras() {
|
public VmodExtras() {
|
||||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
|
||||||
modEventBus.addListener(this::commonSetup);
|
modEventBus.addListener(this::commonSetup);
|
||||||
|
|
||||||
REGISTRY.register(modEventBus);
|
REGISTRY.register(modEventBus);
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
@ -87,6 +66,46 @@ public class VmodExtras {
|
||||||
|
|
||||||
|
|
||||||
private void commonSetup(final FMLCommonSetupEvent event) {
|
private void commonSetup(final FMLCommonSetupEvent event) {
|
||||||
|
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)
|
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
|
@ -99,7 +118,7 @@ public class VmodExtras {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
|
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.DEDICATED_SERVER)
|
||||||
public static class InteractionHandler {
|
public static class InteractionHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -1,138 +0,0 @@
|
||||||
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 net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
|
import space.eptaproject.vmodextras.VmodExtras;
|
||||||
|
|
||||||
|
public class EntityBackupBlock extends Block implements IBE<EntityBackupBlockEntity> {
|
||||||
|
public EntityBackupBlock(BlockBehaviour.Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockEntityType<? extends EntityBackupBlockEntity> getBlockEntityType() {
|
||||||
|
return VmodExtras.ENTITY_BACKUP_BLOCK_ENTITY.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<EntityBackupBlockEntity> getBlockEntityClass() {
|
||||||
|
return EntityBackupBlockEntity.class;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package space.eptaproject.vmodextras.block;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import org.valkyrienskies.core.api.ships.ServerShip;
|
||||||
|
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
||||||
|
import space.eptaproject.vmodextras.VmodExtras;
|
||||||
|
|
||||||
|
|
||||||
|
public class EntityBackupBlockEntity extends BlockEntity {
|
||||||
|
public EntityBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
||||||
|
super(VmodExtras.ENTITY_BACKUP_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(CompoundTag tag) {
|
||||||
|
super.load(tag);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveAdditional(CompoundTag tag) {
|
||||||
|
super.saveAdditional(tag);
|
||||||
|
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipManagingPos(this.level, this.getBlockPos());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package space.eptaproject.vmodextras.compact;
|
||||||
|
|
||||||
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
import space.eptaproject.vmodextras.VmodExtras;
|
||||||
|
import space.eptaproject.vmodextras.compact.computercraft.ComputerCraftCompact;
|
||||||
|
import space.eptaproject.vmodextras.compact.trackwork.TrackWorkCompact;
|
||||||
|
import space.eptaproject.vmodextras.util.ModRegistry;
|
||||||
|
import space.eptaproject.vmodextras.util.Utils;
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package space.eptaproject.vmodextras.compact.computercraft;
|
||||||
|
|
||||||
|
import net.minecraft.world.item.BlockItem;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.Rarity;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
|
import net.minecraft.world.level.material.MapColor;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
import space.eptaproject.vmodextras.compact.computercraft.block.TrackWorkController;
|
||||||
|
import space.eptaproject.vmodextras.compact.computercraft.block.entity.TrackWorkControllerEntity;
|
||||||
|
import space.eptaproject.vmodextras.util.ModRegistry;
|
||||||
|
import space.eptaproject.vmodextras.util.Utils;
|
||||||
|
|
||||||
|
public class ComputerCraftCompact {
|
||||||
|
public static RegistryObject<BlockEntityType<TrackWorkControllerEntity>> TRACK_WORK_CONTROLLER_BLOCK_ENTITY;
|
||||||
|
|
||||||
|
public static RegistryObject<Block> TRACK_WORK_CONTROLLER_BLOCK;
|
||||||
|
public static RegistryObject<Item> TRACK_WORK_CONTROLLER_ITEM;
|
||||||
|
|
||||||
|
public static void init(ModRegistry REGISTRY, ModRegistry.TabBuilder builder) {
|
||||||
|
Utils.executeIsModEnable("trackwork", () -> {
|
||||||
|
TRACK_WORK_CONTROLLER_BLOCK = REGISTRY.BLOCKS.register("track_work_controller", () -> new TrackWorkController(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||||
|
TRACK_WORK_CONTROLLER_BLOCK_ENTITY = REGISTRY.BLOCK_ENTITIES.register("track_work_controller", () -> BlockEntityType.Builder.of(TrackWorkControllerEntity::new, TRACK_WORK_CONTROLLER_BLOCK.get()).build(null));
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.push((registry) -> {
|
||||||
|
Utils.executeIsModEnable("trackwork", () -> {
|
||||||
|
TRACK_WORK_CONTROLLER_ITEM = registry.register("track_work_controller", () -> new BlockItem(TRACK_WORK_CONTROLLER_BLOCK.get(), new Item.Properties().rarity(Rarity.EPIC)));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package space.eptaproject.vmodextras.compact.computercraft.block;
|
||||||
|
|
||||||
|
import com.simibubi.create.foundation.block.IBE;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import space.eptaproject.vmodextras.compact.computercraft.ComputerCraftCompact;
|
||||||
|
import space.eptaproject.vmodextras.compact.computercraft.block.entity.TrackWorkControllerEntity;
|
||||||
|
|
||||||
|
public class TrackWorkController extends Block implements IBE<TrackWorkControllerEntity> {
|
||||||
|
public TrackWorkController(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockEntityType<? extends TrackWorkControllerEntity> getBlockEntityType() {
|
||||||
|
return ComputerCraftCompact.TRACK_WORK_CONTROLLER_BLOCK_ENTITY.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<TrackWorkControllerEntity> getBlockEntityClass() {
|
||||||
|
return TrackWorkControllerEntity.class;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package space.eptaproject.vmodextras.compact.computercraft.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 space.eptaproject.vmodextras.compact.computercraft.ComputerCraftCompact;
|
||||||
|
import space.eptaproject.vmodextras.compact.computercraft.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();
|
||||||
|
peripheralCap.invalidate();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package space.eptaproject.vmodextras.compact.computercraft.peripheral;
|
||||||
|
|
||||||
|
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||||
|
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PeripheralBase implements IPeripheral {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package space.eptaproject.vmodextras.compact.computercraft.peripheral;
|
||||||
|
|
||||||
|
import dan200.computercraft.api.lua.*;
|
||||||
|
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2DoubleArrayMap;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2DoubleMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.joml.Vector3dc;
|
||||||
|
import org.valkyrienskies.core.api.ships.ServerShip;
|
||||||
|
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
||||||
|
import space.eptaproject.vmodextras.compact.computercraft.block.entity.TrackWorkControllerEntity;
|
||||||
|
import space.eptaproject.vmodextras.compact.trackwork.ISimpleWheelController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class TrackWorkControllerPeripheral extends PeripheralBase {
|
||||||
|
private TrackWorkControllerEntity entity;
|
||||||
|
|
||||||
|
public static class Controller<T> {
|
||||||
|
private final Class<T> contoller;
|
||||||
|
private Controller(Class<T> contoller) {
|
||||||
|
this.contoller = contoller;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<T> getContoller() {
|
||||||
|
return contoller;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T get(ServerShip ship) {
|
||||||
|
Objects.requireNonNull(ship);
|
||||||
|
T t = ship.getAttachment(contoller);
|
||||||
|
if (t == null) {
|
||||||
|
try {
|
||||||
|
t = contoller.getDeclaredConstructor().newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Objects.requireNonNull(t);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final List<Controller<?>> DEFS = new ObjectArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TrackWorkControllerPeripheral(TrackWorkControllerEntity entity) {
|
||||||
|
super("track_work_controller");
|
||||||
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction
|
||||||
|
public final void SetSuspensionAdjust(IArguments arguments) throws LuaException {
|
||||||
|
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(this.entity.getLevel(), this.entity.getBlockPos());
|
||||||
|
if (ship != null) {
|
||||||
|
((ISimpleWheelController) SimpleWheelController.getOrCreate(ship)).setSuspensionAdjust(new Vector3d(
|
||||||
|
Math.max(Math.min(arguments.getDouble(0), 1d), 0d),
|
||||||
|
Math.max(Math.min(arguments.getDouble(1), 1.3d), 0.5d),
|
||||||
|
Math.max(Math.min(arguments.getDouble(2), 1d), 0d)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction
|
||||||
|
public final MethodResult GetSuspensionAdjust(IArguments arguments) throws LuaException {
|
||||||
|
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(this.entity.getLevel(), this.entity.getBlockPos());
|
||||||
|
if (ship != null) {
|
||||||
|
Vector3dc vec =((ISimpleWheelController) SimpleWheelController.getOrCreate(ship)).getSuspensionAdjust();
|
||||||
|
Int2DoubleMap map = new Int2DoubleArrayMap();
|
||||||
|
map.put(1, vec.x());
|
||||||
|
map.put(2, vec.y());
|
||||||
|
map.put(3, vec.z());
|
||||||
|
return MethodResult.of(new ObjectLuaTable(map));
|
||||||
|
}
|
||||||
|
|
||||||
|
return MethodResult.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
@LuaFunction
|
||||||
|
public final MethodResult GetMeta(IArguments arguments) throws LuaException {
|
||||||
|
return MethodResult.of();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.util;
|
package space.eptaproject.vmodextras.compact.trackwork;
|
||||||
|
|
||||||
public interface IBlockEntityClear {
|
public interface IBlockEntityClear {
|
||||||
boolean clear();
|
boolean clear();
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.trackwork;
|
package space.eptaproject.vmodextras.compact.trackwork;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
|
@ -0,0 +1,7 @@
|
||||||
|
package space.eptaproject.vmodextras.compact.trackwork;
|
||||||
|
|
||||||
|
import space.eptaproject.vmodextras.mixins.trackwork.PhysicsTrackControllerAccessor;
|
||||||
|
|
||||||
|
public interface IPhysicsTrackController extends PhysicsTrackControllerAccessor, IController {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package space.eptaproject.vmodextras.compact.trackwork;
|
||||||
|
|
||||||
|
import space.eptaproject.vmodextras.mixins.trackwork.SimpleWheelControllerAccessor;
|
||||||
|
|
||||||
|
public interface ISimpleWheelController extends SimpleWheelControllerAccessor, IController {
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package space.eptaproject.vmodextras.compact.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 space.eptaproject.vmodextras.compact.trackwork.block.CompactBackupBlock;
|
||||||
|
import space.eptaproject.vmodextras.compact.trackwork.block.TrackBackupBlock;
|
||||||
|
import space.eptaproject.vmodextras.compact.trackwork.block.entity.CompactBackupBlockEntity;
|
||||||
|
import space.eptaproject.vmodextras.compact.trackwork.block.entity.TrackBackupBlockEntity;
|
||||||
|
import space.eptaproject.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,9 +1,10 @@
|
||||||
package space.eptaproject.vmodextras.block;
|
package space.eptaproject.vmodextras.compact.trackwork.block;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.IBE;
|
import com.simibubi.create.foundation.block.IBE;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import space.eptaproject.vmodextras.VmodExtras;
|
import space.eptaproject.vmodextras.compact.trackwork.TrackWorkCompact;
|
||||||
|
import space.eptaproject.vmodextras.compact.trackwork.block.entity.CompactBackupBlockEntity;
|
||||||
|
|
||||||
public class CompactBackupBlock extends Block implements IBE<CompactBackupBlockEntity> {
|
public class CompactBackupBlock extends Block implements IBE<CompactBackupBlockEntity> {
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ public class CompactBackupBlock extends Block implements IBE<CompactBackupBlockE
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockEntityType<? extends CompactBackupBlockEntity> getBlockEntityType() {
|
public BlockEntityType<? extends CompactBackupBlockEntity> getBlockEntityType() {
|
||||||
return VmodExtras.COMPACT_BACKUP_BLOCK_ENTITY.get();
|
return TrackWorkCompact.COMPACT_BACKUP_BLOCK_ENTITY.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -1,9 +1,10 @@
|
||||||
package space.eptaproject.vmodextras.block;
|
package space.eptaproject.vmodextras.compact.trackwork.block;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.block.IBE;
|
import com.simibubi.create.foundation.block.IBE;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import space.eptaproject.vmodextras.VmodExtras;
|
import space.eptaproject.vmodextras.compact.trackwork.TrackWorkCompact;
|
||||||
|
import space.eptaproject.vmodextras.compact.trackwork.block.entity.TrackBackupBlockEntity;
|
||||||
|
|
||||||
public class TrackBackupBlock extends Block implements IBE<TrackBackupBlockEntity> {
|
public class TrackBackupBlock extends Block implements IBE<TrackBackupBlockEntity> {
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ public class TrackBackupBlock extends Block implements IBE<TrackBackupBlockEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockEntityType<? extends TrackBackupBlockEntity> getBlockEntityType() {
|
public BlockEntityType<? extends TrackBackupBlockEntity> getBlockEntityType() {
|
||||||
return VmodExtras.MY_BLOCK_ENTITY.get();
|
return TrackWorkCompact.MY_BLOCK_ENTITY.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -0,0 +1,97 @@
|
||||||
|
package space.eptaproject.vmodextras.compact.trackwork.block.entity;
|
||||||
|
|
||||||
|
import edn.stratodonut.drivebywire.wire.ShipWireNetworkManager;
|
||||||
|
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
||||||
|
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.world.level.block.Rotation;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
|
import org.valkyrienskies.core.api.ships.ServerShip;
|
||||||
|
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
||||||
|
import space.eptaproject.vmodextras.compact.trackwork.TrackWorkCompact;
|
||||||
|
import space.eptaproject.vmodextras.compact.trackwork.IPhysicsTrackController;
|
||||||
|
import space.eptaproject.vmodextras.compact.trackwork.ISimpleWheelController;
|
||||||
|
|
||||||
|
|
||||||
|
public class CompactBackupBlockEntity extends BlockEntity {
|
||||||
|
private CompoundTag pendingBackupData;
|
||||||
|
|
||||||
|
public CompactBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
||||||
|
super(TrackWorkCompact.COMPACT_BACKUP_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void saveAdditional(CompoundTag tag) {
|
||||||
|
super.saveAdditional(tag);
|
||||||
|
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
||||||
|
if (ship != null) {
|
||||||
|
{
|
||||||
|
PhysicsTrackController physicsTrackController = ship.getAttachment(PhysicsTrackController.class);
|
||||||
|
if (physicsTrackController != null) {
|
||||||
|
IPhysicsTrackController controller = (IPhysicsTrackController) physicsTrackController;
|
||||||
|
CompoundTag local = new CompoundTag();
|
||||||
|
|
||||||
|
controller.encode(local);
|
||||||
|
|
||||||
|
tag.put("PhysicsTrackController", local);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SimpleWheelController simpleWheelController = ship.getAttachment(SimpleWheelController.class);
|
||||||
|
if (simpleWheelController != null) {
|
||||||
|
ISimpleWheelController controller = (ISimpleWheelController) simpleWheelController;
|
||||||
|
CompoundTag local = new CompoundTag();
|
||||||
|
|
||||||
|
controller.encode(local);
|
||||||
|
|
||||||
|
tag.put("SimpleWheelController", local);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ship = (ServerShip) VSGameUtilsKt.getShipManagingPos(this.level, this.getBlockPos());
|
||||||
|
|
||||||
|
if (this.level != null) {
|
||||||
|
if (this.pendingBackupData == null) {
|
||||||
|
this.pendingBackupData = new CompoundTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
ShipWireNetworkManager.get(ship).ifPresent((m) -> this.pendingBackupData.merge(m.serialiseToNbt(this.level, this.getBlockPos())));
|
||||||
|
|
||||||
|
if (this.pendingBackupData != null) {
|
||||||
|
tag.put("WireNetwork", this.pendingBackupData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(CompoundTag tag) {
|
||||||
|
super.load(tag);
|
||||||
|
|
||||||
|
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
|
||||||
|
if (ship != null) {
|
||||||
|
if (tag.contains("SimpleWheelController", Tag.TAG_COMPOUND)) {
|
||||||
|
((ISimpleWheelController) SimpleWheelController.getOrCreate(ship)).decode(tag.getCompound("SimpleWheelController"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.contains("PhysicsTrackController", Tag.TAG_COMPOUND)) {
|
||||||
|
((IPhysicsTrackController) PhysicsTrackController.getOrCreate(ship)).decode(tag.getCompound("PhysicsTrackController"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ship = (ServerShip) VSGameUtilsKt.getShipManagingPos(this.level, getBlockPos());
|
||||||
|
if (ship != null) {
|
||||||
|
if (tag.contains("WireNetwork", 10)) {
|
||||||
|
ShipWireNetworkManager.loadIfNotExists(ship, level, tag.getCompound("WireNetwork"), this.getBlockPos(), Rotation.NONE);
|
||||||
|
|
||||||
|
this.pendingBackupData = tag.getCompound("WireNetwork");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.block;
|
package space.eptaproject.vmodextras.compact.trackwork.block.entity;
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
||||||
|
@ -9,14 +9,14 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import org.valkyrienskies.core.api.ships.ServerShip;
|
import org.valkyrienskies.core.api.ships.ServerShip;
|
||||||
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
import org.valkyrienskies.mod.common.VSGameUtilsKt;
|
||||||
import space.eptaproject.vmodextras.trackwork.IPhysicsTrackController;
|
import space.eptaproject.vmodextras.compact.trackwork.TrackWorkCompact;
|
||||||
import space.eptaproject.vmodextras.trackwork.ISimpleWheelController;
|
import space.eptaproject.vmodextras.compact.trackwork.IPhysicsTrackController;
|
||||||
import space.eptaproject.vmodextras.VmodExtras;
|
import space.eptaproject.vmodextras.compact.trackwork.ISimpleWheelController;
|
||||||
import space.eptaproject.vmodextras.util.IBlockEntityClear;
|
import space.eptaproject.vmodextras.compact.trackwork.IBlockEntityClear;
|
||||||
|
|
||||||
public class TrackBackupBlockEntity extends BlockEntity implements IBlockEntityClear {
|
public class TrackBackupBlockEntity extends BlockEntity implements IBlockEntityClear {
|
||||||
public TrackBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
public TrackBackupBlockEntity(BlockPos p_155229_, BlockState p_155230_) {
|
||||||
super(VmodExtras.MY_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
super(TrackWorkCompact.MY_BLOCK_ENTITY.get(), p_155229_, p_155230_);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundTag tag = new CompoundTag();
|
public CompoundTag tag = new CompoundTag();
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.trackwork.item;
|
package space.eptaproject.vmodextras.compact.trackwork.item;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
|
@ -30,13 +30,7 @@ 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) {
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package space.eptaproject.vmodextras.mixins;
|
||||||
|
|
||||||
|
public class A {
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixins;
|
package space.eptaproject.vmodextras.mixins.trackwork;
|
||||||
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap;
|
import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap;
|
||||||
|
@ -19,14 +19,14 @@ import space.eptaproject.vmodextras.Validator;
|
||||||
@Mixin(BlockPaletteHashMapV1.class)
|
@Mixin(BlockPaletteHashMapV1.class)
|
||||||
public class BlockPaletteHashMapV1Mixin {
|
public class BlockPaletteHashMapV1Mixin {
|
||||||
@Unique
|
@Unique
|
||||||
public final IValidator validator = new Validator();
|
public final IValidator vmodextras$validator = new Validator();
|
||||||
|
|
||||||
@Shadow
|
@Shadow(remap = false)
|
||||||
private @Mutable CrudeIncrementalIntIdentityHashBiMap statePaletteMap;
|
private @Mutable CrudeIncrementalIntIdentityHashBiMap<BlockState> 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 = (BlockState)this.statePaletteMap.byId(id);
|
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 {
|
||||||
validator.valid(block, location, info);
|
vmodextras$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 space.eptaproject.vmodextras.mixins;
|
package space.eptaproject.vmodextras.mixins.trackwork;
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
||||||
import org.joml.Vector3dc;
|
import org.joml.Vector3dc;
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixins;
|
package space.eptaproject.vmodextras.mixins.trackwork;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
|
||||||
|
@ -7,12 +7,12 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import space.eptaproject.vmodextras.Config;
|
import space.eptaproject.vmodextras.Config;
|
||||||
import space.eptaproject.vmodextras.trackwork.IPhysicsTrackController;
|
import space.eptaproject.vmodextras.compact.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 private volatile float suspensionStiffness;
|
@Shadow(remap = false) private volatile float suspensionStiffness;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author
|
* @author
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixins;
|
package space.eptaproject.vmodextras.mixins.trackwork;
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
||||||
import org.joml.Vector3dc;
|
import org.joml.Vector3dc;
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixins;
|
package space.eptaproject.vmodextras.mixins.trackwork;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
import edn.stratodonut.trackwork.tracks.forces.SimpleWheelController;
|
||||||
|
@ -7,12 +7,12 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Overwrite;
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import space.eptaproject.vmodextras.Config;
|
import space.eptaproject.vmodextras.Config;
|
||||||
import space.eptaproject.vmodextras.trackwork.ISimpleWheelController;
|
import space.eptaproject.vmodextras.compact.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 private volatile float suspensionStiffness;
|
@Shadow(remap = false) private volatile float suspensionStiffness;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author
|
* @author
|
|
@ -1,4 +1,4 @@
|
||||||
package space.eptaproject.vmodextras.mixins;
|
package space.eptaproject.vmodextras.mixins.trackwork;
|
||||||
|
|
||||||
import edn.stratodonut.trackwork.items.TrackToolkit;
|
import edn.stratodonut.trackwork.items.TrackToolkit;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
|
@ -1,7 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.trackwork;
|
|
||||||
|
|
||||||
import space.eptaproject.vmodextras.mixins.PhysicsTrackControllerAccessor;
|
|
||||||
|
|
||||||
public interface IPhysicsTrackController extends PhysicsTrackControllerAccessor, IController {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
package space.eptaproject.vmodextras.trackwork;
|
|
||||||
|
|
||||||
import space.eptaproject.vmodextras.mixins.SimpleWheelControllerAccessor;
|
|
||||||
|
|
||||||
public interface ISimpleWheelController extends SimpleWheelControllerAccessor, IController {
|
|
||||||
}
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package space.eptaproject.vmodextras.util;
|
||||||
|
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
|
||||||
|
public class ResourceLocationUtil {
|
||||||
|
public static ResourceLocation fromNamespaceAndPath(String namespace, String path) {
|
||||||
|
return new ResourceLocation(namespace, path);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package space.eptaproject.vmodextras.util;
|
||||||
|
|
||||||
|
import net.minecraftforge.fml.ModList;
|
||||||
|
|
||||||
|
public class Utils {
|
||||||
|
public static void executeIsModEnable(String mod,Runnable runnable) {
|
||||||
|
if (ModList.get().isLoaded(mod)) {
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void executeIsModDisable(String mod,Runnable runnable) {
|
||||||
|
if (!ModList.get().isLoaded(mod)) {
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"": { "model": "vmodextras:block/track_work_controller" }
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,53 +1,6 @@
|
||||||
{
|
{
|
||||||
"credit": "Made with Blockbench",
|
"parent": "block/cube_all",
|
||||||
"texture_size": [64, 64],
|
|
||||||
"textures": {
|
"textures": {
|
||||||
"1": "vmodextras:block/track_backup",
|
"all": "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]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": {
|
||||||
|
"all": "vmodextras:block/track_work_controller"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,53 +1,6 @@
|
||||||
{
|
{
|
||||||
"credit": "Made with Blockbench",
|
"parent": "block/cube_all",
|
||||||
"texture_size": [64, 64],
|
|
||||||
"textures": {
|
"textures": {
|
||||||
"1": "vmodextras:block/track_backup",
|
"all": "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]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": {
|
||||||
|
"all": "vmodextras:block/track_work_controller"
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 434 B After Width: | Height: | Size: 167 B |
Binary file not shown.
After Width: | Height: | Size: 178 B |
|
@ -5,11 +5,15 @@
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"refmap": "vmodextras.refmap.json",
|
"refmap": "vmodextras.refmap.json",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"trackwork.BlockPaletteHashMapV1Mixin",
|
||||||
|
"trackwork.PhysicsTrackControllerAccessor",
|
||||||
|
"trackwork.PhysicsTrackControllerMixin",
|
||||||
|
"trackwork.SimpleWheelControllerAccessor",
|
||||||
|
"trackwork.SimpleWheelControllerMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
},
|
}
|
||||||
"plugin": "space.eptaproject.vmodextras.mixin.MixinPlugin"
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue