mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@996d529 Resend entity using the bundle packet (#9853) PaperMC/Paper@8cf2503 Updated Upstream (Bukkit/CraftBukkit) (#9876) PaperMC/Paper@2935067 Fix null item in sendEquipmentChange (#9869) PaperMC/Paper@b3cac04 Fix crash when version_history.json is empty (#9871) PaperMC/Paper@b1faa5d Fix PotionAPI ignores icon flag (#9864) PaperMC/Paper@52849f6 Cleanup disable explosion knockback patch (#9858) PaperMC/Paper@8b1ac39 Fix warden spawn reason from DEFAULT to NATURAL (#8744) PaperMC/Paper@c6fac38 fix UnsafeValues#loadAdvancement doesn't recalculate position (#9846) PaperMC/Paper@5bdfb29 Add player idle duration API (#9833) PaperMC/Paper@a81a384 Implement Velocity VarInt optimizations (#8418) PaperMC/Paper@415d708 [ci skip] Fix author in last patch PaperMC/Paper@3e4eaf2 [ci skip] Fix module derp PaperMC/Paper@5bb30ce Fix entity camera not being reset when cancelling spectating start/stop events (#9883) PaperMC/Paper@1865625 Fix NPE when no valid world is found on legacy Players (#9885)
125 lines
8.1 KiB
Diff
125 lines
8.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Thu, 25 Jul 2019 18:07:37 -0500
|
|
Subject: [PATCH] Implement elytra settings
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
index 5b80d41b267488d632492239298c94ded9ac40bb..d919966b056116dc2c0777250ecb492a68257d70 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
|
@@ -3556,7 +3556,16 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
|
int j = i / 10;
|
|
|
|
if (j % 2 == 0) {
|
|
- itemstack.hurtAndBreak(1, this, (entityliving) -> {
|
|
+ // Purpur start
|
|
+ int damage = level().purpurConfig.elytraDamagePerSecond;
|
|
+ if (level().purpurConfig.elytraDamageMultiplyBySpeed > 0) {
|
|
+ double speed = getDeltaMovement().lengthSqr();
|
|
+ if (speed > level().purpurConfig.elytraDamageMultiplyBySpeed) {
|
|
+ damage *= (int) speed;
|
|
+ }
|
|
+ }
|
|
+ itemstack.hurtAndBreak(damage, this, (entityliving) -> {
|
|
+ // Purpur end
|
|
entityliving.broadcastBreakEvent(EquipmentSlot.CHEST);
|
|
});
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
|
index 82b0bda3e35ec2157a477e1a17b2b46baadc97d9..0fc45b1048a1c4e0dc2bd1ae0437eecbe113cf96 100644
|
|
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
|
|
@@ -15,6 +15,7 @@ import net.minecraft.util.ByIdMap;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.InteractionResultHolder;
|
|
+import net.minecraft.world.entity.EquipmentSlot;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
|
|
import net.minecraft.world.item.context.UseOnContext;
|
|
@@ -69,6 +70,14 @@ public class FireworkRocketItem extends Item {
|
|
com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.getBukkitEntity());
|
|
if (event.callEvent() && world.addFreshEntity(fireworkRocketEntity)) {
|
|
user.awardStat(Stats.ITEM_USED.get(this));
|
|
+ // Purpur start
|
|
+ if (world.purpurConfig.elytraDamagePerFireworkBoost > 0) {
|
|
+ ItemStack chestItem = user.getItemBySlot(EquipmentSlot.CHEST);
|
|
+ if (chestItem.getItem() == Items.ELYTRA) {
|
|
+ chestItem.hurtAndBreak(world.purpurConfig.elytraDamagePerFireworkBoost, user, (entityliving) -> entityliving.broadcastBreakEvent(EquipmentSlot.CHEST));
|
|
+ }
|
|
+ }
|
|
+ // Purpur end
|
|
if (event.shouldConsume() && !user.getAbilities().instabuild) {
|
|
itemStack.shrink(1);
|
|
} else ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory();
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
index 25be1927304e497a6ebf9d9ec09525a5418095db..6e6f60554b36117a833949ef2f9a4b68f6518a1d 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
@@ -618,7 +618,7 @@ public final class ItemStack {
|
|
int j;
|
|
|
|
if (amount > 0) {
|
|
- j = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.UNBREAKING, this);
|
|
+ j = (getItem() == Items.ELYTRA && player != null && player.level().purpurConfig.elytraIgnoreUnbreaking) ? 0 : EnchantmentHelper.getItemEnchantmentLevel(Enchantments.UNBREAKING, this);
|
|
int k = 0;
|
|
|
|
for (int l = 0; j > 0 && l < amount; ++l) {
|
|
@@ -673,6 +673,12 @@ public final class ItemStack {
|
|
if (this.hurt(amount, entity.getRandom(), entity /*instanceof ServerPlayer ? (ServerPlayer) entity : null*/)) { // Paper - pass LivingEntity for EntityItemDamageEvent
|
|
breakCallback.accept(entity);
|
|
Item item = this.getItem();
|
|
+ // Purpur start
|
|
+ if (item == Items.ELYTRA) {
|
|
+ setDamageValue(item.getMaxDamage() - 1);
|
|
+ return;
|
|
+ }
|
|
+ // Purpur end
|
|
// CraftBukkit start - Check for item breaking
|
|
if (this.count == 1 && entity instanceof net.minecraft.world.entity.player.Player) {
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemBreakEvent((net.minecraft.world.entity.player.Player) entity, this);
|
|
diff --git a/src/main/java/net/minecraft/world/item/TridentItem.java b/src/main/java/net/minecraft/world/item/TridentItem.java
|
|
index 8078f127ff4b6e0aafb5804b9c02e237f79445b5..06c2f30b77a2c8aecc65e0c305f643d53798f364 100644
|
|
--- a/src/main/java/net/minecraft/world/item/TridentItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/TridentItem.java
|
|
@@ -130,6 +130,14 @@ public class TridentItem extends Item implements Vanishable {
|
|
f2 *= f6 / f5;
|
|
f3 *= f6 / f5;
|
|
f4 *= f6 / f5;
|
|
+
|
|
+ // Purpur start
|
|
+ ItemStack chestItem = entityhuman.getItemBySlot(EquipmentSlot.CHEST);
|
|
+ if (chestItem.getItem() == Items.ELYTRA && world.purpurConfig.elytraDamagePerTridentBoost > 0) {
|
|
+ chestItem.hurtAndBreak(world.purpurConfig.elytraDamagePerTridentBoost, entityhuman, (entity) -> entity.broadcastBreakEvent(EquipmentSlot.CHEST));
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
entityhuman.push((double) f2, (double) f3, (double) f4);
|
|
entityhuman.startAutoSpinAttack(20);
|
|
if (entityhuman.onGround()) {
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
index c48fae071a538a11739193f782232edfafb14de4..b34f95b6104b1aebd8c07cf279e168cdb074efb9 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -112,6 +112,19 @@ public class PurpurWorldConfig {
|
|
voidDamageDealt = getDouble("gameplay-mechanics.void-damage-dealt", voidDamageDealt);
|
|
}
|
|
|
|
+ public int elytraDamagePerSecond = 1;
|
|
+ public double elytraDamageMultiplyBySpeed = 0;
|
|
+ public boolean elytraIgnoreUnbreaking = false;
|
|
+ public int elytraDamagePerFireworkBoost = 0;
|
|
+ public int elytraDamagePerTridentBoost = 0;
|
|
+ private void elytraSettings() {
|
|
+ elytraDamagePerSecond = getInt("gameplay-mechanics.elytra.damage-per-second", elytraDamagePerSecond);
|
|
+ elytraDamageMultiplyBySpeed = getDouble("gameplay-mechanics.elytra.damage-multiplied-by-speed", elytraDamageMultiplyBySpeed);
|
|
+ elytraIgnoreUnbreaking = getBoolean("gameplay-mechanics.elytra.ignore-unbreaking", elytraIgnoreUnbreaking);
|
|
+ elytraDamagePerFireworkBoost = getInt("gameplay-mechanics.elytra.damage-per-boost.firework", elytraDamagePerFireworkBoost);
|
|
+ elytraDamagePerTridentBoost = getInt("gameplay-mechanics.elytra.damage-per-boost.trident", elytraDamagePerTridentBoost);
|
|
+ }
|
|
+
|
|
public double minecartMaxSpeed = 0.4D;
|
|
public boolean minecartPlaceAnywhere = false;
|
|
public boolean minecartControllable = false;
|