Search in sources :

Example 1 with WorldFreezingRecipe

use of hellfirepvp.astralsorcery.common.crafting.nojson.freezing.WorldFreezingRecipe in project AstralSorcery by HellFirePvP.

the class CEffectFornax method playEffect.

@Override
public boolean playEffect(World world, BlockPos pos, ConstellationEffectProperties properties, @Nullable IMinorConstellation trait) {
    if (!(world instanceof ServerWorld)) {
        return false;
    }
    Consumer<ItemStack> dropResult = stack -> ItemUtils.dropItemNaturally(world, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5, stack);
    return this.peekNewPosition(world, pos, properties).mapLeft(newEntry -> {
        BlockPos at = newEntry.getPos();
        if (properties.isCorrupted()) {
            WorldFreezingRecipe freezingRecipe = WorldFreezingRegistry.INSTANCE.getRecipeFor(world, at);
            if (freezingRecipe != null) {
                freezingRecipe.doOutput(world, at, world.getBlockState(at), dropResult);
                return true;
            }
            sendConstellationPing(world, new Vector3(at).add(0.5, 0.5, 0.5));
            return false;
        }
        WorldMeltableRecipe meltRecipe = WorldMeltableRegistry.INSTANCE.getRecipeFor(world, at);
        if (meltRecipe != null) {
            meltRecipe.doOutput(world, at, world.getBlockState(at), dropResult);
            return true;
        }
        sendConstellationPing(world, new Vector3(at).add(0.5, 0.5, 0.5));
        return false;
    }).left().orElse(false);
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) TileRitualPedestal(hellfirepvp.astralsorcery.common.tile.TileRitualPedestal) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) ServerWorld(net.minecraft.world.server.ServerWorld) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) BlockPositionGenerator(hellfirepvp.astralsorcery.common.util.block.iterator.BlockPositionGenerator) WorldMeltableRegistry(hellfirepvp.astralsorcery.common.crafting.nojson.WorldMeltableRegistry) ForgeConfigSpec(net.minecraftforge.common.ForgeConfigSpec) IMinorConstellation(hellfirepvp.astralsorcery.common.constellation.IMinorConstellation) CompoundNBT(net.minecraft.nbt.CompoundNBT) ConstellationsAS(hellfirepvp.astralsorcery.common.lib.ConstellationsAS) WorldFreezingRegistry(hellfirepvp.astralsorcery.common.crafting.nojson.WorldFreezingRegistry) PlayerAffectionFlags(hellfirepvp.astralsorcery.common.event.PlayerAffectionFlags) Dist(net.minecraftforge.api.distmarker.Dist) ItemStack(net.minecraft.item.ItemStack) BlockRandomPositionGenerator(hellfirepvp.astralsorcery.common.util.block.iterator.BlockRandomPositionGenerator) ILocatable(hellfirepvp.astralsorcery.common.util.block.ILocatable) EffectTemplatesAS(hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS) MiscUtils(hellfirepvp.astralsorcery.common.util.MiscUtils) WorldFreezingRecipe(hellfirepvp.astralsorcery.common.crafting.nojson.freezing.WorldFreezingRecipe) ColorsAS(hellfirepvp.astralsorcery.common.lib.ColorsAS) Nonnull(javax.annotation.Nonnull) WorldMeltableRecipe(hellfirepvp.astralsorcery.common.crafting.nojson.meltable.WorldMeltableRecipe) Nullable(javax.annotation.Nullable) VFXAlphaFunction(hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) EffectHelper(hellfirepvp.astralsorcery.client.effect.handler.EffectHelper) ListEntries(hellfirepvp.astralsorcery.common.constellation.effect.base.ListEntries) java.awt(java.awt) Consumer(java.util.function.Consumer) VFXColorFunction(hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction) ItemUtils(hellfirepvp.astralsorcery.common.util.item.ItemUtils) ConstellationEffectProperties(hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties) CEffectAbstractList(hellfirepvp.astralsorcery.common.constellation.effect.base.CEffectAbstractList) WorldMeltableRecipe(hellfirepvp.astralsorcery.common.crafting.nojson.meltable.WorldMeltableRecipe) BlockPos(net.minecraft.util.math.BlockPos) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) ItemStack(net.minecraft.item.ItemStack) WorldFreezingRecipe(hellfirepvp.astralsorcery.common.crafting.nojson.freezing.WorldFreezingRecipe)

Aggregations

VFXAlphaFunction (hellfirepvp.astralsorcery.client.effect.function.VFXAlphaFunction)1 VFXColorFunction (hellfirepvp.astralsorcery.client.effect.function.VFXColorFunction)1 EffectHelper (hellfirepvp.astralsorcery.client.effect.handler.EffectHelper)1 EffectTemplatesAS (hellfirepvp.astralsorcery.client.lib.EffectTemplatesAS)1 IMinorConstellation (hellfirepvp.astralsorcery.common.constellation.IMinorConstellation)1 ConstellationEffectProperties (hellfirepvp.astralsorcery.common.constellation.effect.ConstellationEffectProperties)1 CEffectAbstractList (hellfirepvp.astralsorcery.common.constellation.effect.base.CEffectAbstractList)1 ListEntries (hellfirepvp.astralsorcery.common.constellation.effect.base.ListEntries)1 WorldFreezingRegistry (hellfirepvp.astralsorcery.common.crafting.nojson.WorldFreezingRegistry)1 WorldMeltableRegistry (hellfirepvp.astralsorcery.common.crafting.nojson.WorldMeltableRegistry)1 WorldFreezingRecipe (hellfirepvp.astralsorcery.common.crafting.nojson.freezing.WorldFreezingRecipe)1 WorldMeltableRecipe (hellfirepvp.astralsorcery.common.crafting.nojson.meltable.WorldMeltableRecipe)1 PlayerAffectionFlags (hellfirepvp.astralsorcery.common.event.PlayerAffectionFlags)1 ColorsAS (hellfirepvp.astralsorcery.common.lib.ColorsAS)1 ConstellationsAS (hellfirepvp.astralsorcery.common.lib.ConstellationsAS)1 TileRitualPedestal (hellfirepvp.astralsorcery.common.tile.TileRitualPedestal)1 MiscUtils (hellfirepvp.astralsorcery.common.util.MiscUtils)1 ILocatable (hellfirepvp.astralsorcery.common.util.block.ILocatable)1 BlockPositionGenerator (hellfirepvp.astralsorcery.common.util.block.iterator.BlockPositionGenerator)1 BlockRandomPositionGenerator (hellfirepvp.astralsorcery.common.util.block.iterator.BlockRandomPositionGenerator)1