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