mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
Weird Painting spawn (WiP)
This commit is contained in:
parent
0be3379720
commit
1c05455514
8 changed files with 103 additions and 10 deletions
|
|
@ -36,6 +36,7 @@ class Item{
|
|||
WOODEN_DOOR => "WoodenDoorItem",
|
||||
IRON_DOOR => "IronDoorItem",
|
||||
BED => "BedItem",
|
||||
PAINTING => "PaintingItem",
|
||||
);
|
||||
protected $block;
|
||||
protected $id;
|
||||
|
|
@ -44,6 +45,7 @@ class Item{
|
|||
protected $maxStackSize = 64;
|
||||
protected $durability = 0;
|
||||
protected $name;
|
||||
public $isActivable = false;
|
||||
|
||||
public function __construct($id, $meta = 0, $count = 1, $name = "Unknown"){
|
||||
$this->id = (int) $id;
|
||||
|
|
@ -118,4 +120,8 @@ class Item{
|
|||
return 1;
|
||||
}
|
||||
|
||||
public function onActivate(BlockAPI $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
50
src/classes/material/item/generic/Painting.php
Normal file
50
src/classes/material/item/generic/Painting.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|
||||
-
|
||||
/ \
|
||||
/ \
|
||||
/ PocketMine \
|
||||
/ MP \
|
||||
|\ @shoghicp /|
|
||||
|. \ / .|
|
||||
| .. \ / .. |
|
||||
| .. | .. |
|
||||
| .. | .. |
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
\ | /
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class PaintingItem extends Item{
|
||||
public function __construct($meta = 0, $count = 1){
|
||||
parent::__construct(PAINTING, 0, $count, "Painting");
|
||||
$this->isActivable = true;
|
||||
}
|
||||
|
||||
public function onActivate(BlockAPI $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($target->isTransparent === false and $face > 1){
|
||||
$data = array(
|
||||
"x" => $target->x,
|
||||
"y" => $target->y,
|
||||
"z" => $target->z,
|
||||
"yaw" => ($face % 4) * 90,
|
||||
);
|
||||
$server = ServerAPI::request();
|
||||
$e = $server->api->entity->add(ENTITY_OBJECT, OBJECT_PAINTING, $data);
|
||||
$server->api->entity->spawnToAll($e->eid);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -226,7 +226,7 @@ class CustomPacketHandler{
|
|||
$this->raw .= Utils::writeMetadata($this->data["metadata"]);
|
||||
}
|
||||
break;
|
||||
case MC_ADD_ENTITY:
|
||||
case MC_ADD_ENTITY: //Not used?
|
||||
if($this->c === false){
|
||||
$this->data["eid"] = Utils::readInt($this->get(4));
|
||||
$this->data["type"] = ord($this->get(1));
|
||||
|
|
@ -240,9 +240,6 @@ class CustomPacketHandler{
|
|||
$this->raw .= Utils::writeFloat($this->data["y"]);
|
||||
$this->raw .= Utils::writeFloat($this->data["z"]);
|
||||
$this->raw .= Utils::hexToStr("000000020000ffd30000");//Utils::writeInt(0);
|
||||
/*$this->raw .= Utils::writeShort(0);
|
||||
$this->raw .= Utils::writeShort(0);
|
||||
$this->raw .= Utils::writeShort(0);*/
|
||||
}
|
||||
break;
|
||||
case MC_REMOVE_ENTITY:
|
||||
|
|
@ -380,6 +377,23 @@ class CustomPacketHandler{
|
|||
$this->raw .= chr($this->data["meta"]);
|
||||
}
|
||||
break;
|
||||
case MC_ADD_PAINTING:
|
||||
if($this->c === false){
|
||||
$this->data["eid"] = Utils::readInt($this->get(4));
|
||||
$this->data["x"] = Utils::readInt($this->get(4));
|
||||
$this->data["y"] = Utils::readInt($this->get(4));
|
||||
$this->data["z"] = Utils::readInt($this->get(4));
|
||||
$this->data["direction"] = Utils::readInt($this->get(4));
|
||||
$this->data["title"] = $this->get(Utils::readShort($this->get(2), false));
|
||||
}else{
|
||||
$this->raw .= Utils::writeInt($this->data["eid"]);
|
||||
$this->raw .= Utils::writeInt($this->data["x"]);
|
||||
$this->raw .= Utils::writeInt($this->data["y"]);
|
||||
$this->raw .= Utils::writeInt($this->data["z"]);
|
||||
$this->raw .= Utils::writeInt($this->data["direction"]);
|
||||
$this->raw .= Utils::writeShort(strlen($this->data["title"])).$this->data["title"];
|
||||
}
|
||||
break;
|
||||
case MC_EXPLOSION:
|
||||
if($this->c === false){
|
||||
$this->data["x"] = Utils::readFloat($this->get(4));
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ class Entity extends stdClass{
|
|||
//$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type));
|
||||
break;
|
||||
case ENTITY_OBJECT:
|
||||
$this->setHealth(1, "generic");
|
||||
//$this->setName((isset($objects[$this->type]) ? $objects[$this->type]:$this->type));
|
||||
break;
|
||||
case ENTITY_PAINTING:
|
||||
|
|
@ -392,7 +393,16 @@ class Entity extends stdClass{
|
|||
));
|
||||
break;
|
||||
case ENTITY_OBJECT:
|
||||
//$this->setName((isset($objects[$this->type]) ? $objects[$this->type]:$this->type));
|
||||
if($this->type === OBJECT_PAINTING){
|
||||
$player->dataPacket(MC_ADD_PAINTING, array(
|
||||
"eid" => $this->eid,
|
||||
"x" => (int) $this->x,
|
||||
"y" => (int) $this->y,
|
||||
"z" => (int) $this->z,
|
||||
"direction" => $this->getDirection(),
|
||||
"title" => "Creepers",
|
||||
));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -540,10 +550,12 @@ class Entity extends stdClass{
|
|||
$this->crouched = false;
|
||||
$this->updateMetadata();
|
||||
$this->dead = true;
|
||||
$this->server->api->dhandle("entity.event", array("entity" => $this, "event" => 3)); //Entity dead
|
||||
if($this->player instanceof Player){
|
||||
$this->server->api->dhandle("player.death", array("name" => $this->name, "cause" => $cause));
|
||||
}else{
|
||||
$this->close();
|
||||
}
|
||||
$this->server->api->dhandle("entity.event", array("entity" => $this, "event" => 3)); //Entity dead
|
||||
}elseif($this->health > 0){
|
||||
$this->dead = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue