Skip to content
Open
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
26 changes: 11 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -50,34 +50,30 @@ 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
// 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
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 16
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
Expand Down
17 changes: 8 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk16
8 changes: 4 additions & 4 deletions src/main/java/com/zundrel/wrenchable/WrenchableEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/com/zundrel/wrenchable/WrenchableUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -170,16 +171,17 @@ 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);

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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/zundrel/wrenchable/wrench/Wrench.java
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
],

"depends": {
"fabricloader": ">=0.4.0",
"fabricloader": ">=0.11.3",
"fabric": "*"
},
"custom": {
Expand Down