本文整理汇总了Java中org.bukkit.craftbukkit.event.CraftEventFactory类的典型用法代码示例。如果您正苦于以下问题:Java CraftEventFactory类的具体用法?Java CraftEventFactory怎么用?Java CraftEventFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CraftEventFactory类属于org.bukkit.craftbukkit.event包,在下文中一共展示了CraftEventFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: a
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void a(World world, int i, int j, int k, Random random) {
if (!this.m(world, i, j, k) && !world.isRainingAt(i, j + 1, k)) {
int l = world.getData(i, j, k);
if (l > 0) {
world.setData(i, j, k, l - 1, 2);
} else if (!this.e(world, i, j, k)) {
// CraftBukkit start
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
if (CraftEventFactory.callBlockFadeEvent(block, Blocks.DIRT).isCancelled()) {
return;
}
// CraftBukkit end
world.setTypeUpdate(i, j, k, Blocks.DIRT);
}
} else {
world.setData(i, j, k, 7, 2);
}
}
示例2: e
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void e() {
this.a = Math.max(0, this.a - 1);
if (this.a == 4) {
int i = MathHelper.floor(this.b.locX);
int j = MathHelper.floor(this.b.locY);
int k = MathHelper.floor(this.b.locZ);
if (this.c.getType(i, j, k) == Blocks.LONG_GRASS) {
// CraftBukkit
if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, this.b.world.getWorld().getBlockAt(i, j, k), Material.AIR, !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) {
this.c.setAir(i, j, k, false);
}
this.b.p();
} else if (this.c.getType(i, j - 1, k) == Blocks.GRASS) {
// CraftBukkit
if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, this.b.world.getWorld().getBlockAt(i, j - 1, k), Material.DIRT, !this.c.getGameRules().getBoolean("mobGriefing")).isCancelled()) {
this.c.triggerEffect(2001, i, j - 1, k, Block.getId(Blocks.GRASS));
this.c.setTypeAndData(i, j - 1, k, Blocks.DIRT, 0, 2);
}
this.b.p();
}
}
}
示例3: a
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public boolean a(EntityHuman entityhuman) {
ItemStack itemstack = entityhuman.inventory.getItemInHand();
if (itemstack != null && itemstack.getItem() == Items.BUCKET && !entityhuman.abilities.canInstantlyBuild) {
// CraftBukkit start - Got milk?
org.bukkit.Location loc = this.getBukkitEntity().getLocation();
org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Items.MILK_BUCKET);
if (event.isCancelled()) {
return false;
}
if (--itemstack.count <= 0) {
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, CraftItemStack.asNMSCopy(event.getItemStack()));
} else if (!entityhuman.inventory.pickup(new ItemStack(Items.MILK_BUCKET))) {
entityhuman.drop(CraftItemStack.asNMSCopy(event.getItemStack()), false);
}
// CraftBukkit end
return true;
} else {
return super.a(entityhuman);
}
}
示例4: a
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void a(World world, int i, int j, int k, Random random) {
if (world.isEmpty(i, j + 1, k)) {
int l;
for (l = 1; world.getType(i, j - l, k) == this; ++l) {
;
}
if (l < 3) {
int i1 = world.getData(i, j, k);
if (i1 == 15) {
CraftEventFactory.handleBlockGrowEvent(world, i, j + 1, k, this, 0); // CraftBukkit
world.setData(i, j, k, 0, 4);
this.doPhysics(world, i, j + 1, k, this);
} else {
world.setData(i, j, k, i1 + 1, 4);
}
}
}
}
示例5: h
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void h() {
this.lastX = this.locX;
this.lastY = this.locY;
this.lastZ = this.locZ;
++this.a;
this.datawatcher.watch(8, Integer.valueOf(this.b));
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locY);
int k = MathHelper.floor(this.locZ);
if (this.world.worldProvider instanceof WorldProviderTheEnd && this.world.getType(i, j, k) != Blocks.FIRE) {
// CraftBukkit start
if (!CraftEventFactory.callBlockIgniteEvent(this.world, i, j, k, this).isCancelled()) {
this.world.setTypeUpdate(i, j, k, Blocks.FIRE);
}
// CraftBukkit end
}
}
示例6: a
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void a(EntityLightning entitylightning) {
if (!this.world.isStatic) {
EntityPigZombie entitypigzombie = new EntityPigZombie(this.world);
// CraftBukkit start
if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) {
return;
}
// CraftBukkit end
entitypigzombie.setEquipment(0, new ItemStack(Items.GOLD_SWORD));
entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
// CraftBukkit - added a reason for spawning this creature
this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
this.die();
}
}
示例7: openContainer
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void openContainer(IInventory iinventory) {
if (this.activeContainer != this.defaultContainer) {
this.closeInventory();
}
// CraftBukkit start - Inventory open hook
Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerChest(this.inventory, iinventory));
if (container == null) {
iinventory.closeContainer();
return;
}
// CraftBukkit end
this.nextContainerCounter();
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 0, iinventory.getInventoryName(), iinventory.getSize(), iinventory.k_()));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
}
示例8: openHorseInventory
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void openHorseInventory(EntityHorse entityhorse, IInventory iinventory) {
// CraftBukkit start - Inventory open hook
Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorse(this.inventory, iinventory, entityhorse));
if (container == null) {
iinventory.closeContainer();
return;
}
// CraftBukkit end
if (this.activeContainer != this.defaultContainer) {
this.closeInventory();
}
this.nextContainerCounter();
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 11, iinventory.getInventoryName(), iinventory.getSize(), iinventory.k_(), entityhorse.getId()));
this.activeContainer = container; // CraftBukkit - Use container we passed to event
this.activeContainer.windowId = this.containerCounter;
this.activeContainer.addSlotListener(this);
}
示例9: openCustomInventory
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
private void openCustomInventory(Inventory inventory, EntityPlayer player, String windowType) {
if (player.playerConnection == null) return;
Container container = new CraftContainer(inventory, this, player.nextContainerCounter());
container = CraftEventFactory.callInventoryOpenEvent(player, container);
if(container == null) return;
String title = container.getBukkitView().getTitle();
int size = container.getBukkitView().getTopInventory().getSize();
// Special cases
if (windowType.equals("minecraft:crafting_table")
|| windowType.equals("minecraft:anvil")
|| windowType.equals("minecraft:enchanting_table")
) {
size = 0;
}
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title), size));
getHandle().activeContainer = container;
getHandle().activeContainer.addSlotListener(player);
}
示例10: displayGUIWorkbench
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void displayGUIWorkbench(int p_71058_1_, int p_71058_2_, int p_71058_3_)
{
// CraftBukkit start - Inventory open hook
Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerWorkbench(this.inventory, this.worldObj, p_71058_1_, p_71058_2_, p_71058_3_));
if (container == null)
{
return;
}
// CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 1, "Crafting", 9, true));
this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
示例11: func_146102_a
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void func_146102_a(TileEntityDispenser p_146102_1_)
{
// CraftBukkit start - Inventory open hook
Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerDispenser(this.inventory, p_146102_1_));
if (container == null)
{
p_146102_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
return;
}
// CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, p_146102_1_ instanceof TileEntityDropper ? 10 : 3, p_146102_1_.getInventoryName(), p_146102_1_.getSizeInventory(), p_146102_1_.hasCustomInventoryName()));
this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
示例12: tick
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void tick(EntityLiving entityliving, int i) {
if (this.id == REGENERATION.id) {
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
}
} else if (this.id == POISON.id) {
if (entityliving.getHealth() > 1.0F) {
entityliving.damageEntity(CraftEventFactory.POISON, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
}
} else if (this.id == WITHER.id) {
entityliving.damageEntity(DamageSource.WITHER, 1.0F);
} else if (this.id == HUNGER.id && entityliving instanceof EntityHuman) {
((EntityHuman) entityliving).a(0.025F * (float) (i + 1));
} else if (this.id == SATURATION.id && entityliving instanceof EntityHuman) {
if (!entityliving.world.isStatic) {
((EntityHuman) entityliving).getFoodData().eat(i + 1, 1.0F);
}
} else if ((this.id != HEAL.id || entityliving.aM()) && (this.id != HARM.id || !entityliving.aM())) {
if (this.id == HARM.id && !entityliving.aM() || this.id == HEAL.id && entityliving.aM()) {
entityliving.damageEntity(DamageSource.MAGIC, (float) (6 << i));
}
} else {
entityliving.heal((float) Math.max(4 << i, 0), RegainReason.MAGIC); // CraftBukkit
}
}
示例13: e
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void e() {
this.a = Math.max(0, this.a - 1);
if (this.a == 4) {
int i = MathHelper.floor(this.b.locX);
int j = MathHelper.floor(this.b.locY);
int k = MathHelper.floor(this.b.locZ);
if (this.c.getTypeId(i, j, k) == Block.LONG_GRASS.id) {
// CraftBukkit start
if (!CraftEventFactory.callEntityChangeBlockEvent(this.b.getBukkitEntity(), this.b.world.getWorld().getBlockAt(i, j, k), Material.AIR).isCancelled()) {
this.c.setAir(i, j, k, false);
this.b.n();
}
// CraftBukkit end
} else if (this.c.getTypeId(i, j - 1, k) == Block.GRASS.id) {
// CraftBukkit start
if (!CraftEventFactory.callEntityChangeBlockEvent(this.b.getBukkitEntity(), this.b.world.getWorld().getBlockAt(i, j - 1, k), Material.DIRT).isCancelled()) {
this.c.triggerEffect(2001, i, j - 1, k, Block.GRASS.id);
this.c.setTypeIdAndData(i, j - 1, k, Block.DIRT.id, 0, 2);
this.b.n();
}
// CraftBukkit end
}
}
}
示例14: u
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void u(int i) {
if (this.co()) {
// CraftBukkit start - fire HorseJumpEvent, use event power
if (i < 0) {
i = 0;
}
float power;
if (i >= 90) {
power = 1.0F;
} else {
power = 0.4F + 0.4F * (float) i / 90.0F;
}
org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power);
if (!event.isCancelled()) {
this.bI = true;
this.cO();
this.bt = event.getPower();
}
// CraftBukkit end
}
}
示例15: processCloseWindow
import org.bukkit.craftbukkit.event.CraftEventFactory; //导入依赖的package包/类
public void processCloseWindow(C0DPacketCloseWindow p_147356_1_)
{
if (this.playerEntity.isDead)
{
return; // CraftBukkit
}
// Cauldron start - vanilla compatibility
try
{
if (this.playerEntity.openContainer.getBukkitView() != null)
{
CraftEventFactory.handleInventoryCloseEvent(this.playerEntity); // CraftBukkit
}
}
catch (AbstractMethodError e)
{
// do nothing
}
// Cauldron end
this.playerEntity.closeContainer();
}