From 9a08e5d590c9396b685d4da3f1c7dfd53b433654 Mon Sep 17 00:00:00 2001 From: TheRobbie72 Date: Mon, 20 May 2024 15:27:11 +0800 Subject: [PATCH 1/4] Added Create mod trains compatibility --- build.gradle | 10 +- gradle.properties | 6 +- .../compat/create/CreateMixinPlugin.java | 63 +++++ .../mixin/TrackBlockMixin.java | 220 ++++++++++++++++++ .../resources/customportalapi.mixins.json | 4 +- 5 files changed, 300 insertions(+), 3 deletions(-) create mode 100644 src/main/java/net/kyrptonaught/customportalapi/compat/create/CreateMixinPlugin.java create mode 100644 src/main/java/net/kyrptonaught/customportalapi/mixin/TrackBlockMixin.java diff --git a/build.gradle b/build.gradle index 79c3393..bec45c5 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,14 @@ archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group - +repositories { + maven { url = "https://mvn.devos.one/snapshots/" } // Create, Porting Lib, Forge Tags, Milk Lib, Registrate + maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } // Forge Config API Port + maven { url = "https://jitpack.io/" } // Mixin Extras, Fabric ASM + maven { url = "https://maven.tterrag.com/" } // Flywheel + maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes + maven { url = "https://api.modrinth.com/maven" } // LazyDFU +} dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" @@ -18,6 +25,7 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modCompileOnly "com.simibubi.create:create-fabric-${minecraft_version}:${create_version}" } processResources { diff --git a/gradle.properties b/gradle.properties index bc83e64..10144aa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,4 +11,8 @@ fabric_version=0.47.8+1.18.2 # Mod Properties mod_version=0.0.1-beta52-1.18 maven_group=net.kyrptonaught -archives_base_name=customportalapi \ No newline at end of file +archives_base_name=customportalapi + +# Create +# https://modrinth.com/mod/create-fabric/versions +create_version = 0.5.1-f-build.1415+mc1.18.2 \ No newline at end of file diff --git a/src/main/java/net/kyrptonaught/customportalapi/compat/create/CreateMixinPlugin.java b/src/main/java/net/kyrptonaught/customportalapi/compat/create/CreateMixinPlugin.java new file mode 100644 index 0000000..4a11127 --- /dev/null +++ b/src/main/java/net/kyrptonaught/customportalapi/compat/create/CreateMixinPlugin.java @@ -0,0 +1,63 @@ +package net.kyrptonaught.customportalapi.compat.create; + +import com.google.common.collect.ImmutableMap; +import net.fabricmc.loader.api.FabricLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Supplier; + +// file structure based off of https://github.com/Juuxel/Adorn/blob/bd70a2955640897bc68ff1f4f201fe5e6c10bc32/fabric/src/main/java/juuxel/adorn/AdornMixinPlugin.java +// and by "based off of", haha, well. let's justr say. ctrl c + +/** + * Conditionally applies the TrackBlockMixin mixin only when create is loaded. + */ +public final class CreateMixinPlugin implements IMixinConfigPlugin { + private static final Supplier TRUE = () -> true; + + private static final Map> CONDITIONS = ImmutableMap.of( + "net.kyrptonaught.customportalapi.mixin.TrackBlockMixin", () -> FabricLoader.getInstance().isModLoaded("create") + ); + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return CONDITIONS.getOrDefault(mixinClassName, TRUE).get(); + } + + // Boilerplate + + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} \ No newline at end of file diff --git a/src/main/java/net/kyrptonaught/customportalapi/mixin/TrackBlockMixin.java b/src/main/java/net/kyrptonaught/customportalapi/mixin/TrackBlockMixin.java new file mode 100644 index 0000000..1314b35 --- /dev/null +++ b/src/main/java/net/kyrptonaught/customportalapi/mixin/TrackBlockMixin.java @@ -0,0 +1,220 @@ +package net.kyrptonaught.customportalapi.mixin; + +import java.util.Random; + +import com.google.common.base.Predicates; +import com.simibubi.create.content.contraptions.glue.SuperGlueEntity; +import com.simibubi.create.content.trains.track.TrackBlock; +import com.simibubi.create.content.trains.track.TrackBlockEntity; +import com.simibubi.create.foundation.utility.BlockFace; +import com.simibubi.create.foundation.utility.Components; +import com.simibubi.create.foundation.utility.Iterate; + +import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.foundation.utility.Pair; + +import net.kyrptonaught.customportalapi.CustomPortalApiRegistry; +import net.kyrptonaught.customportalapi.CustomPortalBlock; +import net.kyrptonaught.customportalapi.CustomPortalsMod; +import net.kyrptonaught.customportalapi.util.CustomPortalHelper; +import net.kyrptonaught.customportalapi.util.CustomTeleporter; +import net.kyrptonaught.customportalapi.util.PortalLink; +import net.minecraft.util.Formatting; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Direction.Axis; +import net.minecraft.text.MutableText; +import net.minecraft.util.registry.RegistryKey; +import net.minecraft.server.MinecraftServer; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; +import net.minecraft.block.NetherPortalBlock; + +import net.minecraft.block.entity.BlockEntity; + +import net.minecraft.state.property.BooleanProperty; +import net.minecraft.world.PortalForcer; +import net.minecraft.world.TeleportTarget; +import net.minecraft.util.math.Box; + +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.simibubi.create.content.trains.track.TrackPropagator; +import com.simibubi.create.content.trains.track.TrackShape; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.block.BlockState; +import net.minecraft.state.property.EnumProperty; + + +/** + * Mixin applied to the TrackBlock class in the Create mod so that it can recognize and use customportalapi portals. + */ +@Mixin(TrackBlock.class) +public abstract class TrackBlockMixin { + + + @Shadow + protected abstract void connectToNether(ServerWorld level, BlockPos pos, BlockState state); + + @Shadow + @Final + public static final EnumProperty SHAPE = EnumProperty.of("shape", TrackShape.class); + + @Shadow + @Final + public static final BooleanProperty HAS_BE = BooleanProperty.of("turn"); + + protected void connectToOtherDimension(ServerWorld level, BlockPos pos, BlockState state) { + TrackShape shape = state.get(TrackBlock.SHAPE); + Axis portalTest = shape == TrackShape.XO ? Axis.X : shape == TrackShape.ZO ? Axis.Z : null; + if (portalTest == null) + return; + + boolean pop = false; + String fail = null; + BlockPos failPos = null; + + for(Direction d : Iterate.directionsInAxis(portalTest)) { + BlockPos portalPos = pos.offset(d); + BlockState portalState = level.getBlockState(portalPos); + if (!(portalState.getBlock() instanceof NetherPortalBlock) && !(portalState.getBlock() instanceof CustomPortalBlock)) + continue; + + if(portalState.getBlock() instanceof NetherPortalBlock) { + connectToNether(level, pos, state); + } + if(portalState.getBlock() instanceof CustomPortalBlock) { + connectToCustomPortal(level, pos, state); + } + } + } + + protected void connectToCustomPortal(ServerWorld level, BlockPos pos, BlockState state) { + TrackShape shape = state.get(TrackBlock.SHAPE); + Axis portalTest = shape == TrackShape.XO ? Axis.X : shape == TrackShape.ZO ? Axis.Z : null; + if (portalTest == null) + return; + + boolean pop = false; + String fail = null; + BlockPos failPos = null; + + for(Direction d : Iterate.directionsInAxis(portalTest)) { + BlockPos portalPos = pos.offset(d); + BlockState portalState = level.getBlockState(portalPos); + if (!(portalState.getBlock() instanceof CustomPortalBlock)) + continue; + + pop = true; + Pair otherSide = getOtherSide(level, new BlockFace(pos, d)); + if (otherSide == null) { + fail = "missing"; + continue; + } + + ServerWorld otherLevel = otherSide.getFirst(); + BlockFace otherTrack = otherSide.getSecond(); + BlockPos otherTrackPos = otherTrack.getPos(); + BlockState existing = otherLevel.getBlockState(otherTrackPos); + if(!existing.getMaterial() + .isReplaceable()) { + fail = "blocked"; + failPos = otherTrackPos; + continue; + } + + level.setBlockState(pos, state.with(SHAPE, TrackShape.asPortal(d)) + .with(HAS_BE, true), 3); + BlockEntity be = level.getBlockEntity(pos); + if (be instanceof TrackBlockEntity tbe) + tbe.bind(otherLevel.getRegistryKey(), otherTrackPos); + + otherLevel.setBlockState(otherTrackPos, state.with(SHAPE, TrackShape.asPortal(otherTrack.getFace())) + .with(HAS_BE, true), 3); + BlockEntity otherBE = otherLevel.getBlockEntity(otherTrackPos); + if (otherBE instanceof TrackBlockEntity tbe) + tbe.bind(level.getRegistryKey(), pos); + + pop = false; + } + + if (!pop) + return; + + level.breakBlock(pos, true); + + if (fail == null) + return; + PlayerEntity player = level.getClosestPlayer(pos.getX(), pos.getY(), pos.getZ(), 10, Predicates.alwaysTrue()); + if (player == null) + return; + player.sendMessage(Components.literal(" ").append(Lang.translateDirect("portal_track.failed")) + .formatted(Formatting.GOLD), false); + MutableText component = + failPos != null ? Lang.translateDirect("portal_track." + fail, failPos.getX(), failPos.getY(), failPos.getZ()) + : Lang.translateDirect("portal_track." + fail); + player.sendMessage(Components.literal(" - ").formatted(Formatting.GRAY) + .append(component.styled(st -> st.withColor(0xFFD3B4))), false); + } + + @Inject(method = "scheduledTick", at = @At("HEAD"), cancellable = true) + private void trackBlock$tick(BlockState state, ServerWorld level, BlockPos pos, Random p_60465_, CallbackInfo ci) { + TrackPropagator.onRailAdded(level, pos, state); + if (!state.get(SHAPE) + .isPortal()) + connectToOtherDimension(level, pos, state); + ci.cancel(); + } + + protected Pair getOtherSide(ServerWorld level, BlockFace inboundTrack) { + BlockPos portalPos = inboundTrack.getConnectedPos(); + BlockState portalState = level.getBlockState(portalPos); + if (!(portalState.getBlock() instanceof NetherPortalBlock) && !(portalState.getBlock() instanceof CustomPortalBlock)) + return null; + + MinecraftServer minecraftserver = level.getServer(); + ServerWorld otherLevel = null; + if(portalState.getBlock() instanceof NetherPortalBlock) { + RegistryKey resourcekey = level.getRegistryKey() == World.NETHER ? World.OVERWORLD : World.NETHER; + otherLevel = minecraftserver.getWorld(resourcekey); + } else { + PortalLink link = CustomPortalApiRegistry.getPortalLinkFromBase(((CustomPortalBlock)portalState.getBlock()).getPortalBase(level, portalPos)); + RegistryKey resourcekey = level.getRegistryKey() == CustomPortalsMod.dims.get(link.dimID) ? CustomPortalsMod.dims.get(link.returnDimID) : CustomPortalsMod.dims.get(link.dimID);; + otherLevel = minecraftserver.getWorld(resourcekey); + } + if (otherLevel == null) + return null; + + PortalForcer teleporter = otherLevel.getPortalForcer(); + TeleportTarget portalinfo = null; + SuperGlueEntity probe = new SuperGlueEntity(level, new Box(portalPos)); + probe.setYaw(inboundTrack.getFace() + .asRotation()); + if(portalState.getBlock() instanceof NetherPortalBlock) { + portalinfo = probe.getTeleportTarget(otherLevel); + } else { + PortalLink link = CustomPortalApiRegistry.getPortalLinkFromBase(((CustomPortalBlock)portalState.getBlock()).getPortalBase(level, portalPos)); + portalinfo = CustomTeleporter.customTPTarget(otherLevel, probe, portalPos, ((CustomPortalBlock)portalState.getBlock()).getPortalBase(level, portalPos), link.getFrameTester()); + } + if (portalinfo == null) + return null; + + BlockPos otherPortalPos = new BlockPos(portalinfo.position); + BlockState otherPortalState = otherLevel.getBlockState(otherPortalPos); + if (!(otherPortalState.getBlock() instanceof NetherPortalBlock) && !(otherPortalState.getBlock() instanceof CustomPortalBlock)) + return null; + + Direction targetDirection = inboundTrack.getFace(); + if (targetDirection.getAxis() == CustomPortalHelper.getAxisFrom(otherPortalState)) { + targetDirection = targetDirection.rotateYClockwise(); + } + BlockPos otherPos = otherPortalPos.offset(targetDirection); + return Pair.of(otherLevel, new BlockFace(otherPos, targetDirection.getOpposite())); + } +} \ No newline at end of file diff --git a/src/main/resources/customportalapi.mixins.json b/src/main/resources/customportalapi.mixins.json index 889de86..14f7c66 100644 --- a/src/main/resources/customportalapi.mixins.json +++ b/src/main/resources/customportalapi.mixins.json @@ -3,12 +3,14 @@ "minVersion": "0.8", "package": "net.kyrptonaught.customportalapi.mixin", "compatibilityLevel": "JAVA_16", + "plugin": "net.kyrptonaught.customportalapi.compat.create.CreateMixinPlugin", "mixins": [ "EntityMixin", "ServerPlayerMixin", "portalLighters.AbstractFireMixin", "portalLighters.FluidBlockPlacedMixin", - "portalLighters.PotionEntityMixin" + "portalLighters.PotionEntityMixin", + "TrackBlockMixin" ], "client": [ "client.ChunkRendererRegionAccessor", From 0360863d07ce988f0ef581a4992966983fa4339b Mon Sep 17 00:00:00 2001 From: TheRobbie72 Date: Wed, 22 May 2024 19:25:02 +0800 Subject: [PATCH 2/4] Fixed non-player entities from dismounting while going through portals --- .../customportalapi/CustomPortalBlock.java | 16 +++++++++------- .../customportalapi/CustomPortalsMod.java | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/kyrptonaught/customportalapi/CustomPortalBlock.java b/src/main/java/net/kyrptonaught/customportalapi/CustomPortalBlock.java index 0ef7483..a54e1e9 100644 --- a/src/main/java/net/kyrptonaught/customportalapi/CustomPortalBlock.java +++ b/src/main/java/net/kyrptonaught/customportalapi/CustomPortalBlock.java @@ -99,13 +99,15 @@ public void randomDisplayTick(BlockState state, World world, BlockPos pos, Rando @Override public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { - EntityInCustomPortal entityInPortal = (EntityInCustomPortal) entity; - entityInPortal.tickInPortal(pos.toImmutable()); - if (!entityInPortal.didTeleport()) { - if (entityInPortal.getTimeInPortal() >= entity.getMaxNetherPortalTime()) { - entityInPortal.setDidTP(true); - if (!world.isClient) - CustomTeleporter.TPToDim(world, entity, getPortalBase(world, pos), pos); + if (!entity.hasVehicle() && !entity.hasPassengers()) { + EntityInCustomPortal entityInPortal = (EntityInCustomPortal) entity; + entityInPortal.tickInPortal(pos.toImmutable()); + if (!entityInPortal.didTeleport()) { + if (entityInPortal.getTimeInPortal() >= entity.getMaxNetherPortalTime()) { + entityInPortal.setDidTP(true); + if (!world.isClient) + CustomTeleporter.TPToDim(world, entity, getPortalBase(world, pos), pos); + } } } } diff --git a/src/main/java/net/kyrptonaught/customportalapi/CustomPortalsMod.java b/src/main/java/net/kyrptonaught/customportalapi/CustomPortalsMod.java index 7f434c9..5dba007 100644 --- a/src/main/java/net/kyrptonaught/customportalapi/CustomPortalsMod.java +++ b/src/main/java/net/kyrptonaught/customportalapi/CustomPortalsMod.java @@ -62,7 +62,7 @@ public void onInitialize() { return TypedActionResult.pass(stack); })); - //CustomPortalBuilder.beginPortal().frameBlock(Blocks.GLOWSTONE).destDimID(new Identifier("the_nether")).lightWithWater().tintColor(46, 5, 25).registerPortal(); + CustomPortalBuilder.beginPortal().frameBlock(Blocks.GLOWSTONE).destDimID(new Identifier("the_end")).lightWithWater().tintColor(46, 5, 25).registerPortal(); //CustomPortalBuilder.beginPortal().frameBlock(Blocks.OBSIDIAN).destDimID(new Identifier("the_end")).tintColor(66, 135, 245).registerPortalForced(); // CustomPortalBuilder.beginPortal().frameBlock(Blocks.COBBLESTONE).lightWithItem(Items.STICK).destDimID(new Identifier("the_end")).tintColor(45, 24, 45).flatPortal().registerPortal(); //CustomPortalBuilder.beginPortal().frameBlock(Blocks.EMERALD_BLOCK).lightWithWater().destDimID(new Identifier("the_end")).tintColor(25, 76, 156).flatPortal().registerPortal(); From 9e795eb547835da511a1ece4c07af1ff4f9b213d Mon Sep 17 00:00:00 2001 From: TheRobbie72 Date: Thu, 23 May 2024 13:03:54 +0800 Subject: [PATCH 3/4] Final small changes --- .../java/net/kyrptonaught/customportalapi/CustomPortalsMod.java | 2 +- .../net/kyrptonaught/customportalapi/mixin/TrackBlockMixin.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/kyrptonaught/customportalapi/CustomPortalsMod.java b/src/main/java/net/kyrptonaught/customportalapi/CustomPortalsMod.java index 5dba007..cf5c4ac 100644 --- a/src/main/java/net/kyrptonaught/customportalapi/CustomPortalsMod.java +++ b/src/main/java/net/kyrptonaught/customportalapi/CustomPortalsMod.java @@ -62,7 +62,7 @@ public void onInitialize() { return TypedActionResult.pass(stack); })); - CustomPortalBuilder.beginPortal().frameBlock(Blocks.GLOWSTONE).destDimID(new Identifier("the_end")).lightWithWater().tintColor(46, 5, 25).registerPortal(); + //CustomPortalBuilder.beginPortal().frameBlock(Blocks.BEDROCK).destDimID(new Identifier("the_end")).lightWithWater().tintColor(46, 5, 25).registerPortal(); //CustomPortalBuilder.beginPortal().frameBlock(Blocks.OBSIDIAN).destDimID(new Identifier("the_end")).tintColor(66, 135, 245).registerPortalForced(); // CustomPortalBuilder.beginPortal().frameBlock(Blocks.COBBLESTONE).lightWithItem(Items.STICK).destDimID(new Identifier("the_end")).tintColor(45, 24, 45).flatPortal().registerPortal(); //CustomPortalBuilder.beginPortal().frameBlock(Blocks.EMERALD_BLOCK).lightWithWater().destDimID(new Identifier("the_end")).tintColor(25, 76, 156).flatPortal().registerPortal(); diff --git a/src/main/java/net/kyrptonaught/customportalapi/mixin/TrackBlockMixin.java b/src/main/java/net/kyrptonaught/customportalapi/mixin/TrackBlockMixin.java index 1314b35..25fd0c4 100644 --- a/src/main/java/net/kyrptonaught/customportalapi/mixin/TrackBlockMixin.java +++ b/src/main/java/net/kyrptonaught/customportalapi/mixin/TrackBlockMixin.java @@ -164,7 +164,7 @@ protected void connectToCustomPortal(ServerWorld level, BlockPos pos, BlockState } @Inject(method = "scheduledTick", at = @At("HEAD"), cancellable = true) - private void trackBlock$tick(BlockState state, ServerWorld level, BlockPos pos, Random p_60465_, CallbackInfo ci) { + private void CPAtrackBlockTick(BlockState state, ServerWorld level, BlockPos pos, Random p_60465_, CallbackInfo ci) { TrackPropagator.onRailAdded(level, pos, state); if (!state.get(SHAPE) .isPortal()) From ccd572b3d72e89a29a58e719ee4c7be16927022d Mon Sep 17 00:00:00 2001 From: TheRobbie72 Date: Fri, 24 May 2024 00:14:24 +0800 Subject: [PATCH 4/4] Fixed player dismounting in Creative Mode --- .../compat/create/CreateMixinPlugin.java | 3 ++- .../customportalapi/mixin/DCEntityMixin.java | 18 ++++++++++++++++++ src/main/resources/customportalapi.mixins.json | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/main/java/net/kyrptonaught/customportalapi/mixin/DCEntityMixin.java diff --git a/src/main/java/net/kyrptonaught/customportalapi/compat/create/CreateMixinPlugin.java b/src/main/java/net/kyrptonaught/customportalapi/compat/create/CreateMixinPlugin.java index 4a11127..82bfe81 100644 --- a/src/main/java/net/kyrptonaught/customportalapi/compat/create/CreateMixinPlugin.java +++ b/src/main/java/net/kyrptonaught/customportalapi/compat/create/CreateMixinPlugin.java @@ -21,7 +21,8 @@ public final class CreateMixinPlugin implements IMixinConfigPlugin { private static final Supplier TRUE = () -> true; private static final Map> CONDITIONS = ImmutableMap.of( - "net.kyrptonaught.customportalapi.mixin.TrackBlockMixin", () -> FabricLoader.getInstance().isModLoaded("create") + "net.kyrptonaught.customportalapi.mixin.TrackBlockMixin", () -> FabricLoader.getInstance().isModLoaded("create"), + "net.kyrptonaught.customportalapi.mixin.DCEntityMixin", () -> FabricLoader.getInstance().isModLoaded("create") ); @Override diff --git a/src/main/java/net/kyrptonaught/customportalapi/mixin/DCEntityMixin.java b/src/main/java/net/kyrptonaught/customportalapi/mixin/DCEntityMixin.java new file mode 100644 index 0000000..d1040ee --- /dev/null +++ b/src/main/java/net/kyrptonaught/customportalapi/mixin/DCEntityMixin.java @@ -0,0 +1,18 @@ +package net.kyrptonaught.customportalapi.mixin; + +import com.simibubi.create.content.trains.entity.Carriage.DimensionalCarriageEntity; +import net.kyrptonaught.customportalapi.interfaces.EntityInCustomPortal; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(DimensionalCarriageEntity.class) +public abstract class DCEntityMixin { + @Inject(method = "dismountPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;resetNetherPortalCooldown()V")) + public void CPAPortalCooldown(ServerWorld sLevel, ServerPlayerEntity sp, Integer seat, boolean capture, CallbackInfo ci) { + ((EntityInCustomPortal)(Object)sp).setDidTP(true); + } +} diff --git a/src/main/resources/customportalapi.mixins.json b/src/main/resources/customportalapi.mixins.json index 14f7c66..723f07e 100644 --- a/src/main/resources/customportalapi.mixins.json +++ b/src/main/resources/customportalapi.mixins.json @@ -5,6 +5,7 @@ "compatibilityLevel": "JAVA_16", "plugin": "net.kyrptonaught.customportalapi.compat.create.CreateMixinPlugin", "mixins": [ + "DCEntityMixin", "EntityMixin", "ServerPlayerMixin", "portalLighters.AbstractFireMixin",