mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
Update loot table and other patches
This commit is contained in:
parent
e45e2141a0
commit
d611ad767d
@ -21,16 +21,16 @@ diff --git a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.ja
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
|
--- a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
|
+++ b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
|
||||||
@@ -0,0 +0,0 @@ import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
@@ -0,0 +0,0 @@ public class RedstoneTorchBlock extends BaseTorchBlock {
|
||||||
public class RedstoneTorchBlock extends TorchBlock {
|
|
||||||
|
|
||||||
|
public static final MapCodec<RedstoneTorchBlock> CODEC = simpleCodec(RedstoneTorchBlock::new);
|
||||||
public static final BooleanProperty LIT = BlockStateProperties.LIT;
|
public static final BooleanProperty LIT = BlockStateProperties.LIT;
|
||||||
- private static final Map<BlockGetter, List<RedstoneTorchBlock.Toggle>> RECENT_TOGGLES = new WeakHashMap();
|
- private static final Map<BlockGetter, List<RedstoneTorchBlock.Toggle>> RECENT_TOGGLES = new WeakHashMap();
|
||||||
+ // Paper - Move the mapped list to World
|
+ // Paper - Move the mapped list to World
|
||||||
public static final int RECENT_TOGGLE_TIMER = 60;
|
public static final int RECENT_TOGGLE_TIMER = 60;
|
||||||
public static final int MAX_RECENT_TOGGLES = 8;
|
public static final int MAX_RECENT_TOGGLES = 8;
|
||||||
public static final int RESTART_DELAY = 160;
|
public static final int RESTART_DELAY = 160;
|
||||||
@@ -0,0 +0,0 @@ public class RedstoneTorchBlock extends TorchBlock {
|
@@ -0,0 +0,0 @@ public class RedstoneTorchBlock extends BaseTorchBlock {
|
||||||
@Override
|
@Override
|
||||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||||
boolean flag = this.hasNeighborSignal(world, pos, state);
|
boolean flag = this.hasNeighborSignal(world, pos, state);
|
||||||
@ -50,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager();
|
org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager();
|
||||||
@@ -0,0 +0,0 @@ public class RedstoneTorchBlock extends TorchBlock {
|
@@ -0,0 +0,0 @@ public class RedstoneTorchBlock extends BaseTorchBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isToggledTooFrequently(Level world, BlockPos pos, boolean addNew) {
|
private static boolean isToggledTooFrequently(Level world, BlockPos pos, boolean addNew) {
|
@ -503,11 +503,72 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ return tileEntityLootable.getLevel();
|
+ return tileEntityLootable.getLevel();
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/RandomizableContainer.java b/src/main/java/net/minecraft/world/RandomizableContainer.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/RandomizableContainer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/RandomizableContainer.java
|
||||||
|
@@ -0,0 +0,0 @@ public interface RandomizableContainer extends Container {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ private static net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity blockEntity(final RandomizableContainer container) {
|
||||||
|
+ return (net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) container;
|
||||||
|
+ }
|
||||||
|
default boolean tryLoadLootTable(CompoundTag nbt) {
|
||||||
|
+ final net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity entity = blockEntity(this);
|
||||||
|
+ entity.lootableData.loadNbt(nbt);
|
||||||
|
if (nbt.contains("LootTable", 8)) {
|
||||||
|
this.setLootTable(new ResourceLocation(nbt.getString("LootTable")));
|
||||||
|
+ try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(entity.lootTable); } catch (IllegalArgumentException ex) { entity.lootTable = null; } // Paper - validate
|
||||||
|
this.setLootTableSeed(nbt.getLong("LootTableSeed"));
|
||||||
|
- return true;
|
||||||
|
+ return false; // Paper - always load the items, table may still remain
|
||||||
|
+ // Paper end
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default boolean trySaveLootTable(CompoundTag nbt) {
|
||||||
|
+ // Paper start
|
||||||
|
+ final net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity entity = blockEntity(this);
|
||||||
|
+ entity.lootableData.saveNbt(nbt);
|
||||||
|
+ // Paper end
|
||||||
|
ResourceLocation resourceLocation = this.getLootTable();
|
||||||
|
if (resourceLocation == null) {
|
||||||
|
return false;
|
||||||
|
@@ -0,0 +0,0 @@ public interface RandomizableContainer extends Container {
|
||||||
|
nbt.putLong("LootTableSeed", l);
|
||||||
|
}
|
||||||
|
|
||||||
|
- return true;
|
||||||
|
+ return false; // Paper - always save the items, table may still remain
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default void unpackLootTable(@Nullable Player player) {
|
||||||
|
+ final net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity entity = blockEntity(this); // Paper
|
||||||
|
Level level = this.getLevel();
|
||||||
|
BlockPos blockPos = this.getBlockPos();
|
||||||
|
ResourceLocation resourceLocation = this.getLootTable();
|
||||||
|
- if (resourceLocation != null && level != null && level.getServer() != null) {
|
||||||
|
+ if (entity.lootableData.shouldReplenish(player) && level != null) { // Paper
|
||||||
|
LootTable lootTable = level.getServer().getLootData().getLootTable(resourceLocation);
|
||||||
|
if (player instanceof ServerPlayer) {
|
||||||
|
CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, resourceLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
- this.setLootTable((ResourceLocation)null);
|
||||||
|
+ entity.lootableData.processRefill(player); // Paper
|
||||||
|
LootParams.Builder builder = (new LootParams.Builder((ServerLevel)level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockPos));
|
||||||
|
if (player != null) {
|
||||||
|
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
||||||
@ -665,49 +726,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
protected RandomizableContainerBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
protected RandomizableContainerBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||||
super(type, pos, state);
|
super(type, pos, state);
|
||||||
@@ -0,0 +0,0 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean tryLoadLootTable(CompoundTag nbt) {
|
|
||||||
+ this.lootableData.loadNbt(nbt); // Paper
|
|
||||||
if (nbt.contains("LootTable", 8)) {
|
|
||||||
this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
|
|
||||||
+ try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.lootTable); } catch (IllegalArgumentException ex) { this.lootTable = null; } // Paper - validate
|
|
||||||
this.lootTableSeed = nbt.getLong("LootTableSeed");
|
|
||||||
- return true;
|
|
||||||
+ return false; // Paper - always load the items, table may still remain
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean trySaveLootTable(CompoundTag nbt) {
|
|
||||||
+ this.lootableData.saveNbt(nbt); // Paper
|
|
||||||
if (this.lootTable == null) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
@@ -0,0 +0,0 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
|
||||||
nbt.putLong("LootTableSeed", this.lootTableSeed);
|
|
||||||
}
|
|
||||||
|
|
||||||
- return true;
|
|
||||||
+ return false; // Paper - always save the items, table may still remain
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unpackLootTable(@Nullable Player player) {
|
|
||||||
- if (this.lootTable != null && this.level.getServer() != null) {
|
|
||||||
+ if (this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper
|
|
||||||
LootTable lootTable = this.level.getServer().getLootData().getLootTable(this.lootTable);
|
|
||||||
if (player instanceof ServerPlayer) {
|
|
||||||
CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, this.lootTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
- this.lootTable = null;
|
|
||||||
+ this.lootableData.processRefill(player); // Paper
|
|
||||||
LootParams.Builder builder = (new LootParams.Builder((ServerLevel)this.level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition));
|
|
||||||
if (player != null) {
|
|
||||||
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java
|
@ -50,8 +50,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
private void explode() {
|
private void explode() {
|
||||||
@@ -0,0 +0,0 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
@@ -0,0 +0,0 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
||||||
public int getFuse() {
|
public BlockState getBlockState() {
|
||||||
return (Integer) this.entityData.get(PrimedTnt.DATA_FUSE_ID);
|
return (BlockState) this.entityData.get(PrimedTnt.DATA_BLOCK_STATE_ID);
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ // Paper start - Optional prevent TNT from moving in water
|
+ // Paper start - Optional prevent TNT from moving in water
|
Loading…
Reference in New Issue
Block a user