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);
}
}
Aggregations