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
Impl PlayerChangedDimensionEvent, PlayerRespawnEvent and PlayerLoggedOutEvent #118
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b8e2552
Impl PlayerChangedDimensionEvent, PlayerRespawnEvent and
rikka0w0 17f9488
Impl ItemPickupEvent, ItemCraftedEvent, ItemSmeltedEvent in PlayerEvent
rikka0w0 757a8d1
Merge remote-tracking branch 'origin/master' into feature/playerevent
rikka0w0 8241ab2
Add methods to the god class
rikka0w0 1941e94
Apply leo60228's suggestion
rikka0w0 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
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
59 changes: 59 additions & 0 deletions
59
patchwork-events-entity/src/main/java/net/patchworkmc/impl/event/entity/PlayerEvents.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,59 @@ | ||
| /* | ||
| * 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.patchworkmc.impl.event.entity; | ||
|
|
||
| import net.minecraftforge.common.MinecraftForge; | ||
| import net.minecraftforge.event.entity.player.PlayerEvent; | ||
|
|
||
| import net.minecraft.entity.ItemEntity; | ||
| import net.minecraft.entity.player.PlayerEntity; | ||
| import net.minecraft.inventory.Inventory; | ||
| import net.minecraft.item.ItemStack; | ||
| import net.minecraft.world.dimension.DimensionType; | ||
|
|
||
| public class PlayerEvents { | ||
| public static void firePlayerChangedDimensionEvent(PlayerEntity player, DimensionType fromDim, DimensionType toDim) { | ||
| MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim)); | ||
| } | ||
|
|
||
| public static void firePlayerLoggedIn(PlayerEntity player) { | ||
| MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerLoggedInEvent(player)); | ||
| } | ||
|
|
||
| public static void firePlayerLoggedOut(PlayerEntity player) { | ||
| MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerLoggedOutEvent(player)); | ||
| } | ||
|
|
||
| public static void firePlayerRespawnEvent(PlayerEntity player, boolean alive) { | ||
| MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerRespawnEvent(player, alive)); | ||
| } | ||
|
|
||
| public static void firePlayerItemPickupEvent(PlayerEntity player, ItemEntity item, ItemStack clone) { | ||
| MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemPickupEvent(player, item, clone)); | ||
| } | ||
|
|
||
| public static void firePlayerCraftingEvent(PlayerEntity player, ItemStack crafted, Inventory craftMatrix) { | ||
| MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemCraftedEvent(player, crafted, craftMatrix)); | ||
| } | ||
|
|
||
| public static void firePlayerSmeltedEvent(PlayerEntity player, ItemStack smelted) { | ||
| MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemSmeltedEvent(player, smelted)); | ||
| } | ||
| } |
58 changes: 58 additions & 0 deletions
58
...ents-entity/src/main/java/net/patchworkmc/mixin/event/entity/MixinCraftingResultSlot.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,58 @@ | ||
| /* | ||
| * 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.patchworkmc.mixin.event.entity; | ||
|
|
||
| import org.spongepowered.asm.mixin.Final; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.Shadow; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Inject; | ||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
| import org.spongepowered.asm.mixin.injection.At.Shift; | ||
|
|
||
| import net.minecraft.container.CraftingResultSlot; | ||
| import net.minecraft.entity.player.PlayerEntity; | ||
| import net.minecraft.inventory.CraftingInventory; | ||
| import net.minecraft.item.ItemStack; | ||
|
|
||
| import net.patchworkmc.impl.event.entity.PlayerEvents; | ||
|
|
||
| @Mixin(CraftingResultSlot.class) | ||
| public abstract class MixinCraftingResultSlot { | ||
| @Shadow | ||
| @Final | ||
| private PlayerEntity player; | ||
|
|
||
| @Shadow | ||
| @Final | ||
| private CraftingInventory craftingInv; | ||
|
|
||
| @Inject(method = "onCrafted(Lnet/minecraft/item/ItemStack;)V", | ||
| at = @At( | ||
| value = "INVOKE", | ||
| shift = Shift.AFTER, | ||
| ordinal = 0, | ||
| target = "net/minecraft/item/ItemStack.onCraft(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;I)V" | ||
| ) | ||
| ) | ||
| private void onStackCrafted(ItemStack stack, CallbackInfo ci) { | ||
| PlayerEvents.firePlayerCraftingEvent(player, stack, craftingInv); | ||
| } | ||
| } | ||
47 changes: 47 additions & 0 deletions
47
...vents-entity/src/main/java/net/patchworkmc/mixin/event/entity/MixinFurnaceOutputSlot.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,47 @@ | ||
| /* | ||
| * 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.patchworkmc.mixin.event.entity; | ||
|
|
||
| import org.spongepowered.asm.mixin.Final; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.Shadow; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Inject; | ||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
|
||
| import net.minecraft.container.FurnaceOutputSlot; | ||
| import net.minecraft.entity.player.PlayerEntity; | ||
| import net.minecraft.item.ItemStack; | ||
|
|
||
| import net.patchworkmc.impl.event.entity.PlayerEvents; | ||
|
|
||
| @Mixin(FurnaceOutputSlot.class) | ||
| public abstract class MixinFurnaceOutputSlot { | ||
| @Shadow | ||
| @Final | ||
| private PlayerEntity player; | ||
|
|
||
| @Inject(method = "onCrafted(Lnet/minecraft/item/ItemStack;)V", | ||
| at = @At("RETURN") | ||
| ) | ||
| private void onCraftingFinished(ItemStack stack, CallbackInfo ci) { | ||
| PlayerEvents.firePlayerSmeltedEvent(player, stack); | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.