Updated to 1.15
This commit is contained in:
parent
fe6a41e3f3
commit
63d7b6dec8
29
Jenkinsfile
vendored
Normal file
29
Jenkinsfile
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
stages {
|
||||||
|
stage('Clean') {
|
||||||
|
steps {
|
||||||
|
withCredentials([file(credentialsId: 'mod_build_secrets', variable: 'ORG_GRADLE_PROJECT_secretFile')]) {
|
||||||
|
echo 'Cleaning Project'
|
||||||
|
sh 'chmod +x gradlew'
|
||||||
|
sh './gradlew clean'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build and Deploy') {
|
||||||
|
steps {
|
||||||
|
withCredentials([file(credentialsId: 'mod_build_secrets', variable: 'ORG_GRADLE_PROJECT_secretFile')]) {
|
||||||
|
echo 'Building and Deploying to Maven'
|
||||||
|
sh './gradlew build publish'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
archive 'build/libs/**.jar'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
182
build.gradle
182
build.gradle
|
|
@ -9,41 +9,43 @@ buildscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
apply plugin: 'net.minecraftforge.gradle'
|
||||||
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
version = '1.0'
|
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
|
||||||
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
|
||||||
archivesBaseName = 'modid'
|
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
import net.minecraftforge.gradle.common.task.SignJar
|
||||||
|
import groovy.json.JsonSlurper
|
||||||
|
import groovy.json.JsonOutput
|
||||||
|
|
||||||
|
if (project.hasProperty('secretFile')) {
|
||||||
|
loadSecrets(new File((String) findProperty('secretFile')))
|
||||||
|
}
|
||||||
|
|
||||||
|
version = "${version}"
|
||||||
|
group = "tschipp.carryon"
|
||||||
|
archivesBaseName = "carryon-${minecraft_version}"
|
||||||
|
|
||||||
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
||||||
|
|
||||||
|
|
||||||
|
if (System.getenv('BUILD_NUMBER') != null) {
|
||||||
|
version += "." + System.getenv('BUILD_NUMBER')
|
||||||
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
// The mappings can be changed at any time, and must be in the following format.
|
mappings channel: 'snapshot', version: "${mcp_mappings}"
|
||||||
// snapshot_YYYYMMDD Snapshot are built nightly.
|
|
||||||
// stable_# Stables are built at the discretion of the MCP team.
|
|
||||||
// Use non-default mappings at your own risk. they may not always work.
|
|
||||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
|
||||||
mappings channel: 'snapshot', version: '20190719-1.14.3'
|
|
||||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
|
||||||
|
|
||||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
|
||||||
|
|
||||||
// Default run configurations.
|
|
||||||
// These can be tweaked, removed, or duplicated as needed.
|
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
workingDirectory project.file('run')
|
workingDirectory project.file('run')
|
||||||
|
|
||||||
// Recommended logging data for a userdev environment
|
|
||||||
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||||
|
|
||||||
// Recommended logging level for the console
|
|
||||||
property 'forge.logging.console.level', 'debug'
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
examplemod {
|
carryon {
|
||||||
source sourceSets.main
|
source sourceSets.main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,14 +54,12 @@ minecraft {
|
||||||
server {
|
server {
|
||||||
workingDirectory project.file('run')
|
workingDirectory project.file('run')
|
||||||
|
|
||||||
// Recommended logging data for a userdev environment
|
|
||||||
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||||
|
|
||||||
// Recommended logging level for the console
|
|
||||||
property 'forge.logging.console.level', 'debug'
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
examplemod {
|
carryon {
|
||||||
source sourceSets.main
|
source sourceSets.main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,16 +68,14 @@ minecraft {
|
||||||
data {
|
data {
|
||||||
workingDirectory project.file('run')
|
workingDirectory project.file('run')
|
||||||
|
|
||||||
// Recommended logging data for a userdev environment
|
|
||||||
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||||
|
|
||||||
// Recommended logging level for the console
|
|
||||||
property 'forge.logging.console.level', 'debug'
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
|
||||||
args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/')
|
args '--mod', 'carryon', '--all', '--output', file('src/generated/resources/')
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
examplemod {
|
carryon {
|
||||||
source sourceSets.main
|
source sourceSets.main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -85,65 +83,121 @@ minecraft {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url "https://maven.blamejared.com/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||||
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
|
|
||||||
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
|
||||||
minecraft 'net.minecraftforge:forge:1.14.4-28.1.0'
|
|
||||||
|
|
||||||
// You may put jars on which you depend on in ./libs or you may define them like so..
|
|
||||||
// compile "some.group:artifact:version:classifier"
|
|
||||||
// compile "some.group:artifact:version"
|
|
||||||
|
|
||||||
// Real examples
|
|
||||||
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
|
||||||
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
|
||||||
|
|
||||||
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
|
|
||||||
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
|
||||||
|
|
||||||
// These dependencies get remapped to your current MCP mappings
|
|
||||||
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
|
||||||
|
|
||||||
// For more info...
|
|
||||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
|
||||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example for how to get properties into the manifest for reading by the runtime..
|
// Example for how to get properties into the manifest for reading by the runtime..
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes([
|
attributes([
|
||||||
"Specification-Title": "examplemod",
|
"Specification-Title": "carryon",
|
||||||
"Specification-Vendor": "examplemodsareus",
|
"Specification-Vendor": "Carry On",
|
||||||
"Specification-Version": "1", // We are version 1 of ourselves
|
"Specification-Version": "1", // We are version 1 of ourselves
|
||||||
"Implementation-Title": project.name,
|
"Implementation-Title": project.name,
|
||||||
"Implementation-Version": "${version}",
|
"Implementation-Version": "${version}",
|
||||||
"Implementation-Vendor" :"examplemodsareus",
|
"Implementation-Vendor" :"Carry On",
|
||||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example configuration to allow publishing using the maven-publish task
|
jar.finalizedBy('reobfJar')
|
||||||
// we define a custom artifact that is sourced from the reobfJar output task
|
|
||||||
// and then declare that to be published
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||||
// Note you'll need to add a repository here
|
description = 'Creates a JAR containing the source code.'
|
||||||
def reobfFile = file("$buildDir/reobfJar/output.jar")
|
from sourceSets.main.allSource
|
||||||
def reobfArtifact = artifacts.add('default', reobfFile) {
|
classifier = 'sources'
|
||||||
type 'jar'
|
|
||||||
builtBy 'reobfJar'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||||
|
description = 'Creates a JAR containing the JavaDocs.'
|
||||||
|
from javadoc.destinationDir
|
||||||
|
classifier = 'javadoc'
|
||||||
|
}
|
||||||
|
|
||||||
|
task deobfJar(type: Jar) {
|
||||||
|
description = 'Creates a JAR containing the non-obfuscated compiled code.'
|
||||||
|
from sourceSets.main.output
|
||||||
|
classifier = "deobf"
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives sourcesJar
|
||||||
|
archives javadocJar
|
||||||
|
archives deobfJar
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|
||||||
publications {
|
publications {
|
||||||
|
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
artifact reobfArtifact
|
|
||||||
|
groupId project.group
|
||||||
|
artifactId project.archivesBaseName
|
||||||
|
version project.version
|
||||||
|
from components.java
|
||||||
|
|
||||||
|
// Allows the maven pom file to be modified.
|
||||||
|
pom.withXml {
|
||||||
|
|
||||||
|
// Go through all the dependencies.
|
||||||
|
asNode().dependencies.dependency.each { dep ->
|
||||||
|
|
||||||
|
println 'Surpressing artifact ' + dep.artifactId.last().value().last() + ' from maven dependencies.'
|
||||||
|
assert dep.parent().remove(dep)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
artifact sourcesJar {
|
||||||
|
|
||||||
|
classifier 'sources'
|
||||||
|
}
|
||||||
|
artifact javadocJar {
|
||||||
|
|
||||||
|
classifier 'javadoc'
|
||||||
|
}
|
||||||
|
artifact deobfJar {
|
||||||
|
|
||||||
|
classifier 'deobf'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
url "file:///${project.projectDir}/mcmodsrepo"
|
|
||||||
|
url "file://" + System.getenv("local_maven")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task signJar(type: SignJar, dependsOn: jar) {
|
||||||
|
// Skips if the keyStore property is missing.
|
||||||
|
onlyIf {
|
||||||
|
project.hasProperty('modkeyStore')
|
||||||
|
}
|
||||||
|
|
||||||
|
// findProperty allows us to reference the property without it existing.
|
||||||
|
// Using project.propName would cause the script to fail validation if
|
||||||
|
// the property did not exist.
|
||||||
|
keyStore = project.findProperty('modkeyStore')
|
||||||
|
alias = project.findProperty('modkeyStoreAlias')
|
||||||
|
storePass = project.findProperty('modkeyStorePass')
|
||||||
|
keyPass = project.findProperty('modkeyStoreKeyPass')
|
||||||
|
inputFile = jar.archivePath
|
||||||
|
outputFile = jar.archivePath
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runs this task automatically when build is ran.
|
||||||
|
build.dependsOn signJar
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
version=1.13
|
||||||
|
minecraft_version=1.15.2
|
||||||
|
mcp_mappings=20200514-1.15.1
|
||||||
|
forge_version=31.2.36
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import net.minecraftforge.fml.loading.FMLPaths;
|
import net.minecraftforge.fml.loading.FMLPaths;
|
||||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||||
|
import net.minecraftforge.forgespi.language.IModInfo;
|
||||||
import tschipp.carryon.common.config.Configs;
|
import tschipp.carryon.common.config.Configs;
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
import tschipp.carryon.common.scripting.ScriptReader;
|
import tschipp.carryon.common.scripting.ScriptReader;
|
||||||
|
|
@ -35,10 +36,9 @@ import tschipp.carryon.proxy.ServerProxy;
|
||||||
public class CarryOn
|
public class CarryOn
|
||||||
{
|
{
|
||||||
|
|
||||||
public static IProxy proxy = DistExecutor.runForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy());
|
public static IProxy proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> ServerProxy::new);
|
||||||
|
|
||||||
public static final String MODID = "carryon";
|
public static final String MODID = "carryon";
|
||||||
public static final String VERSION = "1.12.2";
|
|
||||||
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
|
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
|
||||||
public static final String DEPENDENCIES = "required-after:forge@[13.20.1.2386,);after:gamestages;";
|
public static final String DEPENDENCIES = "required-after:forge@[13.20.1.2386,);after:gamestages;";
|
||||||
public static final String CERTIFICATE_FINGERPRINT = "55e88f24d04398481ae6f1ce76f65fd776f14227";
|
public static final String CERTIFICATE_FINGERPRINT = "55e88f24d04398481ae6f1ce76f65fd776f14227";
|
||||||
|
|
@ -47,6 +47,7 @@ public class CarryOn
|
||||||
public static boolean FINGERPRINT_VIOLATED = false;
|
public static boolean FINGERPRINT_VIOLATED = false;
|
||||||
|
|
||||||
public static SimpleChannel network;
|
public static SimpleChannel network;
|
||||||
|
public static IModInfo info;
|
||||||
|
|
||||||
public CarryOn()
|
public CarryOn()
|
||||||
{
|
{
|
||||||
|
|
@ -58,13 +59,15 @@ public class CarryOn
|
||||||
Configs.loadConfig(Configs.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-client.toml"));
|
Configs.loadConfig(Configs.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-client.toml"));
|
||||||
Configs.loadConfig(Configs.SERVER_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-server.toml"));
|
Configs.loadConfig(Configs.SERVER_CONFIG, FMLPaths.CONFIGDIR.get().resolve("carryon-server.toml"));
|
||||||
|
|
||||||
|
info = ModLoadingContext.get().getActiveContainer().getModInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup(final FMLCommonSetupEvent event)
|
private void setup(final FMLCommonSetupEvent event)
|
||||||
{
|
{
|
||||||
|
String version = info.getVersion().toString();
|
||||||
// PreInitevent.
|
// PreInitevent.
|
||||||
ScriptReader.preInit();
|
ScriptReader.preInit();
|
||||||
CarryOn.network = NetworkRegistry.newSimpleChannel(new ResourceLocation(CarryOn.MODID, "carryonpackets"), () -> CarryOn.VERSION, s -> true, s -> true);
|
CarryOn.network = NetworkRegistry.newSimpleChannel(new ResourceLocation(CarryOn.MODID, "carryonpackets"), () -> version, version::equals, version::equals);
|
||||||
|
|
||||||
// CLIENT PACKETS
|
// CLIENT PACKETS
|
||||||
CarryOn.network.registerMessage(0, CarrySlotPacket.class, CarrySlotPacket::toBytes, CarrySlotPacket::new, CarrySlotPacket::handle);
|
CarryOn.network.registerMessage(0, CarrySlotPacket.class, CarrySlotPacket::toBytes, CarrySlotPacket::new, CarrySlotPacket::handle);
|
||||||
|
|
@ -73,14 +76,12 @@ public class CarryOn
|
||||||
// SERVER PACKETS
|
// SERVER PACKETS
|
||||||
CarryOn.network.registerMessage(2, SyncKeybindPacket.class, SyncKeybindPacket::toBytes, SyncKeybindPacket::new, SyncKeybindPacket::handle);
|
CarryOn.network.registerMessage(2, SyncKeybindPacket.class, SyncKeybindPacket::toBytes, SyncKeybindPacket::new, SyncKeybindPacket::handle);
|
||||||
|
|
||||||
|
|
||||||
RegistrationHandler.regCommonEvents();
|
RegistrationHandler.regCommonEvents();
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
ScriptReader.parseScripts();
|
ScriptReader.parseScripts();
|
||||||
RegistrationHandler.regOverrideList();
|
RegistrationHandler.regOverrideList();
|
||||||
RegistrationHandler.regCaps();
|
RegistrationHandler.regCaps();
|
||||||
|
|
||||||
|
|
||||||
proxy.setup(event);
|
proxy.setup(event);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,37 +2,35 @@ package tschipp.carryon.client.event;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GLX;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
|
import net.minecraft.client.renderer.Vector3f;
|
||||||
|
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
|
import tschipp.carryon.client.helper.CarryRenderHelper;
|
||||||
import tschipp.carryon.common.handler.RegistrationHandler;
|
import tschipp.carryon.common.handler.RegistrationHandler;
|
||||||
import tschipp.carryon.common.helper.ScriptParseHelper;
|
|
||||||
import tschipp.carryon.common.item.ItemCarryonEntity;
|
import tschipp.carryon.common.item.ItemCarryonEntity;
|
||||||
import tschipp.carryon.common.scripting.CarryOnOverride;
|
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||||
import tschipp.carryon.common.scripting.ScriptChecker;
|
import tschipp.carryon.common.scripting.ScriptChecker;
|
||||||
|
|
||||||
public class RenderEntityEvents
|
public class RenderEntityEvents
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Renders the Entity in First Person
|
* Renders the Entity in First Person
|
||||||
*/
|
*/
|
||||||
|
|
@ -45,45 +43,47 @@ public class RenderEntityEvents
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
int perspective = Minecraft.getInstance().gameSettings.thirdPersonView;
|
int perspective = Minecraft.getInstance().gameSettings.thirdPersonView;
|
||||||
float partialticks = event.getPartialTicks();
|
float partialticks = event.getPartialTicks();
|
||||||
|
MatrixStack matrix = event.getMatrixStack();
|
||||||
|
int light = event.getLight();
|
||||||
|
IRenderTypeBuffer buffer = event.getBuffers();
|
||||||
|
EntityRendererManager manager = Minecraft.getInstance().getRenderManager();
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
{
|
{
|
||||||
if(ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr"))
|
if(ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
Entity entity = ItemCarryonEntity.getEntity(stack, world);
|
Entity entity = ItemCarryonEntity.getEntity(stack, world);
|
||||||
|
|
||||||
if (entity != null)
|
if (entity != null)
|
||||||
{
|
{
|
||||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks;
|
Vec3d playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
||||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks;
|
|
||||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialticks;
|
entity.setPosition(playerpos.x, playerpos.y, playerpos.z);
|
||||||
|
|
||||||
entity.setPosition(d0, d1, d2);
|
|
||||||
entity.rotationYaw = 0.0f;
|
entity.rotationYaw = 0.0f;
|
||||||
entity.prevRotationYaw = 0.0f;
|
entity.prevRotationYaw = 0.0f;
|
||||||
entity.setRotationYawHead(0.0f);
|
entity.setRotationYawHead(0.0f);
|
||||||
|
|
||||||
float height = entity.getHeight();
|
float height = entity.getHeight();
|
||||||
float width = entity.getWidth();
|
float width = entity.getWidth();
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
GlStateManager.scaled(.8, .8, .8);
|
matrix.push();
|
||||||
GlStateManager.rotatef(180, 0, 1, 0);
|
matrix.scale(0.8f, 0.8f, 0.8f);
|
||||||
GlStateManager.translated(0.0, -height - .1, width + 0.1);
|
matrix.rotate(Vector3f.YP.rotationDegrees(180));
|
||||||
GlStateManager.enableAlphaTest();
|
matrix.translate(0.0, -height - .1, width + 0.1);
|
||||||
|
|
||||||
|
RenderSystem.enableAlphaTest();
|
||||||
|
|
||||||
if (perspective == 0)
|
if (perspective == 0)
|
||||||
{
|
{
|
||||||
RenderHelper.enableStandardItemLighting();
|
RenderHelper.enableStandardItemLighting();
|
||||||
Minecraft.getInstance().getRenderManager().setRenderShadow(false);
|
manager.setRenderShadow(false);
|
||||||
|
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
if (carryOverride != null)
|
if (carryOverride != null)
|
||||||
{
|
{
|
||||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
||||||
double[] rotation = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
|
||||||
double[] scaled = ScriptParseHelper.getscaled(carryOverride.getRenderscaled());
|
|
||||||
String entityname = carryOverride.getRenderNameEntity();
|
String entityname = carryOverride.getRenderNameEntity();
|
||||||
if (entityname != null)
|
if (entityname != null)
|
||||||
{
|
{
|
||||||
|
|
@ -99,37 +99,26 @@ public class RenderEntityEvents
|
||||||
if (nbttag != null)
|
if (nbttag != null)
|
||||||
newEntity.deserializeNBT(nbttag);
|
newEntity.deserializeNBT(nbttag);
|
||||||
entity = newEntity;
|
entity = newEntity;
|
||||||
entity.setPosition(d0, d1, d2);
|
entity.setPosition(playerpos.x, playerpos.y, playerpos.z);
|
||||||
entity.rotationYaw = 0.0f;
|
entity.rotationYaw = 0.0f;
|
||||||
entity.prevRotationYaw = 0.0f;
|
entity.prevRotationYaw = 0.0f;
|
||||||
entity.setRotationYawHead(0.0f);
|
entity.setRotationYawHead(0.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.translated(translation[0], translation[1], translation[2]);
|
|
||||||
GlStateManager.rotatef((float) rotation[0], 1, 0, 0);
|
|
||||||
GlStateManager.rotatef((float) rotation[1], 0, 1, 0);
|
|
||||||
GlStateManager.rotatef((float) rotation[2], 0, 0, 1);
|
|
||||||
GlStateManager.scaled(scaled[0], scaled[1], scaled[2]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity instanceof LivingEntity)
|
if(entity instanceof LivingEntity)
|
||||||
((LivingEntity) entity).hurtTime = 0;
|
((LivingEntity) entity).hurtTime = 0;
|
||||||
|
|
||||||
this.renderEntityStatic(entity);
|
manager.renderEntityStatic(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
||||||
Minecraft.getInstance().getRenderManager().setRenderShadow(true);
|
manager.setRenderShadow(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.disableAlphaTest();
|
RenderSystem.disableAlphaTest();
|
||||||
GlStateManager.scaled(1, 1, 1);
|
matrix.pop();
|
||||||
GlStateManager.popMatrix();
|
|
||||||
|
|
||||||
RenderHelper.disableStandardItemLighting();
|
RenderHelper.disableStandardItemLighting();
|
||||||
GlStateManager.disableRescaleNormal();
|
RenderSystem.disableRescaleNormal();
|
||||||
GlStateManager.activeTexture(GLX.GL_TEXTURE1);
|
|
||||||
GlStateManager.disableTexture();
|
|
||||||
GlStateManager.activeTexture(GLX.GL_TEXTURE0);
|
|
||||||
|
|
||||||
if (perspective == 0)
|
if (perspective == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -138,182 +127,4 @@ public class RenderEntityEvents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
private void renderEntityStatic(Entity entity)
|
|
||||||
{
|
|
||||||
if (entity.ticksExisted == 0)
|
|
||||||
{
|
|
||||||
entity.lastTickPosX = entity.posX;
|
|
||||||
entity.lastTickPosY = entity.posY;
|
|
||||||
entity.lastTickPosZ = entity.posZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
float f = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw);
|
|
||||||
int i = this.getBrightnessForRender(entity, Minecraft.getInstance().player);
|
|
||||||
|
|
||||||
if (entity.isBurning())
|
|
||||||
{
|
|
||||||
i = 15728880;
|
|
||||||
}
|
|
||||||
|
|
||||||
int j = i % 65536;
|
|
||||||
int k = i / 65536;
|
|
||||||
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, j, k);
|
|
||||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
|
|
||||||
this.setLightmapDisabled(false);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Minecraft.getInstance().getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, f, 0.0F, true);
|
|
||||||
this.setLightmapDisabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
private int getBrightnessForRender(Entity entity, PlayerEntity player)
|
|
||||||
{
|
|
||||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(player.posX), 0, MathHelper.floor(player.posZ));
|
|
||||||
|
|
||||||
if (entity.world.isBlockLoaded(blockpos$mutableblockpos))
|
|
||||||
{
|
|
||||||
blockpos$mutableblockpos.setY(MathHelper.floor(player.posY + entity.getEyeHeight()));
|
|
||||||
return entity.world.getCombinedLight(blockpos$mutableblockpos, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
private void setLightmapDisabled(boolean disabled)
|
|
||||||
{
|
|
||||||
GlStateManager.activeTexture(GLX.GL_TEXTURE1);
|
|
||||||
|
|
||||||
if (disabled)
|
|
||||||
{
|
|
||||||
GlStateManager.disableTexture();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GlStateManager.enableTexture();
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.activeTexture(GLX.GL_TEXTURE0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Renders the Entity in Third Person
|
|
||||||
*/
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onPlayerRenderPost(RenderPlayerEvent.Post event)
|
|
||||||
{
|
|
||||||
World world = Minecraft.getInstance().world;
|
|
||||||
PlayerEntity player = event.getPlayer();
|
|
||||||
ClientPlayerEntity clientPlayer = Minecraft.getInstance().player;
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
|
||||||
float partialticks = event.getPartialRenderTick();
|
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
|
||||||
{
|
|
||||||
Entity entity = ItemCarryonEntity.getEntity(stack, world);
|
|
||||||
float rotation = 0;
|
|
||||||
|
|
||||||
if (player.getRidingEntity() != null && player.getRidingEntity() instanceof LivingEntity)
|
|
||||||
rotation = -(player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialticks);
|
|
||||||
else
|
|
||||||
rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
|
|
||||||
|
|
||||||
if (entity != null)
|
|
||||||
{
|
|
||||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks;
|
|
||||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks;
|
|
||||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialticks;
|
|
||||||
|
|
||||||
double c0 = clientPlayer.lastTickPosX + (clientPlayer.posX - clientPlayer.lastTickPosX) * partialticks;
|
|
||||||
double c1 = clientPlayer.lastTickPosY + (clientPlayer.posY - clientPlayer.lastTickPosY) * partialticks;
|
|
||||||
double c2 = clientPlayer.lastTickPosZ + (clientPlayer.posZ - clientPlayer.lastTickPosZ) * partialticks;
|
|
||||||
|
|
||||||
Vec3d cameraPos = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView();
|
|
||||||
|
|
||||||
double xOffset = d0 - cameraPos.getX();
|
|
||||||
double yOffset = d1 - cameraPos.getY();
|
|
||||||
double zOffset = d2 - cameraPos.getZ();
|
|
||||||
|
|
||||||
float height = entity.getHeight();
|
|
||||||
float width = entity.getWidth();
|
|
||||||
float multiplier = height * width;
|
|
||||||
|
|
||||||
entity.setPosition(c0, c1, c2);
|
|
||||||
entity.rotationYaw = 0.0f;
|
|
||||||
entity.prevRotationYaw = 0.0f;
|
|
||||||
entity.setRotationYawHead(0.0f);
|
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
GlStateManager.translated(xOffset, yOffset, zOffset);
|
|
||||||
GlStateManager.scaled((10 - multiplier) * 0.08, (10 - multiplier) * 0.08, (10 - multiplier) * 0.08);
|
|
||||||
GlStateManager.rotatef(rotation, 0, 1f, 0);
|
|
||||||
GlStateManager.translated(0.0, height / 2 + -(height / 2) + 1, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
|
||||||
|
|
||||||
if((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && Minecraft.getInstance().gameSettings.thirdPersonView == 0)
|
|
||||||
GlStateManager.translated(0, 0, -0.3);
|
|
||||||
|
|
||||||
if (RenderEvents.doSneakCheck(player))
|
|
||||||
{
|
|
||||||
GlStateManager.translated(0, -0.3, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Minecraft.getInstance().getRenderManager().setRenderShadow(false);
|
|
||||||
|
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
|
||||||
if (carryOverride != null)
|
|
||||||
{
|
|
||||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
|
||||||
double[] rot = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
|
||||||
double[] scaled = ScriptParseHelper.getscaled(carryOverride.getRenderscaled());
|
|
||||||
String entityname = carryOverride.getRenderNameEntity();
|
|
||||||
if (entityname != null)
|
|
||||||
{
|
|
||||||
Entity newEntity = null;
|
|
||||||
|
|
||||||
Optional<EntityType<?>> type = EntityType.byKey(entityname);
|
|
||||||
if(type.isPresent())
|
|
||||||
newEntity = type.get().create(world);
|
|
||||||
|
|
||||||
if (newEntity != null)
|
|
||||||
{
|
|
||||||
CompoundNBT nbttag = carryOverride.getRenderNBT();
|
|
||||||
if (nbttag != null)
|
|
||||||
newEntity.deserializeNBT(nbttag);
|
|
||||||
entity = newEntity;
|
|
||||||
entity.setPosition(c0, c1, c2);
|
|
||||||
entity.rotationYaw = 0.0f;
|
|
||||||
entity.prevRotationYaw = 0.0f;
|
|
||||||
entity.setRotationYawHead(0.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.translated(translation[0], translation[1], translation[2]);
|
|
||||||
GlStateManager.rotatef((float) rot[0], 1, 0, 0);
|
|
||||||
GlStateManager.rotatef((float) rot[1], 0, 1, 0);
|
|
||||||
GlStateManager.rotatef((float) rot[2], 0, 0, 1);
|
|
||||||
GlStateManager.scaled(scaled[0], scaled[1], scaled[2]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(entity instanceof LivingEntity)
|
|
||||||
((LivingEntity) entity).hurtTime = 0;
|
|
||||||
|
|
||||||
renderEntityStatic(entity);
|
|
||||||
Minecraft.getInstance().getRenderManager().setRenderShadow(true);
|
|
||||||
|
|
||||||
GlStateManager.scaled(1, 1, 1);
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
package tschipp.carryon.client.event;
|
package tschipp.carryon.client.event;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GLX;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
|
@ -12,20 +14,28 @@ import net.minecraft.client.GameSettings;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
import net.minecraft.client.renderer.IRenderTypeBuffer.Impl;
|
||||||
|
import net.minecraft.client.renderer.Quaternion;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.client.renderer.Vector3f;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||||
import net.minecraft.client.renderer.entity.PlayerRenderer;
|
import net.minecraft.client.renderer.entity.PlayerRenderer;
|
||||||
import net.minecraft.client.renderer.entity.model.PlayerModel;
|
import net.minecraft.client.renderer.entity.model.PlayerModel;
|
||||||
import net.minecraft.client.renderer.entity.model.RendererModel;
|
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
|
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.Pose;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
|
@ -38,7 +48,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||||
import net.minecraftforge.client.event.RenderSpecificHandEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
import net.minecraftforge.event.TickEvent.PlayerTickEvent;
|
import net.minecraftforge.event.TickEvent.PlayerTickEvent;
|
||||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
|
|
@ -46,6 +56,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.LogicalSide;
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
|
import tschipp.carryon.client.helper.CarryRenderHelper;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
import tschipp.carryon.common.config.Configs.Settings;
|
import tschipp.carryon.common.config.Configs.Settings;
|
||||||
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||||
|
|
@ -101,7 +112,8 @@ public class RenderEvents
|
||||||
{
|
{
|
||||||
CarryOnKeybinds.setKeyPressed(player, true);
|
CarryOnKeybinds.setKeyPressed(player, true);
|
||||||
CarryOn.network.sendToServer(new SyncKeybindPacket(true));
|
CarryOn.network.sendToServer(new SyncKeybindPacket(true));
|
||||||
} else if (!keyPressed && playerKeyPressed)
|
}
|
||||||
|
else if (!keyPressed && playerKeyPressed)
|
||||||
{
|
{
|
||||||
CarryOnKeybinds.setKeyPressed(player, false);
|
CarryOnKeybinds.setKeyPressed(player, false);
|
||||||
CarryOn.network.sendToServer(new SyncKeybindPacket(false));
|
CarryOn.network.sendToServer(new SyncKeybindPacket(false));
|
||||||
|
|
@ -212,6 +224,7 @@ public class RenderEvents
|
||||||
/*
|
/*
|
||||||
* Renders the Block in First Person
|
* Renders the Block in First Person
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void renderHand(RenderHandEvent event)
|
public void renderHand(RenderHandEvent event)
|
||||||
|
|
@ -221,6 +234,9 @@ public class RenderEvents
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
int perspective = Minecraft.getInstance().gameSettings.thirdPersonView;
|
int perspective = Minecraft.getInstance().gameSettings.thirdPersonView;
|
||||||
boolean f1 = Minecraft.getInstance().gameSettings.hideGUI;
|
boolean f1 = Minecraft.getInstance().gameSettings.hideGUI;
|
||||||
|
IRenderTypeBuffer buffer = event.getBuffers();
|
||||||
|
MatrixStack matrix = event.getMatrixStack();
|
||||||
|
int light = event.getLight();
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) && perspective == 0 && !f1)
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) && perspective == 0 && !f1)
|
||||||
{
|
{
|
||||||
|
|
@ -232,18 +248,20 @@ public class RenderEvents
|
||||||
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
||||||
ItemStack tileStack = ItemCarryonBlock.getItemStack(stack);
|
ItemStack tileStack = ItemCarryonBlock.getItemStack(stack);
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
matrix.push();
|
||||||
GlStateManager.scaled(2.5, 2.5, 2.5);
|
matrix.scale(2.5f, 2.5f, 2.5f);
|
||||||
GlStateManager.translated(0, -0.6, -1);
|
matrix.translate(0, -0.5, -1);
|
||||||
GlStateManager.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
|
RenderSystem.disableCull();
|
||||||
|
|
||||||
if (Settings.facePlayer.get() ? !isChest(block) : isChest(block))
|
if (Settings.facePlayer.get() ? !isChest(block) : isChest(block))
|
||||||
{
|
{
|
||||||
GlStateManager.rotatef(180, 0, 1f, 0);
|
matrix.rotate(Vector3f.YP.rotationDegrees(180));
|
||||||
GlStateManager.rotatef(-8, 1f, 0, 0);
|
matrix.rotate(Vector3f.XN.rotationDegrees(8));
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
GlStateManager.rotatef(8, 1f, 0, 0);
|
matrix.rotate(Vector3f.XP.rotationDegrees(8));
|
||||||
}
|
}
|
||||||
|
|
||||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileStack.isEmpty() ? Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state) : Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(tileStack, world, player));
|
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileStack.isEmpty() ? Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state) : Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(tileStack, world, player));
|
||||||
|
|
@ -251,9 +269,8 @@ public class RenderEvents
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
if (carryOverride != null)
|
if (carryOverride != null)
|
||||||
{
|
{
|
||||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
||||||
double[] rotation = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
|
||||||
double[] scaled = ScriptParseHelper.getscaled(carryOverride.getRenderscaled());
|
|
||||||
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
||||||
if (b != null)
|
if (b != null)
|
||||||
{
|
{
|
||||||
|
|
@ -261,246 +278,323 @@ public class RenderEvents
|
||||||
s.setTag(carryOverride.getRenderNBT());
|
s.setTag(carryOverride.getRenderNBT());
|
||||||
model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(s, world, player);
|
model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(s, world, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.translated(translation[0], translation[1], translation[2]);
|
|
||||||
GlStateManager.rotatef((float) rotation[0], 1, 0, 0);
|
|
||||||
GlStateManager.rotatef((float) rotation[1], 0, 1, 0);
|
|
||||||
GlStateManager.rotatef((float) rotation[2], 0, 0, 1);
|
|
||||||
GlStateManager.scaled(scaled[0], scaled[1], scaled[2]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = this.getBrightnessForRender(Minecraft.getInstance().player);
|
|
||||||
int j = i % 65536;
|
|
||||||
int k = i / 65536;
|
|
||||||
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, j, k);
|
|
||||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
this.setLightmapDisabled(false);
|
|
||||||
|
|
||||||
Minecraft.getInstance().getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
Minecraft.getInstance().getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||||
|
|
||||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, tag))
|
CarryRenderHelper.renderItem(state, tag, stack, tileStack, matrix, buffer, light, model);
|
||||||
{
|
|
||||||
Object override = ModelOverridesHandler.getOverrideObject(state, tag);
|
|
||||||
|
|
||||||
if (override instanceof ItemStack)
|
|
||||||
{
|
|
||||||
|
|
||||||
Minecraft.getInstance().getItemRenderer().renderItem((ItemStack) override, model);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
Minecraft.getInstance().getItemRenderer().renderItem(tileStack.isEmpty() ? stack : tileStack, model);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
Minecraft.getInstance().getItemRenderer().renderItem(tileStack.isEmpty() ? stack : tileStack, model);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setLightmapDisabled(true);
|
|
||||||
|
|
||||||
if (perspective == 0)
|
if (perspective == 0)
|
||||||
{
|
{
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.disableBlend();
|
RenderSystem.enableCull();
|
||||||
GlStateManager.scaled(1, 1, 1);
|
RenderSystem.disableBlend();
|
||||||
GlStateManager.popMatrix();
|
matrix.pop();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
private int getBrightnessForRender(PlayerEntity player)
|
|
||||||
{
|
|
||||||
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(player.posX), 0, MathHelper.floor(player.posZ));
|
|
||||||
|
|
||||||
if (player.world.isBlockLoaded(blockpos$mutableblockpos))
|
|
||||||
{
|
|
||||||
blockpos$mutableblockpos.setY(MathHelper.floor(player.posY + player.getEyeHeight()));
|
|
||||||
return player.world.getCombinedLight(blockpos$mutableblockpos, 0);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
private void setLightmapDisabled(boolean disabled)
|
|
||||||
{
|
|
||||||
GlStateManager.activeTexture(GLX.GL_TEXTURE1);
|
|
||||||
|
|
||||||
if (disabled)
|
|
||||||
{
|
|
||||||
GlStateManager.disableTexture();;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
GlStateManager.enableTexture();
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.activeTexture(GLX.GL_TEXTURE0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Renders the Block in Third Person
|
* Render blocks and entities in third person
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPlayerRenderPost(RenderPlayerEvent.Post event)
|
public void onRenderWorld(RenderWorldLastEvent event)
|
||||||
{
|
{
|
||||||
World world = Minecraft.getInstance().world;
|
World world = Minecraft.getInstance().world;
|
||||||
PlayerEntity player = event.getPlayer();
|
float partialticks = event.getPartialTicks();
|
||||||
// ClientPlayerEntity clientPlayer = Minecraft.getInstance().player;
|
Impl buffer = IRenderTypeBuffer.getImpl(Tessellator.getInstance().getBuffer());
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
MatrixStack matrix = event.getMatrixStack();
|
||||||
float partialticks = event.getPartialRenderTick();
|
int light = 0;
|
||||||
|
int perspective = Minecraft.getInstance().gameSettings.thirdPersonView;
|
||||||
|
EntityRendererManager manager = Minecraft.getInstance().getRenderManager();
|
||||||
|
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
RenderSystem.enableBlend();
|
||||||
|
RenderSystem.disableCull();
|
||||||
|
RenderSystem.disableDepthTest();
|
||||||
|
|
||||||
|
for (PlayerEntity player : world.getPlayers())
|
||||||
{
|
{
|
||||||
Block block = ItemCarryonBlock.getBlock(stack);
|
if (perspective == 0 && player == Minecraft.getInstance().player)
|
||||||
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
continue;
|
||||||
CompoundNBT tag = ItemCarryonBlock.getTileData(stack);
|
|
||||||
ItemStack tileItem = ItemCarryonBlock.getItemStack(stack);
|
|
||||||
|
|
||||||
float rotation = 0f;
|
light = Minecraft.getInstance().getRenderManager().getPackedLight(player, partialticks);
|
||||||
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
|
|
||||||
if (player.getRidingEntity() != null && player.getRidingEntity() instanceof LivingEntity)
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack))
|
||||||
rotation = -(player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialticks);
|
|
||||||
else
|
|
||||||
rotation = -(player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
|
|
||||||
|
|
||||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks;
|
|
||||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks;
|
|
||||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialticks;
|
|
||||||
|
|
||||||
|
|
||||||
Vec3d cameraPos = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView();
|
|
||||||
|
|
||||||
double xOffset = d0 - cameraPos.getX();
|
|
||||||
double yOffset = d1 - cameraPos.getY();
|
|
||||||
double zOffset = d2 - cameraPos.getZ();
|
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
GlStateManager.translated(xOffset, yOffset, zOffset);
|
|
||||||
GlStateManager.scaled(0.6, 0.6, 0.6);
|
|
||||||
GlStateManager.enableBlend();
|
|
||||||
|
|
||||||
if (Settings.facePlayer.get() ? !isChest(block) : isChest(block))
|
|
||||||
{
|
{
|
||||||
GlStateManager.rotatef(rotation, 0, 1.0f, 0);
|
Block block = ItemCarryonBlock.getBlock(stack);
|
||||||
GlStateManager.translated(0, 1.6, 0.65);
|
BlockState state = ItemCarryonBlock.getBlockState(stack);
|
||||||
if ((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && Minecraft.getInstance().gameSettings.thirdPersonView == 0)
|
CompoundNBT tag = ItemCarryonBlock.getTileData(stack);
|
||||||
GlStateManager.translated(0, 0, -0.4);
|
ItemStack tileItem = ItemCarryonBlock.getItemStack(stack);
|
||||||
} else
|
|
||||||
{
|
|
||||||
GlStateManager.rotatef(rotation + 180, 0, 1.0f, 0);
|
|
||||||
GlStateManager.translated(0, 1.6, -0.65);
|
|
||||||
if ((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && Minecraft.getInstance().gameSettings.thirdPersonView == 0)
|
|
||||||
GlStateManager.translated(0, 0, 0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doSneakCheck(player))
|
applyBlockTransformations(player, partialticks, matrix, block);
|
||||||
{
|
|
||||||
GlStateManager.translated(0, -0.3, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileItem.isEmpty() ? Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state) : Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(tileItem, world, player));
|
IBakedModel model = ModelOverridesHandler.hasCustomOverrideModel(state, tag) ? ModelOverridesHandler.getCustomOverrideModel(state, tag, world, player) : (tileItem.isEmpty() ? Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state) : Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(tileItem, world, player));
|
||||||
|
|
||||||
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
if (carryOverride != null)
|
if (carryOverride != null)
|
||||||
{
|
|
||||||
double[] translation = ScriptParseHelper.getXYZArray(carryOverride.getRenderTranslation());
|
|
||||||
double[] rot = ScriptParseHelper.getXYZArray(carryOverride.getRenderRotation());
|
|
||||||
double[] scaled = ScriptParseHelper.getscaled(carryOverride.getRenderscaled());
|
|
||||||
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
|
||||||
if (b != null)
|
|
||||||
{
|
{
|
||||||
ItemStack s = new ItemStack(b, 1);
|
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
||||||
s.setTag(carryOverride.getRenderNBT());
|
|
||||||
model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(s, world, player);
|
Block b = StringParser.getBlock(carryOverride.getRenderNameBlock());
|
||||||
|
if (b != null)
|
||||||
|
{
|
||||||
|
ItemStack s = new ItemStack(b, 1);
|
||||||
|
s.setTag(carryOverride.getRenderNBT());
|
||||||
|
model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(s, world, player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.translated(translation[0], translation[1], translation[2]);
|
Minecraft.getInstance().getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||||
GlStateManager.rotatef((float) rot[0], 1, 0, 0);
|
CarryRenderHelper.renderItem(state, tag, stack, tileItem, matrix, buffer, light, model);
|
||||||
GlStateManager.rotatef((float) rot[1], 0, 1, 0);
|
buffer.finish();
|
||||||
GlStateManager.rotatef((float) rot[2], 0, 0, 1);
|
|
||||||
GlStateManager.scaled(scaled[0], scaled[1], scaled[2]);
|
|
||||||
|
|
||||||
|
matrix.pop();
|
||||||
|
|
||||||
|
drawArms(player, partialticks, matrix, buffer, light);
|
||||||
|
|
||||||
|
matrix.pop();
|
||||||
}
|
}
|
||||||
|
else if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
Minecraft.getInstance().getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
|
||||||
|
|
||||||
if (ModelOverridesHandler.hasCustomOverrideModel(state, tag))
|
|
||||||
{
|
{
|
||||||
Object override = ModelOverridesHandler.getOverrideObject(state, tag);
|
Entity entity = ItemCarryonEntity.getEntity(stack, world);
|
||||||
|
|
||||||
if (override instanceof ItemStack)
|
if (entity != null)
|
||||||
{
|
{
|
||||||
Minecraft.getInstance().getItemRenderer().renderItem((ItemStack) override, model);
|
applyEntityTransformations(player, partialticks, matrix, entity);
|
||||||
} else
|
|
||||||
{
|
manager.setRenderShadow(false);
|
||||||
Minecraft.getInstance().getItemRenderer().renderItem(tileItem.isEmpty() ? stack : tileItem, model);
|
|
||||||
|
CarryOnOverride carryOverride = ScriptChecker.getOverride(player);
|
||||||
|
if (carryOverride != null)
|
||||||
|
{
|
||||||
|
CarryRenderHelper.performOverrideTransformation(matrix, carryOverride);
|
||||||
|
|
||||||
|
String entityname = carryOverride.getRenderNameEntity();
|
||||||
|
if (entityname != null)
|
||||||
|
{
|
||||||
|
Entity newEntity = null;
|
||||||
|
|
||||||
|
Optional<EntityType<?>> type = EntityType.byKey(entityname);
|
||||||
|
if (type.isPresent())
|
||||||
|
newEntity = type.get().create(world);
|
||||||
|
|
||||||
|
if (newEntity != null)
|
||||||
|
{
|
||||||
|
CompoundNBT nbttag = carryOverride.getRenderNBT();
|
||||||
|
if (nbttag != null)
|
||||||
|
newEntity.deserializeNBT(nbttag);
|
||||||
|
entity = newEntity;
|
||||||
|
entity.rotationYaw = 0.0f;
|
||||||
|
entity.prevRotationYaw = 0.0f;
|
||||||
|
entity.setRotationYawHead(0.0f);
|
||||||
|
entity.rotationPitch = 0.0f;
|
||||||
|
entity.prevRotationPitch = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity instanceof LivingEntity)
|
||||||
|
((LivingEntity) entity).hurtTime = 0;
|
||||||
|
|
||||||
|
manager.renderEntityStatic(entity, 0, 0, 0, 0f, 0, matrix, buffer, light);
|
||||||
|
buffer.finish();
|
||||||
|
|
||||||
|
matrix.pop();
|
||||||
|
|
||||||
|
drawArms(player, partialticks, matrix, buffer, light);
|
||||||
|
|
||||||
|
manager.setRenderShadow(true);
|
||||||
|
|
||||||
|
matrix.pop();
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
{
|
|
||||||
Minecraft.getInstance().getItemRenderer().renderItem(tileItem.isEmpty() ? stack : tileItem, model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.disableBlend();
|
|
||||||
GlStateManager.scaled(1, 1, 1);
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
}
|
||||||
|
RenderSystem.enableDepthTest();
|
||||||
|
RenderSystem.enableCull();
|
||||||
|
RenderSystem.disableBlend();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyGeneralTransformations(PlayerEntity player, float partialticks, MatrixStack matrix)
|
||||||
|
{
|
||||||
|
int perspective = Minecraft.getInstance().gameSettings.thirdPersonView;
|
||||||
|
Quaternion playerrot = CarryRenderHelper.getExactBodyRotation(player, partialticks);
|
||||||
|
Vec3d playerpos = CarryRenderHelper.getExactPos(player, partialticks);
|
||||||
|
Vec3d cameraPos = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView();
|
||||||
|
Vec3d offset = playerpos.subtract(cameraPos);
|
||||||
|
Pose pose = player.getPose();
|
||||||
|
|
||||||
|
matrix.push();
|
||||||
|
matrix.translate(offset.x, offset.y, offset.z);
|
||||||
|
|
||||||
|
if (perspective == 2)
|
||||||
|
playerrot.multiply(Vector3f.YP.rotationDegrees(180));
|
||||||
|
matrix.rotate(playerrot);
|
||||||
|
|
||||||
|
matrix.push();
|
||||||
|
matrix.scale(0.6f, 0.6f, 0.6f);
|
||||||
|
|
||||||
|
if (perspective == 2)
|
||||||
|
matrix.translate(0, 0, -1.35);
|
||||||
|
|
||||||
|
if (doSneakCheck(player))
|
||||||
|
{
|
||||||
|
matrix.translate(0, -0.4, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pose == Pose.SWIMMING)
|
||||||
|
{
|
||||||
|
float f = player.getSwimAnimation(partialticks);
|
||||||
|
float f3 = player.isInWater() ? -90.0F - player.rotationPitch : -90.0F;
|
||||||
|
float f4 = MathHelper.lerp(f, 0.0F, f3);
|
||||||
|
if (perspective == 2)
|
||||||
|
{
|
||||||
|
matrix.translate(0, 0, 1.35);
|
||||||
|
matrix.rotate(Vector3f.XP.rotationDegrees(f4));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
matrix.rotate(Vector3f.XN.rotationDegrees(f4));
|
||||||
|
|
||||||
|
matrix.translate(0, -1.5, -1.848);
|
||||||
|
if (perspective == 2)
|
||||||
|
matrix.translate(0, 0, 2.38);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pose == Pose.FALL_FLYING)
|
||||||
|
{
|
||||||
|
float f1 = (float) player.getTicksElytraFlying() + partialticks;
|
||||||
|
float f2 = MathHelper.clamp(f1 * f1 / 100.0F, 0.0F, 1.0F);
|
||||||
|
if (!player.isSpinAttacking())
|
||||||
|
{
|
||||||
|
if (perspective == 2)
|
||||||
|
matrix.translate(0, 0, 1.35);
|
||||||
|
|
||||||
|
if (perspective == 2)
|
||||||
|
matrix.rotate(Vector3f.XP.rotationDegrees(f2 * (-90.0F - player.rotationPitch)));
|
||||||
|
else
|
||||||
|
matrix.rotate(Vector3f.XN.rotationDegrees(f2 * (-90.0F - player.rotationPitch)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3d vec3d = player.getLook(partialticks);
|
||||||
|
Vec3d vec3d1 = player.getMotion();
|
||||||
|
double d0 = Entity.horizontalMag(vec3d1);
|
||||||
|
double d1 = Entity.horizontalMag(vec3d);
|
||||||
|
if (d0 > 0.0D && d1 > 0.0D)
|
||||||
|
{
|
||||||
|
double d2 = (vec3d1.x * vec3d.x + vec3d1.z * vec3d.z) / (Math.sqrt(d0) * Math.sqrt(d1));
|
||||||
|
double d3 = vec3d1.x * vec3d.z - vec3d1.z * vec3d.x;
|
||||||
|
|
||||||
|
matrix.rotate(Vector3f.YP.rotation((float) (Math.signum(d3) * Math.acos(d2))));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (perspective != 2)
|
||||||
|
matrix.translate(0, 0, -1.35);
|
||||||
|
matrix.translate(0, -0.2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
matrix.translate(0, 1.6, 0.65);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyBlockTransformations(PlayerEntity player, float partialticks, MatrixStack matrix, Block block)
|
||||||
|
{
|
||||||
|
int perspective = Minecraft.getInstance().gameSettings.thirdPersonView;
|
||||||
|
|
||||||
|
applyGeneralTransformations(player, partialticks, matrix);
|
||||||
|
|
||||||
|
if (Settings.facePlayer.get() ? !isChest(block) : isChest(block))
|
||||||
|
{
|
||||||
|
if ((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && perspective == 0)
|
||||||
|
matrix.translate(0, 0, -0.4);
|
||||||
|
matrix.rotate(Vector3f.YP.rotationDegrees(180));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((ModList.get().isLoaded("realrender") || ModList.get().isLoaded("rfpr")) && perspective == 0)
|
||||||
|
matrix.translate(0, 0, 0.4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyEntityTransformations(PlayerEntity player, float partialticks, MatrixStack matrix, Entity entity)
|
||||||
|
{
|
||||||
|
int perspective = Minecraft.getInstance().gameSettings.thirdPersonView;
|
||||||
|
Pose pose = player.getPose();
|
||||||
|
|
||||||
|
applyGeneralTransformations(player, partialticks, matrix);
|
||||||
|
|
||||||
|
if(perspective == 2)
|
||||||
|
matrix.translate(0, -1.6, 0.65);
|
||||||
|
else
|
||||||
|
matrix.translate(0, -1.6, -0.65);
|
||||||
|
matrix.scale(1.666f, 1.666f, 1.666f);
|
||||||
|
|
||||||
|
float height = entity.getHeight();
|
||||||
|
float width = entity.getWidth();
|
||||||
|
float multiplier = height * width;
|
||||||
|
entity.rotationYaw = 0.0f;
|
||||||
|
entity.prevRotationYaw = 0.0f;
|
||||||
|
entity.setRotationYawHead(0.0f);
|
||||||
|
entity.rotationPitch = 0.0f;
|
||||||
|
entity.prevRotationPitch = 0.0f;
|
||||||
|
|
||||||
|
if (perspective == 2)
|
||||||
|
matrix.rotate(Vector3f.YP.rotationDegrees(180));
|
||||||
|
|
||||||
|
matrix.scale((10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f, (10 - multiplier) * 0.08f);
|
||||||
|
matrix.translate(0.0, height / 2 + -(height / 2) + 1, width - 0.1 < 0.7 ? width - 0.1 + (0.7 - (width - 0.1)) : width - 0.1);
|
||||||
|
|
||||||
|
if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||||
|
{
|
||||||
|
matrix.rotate(Vector3f.XN.rotationDegrees(90));
|
||||||
|
matrix.translate(0, -0.2 * height, 0);
|
||||||
|
|
||||||
|
if(pose == Pose.FALL_FLYING)
|
||||||
|
matrix.translate(0, 0 , 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Renders correct arm rotation
|
* Renders correct arm rotation
|
||||||
*/
|
*/
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
public void drawArms(PlayerEntity player, float partialticks, MatrixStack matrix, IRenderTypeBuffer buffer, int light)
|
||||||
public void onEvent(RenderPlayerEvent.Post event)
|
|
||||||
{
|
{
|
||||||
|
int perspective = Minecraft.getInstance().gameSettings.thirdPersonView;
|
||||||
|
Pose pose = player.getPose();
|
||||||
|
|
||||||
if (!Settings.renderArms.get())
|
if (!Settings.renderArms.get())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (pose == Pose.SWIMMING || pose == Pose.FALL_FLYING)
|
||||||
|
return;
|
||||||
|
|
||||||
if (handleMobends() && !ModList.get().isLoaded("obfuscate"))
|
if (handleMobends() && !ModList.get().isLoaded("obfuscate"))
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.getPlayer();
|
|
||||||
float partialticks = event.getPartialRenderTick();
|
|
||||||
|
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
||||||
{
|
{
|
||||||
PlayerModel<AbstractClientPlayerEntity> model = event.getRenderer().getEntityModel();
|
PlayerModel<AbstractClientPlayerEntity> model = getPlayerModel((AbstractClientPlayerEntity) player);
|
||||||
float rotation = 0;
|
|
||||||
|
|
||||||
if (player.getRidingEntity() != null && player.getRidingEntity() instanceof LivingEntity)
|
|
||||||
rotation = (player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialticks);
|
|
||||||
else
|
|
||||||
rotation = (player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialticks);
|
|
||||||
|
|
||||||
AbstractClientPlayerEntity aplayer = (AbstractClientPlayerEntity) player;
|
AbstractClientPlayerEntity aplayer = (AbstractClientPlayerEntity) player;
|
||||||
ResourceLocation skinLoc = aplayer.getLocationSkin();
|
ResourceLocation skinLoc = aplayer.getLocationSkin();
|
||||||
|
|
||||||
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialticks;
|
matrix.push();
|
||||||
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialticks;
|
if (perspective == 2)
|
||||||
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialticks;
|
matrix.rotate(Vector3f.YP.rotationDegrees(180));
|
||||||
|
|
||||||
Vec3d cameraPos = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView();
|
|
||||||
|
|
||||||
double xOffset = d0 - cameraPos.getX();
|
|
||||||
double yOffset = d1 - cameraPos.getY();
|
|
||||||
double zOffset = d2 - cameraPos.getZ();
|
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
GlStateManager.translated(xOffset, yOffset, zOffset);
|
|
||||||
|
|
||||||
Minecraft.getInstance().getTextureManager().bindTexture(skinLoc);
|
Minecraft.getInstance().getTextureManager().bindTexture(skinLoc);
|
||||||
|
|
||||||
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
CarryOnOverride overrider = ScriptChecker.getOverride(player);
|
||||||
|
IVertexBuilder builder = buffer.getBuffer(RenderType.getEntityCutout(skinLoc));
|
||||||
|
|
||||||
if (overrider != null)
|
if (overrider != null)
|
||||||
{
|
{
|
||||||
double[] rotLeft = null;
|
float[] rotLeft = null;
|
||||||
double[] rotRight = null;
|
float[] rotRight = null;
|
||||||
if (overrider.getRenderRotationLeftArm() != null)
|
if (overrider.getRenderRotationLeftArm() != null)
|
||||||
rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
rotLeft = ScriptParseHelper.getXYZArray(overrider.getRenderRotationLeftArm());
|
||||||
if (overrider.getRenderRotationRightArm() != null)
|
if (overrider.getRenderRotationRightArm() != null)
|
||||||
|
|
@ -511,32 +605,38 @@ public class RenderEvents
|
||||||
|
|
||||||
if (renderLeft && rotLeft != null)
|
if (renderLeft && rotLeft != null)
|
||||||
{
|
{
|
||||||
renderArmPost(model.bipedLeftArm, (float) rotLeft[0], (float) rotLeft[2], rotation, false, doSneakCheck(player));
|
renderArmPost(model.bipedLeftArm, (float) rotLeft[0], (float) rotLeft[2], false, doSneakCheck(player), light, matrix, builder);
|
||||||
renderArmPost(model.bipedLeftArmwear, (float) rotLeft[0], (float) rotLeft[2], rotation, false, doSneakCheck(player));
|
renderArmPost(model.bipedLeftArmwear, (float) rotLeft[0], (float) rotLeft[2], false, doSneakCheck(player), light, matrix, builder);
|
||||||
} else if (renderLeft)
|
}
|
||||||
|
else if (renderLeft)
|
||||||
{
|
{
|
||||||
renderArmPost(model.bipedLeftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation, false, doSneakCheck(player));
|
renderArmPost(model.bipedLeftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), false, doSneakCheck(player), light, matrix, builder);
|
||||||
renderArmPost(model.bipedLeftArmwear, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation, false, doSneakCheck(player));
|
renderArmPost(model.bipedLeftArmwear, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), false, doSneakCheck(player), light, matrix, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renderRight && rotRight != null)
|
if (renderRight && rotRight != null)
|
||||||
{
|
{
|
||||||
renderArmPost(model.bipedRightArm, (float) rotRight[0], (float) rotRight[2], rotation, true, doSneakCheck(player));
|
renderArmPost(model.bipedRightArm, (float) rotRight[0], (float) rotRight[2], true, doSneakCheck(player), light, matrix, builder);
|
||||||
renderArmPost(model.bipedRightArmwear, (float) rotRight[0], (float) rotRight[2], rotation, true, doSneakCheck(player));
|
renderArmPost(model.bipedRightArmwear, (float) rotRight[0], (float) rotRight[2], true, doSneakCheck(player), light, matrix, builder);
|
||||||
} else if (renderRight)
|
}
|
||||||
{
|
else if (renderRight)
|
||||||
renderArmPost(model.bipedRightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation, true, doSneakCheck(player));
|
{
|
||||||
renderArmPost(model.bipedRightArmwear, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation, true, doSneakCheck(player));
|
renderArmPost(model.bipedRightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), true, doSneakCheck(player), light, matrix, builder);
|
||||||
|
renderArmPost(model.bipedRightArmwear, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), true, doSneakCheck(player), light, matrix, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
renderArmPost(model.bipedRightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation, true, doSneakCheck(player));
|
|
||||||
renderArmPost(model.bipedLeftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation, false, doSneakCheck(player));
|
|
||||||
renderArmPost(model.bipedLeftArmwear, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), rotation, false, doSneakCheck(player));
|
|
||||||
renderArmPost(model.bipedRightArmwear, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), rotation, true, doSneakCheck(player));
|
|
||||||
}
|
}
|
||||||
GlStateManager.popMatrix();
|
else
|
||||||
|
{
|
||||||
|
renderArmPost(model.bipedRightArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), true, doSneakCheck(player), light, matrix, builder);
|
||||||
|
renderArmPost(model.bipedLeftArm, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), false, doSneakCheck(player), light, matrix, builder);
|
||||||
|
renderArmPost(model.bipedLeftArmwear, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? 0.15f : 0), false, doSneakCheck(player), light, matrix, builder);
|
||||||
|
renderArmPost(model.bipedRightArmwear, 2.0F + (doSneakCheck(player) ? 0f : 0.2f) - (stack.getItem() == RegistrationHandler.itemEntity ? 0.3f : 0), (stack.getItem() == RegistrationHandler.itemEntity ? -0.15f : 0), true, doSneakCheck(player), light, matrix, builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buffer instanceof Impl)
|
||||||
|
((Impl) buffer).finish();
|
||||||
|
|
||||||
|
matrix.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -554,8 +654,9 @@ public class RenderEvents
|
||||||
if (handleMobends() && !ModList.get().isLoaded("obfuscate"))
|
if (handleMobends() && !ModList.get().isLoaded("obfuscate"))
|
||||||
{
|
{
|
||||||
PlayerEntity player = event.getPlayer();
|
PlayerEntity player = event.getPlayer();
|
||||||
|
Pose pose = player.getPose();
|
||||||
ItemStack stack = player.getHeldItemMainhand();
|
ItemStack stack = player.getHeldItemMainhand();
|
||||||
if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack))
|
if (pose != Pose.SWIMMING && pose != Pose.FALL_FLYING && !stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile && ItemCarryonBlock.hasTileData(stack) || stack.getItem() == RegistrationHandler.itemEntity && ItemCarryonEntity.hasEntityData(stack)))
|
||||||
{
|
{
|
||||||
PlayerModel<AbstractClientPlayerEntity> model = event.getRenderer().getEntityModel();
|
PlayerModel<AbstractClientPlayerEntity> model = event.getRenderer().getEntityModel();
|
||||||
|
|
||||||
|
|
@ -577,7 +678,8 @@ public class RenderEvents
|
||||||
renderArmPre(model.bipedLeftArm);
|
renderArmPre(model.bipedLeftArm);
|
||||||
renderArmPre(model.bipedLeftArmwear);
|
renderArmPre(model.bipedLeftArmwear);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
renderArmPre(model.bipedRightArm);
|
renderArmPre(model.bipedRightArm);
|
||||||
renderArmPre(model.bipedLeftArm);
|
renderArmPre(model.bipedLeftArm);
|
||||||
|
|
@ -589,18 +691,14 @@ public class RenderEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void renderArmPost(RendererModel arm, float x, float z, float rotation, boolean right, boolean sneaking)
|
private void renderArmPost(ModelRenderer arm, float x, float z, boolean right, boolean sneaking, int light, MatrixStack matrix, IVertexBuilder builder)
|
||||||
{
|
{
|
||||||
arm.isHidden = false;
|
matrix.push();
|
||||||
|
arm.showModel = true;
|
||||||
if (right)
|
if (right)
|
||||||
{
|
matrix.translate(0.015, 0, 0);
|
||||||
arm.rotationPointZ = -MathHelper.sin((float) Math.toRadians(rotation)) * 4.75F;
|
else
|
||||||
arm.rotationPointX = -MathHelper.cos((float) Math.toRadians(rotation)) * 4.75F;
|
matrix.translate(-0.015, 0, 0);
|
||||||
} else
|
|
||||||
{
|
|
||||||
arm.rotationPointZ = MathHelper.sin((float) Math.toRadians(rotation)) * 4.75F;
|
|
||||||
arm.rotationPointX = MathHelper.cos((float) Math.toRadians(rotation)) * 4.75F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sneaking)
|
if (!sneaking)
|
||||||
arm.rotationPointY = 20;
|
arm.rotationPointY = 20;
|
||||||
|
|
@ -608,16 +706,17 @@ public class RenderEvents
|
||||||
arm.rotationPointY = 15;
|
arm.rotationPointY = 15;
|
||||||
|
|
||||||
arm.rotateAngleX = (float) x;
|
arm.rotateAngleX = (float) x;
|
||||||
arm.rotateAngleY = (float) -Math.toRadians(rotation);
|
arm.rotateAngleY = (float) 0;
|
||||||
arm.rotateAngleZ = (float) z;
|
arm.rotateAngleZ = (float) -z;
|
||||||
arm.renderWithRotation(0.0625F);
|
arm.render(matrix, builder, light, 655360);
|
||||||
arm.rotationPointY = 2;
|
arm.rotationPointY = 2;
|
||||||
|
matrix.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void renderArmPre(RendererModel arm)
|
private void renderArmPre(ModelRenderer arm)
|
||||||
{
|
{
|
||||||
arm.isHidden = true;
|
arm.showModel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean handleMobends()
|
public boolean handleMobends()
|
||||||
|
|
@ -638,12 +737,12 @@ public class RenderEvents
|
||||||
|
|
||||||
public static boolean doSneakCheck(PlayerEntity player)
|
public static boolean doSneakCheck(PlayerEntity player)
|
||||||
{
|
{
|
||||||
if(player.abilities.isFlying)
|
if (player.abilities.isFlying)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return player.isSneaking();
|
return (player.isSneaking() || player.isCrouching());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isChest(Block block)
|
public static boolean isChest(Block block)
|
||||||
{
|
{
|
||||||
return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST;
|
return block == Blocks.CHEST || block == Blocks.ENDER_CHEST || block == Blocks.TRAPPED_CHEST;
|
||||||
|
|
@ -663,15 +762,16 @@ public class RenderEvents
|
||||||
return getRenderPlayer(player).getEntityModel();
|
return getRenderPlayer(player).getEntityModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
// @SubscribeEvent
|
||||||
@OnlyIn(Dist.CLIENT)
|
// @OnlyIn(Dist.CLIENT)
|
||||||
public void hideItems(RenderSpecificHandEvent event)
|
// public void hideItems(RenderSpecificHandEvent event)
|
||||||
{
|
// {
|
||||||
ItemStack stack = event.getItemStack();
|
// ItemStack stack = event.getItemStack();
|
||||||
|
//
|
||||||
if (stack != null && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
// if (stack != null && (stack.getItem() == RegistrationHandler.itemTile ||
|
||||||
{
|
// stack.getItem() == RegistrationHandler.itemEntity))
|
||||||
event.setCanceled(true);
|
// {
|
||||||
}
|
// event.setCanceled(true);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
//package tschipp.carryon.client.gui;
|
|
||||||
//
|
|
||||||
//import java.util.List;
|
|
||||||
//
|
|
||||||
//import net.minecraft.client.gui.GuiButton;
|
|
||||||
//import net.minecraft.client.gui.GuiScreen;
|
|
||||||
//import net.minecraftforge.common.config.ConfigCategory;
|
|
||||||
//import net.minecraftforge.common.config.ConfigElement;
|
|
||||||
//import net.minecraftforge.common.config.Configuration;
|
|
||||||
//import net.minecraftforge.fml.client.config.GuiConfig;
|
|
||||||
//import net.minecraftforge.fml.client.config.IConfigElement;
|
|
||||||
//import tschipp.carryon.CarryOn;
|
|
||||||
//import tschipp.carryon.common.config.CarryOnConfig;
|
|
||||||
//
|
|
||||||
//public class GuiConfigCarryOn extends GuiConfig
|
|
||||||
//{
|
|
||||||
// private static final String LANG_PREFIX = CarryOn.MODID + ".category.";
|
|
||||||
//
|
|
||||||
// public GuiConfigCarryOn(GuiScreen parent) {
|
|
||||||
// super(parent, getConfigElements(), CarryOn.MODID, false, false, "Carry On Configuration");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static List<IConfigElement> getConfigElements() {
|
|
||||||
//
|
|
||||||
// final Configuration configuration = CarryOnConfig.EventHandler.getConfiguration.get()();
|
|
||||||
//
|
|
||||||
// final ConfigCategory topLevelCategory = configuration.getCategory(Configuration.CATEGORY_GENERAL);
|
|
||||||
// topLevelCategory.getChildren()
|
|
||||||
// .forEach(configCategory -> configCategory.setLanguageKey(GuiConfigCarryOn.LANG_PREFIX + configCategory.getName()));
|
|
||||||
//
|
|
||||||
// return new ConfigElement(topLevelCategory).getChildElements();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void initGui() {
|
|
||||||
// super.initGui();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
||||||
// super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void actionPerformed(GuiButton button) {
|
|
||||||
// super.actionPerformed(button);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
//package tschipp.carryon.client.gui;
|
|
||||||
//
|
|
||||||
//import java.util.Set;
|
|
||||||
//
|
|
||||||
//import net.minecraft.client.Minecraft;
|
|
||||||
//import net.minecraft.client.gui.GuiScreen;
|
|
||||||
//import net.minecraftforge.fml.client.IModGuiFactory;
|
|
||||||
//
|
|
||||||
//public class GuiFactoryCarryOn implements IModGuiFactory
|
|
||||||
//{
|
|
||||||
// @Override
|
|
||||||
// public void initialize(Minecraft minecraftInstance) {
|
|
||||||
// // Do nothing
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /*
|
|
||||||
// @Override
|
|
||||||
// public Class<? extends GuiScreen> mainConfigGuiClass() {
|
|
||||||
// return GuiConfigCarryOn.class;
|
|
||||||
// } */
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /*
|
|
||||||
// @Override
|
|
||||||
// public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
|
||||||
// return null;
|
|
||||||
// } */
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean hasConfigGui()
|
|
||||||
// {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public GuiScreen createConfigGui(GuiScreen parentScreen)
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// return new GuiConfigCarryOn(parentScreen);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
package tschipp.carryon.client.helper;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
import net.minecraft.client.renderer.Quaternion;
|
||||||
|
import net.minecraft.client.renderer.Vector3f;
|
||||||
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
|
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import tschipp.carryon.common.handler.ModelOverridesHandler;
|
||||||
|
import tschipp.carryon.common.helper.ScriptParseHelper;
|
||||||
|
import tschipp.carryon.common.scripting.CarryOnOverride;
|
||||||
|
|
||||||
|
public class CarryRenderHelper
|
||||||
|
{
|
||||||
|
public static Vec3d getExactPos(Entity entity, float partialticks)
|
||||||
|
{
|
||||||
|
return new Vec3d(entity.lastTickPosX + (entity.getPosX() - entity.lastTickPosX) * partialticks, entity.lastTickPosY + (entity.getPosY() - entity.lastTickPosY) * partialticks, entity.lastTickPosZ + (entity.getPosZ() - entity.lastTickPosZ) * partialticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getExactBodyRotationDegrees(LivingEntity entity, float partialticks)
|
||||||
|
{
|
||||||
|
if (entity.getRidingEntity() != null && entity.getRidingEntity() instanceof LivingEntity)
|
||||||
|
return -(entity.prevRotationYawHead + (entity.rotationYawHead - entity.prevRotationYawHead) * partialticks);
|
||||||
|
else
|
||||||
|
return -(entity.prevRenderYawOffset + (entity.renderYawOffset - entity.prevRenderYawOffset) * partialticks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Quaternion getExactBodyRotation(LivingEntity entity, float partialticks)
|
||||||
|
{
|
||||||
|
return Vector3f.YP.rotationDegrees(getExactBodyRotationDegrees(entity, partialticks));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void performOverrideTransformation(MatrixStack matrix, CarryOnOverride override)
|
||||||
|
{
|
||||||
|
float[] translation = ScriptParseHelper.getXYZArray(override.getRenderTranslation());
|
||||||
|
float[] rotation = ScriptParseHelper.getXYZArray(override.getRenderRotation());
|
||||||
|
float[] scaled = ScriptParseHelper.getScaled(override.getRenderScaled());
|
||||||
|
|
||||||
|
matrix.translate(translation[0], translation[1], translation[2]);
|
||||||
|
Quaternion rot = Vector3f.XP.rotationDegrees(rotation[0]);
|
||||||
|
rot.multiply(Vector3f.YP.rotationDegrees(rotation[1]));
|
||||||
|
rot.multiply(Vector3f.ZP.rotationDegrees(rotation[2]));
|
||||||
|
|
||||||
|
matrix.rotate(rot);
|
||||||
|
matrix.scale(scaled[0], scaled[1], scaled[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void renderItem(BlockState state, CompoundNBT tag, ItemStack stack, ItemStack tileStack, MatrixStack matrix, IRenderTypeBuffer buffer, int light, IBakedModel model)
|
||||||
|
{
|
||||||
|
if (ModelOverridesHandler.hasCustomOverrideModel(state, tag))
|
||||||
|
{
|
||||||
|
Object override = ModelOverridesHandler.getOverrideObject(state, tag);
|
||||||
|
|
||||||
|
if (override instanceof ItemStack)
|
||||||
|
{
|
||||||
|
Minecraft.getInstance().getItemRenderer().renderItem((ItemStack) override, TransformType.NONE, false, matrix, buffer, light, 0xFFFFFF, model); //Note: I'm not sure what the second to last argument does, but it seems to work like this
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Minecraft.getInstance().getItemRenderer().renderItem(tileStack.isEmpty() ? stack : tileStack, TransformType.NONE, false, matrix, buffer, light, 0xFFFFFF, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -62,7 +62,7 @@ public class Configs {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onChange(final ModConfig.ConfigReloading event)
|
public static void onChange(final ModConfig.Reloading event)
|
||||||
{
|
{
|
||||||
if(event.getConfig().getModId().equals(CarryOn.MODID))
|
if(event.getConfig().getModId().equals(CarryOn.MODID))
|
||||||
{
|
{
|
||||||
|
|
@ -344,7 +344,10 @@ public class Configs {
|
||||||
"enderstorage:*",
|
"enderstorage:*",
|
||||||
"betterstorage:*",
|
"betterstorage:*",
|
||||||
"practicallogistics2:*",
|
"practicallogistics2:*",
|
||||||
"wearablebackpacks:*"
|
"wearablebackpacks:*",
|
||||||
|
"rftools:screen",
|
||||||
|
"rftools:creative_screen",
|
||||||
|
|
||||||
|
|
||||||
}), (obj) -> obj instanceof String ? true : false);
|
}), (obj) -> obj instanceof String ? true : false);
|
||||||
|
|
||||||
|
|
@ -366,7 +369,9 @@ public class Configs {
|
||||||
"animania:hedgehog*",
|
"animania:hedgehog*",
|
||||||
"animania:cart",
|
"animania:cart",
|
||||||
"animania:wagon",
|
"animania:wagon",
|
||||||
"mynko:*"
|
"mynko:*",
|
||||||
|
"pixelmon:*",
|
||||||
|
"mocreatures:*"
|
||||||
}), (obj) -> obj instanceof String ? true : false);
|
}), (obj) -> obj instanceof String ? true : false);
|
||||||
|
|
||||||
forbiddenStacking = s
|
forbiddenStacking = s
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ public class ItemEntityEvents
|
||||||
if (entity instanceof LivingEntity)
|
if (entity instanceof LivingEntity)
|
||||||
((LivingEntity) entity).setHealth(0);
|
((LivingEntity) entity).setHealth(0);
|
||||||
|
|
||||||
entity.posY=0;
|
entity.setPosition(entity.getPosX(), 0, entity.getPosZ());
|
||||||
entity.remove();
|
entity.remove();
|
||||||
player.setHeldItem(Hand.MAIN_HAND, stack);
|
player.setHeldItem(Hand.MAIN_HAND, stack);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
|
|
@ -172,16 +172,16 @@ public class ItemEntityEvents
|
||||||
|
|
||||||
if (distance < 6)
|
if (distance < 6)
|
||||||
{
|
{
|
||||||
double tempX = entity.posX;
|
double tempX = entity.getPosX();
|
||||||
double tempY = entity.posY;
|
double tempY = entity.getPosY();
|
||||||
double tempZ = entity.posZ;
|
double tempZ = entity.getPosZ();
|
||||||
entityHeld.setPosition(tempX, tempY + 2.6, tempZ);
|
entityHeld.setPosition(tempX, tempY + 2.6, tempZ);
|
||||||
world.addEntity(entityHeld);
|
world.addEntity(entityHeld);
|
||||||
entityHeld.startRiding(topEntity, false);
|
entityHeld.startRiding(topEntity, false);
|
||||||
entityHeld.setPositionAndUpdate(tempX, tempY, tempZ);
|
entityHeld.setPositionAndUpdate(tempX, tempY, tempZ);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
entityHeld.setPosition(entity.posX, entity.posY, entity.posZ);
|
entityHeld.setPosition(entity.getPosX(), entity.getPosY(), entity.getPosZ());
|
||||||
world.addEntity(entityHeld);
|
world.addEntity(entityHeld);
|
||||||
entityHeld.startRiding(topEntity, false);
|
entityHeld.startRiding(topEntity, false);
|
||||||
}
|
}
|
||||||
|
|
@ -191,16 +191,16 @@ public class ItemEntityEvents
|
||||||
ItemEvents.sendPacket(player, 9, 0);
|
ItemEvents.sendPacket(player, 9, 0);
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
event.setCancellationResult(ActionResultType.FAIL);
|
event.setCancellationResult(ActionResultType.FAIL);
|
||||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_HORSE_SADDLE, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.ENTITY_HORSE_SADDLE, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BLOCK_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.BLOCK_NOTE_BLOCK_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BLOCK_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.BLOCK_NOTE_BLOCK_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ public class ItemEvents
|
||||||
eitem.setItem(ItemStack.EMPTY);
|
eitem.setItem(ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockPos pos = new BlockPos(Math.floor(eitem.posX), Math.floor(eitem.posY), Math.floor(eitem.posZ));
|
BlockPos pos = new BlockPos(Math.floor(eitem.getPosX()), Math.floor(eitem.getPosY()), Math.floor(eitem.getPosZ()));
|
||||||
if (positions.containsKey(pos))
|
if (positions.containsKey(pos))
|
||||||
{
|
{
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
|
|
@ -275,7 +275,7 @@ public class ItemEvents
|
||||||
if (!player.world.isRemote)
|
if (!player.world.isRemote)
|
||||||
{
|
{
|
||||||
player.setHeldItem(Hand.MAIN_HAND, ItemStack.EMPTY);
|
player.setHeldItem(Hand.MAIN_HAND, ItemStack.EMPTY);
|
||||||
ItemEntity item = new ItemEntity(player.world, player.posX, player.posY, player.posZ, stack);
|
ItemEntity item = new ItemEntity(player.world, player.getPosX(), player.getPosY(), player.getPosZ(), stack);
|
||||||
sendPacket(player, 9, 0);
|
sendPacket(player, 9, 0);
|
||||||
player.world.addEntity(item);
|
player.world.addEntity(item);
|
||||||
}
|
}
|
||||||
|
|
@ -499,12 +499,12 @@ public class ItemEvents
|
||||||
if (slotBlock != -1)
|
if (slotBlock != -1)
|
||||||
{
|
{
|
||||||
ItemStack dropped = player.inventory.removeStackFromSlot(slotBlock);
|
ItemStack dropped = player.inventory.removeStackFromSlot(slotBlock);
|
||||||
item = new ItemEntity(player.world, player.posX, player.posY, player.posZ, dropped);
|
item = new ItemEntity(player.world, player.getPosX(), player.getPosY(), player.getPosZ(), dropped);
|
||||||
}
|
}
|
||||||
if (slotEntity != -1)
|
if (slotEntity != -1)
|
||||||
{
|
{
|
||||||
ItemStack dropped = player.inventory.removeStackFromSlot(slotEntity);
|
ItemStack dropped = player.inventory.removeStackFromSlot(slotEntity);
|
||||||
item = new ItemEntity(player.world, player.posX, player.posY, player.posZ, dropped);
|
item = new ItemEntity(player.world, player.getPosX(), player.getPosY(), player.getPosZ(), dropped);
|
||||||
}
|
}
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
|
|
@ -529,7 +529,7 @@ public class ItemEvents
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onConfigChanged(ModConfig.ConfigReloading event)
|
public void onConfigChanged(ModConfig.Reloading event)
|
||||||
{
|
{
|
||||||
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
if (event.getConfig().getModId().equals(CarryOn.MODID))
|
||||||
{
|
{
|
||||||
|
|
@ -555,7 +555,7 @@ public class ItemEvents
|
||||||
{
|
{
|
||||||
if (player instanceof ServerPlayerEntity)
|
if (player instanceof ServerPlayerEntity)
|
||||||
{
|
{
|
||||||
CarryOn.network.send(PacketDistributor.NEAR.with(() -> new TargetPoint(player.posX, player.posY, player.posZ, 128, player.world.getDimension().getType())), new CarrySlotPacket(currentItem, player.getEntityId(), hash));
|
CarryOn.network.send(PacketDistributor.NEAR.with(() -> new TargetPoint(player.getPosX(), player.getPosY(), player.getPosZ(), 128, player.world.getDimension().getType())), new CarrySlotPacket(currentItem, player.getEntityId(), hash));
|
||||||
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new CarrySlotPacket(currentItem, player.getEntityId(), hash));
|
CarryOn.network.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new CarrySlotPacket(currentItem, player.getEntityId(), hash));
|
||||||
|
|
||||||
if (currentItem >= 9)
|
if (currentItem >= 9)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public class KeyboardCallbackWrapper
|
||||||
|
|
||||||
public void setup(Minecraft mc)
|
public void setup(Minecraft mc)
|
||||||
{
|
{
|
||||||
oldCallback = GLFW.glfwSetKeyCallback(mc.mainWindow.getHandle(), this::keyCallback);
|
oldCallback = GLFW.glfwSetKeyCallback(mc.getMainWindow().getHandle(), this::keyCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void keyCallback(long window, int key, int scancode, int action, int mods)
|
private void keyCallback(long window, int key, int scancode, int action, int mods)
|
||||||
|
|
|
||||||
|
|
@ -88,9 +88,9 @@ public class ScriptParseHelper
|
||||||
return matching;
|
return matching;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double[] getXYZArray(String s)
|
public static float[] getXYZArray(String s)
|
||||||
{
|
{
|
||||||
double[] d = new double[3];
|
float[] d = new float[3];
|
||||||
d[0] = getValueFromString(s, "x");
|
d[0] = getValueFromString(s, "x");
|
||||||
d[1] = getValueFromString(s, "y");
|
d[1] = getValueFromString(s, "y");
|
||||||
d[2] = getValueFromString(s, "z");
|
d[2] = getValueFromString(s, "z");
|
||||||
|
|
@ -99,17 +99,17 @@ public class ScriptParseHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static double[] getscaled(String s)
|
public static float[] getScaled(String s)
|
||||||
{
|
{
|
||||||
double[] d = new double[3];
|
float[] d = new float[3];
|
||||||
d[0] = getscaledValueFromString(s, "x");
|
d[0] = getScaledValueFromString(s, "x");
|
||||||
d[1] = getscaledValueFromString(s, "y");
|
d[1] = getScaledValueFromString(s, "y");
|
||||||
d[2] = getscaledValueFromString(s, "z");
|
d[2] = getScaledValueFromString(s, "z");
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getscaledValueFromString(String toGetFrom, String key)
|
public static float getScaledValueFromString(String toGetFrom, String key)
|
||||||
{
|
{
|
||||||
if(toGetFrom == null)
|
if(toGetFrom == null)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -119,12 +119,12 @@ public class ScriptParseHelper
|
||||||
{
|
{
|
||||||
if (string.contains(key) && string.contains("="))
|
if (string.contains(key) && string.contains("="))
|
||||||
{
|
{
|
||||||
double numb = 1;
|
float numb = 1;
|
||||||
string = string.replace(key + "=", "");
|
string = string.replace(key + "=", "");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
numb = Double.parseDouble(string);
|
numb = Float.parseFloat(string);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -188,7 +188,7 @@ public class ScriptParseHelper
|
||||||
return x && y && z;
|
return x && y && z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getValueFromString(String toGetFrom, String key)
|
public static float getValueFromString(String toGetFrom, String key)
|
||||||
{
|
{
|
||||||
if(toGetFrom == null)
|
if(toGetFrom == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -198,12 +198,12 @@ public class ScriptParseHelper
|
||||||
{
|
{
|
||||||
if (string.contains(key) && string.contains("="))
|
if (string.contains(key) && string.contains("="))
|
||||||
{
|
{
|
||||||
double numb = 0;
|
float numb = 0;
|
||||||
string = string.replace(key + "=", "");
|
string = string.replace(key + "=", "");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
numb = Double.parseDouble(string);
|
numb = Float.parseFloat(string);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public class ScrollCallbackWrapper
|
||||||
|
|
||||||
public void setup(Minecraft mc)
|
public void setup(Minecraft mc)
|
||||||
{
|
{
|
||||||
oldCallback = GLFW.glfwSetScrollCallback(mc.mainWindow.getHandle(), this::scrollCallback);
|
oldCallback = GLFW.glfwSetScrollCallback(mc.getMainWindow().getHandle(), this::scrollCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scrollCallback(long window, double xoffset, double yoffset)
|
private void scrollCallback(long window, double xoffset, double yoffset)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.potion.EffectInstance;
|
import net.minecraft.potion.EffectInstance;
|
||||||
import net.minecraft.potion.Effects;
|
import net.minecraft.potion.Effects;
|
||||||
|
import net.minecraft.state.BooleanProperty;
|
||||||
|
import net.minecraft.state.DirectionProperty;
|
||||||
|
import net.minecraft.state.EnumProperty;
|
||||||
|
import net.minecraft.state.IProperty;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
|
@ -80,6 +85,7 @@ public class ItemCarryonBlock extends Item
|
||||||
return new StringTextComponent("");
|
return new StringTextComponent("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType onItemUse(ItemUseContext context)
|
public ActionResultType onItemUse(ItemUseContext context)
|
||||||
{
|
{
|
||||||
|
|
@ -117,8 +123,27 @@ public class ItemCarryonBlock extends Item
|
||||||
{
|
{
|
||||||
if (player.canPlayerEdit(pos, facing, stack) && world.isBlockModifiable(player, pos2))
|
if (player.canPlayerEdit(pos, facing, stack) && world.isBlockModifiable(player, pos2))
|
||||||
{
|
{
|
||||||
|
|
||||||
BlockState actualState = containedblock.getStateForPlacement(new BlockItemUseContext(context));
|
BlockState placementState = containedblock.getStateForPlacement(new BlockItemUseContext(context));
|
||||||
|
|
||||||
|
BlockState actualState = containedstate;
|
||||||
|
|
||||||
|
for (IProperty<?> prop : placementState.getValues().keySet())
|
||||||
|
{
|
||||||
|
if (prop instanceof DirectionProperty)
|
||||||
|
actualState = actualState.with((DirectionProperty) prop, placementState.get((DirectionProperty) prop));
|
||||||
|
else if (prop == BlockStateProperties.WATERLOGGED)
|
||||||
|
actualState = actualState.with((BooleanProperty) prop, placementState.get((BooleanProperty) prop));
|
||||||
|
else if(prop instanceof EnumProperty<?>)
|
||||||
|
{
|
||||||
|
Object value = placementState.get(prop);
|
||||||
|
if(value instanceof Direction.Axis)
|
||||||
|
{
|
||||||
|
actualState = actualState.with((EnumProperty)prop, (Direction.Axis)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BlockSnapshot snapshot = new BlockSnapshot(world, pos2, containedstate);
|
BlockSnapshot snapshot = new BlockSnapshot(world, pos2, containedstate);
|
||||||
EntityPlaceEvent event = new EntityPlaceEvent(snapshot, world.getBlockState(pos), player);
|
EntityPlaceEvent event = new EntityPlaceEvent(snapshot, world.getBlockState(pos), player);
|
||||||
MinecraftForge.EVENT_BUS.post(event);
|
MinecraftForge.EVENT_BUS.post(event);
|
||||||
|
|
@ -180,7 +205,8 @@ public class ItemCarryonBlock extends Item
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e)
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
|
|
@ -188,7 +214,7 @@ public class ItemCarryonBlock extends Item
|
||||||
{
|
{
|
||||||
CarryOn.LOGGER.info("Block: " + ItemCarryonBlock.getBlock(stack));
|
CarryOn.LOGGER.info("Block: " + ItemCarryonBlock.getBlock(stack));
|
||||||
CarryOn.LOGGER.info("BlockState: " + ItemCarryonBlock.getBlockState(stack));
|
CarryOn.LOGGER.info("BlockState: " + ItemCarryonBlock.getBlockState(stack));
|
||||||
// CarryOn.LOGGER.info("Meta: " + ItemTile.getMeta(stack));
|
// CarryOn.LOGGER.info("Meta: " + ItemTile.getMeta(stack));
|
||||||
CarryOn.LOGGER.info("ItemStack: " + ItemCarryonBlock.getItemStack(stack));
|
CarryOn.LOGGER.info("ItemStack: " + ItemCarryonBlock.getItemStack(stack));
|
||||||
|
|
||||||
if (ModelOverridesHandler.hasCustomOverrideModel(ItemCarryonBlock.getBlockState(stack), ItemCarryonBlock.getTileData(stack)))
|
if (ModelOverridesHandler.hasCustomOverrideModel(ItemCarryonBlock.getBlockState(stack), ItemCarryonBlock.getTileData(stack)))
|
||||||
|
|
@ -222,7 +248,8 @@ public class ItemCarryonBlock extends Item
|
||||||
|
|
||||||
((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.SLOWNESS, 1, potionLevel(stack), false, false));
|
((LivingEntity) entity).addPotionEffect(new EffectInstance(Effects.SLOWNESS, 1, potionLevel(stack), false, false));
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
stack = ItemStack.EMPTY;
|
stack = ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
@ -253,11 +280,12 @@ public class ItemCarryonBlock extends Item
|
||||||
|
|
||||||
tag.put(TILE_DATA_KEY, chest);
|
tag.put(TILE_DATA_KEY, chest);
|
||||||
|
|
||||||
// ItemStack drop = new ItemStack(state.getBlock().getItemDropped(state, itemRand, 0), 1, state.getBlock().damageDropped(state));
|
// ItemStack drop = new ItemStack(state.getBlock().getItemDropped(state,
|
||||||
|
// itemRand, 0), 1, state.getBlock().damageDropped(state));
|
||||||
|
|
||||||
tag.putString("block", state.getBlock().getRegistryName().toString());
|
tag.putString("block", state.getBlock().getRegistryName().toString());
|
||||||
// Item item = Item.getItemFromBlock(state.getBlock());
|
// Item item = Item.getItemFromBlock(state.getBlock());
|
||||||
// tag.setInt("meta", drop.getItemDamage());
|
// tag.setInt("meta", drop.getItemDamage());
|
||||||
tag.putInt("stateid", Block.getStateId(state));
|
tag.putInt("stateid", Block.getStateId(state));
|
||||||
stack.setTag(tag);
|
stack.setTag(tag);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -295,16 +323,16 @@ public class ItemCarryonBlock extends Item
|
||||||
return Blocks.AIR;
|
return Blocks.AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static int getMeta(ItemStack stack)
|
// public static int getMeta(ItemStack stack)
|
||||||
// {
|
// {
|
||||||
// if (stack.hasTag())
|
// if (stack.hasTag())
|
||||||
// {
|
// {
|
||||||
// CompoundNBT tag = stack.getTag();
|
// CompoundNBT tag = stack.getTag();
|
||||||
// int meta = tag.getInt("meta");
|
// int meta = tag.getInt("meta");
|
||||||
// return meta;
|
// return meta;
|
||||||
// }
|
// }
|
||||||
// return 0;
|
// return 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public static ItemStack getItemStack(ItemStack stack)
|
public static ItemStack getItemStack(ItemStack stack)
|
||||||
{
|
{
|
||||||
|
|
@ -335,16 +363,16 @@ public class ItemCarryonBlock extends Item
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private boolean equal(Object[] a, Object[] b)
|
// private boolean equal(Object[] a, Object[] b)
|
||||||
// {
|
// {
|
||||||
// if (a.length != b.length)
|
// if (a.length != b.length)
|
||||||
// return false;
|
// return false;
|
||||||
//
|
//
|
||||||
// List lA = Arrays.asList(a);
|
// List lA = Arrays.asList(a);
|
||||||
// List lB = Arrays.asList(b);
|
// List lB = Arrays.asList(b);
|
||||||
//
|
//
|
||||||
// return lA.containsAll(lB);
|
// return lA.containsAll(lB);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private int potionLevel(ItemStack stack)
|
private int potionLevel(ItemStack stack)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package tschipp.carryon.common.item;
|
package tschipp.carryon.common.item;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
@ -26,6 +27,7 @@ import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
|
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||||
import tschipp.carryon.CarryOn;
|
import tschipp.carryon.CarryOn;
|
||||||
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
import tschipp.carryon.client.keybinds.CarryOnKeybinds;
|
||||||
import tschipp.carryon.common.config.Configs.Settings;
|
import tschipp.carryon.common.config.Configs.Settings;
|
||||||
|
|
@ -33,6 +35,14 @@ import tschipp.carryon.common.event.ItemEvents;
|
||||||
|
|
||||||
public class ItemCarryonEntity extends Item {
|
public class ItemCarryonEntity extends Item {
|
||||||
|
|
||||||
|
private static final Method initGoals;
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
initGoals = ObfuscationReflectionHelper.findMethod(MobEntity.class, "func_184651_r");
|
||||||
|
initGoals.setAccessible(true);
|
||||||
|
}
|
||||||
|
|
||||||
public static final String ENTITY_DATA_KEY = "entityData";
|
public static final String ENTITY_DATA_KEY = "entityData";
|
||||||
|
|
||||||
public ItemCarryonEntity() {
|
public ItemCarryonEntity() {
|
||||||
|
|
@ -177,7 +187,16 @@ public class ItemCarryonEntity extends Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity != null)
|
if (entity != null)
|
||||||
entity.deserializeNBT(e);
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
initGoals.invoke(entity);
|
||||||
|
entity.deserializeNBT(e);
|
||||||
|
}
|
||||||
|
catch (Exception e1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -492,7 +492,7 @@ public class CarryOnOverride
|
||||||
return renderRotation;
|
return renderRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRenderscaled()
|
public String getRenderScaled()
|
||||||
{
|
{
|
||||||
return renderscaled;
|
return renderscaled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ public class ScriptReader
|
||||||
JsonObject nbt = (JsonObject) render.get("nbt");
|
JsonObject nbt = (JsonObject) render.get("nbt");
|
||||||
JsonElement translation = render.get("translation");
|
JsonElement translation = render.get("translation");
|
||||||
JsonElement rotation = render.get("rotation");
|
JsonElement rotation = render.get("rotation");
|
||||||
JsonElement scaled = render.get("scaled");
|
JsonElement scaled = render.get("scale");
|
||||||
JsonElement rotationLeftArm = render.get("rotation_left_arm");
|
JsonElement rotationLeftArm = render.get("rotation_left_arm");
|
||||||
JsonElement rotationRightArm = render.get("rotation_right_arm");
|
JsonElement rotationRightArm = render.get("rotation_right_arm");
|
||||||
JsonElement renderLeftArm = render.get("render_left_arm");
|
JsonElement renderLeftArm = render.get("render_left_arm");
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ public class ServerProxy implements IProxy
|
||||||
@Override
|
@Override
|
||||||
public void setup(FMLCommonSetupEvent event)
|
public void setup(FMLCommonSetupEvent event)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,24 @@
|
||||||
modLoader="javafml"
|
modLoader="javafml"
|
||||||
loaderVersion="[13,)"
|
loaderVersion="[31,)"
|
||||||
issueTrackerURL="https://github.com/Tschipp/CarryOn/issues"
|
issueTrackerURL="https://github.com/Tschipp/CarryOn/issues"
|
||||||
logoFile="logo.png"
|
logoFile="logo.png"
|
||||||
|
license="GNU LGPLv3"
|
||||||
|
|
||||||
[[mods]]
|
[[mods]]
|
||||||
modId="carryon"
|
modId="carryon"
|
||||||
version="1.12.2"
|
version="${file.jarVersion}"
|
||||||
displayName="Carry On"
|
displayName="Carry On"
|
||||||
description='''Carry On is a simple mod that improves game interaction by allowing players to pick up, carry, and place single block Tile Entities using only their empty hands.'''
|
description='''Carry On is a simple mod that improves game interaction by allowing players to pick up, carry, and place single block Tile Entities using only their empty hands.'''
|
||||||
authors="Tschipp, Purplicious_Cow, cy4n" #mandatory
|
authors="Tschipp, Purplicious_Cow, cy4n" #mandatory
|
||||||
displayURL="https://minecraft.curseforge.com/projects/carry-on" #mandatory
|
displayURL="https://minecraft.curseforge.com/projects/carry-on" #mandatory
|
||||||
updateJSONURL="https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/" #mandatory
|
|
||||||
|
|
||||||
[[dependencies.carryon]] #optional
|
[[dependencies.carryon]] #optional
|
||||||
# the modid of the dependency
|
# the modid of the dependency
|
||||||
modId="forge" #mandatory
|
modId="forge" #mandatory
|
||||||
# Does this dependency have to exist - if not, ordering below must be specified
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
mandatory=true #mandatory
|
mandatory=true #mandatory
|
||||||
# The version range of the dependency
|
# The version range of the dependency
|
||||||
versionRange="[14.23.2.0,)" #mandatory
|
versionRange="[31.2.36,)" #mandatory
|
||||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||||
|
|
@ -28,6 +27,6 @@ logoFile="logo.png"
|
||||||
[[dependencies.carryon]]
|
[[dependencies.carryon]]
|
||||||
modId="minecraft"
|
modId="minecraft"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
versionRange="[1.14.4,1.15)"
|
versionRange="[1.15.2,1.16)"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
Loading…
Reference in New Issue
Block a user