From 18393d104d4c623ef11fa0ff25cd9a4685aee2f0 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sun, 28 Feb 2021 12:12:46 +0200 Subject: [PATCH] Feathers will now float gently to the ground when dropped --- .../com/minelittlepony/unicopia/UTags.java | 2 ++ .../unicopia/entity/ItemImpl.java | 23 +++++++++++++++++-- .../unicopia/tags/items/falls_slowly.json | 8 +++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/data/unicopia/tags/items/falls_slowly.json diff --git a/src/main/java/com/minelittlepony/unicopia/UTags.java b/src/main/java/com/minelittlepony/unicopia/UTags.java index 24cebd7c..169897ef 100644 --- a/src/main/java/com/minelittlepony/unicopia/UTags.java +++ b/src/main/java/com/minelittlepony/unicopia/UTags.java @@ -14,6 +14,8 @@ public interface UTags { Tag FAIRLY_TOXIC = item("fairly_toxic"); Tag SEVERELY_TOXIC = item("severely_toxic"); + Tag FALLS_SLOWLY = item("falls_slowly"); + Tag FRAGILE = block("fragile"); Tag INTERESTING = block("interesting"); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java b/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java index 5f1122e9..63726ac3 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java @@ -4,10 +4,12 @@ import java.util.Random; import com.minelittlepony.unicopia.Owned; import com.minelittlepony.unicopia.Race; +import com.minelittlepony.unicopia.UTags; import com.minelittlepony.unicopia.item.enchantment.UEnchantments; import com.minelittlepony.unicopia.util.VecHelper; import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.MovementType; import net.minecraft.entity.data.DataTracker; @@ -51,14 +53,13 @@ public class ItemImpl implements Equine, Owned { } ItemStack stack = owner.getStack(); + IItemEntity i = (IItemEntity)owner; if (!stack.isEmpty()) { Item item = stack.getItem(); ClingyItem clingy = item instanceof ClingyItem ? (ClingyItem)item : ClingyItem.DEFAULT; - IItemEntity i = (IItemEntity)owner; - if (clingy.isClingy(stack)) { Random rng = owner.world.random; @@ -84,6 +85,24 @@ public class ItemImpl implements Equine, Owned { }); } + if (stack.getItem().isIn(UTags.FALLS_SLOWLY)) { + if (!owner.isOnGround()) { + double ticks = ((Entity)owner).age; + double shift = Math.sin(ticks / 9D) / 9D; + double rise = Math.cos(ticks / 9D) * getPhysics().getGravitySignum(); + + owner.prevYaw = owner.prevYaw; + owner.yaw += 0.3F; + + owner.setVelocity( + owner.getVelocity() + .multiply(0.25, 0, 0.25) + .add(0, rise, 0) + .add(owner.getRotationVec(1)).normalize().multiply(shift) + ); + } + } + if (stack.getItem() instanceof TickableItem) { return ((TickableItem)stack.getItem()).onGroundTick(i) == ActionResult.SUCCESS; } diff --git a/src/main/resources/data/unicopia/tags/items/falls_slowly.json b/src/main/resources/data/unicopia/tags/items/falls_slowly.json new file mode 100644 index 00000000..9968a4d2 --- /dev/null +++ b/src/main/resources/data/unicopia/tags/items/falls_slowly.json @@ -0,0 +1,8 @@ +{ + "replace": false, + "values": [ + "minecraft:feather", + "unicopia:pegasus_feather", + "unicopia:gryphon_feather" + ] +}