mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 18:07:43 +01:00
Controllable minecarts fall damage option and slow down in air fix
This commit is contained in:
@@ -5,7 +5,7 @@ Subject: [PATCH] Controllable Minecarts
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
index 2291135ea..bc61aaff6 100644
|
||||
index 2291135eae..bc61aaff65 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
@@ -36,6 +36,12 @@ public class BlockPosition extends BaseBlockPosition {
|
||||
@@ -22,7 +22,7 @@ index 2291135ea..bc61aaff6 100644
|
||||
super(i, j, k);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index 76575ea5f..c8b1fbcf1 100644
|
||||
index ff412471c8..c5b4ee6ed3 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -99,9 +99,9 @@ public abstract class EntityLiving extends Entity {
|
||||
@@ -39,14 +39,16 @@ index 76575ea5f..c8b1fbcf1 100644
|
||||
protected double aV;
|
||||
protected double aW;
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityMinecartAbstract.java b/src/main/java/net/minecraft/server/EntityMinecartAbstract.java
|
||||
index 13fcb666e..d5e129678 100644
|
||||
index 9bc21ef8a1..a39b596afb 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityMinecartAbstract.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityMinecartAbstract.java
|
||||
@@ -445,12 +445,50 @@ public abstract class EntityMinecartAbstract extends Entity {
|
||||
@@ -445,16 +445,62 @@ public abstract class EntityMinecartAbstract extends Entity {
|
||||
|
||||
public void a(int i, int j, int k, boolean flag) {}
|
||||
|
||||
+ // Purpur start
|
||||
+ private Double lastSpeed;
|
||||
+
|
||||
+ public double getControllableSpeed() {
|
||||
+ BlockPosition position = new BlockPosition(this);
|
||||
+ Block block = world.getType(position).getBlock();
|
||||
@@ -54,10 +56,12 @@ index 13fcb666e..d5e129678 100644
|
||||
+ block = world.getType(position.shift(EnumDirection.DOWN)).getBlock();
|
||||
+ }
|
||||
+ Double speed = world.purpurConfig.controllableMinecartsBlockSpeeds.get(block);
|
||||
+ if (speed == null) {
|
||||
+ if (!block.material.isSolid()) {
|
||||
+ speed = lastSpeed;
|
||||
+ } else if (speed == null) {
|
||||
+ speed = world.purpurConfig.controllableMinecartsBaseSpeed;
|
||||
+ }
|
||||
+ return speed;
|
||||
+ return lastSpeed = speed;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
@@ -66,35 +70,55 @@ index 13fcb666e..d5e129678 100644
|
||||
Vec3D vec3d = this.getMot();
|
||||
|
||||
this.setMot(MathHelper.a(vec3d.x, -d0, d0), vec3d.y, MathHelper.a(vec3d.z, -d0, d0));
|
||||
if (this.onGround) {
|
||||
+ // Purpur start
|
||||
+ if (world.purpurConfig.controllableMinecarts && !isInWater() && !isInLava() && !passengers.isEmpty()) {
|
||||
+ Entity passenger = passengers.get(0);
|
||||
+ if (passenger instanceof EntityHuman) {
|
||||
+ EntityHuman entityhuman = (EntityHuman) passenger;
|
||||
+ if (entityhuman.jumping) {
|
||||
+ Vec3D mot = getMot();
|
||||
+ setMot(mot.x, world.purpurConfig.controllableMinecartsHopBoost, mot.z);
|
||||
+ }
|
||||
+ if (entityhuman.getForward() != 0.0F) {
|
||||
+ Vector dir = entityhuman.getBukkitEntity().getEyeLocation().getDirection().normalize().multiply(getControllableSpeed());
|
||||
+ if (entityhuman.getForward() < 0.0) {
|
||||
+ dir.multiply(-0.5);
|
||||
+ }
|
||||
+ setMot(new Vec3D(dir.getX(), getMot().y, dir.getZ()));
|
||||
+ setStepHeight(world.purpurConfig.controllableMinecartsStepHeight);
|
||||
+ } else {
|
||||
+ setStepHeight(0.0F);
|
||||
+ }
|
||||
+ this.yaw = passenger.yaw - 90;
|
||||
+
|
||||
+ // Purpur start
|
||||
+ if (world.purpurConfig.controllableMinecarts && !isInWater() && !isInLava() && !passengers.isEmpty()) {
|
||||
+ Entity passenger = passengers.get(0);
|
||||
+ if (passenger instanceof EntityHuman) {
|
||||
+ EntityHuman entityhuman = (EntityHuman) passenger;
|
||||
+ if (entityhuman.jumping && this.onGround) {
|
||||
+ setMot(new Vec3D(getMot().x, world.purpurConfig.controllableMinecartsHopBoost, getMot().z));
|
||||
+ }
|
||||
+ if (entityhuman.getForward() != 0.0F) {
|
||||
+ Vector velocity = entityhuman.getBukkitEntity().getEyeLocation().getDirection().normalize().multiply(getControllableSpeed());
|
||||
+ if (entityhuman.getForward() < 0.0) {
|
||||
+ velocity.multiply(-0.5);
|
||||
+ }
|
||||
+ setMot(new Vec3D(velocity.getX(), getMot().y, velocity.getZ()));
|
||||
+ }
|
||||
+ this.yaw = passenger.yaw - 90;
|
||||
+ setStepHeight(world.purpurConfig.controllableMinecartsStepHeight);
|
||||
+ } else {
|
||||
+ setStepHeight(0.0F);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+ } else {
|
||||
+ setStepHeight(0.0F);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
if (this.onGround) {
|
||||
// CraftBukkit start - replace magic numbers with our variables
|
||||
this.setMot(new Vec3D(this.getMot().x * this.derailedX, this.getMot().y * this.derailedY, this.getMot().z * this.derailedZ));
|
||||
// CraftBukkit end
|
||||
}
|
||||
+ else if (world.purpurConfig.controllableMinecarts) setMot(new Vec3D(getMot().x * derailedX, getMot().y, getMot().z * derailedZ)); // Purpur
|
||||
|
||||
this.move(EnumMoveType.SELF, this.getMot());
|
||||
if (!this.onGround) {
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
index b59b52633a..3c7313591f 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
@@ -819,6 +819,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
if (this.isInvulnerable(damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
+ if (damagesource == DamageSource.FALL && getRootVehicle() instanceof EntityMinecartAbstract && world.purpurConfig.controllableMinecarts && !world.purpurConfig.controllableMinecartsFallDamage) return false; // Purpur
|
||||
boolean flag = this.server.j() && this.canPvP() && "fall".equals(damagesource.translationIndex);
|
||||
|
||||
if (!flag && isSpawnInvulnerable() && damagesource != DamageSource.OUT_OF_WORLD) { // Purpur
|
||||
diff --git a/src/main/java/net/minecraft/server/ItemMinecart.java b/src/main/java/net/minecraft/server/ItemMinecart.java
|
||||
index ceef7aaf9..002651aaf 100644
|
||||
index ceef7aaf92..002651aaf3 100644
|
||||
--- a/src/main/java/net/minecraft/server/ItemMinecart.java
|
||||
+++ b/src/main/java/net/minecraft/server/ItemMinecart.java
|
||||
@@ -103,8 +103,10 @@ public class ItemMinecart extends Item {
|
||||
@@ -119,7 +143,7 @@ index ceef7aaf9..002651aaf 100644
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index 2763cc943..e54d071dd 100644
|
||||
index 2763cc943a..e490a561c6 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -1,5 +1,7 @@
|
||||
@@ -141,7 +165,7 @@ index 2763cc943..e54d071dd 100644
|
||||
import static net.pl3x.purpur.PurpurConfig.log;
|
||||
|
||||
public class PurpurWorldConfig {
|
||||
@@ -68,6 +73,32 @@ public class PurpurWorldConfig {
|
||||
@@ -68,6 +73,34 @@ public class PurpurWorldConfig {
|
||||
armorstandStepHeight = (float) getDouble("gameplay-mechanics.armorstand.step-height", armorstandStepHeight);
|
||||
}
|
||||
|
||||
@@ -149,6 +173,7 @@ index 2763cc943..e54d071dd 100644
|
||||
+ public boolean controllableMinecartsPlaceAnywhere = false;
|
||||
+ public float controllableMinecartsStepHeight = 1.0F;
|
||||
+ public double controllableMinecartsHopBoost = 0.5D;
|
||||
+ public boolean controllableMinecartsFallDamage = true;
|
||||
+ public double controllableMinecartsBaseSpeed = 0.1D;
|
||||
+ public Map<Block, Double> controllableMinecartsBlockSpeeds = new HashMap<>();
|
||||
+ private void controllableMinecartsSettings() {
|
||||
@@ -156,6 +181,7 @@ index 2763cc943..e54d071dd 100644
|
||||
+ controllableMinecartsPlaceAnywhere = getBoolean("gameplay-mechanics.controllable-minecarts.place-anywhere", controllableMinecartsPlaceAnywhere);
|
||||
+ controllableMinecartsStepHeight = (float) getDouble("gameplay-mechanics.controllable-minecarts.step-height", controllableMinecartsStepHeight);
|
||||
+ controllableMinecartsHopBoost = getDouble("gameplay-mechanics.controllable-minecarts.hop-boost", controllableMinecartsHopBoost);
|
||||
+ controllableMinecartsFallDamage = getBoolean("gameplay-mechanics.controllable-minecarts.fall-damage", controllableMinecartsFallDamage);
|
||||
+ controllableMinecartsBaseSpeed = getDouble("gameplay-mechanics.controllable-minecarts.base-speed", controllableMinecartsBaseSpeed);
|
||||
+ ConfigurationSection section = getConfigurationSection("gameplay-mechanics.controllable-minecarts.block-speed");
|
||||
+ if (section != null) {
|
||||
|
||||
Reference in New Issue
Block a user