Skip to content

Commit

Permalink
mixin moment
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysdh540 committed Aug 28, 2023
1 parent 62b6a2c commit 9060d93
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;

import org.spongepowered.asm.mixin.Final;
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.Redirect;
Expand All @@ -26,36 +24,36 @@
public class ExtendoGripItemMixin {

@Unique
static Supplier<Multimap<Attribute, AttributeModifier>> singleRange() {
private static Supplier<Multimap<Attribute, AttributeModifier>> createUnlimited$singleRange() {
AttributeModifier am = new AttributeModifier(UUID.fromString("7f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier",
CUConfigs.server().singleExtendoGripRange.get(), AttributeModifier.Operation.ADDITION);
return Suppliers.memoize(() -> ImmutableMultimap.of(Util.getReachAttribute(), am));
}

@Unique
static Supplier<Multimap<Attribute, AttributeModifier>> doubleRange() {
private static Supplier<Multimap<Attribute, AttributeModifier>> createUnlimited$doubleRange() {
AttributeModifier am = new AttributeModifier(UUID.fromString("8f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier",
CUConfigs.server().doubleExtendoGripRange.get(), AttributeModifier.Operation.ADDITION);
return Suppliers.memoize(() -> ImmutableMultimap.of(Util.getReachAttribute(), am));
}

@Redirect(method = "holdingExtendoGripIncreasesRange", at = @At(value = "FIELD", target = "Lcom/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem;rangeModifier:Ljava/util/function/Supplier;"))
private static Supplier<Multimap<Attribute, AttributeModifier>> mainSingle() {
return singleRange();
return createUnlimited$singleRange();
}

@Redirect(method = "holdingExtendoGripIncreasesRange", at = @At(value = "FIELD", target = "Lcom/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem;doubleRangeModifier:Ljava/util/function/Supplier;"))
private static Supplier<Multimap<Attribute, AttributeModifier>> mainDouble() {
return doubleRange();
return createUnlimited$doubleRange();
}

@Redirect(method = "addReachToJoiningPlayersHoldingExtendo", at = @At(value = "FIELD", target = "Lcom/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem;rangeModifier:Ljava/util/function/Supplier;"))
private static Supplier<Multimap<Attribute, AttributeModifier>> joinSingle() {
return singleRange();
return createUnlimited$singleRange();
}

@Redirect(method = "addReachToJoiningPlayersHoldingExtendo", at = @At(value = "FIELD", target = "Lcom/simibubi/create/content/equipment/extendoGrip/ExtendoGripItem;doubleRangeModifier:Ljava/util/function/Supplier;"))
private static Supplier<Multimap<Attribute, AttributeModifier>> joinDouble() {
return doubleRange();
return createUnlimited$doubleRange();
}
}

0 comments on commit 9060d93

Please sign in to comment.