vehicle lootable
This commit is contained in:
4 files changed
+94
-114
No files matched your search
-64
@@ -1,64 +0,0 @@
|
||||
From 3aeeaf31b7a7f888f54e47826e8ec0ddbe65c4bf Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 14:37:42 +0100
|
||||
Subject: [PATCH] paper File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/vehicle/MinecartTNT.java b/net/minecraft/world/entity/vehicle/MinecartTNT.java
|
||||
index 42cc5d2b349a1f6225b0ca66b74b311ccba15c87..da2ff774cd711e3db96376580772ee4eb3293944 100644
|
||||
--- a/net/minecraft/world/entity/vehicle/MinecartTNT.java
|
||||
+++ b/net/minecraft/world/entity/vehicle/MinecartTNT.java
|
||||
@@ -33,6 +33,7 @@ public class MinecartTNT extends AbstractMinecart {
|
||||
public int fuse = -1;
|
||||
public float explosionPowerBase = 4.0F;
|
||||
public float explosionSpeedFactor = 1.0F;
|
||||
+ public boolean isIncendiary = false; // CraftBukkit - add field
|
||||
|
||||
public MinecartTNT(EntityType<? extends MinecartTNT> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -47,6 +48,12 @@ public class MinecartTNT extends AbstractMinecart {
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.fuse > 0) {
|
||||
+ // Paper start - Configurable TNT height nerf
|
||||
+ if (this.level().paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) {
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.OUT_OF_WORLD);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Configurable TNT height nerf
|
||||
this.fuse--;
|
||||
this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5, this.getZ(), 0.0, 0.0, 0.0);
|
||||
} else if (this.fuse == 0) {
|
||||
@@ -101,6 +108,17 @@ public class MinecartTNT extends AbstractMinecart {
|
||||
protected void explode(@Nullable DamageSource damageSource, double radiusModifier) {
|
||||
if (this.level() instanceof ServerLevel serverLevel) {
|
||||
double min = Math.min(Math.sqrt(radiusModifier), 5.0);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent(
|
||||
+ this.getBukkitEntity(),
|
||||
+ (float) (this.explosionPowerBase + this.explosionSpeedFactor * this.random.nextDouble() * 1.5 * min),
|
||||
+ this.isIncendiary
|
||||
+ );
|
||||
+ if (!event.callEvent()) {
|
||||
+ this.fuse = -1;
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
serverLevel.explode(
|
||||
this,
|
||||
damageSource,
|
||||
@@ -108,11 +126,11 @@ public class MinecartTNT extends AbstractMinecart {
|
||||
this.getX(),
|
||||
this.getY(),
|
||||
this.getZ(),
|
||||
- (float)(this.explosionPowerBase + this.explosionSpeedFactor * this.random.nextDouble() * 1.5 * min),
|
||||
- false,
|
||||
+ event.getRadius(), // CraftBukkit - explosion prime event
|
||||
+ event.getFire(), // CraftBukkit - explosion prime event
|
||||
Level.ExplosionInteraction.TNT
|
||||
);
|
||||
- this.discard();
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
}
|
||||
|
||||
+16
-27
@@ -1,14 +1,6 @@
|
||||
From 3aeeaf31b7a7f888f54e47826e8ec0ddbe65c4bf Mon Sep 17 00:00:00 2001
|
||||
From: File <noreply+automated@papermc.io>
|
||||
Date: Sun, 20 Apr 1997 14:37:42 +0100
|
||||
Subject: [PATCH] paper File Patches
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/vehicle/ContainerEntity.java b/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
||||
index 681092fbe4b8643829471ade9d77b18e2283da08..c18aea2bb5ddddadbc858b253ff4c08d82178a18 100644
|
||||
--- a/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
||||
+++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
||||
@@ -62,22 +62,26 @@ public interface ContainerEntity extends Container, MenuProvider {
|
||||
@@ -60,12 +_,12 @@
|
||||
default void addChestVehicleSaveData(CompoundTag tag, HolderLookup.Provider levelRegistry) {
|
||||
if (this.getContainerLootTable() != null) {
|
||||
tag.putString("LootTable", this.getContainerLootTable().location().toString());
|
||||
@@ -23,24 +15,21 @@ index 681092fbe4b8643829471ade9d77b18e2283da08..c18aea2bb5ddddadbc858b253ff4c08d
|
||||
}
|
||||
|
||||
default void readChestVehicleSaveData(CompoundTag tag, HolderLookup.Provider levelRegistry) {
|
||||
this.clearItemStacks();
|
||||
if (tag.contains("LootTable", 8)) {
|
||||
- this.setContainerLootTable(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(tag.getString("LootTable"))));
|
||||
+ this.setContainerLootTable(net.minecraft.Optionull.map(ResourceLocation.tryParse(tag.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl))); // Paper - Validate ResourceLocation
|
||||
+ // Paper start - LootTable API
|
||||
+ if (this.getContainerLootTable() != null) {
|
||||
+ this.lootableData().loadNbt(tag);
|
||||
+ }
|
||||
+ // Paper end - LootTable API
|
||||
this.setContainerLootTableSeed(tag.getLong("LootTableSeed"));
|
||||
- } else {
|
||||
- ContainerHelper.loadAllItems(tag, this.getItemStacks(), levelRegistry);
|
||||
@@ -73,7 +_,12 @@
|
||||
ResourceKey<LootTable> resourceKey = tag.read("LootTable", LootTable.KEY_CODEC).orElse(null);
|
||||
this.setContainerLootTable(resourceKey);
|
||||
this.setContainerLootTableSeed(tag.getLongOr("LootTableSeed", 0L));
|
||||
- if (resourceKey == null) {
|
||||
+ // Paper start - LootTable API
|
||||
+ if (this.getContainerLootTable() != null) {
|
||||
+ this.lootableData().loadNbt(tag);
|
||||
+ }
|
||||
+ // Paper end - LootTable API
|
||||
+ if (true || resourceKey == null) { // Paper - always read the items, table may still remain
|
||||
ContainerHelper.loadAllItems(tag, this.getItemStacks(), levelRegistry);
|
||||
}
|
||||
+ ContainerHelper.loadAllItems(tag, this.getItemStacks(), levelRegistry); // Paper - always read the items, table may still remain
|
||||
}
|
||||
|
||||
default void chestVehicleDestroyed(DamageSource damageSource, ServerLevel level, Entity entity) {
|
||||
@@ -91,19 +95,27 @@ public interface ContainerEntity extends Container, MenuProvider {
|
||||
@@ -89,19 +_,27 @@
|
||||
}
|
||||
|
||||
default InteractionResult interactWithContainerVehicle(Player player) {
|
||||
@@ -71,7 +60,7 @@ index 681092fbe4b8643829471ade9d77b18e2283da08..c18aea2bb5ddddadbc858b253ff4c08d
|
||||
LootParams.Builder builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position());
|
||||
if (player != null) {
|
||||
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
|
||||
@@ -173,4 +185,14 @@ public interface ContainerEntity extends Container, MenuProvider {
|
||||
@@ -171,4 +_,14 @@
|
||||
default boolean isChestVehicleStillValid(Player player) {
|
||||
return !this.isRemoved() && player.canInteractWithEntity(this.getBoundingBox(), 4.0);
|
||||
}
|
||||
@@ -82,7 +71,7 @@ index 681092fbe4b8643829471ade9d77b18e2283da08..c18aea2bb5ddddadbc858b253ff4c08d
|
||||
+ }
|
||||
+
|
||||
+ default com.destroystokyo.paper.loottable.PaperLootableInventory getLootableInventory() {
|
||||
+ return ((com.destroystokyo.paper.loottable.PaperLootableInventory) ((net.minecraft.world.entity.Entity) this).getBukkitEntity());
|
||||
+ return ((com.destroystokyo.paper.loottable.PaperLootableInventory) ((Entity) this).getBukkitEntity());
|
||||
+ }
|
||||
+ // Paper end - LootTable API
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
--- a/net/minecraft/world/entity/vehicle/MinecartTNT.java
|
||||
+++ b/net/minecraft/world/entity/vehicle/MinecartTNT.java
|
||||
@@ -38,6 +_,7 @@
|
||||
public int fuse = -1;
|
||||
public float explosionPowerBase = 4.0F;
|
||||
public float explosionSpeedFactor = 1.0F;
|
||||
+ public boolean isIncendiary = false; // CraftBukkit
|
||||
|
||||
public MinecartTNT(EntityType<? extends MinecartTNT> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -52,6 +_,12 @@
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.fuse > 0) {
|
||||
+ // Paper start - Configurable TNT height nerf
|
||||
+ if (this.level().paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) {
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.OUT_OF_WORLD);
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Configurable TNT height nerf
|
||||
this.fuse--;
|
||||
this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5, this.getZ(), 0.0, 0.0, 0.0);
|
||||
} else if (this.fuse == 0) {
|
||||
@@ -107,6 +_,17 @@
|
||||
if (this.level() instanceof ServerLevel serverLevel) {
|
||||
if (serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) {
|
||||
double min = Math.min(Math.sqrt(radiusModifier), 5.0);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent(
|
||||
+ this.getBukkitEntity(),
|
||||
+ (float) (this.explosionPowerBase + this.explosionSpeedFactor * this.random.nextDouble() * 1.5 * min),
|
||||
+ this.isIncendiary
|
||||
+ );
|
||||
+ if (!event.callEvent()) {
|
||||
+ this.fuse = -1;
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
serverLevel.explode(
|
||||
this,
|
||||
damageSource,
|
||||
@@ -114,13 +_,13 @@
|
||||
this.getX(),
|
||||
this.getY(),
|
||||
this.getZ(),
|
||||
- (float)(this.explosionPowerBase + this.explosionSpeedFactor * this.random.nextDouble() * 1.5 * min),
|
||||
- false,
|
||||
+ event.getRadius(), // CraftBukkit - explosion prime event
|
||||
+ event.getFire(), // CraftBukkit - explosion prime event
|
||||
Level.ExplosionInteraction.TNT
|
||||
);
|
||||
- this.discard();
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
|
||||
} else if (this.isPrimed()) {
|
||||
- this.discard();
|
||||
+ this.discard(null); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
-23
@@ -5,12 +5,13 @@ import io.papermc.paper.configuration.type.DurationOrDisabled;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.minecraft.core.UUIDUtil;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.world.RandomizableContainer;
|
||||
import net.minecraft.world.entity.vehicle.ContainerEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -164,30 +165,25 @@ public class PaperLootableInventoryData {
|
||||
private static final String LOOTED_PLAYERS = "lootedPlayers";
|
||||
|
||||
public void loadNbt(final CompoundTag base) {
|
||||
if (!base.contains(ROOT, Tag.TAG_COMPOUND)) {
|
||||
final Optional<CompoundTag> compOpt = base.getCompound(ROOT);
|
||||
if (compOpt.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final CompoundTag comp = base.getCompound(ROOT);
|
||||
if (comp.contains(LAST_FILL)) {
|
||||
this.lastFill = comp.getLong(LAST_FILL);
|
||||
CompoundTag comp = compOpt.get();
|
||||
this.lastFill = comp.getLongOr(LAST_FILL, -1);
|
||||
this.nextRefill = comp.getLongOr(NEXT_REFILL, -1);
|
||||
this.numRefills = comp.getIntOr(NUM_REFILLS, 0);
|
||||
final ListTag list = comp.getListOrEmpty(LOOTED_PLAYERS);
|
||||
final int size = list.size();
|
||||
if (size > 0) {
|
||||
this.lootedPlayers = new HashMap<>(list.size());
|
||||
}
|
||||
if (comp.contains(NEXT_REFILL)) {
|
||||
this.nextRefill = comp.getLong(NEXT_REFILL);
|
||||
}
|
||||
|
||||
if (comp.contains(NUM_REFILLS)) {
|
||||
this.numRefills = comp.getInt(NUM_REFILLS);
|
||||
}
|
||||
if (comp.contains(LOOTED_PLAYERS, Tag.TAG_LIST)) {
|
||||
final ListTag list = comp.getList(LOOTED_PLAYERS, Tag.TAG_COMPOUND);
|
||||
final int size = list.size();
|
||||
if (size > 0) {
|
||||
this.lootedPlayers = new HashMap<>(list.size());
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
final CompoundTag cmp = list.getCompound(i);
|
||||
this.lootedPlayers.put(cmp.getUUID("UUID"), cmp.getLong("Time"));
|
||||
}
|
||||
for (int i = 0; i < size; i++) {
|
||||
list.getCompound(i).ifPresent(tag -> {
|
||||
tag.read("UUID", UUIDUtil.CODEC).ifPresent(uuid -> {
|
||||
this.lootedPlayers.put(uuid, tag.getLongOr("Time", 0));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +202,7 @@ public class PaperLootableInventoryData {
|
||||
final ListTag list = new ListTag();
|
||||
for (final Map.Entry<UUID, Long> entry : this.lootedPlayers.entrySet()) {
|
||||
final CompoundTag cmp = new CompoundTag();
|
||||
cmp.putUUID("UUID", entry.getKey());
|
||||
cmp.store("UUID", UUIDUtil.CODEC, entry.getKey());
|
||||
cmp.putLong("Time", entry.getValue());
|
||||
list.add(cmp);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user