mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 809466f2e Fix anchor respawn acting as a bed respawn when using the end portal (#5540) d219fd642 [Auto] Updated Upstream (Bukkit/CraftBukkit) db464b099 Implement methods to convert between Component and Brigadier's Message (#5542) 4047cffca Add PlayerBedFailEnterEvent (#4935) 70d697e6e Update Paperpclip 5ed771591 [CI-SKIP] Remove bad null annotation (#5538) 454a4c78e More World API (#3850) 869e02304 Add PlayerDeepSleepEvent (#5525) fb56fc35e fix non-dummy objectives not updating dc859a61f [CI-SKIP] [Auto] Rebuild Patches 7d1689f1a Add missing checkReachable check for shulker boxes (#5453) ba8eb3d4b Add missing Javadoc for COLORABLE MaterialTag (#5376) db801cbf3 Fix PlayerItemHeldEvent firing twice (#5534) 14de2b795 fix PigZombieAngerEvent cancellation (fixes #5319) (v2) (#5329) 86d684ad1 Add get-set drop chance to EntityEquipment (#5528) 33fb8cf63 Add consumeFuel to FurnaceBurnEvent (#5532) 9957f4630 Fix duplicating /give items on item drop cancel (#5536) d94882043 Fix legacyComposer not using AsyncChatEvent messages (#5509) 053bd82cc Don't print spawn load time when not loading spawn (#5467) a6d78caae Add isDeeplySleeping to HumanEntity (#5470) 711b7a80b Expose more Adventure serializers through PaperComponents (#5443) 3f63bde0c Set Area Effect Cloud Rotation (#5462) 3523f0fda Remove useless check on player interact cancellation (#5448) 6574d1aa8 fix #5526 - use correct type when sending message to clients dbfa833ec don't throw when loading TE with invalid keys a9525a6f7 Do not schedule poi task for each block write on chunk gen 39bf5b525 Update teams known as code owners fbae9dbe0 [Auto] Updated Upstream (Bukkit/CraftBukkit) ac4a33aab [Auto] Updated Upstream (Bukkit) c1e07158b [Auto] Updated Upstream (Bukkit/CraftBukkit) 5e4b88e95 Fix dangling sout 23afda179 basic hostname validation 0fb8bdf0e Updated Upstream (Bukkit/CraftBukkit) (#5508) 88ab784da [Auto] Updated Upstream (CraftBukkit) ca7111d5f Fix PlayerItemConsumeEvent cancelling (fixes #4682) (#5383) 06fb560dc Add support for tab completing and highlighting console input from the Brigadier command tree (#5437) 0a9b89c7a Fix occasional light gen issues for neighbor blocks (#5500) Tuinity Changes: b12d0cce3 Replace ticket level propagator 42df8e1e0 Correctly handle recursion for chunkholder updates 73eb2a856 Do not copy visible chunks 8a4f3be69 Do not schedule poi task for each block write on chunk gen 7d36676fc Fix light source locking f1ec0c20d Add concurrency check to ProtoChunk light sources 159d1468f Improvements to chunk loader system 32b4d526b Updated Upstream (Paper) ac5adca33 Make sure lit is set for pre 1.14 chunks Airplane Changes: d8bdbc508 Reduce allocations for fire spreading 41051fd56 Redo reduction of entity chunk ticking check patch 31272d80f Flare Update 8f3271328 Remove criterion patch 0fed2df62 Various patches that need to be reorganized later f78856bde Updated Upstream (Tuinity) f7d6382ad Flare Update 71d079991 Update gradle configuration 0f7977428 Updated Upstream (Tuinity) 3b3cde7b0 Correctly use DEAR values, fix config reloading dd6091981 Updated Upstream (Tuinity) 07897895b Updated Upstream (Tuinity) c1e4d7143 Fluid cache patch
239 lines
13 KiB
Diff
239 lines
13 KiB
Diff
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] Controllable Minecarts
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/core/BlockPosition.java b/src/main/java/net/minecraft/core/BlockPosition.java
|
|
index 3c51ee00aa53e561c02bb779c7115d8475d70ed7..456253043cca1b07e7e4791d096682f23749473d 100644
|
|
--- a/src/main/java/net/minecraft/core/BlockPosition.java
|
|
+++ b/src/main/java/net/minecraft/core/BlockPosition.java
|
|
@@ -11,6 +11,7 @@ import java.util.stream.StreamSupport;
|
|
import javax.annotation.concurrent.Immutable;
|
|
import net.minecraft.SystemUtils;
|
|
import net.minecraft.util.MathHelper;
|
|
+import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.level.block.EnumBlockRotation;
|
|
import net.minecraft.world.level.levelgen.structure.StructureBoundingBox;
|
|
import net.minecraft.world.phys.AxisAlignedBB;
|
|
@@ -42,6 +43,12 @@ public class BlockPosition extends BaseBlockPosition {
|
|
private static final int m = 38;
|
|
// Paper end
|
|
|
|
+ // Purpur start
|
|
+ public BlockPosition(Entity entity) {
|
|
+ super(entity.locX(), entity.locY(), entity.locZ());
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
public BlockPosition(int i, int j, int k) {
|
|
super(i, j, k);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/level/EntityPlayer.java b/src/main/java/net/minecraft/server/level/EntityPlayer.java
|
|
index c337b22a2f8ce5c76a1699956f6c06721046e814..e8f39bcf57e960be4a87acfa49910ab6ede8842f 100644
|
|
--- a/src/main/java/net/minecraft/server/level/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/EntityPlayer.java
|
|
@@ -106,6 +106,7 @@ import net.minecraft.world.entity.monster.EntityMonster;
|
|
import net.minecraft.world.entity.player.EntityHuman;
|
|
import net.minecraft.world.entity.player.EnumChatVisibility;
|
|
import net.minecraft.world.entity.projectile.EntityArrow;
|
|
+import net.minecraft.world.entity.vehicle.EntityMinecartAbstract;
|
|
import net.minecraft.world.inventory.Container;
|
|
import net.minecraft.world.inventory.ContainerHorse;
|
|
import net.minecraft.world.inventory.ICrafting;
|
|
@@ -1132,6 +1133,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/world/entity/EntityLiving.java b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
index 5cdefe2a1b4085e3aae7dbbb751cfd368593ebd7..f1781c2100bf3a8fa7123b66f9ab682177d6490e 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityLiving.java
|
|
@@ -194,9 +194,9 @@ public abstract class EntityLiving extends Entity {
|
|
protected int aO;protected int getKillCount() { return this.aO; } // Paper - OBFHELPER
|
|
public float lastDamage;
|
|
public boolean jumping; // Paper protected -> public
|
|
- public float aR;
|
|
- public float aS;
|
|
- public float aT;
|
|
+ public float aR; public float getStrafe() { return aR; } public void setStrafe(float strafe) { aR = strafe; } // Purpur - OBFHELPER
|
|
+ public float aS; public float getVertical() { return aS; } public void setVertical(float vertical) { aS = vertical; } // Purpur - OBFHELPER
|
|
+ public float aT; public float getForward() { return aT; } public void setForward(float forward) { aT = forward; } // Purpur - OBFHELPER
|
|
protected int aU;
|
|
protected double aV;
|
|
protected double aW;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java b/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
|
index 75a88ab5d5b0fdb98ea8d61bb6b82049b21101f3..3cd9a7956f9cbb3f66764adfede12b3b25024c41 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/EntityMinecartAbstract.java
|
|
@@ -484,16 +484,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();
|
|
+ if (!block.getMaterial().isSolid()) {
|
|
+ block = world.getType(position.shift(EnumDirection.DOWN)).getBlock();
|
|
+ }
|
|
+ Double speed = world.purpurConfig.controllableMinecartsBlockSpeeds.get(block);
|
|
+ if (!block.getMaterial().isSolid()) {
|
|
+ speed = lastSpeed;
|
|
+ } else if (speed == null) {
|
|
+ speed = world.purpurConfig.controllableMinecartsBaseSpeed;
|
|
+ }
|
|
+ return lastSpeed = speed;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
protected void h() {
|
|
double d0 = this.getMaxSpeed();
|
|
Vec3D vec3d = this.getMot();
|
|
|
|
this.setMot(MathHelper.a(vec3d.x, -d0, d0), vec3d.y, MathHelper.a(vec3d.z, -d0, d0));
|
|
+
|
|
+ // 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);
|
|
+ }
|
|
+ } 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/world/item/ItemMinecart.java b/src/main/java/net/minecraft/world/item/ItemMinecart.java
|
|
index 527f3ed664854cdd938c34f00a064bc2f77148cc..d50a1093aa9b6d7187b59566309a3abd05125e07 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemMinecart.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemMinecart.java
|
|
@@ -121,8 +121,10 @@ public class ItemMinecart extends Item {
|
|
IBlockData iblockdata = world.getType(blockposition);
|
|
|
|
if (!iblockdata.a((Tag) TagsBlock.RAILS)) {
|
|
- return EnumInteractionResult.FAIL;
|
|
- } else {
|
|
+ // Purpur start - place minecarts anywhere
|
|
+ if (!world.purpurConfig.controllableMinecartsPlaceAnywhere) return EnumInteractionResult.FAIL;
|
|
+ if (iblockdata.getMaterial().isSolid()) blockposition = blockposition.shift(itemactioncontext.getClickedFace());
|
|
+ } //else { // Purpur end - place minecarts anywhere
|
|
ItemStack itemstack = itemactioncontext.getItemStack();
|
|
|
|
if (!world.isClientSide) {
|
|
@@ -149,6 +151,6 @@ public class ItemMinecart extends Item {
|
|
|
|
itemstack.subtract(1);
|
|
return EnumInteractionResult.a(world.isClientSide);
|
|
- }
|
|
+ //} // Purpur - place minecarts anywhere
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
index f8a982add50862f1bc977f3039e7e9aeed9138ae..e18b3b575e4fe3fde869e749070feefb31548a25 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
@@ -41,6 +41,7 @@ import net.minecraft.world.level.block.entity.TileEntity;
|
|
import net.minecraft.world.level.block.state.BlockBase;
|
|
import net.minecraft.world.level.block.state.BlockStateList;
|
|
import net.minecraft.world.level.block.state.IBlockData;
|
|
+import net.minecraft.world.level.material.Material;
|
|
import net.minecraft.world.level.storage.loot.LootTableInfo;
|
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
|
|
import net.minecraft.world.phys.Vec3D;
|
|
@@ -83,6 +84,7 @@ public class Block extends BlockBase implements IMaterial {
|
|
return timing;
|
|
}
|
|
// Paper end
|
|
+ public Material getMaterial() { return material; } // Purpur - OBFHELPER
|
|
@Nullable
|
|
private String name;
|
|
@Nullable
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 2e4a928a3e88fb3d961d9530695cd7154321c79b..3a6a19bd4e952a6deb1def80755387cab75bbad8 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -1,13 +1,18 @@
|
|
package net.pl3x.purpur;
|
|
|
|
import net.minecraft.core.IRegistry;
|
|
+import net.minecraft.world.level.block.Block;
|
|
+import net.minecraft.world.level.block.Blocks;
|
|
import net.minecraft.world.item.Item;
|
|
import net.minecraft.world.item.Items;
|
|
import net.minecraft.resources.MinecraftKey;
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
import java.util.ArrayList;
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
+import java.util.Map;
|
|
+
|
|
import static net.pl3x.purpur.PurpurConfig.log;
|
|
|
|
public class PurpurWorldConfig {
|
|
@@ -68,6 +73,34 @@ public class PurpurWorldConfig {
|
|
armorstandStepHeight = (float) getDouble("gameplay-mechanics.armorstand.step-height", armorstandStepHeight);
|
|
}
|
|
|
|
+ public boolean controllableMinecarts = false;
|
|
+ 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() {
|
|
+ controllableMinecarts = getBoolean("gameplay-mechanics.controllable-minecarts.enabled", controllableMinecarts);
|
|
+ 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) {
|
|
+ for (String key : section.getKeys(false)) {
|
|
+ Block block = IRegistry.BLOCK.get(new MinecraftKey(key));
|
|
+ if (block != Blocks.AIR) {
|
|
+ controllableMinecartsBlockSpeeds.put(block, section.getDouble(key, controllableMinecartsBaseSpeed));
|
|
+ }
|
|
+ }
|
|
+ } else {
|
|
+ set("gameplay-mechanics.controllable-minecarts.block-speed.grass-block", 0.3D);
|
|
+ set("gameplay-mechanics.controllable-minecarts.block-speed.stone", 0.5D);
|
|
+ }
|
|
+ }
|
|
+
|
|
public boolean idleTimeoutKick = true;
|
|
public boolean idleTimeoutTickNearbyEntities = true;
|
|
public boolean idleTimeoutCountAsSleeping = false;
|