mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
php 8.1 fixs
This commit is contained in:
parent
10c126b4d5
commit
9abba9a2a2
13 changed files with 90 additions and 11 deletions
|
|
@ -1717,7 +1717,7 @@ class Player{
|
|||
switch($packet->action){
|
||||
case 5: //Shot arrow
|
||||
if($this->entity->inAction === true){
|
||||
if($this->getSlot($this->slot)->getID() === BOW){
|
||||
if($this->getSlot($this->slot)->getID() === BOW){ // and player had arrow){
|
||||
if($this->startAction !== false){
|
||||
$time = microtime(true) - $this->startAction;
|
||||
$d = [
|
||||
|
|
@ -1727,12 +1727,15 @@ class Player{
|
|||
"yaw" => $this->entity->yaw,
|
||||
"pitch" => $this->entity->pitch
|
||||
];
|
||||
$e = $this->server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_ARROW, $d);
|
||||
$e = $this->server->api->entity->add($this->level, ENTITY_OBJECT, OBJECT_SNOWBALL, $d);
|
||||
$e->speedX = -sin(($e->yaw / 180) * M_PI) * cos(($e->pitch / 180) * M_PI);
|
||||
$e->speedZ = cos(($e->yaw / 180) * M_PI) * cos(($e->pitch / 180) * M_PI);
|
||||
$e->speedY = -sin(($e->pitch / 180) * M_PI);
|
||||
$e->shoot($e->speedX, $e->speedY, $e->speedZ, 1.5, 1.0);
|
||||
$this->server->api->entity->spawnToAll($e);
|
||||
//$this->server->api->entity->spawnToAll($e);
|
||||
$e->spawn($this);
|
||||
$this->getSlot($this->slot)->useOn("shooting", true);
|
||||
$this->removeItem(ARROW, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Arrow extends Projectile{
|
|||
}
|
||||
|
||||
public function spawn($player){
|
||||
if($this->type === OBJECT_ARROW){
|
||||
//if($this->type === OBJECT_ARROW){
|
||||
$pk = new AddEntityPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->type = $this->type;
|
||||
|
|
@ -56,6 +56,6 @@ class Arrow extends Projectile{
|
|||
$pk = new SetEntityMotionPacket;
|
||||
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
|
||||
$player->dataPacket($pk);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
61
src/entity/object/projectile/Snowball.php
Normal file
61
src/entity/object/projectile/Snowball.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
class Snowball extends Projectile{
|
||||
const TYPE = OBJECT_SNOWBALL;
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
//$this->server->schedule(1210, array($this, "update")); //Despawn
|
||||
}
|
||||
|
||||
public function handleUpdate(){
|
||||
$pk = new MoveEntityPacket_PosRot;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->yaw = $this->yaw;
|
||||
$pk->pitch = $this->pitch;
|
||||
$this->server->api->player->broadcastPacket($this->level->players, $pk);
|
||||
}
|
||||
|
||||
public function shoot($d, $d1, $d2, $f, $f1){ //original name from 0.8.1 IDA decompilation, var names are taken from b1.7.3
|
||||
$f2 = sqrt($d * $d + $d1 * $d1 + $d2 * $d2);
|
||||
$d /= $f2;
|
||||
$d1 /= $f2;
|
||||
$d2 /= $f2;
|
||||
$d += $this->random->nextGaussian() * 0.0075 * $f1; //0.0074999998323619366 replaced with 0.0075
|
||||
$d1 += $this->random->nextGaussian() * 0.0075 * $f1;
|
||||
$d2 += $this->random->nextGaussian() * 0.0075 * $f1;
|
||||
$d *= $f;
|
||||
$d1 *= $f;
|
||||
$d2 *= $f;
|
||||
$this->speedX = $d;
|
||||
$this->speedY = $d1;
|
||||
$this->speedZ = $d2;
|
||||
$f3 = sqrt($d * $d + $d2 * $d2);
|
||||
$this->yaw = (atan2($d, $d2) * 180) / M_PI;
|
||||
$this->pitch = (atan2($d1, $f3) * 180) / M_PI;
|
||||
$this->update();
|
||||
//TODO i guess? $ticksInGround = 0;
|
||||
}
|
||||
|
||||
public function spawn($player){
|
||||
//if($this->type === OBJECT_ARROW){
|
||||
$pk = new AddEntityPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->type = $this->type;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->did = 1;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket;
|
||||
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
|
||||
$player->dataPacket($pk);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,6 +25,8 @@ class EntityRegistry{
|
|||
self::registerEntity(PrimedTNT::class);
|
||||
self::registerEntity(Painting::class);
|
||||
self::registerEntity(Minecart::class);
|
||||
self::registerEntity(Snowball::class);
|
||||
//self::registerEntity(Egg::class);
|
||||
}
|
||||
|
||||
/*Register an Entity*/
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ class Item{
|
|||
5 => 1561, //DIAMOND(called EMERALD in disassembled code)
|
||||
FLINT_STEEL => 65, //lets assume it is correct
|
||||
SHEARS => 239, //x2
|
||||
BOW => 385 //x3
|
||||
BOW => 2 //x3
|
||||
];
|
||||
|
||||
if(($type = $this->getLevel()) === false){
|
||||
|
|
|
|||
|
|
@ -21,18 +21,22 @@ class Matrix implements ArrayAccess{
|
|||
}
|
||||
}
|
||||
|
||||
public function offsetExists($offset){
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset){
|
||||
return isset($this->matrix[(int) $offset]);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset){
|
||||
return $this->matrix[(int) $offset];
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value){
|
||||
$this->matrix[(int) $offset] = $value;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset){
|
||||
unset($this->matrix[(int) $offset]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,12 @@ class Compound extends NamedTag implements \ArrayAccess{
|
|||
}
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset){
|
||||
return isset($this->{$offset});
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset){
|
||||
if($this->{$offset} instanceof Tag){
|
||||
if($this->{$offset} instanceof \ArrayAccess){
|
||||
|
|
@ -44,6 +46,7 @@ class Compound extends NamedTag implements \ArrayAccess{
|
|||
return null;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value){
|
||||
if($value instanceof Tag){
|
||||
$this->{$offset} = $value;
|
||||
|
|
@ -52,6 +55,7 @@ class Compound extends NamedTag implements \ArrayAccess{
|
|||
}
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset){
|
||||
unset($this->{$offset});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,10 +40,12 @@ class Enum extends NamedTag implements \ArrayAccess, \Countable{
|
|||
return $value;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset){
|
||||
return isset($this->{$offset});
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset){
|
||||
if($this->{$offset} instanceof Tag){
|
||||
if($this->{$offset} instanceof \ArrayAccess){
|
||||
|
|
@ -56,6 +58,7 @@ class Enum extends NamedTag implements \ArrayAccess, \Countable{
|
|||
return null;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value){
|
||||
if($value instanceof Tag){
|
||||
$this->{$offset} = $value;
|
||||
|
|
@ -64,10 +67,12 @@ class Enum extends NamedTag implements \ArrayAccess, \Countable{
|
|||
}
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset){
|
||||
unset($this->{$offset});
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count($mode = COUNT_NORMAL){
|
||||
for($i = 0; true; $i++){
|
||||
if(!isset($this->{$i})){
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ class RakNetCodec{
|
|||
|
||||
public function __construct(RakNetPacket $packet){
|
||||
$this->packet = $packet;
|
||||
$this->buffer =& $this->packet->buffer;
|
||||
$this->buffer = &$this->packet->buffer;
|
||||
$this->encode();
|
||||
}
|
||||
|
||||
private function encode(){
|
||||
if(strlen($this->packet->buffer) > 0){
|
||||
if($this->packet->buffer != null && strlen($this->packet->buffer) > 0){
|
||||
return;
|
||||
}
|
||||
$this->buffer .= chr($this->packet->pid());
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ abstract class RakNetDataPacket extends stdClass{
|
|||
}
|
||||
|
||||
protected function putByte($v){
|
||||
$this->buffer .= chr($v);
|
||||
$this->buffer .= chr((int)$v);
|
||||
}
|
||||
|
||||
protected function getString(){
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class BiomeSelector
|
|||
}
|
||||
|
||||
public static function registerBiome(Biome $b){
|
||||
ConsoleAPI::debug("Registered $b");
|
||||
//ConsoleAPI::debug("Registered $b");
|
||||
self::$biomes[$b->getID()] = $b;
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue