Skip to content

Commit

Permalink
Switch to using expressions for spawnSprintParticle
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Oct 20, 2024
1 parent 4cee25a commit d8793cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ mod_version = 3.1.0
# https://fabricmc.net/develop
minecraft_version = 1.21.1
minecraft_dependency = >=1.21.1 <=1.21.2
loader_version = 0.16.5
loader_version = 0.16.7
fabric_api_version = 0.105.0+1.21.1

# Mixin Extra's
# https://github.com/LlamaLad7/MixinExtras
# If set to 'none' Mixin Extra's will not be JiJ'd and Porting Lib will use whatever version fabric loader bundles
# ! Reason: Currently using the same one bundled by fabric loader
mixin_extras_version = none
# ! Reason: Expressions
mixin_extras_version = 0.5.0-beta.3

# Mappings
# https://parchmentmc.org/docs/getting-started
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.github.fabricators_of_create.porting_lib.mixin.common;

import com.llamalad7.mixinextras.expression.Definition;
import com.llamalad7.mixinextras.expression.Expression;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;

import io.github.fabricators_of_create.porting_lib.core.util.INBTSerializable;
Expand All @@ -8,11 +11,7 @@
import org.jetbrains.annotations.Nullable;
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.LocalCapture;

import io.github.fabricators_of_create.porting_lib.block.CustomRunningEffectsBlock;
import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -54,23 +53,15 @@ public CompoundTag serializeNBT(HolderLookup.Provider provider) {

// RUNNING EFFECTS

@Inject(
method = "spawnSprintParticle",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;",
shift = At.Shift.BY,
by = 2
),
cancellable = true
)
public void port_lib$spawnSprintParticle(CallbackInfo ci, @Local BlockPos pos, @Local BlockState state) {
@Definition(id = "blockState", local = @Local(type = BlockState.class))
@Definition(id = "getRenderShape", method = "Lnet/minecraft/world/level/block/state/BlockState;getRenderShape()Lnet/minecraft/world/level/block/RenderShape;")
@Definition(id = "INVISIBLE", field = "Lnet/minecraft/world/level/block/RenderShape;INVISIBLE:Lnet/minecraft/world/level/block/RenderShape;")
@Expression("blockState.getRenderShape() != INVISIBLE")
@ModifyExpressionValue(method = "spawnSprintParticle", at = @At("MIXINEXTRAS:EXPRESSION"))
public boolean port_lib$spawnSprintParticle(boolean original, @Local BlockPos pos, @Local BlockState state) {
//noinspection ConstantValue
if (state.getBlock() instanceof CustomRunningEffectsBlock custom &&
custom.addRunningEffects(state, level, pos, (Entity) (Object) this)) {
ci.cancel();
}
return original && !(state.getBlock() instanceof CustomRunningEffectsBlock custom &&
custom.addRunningEffects(state, level, pos, (Entity) (Object) this));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"priority": 951,
"package": "io.github.fabricators_of_create.porting_lib.mixin",
"plugin": "io.github.fabricators_of_create.porting_lib.mixin.PortingLibMixinPlugin",
"minMixinExtrasVersion": "0.5.0-beta.3",
"compatibilityLevel": "JAVA_17",
"mixins": [
"client.BoatRendererMixin",
Expand Down

0 comments on commit d8793cf

Please sign in to comment.