mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-06-23 05:22:52 +00:00
Merge remote-tracking branch 'origin/main' into feat/minigames
This commit is contained in:
commit
53adb29b27
|
|
@ -110,81 +110,75 @@ void ItemFrameRenderer::drawFrame(shared_ptr<ItemFrame> itemFrame)
|
|||
|
||||
void ItemFrameRenderer::drawItem(shared_ptr<ItemFrame> entity)
|
||||
{
|
||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
||||
|
||||
shared_ptr<ItemInstance> instance = entity->getItem();
|
||||
if (instance == nullptr) return;
|
||||
shared_ptr<ItemInstance> instance = entity->getItem();
|
||||
if (instance == nullptr) return;
|
||||
|
||||
shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(entity->level, 0, 0, 0, instance);
|
||||
itemEntity->getItem()->count = 1;
|
||||
itemEntity->bobOffs = 0;
|
||||
shared_ptr<ItemEntity> itemEntity = std::make_shared<ItemEntity>(entity->level, 0, 0, 0, instance);
|
||||
itemEntity->getItem()->count = 1;
|
||||
itemEntity->bobOffs = 0;
|
||||
|
||||
glPushMatrix();
|
||||
glPushMatrix();
|
||||
|
||||
glTranslatef((-7.25f / 16.0f) * Direction::STEP_X[entity->dir], -0.18f, (-7.25f / 16.0f) * Direction::STEP_Z[entity->dir]);
|
||||
glRotatef(180 + entity->yRot, 0, 1, 0);
|
||||
glRotatef(-90 * entity->getRotation(), 0, 0, 1);
|
||||
glRotatef(180.0f + entity->yRot, 0, 1, 0);
|
||||
glTranslatef(0.0f, 0.0f, -0.4375f);
|
||||
|
||||
switch (entity->getRotation())
|
||||
{
|
||||
case 1:
|
||||
glTranslatef(-0.16f, -0.16f, 0);
|
||||
break;
|
||||
case 2:
|
||||
glTranslatef(0, -0.32f, 0);
|
||||
break;
|
||||
case 3:
|
||||
glTranslatef(0.16f, -0.16f, 0);
|
||||
break;
|
||||
}
|
||||
int rotation = entity->getRotation();
|
||||
bool isMap = (itemEntity->getItem()->getItem() == Item::map);
|
||||
int effectiveRotation = isMap ? 2 * (rotation % 4) : rotation;
|
||||
|
||||
if (itemEntity->getItem()->getItem() == Item::map)
|
||||
{
|
||||
entityRenderDispatcher->textures->bindTexture(&MAP_BACKGROUND_LOCATION);
|
||||
Tesselator *t = Tesselator::getInstance();
|
||||
glRotatef(-45.0f * effectiveRotation, 0, 0, 1);
|
||||
glTranslatef(0.0f, -0.41f/2, 0.0f);
|
||||
|
||||
glRotatef(180, 0, 1, 0);
|
||||
glRotatef(180, 0, 0, 1);
|
||||
glScalef(1.0f / 128.0f, 1.0f / 128.0f, 1.0f / 128.0f);
|
||||
glTranslatef(-64.0f, -87.0f, -3.0f);
|
||||
glNormal3f(0, 0, -1);
|
||||
t->begin();
|
||||
int vo = 7;
|
||||
t->vertexUV(0.0f, 128.0f, 0.0f, 0.0f, 1.0f);
|
||||
t->vertexUV(128.0f, 128.0f, 0.0f, 1.0f, 1.0f);
|
||||
t->vertexUV(128.0f, 0.0f, 0.0f, 1.0f, 0.0f);
|
||||
t->vertexUV(0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
t->end();
|
||||
if (isMap)
|
||||
{
|
||||
//entityRenderDispatcher->textures->bindTexture(&MAP_BACKGROUND_LOCATION);
|
||||
//Tesselator *t = Tesselator::getInstance();
|
||||
|
||||
shared_ptr<MapItemSavedData> data = Item::map->getSavedData(itemEntity->getItem(), entity->level);
|
||||
if (data != nullptr)
|
||||
{
|
||||
entityRenderDispatcher->itemInHandRenderer->minimap->render(nullptr, entityRenderDispatcher->textures, data, entity->entityId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (itemEntity->getItem()->getItem() == Item::compass)
|
||||
{
|
||||
CompassTexture *ct = CompassTexture::instance;
|
||||
double compassRot = ct->rot;
|
||||
double compassRotA = ct->rota;
|
||||
ct->rot = 0;
|
||||
ct->rota = 0;
|
||||
ct->updateFromPosition(entity->level, entity->x, entity->z, Mth::wrapDegrees( static_cast<float>(180 + entity->dir * 90) ), false, true);
|
||||
ct->rot = compassRot;
|
||||
ct->rota = compassRotA;
|
||||
}
|
||||
glRotatef(180, 0, 1, 0);
|
||||
glRotatef(180, 0, 0, 1);
|
||||
glScalef(1.0f / 128.0f, 1.0f / 128.0f, 1.0f / 128.0f);
|
||||
glTranslatef(-64.0f, -87.0f, -3.0f);
|
||||
|
||||
EntityRenderDispatcher::instance->render(itemEntity, 0, 0, 0, 0, 0, true);
|
||||
//glNormal3f(0, 0, -1);
|
||||
//t->begin();
|
||||
//t->vertexUV(0.0f, 128.0f, 0.0f, 0.0f, 1.0f);
|
||||
//t->vertexUV(128.0f, 128.0f, 0.0f, 1.0f, 1.0f);
|
||||
//t->vertexUV(128.0f, 0.0f, 0.0f, 1.0f, 0.0f);
|
||||
//t->vertexUV(0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
//t->end();
|
||||
|
||||
if (itemEntity->getItem()->getItem() == Item::compass)
|
||||
{
|
||||
CompassTexture *ct = CompassTexture::instance;
|
||||
ct->cycleFrames();
|
||||
}
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
shared_ptr<MapItemSavedData> data = Item::map->getSavedData(itemEntity->getItem(), entity->level);
|
||||
if (data != nullptr)
|
||||
{
|
||||
entityRenderDispatcher->itemInHandRenderer->minimap->render(
|
||||
nullptr, entityRenderDispatcher->textures, data, entity->entityId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (itemEntity->getItem()->getItem() == Item::compass)
|
||||
{
|
||||
CompassTexture *ct = CompassTexture::instance;
|
||||
double compassRot = ct->rot;
|
||||
double compassRotA = ct->rota;
|
||||
ct->rot = 0;
|
||||
ct->rota = 0;
|
||||
ct->updateFromPosition(entity->level, entity->x, entity->z,
|
||||
Mth::wrapDegrees(static_cast<float>(180 + entity->dir * 90)), false, true);
|
||||
ct->rot = compassRot;
|
||||
ct->rota = compassRotA;
|
||||
}
|
||||
|
||||
EntityRenderDispatcher::instance->render(itemEntity, 0, 0, 0, 0, 0, true);
|
||||
|
||||
if (itemEntity->getItem()->getItem() == Item::compass)
|
||||
{
|
||||
CompassTexture *ct = CompassTexture::instance;
|
||||
ct->cycleFrames();
|
||||
}
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "net.minecraft.world.item.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
#include "net.minecraft.world.level.redstone.h"
|
||||
|
|
@ -107,33 +107,42 @@ bool ComparatorTile::shouldTurnOn(Level *level, int x, int y, int z, int data)
|
|||
|
||||
int ComparatorTile::getInputSignal(Level *level, int x, int y, int z, int data)
|
||||
{
|
||||
int result = DiodeTile::getInputSignal(level, x, y, z, data);
|
||||
int result = DiodeTile::getInputSignal(level, x, y, z, data);
|
||||
|
||||
int dir = getDirection(data);
|
||||
int xx = x + Direction::STEP_X[dir];
|
||||
int zz = z + Direction::STEP_Z[dir];
|
||||
int tile = level->getTile(xx, y, zz);
|
||||
int dir = getDirection(data);
|
||||
int xx = x + Direction::STEP_X[dir];
|
||||
int zz = z + Direction::STEP_Z[dir];
|
||||
int tile = level->getTile(xx, y, zz);
|
||||
|
||||
if (tile > 0)
|
||||
{
|
||||
if (Tile::tiles[tile]->hasAnalogOutputSignal())
|
||||
{
|
||||
result = Tile::tiles[tile]->getAnalogOutputSignal(level, xx, y, zz, Direction::DIRECTION_OPPOSITE[dir]);
|
||||
}
|
||||
else if (result < Redstone::SIGNAL_MAX && Tile::isSolidBlockingTile(tile))
|
||||
{
|
||||
xx += Direction::STEP_X[dir];
|
||||
zz += Direction::STEP_Z[dir];
|
||||
tile = level->getTile(xx, y, zz);
|
||||
if (tile > 0)
|
||||
{
|
||||
if (Tile::tiles[tile]->hasAnalogOutputSignal())
|
||||
{
|
||||
result = Tile::tiles[tile]->getAnalogOutputSignal(level, xx, y, zz, Direction::DIRECTION_OPPOSITE[dir]);
|
||||
}
|
||||
else if (result < Redstone::SIGNAL_MAX && Tile::isSolidBlockingTile(tile))
|
||||
{
|
||||
xx += Direction::STEP_X[dir];
|
||||
zz += Direction::STEP_Z[dir];
|
||||
tile = level->getTile(xx, y, zz);
|
||||
|
||||
if (tile > 0 && Tile::tiles[tile]->hasAnalogOutputSignal())
|
||||
{
|
||||
result = Tile::tiles[tile]->getAnalogOutputSignal(level, xx, y, zz, Direction::DIRECTION_OPPOSITE[dir]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tile > 0 && Tile::tiles[tile]->hasAnalogOutputSignal())
|
||||
{
|
||||
result = Tile::tiles[tile]->getAnalogOutputSignal(level, xx, y, zz, Direction::DIRECTION_OPPOSITE[dir]);
|
||||
}
|
||||
|
||||
else if (tile == 0)
|
||||
{
|
||||
shared_ptr<ItemFrame> frame = getItemFrame(level, xx, y, zz);
|
||||
if (frame != nullptr)
|
||||
{
|
||||
result = frame->getAnalogOutput();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
shared_ptr<ComparatorTileEntity> ComparatorTile::getComparator(LevelSource *level, int x, int y, int z)
|
||||
|
|
@ -250,4 +259,28 @@ shared_ptr<TileEntity> ComparatorTile::newTileEntity(Level *level)
|
|||
bool ComparatorTile::TestUse()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
shared_ptr<ItemFrame> ComparatorTile::getItemFrame(
|
||||
Level* level,
|
||||
int x,
|
||||
int y,
|
||||
int z)
|
||||
{
|
||||
AABB* box = AABB::newTemp(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
x + 1,
|
||||
y + 1,
|
||||
z + 1
|
||||
);
|
||||
|
||||
vector<shared_ptr<Entity>>* entities =
|
||||
level->getEntitiesOfClass(typeid(ItemFrame), box);
|
||||
|
||||
if (entities == nullptr || entities->size() != 1)
|
||||
return nullptr;
|
||||
|
||||
return dynamic_pointer_cast<ItemFrame>((*entities)[0]);
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "DiodeTile.h"
|
||||
#include "EntityTile.h"
|
||||
#include "AABB.h"
|
||||
|
||||
class ComparatorTileEntity;
|
||||
|
||||
|
|
@ -57,4 +58,5 @@ public:
|
|||
virtual bool triggerEvent(Level *level, int x, int y, int z, int b0, int b1);
|
||||
virtual shared_ptr<TileEntity> newTileEntity(Level *level);
|
||||
virtual bool TestUse();
|
||||
shared_ptr<ItemFrame> ComparatorTile::getItemFrame(Level* level,int x,int y,int z);
|
||||
};
|
||||
|
|
@ -10,7 +10,8 @@
|
|||
#include "net.minecraft.world.level.saveddata.h"
|
||||
#include "com.mojang.nbt.h"
|
||||
#include "ItemFrame.h"
|
||||
|
||||
#include "DamageSource.h"
|
||||
#include "Level.h"
|
||||
|
||||
|
||||
|
||||
|
|
@ -87,29 +88,52 @@ shared_ptr<ItemInstance> ItemFrame::getItem()
|
|||
return getEntityData()->getItemInstance(DATA_ITEM);
|
||||
}
|
||||
|
||||
void ItemFrame::setItem(shared_ptr<ItemInstance> item)
|
||||
void ItemFrame::setItem(shared_ptr<ItemInstance> item, bool notifyNeighbors)
|
||||
{
|
||||
if(item != nullptr)
|
||||
{
|
||||
item = item->copy();
|
||||
item->count = 1;
|
||||
if (item != nullptr)
|
||||
{
|
||||
item = item->copy();
|
||||
item->count = 1;
|
||||
item->setFramed(dynamic_pointer_cast<ItemFrame>(shared_from_this()));
|
||||
}
|
||||
getEntityData()->set(DATA_ITEM, item);
|
||||
getEntityData()->markDirty(DATA_ITEM);
|
||||
|
||||
item->setFramed(dynamic_pointer_cast<ItemFrame>( shared_from_this() ));
|
||||
}
|
||||
getEntityData()->set(DATA_ITEM, item);
|
||||
getEntityData()->markDirty(DATA_ITEM);
|
||||
if (notifyNeighbors)
|
||||
{
|
||||
level->updateNeighbourForOutputSignal(xTile, yTile, zTile, Tile::comparator_off->id);
|
||||
}
|
||||
}
|
||||
|
||||
int ItemFrame::getRotation()
|
||||
void ItemFrame::setItem(shared_ptr<ItemInstance> item)
|
||||
{
|
||||
return getEntityData()->getByte(DATA_ROTATION);
|
||||
setItem(item, true);
|
||||
}
|
||||
|
||||
void ItemFrame::setRotation(int rotation)
|
||||
int ItemFrame::getRotation()
|
||||
{
|
||||
getEntityData()->set(DATA_ROTATION, static_cast<byte>(rotation % 4));
|
||||
return getEntityData()->getByte(DATA_ROTATION);
|
||||
}
|
||||
|
||||
void ItemFrame::setRotation(int rotation, bool notifyNeighbors)
|
||||
{
|
||||
getEntityData()->set(DATA_ROTATION, static_cast<byte>(rotation % 8));
|
||||
|
||||
if (notifyNeighbors)
|
||||
{
|
||||
level->updateNeighbourForOutputSignal(xTile, yTile, zTile, Tile::comparator_off->id);
|
||||
}
|
||||
}
|
||||
|
||||
void ItemFrame::setRotation(int rotation)
|
||||
{
|
||||
|
||||
getEntityData()->set(DATA_ROTATION, static_cast<byte>(rotation % 8));
|
||||
level->updateNeighbourForOutputSignal(xTile, yTile, zTile, Tile::comparator_off->id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ItemFrame::addAdditonalSaveData(CompoundTag *tag)
|
||||
{
|
||||
if (getItem() != nullptr)
|
||||
|
|
@ -171,3 +195,54 @@ bool ItemFrame::interact(shared_ptr<Player> player)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ItemFrame::hurt(DamageSource *source, float damage)
|
||||
{
|
||||
if (level->isClientSide) return false;
|
||||
|
||||
shared_ptr<ItemInstance> item = getItem();
|
||||
|
||||
if (!source->isExplosion() && item != nullptr)
|
||||
{
|
||||
shared_ptr<Entity> sourceEntity = source->getEntity();
|
||||
|
||||
if (sourceEntity != nullptr && sourceEntity->instanceof(eTYPE_PLAYER))
|
||||
{
|
||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(sourceEntity);
|
||||
if (!player->abilities.instabuild)
|
||||
{
|
||||
shared_ptr<ItemInstance> copy = item->copy();
|
||||
removeFramedMap(copy);
|
||||
spawnAtLocation(copy, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
removeFramedMap(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
shared_ptr<ItemInstance> copy = item->copy();
|
||||
removeFramedMap(copy);
|
||||
spawnAtLocation(copy, 0);
|
||||
}
|
||||
|
||||
setItem(nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
return HangingEntity::hurt(source, damage);
|
||||
}
|
||||
|
||||
int ItemFrame::getAnalogOutput()
|
||||
{
|
||||
shared_ptr<ItemInstance> item = getItem();
|
||||
if (item == nullptr) return 0;
|
||||
return getRotation() % 8 + 1;
|
||||
}
|
||||
|
||||
|
||||
float ItemFrame::getPickRadius()
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
|
@ -38,9 +38,14 @@ private:
|
|||
|
||||
public:
|
||||
shared_ptr<ItemInstance> getItem();
|
||||
void setItem(shared_ptr<ItemInstance> item, bool notifyNeighbors);
|
||||
void setItem(shared_ptr<ItemInstance> item);
|
||||
int getRotation();
|
||||
void setRotation(int rotation, bool notifyNeighbors);
|
||||
void setRotation(int rotation);
|
||||
virtual bool hurt(DamageSource *source, float damage) override;
|
||||
virtual int getAnalogOutput();
|
||||
virtual float getPickRadius()override;
|
||||
|
||||
virtual void addAdditonalSaveData(CompoundTag *tag);
|
||||
virtual void readAdditionalSaveData(CompoundTag *tag);
|
||||
|
|
|
|||
|
|
@ -20,3 +20,4 @@
|
|||
#include "TheEndPortalTileEntity.h"
|
||||
#include "SkullTileEntity.h"
|
||||
#include "EnderChestTileEntity.h"
|
||||
#include "ItemFrame.h"
|
||||
|
|
|
|||
Loading…
Reference in a new issue