Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 30 additions & 40 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'fabric-loom' version '1.0.7'
id 'maven-publish'
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -31,56 +31,46 @@ dependencies {
}

processResources {
inputs.property "version", project.version
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
}
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

// Minecraft 1.18 upwards uses Java 17.
it.options.release = 17
it.options.release = 17
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
publications {
mavenJava(MavenPublication) {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.11
loader_version=0.14.9
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.8
loader_version=0.14.21

# Mod Properties
mod_version = 1.5.0
mod_version = 1.5.1
maven_group = leaf-decay
archives_base_name = leaf-decay

# Dependencies
fabric_version=0.60.0+1.19.2
fabric_version=0.84.0+1.20.1
cloth_config_version = 7.0.72
mod_menu_version = 4.0.0
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 23 additions & 12 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}

mavenCentral()
gradlePluginPortal()
}
}
}
33 changes: 19 additions & 14 deletions src/main/java/draylar/leafdecay/mixin/LogBreakMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import draylar.leafdecay.scheduler.FutureBlockBreak;
import draylar.leafdecay.scheduler.LeafBreakHandler;
import net.minecraft.block.*;
import net.minecraft.block.LeavesBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
Expand All @@ -15,20 +16,24 @@
@Mixin(Block.class)
public class LogBreakMixin {

@Inject(
method = "onBreak",
at = @At("TAIL")
)
private void afterBreak(World world, BlockPos pos, BlockState state, PlayerEntity player, CallbackInfo info) {
if (!world.isClient && (state.getBlock() instanceof PillarBlock) && state.getMaterial().equals(Material.WOOD)) {
BlockPos upPosition = pos.up();
BlockState upState = world.getBlockState(upPosition);
@Inject(method = "onBreak", at = @At("TAIL"))
private void afterBreak(World world, BlockPos pos, BlockState state,
PlayerEntity player, CallbackInfo info) {
if (!world.isClient && (state.getBlock() instanceof PillarBlock) &&
(state.isOf(Blocks.OAK_LOG) || state.isOf(Blocks.BIRCH_LOG) ||
state.isOf(Blocks.ACACIA_LOG) || state.isOf(Blocks.SPRUCE_LOG) ||
state.isOf(Blocks.JUNGLE_LOG) || state.isOf(Blocks.CHERRY_LOG) ||
state.isOf(Blocks.DARK_OAK_LOG) || state.isOf(Blocks.MANGROVE_LOG))) {

// trigger chain break on the leaf block above a log
if (upState.getBlock() instanceof LeavesBlock) {
FutureBlockBreak futureLeafBreak = new FutureBlockBreak((ServerWorld) world, upPosition, 4);
LeafBreakHandler.addFutureBreak(futureLeafBreak);
}
}
BlockPos upPosition = pos.up();
BlockState upState = world.getBlockState(upPosition);

// trigger chain break on the leaf block above a log
if (upState.getBlock() instanceof LeavesBlock) {
FutureBlockBreak futureLeafBreak =
new FutureBlockBreak((ServerWorld)world, upPosition, 4);
LeafBreakHandler.addFutureBreak(futureLeafBreak);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
import net.minecraft.block.BlockState;
import net.minecraft.block.LeavesBlock;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Pair;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class LeafBreakHandler {

Expand Down
13 changes: 5 additions & 8 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

{
"schemaVersion": 1,
"id": "leaf-decay",
"version": "${version}",

"name": "Leaf Decay",
"description": "Simple mod for quick leaf decay!",
"authors": [
Expand All @@ -14,10 +12,8 @@
"sources": "https://github.com/Draylar/leaf-decay",
"issues": "https://github.com/Draylar/leaf-decay/issues"
},

"license": "MIT",
"icon": "assets/leaf-decay/icon.png",

"environment": "*",
"entrypoints": {
"main": [
Expand All @@ -27,9 +23,10 @@
"mixins": [
"leafdecay.mixins.json"
],

"depends": {
"fabricloader": ">=0.7.0",
"fabric": ">=0.14.0"
"fabricloader": ">=0.14.21",
"minecraft": "~1.20.1",
"java": ">=17",
"fabric-api": "*"
}
}
}