diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f21661a..e9c149d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,5 @@ +## [1.15.1-2.0.1] - 2019-12-20 +- Add an option in the config to instantly break leaves (defaults to false). + ## [1.15.1-2.0.0] - 2019-12-17 - Port to 1.15.1 diff --git a/README.md b/README.md index fef3957c..bcf15c6a 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,4 @@ Several options are available in the config file: - max\_log\_count: The maximum number of log a tree can be mad of (if more the mod won't apply). - preserve_tools: If this option is enabled your tool won't be broken by chopping down a big tree, it'll instead be left with 1 of durability. - reverse_sneaking: If this option is enabled you'll need to sneak in order to break the whole tree. +- break_leaves: If this is set to true, leaves will despawn instantly when a tree is broken (even if not cut in one shot). diff --git a/changes.md b/changes.md index 14f66a28..ccca1bb5 100644 --- a/changes.md +++ b/changes.md @@ -1 +1 @@ -- Port to 1.15.1 \ No newline at end of file +- Add an option in the config to instantly break leaves (defaults to false). \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 360c73fb..50665ead 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,9 +13,9 @@ changelogUrl = https://github.com/RakSrinaNa/FallingTree/blob/1.15.1/CHANGELOG.m mc_version = 1.15.1 -forge_version = 1.15.1-30.0.0 +forge_version = 1.15.1-30.0.14 mcp_channel = snapshot -mcp_mappings = 20191217-1.14.3 +mcp_mappings = 20191220-1.14.3 curseforge_project_id=349559 diff --git a/src/main/java/fr/raksrinana/fallingtree/FallingTree.java b/src/main/java/fr/raksrinana/fallingtree/FallingTree.java index d618df2a..ef4a8a56 100644 --- a/src/main/java/fr/raksrinana/fallingtree/FallingTree.java +++ b/src/main/java/fr/raksrinana/fallingtree/FallingTree.java @@ -16,7 +16,7 @@ public class FallingTree{ public static final String MOD_ID = "falling_tree"; public static final String MOD_NAME = "Falling Tree"; - public static final String VERSION = "2.0.0"; + public static final String VERSION = "2.0.1"; public static final Logger LOGGER = LogManager.getLogger(MOD_ID); public FallingTree(){ diff --git a/src/main/java/fr/raksrinana/fallingtree/ForgeEventSubscriber.java b/src/main/java/fr/raksrinana/fallingtree/ForgeEventSubscriber.java index 25f76ba3..097b6229 100644 --- a/src/main/java/fr/raksrinana/fallingtree/ForgeEventSubscriber.java +++ b/src/main/java/fr/raksrinana/fallingtree/ForgeEventSubscriber.java @@ -2,13 +2,20 @@ import fr.raksrinana.fallingtree.config.Config; import fr.raksrinana.fallingtree.tree.TreeHandler; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.tags.BlockTags; import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.world.IWorld; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import javax.annotation.Nonnull; +import java.util.Random; @Mod.EventBusSubscriber(modid = FallingTree.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public final class ForgeEventSubscriber{ @@ -39,4 +46,21 @@ private static boolean isPlayerInRightState(PlayerEntity player){ } return TreeHandler.canPlayerBreakTree(player); } + + @SubscribeEvent + public static void onNeighborNotifyEvent(BlockEvent.NeighborNotifyEvent event){ + if(Config.COMMON.breakLeaves.get() && !event.getWorld().isRemote()){ + BlockState state = event.getState(); + Block block = state.getBlock(); + BlockPos pos = event.getPos(); + if(block.isIn(BlockTags.LEAVES)){ + if(state.ticksRandomly()){ + IWorld world = event.getWorld(); + if(world instanceof ServerWorld){ + block.func_225542_b_(state, (ServerWorld) world, pos, new Random()); + } + } + } + } + } } diff --git a/src/main/java/fr/raksrinana/fallingtree/config/CommonConfig.java b/src/main/java/fr/raksrinana/fallingtree/config/CommonConfig.java index 0de78759..864b049d 100644 --- a/src/main/java/fr/raksrinana/fallingtree/config/CommonConfig.java +++ b/src/main/java/fr/raksrinana/fallingtree/config/CommonConfig.java @@ -19,6 +19,7 @@ public class CommonConfig{ public final ForgeConfigSpec.BooleanValue ignoreDurabilityLoss; public final ForgeConfigSpec.BooleanValue preserveTools; public final ForgeConfigSpec.BooleanValue reverseSneaking; + public final ForgeConfigSpec.BooleanValue breakLeaves; public final ForgeConfigSpec.IntValue maxTreeSize; @@ -32,6 +33,7 @@ public CommonConfig(ForgeConfigSpec.Builder builder){ maxTreeSize = builder.comment("The maximum size of a tree. If there's more logs than this value the tree won't be cut.").defineInRange("max_log_count", 100, 1, Integer.MAX_VALUE); preserveTools = builder.comment("When set to true, when a tree is broken and the tool is about to break we will just break one block and not the whole tree.").define("preserve_tools", false); reverseSneaking = builder.comment("When set to true, a tree will only be chopped down if the player is sneaking").define("reverse_sneaking", false); + breakLeaves = builder.comment("When set to true, leaves will be broken instantly").define("break_leaves", false); } public Stream getWhitelistedLogs(){ diff --git a/update.json b/update.json index 47670f90..8b07c8ce 100644 --- a/update.json +++ b/update.json @@ -2,10 +2,11 @@ "homepage": "https://github.com/RakSrinaNa/FallingTree", "changelog": "https://github.com/RakSrinaNa/FallingTree/blob/1.15.1/CHANGELOG.md", "1.15.1": { + "2.0.1": "https://github.com/RakSrinaNa/FallingTree/blob/1.15.1/CHANGELOG.md", "2.0.0": "https://github.com/RakSrinaNa/FallingTree/blob/1.15.1/CHANGELOG.md" }, "promos": { - "1.15.1-latest": "2.0.0", - "1.15.1-recommended": "2.0.0" + "1.15.1-latest": "2.0.1", + "1.15.1-recommended": "2.0.1" } } \ No newline at end of file