From 5db73c64db37b8e3639ae82fa9bcf2cc270689a3 Mon Sep 17 00:00:00 2001 From: rhysdh540 Date: Sun, 5 Nov 2023 15:08:05 -0500 Subject: [PATCH] actual finally good fix for the weird placement info thing since when was cursed type casting ever good? also formatting --- .../rdh/createunlimited/config/CUConfigs.java | 1 - .../config/command/CUCommands.java | 14 +++++----- .../duck/PlacementInfoDuck.java | 10 ------- .../createunlimited/mixin/CTrainsMixin.java | 1 - .../mixin/CarriageContraptionMixin.java | 1 - .../mixin/CopycatBlockMixin.java | 2 -- .../mixin/PlacementInfoMixin.java | 27 ------------------- .../mixin/StationBlockEntityMixin.java | 2 -- .../mixin/SuperGlueSelectionPacketMixin.java | 1 - .../mixin/TrackPlacementMixin.java | 17 ++++++------ .../mixin/TrainRelocatorMixin.java | 1 - .../mixin/accessor/CValueAccessor.java | 4 +-- .../mixin/accessor/PlacementInfoAccessor.java | 20 -------------- .../createunlimited-common.mixins.json | 1 - 14 files changed, 17 insertions(+), 85 deletions(-) delete mode 100644 common/src/main/java/dev/rdh/createunlimited/duck/PlacementInfoDuck.java delete mode 100644 common/src/main/java/dev/rdh/createunlimited/mixin/PlacementInfoMixin.java diff --git a/common/src/main/java/dev/rdh/createunlimited/config/CUConfigs.java b/common/src/main/java/dev/rdh/createunlimited/config/CUConfigs.java index f04bb20..0b4ec04 100644 --- a/common/src/main/java/dev/rdh/createunlimited/config/CUConfigs.java +++ b/common/src/main/java/dev/rdh/createunlimited/config/CUConfigs.java @@ -1,6 +1,5 @@ package dev.rdh.createunlimited.config; - import com.simibubi.create.foundation.config.ConfigBase; import com.simibubi.create.foundation.config.ui.BaseConfigScreen; diff --git a/common/src/main/java/dev/rdh/createunlimited/config/command/CUCommands.java b/common/src/main/java/dev/rdh/createunlimited/config/command/CUCommands.java index 59e12e4..184d179 100644 --- a/common/src/main/java/dev/rdh/createunlimited/config/command/CUCommands.java +++ b/common/src/main/java/dev/rdh/createunlimited/config/command/CUCommands.java @@ -24,7 +24,6 @@ import net.minecraft.network.chat.ComponentUtils; import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.world.entity.Entity; import net.minecraftforge.common.ForgeConfigSpec.*; @@ -61,17 +60,17 @@ public static void registerConfigCommand() { LiteralArgumentBuilder category = null; for (Field field : CUServer.class.getDeclaredFields()) { - //skip if not config value or string + // skip if not config value or string if (!CValue.class.isAssignableFrom(field.getType())) continue; String name = field.getName(); - //change category if needed + // change category if needed if (field.getType() == ConfigGroup.class) { if (category != null) base.then(category); category = literal(name); - //add description for category + // add description for category assert base != null; base.then(literal(field.getName()).executes(context -> { context.message(CUServer.getComment(name)); @@ -91,12 +90,13 @@ public static void registerConfigCommand() { continue; } - ConfigValue value = ((CValueAccessor) cValue).value; + // get config as forge config value + ConfigValue value = ((CValueAccessor) cValue).value; - //get, description, reset + // get, description, reset gdr(category, name, value); - //set for boolean + // set for boolean if (value instanceof BooleanValue bValue) setBoolean(category, name, bValue); diff --git a/common/src/main/java/dev/rdh/createunlimited/duck/PlacementInfoDuck.java b/common/src/main/java/dev/rdh/createunlimited/duck/PlacementInfoDuck.java deleted file mode 100644 index 3c06ad1..0000000 --- a/common/src/main/java/dev/rdh/createunlimited/duck/PlacementInfoDuck.java +++ /dev/null @@ -1,10 +0,0 @@ -package dev.rdh.createunlimited.duck; - -import dev.rdh.createunlimited.mixin.accessor.PlacementInfoAccessor; - -import com.simibubi.create.content.trains.track.TrackPlacement.PlacementInfo; - -public interface PlacementInfoDuck extends PlacementInfoAccessor { - PlacementInfo self(); - PlacementInfo withMessage(String message); -} diff --git a/common/src/main/java/dev/rdh/createunlimited/mixin/CTrainsMixin.java b/common/src/main/java/dev/rdh/createunlimited/mixin/CTrainsMixin.java index 080b937..b5904eb 100755 --- a/common/src/main/java/dev/rdh/createunlimited/mixin/CTrainsMixin.java +++ b/common/src/main/java/dev/rdh/createunlimited/mixin/CTrainsMixin.java @@ -1,6 +1,5 @@ package dev.rdh.createunlimited.mixin; - import com.simibubi.create.infrastructure.config.CTrains; import dev.rdh.createunlimited.CreateUnlimited; diff --git a/common/src/main/java/dev/rdh/createunlimited/mixin/CarriageContraptionMixin.java b/common/src/main/java/dev/rdh/createunlimited/mixin/CarriageContraptionMixin.java index aae2742..3e944dc 100644 --- a/common/src/main/java/dev/rdh/createunlimited/mixin/CarriageContraptionMixin.java +++ b/common/src/main/java/dev/rdh/createunlimited/mixin/CarriageContraptionMixin.java @@ -1,6 +1,5 @@ package dev.rdh.createunlimited.mixin; - import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.simibubi.create.content.trains.entity.CarriageContraption; diff --git a/common/src/main/java/dev/rdh/createunlimited/mixin/CopycatBlockMixin.java b/common/src/main/java/dev/rdh/createunlimited/mixin/CopycatBlockMixin.java index bb16b39..5ea100a 100755 --- a/common/src/main/java/dev/rdh/createunlimited/mixin/CopycatBlockMixin.java +++ b/common/src/main/java/dev/rdh/createunlimited/mixin/CopycatBlockMixin.java @@ -1,7 +1,5 @@ package dev.rdh.createunlimited.mixin; - - import com.simibubi.create.content.decoration.copycat.CopycatBlock; import dev.rdh.createunlimited.config.CUConfigs; diff --git a/common/src/main/java/dev/rdh/createunlimited/mixin/PlacementInfoMixin.java b/common/src/main/java/dev/rdh/createunlimited/mixin/PlacementInfoMixin.java deleted file mode 100644 index 5134434..0000000 --- a/common/src/main/java/dev/rdh/createunlimited/mixin/PlacementInfoMixin.java +++ /dev/null @@ -1,27 +0,0 @@ -package dev.rdh.createunlimited.mixin; - -import dev.rdh.createunlimited.duck.PlacementInfoDuck; - -import manifold.rt.api.NoBootstrap; - -import com.simibubi.create.content.trains.track.TrackPlacement.PlacementInfo; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; - -@NoBootstrap -@SuppressWarnings({ "DataFlowIssue", "AddedMixinMembersNamePattern" }) -@Mixin(value = PlacementInfo.class, remap = false) -public abstract class PlacementInfoMixin implements PlacementInfoDuck { - @Override - @Unique(silent = true) // at runtime just use the original method - public PlacementInfo withMessage(String message) { - return self().withMessage(message); - } - - @Unique - @Override - public PlacementInfo self() { - return (PlacementInfo) (Object) this; - } -} diff --git a/common/src/main/java/dev/rdh/createunlimited/mixin/StationBlockEntityMixin.java b/common/src/main/java/dev/rdh/createunlimited/mixin/StationBlockEntityMixin.java index 9b4d98e..f561358 100644 --- a/common/src/main/java/dev/rdh/createunlimited/mixin/StationBlockEntityMixin.java +++ b/common/src/main/java/dev/rdh/createunlimited/mixin/StationBlockEntityMixin.java @@ -1,7 +1,5 @@ package dev.rdh.createunlimited.mixin; - - import com.simibubi.create.content.trains.station.StationBlockEntity; import dev.rdh.createunlimited.config.CUConfigs; diff --git a/common/src/main/java/dev/rdh/createunlimited/mixin/SuperGlueSelectionPacketMixin.java b/common/src/main/java/dev/rdh/createunlimited/mixin/SuperGlueSelectionPacketMixin.java index 63c5294..66c8746 100644 --- a/common/src/main/java/dev/rdh/createunlimited/mixin/SuperGlueSelectionPacketMixin.java +++ b/common/src/main/java/dev/rdh/createunlimited/mixin/SuperGlueSelectionPacketMixin.java @@ -1,6 +1,5 @@ package dev.rdh.createunlimited.mixin; - import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; diff --git a/common/src/main/java/dev/rdh/createunlimited/mixin/TrackPlacementMixin.java b/common/src/main/java/dev/rdh/createunlimited/mixin/TrackPlacementMixin.java index ec46710..81ad920 100755 --- a/common/src/main/java/dev/rdh/createunlimited/mixin/TrackPlacementMixin.java +++ b/common/src/main/java/dev/rdh/createunlimited/mixin/TrackPlacementMixin.java @@ -1,6 +1,5 @@ package dev.rdh.createunlimited.mixin; - import com.simibubi.create.AllTags; import com.simibubi.create.content.trains.track.*; import com.simibubi.create.foundation.utility.*; @@ -10,7 +9,7 @@ import dev.rdh.createunlimited.Util; import dev.rdh.createunlimited.config.CUConfigs; -import dev.rdh.createunlimited.duck.PlacementInfoDuck; +import dev.rdh.createunlimited.mixin.accessor.PlacementInfoAccessor; import manifold.rt.api.NoBootstrap; @@ -58,12 +57,12 @@ public static PlacementInfo tryConnect(Level level, Player player, BlockPos pos2 && hoveringMaxed == maximiseTurn && lookAngle == hoveringAngle) return cached; - PlacementInfoDuck info = (PlacementInfoDuck) new PlacementInfo(TrackMaterial.fromItem(stack.getItem())); + var info = (PlacementInfo & PlacementInfoAccessor) new PlacementInfo(TrackMaterial.fromItem(stack.getItem())); hoveringMaxed = maximiseTurn; hoveringAngle = lookAngle; hoveringPos = pos2; lastItem = stack; - cached = info.self(); + cached = info; ITrackBlock track = (ITrackBlock) state2.getBlock(); Pair nearestTrackAxis = track.getNearestTrackAxis(level, pos2, state2, lookVec); @@ -339,14 +338,14 @@ public static PlacementInfo tryConnect(Level level, Player player, BlockPos pos2 info.axis1 = axis1; info.axis2 = axis2; - placeTracks(level, info.self(), state1, state2, targetPos1, targetPos2, true); + placeTracks(level, info, state1, state2, targetPos1, targetPos2, true); ItemStack offhandItem = player.getOffhandItem() .copy(); boolean shouldPave = offhandItem.getItem() instanceof BlockItem; if (shouldPave) { BlockItem paveItem = (BlockItem) offhandItem.getItem(); - paveTracks(level, info.self(), paveItem, true); + paveTracks(level, info, paveItem, true); info.hasRequiredPavement = true; } @@ -416,12 +415,12 @@ else if (j == inv.selected) } if (level.isClientSide()) - return info.self(); + return info; if (shouldPave) { BlockItem paveItem = (BlockItem) offhandItem.getItem(); - paveTracks(level, info.self(), paveItem, false); + paveTracks(level, info, paveItem, false); } - return placeTracks(level, info.self(), state1, state2, targetPos1, targetPos2, false); + return placeTracks(level, info, state1, state2, targetPos1, targetPos2, false); } @Invoker("paveTracks") diff --git a/common/src/main/java/dev/rdh/createunlimited/mixin/TrainRelocatorMixin.java b/common/src/main/java/dev/rdh/createunlimited/mixin/TrainRelocatorMixin.java index cb92938..c6eeaf5 100755 --- a/common/src/main/java/dev/rdh/createunlimited/mixin/TrainRelocatorMixin.java +++ b/common/src/main/java/dev/rdh/createunlimited/mixin/TrainRelocatorMixin.java @@ -1,6 +1,5 @@ package dev.rdh.createunlimited.mixin; - import com.simibubi.create.content.trains.entity.TrainRelocator; import dev.rdh.createunlimited.config.CUConfigs; diff --git a/common/src/main/java/dev/rdh/createunlimited/mixin/accessor/CValueAccessor.java b/common/src/main/java/dev/rdh/createunlimited/mixin/accessor/CValueAccessor.java index ea19754..4876ca7 100644 --- a/common/src/main/java/dev/rdh/createunlimited/mixin/accessor/CValueAccessor.java +++ b/common/src/main/java/dev/rdh/createunlimited/mixin/accessor/CValueAccessor.java @@ -11,7 +11,7 @@ @NoBootstrap @Mixin(value = CValue.class, remap = false) -public interface CValueAccessor> { +public interface CValueAccessor { @Accessor("value") - ConfigValue getValue(); + ConfigValue getValue(); } diff --git a/common/src/main/java/dev/rdh/createunlimited/mixin/accessor/PlacementInfoAccessor.java b/common/src/main/java/dev/rdh/createunlimited/mixin/accessor/PlacementInfoAccessor.java index 57d3332..bb81f2c 100644 --- a/common/src/main/java/dev/rdh/createunlimited/mixin/accessor/PlacementInfoAccessor.java +++ b/common/src/main/java/dev/rdh/createunlimited/mixin/accessor/PlacementInfoAccessor.java @@ -81,24 +81,4 @@ public interface PlacementInfoAccessor { BlockPos getPos2(); @Accessor("pos2") void setPos2(BlockPos pos2); - - @Accessor("requiredTracks") - int getRequiredTracks(); - @Accessor("requiredTracks") - void setRequiredTracks(int requiredTracks); - - @Accessor("hasRequiredTracks") - boolean hasRequiredTracks(); - @Accessor("hasRequiredTracks") - void setHasRequiredTracks(boolean hasRequiredTracks); - - @Accessor("requiredPavement") - int getRequiredPavement(); - @Accessor("requiredPavement") - void setRequiredPavement(int requiredPavement); - - @Accessor("hasRequiredPavement") - boolean hasRequiredPavement(); - @Accessor("hasRequiredPavement") - void setHasRequiredPavement(boolean hasRequiredPavement); } diff --git a/common/src/main/resources/createunlimited-common.mixins.json b/common/src/main/resources/createunlimited-common.mixins.json index ebafa8c..8c7cf9e 100755 --- a/common/src/main/resources/createunlimited-common.mixins.json +++ b/common/src/main/resources/createunlimited-common.mixins.json @@ -10,7 +10,6 @@ "CopycatBlockMixin", "CTrainsMixin", "ExtendoGripItemMixin", - "PlacementInfoMixin", "StationBlockEntityMixin", "SuperGlueSectionHandlerMixin", "SuperGlueSelectionPacketMixin",