Skip to content

Commit

Permalink
1.16.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Flourick committed Sep 2, 2020
1 parent 52ac81c commit 17338c3
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 91 deletions.
12 changes: 3 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,14 @@ archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

minecraft {
}

dependencies {
//to change the versions see the gradle.properties file
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}"

// Fabric API. This is technically optional, but you probably want it anyway.
modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}

processResources {
Expand Down Expand Up @@ -63,7 +57,7 @@ publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(jar) {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx2G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.15.2
yarn_mappings=1.15.2+build.17
loader_version=0.7.2+build.174
minecraft_version=1.16.2
yarn_mappings=1.16.2+build.43
loader_version=0.9.2+build.206

# Mod Properties
mod_version = 1.0.5
mod_version = 1.0.6
maven_group = net.clayborn
archives_base_name = accurate-block-placement

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric
fabric_version=0.5.1+build.294-1.15
fabric_version=0.19.0+build.398-1.16
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
51 changes: 31 additions & 20 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down Expand Up @@ -109,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
Expand Down Expand Up @@ -138,19 +154,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

Expand All @@ -159,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
21 changes: 20 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
Original file line number Diff line number Diff line change
@@ -1,68 +1,47 @@
package net.clayborn.accurateblockplacement;

import java.util.UUID;

import org.lwjgl.glfw.GLFW;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry;
import net.fabricmc.fabric.api.event.client.ClientTickCallback;

import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.network.MessageType;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;

public class AccurateBlockPlacementMod implements ModInitializer
{
// global state
public static Boolean disableNormalItemUse = false;
public static boolean isAccurateBlockPlacementEnabled = true;

private static FabricKeyBinding keyBinding;
public static Boolean disableNormalItemUse = false;
public static boolean isAccurateBlockPlacementEnabled = true;

private static boolean wasAccurateBlockPlacementToggleKeyPressed = false;

final static String KEY_CATEGORY_NAME = "Accurate Block Placement";
public static MinecraftClient MC;

@Override
public void onInitialize()
{
keyBinding = FabricKeyBinding.Builder.create(
new Identifier("accurateblockplacement", "togglevanillaplacement"),
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_UNKNOWN,
KEY_CATEGORY_NAME
).build();
MC = MinecraftClient.getInstance();

KeyBindingRegistry.INSTANCE.addCategory(KEY_CATEGORY_NAME);
KeyBindingRegistry.INSTANCE.register(keyBinding);
KeyBinding keybind = KeyBindingHelper.registerKeyBinding(new KeyBinding("net.clayborn.accurateblockplacement.togglevanillaplacement", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_UNKNOWN, "Accurate Block Placement"));

ClientTickCallback.EVENT.register(e -> {
MinecraftClient client = MinecraftClient.getInstance();

if (client == null || client.inGameHud == null) return;

if(keyBinding.isPressed()) {
if(!wasAccurateBlockPlacementToggleKeyPressed) {
isAccurateBlockPlacementEnabled = !isAccurateBlockPlacementEnabled;

TranslatableText message = null;

if(isAccurateBlockPlacementEnabled) {
message = new TranslatableText("net.clayborn.accurateblockplacement.modplacementmodemessage");
}
else {
message = new TranslatableText("net.clayborn.accurateblockplacement.vanillaplacementmodemessage");
}

client.inGameHud.addChatMessage(MessageType.SYSTEM, message);
}
wasAccurateBlockPlacementToggleKeyPressed = true;
ClientTickEvents.END_CLIENT_TICK.register(e -> {
while(keybind.wasPressed()) {
isAccurateBlockPlacementEnabled = !isAccurateBlockPlacementEnabled;

TranslatableText message = null;

if(isAccurateBlockPlacementEnabled) {
message = new TranslatableText("net.clayborn.accurateblockplacement.modplacementmodemessage");
}
else {
message = new TranslatableText("net.clayborn.accurateblockplacement.vanillaplacementmodemessage");
}

MC.inGameHud.addChatMessage(MessageType.SYSTEM, message, UUID.fromString("00000000-0000-0000-0000-000000000000"));
}
else {
wasAccurateBlockPlacementToggleKeyPressed = false;
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.clayborn.accurateblockplacement.AccurateBlockPlacementMod;
import net.clayborn.accurateblockplacement.IKeyBindingAccessor;
import net.clayborn.accurateblockplacement.IMinecraftClientAccessor;

import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -113,7 +113,7 @@ private Boolean doesBlockHaveOverriddenActivateMethod(Block block)
// TODO: consider cache of results

try {
return !block.getClass().getMethod(blockActivateMethodName, BlockState.class, World.class, BlockPos.class, PlayerEntity.class, Hand.class, BlockHitResult.class).getDeclaringClass().equals(Block.class);
return !block.getClass().getMethod(blockActivateMethodName, BlockState.class, World.class, BlockPos.class, PlayerEntity.class, Hand.class, BlockHitResult.class).getDeclaringClass().equals(AbstractBlock.class);
}
catch(Exception e) {
System.out.println("[ERROR] Unable to find block " + block.getClass().getName() + " activate method!");
Expand Down Expand Up @@ -309,7 +309,7 @@ private void onUpdateTargetedEntityComplete(CallbackInfo info)
if(lastPlacedBlockPos != null && lastPlayerPlacedBlockPos != null) {
facingAxisPlayerPos = client.player.getPos().getComponentAlongAxis(targetPlacement.getSide().getAxis());
facingAxisPlayerLastPos = lastPlayerPlacedBlockPos.getComponentAlongAxis(targetPlacement.getSide().getAxis());
facingAxisLastPlacedPos = new Vec3d(lastPlacedBlockPos).getComponentAlongAxis(targetPlacement.getSide().getAxis());
facingAxisLastPlacedPos = new Vec3d(lastPlacedBlockPos.getX(), lastPlacedBlockPos.getY(), lastPlacedBlockPos.getZ()).getComponentAlongAxis(targetPlacement.getSide().getAxis());
}

IMinecraftClientAccessor clientAccessor = (IMinecraftClientAccessor) client;
Expand Down Expand Up @@ -364,7 +364,7 @@ private void onUpdateTargetedEntityComplete(CallbackInfo info)
}

// always run at least once if we reach here
// if this isn't a freshkey press, turn on the run once flag
// if this isn't a fresh key press, turn on the run once flag
Boolean runOnceFlag = !freshKeyPress;

// in case they manage to push the button multiple times per frame
Expand All @@ -383,7 +383,7 @@ private void onUpdateTargetedEntityComplete(CallbackInfo info)
}
else {
// prevent slow rounding error from eventually moving the player out of range
Vec3d summedLastPlayerPos = lastPlayerPlacedBlockPos.add(new Vec3d(targetPlacement.getSide().getVector()));
Vec3d summedLastPlayerPos = lastPlayerPlacedBlockPos.add(new Vec3d(targetPlacement.getSide().getVector().getX(), targetPlacement.getSide().getVector().getY(), targetPlacement.getSide().getVector().getZ()));

Vec3d newLastPlayerPlacedPos = null;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"key.accurateblockplacement.togglevanillaplacement": "Toggle Vanilla Placement (report bugs!)",
"net.clayborn.accurateblockplacement.togglevanillaplacement": "Toggle Vanilla Placement",
"net.clayborn.accurateblockplacement.modplacementmodemessage": "Accurate block placement mode is now enabled.",
"net.clayborn.accurateblockplacement.vanillaplacementmodemessage": "Vanilla block placement mode is now enabled (please report any bugs or issues)."
}
8 changes: 4 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"contact": {
"homepage": "https://minecraft.curseforge.com/projects/accurate-block-placement",
"sources": "https://github.com/orbwoi/AccurateBlockPlacement"
"sources": "https://github.com/Flourick/AccurateBlockPlacement"
},

"license": "MIT",
Expand All @@ -23,12 +23,12 @@
]
},
"mixins": [
"accurateblockplacement.mixins.json"
"accurateblockplacement.mixins.json"
],

"depends": {
"minecraft": "1.15.x",
"fabricloader": ">=0.7.0",
"minecraft": "1.16.x",
"fabricloader": ">=0.8.8",
"fabric": "*"
},
"custom": {
Expand Down

0 comments on commit 17338c3

Please sign in to comment.