Change potion throwing to chargeable
Charging too long makes you accidentally drink your potion This also significantly increases how far you can throw potions. Doesn't quite match bows still though.
This commit is contained in:
parent
a8bdbaa187
commit
b6a648fddf
|
|
@ -1,12 +1,54 @@
|
|||
package xyz.nearmisses.patience.mc_rebalance.mixin;
|
||||
|
||||
import net.minecraft.world.item.ThrowablePotionItem;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.projectile.ThrownPotion;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
@Mixin(ThrowablePotionItem.class)
|
||||
public class PotionThrowRework {
|
||||
@ModifyConstant(method="use", constant = @Constant(floatValue = 0.5F))
|
||||
private float teachSteveToThrow(float constant){return constant*1.8F;}
|
||||
public abstract class PotionThrowRework extends PotionItem implements ProjectileItem {
|
||||
public PotionThrowRework(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author emeraldquartz
|
||||
* @reason This fundamentally changes the way potions are managed in a way that can't be cleanly handled inside the original use() function.
|
||||
*/
|
||||
@Overwrite
|
||||
public @NotNull InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand interactionHand) {
|
||||
ItemStack itemStack = player.getItemInHand(interactionHand);
|
||||
|
||||
player.startUsingItem(interactionHand);
|
||||
return InteractionResultHolder.sidedSuccess(itemStack, level.isClientSide());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseUsing(ItemStack itemStack, Level level, LivingEntity livingEntity, int i){
|
||||
if( livingEntity instanceof Player player) {
|
||||
if (!level.isClientSide) {
|
||||
ThrownPotion thrownPotion = new ThrownPotion(level, player);
|
||||
thrownPotion.setItem(itemStack);
|
||||
i = Math.max(28-i, 4);
|
||||
|
||||
thrownPotion.shootFromRotation(player, player.getXRot(), player.getYRot(), -20.0F, 0.04F*i, 1.0F);
|
||||
level.addFreshEntity(thrownPotion);
|
||||
}
|
||||
|
||||
player.awardStat(Stats.ITEM_USED.get(this));
|
||||
itemStack.consume(1, player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull UseAnim getUseAnimation(ItemStack itemStack) {
|
||||
return UseAnim.BOW;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue