Update to NeoLegacy Latest
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user