mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 23:27:59 +01:00
Rebalance the metamorphosis potion and turn players' hearts black when they're turning
This commit is contained in:
parent
cf07f5d341
commit
f210d1cd9f
5 changed files with 88 additions and 10 deletions
|
@ -23,6 +23,7 @@ public class Commands {
|
||||||
DisguiseCommand.register(dispatcher);
|
DisguiseCommand.register(dispatcher);
|
||||||
TraitCommand.register(dispatcher);
|
TraitCommand.register(dispatcher);
|
||||||
EmoteCommand.register(dispatcher);
|
EmoteCommand.register(dispatcher);
|
||||||
|
ManaCommand.register(dispatcher);
|
||||||
});
|
});
|
||||||
Object game = FabricLoader.getInstance().getGameInstance();
|
Object game = FabricLoader.getInstance().getGameInstance();
|
||||||
if (game instanceof MinecraftServer) {
|
if (game instanceof MinecraftServer) {
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.minelittlepony.unicopia.command;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.entity.player.MagicReserves;
|
||||||
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.arguments.FloatArgumentType;
|
||||||
|
import net.minecraft.server.command.CommandManager;
|
||||||
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
public class ManaCommand {
|
||||||
|
static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
|
dispatcher.register(CommandManager
|
||||||
|
.literal("mana")
|
||||||
|
.then(CommandManager.argument("type", EnumArgumentType.of(ManaType.class)).executes(source -> {
|
||||||
|
var type = source.getArgument("type", ManaType.class);
|
||||||
|
var pony = Pony.of(source.getSource().getPlayer());
|
||||||
|
var bar = type.getBar(pony.getMagicalReserves());
|
||||||
|
|
||||||
|
source.getSource().getPlayer().sendMessage(Text.literal(type.name() + " is " + bar.get() + "/" + bar.getMax()));
|
||||||
|
return 0;
|
||||||
|
})
|
||||||
|
.then(CommandManager.argument("value", FloatArgumentType.floatArg()).executes(source -> {
|
||||||
|
var type = source.getArgument("type", ManaType.class);
|
||||||
|
var pony = Pony.of(source.getSource().getPlayer());
|
||||||
|
var bar = type.getBar(pony.getMagicalReserves());
|
||||||
|
|
||||||
|
bar.set(source.getArgument("value", Float.class));
|
||||||
|
source.getSource().getPlayer().sendMessage(Text.literal("Set " + type.name() + " to " + bar.get() + "/" + bar.getMax()));
|
||||||
|
return 0;
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ManaType {
|
||||||
|
EXERTION(MagicReserves::getExertion),
|
||||||
|
EXHAUSTION(MagicReserves::getExhaustion),
|
||||||
|
ENERGY(MagicReserves::getEnergy),
|
||||||
|
MANA(MagicReserves::getMana),
|
||||||
|
XP(MagicReserves::getXp);
|
||||||
|
|
||||||
|
private final Function<MagicReserves, MagicReserves.Bar> getter;
|
||||||
|
|
||||||
|
ManaType(Function<MagicReserves, MagicReserves.Bar> getter) {
|
||||||
|
this.getter = getter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MagicReserves.Bar getBar(MagicReserves reserves) {
|
||||||
|
return getter.apply(reserves);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,10 +11,7 @@ import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.entity.effect.*;
|
||||||
import net.minecraft.entity.effect.StatusEffect;
|
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
|
||||||
import net.minecraft.entity.effect.StatusEffectCategory;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
@ -22,7 +19,7 @@ import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
public class RaceChangeStatusEffect extends StatusEffect {
|
public class RaceChangeStatusEffect extends StatusEffect {
|
||||||
public static final int STAGE_DURATION = 50;
|
public static final int STAGE_DURATION = 200;
|
||||||
public static final int MAX_DURATION = Stage.VALUES.length * STAGE_DURATION + 1;
|
public static final int MAX_DURATION = Stage.VALUES.length * STAGE_DURATION + 1;
|
||||||
|
|
||||||
public static final StatusEffect CHANGE_RACE_EARTH = register(0x886F0F, Race.EARTH);
|
public static final StatusEffect CHANGE_RACE_EARTH = register(0x886F0F, Race.EARTH);
|
||||||
|
@ -41,6 +38,10 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasEffect(PlayerEntity player) {
|
||||||
|
return player.getStatusEffects().stream().anyMatch(effect -> effect.getEffectType() instanceof RaceChangeStatusEffect);
|
||||||
|
}
|
||||||
|
|
||||||
public RaceChangeStatusEffect(int color, Race race) {
|
public RaceChangeStatusEffect(int color, Race race) {
|
||||||
super(StatusEffectCategory.NEUTRAL, color);
|
super(StatusEffectCategory.NEUTRAL, color);
|
||||||
this.race = race;
|
this.race = race;
|
||||||
|
@ -85,10 +86,10 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
||||||
if (stage != Stage.DEATH && entity instanceof PlayerEntity) {
|
if (stage != Stage.DEATH && entity instanceof PlayerEntity) {
|
||||||
((PlayerEntity)entity).sendMessage(stage.getMessage(race), true);
|
((PlayerEntity)entity).sendMessage(stage.getMessage(race), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.damage(DamageSource.MAGIC, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entity.setHealth(1);
|
||||||
|
|
||||||
if (entity instanceof PlayerEntity) {
|
if (entity instanceof PlayerEntity) {
|
||||||
Pony pony = (Pony)eq;
|
Pony pony = (Pony)eq;
|
||||||
MagicReserves magic = pony.getMagicalReserves();
|
MagicReserves magic = pony.getMagicalReserves();
|
||||||
|
@ -110,11 +111,14 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
||||||
|
|
||||||
if (eq instanceof Pony pony) {
|
if (eq instanceof Pony pony) {
|
||||||
MagicReserves magic = pony.getMagicalReserves();
|
MagicReserves magic = pony.getMagicalReserves();
|
||||||
magic.getExertion().set(0.2F);
|
magic.getEnergy().set(0.6F);
|
||||||
|
magic.getExhaustion().set(0);
|
||||||
|
magic.getExertion().set(0);
|
||||||
pony.setDirty();
|
pony.setDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.damage(MagicalDamageSource.TRIBE_SWAP, Float.MAX_VALUE);
|
entity.damage(MagicalDamageSource.TRIBE_SWAP, Float.MAX_VALUE);
|
||||||
|
entity.setHealth(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,36 @@
|
||||||
package com.minelittlepony.unicopia.mixin.client;
|
package com.minelittlepony.unicopia.mixin.client;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.*;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.client.gui.UHud;
|
import com.minelittlepony.unicopia.client.gui.UHud;
|
||||||
|
import com.minelittlepony.unicopia.entity.effect.RaceChangeStatusEffect;
|
||||||
|
|
||||||
import net.minecraft.client.gui.hud.InGameHud;
|
import net.minecraft.client.gui.hud.InGameHud;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
@Mixin(InGameHud.class)
|
@Mixin(InGameHud.class)
|
||||||
public class MixinInGameHud {
|
abstract class MixinInGameHud {
|
||||||
@Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;F)V", at = @At("HEAD"))
|
@Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;F)V", at = @At("HEAD"))
|
||||||
private void onRender(MatrixStack stack, float tickDelta, CallbackInfo info) {
|
private void onRender(MatrixStack stack, float tickDelta, CallbackInfo info) {
|
||||||
UHud.INSTANCE.render((InGameHud)(Object)this, stack, tickDelta);
|
UHud.INSTANCE.render((InGameHud)(Object)this, stack, tickDelta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Mixin(targets = "net.minecraft.client.gui.hud.InGameHud$HeartType")
|
||||||
|
abstract class MixinInGameHud$HeartType {
|
||||||
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
|
@Inject(
|
||||||
|
method = "fromPlayerState(Lnet/minecraft/entity/player/PlayerEntity;F)Lnet/minecraft/client/gui/hud/InGameHud$HeartType;",
|
||||||
|
at = @At("RETURN"),
|
||||||
|
cancellable = true)
|
||||||
|
private static void onFromPlayerState(PlayerEntity player, CallbackInfoReturnable<Enum> cbi) {
|
||||||
|
if (RaceChangeStatusEffect.hasEffect(player)) {
|
||||||
|
cbi.setReturnValue(Enum.valueOf(cbi.getReturnValue().getClass(), "WITHERED"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,6 +39,7 @@
|
||||||
"client.MixinEntityRenderDispatcher",
|
"client.MixinEntityRenderDispatcher",
|
||||||
"client.MixinGameRenderer",
|
"client.MixinGameRenderer",
|
||||||
"client.MixinInGameHud",
|
"client.MixinInGameHud",
|
||||||
|
"client.MixinInGameHud$HeartType",
|
||||||
"client.MixinItem",
|
"client.MixinItem",
|
||||||
"client.MixinItemModels",
|
"client.MixinItemModels",
|
||||||
"client.MixinKeyboardInput",
|
"client.MixinKeyboardInput",
|
||||||
|
|
Loading…
Reference in a new issue