Skip to content

Commit

Permalink
Fix #20 for 1.16.1 (Forge)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakambda committed Sep 4, 2020
1 parent f3175c1 commit 6cd95e4
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
.idea
build
eclipse
/logs
/run
/run-client
/run-server

version.properties
secrets.properties
secrets.properties
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
6 changes: 1 addition & 5 deletions changes.md
Original file line number Diff line number Diff line change
@@ -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.
* Perform less ticking on leaves (#20)
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 7 additions & 12 deletions src/main/java/fr/raksrinana/fallingtree/ForgeEventSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ 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();
BlockPos eventPos = event.getPos();
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));
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class TreeConfiguration{
private final ForgeConfigSpec.ConfigValue<BreakMode> 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.",
Expand All @@ -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.")
Expand All @@ -58,8 +58,8 @@ public Collection<Block> getBlacklistedLogs(){
return getAsBlocks(blacklistedLogs.get());
}

public int getLavesBreakingForceRadius(){
return this.lavesBreakingForceRadius.get();
public int getLeavesBreakingForceRadius(){
return this.leavesBreakingForceRadius.get();
}

public int getMaxSize(){
Expand All @@ -78,8 +78,8 @@ public Collection<Block> getWhitelistedLogs(){
return getAsBlocks(whitelistedLogs.get());
}

public boolean isLavesBreaking(){
return this.lavesBreaking.get();
public boolean isLeavesBreaking(){
return this.leavesBreaking.get();
}

public BreakMode getBreakMode(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions update.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}

0 comments on commit 6cd95e4

Please sign in to comment.