-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6935a9
commit 9be8973
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
src/main/java/mega/blendtronic/mixin/mixins/common/FastLeafDecay/BlockLeavesBaseMixin.java
This file contains 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 @@ | ||
/* | ||
* Blendtronic | ||
* | ||
* Copyright (C) 2021-2024 SirFell, the MEGA team | ||
* All Rights Reserved | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* This program 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, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package mega.blendtronic.mixin.mixins.common.FastLeafDecay; | ||
|
||
import mega.blendtronic.modules.FastLeafDecay.LeafDecayHelper; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockLeavesBase; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.world.World; | ||
|
||
@Mixin(BlockLeavesBase.class) | ||
public abstract class BlockLeavesBaseMixin extends Block { | ||
protected BlockLeavesBaseMixin(Material materialIn) { | ||
super(materialIn); | ||
} | ||
|
||
@Override | ||
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) { | ||
LeafDecayHelper.handleLeafDecay(world, x, y, z, this); | ||
} | ||
} |
This file contains 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
40 changes: 40 additions & 0 deletions
40
src/main/java/mega/blendtronic/modules/FastLeafDecay/LeafDecayHelper.java
This file contains 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,40 @@ | ||
/* | ||
* Blendtronic | ||
* | ||
* Copyright (C) 2021-2024 SirFell, the MEGA team | ||
* All Rights Reserved | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* This program 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, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package mega.blendtronic.modules.FastLeafDecay; | ||
|
||
import mega.blendtronic.config.MinecraftConfig; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.Random; | ||
|
||
public class LeafDecayHelper { | ||
private static final Random rng = new Random(); | ||
public static void handleLeafDecay(World world, int x, int y, int z, Block block) { | ||
if (MinecraftConfig.FAST_LEAF_DECAY) { | ||
world.scheduleBlockUpdate(x, y, z, block, MinecraftConfig.DECAY_SPEED + (MinecraftConfig.DECAY_FUZZ > 0 ? rng.nextInt(MinecraftConfig.DECAY_FUZZ) : 0)); | ||
} | ||
} | ||
} |