mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Fixed Sugar Creative Item cant use in MCPE 0.5
This commit is contained in:
parent
7c60ca753a
commit
e7e7c81e07
3 changed files with 270 additions and 1 deletions
|
|
@ -196,6 +196,190 @@ class BlockAPI{
|
|||
[DYE, 9],
|
||||
[DYE, 8]
|
||||
|
||||
];
|
||||
public static $creative_old = [
|
||||
//Building
|
||||
[STONE, 0],
|
||||
[COBBLESTONE, 0],
|
||||
[STONE_BRICKS, 0],
|
||||
[STONE_BRICKS, 1],
|
||||
[STONE_BRICKS, 2],
|
||||
[MOSS_STONE, 0],
|
||||
[WOODEN_PLANKS, 0],
|
||||
[BRICKS, 0],
|
||||
|
||||
[DIRT, 0],
|
||||
[GRASS, 0],
|
||||
[CLAY_BLOCK, 0],
|
||||
[SANDSTONE, 0],
|
||||
[SANDSTONE, 1],
|
||||
[SANDSTONE, 2],
|
||||
[SAND, 0],
|
||||
[GRAVEL, 0],
|
||||
[TRUNK, 0],
|
||||
[TRUNK, 1],
|
||||
[TRUNK, 2],
|
||||
[NETHER_BRICKS, 0],
|
||||
[NETHERRACK, 0],
|
||||
[COBBLESTONE_STAIRS, 0],
|
||||
[OAK_WOOD_STAIRS, 0],
|
||||
[BRICK_STAIRS, 0],
|
||||
[SANDSTONE_STAIRS, 0],
|
||||
[STONE_BRICK_STAIRS, 0],
|
||||
[NETHER_BRICKS_STAIRS, 0],
|
||||
[QUARTZ_STAIRS, 0],
|
||||
[SLAB, 0],
|
||||
[SLAB, 1],
|
||||
[SLAB, 2],
|
||||
[SLAB, 3],
|
||||
[SLAB, 4],
|
||||
[SLAB, 5],
|
||||
[SLAB, 6],
|
||||
[QUARTZ_BLOCK, 0],
|
||||
[QUARTZ_BLOCK, 1],
|
||||
[QUARTZ_BLOCK, 2],
|
||||
[COAL_ORE, 0],
|
||||
[IRON_ORE, 0],
|
||||
[GOLD_ORE, 0],
|
||||
[DIAMOND_ORE, 0],
|
||||
[LAPIS_ORE, 0],
|
||||
[REDSTONE_ORE, 0],
|
||||
[GOLD_BLOCK, 0],
|
||||
[IRON_BLOCK, 0],
|
||||
[DIAMOND_BLOCK, 0],
|
||||
[LAPIS_BLOCK, 0],
|
||||
[OBSIDIAN, 0],
|
||||
[ICE, 0],
|
||||
[SNOW_BLOCK, 0],
|
||||
|
||||
//Decoration
|
||||
[GLASS, 0],
|
||||
[GLOWSTONE_BLOCK, 0],
|
||||
[NETHER_REACTOR, 0],
|
||||
[WOOL, 0],
|
||||
[WOOL, 7],
|
||||
[WOOL, 6],
|
||||
[WOOL, 5],
|
||||
[WOOL, 4],
|
||||
[WOOL, 3],
|
||||
[WOOL, 2],
|
||||
[WOOL, 1],
|
||||
[WOOL, 15],
|
||||
[WOOL, 14],
|
||||
[WOOL, 13],
|
||||
[WOOL, 12],
|
||||
[WOOL, 11],
|
||||
[WOOL, 10],
|
||||
[WOOL, 9],
|
||||
[WOOL, 8],
|
||||
[LADDER, 0],
|
||||
[TORCH, 0],
|
||||
[GLASS_PANE, 0],
|
||||
[WOODEN_DOOR, 0],
|
||||
[TRAPDOOR, 0],
|
||||
[FENCE, 0],
|
||||
[FENCE_GATE, 0],
|
||||
[BED, 0],
|
||||
[BOOKSHELF, 0],
|
||||
[PAINTING, 0],
|
||||
[WORKBENCH, 0],
|
||||
[STONECUTTER, 0],
|
||||
[CHEST, 0],
|
||||
[FURNACE, 0],
|
||||
[TNT, 0],
|
||||
[DANDELION, 0],
|
||||
[CYAN_FLOWER, 0],
|
||||
[BROWN_MUSHROOM, 0],
|
||||
[RED_MUSHROOM, 0],
|
||||
[CACTUS, 0],
|
||||
[MELON_BLOCK, 0],
|
||||
[SUGARCANE, 0],
|
||||
[SUGARCANE_BLOCK, 0],
|
||||
[SAPLING, 0],
|
||||
[SAPLING, 1],
|
||||
[SAPLING, 2],
|
||||
[LEAVES, 0],
|
||||
[LEAVES, 1],
|
||||
[LEAVES, 2],
|
||||
//Seeds
|
||||
[SEEDS, 0],
|
||||
[MELON_SEEDS, 0],
|
||||
[DYE, 15],
|
||||
//Tools
|
||||
[IRON_HOE, 0],
|
||||
[IRON_SWORD, 0],
|
||||
[BOW, 0],
|
||||
[SIGN, 0],
|
||||
|
||||
];
|
||||
public static $creative_legacy = [
|
||||
//Building
|
||||
[STONE_SHOVEL, 0],
|
||||
[STONE_PICKAXE, 0],
|
||||
[STONE_AXE, 0],
|
||||
[SHEARS, 0],
|
||||
[STONE_SWORD, 0],
|
||||
[LADDER, 0],
|
||||
[TORCH, 0],
|
||||
[WOODEN_DOOR, 0],
|
||||
[FENCE, 0],
|
||||
[FENCE_GATE, 0],
|
||||
[COBBLESTONE, 0],
|
||||
[WOOD, 2],
|
||||
[WOOD, 1],
|
||||
[WOODEN_PLANKS, 0],
|
||||
[BRICKS, 0],
|
||||
[DIRT, 0],
|
||||
[SANDSTONE, 0],
|
||||
[GRAVEL, 0],
|
||||
[COBBLESTONE_STAIRS, 0],
|
||||
[WOODEN_STAIRS, 0],
|
||||
[BRICK_STAIRS, 0],
|
||||
[SLAB, 0],
|
||||
[SLAB, 3],
|
||||
[SLAB, 2],
|
||||
[SLAB, 4],
|
||||
[SAND, 0],
|
||||
[WOOL, 7],
|
||||
[WOOL, 6],
|
||||
[WOOL, 5],
|
||||
[WOOL, 4],
|
||||
[WOOL, 3],
|
||||
[WOOL, 2],
|
||||
[WOOL, 1],
|
||||
[WOOL, 15],
|
||||
[WOOL, 14],
|
||||
[WOOL, 13],
|
||||
[WOOL, 12],
|
||||
[WOOL, 11],
|
||||
[WOOL, 10],
|
||||
[WOOL, 9],
|
||||
[WOOL, 8],
|
||||
[GLASS, 0],
|
||||
[GLASS_PANE, 0],
|
||||
[LEAVES, 0],
|
||||
[LEAVES, 1],
|
||||
[LEAVES, 2],
|
||||
[GOLD_BLOCK, 0],
|
||||
[IRON_BLOCK, 0],
|
||||
[DIAMOND_BLOCK, 0],
|
||||
[LAPIS_BLOCK, 0],
|
||||
[OBSIDIAN, 0],
|
||||
[BOOKSHELF, 0],
|
||||
[WORKBENCH, 0],
|
||||
[FURNACE, 0],
|
||||
[DANDELION, 0],
|
||||
[ROSE, 0],
|
||||
[BROWN_MUSHROOM, 0],
|
||||
[RED_MUSHROOM, 0],
|
||||
[CACTUS, 0],
|
||||
[SUGARCANE_BLOCK, 0],
|
||||
[COAL_ORE, 0],
|
||||
[IRON_ORE, 0],
|
||||
[GOLD_ORE, 0],
|
||||
[DIAMOND_ORE, 0],
|
||||
[LAPIS_ORE, 0],
|
||||
|
||||
];
|
||||
private $server;
|
||||
private $scheduledUpdates = [];
|
||||
|
|
@ -674,7 +858,7 @@ class BlockAPI{
|
|||
}
|
||||
}
|
||||
|
||||
public static function convertHighItemIdsToOldItemIds(int $protocolId, int $itemId, int $metaData = 0) : int{
|
||||
public static function convertHighItemIdsToOldItemIds(int $protocolId, int $itemId, int $metaData = 0) : int{ //TODO Id metadata
|
||||
if ($protocolId >= ProtocolInfo12::CURRENT_PROTOCOL_12) {
|
||||
return $itemId;
|
||||
}
|
||||
|
|
@ -691,6 +875,10 @@ class BlockAPI{
|
|||
|
||||
if ($protocolId <= ProtocolInfo9::CURRENT_PROTOCOL_9) {
|
||||
$idMap += [
|
||||
WOOD_SLAB => SLAB,
|
||||
BIRCH_WOODEN_STAIRS => WOODEN_STAIRS,
|
||||
JUNGLE_WOODEN_STAIRS => WOODEN_STAIRS,
|
||||
SPRUCE_WOODEN_STAIRS => WOODEN_STAIRS,
|
||||
SPAWN_EGG => AIR,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1554,9 +1554,19 @@ class Player{
|
|||
}
|
||||
}elseif(($gm & 0x01) === 0x01){
|
||||
$inv = [];
|
||||
if($this->PROTOCOL >= ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||
foreach(BlockAPI::$creative as $item){
|
||||
$inv[] = BlockAPI::getItem($item[0], $item[1], 1);
|
||||
}
|
||||
}elseif($this->PROTOCOL > ProtocolInfo6::CURRENT_PROTOCOL_6){
|
||||
foreach(BlockAPI::$creative_old as $item){
|
||||
$inv[] = [$item[0], $item[1], 1];
|
||||
}
|
||||
}else{
|
||||
foreach(BlockAPI::$creative_legacy as $item){
|
||||
$inv[] = [$item[0], $item[1], 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->gamemode = $gm;
|
||||
$this->saveInventory = ($this->gamemode & 1) == SURVIVAL;
|
||||
|
|
@ -2315,9 +2325,19 @@ class Player{
|
|||
$inv[] = [0, 0, 1];
|
||||
}
|
||||
}else{
|
||||
if($this->PROTOCOL >= ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||
foreach(BlockAPI::$creative as $item){
|
||||
$inv[] = [$item[0], $item[1], 1];
|
||||
}
|
||||
}elseif($this->PROTOCOL > ProtocolInfo6::CURRENT_PROTOCOL_6){
|
||||
foreach(BlockAPI::$creative_old as $item){
|
||||
$inv[] = [$item[0], $item[1], 1];
|
||||
}
|
||||
}else{
|
||||
foreach(BlockAPI::$creative_legacy as $item){
|
||||
$inv[] = [$item[0], $item[1], 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
|
@ -2551,9 +2571,23 @@ class Player{
|
|||
$inv[] = [0, 0, 1];
|
||||
}
|
||||
}else{
|
||||
if($this->PROTOCOL >= ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||
foreach(BlockAPI::$creative as $item){
|
||||
$inv[] = [$item[0], $item[1], 1];
|
||||
}
|
||||
}elseif($this->PROTOCOL > ProtocolInfo6::CURRENT_PROTOCOL_6){
|
||||
foreach(BlockAPI::$creative_old as $i => $d){
|
||||
if($d[0] === $packet->item and $d[1] === $packet->meta){
|
||||
$packet->slot = $i;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach(BlockAPI::$creative_legacy as $i => $d){
|
||||
if($d[0] === $packet->item and $d[1] === $packet->meta){
|
||||
$packet->slot = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
|
@ -2686,6 +2720,35 @@ class Player{
|
|||
break;
|
||||
}
|
||||
|
||||
if($this->PROTOCOL <= ProtocolInfo8::CURRENT_PROTOCOL_8 && ($this->gamemode & 1) == SURVIVAL){
|
||||
foreach($this->inventory as $slot => $item) {
|
||||
if ($item->getID() === AIR or $item->count <= 0) {
|
||||
continue;
|
||||
}
|
||||
$data = [
|
||||
"x" => $this->entity->x,
|
||||
"y" => $this->entity->y - 0.3 + $this->entity->height - 0.12,
|
||||
"z" => $this->entity->z,
|
||||
"level" => $this->level,
|
||||
"speedX" => 0,
|
||||
"speedY" => 0,
|
||||
"speedZ" => 0,
|
||||
"item" => $item,
|
||||
"itemID" => $item->getID()
|
||||
];
|
||||
for ($count = $item->count; $count > 0;) {
|
||||
$item->count = min($item->getMaxStackSize(), $count);
|
||||
$count -= $item->count;
|
||||
$e = $this->server->api->entity->add($this->level, ENTITY_ITEM, ENTITY_ITEM_TYPE, $data);
|
||||
$e->spawn($this);
|
||||
$pk = new TakeItemEntityPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->target = $e->eid;
|
||||
$this->entityQueueDataPacket($pk);
|
||||
$e->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
$pk = new SetTimePacket;
|
||||
$pk->time = $this->level->getTime();
|
||||
$pk->started = !$this->level->isTimeStopped();
|
||||
|
|
@ -2803,11 +2866,25 @@ class Player{
|
|||
}
|
||||
}elseif(($this->gamemode & 0x01) === CREATIVE){
|
||||
$packet->slot = false;
|
||||
if($this->PROTOCOL >= ProtocolInfo12::CURRENT_PROTOCOL_12){
|
||||
foreach(BlockAPI::$creative as $i => $d){
|
||||
if($d[0] === $packet->item and $d[1] === $packet->meta){
|
||||
$packet->slot = $i;
|
||||
}
|
||||
}
|
||||
}elseif($this->PROTOCOL > ProtocolInfo6::CURRENT_PROTOCOL_6){
|
||||
foreach(BlockAPI::$creative_old as $i => $d){
|
||||
if($d[0] === $packet->item and $d[1] === $packet->meta){
|
||||
$packet->slot = $i;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
foreach(BlockAPI::$creative_legacy as $i => $d){
|
||||
if($d[0] === $packet->item and $d[1] === $packet->meta){
|
||||
$packet->slot = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($packet->slot !== false){
|
||||
$data["item"] = $this->getSlot($packet->slot);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -1717,6 +1717,10 @@ class Entity extends Position
|
|||
$this->dead = true;
|
||||
if($this->player instanceof Player){
|
||||
if($this->player->PROTOCOL <= ProtocolInfo9::CURRENT_PROTOCOL_9){
|
||||
$pk = new EntityEventPacket;
|
||||
$pk->eid = $this->eid;
|
||||
$pk->event = EntityEventPacket::ENTITY_DEAD;
|
||||
$this->player->entityQueueDataPacket($pk);
|
||||
$this->player->isWorkbench = false;
|
||||
$this->player->isStoneCutter = false;
|
||||
if($this->player->PROTOCOL < ProtocolInfo6::CURRENT_PROTOCOL_6){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue