From 6cd95e443976c94adf4423c3b8152c301823e47a Mon Sep 17 00:00:00 2001 From: Thomas Couchoud Date: Fri, 4 Sep 2020 17:19:52 +0200 Subject: [PATCH] Fix #20 for 1.16.1 (Forge) --- .gitignore | 4 +++- CHANGELOG.md | 3 +++ build.gradle | 2 +- changes.md | 6 +----- gradle.properties | 4 ++-- .../fallingtree/ForgeEventSubscriber.java | 19 +++++++------------ .../fallingtree/config/TreeConfiguration.java | 16 ++++++++-------- .../fallingtree/tree/TreeHandler.java | 2 +- update.json | 5 +++-- 9 files changed, 29 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 27a5d8c7..ccb2ff90 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,10 @@ .idea build eclipse +/logs +/run /run-client /run-server version.properties -secrets.properties \ No newline at end of file +secrets.properties diff --git a/CHANGELOG.md b/CHANGELOG.md index a816acf0..6e382504 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [Forge-1.16.1-2.3.0] - 2020-09-04 +* Perform less ticking on leaves (#20) + ## [1.16.1-2.2.1] - 2020-07-31 * Remove some useless logs in the console. * Add an option `speed_multiplicand` to modify the breaking speed of the log. diff --git a/build.gradle b/build.gradle index e40ff8bd..9ba78105 100644 --- a/build.gradle +++ b/build.gradle @@ -214,7 +214,7 @@ void moveOldLog() { def version = project.version def dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd") def currDate = LocalDate.now() - def combined = "## [${project.loader}-${version}] - " + currDate.format(dateFormat) + System.lineSeparator() + new_log_file.text.trim() + System.lineSeparator() + System.lineSeparator() + old_log_file.text + def combined = "## [${project.loader}-${project.minecraft_version}-${version}] - " + currDate.format(dateFormat) + System.lineSeparator() + new_log_file.text.trim() + System.lineSeparator() + System.lineSeparator() + old_log_file.text old_log_file.setText(combined) } } diff --git a/changes.md b/changes.md index 3a0672a9..af56398d 100644 --- a/changes.md +++ b/changes.md @@ -1,5 +1 @@ -* Remove some useless logs in the console. - -* Add an option `speed_multiplicand` to modify the breaking speed of the log. - -* Improve shift_down mode for big trees. \ No newline at end of file +* Perform less ticking on leaves (#20) \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index e6da9f8c..5b970f9e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,14 +4,14 @@ org.gradle.daemon=false group=fr.raksrinana loader=Forge mod_id=falling_tree -version=2.2.1 +version=2.3.0 changelogUrl=https://github.com/RakSrinaNa/FallingTree/blob/1.16.1/CHANGELOG.md repoName=FallingTree name=Falling Tree minecraft_version=1.16.1 -forge_version=1.16.1-32.0.98 +forge_version=1.16.1-32.0.108 mcp_channel=snapshot mcp_mappings=20200514-1.16 diff --git a/src/main/java/fr/raksrinana/fallingtree/ForgeEventSubscriber.java b/src/main/java/fr/raksrinana/fallingtree/ForgeEventSubscriber.java index d454ad66..77de6e61 100644 --- a/src/main/java/fr/raksrinana/fallingtree/ForgeEventSubscriber.java +++ b/src/main/java/fr/raksrinana/fallingtree/ForgeEventSubscriber.java @@ -103,7 +103,7 @@ private static boolean isPlayerInRightState(PlayerEntity player){ @SubscribeEvent public static void onNeighborNotifyEvent(BlockEvent.NeighborNotifyEvent event){ - if(Config.COMMON.getTreesConfiguration().isLavesBreaking() && !event.getWorld().isRemote()){ + if(Config.COMMON.getTreesConfiguration().isLeavesBreaking() && !event.getWorld().isRemote()){ ServerWorld world = (ServerWorld) event.getWorld(); BlockState eventState = event.getState(); Block eventBlock = eventState.getBlock(); @@ -111,7 +111,7 @@ public static void onNeighborNotifyEvent(BlockEvent.NeighborNotifyEvent event){ if(eventBlock.isAir(eventState, world, eventPos)){ for(Direction facing : event.getNotifiedSides()){ BlockPos neighborPos = eventPos.offset(facing); - if(world.isBlockLoaded(neighborPos)){ + if(world.isAreaLoaded(neighborPos, 1)){ BlockState neighborState = event.getWorld().getBlockState(neighborPos); if(isLeafBlock(neighborState.getBlock())){ scheduledLeavesBreaking.add(new LeafBreakingSchedule(world, neighborPos, 4)); @@ -130,19 +130,14 @@ public static void onServerTick(TickEvent.ServerTickEvent event){ LeafBreakingSchedule leafBreakingSchedule = leavesBreak.next(); ServerWorld world = leafBreakingSchedule.getWorld(); if(leafBreakingSchedule.getRemainingTicks() <= 0){ - if(world.isBlockLoaded(leafBreakingSchedule.getBlockPos())){ + if(world.isAreaLoaded(leafBreakingSchedule.getBlockPos(), 1)){ BlockState state = world.getBlockState(leafBreakingSchedule.getBlockPos()); - Block block = state.getBlock(); - if(isLeafBlock(block)){ - block.randomTick(state, world, leafBreakingSchedule.getBlockPos(), world.getRandom()); + state.tick(world, leafBreakingSchedule.getBlockPos(), world.getRandom()); + if(state.ticksRandomly()){ + state.randomTick(world, leafBreakingSchedule.getBlockPos(), world.getRandom()); } - else{ - leavesBreak.remove(); - } - } - else{ - leavesBreak.remove(); } + leavesBreak.remove(); } else{ leafBreakingSchedule.tick(); diff --git a/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java b/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java index 2151bb23..4a144bcf 100644 --- a/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java +++ b/src/main/java/fr/raksrinana/fallingtree/config/TreeConfiguration.java @@ -16,8 +16,8 @@ public class TreeConfiguration{ private final ForgeConfigSpec.ConfigValue breakMode; private final ForgeConfigSpec.IntValue maxSize; private final ForgeConfigSpec.IntValue minimumLeavesAroundRequired; - private final ForgeConfigSpec.BooleanValue lavesBreaking; - private final ForgeConfigSpec.IntValue lavesBreakingForceRadius; + private final ForgeConfigSpec.BooleanValue leavesBreaking; + private final ForgeConfigSpec.IntValue leavesBreakingForceRadius; public TreeConfiguration(ForgeConfigSpec.Builder builder){ breakMode = builder.comment("How to break the tree.", @@ -39,9 +39,9 @@ public TreeConfiguration(ForgeConfigSpec.Builder builder){ maxSize = builder.comment("The maximum size of a tree. If there's more logs than this value the tree won't be cut.", "INFO: Only in INSTANTANEOUS mode.") .defineInRange("logs_max_count", 100, 1, Integer.MAX_VALUE); - lavesBreaking = builder.comment("When set to true, leaves that should naturally break will be broken instantly.") + leavesBreaking = builder.comment("When set to true, leaves that should naturally break will be broken instantly.") .define("leaves_breaking", true); - lavesBreakingForceRadius = builder.comment("Radius to force break leaves. If another tree is still holding the leaves they'll still be broken. If the leaves are persistent (placed by player) they'll also be destroyed.", + leavesBreakingForceRadius = builder.comment("Radius to force break leaves. If another tree is still holding the leaves they'll still be broken. If the leaves are persistent (placed by player) they'll also be destroyed.", "The radius is applied from one of the top most log blocks.", "INFO: break_leaves must be activated for this to take effect.", "INFO: Only in INSTANTANEOUS mode.") @@ -58,8 +58,8 @@ public Collection getBlacklistedLogs(){ return getAsBlocks(blacklistedLogs.get()); } - public int getLavesBreakingForceRadius(){ - return this.lavesBreakingForceRadius.get(); + public int getLeavesBreakingForceRadius(){ + return this.leavesBreakingForceRadius.get(); } public int getMaxSize(){ @@ -78,8 +78,8 @@ public Collection getWhitelistedLogs(){ return getAsBlocks(whitelistedLogs.get()); } - public boolean isLavesBreaking(){ - return this.lavesBreaking.get(); + public boolean isLeavesBreaking(){ + return this.leavesBreaking.get(); } public BreakMode getBreakMode(){ diff --git a/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java b/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java index 880aa328..b18db7b4 100644 --- a/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java +++ b/src/main/java/fr/raksrinana/fallingtree/tree/TreeHandler.java @@ -102,7 +102,7 @@ public static boolean destroyInstant(@Nonnull Tree tree, @Nonnull PlayerEntity p tool.damageItem(toolDamage, player, (entity) -> {}); } if(isTreeFullyBroken){ - final int radius = Config.COMMON.getTreesConfiguration().getLavesBreakingForceRadius(); + final int radius = Config.COMMON.getTreesConfiguration().getLeavesBreakingForceRadius(); if(radius > 0){ tree.getLogs().stream().max(Comparator.comparingInt(BlockPos::getY)).ifPresent(topLog -> { BlockPos.Mutable checkPos = new BlockPos.Mutable(); diff --git a/update.json b/update.json index d4a01543..ebba6397 100644 --- a/update.json +++ b/update.json @@ -2,6 +2,7 @@ "homepage": "https://github.com/RakSrinaNa/FallingTree", "changelog": "https://github.com/RakSrinaNa/FallingTree/blob/1.16.1/CHANGELOG.md", "1.16.1": { + "2.3.0": "https://github.com/RakSrinaNa/FallingTree/blob/1.16.1/CHANGELOG.md", "2.2.1": "https://github.com/RakSrinaNa/FallingTree/blob/1.16.1/CHANGELOG.md", "2.2.0": "https://github.com/RakSrinaNa/FallingTree/blob/1.16.1/CHANGELOG.md", "2.1.8": "https://github.com/RakSrinaNa/FallingTree/blob/1.16.1/CHANGELOG.md", @@ -11,7 +12,7 @@ "2.1.4": "https://github.com/RakSrinaNa/FallingTree/blob/1.16.1/CHANGELOG.md" }, "promos": { - "1.16.1-latest": "2.2.1", - "1.16.1-recommended": "2.2.1" + "1.16.1-latest": "2.3.0", + "1.16.1-recommended": "2.3.0" } } \ No newline at end of file