net.minecraftforge.fml.common.gameevent.PlayerEvent Java Examples

The following examples show how to use net.minecraftforge.fml.common.gameevent.PlayerEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftingHelper.java    From malmo with MIT License 5 votes vote down vote up
/**
 * Attempt to smelt the given item.<br>
 * This returns instantly, callously disregarding such frivolous niceties as cooking times or the presence of a furnace.<br>
 * It will, however, consume fuel from the player's inventory.
 *
 * @param player
 * @param input  the raw ingredients we want to cook.
 * @return true if cooking was successful.
 */
public static boolean attemptSmelting(EntityPlayerMP player, ItemStack input) {
    if (player == null || input == null)
        return false;
    List<ItemStack> ingredients = new ArrayList<ItemStack>();
    ingredients.add(input);
    ItemStack isOutput = FurnaceRecipes.instance().getSmeltingList().get(input);
    if (isOutput == null)
        return false;
    int cookingTime = 200;  // Seems to be hard-coded in TileEntityFurnace.
    if (playerHasIngredients(player, ingredients) && totalBurnTimeInInventory(player) >= cookingTime) {
        removeIngredientsFromPlayer(player, ingredients);
        burnInventory(player, cookingTime, input);

        ItemStack resultForInventory = isOutput.copy();
        ItemStack resultForReward = isOutput.copy();
        player.inventory.addItemStackToInventory(resultForInventory);
        RewardForCollectingItemImplementation.GainItemEvent event = new RewardForCollectingItemImplementation.GainItemEvent(resultForReward);
        event.setCause(2);
        MinecraftForge.EVENT_BUS.post(event);

        // Now trigger a smelt event
        MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemSmeltedEvent(player, resultForReward));
        return true;
    }
    return false;
}
 
Example #2
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerEvent.PlayerLoggedOutEvent event) {
    if (event.player.worldObj.isRemote) {
        return;
    }
    handleQuit((EntityPlayerMP) event.player);
}
 
Example #3
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerEvent.PlayerLoggedOutEvent event) {
    if (event.player.world.isRemote) {
        return;
    }
    handleQuit((EntityPlayerMP) event.player);
}
 
Example #4
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerEvent.PlayerLoggedOutEvent event) {
    if (event.player.worldObj.isRemote) {
        return;
    }
    handleQuit((EntityPlayerMP) event.player);
}
 
Example #5
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerEvent.PlayerLoggedOutEvent event) {
    if (event.player.world.isRemote) {
        return;
    }
    handleQuit((EntityPlayerMP) event.player);
}
 
Example #6
Source File: ForgeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerQuit(PlayerEvent.PlayerLoggedOutEvent event) {
    if (event.player.worldObj.isRemote) {
        return;
    }
    handleQuit((EntityPlayerMP) event.player);
}
 
Example #7
Source File: TofuEventLoader.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onCrafting(PlayerEvent.ItemCraftedEvent event) {
       EntityPlayer player = event.player;
       ItemStack item = event.crafting;
	IInventory craftMatrix = event.craftMatrix;
	
	if(craftMatrix instanceof InventoryCrafting){
	InventoryCrafting craftMatrix1 = (InventoryCrafting) craftMatrix;
	IRecipe recipe = ForgeRegistries.RECIPES.getValue(new ResourceLocation(TofuMain.MODID, "soymilk_cloth"));
	if(recipe!=null){
		if(!item.isEmpty()&&recipe.matches(craftMatrix1, player.world))
			player.inventory.addItemStackToInventory(new ItemStack(ItemLoader.material,1,11));
		}
	}
}
 
Example #8
Source File: PlayerConnectToServerHandler.java    From AgriCraft with MIT License 5 votes vote down vote up
@SubscribeEvent
@SuppressWarnings("unused")
public void onConnect(PlayerEvent.PlayerLoggedInEvent event) {
    EntityPlayerMP player = (EntityPlayerMP) event.player;
    syncSoils(player);
    syncPlants(player);
    syncMutations(player);
}
 
Example #9
Source File: SpellTicker.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public static void onLogin(PlayerEvent.PlayerLoggedInEvent event) {
	if (event.player.world.isRemote) return;

	WizardryWorld cap = WizardryWorldCapability.get(event.player.world);
	if (cap == null) return;

	//	PacketHandler.NETWORK.sendToDimension(new PacketSyncWizardryWorld(cap.serializeNBT()), event.player.world.provider.getDimension());
}
 
Example #10
Source File: ModCapabilities.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public static void onDimChange(PlayerEvent.PlayerChangedDimensionEvent event) {
	if (event.player.world.isRemote) return;

	IManaCapability manaCap = ManaCapabilityProvider.getCap(event.player);
	if (manaCap != null)
		manaCap.dataChanged(event.player);

	IMiscCapability miscCap = MiscCapabilityProvider.getCap(event.player);
	if (miscCap != null)
		miscCap.dataChanged(event.player);
}
 
Example #11
Source File: ModCapabilities.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public static void onRespawn(PlayerEvent.PlayerRespawnEvent event) {
	if (event.player.world.isRemote) return;

	IManaCapability manaCap = ManaCapabilityProvider.getCap(event.player);
	if (manaCap != null)
		manaCap.dataChanged(event.player);

	IMiscCapability miscCap = MiscCapabilityProvider.getCap(event.player);
	if (miscCap != null)
		miscCap.dataChanged(event.player);
}
 
Example #12
Source File: ModCapabilities.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public static void onLogin(PlayerEvent.PlayerLoggedInEvent event) {
	if (event.player.world.isRemote) return;

	IManaCapability manaCap = ManaCapabilityProvider.getCap(event.player);
	if (manaCap != null)
		manaCap.dataChanged(event.player);

	IMiscCapability miscCap = MiscCapabilityProvider.getCap(event.player);
	if (miscCap != null)
		miscCap.dataChanged(event.player);
}
 
Example #13
Source File: PlayerEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event)
{
    if (event.player instanceof EntityPlayerMP)
    {
        PlacementProperties.getInstance().syncAllDataForPlayer((EntityPlayerMP) event.player);
    }
}
 
Example #14
Source File: ConfigSync.java    From TinkersToolLeveling with MIT License 5 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.SERVER)
public void playerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
  if(event.player instanceof EntityPlayerMP && FMLCommonHandler.instance().getSide().isServer()) {
    ConfigSyncPacket packet = new ConfigSyncPacket();
    TinkerToolLeveling.networkWrapper.network.sendTo(packet, (EntityPlayerMP) event.player);
  }
}
 
Example #15
Source File: PLEvent.java    From Production-Line with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onPlayerPickup(PlayerEvent.ItemPickupEvent event) {
    if (event.pickedUp.getEntityItem().isItemEqual(new ItemStack(PLBlocks.oreIridium))) {
        event.player.addStat(PLAchievement.getIrOre, 1);
    }
}
 
Example #16
Source File: SyncEventHandler.java    From GokiStats with MIT License 4 votes vote down vote up
@SubscribeEvent
public static void playerRespawn(PlayerEvent.PlayerRespawnEvent event) {
    syncPlayerData(event.player);
}
 
Example #17
Source File: SyncEventHandler.java    From GokiStats with MIT License 4 votes vote down vote up
@SubscribeEvent
public static void playerChangedWorld(PlayerEvent.PlayerChangedDimensionEvent event) {
    syncPlayerData(event.player);
}
 
Example #18
Source File: PLEvent.java    From Production-Line with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onPlayerCrafting(PlayerEvent.ItemCraftedEvent event) {
    if (event.crafting.getItem().equals(PLBlocks.carbonizeFurnace.getItem())) {
        event.player.addStat(PLAchievement.getCarbonizeFurnace, 1);
    }
}
 
Example #19
Source File: RewardForCollectingItemQuantityImplementation.java    From malmo with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onItemSmelt(PlayerEvent.ItemSmeltedEvent event) {
    if (event.player instanceof EntityPlayerMP && !event.smelting.isEmpty())
        checkForMatch(event.smelting);
}
 
Example #20
Source File: RocketEventHandler.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@SubscribeEvent
public void playerTeleportEvent(PlayerEvent.PlayerChangedDimensionEvent event) {
	//Fix O2, space elevator popup displaying after teleporting
	lastDisplayTime = -1000;
}
 
Example #21
Source File: AgriCraft.java    From AgriCraft with MIT License 4 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent e) {
    AgriAlphaWarnings.chooseMessage(l -> e.player.sendMessage(ForgeHooks.newChatWithLinks(l)));
}
 
Example #22
Source File: PlayerEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event)
{
    PlayerTaskScheduler.getInstance().removeTask(event.player, null);
}
 
Example #23
Source File: SyncEventHandler.java    From GokiStats with MIT License 4 votes vote down vote up
@SubscribeEvent
public static void playerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
    syncPlayerData(event.player);
}
 
Example #24
Source File: AgentQuitFromSmeltingItemImplementation.java    From malmo with MIT License 4 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onItemSmelt(PlayerEvent.ItemSmeltedEvent event) {
    if (event.player instanceof EntityPlayerMP && !event.smelting.isEmpty())
        checkForMatch(event.smelting);
}
 
Example #25
Source File: RewardForSmeltingItemImplementation.java    From malmo with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onItemSmelt(PlayerEvent.ItemSmeltedEvent event) {
    if (event.player instanceof EntityPlayerMP && !event.smelting.isEmpty())
        checkForMatch(event.smelting);
}
 
Example #26
Source File: RewardForCollectingItemQuantityImplementation.java    From malmo with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onItemCraft(PlayerEvent.ItemCraftedEvent event) {
    if (event.player instanceof EntityPlayerMP && !event.crafting.isEmpty())
        checkForMatch(event.crafting);
}
 
Example #27
Source File: RewardForCraftingItemImplementation.java    From malmo with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onItemCraft(PlayerEvent.ItemCraftedEvent event) {
    if (event.player instanceof EntityPlayerMP && !event.crafting.isEmpty())
        checkForMatch(event.crafting);
}
 
Example #28
Source File: AgentQuitFromPossessingItemImplementation.java    From malmo with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onItemSmelt(PlayerEvent.ItemSmeltedEvent event) {
    if (event.player instanceof EntityPlayerMP && !event.smelting.isEmpty())
        checkForMatch(event.smelting);
}
 
Example #29
Source File: AgentQuitFromPossessingItemImplementation.java    From malmo with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onItemCraft(PlayerEvent.ItemCraftedEvent event) {
    if (event.player instanceof EntityPlayerMP && !event.crafting.isEmpty())
        checkForMatch(event.crafting);
}
 
Example #30
Source File: AgentQuitFromCollectingItemQuantityImplementation.java    From malmo with MIT License 4 votes vote down vote up
@SubscribeEvent
public void onItemSmelt(PlayerEvent.ItemSmeltedEvent event) {
    if (event.player instanceof EntityPlayerMP && !event.smelting.isEmpty())
        checkForMatch(event.smelting);
}