mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 08:17:44 +01:00
SPIGOT-7933: Improve custom Minecart max speed
By: md_5 <git@md-5.net>
This commit is contained in:
parent
82bd6be3e1
commit
83f48fb3c6
@ -27,7 +27,7 @@
|
|||||||
+ private double flyingX = 0.95;
|
+ private double flyingX = 0.95;
|
||||||
+ private double flyingY = 0.95;
|
+ private double flyingY = 0.95;
|
||||||
+ private double flyingZ = 0.95;
|
+ private double flyingZ = 0.95;
|
||||||
+ public double maxSpeed = 0.4D;
|
+ public Double maxSpeed;
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
+
|
||||||
protected EntityMinecartAbstract(EntityTypes<?> entitytypes, World world) {
|
protected EntityMinecartAbstract(EntityTypes<?> entitytypes, World world) {
|
||||||
|
@ -12,7 +12,20 @@
|
|||||||
public class NewMinecartBehavior extends MinecartBehavior {
|
public class NewMinecartBehavior extends MinecartBehavior {
|
||||||
|
|
||||||
public static final int POS_ROT_LERP_TICKS = 3;
|
public static final int POS_ROT_LERP_TICKS = 3;
|
||||||
@@ -544,7 +549,7 @@
|
@@ -516,6 +521,12 @@
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMaxSpeed(WorldServer worldserver) {
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ Double maxSpeed = this.minecart.maxSpeed;
|
||||||
|
+ if (maxSpeed != null) {
|
||||||
|
+ return (this.minecart.isInWater() ? maxSpeed / 2.0D : maxSpeed);
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
return (double) worldserver.getGameRules().getInt(GameRules.RULE_MINECART_MAX_SPEED) * (this.minecart.isInWater() ? 0.5D : 1.0D) / 20.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -544,7 +555,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getSlowdownFactor() {
|
public double getSlowdownFactor() {
|
||||||
@ -21,7 +34,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -571,6 +576,14 @@
|
@@ -571,6 +582,14 @@
|
||||||
Entity entity = (Entity) iterator.next();
|
Entity entity = (Entity) iterator.next();
|
||||||
|
|
||||||
if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.minecart.isVehicle() && !entity.isPassenger()) {
|
if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.minecart.isVehicle() && !entity.isPassenger()) {
|
||||||
@ -36,7 +49,7 @@
|
|||||||
boolean flag = entity.startRiding(this.minecart);
|
boolean flag = entity.startRiding(this.minecart);
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@@ -597,6 +610,16 @@
|
@@ -597,6 +616,16 @@
|
||||||
Entity entity = (Entity) iterator.next();
|
Entity entity = (Entity) iterator.next();
|
||||||
|
|
||||||
if (entity instanceof EntityHuman || entity instanceof EntityIronGolem || entity instanceof EntityMinecartAbstract || this.minecart.isVehicle() || entity.isPassenger()) {
|
if (entity instanceof EntityHuman || entity instanceof EntityIronGolem || entity instanceof EntityMinecartAbstract || this.minecart.isVehicle() || entity.isPassenger()) {
|
||||||
@ -53,7 +66,7 @@
|
|||||||
entity.push((Entity) this.minecart);
|
entity.push((Entity) this.minecart);
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
@@ -609,6 +632,14 @@
|
@@ -609,6 +638,14 @@
|
||||||
Entity entity1 = (Entity) iterator1.next();
|
Entity entity1 = (Entity) iterator1.next();
|
||||||
|
|
||||||
if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) {
|
if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) {
|
||||||
|
@ -54,12 +54,17 @@
|
|||||||
entity1.push((Entity) this.minecart);
|
entity1.push((Entity) this.minecart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -487,11 +518,11 @@
|
@@ -487,11 +518,17 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxSpeed(WorldServer worldserver) {
|
public double getMaxSpeed(WorldServer worldserver) {
|
||||||
- return this.minecart.isInWater() ? 0.2D : 0.4D;
|
+ // CraftBukkit start
|
||||||
+ return (this.minecart.isInWater() ? this.minecart.maxSpeed / 2.0D: this.minecart.maxSpeed); // CraftBukkit
|
+ Double maxSpeed = this.minecart.maxSpeed;
|
||||||
|
+ if (maxSpeed != null) {
|
||||||
|
+ return (this.minecart.isInWater() ? maxSpeed / 2.0D : maxSpeed);
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
return this.minecart.isInWater() ? 0.2D : 0.4D;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.bukkit.craftbukkit.entity;
|
package org.bukkit.craftbukkit.entity;
|
||||||
|
|
||||||
|
import net.minecraft.server.level.WorldServer;
|
||||||
import net.minecraft.world.entity.vehicle.EntityMinecartAbstract;
|
import net.minecraft.world.entity.vehicle.EntityMinecartAbstract;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
import net.minecraft.world.level.block.state.IBlockData;
|
||||||
@ -28,7 +29,7 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxSpeed() {
|
public double getMaxSpeed() {
|
||||||
return getHandle().maxSpeed;
|
return getHandle().getBehavior().getMaxSpeed((WorldServer) getHandle().level());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user