Skip to content

Commit

Permalink
hopefully working reach effect
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Oct 24, 2023
1 parent b6cb323 commit 827cd18
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/net/frozenblock/wilderwild/WilderWild.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import net.frozenblock.wilderwild.registry.RegisterItems;
import net.frozenblock.wilderwild.registry.RegisterLootTables;
import net.frozenblock.wilderwild.registry.RegisterMemoryModuleTypes;
import net.frozenblock.wilderwild.registry.RegisterMobEffects;
import net.frozenblock.wilderwild.registry.RegisterParticles;
import net.frozenblock.wilderwild.registry.RegisterProperties;
import net.frozenblock.wilderwild.registry.RegisterResources;
Expand Down Expand Up @@ -163,6 +164,7 @@ public void onInitialize(String modId, ModContainer container) {
RegisterParticles.registerParticles();
RegisterResources.register(container);
RegisterProperties.init();
RegisterMobEffects.init();
RegisterCriteria.init();

RegisterFeatures.init();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.frozenblock.wilderwild.mixin.client.crab;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.frozenblock.wilderwild.registry.RegisterMobEffects;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

@Environment(EnvType.CLIENT)
@Mixin(MultiPlayerGameMode.class)
public class MultiPlayerGameModeMixin {

@Shadow @Final
private Minecraft minecraft;

@ModifyReturnValue(method = "getPickRange", at = @At("RETURN"))
public float wilderWild$getPickRange(float original) {
if (this.minecraft.player != null && this.minecraft.player.hasEffect(RegisterMobEffects.REACH)) {
int amplifier = this.minecraft.player.getEffect(RegisterMobEffects.REACH).getAmplifier() + 1;
return original + (amplifier * 0.75F);
}
return original;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.frozenblock.wilderwild.mixin.entity.crab;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.frozenblock.wilderwild.registry.RegisterMobEffects;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerPlayerGameMode;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(ServerPlayerGameMode.class)
public class ServerPlayerGameModeMixin {

@Shadow @Final
protected ServerPlayer player;

@ModifyExpressionValue(method = "handleBlockBreakAction", at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;MAX_INTERACTION_DISTANCE:D"))
public double wilderWild$handleBlockBreakAction(double original) {
if (this.player != null && this.player.hasEffect(RegisterMobEffects.REACH)) {
int amplifier = this.player.getEffect(RegisterMobEffects.REACH).getAmplifier() + 1;
return original + (amplifier * 0.75);
}
return original;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2023 FrozenBlock
* This file is part of Wilder Wild.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <https://www.gnu.org/licenses/>.
*/

package net.frozenblock.wilderwild.registry;

import net.frozenblock.wilderwild.misc.WilderSharedConstants;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import org.jetbrains.annotations.NotNull;

public final class RegisterMobEffects {

public static final MobEffect REACH = register("reach_boost", new MobEffect(MobEffectCategory.BENEFICIAL, 16646020));

private RegisterMobEffects() {
throw new UnsupportedOperationException("RegisterMobEffects contains only static declarations.");
}

public static void init() {
WilderSharedConstants.logWild("Registering MobEffects for", WilderSharedConstants.UNSTABLE_LOGGING);
}

private static @NotNull MobEffect register(String id, MobEffect entry) {
return Registry.register(BuiltInRegistries.MOB_EFFECT, WilderSharedConstants.id(id), entry);
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/wilderwild/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
"item.wilderwild.yellow_firefly_bottle": "Yellow Firefly in a Bottle",
"item.wilderwild.split_coconut": "Split Coconut",
"item.wilderwild.prickly_pear": "Prickly Pear",
"effect.wilderwild.reach_boost": "Reach Boost",
"option.wilderwild.component.title": "Wilder Wild Options",
"option.wilderwild.block": "Block",
"option.wilderwild.entity": "Entity",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/main/resources/wilderwild.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"entity.boat.BoatDropsMixin",
"entity.boat.BoatTypeMixin",
"entity.boat.ChestBoatDropsMixin",
"entity.crab.ServerPlayerGameModeMixin",
"entity.crab.VibrationSystemTickerMixin",
"entity.crab.WallClimberNavigationMixin",
"entity.easter.EntityMixin",
Expand Down Expand Up @@ -89,6 +90,7 @@
"client": [
"client.allay.AllayModelMixin",
"client.brush.LevelRendererMixin",
"client.crab.MultiPlayerGameModeMixin",
"client.easter.MerpSlimeRenderer",
"client.easter.ScottTheWozMixin",
"client.easter.StellaWardenModel",
Expand Down

0 comments on commit 827cd18

Please sign in to comment.