summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft
diff options
context:
space:
mode:
authorEvilSeph <evilseph@gmail.com>2011-10-01 13:31:28 -0400
committerEvilSeph <evilseph@gmail.com>2011-10-01 13:37:03 -0400
commit22baa13894264fad9584a10bcdf7427588c07989 (patch)
treeeeae6ca7d48653cb3a19126c4051e00035503d76 /src/main/java/net/minecraft
parentd53a155e4c3c75ed5bf797d75e8df63dd59f1f59 (diff)
downloadcraftbukkit-22baa13894264fad9584a10bcdf7427588c07989.tar
craftbukkit-22baa13894264fad9584a10bcdf7427588c07989.tar.gz
craftbukkit-22baa13894264fad9584a10bcdf7427588c07989.tar.lz
craftbukkit-22baa13894264fad9584a10bcdf7427588c07989.tar.xz
craftbukkit-22baa13894264fad9584a10bcdf7427588c07989.zip
Painting improvements. Thanks CelticMinstrel!
Implement get/setArt and facing direction for paintings; expanded painting break causes; added painting support to World.spawn
Diffstat (limited to 'src/main/java/net/minecraft')
-rw-r--r--src/main/java/net/minecraft/server/EntityPainting.java54
1 files changed, 48 insertions, 6 deletions
diff --git a/src/main/java/net/minecraft/server/EntityPainting.java b/src/main/java/net/minecraft/server/EntityPainting.java
index d94fe56c..c0441a8e 100644
--- a/src/main/java/net/minecraft/server/EntityPainting.java
+++ b/src/main/java/net/minecraft/server/EntityPainting.java
@@ -4,8 +4,11 @@ import java.util.ArrayList;
import java.util.List;
// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Painting;
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
-import org.bukkit.event.painting.PaintingBreakByWorldEvent;
+import org.bukkit.event.painting.PaintingBreakEvent.RemoveCause;
+import org.bukkit.event.painting.PaintingBreakEvent;
// CraftBukkit end
public class EntityPainting extends Entity {
@@ -123,7 +126,17 @@ public class EntityPainting extends Entity {
this.f = 0;
if (!this.i()) {
// CraftBukkit start
- PaintingBreakByWorldEvent event = new PaintingBreakByWorldEvent((org.bukkit.entity.Painting) this.getBukkitEntity());
+ Material material = this.world.getMaterial((int)this.locX, (int)this.locY, (int)this.locZ);
+ RemoveCause cause;
+ if (material.equals(Material.WATER)) {
+ cause = RemoveCause.WATER;
+ } else if (!material.equals(Material.AIR)) {
+ // TODO: This feels insufficient to catch 100% of suffocation cases
+ cause = RemoveCause.OBSTRUCTION;
+ } else {
+ cause = RemoveCause.PHYSICS;
+ }
+ PaintingBreakEvent event = new PaintingBreakEvent((Painting) this.getBukkitEntity(), cause);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
@@ -204,11 +217,21 @@ public class EntityPainting extends Entity {
public boolean damageEntity(DamageSource damagesource, int i) {
if (!this.dead && !this.world.isStatic) {
// CraftBukkit start
- PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((org.bukkit.entity.Painting) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity());
- this.world.getServer().getPluginManager().callEvent(event);
+ PaintingBreakEvent event = null;
+ if (damagesource.getEntity() != null) {
+ event = new PaintingBreakByEntityEvent((Painting) this.getBukkitEntity(), damagesource.getEntity() == null ? null : damagesource.getEntity().getBukkitEntity());
+ } else {
+ if (damagesource == DamageSource.FIRE) {
+ event = new PaintingBreakEvent((Painting) this.getBukkitEntity(), RemoveCause.FIRE);
+ }
+ // TODO: Could put other stuff here?
+ }
+ if (event != null) {
+ this.world.getServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- return true;
+ if (event.isCancelled()) {
+ return true;
+ }
}
if(!dead) {
@@ -222,6 +245,25 @@ public class EntityPainting extends Entity {
return true;
}
+ // CraftBukkit start - copy of a method in Entity except for the CraftBukkit-specific code
+ // TODO: Better way?
+ public void a(EntityWeatherStorm entityweatherstorm) {
+ // CraftBukkit start
+ PaintingBreakByEntityEvent event = new PaintingBreakByEntityEvent((Painting) this.getBukkitEntity(), entityweatherstorm.getBukkitEntity());
+ Bukkit.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
+ ++this.fireTicks;
+ if (this.fireTicks == 0) {
+ this.fireTicks = 300;
+ }
+ }
+ // CraftBukkit end
+
public void b(NBTTagCompound nbttagcompound) {
nbttagcompound.a("Dir", (byte) this.a);
nbttagcompound.setString("Motive", this.e.A);