mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-09 19:22:50 +00:00
TU19: merge Minecraft.World/Blocks
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
#include "../Platform/stdafx.h"
|
||||
#include "../Headers/net.minecraft.world.level.h"
|
||||
#include "../Headers/net.minecraft.world.h"
|
||||
#include "../Headers/net.minecraft.world.entity.item.h"
|
||||
#include "../Headers/net.minecraft.world.item.h"
|
||||
#include "../Headers/net.minecraft.world.level.h"
|
||||
#include "../Headers/net.minecraft.world.level.tile.entity.h"
|
||||
#include "../Entities/Mobs/WitherBoss.h"
|
||||
#include "../Headers/net.minecraft.h"
|
||||
#include "SkullTile.h"
|
||||
|
||||
SkullTile::SkullTile(int id) : EntityTile(id, Material::decoration, false) {
|
||||
SkullTile::SkullTile(int id)
|
||||
: BaseEntityTile(id, Material::decoration, false) {
|
||||
setShape(4.0f / 16.0f, 0, 4.0f / 16.0f, 12.0f / 16.0f, .5f, 12.0f / 16.0f);
|
||||
}
|
||||
|
||||
@@ -47,13 +51,13 @@ void SkullTile::updateShape(LevelSource* level, int x, int y, int z,
|
||||
|
||||
AABB* SkullTile::getAABB(Level* level, int x, int y, int z) {
|
||||
updateShape(level, x, y, z);
|
||||
return EntityTile::getAABB(level, x, y, z);
|
||||
return BaseEntityTile::getAABB(level, x, y, z);
|
||||
}
|
||||
|
||||
void SkullTile::setPlacedBy(Level* level, int x, int y, int z,
|
||||
std::shared_ptr<Mob> by) {
|
||||
std::shared_ptr<LivingEntity> by) {
|
||||
int dir = Mth::floor(by->yRot * 4 / (360) + 2.5) & 3;
|
||||
level->setData(x, y, z, dir);
|
||||
level->setData(x, y, z, dir, Tile::UPDATE_CLIENTS);
|
||||
}
|
||||
|
||||
std::shared_ptr<TileEntity> SkullTile::newTileEntity(Level* level) {
|
||||
@@ -71,9 +75,7 @@ int SkullTile::cloneTileData(Level* level, int x, int y, int z) {
|
||||
if (skull != NULL) {
|
||||
return skull->getSkullType();
|
||||
}
|
||||
return 0;
|
||||
// 4J Stu - Not added yet
|
||||
// return EntityTile::cloneTileData(level, x, y, z);
|
||||
return BaseEntityTile::cloneTileData(level, x, y, z);
|
||||
}
|
||||
|
||||
int SkullTile::getSpawnResourcesAuxValue(int data) { return data; }
|
||||
@@ -86,23 +88,16 @@ void SkullTile::spawnResources(Level* level, int x, int y, int z, int data,
|
||||
|
||||
void SkullTile::playerWillDestroy(Level* level, int x, int y, int z, int data,
|
||||
std::shared_ptr<Player> player) {
|
||||
// 4J Stu - Not implemented
|
||||
#if 0
|
||||
if (player->abilities.instabuild)
|
||||
{
|
||||
// prevent resource drop
|
||||
data |= NO_DROP_BIT;
|
||||
level.setData(x, y, z, data);
|
||||
}
|
||||
EntityTile::playerWillDestroy(level, x, y, z, data, player);
|
||||
#endif
|
||||
if (player->abilities.instabuild) {
|
||||
// prevent resource drop
|
||||
data |= NO_DROP_BIT;
|
||||
level->setData(x, y, z, data, Tile::UPDATE_NONE);
|
||||
}
|
||||
BaseEntityTile::playerWillDestroy(level, x, y, z, data, player);
|
||||
}
|
||||
|
||||
void SkullTile::onRemove(Level* level, int x, int y,
|
||||
int z) //, int id, int data)
|
||||
{
|
||||
void SkullTile::onRemove(Level* level, int x, int y, int z, int id, int data) {
|
||||
if (level->isClientSide) return;
|
||||
int data = level->getData(x, y, z);
|
||||
if ((data & NO_DROP_BIT) == 0) {
|
||||
std::shared_ptr<ItemInstance> item = std::shared_ptr<ItemInstance>(
|
||||
new ItemInstance(Item::skull_Id, 1, cloneTileData(level, x, y, z)));
|
||||
@@ -118,7 +113,7 @@ void SkullTile::onRemove(Level* level, int x, int y,
|
||||
|
||||
popResource(level, x, y, z, item);
|
||||
}
|
||||
EntityTile::onRemove(level, x, y, z, id, data);
|
||||
BaseEntityTile::onRemove(level, x, y, z, id, data);
|
||||
}
|
||||
|
||||
int SkullTile::getResource(int data, Random* random, int playerBonusLevel) {
|
||||
@@ -127,105 +122,175 @@ int SkullTile::getResource(int data, Random* random, int playerBonusLevel) {
|
||||
|
||||
void SkullTile::checkMobSpawn(Level* level, int x, int y, int z,
|
||||
std::shared_ptr<SkullTileEntity> placedSkull) {
|
||||
// 4J Stu - Don't have Withers yet, so don't need this
|
||||
#if 0
|
||||
if (placedSkull.getSkullType() == SkullTileEntity.TYPE_WITHER && y >= 2 && level.difficulty > Difficulty.PEACEFUL) {
|
||||
if (placedSkull->getSkullType() == SkullTileEntity::TYPE_WITHER && y >= 2 &&
|
||||
level->difficulty > Difficulty::PEACEFUL && !level->isClientSide) {
|
||||
// Check wither boss spawn
|
||||
int ss = Tile::soulsand_Id;
|
||||
|
||||
// check wither boss spawn
|
||||
// North-south alignment
|
||||
for (int zo = -2; zo <= 0; zo++) {
|
||||
if ( //
|
||||
level->getTile(x, y - 1, z + zo) == ss && //
|
||||
level->getTile(x, y - 1, z + zo + 1) == ss && //
|
||||
level->getTile(x, y - 2, z + zo + 1) == ss && //
|
||||
level->getTile(x, y - 1, z + zo + 2) == ss && //
|
||||
isSkullAt(level, x, y, z + zo,
|
||||
SkullTileEntity::TYPE_WITHER) && //
|
||||
isSkullAt(level, x, y, z + zo + 1,
|
||||
SkullTileEntity::TYPE_WITHER) && //
|
||||
isSkullAt(level, x, y, z + zo + 2,
|
||||
SkullTileEntity::TYPE_WITHER)) {
|
||||
level->setData(x, y, z + zo, NO_DROP_BIT, Tile::UPDATE_CLIENTS);
|
||||
level->setData(x, y, z + zo + 1, NO_DROP_BIT,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setData(x, y, z + zo + 2, NO_DROP_BIT,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x, y, z + zo, 0, 0, Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x, y, z + zo + 1, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x, y, z + zo + 2, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x, y - 1, z + zo, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x, y - 1, z + zo + 1, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x, y - 1, z + zo + 2, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x, y - 2, z + zo + 1, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
|
||||
final int ss = Tile.hellSand.id;
|
||||
// 4J: Check that we can spawn a Wither
|
||||
if (level->canCreateMore(eTYPE_WITHERBOSS,
|
||||
Level::eSpawnType_Egg)) {
|
||||
// 4J: Removed !isClientSide check because there's one
|
||||
// earlier on
|
||||
std::shared_ptr<WitherBoss> witherBoss =
|
||||
std::shared_ptr<WitherBoss>(new WitherBoss(level));
|
||||
witherBoss->moveTo(x + 0.5, y - 1.45, z + zo + 1.5, 90, 0);
|
||||
witherBoss->yBodyRot = 90;
|
||||
witherBoss->makeInvulnerable();
|
||||
level->addEntity(witherBoss);
|
||||
} else {
|
||||
// 4J: Can't spawn, drop resource instead
|
||||
Tile::tiles[Tile::soulsand_Id]->spawnResources(
|
||||
level, x, y - 1, z + zo, 0, 0);
|
||||
Tile::tiles[Tile::soulsand_Id]->spawnResources(
|
||||
level, x, y - 1, z + zo + 1, 0, 0);
|
||||
Tile::tiles[Tile::soulsand_Id]->spawnResources(
|
||||
level, x, y - 2, z + zo + 1, 0, 0);
|
||||
Tile::tiles[Tile::soulsand_Id]->spawnResources(
|
||||
level, x, y - 1, z + zo + 2, 0, 0);
|
||||
|
||||
// north-south alignment
|
||||
for (int zo = -2; zo <= 0; zo++) {
|
||||
if ( //
|
||||
level.getTile(x, y - 1, z + zo) == ss && //
|
||||
level.getTile(x, y - 1, z + zo + 1) == ss && //
|
||||
level.getTile(x, y - 2, z + zo + 1) == ss && //
|
||||
level.getTile(x, y - 1, z + zo + 2) == ss && //
|
||||
isSkullAt(level, x, y, z + zo, SkullTileEntity.TYPE_WITHER) && //
|
||||
isSkullAt(level, x, y, z + zo + 1, SkullTileEntity.TYPE_WITHER) && //
|
||||
isSkullAt(level, x, y, z + zo + 2, SkullTileEntity.TYPE_WITHER)) {
|
||||
std::shared_ptr<ItemInstance> itemInstance =
|
||||
std::shared_ptr<ItemInstance>(new ItemInstance(
|
||||
Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER));
|
||||
std::shared_ptr<ItemEntity> itemEntity =
|
||||
std::shared_ptr<ItemEntity>(new ItemEntity(
|
||||
level, x, y, z + zo + 1, itemInstance));
|
||||
level->addEntity(itemEntity);
|
||||
}
|
||||
|
||||
level.setDataNoUpdate(x, y, z + zo, NO_DROP_BIT);
|
||||
level.setDataNoUpdate(x, y, z + zo + 1, NO_DROP_BIT);
|
||||
level.setDataNoUpdate(x, y, z + zo + 2, NO_DROP_BIT);
|
||||
level.setTileNoUpdate(x, y, z + zo, 0);
|
||||
level.setTileNoUpdate(x, y, z + zo + 1, 0);
|
||||
level.setTileNoUpdate(x, y, z + zo + 2, 0);
|
||||
level.setTileNoUpdate(x, y - 1, z + zo, 0);
|
||||
level.setTileNoUpdate(x, y - 1, z + zo + 1, 0);
|
||||
level.setTileNoUpdate(x, y - 1, z + zo + 2, 0);
|
||||
level.setTileNoUpdate(x, y - 2, z + zo + 1, 0);
|
||||
for (int i = 0; i < 120; i++) {
|
||||
level->addParticle(
|
||||
eParticleType_snowballpoof,
|
||||
x + level->random->nextDouble(),
|
||||
y - 2 + level->random->nextDouble() * 3.9,
|
||||
z + zo + 1 + level->random->nextDouble(), 0, 0, 0);
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
WitherBoss witherBoss = new WitherBoss(level);
|
||||
witherBoss.moveTo(x + 0.5, y - 1.45, z + zo + 1.5, 90, 0);
|
||||
witherBoss.yBodyRot = 90;
|
||||
witherBoss.makeInvulnerable();
|
||||
level.addEntity(witherBoss);
|
||||
}
|
||||
level->tileUpdated(x, y, z + zo, 0);
|
||||
level->tileUpdated(x, y, z + zo + 1, 0);
|
||||
level->tileUpdated(x, y, z + zo + 2, 0);
|
||||
level->tileUpdated(x, y - 1, z + zo, 0);
|
||||
level->tileUpdated(x, y - 1, z + zo + 1, 0);
|
||||
level->tileUpdated(x, y - 1, z + zo + 2, 0);
|
||||
level->tileUpdated(x, y - 2, z + zo + 1, 0);
|
||||
|
||||
for (int i = 0; i < 120; i++) {
|
||||
level.addParticle("snowballpoof", x + level.random.nextDouble(), y - 2 + level.random.nextDouble() * 3.9, z + zo + 1 + level.random.nextDouble(), 0, 0, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// West-east alignment
|
||||
for (int xo = -2; xo <= 0; xo++) {
|
||||
if ( //
|
||||
level->getTile(x + xo, y - 1, z) == ss && //
|
||||
level->getTile(x + xo + 1, y - 1, z) == ss && //
|
||||
level->getTile(x + xo + 1, y - 2, z) == ss && //
|
||||
level->getTile(x + xo + 2, y - 1, z) == ss && //
|
||||
isSkullAt(level, x + xo, y, z,
|
||||
SkullTileEntity::TYPE_WITHER) && //
|
||||
isSkullAt(level, x + xo + 1, y, z,
|
||||
SkullTileEntity::TYPE_WITHER) && //
|
||||
isSkullAt(level, x + xo + 2, y, z,
|
||||
SkullTileEntity::TYPE_WITHER)) {
|
||||
level->setData(x + xo, y, z, NO_DROP_BIT, Tile::UPDATE_CLIENTS);
|
||||
level->setData(x + xo + 1, y, z, NO_DROP_BIT,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setData(x + xo + 2, y, z, NO_DROP_BIT,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x + xo, y, z, 0, 0, Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x + xo + 1, y, z, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x + xo + 2, y, z, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x + xo, y - 1, z, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x + xo + 1, y - 1, z, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x + xo + 2, y - 1, z, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
level->setTileAndData(x + xo + 1, y - 2, z, 0, 0,
|
||||
Tile::UPDATE_CLIENTS);
|
||||
|
||||
level.tileUpdated(x, y, z + zo, 0);
|
||||
level.tileUpdated(x, y, z + zo + 1, 0);
|
||||
level.tileUpdated(x, y, z + zo + 2, 0);
|
||||
level.tileUpdated(x, y - 1, z + zo, 0);
|
||||
level.tileUpdated(x, y - 1, z + zo + 1, 0);
|
||||
level.tileUpdated(x, y - 1, z + zo + 2, 0);
|
||||
level.tileUpdated(x, y - 2, z + zo + 1, 0);
|
||||
// 4J: Check that we can spawn a Wither
|
||||
if (level->canCreateMore(eTYPE_WITHERBOSS,
|
||||
Level::eSpawnType_Egg)) {
|
||||
// 4J: Removed !isClientSide check because there's one
|
||||
// earlier on
|
||||
std::shared_ptr<WitherBoss> witherBoss =
|
||||
std::shared_ptr<WitherBoss>(new WitherBoss(level));
|
||||
witherBoss->moveTo(x + xo + 1.5, y - 1.45, z + .5, 0, 0);
|
||||
witherBoss->makeInvulnerable();
|
||||
level->addEntity(witherBoss);
|
||||
} else {
|
||||
// 4J: Can't spawn, drop resource instead
|
||||
Tile::tiles[Tile::soulsand_Id]->spawnResources(
|
||||
level, x + xo, y - 1, z, 0, 0);
|
||||
Tile::tiles[Tile::soulsand_Id]->spawnResources(
|
||||
level, x + xo + 1, y - 1, z, 0, 0);
|
||||
Tile::tiles[Tile::soulsand_Id]->spawnResources(
|
||||
level, x + xo + 1, y - 2, z, 0, 0);
|
||||
Tile::tiles[Tile::soulsand_Id]->spawnResources(
|
||||
level, x + xo + 2, y - 1, z, 0, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
// west-east alignment
|
||||
for (int xo = -2; xo <= 0; xo++) {
|
||||
if ( //
|
||||
level.getTile(x + xo, y - 1, z) == ss && //
|
||||
level.getTile(x + xo + 1, y - 1, z) == ss && //
|
||||
level.getTile(x + xo + 1, y - 2, z) == ss && //
|
||||
level.getTile(x + xo + 2, y - 1, z) == ss && //
|
||||
isSkullAt(level, x + xo, y, z, SkullTileEntity.TYPE_WITHER) && //
|
||||
isSkullAt(level, x + xo + 1, y, z, SkullTileEntity.TYPE_WITHER) && //
|
||||
isSkullAt(level, x + xo + 2, y, z, SkullTileEntity.TYPE_WITHER)) {
|
||||
std::shared_ptr<ItemInstance> itemInstance =
|
||||
std::shared_ptr<ItemInstance>(new ItemInstance(
|
||||
Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER));
|
||||
std::shared_ptr<ItemEntity> itemEntity =
|
||||
std::shared_ptr<ItemEntity>(new ItemEntity(
|
||||
level, x + xo + 1, y, z, itemInstance));
|
||||
level->addEntity(itemEntity);
|
||||
}
|
||||
|
||||
level.setDataNoUpdate(x + xo, y, z, NO_DROP_BIT);
|
||||
level.setDataNoUpdate(x + xo + 1, y, z, NO_DROP_BIT);
|
||||
level.setDataNoUpdate(x + xo + 2, y, z, NO_DROP_BIT);
|
||||
level.setTileNoUpdate(x + xo, y, z, 0);
|
||||
level.setTileNoUpdate(x + xo + 1, y, z, 0);
|
||||
level.setTileNoUpdate(x + xo + 2, y, z, 0);
|
||||
level.setTileNoUpdate(x + xo, y - 1, z, 0);
|
||||
level.setTileNoUpdate(x + xo + 1, y - 1, z, 0);
|
||||
level.setTileNoUpdate(x + xo + 2, y - 1, z, 0);
|
||||
level.setTileNoUpdate(x + xo + 1, y - 2, z, 0);
|
||||
for (int i = 0; i < 120; i++) {
|
||||
level->addParticle(
|
||||
eParticleType_snowballpoof,
|
||||
x + xo + 1 + level->random->nextDouble(),
|
||||
y - 2 + level->random->nextDouble() * 3.9,
|
||||
z + level->random->nextDouble(), 0, 0, 0);
|
||||
}
|
||||
|
||||
if (!level.isClientSide) {
|
||||
WitherBoss witherBoss = new WitherBoss(level);
|
||||
witherBoss.moveTo(x + xo + 1.5, y - 1.45, z + .5, 0, 0);
|
||||
witherBoss.makeInvulnerable();
|
||||
level.addEntity(witherBoss);
|
||||
}
|
||||
level->tileUpdated(x + xo, y, z, 0);
|
||||
level->tileUpdated(x + xo + 1, y, z, 0);
|
||||
level->tileUpdated(x + xo + 2, y, z, 0);
|
||||
level->tileUpdated(x + xo, y - 1, z, 0);
|
||||
level->tileUpdated(x + xo + 1, y - 1, z, 0);
|
||||
level->tileUpdated(x + xo + 2, y - 1, z, 0);
|
||||
level->tileUpdated(x + xo + 1, y - 2, z, 0);
|
||||
|
||||
for (int i = 0; i < 120; i++) {
|
||||
level.addParticle("snowballpoof", x + xo + 1 + level.random.nextDouble(), y - 2 + level.random.nextDouble() * 3.9, z + level.random.nextDouble(), 0, 0, 0);
|
||||
}
|
||||
|
||||
level.tileUpdated(x + xo, y, z, 0);
|
||||
level.tileUpdated(x + xo + 1, y, z, 0);
|
||||
level.tileUpdated(x + xo + 2, y, z, 0);
|
||||
level.tileUpdated(x + xo, y - 1, z, 0);
|
||||
level.tileUpdated(x + xo + 1, y - 1, z, 0);
|
||||
level.tileUpdated(x + xo + 2, y - 1, z, 0);
|
||||
level.tileUpdated(x + xo + 1, y - 2, z, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SkullTile::isSkullAt(Level* level, int x, int y, int z, int skullType) {
|
||||
@@ -246,10 +311,9 @@ void SkullTile::registerIcons(IconRegister* iconRegister) {
|
||||
}
|
||||
|
||||
Icon* SkullTile::getTexture(int face, int data) {
|
||||
return Tile::hellSand->getTexture(face);
|
||||
return Tile::soulsand->getTexture(face);
|
||||
}
|
||||
|
||||
std::wstring SkullTile::getTileItemIconName() {
|
||||
return L"";
|
||||
// return SkullItem::ICON_NAMES[0];
|
||||
}
|
||||
return getIconName() + L"_" + SkullItem::ICON_NAMES[0];
|
||||
}
|
||||
Reference in New Issue
Block a user