Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
Implement cooldown API
Dieser Commit ist enthalten in:
Ursprung
e04a1793ae
Commit
be9ef980b9
26
nms-patches/ItemCooldown.patch
Normale Datei
26
nms-patches/ItemCooldown.patch
Normale Datei
@ -0,0 +1,26 @@
|
|||||||
|
--- a/net/minecraft/server/ItemCooldown.java
|
||||||
|
+++ b/net/minecraft/server/ItemCooldown.java
|
||||||
|
@@ -7,8 +7,8 @@
|
||||||
|
|
||||||
|
public class ItemCooldown {
|
||||||
|
|
||||||
|
- private final Map<Item, ItemCooldown.Info> a = Maps.newHashMap();
|
||||||
|
- private int b;
|
||||||
|
+ public final Map<Item, ItemCooldown.Info> a = Maps.newHashMap(); // PAIL: private->public
|
||||||
|
+ public int b; // PAIL: currentTick, private->public
|
||||||
|
|
||||||
|
public ItemCooldown() {}
|
||||||
|
|
||||||
|
@@ -55,10 +55,10 @@
|
||||||
|
|
||||||
|
protected void c(Item item) {}
|
||||||
|
|
||||||
|
- class Info {
|
||||||
|
+ public class Info { // PAIL: private->public
|
||||||
|
|
||||||
|
final int a;
|
||||||
|
- final int b;
|
||||||
|
+ public final int b; // PAIL: endTick, private->public
|
||||||
|
|
||||||
|
private Info(int i, int j) {
|
||||||
|
this.a = i;
|
@ -52,7 +52,7 @@
|
|||||||
if (this.isCreative()) {
|
if (this.isCreative()) {
|
||||||
if (!this.world.douseFire((EntityHuman) null, blockposition, enumdirection)) {
|
if (!this.world.douseFire((EntityHuman) null, blockposition, enumdirection)) {
|
||||||
this.breakBlock(blockposition);
|
this.breakBlock(blockposition);
|
||||||
@@ -125,15 +146,49 @@
|
@@ -125,14 +146,48 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,8 +79,8 @@
|
|||||||
f = iblockdata.a((EntityHuman) this.player, this.player.world, blockposition);
|
f = iblockdata.a((EntityHuman) this.player, this.player.world, blockposition);
|
||||||
+ // Allow fire punching to be blocked
|
+ // Allow fire punching to be blocked
|
||||||
+ this.world.douseFire((EntityHuman) null, blockposition, enumdirection);
|
+ this.world.douseFire((EntityHuman) null, blockposition, enumdirection);
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
+ if (event.useItemInHand() == Event.Result.DENY) {
|
+ if (event.useItemInHand() == Event.Result.DENY) {
|
||||||
+ // If we 'insta destroyed' then the client needs to be informed.
|
+ // If we 'insta destroyed' then the client needs to be informed.
|
||||||
+ if (f > 1.0f) {
|
+ if (f > 1.0f) {
|
||||||
@ -98,12 +98,11 @@
|
|||||||
+
|
+
|
||||||
+ if (blockEvent.getInstaBreak()) {
|
+ if (blockEvent.getInstaBreak()) {
|
||||||
+ f = 2.0f;
|
+ f = 2.0f;
|
||||||
+ }
|
}
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
if (iblockdata.getMaterial() != Material.AIR && f >= 1.0F) {
|
if (iblockdata.getMaterial() != Material.AIR && f >= 1.0F) {
|
||||||
this.breakBlock(blockposition);
|
this.breakBlock(blockposition);
|
||||||
} else {
|
|
||||||
@@ -150,6 +205,7 @@
|
@@ -150,6 +205,7 @@
|
||||||
|
|
||||||
public void a(BlockPosition blockposition) {
|
public void a(BlockPosition blockposition) {
|
||||||
@ -224,7 +223,7 @@
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,63 +419,86 @@
|
@@ -280,63 +419,90 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,12 +249,16 @@
|
|||||||
- if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) {
|
- if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) {
|
||||||
- itileinventory = ((BlockChest) block).c(world, blockposition);
|
- itileinventory = ((BlockChest) block).c(world, blockposition);
|
||||||
- }
|
- }
|
||||||
+ if (itemstack.getItem() instanceof ItemBlock && !entityhuman.dk()) { // PAIL: creativeAndOp
|
+ if (entityhuman.di().a(itemstack.getItem())) {
|
||||||
+ Block block1 = ((ItemBlock) itemstack.getItem()).getBlock();
|
+ cancelledBlock = true;
|
||||||
|
+ }
|
||||||
|
|
||||||
- if (itileinventory != null) {
|
- if (itileinventory != null) {
|
||||||
- entityhuman.openContainer(itileinventory);
|
- entityhuman.openContainer(itileinventory);
|
||||||
- return EnumInteractionResult.SUCCESS;
|
- return EnumInteractionResult.SUCCESS;
|
||||||
|
+ if (itemstack.getItem() instanceof ItemBlock && !entityhuman.dk()) { // PAIL: creativeAndOp
|
||||||
|
+ Block block1 = ((ItemBlock) itemstack.getItem()).getBlock();
|
||||||
|
+
|
||||||
+ if (block1 instanceof BlockCommand || block1 instanceof BlockStructure) {
|
+ if (block1 instanceof BlockCommand || block1 instanceof BlockStructure) {
|
||||||
+ cancelledBlock = true;
|
+ cancelledBlock = true;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventoryView;
|
|||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftMerchant;
|
import org.bukkit.craftbukkit.inventory.CraftMerchant;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
import org.bukkit.inventory.EntityEquipment;
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
import org.bukkit.permissions.PermissibleBase;
|
import org.bukkit.permissions.PermissibleBase;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
@ -416,4 +417,27 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||||||
public int getExpToLevel() {
|
public int getExpToLevel() {
|
||||||
return getHandle().getExpToLevel();
|
return getHandle().getExpToLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCooldown(Material material) {
|
||||||
|
Preconditions.checkArgument(material != null, "material");
|
||||||
|
|
||||||
|
return getHandle().di().a(CraftMagicNumbers.getItem(material)); // PAIL: getCooldownTracker
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCooldown(Material material) {
|
||||||
|
Preconditions.checkArgument(material != null, "material");
|
||||||
|
|
||||||
|
ItemCooldown.Info cooldown = getHandle().di().a.get(CraftMagicNumbers.getItem(material));
|
||||||
|
return (cooldown == null) ? 0 : Math.max(0, cooldown.b - getHandle().di().b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCooldown(Material material, int ticks) {
|
||||||
|
Preconditions.checkArgument(material != null, "material");
|
||||||
|
Preconditions.checkArgument(ticks >= 0, "Cannot have negative cooldown");
|
||||||
|
|
||||||
|
getHandle().di().a(CraftMagicNumbers.getItem(material), ticks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren