Block Hunt changes

This commit is contained in:
Chiss 2013-11-14 16:28:29 +11:00
parent 0013b1bacf
commit 99c97d1ecd
14 changed files with 1063 additions and 293 deletions

View File

@ -0,0 +1,246 @@
package net.minecraft.server.v1_6_R3;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Random;
import org.bukkit.craftbukkit.v1_6_R3.event.CraftEventFactory;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class EntityFallingBlock extends Entity
{
public int id;
public int data;
public int c;
public boolean dropItem;
private boolean f;
private boolean hurtEntities;
private int fallHurtMax;
private float fallHurtAmount;
public NBTTagCompound tileEntityData;
public boolean spectating;
public EntityFallingBlock(World world)
{
super(world);
this.dropItem = true;
this.fallHurtMax = 40;
this.fallHurtAmount = 2.0F;
}
public EntityFallingBlock(World world, double d0, double d1, double d2, int i) {
this(world, d0, d1, d2, i, 0);
}
public EntityFallingBlock(World world, double d0, double d1, double d2, int i, int j) {
super(world);
this.dropItem = true;
this.fallHurtMax = 40;
this.fallHurtAmount = 2.0F;
this.id = i;
this.data = j;
this.m = true;
a(0.98F, 0.98F);
this.height = (this.length / 2.0F);
setPosition(d0, d1, d2);
this.motX = 0.0D;
this.motY = 0.0D;
this.motZ = 0.0D;
this.lastX = d0;
this.lastY = d1;
this.lastZ = d2;
}
protected boolean e_() {
return false;
}
protected void a() {
}
public boolean L() {
return !this.dead && !spectating;
}
public void l_() {
if (this.id == 0) {
die();
} else {
this.lastX = this.locX;
this.lastY = this.locY;
this.lastZ = this.locZ;
this.c += 1;
this.motY -= 0.03999999910593033D;
move(this.motX, this.motY, this.motZ);
this.motX *= 0.9800000190734863D;
this.motY *= 0.9800000190734863D;
this.motZ *= 0.9800000190734863D;
if (!this.world.isStatic) {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locY);
int k = MathHelper.floor(this.locZ);
if (this.c == 1)
{
if ((this.c != 1) || (this.world.getTypeId(i, j, k) != this.id) || (this.world.getData(i, j, k) != this.data) || (CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, 0, 0).isCancelled())) {
die();
return;
}
this.world.setAir(i, j, k);
}
if (this.onGround) {
this.motX *= 0.699999988079071D;
this.motZ *= 0.699999988079071D;
this.motY *= -0.5D;
if (this.world.getTypeId(i, j, k) != Block.PISTON_MOVING.id) {
die();
if ((!this.f) && (this.world.mayPlace(this.id, i, j, k, true, 1, (Entity)null, (ItemStack)null)) && (!BlockSand.canFall(this.world, i, j - 1, k)) && (i >= -30000000) && (k >= -30000000) && (i < 30000000) && (k < 30000000) && (j > 0) && (j < 256) && ((this.world.getTypeId(i, j, k) != this.id) || (this.world.getData(i, j, k) != this.data))) {
if (CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.id, this.data).isCancelled()) {
return;
}
this.world.setTypeIdAndData(i, j, k, this.id, this.data, 3);
if ((Block.byId[this.id] instanceof BlockSand)) {
((BlockSand)Block.byId[this.id]).a_(this.world, i, j, k, this.data);
}
if ((this.tileEntityData != null) && ((Block.byId[this.id] instanceof IContainer))) {
TileEntity tileentity = this.world.getTileEntity(i, j, k);
if (tileentity != null) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
tileentity.b(nbttagcompound);
Iterator iterator = this.tileEntityData.c().iterator();
while (iterator.hasNext()) {
NBTBase nbtbase = (NBTBase)iterator.next();
if ((!nbtbase.getName().equals("x")) && (!nbtbase.getName().equals("y")) && (!nbtbase.getName().equals("z"))) {
nbttagcompound.set(nbtbase.getName(), nbtbase.clone());
}
}
tileentity.a(nbttagcompound);
tileentity.update();
}
}
} else if ((this.dropItem) && (!this.f)) {
a(new ItemStack(this.id, 1, Block.byId[this.id].getDropData(this.data)), 0.0F);
}
}
} else if (((this.c > 100) && (!this.world.isStatic) && ((j < 1) || (j > 256))) || (this.c > 600)) {
if (this.dropItem) {
a(new ItemStack(this.id, 1, Block.byId[this.id].getDropData(this.data)), 0.0F);
}
die();
}
}
}
}
protected void b(float f) {
if (this.hurtEntities) {
int i = MathHelper.f(f - 1.0F);
if (i > 0) {
ArrayList arraylist = new ArrayList(this.world.getEntities(this, this.boundingBox));
DamageSource damagesource = this.id == Block.ANVIL.id ? DamageSource.ANVIL : DamageSource.FALLING_BLOCK;
Iterator iterator = arraylist.iterator();
while (iterator.hasNext()) {
Entity entity = (Entity)iterator.next();
float damage = Math.min(MathHelper.d(i * this.fallHurtAmount), this.fallHurtMax);
EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(this, entity, EntityDamageEvent.DamageCause.FALLING_BLOCK, damage);
if (!event.isCancelled())
{
entity.damageEntity(damagesource, (float)event.getDamage());
}
}
if ((this.id == Block.ANVIL.id) && (this.random.nextFloat() < 0.0500000007450581D + i * 0.05D)) {
int j = this.data >> 2;
int k = this.data & 0x3;
j++;
if (j > 2)
this.f = true;
else
this.data = (k | j << 2);
}
}
}
}
protected void b(NBTTagCompound nbttagcompound)
{
nbttagcompound.setByte("Tile", (byte)this.id);
nbttagcompound.setInt("TileID", this.id);
nbttagcompound.setByte("Data", (byte)this.data);
nbttagcompound.setByte("Time", (byte)this.c);
nbttagcompound.setBoolean("DropItem", this.dropItem);
nbttagcompound.setBoolean("HurtEntities", this.hurtEntities);
nbttagcompound.setFloat("FallHurtAmount", this.fallHurtAmount);
nbttagcompound.setInt("FallHurtMax", this.fallHurtMax);
if (this.tileEntityData != null)
nbttagcompound.setCompound("TileEntityData", this.tileEntityData);
}
protected void a(NBTTagCompound nbttagcompound)
{
if (nbttagcompound.hasKey("TileID"))
this.id = nbttagcompound.getInt("TileID");
else {
this.id = (nbttagcompound.getByte("Tile") & 0xFF);
}
this.data = (nbttagcompound.getByte("Data") & 0xFF);
this.c = (nbttagcompound.getByte("Time") & 0xFF);
if (nbttagcompound.hasKey("HurtEntities")) {
this.hurtEntities = nbttagcompound.getBoolean("HurtEntities");
this.fallHurtAmount = nbttagcompound.getFloat("FallHurtAmount");
this.fallHurtMax = nbttagcompound.getInt("FallHurtMax");
} else if (this.id == Block.ANVIL.id) {
this.hurtEntities = true;
}
if (nbttagcompound.hasKey("DropItem")) {
this.dropItem = nbttagcompound.getBoolean("DropItem");
}
if (nbttagcompound.hasKey("TileEntityData")) {
this.tileEntityData = nbttagcompound.getCompound("TileEntityData");
}
if (nbttagcompound.hasKey("Bukkit.tileData")) {
this.tileEntityData = ((NBTTagCompound)nbttagcompound.getCompound("Bukkit.tileData").clone());
}
if (this.id == 0)
this.id = Block.SAND.id;
}
public void a(boolean flag)
{
this.hurtEntities = flag;
}
public void a(CrashReportSystemDetails crashreportsystemdetails) {
super.a(crashreportsystemdetails);
crashreportsystemdetails.a("Immitating block ID", Integer.valueOf(this.id));
crashreportsystemdetails.a("Immitating block data", Integer.valueOf(this.data));
}
public boolean damageEntity(DamageSource damagesource, float f) {
CraftEventFactory.handleEntityDamageEvent(this, damagesource, f);
return false;
}
}

View File

@ -17,6 +17,7 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -455,6 +456,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
player.setAllowFlight(false);
UtilInv.Clear(player);
((CraftEntity)player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
player.setFoodLevel(20);
player.setSaturation(3f);
player.setExhaustion(0f);

View File

@ -966,4 +966,9 @@ public abstract class Game implements Listener
{
return false;
}
public boolean CanThrowTNT(Location location)
{
return true;
}
}

View File

@ -0,0 +1,245 @@
package nautilus.game.arcade.game.games.hideseek.forms;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.hideseek.HideSeek;
import nautilus.game.arcade.game.games.hideseek.kits.KitHiderQuick;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftFallingSand;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class BlockForm extends Form
{
private Material _mat;
private Block _block;
private Location _loc;
public BlockForm(HideSeek host, Player player, Material mat)
{
super(host, player);
_mat = mat;
_loc = player.getLocation();
Apply();
}
@Override
public void Apply()
{
//Remove Old
if (Player.getPassenger() != null)
{
Recharge.Instance.useForce(Player, "PassengerChange", 100);
Player.getPassenger().remove();
Player.eject();
}
((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32));
//Player > Chicken
DisguiseChicken disguise = new DisguiseChicken(Player);
disguise.setBaby();
Host.Manager.GetDisguise().disguise(disguise);
//Apply Falling Block
FallingBlockCheck();
//Inform
UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false) + " Block") + "!"));
//Give Item
Player.getInventory().setItem(8, new ItemStack(Host.GetItemEquivilent(_mat)));
UtilInv.Update(Player);
//Sound
Player.playSound(Player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
}
@Override
public void Remove()
{
SolidifyRemove();
Host.Manager.GetDisguise().undisguise(Player);
//Remove FB
if (Player.getPassenger() != null)
{
Recharge.Instance.useForce(Player, "PassengerChange", 100);
Player.getPassenger().remove();
Player.eject();
}
((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
}
public void SolidifyUpdate()
{
if (!Player.isSprinting())
((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32));
//Not a Block
if (_block == null)
{
//Moved
if (!_loc.getBlock().equals(Player.getLocation().getBlock()))
{
Player.setExp(0);
_loc = Player.getLocation();
}
//Unmoved
else
{
double hideBoost = 0.025;
if (Host.GetKit(Player) instanceof KitHiderQuick)
hideBoost = 0.1;
Player.setExp((float) Math.min(0.999f, Player.getExp() + hideBoost));
//Set Block
if (Player.getExp() >= 0.999f)
{
Block block = Player.getLocation().getBlock();
//Not Able
if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
{
UtilPlayer.message(Player, F.main("Game", "You cannot become a Solid Block here."));
Player.setExp(0f);
return;
}
//Set Block
_block = block;
//Effect
Player.playEffect(Player.getLocation(), Effect.STEP_SOUND, _mat);
//block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _mat);
//Display
SolidifyVisual();
//Invisible
//Host.Manager.GetCondition().Factory().Cloak("Disguised as Block", Player, Player, 60000, false, false);
//Sound
Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
}
}
}
//Is a Block
else
{
//Moved
if (!_loc.getBlock().equals(Player.getLocation().getBlock()))
{
SolidifyRemove();
}
//Send Packets
else
{
SolidifyVisual();
}
}
}
public void SolidifyRemove()
{
if (_block != null)
{
MapUtil.QuickChangeBlockAt(_block.getLocation(), 0, (byte)0);
_block = null;
}
Player.setExp(0f);
//Host.Manager.GetCondition().EndCondition(Player, null, "Disguised as Block");
//Inform
Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 0.5f);
FallingBlockCheck();
}
@SuppressWarnings("deprecation")
public void SolidifyVisual()
{
if (_block == null)
return;
//Remove Old
if (Player.getPassenger() != null)
{
Recharge.Instance.useForce(Player, "PassengerChange", 100);
Player.getPassenger().remove();
Player.eject();
}
//Others
for (Player other : UtilServer.getPlayers())
other.sendBlockChange(Player.getLocation(), _mat, (byte)0);
//Self
Player.sendBlockChange(Player.getLocation(), 36, (byte)0);
FallingBlockCheck();
}
public void FallingBlockCheck()
{
//Block Form (Hide Falling)
if (_block != null)
return;
//Recreate Falling
if (Player.getPassenger() == null || !Player.getPassenger().isValid())
{
if (!Recharge.Instance.use(Player, "PassengerChange", 100, false))
return;
//Falling Block
FallingBlock block = Player.getWorld().spawnFallingBlock(Player.getEyeLocation(), _mat, (byte)0);
//No Arrow Collision
((CraftFallingSand)block).getHandle().spectating = true;
Player.setPassenger(block);
}
//Ensure Falling doesnt Despawn
else
{
((CraftFallingSand)Player.getPassenger()).getHandle().c = 1;
Player.getPassenger().setTicksLived(1);
}
}
public Block GetBlock()
{
return _block;
}
}

View File

@ -0,0 +1,65 @@
package nautilus.game.arcade.game.games.hideseek.forms;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.*;
import nautilus.game.arcade.game.games.hideseek.HideSeek;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class CreatureForm extends Form
{
private EntityType _type;
private DisguiseBase _disguise;
public CreatureForm(HideSeek host, Player player, EntityType entityType)
{
super(host, player);
_type = entityType;
Apply();
}
@Override
public void Apply()
{
Material icon = Material.PORK;
if (_type == EntityType.CHICKEN) {_disguise = new DisguiseChicken(Player); icon = Material.FEATHER;}
else if (_type == EntityType.COW) {_disguise = new DisguiseCow(Player); icon = Material.LEATHER;}
else if (_type == EntityType.SHEEP) {_disguise = new DisguiseSheep(Player); icon = Material.WOOL;}
else if (_type == EntityType.PIG) {_disguise = new DisguisePig(Player); icon = Material.PORK;}
Host.Manager.GetDisguise().disguise(_disguise);
((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
//Inform
UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a " + F.elem(UtilEnt.getName(_type)) + "!"));
//Give Item
Player.getInventory().setItem(8, new ItemStack(Host.GetItemEquivilent(icon)));
UtilInv.Update(Player);
//Sound
Player.playSound(Player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
}
@Override
public void Remove()
{
Host.Manager.GetDisguise().undisguise(Player);
((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
}
}

View File

@ -0,0 +1,20 @@
package nautilus.game.arcade.game.games.hideseek.forms;
import nautilus.game.arcade.game.games.hideseek.HideSeek;
import org.bukkit.entity.Player;
public abstract class Form
{
public HideSeek Host;
public Player Player;
public Form(HideSeek host, Player player)
{
Host = host;
Player = player;
}
public abstract void Apply();
public abstract void Remove();
}

View File

@ -17,13 +17,12 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.*;
public class KitHiderQuick extends Kit
{
public KitHiderQuick(ArcadeManager manager)
{
super(manager, "Instant Hider", KitAvailability.Free,
super(manager, "Instant Hider", KitAvailability.Green,
new String[]
{
@ -42,7 +41,7 @@ public class KitHiderQuick extends Kit
public void GiveItems(Player player)
{
//Swap
player.getInventory().setItem(0, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 1, C.cYellow + C.Bold + "Click Block" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Change Form"));
player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 1, C.cYellow + C.Bold + "Click Block" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Change Form"));
}
@Override

View File

@ -23,7 +23,7 @@ public class KitHiderShocker extends Kit
{
public KitHiderShocker(ArcadeManager manager)
{
super(manager, "Shocking Hider", KitAvailability.Free,
super(manager, "Shocking Hider", KitAvailability.Blue,
new String[]
{
@ -41,7 +41,7 @@ public class KitHiderShocker extends Kit
@Override
public void GiveItems(Player player)
{
player.getInventory().setItem(0, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 1, C.cYellow + C.Bold + "Click Block" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Change Form"));
player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 1, C.cYellow + C.Bold + "Click Block" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Change Form"));
}
@Override

View File

@ -26,7 +26,7 @@ public class KitHiderSwapper extends Kit
new String[]
{
"Can change form 12 times!"
"Can change form up to 24 times!"
},
new Perk[]
@ -40,7 +40,7 @@ public class KitHiderSwapper extends Kit
@Override
public void GiveItems(Player player)
{
player.getInventory().setItem(0, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 12, C.cYellow + C.Bold + "Click Block" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Change Form"));
player.getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 1, C.cYellow + C.Bold + "Click Block" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Change Form"));
}
@Override

View File

@ -22,7 +22,7 @@ public class KitSeekerHunter extends Kit
{
public KitSeekerHunter(ArcadeManager manager)
{
super(manager, "Hunter Seeker", KitAvailability.Green,
super(manager, "Hunter Seeker", KitAvailability.Blue,
new String[]
{
"Tick......tick...tick.tick.",

View File

@ -30,7 +30,7 @@ public class KitSeekerTNT extends Kit
new Perk[]
{
new PerkBomber(10, 4, -1)
new PerkBomber(15, 2, -1)
},
EntityType.ZOMBIE,
new ItemStack(Material.TNT));

View File

@ -87,8 +87,6 @@ public class SuperSmash extends SoloGame
this.SpawnDistanceRequirement = 16;
this.InventoryOpen = false;
this.HungerSet = 20;
}
@EventHandler(priority = EventPriority.HIGH)
@ -344,6 +342,8 @@ public class SuperSmash extends SoloGame
if (!IsLive())
return;
hungerTick = (hungerTick + 1)%8;
for (Player player : GetPlayers(true))
{
if (player.getFoodLevel() <= 0)
@ -355,8 +355,6 @@ public class SuperSmash extends SoloGame
UtilPlayer.message(player, F.main("Game", "Attack other players to restore hunger!"));
}
hungerTick = (hungerTick + 1)%8;
if (hungerTick == 0)
UtilPlayer.hunger(player, -1);
}

View File

@ -35,7 +35,7 @@ public class PerkBomber extends Perk
private int _spawnRate;
private int _max;
private int _fuse;
public PerkBomber(int spawnRate, int max, int fuse)
{
super("Bomber", new String[]
@ -133,6 +133,13 @@ public class PerkBomber extends Perk
event.setCancelled(true);
if (!Manager.GetGame().CanThrowTNT(player.getLocation()))
{
//Inform
UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throwing TNT") + " here."));
return;
}
UtilInv.remove(player, Material.TNT, (byte)0, 1);
UtilInv.Update(player);