the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 101 lines 2.5 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.level.h" 3#include "net.minecraft.world.level.tile.h" 4#include "EnderChestTileEntity.h" 5 6EnderChestTileEntity::EnderChestTileEntity() 7{ 8 openness = oOpenness = 0.0f; 9 openCount = 0; 10 tickInterval = 0; 11} 12 13void EnderChestTileEntity::tick() 14{ 15 TileEntity::tick(); 16 17 if (++tickInterval % 20 * 4 == 0) 18 { 19 level->tileEvent(x, y, z, Tile::enderChest_Id, ChestTile::EVENT_SET_OPEN_COUNT, openCount); 20 } 21 22 oOpenness = openness; 23 24 float speed = 0.10f; 25 if (openCount > 0 && openness == 0) 26 { 27 double xc = x + 0.5; 28 double zc = z + 0.5; 29 30 // 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit 31 level->playSound(xc, y + 0.5, zc, eSoundType_RANDOM_CHEST_OPEN, 0.2f, level->random->nextFloat() * 0.1f + 0.9f); 32 } 33 if ((openCount == 0 && openness > 0) || (openCount > 0 && openness < 1)) 34 { 35 float oldOpen = openness; 36 if (openCount > 0) openness += speed; 37 else openness -= speed; 38 if (openness > 1) 39 { 40 openness = 1; 41 } 42 float lim = 0.5f; 43 if (openness < lim && oldOpen >= lim) 44 { 45 double xc = x + 0.5; 46 double zc = z + 0.5; 47 48 // 4J-PB - Seems the chest open volume is much louder than other sounds from user reports. We'll tone it down a bit 49 level->playSound(xc, y + 0.5, zc, eSoundType_RANDOM_CHEST_CLOSE, 0.2f, level->random->nextFloat() * 0.1f + 0.9f); 50 } 51 if (openness < 0) 52 { 53 openness = 0; 54 } 55 } 56} 57 58bool EnderChestTileEntity::triggerEvent(int b0, int b1) 59{ 60 if (b0 == ChestTile::EVENT_SET_OPEN_COUNT) 61 { 62 openCount = b1; 63 return true; 64 } 65 return TileEntity::triggerEvent(b0, b1); 66} 67 68void EnderChestTileEntity::setRemoved() 69{ 70 clearCache(); 71 TileEntity::setRemoved(); 72} 73 74void EnderChestTileEntity::startOpen() 75{ 76 openCount++; 77 level->tileEvent(x, y, z, Tile::enderChest_Id, ChestTile::EVENT_SET_OPEN_COUNT, openCount); 78} 79 80void EnderChestTileEntity::stopOpen() 81{ 82 openCount--; 83 level->tileEvent(x, y, z, Tile::enderChest_Id, ChestTile::EVENT_SET_OPEN_COUNT, openCount); 84} 85 86bool EnderChestTileEntity::stillValid(shared_ptr<Player> player) 87{ 88 if (level->getTileEntity(x, y, z) != shared_from_this()) return false; 89 if (player->distanceToSqr(x + 0.5, y + 0.5, z + 0.5) > 8 * 8) return false; 90 91 return true; 92} 93 94// 4J Added 95shared_ptr<TileEntity> EnderChestTileEntity::clone() 96{ 97 shared_ptr<EnderChestTileEntity> result = shared_ptr<EnderChestTileEntity>( new EnderChestTileEntity() ); 98 TileEntity::clone(result); 99 100 return result; 101}