diff --git a/build.gradle b/build.gradle index e343c60..a170505 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ plugins { - id 'fabric-loom' version '0.2.7-SNAPSHOT' + id 'fabric-loom' version '0.8-SNAPSHOT' id "com.jfrog.bintray" version "1.8.4" id 'maven-publish' } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_16 +targetCompatibility = JavaVersion.VERSION_16 if(rootProject.file('private.gradle').exists()) { //Publishing details apply from: 'private.gradle' @@ -50,27 +50,22 @@ repositories { dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modCompile "net.fabricmc:fabric-loader:${project.loader_version}" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation ("grondag:fermion-mc116:${project.fermion_version}") { transitive = false } - modImplementation ("grondag:fermion-modkeys-mc116:${project.fermion_modkeys_version}") { transitive = false } - include "grondag:fermion-mc116:${project.fermion_version}" - include "grondag:fermion-modkeys-mc116:${project.fermion_modkeys_version}" + modImplementation ("grondag:fermion-mc117:${project.fermion_version}") { transitive = false } + modImplementation ("grondag:fermion-modkeys-mc117:${project.fermion_modkeys_version}") { transitive = false } + include "grondag:fermion-mc117:${project.fermion_version}" + include "grondag:fermion-modkeys-mc117:${project.fermion_modkeys_version}" } processResources { inputs.property "version", project.version - from(sourceSets.main.resources.srcDirs) { - include "fabric.mod.json" + filesMatching("fabric.mod.json") { expand "version": project.version } - - from(sourceSets.main.resources.srcDirs) { - exclude "fabric.mod.json" - } } // ensure that the encoding is set to UTF-8, no matter what the system default is @@ -78,6 +73,7 @@ processResources { // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html tasks.withType(JavaCompile) { options.encoding = "UTF-8" + options.release = 16 } // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task diff --git a/gradle.properties b/gradle.properties index 71a0130..d07aaf3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,18 +3,17 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version = 1.16.1 -yarn_mappings = 1.16.1+build.21 -loader_version = 0.9.0+build.204 -fabric_version=0.15.1+build.380-1.16.1 +minecraft_version = 1.17 +yarn_mappings = 1.17+build.5 +loader_version = 0.11.3 +fabric_version=0.34.9+1.17 # Mod Properties -mod_version = 1.0.0 +mod_version = 1.1.0 maven_group = com.zundrel archives_base_name = wrenchable # Dependencies -# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api -fermion_version=2.1.191 -fermion_modkeys_version=1.8.191 -modmenu_version=1.14.5+build.30 +fermion_version=2.11.241 +fermion_modkeys_version=1.10.241 +modmenu_version=1.16.8 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e8ec9b8..e5338d3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Sun Apr 05 08:38:40 BRT 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..8bb4a87 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +jdk: + - openjdk16 \ No newline at end of file diff --git a/src/main/java/com/zundrel/wrenchable/WrenchableEvents.java b/src/main/java/com/zundrel/wrenchable/WrenchableEvents.java index bab5448..d42cc7f 100644 --- a/src/main/java/com/zundrel/wrenchable/WrenchableEvents.java +++ b/src/main/java/com/zundrel/wrenchable/WrenchableEvents.java @@ -33,8 +33,8 @@ public static void init() { } } - if (!heldStack.isEmpty() && WrenchableUtilities.isWrench(heldStack.getItem())) { - Wrench wrench = WrenchableUtilities.getWrench(heldStack.getItem()); + if (!heldStack.isEmpty() && WrenchableUtilities.isWrench(heldStack)) { + Wrench wrench = WrenchableUtilities.getWrench(heldStack); if (world.getBlockState(pos).getBlock() instanceof BlockWrenchable) { wrench.onBlockWrenched(world, heldStack, playerEntity, hand, blockHitResult); @@ -82,8 +82,8 @@ public static void init() { UseEntityCallback.EVENT.register(((playerEntity, world, hand, entity, entityHitResult) -> { ItemStack heldStack = playerEntity.getStackInHand(hand); - if (!heldStack.isEmpty() && WrenchableUtilities.isWrench(heldStack.getItem())) { - Wrench wrench = WrenchableUtilities.getWrench(heldStack.getItem()); + if (!heldStack.isEmpty() && WrenchableUtilities.isWrench(heldStack)) { + Wrench wrench = WrenchableUtilities.getWrench(heldStack); if (entity instanceof EntityWrenchable) { wrench.onEntityWrenched(world, heldStack, playerEntity, hand, entityHitResult); diff --git a/src/main/java/com/zundrel/wrenchable/WrenchableUtilities.java b/src/main/java/com/zundrel/wrenchable/WrenchableUtilities.java index cf90000..66904a0 100644 --- a/src/main/java/com/zundrel/wrenchable/WrenchableUtilities.java +++ b/src/main/java/com/zundrel/wrenchable/WrenchableUtilities.java @@ -8,6 +8,7 @@ import net.minecraft.block.SkullBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.state.property.Properties; import net.minecraft.util.BlockRotation; import net.minecraft.util.hit.BlockHitResult; @@ -142,9 +143,9 @@ public static void doRotationBehavior(World world, PlayerEntity player, BlockHit if (ModKeys.isSecondaryPressed(player)) { if (block instanceof SkullBlock) - world.setBlockState(pos, state.with(Properties.ROTATION, MathHelper.floor((double)((player.yaw) * 16.0F / 360.0F) + 0.5D) & 15)); + world.setBlockState(pos, state.with(Properties.ROTATION, MathHelper.floor((double)((player.headYaw) * 16.0F / 360.0F) + 0.5D) & 15)); else - world.setBlockState(pos, state.with(Properties.ROTATION, MathHelper.floor((double)((180.0F + player.yaw) * 16.0F / 360.0F) + 0.5D) & 15)); + world.setBlockState(pos, state.with(Properties.ROTATION, MathHelper.floor((double)((180.0F + player.headYaw) * 16.0F / 360.0F) + 0.5D) & 15)); world.updateNeighbor(pos, block, pos); return; } @@ -170,8 +171,9 @@ public static void doRotationBehavior(World world, PlayerEntity player, BlockHit } } - public static Wrench getWrench(Item item) { - if (item instanceof Wrench) + public static Wrench getWrench(ItemStack stack) { + Item item = stack.getItem(); + if (item instanceof Wrench && ((Wrench) item).canWrench(stack)) return (Wrench) item; else if (WrenchableRegistry.isWrench(item)) return WrenchableRegistry.getWrench(item); @@ -179,7 +181,7 @@ else if (WrenchableRegistry.isWrench(item)) return null; } - public static boolean isWrench(Item item) { - return item instanceof Wrench || WrenchableRegistry.isWrench(item); + public static boolean isWrench(ItemStack stack) { + return (stack.getItem() instanceof Wrench && ((Wrench) stack.getItem()).canWrench(stack)) || WrenchableRegistry.isWrench(stack.getItem()); } } diff --git a/src/main/java/com/zundrel/wrenchable/block/defaults/PistonInstanceListener.java b/src/main/java/com/zundrel/wrenchable/block/defaults/PistonInstanceListener.java index bede979..0065e0e 100644 --- a/src/main/java/com/zundrel/wrenchable/block/defaults/PistonInstanceListener.java +++ b/src/main/java/com/zundrel/wrenchable/block/defaults/PistonInstanceListener.java @@ -30,7 +30,7 @@ public void onWrenched(World world, PlayerEntity player, BlockHitResult result) world.setBlockState(pos, Blocks.PISTON.getDefaultState().with(Properties.FACING, state.get(Properties.FACING))); world.playSound(null, pos, SoundEvents.ENTITY_SLIME_SQUISH, SoundCategory.BLOCKS, 1, 1F); if (!player.isCreative()) - player.inventory.offerOrDrop(world, new ItemStack(Items.SLIME_BALL)); + player.getInventory().offerOrDrop(new ItemStack(Items.SLIME_BALL)); return; } diff --git a/src/main/java/com/zundrel/wrenchable/block/defaults/SignInstanceListener.java b/src/main/java/com/zundrel/wrenchable/block/defaults/SignInstanceListener.java index 13ad74c..1da8d67 100644 --- a/src/main/java/com/zundrel/wrenchable/block/defaults/SignInstanceListener.java +++ b/src/main/java/com/zundrel/wrenchable/block/defaults/SignInstanceListener.java @@ -23,7 +23,7 @@ public void onWrenched(World world, PlayerEntity player, BlockHitResult result) SignBlockEntity blockEntity = (SignBlockEntity) world.getBlockEntity(pos); if (ModKeys.isPrimaryPressed(player) && world.getBlockEntity(result.getBlockPos()) instanceof SignBlockEntity) { - blockEntity.setEditor(player); + blockEntity.setEditor(player.getUuid()); if (world.isClient()) { blockEntity.setEditable(true); } diff --git a/src/main/java/com/zundrel/wrenchable/wrench/Wrench.java b/src/main/java/com/zundrel/wrenchable/wrench/Wrench.java index 4b9a8d8..43f57d2 100644 --- a/src/main/java/com/zundrel/wrenchable/wrench/Wrench.java +++ b/src/main/java/com/zundrel/wrenchable/wrench/Wrench.java @@ -42,4 +42,11 @@ public interface Wrench { * @author Zundrel */ default void onEntityWrenched(World world, ItemStack stack, PlayerEntity player, Hand hand, EntityHitResult result) {}; + + /** + * This method determines if a wrench can be used. Good for alternate modes. + * @param stack The wrench ItemStack which the player is currently holding. + * @author Zundrel + */ + default boolean canWrench(ItemStack stack) { return true; }; } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 4a5d4e3..43da8bb 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -28,7 +28,7 @@ ], "depends": { - "fabricloader": ">=0.4.0", + "fabricloader": ">=0.11.3", "fabric": "*" }, "custom": {