mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-28 03:19:22 +00:00
99 lines
5.5 KiB
Diff
99 lines
5.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
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 bdf4e0fc8c8efd61a44e31042b6117420f9b656f..4396849cfc3f75c320dfaea95843e75495dc3337 100644
|
|
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
|
@@ -598,6 +598,7 @@ public final class LeavesConfig {
|
|
}
|
|
|
|
public static void registerCarpetRules() {
|
|
+ CarpetRules.register(CarpetRule.of("carpet", "creativeNoClip", creativeNoClip));
|
|
}
|
|
|
|
public static boolean creativeNoClip = false;
|