当前位置: 首页>>代码示例>>Java>>正文


Java SubscribeEvent类代码示例

本文整理汇总了Java中net.minecraftforge.fml.common.eventhandler.SubscribeEvent的典型用法代码示例。如果您正苦于以下问题:Java SubscribeEvent类的具体用法?Java SubscribeEvent怎么用?Java SubscribeEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SubscribeEvent类属于net.minecraftforge.fml.common.eventhandler包,在下文中一共展示了SubscribeEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleHearingSounds

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void handleHearingSounds(PlaySoundEvent event) {
	EntityPlayer p = Minecraft.getMinecraft().player;
	if (p != null)
	{
		Tuple<SoundType, Double> result = getTypeFromSound(event.getName(), event.getSound());
		if (p.getHeldItemMainhand().getItem() == this)
		{
			if (addSound(p.getHeldItemMainhand(), result.getFirst(), result.getSecond())){
				PacketHandler.INSTANCE.sendToServer(new MessageCompositionUpdate(p.getUniqueID(),p.getHeldItemMainhand().getTagCompound(),true));
			}
		} else if (p.getHeldItemOffhand().getItem() == this) {
			if (addSound(p.getHeldItemOffhand(), result.getFirst(), result.getSecond())){
				PacketHandler.INSTANCE.sendToServer(new MessageCompositionUpdate(p.getUniqueID(),p.getHeldItemOffhand().getTagCompound(),false));
			}
		}
	}
}
 
开发者ID:TeamMelodium,项目名称:Melodium,代码行数:20,代码来源:ItemCompositionPaper.java

示例2: onRenderOverlayText

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void onRenderOverlayText(RenderGameOverlayEvent.Text event)
{
	ScaledResolution sr = event.getResolution();
	EntityPlayer player = Minecraft.getMinecraft().player;
	Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);
	
	if (!player.capabilities.isCreativeMode && statsCap != null)
	{
		String mana = statsCap.getMana() + " / " + statsCap.getMaxMana();
		
		GL11.glPushMatrix();
		GL11.glScalef(0.5F, 0.5F, 0.5F);
		Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(mana, (sr.getScaledWidth() / 2 + 37) * 2, (sr.getScaledHeight() - 37) * 2, 0xFFFFFF);
		GL11.glPopMatrix();
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:18,代码来源:GuiMana.java

示例3: itemRegistry

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public static void itemRegistry(RegistryEvent.Register<Item> e) {
	IForgeRegistry<Item> reg = e.getRegistry();
	registerItemBlock(reg, ModItems.compressor);
	registerItemBlock(reg, ModItems.defier);
	registerItemBlock(reg, ModItems.patternmolder);
	registerItemBlock(reg, ModItems.energyprovider);

	reg.register(new DefierItem("largemass"));
	reg.register(new DefierItem("defiercore"));
	reg.register(new DefierItem("defierstar"));
	reg.register(new EnergyStarItem());
	reg.register(new DefierItem("strongstar"));
	reg.register(new DefierItem("speedstar"));
	reg.register(new PatternItem());
}
 
开发者ID:tiffit,项目名称:Defier,代码行数:17,代码来源:CommonProxy.java

示例4: onRenderTick

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent ev)
{
    purgeExpiredFragments(null);
    if (Minecraft.getMinecraft().currentScreen != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu))
        return;

    int displayWidth = Minecraft.getMinecraft().displayWidth;
    int displayHeight = Minecraft.getMinecraft().displayHeight;
    ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft(), displayWidth, displayHeight);
    int width = res.getScaledWidth();
    int height = res.getScaledHeight();
    float rx = (float) width / 1000f;
    float ry = (float) height / 1000f;

    synchronized(this.fragments)
    {
        for (TextCategory cat : TextCategory.values())
        {
            TextCategoryAttributes atts = this.attributes.get(cat);
            if (atts != null && (!atts.flashing || ((System.currentTimeMillis() / 500) % 3 != 0)) && shouldDisplay(atts.displayLevel))
            {
                int x = Math.round(rx * (float) atts.xOrg);
                int y = Math.round(ry * (float) atts.yOrg);
                ArrayList<TextFragment> frags = this.fragments.get(cat);
                if (frags != null && !frags.isEmpty())
                {
                    for (TextFragment frag : frags)
                    {
                        drawText(frag.text, x, y, atts.colour);
                        y += 10;
                    }
                }
            }
        }
    }
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:38,代码来源:ScreenHelper.java

示例5: onTickPlayerTick

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void onTickPlayerTick(TickEvent.PlayerTickEvent event)
{
    if (event.side.isClient() || event.phase != TickEvent.Phase.START || !hasPermission(event.player)) return;
    int count = event.player.getEntityData().getInteger(NBT_COUNTER);
    if (count <= 0) return;
    event.player.getEntityData().setInteger(NBT_COUNTER, count - 1);
    Data data = ServerHelper.getData();
    if (data != null)
    {
        try
        {
            DebugServerInfo.getSnw().sendTo(data, (EntityPlayerMP) event.player);
        }
        catch (Exception e)
        {
            getLogger().info("Caught error in sendTo. {} ({})", e.getMessage(), e.getClass().getName());
        }
    }
}
 
开发者ID:dries007,项目名称:DebugServerInfo,代码行数:21,代码来源:ServerHelper.java

示例6: onLootTableLoad

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void onLootTableLoad(LootTableLoadEvent event) {
    if (ConfigHandler.general.enableDungeonLoot) {
        String prefix = "minecraft:chests/";
        String name = event.getName().toString();
        if (name.startsWith(prefix)) {
            String file = name.substring(name.indexOf(prefix) + prefix.length());
            switch (file) {
                case "abandoned_mineshaft":
                case "desert_pyramid":
                case "jungle_temple":
                case "simple_dungeon":
                case "spawn_bonus_chest":
                case "stronghold_corridor":
                case "village_blacksmith":
                    LootEntry entry = new LootEntryTable(RL("inject/simple_dungeon_loot"), 1, 0,  new LootCondition[0], "pneumaticcraft_inject_entry");
                    LootPool pool = new LootPool(new LootEntry[]{entry}, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "pneumaticcraft_inject_pool");
                    event.getTable().addPool(pool);
                    break;
                default:
                    break;
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:26,代码来源:EventHandlerPneumaticCraft.java

示例7: onItemCrafted

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent event)
{
	if (event.player.worldObj.isRemote) { return; }	// Server side only

	if (event.crafting.getItem() instanceof LeaderRequiredItem)	// Only leaders can craft this item
	{
		if (TerritoryHandler.getFactionPlayerIsLeaderOf(event.player) == null)
		{
			Main.console("Item is leader-only, but the player is not a leader. Removing the item.");
			event.crafting.stackSize = 0;	// Not having it

			//event.setCanceled(true);	// That event cannot be cancelled. How do I reliably stop the creation of this item? Setting the stack size itself seems to be delayed until the metadata changes,
										// or some time passes and a sync is started
			//TODO: Refund the items used?
		}
		// else, is leader of at least one faction. Checks out.
	}
}
 
开发者ID:Domochevsky,项目名称:minecraft-territorialdealings,代码行数:20,代码来源:EventListener.java

示例8: guiPostInit

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) {
	if (Minecraft.getMinecraft().player != null) {
		if ((event.getGui() instanceof GuiInventory || event.getGui() instanceof GuiContainerCreative || event.getGui() instanceof GuiWearables)
				&& !Minecraft.getMinecraft().player.getCapability(TF2weapons.INVENTORY_CAP, null).isEmpty()) {
			// GuiContainer gui = (GuiContainer) event.getGui();
			event.getButtonList().add(new GuiButton(97535627, event.getGui().width / 2 - 10, event.getGui().height / 2 + 95, 20, 20, "W"));
		}

		if (event.getGui() instanceof GuiMerchant)
			if (((GuiMerchant) event.getGui()).getMerchant().getDisplayName().getUnformattedText().equals(I18n.format("entity.hale.name"))) {
				event.getButtonList().add(new GuiButton(7578, event.getGui().width / 2 - 100, event.getGui().height / 2 - 110, 100, 20, "Change Team"));
				event.getButtonList().add(new GuiButton(7579, event.getGui().width / 2, event.getGui().height / 2 - 110, 100, 20, "Recover Lost Items"));
			}
		Minecraft.getMinecraft().player.getCapability(TF2weapons.WEAPONS_CAP, null).state &= 8;
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:18,代码来源:TF2EventsClient.java

示例9: craftItem

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void craftItem(net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent event) {
	ItemStack withPattern=ItemStack.EMPTY;
	ItemStack noPattern=ItemStack.EMPTY;
	for(int i=0; i<event.craftMatrix.getSizeInventory();i++){
		ItemStack stack=event.craftMatrix.getStackInSlot(i);
		if(!stack.isEmpty() && stack.getItem() instanceof ItemBanner){
			if(TileEntityBanner.getPatterns(stack)>0){
				withPattern=stack;
			}
			else{
				noPattern=stack;
			}
			if(!withPattern.isEmpty()&&!noPattern.isEmpty()){
				withPattern.shrink(1);
			}
		}
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:20,代码来源:TF2EventsCommon.java

示例10: checkPlayerNBT

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void checkPlayerNBT(PlayerEvent.Clone event) {
	
	if (!event.isWasDeath())
		return;
	
	EntityPlayer old = event.getOriginal();
	EntityPlayer player = event.getEntityPlayer();
	
	NBTTagCompound oldtag = old.getEntityData();
	NBTTagCompound tag = player.getEntityData();
	if (oldtag.hasKey(GrowthSteps.TAG_GROWTHSTAGES)) {
		tag.setTag(GrowthSteps.TAG_GROWTHSTAGES, oldtag.getTagList(GrowthSteps.TAG_GROWTHSTAGES, 10).copy());
	}
	if (oldtag.hasKey("hasSacrificed"))
		tag.setBoolean("hasSacrificed", oldtag.getBoolean("hasSacrificed"));
	if (oldtag.hasKey(SeedBehavior.TAG_ABSTRACT))
		tag.setInteger(SeedBehavior.TAG_ABSTRACT, oldtag.getInteger(SeedBehavior.TAG_ABSTRACT));
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:20,代码来源:UCEventHandlerServer.java

示例11: onPreRenderBlockLayer

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPreRenderBlockLayer(RenderBlockLayerEvent.Pre event) {
    if(!isInternalCall) {
        if (!event.getRenderLayer().equals(BlockRenderLayer.TRANSLUCENT)) {
            event.setCanceled(true);
        } else if (event.getRenderLayer().equals(BlockRenderLayer.TRANSLUCENT)) {
            isInternalCall = true;
            Entity renderEntity = MC.getRenderViewEntity();
            GlStateManager.disableAlpha();
            MC.renderGlobal.renderBlockLayer(BlockRenderLayer.SOLID, event.getPartialTicks(), 0, renderEntity);
            GlStateManager.enableAlpha();
            MC.renderGlobal.renderBlockLayer(BlockRenderLayer.CUTOUT_MIPPED, event.getPartialTicks(), 0, renderEntity);
            MC.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
            MC.renderGlobal.renderBlockLayer(BlockRenderLayer.CUTOUT, event.getPartialTicks(), 0, renderEntity);
            MC.getTextureManager().getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
            GlStateManager.disableAlpha();
            isInternalCall = false;
        }
    }
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:21,代码来源:XrayMod.java

示例12: lootTableLoaded

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void lootTableLoaded(LootTableLoadEvent event)
{
	ResourceLocation poolName = event.getName();

	String injectTablePath = "inject/" + poolName.getResourceDomain() + "/" + poolName.getResourcePath();

	if (!LootTableInjector.INJECTED_LOOT_TABLES.contains(injectTablePath))
	{
		return;
	}

	LootTable injectTable = event.getLootTableManager().getLootTableFromLocation(new ResourceLocation(BetterThanWeagles.MODID, injectTablePath));
	for (int i = 0; i < LootTableInjector.MAX_POOLS; i++)
	{
		LootPool pool = injectTable.getPool(String.format("inject%d", i));
		if (pool != null)
		{
			event.getTable().addPool(pool);
		}
	}
}
 
开发者ID:DarkMorford,项目名称:BetterThanWeagles,代码行数:23,代码来源:LootTableInjector.java

示例13: track

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void track(PlayerTickEvent event) {
    EntityPlayer player = event.player;
    
    Item heldItem = player.getHeldItemMainhand().getItem();
    if (!(heldItem instanceof ItemBlock)) {
        return;
    }    
    
    IBlockState heldBlockState = Block.getBlockFromItem(heldItem).getDefaultState();
    BlockPos basePos = player.getPosition().add(0, -1, 0);
    IBlockState baseState = player.getEntityWorld().getBlockState(basePos);
    
    if (heldBlockState.equals(baseState)) {
        return;
    }

    player.getEntityWorld().setBlockState(basePos, heldBlockState);
}
 
开发者ID:JustinSDK,项目名称:craftsman,代码行数:20,代码来源:Turtle.java

示例14: tick

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void tick(TickEvent.ClientTickEvent event) {
    clientTick++;
    ClientProxy.renderHelper.tick();

    inTick = true;
    synchronized (lock) {
        inTick = true;
        Iterator<Runnable> iterator = queuedRunnables.keySet().iterator();
        while (iterator.hasNext()) {
            Runnable r = iterator.next();
            Counter delay = queuedRunnables.get(r);
            delay.decrement();
            if(delay.value <= 0) {
                r.run();
                iterator.remove();
            }
        }
        inTick = false;
        for (Map.Entry<Runnable, Integer> waiting : waitingRunnables.entrySet()) {
            queuedRunnables.put(waiting.getKey(), new Counter(waiting.getValue()));
        }
    }
    waitingRunnables.clear();
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:26,代码来源:ClientScheduler.java

示例15: setUpgradeChance

import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; //导入依赖的package包/类
@SubscribeEvent
public void setUpgradeChance(AnvilRepairEvent event) {
	
	ItemStack output = event.getItemResult();
	EntityPlayer player = event.getEntityPlayer();
	if (output == null)
		return;
	if (player == null)
		return;
	
	if (player.worldObj.isRemote)
		return;
	
	if (output.getItem() instanceof IBookUpgradeable) {
		int upgradelevel = NBTUtils.getInt(output, ItemGeneric.TAG_UPGRADE, -1);
		if (upgradelevel == 10) {
			Random rand = new Random();
			if (rand.nextBoolean() == false && !player.worldObj.isRemote) {
				player.addChatMessage(new TextComponentString(TextFormatting.RED + "You attempt to refine this item, but it breaks.."));
				output.stackSize = 0;
			}
		}
	}
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:25,代码来源:UCEventHandlerServer.java


注:本文中的net.minecraftforge.fml.common.eventhandler.SubscribeEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。