gun should always revert blockchanges made by player

This commit is contained in:
UnknownShadow200 2019-02-01 15:21:12 +11:00
parent 4bf0b21023
commit 5c1a9654d5
2 changed files with 6 additions and 8 deletions

View File

@ -31,15 +31,11 @@ namespace MCGalaxy.Commands.Fun {
p.Message("Guns cannot be used on this map!"); return;
}
if (p.weapon != null && message.Length == 0) {
p.weapon.Disable();
p.weapon = null;
return;
p.weapon.Disable(); return;
}
Gun gun = GetGun(p, message);
if (gun == null) { Help(p); return; }
p.weapon = gun;
gun.Enable(p);
}

View File

@ -42,11 +42,12 @@ namespace MCGalaxy.Games {
}
this.p = p;
p.ClearBlockchange();
p.weapon = this;
p.Blockchange += BlockClickCallback;
if (p.Supports(CpeExt.PlayerClick)) {
p.Message(Name + " engaged, click to fire at will");
} else {
p.Blockchange += BlockClickCallback;
p.Message(Name + " engaged, fire at will");
aimer = new AimBox();
aimer.Hook(p);
@ -67,8 +68,9 @@ namespace MCGalaxy.Games {
Weapon weapon = p.weapon;
if (weapon == null) return;
// always revert block back, client assumes changes always succeed
p.RevertBlock(x, y, z);
// defer to player click handler
// defer to player click handler if used
if (weapon.aimer == null) return;
if (!p.level.Config.Guns) { weapon.Disable(); return; }