mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Merge branch 'kotyaralih:master' into master
This commit is contained in:
commit
f2e82b77de
6 changed files with 90 additions and 60 deletions
|
|
@ -501,9 +501,16 @@ class BlockAPI{
|
|||
$hand->position($block);
|
||||
//$face = -1;
|
||||
}
|
||||
|
||||
if($hand->isSolid === true and $block->boundingBox->intersectsWith($player->entity->boundingBox) && ($hand->getID() != BED_BLOCK && $hand->getID() != CARPET)){
|
||||
return $this->cancelAction($block, $player, false); //Entity in block
|
||||
|
||||
if($hand->isSolid === true && ($hand->getID() != BED_BLOCK && $hand->getID() != CARPET)){
|
||||
$aabb = $hand->getAABB($block->level, $block->x, $block->y, $block->z);
|
||||
$playerbb = $player->entity->boundingBox;
|
||||
//$aabb->intersectsWith($playerbb) is not good enough for this case
|
||||
//minY+0.21 is used to stop sneaking from triggering action cancelling
|
||||
if(($aabb->maxX > $playerbb->minX && $aabb->minX < $playerbb->maxX) && ($aabb->maxY > ($playerbb->minY+0.21) && $aabb->minY < $playerbb->maxY) && ($aabb->maxZ > $playerbb->minZ && $aabb->minZ < $playerbb->maxZ)){
|
||||
return $this->cancelAction($block, $player, false); //Entity in block
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($this->server->api->dhandle("player.block.place", ["player" => $player, "block" => $block, "target" => $target, "item" => $item]) === false){
|
||||
|
|
|
|||
|
|
@ -422,6 +422,8 @@ class Player{
|
|||
public function sendBuffer(){
|
||||
if($this->bufferLen > 0 and $this->buffer instanceof RakNetPacket){
|
||||
$this->buffer->seqNumber = $this->counter[0]++;
|
||||
$this->recoveryQueue[$this->buffer->seqNumber] = $this->buffer;
|
||||
$this->buffer->sendtime = microtime(true);
|
||||
$this->send($this->buffer);
|
||||
}
|
||||
$this->bufferLen = 0;
|
||||
|
|
@ -965,15 +967,6 @@ class Player{
|
|||
}
|
||||
|
||||
if($m !== ""){
|
||||
|
||||
/*$pk = new LevelEventPacket();
|
||||
$pk->evid = LevelEventPacket::EVENT_OPEN_DOOR_SOUND;
|
||||
$pk->x = $this->entity->x;
|
||||
$pk->y = $this->entity->y;
|
||||
$pk->z = $this->entity->z;
|
||||
$pk->data = 0;
|
||||
$this->dataPacket($pk);*/
|
||||
|
||||
$pk = new MessagePacket;
|
||||
$pk->source = ($author instanceof Player) ? $author->username : $author;
|
||||
$pk->message = TextFormat::clean($m); //Colors not implemented :(
|
||||
|
|
@ -2989,6 +2982,7 @@ class Player{
|
|||
switch($packet->pid()){
|
||||
case RakNetInfo::NACK:
|
||||
foreach($packet->packets as $count){
|
||||
|
||||
if(isset($this->recoveryQueue[$count])){
|
||||
$this->resendQueue[$count] =& $this->recoveryQueue[$count];
|
||||
$this->lag[] = $time - $this->recoveryQueue[$count]->sendtime;
|
||||
|
|
|
|||
|
|
@ -23,36 +23,37 @@ class FallingSand extends Entity{
|
|||
public function update($now){
|
||||
if($this->closed) return;
|
||||
|
||||
if( $this->data["Tile"] == AIR) $this->close();
|
||||
else {
|
||||
$this->lastX = $this->x;
|
||||
$this->lastY = $this->y;
|
||||
$this->lastZ = $this->z;
|
||||
++$this->fallTime;
|
||||
$this->speedY -= 0.04;
|
||||
$this->move($this->speedX, $this->speedY, $this->speedZ);
|
||||
|
||||
$this->speedX *= 0.98;
|
||||
$this->speedY *= 0.98;
|
||||
$this->speedZ *= 0.98;
|
||||
|
||||
$x = floor($this->x);
|
||||
$y = floor($this->y);
|
||||
$z = floor($this->z);
|
||||
|
||||
if($this->onGround){
|
||||
$this->speedX *= 0.7;
|
||||
$this->speedZ *= 0.7;
|
||||
$this->speedY *= -0.5;
|
||||
if( $this->data["Tile"] == AIR) {
|
||||
$this->close();
|
||||
return;
|
||||
}
|
||||
$this->lastX = $this->x;
|
||||
$this->lastY = $this->y;
|
||||
$this->lastZ = $this->z;
|
||||
++$this->fallTime;
|
||||
$this->speedY -= 0.04;
|
||||
$this->move($this->speedX, $this->speedY, $this->speedZ);
|
||||
|
||||
$this->speedX *= 0.98;
|
||||
$this->speedY *= 0.98;
|
||||
$this->speedZ *= 0.98;
|
||||
|
||||
$x = floor($this->x);
|
||||
$y = floor($this->y);
|
||||
$z = floor($this->z);
|
||||
|
||||
if($this->onGround){
|
||||
$this->speedX *= 0.7;
|
||||
$this->speedZ *= 0.7;
|
||||
$this->speedY *= -0.5;
|
||||
$this->close();
|
||||
//TODO vanilla-like checking?
|
||||
$this->level->fastSetBlockUpdate($x, $y, $z, $this->data["Tile"], 0, true); //TODO add metadata
|
||||
}elseif(($blockAt = $this->level->level->getBlockID($x, $y, $z)) != 0){
|
||||
//TODO vanilla-like checking?
|
||||
if(StaticBlock::getIsTransparent($blockAt) && !StaticBlock::getIsLiquid($blockAt)){
|
||||
$this->close();
|
||||
//TODO vanilla-like checking?
|
||||
$this->level->fastSetBlockUpdate($x, $y, $z, $this->data["Tile"], 0, true); //TODO add metadata
|
||||
}elseif(($blockAt = $this->level->level->getBlockID($x, $y, $z)) != 0){
|
||||
//TODO vanilla-like checking?
|
||||
if(StaticBlock::getIsTransparent($blockAt) && !StaticBlock::getIsLiquid($blockAt)){
|
||||
$this->close();
|
||||
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->data["Tile"], 0, 1)); //TODO add metadata
|
||||
}
|
||||
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->data["Tile"], 0, 1)); //TODO add metadata
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,32 @@ class GenericBlock extends Block{
|
|||
return $this->level->setBlock($this, new AirBlock(), true, false, true);
|
||||
}
|
||||
|
||||
public static function onPlace(Level $level, $x, $y, $z){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
if(StaticBlock::getHasPhysics($id)){
|
||||
ServerAPI::request()->api->block->scheduleBlockUpdateXYZ($level, $x, $y, $z, BLOCK_UPDATE_SCHEDULED, 2); //tick delay == 2
|
||||
}else{
|
||||
parent::onPlace($level, $x, $y, $z);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onUpdate(Level $level, $x, $y, $z, $type){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
$down = $level->level->getBlockID($x, $y - 1, $z);
|
||||
if($down == AIR || StaticBlock::getIsLiquid($down)){
|
||||
$data = array(
|
||||
"x" => $x + 0.5,
|
||||
"y" => $y - 0.5,
|
||||
"z" => $z + 0.5,
|
||||
"Tile" => $id,
|
||||
);
|
||||
$server = ServerAPI::request();
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
$e = $server->api->entity->add($level, ENTITY_FALLING, FALLING_SAND, $data);
|
||||
$server->api->entity->spawnToAll($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $type
|
||||
*
|
||||
|
|
@ -55,19 +81,7 @@ class GenericBlock extends Block{
|
|||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
[$id, $meta] = $level->level->getBlock($x, $y, $z);
|
||||
if(StaticBlock::getHasPhysics($id)){ //TODO move from here to different class
|
||||
$down = $level->level->getBlockID($x, $y - 1, $z);
|
||||
if($down == AIR || StaticBlock::getIsLiquid($down)){
|
||||
$data = array(
|
||||
"x" => $x + 0.5,
|
||||
"y" => $y - 0.5,
|
||||
"z" => $z + 0.5,
|
||||
"Tile" => $id,
|
||||
);
|
||||
$server = ServerAPI::request();
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
$e = $server->api->entity->add($level, ENTITY_FALLING, FALLING_SAND, $data);
|
||||
$server->api->entity->spawnToAll($e);
|
||||
}
|
||||
static::onUpdate($level, $x, $y, $z, BLOCK_UPDATE_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,19 @@ class FenceBlock extends TransparentBlock{
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function getAABB(Level $level, $x, $y, $z){
|
||||
$v9 = self::canConnectTo($level, $x, $y, $z - 1);
|
||||
$v10 = self::canConnectTo($level, $x, $y, $z + 1);
|
||||
$v11 = self::canConnectTo($level, $x - 1, $y, $z);
|
||||
$v12 = self::canConnectTo($level, $x + 1, $y, $z);
|
||||
$minX = $v11 ? 0 : 0.375;
|
||||
$minZ = $v9 ? 0 : 0.375;
|
||||
$maxZ = $v10 ? 1 : 0.625;
|
||||
$maxX = !$v12 ? 0.625 : 1;
|
||||
StaticBlock::setBlockBounds(static::$blockID, $minX, 0, $minZ, $maxX, 1.5, $maxZ);
|
||||
return parent::getAABB($level, $x, $y, $z);
|
||||
}
|
||||
|
||||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
$v8 = self::canConnectTo($level, $x, $y, $z - 1);
|
||||
$v9 = self::canConnectTo($level, $x, $y, $z + 1);
|
||||
|
|
|
|||
|
|
@ -353,13 +353,14 @@ class PMFLevel extends PMF{
|
|||
}
|
||||
|
||||
public function getBlockID($x, $y, $z){
|
||||
if($y > 127 || $y < 0){
|
||||
return 0;
|
||||
}
|
||||
|
||||
if($x < 0 || $x > 255 || $z < 0 || $z > 255){
|
||||
return INVISIBLE_BEDROCK;
|
||||
}
|
||||
|
||||
if($y > 127 || $y < 0){
|
||||
return 0;
|
||||
}
|
||||
$X = $x >> 4;
|
||||
$Z = $z >> 4;
|
||||
$Y = $y >> 4;
|
||||
|
|
@ -460,12 +461,12 @@ class PMFLevel extends PMF{
|
|||
}
|
||||
|
||||
public function getBlock($x, $y, $z){
|
||||
if($x < 0 || $x > 255 || $z < 0 || $z > 255){
|
||||
return [INVISIBLE_BEDROCK, 0];
|
||||
}
|
||||
if($y < 0 || $y > 127){
|
||||
return [AIR, 0];
|
||||
}
|
||||
if($x < 0 || $x > 255 || $z < 0 || $z > 255){
|
||||
return [INVISIBLE_BEDROCK, 0];
|
||||
}
|
||||
|
||||
$X = $x >> 4;
|
||||
$Z = $z >> 4;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue