Skip to content

Commit

Permalink
fix: pipe interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Litt1eBai committed Sep 10, 2024
1 parent e85b99d commit 5249303
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 18 deletions.
32 changes: 28 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ plugins {
id "me.shedaniel.unified-publishing" version "0.1.+"
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
// vendor = JvmVendorSpec.ANY
}
}

tasks.named('wrapper', Wrapper).configure {
// Define wrapper values here so as to not have to always do so when updating gradlew.properties.
// Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
Expand Down Expand Up @@ -56,6 +63,10 @@ tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

static def isJetBrainsRuntime() {
return System.getProperty('java.vm.vendor').contains('JetBrains')
}

neoForge {
// Specify the version of NeoForge to use.
version = project.neo_version
Expand All @@ -76,6 +87,16 @@ neoForge {
sourceSet(sourceSets.main)
}
}

if (isJetBrainsRuntime()) {
runs {
client {
jvmArgument("-XX:+AllowEnhancedClassRedefinition")
jvmArgument("-XX:HotswapAgent=fatjar")
}
}
}

runs {
client {
client()
Expand All @@ -89,6 +110,9 @@ neoForge {
systemProperty 'mixin.env.remapRefMap', 'true'
systemProperty 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"

// jvmArgument("-Dmixin.debug.verbose=true")
// jvmArgument("-Dmixin.debug.export=true")

// These arguments allow for optional authentication with Mojang servers.
// If you want to authenticate, put these properties in GRADLE_HOME/gradle.properties.
// By default, this is C:\Users\<your username>\.gradle\gradle.properties on Windows or ~/.gradle/gradle.properties on Linux/MacOS.
Expand All @@ -107,8 +131,8 @@ neoForge {
}

// Add mixin config to runtime
// programArgument('-mixin.config=' + project.getProperty('mod_id') + '.mixins.json')
// programArgument('-mixin.config=' + project.getProperty('mod_id') + '.data.mixins.json')
programArgument('-mixin.config=' + project.getProperty('mod_id') + '.mixins.json')
programArgument('-mixin.config=' + project.getProperty('mod_id') + '.data.mixins.json')
}

server {
Expand All @@ -122,7 +146,7 @@ neoForge {
systemProperty 'mixin.debug.export', 'true'

// Add mixin config to runtime
// programArgument('-mixin.config=' + project.getProperty('mod_id') + '.mixins.json')
programArgument('-mixin.config=' + project.getProperty('mod_id') + '.mixins.json')
programArgument('-mixin.config=' + project.getProperty('mod_id') + '.data.mixins.json')
}

Expand All @@ -137,7 +161,7 @@ neoForge {
systemProperty 'mixin.debug.export', 'true'

// Add mixin config to runtime
// programArgument('-mixin.config=' + project.getProperty('mod_id') + '.mixins.json')
programArgument('-mixin.config=' + project.getProperty('mod_id') + '.mixins.json')
programArgument('-mixin.config=' + project.getProperty('mod_id') + '.data.mixins.json')

// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
Expand Down
17 changes: 3 additions & 14 deletions src/main/java/org/teacon/xkdeco/mixin/air_duct/EntityMixin.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.teacon.xkdeco.mixin.air_duct;

import org.spongepowered.asm.mixin.Debug;
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.teacon.xkdeco.XKDeco;
import org.teacon.xkdeco.block.AirDuctBlock;
import org.teacon.xkdeco.duck.XKDPlayer;
import org.teacon.xkdeco.util.CommonProxy;
Expand Down Expand Up @@ -37,27 +39,14 @@ public abstract class EntityMixin {
private BlockPos blockPosition;

@Shadow
public abstract BlockState getFeetBlockState();
public abstract BlockState getInBlockState();

@Shadow
public abstract AABB getBoundingBox();

@Shadow
public abstract boolean hasPose(Pose pPose);

@Inject(method = "canEnterPose", at = @At("HEAD"), cancellable = true)
private void xkdeco$canEnterPose(Pose pPose, CallbackInfoReturnable<Boolean> cir) {
if (pPose != Pose.STANDING && pPose != Pose.CROUCHING) {
return;
}
if (!(this instanceof XKDPlayer player)) {
return;
}
if (player.xkdeco$forceSwimmingPose() || getFeetBlockState().getBlock() instanceof AirDuctBlock) {
cir.setReturnValue(false);
}
}

@Inject(method = "isInvisible", at = @At("HEAD"), cancellable = true)
private void xkdeco$isInvisible(CallbackInfoReturnable<Boolean> cir) {
if (this instanceof XKDPlayer player && player.xkdeco$isHidingInAirDuct()) {
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/teacon/xkdeco/mixin/air_duct/PlayerMixin.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package org.teacon.xkdeco.mixin.air_duct;

import net.minecraft.world.level.block.state.BlockState;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.teacon.xkdeco.XKDeco;
import org.teacon.xkdeco.block.AirDuctBlock;
import org.teacon.xkdeco.block.XKDBlock;
import org.teacon.xkdeco.duck.XKDPlayer;

Expand Down Expand Up @@ -54,6 +60,19 @@ protected PlayerMixin(EntityType<? extends LivingEntity> pEntityType, Level pLev
}
}

@Inject(method = "canPlayerFitWithinBlocksAndEntitiesWhen", at = @At("HEAD"), cancellable = true)
private void xkdeco$canPlayerFitWithinBlocksAndEntitiesWhen(Pose pose, CallbackInfoReturnable<Boolean> cir) {
if (pose != Pose.STANDING && pose != Pose.CROUCHING) {
return;
}
if (!(this instanceof XKDPlayer player)) {
return;
}
if (player.xkdeco$forceSwimmingPose() || getInBlockState().getBlock() instanceof AirDuctBlock) {
cir.setReturnValue(false);
}
}

@Override
public boolean xkdeco$isHidingInAirDuct() {
return xkdeco$isHidingInAirDuct;
Expand Down
Empty file.

0 comments on commit 5249303

Please sign in to comment.