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


Java PlayerEvent.ItemCraftedEvent方法代碼示例

本文整理匯總了Java中cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerEvent.ItemCraftedEvent方法的具體用法?Java PlayerEvent.ItemCraftedEvent怎麽用?Java PlayerEvent.ItemCraftedEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cpw.mods.fml.common.gameevent.PlayerEvent的用法示例。


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

示例1: onCraft

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onCraft(PlayerEvent.ItemCraftedEvent event) {
	if (event.crafting != null) {
		ItemStack rod = null;
		ItemStack toTransmute = null;
		ItemStack transmuted = event.crafting;
		for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++)
			if (event.craftMatrix.getStackInSlot(i) != null)
				if (event.craftMatrix.getStackInSlot(i).getItem() instanceof ITransmutationItem) {
					rod = event.craftMatrix.getStackInSlot(i).copy();
				} else {
					if (toTransmute != null)
						return;
					toTransmute = event.craftMatrix.getStackInSlot(i);
				}
		if (rod != null && toTransmute != null && transmuted != null) {
			((ITransmutationItem)rod.getItem()).transmute(rod, toTransmute.getItem(), toTransmute.getItemDamage(), 
					transmuted.getItem(), transmuted.getItemDamage());
			event.player.inventory.addItemStackToInventory(rod);
			if (!event.player.getEntityWorld().isRemote)
				DartCraft2.NETWORK.sendToAll(new DartCraftEffectPacket(event.player.getEntityWorld(), (int) event.player.posX, (int) event.player.posY, (int) event.player.posZ));
		}
	}
}
 
開發者ID:austinv11,項目名稱:DartCraft2,代碼行數:25,代碼來源:TransmutationHandler.java

示例2: onCrafting

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onCrafting(PlayerEvent.ItemCraftedEvent event) {
	if(event.crafting != null) {
		Item item = event.crafting.getItem();
		if(item == LibVulpesItems.itemHoloProjector) 
			event.player.triggerAchievement(ARAchivements.holographic);
		else if(item == Item.getItemFromBlock(AdvancedRocketryBlocks.blockRollingMachine))
			event.player.triggerAchievement(ARAchivements.rollin);
		else if(item == Item.getItemFromBlock(AdvancedRocketryBlocks.blockCrystallizer))
			event.player.triggerAchievement(ARAchivements.crystalline);
		else if(item == Item.getItemFromBlock(AdvancedRocketryBlocks.blockLathe))
			event.player.triggerAchievement(ARAchivements.spinDoctor);
		else if(item ==Item.getItemFromBlock(AdvancedRocketryBlocks.blockElectrolyser))
			event.player.triggerAchievement(ARAchivements.electrifying);
		else if(item == Item.getItemFromBlock(AdvancedRocketryBlocks.blockArcFurnace))
			event.player.triggerAchievement(ARAchivements.feelTheHeat);
		else if(item == Item.getItemFromBlock(AdvancedRocketryBlocks.blockWarpCore))
			event.player.triggerAchievement(ARAchivements.warp);
		else if(item == Item.getItemFromBlock(AdvancedRocketryBlocks.blockPlatePress))
			event.player.triggerAchievement(ARAchivements.blockPresser);
	}
}
 
開發者ID:zmaster587,項目名稱:AdvancedRocketry,代碼行數:23,代碼來源:PlanetEventHandler.java

示例3: onPlayerItemCrafted

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onPlayerItemCrafted(PlayerEvent.ItemCraftedEvent event) {

    if (event.crafting.isItemEqual(new ItemStack(ModItems.ammo))) {
        for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) {
            ItemStack stack = event.craftMatrix.getStackInSlot(i);
            if (stack != null && stack.isItemStackDamageable()) {

                if (stack.getItemDamage() <= stack.getMaxDamage() - 1) {
                    stack.setItemDamage(stack.getItemDamage() + 1);
                    stack.stackSize++;
                } else {
                    event.craftMatrix.setInventorySlotContents(i, null);
                    MinecraftForge.EVENT_BUS
                            .post(new PlayerDestroyItemEvent(event.player,
                                    stack));
                }
            }
        }
    }
}
 
開發者ID:iTitus,項目名稱:MyMod,代碼行數:22,代碼來源:CraftingHandler.java

示例4: onCraft

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onCraft(PlayerEvent.ItemCraftedEvent event){
    ItemStack pickaxe = null;

    if(OreHelper.isItemThisOre(event.crafting, "dustTinyGem")){
        for(int slot = 0; slot < event.craftMatrix.getSizeInventory(); slot++){
            if(event.craftMatrix.getStackInSlot(slot) != null){
                ItemStack stack = event.craftMatrix.getStackInSlot(slot);
                if(stack.getItem().getHarvestLevel(stack, "pickaxe") >= 2){
                    if(stack.getItemDamage() < stack.getMaxDamage() - 7){
                        pickaxe = stack.copy();
                    }
                }
            }
        }
    }
    if(pickaxe != null){
        pickaxe.damageItem(5, event.player);
        if(!event.player.worldObj.isRemote) {
            MiscHelper.drop(event.player, pickaxe, 0);
        }
    }
}
 
開發者ID:goldenapple3,項目名稱:Marble,代碼行數:24,代碼來源:CraftingHandler.java

示例5: itemCraftedEvent

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void itemCraftedEvent(PlayerEvent.ItemCraftedEvent event) { //fired after pulling the item away
    GameRegistry.UniqueIdentifier identifier =  GameRegistry.findUniqueIdentifierFor(event.crafting.getItem());
    ExtendedPlayer playerData = ExtendedPlayer.get(event.player);
    for (String modId : playerData.disabledMods.keySet()){
        if (modId.toLowerCase().trim().equals(identifier.modId.toLowerCase().trim())){ //trims unnecessary?
            if (!playerData.disabledMods.get(modId)){
                if (!PlayerData.getBlacklistGroupDisabled(modId, event.player)){   //if mod group isn't disabled
                    PlayerData.disableGroupMods(modId, event.player);              //disable them
                    CommonProxy.saveProxyData(event.player);                       //save changes
                    NetworkingHandler.network.sendToServer(new UpdateCraftingMessage("updtCrftng")); //send message from client to server to update
                }
            }
        }
    }

}
 
開發者ID:gr8pefish,項目名稱:HardChoices,代碼行數:18,代碼來源:FMLEventHandler.java

示例6: onCraft

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
  public void onCraft(PlayerEvent.ItemCraftedEvent event)
  {
Item item = event.crafting.getItem();

if (item == ItemRegister.BLUE_STICK)
	event.player.triggerAchievement(AchievementList.NEW_ITEMS);
else if (item == ItemRegister.TITANIUM_CHESTPLATE || item == ItemRegister.TITANIUM_BOOTS || item == ItemRegister.TITANIUM_PANTS ||item == ItemRegister.TITANIUM_HELMET)
	event.player.triggerAchievement(AchievementList.TITANIUM_STUFF);
else if (item == ItemRegister.SILVER_PICKAXE)
	event.player.triggerAchievement(AchievementList.SILVER_PICKAXE);
else if (item == ItemRegister.ETHERNIUM_SWORD)
	event.player.triggerAchievement(AchievementList.ETHERNIUM_SWORD);
  }
 
開發者ID:GhostMonk3408,項目名稱:MidgarCrusade,代碼行數:15,代碼來源:JoueurEvent.java

示例7: onCrafting

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onCrafting(PlayerEvent.ItemCraftedEvent event)
{
    // TODO: Implement ItemSmeltingHandler (Achievement on Smelt ??)

    //if (event.crafting.getItem().equals(ModItems.testItem))
    //if (event.crafting.getItem().equals(Item.getItemFromBlock(ModBlocks.testBlock))

    //event.player.addStat(AchievementHandler.DEBUG, 1);
}
 
開發者ID:Kithio,項目名稱:Thallus,代碼行數:11,代碼來源:PlayerEventHandler.java

示例8: playerEvent_ItemCrafting

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void playerEvent_ItemCrafting(PlayerEvent.ItemCraftedEvent event)
{
    ItemsLogEvent log = new ItemsLogEvent();

    log.setType(TYPE_ITEM_CRAFTING);
    log.setPlayerPosAndUuid(event.player);
    log.setData(event.crafting);

    LoggingQueue.addToQueue(log);
}
 
開發者ID:DoubleDoorDevelopment,項目名稱:D3Log,代碼行數:12,代碼來源:FMLEventHandler.java

示例9: onCrafting

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onCrafting(PlayerEvent.ItemCraftedEvent event)
{	
	final int x = 1;
	final int y = Reference.chiselBreakTime;
	int rand = new Random().nextInt(y-x) + x;

	for(int i=0; i < event.craftMatrix.getSizeInventory(); i++) //Checks all the slots
	{               
		if(event.craftMatrix.getStackInSlot(i) != null) //If there is an item
		{
			
			ItemStack j = event.craftMatrix.getStackInSlot(i); //Gets the item
			
			if(j.getItem() != null && j.getItem() == ModItems.chisel && j.getItemDamage() == 0 && rand == 2)
			{
				ItemStack l = new ItemStack(ModItems.chisel, 2, 1);
				event.craftMatrix.setInventorySlotContents(i, l);
			}
			
			else if(j.getItem() != null && j.getItem() == ModItems.chisel && j.getItemDamage() == 0 && rand != 2)
			{
				ItemStack k = new ItemStack(ModItems.chisel, 2, 0); //Makes a new itemstack that's been damaged and has 2 items
				event.craftMatrix.setInventorySlotContents(i, k); //Sets the slot to the new item     
			}
			
		}
	}
}
 
開發者ID:jasonmpen,項目名稱:CarbonMod,代碼行數:30,代碼來源:CraftingEvent.java

示例10: onItemCrafted

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onItemCrafted(PlayerEvent.ItemCraftedEvent e) {
    //Detects if the player crafts the integration table, the very first achievement
    if (e.crafting.getItem() == Item.getItemFromBlock(CYBBlocks.integTable)) {
        e.player.addStat(CYBAchievements.getAchievement(0), 1);
    }

    //Detects if the player crafts their first implant, the second achievement
    if (e.crafting.getItem() instanceof Implant) {
        e.player.addStat(CYBAchievements.getAchievement(1), 1);
    }
}
 
開發者ID:Aurilux,項目名稱:Cybernetica,代碼行數:13,代碼來源:AchievementListener.java

示例11: onPlayerItemCrafted

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SuppressWarnings({ "static-method", "javadoc" })
@SubscribeEvent
public void onPlayerItemCrafted(PlayerEvent.ItemCraftedEvent event)
{
    IInventory craftMatrix = event.craftMatrix;
    for (int i = 0; i < craftMatrix.getSizeInventory(); i++)
    {
        if (craftMatrix.getStackInSlot(i) != null)
        {
            ItemStack j = craftMatrix.getStackInSlot(i);
            if (j.getItem() != null && (j.getItem() == RegistrationHandler.hammer || j.getItem() == RegistrationHandler.diamondHammer))
            {
                ItemStack k;
                if (j.getItem() == RegistrationHandler.hammer) k = new ItemStack(RegistrationHandler.hammer, 2, (j.getItemDamage() + 1));
                else k = new ItemStack(RegistrationHandler.diamondHammer, 2, (j.getItemDamage() + 1));
                if (k.getItemDamage() >= k.getMaxDamage())
                {
                    k.stackSize--;
                }
                craftMatrix.setInventorySlotContents(i, k);
            }
        }
    }
    
    if (event.crafting.getItem() == RegistrationHandler.hammer) event.player.triggerAchievement(RegistrationHandler.hammerAchievement);
    if (event.crafting.getItem() == RegistrationHandler.diamondHammer) event.player.triggerAchievement(RegistrationHandler.diamondHammerAchievement);
    if (event.crafting.isItemEqual(RegistrationHandler.grassPlate)) event.player.triggerAchievement(RegistrationHandler.ecoAchievement);
    if (event.crafting.isItemEqual(RegistrationHandler.tntPlate)) event.player.triggerAchievement(RegistrationHandler.suicideAchievement);
    if (event.crafting.isItemEqual(RegistrationHandler.obsidianPlate)) event.player.triggerAchievement(RegistrationHandler.betterAchievement);
}
 
開發者ID:CoreModding,項目名稱:MoArmor,代碼行數:31,代碼來源:CraftingHandler.java

示例12: CraftingEvent

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
	public void CraftingEvent(PlayerEvent.ItemCraftedEvent event){
		if(event.crafting.getItem() == ModItems.nileEssence){
			event.player.addStat(ModAchievements.NileStart, 1);		
		}
		if(event.crafting.getItem() == ModItems.nileDust){
			event.player.addStat(ModAchievements.NileStart, 1);		
		}
		if(event.crafting.getItem() == ModItems.nileSword){
			event.player.addStat(ModAchievements.buildNileSword, 1);		
		}
		if(Block.getBlockFromItem(event.crafting.getItem()).equals(ModBlocks.nileWorktable)){
			event.player.addStat(ModAchievements.buildNWorkBench, 1);		
		}	
		if(event.crafting.getItem() == ModItems.nileBone){
			event.player.addStat(ModAchievements.buildBone, 1);		
		}
	
		if(Constants.DEF_DARKLOAD == true){
			if(event.crafting.getItem() == ModItems.darkEssence){
				event.player.addStat(ModAchievements.DarkStart, 1);		
			}
			if(event.crafting.getItem() == ModItems.darkDust){
				event.player.addStat(ModAchievements.DarkStart, 1);		
			}
			/*if(event.crafting.getItem() == ModItems.darkSword){
			event.player.addStat(ModAchievements.buildNileSword, 1);		
		}
		if(event.crafting.getItem() == ModItems.darkNileBone){
			event.player.addStat(ModAchievements.buildBone, 1);		
		}*/
	}
}
 
開發者ID:NovaViper,項目名稱:ZeroQuest,代碼行數:34,代碼來源:AchievementEvents.java

示例13: playerCraftsBackpack

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void playerCraftsBackpack(PlayerEvent.ItemCraftedEvent event)
{
    if (event.crafting.getItem() == ModItems.adventureBackpack)
    {
        LogHelper.info("Player crafted a backpack, and that backpack's appearance is: " + event.crafting.getTagCompound().getString("colorName"));
        if (BackpackNames.getBackpackColorName(event.crafting).equals("Dragon"))
        {
            event.player.dropPlayerItemWithRandomChoice(new ItemStack(Blocks.dragon_egg, 1), false);
            event.player.playSound("mob.enderdragon.growl", 1.0f, 5.0f);
        }
    }
}
 
開發者ID:Darkona,項目名稱:AdventureBackpack2,代碼行數:14,代碼來源:PlayerEventHandler.java

示例14: craftEvent

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void craftEvent(PlayerEvent.ItemCraftedEvent event) {
    if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) return;

    if (RandomUtils.nextInt(0, 4) == 0) {
        DiscoveryManager.unlockItem(QADiscoveries.Item.ARRANGEMENT.get().getKey(), event.player, false);
    }

    if (event.crafting.getItem() == QAItems.JOURNAL.getItem())
        DiscoveryManager.unlockItem(QADiscoveries.Item.DISCOVERY.get().getKey(), event.player, false);

    if (event.crafting.getItem() == Item.getItemFromBlock(Blocks.ender_chest))
        DiscoveryManager.unlockItem(QADiscoveries.Item.PLAYER.get().getKey(), event.player, false);
}
 
開發者ID:MSourceCoded,項目名稱:Quantum-Anomalies,代碼行數:15,代碼來源:DiscoveryListener.java

示例15: handleCrafting

import cpw.mods.fml.common.gameevent.PlayerEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void handleCrafting (PlayerEvent.ItemCraftedEvent event) {
    if (event.crafting.getItem() instanceof ItemThinLog) {
        for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) {
            ItemStack item = event.craftMatrix.getStackInSlot(i);
            if (item != null && isValidAxe(item) && item.getItemDamage() < item.getMaxDamage()) {
                ItemStack modifiedAxe = item.copy();
                modifiedAxe.setItemDamage(modifiedAxe.getItemDamage() + 1);
                modifiedAxe.stackSize += modifiedAxe.stackSize;

                event.craftMatrix.setInventorySlotContents(i, modifiedAxe);
            }
        }
    }
}
 
開發者ID:jaquadro,項目名稱:GardenCollection,代碼行數:16,代碼來源:ForgeEventHandler.java


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