Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
EntityChangeBlockEvent.java
1 package org.bukkit.event.entity;
2 
3 import org.bukkit.Material;
4 import org.bukkit.block.Block;
5 import org.bukkit.entity.Entity;
9 
10 /**
11  * Called when any Entity, excluding players, changes a block.
12  */
13 public class EntityChangeBlockEvent extends EntityEvent implements Cancellable {
14  private static final HandlerList handlers = new HandlerList();
15  private final Block block;
16  private boolean cancel;
17  private final Material to;
18  private final byte data;
19 
20  /**
21  *
22  * @param what the LivingEntity causing the change
23  * @param block the block (before the change)
24  * @param to the future material being changed to
25  * @deprecated Provided as a backward compatibility before the data byte
26  * was provided, and type increased to all entities
27  */
28  @Deprecated
29  public EntityChangeBlockEvent(final LivingEntity what, final Block block, final Material to) {
30  this (what, block, to, (byte) 0);
31  }
32 
33  /**
34  *
35  * @param what the Entity causing the change
36  * @param block the block (before the change)
37  * @param to the future material being changed to
38  * @param data the future block data
39  * @deprecated Magic value
40  */
41  @Deprecated
42  public EntityChangeBlockEvent(final Entity what, final Block block, final Material to, final byte data) {
43  super(what);
44  this.block = block;
45  this.cancel = false;
46  this.to = to;
47  this.data = data;
48  }
49 
50  /**
51  * Gets the block the entity is changing
52  *
53  * @return the block that is changing
54  */
55  public Block getBlock() {
56  return block;
57  }
58 
59  public boolean isCancelled() {
60  return cancel;
61  }
62 
63  public void setCancelled(boolean cancel) {
64  this.cancel = cancel;
65  }
66 
67  /**
68  * Gets the Material that the block is changing into
69  *
70  * @return the material that the block is changing into
71  */
72  public Material getTo() {
73  return to;
74  }
75 
76  /**
77  * Gets the data for the block that would be changed into
78  *
79  * @return the data for the block that would be changed into
80  * @deprecated Magic value
81  */
82  @Deprecated
83  public byte getData() {
84  return data;
85  }
86 
87  @Override
88  public HandlerList getHandlers() {
89  return handlers;
90  }
91 
92  public static HandlerList getHandlerList() {
93  return handlers;
94  }
95 }
EntityChangeBlockEvent(final Entity what, final Block block, final Material to, final byte data)
EntityChangeBlockEvent(final LivingEntity what, final Block block, final Material to)