use of hellfirepvp.astralsorcery.common.tile.TileRitualPedestal in project AstralSorcery by HellFirePvP.
the class StarlightReceiverRitualPedestal method updateFromTileEntity.
@Override
public <T extends TileEntity> boolean updateFromTileEntity(T tile) {
if (!(tile instanceof TileRitualPedestal)) {
// Whatever.
return super.updateFromTileEntity(tile);
}
TileRitualPedestal trp = (TileRitualPedestal) tile;
if (this.channelingType != trp.getRitualConstellation() || (this.attributes != null && trp.getAttributes() == null) || this.hasMultiblock != trp.hasMultiblock()) {
this.effect = null;
this.offsetMirrors.clear();
if (trp.isWorking() || !trp.getMirrors().isEmpty()) {
this.markForTileSync();
}
}
boolean ritualLinkChanged;
if (this.ritualLinkPos == null) {
ritualLinkChanged = trp.getRitualLinkTo() != null;
} else {
ritualLinkChanged = !this.ritualLinkPos.equals(trp.getRitualLinkTo());
}
this.doesSeeSky = trp.doesSeeSky();
this.hasMultiblock = trp.hasMultiblock();
this.channelingType = trp.getRitualConstellation();
this.channelingTrait = trp.getRitualTrait();
this.attributes = trp.getAttributes();
this.ritualLinkPos = trp.getRitualLinkTo();
if (this.channelingType != null && this.attributes != null && this.hasMultiblock && (this.effect == null || ritualLinkChanged)) {
this.effect = ConstellationEffectRegistry.createInstance(this, this.channelingType);
this.markForTileSync();
}
if (!this.hasMultiblock || this.effect == null) {
this.collectedStarlight = 0;
}
this.markDirty(trp.getWorld());
return super.updateFromTileEntity(tile);
}
use of hellfirepvp.astralsorcery.common.tile.TileRitualPedestal in project AstralSorcery by HellFirePvP.
the class ConstellationEffect method getPedestal.
@Nullable
public TileRitualPedestal getPedestal(World world, BlockPos pos) {
TileEntity te = MiscUtils.getTileAt(world, pos, TileEntity.class, false);
if (te instanceof TileRitualLink) {
TileRitualLink link = (TileRitualLink) te;
pos = link.getLinkedTo();
if (pos != null) {
pos = pos.subtract(TileRitualPedestal.RITUAL_ANCHOR_OFFEST);
return MiscUtils.getTileAt(world, pos, TileRitualPedestal.class, false);
}
}
return te instanceof TileRitualPedestal ? (TileRitualPedestal) te : null;
}
use of hellfirepvp.astralsorcery.common.tile.TileRitualPedestal in project AstralSorcery by HellFirePvP.
the class RegistryCrystalProperties method initDefaultAttributes.
public static void initDefaultAttributes() {
SOURCE_RITUAL_PEDESTAL = new PropertySource<StarlightReceiverRitualPedestal, Ritual>(AstralSorcery.key("ritual_network")) {
@Override
public Ritual createInstance(StarlightReceiverRitualPedestal obj) {
return new Ritual(this, obj.getChannelingType(), obj.getChannelingTrait());
}
};
SOURCE_TILE_RITUAL_PEDESTAL = new PropertySource<TileRitualPedestal, Ritual>(AstralSorcery.key("ritual_tile")) {
@Override
public Ritual createInstance(TileRitualPedestal obj) {
return new Ritual(this, obj.getRitualConstellation(), obj.getRitualTrait());
}
};
SOURCE_COLLECTOR_CRYSTAL = new PropertySource<IndependentCrystalSource, Crystal>(AstralSorcery.key("crystal_network")) {
@Override
public Crystal createInstance(IndependentCrystalSource obj) {
return new Crystal(this, obj.getStarlightType());
}
};
SOURCE_TILE_COLLECTOR_CRYSTAL = new PropertySource<TileCollectorCrystal, Crystal>(AstralSorcery.key("crystal_tile")) {
@Override
public Crystal createInstance(TileCollectorCrystal obj) {
return new Crystal(this, obj.getAttunedConstellation());
}
};
CREATIVE_CRYSTAL_TOOL_ATTRIBUTES = CrystalAttributes.Builder.newBuilder(false).addProperty(PROPERTY_SIZE, 3).addProperty(PROPERTY_SHAPE, 3).addProperty(PROPERTY_TOOL_DURABILITY, 3).addProperty(PROPERTY_TOOL_EFFICIENCY, 3).build();
WORLDGEN_SHRINE_COLLECTOR_ATTRIBUTES = CrystalAttributes.Builder.newBuilder(false).addProperty(PROPERTY_SIZE, 2).addProperty(PROPERTY_SHAPE, 2).addProperty(PROPERTY_PURITY, 2).addProperty(PROPERTY_COLLECTOR_COLLECTION_RATE, 2).build();
CREATIVE_ROCK_COLLECTOR_ATTRIBUTES = CrystalAttributes.Builder.newBuilder(false).addProperty(PROPERTY_SIZE, 3).addProperty(PROPERTY_SHAPE, 3).addProperty(PROPERTY_PURITY, 2).addProperty(PROPERTY_COLLECTOR_COLLECTION_RATE, 3).build();
CREATIVE_CELESTIAL_COLLECTOR_ATTRIBUTES = CrystalAttributes.Builder.newBuilder(false).addProperty(PROPERTY_SIZE, 3).addProperty(PROPERTY_SHAPE, 3).addProperty(PROPERTY_PURITY, 2).addProperty(PROPERTY_COLLECTOR_COLLECTION_RATE, 3).build();
LENS_PRISM_CREATIVE_ATTRIBUTES = CrystalAttributes.Builder.newBuilder(false).addProperty(PROPERTY_PURITY, 2).addProperty(PROPERTY_SHAPE, 3).build();
}
use of hellfirepvp.astralsorcery.common.tile.TileRitualPedestal in project AstralSorcery by HellFirePvP.
the class BlockRitualPedestal method neighborChanged.
@Override
public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) {
super.neighborChanged(state, world, pos, block, fromPos, isMoving);
TileRitualPedestal te = MiscUtils.getTileAt(world, pos, TileRitualPedestal.class, true);
if (te != null && !world.isRemote()) {
BlockPos toCheck = pos.up();
BlockState other = world.getBlockState(toCheck);
if (Block.doesSideFillSquare(other.getCollisionShape(world, pos), Direction.DOWN)) {
ItemUtils.dropItem(world, pos.getX() + 0.5, pos.getY() + 0.8, pos.getZ() + 0.5, te.getCurrentCrystal());
te.tryPlaceCrystalInPedestal(ItemStack.EMPTY);
}
}
}
use of hellfirepvp.astralsorcery.common.tile.TileRitualPedestal in project AstralSorcery by HellFirePvP.
the class BlockRitualPedestal method onBlockActivated.
@Override
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rtr) {
if (world.isRemote()) {
return ActionResultType.SUCCESS;
}
TileRitualPedestal pedestal = MiscUtils.getTileAt(world, pos, TileRitualPedestal.class, true);
if (pedestal == null) {
return ActionResultType.PASS;
}
ItemStack heldItem = player.getHeldItem(hand);
ItemStack in = pedestal.getCurrentCrystal();
if (player.isSneaking()) {
pedestal.tryPlaceCrystalInPedestal(ItemStack.EMPTY);
if (player.getHeldItem(hand).isEmpty()) {
player.setHeldItem(hand, in);
} else {
player.inventory.placeItemBackInInventory(world, in);
}
} else {
player.setHeldItem(hand, pedestal.tryPlaceCrystalInPedestal(heldItem));
}
return ActionResultType.SUCCESS;
}
Aggregations