Skip to content

Commit

Permalink
Creative fly no clip (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Jun 27, 2023
1 parent 325f1c7 commit 9064ce4
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 2 deletions.
9 changes: 7 additions & 2 deletions patches/server/0004-Leaves-Server-Config-And-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ index a53514f2c510b29f596c361de7bc0b405c27e964..269c7ba0707db4fdc45a70000e0be892
.withRequiredArg()
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..0a7a28151137a34346c9c4aca1ba53f2b77ee55a
index 0000000000000000000000000000000000000000..5a93e6f42bcfde75818daad520da01cf5de6cc47
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -0,0 +1,747 @@
@@ -0,0 +1,752 @@
+package top.leavesmc.leaves;
+
+import com.destroystokyo.paper.util.SneakyThrow;
Expand Down Expand Up @@ -704,6 +704,11 @@ index 0000000000000000000000000000000000000000..0a7a28151137a34346c9c4aca1ba53f2
+ public static void registerCarpetRules() {
+ }
+
+ public static boolean creativeNoClip = false;
+ private static void creativeNoClip() {
+ creativeNoClip = getBoolean("settings.modify.creative-no-clip", creativeNoClip);
+ }
+
+ public static final class WorldConfig {
+
+ public final String worldName;
Expand Down
13 changes: 13 additions & 0 deletions patches/server/0070-Leaves-carpet-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ index 6c19d9b64830efe4b9d6f17d8ca92f88ad3475d5..fb6810289ac855e622d3970101f27b21

final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();

diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 4a7fa92d4f5bce5cbead17a5a5579a96a84dafad..d5f5a9f61a4a030246c12bf48c93139196475540 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -15,6 +15,8 @@ import top.leavesmc.leaves.bot.agent.Actions;
import top.leavesmc.leaves.profile.LeavesMinecraftSessionService;
import top.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol;
import top.leavesmc.leaves.util.MathUtils;
+import top.leavesmc.leaves.protocol.CarpetServerProtocol.CarpetRule;
+import top.leavesmc.leaves.protocol.CarpetServerProtocol.CarpetRules;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
diff --git a/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java
new file mode 100644
index 0000000000000000000000000000000000000000..afcbb7b8c9a6e933665500b068fe7c9111658df7
Expand Down
98 changes: 98 additions & 0 deletions patches/server/0071-Creative-fly-no-clip.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <[email protected]>
Date: Tue, 27 Jun 2023 09:26:58 +0800
Subject: [PATCH] Creative fly no clip


diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 58152160d609d0e9d105153aeb166a56a7955603..352ef747063f9cb1a26bf906f8cb52351ec4ae1d 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -242,8 +242,8 @@ public abstract class Player extends LivingEntity {

@Override
public void tick() {
- this.noPhysics = this.isSpectator();
- if (this.isSpectator()) {
+ this.noPhysics = this.isCreativeFlyOrSpectator(); // Leaves - creative no clip
+ if (this.isCreativeFlyOrSpectator()) { // Leaves - creative no clip
this.setOnGround(false);
}

@@ -415,7 +415,7 @@ public abstract class Player extends LivingEntity {

Pose entitypose1;

- if (!this.isSpectator() && !this.isPassenger() && !this.canEnterPose(entitypose)) {
+ if (!this.isCreativeFlyOrSpectator() && !this.isPassenger() && !this.canEnterPose(entitypose)) { // Leaves - creative no clip
if (this.canEnterPose(Pose.CROUCHING)) {
entitypose1 = Pose.CROUCHING;
} else {
@@ -576,7 +576,7 @@ public abstract class Player extends LivingEntity {
}

this.bob += (f - this.bob) * 0.4F;
- if (this.getHealth() > 0.0F && !this.isSpectator()) {
+ if (this.getHealth() > 0.0F && !this.isCreativeFlyOrSpectator()) { // Leaves - creative no clip
AABB axisalignedbb;

if (this.isPassenger() && !this.getVehicle().isRemoved()) {
@@ -2130,6 +2130,12 @@ public abstract class Player extends LivingEntity {
@Override
public abstract boolean isSpectator();

+ // Leaves start - creative no clip
+ public boolean isCreativeFlyOrSpectator() {
+ return isSpectator() || (top.leavesmc.leaves.LeavesConfig.creativeNoClip && isCreative() && getAbilities().flying);
+ }
+ // Leaves end - creative no clip
+
@Override
public boolean canBeHitByProjectile() {
return !this.isSpectator() && super.canBeHitByProjectile();
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
index 25a9c38c60d183bb65b14f4d7550ab98b431c218..118a5b4c0a5268d52c69b0cfd061dbccfacf81b4 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
@@ -151,7 +151,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
for (int i = 0; i < list.size(); ++i) {
Entity entity = (Entity) list.get(i);

- if (entity.getPistonPushReaction() != PushReaction.IGNORE) {
+ if (entity.getPistonPushReaction() != PushReaction.IGNORE && !(entity instanceof Player player && player.isCreativeFlyOrSpectator())) { // Leaves - creative no clip
entity.move(MoverType.SHULKER_BOX, new Vec3((axisalignedbb.getXsize() + 0.01D) * (double) enumdirection.getStepX(), (axisalignedbb.getYsize() + 0.01D) * (double) enumdirection.getStepY(), (axisalignedbb.getZsize() + 0.01D) * (double) enumdirection.getStepZ()));
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
index d9baa85962236c42219cf09d4f3129be93ff069c..c1bd06fbc2c5683888f7264c35c25feb31b00d67 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
@@ -19,6 +19,7 @@ import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntitySelector;
+import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ChunkPos;
@@ -128,7 +129,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
}

public static boolean canEntityTeleport(Entity entity) {
- return EntitySelector.NO_SPECTATORS.test(entity) && !entity.getRootVehicle().isOnPortalCooldown();
+ return EntitySelector.NO_SPECTATORS.test(entity) && !entity.getRootVehicle().isOnPortalCooldown() && !(entity instanceof Player player && player.isCreativeFlyOrSpectator()); // Leaves - creative no clip
}

public boolean isSpawning() {
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index d5f5a9f61a4a030246c12bf48c93139196475540..627bc22798ad6bbdb599f55a2a296920573bcaa6 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -595,6 +595,7 @@ public final class LeavesConfig {
}

public static void registerCarpetRules() {
+ CarpetRules.rules.put("creativeNoClip", new CarpetRule("carpet", "creativeNoClip", Boolean.toString(creativeNoClip)));
}

public static boolean creativeNoClip = false;

0 comments on commit 9064ce4

Please sign in to comment.