mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2024-12-21 16:17:37 +01:00
try to fix npe
This commit is contained in:
parent
41a7211715
commit
885f881a83
@ -1,7 +1,7 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
`java-library`
|
||||
id("net.minecrell.licenser") version "0.4.1"
|
||||
id("fabric-loom") version "0.6-SNAPSHOT"
|
||||
id("com.palantir.git-version") version "0.12.0-rc2"
|
||||
@ -136,20 +136,12 @@ tasks.withType<JavaCompile> {
|
||||
// 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.
|
||||
options.encoding = "UTF-8"
|
||||
|
||||
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
|
||||
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
|
||||
// We'll use that if it's available, but otherwise we'll use the older option.
|
||||
val targetVersion = 8
|
||||
if (JavaVersion.current().isJava9Compatible) {
|
||||
options.release.set(targetVersion)
|
||||
} else {
|
||||
sourceCompatibility = JavaVersion.toVersion(targetVersion).toString()
|
||||
targetCompatibility = JavaVersion.toVersion(targetVersion).toString()
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(8))
|
||||
}
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@ -110,7 +111,9 @@ public class VRHandItemProvider extends HandItemProvider {
|
||||
}
|
||||
|
||||
private Item fromNative(ItemStack original) {
|
||||
int id = swordId(Registry.ITEM.getId(original.getItem()).toString());
|
||||
Identifier iid = Registry.ITEM.getId(original.getItem());
|
||||
if (iid == null) return new Item(0, (byte) 0, (short) 0, null);
|
||||
int id = swordId(iid.toString());
|
||||
return new Item(id, (byte) original.getCount(), (short) original.getDamage(), null);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user