use of hellfirepvp.astralsorcery.common.constellation.IMajorConstellation in project AstralSorcery by HellFirePvP.
the class ScreenJournalPerkTree method init.
@Override
protected void init() {
super.init();
if (this.expectReinit) {
this.expectReinit = false;
return;
}
this.guiOffsetX = guiLeft + 10;
this.guiOffsetY = guiTop + 10;
boolean shifted = false;
PlayerProgress progress = ResearchHelper.getClientProgress();
IMajorConstellation attunement = progress.getAttunedConstellation();
if (attunement != null) {
AbstractPerk root = PerkTree.PERK_TREE.getRootPerk(LogicalSide.CLIENT, attunement);
if (root != null) {
Point.Float shift = this.sizeHandler.evRelativePos(root.getOffset());
this.moveMouse(MathHelper.floor(shift.x), MathHelper.floor(shift.y));
shifted = true;
}
}
if (!shifted) {
this.moveMouse(MathHelper.floor(this.sizeHandler.getTotalWidth() / 2), MathHelper.floor(this.sizeHandler.getTotalHeight() / 2));
}
this.applyMovedMouseOffset();
}
use of hellfirepvp.astralsorcery.common.constellation.IMajorConstellation in project AstralSorcery by HellFirePvP.
the class PlayerProgress method load.
// Loading from flat-file, persistent data
public void load(CompoundNBT compound) {
knownConstellations.clear();
seenConstellations.clear();
researchProgression.clear();
storedConstellationPapers.clear();
attunedConstellation = null;
tierReached = ProgressionTier.DISCOVERY;
wasOnceAttuned = false;
tomeReceived = false;
usePerkAbilities = true;
if (compound.contains("seenConstellations")) {
ListNBT list = compound.getList("seenConstellations", Constants.NBT.TAG_STRING);
for (int i = 0; i < list.size(); i++) {
seenConstellations.add(new ResourceLocation(list.getString(i)));
}
}
if (compound.contains("constellations")) {
ListNBT list = compound.getList("constellations", Constants.NBT.TAG_STRING);
for (int i = 0; i < list.size(); i++) {
ResourceLocation s = new ResourceLocation(list.getString(i));
knownConstellations.add(s);
if (!seenConstellations.contains(s)) {
seenConstellations.add(s);
}
}
}
if (compound.contains("storedConstellationPapers")) {
ListNBT list = compound.getList("storedConstellationPapers", Constants.NBT.TAG_STRING);
for (int i = 0; i < list.size(); i++) {
ResourceLocation s = new ResourceLocation(list.getString(i));
storedConstellationPapers.add(s);
if (!seenConstellations.contains(s)) {
seenConstellations.add(s);
}
}
}
if (compound.contains("attuned")) {
String cst = compound.getString("attuned");
IConstellation c = ConstellationRegistry.getConstellation(new ResourceLocation(cst));
if (!(c instanceof IMajorConstellation)) {
AstralSorcery.log.warn("Failed to load attuned Constellation: " + cst + " - constellation doesn't exist or isn't major.");
} else {
attunedConstellation = (IMajorConstellation) c;
}
}
this.perkData.load(this, compound);
if (compound.contains("tierReached")) {
int tierOrdinal = compound.getInt("tierReached");
tierReached = MiscUtils.getEnumEntry(ProgressionTier.class, tierOrdinal);
}
if (compound.contains("research")) {
int[] research = compound.getIntArray("research");
for (int resOrdinal : research) {
researchProgression.add(MiscUtils.getEnumEntry(ResearchProgression.class, resOrdinal));
}
}
this.wasOnceAttuned = compound.getBoolean("wasAttuned");
if (!compound.contains("bookReceived")) {
// Legacy support for player progress files that do not have the tag yet.
this.tomeReceived = true;
} else {
this.tomeReceived = compound.getBoolean("bookReceived");
}
if (compound.contains("usePerkAbilities")) {
this.usePerkAbilities = compound.getBoolean("usePerkAbilities");
}
}
use of hellfirepvp.astralsorcery.common.constellation.IMajorConstellation in project AstralSorcery by HellFirePvP.
the class ItemShiftingStar method onItemUseFinish.
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
if (!worldIn.isRemote() && entityLiving instanceof ServerPlayerEntity) {
ServerPlayerEntity player = (ServerPlayerEntity) entityLiving;
IMajorConstellation cst = this.getBaseConstellation();
if (cst != null) {
PlayerProgress prog = ResearchHelper.getProgress(player, LogicalSide.SERVER);
if (!prog.isValid() || !prog.wasOnceAttuned() || !prog.hasConstellationDiscovered(cst)) {
return stack;
}
double perkExp = prog.getPerkData().getPerkExp();
if (ResearchManager.setAttunedConstellation(player, cst)) {
ResearchManager.setExp(player, MathHelper.lfloor(perkExp));
player.sendMessage(new TranslationTextComponent("astralsorcery.progress.switch.attunement").mergeStyle(TextFormatting.BLUE), Util.DUMMY_UUID);
SoundHelper.playSoundAround(SoundEvents.BLOCK_GLASS_BREAK, worldIn, entityLiving.getPosition(), 1F, 1F);
return ItemStack.EMPTY;
}
} else if (ResearchManager.setAttunedConstellation(player, null)) {
player.sendMessage(new TranslationTextComponent("astralsorcery.progress.remove.attunement").mergeStyle(TextFormatting.BLUE), Util.DUMMY_UUID);
SoundHelper.playSoundAround(SoundEvents.BLOCK_GLASS_BREAK, worldIn, entityLiving.getPosition(), 1F, 1F);
return ItemStack.EMPTY;
}
}
return stack;
}
use of hellfirepvp.astralsorcery.common.constellation.IMajorConstellation in project AstralSorcery by HellFirePvP.
the class CommandAttune method run.
@Override
public int run(CommandContext<CommandSource> context) throws CommandSyntaxException {
PlayerEntity player = (PlayerEntity) context.getArgument("player", EntitySelector.class).selectOne(context.getSource());
IMajorConstellation cst = (IMajorConstellation) context.getArgument("constellation", IConstellation.class);
if (ResearchManager.setAttunedConstellation(player, cst)) {
context.getSource().sendFeedback(new StringTextComponent("Success! Player has been attuned to ").append(cst.getConstellationName().mergeStyle(TextFormatting.BLUE)).mergeStyle(TextFormatting.GREEN), true);
} else {
context.getSource().sendFeedback(new StringTextComponent("Failed! Player specified doesn't seem to have the research progress necessary!").mergeStyle(TextFormatting.RED), true);
}
return 0;
}
use of hellfirepvp.astralsorcery.common.constellation.IMajorConstellation in project AstralSorcery by HellFirePvP.
the class ItemShiftingStar method playUseEffects.
@OnlyIn(Dist.CLIENT)
private void playUseEffects(LivingEntity player, int tick, int total) {
IMajorConstellation cst = this.getBaseConstellation();
if (cst == null) {
FXFacingParticle p = EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(Vector3.atEntityCorner(player).addY(player.getHeight() / 2)).setMotion(new Vector3(-0.1 + random.nextFloat() * 0.2, 0.01, -0.1 + random.nextFloat() * 0.2)).setScaleMultiplier(0.2F + random.nextFloat());
if (random.nextBoolean()) {
p.color(VFXColorFunction.WHITE);
}
} else {
float percCycle = (float) ((((float) (tick % total)) / ((float) total)) * 2 * Math.PI);
int parts = 5;
for (int i = 0; i < parts; i++) {
float angleSwirl = 75F;
Vector3 center = Vector3.atEntityCorner(player).addY(player.getHeight() / 2);
Vector3 v = Vector3.RotAxis.X_AXIS.clone();
float originalAngle = (((float) i) / ((float) parts)) * 360F;
double angle = originalAngle + (MathHelper.sin(percCycle) * angleSwirl);
v.rotate(-Math.toRadians(angle), Vector3.RotAxis.Y_AXIS).normalize().multiply(4);
Vector3 pos = center.clone().add(v);
Vector3 mot = center.clone().subtract(pos).normalize().multiply(0.1);
FXFacingParticle p = EffectHelper.of(EffectTemplatesAS.GENERIC_PARTICLE).spawn(pos).setScaleMultiplier(0.25F + random.nextFloat() * 0.4F).setMotion(mot).setMaxAge(50);
if (random.nextInt(4) == 0) {
p.color(VFXColorFunction.WHITE);
} else if (random.nextInt(3) == 0) {
p.color(VFXColorFunction.constant(cst.getConstellationColor().brighter()));
} else {
p.color(VFXColorFunction.constant(cst.getConstellationColor()));
}
}
}
}
Aggregations