mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Adjust damage amount when removing the alicorn amulet
This commit is contained in:
parent
207320f6a0
commit
5a88206bf5
4 changed files with 84 additions and 4 deletions
|
@ -11,6 +11,7 @@ import net.minecraft.entity.*;
|
|||
import net.minecraft.entity.data.DataTracker;
|
||||
import net.minecraft.entity.data.TrackedData;
|
||||
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||
import net.minecraft.entity.decoration.ItemFrameEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -129,10 +130,12 @@ public class ItemImpl implements Equine<ItemEntity> {
|
|||
return physics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Race getSpecies() {
|
||||
return Race.fromName(entity.getDataTracker().get(ITEM_RACE), Race.HUMAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpecies(Race race) {
|
||||
entity.getDataTracker().set(ITEM_RACE, Race.REGISTRY.getId(race).toString());
|
||||
}
|
||||
|
@ -207,5 +210,9 @@ public class ItemImpl implements Equine<ItemEntity> {
|
|||
default void interactWithPlayer(IItemEntity entity, PlayerEntity player) {
|
||||
|
||||
}
|
||||
|
||||
default void inFrameTick(ItemFrameEntity entity) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,12 @@ import com.minelittlepony.unicopia.USounds;
|
|||
import com.minelittlepony.unicopia.entity.*;
|
||||
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
||||
import com.minelittlepony.unicopia.entity.player.*;
|
||||
import com.minelittlepony.unicopia.particle.FollowingParticleEffect;
|
||||
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||
import com.minelittlepony.unicopia.particle.UParticles;
|
||||
import com.minelittlepony.unicopia.trinkets.TrinketsDelegate;
|
||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||
import com.minelittlepony.unicopia.util.VecHelper;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
@ -24,16 +28,20 @@ import net.minecraft.entity.*;
|
|||
import net.minecraft.entity.Entity.RemovalReason;
|
||||
import net.minecraft.entity.attribute.*;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.decoration.ItemFrameEntity;
|
||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.world.LocalDifficulty;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -126,12 +134,14 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
|
|||
return;
|
||||
}
|
||||
|
||||
float attachedTime = timeWorn / 100F;
|
||||
float attachedTime = timeWorn / ItemTracker.HOURS;
|
||||
|
||||
LocalDifficulty difficulty = wearer.asWorld().getLocalDifficulty(wearer.getOrigin());
|
||||
float amount = attachedTime * (1 + difficulty.getClampedLocalDifficulty());
|
||||
float amount = Math.min(entity.getMaxHealth() - 1, (attachedTime / 4) * (1 + difficulty.getClampedLocalDifficulty()));
|
||||
|
||||
amount = Math.min(amount, entity.getMaxHealth());
|
||||
if (timeWorn > ItemTracker.DAYS) {
|
||||
amount++;
|
||||
}
|
||||
|
||||
if (entity instanceof PlayerEntity player) {
|
||||
player.getHungerManager().setFoodLevel(1);
|
||||
|
@ -142,7 +152,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
|
|||
entity.addStatusEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 200, 3));
|
||||
}
|
||||
|
||||
if (attachedTime > 120) {
|
||||
if (attachedTime > ItemTracker.HOURS / 2) {
|
||||
entity.takeKnockback(1, 1, 1);
|
||||
wearer.updateVelocity();
|
||||
}
|
||||
|
@ -281,4 +291,37 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab
|
|||
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inFrameTick(ItemFrameEntity entity) {
|
||||
Random rng = entity.world.random;
|
||||
|
||||
if (rng.nextInt(500) == 0) {
|
||||
entity.world.playSound(null, entity.getBlockPos(), USounds.ITEM_ALICORN_AMULET_AMBIENT, SoundCategory.HOSTILE, 0.5F, 1);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
entity.world.addParticle(rng.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME,
|
||||
rng.nextTriangular(entity.getX(), 0.5),
|
||||
rng.nextTriangular(entity.getY(), 0.5),
|
||||
rng.nextTriangular(entity.getZ(), 0.5),
|
||||
0, 0, 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ((entity.age / 1000) % 10 == 0 && entity.age % 50 == 0) {
|
||||
for (Entity target : VecHelper.findInRange(entity, entity.world, entity.getPos(), 10, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR)) {
|
||||
for (ItemStack equipment : target.getItemsEquipped()) {
|
||||
if (equipment.getItem() == UItems.GROGARS_BELL) {
|
||||
ChargeableItem chargeable = (ChargeableItem)UItems.GROGARS_BELL;
|
||||
if (chargeable.hasCharge(equipment)) {
|
||||
ChargeableItem.consumeEnergy(equipment, 3);
|
||||
ParticleUtils.spawnParticle(entity.world,
|
||||
new FollowingParticleEffect(UParticles.HEALTH_DRAIN, entity, 0.4F)
|
||||
.withChild(ParticleTypes.COMPOSTER), target.getEyePos(), Vec3d.ZERO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package com.minelittlepony.unicopia.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.ItemImpl.ClingyItem;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.decoration.AbstractDecorationEntity;
|
||||
import net.minecraft.entity.decoration.ItemFrameEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@Mixin(AbstractDecorationEntity.class)
|
||||
abstract class MixinAbstractDecorationEntity extends Entity {
|
||||
MixinAbstractDecorationEntity() { super(null, null); }
|
||||
|
||||
@Inject(method = "tick()V", at = @At("HEAD"), cancellable = true)
|
||||
private void beforeTick(CallbackInfo info) {
|
||||
final Object _this = this;
|
||||
if (_this instanceof ItemFrameEntity self) {
|
||||
ItemStack stack = self.getHeldItemStack();
|
||||
if (stack.getItem() instanceof ClingyItem item) {
|
||||
item.inFrameTick(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
"refmap": "unicopia.mixin.refmap.json",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"MixinAbstractDecorationEntity",
|
||||
"MixinBlazeEntity",
|
||||
"MixinBlockEntity",
|
||||
"MixinBlockItem",
|
||||
|
|
Loading…
Reference in a new issue