use of net.minecraftforge.eventbus.api.SubscribeEvent in project MinecraftForge by MinecraftForge.
the class ForgeInternalHandler method onEntityJoinWorld.
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityJoinWorld(EntityJoinWorldEvent event) {
Entity entity = event.getEntity();
if (entity.getClass().equals(ItemEntity.class)) {
ItemStack stack = ((ItemEntity) entity).getItem();
Item item = stack.getItem();
if (item.hasCustomEntity(stack)) {
Entity newEntity = item.createEntity(event.getWorld(), entity, stack);
if (newEntity != null) {
entity.discard();
event.setCanceled(true);
var executor = LogicalSidedProvider.WORKQUEUE.get(event.getWorld().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER);
executor.tell(new TickTask(0, () -> event.getWorld().addFreshEntity(newEntity)));
}
}
}
}
use of net.minecraftforge.eventbus.api.SubscribeEvent in project MinecraftForge by MinecraftForge.
the class ForgeInternalHandler method onResourceReload.
@SubscribeEvent
public void onResourceReload(AddReloadListenerEvent event) {
INSTANCE = new LootModifierManager();
event.addListener(INSTANCE);
}
use of net.minecraftforge.eventbus.api.SubscribeEvent in project MinecraftForge by MinecraftForge.
the class ModelDataManager method onChunkUnload.
@SubscribeEvent
public static void onChunkUnload(ChunkEvent.Unload event) {
if (!event.getChunk().getWorldForge().isClientSide())
return;
ChunkPos chunk = event.getChunk().getPos();
needModelDataRefresh.remove(chunk);
modelDataCache.remove(chunk);
}
use of net.minecraftforge.eventbus.api.SubscribeEvent in project Geolosys by oitsjustjose.
the class PlutonRegistry method onBiomesLoaded.
@SubscribeEvent
public void onBiomesLoaded(BiomeLoadingEvent evt) {
BiomeGenerationSettingsBuilder settings = evt.getGeneration();
// Removes vanilla ores
if (CommonConfig.REMOVE_VANILLA_ORES.get()) {
for (GenerationStage.Decoration deco : decorations) {
FeatureUtils.destroyFeature(settings.getFeatures(deco), OreRemover.filterFeatures(settings.getFeatures(deco)));
}
}
DepositFeature o = new DepositFeature(NoFeatureConfig.CODEC);
settings.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, o.withConfiguration(NoFeatureConfig.NO_FEATURE_CONFIG));
}
use of net.minecraftforge.eventbus.api.SubscribeEvent 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());
}
}
Aggregations