mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
bed will now break from tnt explosion
This commit is contained in:
parent
fc0f3f6bde
commit
7bc97cca37
3 changed files with 41 additions and 14 deletions
|
|
@ -248,15 +248,15 @@ class EntityAPI{
|
|||
$e->setHealth($e->getHealth() - $attack, $cause, $force);
|
||||
}
|
||||
|
||||
public function dropRawPos(Position $pos, $item, $speedX, $speedY, $speedZ){
|
||||
public function dropRawPos(Level $level, $x, $y, $z, $item, $speedX, $speedY, $speedZ){
|
||||
if($item->getID() === AIR or $item->count <= 0){
|
||||
return;
|
||||
}
|
||||
$data = [
|
||||
"x" => $pos->x,
|
||||
"y" => $pos->y,
|
||||
"z" => $pos->z,
|
||||
"level" => $pos->level,
|
||||
"x" => $x,
|
||||
"y" => $y,
|
||||
"z" => $z,
|
||||
"level" => $level,
|
||||
"speedX" => $speedX,
|
||||
"speedY" => $speedY,
|
||||
"speedZ" => $speedZ,
|
||||
|
|
@ -268,7 +268,7 @@ class EntityAPI{
|
|||
for($count = $item->count; $count > 0;){
|
||||
$item->count = min($item->getMaxStackSize(), $count);
|
||||
$count -= $item->count;
|
||||
$e = $this->add($pos->level, ENTITY_ITEM, ENTITY_ITEM_TYPE, $data);
|
||||
$e = $this->add($level, ENTITY_ITEM, ENTITY_ITEM_TYPE, $data);
|
||||
$this->spawnToAll($e);
|
||||
$this->server->api->handle("entity.motion", $e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2184,7 +2184,7 @@ class Player{
|
|||
$sX += cos($f3) * $f1;
|
||||
$sY += ($this->entity->random->nextFloat() - $this->entity->random->nextFloat()) * 0.1;
|
||||
$sZ += sin($f3) * $f1;
|
||||
$this->server->api->entity->dropRawPos(new Position($this->entity->x, $this->entity->y - 0.3 + $this->entity->height - 0.12, $this->entity->z, $this->level), $packet->item, $sX, $sY, $sZ);
|
||||
$this->server->api->entity->dropRawPos($this->level, $this->entity->x, $this->entity->y - 0.3 + $this->entity->height - 0.12, $this->entity->z, $packet->item, $sX, $sY, $sZ);
|
||||
$this->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), false);
|
||||
}
|
||||
if($this->entity->inAction === true){
|
||||
|
|
|
|||
|
|
@ -24,7 +24,34 @@ class BedBlock extends TransparentBlock{
|
|||
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
|
||||
return [static::getAABB($level, $x, $y, $z)];
|
||||
}
|
||||
|
||||
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
|
||||
|
||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||
$dir = $meta & 3;
|
||||
$isHead = ($meta >> 3) & 1;
|
||||
|
||||
$offX = self::HEAD_DIRECTION_OFFSETS[$dir][0];
|
||||
$offZ = self::HEAD_DIRECTION_OFFSETS[$dir][1];
|
||||
|
||||
if($isHead){
|
||||
if($level->level->getBlockID($x - $offX, $y, $z - $offZ) != BED_BLOCK){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
}
|
||||
}else if($level->level->getBlockID($x + $offX, $y, $z + $offZ) != BED_BLOCK){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
|
||||
ServerAPI::request()->api->entity->dropRawPos(
|
||||
$level,
|
||||
$x + (lcg_value() * 0.7) + 0.15,
|
||||
$y + (lcg_value() * 0.7) + 0.15,
|
||||
$z + (lcg_value() * 0.7) + 0.15,
|
||||
BlockAPI::getItem(BED, 0, 1),
|
||||
lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public static function findStandUpPosition(Level $level, $x, $y, $z){
|
||||
$blockMeta = $level->level->getBlockDamage($x, $y, $z);
|
||||
$direction = $blockMeta & 0x3;
|
||||
|
|
@ -95,8 +122,8 @@ class BedBlock extends TransparentBlock{
|
|||
$downNext = $next->getSide(0);
|
||||
if($next->isReplaceable === true and $downNext->isTransparent === false){
|
||||
$meta = (($d + 3) % 4) & 0x03;
|
||||
$this->level->setBlock($block, BlockAPI::get($this->id, $meta), true, false, true);
|
||||
$this->level->setBlock($next, BlockAPI::get($this->id, $meta | 0x08), true, false, true);
|
||||
$this->level->fastSetBlockUpdate($block->x, $block->y, $block->z, $this->id, $meta, true);
|
||||
$this->level->fastSetBlockUpdate($next->x, $next->y, $next->z, $this->id, $meta | 0x08, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -127,16 +154,16 @@ class BedBlock extends TransparentBlock{
|
|||
}else{ //Bottom Part of Bed
|
||||
switch($this->meta & 0x7){
|
||||
case 0:
|
||||
if($blockSouth->id === $this->id) $this->level->setBlock($blockSouth, new AirBlock(), true, false, true);
|
||||
if($blockSouth->id === $this->id) $this->level->setBlock($blockSouth, new AirBlock(), false, false, true);
|
||||
break;
|
||||
case 1:
|
||||
if($blockWest->id === $this->id) $this->level->setBlock($blockWest, new AirBlock(), true, false, true);
|
||||
if($blockWest->id === $this->id) $this->level->setBlock($blockWest, new AirBlock(), false, false, true);
|
||||
break;
|
||||
case 2:
|
||||
if($blockNorth->id === $this->id) $this->level->setBlock($blockNorth, new AirBlock(), true, false, true);
|
||||
if($blockNorth->id === $this->id) $this->level->setBlock($blockNorth, new AirBlock(), false, false, true);
|
||||
break;
|
||||
case 3:
|
||||
if($blockEast->id === $this->id) $this->level->setBlock($blockEast, new AirBlock(), true, false, true);
|
||||
if($blockEast->id === $this->id) $this->level->setBlock($blockEast, new AirBlock(), false, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue