mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
port Minecart settings and WASD controls patch
This commit is contained in:
@@ -1,236 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sat, 29 Jun 2019 02:32:40 -0500
|
||||
Subject: [PATCH] Minecart settings and WASD controls
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 5e8a5e8e4120420a170c4733ae217e7948cef46c..3ea226168519e07b10d015f4c9b2b369569daf11 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1439,6 +1439,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
if (this.isInvulnerableTo(world, source)) {
|
||||
return false;
|
||||
} else {
|
||||
+ if (source.is(net.minecraft.tags.DamageTypeTags.IS_FALL) && getRootVehicle() instanceof net.minecraft.world.entity.vehicle.AbstractMinecart && level().purpurConfig.minecartControllable && !level().purpurConfig.minecartControllableFallDamage) return false; // Purpur - Minecart settings and WASD controls
|
||||
Entity entity = source.getEntity();
|
||||
|
||||
if (entity instanceof net.minecraft.world.entity.player.Player) {
|
||||
diff --git a/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
index cdc8606ffe5c75ee19d92e9f86f26b2a502d765e..d0c93f87795d7162bbfb3fdadadb6ae1c5fdaeeb 100644
|
||||
--- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
+++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
@@ -92,6 +92,10 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
private double flyingY = 0.95;
|
||||
private double flyingZ = 0.95;
|
||||
public Double maxSpeed;
|
||||
+ // Purpur start - Minecart settings and WASD controls
|
||||
+ public double storedMaxSpeed;
|
||||
+ public boolean isNewBehavior;
|
||||
+ // Purpur end - Minecart settings and WASD controls
|
||||
// CraftBukkit end
|
||||
public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API
|
||||
|
||||
@@ -100,8 +104,13 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
this.blocksBuilding = true;
|
||||
if (AbstractMinecart.useExperimentalMovement(world)) {
|
||||
this.behavior = new NewMinecartBehavior(this);
|
||||
+ this.isNewBehavior = true; // Purpur - Minecart settings and WASD controls
|
||||
} else {
|
||||
this.behavior = new OldMinecartBehavior(this);
|
||||
+ // Purpur start - Minecart settings and WASD controls
|
||||
+ this.isNewBehavior = false;
|
||||
+ maxSpeed = storedMaxSpeed = world.purpurConfig.minecartMaxSpeed;
|
||||
+ // Purpur end - Minecart settings and WASD controls
|
||||
}
|
||||
|
||||
}
|
||||
@@ -289,6 +298,14 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
+ // Purpur start - Minecart settings and WASD controls
|
||||
+ if (!this.isNewBehavior) {
|
||||
+ if (storedMaxSpeed != level().purpurConfig.minecartMaxSpeed) {
|
||||
+ maxSpeed = storedMaxSpeed = level().purpurConfig.minecartMaxSpeed;
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Minecart settings and WASD controls
|
||||
+
|
||||
// CraftBukkit start
|
||||
double prevX = this.getX();
|
||||
double prevY = this.getY();
|
||||
@@ -426,16 +443,63 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
this.behavior.moveAlongTrack(world);
|
||||
}
|
||||
|
||||
+ // Purpur start - Minecart settings and WASD controls
|
||||
+ private Double lastSpeed;
|
||||
+
|
||||
+ public double getControllableSpeed() {
|
||||
+ BlockState blockState = level().getBlockState(this.blockPosition());
|
||||
+ if (!blockState.isSolid()) {
|
||||
+ blockState = level().getBlockState(this.blockPosition().relative(Direction.DOWN));
|
||||
+ }
|
||||
+ Double speed = level().purpurConfig.minecartControllableBlockSpeeds.get(blockState.getBlock());
|
||||
+ if (!blockState.isSolid()) {
|
||||
+ speed = lastSpeed;
|
||||
+ }
|
||||
+ if (speed == null) {
|
||||
+ speed = level().purpurConfig.minecartControllableBaseSpeed;
|
||||
+ }
|
||||
+ return lastSpeed = speed;
|
||||
+ }
|
||||
+ // Purpur end - Minecart settings and WASD controls
|
||||
+
|
||||
protected void comeOffTrack(ServerLevel world) {
|
||||
double d0 = this.getMaxSpeed(world);
|
||||
Vec3 vec3d = this.getDeltaMovement();
|
||||
|
||||
this.setDeltaMovement(Mth.clamp(vec3d.x, -d0, d0), vec3d.y, Mth.clamp(vec3d.z, -d0, d0));
|
||||
+
|
||||
+ // Purpur start - Minecart settings and WASD controls
|
||||
+ if (level().purpurConfig.minecartControllable && !isInWater() && !isInLava() && !passengers.isEmpty()) {
|
||||
+ Entity passenger = passengers.get(0);
|
||||
+ if (passenger instanceof net.minecraft.server.level.ServerPlayer player) {
|
||||
+ net.minecraft.world.entity.player.Input lastClientInput = player.getLastClientInput();
|
||||
+ float forward = (lastClientInput.forward() == lastClientInput.backward() ? 0.0F : lastClientInput.forward() ? 1.0F : -1.0F);
|
||||
+ if (lastClientInput.jump() && this.onGround) {
|
||||
+ setDeltaMovement(new Vec3(getDeltaMovement().x, level().purpurConfig.minecartControllableHopBoost, getDeltaMovement().z));
|
||||
+ }
|
||||
+ if (forward != 0.0F) {
|
||||
+ Vector velocity = player.getBukkitEntity().getEyeLocation().getDirection().normalize().multiply(getControllableSpeed());
|
||||
+ if (forward < 0.0) {
|
||||
+ velocity.multiply(-0.5);
|
||||
+ }
|
||||
+ setDeltaMovement(new Vec3(velocity.getX(), getDeltaMovement().y, velocity.getZ()));
|
||||
+ }
|
||||
+ this.setYRot(passenger.getYRot() - 90);
|
||||
+ maxUpStep = level().purpurConfig.minecartControllableStepHeight;
|
||||
+ } else {
|
||||
+ maxUpStep = 0.0F;
|
||||
+ }
|
||||
+ } else {
|
||||
+ maxUpStep = 0.0F;
|
||||
+ }
|
||||
+ // Purpur end - Minecart settings and WASD controls
|
||||
+
|
||||
if (this.onGround()) {
|
||||
// CraftBukkit start - replace magic numbers with our variables
|
||||
this.setDeltaMovement(new Vec3(this.getDeltaMovement().x * this.derailedX, this.getDeltaMovement().y * this.derailedY, this.getDeltaMovement().z * this.derailedZ));
|
||||
// CraftBukkit end
|
||||
}
|
||||
+ else if (level().purpurConfig.minecartControllable) setDeltaMovement(new Vec3(getDeltaMovement().x * derailedX, getDeltaMovement().y, getDeltaMovement().z * derailedZ)); // Purpur - Minecart settings and WASD controls
|
||||
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
if (!this.onGround()) {
|
||||
diff --git a/net/minecraft/world/item/MinecartItem.java b/net/minecraft/world/item/MinecartItem.java
|
||||
index 7153d9ed12276a0f2d8b8a17c79734aa25ed1fa5..a82faf7f07cd71c8748979a726b1e7857d88e195 100644
|
||||
--- a/net/minecraft/world/item/MinecartItem.java
|
||||
+++ b/net/minecraft/world/item/MinecartItem.java
|
||||
@@ -35,8 +35,9 @@ public class MinecartItem extends Item {
|
||||
BlockState iblockdata = world.getBlockState(blockposition);
|
||||
|
||||
if (!iblockdata.is(BlockTags.RAILS)) {
|
||||
- return InteractionResult.FAIL;
|
||||
- } else {
|
||||
+ if (!world.purpurConfig.minecartPlaceAnywhere) return InteractionResult.FAIL; // Purpur - Minecart settings and WASD controls
|
||||
+ if (iblockdata.isSolid()) blockposition = blockposition.relative(context.getClickedFace());
|
||||
+ } // else { // Purpur - Minecart settings and WASD controls
|
||||
ItemStack itemstack = context.getItemInHand();
|
||||
RailShape blockpropertytrackposition = iblockdata.getBlock() instanceof BaseRailBlock ? (RailShape) iblockdata.getValue(((BaseRailBlock) iblockdata.getBlock()).getShapeProperty()) : RailShape.NORTH_SOUTH;
|
||||
double d0 = 0.0D;
|
||||
@@ -80,6 +81,6 @@ public class MinecartItem extends Item {
|
||||
itemstack.shrink(1);
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
- }
|
||||
+ // } // Purpur - Minecart settings and WASD controls
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
index 8c0f332a1a0918f60226d969918ae7fe4fe74166..6376b8b3ff444f4cab93e2bb5d2becc77c33c118 100644
|
||||
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
@@ -99,7 +99,7 @@ public abstract class BlockBehaviour implements FeatureElement {
|
||||
protected final float jumpFactor;
|
||||
protected final boolean dynamicShape;
|
||||
protected final FeatureFlagSet requiredFeatures;
|
||||
- protected final BlockBehaviour.Properties properties;
|
||||
+ public final BlockBehaviour.Properties properties; // Purpur - protected -> public
|
||||
protected final Optional<ResourceKey<LootTable>> drops;
|
||||
protected final String descriptionId;
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
index 1cc5c2f6b2d110174a2c79d26386f96301050834..21e3931d64d32e69b8ba6f7e6d1a9bf044c7c9a8 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
||||
@@ -96,6 +96,68 @@ public class PurpurWorldConfig {
|
||||
armorstandStepHeight = (float) getDouble("gameplay-mechanics.armorstand.step-height", armorstandStepHeight);
|
||||
}
|
||||
|
||||
+ public double minecartMaxSpeed = 0.4D;
|
||||
+ public boolean minecartPlaceAnywhere = false;
|
||||
+ public boolean minecartControllable = false;
|
||||
+ public float minecartControllableStepHeight = 1.0F;
|
||||
+ public double minecartControllableHopBoost = 0.5D;
|
||||
+ public boolean minecartControllableFallDamage = true;
|
||||
+ public double minecartControllableBaseSpeed = 0.1D;
|
||||
+ public Map<Block, Double> minecartControllableBlockSpeeds = new HashMap<>();
|
||||
+ private void minecartSettings() {
|
||||
+ if (PurpurConfig.version < 12) {
|
||||
+ boolean oldBool = getBoolean("gameplay-mechanics.controllable-minecarts.place-anywhere", minecartPlaceAnywhere);
|
||||
+ set("gameplay-mechanics.controllable-minecarts.place-anywhere", null);
|
||||
+ set("gameplay-mechanics.minecart.place-anywhere", oldBool);
|
||||
+ oldBool = getBoolean("gameplay-mechanics.controllable-minecarts.enabled", minecartControllable);
|
||||
+ set("gameplay-mechanics.controllable-minecarts.enabled", null);
|
||||
+ set("gameplay-mechanics.minecart.controllable.enabled", oldBool);
|
||||
+ double oldDouble = getDouble("gameplay-mechanics.controllable-minecarts.step-height", minecartControllableStepHeight);
|
||||
+ set("gameplay-mechanics.controllable-minecarts.step-height", null);
|
||||
+ set("gameplay-mechanics.minecart.controllable.step-height", oldDouble);
|
||||
+ oldDouble = getDouble("gameplay-mechanics.controllable-minecarts.hop-boost", minecartControllableHopBoost);
|
||||
+ set("gameplay-mechanics.controllable-minecarts.hop-boost", null);
|
||||
+ set("gameplay-mechanics.minecart.controllable.hop-boost", oldDouble);
|
||||
+ oldBool = getBoolean("gameplay-mechanics.controllable-minecarts.fall-damage", minecartControllableFallDamage);
|
||||
+ set("gameplay-mechanics.controllable-minecarts.fall-damage", null);
|
||||
+ set("gameplay-mechanics.minecart.controllable.fall-damage", oldBool);
|
||||
+ oldDouble = getDouble("gameplay-mechanics.controllable-minecarts.base-speed", minecartControllableBaseSpeed);
|
||||
+ set("gameplay-mechanics.controllable-minecarts.base-speed", null);
|
||||
+ set("gameplay-mechanics.minecart.controllable.base-speed", oldDouble);
|
||||
+ ConfigurationSection section = getConfigurationSection("gameplay-mechanics.controllable-minecarts.block-speed");
|
||||
+ if (section != null) {
|
||||
+ for (String key : section.getKeys(false)) {
|
||||
+ if ("grass-block".equals(key)) key = "grass_block"; // oopsie
|
||||
+ oldDouble = section.getDouble(key, minecartControllableBaseSpeed);
|
||||
+ set("gameplay-mechanics.controllable-minecarts.block-speed." + key, null);
|
||||
+ set("gameplay-mechanics.minecart.controllable.block-speed." + key, oldDouble);
|
||||
+ }
|
||||
+ set("gameplay-mechanics.controllable-minecarts.block-speed", null);
|
||||
+ }
|
||||
+ set("gameplay-mechanics.controllable-minecarts", null);
|
||||
+ }
|
||||
+
|
||||
+ minecartMaxSpeed = getDouble("gameplay-mechanics.minecart.max-speed", minecartMaxSpeed);
|
||||
+ minecartPlaceAnywhere = getBoolean("gameplay-mechanics.minecart.place-anywhere", minecartPlaceAnywhere);
|
||||
+ minecartControllable = getBoolean("gameplay-mechanics.minecart.controllable.enabled", minecartControllable);
|
||||
+ minecartControllableStepHeight = (float) getDouble("gameplay-mechanics.minecart.controllable.step-height", minecartControllableStepHeight);
|
||||
+ minecartControllableHopBoost = getDouble("gameplay-mechanics.minecart.controllable.hop-boost", minecartControllableHopBoost);
|
||||
+ minecartControllableFallDamage = getBoolean("gameplay-mechanics.minecart.controllable.fall-damage", minecartControllableFallDamage);
|
||||
+ minecartControllableBaseSpeed = getDouble("gameplay-mechanics.minecart.controllable.base-speed", minecartControllableBaseSpeed);
|
||||
+ ConfigurationSection section = getConfigurationSection("gameplay-mechanics.minecart.controllable.block-speed");
|
||||
+ if (section != null) {
|
||||
+ for (String key : section.getKeys(false)) {
|
||||
+ Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(key));
|
||||
+ if (block != Blocks.AIR) {
|
||||
+ minecartControllableBlockSpeeds.put(block, section.getDouble(key, minecartControllableBaseSpeed));
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ set("gameplay-mechanics.minecart.controllable.block-speed.grass_block", 0.3D);
|
||||
+ set("gameplay-mechanics.minecart.controllable.block-speed.stone", 0.5D);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
public boolean idleTimeoutKick = true;
|
||||
public boolean idleTimeoutTickNearbyEntities = true;
|
||||
public boolean idleTimeoutCountAsSleeping = false;
|
||||
@@ -0,0 +1,148 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sat, 29 Jun 2019 02:32:40 -0500
|
||||
Subject: [PATCH] Minecart settings and WASD controls
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index a1ebdd491e79fff8e224095ee6058cd550c009f4..764d1433c92a52cdcaf9534a22a3a23486095969 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1227,6 +1227,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
if (this.isInvulnerableTo(level, damageSource)) {
|
||||
return false;
|
||||
} else {
|
||||
+ if (damageSource.is(net.minecraft.tags.DamageTypeTags.IS_FALL) && getRootVehicle() instanceof net.minecraft.world.entity.vehicle.AbstractMinecart && level().purpurConfig.minecartControllable && !level().purpurConfig.minecartControllableFallDamage) return false; // Purpur - Minecart settings and WASD controls
|
||||
Entity entity = damageSource.getEntity();
|
||||
if (!( // Paper - split the if statement. If below statement is false, hurtServer would not have been evaluated. Return false.
|
||||
!(entity instanceof Player player && !this.canHarmPlayer(player))
|
||||
diff --git a/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
index 9e15e7159cf98b3928110df9eae6de93793bf44e..6df4d736d94b9e49a3eb3d59a329e37127aa64cd 100644
|
||||
--- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
+++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||
@@ -83,6 +83,10 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
private double flyingY = 0.95;
|
||||
private double flyingZ = 0.95;
|
||||
public Double maxSpeed;
|
||||
+ // Purpur start - Minecart settings and WASD controls
|
||||
+ public double storedMaxSpeed;
|
||||
+ public boolean isNewBehavior;
|
||||
+ // Purpur end - Minecart settings and WASD controls
|
||||
public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -91,8 +95,13 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
this.blocksBuilding = true;
|
||||
if (useExperimentalMovement(level)) {
|
||||
this.behavior = new NewMinecartBehavior(this);
|
||||
+ this.isNewBehavior = true; // Purpur - Minecart settings and WASD controls
|
||||
} else {
|
||||
this.behavior = new OldMinecartBehavior(this);
|
||||
+ // Purpur start - Minecart settings and WASD controls
|
||||
+ this.isNewBehavior = false;
|
||||
+ maxSpeed = storedMaxSpeed = level.purpurConfig.minecartMaxSpeed;
|
||||
+ // Purpur end - Minecart settings and WASD controls
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,6 +267,14 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
+ // Purpur start - Minecart settings and WASD controls
|
||||
+ if (!this.isNewBehavior) {
|
||||
+ if (storedMaxSpeed != level().purpurConfig.minecartMaxSpeed) {
|
||||
+ maxSpeed = storedMaxSpeed = level().purpurConfig.minecartMaxSpeed;
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end - Minecart settings and WASD controls
|
||||
+
|
||||
// CraftBukkit start
|
||||
double prevX = this.getX();
|
||||
double prevY = this.getY();
|
||||
@@ -394,15 +411,61 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||
this.behavior.moveAlongTrack(level);
|
||||
}
|
||||
|
||||
+ // Purpur start - Minecart settings and WASD controls
|
||||
+ private Double lastSpeed;
|
||||
+
|
||||
+ public double getControllableSpeed() {
|
||||
+ BlockState blockState = level().getBlockState(this.blockPosition());
|
||||
+ if (!blockState.isSolid()) {
|
||||
+ blockState = level().getBlockState(this.blockPosition().relative(Direction.DOWN));
|
||||
+ }
|
||||
+ Double speed = level().purpurConfig.minecartControllableBlockSpeeds.get(blockState.getBlock());
|
||||
+ if (!blockState.isSolid()) {
|
||||
+ speed = lastSpeed;
|
||||
+ }
|
||||
+ if (speed == null) {
|
||||
+ speed = level().purpurConfig.minecartControllableBaseSpeed;
|
||||
+ }
|
||||
+ return lastSpeed = speed;
|
||||
+ }
|
||||
+ // Purpur end - Minecart settings and WASD controls
|
||||
+
|
||||
protected void comeOffTrack(ServerLevel level) {
|
||||
double maxSpeed = this.getMaxSpeed(level);
|
||||
Vec3 deltaMovement = this.getDeltaMovement();
|
||||
this.setDeltaMovement(Mth.clamp(deltaMovement.x, -maxSpeed, maxSpeed), deltaMovement.y, Mth.clamp(deltaMovement.z, -maxSpeed, maxSpeed));
|
||||
+
|
||||
+ // Purpur start - Minecart settings and WASD controls
|
||||
+ if (level().purpurConfig.minecartControllable && !isInWater() && !isInLava() && !passengers.isEmpty()) {
|
||||
+ Entity passenger = passengers.get(0);
|
||||
+ if (passenger instanceof net.minecraft.server.level.ServerPlayer player) {
|
||||
+ net.minecraft.world.entity.player.Input lastClientInput = player.getLastClientInput();
|
||||
+ float forward = (lastClientInput.forward() == lastClientInput.backward() ? 0.0F : lastClientInput.forward() ? 1.0F : -1.0F);
|
||||
+ if (lastClientInput.jump() && this.onGround) {
|
||||
+ setDeltaMovement(new Vec3(getDeltaMovement().x, level().purpurConfig.minecartControllableHopBoost, getDeltaMovement().z));
|
||||
+ }
|
||||
+ if (forward != 0.0F) {
|
||||
+ org.bukkit.util.Vector velocity = player.getBukkitEntity().getEyeLocation().getDirection().normalize().multiply(getControllableSpeed());
|
||||
+ if (forward < 0.0) {
|
||||
+ velocity.multiply(-0.5);
|
||||
+ }
|
||||
+ setDeltaMovement(new Vec3(velocity.getX(), getDeltaMovement().y, velocity.getZ()));
|
||||
+ }
|
||||
+ this.setYRot(passenger.getYRot() - 90);
|
||||
+ maxUpStep = level().purpurConfig.minecartControllableStepHeight;
|
||||
+ } else {
|
||||
+ maxUpStep = 0.0F;
|
||||
+ }
|
||||
+ } else {
|
||||
+ maxUpStep = 0.0F;
|
||||
+ }
|
||||
+ // Purpur end - Minecart settings and WASD controls
|
||||
if (this.onGround()) {
|
||||
// CraftBukkit start - replace magic numbers with our variables
|
||||
this.setDeltaMovement(new Vec3(this.getDeltaMovement().x * this.derailedX, this.getDeltaMovement().y * this.derailedY, this.getDeltaMovement().z * this.derailedZ));
|
||||
// CraftBukkit end
|
||||
}
|
||||
+ else if (level().purpurConfig.minecartControllable) setDeltaMovement(new Vec3(getDeltaMovement().x * derailedX, getDeltaMovement().y, getDeltaMovement().z * derailedZ)); // Purpur - Minecart settings and WASD controls
|
||||
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
if (!this.onGround()) {
|
||||
diff --git a/net/minecraft/world/item/MinecartItem.java b/net/minecraft/world/item/MinecartItem.java
|
||||
index 620069daba04d48b57fc933328eda77f6ca9333e..0403b9b01994269d394820e8c8710ba1b9808bf0 100644
|
||||
--- a/net/minecraft/world/item/MinecartItem.java
|
||||
+++ b/net/minecraft/world/item/MinecartItem.java
|
||||
@@ -30,8 +30,9 @@ public class MinecartItem extends Item {
|
||||
BlockPos clickedPos = context.getClickedPos();
|
||||
BlockState blockState = level.getBlockState(clickedPos);
|
||||
if (!blockState.is(BlockTags.RAILS)) {
|
||||
- return InteractionResult.FAIL;
|
||||
- } else {
|
||||
+ if (!level.purpurConfig.minecartPlaceAnywhere) return InteractionResult.FAIL; // Purpur - Minecart settings and WASD controls
|
||||
+ if (blockState.isSolid()) clickedPos = clickedPos.relative(context.getClickedFace());
|
||||
+ } // else { // Purpur - Minecart settings and WASD controls
|
||||
ItemStack itemInHand = context.getItemInHand();
|
||||
RailShape railShape = blockState.getBlock() instanceof BaseRailBlock
|
||||
? blockState.getValue(((BaseRailBlock)blockState.getBlock()).getShapeProperty())
|
||||
@@ -72,6 +73,6 @@ public class MinecartItem extends Item {
|
||||
itemInHand.shrink(1);
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
- }
|
||||
+ // } // Purpur - Minecart settings and WASD controls
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.monster.Shulker;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -82,6 +84,68 @@ public class PurpurWorldConfig {
|
||||
armorstandStepHeight = (float) getDouble("gameplay-mechanics.armorstand.step-height", armorstandStepHeight);
|
||||
}
|
||||
|
||||
public double minecartMaxSpeed = 0.4D;
|
||||
public boolean minecartPlaceAnywhere = false;
|
||||
public boolean minecartControllable = false;
|
||||
public float minecartControllableStepHeight = 1.0F;
|
||||
public double minecartControllableHopBoost = 0.5D;
|
||||
public boolean minecartControllableFallDamage = true;
|
||||
public double minecartControllableBaseSpeed = 0.1D;
|
||||
public Map<Block, Double> minecartControllableBlockSpeeds = new HashMap<>();
|
||||
private void minecartSettings() {
|
||||
if (PurpurConfig.version < 12) {
|
||||
boolean oldBool = getBoolean("gameplay-mechanics.controllable-minecarts.place-anywhere", minecartPlaceAnywhere);
|
||||
set("gameplay-mechanics.controllable-minecarts.place-anywhere", null);
|
||||
set("gameplay-mechanics.minecart.place-anywhere", oldBool);
|
||||
oldBool = getBoolean("gameplay-mechanics.controllable-minecarts.enabled", minecartControllable);
|
||||
set("gameplay-mechanics.controllable-minecarts.enabled", null);
|
||||
set("gameplay-mechanics.minecart.controllable.enabled", oldBool);
|
||||
double oldDouble = getDouble("gameplay-mechanics.controllable-minecarts.step-height", minecartControllableStepHeight);
|
||||
set("gameplay-mechanics.controllable-minecarts.step-height", null);
|
||||
set("gameplay-mechanics.minecart.controllable.step-height", oldDouble);
|
||||
oldDouble = getDouble("gameplay-mechanics.controllable-minecarts.hop-boost", minecartControllableHopBoost);
|
||||
set("gameplay-mechanics.controllable-minecarts.hop-boost", null);
|
||||
set("gameplay-mechanics.minecart.controllable.hop-boost", oldDouble);
|
||||
oldBool = getBoolean("gameplay-mechanics.controllable-minecarts.fall-damage", minecartControllableFallDamage);
|
||||
set("gameplay-mechanics.controllable-minecarts.fall-damage", null);
|
||||
set("gameplay-mechanics.minecart.controllable.fall-damage", oldBool);
|
||||
oldDouble = getDouble("gameplay-mechanics.controllable-minecarts.base-speed", minecartControllableBaseSpeed);
|
||||
set("gameplay-mechanics.controllable-minecarts.base-speed", null);
|
||||
set("gameplay-mechanics.minecart.controllable.base-speed", oldDouble);
|
||||
ConfigurationSection section = getConfigurationSection("gameplay-mechanics.controllable-minecarts.block-speed");
|
||||
if (section != null) {
|
||||
for (String key : section.getKeys(false)) {
|
||||
if ("grass-block".equals(key)) key = "grass_block"; // oopsie
|
||||
oldDouble = section.getDouble(key, minecartControllableBaseSpeed);
|
||||
set("gameplay-mechanics.controllable-minecarts.block-speed." + key, null);
|
||||
set("gameplay-mechanics.minecart.controllable.block-speed." + key, oldDouble);
|
||||
}
|
||||
set("gameplay-mechanics.controllable-minecarts.block-speed", null);
|
||||
}
|
||||
set("gameplay-mechanics.controllable-minecarts", null);
|
||||
}
|
||||
|
||||
minecartMaxSpeed = getDouble("gameplay-mechanics.minecart.max-speed", minecartMaxSpeed);
|
||||
minecartPlaceAnywhere = getBoolean("gameplay-mechanics.minecart.place-anywhere", minecartPlaceAnywhere);
|
||||
minecartControllable = getBoolean("gameplay-mechanics.minecart.controllable.enabled", minecartControllable);
|
||||
minecartControllableStepHeight = (float) getDouble("gameplay-mechanics.minecart.controllable.step-height", minecartControllableStepHeight);
|
||||
minecartControllableHopBoost = getDouble("gameplay-mechanics.minecart.controllable.hop-boost", minecartControllableHopBoost);
|
||||
minecartControllableFallDamage = getBoolean("gameplay-mechanics.minecart.controllable.fall-damage", minecartControllableFallDamage);
|
||||
minecartControllableBaseSpeed = getDouble("gameplay-mechanics.minecart.controllable.base-speed", minecartControllableBaseSpeed);
|
||||
ConfigurationSection section = getConfigurationSection("gameplay-mechanics.minecart.controllable.block-speed");
|
||||
if (section != null) {
|
||||
for (String key : section.getKeys(false)) {
|
||||
Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(key));
|
||||
if (block != Blocks.AIR) {
|
||||
minecartControllableBlockSpeeds.put(block, section.getDouble(key, minecartControllableBaseSpeed));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
set("gameplay-mechanics.minecart.controllable.block-speed.grass_block", 0.3D);
|
||||
set("gameplay-mechanics.minecart.controllable.block-speed.stone", 0.5D);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean idleTimeoutKick = true;
|
||||
public boolean idleTimeoutTickNearbyEntities = true;
|
||||
public boolean idleTimeoutCountAsSleeping = false;
|
||||
|
||||
Reference in New Issue
Block a user