use of ivorius.reccomplex.events.ItemGenerationEvent in project RecurrentComplex by Ivorforce.
the class RCForgeEventHandler method onItemGeneration.
@SubscribeEvent
public void onItemGeneration(ItemGenerationEvent event) {
Pair<String, Float> pair = null;
if (event instanceof ItemGenerationEvent.Artifact)
pair = RCConfig.customArtifactTag;
else if (event instanceof ItemGenerationEvent.Book)
pair = RCConfig.customBookTag;
if (pair != null && pair.getRight() > 0.0f && event.random.nextFloat() < pair.getRight()) {
WeightedItemCollection weightedItemCollection = WeightedItemCollectionRegistry.INSTANCE.get(pair.getLeft());
if (weightedItemCollection != null)
event.inventory.setInventorySlotContents(event.fromSlot, weightedItemCollection.getRandomItemStack(event.server, event.random));
event.setCanceled(true);
}
}
Aggregations