mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-04 07:17:46 +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 flyingY = 0.95;
|
||||
+ private double flyingZ = 0.95;
|
||||
+ public double maxSpeed = 0.4D;
|
||||
+ public Double maxSpeed;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected EntityMinecartAbstract(EntityTypes<?> entitytypes, World world) {
|
||||
|
@ -12,7 +12,20 @@
|
||||
public class NewMinecartBehavior extends MinecartBehavior {
|
||||
|
||||
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
|
||||
public double getSlowdownFactor() {
|
||||
@ -21,7 +34,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -571,6 +576,14 @@
|
||||
@@ -571,6 +582,14 @@
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
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);
|
||||
|
||||
if (flag) {
|
||||
@@ -597,6 +610,16 @@
|
||||
@@ -597,6 +616,16 @@
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
if (entity instanceof EntityHuman || entity instanceof EntityIronGolem || entity instanceof EntityMinecartAbstract || this.minecart.isVehicle() || entity.isPassenger()) {
|
||||
@ -53,7 +66,7 @@
|
||||
entity.push((Entity) this.minecart);
|
||||
flag = true;
|
||||
}
|
||||
@@ -609,6 +632,14 @@
|
||||
@@ -609,6 +638,14 @@
|
||||
Entity entity1 = (Entity) iterator1.next();
|
||||
|
||||
if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) {
|
||||
|
@ -54,12 +54,17 @@
|
||||
entity1.push((Entity) this.minecart);
|
||||
}
|
||||
}
|
||||
@@ -487,11 +518,11 @@
|
||||
@@ -487,11 +518,17 @@
|
||||
|
||||
@Override
|
||||
public double getMaxSpeed(WorldServer worldserver) {
|
||||
- return this.minecart.isInWater() ? 0.2D : 0.4D;
|
||||
+ return (this.minecart.isInWater() ? this.minecart.maxSpeed / 2.0D: this.minecart.maxSpeed); // CraftBukkit
|
||||
+ // CraftBukkit start
|
||||
+ 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
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.world.entity.vehicle.EntityMinecartAbstract;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
@ -28,7 +29,7 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
||||
|
||||
@Override
|
||||
public double getMaxSpeed() {
|
||||
return getHandle().maxSpeed;
|
||||
return getHandle().getBehavior().getMaxSpeed((WorldServer) getHandle().level());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user