Skip to content

Commit

Permalink
1.19 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysdh540 committed Aug 28, 2023
1 parent d231729 commit 62b6a2c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
6 changes: 3 additions & 3 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# DO NOT EDIT
# Generated by the build script. Change mcVer property to change minecraft version.

POST_MC_1_19_2=
PRE_CURRENT_MC_1_19_2=
MC_1_19_2=
POST_CURRENT_MC_1_19_2=
PRE_MC_1_20_1=
PRE_CURRENT_MC_1_20_1=
MC_1_20_1=
POST_CURRENT_MC_1_20_1=
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
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 @@ -23,17 +25,37 @@
@Mixin(ExtendoGripItem.class)
public class ExtendoGripItemMixin {

@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>> g() {
@Unique
static Supplier<Multimap<Attribute, AttributeModifier>> singleRange() {
AttributeModifier am = new AttributeModifier(UUID.fromString("7f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier",
CUConfigs.server().singleExtendoGripRange.get(), AttributeModifier.Operation.ADDITION);
CUConfigs.server().singleExtendoGripRange.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;doubleRangeModifier:Ljava/util/function/Supplier;"))
private static Supplier<Multimap<Attribute, AttributeModifier>> a() {
@Unique
static Supplier<Multimap<Attribute, AttributeModifier>> doubleRange() {
AttributeModifier am = new AttributeModifier(UUID.fromString("8f7dbdb2-0d0d-458a-aa40-ac7633691f66"), "Range modifier",
CUConfigs.server().doubleExtendoGripRange.get(), AttributeModifier.Operation.ADDITION);
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();
}

@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();
}

@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();
}

@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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

import dev.rdh.createunlimited.config.CUConfigs;

#if PRE_CURRENT_MC_1_19_2
import net.minecraftforge.api.fml.event.config.ModConfigEvents;
#elif POST_CURRENT_MC_1_20_1
import fuzs.forgeconfigapiport.api.config.v2.ModConfigEvents;
#endif
import net.fabricmc.api.ModInitializer;

public class CreateUnlimitedFabric implements ModInitializer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public static boolean isDevEnv() {
}

public static Attribute getReachAttribute() {
#if POST_CURRENT_MC_1_20_1
return ForgeMod.BLOCK_REACH.get();
#elif PRE_CURRENT_MC_1_19_2
return ForgeMod.REACH_DISTANCE.get();
#endif
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ forgix_version=1.2.6
shadow_version=8.1.1

# the mc version to compile against (see their respective property files for version-specific stuff)
mcVer=1.20.1
mcVer=1.19.2

# which versions to put in the build.properties file
mc_versions=1.19.2, 1.20.1
Expand Down

0 comments on commit 62b6a2c

Please sign in to comment.