mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-16 04:33:56 -07:00
Implement Bucket events
This commit is contained in:
72
src/main/java/net/minecraft/server/EntityCow.java
Normal file
72
src/main/java/net/minecraft/server/EntityCow.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class EntityCow extends EntityAnimal {
|
||||
|
||||
public EntityCow(World world) {
|
||||
super(world);
|
||||
this.texture = "/mob/cow.png";
|
||||
this.a(0.9F, 1.3F);
|
||||
}
|
||||
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
super.a(nbttagcompound);
|
||||
}
|
||||
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
super.b(nbttagcompound);
|
||||
}
|
||||
|
||||
protected String e() {
|
||||
return "mob.cow";
|
||||
}
|
||||
|
||||
protected String f() {
|
||||
return "mob.cowhurt";
|
||||
}
|
||||
|
||||
protected String g() {
|
||||
return "mob.cowhurt";
|
||||
}
|
||||
|
||||
protected float i() {
|
||||
return 0.4F;
|
||||
}
|
||||
|
||||
protected int h() {
|
||||
return Item.LEATHER.id;
|
||||
}
|
||||
|
||||
public boolean a(EntityHuman entityhuman) {
|
||||
ItemStack itemstack = entityhuman.inventory.b();
|
||||
|
||||
if (itemstack != null && itemstack.id == Item.BUCKET.id) {
|
||||
// CraftBukkit start - got milk?
|
||||
Location loc = this.getBukkitEntity().getLocation();
|
||||
PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Item.MILK_BUCKET);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CraftItemStack itemInHand = (CraftItemStack) event.getItemStack();
|
||||
byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
|
||||
itemstack = new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data );
|
||||
|
||||
entityhuman.inventory.a(entityhuman.inventory.c, itemstack);
|
||||
// CraftBukkit end
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user