Added events related to weather in 1.5. Thanks wizjany!
Dieser Commit ist enthalten in:
Ursprung
1d0a6d56b7
Commit
d2a4c510b3
@ -4,6 +4,7 @@ package net.minecraft.server;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.CreeperPowerEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class EntityCreeper extends EntityMonster {
|
||||
@ -125,6 +126,16 @@ public class EntityCreeper extends EntityMonster {
|
||||
|
||||
public void a(EntityWeatherStorm entityweatherstorm) {
|
||||
super.a(entityweatherstorm);
|
||||
this.datawatcher.b(17, Byte.valueOf((byte) 1));
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer) this.world).getServer();
|
||||
org.bukkit.entity.Entity entity = this.getBukkitEntity();
|
||||
|
||||
CreeperPowerEvent event = new CreeperPowerEvent(entity, entityweatherstorm.getBukkitEntity(), CreeperPowerEvent.PowerCause.LIGHTNING);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
this.datawatcher.b(17, Byte.valueOf((byte) 1));
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
95
src/main/java/net/minecraft/server/EntityPig.java
Normale Datei
95
src/main/java/net/minecraft/server/EntityPig.java
Normale Datei
@ -0,0 +1,95 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
//CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.PigZapEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class EntityPig extends EntityAnimal {
|
||||
|
||||
public EntityPig(World world) {
|
||||
super(world);
|
||||
this.texture = "/mob/pig.png";
|
||||
this.b(0.9F, 0.9F);
|
||||
}
|
||||
|
||||
protected void b() {
|
||||
this.datawatcher.a(16, Byte.valueOf((byte) 0));
|
||||
}
|
||||
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
super.b(nbttagcompound);
|
||||
nbttagcompound.a("Saddle", this.x());
|
||||
}
|
||||
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
super.a(nbttagcompound);
|
||||
this.a(nbttagcompound.m("Saddle"));
|
||||
}
|
||||
|
||||
protected String g() {
|
||||
return "mob.pig";
|
||||
}
|
||||
|
||||
protected String h() {
|
||||
return "mob.pig";
|
||||
}
|
||||
|
||||
protected String i() {
|
||||
return "mob.pigdeath";
|
||||
}
|
||||
|
||||
public boolean a(EntityHuman entityhuman) {
|
||||
if (this.x() && !this.world.isStatic
|
||||
&& (this.passenger == null || this.passenger == entityhuman)) {
|
||||
entityhuman.mount(this);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected int j() {
|
||||
return this.fireTicks > 0 ? Item.GRILLED_PORK.id : Item.PORK.id;
|
||||
}
|
||||
|
||||
public boolean x() {
|
||||
return (this.datawatcher.a(16) & 1) != 0;
|
||||
}
|
||||
|
||||
public void a(boolean flag) {
|
||||
if (flag) {
|
||||
this.datawatcher.b(16, Byte.valueOf((byte) 1));
|
||||
} else {
|
||||
this.datawatcher.b(16, Byte.valueOf((byte) 0));
|
||||
}
|
||||
}
|
||||
|
||||
public void a(EntityWeatherStorm entityweatherstorm) {
|
||||
EntityPigZombie entitypigzombie = new EntityPigZombie(this.world);
|
||||
entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ,
|
||||
this.yaw, this.pitch);
|
||||
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer) this.world).getServer();
|
||||
org.bukkit.entity.Entity entity = this.getBukkitEntity();
|
||||
|
||||
PigZapEvent event = new PigZapEvent(entity, entityweatherstorm.getBukkitEntity(), entitypigzombie.getBukkitEntity());
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
this.world.addEntity(entitypigzombie);
|
||||
this.die();
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
protected void a(float f) {
|
||||
super.a(f);
|
||||
if (f > 5.0F && this.passenger instanceof EntityHuman) {
|
||||
((EntityHuman) this.passenger).a((Statistic) AchievementList.u);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,11 +9,14 @@ import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class World implements IBlockAccess {
|
||||
@ -1490,7 +1493,13 @@ public class World implements IBlockAccess {
|
||||
--i;
|
||||
this.worldData.b(i);
|
||||
if (i <= 0) {
|
||||
this.worldData.a(!this.worldData.j());
|
||||
CraftServer server = ((WorldServer) this).getServer();
|
||||
|
||||
ThunderChangeEvent thunder = new ThunderChangeEvent(((WorldServer) this).getWorld(), !this.worldData.j());
|
||||
server.getPluginManager().callEvent(thunder);
|
||||
if (!thunder.isCancelled()) {
|
||||
this.worldData.a(!this.worldData.j());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1506,7 +1515,13 @@ public class World implements IBlockAccess {
|
||||
--j;
|
||||
this.worldData.c(j);
|
||||
if (j <= 0) {
|
||||
this.worldData.b(!this.worldData.l());
|
||||
CraftServer server = ((WorldServer) this).getServer();
|
||||
|
||||
WeatherChangeEvent weather = new WeatherChangeEvent(((WorldServer) this).getWorld(), !this.worldData.l());
|
||||
server.getPluginManager().callEvent(weather);
|
||||
if (!weather.isCancelled()) {
|
||||
this.worldData.b(!this.worldData.l());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1543,10 +1558,23 @@ public class World implements IBlockAccess {
|
||||
}
|
||||
|
||||
private void y() {
|
||||
this.worldData.c(0);
|
||||
this.worldData.b(false);
|
||||
this.worldData.b(0);
|
||||
this.worldData.a(false);
|
||||
// CraftBukkit start
|
||||
CraftServer server = ((WorldServer) this).getServer();
|
||||
|
||||
WeatherChangeEvent weather = new WeatherChangeEvent((org.bukkit.World) this, false);
|
||||
server.getPluginManager().callEvent(weather);
|
||||
|
||||
ThunderChangeEvent thunder = new ThunderChangeEvent((org.bukkit.World) this, false);
|
||||
server.getPluginManager().callEvent(thunder);
|
||||
if (!weather.isCancelled()) {
|
||||
this.worldData.c(0);
|
||||
this.worldData.b(false);
|
||||
}
|
||||
if (!thunder.isCancelled()) {
|
||||
this.worldData.b(0);
|
||||
this.worldData.a(false);
|
||||
}
|
||||
//CraftBukkit end
|
||||
}
|
||||
|
||||
protected void j() {
|
||||
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
|
||||
public class WorldServer extends World implements BlockChangeDelegate {
|
||||
// CraftBukkit end
|
||||
@ -105,8 +106,15 @@ public class WorldServer extends World implements BlockChangeDelegate {
|
||||
|
||||
public boolean a(Entity entity) {
|
||||
if (super.a(entity)) {
|
||||
this.server.serverConfigurationManager.a(entity.locX, entity.locY, entity.locZ, 512.0D, new Packet71Weather(entity));
|
||||
return true;
|
||||
CraftServer server = cserver;
|
||||
|
||||
LightningStrikeEvent lightning = new LightningStrikeEvent((org.bukkit.World) world, entity.getBukkitEntity());
|
||||
server.getPluginManager().callEvent(lightning);
|
||||
if (!lightning.isCancelled()) {
|
||||
this.server.serverConfigurationManager.a(entity.locX, entity.locY, entity.locZ, 512.0D, new Packet71Weather(entity));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ import java.util.Random;
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
import org.bukkit.event.world.SpawnChangeEvent;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Boat;
|
||||
@ -121,16 +123,16 @@ public class CraftWorld implements World {
|
||||
public boolean unloadChunk(int x, int z, boolean save) {
|
||||
return unloadChunk(x, z, save, false);
|
||||
}
|
||||
|
||||
|
||||
public boolean unloadChunkRequest(int x, int z) {
|
||||
return unloadChunkRequest(x, z, true);
|
||||
}
|
||||
|
||||
|
||||
public boolean unloadChunkRequest(int x, int z, boolean safe) {
|
||||
if (safe && isChunkInUse(x, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
provider.queueUnload(x, z);
|
||||
|
||||
return true;
|
||||
@ -554,13 +556,19 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public void setStorm(boolean hasStorm) {
|
||||
world.worldData.b(hasStorm);
|
||||
|
||||
// These numbers are from Minecraft
|
||||
if (hasStorm) {
|
||||
setWeatherDuration(rand.nextInt(12000) + 12000);
|
||||
} else {
|
||||
setWeatherDuration(rand.nextInt(168000) + 12000);
|
||||
CraftServer server = world.getServer();
|
||||
|
||||
WeatherChangeEvent weather = new WeatherChangeEvent((org.bukkit.World) this, hasStorm);
|
||||
server.getPluginManager().callEvent(weather);
|
||||
if (!weather.isCancelled()) {
|
||||
world.worldData.b(hasStorm);
|
||||
|
||||
// These numbers are from Minecraft
|
||||
if (hasStorm) {
|
||||
setWeatherDuration(rand.nextInt(12000) + 12000);
|
||||
} else {
|
||||
setWeatherDuration(rand.nextInt(168000) + 12000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -577,22 +585,28 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public void setThundering(boolean thundering) {
|
||||
world.worldData.a(thundering);
|
||||
|
||||
// These numbers are from Minecraft
|
||||
if (thundering) {
|
||||
setThunderDuration(rand.nextInt(12000) + 3600);
|
||||
} else {
|
||||
setThunderDuration(rand.nextInt(168000) + 12000);
|
||||
CraftServer server = world.getServer();
|
||||
|
||||
ThunderChangeEvent thunder = new ThunderChangeEvent((org.bukkit.World) this, thundering);
|
||||
server.getPluginManager().callEvent(thunder);
|
||||
if (!thunder.isCancelled()) {
|
||||
world.worldData.a(thundering);
|
||||
|
||||
// These numbers are from Minecraft
|
||||
if (thundering) {
|
||||
setThunderDuration(rand.nextInt(12000) + 3600);
|
||||
} else {
|
||||
setThunderDuration(rand.nextInt(168000) + 12000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getThunderDuration() {
|
||||
return world.worldData.k();
|
||||
}
|
||||
|
||||
public void setThunderDuration(int duration) {
|
||||
world.worldData.b(duration);
|
||||
world.worldData.b(duration);
|
||||
}
|
||||
|
||||
public long getSeed() {
|
||||
|
@ -1,8 +1,11 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityCreeper;
|
||||
import net.minecraft.server.WorldServer;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.event.entity.CreeperPowerEvent;
|
||||
|
||||
public class CraftCreeper extends CraftMonster implements Creeper {
|
||||
|
||||
@ -20,11 +23,28 @@ public class CraftCreeper extends CraftMonster implements Creeper {
|
||||
}
|
||||
|
||||
public void setPowered(boolean powered) {
|
||||
// CraftBukkit start
|
||||
CraftServer server = this.server;
|
||||
org.bukkit.entity.Entity entity = this.getHandle().getBukkitEntity();
|
||||
|
||||
if (powered) {
|
||||
getHandle().W().b(17, (byte)1);
|
||||
CreeperPowerEvent event = new CreeperPowerEvent(entity, CreeperPowerEvent.PowerCause.SET_ON);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
getHandle().W().b(17, (byte)1);
|
||||
}
|
||||
} else {
|
||||
getHandle().W().b(17, (byte)0);
|
||||
CreeperPowerEvent event = new CreeperPowerEvent(entity, CreeperPowerEvent.PowerCause.SET_OFF);
|
||||
server.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
getHandle().W().b(17, (byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
// CraftBukkit end
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityPig;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.CraftAnimals;
|
||||
import org.bukkit.entity.Pig;
|
||||
|
||||
public class CraftPig extends CraftAnimals implements Pig {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren