diff --git a/.github/workflows/draftrelease.yml b/.github/workflows/draftrelease.yml index 0b7ee7f..9b6bd9e 100644 --- a/.github/workflows/draftrelease.yml +++ b/.github/workflows/draftrelease.yml @@ -1,12 +1,12 @@ # This workflow will build a Java project with Gradle # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle -name: fabric-1.16 - Draft release +name: fabric-1.8.9 - Draft release on: push: # Sequence of patterns matched against refs/tags - tags: 'v*-1.16' # Push events to matching v*-1.16 + tags: 'v*-1.8.9' # Push events to matching v*-1.8.9 jobs: build: diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index cdcc05e..9346217 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,13 +1,13 @@ # This workflow will build a Java project with Gradle # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle -name: fabric-1.16 - Snapshot +name: fabric-1.8.9 - Snapshot on: push: - branches: fabric-1.16 + branches: fabric-1.8.9 pull_request: - branches: fabric-1.16 + branches: fabric-1.8.9 jobs: build: diff --git a/build.gradle b/build.gradle index d7f1055..81b15a8 100644 --- a/build.gradle +++ b/build.gradle @@ -24,11 +24,41 @@ archivesBaseName = project.archives_base_name version = project.mod_version + "-" + project.minecraft_version group = project.maven_group +repositories { + mavenCentral() + jcenter() + maven { + name = 'Fabric' + url = 'http://maven.fabricmc.net/' + } + maven { + name = 'SpongePowered' + url = 'http://repo.spongepowered.org/maven' + } + maven { + name = 'mojang' + url = 'https://libraries.minecraft.net/' + } + maven { + name = 'legacy-fabric' + url = 'https://dl.bintray.com/legacy-fabric/Legacy-Fabric-Maven' + } +} + +minecraft { + intermediaryUrl = { + return "https://dl.bintray.com/legacy-fabric/Legacy-Fabric-Maven/net/fabricmc/intermediary/" + it + "/intermediary-" + it + "-v2.jar"; + } +} + dependencies { //to change the versions see the gradle.properties file + implementation "com.google.guava:guava:23.5-jre" minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + modImplementation ("net.fabricmc:fabric-loader-1.8.9:${project.loader_version}") { + exclude module: "guava" + } } import groovy.json.JsonSlurper diff --git a/gradle.properties b/gradle.properties index a053f78..b672dd1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,11 @@ # Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G +org.gradle.jvmargs=-Xmx2G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.16 - yarn_mappings=1.16+build.4 - loader_version=0.7.4+build.177 + minecraft_version = 1.8.9 + yarn_mappings = 1.8.9+build.202011050955 + loader_version = 0.9.3+build.202009100647 # Mod Properties mod_version = 1.0.1 diff --git a/src/main/java/com/github/NeRdTheNed/Punch2Prime/TntBlockMixin.java b/src/main/java/com/github/NeRdTheNed/Punch2Prime/TntBlockMixin.java index 03ed0f6..5730b3a 100644 --- a/src/main/java/com/github/NeRdTheNed/Punch2Prime/TntBlockMixin.java +++ b/src/main/java/com/github/NeRdTheNed/Punch2Prime/TntBlockMixin.java @@ -1,25 +1,60 @@ package com.github.NeRdTheNed.Punch2Prime; -import org.apache.logging.log4j.LogManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.ModifyArg; import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.TntBlock; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.stat.Stats; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; @Mixin(TntBlock.class) public abstract class TntBlockMixin extends Block { // Dummy constructor, I'm not sure if this is how it's supposed to be done or if I'm bad at Mixins. - public TntBlockMixin(Settings settings) { - super(settings); + public TntBlockMixin() { + super(null); } - @Inject(method = "", at = @At("TAIL")) - private void init(CallbackInfo a) { - setDefaultState(getDefaultState().with(TntBlock.UNSTABLE, true)); - LogManager.getLogger("Punch 2 Prime").info("Newly placed TNT will now be punchable!"); + // Fabric hacks :/ Overrides used to fix the vanilla bug of a TNT item dropping when the TNT is activated by punching it. + // I've attempted to retain "compatibility" with other mods by checking if the block is specifically a TNT block, so any other blocks extending the TNT block shouldn't be affected. + @Override + public void harvest(World world, PlayerEntity player, BlockPos pos, BlockState state, BlockEntity be) { + if (!state.getBlock().isEqualTo(Blocks.TNT)) { + super.harvest(world, player, pos, state, be); + return; + } + + player.incrementStat(Stats.BLOCK_STATS[getIdByBlock(this)]); + player.addExhaustion(0.025F); + } + + /** + * Doesn't work, no clue why :( + * + *
+	 * {@literal @}Inject(method = "", at {@literal @}At("TAIL"))
+	 * private void init(CallbackInfo a) {
+	 * 	setDefaultState(stateManager.getDefaultState().with(TntBlock.EXPLODE, true));
+	 * 	LogManager.getLogger("Punch 2 Prime").info("Newly placed TNT will now be punchable!");
+	 * }
+	 * 
+ */ + + // Hack to make the TNT block always explode when punched, as setting it as the default state doesn't work. + // I've attempted to retain "compatibility" with other mods by checking if the block is specifically a TNT block, so any other blocks extending the TNT block shouldn't be affected. + @ModifyArg(method = "onBreakByPlayer(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/TntBlock;method_1034(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/LivingEntity;)V")) + private BlockState method_1034(BlockState state) { + if (state.getBlock().isEqualTo(Blocks.TNT)) { + return state.with(TntBlock.EXPLODE, true); + } + + return state; } }