Update to Minecraft 1.20.5

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2024-04-24 01:15:00 +10:00
parent 899f2acb84
commit f3502f6dac
54 changed files with 1814 additions and 741 deletions

View File

@@ -1,7 +1,11 @@
package org.bukkit.block.spawner;
import com.google.common.base.Preconditions;
import java.util.Map;
import org.bukkit.entity.EntitySnapshot;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.loot.LootTable;
import org.bukkit.loot.LootTables;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -13,13 +17,19 @@ public class SpawnerEntry {
private EntitySnapshot snapshot;
private int spawnWeight;
private SpawnRule spawnRule;
private Equipment equipment;
public SpawnerEntry(@NotNull EntitySnapshot snapshot, int spawnWeight, @Nullable SpawnRule spawnRule) {
this(snapshot, spawnWeight, spawnRule, null);
}
public SpawnerEntry(@NotNull EntitySnapshot snapshot, int spawnWeight, @Nullable SpawnRule spawnRule, @Nullable Equipment equipment) {
Preconditions.checkArgument(snapshot != null, "Snapshot cannot be null");
this.snapshot = snapshot;
this.spawnWeight = spawnWeight;
this.spawnRule = spawnRule;
this.equipment = equipment;
}
/**
@@ -82,4 +92,75 @@ public class SpawnerEntry {
public void setSpawnRule(@Nullable SpawnRule spawnRule) {
this.spawnRule = spawnRule;
}
/**
* Gets the equipment which will be applied to the spawned entity.
*
* @return the equipment, or null
*/
@Nullable
public Equipment getEquipment() {
return equipment;
}
/**
* Sets the equipment which will be applied to the spawned entity.
*
* @param equipment new equipment, or null
*/
public void setEquipment(@Nullable Equipment equipment) {
this.equipment = equipment;
}
/**
* Represents the equipment loot table applied to a spawned entity.
*/
public static class Equipment {
private LootTable equipmentLootTable;
private final Map<EquipmentSlot, Float> dropChances;
public Equipment(@NotNull LootTable equipmentLootTable, @NotNull Map<EquipmentSlot, Float> dropChances) {
this.equipmentLootTable = equipmentLootTable;
this.dropChances = dropChances;
}
/**
* Set the loot table for the entity.
* <br>
* To remove a loot table use null. Do not use {@link LootTables#EMPTY}
* to clear a LootTable.
*
* @param table this {@link org.bukkit.entity.Mob} will have.
*/
public void setEquipmentLootTable(@NotNull LootTable table) {
this.equipmentLootTable = table;
}
/**
* Gets the loot table for the entity.
* <br>
*
* If an entity does not have a loot table, this will return null, NOT
* an empty loot table.
*
* @return the loot table for this entity.
*/
@NotNull
public LootTable getEquipmentLootTable() {
return this.equipmentLootTable;
}
/**
* Gets a mutable map of the drop chances for each slot of the entity.
* If non-null, the entity's drop chances will be overridden with the
* given value.
*
* @return mutable map of drop chances
*/
@NotNull
public Map<EquipmentSlot, Float> getDropChances() {
return this.dropChances;
}
}
}