2016-05-31 23:43:11 +00:00
|
|
|
package WayofTime.bloodmagic.compat.waila.provider;
|
|
|
|
|
2018-06-29 04:56:25 +00:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
2018-02-16 02:49:01 +00:00
|
|
|
import WayofTime.bloodmagic.util.Constants;
|
2018-03-04 17:17:23 +00:00
|
|
|
import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitual;
|
2018-02-16 02:49:01 +00:00
|
|
|
import WayofTime.bloodmagic.util.helper.PlayerHelper;
|
2016-05-31 23:43:11 +00:00
|
|
|
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
|
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
2017-08-16 04:30:48 +00:00
|
|
|
import mcp.mobius.waila.api.IWailaConfigHandler;
|
|
|
|
import mcp.mobius.waila.api.IWailaDataAccessor;
|
|
|
|
import mcp.mobius.waila.api.IWailaDataProvider;
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2018-02-09 03:01:12 +00:00
|
|
|
import javax.annotation.Nonnull;
|
2017-08-16 04:30:48 +00:00
|
|
|
import java.util.List;
|
2016-05-31 23:43:11 +00:00
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
public class DataProviderRitualController implements IWailaDataProvider {
|
2016-05-31 23:43:11 +00:00
|
|
|
|
2018-02-09 03:01:12 +00:00
|
|
|
public static final IWailaDataProvider INSTANCE = new DataProviderRitualController();
|
2016-05-31 23:43:11 +00:00
|
|
|
|
2018-02-09 03:01:12 +00:00
|
|
|
@Nonnull
|
2016-05-31 23:43:11 +00:00
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
|
2016-05-31 23:43:11 +00:00
|
|
|
if (!config.getConfig(Constants.Compat.WAILA_CONFIG_RITUAL))
|
|
|
|
return currenttip;
|
|
|
|
|
2018-02-09 03:01:12 +00:00
|
|
|
NBTTagCompound tag = accessor.getNBTData();
|
|
|
|
if (tag.getBoolean("master")) {
|
2018-04-08 19:55:23 +00:00
|
|
|
if (tag.hasKey("ritual")) {
|
2018-02-09 03:01:12 +00:00
|
|
|
currenttip.add(TextHelper.localizeEffect(tag.getString("ritual")));
|
2018-04-08 19:55:23 +00:00
|
|
|
if (tag.hasKey("owner"))
|
|
|
|
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentOwner", tag.getString("owner")));
|
|
|
|
if (!tag.getBoolean("active"))
|
|
|
|
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.deactivated"));
|
|
|
|
if (!tag.getBoolean("enabled"))
|
|
|
|
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.config.disabled"));
|
|
|
|
}
|
2017-08-16 04:30:48 +00:00
|
|
|
} else {
|
2018-02-09 03:01:12 +00:00
|
|
|
if (tag.hasKey("ritual")) {
|
|
|
|
currenttip.add(TextHelper.localizeEffect(tag.getString("ritual")));
|
|
|
|
if (!tag.getBoolean("enabled"))
|
|
|
|
currenttip.add(TextHelper.localizeEffect("tooltip.bloodmagic.config.disabled"));
|
|
|
|
}
|
2016-05-31 23:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return currenttip;
|
|
|
|
}
|
|
|
|
|
2018-02-09 03:01:12 +00:00
|
|
|
@Nonnull
|
2016-05-31 23:43:11 +00:00
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
|
2018-02-09 03:01:12 +00:00
|
|
|
|
|
|
|
if (te instanceof TileMasterRitualStone) {
|
|
|
|
TileMasterRitualStone mrs = (TileMasterRitualStone) te;
|
|
|
|
tag.setBoolean("master", true);
|
|
|
|
if (mrs.getCurrentRitual() != null) {
|
2019-02-01 03:10:37 +00:00
|
|
|
tag.setString("ritual", mrs.getCurrentRitual().getTranslationKey());
|
2018-02-09 03:01:12 +00:00
|
|
|
tag.setBoolean("active", mrs.isActive());
|
2018-02-28 00:59:51 +00:00
|
|
|
if (mrs.getOwner() != null)
|
2018-02-09 03:01:12 +00:00
|
|
|
tag.setString("owner", PlayerHelper.getUsernameFromUUID(mrs.getOwner()));
|
2018-06-29 04:56:25 +00:00
|
|
|
tag.setBoolean("enabled", BloodMagic.RITUAL_MANAGER.enabled(BloodMagic.RITUAL_MANAGER.getId(mrs.getCurrentRitual()), false));
|
2018-02-09 03:01:12 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tag.setBoolean("master", false);
|
|
|
|
|
2018-06-29 04:56:25 +00:00
|
|
|
ImperfectRitual ritual = BloodMagic.RITUAL_MANAGER.getImperfectRitual(world.getBlockState(pos.up()));
|
2018-02-09 03:01:12 +00:00
|
|
|
if (ritual != null) {
|
2019-02-01 03:10:37 +00:00
|
|
|
tag.setString("ritual", ritual.getTranslationKey());
|
2018-06-29 04:56:25 +00:00
|
|
|
tag.setBoolean("enabled", BloodMagic.RITUAL_MANAGER.enabled(BloodMagic.RITUAL_MANAGER.getId(ritual), false));
|
2018-02-09 03:01:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return tag;
|
2016-05-31 23:43:11 +00:00
|
|
|
}
|
|
|
|
}
|