This repository was archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
EntityItemPickupEvent + PlayerEvent#ItemPickupEvent #101
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
07f6610
EntityItemPickupEvent + PlayerEvent#ItemPickupEvent
Rongmario cd2e462
Alternate way with Overwrite implemented
Rongmario 2c8748e
Reverted Overwrite + Fixed non-Overwrite implementation
Rongmario 8c23322
checkstyle pls
Rongmario 297b1dd
Implemented ItemTossEvent + Start on IForgeEntity
Rongmario File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
patchwork-events-entity/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * Minecraft Forge, Patchwork Project | ||
| * Copyright (c) 2016-2020, 2019-2020 | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation version 2.1 | ||
| * of the License. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| package net.minecraftforge.event.entity.item; | ||
|
|
||
| import net.minecraftforge.event.entity.EntityEvent; | ||
|
|
||
| import net.minecraft.entity.ItemEntity; | ||
|
|
||
| /** | ||
| * Base class for all ItemEntity events. Contains a reference to the | ||
| * ItemEntity of interest. For most ItemEntity events, there's little to no | ||
| * additional useful data from the firing method that isn't already contained | ||
| * within the ItemEntity instance. | ||
| */ | ||
| public class ItemEvent extends EntityEvent { | ||
| private final ItemEntity entityItem; | ||
|
|
||
| /** | ||
| * Creates a new event for an EntityItem. | ||
| * | ||
| * @param itemEntity The EntityItem for this event | ||
| */ | ||
| public ItemEvent(ItemEntity itemEntity) { | ||
| super(itemEntity); | ||
| this.entityItem = itemEntity; | ||
| } | ||
|
|
||
| /** | ||
| * The relevant EntityItem for this event, already cast for you. | ||
| */ | ||
| public ItemEntity getEntityItem() { | ||
| return entityItem; | ||
| } | ||
| } |
52 changes: 52 additions & 0 deletions
52
...ork-events-entity/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Minecraft Forge, Patchwork Project | ||
| * Copyright (c) 2016-2020, 2019-2020 | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation version 2.1 | ||
| * of the License. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| package net.minecraftforge.event.entity.item; | ||
|
|
||
| import net.minecraft.entity.ItemEntity; | ||
|
|
||
| /** | ||
| * Event that is fired when an ItemEntity's age has reached its maximum | ||
| * lifespan. Canceling this event will prevent the ItemEntity from being | ||
| * flagged as dead, thus staying it's removal from the world. If canceled | ||
| * it will add more time to the entities life equal to extraLife. | ||
| */ | ||
|
|
||
| public class ItemExpireEvent extends ItemEvent { | ||
| private int extraLife; | ||
|
|
||
| /** | ||
| * Creates a new event for an expiring EntityItem. | ||
| * | ||
| * @param entityItem The ItemEntity being deleted. | ||
| * @param extraLife The amount of time to be added to this entities lifespan if the event is canceled. | ||
| */ | ||
| public ItemExpireEvent(ItemEntity entityItem, int extraLife) { | ||
| super(entityItem); | ||
| this.setExtraLife(extraLife); | ||
| } | ||
|
|
||
| public int getExtraLife() { | ||
| return extraLife; | ||
| } | ||
|
|
||
| public void setExtraLife(int extraLife) { | ||
| this.extraLife = extraLife; | ||
| } | ||
| } |
52 changes: 52 additions & 0 deletions
52
...hwork-events-entity/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Minecraft Forge, Patchwork Project | ||
| * Copyright (c) 2016-2020, 2019-2020 | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation version 2.1 | ||
| * of the License. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| package net.minecraftforge.event.entity.item; | ||
|
|
||
| import net.minecraft.entity.ItemEntity; | ||
| import net.minecraft.entity.player.PlayerEntity; | ||
|
|
||
| /** | ||
| * Event that is fired whenever a player tosses (Q) an item or drag-n-drops a | ||
| * stack of items outside the inventory GUI screens. Canceling the event will | ||
| * stop the items from entering the world, but will not prevent them being | ||
| * removed from the inventory - and thus removed from the system. | ||
| */ | ||
| // TODO: Call Location - ForgeHook#onPlayerTossEvent -> PlayerEntity#dropSelectedItem + PlayerEntity#dropItem | ||
| public class ItemTossEvent extends ItemEvent { | ||
| private final PlayerEntity player; | ||
|
|
||
| /** | ||
| * Creates a new event for ItemEntities tossed by a player. | ||
| * | ||
| * @param entityItem The ItemEntity being tossed. | ||
| * @param player The player tossing the item. | ||
| */ | ||
| public ItemTossEvent(ItemEntity entityItem, PlayerEntity player) { | ||
| super(entityItem); | ||
| this.player = player; | ||
| } | ||
|
|
||
| /** | ||
| * The player tossing the item. | ||
| */ | ||
| public PlayerEntity getPlayer() { | ||
| return player; | ||
| } | ||
| } | ||
46 changes: 46 additions & 0 deletions
46
...ts-entity/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Minecraft Forge, Patchwork Project | ||
| * Copyright (c) 2016-2020, 2019-2020 | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation version 2.1 | ||
| * of the License. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| package net.minecraftforge.event.entity.player; | ||
|
|
||
| import net.minecraft.entity.ItemEntity; | ||
| import net.minecraft.entity.player.PlayerEntity; | ||
|
|
||
| /** | ||
| * This event is called when a player collides with a EntityItem on the ground. | ||
| * The event can be canceled, and no further processing will be done. | ||
| * | ||
| * <p>You can set the result of this event to ALLOW which will trigger the | ||
| * processing of achievements, FML's event, play the sound, and kill the | ||
| * entity if all the items are picked up. | ||
| * | ||
| * <p>setResult(ALLOW) is the same as the old setHandled() | ||
| */ | ||
| public class EntityItemPickupEvent extends PlayerEvent { | ||
| private final ItemEntity item; | ||
|
|
||
| public EntityItemPickupEvent(PlayerEntity player, ItemEntity item) { | ||
| super(player); | ||
| this.item = item; | ||
| } | ||
|
|
||
| public ItemEntity getItem() { | ||
| return item; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May as well leave this out if you're not going to implement the hooks for it
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do it in the same PR if its cool :^)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go ahead