big update

update Suspension Stiffness
edit limit
add save of vmod
This commit is contained in:
p2vman 2025-05-25 16:30:30 +03:00
parent 4b1eb9355b
commit 6e215209e4
25 changed files with 491 additions and 73 deletions

View File

@ -5,6 +5,7 @@
<profile name="Gradle Imported" enabled="true">
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="false">
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/io.github.llamalad7/mixinextras-common/0.4.1/a7f425cc49de7f10d008a9a676f5f023ebac13bb/mixinextras-common-0.4.1.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.spongepowered/mixin/0.8.5/6d1c8bf4c28e697f472a83bd6add76ec4951734/mixin-0.8.5-processor.jar" />
<entry name="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.20/18bcea7d5df4d49227b4a0743a536208ce4825bb/lombok-1.18.20.jar" />
</processorPath>

View File

@ -26,5 +26,15 @@
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
<remote-repository>
<option name="id" value="Modrinth" />
<option name="name" value="Modrinth" />
<option name="url" value="https://api.modrinth.com/maven" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://maven.tterrag.com/releases" />
</remote-repository>
</component>
</project>

View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<writeAnnotations>
<writeAnnotation name="org.spongepowered.asm.mixin.Unique" />
</writeAnnotations>
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="ms-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />

View File

@ -140,6 +140,19 @@ repositories {
// flatDir {
// dir 'libs'
// }
flatDir {
dirs("libs")
}
maven {
name = "Modrinth"
url = uri("https://api.modrinth.com/maven")
}
maven {
url = uri("https://maven.tterrag.com/releases")
}
}
dependencies {
@ -163,7 +176,22 @@ dependencies {
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/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("org.valkyrienskies:valkyrienskies-120:2.3.0-beta.7"))
implementation 'net.minecraftforge:modlauncher:10.1.1'
implementation 'net.minecraftforge:forgespi:7.1.0'
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.4.1"))
implementation(jarJar("io.github.llamalad7:mixinextras-forge:0.4.1")) {
jarJar.ranged(it, "[0.4.1,)")
}
implementation fg.deobf(files("./libs/drivebywire-1.20.1-0.0.10.jar"))
implementation(fg.deobf("com.simibubi.create:create-1.20.1:0.5.1.j"))
implementation fg.deobf(files("./libs/api-1.1.0+b19b27c4a4.jar"))
// For more info:
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
@ -173,6 +201,7 @@ dependencies {
compileOnly 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
}
@ -185,7 +214,7 @@ tasks.named('processResources', ProcessResources).configure {
forge_version : forge_version, forge_version_range: forge_version_range,
loader_version_range: loader_version_range,
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors : mod_authors, mod_description: mod_description,]
mod_authors : mod_authors, mod_description: mod_description,the_vmod_version:the_vmod_version,valkyrien_ship_schematics_version:valkyrien_ship_schematics_version,]
inputs.properties replaceProperties

View File

@ -1,16 +1,9 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
# The Minecraft version must agree with the Forge version to get a valid artifact
minecraft_version=1.20.1
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.1,1.21)
# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=47.4.1
# The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[47,)
# The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[47,)
# The mapping channel to use for mappings.
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
@ -27,23 +20,14 @@ loader_version_range=[47,)
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
mapping_channel=official
# The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel.
mapping_version=1.20.1
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
# Must match the String constant located in the main mod class annotated with @Mod.
mod_id=vmodaddon
# The human-readable display name for the mod.
mod_name=VModAddon
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.0-SNAPSHOT
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_group_id=space.eptaproject
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=p2vman
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=
the_vmod_version = 1.2.2
valkyrien_ship_schematics_version = 1.0

View File

@ -1,24 +1,30 @@
package space.eptaproject.vmodaddon;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.List;
import java.util.Objects;
import java.util.*;
public class 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>> ITEM_BLACK_LIST;
public static final ForgeConfigSpec.ConfigValue<String> RESOURCE_LOCATION;
public static List<ResourceLocation> parsedList = new ObjectArrayList<>();
private static List<Map.Entry<Integer, ResourceLocation>> ITEM = new ObjectImmutableList<>(new ArrayList<>());
public static ResourceLocation replace = Validator.RB;
static {
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
builder.push("Settings");
builder.push("Schematic");
RESOURCE_LOCATION_LIST = builder
.comment("List of blocked blocks, format: 'modid:path'")
@ -35,6 +41,18 @@ public class Config {
Validator.RB.toString()
);
builder.pop();
builder.push("Inventory");
ITEM_BLACK_LIST = builder
.comment("List of blocked items, format: 'modid:path'")
.defineListAllowEmpty(
"blocked",
List.of("minecraft:stone", "minecraft:diamond_block"),
obj -> obj instanceof String && ResourceLocation.isValidResourceLocation((String) obj)
);
builder.pop();
COMMON_CONFIG = builder.build();
}
@ -50,6 +68,18 @@ public class Config {
})
.filter(Objects::nonNull)
.toList();
ITEM = new ObjectImmutableList(ITEM_BLACK_LIST.get().stream()
.map(s -> {
try {
ResourceLocation location = ResourceLocation.parse(s);
return new AbstractMap.SimpleEntry<Integer, ResourceLocation>(location.hashCode(), location);
} catch (Exception e) {
return null;
}
})
.filter(Objects::nonNull)
.toList());
try {
replace = ResourceLocation.parse(RESOURCE_LOCATION.get());
} catch (Exception e) {
@ -57,4 +87,18 @@ public class Config {
}
}
public static boolean contains(ItemStack stack) {
if (stack.isEmpty()) return false;
ResourceLocation id = ForgeRegistries.ITEMS.getKey(stack.getItem());
if (id == null) return false;
int hash = id.hashCode();
for (var entry : ITEM) {
if (entry.getKey() == hash && entry.getValue().equals(id)) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,8 @@
package space.eptaproject.vmodaddon;
import space.eptaproject.vmodaddon.mixins.PhysicsTrackControllerAccessor;
public interface IPhysicsTrackController extends PhysicsTrackControllerAccessor {
void SetRawDamperCoefficient(float delta);
float GetRawDamperCoefficient();
}

View File

@ -5,13 +5,13 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.registries.ForgeRegistries;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.logging.Logger;
@ToString
public class Validator implements IValidator {
public static final Logger LOGGER = Logger.getLogger("Validator");
public static final Logger LOGGER = LoggerFactory.getLogger("Validator");
public static ResourceLocation RB = ResourceLocation.fromNamespaceAndPath(Vmodaddon.MODID, "example_block");
public Validator() {

View File

@ -1,10 +1,16 @@
package space.eptaproject.vmodaddon;
import com.mojang.logging.LogUtils;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
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.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;
@ -17,8 +23,9 @@ import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import org.slf4j.Logger;
import space.eptaproject.vmodaddon.block.TBB;
import space.eptaproject.vmodaddon.block.TBBE;
// The value here should match an entry in the META-INF/mods.toml file
@Mod(Vmodaddon.MODID)
public class Vmodaddon {
@ -27,15 +34,27 @@ public class Vmodaddon {
private static final Logger LOGGER = LogUtils.getLogger();
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MODID);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
public static final RegistryObject<Block> EXAMPLE_BLOCK = BLOCKS.register("example_block", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
public static final RegistryObject<Block> TRAK_BUK = BLOCKS.register("tb", () -> new TBB(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
public static final RegistryObject<BlockEntityType<TBBE>> MY_BLOCK_ENTITY = BLOCK_ENTITIES.register("my_block_entity",
() -> BlockEntityType.Builder.of(TBBE::new, TRAK_BUK.get()).build(null));
public static final RegistryObject<Item> MY_BLOCK_ITEM = ITEMS.register("tb",
() -> new BlockItem(TRAK_BUK.get(), new Item.Properties()));
public Vmodaddon() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
modEventBus.addListener(this::commonSetup);
BLOCKS.register(modEventBus);
BLOCK_ENTITIES.register(modEventBus);
ITEMS.register(modEventBus);
MinecraftForge.EVENT_BUS.register(this);
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_CONFIG);
@ -54,4 +73,30 @@ public class Vmodaddon {
}
}
}
@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);
}
}
}
}

View File

@ -0,0 +1,23 @@
package space.eptaproject.vmodaddon.block;
import com.simibubi.create.foundation.block.IBE;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.entity.BlockEntityType;
import space.eptaproject.vmodaddon.Vmodaddon;
public class TBB extends HorizontalDirectionalBlock implements IBE<TBBE> {
public TBB(Properties properties) {
super(properties);
}
@Override
public BlockEntityType<? extends TBBE> getBlockEntityType() {
return Vmodaddon.MY_BLOCK_ENTITY.get();
}
@Override
public Class<TBBE> getBlockEntityClass() {
return TBBE.class;
}
}

View File

@ -0,0 +1,43 @@
package space.eptaproject.vmodaddon.block;
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Mth;
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.vmodaddon.IPhysicsTrackController;
import space.eptaproject.vmodaddon.Vmodaddon;
public class TBBE extends BlockEntity {
public TBBE(BlockPos p_155229_, BlockState p_155230_) {
super(Vmodaddon.MY_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 controller = ship.getAttachment(PhysicsTrackController.class);
if (controller != null) {
tag.putFloat("SuspensionStiffness", ((IPhysicsTrackController) controller).getSuspensionStiffness());
}
}
}
@Override
public void load(CompoundTag tag) {
super.load(tag);
if (tag.contains("SuspensionStiffness")) {
ServerShip ship = (ServerShip) VSGameUtilsKt.getShipObjectManagingPos(this.level, getBlockPos());
if (ship != null) {
PhysicsTrackController controller = PhysicsTrackController.getOrCreate(ship);
((IPhysicsTrackController) controller).setSuspensionStiffness(tag.getFloat("SuspensionStiffness"));
}
}
}
}

View File

@ -0,0 +1,12 @@
package space.eptaproject.vmodaddon.mixin;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface A {
String[] value();
}

View File

@ -0,0 +1,8 @@
package space.eptaproject.vmodaddon.mixin;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
public interface ITransformer {
void transform(String targetClassName, ClassNode classNode, String mixinClassName, IMixinInfo mixinInfo);
}

View File

@ -0,0 +1,35 @@
package space.eptaproject.vmodaddon.mixin;
import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
import java.util.Map;
public class InstanceHolder<T> {
private final Map<Class<? extends T>, T> instances = new Object2ObjectArrayMap<>();
public InstanceHolder() {
}
public T get(String cls) {
try {
return get((Class<? extends T>) Class.forName(cls));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public T get(Class<? extends T> cls) {
if (instances.containsKey(cls)) {
return instances.get(cls);
}
try {
T instance = cls.getDeclaredConstructor().newInstance();
instances.put(cls, instance);
return instance;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,36 @@
package space.eptaproject.vmodaddon.mixin;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.*;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.ListIterator;
public class KotlinOptimizationTransformer implements ITransformer {
@Override
public void transform(String targetClassName, ClassNode classNode, String mixinClassName, IMixinInfo mixinInfo) {
for (MethodNode method : classNode.methods) {
ListIterator<AbstractInsnNode> it = method.instructions.iterator();
while (it.hasNext()) {
AbstractInsnNode insn = it.next();
if (insn.getOpcode() == Opcodes.INVOKESTATIC &&
insn instanceof MethodInsnNode methodInsn &&
methodInsn.owner.equals("kotlin/jvm/internal/Intrinsics") &&
(methodInsn.name.equals("checkParameterIsNotNull") || methodInsn.name.equals("checkNotNullParameter") || methodInsn.name.equals("checkNotNullExpressionValue")) &&
methodInsn.desc.equals("(Ljava/lang/Object;Ljava/lang/String;)V")) {
AbstractInsnNode arg2Insn = methodInsn.getPrevious();
AbstractInsnNode arg1Insn = arg2Insn != null ? arg2Insn.getPrevious() : null;
method.instructions.remove(arg1Insn);
method.instructions.remove(arg2Insn);
method.instructions.remove(insn);
}
}
}
}
}

View File

@ -0,0 +1,91 @@
package space.eptaproject.vmodaddon.mixin;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Type;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import org.objectweb.asm.tree.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
public class MixinPlugin implements IMixinConfigPlugin {
public InstanceHolder<ITransformer> transformerInstanceHolder = new InstanceHolder<>();
@Override
public void onLoad(String mixinPackage) {
}
@Override
public String getRefMapperConfig() {
return null;
}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return true;
}
@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
}
@Override
public List<String> getMixins() {
return List.of(
"BlockPaletteHashMapV1Mixin",
"PhysicsTrackControllerAccessor",
"PhysicsTrackControllerMixin"
);
}
@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@Override
public void postApply(String targetClassName, ClassNode classNode, String mixinClassName, IMixinInfo mixinInfo) {
String annotationDesc = "Lspace/eptaproject/vmodaddon/mixin/A;";
if (classNode.visibleAnnotations == null) {
classNode.visibleAnnotations = new ArrayList<>();
}
AnnotationNode existing = null;
for (AnnotationNode ann : classNode.visibleAnnotations) {
if (Objects.equals(ann.desc, annotationDesc)) {
existing = ann;
break;
}
}
if (existing != null) {
List<Object> values = existing.values;
for (int i = 0; i < values.size(); i += 2) {
String key = (String) values.get(i);
if (key.equals("value")) {
List<String> list = (List<String>) values.get(i + 1);
if (!list.contains(mixinClassName)) {
list.add(mixinClassName);
}
return;
}
}
values.add("value");
values.add(new ArrayList<>(List.of(mixinClassName)));
} else {
AnnotationNode newAnnotation = new AnnotationNode(annotationDesc);
newAnnotation.values = new ArrayList<>();
newAnnotation.values.add("value");
newAnnotation.values.add(new ArrayList<>(List.of(mixinClassName)));
classNode.visibleAnnotations.add(newAnnotation);
}
transformerInstanceHolder.get(KotlinOptimizationTransformer.class).transform(targetClassName, classNode, mixinClassName, mixinInfo);
}
}

View File

@ -1,33 +0,0 @@
package space.eptaproject.vmodaddon.mixin;
import kotlin.jvm.functions.Function3;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.spaceeye.valkyrien_ship_schematics.interfaces.v1.IShipSchematicDataV1;
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;
import java.util.List;
@Mixin(targets = "net.spaceeye.vmod.schematic.SchematicActionsQueue$SchemPlacementItem")
public class SchemPlacementItemMixin {
@Inject(method = "<init>", at = @At("RETURN"))
private void afterConstruct(ServerLevel level, ServerPlayer player, IShipSchematicDataV1 schematicV1, List shipsToCreate, Function3 postPlacementFn, CallbackInfo ci) {
//IBlockStatePalette palette = schematicV1.getBlockPalette();
//Map<Long, ChunkyBlockData<BlockItem>> blockData = schematicV1.getBlockData();
//for (Map.Entry<Long, ChunkyBlockData<BlockItem>> entry : blockData.entrySet()) {
// ChunkyBlockData<BlockItem> chunk_data = entry.getValue();
// chunk_data.getBlocks().forEach((a, b) -> {
// b.forEach((c, f) -> {
// BlockState state = palette.fromId(f.getPaletteId());
//
// });
// });
//}
}
}

View File

@ -0,0 +1,12 @@
package space.eptaproject.vmodaddon.mixin;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Transformers {
Class<? extends ITransformer>[] transformers();
}

View File

@ -0,0 +1,4 @@
@ApiStatus.Experimental
package space.eptaproject.vmodaddon.mixin;
import org.jetbrains.annotations.ApiStatus;

View File

@ -1,5 +1,6 @@
package space.eptaproject.vmodaddon.mixin;
package space.eptaproject.vmodaddon.mixins;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.CrudeIncrementalIntIdentityHashBiMap;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
@ -14,8 +15,11 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import space.eptaproject.vmodaddon.IValidator;
import space.eptaproject.vmodaddon.Validator;
import space.eptaproject.vmodaddon.mixin.KotlinOptimizationTransformer;
import space.eptaproject.vmodaddon.mixin.Transformers;
@Mixin(BlockPaletteHashMapV1.class)
@Transformers(transformers = {KotlinOptimizationTransformer.class})
public class BlockPaletteHashMapV1Mixin {
@Unique
public final IValidator validator = new Validator();
@ -24,17 +28,21 @@ public class BlockPaletteHashMapV1Mixin {
private @Mutable CrudeIncrementalIntIdentityHashBiMap statePaletteMap;
@Inject(method = "fromId", at = @At("RETURN"), remap = false, cancellable = true)
private void aboba(int id, CallbackInfoReturnable<BlockState> cir) {
private void vmodaddon$fromId(int id, CallbackInfoReturnable<BlockState> cir) {
BlockState blockState = (BlockState)this.statePaletteMap.byId(id);
if (blockState.isAir()) {
if (blockState == null || blockState.isAir()) {
return;
}
Block block = blockState.getBlock();
ResourceLocation location = ForgeRegistries.BLOCKS.getKey(block);
CallbackInfoReturnable<BlockState> info = new CallbackInfoReturnable<>("blockstate-validator", true);
validator.valid(block, ForgeRegistries.BLOCKS.getKey(block), info);
try {
validator.valid(block, location, info);
} catch (Exception e) {
Validator.LOGGER.error("Error validating: {}", location, e);
}
if (info.isCancelled()) {
cir.setReturnValue(info.getReturnValue());
cir.cancel();

View File

@ -0,0 +1,14 @@
package space.eptaproject.vmodaddon.mixins;
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(PhysicsTrackController.class)
public interface PhysicsTrackControllerAccessor {
@Accessor(value = "suspensionStiffness", remap = false)
float getSuspensionStiffness();
@Accessor(value = "suspensionStiffness", remap = false)
void setSuspensionStiffness(float val);
}

View File

@ -0,0 +1,37 @@
package space.eptaproject.vmodaddon.mixins;
import edn.stratodonut.trackwork.tracks.forces.PhysicsTrackController;
import org.joml.Math;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import space.eptaproject.vmodaddon.IPhysicsTrackController;
@Mixin(PhysicsTrackController.class)
public abstract class PhysicsTrackControllerMixin implements IPhysicsTrackController {
@Shadow private volatile float suspensionStiffness;
@Unique
private volatile float damperCoefficient = 0;
@Override
public void SetRawDamperCoefficient(float delta) {
this.damperCoefficient = delta;
}
@Override
public float GetRawDamperCoefficient() {
return damperCoefficient;
}
/**
* @author
* @reason
*/
@Overwrite(remap = false)
public final float setDamperCoefficient(float delta) {
this.suspensionStiffness = Math.clamp(1.0F, 50.0F, this.suspensionStiffness + delta);
return this.suspensionStiffness;
}
}

View File

@ -1 +1,3 @@
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 place(JJ)Ljava/lang/Boolean; # place

View File

@ -53,7 +53,7 @@ versionRange = "${forge_version_range}" #mandatory
# AFTER - This mod is loaded AFTER the dependency
ordering = "NONE"
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
side = "BOTH"# Here's another dependency
side = "SERVER"# Here's another dependency
[[dependencies."${mod_id}"]]
modId = "minecraft"
mandatory = true
@ -65,13 +65,13 @@ side = "BOTH"
[[dependencies."${mod_id}"]]
modId = "the_vmod"
mandatory = true
versionRange = "1.2.2"
versionRange = "${the_vmod_version}"
ordering = "NONE"
side = "BOTH"
[[dependencies."${mod_id}"]]
modId = "valkyrien_ship_schematics"
mandatory = true
versionRange = "1.0"
versionRange = "${valkyrien_ship_schematics_version}"
ordering = "NONE"
side = "BOTH"

View File

@ -1,15 +1,15 @@
{
"required": true,
"minVersion": "0.8",
"package": "space.eptaproject.vmodaddon.mixin",
"package": "space.eptaproject.vmodaddon.mixins",
"compatibilityLevel": "JAVA_8",
"refmap": "vmodaddon.refmap.json",
"mixins": [
"BlockPaletteHashMapV1Mixin"
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
},
"plugin": "space.eptaproject.vmodaddon.mixin.MixinPlugin"
}