Skip to content

Commit

Permalink
Fix knockback (LeavesMC#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lumine1909 committed Sep 15, 2024
1 parent be7be8b commit 594ca27
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions patches/server/0010-Fakeplayer-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1918,16 +1918,17 @@ index 0000000000000000000000000000000000000000..0db337866c71283464d026a4f230016b
+}
diff --git a/src/main/java/org/leavesmc/leaves/bot/ServerBot.java b/src/main/java/org/leavesmc/leaves/bot/ServerBot.java
new file mode 100644
index 0000000000000000000000000000000000000000..d53e0784633071f185682c4ca584b2416324e63c
index 0000000000000000000000000000000000000000..d84b15b6e366e158a9ca99a63c05417f087e7c27
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/bot/ServerBot.java
@@ -0,0 +1,535 @@
@@ -0,0 +1,543 @@
+package org.leavesmc.leaves.bot;
+
+import com.google.common.collect.ImmutableMap;
+import com.mojang.authlib.GameProfile;
+import com.mojang.authlib.properties.Property;
+import io.papermc.paper.adventure.PaperAdventure;
+import io.papermc.paper.event.entity.EntityKnockbackEvent;
+import net.minecraft.core.BlockPos;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.protocol.Packet;
Expand All @@ -1947,6 +1948,7 @@ index 0000000000000000000000000000000000000000..d53e0784633071f185682c4ca584b241
+import net.minecraft.world.damagesource.DamageSource;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.EquipmentSlot;
+import net.minecraft.world.entity.ai.attributes.Attributes;
+import net.minecraft.world.entity.item.ItemEntity;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.inventory.ChestMenu;
Expand All @@ -1956,6 +1958,7 @@ index 0000000000000000000000000000000000000000..d53e0784633071f185682c4ca584b241
+import net.minecraft.world.level.gameevent.GameEvent;
+import net.minecraft.world.level.portal.DimensionTransition;
+import net.minecraft.world.phys.EntityHitResult;
+import net.minecraft.world.phys.Vec3;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
Expand Down Expand Up @@ -2004,6 +2007,8 @@ index 0000000000000000000000000000000000000000..d53e0784633071f185682c4ca584b241
+
+ public int removeTaskId = -1;
+
+ private Vec3 knockback = Vec3.ZERO;
+
+ public ServerBot(MinecraftServer server, ServerLevel world, GameProfile profile) {
+ super(server, world, profile, ClientInformation.createDefault());
+ this.entityData.set(Player.DATA_PLAYER_MODE_CUSTOMISATION, (byte) -2);
Expand Down Expand Up @@ -2241,6 +2246,8 @@ index 0000000000000000000000000000000000000000..d53e0784633071f185682c4ca584b241
+ }
+
+ this.updateIsUnderwater();
+ this.addDeltaMovement(knockback);
+ knockback = Vec3.ZERO;
+ this.livingEntityTick();
+ // this.moveCloak();
+
Expand Down Expand Up @@ -2268,7 +2275,7 @@ index 0000000000000000000000000000000000000000..d53e0784633071f185682c4ca584b241
+ return this.getBukkitPlayer().getLocation();
+ }
+
+ /*
+
+ @Override
+ public void knockback(double strength, double x, double z, @Nullable Entity attacker, @NotNull EntityKnockbackEvent.Cause cause) {
+ strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
Expand All @@ -2280,6 +2287,7 @@ index 0000000000000000000000000000000000000000..d53e0784633071f185682c4ca584b241
+ }
+ }
+
+ /*
+ private void updateLocation() {
+ this.velocity = new Vec3(this.xxa, this.yya, this.zza);
+
Expand Down

0 comments on commit 594ca27

Please sign in to comment.