Backport modern Rosa Arcana behavior (#109)

Co-authored-by: Nikolay S. <nicksitnikov@gmail.com>
This commit is contained in:
koolkrafter5andNikolay S. authored and GitHub committed 2025-11-03 17:03:15 -06:00
1 parent 4ee06de9f0
commit c0daedcbd8
7 files changed
+123 -22

No files matched your search

@@ -11,9 +11,18 @@
package vazkii.botania.common.block.subtile.generating;
import java.util.List;
import java.util.Map;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.SubTileGenerating;
@@ -22,22 +31,114 @@ import vazkii.botania.common.lexicon.LexiconData;
public class SubTileArcaneRose extends SubTileGenerating {
private static final int MANA_PER_XP = 50;
private static final int RANGE = 1;
@Override
public void onUpdate() {
super.onUpdate();
if(mana >= getMaxMana())
return;
World world = supertile.getWorldObj();
List<EntityPlayer> players = supertile.getWorldObj().getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + 1, supertile.zCoord + RANGE + 1));
for(EntityPlayer player : players)
if(ExperienceHelper.getPlayerXP(player) >= 1 && player.onGround) {
ExperienceHelper.drainPlayerXP(player, 1);
mana += 50;
return;
if (mana >= getMaxMana() || world.isRemote) {
return;
}
AxisAlignedBB effectBounds = AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord, supertile.zCoord - RANGE, supertile.xCoord + RANGE + 1, supertile.yCoord + 1, supertile.zCoord + RANGE + 1);
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, effectBounds);
for (EntityPlayer player : players) {
if (ExperienceHelper.getPlayerXP(player) <= 0 || !player.onGround) continue;
ExperienceHelper.drainPlayerXP(player, 1);
addMana(MANA_PER_XP);
return;
}
List<EntityXPOrb> orbs = world.getEntitiesWithinAABB(EntityXPOrb.class, effectBounds);
for (EntityXPOrb orb : orbs) {
if (orb.isDead) continue;
addMana(orb.getXpValue() * MANA_PER_XP);
orb.setDead();
float pitch = (world.rand.nextFloat() - world.rand.nextFloat()) * 0.35F + 0.9F;
world.playSoundAtEntity(orb, "random.orb", 0.1F, pitch);
return;
}
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, effectBounds);
for (EntityItem entity : items) {
ItemStack oldStack = entity.getEntityItem();
if (entity.isDead || oldStack == null) continue;
if (oldStack.getItem() != Items.enchanted_book && !oldStack.isItemEnchanted()) {
continue;
}
int xp = getEnchantmentXpValue(oldStack);
if (xp <= 0) continue;
ItemStack newStack = disenchantAndSplit(oldStack);
if (oldStack.stackSize <= 0) entity.setDead();
EntityItem newEntity = new EntityItem(world, entity.posX, entity.posY, entity.posZ, newStack);
newEntity.motionX = entity.motionX;
newEntity.motionY = entity.motionY;
newEntity.motionZ = entity.motionZ;
newEntity.age = entity.age;
newEntity.delayBeforeCanPickup = entity.delayBeforeCanPickup;
world.spawnEntityInWorld(newEntity);
while (xp > 0) {
int i = EntityXPOrb.getXPSplit(xp);
xp -= i;
world.spawnEntityInWorld(new EntityXPOrb(world, newEntity.posX, newEntity.posY, newEntity.posZ, i));
}
return;
}
}
/**
* Modified method from GrindstoneMenu
* Removed check for curses since they don't exist in this version
*/
private static int getEnchantmentXpValue(ItemStack stack) {
if (stack.hasTagCompound()) {
NBTTagCompound tag = stack.getTagCompound();
// Don't remove "enchants" from Tinkers' Construct tools
if (tag.hasKey("InfiTool")) return 0;
}
int ret = 0;
Map<Integer, Integer> map = EnchantmentHelper.getEnchantments(stack);
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
Enchantment enchantment = Enchantment.enchantmentsList[entry.getKey()];
Integer integer = entry.getValue();
ret += enchantment.getMinEnchantability(integer);
}
return ret;
}
/**
* Modified method from GrindstoneMenu, no damage and count setting
* Removed check for curses since they don't exist in this version
*/
private static ItemStack disenchantAndSplit(ItemStack stack) {
ItemStack newStack = stack.splitStack(1);
if (newStack.hasTagCompound()) {
NBTTagCompound tag = newStack.getTagCompound();
tag.removeTag("ench");
tag.removeTag("RepairCost");
if (tag.hasNoTags()) {
newStack.setTagCompound(null);
}
}
if (stack.getItem() == Items.enchanted_book) {
newStack = new ItemStack(Items.book);
if (stack.hasDisplayName()) {
newStack.setStackDisplayName(stack.getDisplayName());
}
}
return newStack;
}
@Override
@@ -3027,8 +3027,8 @@ botania.page.thermalily1=&o0108 Style&r.
# -- ROSA ARCANA
botania.entry.arcanerose=Rosa Arcana
botania.tagline.arcanerose=Mana from experience
botania.page.arcanerose0=&4Experience Points&0 are a form of magic of sorts. The &1Rosa Arcana&0 can tap into it and absorb the experience of players on the ground around it, turning it into &1Mana&0.<br>What the flower can not do, however, is absorb raw experience orbs from the floor. They must first be gathered by a player.
botania.page.arcanerose1=&oWhen this card is Summoned, toss a coin&r.
botania.page.arcanerose0=&4Experience Points&0 contain a magic of their own. The &1Rosa Arcana&0 can tap into this magic, absorbing the experience of nearby players and turning it into &4Mana&0.<br>It can also synthesize mana from experience orbs and enchanted items in the world.
botania.page.arcanerose1=&oWhen this flower is planted, toss a coin&r.
# -- MUNCHDEW
botania.entry.munchdew=Munchdew
@@ -2006,8 +2006,8 @@ botania.page.thermalily1=&o0108 Style&r.
# -- ROSA ARCANA
botania.entry.arcanerose=Rosa Arcana
botania.page.arcanerose0=&4Experience Points&0 are a form of magic of sorts. The &1Rosa Arcana&0 can tap into it and absorb the experience of players on the ground around it, turning it into &1Mana&0.
botania.page.arcanerose1=&oWhen this card is Summoned, toss a coin&r.
botania.page.arcanerose0="Les &4orbes d'expérience&0 sont magiques elles aussi. La &1rosa arcana$(&0 se sert de cette magie pour la convertir en &1mana&0.<br>Les objets enchantés peuvent également être transformés en &1mana&0.",
botania.page.arcanerose1=&orosae, rosas, rosarum&r.
# -- MUNCHDEW
botania.entry.munchdew=Munchdew
@@ -2544,8 +2544,8 @@ botania.page.thermalily1=&o0108 Style&r.
# -- ROSA ARCANA
botania.entry.arcanerose=Rosa Arcana
botania.tagline.arcanerose=Mana pela experiência
botania.page.arcanerose0=&4Pontos de Experiência&0 são uma forma de magia. A &1Rosa Arcana&0 pode aproveitar isso, absorvendo a experiência de jogadores ao redor dela, produzindo &1Mana&0.<br>A flor não consegue coletar orbes do chão, o jogador deve pegá-las antes.
botania.page.arcanerose1=&oQuando essa carta é ativada, jogue uma moeda&r.
botania.page.arcanerose0=&4Pontos de Experiência&0 possuem uma certa magia neles. A &1Rosa Arcana&0 pode fazer uso dessa magia, absorvendo a experiência de jogadores próximos e convertendo ela em &1Mana&0.$<br>Ela pode também sintetizar mana a partir de orbes de experiência e itens encantados no mundo.
botania.page.arcanerose1=&oQuando essa flor é plantada, jogue uma moeda&r.
# -- MUNCHDEW
botania.entry.munchdew=Munchdew
@@ -1247,7 +1247,7 @@ tile.botania:flower.nightshadePrime.name=Ночное начало
tile.botania:flower.nightshadePrime.reference=Вы не должны держать это
tile.botania:flower.nightshadeDecor.name=Декоративный Паслён
tile.botania:flower.nightshadeDecor.reference=Призрачная подпись
tile.botania:flower.arcanerose.name=Тайная роза
tile.botania:flower.arcanerose.name=Роза тайн
tile.botania:flower.arcanerose.reference=e=mc2
tile.botania:flower.munchdew.name=Жвачник крапчатый
tile.botania:flower.munchdew.reference=Ом-ном-ном
@@ -2557,10 +2557,10 @@ botania.page.thermalily3=Размещение &1Лавы&0 в мире, безу
botania.page.thermalily1=&oОн мог бы съесть и солнце.
# -- ROSA ARCANA
botania.entry.arcanerose=Тайная роза
botania.entry.arcanerose=Роза тайн
botania.tagline.arcanerose=Мана из опыта
botania.page.arcanerose0=&4Очки опыта&0 - это своего рода форма магии. &1Тайная роза&0 может высасывать опыт из игроков находящихся рядом с цветком, превращая его в &1ману&0. Но этот цветок не может поглощать сферы опыта.
botania.page.arcanerose1=&oОсторожно! Этот цветок может стать умнее вас...
botania.page.arcanerose0=&4Очки опыта&0 — это своего рода форма магии. &1Роза тайн&0 может взаимодействовать с этой магией и поглощать опыт игроков поблизости, превращая его в &1ману&0.<br>Она также может синтезировать &1ману&0 из выпавших сфер опыта и зачарованных предметов.
botania.page.arcanerose1=&oОсторожно! Этот цветок может стать умнее вас&r...
# -- MUNCHDEW
botania.entry.munchdew=Жвачник крапчатый
@@ -2562,8 +2562,8 @@ botania.page.thermalily1=&o0108款&r.
# -- ROSA ARCANA
botania.entry.arcanerose=阿卡纳蔷薇
botania.tagline.arcanerose=经验当魔力使
botania.page.arcanerose0=&4经验点&0是一种形式的魔力. &1阿卡纳蔷薇&0能吸收附近玩家 的经验,并利用它产生&1魔力&0.
botania.page.arcanerose1=&o该卡被召唤时,投掷硬币&r.
botania.page.arcanerose0="&4经验点&0是一种形式的魔力.&1阿卡纳蔷薇&0能吸收附近玩家的经验,并利用它产生&1魔力&0。<br>它也可以吸收世界中掉落的经验球或利用附魔物品来产生魔力"
botania.page.arcanerose1=&o该花被种植时,投掷一枚硬币&r.
# -- MUNCHDEW
botania.entry.munchdew=咀叶花
@@ -2551,8 +2551,8 @@ botania.page.thermalily1=&o0108 Style&r.
# -- ROSA ARCANA
botania.entry.arcanerose=阿卡納薔薇
botania.tagline.arcanerose=經驗化作魔力
botania.page.arcanerose0=&4經驗球&0是一種形式的瑪那. &1阿卡納薔薇&0能吸收附近玩家 的經驗,並利用它產生&1瑪那&0. <br>花不能從地面吸取經驗珠。他們必須由玩家來收集。
botania.page.arcanerose1=&o該卡被召喚時,投擲硬幣&r.
botania.page.arcanerose0=&4經驗點&0是一種形式的瑪那。&1阿卡納薔薇&0能吸收附近玩家的經驗,並利用它產生&1瑪那&0。<br>它也可以吸收世界中掉落的經驗球或利用附魔物品來產生瑪那
botania.page.arcanerose1=&o該花被種植時,投擲一枚硬幣&r.
# -- MUNCHDEW
botania.entry.munchdew=咀葉花