Skip to content

Commit

Permalink
Get BooleanProperty equals injection working using @WrapOperation o…
Browse files Browse the repository at this point in the history
…n the instanceof check
  • Loading branch information
jpenilla committed Aug 9, 2024
1 parent f4f7670 commit cbdcab7
Showing 1 changed file with 6 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package ca.spottedleaf.moonrise.mixin.blockstate_propertyaccess;

import ca.spottedleaf.moonrise.patches.blockstate_propertyaccess.PropertyAccess;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.Property;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Constant;

@Mixin(BooleanProperty.class)
abstract class BooleanPropertyMixin extends Property<Boolean> implements PropertyAccess<Boolean> {
Expand All @@ -19,35 +20,16 @@ protected BooleanPropertyMixin(String string, Class<Boolean> class_) {
* @reason Properties are identity comparable
* @author Spottedleaf
*/
/*
TODO: idk why this isn't working, we'll just redirect the super call for now and deal with the useless instanceof op
@WrapOperation(
method = "equals",
at = @At(
value = "CONSTANT",
opcode = Opcodes.INSTANCEOF,
args = "classValue=net/minecraft/world/level/block/state/properties/BooleanProperty"
constant = @Constant(
classValue = BooleanProperty.class,
ordinal = 0
)
)
private boolean skipFurtherComparison(final Object obj, final Operation<Boolean> orig) {
return false;
}
*/

/**
* @reason Properties are identity comparable
* @author Spottedleaf
*/
@Redirect(
method = "equals",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/block/state/properties/Property;equals(Ljava/lang/Object;)Z"
)
)
private boolean skipSuperCheck(final Property instance, final Object object) {
return false;
}

@Override
public final boolean moonrise$requiresDefaultImpl() {
Expand Down

0 comments on commit cbdcab7

Please sign in to comment.