This commit is contained in:
piebot
2026-03-16 22:40:16 +03:00
9 changed files with 236 additions and 159 deletions
+48 -25
View File
@@ -80,6 +80,9 @@ void ArmorStand::defineSynchedData()
void ArmorStand::tick()
{
float lockedRot = this->yRot;
if (this->isInWater()|| this->isInLava()) {
this->yd -= 0.0392;
}
LivingEntity::tick();
this->yRot = lockedRot;
this->yRotO = lockedRot;
@@ -87,6 +90,8 @@ void ArmorStand::tick()
this->yBodyRotO = lockedRot;
this->yHeadRot = lockedRot;
this->yHeadRotO = lockedRot;
}
bool ArmorStand::interact(shared_ptr<Player> player)
@@ -142,50 +147,61 @@ bool ArmorStand::interact(shared_ptr<Player> player)
return true;
}
}
bool ArmorStand::hurt(DamageSource *source, float damage)
{
if (isInvulnerable()) return false;
if (level->isClientSide || removed) return false;
if (isMarker()) return false;
if (isInvulnerable() || level->isClientSide || removed || isMarker()) return false;
if (dynamic_cast<EntityDamageSource *>(source) != nullptr)
{
shared_ptr<Entity> attacker = source->getEntity();
if (attacker != nullptr && attacker->instanceof(eTYPE_PLAYER))
{
shared_ptr<Player> player = dynamic_pointer_cast<Player>(attacker);
if (player->abilities.instabuild)
{
level->broadcastEntityEvent(shared_from_this(), (byte)31);
if (source != nullptr && source->getMsgId() == eEntityDamageType_Suffocate) return false;
bool isFireDamage = source->isFire();
if (dynamic_cast<EntityDamageSource *>(source) != nullptr) {
shared_ptr<Entity> attacker = source->getEntity();
if (attacker != nullptr && attacker->instanceof(eTYPE_PLAYER)) {
if (dynamic_pointer_cast<Player>(attacker)->abilities.instabuild) {
level->broadcastEntityEvent(shared_from_this(), (byte)31);
remove();
return true;
}
}
}
long long now = (long long)tickCount;
if (now - lastHit > 5)
{
if (isFireDamage) {
float currentHealth = this->getHealth() - 0.1f;
this->setHealth(currentHealth);
if (currentHealth <= 0) {
//level->broadcastEntityEvent(shared_from_this(), (byte)31);
remove();
return true;
}
return false;
}
if (now - lastHit > 5) {
level->broadcastEntityEvent(shared_from_this(), (byte)32);
lastHit = now;
}
else
{
return true;
} else {
level->broadcastEntityEvent(shared_from_this(), (byte)31);
remove();
spawnAtLocation(Item::armor_stand_Id, 1);
for (int i = 0; i < 5; i++) {
if (equipment[i] != nullptr) {
spawnAtLocation(equipment[i], 0.0f);
}
if (equipment[i] != nullptr) spawnAtLocation(equipment[i], 0.0f);
}
return true;
}
return true;
}
bool ArmorStand::isPickable()
@@ -427,4 +443,11 @@ void ArmorStand::handleEntityEvent(byte id)
lastHit = (long long)tickCount;
else
LivingEntity::handleEntityEvent(id);
}
}
bool ArmorStand::updateInWaterState()
{
return Entity::updateInWaterState();
}
+5
View File
@@ -97,6 +97,9 @@ public:
virtual wstring getAName() override { return L""; }
virtual wstring getDisplayName() override { return L""; }
virtual wstring getNetworkName() override { return L""; }
virtual bool isInWall() override { return false; }
virtual shared_ptr<ItemInstance> getCarriedItem() override;
virtual shared_ptr<ItemInstance> getCarried(int slot) override;
@@ -107,6 +110,8 @@ public:
virtual void readAdditionalSaveData(CompoundTag *tag) override;
virtual void addAdditonalSaveData(CompoundTag *tag) override;
virtual void handleEntityEvent(byte eventId) override;
virtual bool updateInWaterState() override;
protected:
virtual void defineSynchedData() override;
+6 -6
View File
@@ -509,10 +509,10 @@ void Item::staticCtor()
Item::lead = (new LeashItem(164)) ->setBaseItemTypeAndMaterial(eBaseItemType_pockettool, eMaterial_undefined)->setIconName(L"lead")->setDescriptionId(IDS_ITEM_LEAD)->setUseDescriptionId(IDS_DESC_LEAD);
Item::nameTag = (new NameTagItem(165)) ->setIconName(L"name_tag")->setDescriptionId(IDS_ITEM_NAME_TAG)->setUseDescriptionId(IDS_DESC_NAME_TAG);
Item::mutton_raw = (new FoodItem(167, 2, FoodConstants::FOOD_SATURATION_LOW, true))->setIconName(L"muttonRaw")->setDescriptionId(IDS_ITEM_BEEF_RAW)->setUseDescriptionId(IDS_DESC_BEEF_RAW);
Item::mutton_cooked = (new FoodItem(168, 8, FoodConstants::FOOD_SATURATION_NORMAL, true))->setIconName(L"muttonCooked")->setDescriptionId(IDS_ITEM_BEEF_COOKED)->setUseDescriptionId(IDS_DESC_BEEF_COOKED);
Item::rabbit_raw = (new FoodItem(155, 1.8, FoodConstants::FOOD_SATURATION_NORMAL, true))->setIconName(L"rabbitRaw")->setDescriptionId(IDS_ITEM_BEEF_RAW)->setUseDescriptionId(IDS_DESC_BEEF_RAW);
Item::rabbit_cooked = (new FoodItem(156, 5, FoodConstants::FOOD_SATURATION_NORMAL, true))->setIconName(L"rabbitCooked")->setDescriptionId(IDS_ITEM_BEEF_RAW)->setUseDescriptionId(IDS_DESC_BEEF_RAW);
Item::mutton_raw = (new FoodItem(167, 2, FoodConstants::FOOD_SATURATION_LOW, true))->setIconName(L"muttonRaw")->setDescriptionId(IDS_ITEM_MUTTON_RAW)->setUseDescriptionId(IDS_DESC_MUTTON_RAW);
Item::mutton_cooked = (new FoodItem(168, 6, FoodConstants::FOOD_SATURATION_NORMAL, true))->setIconName(L"muttonCooked")->setDescriptionId(IDS_ITEM_MUTTON_COOKED)->setUseDescriptionId(IDS_DESC_MUTTON_COOKED);
Item::rabbit_raw = (new FoodItem(155, 1, FoodConstants::FOOD_SATURATION_NORMAL, true))->setIconName(L"rabbitRaw")->setDescriptionId(IDS_ITEM_RABBIT_RAW)->setUseDescriptionId(IDS_DESC_RABBIT_RAW);
Item::rabbit_cooked = (new FoodItem(156, 5, FoodConstants::FOOD_SATURATION_NORMAL, true))->setIconName(L"rabbitCooked")->setDescriptionId(IDS_ITEM_RABBIT_COOKED)->setUseDescriptionId(IDS_DESC_RABBIT_COOKED);
Item::door_spruce = (new DoorItem(171, Material::wood, L"doorSpruce"))->setBaseItemTypeAndMaterial(eBaseItemType_door, eMaterial_wood)->setIconName(L"doorSpruce")->setDescriptionId(IDS_ITEM_DOOR_SPRUCE)->setUseDescriptionId(IDS_DESC_DOOR_WOOD);
Item::door_birch = (new DoorItem(172, Material::wood, L"doorBirch"))->setBaseItemTypeAndMaterial(eBaseItemType_door, eMaterial_wood)->setIconName(L"doorBirch")->setDescriptionId(IDS_ITEM_DOOR_BIRCH)->setUseDescriptionId(IDS_DESC_DOOR_WOOD);
@@ -520,8 +520,8 @@ void Item::staticCtor()
Item::door_acacia = (new DoorItem(174, Material::wood, L"doorAcacia"))->setBaseItemTypeAndMaterial(eBaseItemType_door, eMaterial_wood)->setIconName(L"doorAcacia")->setDescriptionId(IDS_ITEM_DOOR_ACACIA)->setUseDescriptionId(IDS_DESC_DOOR_WOOD);
Item::door_dark = (new DoorItem(175, Material::wood, L"doorDark"))->setBaseItemTypeAndMaterial(eBaseItemType_door, eMaterial_wood)->setIconName(L"doorDark")->setDescriptionId(IDS_ITEM_DOOR_DARK)->setUseDescriptionId(IDS_DESC_DOOR_WOOD);
Item::rabbit_hide = ( new Item(159) ) ->setIconName(L"rabbitHide")->setDescriptionId(IDS_ITEM_LEATHER)->setUseDescriptionId(IDS_DESC_LEATHER);
Item::rabbits_foot = ( new Item(158) ) ->setIconName(L"rabbitsFoot")->setDescriptionId(IDS_ITEM_LEATHER)->setUseDescriptionId(IDS_DESC_LEATHER);
Item::rabbit_hide = ( new Item(159) ) ->setIconName(L"rabbitHide")->setDescriptionId(IDS_ITEM_RABBIT_HIDE)->setUseDescriptionId(IDS_DESC_RABBIT_HIDE);
Item::rabbits_foot = ( new Item(158) ) ->setIconName(L"rabbitsFoot")->setDescriptionId(IDS_ITEM_RABBIT_FOOT)->setUseDescriptionId(IDS_DESC_RABBIT_FOOT);
Item::armor_stand = (new ArmorStandItem(160)) ->setBaseItemTypeAndMaterial(eBaseItemType_HangingItem,eMaterial_cloth)->setIconName(L"armorStand")->setDescriptionId(IDS_ITEM_ARMOR_STAND)->setUseDescriptionId(IDS_DESC_ARMOR_STAND);
}
+1 -1
View File
@@ -1030,7 +1030,7 @@ Recipes::Recipes()
L" S ",
L"SXS",
L'S', Item::stick,
L'X',Tile::stoneSlabHalf,
L'X', Tile::stoneSlabHalf,
L'D');