diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php old mode 100644 new mode 100755 index 60b2e6e6..503aa5d4 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -297,6 +297,8 @@ class BlockAPI{ if(!isset($params[2])){ $item->count = $item->getMaxStackSize(); + }elseif((!isset($params[2])) and ($item->getMaxStackSize() == 0)){ + $item->count = 64; }else{ $item->count = (int) $params[2]; } diff --git a/src/Player.php b/src/Player.php old mode 100644 new mode 100755 index 99624db3..3fe866fa --- a/src/Player.php +++ b/src/Player.php @@ -938,13 +938,6 @@ class Player{ } } } - - if($pos->level->getName() !== $this->level->getName()) { // we're switching levels. - $freq = $this->server->extraprops->get("update-frequency"); - if($this->server->extraprops->get("update-client-on-world-switch")) { - $rf = new ClientRenderFix($this, $freq); - } - } $this->level->freeAllChunks($this); $this->level = $pos->level; diff --git a/src/config.php b/src/config.php old mode 100644 new mode 100755 index 331cab11..197ac88d --- a/src/config.php +++ b/src/config.php @@ -21,36 +21,24 @@ set_time_limit(0); -if(ini_get("date.timezone") == ""){ //No Timezone set - date_default_timezone_set("GMT"); - if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){ - $time = time(); - $time -= $time % 60; - //TODO: Parse different time & date formats by region. ¬¬ world - //Example: USA - exec("time.exe /T", $hour); - $i = array_map("intval", explode(":", trim($hour[0]))); - exec("date.exe /T", $date); - $j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0]))); - $offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60; - }else{ - exec("date +%s", $t); - $offset = round((intval(trim($t[0])) - time()) / 60) * 60; - } - - $daylight = (int) date("I"); - $d = timezone_name_from_abbr("", $offset, $daylight); - @ini_set("date.timezone", $d); - date_default_timezone_set($d); +date_default_timezone_set("GMT"); +if(strpos(" ".strtoupper(php_uname("s")), " WIN") !== false){ + $time = time(); + $time -= $time % 60; + exec("time.exe /T", $hour); + $i = array_map("intval", explode(":", trim($hour[0]))); + exec("date.exe /T", $date); + $j = array_map("intval", explode(substr($date[0], 2, 1), trim($date[0]))); + $offset = round((mktime($i[0], $i[1], 0, $j[1], $j[0], $j[2]) - $time) / 60) * 60; }else{ - $d = @date_default_timezone_get(); - if(strpos($d, "/") === false){ - $d = timezone_name_from_abbr($d); - @ini_set("date.timezone", $d); - date_default_timezone_set($d); - } + exec("date +%s", $t); + $offset = round((intval(trim($t[0])) - time()) / 60) * 60; } +$daylight = (int) date("I"); + +date_default_timezone_set(timezone_name_from_abbr("", $offset, $daylight)); + gc_enable(); error_reporting(E_ALL | E_STRICT); ini_set("allow_url_fopen", 1); @@ -68,7 +56,7 @@ ini_set("memory_limit", "128M"); //Default define("LOG", true); define("START_TIME", microtime(true)); define("MAJOR_VERSION", "1.0 (Alpha_1.3.12)"); -define("CODENAME", "懐かしさ (Nostalgia)"); //i'm not very creative - kotyaralih +define("CODENAME", "懐かしさ (Nostalgia)"); define("CURRENT_MINECRAFT_VERSION", "v0.8.1 alpha"); define("CURRENT_API_VERSION", 12); define("CURRENT_PHP_VERSION", "5.5"); @@ -77,4 +65,4 @@ if(file_exists(FILE_PATH.".git/refs/heads/master")){ //Found Git information! define("GIT_COMMIT", strtolower(trim(file_get_contents(FILE_PATH.".git/refs/heads/master")))); }else{ //Unknown :( define("GIT_COMMIT", str_repeat("00", 20)); -} +} \ No newline at end of file diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php old mode 100644 new mode 100755 index 0285f1ab..0ab25e74 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -133,6 +133,7 @@ define("LIT_PUMPKIN", 91); define("JACK_O_LANTERN", 91); define("CAKE_BLOCK", 92); +define("INVISIBLE_BEDROCK", 95); define("TRAPDOOR", 96); define("STONE_BRICKS", 98); @@ -191,3 +192,7 @@ define("BEETROOT_BLOCK", 244); define("STONECUTTER", 245); define("GLOWING_OBSIDIAN", 246); define("NETHER_REACTOR", 247); +define("INFO_UPDATE", 248); +define("INFO_UPDATE2", 249); + +define("RESERVED6", 255); \ No newline at end of file diff --git a/src/constants/ItemIDs.php b/src/constants/ItemIDs.php old mode 100644 new mode 100755 index 151941c7..6155657e --- a/src/constants/ItemIDs.php +++ b/src/constants/ItemIDs.php @@ -90,7 +90,7 @@ define("GOLD_CHESTPLATE", 315); define("GOLD_LEGGINGS", 316); define("GOLD_BOOTS", 317); define("FLINT", 318); -define("RAW_PORKCHOP", 319); +define("PORKCHOP", 319); define("COOKED_PORKCHOP", 320); define("PAINTING", 321); define("GOLDEN_APPLE", 322); @@ -111,7 +111,7 @@ define("BRICK", 336); define("CLAY", 337); define("SUGARCANE", 338); define("SUGAR_CANE", 338); -define("SUGAR_CANES", 338); +define("REED", 338); define("PAPER", 339); define("BOOK", 340); define("SLIMEBALL", 341); @@ -121,25 +121,20 @@ define("COMPASS", 345); define("CLOCK", 347); define("GLOWSTONE_DUST", 348); -//define("RAW_FISH", 349); -//define("COOKED_FISH", 350); define("DYE", 351); define("BONE", 352); define("SUGAR", 353); define("CAKE", 354); define("BED", 355); -//define("COOKIE", 357); - define("SHEARS", 359); define("MELON", 360); define("MELON_SLICE", 360); define("PUMPKIN_SEEDS", 361); define("MELON_SEEDS", 362); -define("RAW_BEEF", 363); +define("BEEF", 363); define("STEAK", 364); define("COOKED_BEEF", 364); - define("RAW_CHICKEN", 365); define("COOKED_CHICKEN", 366); diff --git a/src/material/Block.php b/src/material/Block.php old mode 100644 new mode 100755 index 223edc13..43d47f17 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -102,6 +102,8 @@ abstract class Block extends Position{ GLOWSTONE_BLOCK => "GlowstoneBlock", LIT_PUMPKIN => "LitPumpkinBlock", + INVISIBLE_BEDROCK => "InvisibleBedrockBlock", + CAKE_BLOCK => "CakeBlock", TRAPDOOR => "TrapdoorBlock", @@ -146,6 +148,9 @@ abstract class Block extends Position{ STONECUTTER => "StonecutterBlock", GLOWING_OBSIDIAN => "GlowingObsidianBlock", NETHER_REACTOR => "NetherReactorBlock", + INFO_UPDATE => "InfoUpdateBlock", + INFO_UPDATE2 => "InfoUpdate2Block", + RESERVED6 => "Reserved6Block", ); protected $id; protected $meta; diff --git a/src/material/Item.php b/src/material/Item.php old mode 100644 new mode 100755 index b7861d67..2b948bbe --- a/src/material/Item.php +++ b/src/material/Item.php @@ -21,41 +21,104 @@ class Item{ public static $class = array( - SUGARCANE => "SugarcaneItem", - WHEAT_SEEDS => "WheatSeedsItem", - PUMPKIN_SEEDS => "PumpkinSeedsItem", - MELON_SEEDS => "MelonSeedsItem", + + //armor + + //food + APPLE => "AppleItem", MUSHROOM_STEW => "MushroomStewItem", - BEETROOT_SOUP => "BeetrootSoupItem", + BREAD => "BreadItem", + PORKCHOP => "PorkchopItem", + COOKED_PORKCHOP => "CookedPorkchopItem", + CAKE => "CakeItem", + MELON => "MelonItem", + BEEF => "BeefItem", + STEAK => "SteakItem", + RAW_CHICKEN => "RawChickenItem", + COOKED_CHICKEN => "CookedChickenItem", CARROT => "CarrotItem", POTATO => "PotatoItem", - BEETROOT_SEEDS => "BeetrootSeedsItem", + BAKED_POTATO => "CookedPotatoItem", + PUMPKIN_PIE => "PumpkinPieItem", + BEETROOT => "BeetrootItem", + BEETROOT_SOUP => "BeetrootSoupItem", + + //generic + ARROW => "ArrowItem", + COAL => "CoalItem", + DIAMOND => "DiamondItem", + IRON_INGOT => "IronIngotItem", + GOLD_INGOT => "GoldIngotItem", + STICK => "StickItem", + BOWL => "BowlItem", + 'STRING' => "StringItem", + FEATHER => "FeatherItem", + GUNPOWDER => "GunpowderItem", + WHEAT_SEEDS => "WheatSeedsItem", + WHEAT => "WheatItem", + FLINT => "FlintItem", + PAINTING => "PaintingItem", SIGN => "SignItem", WOODEN_DOOR => "WoodenDoorItem", BUCKET => "BucketItem", + MINECART => "MinecartItem", + SADDLE => "SaddleItem", IRON_DOOR => "IronDoorItem", - CAKE => "CakeItem", - BED => "BedItem", - PAINTING => "PaintingItem", - COAL => "CoalItem", - APPLE => "AppleItem", - SPAWN_EGG => "SpawnEggItem", - DIAMOND => "DiamondItem", - STICK => "StickItem", - BOWL => "BowlItem", - FEATHER => "FeatherItem", + REDSTONE => "RedstoneItem", + SNOWBALL => "SnowballItem", + LEATHER => "LeatherItem", BRICK => "BrickItem", - IRON_INGOT => "IronIngotItem", - GOLD_INGOT => "GoldIngotItem", + CLAY => "ClayItem", + SUGARCANE => "SugarCaneItem", + PAPER => "PaperItem", + BOOK => "BookItem", + SLIMEBALL => "SlimeballItem", + EGG => "EggItem", + GLOWSTONE_DUST => "GlowstoneDustItem", + DYE => "DyeItem", + BONE => "BoneItem", + SUGAR => "SugarItem", + BED => "BedItem", + PUMPKIN_SEEDS => "PumpkinSeedsItem", + MELON_SEEDS => "MelonSeedsItem", + SPAWN_EGG => "SpawnEggItem", + NETHER_BRICK => "NetherBrickItem", + QUARTZ => "QuartzItem", + CAMERA => "CameraItem", + BEETROOT_SEEDS => "BeetrootSeedsItem", + + //tool IRON_SHOVEL => "IronShovelItem", IRON_PICKAXE => "IronPickaxeItem", IRON_AXE => "IronAxeItem", - IRON_HOE => "IronHoeItem", + FLINT_STEEL => "FlintSteelItem", + BOW => "BowItem", + IRON_SWORD => "IronSwordItem", WOODEN_SWORD => "WoodenSwordItem", WOODEN_SHOVEL => "WoodenShovelItem", WOODEN_PICKAXE => "WoodenPickaxeItem", WOODEN_AXE => "WoodenAxeItem", - FLINT_STEEL => "FlintSteelItem", + STONE_SWORD => "StoneSwordItem", + STONE_SHOVEL => "StoneShovelItem", + STONE_PICKAXE => "StonePickaxeItem", + STONE_AXE => "StoneAxeItem", + DIAMOND_SWORD => "DiamondSwordItem", + DIAMOND_SHOVEL => "DiamondShovelItem", + DIAMOND_PICKAXE => "DiamondPickaxeItem", + DIAMOND_AXE => "DiamondAxeItem", + GOLDEN_SWORD => "GoldenSwordItem", + GOLDEN_SHOVEL => "GoldenShovelItem", + GOLDEN_PICKAXE => "GoldenPickaxeItem", + GOLDEN_AXE => "GoldenAxeItem", + WOODEN_HOE => "WoodenHoeItem", + STONE_HOE => "StoneHoeItem", + IRON_HOE => "IronHoeItem", + DIAMOND_HOE => "DiamondHoeItem", + GOLDEN_HOE => "GoldenHoeItem", + COMPASS => "CompassItem", + CLOCK => "ClockItem", + SHEARS => "ShearsItem", + ); protected $block; protected $id; @@ -195,7 +258,7 @@ class Item{ return 3; case DIAMOND_PICKAXE: return 5; - case GOLD_PICKAXE: + case GOLDEN_PICKAXE: return 2; default: return false; @@ -212,7 +275,7 @@ class Item{ return 3; case DIAMOND_AXE: return 5; - case GOLD_AXE: + case GOLDEN_AXE: return 2; default: return false; @@ -229,7 +292,7 @@ class Item{ return 3; case DIAMOND_SWORD: return 5; - case GOLD_SWORD: + case GOLDEN_SWORD: return 2; default: return false; @@ -246,7 +309,7 @@ class Item{ return 3; case DIAMOND_SHOVEL: return 5; - case GOLD_SHOVEL: + case GOLDEN_SHOVEL: return 2; default: return false; @@ -259,7 +322,7 @@ class Item{ case WOODEN_HOE: case STONE_HOE: case DIAMOND_HOE: - case GOLD_HOE: + case GOLDEN_HOE: return true; default: return false; diff --git a/src/material/block/solid/InfoUpdate.php b/src/material/block/solid/InfoUpdate.php new file mode 100755 index 00000000..3b7605bc --- /dev/null +++ b/src/material/block/solid/InfoUpdate.php @@ -0,0 +1,29 @@ +breakable = true; + $this->hardness = 0; + } + +} \ No newline at end of file diff --git a/src/material/block/solid/InfoUpdate2.php b/src/material/block/solid/InfoUpdate2.php new file mode 100755 index 00000000..99231e3c --- /dev/null +++ b/src/material/block/solid/InfoUpdate2.php @@ -0,0 +1,29 @@ +breakable = true; + $this->hardness = 0; + } + +} \ No newline at end of file diff --git a/src/material/block/solid/InvisibleBedrock.php b/src/material/block/solid/InvisibleBedrock.php new file mode 100755 index 00000000..4d660076 --- /dev/null +++ b/src/material/block/solid/InvisibleBedrock.php @@ -0,0 +1,36 @@ +breakable = false; + $this->hardness = 3600000; + } + + public function isBreakable(Item $item, Player $player){ + if(($player->gamemode & 0x01) === 0x01){ + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/src/material/block/solid/Reserved6.php b/src/material/block/solid/Reserved6.php new file mode 100644 index 00000000..c1835cf6 --- /dev/null +++ b/src/material/block/solid/Reserved6.php @@ -0,0 +1,29 @@ +breakable = true; + $this->hardness = 0; + } + +} \ No newline at end of file diff --git a/src/material/item/generic/Apple.php b/src/material/item/food/Apple.php old mode 100644 new mode 100755 similarity index 100% rename from src/material/item/generic/Apple.php rename to src/material/item/food/Apple.php diff --git a/src/material/item/food/BakedPotato.php b/src/material/item/food/BakedPotato.php new file mode 100755 index 00000000..dc8de4de --- /dev/null +++ b/src/material/item/food/BakedPotato.php @@ -0,0 +1,27 @@ + "Inc Sac", + 1 => "Rose Red", + 2 => "Cactus Green", + 3 => "Cocoa Beans", + 4 => "Lapis Lazuli", + 5 => "Purple Dye", + 6 => "Cyan Dye", + 7 => "Light Gray Dye", + 8 => "Gray Dye", + 9 => "Pink Dye", + 10 => "Lime Dye", + 11 => "Dandelion Yellow", + 12 => "Light Blue Dye", + 13 => "Magenta Dye", + 14 => "Orange Dye", + 15 => "Bone Meal", + ); + $this->name = $names[$this->meta]; + } +} \ No newline at end of file diff --git a/src/material/item/generic/Egg.php b/src/material/item/generic/Egg.php new file mode 100755 index 00000000..37a4c7ad --- /dev/null +++ b/src/material/item/generic/Egg.php @@ -0,0 +1,27 @@ +buffer{$this->offset}); } -} +} \ No newline at end of file diff --git a/src/world/ClientRenderFix.php b/src/world/ClientRenderFix.php deleted file mode 100644 index 72f4bf70..00000000 --- a/src/world/ClientRenderFix.php +++ /dev/null @@ -1,143 +0,0 @@ -server = ServerAPI::request(); - $this->player = $player; - $this->startingFromX = round($player->entity->x,0); - $this->startChunkX = $this->block2Chunk($this->startingFromX); - $this->lowerLeftChunkX = $this->startChunkX; - $this->startingFromZ = round($player->entity->z,0); - $this->startChunkZ = $this->block2Chunk($this->startingFromZ); - $this->lowerLeftChunkZ = $this->startChunkZ; - $this->server->schedule($freq, array($this,"updateSpiral"),array(),true); - // Doing 0 = bottom, 1 = left side, 2 = top, 3 = right side. - } - - private function block2Chunk($inputBlock) { - $output = intval($inputBlock / 16); - return $output; - } - private function chunk2MidBlock($inputChunk) { - $output = $inputChunk * 16 + 8; - return $output; - } - - // Given x and y chunks, see if these chunks lie within the world. - // If they do, send out the packet and increase our nupdated. Otherwise, return false. - // Also, check to see if we are done. - private function try2Update($xChunk, $zChunk) { - if($xChunk < 0) return false; - if($xChunk > 15) return false; - if($zChunk < 0) return false; - if($zChunk > 15) return false; - $this->mkPacket($this->chunk2MidBlock($xChunk), $this->chunk2MidBlock($zChunk)); - $this->nUpdated++; - if($this->nUpdated > 255) { - $this->spiralDone = true; - } - - return true; - } - - // Send a spiral, which is really a box that grows around the starting chunk x, z. - // This function should be called set up for whatever chunk it expects to try next. - // For each growing box it sends the bottom, left side, top, right side. - public function updateSpiral() { - if(!$this->player instanceof Player) return false; - $sentPacket = false; - $maxSideIndex = $this->sideLength - 1; - - // Keep try to send chunks until we succeed in sending one. - while(!$sentPacket) { - // Prevent problem is updating from locking up server. Should never happen: - if ($this->sideLength > 32) return false; - - switch($this->doing) { - case 0: // Sending bottom. Send index 0 to sideLength; - $sentPacket = $this->try2Update($this->lowerLeftChunkX + $this->sideIndex, $this->lowerLeftChunkZ); - // Look for special case of first chunk sent. If so, move the lowerLeft down and left one. - if($this->sideLength === 1) { - $this->lowerLeftChunkX--; - $this->lowerLeftChunkZ--; - $this->sideLength += 2; - $this->sideIndex = 0; - $this->doing = 0; - break; - } - // Check to see if we are done sending bottom: - $this->sideIndex++; - if($this->sideIndex > $maxSideIndex) { - $this->doing = 1; // Set up to start sending left side. - $this->sideIndex = 1; // start with index 1, not zero. - } - break; - case 1: // Sending left side - $sentPacket = $this->try2Update($this->lowerLeftChunkX, $this->lowerLeftChunkZ + $this->sideIndex); - // Done sending left? - $this->sideIndex++; - if($this->sideIndex >= $this->sideLength) { - $this->sideIndex = 1; - $this->doing = 2; - } - break; - case 2: // Sending top - $sentPacket = $this->try2Update($this->lowerLeftChunkX + $this->sideIndex, $this->lowerLeftChunkZ + $maxSideIndex); - $this->sideIndex++; - // Done sending top? - if($this->sideIndex >= $this->sideLength) { - $this->sideIndex = 1; - $this->doing = 3; - } - break; - case 3: // Sending right - $sentPacket = $this->try2Update( $this->lowerLeftChunkX + $maxSideIndex, $this->lowerLeftChunkZ + $this->sideIndex); - $this->sideIndex++; - // Done sending top? If so, move the lower left down and left a chunk, increase sideLength by 2. - if ($this->sideIndex >= $maxSideIndex) { - $this->lowerLeftChunkX--; - $this->lowerLeftChunkZ--; - $this->sideLength += 2; - $this->sideIndex = 0; - $this->doing = 0; - } - break; - } - } - - if($this->spiralDone === false) return true; - if($this->spiralDone === true) return false; - } - - - public function mkPacket($x,$z) { - $pk = new UpdateBlockPacket(); - $pk->x = $x; - $pk->z = $z; - $pk->y = 127; - $pk->block = GLOWSTONE_BLOCK; - $pk->meta = 0; - $this->player->dataPacket($pk); - } -} \ No newline at end of file