change block destruction logic
This commit is contained in:
parent
2504f24b7b
commit
2d476cbf8a
39 changed files with 175 additions and 746 deletions
|
@ -21,7 +21,7 @@ public class CommandGod extends Command {
|
|||
}
|
||||
|
||||
public void exec(CommandEnvironment env, Executor exec, List<EntityNPC> players, boolean remove, boolean quiet) {
|
||||
remove = !remove && exec.isPlayer() && players.size() == 1 && players.get(0).connection == exec ? players.get(0).hasEffect(Effect.HASTE) && players.get(0).getEffect(Effect.HASTE).getAmplifier() == 255 : remove;
|
||||
remove = !remove && exec.isPlayer() && players.size() == 1 && players.get(0).connection == exec ? players.get(0).hasEffect(Effect.PUNCHING) && players.get(0).getEffect(Effect.PUNCHING).getAmplifier() == 255 : remove;
|
||||
for(EntityNPC player : players) {
|
||||
player.setGodMode(!remove);
|
||||
if(!quiet)
|
||||
|
|
|
@ -186,15 +186,6 @@ public class Player extends User implements Executor, IPlayer
|
|||
private Vec3i selOffset;
|
||||
private EditAction edit = EditAction.SELECT;
|
||||
|
||||
private LocalPos startPos = LocalPos.ORIGIN;
|
||||
private LocalPos removingPos = LocalPos.ORIGIN;
|
||||
private boolean isDestroyingBlock;
|
||||
private boolean receivedFinishDiggingPacket;
|
||||
private int initialDamage;
|
||||
private int curblockDamage;
|
||||
private int initialBlockDamage;
|
||||
private int durabilityRemainingOnBlock = -1;
|
||||
|
||||
private boolean isChangingQuantityOnly;
|
||||
private int respawnTimer;
|
||||
|
||||
|
@ -234,12 +225,6 @@ public class Player extends User implements Executor, IPlayer
|
|||
if(this.entity == null)
|
||||
this.entity = new EntityHuman(world);
|
||||
this.entity.setServerPlayer(this);
|
||||
this.isDestroyingBlock = false;
|
||||
this.receivedFinishDiggingPacket = false;
|
||||
this.initialDamage = 0;
|
||||
this.curblockDamage = 0;
|
||||
this.initialBlockDamage = 0;
|
||||
this.durabilityRemainingOnBlock = -1;
|
||||
this.managedPosX = 0.0;
|
||||
this.managedPosZ = 0.0;
|
||||
this.combinedHealth = Float.MIN_VALUE;
|
||||
|
@ -1048,61 +1033,6 @@ public class Player extends User implements Executor, IPlayer
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
++this.curblockDamage;
|
||||
|
||||
if (this.receivedFinishDiggingPacket)
|
||||
{
|
||||
int i = this.curblockDamage - this.initialBlockDamage;
|
||||
Block block = this.entity.worldObj.getState(this.removingPos).getBlock();
|
||||
|
||||
if (block == Blocks.air)
|
||||
{
|
||||
this.receivedFinishDiggingPacket = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = block.getHardness(this.entity, this.entity.worldObj, this.removingPos) * (float)(i + 1);
|
||||
int j = (int)(f * 10.0F);
|
||||
|
||||
if (j != this.durabilityRemainingOnBlock)
|
||||
{
|
||||
this.durabilityRemainingOnBlock = j;
|
||||
}
|
||||
|
||||
if (f >= 1.0F)
|
||||
{
|
||||
this.receivedFinishDiggingPacket = false;
|
||||
this.tryHarvestBlock(this.removingPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.isDestroyingBlock)
|
||||
{
|
||||
Block block1 = this.entity.worldObj.getState(this.startPos).getBlock();
|
||||
|
||||
if (block1 == Blocks.air)
|
||||
{
|
||||
this.durabilityRemainingOnBlock = -1;
|
||||
this.isDestroyingBlock = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int k = this.curblockDamage - this.initialDamage;
|
||||
float f1 = block1.getHardness(this.entity, this.entity.worldObj, this.removingPos) * (float)(k + 1);
|
||||
int l = (int)(f1 * 10.0F);
|
||||
|
||||
if (l != this.durabilityRemainingOnBlock)
|
||||
{
|
||||
this.durabilityRemainingOnBlock = l;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockClicked(LocalPos pos, Facing side)
|
||||
|
@ -1115,71 +1045,16 @@ public class Player extends User implements Executor, IPlayer
|
|||
return;
|
||||
}
|
||||
|
||||
// if (this.creative)
|
||||
// {
|
||||
// if (!this.worldObj.extinguishFire(null, pos, side))
|
||||
// {
|
||||
// this.tryHarvestBlock(pos);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
Block block = this.entity.worldObj.getState(pos).getBlock();
|
||||
|
||||
this.entity.worldObj.extinguishFire(null, pos, side);
|
||||
this.initialDamage = this.curblockDamage;
|
||||
float f = 1.0F;
|
||||
|
||||
if (block != Blocks.air)
|
||||
{
|
||||
block.onStartBreak(this.entity.worldObj, pos, this.entity);
|
||||
f = block.getHardness(this.entity, this.entity.worldObj, pos);
|
||||
if(this.entity.canHarvestBlock(block))
|
||||
this.tryHarvestBlock(pos);
|
||||
}
|
||||
|
||||
if (block != Blocks.air && f >= 1.0F)
|
||||
{
|
||||
this.tryHarvestBlock(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isDestroyingBlock = true;
|
||||
this.startPos = pos;
|
||||
int i = (int)(f * 10.0F);
|
||||
this.durabilityRemainingOnBlock = i;
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
public void blockRemoving(LocalPos pos)
|
||||
{
|
||||
if (pos.equals(this.startPos))
|
||||
{
|
||||
int i = this.curblockDamage - this.initialDamage;
|
||||
Block block = this.entity.worldObj.getState(pos).getBlock();
|
||||
|
||||
if (block != Blocks.air)
|
||||
{
|
||||
float f = block.getHardness(this.entity, this.entity.worldObj, pos) * (float)(i + 1);
|
||||
|
||||
if (f >= 0.7F)
|
||||
{
|
||||
this.isDestroyingBlock = false;
|
||||
this.tryHarvestBlock(pos);
|
||||
}
|
||||
else if (!this.receivedFinishDiggingPacket)
|
||||
{
|
||||
this.isDestroyingBlock = false;
|
||||
this.receivedFinishDiggingPacket = true;
|
||||
this.removingPos = pos;
|
||||
this.initialBlockDamage = this.initialDamage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelDestroyingBlock()
|
||||
{
|
||||
this.isDestroyingBlock = false;
|
||||
}
|
||||
|
||||
private boolean removeBlock(LocalPos pos)
|
||||
|
@ -2282,8 +2157,6 @@ public class Player extends User implements Executor, IPlayer
|
|||
return;
|
||||
|
||||
case START_DESTROY_BLOCK:
|
||||
case ABORT_DESTROY_BLOCK:
|
||||
case STOP_DESTROY_BLOCK:
|
||||
double d0 = this.entity.posX - ((double)blockpos.getX() + 0.5D);
|
||||
double d1 = this.entity.posY - ((double)blockpos.getY() + 0.5D) + 1.5D;
|
||||
double d2 = this.entity.posZ - ((double)blockpos.getZ() + 0.5D);
|
||||
|
@ -2301,32 +2174,13 @@ public class Player extends User implements Executor, IPlayer
|
|||
}
|
||||
else
|
||||
{
|
||||
if (packetIn.getStatus() == CPacketBreak.Action.START_DESTROY_BLOCK)
|
||||
if (World.isValidXZ(blockpos))
|
||||
{
|
||||
if (World.isValidXZ(blockpos))
|
||||
{
|
||||
this.onBlockClicked(blockpos, packetIn.getFacing());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sendPacket(new SPacketBlockChange(worldserver, blockpos));
|
||||
}
|
||||
this.onBlockClicked(blockpos, packetIn.getFacing());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (packetIn.getStatus() == CPacketBreak.Action.STOP_DESTROY_BLOCK)
|
||||
{
|
||||
this.blockRemoving(blockpos);
|
||||
}
|
||||
else if (packetIn.getStatus() == CPacketBreak.Action.ABORT_DESTROY_BLOCK)
|
||||
{
|
||||
this.cancelDestroyingBlock();
|
||||
}
|
||||
|
||||
if (worldserver.getState(blockpos).getBlock() != Blocks.air)
|
||||
{
|
||||
this.sendPacket(new SPacketBlockChange(worldserver, blockpos));
|
||||
}
|
||||
this.sendPacket(new SPacketBlockChange(worldserver, blockpos));
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -2672,7 +2526,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
|
||||
case GOD:
|
||||
if(this.isAdmin()) {
|
||||
boolean god = !this.entity.hasEffect(Effect.HASTE) || this.entity.getEffect(Effect.HASTE).getAmplifier() != 255;
|
||||
boolean god = !this.entity.hasEffect(Effect.PUNCHING) || this.entity.getEffect(Effect.PUNCHING).getAmplifier() != 255;
|
||||
this.entity.setGodMode(god);
|
||||
this.addFeed(god ? (Color.GREEN + "Statuseffekte wurden hinzugefügt") : (Color.RED + "Statuseffekte wurden entfernt"));
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ public class VillageCollection
|
|||
private boolean isWoodDoor(WorldServer world, LocalPos doorPos)
|
||||
{
|
||||
Block block = world.getState(doorPos).getBlock();
|
||||
return block instanceof BlockDoor ? block.getMaterial() == Material.WOOD : false;
|
||||
return block instanceof BlockDoor ? block.getMaterial() == Material.BURNABLE : false;
|
||||
}
|
||||
|
||||
public TagObject toTags()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue