Search in sources :

Example 1 with IDepositCapability

use of com.oitsjustjose.geolosys.common.world.capability.IDepositCapability in project Geolosys by oitsjustjose.

the class ManualGifting method onPlayerJoin.

@SubscribeEvent
public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) {
    if (!CommonConfig.GIVE_MANUAL_TO_NEW.get()) {
        return;
    }
    PlayerEntity player = event.getPlayer();
    IDepositCapability geolosysCap = event.getEntity().getEntityWorld().getCapability(GeolosysAPI.GEOLOSYS_WORLD_CAPABILITY).orElse(null);
    if (geolosysCap == null) {
        return;
    }
    if (!geolosysCap.hasPlayerReceivedManual(player.getUniqueID())) {
        ItemHandlerHelper.giveItemToPlayer(player, PatchouliAPI.get().getBookStack(new ResourceLocation(Constants.MODID, "field_manual")));
        geolosysCap.setPlayerReceivedManual(player.getUniqueID());
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) IDepositCapability(com.oitsjustjose.geolosys.common.world.capability.IDepositCapability) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with IDepositCapability

use of com.oitsjustjose.geolosys.common.world.capability.IDepositCapability in project Geolosys by oitsjustjose.

the class DepositFeature method generate.

@Override
@ParametersAreNonnullByDefault
public boolean generate(ISeedReader reader, ChunkGenerator generator, Random rand, BlockPos pos, NoFeatureConfig config) {
    if (generator instanceof FlatChunkGenerator) {
        return false;
    }
    IDepositCapability cap = reader.getWorld().getCapability(GeolosysAPI.GEOLOSYS_WORLD_CAPABILITY).orElse(null);
    if (cap == null) {
        Geolosys.getInstance().LOGGER.error("NULL PLUTON CAPABILITY!!!");
        return false;
    }
    boolean placedPending = placePendingBlocks(reader, cap, pos);
    ChunkPos chunkPos = new ChunkPos(pos);
    if (cap.hasPlutonGenerated(chunkPos)) {
        return false;
    }
    IDeposit pluton = GeolosysAPI.plutonRegistry.pick(reader, pos, rand);
    if (pluton == null) {
        // Could be no pluton for the dimension
        return false;
    }
    if (rand.nextInt(CommonConfig.CHUNK_SKIP_CHANCE.get()) > pluton.getGenWt()) {
        return false;
    }
    boolean anyGenerated = pluton.generate(reader, pos, cap) > 0;
    if (anyGenerated) {
        pluton.afterGen(reader, pos, cap);
        cap.setPlutonGenerated(chunkPos);
        return true;
    }
    return placedPending;
}
Also used : IDeposit(com.oitsjustjose.geolosys.api.world.IDeposit) FlatChunkGenerator(net.minecraft.world.gen.FlatChunkGenerator) ChunkPos(net.minecraft.util.math.ChunkPos) IDepositCapability(com.oitsjustjose.geolosys.common.world.capability.IDepositCapability) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Aggregations

IDepositCapability (com.oitsjustjose.geolosys.common.world.capability.IDepositCapability)2 IDeposit (com.oitsjustjose.geolosys.api.world.IDeposit)1 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 ChunkPos (net.minecraft.util.math.ChunkPos)1 FlatChunkGenerator (net.minecraft.world.gen.FlatChunkGenerator)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1