Search in sources :

Example 1 with BlockTransmutationContext

use of hellfirepvp.astralsorcery.common.crafting.recipe.BlockTransmutationContext in project AstralSorcery by HellFirePvP.

the class BlockTransmutationHandler method receiveStarlight.

@Override
public void receiveStarlight(World world, Random rand, BlockPos pos, BlockState state, IWeakConstellation starlightType, double amount) {
    BlockTransmutation recipe = RecipeTypesAS.TYPE_BLOCK_TRANSMUTATION.findRecipe(new BlockTransmutationContext(world, pos, state, starlightType));
    if (recipe == null) {
        // Wait what
        return;
    }
    WorldBlockPos at = WorldBlockPos.wrapServer(world, pos);
    ActiveTransmutation activeRecipe = runningTransmutations.get(at);
    if (activeRecipe == null || !activeRecipe.recipe.equals(recipe)) {
        activeRecipe = new ActiveTransmutation(recipe);
        runningTransmutations.put(at, activeRecipe);
    }
    activeRecipe.acceptStarlight(amount);
    PktPlayEffect pkt = new PktPlayEffect(PktPlayEffect.Type.BLOCK_TRANSMUTATION_TICK).addData(buf -> ByteBufUtils.writePos(buf, pos));
    PacketChannel.CHANNEL.sendToAllAround(pkt, PacketChannel.pointFromPos(world, pos, 24));
    if (activeRecipe.isFinished() && activeRecipe.finish(world, pos)) {
        runningTransmutations.remove(at);
    }
}
Also used : WorldBlockPos(hellfirepvp.astralsorcery.common.util.block.WorldBlockPos) BlockTransmutationContext(hellfirepvp.astralsorcery.common.crafting.recipe.BlockTransmutationContext) PktPlayEffect(hellfirepvp.astralsorcery.common.network.play.server.PktPlayEffect) BlockTransmutation(hellfirepvp.astralsorcery.common.crafting.recipe.BlockTransmutation)

Aggregations

BlockTransmutation (hellfirepvp.astralsorcery.common.crafting.recipe.BlockTransmutation)1 BlockTransmutationContext (hellfirepvp.astralsorcery.common.crafting.recipe.BlockTransmutationContext)1 PktPlayEffect (hellfirepvp.astralsorcery.common.network.play.server.PktPlayEffect)1 WorldBlockPos (hellfirepvp.astralsorcery.common.util.block.WorldBlockPos)1