mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
changed item type from item id to 64
This commit is contained in:
parent
eab6573b84
commit
5208611d38
8 changed files with 24 additions and 19 deletions
|
|
@ -158,7 +158,7 @@ class EntityAPI{
|
|||
$efl = EntityRegistry::$entityList->getEntityFromTypeAndClass($type, $class);
|
||||
if($efl instanceof PropertyEntity){
|
||||
$class = $efl->getEntityName();
|
||||
$this->entities[$eid] = new $class($level, $eid, $efl->getEntityClass(), $efl->getEntityClass() === ENTITY_ITEM ? $type : $efl->getEntityType(), $data);
|
||||
$this->entities[$eid] = new $class($level, $eid, $efl->getEntityClass(), $efl->getEntityType(), $data);
|
||||
}else{
|
||||
$this->entities[$eid] = new Entity($level, $eid, $class, $type, $data);
|
||||
}
|
||||
|
|
@ -261,12 +261,14 @@ class EntityAPI{
|
|||
"speedY" => $speedY,
|
||||
"speedZ" => $speedZ,
|
||||
"item" => $item,
|
||||
"itemID" => $item->getID()
|
||||
];
|
||||
|
||||
if($this->server->api->handle("item.drop", $data) !== false){
|
||||
for($count = $item->count; $count > 0;){
|
||||
$item->count = min($item->getMaxStackSize(), $count);
|
||||
$count -= $item->count;
|
||||
$e = $this->add($pos->level, ENTITY_ITEM, $item->getID(), $data);
|
||||
$e = $this->add($pos->level, ENTITY_ITEM, ENTITY_ITEM_TYPE, $data);
|
||||
$this->spawnToAll($e);
|
||||
$this->server->api->handle("entity.motion", $e);
|
||||
}
|
||||
|
|
@ -286,12 +288,13 @@ class EntityAPI{
|
|||
"speedY" => 0.2,
|
||||
"speedZ" => lcg_value() * 0.2 - 0.1,
|
||||
"item" => $item,
|
||||
"itemID" => $item->getID()
|
||||
];
|
||||
if($this->server->api->handle("item.drop", $data) !== false){
|
||||
for($count = $item->count; $count > 0;){
|
||||
$item->count = min($item->getMaxStackSize(), $count);
|
||||
$count -= $item->count;
|
||||
$e = $this->add($pos->level, ENTITY_ITEM, $item->getID(), $data);
|
||||
$e = $this->add($pos->level, ENTITY_ITEM, ENTITY_ITEM_TYPE, $data);
|
||||
$this->spawnToAll($e);
|
||||
$this->server->api->handle("entity.motion", $e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,9 +65,10 @@ class LevelAPI{
|
|||
$entity["pitch"] = $entity["Rotation"][1];
|
||||
|
||||
if($entity["id"] === 64){ //Item Drop
|
||||
$e = $this->server->api->entity->add($this->levels[$name], ENTITY_ITEM, $entity["Item"]["id"], [
|
||||
$e = $this->server->api->entity->add($this->levels[$name], ENTITY_ITEM, ENTITY_ITEM_TYPE, [
|
||||
"meta" => $entity["Item"]["Damage"],
|
||||
"stack" => $entity["Item"]["Count"],
|
||||
"itemID" => $entity["Item"]["id"],
|
||||
"x" => $entity["Pos"][0],
|
||||
"y" => $entity["Pos"][1],
|
||||
"z" => $entity["Pos"][2],
|
||||
|
|
|
|||
|
|
@ -760,9 +760,9 @@ class Player{
|
|||
$pk->target = $data["entity"]->eid;
|
||||
$this->dataPacket($pk);
|
||||
if(($this->gamemode & 0x01) === 0x00){
|
||||
$this->addItem($data["entity"]->type, $data["entity"]->meta, $data["entity"]->stack, false);
|
||||
$this->addItem($data["entity"]->itemID, $data["entity"]->meta, $data["entity"]->stack, false);
|
||||
}
|
||||
switch($data["entity"]->type){
|
||||
switch($data["entity"]->itemID){
|
||||
case WOOD:
|
||||
AchievementAPI::grantAchievement($this, "mineWood");
|
||||
break;
|
||||
|
|
@ -2074,7 +2074,6 @@ 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->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ define("ENTITY_OBJECT", 3);
|
|||
define("OBJECT_MINECART", 84);
|
||||
|
||||
define("ENTITY_ITEM", 4);
|
||||
|
||||
define("ENTITY_ITEM_TYPE", 64);
|
||||
|
||||
define("ENTITY_FALLING", 5);
|
||||
define("FALLING_SAND", 66);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class TaskFollowParent extends TaskBase
|
|||
}
|
||||
$parent = $ai->entity->parent;
|
||||
|
||||
$ai->mobController->setLookPosition($parent->x, $parent->y + $parent->getEyeHeight(), $parent->z, 30, $ai->entity->getVerticalFaceSpeed());
|
||||
$ai->mobController->setLookPosition($parent->x, $parent->y + $parent->getEyeHeight(), $parent->z, 10, $ai->entity->getVerticalFaceSpeed());
|
||||
$ai->mobController->setMovingTarget($parent->x, $parent->y, $parent->z, $this->speedMultiplier);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
class ItemEntity extends Entity{
|
||||
const TYPE = "itemSpecial";
|
||||
const TYPE = ENTITY_ITEM_TYPE;
|
||||
const CLASS_TYPE = ENTITY_ITEM;
|
||||
public static $searchRadiusX = 0.5, $searchRadiusY = 0.0, $searchRadiusZ = 0.5;
|
||||
|
||||
public $meta, $stack;
|
||||
public $meta, $stack, $itemID;
|
||||
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = array())
|
||||
{
|
||||
|
|
@ -13,11 +13,13 @@ class ItemEntity extends Entity{
|
|||
$this->setSize(0.25, 0.25);
|
||||
$this->yOffset = $this->height / 2;
|
||||
if(isset($data["item"]) and ($data["item"] instanceof Item)){
|
||||
$this->meta = $this->data["item"]->getMetadata();
|
||||
$this->stack = $this->data["item"]->count;
|
||||
$this->meta = $data["item"]->getMetadata();
|
||||
$this->stack = $data["item"]->count;
|
||||
$this->itemID = $data["item"]->getID();
|
||||
} else{
|
||||
$this->meta = (int) $this->data["meta"];
|
||||
$this->stack = (int) $this->data["stack"];
|
||||
$this->meta = (int) $data["meta"];
|
||||
$this->stack = (int) $data["stack"];
|
||||
$this->itemID = (int) $data["itemID"];
|
||||
}
|
||||
$this->hasGravity = true;
|
||||
$this->setHealth(5, "generic");
|
||||
|
|
@ -50,7 +52,7 @@ class ItemEntity extends Entity{
|
|||
$pk->yaw = $this->yaw;
|
||||
$pk->pitch = $this->pitch;
|
||||
$pk->roll = 0;
|
||||
$pk->item = BlockAPI::getItem($this->type, $this->meta, $this->stack);
|
||||
$pk->item = BlockAPI::getItem($this->itemID, $this->meta, $this->stack);
|
||||
$pk->metadata = $this->getMetadata();
|
||||
$player->dataPacket($pk);
|
||||
|
||||
|
|
@ -68,7 +70,7 @@ class ItemEntity extends Entity{
|
|||
if($another->eid == $this->eid) return false;
|
||||
|
||||
if(!$another->closed && !$this->closed){
|
||||
if($another->type == $this->type && $another->meta == $this->meta){
|
||||
if($another->itemID == $this->itemID && $another->meta == $this->meta){
|
||||
if(($another->stack + $this->stack) > 64) return false; //TODO dynamic stack size
|
||||
|
||||
$another->stack += $this->stack;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ class EntityList{
|
|||
$this->entities[$property->getEntityType()] = $property;
|
||||
}
|
||||
public function getEntityFromTypeAndClass($type, $class){
|
||||
if($class === ENTITY_ITEM) return $this->entities["itemSpecial"];
|
||||
return isset($this->entities[$type]) && $this->entities[$type]->getEntityClass() === $class ? $this->entities[$type] : 0;
|
||||
}
|
||||
private $entities = [];
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ class Level{
|
|||
|
||||
$this->checkSleep();
|
||||
|
||||
if($server->ticks % 10 === 0){ //10 ticks delay
|
||||
if($server->ticks % 10 === 0){
|
||||
$this->mobSpawner->handle();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue