當前位置: 首頁>>代碼示例>>Java>>正文


Java EventPriority類代碼示例

本文整理匯總了Java中net.minecraftforge.fml.common.eventhandler.EventPriority的典型用法代碼示例。如果您正苦於以下問題:Java EventPriority類的具體用法?Java EventPriority怎麽用?Java EventPriority使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EventPriority類屬於net.minecraftforge.fml.common.eventhandler包,在下文中一共展示了EventPriority類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onLivingAttack

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onLivingAttack(LivingAttackEvent event)
{
	/*
	 * Player attacks a monster OR another player
	 */
	if (event.getSource().getTrueSource() instanceof EntityPlayer && !event.getSource().getTrueSource().getEntityWorld().isRemote)
	{
		EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
		EntityLivingBase enemy = event.getEntityLiving();
		ItemStack stack = player.inventory.getCurrentItem();
		PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
		
		if (playerInfo != null && stack != null && stack.getItem() instanceof ItemSword && !(stack.getItem() instanceof ItemLEAdvancedMelee))
		{
			NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
			
			if (playerInfo.getPlayerLevel() >= nbt.getInteger("Level"))
			{
				useWeaponAttributes(event.getAmount(), player, enemy, stack, nbt);
			}
		}
	}
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:25,代碼來源:EventLivingHurtAttack.java

示例2: onItemTooltip

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onItemTooltip(ItemTooltipEvent event)
{
	ArrayList<String> tooltip = (ArrayList<String>) event.getToolTip();
	ItemStack stack = event.getItemStack();
	NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
	
	if (event.getEntityPlayer() != null)
	{
		PlayerInformation info = (PlayerInformation) event.getEntityPlayer().getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
		
		if (info != null && (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemLEMagical || stack.getItem() instanceof ItemLEBauble))
		{
			Rarity rarity = Rarity.getRarity(nbt);
			
			if (rarity != Rarity.DEFAULT)
			{
				if (stack.getItem() instanceof ItemSword) drawMelee(tooltip, stack, nbt, event.getEntityPlayer(), info);
				else if (stack.getItem() instanceof ItemArmor) drawArmor(tooltip, stack, nbt, event.getEntityPlayer(), info);
				else if (stack.getItem() instanceof ItemLEMagical) drawMagical(tooltip, stack, nbt, event.getEntityPlayer(), info);
				else if (stack.getItem() instanceof ItemLEBauble) drawBauble(tooltip, stack, nbt, event.getEntityPlayer(), info);
			}
		}
	}
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:26,代碼來源:EventItemTooltip.java

示例3: onInitGuiPost

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onInitGuiPost(GuiScreenEvent.InitGuiEvent.Post event)
{
    if(!hasShownFirstGui)
    {
        hasShownFirstGui = true;

        //Add the layer renderers
        Render renderer = Minecraft.getMinecraft().getRenderManager().getEntityClassRenderObject(EntityLlama.class);
        if(renderer instanceof RenderLlama)
        {
            RenderLlama renderLlama = (RenderLlama)renderer;
            renderLlama.addLayer(new LayerFancyLlama(renderLlama));
        }
    }
}
 
開發者ID:iChun,項目名稱:BetterThanLlamas,代碼行數:17,代碼來源:BetterThanLlamas.java

示例4: placeKiln

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority=EventPriority.HIGH)
public void placeKiln(PlayerInteractEvent.RightClickBlock event){
	if(event.getWorld().getBlockState(event.getPos()).getBlock()==BlocksRegistry.potteryKiln){
		event.setUseBlock(Result.ALLOW);
	}else if(!event.isCanceled()&&event.getEntityPlayer().isSneaking()&&PotteryKilnRecipe.isValidInput(event.getItemStack())){
		if(event.getFace()==EnumFacing.UP&&event.getWorld().getBlockState(event.getPos()).isSideSolid(event.getWorld(), event.getPos(), EnumFacing.UP)&&
				event.getWorld().getBlockState(event.getPos().offset(EnumFacing.UP)).getBlock().isReplaceable(event.getWorld(), event.getPos().offset(EnumFacing.UP))){
			if(!event.getWorld().isRemote){
				event.getWorld().setBlockState(event.getPos().offset(EnumFacing.UP), BlocksRegistry.potteryKiln.getDefaultState());
				TilePotteryKiln tile=((TilePotteryKiln)event.getWorld().getTileEntity(event.getPos().offset(EnumFacing.UP)));
				event.getEntityPlayer().setHeldItem(event.getHand(), tile.pottery.insertItem(0, event.getItemStack(), false));
				event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_GRAVEL_PLACE, SoundCategory.BLOCKS, 1F, 1F);
				event.getWorld().notifyBlockUpdate(event.getPos().offset(EnumFacing.UP), BlocksRegistry.potteryKiln.getDefaultState(), BlocksRegistry.potteryKiln.getDefaultState(), 2);
			}
			event.setUseBlock(Result.DENY);
			event.setUseItem(Result.DENY);
		}
	}
}
 
開發者ID:EnderiumSmith,項目名稱:CharcoalPit,代碼行數:20,代碼來源:PileIgnitr.java

示例5: onEvent

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public static void onEvent(KeyInputEvent event) {
	Minecraft mc = Minecraft.getMinecraft();
	EntityPlayer player = mc.player;

	CartCapability entityData = player.getCapability(Currency.CART_DATA, null);

	boolean isEmpty = true;

	if (entityData != null && entityData.getCart() != null) {
		for (ItemStack stack : entityData.getCart()) {
			if (!stack.isEmpty()) {
				isEmpty = false;
			}
		}
	}

	if (!isEmpty && openList.isPressed()) {
		Minecraft.getMinecraft().player.openGui(Currency.INSTANCE, 5, mc.world, (int) player.posX, (int) player.posY, (int) player.posZ);
	}
}
 
開發者ID:Zundrel,項目名稱:Never-Enough-Currency,代碼行數:23,代碼來源:KeybindHandler.java

示例6: CommandEvents

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
  public void CommandEvents(CommandEvent evt) {
	
	if(Main.debug==1)System.out.println(evt.getSender().getName() + " called Command " + evt.getSender().toString());

	
	if(evt.getSender() instanceof EntityPlayer){
	if(!Main.logged.contains(evt.getSender().getName())){
		//System.out.println(evt.getCommand().getCommandName().toString());
		if(!evt.getCommand().getCommandName().toString().contains("login") && !evt.getCommand().getCommandName().toString().contains("register")){
		evt.setCanceled(true);
		if(Main.passwords.containsKey(evt.getSender().getName())){
			evt.getSender().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("loginmessage")));
		} else {
		evt.getSender().addChatMessage(new TextComponentString(TextFormatting.RED + (String)Main.config.get("registermessage")));
		}
		} 
	}
	}
}
 
開發者ID:Fungie2134,項目名稱:AuthMod,代碼行數:21,代碼來源:CommandEvents.java

示例7: PlayerLoggedOut

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
 public void PlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent evt) {

if(Main.debug==1)System.out.println(evt.player.getName() + " called PlayentLoggedOut");
MinecraftServer minecraftServer = FMLServerHandler.instance().getServer();
String brut = minecraftServer.getPlayerList().getPlayerByUsername(evt.player.getName()).connection.getNetworkManager().getRemoteAddress().toString().replaceAll("/", "");
int lenght = brut.length();
brut = brut.substring(0, lenght-6);


if(Integer.parseInt((String) Main.config.get("iplogin")) > 0 && !Main.ips.containsKey(brut) && Main.logged.contains(evt.player.getName())){
	Main.ips.put(brut, 0);
	}


Main.logged.remove(evt.player.getName());
Main.posX.remove(evt.player.getName());
Main.posY.remove(evt.player.getName());
Main.posZ.remove(evt.player.getName());
Main.time.remove(evt.player.getName());
}
 
開發者ID:Fungie2134,項目名稱:AuthMod,代碼行數:22,代碼來源:PlayerLoggedOut.java

示例8: onHeal

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW)
public static void onHeal(LivingHealEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    if (!entity.hasCapability(CapabilityExtendedHealthSystem.INSTANCE, null))
        return;
    event.setCanceled(true);
    if (!FirstAid.activeHealingConfig.allowOtherHealingItems)
        return;
    float amount = event.getAmount();
    //Hacky shit to reduce vanilla regen
    if (FirstAid.activeHealingConfig.allowNaturalRegeneration && Arrays.stream(Thread.currentThread().getStackTrace()).anyMatch(stackTraceElement -> stackTraceElement.getClassName().equals(FoodStats.class.getName())))
        amount = amount * (float) FirstAid.activeHealingConfig.naturalRegenMultiplier;
    else
        amount = amount * (float) FirstAid.activeHealingConfig.otherRegenMultiplier;
    HealthDistribution.distributeHealth(amount, (EntityPlayer) entity, true);
}
 
開發者ID:ichttt,項目名稱:FirstAid,代碼行數:17,代碼來源:EventHandler.java

示例9: onWitherBoneHarvestEvent

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onWitherBoneHarvestEvent(BlockEvent.HarvestDropsEvent event) {
	if (event.getHarvester() == null) {
		return;
	}

	EntityPlayer player = event.getHarvester();
	ItemStack stack = player.getHeldItemMainhand();

	boolean flag = false;

	if (stack.getItem() instanceof IHaftTool) {
		if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) {
			flag = true;
		}
	}

	if (flag) {
		if (player.dimension != DimensionType.NETHER.getId()) {
			stack.damageItem(7, player);
		}
	}
}
 
開發者ID:the-realest-stu,項目名稱:Adventurers-Toolbox,代碼行數:24,代碼來源:SpecialToolAbilityHandler.java

示例10: onGuiKeyboardEvent

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW)
public void onGuiKeyboardEvent(GuiScreenEvent.KeyboardInputEvent.Post event) {
	if (Keyboard.getEventKeyState()) {
		int eventKey = Keyboard.getEventKey();
		if (KeyBindings.TOGGLE.isActiveAndMatches(eventKey)) {
			Config.toggleEnabled();
			event.setCanceled(true);
		} else if (KeyBindings.ZOOM_IN.isActiveAndMatches(eventKey)) {
			Config.increaseZoom();
			event.setCanceled(true);
		} else if (KeyBindings.ZOOM_OUT.isActiveAndMatches(eventKey)) {
			Config.decreaseZoom();
			event.setCanceled(true);
		}
	}
}
 
開發者ID:mezz,項目名稱:ItemZoom,代碼行數:17,代碼來源:EventHandler.java

示例11: onItemStackTooltip

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW)
public void onItemStackTooltip(RenderTooltipEvent.Pre event) {
	if (!Config.isToggledEnabled() && !isEnableKeyHeld()) {
		return;
	}
	ItemStack itemStack = event.getStack();
	//noinspection ConstantConditions
	if (itemStack == null || itemStack.isEmpty()) {
		return;
	}
	if (Config.isJeiOnly() && !ItemStack.areItemStacksEqual(itemStack, JeiCompat.getStackUnderMouse())) {
		return;
	}

	Minecraft minecraft = Minecraft.getMinecraft();
	GuiScreen currentScreen = minecraft.currentScreen;
	if (currentScreen instanceof GuiContainer) {
		GuiContainer guiContainer = (GuiContainer) currentScreen;
		renderZoomedStack(itemStack, guiContainer, minecraft);
	}
}
 
開發者ID:mezz,項目名稱:ItemZoom,代碼行數:22,代碼來源:EventHandler.java

示例12: onTick

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW)
public void onTick(TickEvent.RenderTickEvent event) {
    if (TextDisplayerMod.getInstance().getWebsiteUtils().isDisabled()) return;

    boolean isClickedLeft = Mouse.isButtonDown(0);
    if (isClickedLeft != this.lastLeft) {
        this.lastLeft = isClickedLeft;
        if (isClickedLeft) {
            this.leftClicks.add(System.currentTimeMillis());
        }
    }

    boolean isClickedRight = Mouse.isButtonDown(1);
    if (isClickedRight != this.lastRight) {
        this.lastRight = isClickedRight;
        if (isClickedRight) {
            this.rightClicks.add(System.currentTimeMillis());
        }
    }
}
 
開發者ID:boomboompower,項目名稱:TextDisplayer,代碼行數:21,代碼來源:CPSParser.java

示例13: craftItem

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的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

示例14: onPlayerPearl

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerPearl(EnderTeleportEvent event)
{
    if ( !(event.getEntityLiving() instanceof EntityPlayerMP) )
        return;

    if ( Config.getKnockBack() == 0.0 || !Config.getDenyEnderpearl() )
        return;

    EntityPlayerMP player = (EntityPlayerMP) event.getEntityLiving();
    Log.trace( "Caught pearl teleport event by %s", player.getDisplayName() );

    Location target = new Location(event, player);
    Location newLoc = BorderCheck.checkPlayer(player, target, true, true);

    if (newLoc != null)
    {
        event.setCanceled(true);
        event.setTargetX(newLoc.posX);
        event.setTargetY(newLoc.posY);
        event.setTargetZ(newLoc.posZ);
    }
}
 
開發者ID:abused,項目名稱:World-Border,代碼行數:24,代碼來源:EnderPearlListener.java

示例15: onInitGuiPost

import net.minecraftforge.fml.common.eventhandler.EventPriority; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onInitGuiPost(GuiScreenEvent.InitGuiEvent.Post event)
{
    if(!hasShownFirstGui)
    {
        hasShownFirstGui = true;

        //Add the layer renderers
        Render renderer = Minecraft.getMinecraft().getRenderManager().getEntityClassRenderObject(EntityRabbit.class);
        if(renderer instanceof RenderRabbit)
        {
            RenderRabbit renderRabbit = (RenderRabbit)renderer;
            renderRabbit.addLayer(new LayerFancyBunny(renderRabbit));
        }
    }
}
 
開發者ID:iChun,項目名稱:Better-Than-Bunnies,代碼行數:17,代碼來源:BetterThanBunnies.java


注:本文中的net.minecraftforge.fml.common.eventhandler.EventPriority類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。