Search in sources :

Example 86 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project MC-Prefab by Brian-Wuest.

the class ModEventHandler method onPlayerLoginEvent.

/**
 * This event occurs when a player logs in. This is used to send server configuration to the client.
 *
 * @param event The event object.
 */
@SubscribeEvent
public static void onPlayerLoginEvent(PlayerLoggedInEvent event) {
    if (!event.getPlayer().level.isClientSide) {
        CompoundTag tag = CommonProxy.proxyConfiguration.serverConfiguration.ToNBTTagCompound();
        Prefab.network.sendTo(new ConfigSyncMessage(tag), ((ServerPlayer) event.getPlayer()).connection.connection, NetworkDirection.PLAY_TO_CLIENT);
        Prefab.LOGGER.info("Sent config to '" + event.getPlayer().getDisplayName().getString() + "'.");
    }
}
Also used : ConfigSyncMessage(com.wuest.prefab.proxy.messages.ConfigSyncMessage) ServerPlayer(net.minecraft.server.level.ServerPlayer) CompoundTag(net.minecraft.nbt.CompoundTag) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 87 with SubscribeEvent

use of net.minecraftforge.eventbus.api.SubscribeEvent in project Ceramics by KnightMiner.

the class ClientEvents method setupClient.

@SubscribeEvent
static void setupClient(FMLClientSetupEvent event) {
    RenderType cutout = RenderType.getCutout();
    RenderTypeLookup.setRenderLayer(Registration.TERRACOTTA_GAUGE.get(), cutout);
    RenderTypeLookup.setRenderLayer(Registration.PORCELAIN_GAUGE.get(), cutout);
    RenderTypeLookup.setRenderLayer(Registration.TERRACOTTA_CISTERN.get(), cutout);
    Registration.COLORED_CISTERN.forEach(cistern -> RenderTypeLookup.setRenderLayer(cistern, cutout));
    RenderTypeLookup.setRenderLayer(Registration.TERRACOTTA_FAUCET.get(), cutout);
    RenderTypeLookup.setRenderLayer(Registration.TERRACOTTA_CHANNEL.get(), cutout);
    ScreenManager.registerFactory(Registration.KILN_CONTAINER.get(), KilnScreen::new);
    ClientRegistry.bindTileEntityRenderer(Registration.CISTERN_TILE_ENTITY.get(), CisternTileEntityRenderer::new);
    ClientRegistry.bindTileEntityRenderer(Registration.FAUCET_TILE_ENTITY.get(), FaucetTileEntityRenderer::new);
    ClientRegistry.bindTileEntityRenderer(Registration.CHANNEL_TILE_ENTITY.get(), ChannelTileEntityRenderer::new);
}
Also used : KilnScreen(knightminer.ceramics.client.gui.KilnScreen) CisternTileEntityRenderer(knightminer.ceramics.client.renderer.CisternTileEntityRenderer) FaucetTileEntityRenderer(knightminer.ceramics.client.renderer.FaucetTileEntityRenderer) ChannelTileEntityRenderer(knightminer.ceramics.client.renderer.ChannelTileEntityRenderer) RenderType(net.minecraft.client.renderer.RenderType) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)87 PlayerEntity (net.minecraft.entity.player.PlayerEntity)18 ItemStack (net.minecraft.item.ItemStack)17 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)11 ResourceLocation (net.minecraft.util.ResourceLocation)10 World (net.minecraft.world.World)8 Player (net.minecraft.world.entity.player.Player)8 BlockPos (net.minecraft.util.math.BlockPos)7 Entity (net.minecraft.world.entity.Entity)7 ItemStack (net.minecraft.world.item.ItemStack)7 CompoundNBT (net.minecraft.nbt.CompoundNBT)6 Minecraft (net.minecraft.client.Minecraft)5 BlockPos (net.minecraft.core.BlockPos)5 ServerPlayer (net.minecraft.server.level.ServerPlayer)5 StringTextComponent (net.minecraft.util.text.StringTextComponent)5 Item (net.minecraft.world.item.Item)5 BlockItem (net.minecraft.item.BlockItem)4 ResourceLocation (net.minecraft.resources.ResourceLocation)4 BlockState (net.minecraft.world.level.block.state.BlockState)4 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)4