summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2012-12-22 12:37:06 -0600
committerTravis Watkins <amaranth@ubuntu.com>2012-12-22 13:06:55 -0600
commitda571ef428883a1f7d75463ce49c12e69475b29d (patch)
treeb00c4199569f1604140db70bb7daccb56273dc32
parentdc85940526734c0f76816b0e747c002d67fc2a99 (diff)
downloadcraftbukkit-da571ef428883a1f7d75463ce49c12e69475b29d.tar
craftbukkit-da571ef428883a1f7d75463ce49c12e69475b29d.tar.gz
craftbukkit-da571ef428883a1f7d75463ce49c12e69475b29d.tar.lz
craftbukkit-da571ef428883a1f7d75463ce49c12e69475b29d.tar.xz
craftbukkit-da571ef428883a1f7d75463ce49c12e69475b29d.zip
Add DispenseBehaviorFireworks and EntityFireworks for diff visibility
-rw-r--r--src/main/java/net/minecraft/server/DispenseBehaviorFireworks.java26
-rw-r--r--src/main/java/net/minecraft/server/EntityFireworks.java121
2 files changed, 147 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorFireworks.java b/src/main/java/net/minecraft/server/DispenseBehaviorFireworks.java
new file mode 100644
index 00000000..63592cbd
--- /dev/null
+++ b/src/main/java/net/minecraft/server/DispenseBehaviorFireworks.java
@@ -0,0 +1,26 @@
+package net.minecraft.server;
+
+public class DispenseBehaviorFireworks extends DispenseBehaviorItem {
+
+ final MinecraftServer b;
+
+ public DispenseBehaviorFireworks(MinecraftServer minecraftserver) {
+ this.b = minecraftserver;
+ }
+
+ public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
+ EnumFacing enumfacing = EnumFacing.a(isourceblock.h());
+ double d0 = isourceblock.getX() + (double) enumfacing.c();
+ double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F);
+ double d2 = isourceblock.getZ() + (double) enumfacing.e();
+ EntityFireworks entityfireworks = new EntityFireworks(isourceblock.k(), d0, d1, d2, itemstack);
+
+ isourceblock.k().addEntity(entityfireworks);
+ itemstack.a(1);
+ return itemstack;
+ }
+
+ protected void a(ISourceBlock isourceblock) {
+ isourceblock.k().triggerEffect(1002, isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ(), 0);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/EntityFireworks.java b/src/main/java/net/minecraft/server/EntityFireworks.java
new file mode 100644
index 00000000..0553ec8d
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EntityFireworks.java
@@ -0,0 +1,121 @@
+package net.minecraft.server;
+
+public class EntityFireworks extends Entity {
+
+ private int a;
+ private int b;
+
+ public EntityFireworks(World world) {
+ super(world);
+ this.a(0.25F, 0.25F);
+ }
+
+ protected void a() {
+ this.datawatcher.a(8, new ItemStack(0, 0, 0));
+ }
+
+ public EntityFireworks(World world, double d0, double d1, double d2, ItemStack itemstack) {
+ super(world);
+ this.a = 0;
+ this.a(0.25F, 0.25F);
+ this.setPosition(d0, d1, d2);
+ this.height = 0.0F;
+ int i = 1;
+
+ if (itemstack != null && itemstack.hasTag()) {
+ this.datawatcher.watch(8, itemstack);
+ NBTTagCompound nbttagcompound = itemstack.getTag();
+ NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Fireworks");
+
+ if (nbttagcompound1 != null) {
+ i += nbttagcompound1.getByte("Flight");
+ }
+ }
+
+ this.motX = this.random.nextGaussian() * 0.001D;
+ this.motZ = this.random.nextGaussian() * 0.001D;
+ this.motY = 0.05D;
+ this.b = 10 * i + this.random.nextInt(6) + this.random.nextInt(7);
+ }
+
+ public void j_() {
+ this.T = this.locX;
+ this.U = this.locY;
+ this.V = this.locZ;
+ super.j_();
+ this.motX *= 1.15D;
+ this.motZ *= 1.15D;
+ this.motY += 0.04D;
+ this.move(this.motX, this.motY, this.motZ);
+ float f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
+
+ this.yaw = (float) (Math.atan2(this.motX, this.motZ) * 180.0D / 3.1415927410125732D);
+
+ for (this.pitch = (float) (Math.atan2(this.motY, (double) f) * 180.0D / 3.1415927410125732D); this.pitch - this.lastPitch < -180.0F; this.lastPitch -= 360.0F) {
+ ;
+ }
+
+ while (this.pitch - this.lastPitch >= 180.0F) {
+ this.lastPitch += 360.0F;
+ }
+
+ while (this.yaw - this.lastYaw < -180.0F) {
+ this.lastYaw -= 360.0F;
+ }
+
+ while (this.yaw - this.lastYaw >= 180.0F) {
+ this.lastYaw += 360.0F;
+ }
+
+ this.pitch = this.lastPitch + (this.pitch - this.lastPitch) * 0.2F;
+ this.yaw = this.lastYaw + (this.yaw - this.lastYaw) * 0.2F;
+ if (this.a == 0) {
+ this.world.makeSound(this, "fireworks.launch", 3.0F, 1.0F);
+ }
+
+ ++this.a;
+ if (this.world.isStatic && this.a % 2 < 2) {
+ this.world.addParticle("fireworksSpark", this.locX, this.locY - 0.3D, this.locZ, this.random.nextGaussian() * 0.05D, -this.motY * 0.5D, this.random.nextGaussian() * 0.05D);
+ }
+
+ if (!this.world.isStatic && this.a > this.b) {
+ this.world.broadcastEntityEffect(this, (byte) 17);
+ this.die();
+ }
+ }
+
+ public void b(NBTTagCompound nbttagcompound) {
+ nbttagcompound.setInt("Life", this.a);
+ nbttagcompound.setInt("LifeTime", this.b);
+ ItemStack itemstack = this.datawatcher.f(8);
+
+ if (itemstack != null) {
+ NBTTagCompound nbttagcompound1 = new NBTTagCompound();
+
+ itemstack.save(nbttagcompound1);
+ nbttagcompound.setCompound("FireworksItem", nbttagcompound1);
+ }
+ }
+
+ public void a(NBTTagCompound nbttagcompound) {
+ this.a = nbttagcompound.getInt("Life");
+ this.b = nbttagcompound.getInt("LifeTime");
+ NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("FireworksItem");
+
+ if (nbttagcompound1 != null) {
+ ItemStack itemstack = ItemStack.a(nbttagcompound1);
+
+ if (itemstack != null) {
+ this.datawatcher.watch(8, itemstack);
+ }
+ }
+ }
+
+ public float c(float f) {
+ return super.c(f);
+ }
+
+ public boolean aq() {
+ return false;
+ }
+}