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
Implement SaplingGrowTreeEvent and BlockEvent.FarmlandTrampleEvent #146
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d1c5c59
Implement SaplingGrowTreeEvent and BlockEvent.FarmlandTrampleEvent
cittyinthecloud 5ba2788
Requested changes
cittyinthecloud 658385b
Has result
cittyinthecloud b01e79a
Merge remote-tracking branch 'upstream/master' into feature/sapling-a…
cittyinthecloud 3c7f451
Fix imports
cittyinthecloud 4a9138e
Merge
cittyinthecloud 994aec0
Merge remote-tracking branch 'origin/master' into feature/sapling-and…
JFronny 91a1ad5
Fix checkstyle
JFronny b46a698
Merge pull request #194 from JFronny/feature/sapling-and-farmland
TheGlitch76 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
65 changes: 65 additions & 0 deletions
65
...hwork-events-world/src/main/java/net/minecraftforge/event/world/SaplingGrowTreeEvent.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,65 @@ | ||
| /* | ||
| * 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.world; | ||
|
|
||
| import java.util.Random; | ||
|
|
||
| import net.minecraft.block.BlockState; | ||
| import net.minecraft.util.math.BlockPos; | ||
| import net.minecraft.world.IWorld; | ||
|
|
||
| /** | ||
| * SaplingGrowTreeEvent is fired when a sapling grows into a tree. | ||
| * | ||
| * <p>This event is fired during sapling growth in | ||
| * {@link net.minecraft.block.SaplingBlock#generate(IWorld, BlockPos, BlockState, Random)}. | ||
| * | ||
| * <p>{@link #pos} contains the coordinates of the growing sapling. | ||
| * {@link #rand} contains an instance of Random for use. | ||
| * | ||
| * <p>This event is not cancellable. | ||
| * | ||
| * <p>This event has a result. | ||
| * This result determines if the sapling is allowed to grow. | ||
| */ | ||
|
|
||
| public class SaplingGrowTreeEvent extends WorldEvent { | ||
| private final BlockPos pos; | ||
| private final Random rand; | ||
|
|
||
| public SaplingGrowTreeEvent(IWorld world, Random rand, BlockPos pos) { | ||
| super(world); | ||
| this.rand = rand; | ||
| this.pos = pos; | ||
| } | ||
|
|
||
| public BlockPos getPos() { | ||
| return pos; | ||
| } | ||
|
|
||
| public Random getRand() { | ||
| return rand; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hasResult() { | ||
| return true; | ||
| } | ||
| } | ||
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
44 changes: 44 additions & 0 deletions
44
...hwork-events-world/src/main/java/net/patchworkmc/mixin/event/world/MixinSaplingBlock.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,44 @@ | ||
| /* | ||
| * 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.world; | ||
|
|
||
| import java.util.Random; | ||
|
|
||
| import org.spongepowered.asm.mixin.Mixin; | ||
| 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.block.BlockState; | ||
| import net.minecraft.block.SaplingBlock; | ||
| import net.minecraft.util.math.BlockPos; | ||
| import net.minecraft.world.IWorld; | ||
|
|
||
| import net.patchworkmc.impl.event.world.WorldEvents; | ||
|
|
||
| @Mixin(SaplingBlock.class) | ||
| public class MixinSaplingBlock { | ||
| @Inject(method = "generate", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/sapling/SaplingGenerator;generate(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Ljava/util/Random;)Z"), cancellable = true) | ||
| private void onGenerateTree(IWorld world, BlockPos pos, BlockState state, Random random, CallbackInfo ci) { | ||
| if (!WorldEvents.onSaplingGrowTree(world, random, pos)) { | ||
| ci.cancel(); | ||
| } | ||
| } | ||
| } |
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
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
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
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.