mirror of
https://github.com/GTNewHorizons/ThaumicBases.git
synced 2026-11-13 17:04:07 +00:00
Fix infusion stabiliser (#17)
* Update buildscript & spotlessApply * Fix infusion stabiliser
This commit is contained in:
1 parent
c1d96e99db
commit
85c644496a
135 files changed
+14445
-13271
No files matched your search
@@ -1,4 +1,4 @@
|
||||
# ThaumicBases
|
||||
An addon for ThaumCraft 4(made by Azanor), which adds a lot of random things.
|
||||
An addon for ThaumCraft 4(made by Azanor), which adds a lot of random things.
|
||||
|
||||
ThaumicBases is redistributed under CreativeCommons 4.0 share-alike license(http://creativecommons.org/licenses/by-sa/4.0/)
|
||||
+302
-93
@@ -1,4 +1,4 @@
|
||||
//version: 1644349045
|
||||
//version: 1656003794
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
|
||||
@@ -9,26 +9,33 @@ Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.g
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.internal.logging.text.StyledTextOutput.Style
|
||||
import org.gradle.internal.logging.text.StyledTextOutputFactory
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
import java.util.zip.ZipOutputStream
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "https://maven.minecraftforge.net"
|
||||
name 'forge'
|
||||
url 'https://maven.minecraftforge.net'
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
name 'sonatype'
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
||||
}
|
||||
maven {
|
||||
name = "Scala CI dependencies"
|
||||
url = "https://repo1.maven.org/maven2/"
|
||||
name 'Scala CI dependencies'
|
||||
url 'https://repo1.maven.org/maven2/'
|
||||
}
|
||||
maven {
|
||||
name = "jitpack"
|
||||
url = "https://jitpack.io"
|
||||
name 'jitpack'
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
@@ -37,21 +44,28 @@ buildscript {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'idea'
|
||||
id 'eclipse'
|
||||
id 'scala'
|
||||
id 'maven-publish'
|
||||
id('org.jetbrains.kotlin.jvm') version ('1.6.10') apply false
|
||||
id('org.ajoberstar.grgit') version('4.1.1')
|
||||
id('com.github.johnrengelman.shadow') version('4.0.4')
|
||||
id('com.palantir.git-version') version('0.13.0') apply false
|
||||
id('de.undercouch.download') version('5.0.1')
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
|
||||
id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false
|
||||
id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false
|
||||
id 'org.ajoberstar.grgit' version '4.1.1'
|
||||
id 'com.github.johnrengelman.shadow' version '4.0.4'
|
||||
id 'com.palantir.git-version' version '0.13.0' apply false
|
||||
id 'de.undercouch.download' version '5.0.1'
|
||||
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
|
||||
id "com.diffplug.spotless" version "6.7.2"
|
||||
}
|
||||
|
||||
if (project.file('.git/HEAD').isFile()) {
|
||||
apply plugin: 'com.palantir.git-version'
|
||||
}
|
||||
|
||||
def out = services.get(StyledTextOutputFactory).create('an-output')
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
def projectJavaVersion = JavaLanguageVersion.of(8)
|
||||
@@ -70,6 +84,37 @@ idea {
|
||||
}
|
||||
}
|
||||
|
||||
// Spotless autoformatter
|
||||
// See https://github.com/diffplug/spotless/tree/main/plugin-gradle
|
||||
// Can be locally toggled via spotless:off/spotless:on comments
|
||||
spotless {
|
||||
encoding 'UTF-8'
|
||||
|
||||
format 'misc', {
|
||||
target '*.md', '.gitignore'
|
||||
|
||||
trimTrailingWhitespace()
|
||||
indentWithSpaces(4)
|
||||
endWithNewline()
|
||||
}
|
||||
java {
|
||||
toggleOffOn()
|
||||
importOrder()
|
||||
removeUnusedImports()
|
||||
palantirJavaFormat('1.1.0') // last version supporting jvm 8
|
||||
}
|
||||
kotlin {
|
||||
toggleOffOn()
|
||||
ktfmt('0.39')
|
||||
}
|
||||
groovyGradle {
|
||||
toggleOffOn()
|
||||
importOrder()
|
||||
target '*.gradle'
|
||||
greclipse('4.19.0') // last version supporting jvm 8
|
||||
}
|
||||
}
|
||||
|
||||
if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
|
||||
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
|
||||
}
|
||||
@@ -96,6 +141,10 @@ checkPropertyExists("usesShadowedDependencies")
|
||||
checkPropertyExists("developmentEnvironmentUserName")
|
||||
|
||||
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
|
||||
boolean usesMixinDebug = project.findProperty('usesMixinDebug') ?: project.usesMixins.toBoolean()
|
||||
String channel = project.findProperty('channel') ? project.channel : 'stable'
|
||||
String mappingsVersion = project.findProperty('mappingsVersion') ? project.mappingsVersion : '12'
|
||||
String remoteMappings = project.findProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/'
|
||||
|
||||
String javaSourceDir = "src/main/java/"
|
||||
String scalaSourceDir = "src/main/scala/"
|
||||
@@ -167,8 +216,8 @@ configurations.all {
|
||||
try {
|
||||
'git config core.fileMode false'.execute()
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("\u001B[31mgit isn't installed at all\u001B[0m")
|
||||
catch (Exception ignored) {
|
||||
out.style(Style.Failure).println("git isn't installed at all")
|
||||
}
|
||||
|
||||
// Pulls version first from the VERSION env and then git tag
|
||||
@@ -177,19 +226,22 @@ String versionOverride = System.getenv("VERSION") ?: null
|
||||
try {
|
||||
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("\n\u001B[1;31mThis mod must be version controlled by Git AND the repository must provide at least one tag,\n" +
|
||||
"or the VERSION override must be set! \u001B[32m(Don't download from GitHub using the ZIP option, instead\n" +
|
||||
"clone the repository, see\u001B[33m https://gtnh.miraheze.org/wiki/Development \u001B[32mfor details.)\u001B[0m\n");
|
||||
catch (Exception ignored) {
|
||||
out.style(Style.Failure).text(
|
||||
'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
|
||||
'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' +
|
||||
'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
|
||||
)
|
||||
versionOverride = 'NO-GIT-TAG-SET'
|
||||
identifiedVersion = versionOverride
|
||||
}
|
||||
version = minecraftVersion + '-' + identifiedVersion
|
||||
String modVersion = identifiedVersion
|
||||
ext {
|
||||
modVersion = identifiedVersion
|
||||
}
|
||||
|
||||
if( identifiedVersion.equals(versionOverride) ) {
|
||||
logger.error('\u001B[31m\u001B[7mWe hope you know what you\'re doing using\u001B[0m\u001B[1;34m ' + modVersion + '\u001B[0m\n');
|
||||
logger.error('\7\u001B[31mGoing to blindly try to use\u001B[1;34m ' + modVersion + '\u001B[0m\u001B[31m, this probably won\'t work the way you expect!!\u001B[0m\n');
|
||||
if(identifiedVersion == versionOverride) {
|
||||
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
|
||||
}
|
||||
|
||||
group = modGroup
|
||||
@@ -200,22 +252,25 @@ else {
|
||||
archivesBaseName = modId
|
||||
}
|
||||
|
||||
|
||||
def arguments = []
|
||||
def jvmArguments = []
|
||||
|
||||
if(usesMixins.toBoolean()) {
|
||||
if (usesMixins.toBoolean()) {
|
||||
arguments += [
|
||||
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
|
||||
]
|
||||
jvmArguments += [
|
||||
"-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true"
|
||||
]
|
||||
if (usesMixinDebug.toBoolean()) {
|
||||
jvmArguments += [
|
||||
"-Dmixin.debug.countInjections=true",
|
||||
"-Dmixin.debug.verbose=true",
|
||||
"-Dmixin.debug.export=true"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion
|
||||
runDir = "run"
|
||||
version = minecraftVersion + '-' + forgeVersion + '-' + minecraftVersion
|
||||
runDir = 'run'
|
||||
|
||||
if (replaceGradleTokenInFile) {
|
||||
replaceIn replaceGradleTokenInFile
|
||||
@@ -248,8 +303,8 @@ minecraft {
|
||||
}
|
||||
}
|
||||
|
||||
if(file("addon.gradle").exists()) {
|
||||
apply from: "addon.gradle"
|
||||
if(file('addon.gradle').exists()) {
|
||||
apply from: 'addon.gradle'
|
||||
}
|
||||
|
||||
apply from: 'repositories.gradle'
|
||||
@@ -262,58 +317,63 @@ configurations {
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "Overmind forge repo mirror"
|
||||
url = "https://gregtech.overminddl1.com/"
|
||||
name 'Overmind forge repo mirror'
|
||||
url 'https://gregtech.overminddl1.com/'
|
||||
}
|
||||
if(usesMixins.toBoolean()) {
|
||||
maven {
|
||||
name = "sponge"
|
||||
url = "https://repo.spongepowered.org/repository/maven-public"
|
||||
name 'sponge'
|
||||
url 'https://repo.spongepowered.org/repository/maven-public'
|
||||
}
|
||||
maven {
|
||||
url = "https://jitpack.io"
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
if(usesMixins.toBoolean()) {
|
||||
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
|
||||
annotationProcessor("com.google.guava:guava:24.1.1-jre")
|
||||
annotationProcessor("com.google.code.gson:gson:2.8.6")
|
||||
annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT")
|
||||
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
|
||||
annotationProcessor('com.google.guava:guava:24.1.1-jre')
|
||||
annotationProcessor('com.google.code.gson:gson:2.8.6')
|
||||
annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT')
|
||||
// using 0.8 to workaround a issue in 0.7 which fails mixin application
|
||||
compile("com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH") {
|
||||
compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') {
|
||||
// Mixin includes a lot of dependencies that are too up-to-date
|
||||
exclude module: "launchwrapper"
|
||||
exclude module: "guava"
|
||||
exclude module: "gson"
|
||||
exclude module: "commons-io"
|
||||
exclude module: "log4j-core"
|
||||
exclude module: 'launchwrapper'
|
||||
exclude module: 'guava'
|
||||
exclude module: 'gson'
|
||||
exclude module: 'commons-io'
|
||||
exclude module: 'log4j-core'
|
||||
}
|
||||
compile("com.github.GTNewHorizons:SpongeMixins:1.5.0")
|
||||
compile('com.github.GTNewHorizons:SpongeMixins:1.5.0')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: 'dependencies.gradle'
|
||||
|
||||
def mixingConfigRefMap = "mixins." + modId + ".refmap.json"
|
||||
def mixingConfigRefMap = 'mixins.' + modId + '.refmap.json'
|
||||
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap
|
||||
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
|
||||
|
||||
task generateAssets {
|
||||
if(usesMixins.toBoolean()) {
|
||||
getFile("/src/main/resources/mixins." + modId + ".json").text = """{
|
||||
if (usesMixins.toBoolean()) {
|
||||
def mixinConfigFile = getFile("/src/main/resources/mixins." + modId + ".json");
|
||||
if (!mixinConfigFile.exists()) {
|
||||
mixinConfigFile.text = """{
|
||||
"required": true,
|
||||
"minVersion": "0.7.11",
|
||||
"package": "${modGroup}.${mixinsPackage}",
|
||||
"plugin": "${modGroup}.${mixinPlugin}",
|
||||
"refmap": "${mixingConfigRefMap}",
|
||||
"target": "@env(DEFAULT)",
|
||||
"compatibilityLevel": "JAVA_8"
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [],
|
||||
"client": [],
|
||||
"server": []
|
||||
}
|
||||
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,21 +461,20 @@ tasks.withType(JavaExec).configureEach {
|
||||
)
|
||||
}
|
||||
|
||||
processResources
|
||||
{
|
||||
processResources {
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
// replace modVersion and minecraftVersion
|
||||
expand "minecraftVersion": project.minecraft.version,
|
||||
"modVersion": modVersion,
|
||||
"modId": modId,
|
||||
"modName": modName
|
||||
"modVersion": modVersion,
|
||||
"modId": modId,
|
||||
"modName": modName
|
||||
}
|
||||
|
||||
if(usesMixins.toBoolean()) {
|
||||
@@ -430,7 +489,7 @@ processResources
|
||||
|
||||
def getManifestAttributes() {
|
||||
def manifestAttributes = [:]
|
||||
if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) {
|
||||
if(!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
|
||||
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
|
||||
}
|
||||
|
||||
@@ -446,14 +505,14 @@ def getManifestAttributes() {
|
||||
manifestAttributes += [
|
||||
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
|
||||
"MixinConfigs" : "mixins." + modId + ".json",
|
||||
"ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
|
||||
"ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean()
|
||||
]
|
||||
}
|
||||
return manifestAttributes
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from (sourceSets.main.allJava)
|
||||
from (sourceSets.main.allSource)
|
||||
from (file("$projectDir/LICENSE"))
|
||||
getArchiveClassifier().set('sources')
|
||||
}
|
||||
@@ -508,7 +567,7 @@ task devJar(type: Jar) {
|
||||
}
|
||||
|
||||
task apiJar(type: Jar) {
|
||||
from (sourceSets.main.allJava) {
|
||||
from (sourceSets.main.allSource) {
|
||||
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
|
||||
}
|
||||
|
||||
@@ -533,12 +592,15 @@ artifacts {
|
||||
}
|
||||
}
|
||||
|
||||
// The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID),
|
||||
// The gradle metadata includes all of the additional deps that we disabled from POM generation (including forgeBin with no groupID),
|
||||
// and isn't strictly needed with the POM so just disable it.
|
||||
tasks.withType(GenerateModuleMetadata) {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
// workaround variable hiding in pom processing
|
||||
def projectConfigs = project.configurations
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
@@ -547,7 +609,7 @@ publishing {
|
||||
artifact source: shadowJar, classifier: ""
|
||||
}
|
||||
if(!noPublishedSources) {
|
||||
artifact source: sourcesJar, classifier: "src"
|
||||
artifact source: sourcesJar, classifier: "sources"
|
||||
}
|
||||
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
|
||||
if (apiPackage) {
|
||||
@@ -558,17 +620,21 @@ publishing {
|
||||
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
|
||||
// Using the identified version, not project.version as it has the prepended 1.7.10
|
||||
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
|
||||
|
||||
// remove extra garbage from who knows where
|
||||
|
||||
// remove extra garbage from minecraft and minecraftDeps configuration
|
||||
pom.withXml {
|
||||
def badPomGroup = ['net.minecraft', 'com.google.code.findbugs', 'org.ow2.asm', 'com.typesafe.akka', 'com.typesafe', 'org.scala-lang',
|
||||
'org.scala-lang.plugins', 'net.sf.jopt-simple', 'lzma', 'com.mojang', 'org.apache.commons', 'org.apache.httpcomponents',
|
||||
'commons-logging', 'java3d', 'net.sf.trove4j', 'com.ibm.icu', 'com.paulscode', 'io.netty', 'com.google.guava',
|
||||
'commons-io', 'commons-codec', 'net.java.jinput', 'net.java.jutils', 'com.google.code.gson', 'org.apache.logging.log4j',
|
||||
'org.lwjgl.lwjgl', 'tv.twitch', '']
|
||||
def badArtifacts = [:].withDefault {[] as Set<String>}
|
||||
for (configuration in [projectConfigs.minecraft, projectConfigs.minecraftDeps]) {
|
||||
for (dependency in configuration.allDependencies) {
|
||||
badArtifacts[dependency.group == null ? "" : dependency.group] += dependency.name
|
||||
}
|
||||
}
|
||||
// example for specifying extra stuff to ignore
|
||||
// badArtifacts["org.example.group"] += "artifactName"
|
||||
|
||||
Node pomNode = asNode()
|
||||
pomNode.dependencies.'*'.findAll() {
|
||||
badPomGroup.contains(it.groupId.text())
|
||||
badArtifacts[it.groupId.text()].contains(it.artifactId.text())
|
||||
}.each() {
|
||||
it.parent().remove(it)
|
||||
}
|
||||
@@ -600,7 +666,7 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
|
||||
if (autoUpdateBuildScript.toBoolean()) {
|
||||
performBuildScriptUpdate(projectDir.toString())
|
||||
} else {
|
||||
println("Build script update available! Run 'gradle updateBuildScript'")
|
||||
out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,7 +678,7 @@ boolean performBuildScriptUpdate(String projectDir) {
|
||||
if (isNewBuildScriptVersionAvailable(projectDir)) {
|
||||
def buildscriptFile = getFile("build.gradle")
|
||||
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
|
||||
print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
|
||||
out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -627,7 +693,6 @@ boolean isNewBuildScriptVersionAvailable(String projectDir) {
|
||||
String availableBuildScriptHash = getVersionHash(availableBuildScript)
|
||||
|
||||
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
|
||||
return !isUpToDate
|
||||
}
|
||||
|
||||
static String getVersionHash(String buildScriptContent) {
|
||||
@@ -643,7 +708,103 @@ configure(updateBuildScript) {
|
||||
description = 'Updates the build script to the latest version'
|
||||
}
|
||||
|
||||
// Deobfuscation
|
||||
// Parameter Deobfuscation
|
||||
|
||||
task deobfParams {
|
||||
doLast {
|
||||
|
||||
String mcpDir = "$project.gradle.gradleUserHomeDir/caches/minecraft/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion"
|
||||
String mcpZIP = "$mcpDir/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip"
|
||||
String paramsCSV = "$mcpDir/params.csv"
|
||||
|
||||
download.run {
|
||||
src "https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_$channel/$mappingsVersion-$minecraftVersion/mcp_$channel-$mappingsVersion-${minecraftVersion}.zip"
|
||||
dest mcpZIP
|
||||
overwrite false
|
||||
}
|
||||
|
||||
if(!file(paramsCSV).exists()) {
|
||||
println("Extracting MCP archive ...")
|
||||
unzip(mcpZIP, mcpDir)
|
||||
}
|
||||
|
||||
println("Parsing params.csv ...")
|
||||
Map<String, String> params = new HashMap<>()
|
||||
Files.lines(Paths.get(paramsCSV)).forEach{line ->
|
||||
String[] cells = line.split(",")
|
||||
if(cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) {
|
||||
params.put(cells[0], cells[1])
|
||||
}
|
||||
}
|
||||
|
||||
out.style(Style.Success).println("Modified ${replaceParams(file("$projectDir/src/main/java"), params)} files!")
|
||||
out.style(Style.Failure).println("Don't forget to verify that the code still works as before!\n It could be broken due to duplicate variables existing now\n or parameters taking priority over other variables.")
|
||||
}
|
||||
}
|
||||
|
||||
static int replaceParams(File file, Map<String, String> params) {
|
||||
int fileCount = 0
|
||||
|
||||
if(file.isDirectory()) {
|
||||
for(File f : file.listFiles()) {
|
||||
fileCount += replaceParams(f, params)
|
||||
}
|
||||
return fileCount
|
||||
}
|
||||
println("Visiting ${file.getName()} ...")
|
||||
try {
|
||||
String content = new String(Files.readAllBytes(file.toPath()))
|
||||
int hash = content.hashCode()
|
||||
params.forEach{key, value ->
|
||||
content = content.replaceAll(key, value)
|
||||
}
|
||||
if(hash != content.hashCode()) {
|
||||
Files.write(file.toPath(), content.getBytes("UTF-8"))
|
||||
return 1
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Credit: bitsnaps (https://gist.github.com/bitsnaps/00947f2dce66f4bbdabc67d7e7b33681)
|
||||
static unzip(String zipFileName, String outputDir) {
|
||||
byte[] buffer = new byte[16384]
|
||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName))
|
||||
ZipEntry zipEntry = zis.getNextEntry()
|
||||
while (zipEntry != null) {
|
||||
File newFile = new File(outputDir + File.separator, zipEntry.name)
|
||||
if (zipEntry.isDirectory()) {
|
||||
if (!newFile.isDirectory() && !newFile.mkdirs()) {
|
||||
throw new IOException("Failed to create directory $newFile")
|
||||
}
|
||||
} else {
|
||||
// fix for Windows-created archives
|
||||
File parent = newFile.parentFile
|
||||
if (!parent.isDirectory() && !parent.mkdirs()) {
|
||||
throw new IOException("Failed to create directory $parent")
|
||||
}
|
||||
// write file content
|
||||
FileOutputStream fos = new FileOutputStream(newFile)
|
||||
int len = 0
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
fos.write(buffer, 0, len)
|
||||
}
|
||||
fos.close()
|
||||
}
|
||||
zipEntry = zis.getNextEntry()
|
||||
}
|
||||
zis.closeEntry()
|
||||
zis.close()
|
||||
}
|
||||
|
||||
configure(deobfParams) {
|
||||
group = 'forgegradle'
|
||||
description = 'Rename all obfuscated parameter names inherited from Minecraft classes'
|
||||
}
|
||||
|
||||
// Dependency Deobfuscation
|
||||
|
||||
def deobf(String sourceURL) {
|
||||
try {
|
||||
@@ -656,7 +817,7 @@ def deobf(String sourceURL) {
|
||||
fileName = fileName.substring(lastSlash + 1)
|
||||
}
|
||||
//get rid of extension:
|
||||
if(fileName.endsWith(".jar")) {
|
||||
if(fileName.endsWith(".jar") || fileName.endsWith(".litemod")) {
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf("."))
|
||||
}
|
||||
|
||||
@@ -668,26 +829,40 @@ def deobf(String sourceURL) {
|
||||
Collections.reverse(parts)
|
||||
hostName = String.join(".", parts)
|
||||
|
||||
return deobf(sourceURL, hostName + "/" + fileName)
|
||||
return deobf(sourceURL, "$hostName/$fileName")
|
||||
} catch(Exception e) {
|
||||
return deobf(sourceURL, "deobf/" + String.valueOf(sourceURL.hashCode()))
|
||||
return deobf(sourceURL, "deobf/${sourceURL.hashCode()}")
|
||||
}
|
||||
}
|
||||
|
||||
// The method above is to be preferred. Use this method if the filename is not at the end of the URL.
|
||||
def deobf(String sourceURL, String fileName) {
|
||||
String cacheDir = System.getProperty("user.home") + "/.gradle/caches/"
|
||||
String bon2Dir = cacheDir + "forge_gradle/deobf"
|
||||
String bon2File = bon2Dir + "/BON2-2.5.0.jar"
|
||||
String obfFile = cacheDir + "modules-2/files-2.1/" + fileName + ".jar"
|
||||
String deobfFile = cacheDir + "modules-2/files-2.1/" + fileName + "-deobf.jar"
|
||||
|
||||
def deobf(String sourceURL, String rawFileName) {
|
||||
String bon2Version = "2.5.1"
|
||||
String fileName = URLDecoder.decode(rawFileName, "UTF-8")
|
||||
String cacheDir = "$project.gradle.gradleUserHomeDir/caches"
|
||||
String bon2Dir = "$cacheDir/forge_gradle/deobf"
|
||||
String bon2File = "$bon2Dir/BON2-${bon2Version}.jar"
|
||||
String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar"
|
||||
String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar"
|
||||
|
||||
if(file(deobfFile).exists()) {
|
||||
return files(deobfFile)
|
||||
}
|
||||
|
||||
String mappingsVer
|
||||
if(remoteMappings) {
|
||||
String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion"
|
||||
String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip"
|
||||
|
||||
zipMappings(mappingsZIP, remoteMappings, bon2Dir)
|
||||
|
||||
mappingsVer = "snapshot_$id"
|
||||
} else {
|
||||
mappingsVer = "${channel}_$mappingsVersion"
|
||||
}
|
||||
|
||||
download.run {
|
||||
src 'https://github.com/GTNewHorizons/BON2/releases/download/2.5.0/BON2-2.5.0.CUSTOM-all.jar'
|
||||
src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar"
|
||||
dest bon2File
|
||||
quiet true
|
||||
overwrite false
|
||||
@@ -701,22 +876,56 @@ def deobf(String sourceURL, String fileName) {
|
||||
}
|
||||
|
||||
exec {
|
||||
commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', '1.7.10', '--mappingsVer', 'stable_12', '--notch'
|
||||
commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', minecraftVersion, '--mappingsVer', mappingsVer, '--notch'
|
||||
workingDir bon2Dir
|
||||
standardOutput = new ByteArrayOutputStream()
|
||||
standardOutput = new FileOutputStream("${deobfFile}.log")
|
||||
}
|
||||
|
||||
return files(deobfFile)
|
||||
}
|
||||
|
||||
def zipMappings(String zipPath, String url, String bon2Dir) {
|
||||
File zipFile = new File(zipPath)
|
||||
if(zipFile.exists()) {
|
||||
return
|
||||
}
|
||||
|
||||
String fieldsCache = "$bon2Dir/data/fields.csv"
|
||||
String methodsCache = "$bon2Dir/data/methods.csv"
|
||||
|
||||
download.run {
|
||||
src "${url}fields.csv"
|
||||
dest fieldsCache
|
||||
quiet true
|
||||
}
|
||||
download.run {
|
||||
src "${url}methods.csv"
|
||||
dest methodsCache
|
||||
quiet true
|
||||
}
|
||||
|
||||
zipFile.getParentFile().mkdirs()
|
||||
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))
|
||||
|
||||
zos.putNextEntry(new ZipEntry("fields.csv"))
|
||||
Files.copy(Paths.get(fieldsCache), zos)
|
||||
zos.closeEntry()
|
||||
|
||||
zos.putNextEntry(new ZipEntry("methods.csv"))
|
||||
Files.copy(Paths.get(methodsCache), zos)
|
||||
zos.closeEntry()
|
||||
|
||||
zos.close()
|
||||
}
|
||||
|
||||
// Helper methods
|
||||
|
||||
def checkPropertyExists(String propertyName) {
|
||||
if (project.hasProperty(propertyName) == false) {
|
||||
if (!project.hasProperty(propertyName)) {
|
||||
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties")
|
||||
}
|
||||
}
|
||||
|
||||
def getFile(String relativePath) {
|
||||
return new File(projectDir, relativePath)
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
|
||||
compile('curse.maven:dummycore-230103:2244260')
|
||||
compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev')
|
||||
runtime("com.github.GTNewHorizons:NotEnoughItems:2.2.6-GTNH:dev")
|
||||
compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
|
||||
compile('curse.maven:dummycore-230103:2244260')
|
||||
compile('com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev')
|
||||
runtime("com.github.GTNewHorizons:NotEnoughItems:2.2.17-GTNH:dev")
|
||||
|
||||
runtime('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
|
||||
runtime('com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev') // Required to allow dummycore to run in dev
|
||||
runtime('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
|
||||
runtime('com.github.GTNewHorizons:CodeChickenCore:1.1.5:dev') // Required to allow dummycore to run in dev
|
||||
}
|
||||
+11
-11
@@ -1,15 +1,15 @@
|
||||
// Add any additional repositories for your dependencies here
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name 'GTNH Maven'
|
||||
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
|
||||
allowInsecureProtocol
|
||||
}
|
||||
maven {
|
||||
url 'https://cursemaven.com'
|
||||
}
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
maven {
|
||||
name 'GTNH Maven'
|
||||
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
|
||||
allowInsecureProtocol
|
||||
}
|
||||
maven {
|
||||
url 'https://cursemaven.com'
|
||||
}
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package tb.api;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public interface ITobacco {
|
||||
|
||||
public abstract void performTobaccoEffect(EntityPlayer smoker, int metadata, boolean isSilverwood);
|
||||
|
||||
public abstract void performTobaccoEffect(EntityPlayer smoker, int metadata, boolean isSilverwood);
|
||||
}
|
||||
@@ -1,15 +1,9 @@
|
||||
package tb.api;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import tb.utils.TBUtils;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.entities.IEldritchMob;
|
||||
import thaumcraft.api.entities.ITaintedMob;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.lib.research.ScanManager;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EnumCreatureAttribute;
|
||||
import net.minecraft.entity.boss.IBossDisplayData;
|
||||
@@ -22,349 +16,326 @@ import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.IExtendedEntityProperties;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import tb.utils.TBUtils;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.entities.IEldritchMob;
|
||||
import thaumcraft.api.entities.ITaintedMob;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.lib.research.ScanManager;
|
||||
|
||||
public class RevolverUpgrade {
|
||||
|
||||
public static RevolverUpgrade[] allUpgrades = new RevolverUpgrade[24];
|
||||
public static Hashtable<String, Integer> textToIntMapping = new Hashtable<String, Integer>();
|
||||
public static Hashtable<Integer, String> intToTextMapping = new Hashtable<Integer, String>();
|
||||
|
||||
public int maxLevel;
|
||||
public final int id;
|
||||
public final String text_id;
|
||||
public int instability;
|
||||
|
||||
public static final ResourceLocation eldritchTextures = new ResourceLocation("thaumicbases","textures/items/revolver/revolverDarkMetalEldritch.png");
|
||||
public static final ResourceLocation primalTextures = new ResourceLocation("thaumicbases","textures/items/revolver/revolverGunPrimalUV.png");
|
||||
public static final ResourceLocation taintedTextures = new ResourceLocation("thaumicbases","textures/items/revolver/revolverGunTaintedUV.png");
|
||||
public static final ResourceLocation voidTextures = new ResourceLocation("thaumicbases","textures/items/revolver/revolverHandleVoidUV.png");
|
||||
|
||||
public final ArrayList<RevolverUpgrade> conflicts = new ArrayList<RevolverUpgrade>();
|
||||
|
||||
public RevolverUpgrade(int id, String name)
|
||||
{
|
||||
text_id = name;
|
||||
this.id = id;
|
||||
|
||||
if(id < allUpgrades.length && allUpgrades[id] != null)
|
||||
{
|
||||
FMLLog.warning("[TB]Attempting to register revolver upgrade "+name+"["+id+"], but the ID is already occupied by "+allUpgrades[id].text_id+"["+allUpgrades[id].id+"], ignoring.", new Object[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (id >= allUpgrades.length)
|
||||
{
|
||||
RevolverUpgrade[] copied = new RevolverUpgrade[allUpgrades.length+1];
|
||||
System.arraycopy(allUpgrades, 0, copied, 0, allUpgrades.length);
|
||||
allUpgrades = copied;
|
||||
}
|
||||
|
||||
allUpgrades[id] = this;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return StatCollector.translateToLocal("revolverUpgrade."+text_id+".name");
|
||||
}
|
||||
|
||||
public int getID()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTextID()
|
||||
{
|
||||
return text_id;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public RevolverUpgrade setMaxLevel(int i)
|
||||
{
|
||||
maxLevel = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean conflictsWith(RevolverUpgrade upgrade)
|
||||
{
|
||||
return conflicts.contains(upgrade);
|
||||
}
|
||||
|
||||
public RevolverUpgrade addConflict(RevolverUpgrade... upgrade)
|
||||
{
|
||||
for(RevolverUpgrade rUpgr : upgrade)
|
||||
{
|
||||
if(!conflicts.contains(rUpgr))
|
||||
conflicts.add(rUpgr);
|
||||
|
||||
if(!rUpgr.conflicts.contains(this))
|
||||
rUpgr.conflicts.add(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getInstabilityForLevel(int level)
|
||||
{
|
||||
return instability * level;
|
||||
}
|
||||
|
||||
public RevolverUpgrade setInstabilityPerLevel(int newValue)
|
||||
{
|
||||
instability = newValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the revolver damage - pass 0
|
||||
* @param base - the entity to modify against. null means that the modification is not applied for the attack, and rather is applied for the information.
|
||||
* @param revolver - the revolver
|
||||
* @param currentModification - damage BEFORE the modification
|
||||
* @param modLevel - the level of this modifier
|
||||
* @return the new damage value
|
||||
*/
|
||||
public float modifyDamage_start(EntityLivingBase base, ItemStack revolver, float currentModification, int modLevel)
|
||||
{
|
||||
if(base != null)
|
||||
{
|
||||
if(this == power)
|
||||
return (float) (currentModification*(Math.pow(1.1F, modLevel)));
|
||||
|
||||
if(this == silver && (base.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD || isBMEntity(base) || (base instanceof EntityPlayer && isWerewolf(EntityPlayer.class.cast(base)))))
|
||||
return (float) (currentModification*(Math.pow(1.2F, modLevel)));
|
||||
|
||||
if(this == atropodsBane && base.getCreatureAttribute() == EnumCreatureAttribute.ARTHROPOD)
|
||||
return (float) (currentModification*(Math.pow(1.2F, modLevel)));
|
||||
|
||||
if(this == eldritchBane && (base instanceof IEldritchMob || base instanceof EntityEnderman))
|
||||
return (float) (currentModification*(Math.pow(1.2F, modLevel)));
|
||||
|
||||
if(this == dueling && base instanceof EntityPlayer)
|
||||
return (float) (currentModification*(Math.pow(1.2F, modLevel)));
|
||||
|
||||
if(this == eldritch)
|
||||
{
|
||||
if(base instanceof IBossDisplayData)
|
||||
return (float) (currentModification*(Math.pow(1.3F, modLevel)));
|
||||
else
|
||||
return currentModification / 1.2F;
|
||||
}
|
||||
|
||||
if(this == piercig)
|
||||
return currentModification * 1.1F;
|
||||
|
||||
if(this == tainted)
|
||||
{
|
||||
if(base instanceof ITaintedMob)
|
||||
return currentModification / 1.6F;
|
||||
else
|
||||
return (float) (currentModification*(Math.pow(1.2F, modLevel)));
|
||||
}
|
||||
}
|
||||
return currentModification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the revolver damage - pass 1
|
||||
* @param base - the entity to modify against. null means that the modification is not applied for the attack, and rather is applied for the information.
|
||||
* @param revolver - the revolver
|
||||
* @param currentModification - damage BEFORE the modification
|
||||
* @param modLevel - the level of this modifier
|
||||
* @return the new damage value
|
||||
*/
|
||||
public float modifyDamage_end(EntityLivingBase base, ItemStack revolver, float currentModification, int modLevel)
|
||||
{
|
||||
if(this == primal)
|
||||
return currentModification * 2;
|
||||
|
||||
return currentModification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if the bullet is destroyed.
|
||||
* @param base the entity damaged
|
||||
* @param user the shooter(can be null?)
|
||||
* @param revolver the revolver
|
||||
* @param damageDealt the damage dealt
|
||||
* @param modLevel the level of this upgrade
|
||||
* @return true to destroy bulled, false otherwise
|
||||
*/
|
||||
public boolean afterhit(EntityLivingBase base, EntityPlayer user,ItemStack revolver,final float damageDealt, int modLevel)
|
||||
{
|
||||
if(this == tainted)
|
||||
if(base.worldObj.rand.nextDouble() <= 0.1D)
|
||||
base.addPotionEffect(new PotionEffect(Config.potionTaintPoisonID,200,1,true));
|
||||
|
||||
if(this == poisoned)
|
||||
base.addPotionEffect(new PotionEffect(Potion.poison.id,200,1,true));
|
||||
|
||||
if(this == knowledge && base.getHealth() <= 0 && user != null)
|
||||
{
|
||||
if(user.worldObj.rand.nextInt(Math.max(1, 7-modLevel)) == 0)
|
||||
{
|
||||
AspectList aspectsCompound = ScanManager.generateEntityAspects(base);
|
||||
if(aspectsCompound != null && aspectsCompound.size() > 0)
|
||||
{
|
||||
Aspect[] al = aspectsCompound.getAspects();
|
||||
for(int i = 0; i < al.length; ++i)
|
||||
{
|
||||
TBUtils.addAspectToKnowledgePool(user, al[i], (short) 1);
|
||||
if(user.worldObj.rand.nextBoolean())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(this == piercig)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if the bullet can travel through the ground or should get destroyed on contact
|
||||
* @param user the player using the weapon(can be null?)
|
||||
* @param revolver the revolver
|
||||
* @param modLevel the level of this upgrade
|
||||
* @return
|
||||
*/
|
||||
public boolean bulletNoclip(EntityPlayer user,ItemStack revolver, int modLevel)
|
||||
{
|
||||
if(this == primal)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the amount of shots 1 aspect point gives to the weapon
|
||||
* @param user the player
|
||||
* @param revolver the gun
|
||||
* @param modLevel this level
|
||||
* @param originalLevel 2 or the result of previous run of this
|
||||
* @param hasPrimal if the primal upgrade is installed
|
||||
* @return -1 for 2 consumption, anythingelse otherwise
|
||||
*/
|
||||
public int modifyShots(EntityPlayer user, ItemStack revolver, int modLevel, int originalLevel, boolean hasPrimal)
|
||||
{
|
||||
if(this == primal)
|
||||
return -1;
|
||||
|
||||
if(this == efficiency)
|
||||
return hasPrimal ? modLevel == 5 ? 1 : -1 : originalLevel+modLevel;
|
||||
|
||||
return originalLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to modify the bullet speed
|
||||
* @param user the player
|
||||
* @param revolver the gun
|
||||
* @param origSpeed the original bullet speed
|
||||
* @param modLevel the level of the modifier
|
||||
* @return
|
||||
*/
|
||||
public double modifySpeed(EntityPlayer user, ItemStack revolver, float origSpeed, int modLevel)
|
||||
{
|
||||
if(this == speed)
|
||||
return (float)origSpeed*Math.pow(1.09F, modLevel);
|
||||
return origSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for rendering to override the texture for a specific part of the weapon. If 2 or more upgrades override the same part texture the latest in the list will get rendered.
|
||||
* @param revolver the revolver
|
||||
* @param part The actual part.<BR>0 = Handle<BR>1 = Cylinder<BR>2 = generic metal texture<BR>3 = Barrel<BR>4 = Trigger
|
||||
* @param level The level of this upgrade
|
||||
* @return null if the texture is not overriden, your texture otherwise.
|
||||
*/
|
||||
public ResourceLocation getOverridePartTexture(ItemStack revolver, int part, int level)
|
||||
{
|
||||
if(this == eldritch && part == 2)
|
||||
return eldritchTextures;
|
||||
|
||||
if(this == primal && part == 3)
|
||||
return primalTextures;
|
||||
|
||||
if(this == tainted && part == 3)
|
||||
return taintedTextures;
|
||||
|
||||
if(this == uvoid && part == 0)
|
||||
return voidTextures;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isBMEntity(EntityLivingBase base)
|
||||
{
|
||||
if(Loader.isModLoaded("AWWayofTime"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> demonClass = Class.forName("WayofTime.alchemicalWizardry.common.IDemon");
|
||||
if(demonClass.isInstance(base))
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isWerewolf(EntityPlayer p)
|
||||
{
|
||||
if(Loader.isModLoaded("witchery"))
|
||||
{
|
||||
if(p.getExtendedProperties("WitcheryExtendedPlayer") != null)
|
||||
{
|
||||
IExtendedEntityProperties props = p.getExtendedProperties("WitcheryExtendedPlayer");
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
props.saveNBTData(tag);
|
||||
return tag.getCompoundTag("WitcheryExtendedPlayer").getInteger("WerewolfLevel") > 0 || tag.getInteger("WerewolfLevel") > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void initConflictingMappings()
|
||||
{
|
||||
power.addConflict(silver,atropodsBane,eldritchBane,dueling,eldritch);
|
||||
silver.addConflict(atropodsBane,eldritchBane,dueling,eldritch);
|
||||
atropodsBane.addConflict(eldritchBane,dueling,eldritch);
|
||||
eldritchBane.addConflict(dueling,eldritch);
|
||||
dueling.addConflict(eldritch);
|
||||
|
||||
accuracy.addConflict(speed,efficiency);
|
||||
speed.addConflict(efficiency);
|
||||
|
||||
poisoned.addConflict(primal,tainted,knowledge);
|
||||
primal.addConflict(tainted,knowledge);
|
||||
tainted.addConflict(knowledge);
|
||||
}
|
||||
|
||||
public static final RevolverUpgrade power = new RevolverUpgrade(0,"POWER").setMaxLevel(5).setInstabilityPerLevel(2);
|
||||
public static final RevolverUpgrade accuracy = new RevolverUpgrade(1,"ACCURACY").setMaxLevel(3).setInstabilityPerLevel(1);
|
||||
public static final RevolverUpgrade silver = new RevolverUpgrade(2,"SILVER").setMaxLevel(5).setInstabilityPerLevel(3);
|
||||
public static final RevolverUpgrade poisoned = new RevolverUpgrade(3,"POISONED").setMaxLevel(3).setInstabilityPerLevel(1);
|
||||
public static final RevolverUpgrade atropodsBane = new RevolverUpgrade(4,"BANE_OF_ATROPODS").setMaxLevel(5).setInstabilityPerLevel(3);
|
||||
public static final RevolverUpgrade eldritchBane = new RevolverUpgrade(5,"BANE_OF_ELDRITCH").setMaxLevel(5).setInstabilityPerLevel(3);
|
||||
public static final RevolverUpgrade piercig = new RevolverUpgrade(6,"PIERCING").setMaxLevel(1).setInstabilityPerLevel(12);
|
||||
public static final RevolverUpgrade dueling = new RevolverUpgrade(7,"DUELING").setMaxLevel(5).setInstabilityPerLevel(3);
|
||||
public static final RevolverUpgrade tainted = new RevolverUpgrade(8,"TAINTED").setMaxLevel(3).setInstabilityPerLevel(5);
|
||||
public static final RevolverUpgrade primal = new RevolverUpgrade(9,"PRIMAL").setMaxLevel(1).setInstabilityPerLevel(12);
|
||||
public static final RevolverUpgrade speed = new RevolverUpgrade(10,"SPEED").setMaxLevel(5).setInstabilityPerLevel(2);
|
||||
public static final RevolverUpgrade efficiency = new RevolverUpgrade(11,"EFFICIENCY").setMaxLevel(5).setInstabilityPerLevel(4);
|
||||
public static final RevolverUpgrade eldritch = new RevolverUpgrade(12,"ELDRITCH").setMaxLevel(2).setInstabilityPerLevel(7);
|
||||
public static final RevolverUpgrade uvoid = new RevolverUpgrade(13,"VOID").setMaxLevel(3).setInstabilityPerLevel(4);
|
||||
public static final RevolverUpgrade knowledge = new RevolverUpgrade(14,"KNOWLEDGE").setMaxLevel(5).setInstabilityPerLevel(1);
|
||||
public static final RevolverUpgrade heavy = new RevolverUpgrade(15,"HEAVY").setMaxLevel(5).setInstabilityPerLevel(1);
|
||||
|
||||
public static RevolverUpgrade[] allUpgrades = new RevolverUpgrade[24];
|
||||
public static Hashtable<String, Integer> textToIntMapping = new Hashtable<String, Integer>();
|
||||
public static Hashtable<Integer, String> intToTextMapping = new Hashtable<Integer, String>();
|
||||
|
||||
public int maxLevel;
|
||||
public final int id;
|
||||
public final String text_id;
|
||||
public int instability;
|
||||
|
||||
public static final ResourceLocation eldritchTextures =
|
||||
new ResourceLocation("thaumicbases", "textures/items/revolver/revolverDarkMetalEldritch.png");
|
||||
public static final ResourceLocation primalTextures =
|
||||
new ResourceLocation("thaumicbases", "textures/items/revolver/revolverGunPrimalUV.png");
|
||||
public static final ResourceLocation taintedTextures =
|
||||
new ResourceLocation("thaumicbases", "textures/items/revolver/revolverGunTaintedUV.png");
|
||||
public static final ResourceLocation voidTextures =
|
||||
new ResourceLocation("thaumicbases", "textures/items/revolver/revolverHandleVoidUV.png");
|
||||
|
||||
public final ArrayList<RevolverUpgrade> conflicts = new ArrayList<RevolverUpgrade>();
|
||||
|
||||
public RevolverUpgrade(int id, String name) {
|
||||
text_id = name;
|
||||
this.id = id;
|
||||
|
||||
if (id < allUpgrades.length && allUpgrades[id] != null) {
|
||||
FMLLog.warning(
|
||||
"[TB]Attempting to register revolver upgrade " + name + "[" + id
|
||||
+ "], but the ID is already occupied by " + allUpgrades[id].text_id + "["
|
||||
+ allUpgrades[id].id + "], ignoring.",
|
||||
new Object[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (id >= allUpgrades.length) {
|
||||
RevolverUpgrade[] copied = new RevolverUpgrade[allUpgrades.length + 1];
|
||||
System.arraycopy(allUpgrades, 0, copied, 0, allUpgrades.length);
|
||||
allUpgrades = copied;
|
||||
}
|
||||
|
||||
allUpgrades[id] = this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return StatCollector.translateToLocal("revolverUpgrade." + text_id + ".name");
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTextID() {
|
||||
return text_id;
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
public RevolverUpgrade setMaxLevel(int i) {
|
||||
maxLevel = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean conflictsWith(RevolverUpgrade upgrade) {
|
||||
return conflicts.contains(upgrade);
|
||||
}
|
||||
|
||||
public RevolverUpgrade addConflict(RevolverUpgrade... upgrade) {
|
||||
for (RevolverUpgrade rUpgr : upgrade) {
|
||||
if (!conflicts.contains(rUpgr)) conflicts.add(rUpgr);
|
||||
|
||||
if (!rUpgr.conflicts.contains(this)) rUpgr.conflicts.add(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getInstabilityForLevel(int level) {
|
||||
return instability * level;
|
||||
}
|
||||
|
||||
public RevolverUpgrade setInstabilityPerLevel(int newValue) {
|
||||
instability = newValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the revolver damage - pass 0
|
||||
* @param base - the entity to modify against. null means that the modification is not applied for the attack, and rather is applied for the information.
|
||||
* @param revolver - the revolver
|
||||
* @param currentModification - damage BEFORE the modification
|
||||
* @param modLevel - the level of this modifier
|
||||
* @return the new damage value
|
||||
*/
|
||||
public float modifyDamage_start(
|
||||
EntityLivingBase base, ItemStack revolver, float currentModification, int modLevel) {
|
||||
if (base != null) {
|
||||
if (this == power) return (float) (currentModification * (Math.pow(1.1F, modLevel)));
|
||||
|
||||
if (this == silver
|
||||
&& (base.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD
|
||||
|| isBMEntity(base)
|
||||
|| (base instanceof EntityPlayer && isWerewolf(EntityPlayer.class.cast(base)))))
|
||||
return (float) (currentModification * (Math.pow(1.2F, modLevel)));
|
||||
|
||||
if (this == atropodsBane && base.getCreatureAttribute() == EnumCreatureAttribute.ARTHROPOD)
|
||||
return (float) (currentModification * (Math.pow(1.2F, modLevel)));
|
||||
|
||||
if (this == eldritchBane && (base instanceof IEldritchMob || base instanceof EntityEnderman))
|
||||
return (float) (currentModification * (Math.pow(1.2F, modLevel)));
|
||||
|
||||
if (this == dueling && base instanceof EntityPlayer)
|
||||
return (float) (currentModification * (Math.pow(1.2F, modLevel)));
|
||||
|
||||
if (this == eldritch) {
|
||||
if (base instanceof IBossDisplayData) return (float) (currentModification * (Math.pow(1.3F, modLevel)));
|
||||
else return currentModification / 1.2F;
|
||||
}
|
||||
|
||||
if (this == piercig) return currentModification * 1.1F;
|
||||
|
||||
if (this == tainted) {
|
||||
if (base instanceof ITaintedMob) return currentModification / 1.6F;
|
||||
else return (float) (currentModification * (Math.pow(1.2F, modLevel)));
|
||||
}
|
||||
}
|
||||
return currentModification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies the revolver damage - pass 1
|
||||
* @param base - the entity to modify against. null means that the modification is not applied for the attack, and rather is applied for the information.
|
||||
* @param revolver - the revolver
|
||||
* @param currentModification - damage BEFORE the modification
|
||||
* @param modLevel - the level of this modifier
|
||||
* @return the new damage value
|
||||
*/
|
||||
public float modifyDamage_end(EntityLivingBase base, ItemStack revolver, float currentModification, int modLevel) {
|
||||
if (this == primal) return currentModification * 2;
|
||||
|
||||
return currentModification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if the bullet is destroyed.
|
||||
* @param base the entity damaged
|
||||
* @param user the shooter(can be null?)
|
||||
* @param revolver the revolver
|
||||
* @param damageDealt the damage dealt
|
||||
* @param modLevel the level of this upgrade
|
||||
* @return true to destroy bulled, false otherwise
|
||||
*/
|
||||
public boolean afterhit(
|
||||
EntityLivingBase base, EntityPlayer user, ItemStack revolver, final float damageDealt, int modLevel) {
|
||||
if (this == tainted)
|
||||
if (base.worldObj.rand.nextDouble() <= 0.1D)
|
||||
base.addPotionEffect(new PotionEffect(Config.potionTaintPoisonID, 200, 1, true));
|
||||
|
||||
if (this == poisoned) base.addPotionEffect(new PotionEffect(Potion.poison.id, 200, 1, true));
|
||||
|
||||
if (this == knowledge && base.getHealth() <= 0 && user != null) {
|
||||
if (user.worldObj.rand.nextInt(Math.max(1, 7 - modLevel)) == 0) {
|
||||
AspectList aspectsCompound = ScanManager.generateEntityAspects(base);
|
||||
if (aspectsCompound != null && aspectsCompound.size() > 0) {
|
||||
Aspect[] al = aspectsCompound.getAspects();
|
||||
for (int i = 0; i < al.length; ++i) {
|
||||
TBUtils.addAspectToKnowledgePool(user, al[i], (short) 1);
|
||||
if (user.worldObj.rand.nextBoolean()) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this == piercig) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if the bullet can travel through the ground or should get destroyed on contact
|
||||
* @param user the player using the weapon(can be null?)
|
||||
* @param revolver the revolver
|
||||
* @param modLevel the level of this upgrade
|
||||
* @return
|
||||
*/
|
||||
public boolean bulletNoclip(EntityPlayer user, ItemStack revolver, int modLevel) {
|
||||
if (this == primal) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the amount of shots 1 aspect point gives to the weapon
|
||||
* @param user the player
|
||||
* @param revolver the gun
|
||||
* @param modLevel this level
|
||||
* @param originalLevel 2 or the result of previous run of this
|
||||
* @param hasPrimal if the primal upgrade is installed
|
||||
* @return -1 for 2 consumption, anythingelse otherwise
|
||||
*/
|
||||
public int modifyShots(EntityPlayer user, ItemStack revolver, int modLevel, int originalLevel, boolean hasPrimal) {
|
||||
if (this == primal) return -1;
|
||||
|
||||
if (this == efficiency) return hasPrimal ? modLevel == 5 ? 1 : -1 : originalLevel + modLevel;
|
||||
|
||||
return originalLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to modify the bullet speed
|
||||
* @param user the player
|
||||
* @param revolver the gun
|
||||
* @param origSpeed the original bullet speed
|
||||
* @param modLevel the level of the modifier
|
||||
* @return
|
||||
*/
|
||||
public double modifySpeed(EntityPlayer user, ItemStack revolver, float origSpeed, int modLevel) {
|
||||
if (this == speed) return (float) origSpeed * Math.pow(1.09F, modLevel);
|
||||
return origSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for rendering to override the texture for a specific part of the weapon. If 2 or more upgrades override the same part texture the latest in the list will get rendered.
|
||||
* @param revolver the revolver
|
||||
* @param part The actual part.<BR>0 = Handle<BR>1 = Cylinder<BR>2 = generic metal texture<BR>3 = Barrel<BR>4 = Trigger
|
||||
* @param level The level of this upgrade
|
||||
* @return null if the texture is not overriden, your texture otherwise.
|
||||
*/
|
||||
public ResourceLocation getOverridePartTexture(ItemStack revolver, int part, int level) {
|
||||
if (this == eldritch && part == 2) return eldritchTextures;
|
||||
|
||||
if (this == primal && part == 3) return primalTextures;
|
||||
|
||||
if (this == tainted && part == 3) return taintedTextures;
|
||||
|
||||
if (this == uvoid && part == 0) return voidTextures;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isBMEntity(EntityLivingBase base) {
|
||||
if (Loader.isModLoaded("AWWayofTime")) {
|
||||
try {
|
||||
Class<?> demonClass = Class.forName("WayofTime.alchemicalWizardry.common.IDemon");
|
||||
if (demonClass.isInstance(base)) return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isWerewolf(EntityPlayer p) {
|
||||
if (Loader.isModLoaded("witchery")) {
|
||||
if (p.getExtendedProperties("WitcheryExtendedPlayer") != null) {
|
||||
IExtendedEntityProperties props = p.getExtendedProperties("WitcheryExtendedPlayer");
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
props.saveNBTData(tag);
|
||||
return tag.getCompoundTag("WitcheryExtendedPlayer").getInteger("WerewolfLevel") > 0
|
||||
|| tag.getInteger("WerewolfLevel") > 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void initConflictingMappings() {
|
||||
power.addConflict(silver, atropodsBane, eldritchBane, dueling, eldritch);
|
||||
silver.addConflict(atropodsBane, eldritchBane, dueling, eldritch);
|
||||
atropodsBane.addConflict(eldritchBane, dueling, eldritch);
|
||||
eldritchBane.addConflict(dueling, eldritch);
|
||||
dueling.addConflict(eldritch);
|
||||
|
||||
accuracy.addConflict(speed, efficiency);
|
||||
speed.addConflict(efficiency);
|
||||
|
||||
poisoned.addConflict(primal, tainted, knowledge);
|
||||
primal.addConflict(tainted, knowledge);
|
||||
tainted.addConflict(knowledge);
|
||||
}
|
||||
|
||||
public static final RevolverUpgrade power =
|
||||
new RevolverUpgrade(0, "POWER").setMaxLevel(5).setInstabilityPerLevel(2);
|
||||
public static final RevolverUpgrade accuracy =
|
||||
new RevolverUpgrade(1, "ACCURACY").setMaxLevel(3).setInstabilityPerLevel(1);
|
||||
public static final RevolverUpgrade silver =
|
||||
new RevolverUpgrade(2, "SILVER").setMaxLevel(5).setInstabilityPerLevel(3);
|
||||
public static final RevolverUpgrade poisoned =
|
||||
new RevolverUpgrade(3, "POISONED").setMaxLevel(3).setInstabilityPerLevel(1);
|
||||
public static final RevolverUpgrade atropodsBane =
|
||||
new RevolverUpgrade(4, "BANE_OF_ATROPODS").setMaxLevel(5).setInstabilityPerLevel(3);
|
||||
public static final RevolverUpgrade eldritchBane =
|
||||
new RevolverUpgrade(5, "BANE_OF_ELDRITCH").setMaxLevel(5).setInstabilityPerLevel(3);
|
||||
public static final RevolverUpgrade piercig =
|
||||
new RevolverUpgrade(6, "PIERCING").setMaxLevel(1).setInstabilityPerLevel(12);
|
||||
public static final RevolverUpgrade dueling =
|
||||
new RevolverUpgrade(7, "DUELING").setMaxLevel(5).setInstabilityPerLevel(3);
|
||||
public static final RevolverUpgrade tainted =
|
||||
new RevolverUpgrade(8, "TAINTED").setMaxLevel(3).setInstabilityPerLevel(5);
|
||||
public static final RevolverUpgrade primal =
|
||||
new RevolverUpgrade(9, "PRIMAL").setMaxLevel(1).setInstabilityPerLevel(12);
|
||||
public static final RevolverUpgrade speed =
|
||||
new RevolverUpgrade(10, "SPEED").setMaxLevel(5).setInstabilityPerLevel(2);
|
||||
public static final RevolverUpgrade efficiency =
|
||||
new RevolverUpgrade(11, "EFFICIENCY").setMaxLevel(5).setInstabilityPerLevel(4);
|
||||
public static final RevolverUpgrade eldritch =
|
||||
new RevolverUpgrade(12, "ELDRITCH").setMaxLevel(2).setInstabilityPerLevel(7);
|
||||
public static final RevolverUpgrade uvoid =
|
||||
new RevolverUpgrade(13, "VOID").setMaxLevel(3).setInstabilityPerLevel(4);
|
||||
public static final RevolverUpgrade knowledge =
|
||||
new RevolverUpgrade(14, "KNOWLEDGE").setMaxLevel(5).setInstabilityPerLevel(1);
|
||||
public static final RevolverUpgrade heavy =
|
||||
new RevolverUpgrade(15, "HEAVY").setMaxLevel(5).setInstabilityPerLevel(1);
|
||||
}
|
||||
@@ -1,36 +1,44 @@
|
||||
package tb.client;
|
||||
|
||||
import tb.api.RevolverUpgrade;
|
||||
import tb.common.item.ItemRevolver;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.client.event.FOVUpdateEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
import tb.api.RevolverUpgrade;
|
||||
import tb.common.item.ItemRevolver;
|
||||
|
||||
public class RevolverEvents
|
||||
{
|
||||
@SubscribeEvent
|
||||
public void renderCrossharEvent(RenderGameOverlayEvent event)
|
||||
{
|
||||
if(event.type == ElementType.CROSSHAIRS && Minecraft.getMinecraft().thePlayer.isSneaking())
|
||||
{
|
||||
if(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getItem() instanceof ItemRevolver)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void renderZoomEvent(FOVUpdateEvent event)
|
||||
{
|
||||
if(Minecraft.getMinecraft().thePlayer.isSneaking())
|
||||
{
|
||||
if(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getItem() instanceof ItemRevolver)
|
||||
{
|
||||
event.newfov = 0.9F / (ItemRevolver.getUpgradeLevel(Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(), RevolverUpgrade.accuracy)+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class RevolverEvents {
|
||||
@SubscribeEvent
|
||||
public void renderCrossharEvent(RenderGameOverlayEvent event) {
|
||||
if (event.type == ElementType.CROSSHAIRS
|
||||
&& Minecraft.getMinecraft().thePlayer.isSneaking()) {
|
||||
if (Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null
|
||||
&& Minecraft.getMinecraft()
|
||||
.thePlayer
|
||||
.getCurrentEquippedItem()
|
||||
.getItem()
|
||||
instanceof ItemRevolver) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void renderZoomEvent(FOVUpdateEvent event) {
|
||||
if (Minecraft.getMinecraft().thePlayer.isSneaking()) {
|
||||
if (Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null
|
||||
&& Minecraft.getMinecraft()
|
||||
.thePlayer
|
||||
.getCurrentEquippedItem()
|
||||
.getItem()
|
||||
instanceof ItemRevolver) {
|
||||
event.newfov = 0.9F
|
||||
/ (ItemRevolver.getUpgradeLevel(
|
||||
Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(),
|
||||
RevolverUpgrade.accuracy)
|
||||
+ 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +1,55 @@
|
||||
package tb.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tb.common.inventory.ContainerRevolver;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tb.common.inventory.ContainerRevolver;
|
||||
|
||||
public class GuiRevolver extends GuiContainer
|
||||
{
|
||||
public class GuiRevolver extends GuiContainer {
|
||||
|
||||
public static final ResourceLocation revolverTextures = new ResourceLocation("thaumicbases","textures/gui/revolver.png");
|
||||
public int blockedSlot;
|
||||
|
||||
public GuiRevolver(InventoryPlayer inv, World w, int x, int y, int z)
|
||||
{
|
||||
super(new ContainerRevolver(inv,w,x,y,z));
|
||||
this.blockedSlot = inv.currentItem;
|
||||
}
|
||||
|
||||
//Draw a cross above the revolver
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseZ)
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(revolverTextures);
|
||||
float storedZLevel = this.zLevel;
|
||||
|
||||
this.zLevel = 200;
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
drawTexturedModalRect(8 + blockedSlot * 18, 142, 240, 0, 16, 16);
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
this.zLevel = storedZLevel;
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseZ)
|
||||
{
|
||||
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
|
||||
if (p.inventory.mainInventory.length > this.blockedSlot && p.inventory.mainInventory[this.blockedSlot] == null)
|
||||
p.closeScreen();
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(revolverTextures);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
}
|
||||
public static final ResourceLocation revolverTextures =
|
||||
new ResourceLocation("thaumicbases", "textures/gui/revolver.png");
|
||||
public int blockedSlot;
|
||||
|
||||
public GuiRevolver(InventoryPlayer inv, World w, int x, int y, int z) {
|
||||
super(new ContainerRevolver(inv, w, x, y, z));
|
||||
this.blockedSlot = inv.currentItem;
|
||||
}
|
||||
|
||||
// Draw a cross above the revolver
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseZ) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(revolverTextures);
|
||||
float storedZLevel = this.zLevel;
|
||||
|
||||
this.zLevel = 200;
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
drawTexturedModalRect(8 + blockedSlot * 18, 142, 240, 0, 16, 16);
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
this.zLevel = storedZLevel;
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseZ) {
|
||||
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
|
||||
if (p.inventory.mainInventory.length > this.blockedSlot && p.inventory.mainInventory[this.blockedSlot] == null)
|
||||
p.closeScreen();
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(revolverTextures);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ package tb.client.gui;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
@@ -17,33 +15,30 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.client.C17PacketCustomPayload;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tb.common.inventory.ContainerThaumicAnvil;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiThaumicAnvil extends GuiContainer implements ICrafting
|
||||
{
|
||||
public class GuiThaumicAnvil extends GuiContainer implements ICrafting {
|
||||
private static final ResourceLocation field_147093_u = new ResourceLocation("textures/gui/container/anvil.png");
|
||||
private ContainerThaumicAnvil field_147092_v;
|
||||
private GuiTextField field_147091_w;
|
||||
private InventoryPlayer field_147094_x;
|
||||
|
||||
public GuiThaumicAnvil(InventoryPlayer p_i1073_1_, World p_i1073_2_, int p_i1073_3_, int p_i1073_4_, int p_i1073_5_)
|
||||
{
|
||||
super(new ContainerThaumicAnvil(p_i1073_1_, p_i1073_2_, p_i1073_3_, p_i1073_4_, p_i1073_5_, Minecraft.getMinecraft().thePlayer));
|
||||
public GuiThaumicAnvil(
|
||||
InventoryPlayer p_i1073_1_, World p_i1073_2_, int p_i1073_3_, int p_i1073_4_, int p_i1073_5_) {
|
||||
super(new ContainerThaumicAnvil(
|
||||
p_i1073_1_, p_i1073_2_, p_i1073_3_, p_i1073_4_, p_i1073_5_, Minecraft.getMinecraft().thePlayer));
|
||||
this.field_147094_x = p_i1073_1_;
|
||||
this.field_147092_v = (ContainerThaumicAnvil)this.inventorySlots;
|
||||
this.field_147092_v = (ContainerThaumicAnvil) this.inventorySlots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the buttons (and other controls) to the screen in question.
|
||||
*/
|
||||
public void initGui()
|
||||
{
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
@@ -60,8 +55,7 @@ public class GuiThaumicAnvil extends GuiContainer implements ICrafting
|
||||
/**
|
||||
* Called when the screen is unloaded. Used to disable keyboard repeat events
|
||||
*/
|
||||
public void onGuiClosed()
|
||||
{
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
this.inventorySlots.removeCraftingFromCrafters(this);
|
||||
@@ -70,45 +64,35 @@ public class GuiThaumicAnvil extends GuiContainer implements ICrafting
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
|
||||
{
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
this.fontRendererObj.drawString(I18n.format("container.repair", new Object[0]), 60, 6, 4210752);
|
||||
|
||||
if (this.field_147092_v.maximumCost > 0)
|
||||
{
|
||||
if (this.field_147092_v.maximumCost > 0) {
|
||||
int k = 8453920;
|
||||
boolean flag = true;
|
||||
String s = I18n.format("container.repair.cost", new Object[] {Integer.valueOf(this.field_147092_v.maximumCost)});
|
||||
String s = I18n.format(
|
||||
"container.repair.cost", new Object[] {Integer.valueOf(this.field_147092_v.maximumCost)});
|
||||
|
||||
if (this.field_147092_v.maximumCost >= 40 && !this.mc.thePlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (this.field_147092_v.maximumCost >= 40 && !this.mc.thePlayer.capabilities.isCreativeMode) {
|
||||
s = I18n.format("container.repair.expensive", new Object[0]);
|
||||
k = 16736352;
|
||||
}
|
||||
else if (!this.field_147092_v.getSlot(2).getHasStack())
|
||||
{
|
||||
} else if (!this.field_147092_v.getSlot(2).getHasStack()) {
|
||||
flag = false;
|
||||
}
|
||||
else if (!this.field_147092_v.getSlot(2).canTakeStack(this.field_147094_x.player))
|
||||
{
|
||||
} else if (!this.field_147092_v.getSlot(2).canTakeStack(this.field_147094_x.player)) {
|
||||
k = 16736352;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
int l = -16777216 | (k & 16579836) >> 2 | k & -16777216;
|
||||
int i1 = this.xSize - 8 - this.fontRendererObj.getStringWidth(s);
|
||||
byte b0 = 67;
|
||||
|
||||
if (this.fontRendererObj.getUnicodeFlag())
|
||||
{
|
||||
if (this.fontRendererObj.getUnicodeFlag()) {
|
||||
drawRect(i1 - 3, b0 - 2, this.xSize - 7, b0 + 10, -16777216);
|
||||
drawRect(i1 - 2, b0 - 1, this.xSize - 8, b0 + 9, -12895429);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.fontRendererObj.drawString(s, i1, b0 + 1, l);
|
||||
this.fontRendererObj.drawString(s, i1 + 1, b0, l);
|
||||
this.fontRendererObj.drawString(s, i1 + 1, b0 + 1, l);
|
||||
@@ -124,37 +108,34 @@ public class GuiThaumicAnvil extends GuiContainer implements ICrafting
|
||||
/**
|
||||
* Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
|
||||
*/
|
||||
protected void keyTyped(char p_73869_1_, int p_73869_2_)
|
||||
{
|
||||
if (this.field_147091_w.textboxKeyTyped(p_73869_1_, p_73869_2_))
|
||||
{
|
||||
protected void keyTyped(char p_73869_1_, int p_73869_2_) {
|
||||
if (this.field_147091_w.textboxKeyTyped(p_73869_1_, p_73869_2_)) {
|
||||
this.func_147090_g();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
super.keyTyped(p_73869_1_, p_73869_2_);
|
||||
}
|
||||
}
|
||||
|
||||
private void func_147090_g()
|
||||
{
|
||||
private void func_147090_g() {
|
||||
String s = this.field_147091_w.getText();
|
||||
Slot slot = this.field_147092_v.getSlot(0);
|
||||
|
||||
if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
|
||||
{
|
||||
if (slot != null
|
||||
&& slot.getHasStack()
|
||||
&& !slot.getStack().hasDisplayName()
|
||||
&& s.equals(slot.getStack().getDisplayName())) {
|
||||
s = "";
|
||||
}
|
||||
|
||||
this.field_147092_v.updateItemName(s);
|
||||
this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", s.getBytes(Charsets.UTF_8)));
|
||||
this.mc.thePlayer.sendQueue.addToSendQueue(
|
||||
new C17PacketCustomPayload("MC|ItemName", s.getBytes(Charsets.UTF_8)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse is clicked.
|
||||
*/
|
||||
protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_)
|
||||
{
|
||||
protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_) {
|
||||
super.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_);
|
||||
this.field_147091_w.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_);
|
||||
}
|
||||
@@ -162,32 +143,31 @@ public class GuiThaumicAnvil extends GuiContainer implements ICrafting
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
|
||||
{
|
||||
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) {
|
||||
super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
this.field_147091_w.drawTextBox();
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_)
|
||||
{
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(field_147093_u);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
this.drawTexturedModalRect(k + 59, l + 20, 0, this.ySize + (this.field_147092_v.getSlot(0).getHasStack() ? 0 : 16), 110, 16);
|
||||
this.drawTexturedModalRect(
|
||||
k + 59, l + 20, 0, this.ySize + (this.field_147092_v.getSlot(0).getHasStack() ? 0 : 16), 110, 16);
|
||||
|
||||
if ((this.field_147092_v.getSlot(0).getHasStack() || this.field_147092_v.getSlot(1).getHasStack()) && !this.field_147092_v.getSlot(2).getHasStack())
|
||||
{
|
||||
if ((this.field_147092_v.getSlot(0).getHasStack()
|
||||
|| this.field_147092_v.getSlot(1).getHasStack())
|
||||
&& !this.field_147092_v.getSlot(2).getHasStack()) {
|
||||
this.drawTexturedModalRect(k + 99, l + 45, this.xSize, 0, 28, 21);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void sendContainerAndContentsToPlayer(Container p_71110_1_, List p_71110_2_)
|
||||
{
|
||||
public void sendContainerAndContentsToPlayer(Container p_71110_1_, List p_71110_2_) {
|
||||
this.sendSlotContents(p_71110_1_, 0, p_71110_1_.getSlot(0).getStack());
|
||||
}
|
||||
|
||||
@@ -195,15 +175,12 @@ public class GuiThaumicAnvil extends GuiContainer implements ICrafting
|
||||
* Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
|
||||
* contents of that slot. Args: Container, slot number, slot contents
|
||||
*/
|
||||
public void sendSlotContents(Container p_71111_1_, int p_71111_2_, ItemStack p_71111_3_)
|
||||
{
|
||||
if (p_71111_2_ == 0)
|
||||
{
|
||||
public void sendSlotContents(Container p_71111_1_, int p_71111_2_, ItemStack p_71111_3_) {
|
||||
if (p_71111_2_ == 0) {
|
||||
this.field_147091_w.setText(p_71111_3_ == null ? "" : p_71111_3_.getDisplayName());
|
||||
this.field_147091_w.setEnabled(p_71111_3_ != null);
|
||||
|
||||
if (p_71111_3_ != null)
|
||||
{
|
||||
if (p_71111_3_ != null) {
|
||||
this.func_147090_g();
|
||||
}
|
||||
}
|
||||
@@ -215,4 +192,4 @@ public class GuiThaumicAnvil extends GuiContainer implements ICrafting
|
||||
* value. Both are truncated to shorts in non-local SMP.
|
||||
*/
|
||||
public void sendProgressBarUpdate(Container p_71112_1_, int p_71112_2_, int p_71112_3_) {}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ package tb.client.gui;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
@@ -17,33 +15,29 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.client.C17PacketCustomPayload;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tb.common.inventory.ContainerVoidAnvil;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiVoidAnvil extends GuiContainer implements ICrafting
|
||||
{
|
||||
public class GuiVoidAnvil extends GuiContainer implements ICrafting {
|
||||
private static final ResourceLocation field_147093_u = new ResourceLocation("textures/gui/container/anvil.png");
|
||||
private ContainerVoidAnvil field_147092_v;
|
||||
private GuiTextField field_147091_w;
|
||||
private InventoryPlayer field_147094_x;
|
||||
|
||||
public GuiVoidAnvil(InventoryPlayer p_i1073_1_, World p_i1073_2_, int p_i1073_3_, int p_i1073_4_, int p_i1073_5_)
|
||||
{
|
||||
super(new ContainerVoidAnvil(p_i1073_1_, p_i1073_2_, p_i1073_3_, p_i1073_4_, p_i1073_5_, Minecraft.getMinecraft().thePlayer));
|
||||
public GuiVoidAnvil(InventoryPlayer p_i1073_1_, World p_i1073_2_, int p_i1073_3_, int p_i1073_4_, int p_i1073_5_) {
|
||||
super(new ContainerVoidAnvil(
|
||||
p_i1073_1_, p_i1073_2_, p_i1073_3_, p_i1073_4_, p_i1073_5_, Minecraft.getMinecraft().thePlayer));
|
||||
this.field_147094_x = p_i1073_1_;
|
||||
this.field_147092_v = (ContainerVoidAnvil)this.inventorySlots;
|
||||
this.field_147092_v = (ContainerVoidAnvil) this.inventorySlots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the buttons (and other controls) to the screen in question.
|
||||
*/
|
||||
public void initGui()
|
||||
{
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
@@ -60,8 +54,7 @@ public class GuiVoidAnvil extends GuiContainer implements ICrafting
|
||||
/**
|
||||
* Called when the screen is unloaded. Used to disable keyboard repeat events
|
||||
*/
|
||||
public void onGuiClosed()
|
||||
{
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
this.inventorySlots.removeCraftingFromCrafters(this);
|
||||
@@ -70,45 +63,35 @@ public class GuiVoidAnvil extends GuiContainer implements ICrafting
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
|
||||
{
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
this.fontRendererObj.drawString(I18n.format("container.repair", new Object[0]), 60, 6, 4210752);
|
||||
|
||||
if (this.field_147092_v.maximumCost > 0)
|
||||
{
|
||||
if (this.field_147092_v.maximumCost > 0) {
|
||||
int k = 8453920;
|
||||
boolean flag = true;
|
||||
String s = I18n.format("container.repair.cost", new Object[] {Integer.valueOf(this.field_147092_v.maximumCost)});
|
||||
String s = I18n.format(
|
||||
"container.repair.cost", new Object[] {Integer.valueOf(this.field_147092_v.maximumCost)});
|
||||
|
||||
if (this.field_147092_v.maximumCost >= 40 && !this.mc.thePlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (this.field_147092_v.maximumCost >= 40 && !this.mc.thePlayer.capabilities.isCreativeMode) {
|
||||
s = I18n.format("container.repair.expensive", new Object[0]);
|
||||
k = 16736352;
|
||||
}
|
||||
else if (!this.field_147092_v.getSlot(2).getHasStack())
|
||||
{
|
||||
} else if (!this.field_147092_v.getSlot(2).getHasStack()) {
|
||||
flag = false;
|
||||
}
|
||||
else if (!this.field_147092_v.getSlot(2).canTakeStack(this.field_147094_x.player))
|
||||
{
|
||||
} else if (!this.field_147092_v.getSlot(2).canTakeStack(this.field_147094_x.player)) {
|
||||
k = 16736352;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
int l = -16777216 | (k & 16579836) >> 2 | k & -16777216;
|
||||
int i1 = this.xSize - 8 - this.fontRendererObj.getStringWidth(s);
|
||||
byte b0 = 67;
|
||||
|
||||
if (this.fontRendererObj.getUnicodeFlag())
|
||||
{
|
||||
if (this.fontRendererObj.getUnicodeFlag()) {
|
||||
drawRect(i1 - 3, b0 - 2, this.xSize - 7, b0 + 10, -16777216);
|
||||
drawRect(i1 - 2, b0 - 1, this.xSize - 8, b0 + 9, -12895429);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.fontRendererObj.drawString(s, i1, b0 + 1, l);
|
||||
this.fontRendererObj.drawString(s, i1 + 1, b0, l);
|
||||
this.fontRendererObj.drawString(s, i1 + 1, b0 + 1, l);
|
||||
@@ -124,37 +107,34 @@ public class GuiVoidAnvil extends GuiContainer implements ICrafting
|
||||
/**
|
||||
* Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
|
||||
*/
|
||||
protected void keyTyped(char p_73869_1_, int p_73869_2_)
|
||||
{
|
||||
if (this.field_147091_w.textboxKeyTyped(p_73869_1_, p_73869_2_))
|
||||
{
|
||||
protected void keyTyped(char p_73869_1_, int p_73869_2_) {
|
||||
if (this.field_147091_w.textboxKeyTyped(p_73869_1_, p_73869_2_)) {
|
||||
this.func_147090_g();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
super.keyTyped(p_73869_1_, p_73869_2_);
|
||||
}
|
||||
}
|
||||
|
||||
private void func_147090_g()
|
||||
{
|
||||
private void func_147090_g() {
|
||||
String s = this.field_147091_w.getText();
|
||||
Slot slot = this.field_147092_v.getSlot(0);
|
||||
|
||||
if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
|
||||
{
|
||||
if (slot != null
|
||||
&& slot.getHasStack()
|
||||
&& !slot.getStack().hasDisplayName()
|
||||
&& s.equals(slot.getStack().getDisplayName())) {
|
||||
s = "";
|
||||
}
|
||||
|
||||
this.field_147092_v.updateItemName(s);
|
||||
this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", s.getBytes(Charsets.UTF_8)));
|
||||
this.mc.thePlayer.sendQueue.addToSendQueue(
|
||||
new C17PacketCustomPayload("MC|ItemName", s.getBytes(Charsets.UTF_8)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse is clicked.
|
||||
*/
|
||||
protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_)
|
||||
{
|
||||
protected void mouseClicked(int p_73864_1_, int p_73864_2_, int p_73864_3_) {
|
||||
super.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_);
|
||||
this.field_147091_w.mouseClicked(p_73864_1_, p_73864_2_, p_73864_3_);
|
||||
}
|
||||
@@ -162,32 +142,31 @@ public class GuiVoidAnvil extends GuiContainer implements ICrafting
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
|
||||
{
|
||||
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) {
|
||||
super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
this.field_147091_w.drawTextBox();
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_)
|
||||
{
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(field_147093_u);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
this.drawTexturedModalRect(k + 59, l + 20, 0, this.ySize + (this.field_147092_v.getSlot(0).getHasStack() ? 0 : 16), 110, 16);
|
||||
this.drawTexturedModalRect(
|
||||
k + 59, l + 20, 0, this.ySize + (this.field_147092_v.getSlot(0).getHasStack() ? 0 : 16), 110, 16);
|
||||
|
||||
if ((this.field_147092_v.getSlot(0).getHasStack() || this.field_147092_v.getSlot(1).getHasStack()) && !this.field_147092_v.getSlot(2).getHasStack())
|
||||
{
|
||||
if ((this.field_147092_v.getSlot(0).getHasStack()
|
||||
|| this.field_147092_v.getSlot(1).getHasStack())
|
||||
&& !this.field_147092_v.getSlot(2).getHasStack()) {
|
||||
this.drawTexturedModalRect(k + 99, l + 45, this.xSize, 0, 28, 21);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void sendContainerAndContentsToPlayer(Container p_71110_1_, List p_71110_2_)
|
||||
{
|
||||
public void sendContainerAndContentsToPlayer(Container p_71110_1_, List p_71110_2_) {
|
||||
this.sendSlotContents(p_71110_1_, 0, p_71110_1_.getSlot(0).getStack());
|
||||
}
|
||||
|
||||
@@ -195,15 +174,12 @@ public class GuiVoidAnvil extends GuiContainer implements ICrafting
|
||||
* Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
|
||||
* contents of that slot. Args: Container, slot number, slot contents
|
||||
*/
|
||||
public void sendSlotContents(Container p_71111_1_, int p_71111_2_, ItemStack p_71111_3_)
|
||||
{
|
||||
if (p_71111_2_ == 0)
|
||||
{
|
||||
public void sendSlotContents(Container p_71111_1_, int p_71111_2_, ItemStack p_71111_3_) {
|
||||
if (p_71111_2_ == 0) {
|
||||
this.field_147091_w.setText(p_71111_3_ == null ? "" : p_71111_3_.getDisplayName());
|
||||
this.field_147091_w.setEnabled(p_71111_3_ != null);
|
||||
|
||||
if (p_71111_3_ != null)
|
||||
{
|
||||
if (p_71111_3_ != null) {
|
||||
this.func_147090_g();
|
||||
}
|
||||
}
|
||||
@@ -215,4 +191,4 @@ public class GuiVoidAnvil extends GuiContainer implements ICrafting
|
||||
* value. Both are truncated to shorts in non-local SMP.
|
||||
*/
|
||||
public void sendProgressBarUpdate(Container p_71112_1_, int p_71112_2_, int p_71112_3_) {}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,6 @@
|
||||
package tb.client.render.block;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tb.common.tile.TileBrazier;
|
||||
import thaumcraft.client.renderers.block.BlockRenderer;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.blocks.BlockCosmeticSolid;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -13,114 +8,110 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import tb.common.tile.TileBrazier;
|
||||
import thaumcraft.client.renderers.block.BlockRenderer;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
|
||||
public class BrazierRenderer extends BlockRenderer implements ISimpleBlockRenderingHandler{
|
||||
public class BrazierRenderer extends BlockRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId,RenderBlocks renderer)
|
||||
{
|
||||
IIcon icon = ConfigBlocks.blockCosmeticSolid.getIcon(0, 6);
|
||||
//base1
|
||||
block.setBlockBounds(W1, 0, W1, W15, W2, W15);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
//base2
|
||||
block.setBlockBounds(W2, W2, W2, W14, W4, W14);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
//pillar
|
||||
block.setBlockBounds(W4, W4, W4, W12, W12, W12);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
//bowl base
|
||||
block.setBlockBounds(W2, W12, W2, W14, W13, W14);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
//bowl 1
|
||||
block.setBlockBounds(W2, W13, W13, W14, 1, W14);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
//bowl 2
|
||||
block.setBlockBounds(W2, W13, W2, W14, 1, W3);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
//bowl 3
|
||||
block.setBlockBounds(W2, W13, W3, W3, 1, W13);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
//bowl 4
|
||||
block.setBlockBounds(W13, W13, W3, W14, 1, W13);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
|
||||
icon = Blocks.coal_block.getIcon(0, 0);
|
||||
//coal
|
||||
block.setBlockBounds(W3, W13, W3, W13, W14, W13);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
}
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
IIcon icon = ConfigBlocks.blockCosmeticSolid.getIcon(0, 6);
|
||||
// base1
|
||||
block.setBlockBounds(W1, 0, W1, W15, W2, W15);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
// base2
|
||||
block.setBlockBounds(W2, W2, W2, W14, W4, W14);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
// pillar
|
||||
block.setBlockBounds(W4, W4, W4, W12, W12, W12);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
// bowl base
|
||||
block.setBlockBounds(W2, W12, W2, W14, W13, W14);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
// bowl 1
|
||||
block.setBlockBounds(W2, W13, W13, W14, 1, W14);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
// bowl 2
|
||||
block.setBlockBounds(W2, W13, W2, W14, 1, W3);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
// bowl 3
|
||||
block.setBlockBounds(W2, W13, W3, W3, 1, W13);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
// bowl 4
|
||||
block.setBlockBounds(W13, W13, W3, W14, 1, W13);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z,Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
renderer.setOverrideBlockTexture(ConfigBlocks.blockCosmeticSolid.getIcon(0, 6));
|
||||
//base1
|
||||
renderer.setRenderBounds(W1, 0, W1, W15, W2, W15);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
//base2
|
||||
renderer.setRenderBounds(W2, W2, W2, W14, W4, W14);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
//pillar
|
||||
renderer.setRenderBounds(W4, W4, W4, W12, W12, W12);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
//bowl base
|
||||
renderer.setRenderBounds(W2, W12, W2, W14, W13, W14);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
//bowl 1 (s)
|
||||
renderer.setRenderBounds(W2, W13, W13, W14, 1, W14);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
//bowl 2 (n)
|
||||
renderer.setRenderBounds(W2, W13, W2, W14, 1, W3);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
//bowl 3 (w)
|
||||
renderer.setRenderBounds(W2, W13, W3, W3, 1, W13);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
//bowl 4 (e)
|
||||
renderer.setRenderBounds(W13, W13, W3, W14, 1, W13);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
//coal fill
|
||||
renderer.setOverrideBlockTexture(Blocks.coal_block.getIcon(0, 0));
|
||||
renderer.setRenderBounds(W3, W13, W3, W13, W14, W13);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof TileBrazier && ((TileBrazier)tile).burning)
|
||||
{
|
||||
renderer.setOverrideBlockTexture(Blocks.fire.getIcon(2, 0));
|
||||
Tessellator.instance.setBrightness(247);
|
||||
Tessellator.instance.setColorOpaque_I(0xffffff);
|
||||
renderer.drawCrossedSquares(Blocks.fire.getIcon(2, 0), x, y+W14, z, 0.5F);
|
||||
}
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
renderer.clearOverrideBlockTexture();
|
||||
return true;
|
||||
}
|
||||
icon = Blocks.coal_block.getIcon(0, 0);
|
||||
// coal
|
||||
block.setBlockBounds(W3, W13, W3, W13, W14, W13);
|
||||
renderer.setRenderBoundsFromBlock(block);
|
||||
drawFaces(renderer, block, icon, icon, icon, icon, icon, icon, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean renderWorldBlock(
|
||||
IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
renderer.renderAllFaces = true;
|
||||
|
||||
@Override
|
||||
public int getRenderId()
|
||||
{
|
||||
return 0x1242fd;
|
||||
}
|
||||
renderer.setOverrideBlockTexture(ConfigBlocks.blockCosmeticSolid.getIcon(0, 6));
|
||||
// base1
|
||||
renderer.setRenderBounds(W1, 0, W1, W15, W2, W15);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
// base2
|
||||
renderer.setRenderBounds(W2, W2, W2, W14, W4, W14);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
// pillar
|
||||
renderer.setRenderBounds(W4, W4, W4, W12, W12, W12);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
// bowl base
|
||||
renderer.setRenderBounds(W2, W12, W2, W14, W13, W14);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
// bowl 1 (s)
|
||||
renderer.setRenderBounds(W2, W13, W13, W14, 1, W14);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
// bowl 2 (n)
|
||||
renderer.setRenderBounds(W2, W13, W2, W14, 1, W3);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
// bowl 3 (w)
|
||||
renderer.setRenderBounds(W2, W13, W3, W3, 1, W13);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
// bowl 4 (e)
|
||||
renderer.setRenderBounds(W13, W13, W3, W14, 1, W13);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
// coal fill
|
||||
renderer.setOverrideBlockTexture(Blocks.coal_block.getIcon(0, 0));
|
||||
renderer.setRenderBounds(W3, W13, W3, W13, W14, W13);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile != null && tile instanceof TileBrazier && ((TileBrazier) tile).burning) {
|
||||
renderer.setOverrideBlockTexture(Blocks.fire.getIcon(2, 0));
|
||||
Tessellator.instance.setBrightness(247);
|
||||
Tessellator.instance.setColorOpaque_I(0xffffff);
|
||||
renderer.drawCrossedSquares(Blocks.fire.getIcon(2, 0), x, y + W14, z, 0.5F);
|
||||
}
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
renderer.clearOverrideBlockTexture();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return 0x1242fd;
|
||||
}
|
||||
}
|
||||
@@ -1,94 +1,86 @@
|
||||
package tb.client.render.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import thaumcraft.client.renderers.block.BlockRenderer;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import thaumcraft.client.renderers.block.BlockRenderer;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
|
||||
public class CampfireRenderer extends BlockRenderer implements ISimpleBlockRenderingHandler{
|
||||
public class CampfireRenderer extends BlockRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z,Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
renderer.renderAllFaces = true;
|
||||
/*
|
||||
* looks like shit
|
||||
renderer.setOverrideBlockTexture(Blocks.cobblestone.getIcon(0, 0));
|
||||
|
||||
Random rand = new Random(x+y+z);
|
||||
|
||||
for(int i = 0; i < 6+rand.nextInt(5); ++i)
|
||||
{
|
||||
double dx = rand.nextDouble();
|
||||
double dy = 0;
|
||||
double dz = rand.nextDouble();
|
||||
|
||||
renderer.setRenderBounds(dx, dy, dz, dx+0.1D, dy+0.1D, dz+0.1D);
|
||||
renderer.renderStandardBlock(Blocks.stone, x, y, z);
|
||||
}*/
|
||||
|
||||
//gravel base
|
||||
renderer.setOverrideBlockTexture(Blocks.gravel.getIcon(0, 0));
|
||||
renderer.setRenderBounds(W1, 0, W1, W15, W1, W15);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
//coal pit
|
||||
renderer.setOverrideBlockTexture(Blocks.coal_block.getIcon(0, 0));
|
||||
renderer.setRenderBounds(0.25D, 0, 0.25D, 0.75D, W2-0.001, 0.75D);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
//logs
|
||||
renderer.setOverrideBlockTexture(ConfigBlocks.blockMagicalLog.getIcon(2, 0));
|
||||
double yIndex = 0;
|
||||
if(world.getBlockMetadata(x, y, z) > 0)
|
||||
for(int i = 0; i < 2; ++i)
|
||||
{
|
||||
renderer.setRenderBounds(W3, 0+yIndex+(W2*i), W2, W5, W2+yIndex+(W2*i), W14); //layer 1,1
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(W11, 0+yIndex+(W2*i), W2, W13, W2+yIndex+(W2*i), W14);//layer 1,2
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(W2, W2+yIndex+(W2*i), W3, W14, W4+yIndex+(W2*i), W5);//layer 2,1
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(W2, W2+yIndex+(W2*i), W11, W14, W4+yIndex+(W2*i), W13);//layer 2,2
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
yIndex += W2;
|
||||
}
|
||||
|
||||
|
||||
if(world.getBlockMetadata(x, y, z) > 1)
|
||||
{
|
||||
renderer.setOverrideBlockTexture(Blocks.fire.getIcon(2, 0));
|
||||
Tessellator.instance.setBrightness(247);
|
||||
Tessellator.instance.setColorOpaque_I(0xffffff);
|
||||
renderer.drawCrossedSquares(Blocks.fire.getIcon(2, 0), x, y, z, 0.75F);
|
||||
}
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
renderer.clearOverrideBlockTexture();
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean renderWorldBlock(
|
||||
IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
renderer.renderAllFaces = true;
|
||||
/*
|
||||
* looks like shit
|
||||
renderer.setOverrideBlockTexture(Blocks.cobblestone.getIcon(0, 0));
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return false;
|
||||
}
|
||||
Random rand = new Random(x+y+z);
|
||||
|
||||
@Override
|
||||
public int getRenderId()
|
||||
{
|
||||
return 0x1242fe;
|
||||
}
|
||||
for(int i = 0; i < 6+rand.nextInt(5); ++i)
|
||||
{
|
||||
double dx = rand.nextDouble();
|
||||
double dy = 0;
|
||||
double dz = rand.nextDouble();
|
||||
|
||||
renderer.setRenderBounds(dx, dy, dz, dx+0.1D, dy+0.1D, dz+0.1D);
|
||||
renderer.renderStandardBlock(Blocks.stone, x, y, z);
|
||||
}*/
|
||||
|
||||
// gravel base
|
||||
renderer.setOverrideBlockTexture(Blocks.gravel.getIcon(0, 0));
|
||||
renderer.setRenderBounds(W1, 0, W1, W15, W1, W15);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
// coal pit
|
||||
renderer.setOverrideBlockTexture(Blocks.coal_block.getIcon(0, 0));
|
||||
renderer.setRenderBounds(0.25D, 0, 0.25D, 0.75D, W2 - 0.001, 0.75D);
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
// logs
|
||||
renderer.setOverrideBlockTexture(ConfigBlocks.blockMagicalLog.getIcon(2, 0));
|
||||
double yIndex = 0;
|
||||
if (world.getBlockMetadata(x, y, z) > 0)
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
renderer.setRenderBounds(W3, 0 + yIndex + (W2 * i), W2, W5, W2 + yIndex + (W2 * i), W14); // layer 1,1
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(W11, 0 + yIndex + (W2 * i), W2, W13, W2 + yIndex + (W2 * i), W14); // layer 1,2
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
renderer.setRenderBounds(W2, W2 + yIndex + (W2 * i), W3, W14, W4 + yIndex + (W2 * i), W5); // layer 2,1
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
renderer.setRenderBounds(
|
||||
W2, W2 + yIndex + (W2 * i), W11, W14, W4 + yIndex + (W2 * i), W13); // layer 2,2
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
yIndex += W2;
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x, y, z) > 1) {
|
||||
renderer.setOverrideBlockTexture(Blocks.fire.getIcon(2, 0));
|
||||
Tessellator.instance.setBrightness(247);
|
||||
Tessellator.instance.setColorOpaque_I(0xffffff);
|
||||
renderer.drawCrossedSquares(Blocks.fire.getIcon(2, 0), x, y, z, 0.75F);
|
||||
}
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
renderer.clearOverrideBlockTexture();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return 0x1242fe;
|
||||
}
|
||||
}
|
||||
@@ -1,155 +1,148 @@
|
||||
package tb.client.render.block;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tb.common.block.BlockRelocator;
|
||||
import tb.common.tile.TileRelocator;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tb.common.block.BlockRelocator;
|
||||
import tb.common.tile.TileRelocator;
|
||||
|
||||
public class ThaumicRelocatorRenderer implements ISimpleBlockRenderingHandler{
|
||||
public class ThaumicRelocatorRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
BlockRelocator rl = (BlockRelocator) block;
|
||||
|
||||
int color = metadata < 6 ? 0xffff77 : 0x0077ff;
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId,RenderBlocks renderer)
|
||||
{
|
||||
BlockRelocator rl = (BlockRelocator) block;
|
||||
|
||||
int color = metadata < 6 ? 0xffff77 : 0x0077ff;
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||
renderer.renderFaceYNeg(Blocks.glass, 0.0D, 0.0D, 0.0D, rl.icons[1]);
|
||||
tessellator.draw();
|
||||
|
||||
//Glow
|
||||
|
||||
// Glow
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
tessellator.setColorOpaque_I(color);
|
||||
tessellator.setBrightness(250);
|
||||
renderer.renderFaceYPos(Blocks.glass, 0.0D, 0.0D, 0.0D, rl.icons[3]);
|
||||
tessellator.draw();
|
||||
|
||||
//Top
|
||||
|
||||
// Top
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(Blocks.glass, 0.0D, 0.0D, 0.0D, rl.icons[0]);
|
||||
tessellator.draw();
|
||||
|
||||
//Glow
|
||||
|
||||
// Glow
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_I(color);
|
||||
tessellator.setBrightness(250);
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
renderer.renderFaceZNeg(Blocks.glass, 0.0D, 0.0D, 0.0D, rl.icons[3]);
|
||||
tessellator.draw();
|
||||
|
||||
//Side
|
||||
|
||||
// Side
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||
renderer.renderFaceZNeg(Blocks.glass, 0.0D, 0.0D, 0.0D, rl.icons[2]);
|
||||
tessellator.draw();
|
||||
|
||||
//Glow
|
||||
|
||||
// Glow
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_I(color);
|
||||
tessellator.setBrightness(250);
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(Blocks.glass, 0.0D, 0.0D, 0.0D, rl.icons[3]);
|
||||
tessellator.draw();
|
||||
|
||||
//Side
|
||||
|
||||
// Side
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(Blocks.glass, 0.0D, 0.0D, 0.0D, rl.icons[2]);
|
||||
tessellator.draw();
|
||||
|
||||
//Glow
|
||||
|
||||
// Glow
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_I(color);
|
||||
tessellator.setBrightness(250);
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(Blocks.glass, 0.0D, 0.0D, 0.0D, rl.icons[3]);
|
||||
tessellator.draw();
|
||||
|
||||
//Side
|
||||
|
||||
// Side
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(Blocks.glass, 0.0D, 0.0D, 0.0D, rl.icons[2]);
|
||||
tessellator.draw();
|
||||
|
||||
//Glow
|
||||
|
||||
// Glow
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_I(color);
|
||||
tessellator.setBrightness(250);
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(Blocks.glass, 0.0D, 0.0D, 0.0D, rl.icons[3]);
|
||||
tessellator.draw();
|
||||
|
||||
//Side
|
||||
|
||||
// Side
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(Blocks.glass, 0.0D, 0.0D, 0.0D, rl.icons[2]);
|
||||
tessellator.draw();
|
||||
|
||||
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z,Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
int color = meta < 6 ? 0xffff77 : 0x0077ff;
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
BlockRelocator rl = (BlockRelocator) block;
|
||||
|
||||
TileRelocator tile = (TileRelocator) world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile.isBlockPowered())
|
||||
color = 0x333333;
|
||||
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
Tessellator.instance.setColorOpaque_I(color);
|
||||
|
||||
renderer.renderFaceYNeg(Blocks.glass, x, y + 0.01D, z, rl.icons[3]);
|
||||
|
||||
renderer.renderFaceYPos(Blocks.glass, x, y - 0.01D, z, rl.icons[3]);
|
||||
|
||||
renderer.renderFaceXNeg(Blocks.glass, x + 0.01D, y, z, rl.icons[3]);
|
||||
|
||||
renderer.renderFaceXPos(Blocks.glass, x - 0.01D, y, z, rl.icons[3]);
|
||||
|
||||
renderer.renderFaceZNeg(Blocks.glass, x, y, z + 0.01D, rl.icons[3]);
|
||||
|
||||
renderer.renderFaceZPos(Blocks.glass, x, y, z - 0.01D, rl.icons[3]);
|
||||
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean renderWorldBlock(
|
||||
IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int color = meta < 6 ? 0xffff77 : 0x0077ff;
|
||||
|
||||
@Override
|
||||
public int getRenderId()
|
||||
{
|
||||
return 0x1242ff;
|
||||
}
|
||||
BlockRelocator rl = (BlockRelocator) block;
|
||||
|
||||
TileRelocator tile = (TileRelocator) world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile.isBlockPowered()) color = 0x333333;
|
||||
|
||||
renderer.renderStandardBlock(block, x, y, z);
|
||||
|
||||
Tessellator.instance.setColorOpaque_I(color);
|
||||
|
||||
renderer.renderFaceYNeg(Blocks.glass, x, y + 0.01D, z, rl.icons[3]);
|
||||
|
||||
renderer.renderFaceYPos(Blocks.glass, x, y - 0.01D, z, rl.icons[3]);
|
||||
|
||||
renderer.renderFaceXNeg(Blocks.glass, x + 0.01D, y, z, rl.icons[3]);
|
||||
|
||||
renderer.renderFaceXPos(Blocks.glass, x - 0.01D, y, z, rl.icons[3]);
|
||||
|
||||
renderer.renderFaceZNeg(Blocks.glass, x, y, z + 0.01D, rl.icons[3]);
|
||||
|
||||
renderer.renderFaceZPos(Blocks.glass, x, y, z - 0.01D, rl.icons[3]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return 0x1242ff;
|
||||
}
|
||||
}
|
||||
@@ -4,18 +4,19 @@ import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class RenderBullet extends Render{
|
||||
public class RenderBullet extends Render {
|
||||
|
||||
@Override
|
||||
public void doRender(Entity p_76986_1_, double p_76986_2_,
|
||||
double p_76986_4_, double p_76986_6_, float p_76986_8_,
|
||||
float p_76986_9_) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void doRender(
|
||||
Entity p_76986_1_,
|
||||
double p_76986_2_,
|
||||
double p_76986_4_,
|
||||
double p_76986_6_,
|
||||
float p_76986_8_,
|
||||
float p_76986_9_) {}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,6 @@ package tb.client.render.item;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tb.common.item.ItemCastingBracelet;
|
||||
import thaumcraft.client.lib.UtilsFX;
|
||||
import thaumcraft.client.renderers.block.BlockRenderer;
|
||||
import thaumcraft.client.renderers.models.gear.ModelWand;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
@@ -32,218 +23,204 @@ import net.minecraft.util.Timer;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tb.common.item.ItemCastingBracelet;
|
||||
import thaumcraft.client.lib.UtilsFX;
|
||||
import thaumcraft.client.renderers.block.BlockRenderer;
|
||||
import thaumcraft.client.renderers.models.gear.ModelWand;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
|
||||
public class CastingBraceletRenderer implements IItemRenderer{
|
||||
public class CastingBraceletRenderer implements IItemRenderer {
|
||||
|
||||
public static final IModelCustom bracelet = AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases","models/bracelet/bracelet.obj"));
|
||||
public static final RenderBlocks renderBlocks = new RenderBlocks();
|
||||
public static final ModelWand wand = new ModelWand();
|
||||
|
||||
public static ModelRenderer getWandFociModel()
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<ModelWand> wandModelClass = ModelWand.class;
|
||||
Field foci = wandModelClass.getDeclaredField("Focus");//<- If only that field had been declared as public... Oh well.
|
||||
boolean accessible = foci.isAccessible();
|
||||
if(!accessible)
|
||||
foci.setAccessible(true);
|
||||
|
||||
ModelRenderer model = ModelRenderer.class.cast(foci.get(wand));
|
||||
|
||||
if(!accessible)
|
||||
foci.setAccessible(false);
|
||||
|
||||
return model;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public static final IModelCustom bracelet =
|
||||
AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases", "models/bracelet/bracelet.obj"));
|
||||
public static final RenderBlocks renderBlocks = new RenderBlocks();
|
||||
public static final ModelWand wand = new ModelWand();
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,ItemRendererHelper helper)
|
||||
{
|
||||
if (helper == IItemRenderer.ItemRendererHelper.BLOCK_3D)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Timer getMCTimer()
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<Minecraft> mcClass = Minecraft.class;
|
||||
Field timerField = mcClass.getDeclaredFields()[16];
|
||||
if(!timerField.isAccessible())
|
||||
timerField.setAccessible(true);
|
||||
|
||||
return Timer.class.cast(timerField.get(Minecraft.getMinecraft()));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static ModelRenderer getWandFociModel() {
|
||||
try {
|
||||
Class<ModelWand> wandModelClass = ModelWand.class;
|
||||
Field foci = wandModelClass.getDeclaredField(
|
||||
"Focus"); // <- If only that field had been declared as public... Oh well.
|
||||
boolean accessible = foci.isAccessible();
|
||||
if (!accessible) foci.setAccessible(true);
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
||||
{
|
||||
EntityClientPlayerMP entityclientplayermp = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
ItemWandCasting wand = (ItemWandCasting)item.getItem();
|
||||
ItemStack focusStack = wand.getFocusItem(item);
|
||||
|
||||
//float renderPartialTicks = getMCTimer().renderPartialTicks;
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
{
|
||||
ModelRenderer model = ModelRenderer.class.cast(foci.get(wand));
|
||||
|
||||
if (!accessible) foci.setAccessible(false);
|
||||
|
||||
return model;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
if (helper == IItemRenderer.ItemRendererHelper.BLOCK_3D) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Timer getMCTimer() {
|
||||
try {
|
||||
Class<Minecraft> mcClass = Minecraft.class;
|
||||
Field timerField = mcClass.getDeclaredFields()[16];
|
||||
if (!timerField.isAccessible()) timerField.setAccessible(true);
|
||||
|
||||
return Timer.class.cast(timerField.get(Minecraft.getMinecraft()));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
EntityClientPlayerMP entityclientplayermp = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
ItemWandCasting wand = (ItemWandCasting) item.getItem();
|
||||
ItemStack focusStack = wand.getFocusItem(item);
|
||||
|
||||
// float renderPartialTicks = getMCTimer().renderPartialTicks;
|
||||
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
GL11.glPushMatrix();
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(entityclientplayermp.getLocationSkin());
|
||||
|
||||
|
||||
GL11.glTranslated(0.5D, 1, 1);
|
||||
|
||||
GL11.glRotated(90, 0, 0, 1);
|
||||
GL11.glRotated(220, 1, 0, 0);
|
||||
|
||||
if(entityclientplayermp.isUsingItem())
|
||||
{
|
||||
GL11.glTranslated(-0.5D, 0D, 0);
|
||||
GL11.glRotated(-45, 0, 0, 1);
|
||||
|
||||
|
||||
if (entityclientplayermp.isUsingItem()) {
|
||||
GL11.glTranslated(-0.5D, 0D, 0);
|
||||
GL11.glRotated(-45, 0, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
Render render = RenderManager.instance.getEntityRenderObject(Minecraft.getMinecraft().thePlayer);
|
||||
RenderPlayer renderplayer = (RenderPlayer)render;
|
||||
RenderPlayer renderplayer = (RenderPlayer) render;
|
||||
float f10 = 3.0F;
|
||||
GL11.glScalef(f10, f10, f10);
|
||||
renderplayer.renderFirstPersonArm(Minecraft.getMinecraft().thePlayer);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
|
||||
GL11.glRotated(-45, 0, 1, 0);
|
||||
GL11.glTranslated(1.2D, 0.1D, -1);
|
||||
GL11.glScaled(0.6D, 0.6D, 0.6D);
|
||||
if(entityclientplayermp.isUsingItem())
|
||||
{
|
||||
GL11.glTranslated(0D, 1D, 0);
|
||||
GL11.glRotated(35, 1, 0, 0);
|
||||
GL11.glTranslated(0D, 0D, -0.7D);
|
||||
GL11.glScaled(0.8D, 0.8D, 0.8D);
|
||||
if (entityclientplayermp.isUsingItem()) {
|
||||
GL11.glTranslated(0D, 1D, 0);
|
||||
GL11.glRotated(35, 1, 0, 0);
|
||||
GL11.glTranslated(0D, 0D, -0.7D);
|
||||
GL11.glScaled(0.8D, 0.8D, 0.8D);
|
||||
}
|
||||
}
|
||||
|
||||
if(type == ItemRenderType.INVENTORY)
|
||||
{
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
}
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED)
|
||||
{
|
||||
GL11.glScaled(0.25D, 0.25D, 0.25D);
|
||||
GL11.glRotated(-45, 0, 1, 0);
|
||||
GL11.glTranslated(2.85D, 2.9D, 1.3D);
|
||||
EntityLivingBase wielder = (EntityLivingBase) data[1];
|
||||
if(wielder.isInvisible())
|
||||
return;
|
||||
}
|
||||
|
||||
if(type == ItemRenderType.ENTITY)
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
|
||||
double ds = 0.2D;
|
||||
GL11.glScaled(ds, ds, ds);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ItemCastingBracelet.braceletTextures[Math.min(ItemCastingBracelet.braceletTextures.length-1, item.getItemDamage())]);
|
||||
GL11.glPushMatrix();
|
||||
if(wand.getRod(item) != null && wand.getRod(item).isGlowing())
|
||||
{
|
||||
int j = (int)(200.0F + MathHelper.sin(entityclientplayermp.ticksExisted) * 5.0F + 5.0F);
|
||||
int k = j % 65536;
|
||||
int l = j / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, k / 1.0F, l / 1.0F);
|
||||
}
|
||||
bracelet.renderAll();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(focusStack != null)
|
||||
{
|
||||
if (wand.getFocus(item).getOrnament(focusStack) != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(5, 5, 5);
|
||||
GL11.glTranslated(0, 0.7D, 0);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
IIcon icon = wand.getFocus(item).getOrnament(focusStack);
|
||||
float minU = icon.getMinU();
|
||||
float minV = icon.getMinV();
|
||||
float maxU = icon.getMaxU();
|
||||
float maxV = icon.getMaxV();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(-0.25F, -0.1F, 0.0275F);
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.1F);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-0.25F, -0.1F, 0.0275F);
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.1F);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
float alpha = 0.95F;
|
||||
if (wand.getFocus(item).getFocusDepthLayerIcon(focusStack) != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(5, 5, 5);
|
||||
GL11.glTranslated(0, 0.87D, 0);
|
||||
GL11.glTranslatef(0.0F, -0.15F, 0.0F);
|
||||
GL11.glScaled(0.165D, 0.1765D, 0.165D); //<- using the same numbers as Azanor, since the rendering should be identical to his.
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
||||
renderBlocks.setRenderBoundsFromBlock(Blocks.glass);
|
||||
BlockRenderer.drawFaces(renderBlocks, null, wand.getFocus(item).getFocusDepthLayerIcon(focusStack), false);
|
||||
alpha = 0.6F;
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
if (Thaumcraft.isHalloween)
|
||||
UtilsFX.bindTexture("textures/models/spec_h.png");
|
||||
else
|
||||
UtilsFX.bindTexture("textures/models/wand.png");
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glScaled(5, 5, 5);
|
||||
GL11.glTranslated(0, 0.87D, 0);
|
||||
GL11.glTranslatef(0.0F, -0.0475F, 0.0F);
|
||||
GL11.glScaled(0.525D, 0.5525D, 0.525D);
|
||||
Color c = new Color(wand.getFocus(item).getFocusColor(focusStack));
|
||||
GL11.glColor4f(c.getRed() / 255.0F, c.getGreen() / 255.0F, c.getBlue() / 255.0F, alpha);
|
||||
int j = (int)(195.0F + MathHelper.sin(entityclientplayermp.ticksExisted / 3.0F) * 10.0F + 10.0F);
|
||||
int k = j % 65536;
|
||||
int l = j / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, k / 1.0F, l / 1.0F);
|
||||
getWandFociModel().render(0.0625F);
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.EQUIPPED) {
|
||||
GL11.glScaled(0.25D, 0.25D, 0.25D);
|
||||
GL11.glRotated(-45, 0, 1, 0);
|
||||
GL11.glTranslated(2.85D, 2.9D, 1.3D);
|
||||
EntityLivingBase wielder = (EntityLivingBase) data[1];
|
||||
if (wielder.isInvisible()) return;
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.ENTITY) GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
|
||||
double ds = 0.2D;
|
||||
GL11.glScaled(ds, ds, ds);
|
||||
Minecraft.getMinecraft()
|
||||
.renderEngine
|
||||
.bindTexture(
|
||||
ItemCastingBracelet.braceletTextures[
|
||||
Math.min(ItemCastingBracelet.braceletTextures.length - 1, item.getItemDamage())]);
|
||||
GL11.glPushMatrix();
|
||||
if (wand.getRod(item) != null && wand.getRod(item).isGlowing()) {
|
||||
int j = (int) (200.0F + MathHelper.sin(entityclientplayermp.ticksExisted) * 5.0F + 5.0F);
|
||||
int k = j % 65536;
|
||||
int l = j / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, k / 1.0F, l / 1.0F);
|
||||
}
|
||||
bracelet.renderAll();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (focusStack != null) {
|
||||
if (wand.getFocus(item).getOrnament(focusStack) != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(5, 5, 5);
|
||||
GL11.glTranslated(0, 0.7D, 0);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
IIcon icon = wand.getFocus(item).getOrnament(focusStack);
|
||||
float minU = icon.getMinU();
|
||||
float minV = icon.getMinV();
|
||||
float maxU = icon.getMaxU();
|
||||
float maxV = icon.getMaxV();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(-0.25F, -0.1F, 0.0275F);
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
ItemRenderer.renderItemIn2D(
|
||||
tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.1F);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-0.25F, -0.1F, 0.0275F);
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
ItemRenderer.renderItemIn2D(
|
||||
tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.1F);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
float alpha = 0.95F;
|
||||
if (wand.getFocus(item).getFocusDepthLayerIcon(focusStack) != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(5, 5, 5);
|
||||
GL11.glTranslated(0, 0.87D, 0);
|
||||
GL11.glTranslatef(0.0F, -0.15F, 0.0F);
|
||||
GL11.glScaled(
|
||||
0.165D, 0.1765D,
|
||||
0.165D); // <- using the same numbers as Azanor, since the rendering should be identical to his.
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
||||
renderBlocks.setRenderBoundsFromBlock(Blocks.glass);
|
||||
BlockRenderer.drawFaces(
|
||||
renderBlocks, null, wand.getFocus(item).getFocusDepthLayerIcon(focusStack), false);
|
||||
alpha = 0.6F;
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
if (Thaumcraft.isHalloween) UtilsFX.bindTexture("textures/models/spec_h.png");
|
||||
else UtilsFX.bindTexture("textures/models/wand.png");
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glScaled(5, 5, 5);
|
||||
GL11.glTranslated(0, 0.87D, 0);
|
||||
GL11.glTranslatef(0.0F, -0.0475F, 0.0F);
|
||||
GL11.glScaled(0.525D, 0.5525D, 0.525D);
|
||||
Color c = new Color(wand.getFocus(item).getFocusColor(focusStack));
|
||||
GL11.glColor4f(c.getRed() / 255.0F, c.getGreen() / 255.0F, c.getBlue() / 255.0F, alpha);
|
||||
int j = (int) (195.0F + MathHelper.sin(entityclientplayermp.ticksExisted / 3.0F) * 10.0F + 10.0F);
|
||||
int k = j % 65536;
|
||||
int l = j / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, k / 1.0F, l / 1.0F);
|
||||
getWandFociModel().render(0.0625F);
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +1,106 @@
|
||||
package tb.client.render.item;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class HerobrinesScytheRenderer implements IItemRenderer{
|
||||
public class HerobrinesScytheRenderer implements IItemRenderer {
|
||||
|
||||
protected static RenderItem itemRender = new RenderItem();
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
protected static RenderItem itemRender = new RenderItem();
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
|
||||
ItemRendererHelper helper) {
|
||||
return type != ItemRenderType.EQUIPPED_FIRST_PERSON && type != ItemRenderType.ENTITY;
|
||||
}
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
if(item != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
{
|
||||
GL11.glScaled(3, 3, 3);
|
||||
GL11.glTranslated(0, -0.4D, 0.3D);
|
||||
GL11.glRotated(15, 0, 1, 0);
|
||||
GL11.glRotated(15, 0, 0, 1);
|
||||
IIcon icon = item.getIconIndex();
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMinU(), icon.getMinV(), icon.getMaxU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.03125F);
|
||||
}
|
||||
|
||||
if(type == ItemRenderType.INVENTORY)
|
||||
{
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glTranslatef(0.7F, -0.9F, 1);
|
||||
GL11.glScaled(2, 2, 2);
|
||||
GL11.glRotated(60, 0, 1, 1);
|
||||
IIcon icon = item.getIconIndex();
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMinU(), icon.getMinV(), icon.getMaxU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
}
|
||||
|
||||
if(type == ItemRenderType.ENTITY)
|
||||
{
|
||||
GL11.glScaled(4, 4, 4);
|
||||
GL11.glRotated(90, 1, 0, 0);
|
||||
GL11.glRotated(35, 0, 0, 1);
|
||||
GL11.glTranslated(-0.5D, -0.5D, 0.05D);
|
||||
IIcon icon = item.getIconIndex();
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMinU(), icon.getMinV(), icon.getMaxU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
|
||||
}
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED)
|
||||
{
|
||||
GL11.glScaled(6, 6, 6);
|
||||
GL11.glRotated(135, 0, 1, 0);
|
||||
GL11.glRotatef(-35, 0, 0, 1);
|
||||
GL11.glTranslated(-0.7D, -0.4D, 0.01D);
|
||||
IIcon icon = item.getIconIndex();
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMinU(), icon.getMinV(), icon.getMaxU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0225F);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return type != ItemRenderType.EQUIPPED_FIRST_PERSON && type != ItemRenderType.ENTITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
if (item != null) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
GL11.glScaled(3, 3, 3);
|
||||
GL11.glTranslated(0, -0.4D, 0.3D);
|
||||
GL11.glRotated(15, 0, 1, 0);
|
||||
GL11.glRotated(15, 0, 0, 1);
|
||||
IIcon icon = item.getIconIndex();
|
||||
ItemRenderer.renderItemIn2D(
|
||||
Tessellator.instance,
|
||||
icon.getMinU(),
|
||||
icon.getMinV(),
|
||||
icon.getMaxU(),
|
||||
icon.getMaxV(),
|
||||
icon.getIconWidth(),
|
||||
icon.getIconHeight(),
|
||||
0.03125F);
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glTranslatef(0.7F, -0.9F, 1);
|
||||
GL11.glScaled(2, 2, 2);
|
||||
GL11.glRotated(60, 0, 1, 1);
|
||||
IIcon icon = item.getIconIndex();
|
||||
ItemRenderer.renderItemIn2D(
|
||||
Tessellator.instance,
|
||||
icon.getMinU(),
|
||||
icon.getMinV(),
|
||||
icon.getMaxU(),
|
||||
icon.getMaxV(),
|
||||
icon.getIconWidth(),
|
||||
icon.getIconHeight(),
|
||||
0.0625F);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.ENTITY) {
|
||||
GL11.glScaled(4, 4, 4);
|
||||
GL11.glRotated(90, 1, 0, 0);
|
||||
GL11.glRotated(35, 0, 0, 1);
|
||||
GL11.glTranslated(-0.5D, -0.5D, 0.05D);
|
||||
IIcon icon = item.getIconIndex();
|
||||
ItemRenderer.renderItemIn2D(
|
||||
Tessellator.instance,
|
||||
icon.getMinU(),
|
||||
icon.getMinV(),
|
||||
icon.getMaxU(),
|
||||
icon.getMaxV(),
|
||||
icon.getIconWidth(),
|
||||
icon.getIconHeight(),
|
||||
0.0625F);
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.EQUIPPED) {
|
||||
GL11.glScaled(6, 6, 6);
|
||||
GL11.glRotated(135, 0, 1, 0);
|
||||
GL11.glRotatef(-35, 0, 0, 1);
|
||||
GL11.glTranslated(-0.7D, -0.4D, 0.01D);
|
||||
IIcon icon = item.getIconIndex();
|
||||
ItemRenderer.renderItemIn2D(
|
||||
Tessellator.instance,
|
||||
icon.getMinU(),
|
||||
icon.getMinV(),
|
||||
icon.getMaxU(),
|
||||
icon.getMaxV(),
|
||||
icon.getIconWidth(),
|
||||
icon.getIconHeight(),
|
||||
0.0225F);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,43 @@
|
||||
package tb.client.render.item;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tb.common.item.ItemNodeFoci;
|
||||
import DummyCore.Utils.MiscUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tb.common.item.ItemNodeFoci;
|
||||
|
||||
public class NodeFociRenderer implements IItemRenderer{
|
||||
public class NodeFociRenderer implements IItemRenderer {
|
||||
|
||||
public static final IModelCustom model = AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases","models/nodeManipulator/foci.obj"));
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
public static final IModelCustom model =
|
||||
AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases", "models/nodeManipulator/foci.obj"));
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScalef(0.25F, 0.25F, 0.25F);
|
||||
|
||||
if(type == ItemRenderType.INVENTORY)
|
||||
GL11.glTranslated(0, -1, 0);
|
||||
|
||||
MiscUtils.bindTexture("thaumicbases", "textures/blocks/nodeManipulator/foci_"+ItemNodeFoci.names[item.getItemDamage()]+".png");
|
||||
model.renderAll();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScalef(0.25F, 0.25F, 0.25F);
|
||||
|
||||
if (type == ItemRenderType.INVENTORY) GL11.glTranslated(0, -1, 0);
|
||||
|
||||
MiscUtils.bindTexture(
|
||||
"thaumicbases",
|
||||
"textures/blocks/nodeManipulator/foci_" + ItemNodeFoci.names[item.getItemDamage()] + ".png");
|
||||
model.renderAll();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -1,41 +1,40 @@
|
||||
package tb.client.render.item;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class NodeLinkerItemRenderer implements IItemRenderer{
|
||||
|
||||
public static final IModelCustom model = AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases","models/nodeLinker/nodeLinker.obj"));
|
||||
public static final ResourceLocation genIcon = new ResourceLocation("thaumicbases","textures/blocks/nodeLinker/nodeLinkerUV.png");
|
||||
public class NodeLinkerItemRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
public static final IModelCustom model =
|
||||
AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases", "models/nodeLinker/nodeLinker.obj"));
|
||||
public static final ResourceLocation genIcon =
|
||||
new ResourceLocation("thaumicbases", "textures/blocks/nodeLinker/nodeLinkerUV.png");
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
|
||||
ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
GL11.glTranslated(0, -0.3D, 0);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(genIcon);
|
||||
model.renderAll();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
GL11.glTranslated(0, -0.3D, 0);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(genIcon);
|
||||
model.renderAll();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,45 @@
|
||||
package tb.client.render.item;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class NodeManipulatorItemRenderer implements IItemRenderer{
|
||||
|
||||
public static final IModelCustom model = AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases","models/nodeManipulator/nodeManipulator.obj"));
|
||||
public static final ResourceLocation genIcon = new ResourceLocation("thaumicbases","textures/blocks/nodeManipulator/baseUVMap.png");
|
||||
public class NodeManipulatorItemRenderer implements IItemRenderer {
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
public static final IModelCustom model = AdvancedModelLoader.loadModel(
|
||||
new ResourceLocation("thaumicbases", "models/nodeManipulator/nodeManipulator.obj"));
|
||||
public static final ResourceLocation genIcon =
|
||||
new ResourceLocation("thaumicbases", "textures/blocks/nodeManipulator/baseUVMap.png");
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
|
||||
ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glRotated(180, 1, 0, 0);
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
GL11.glTranslated(0, -0.5D, 0);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(genIcon);
|
||||
model.renderPart("base_Cube.001");
|
||||
model.renderPart("handle_0_Cube.002");
|
||||
model.renderPart("handle_1_Cube.002");
|
||||
model.renderPart("handle_2_Cube.002");
|
||||
model.renderPart("handle_3_Cube.002");
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glRotated(180, 1, 0, 0);
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
GL11.glTranslated(0, -0.5D, 0);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(genIcon);
|
||||
model.renderPart("base_Cube.001");
|
||||
model.renderPart("handle_0_Cube.002");
|
||||
model.renderPart("handle_1_Cube.002");
|
||||
model.renderPart("handle_2_Cube.002");
|
||||
model.renderPart("handle_3_Cube.002");
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,7 @@
|
||||
package tb.client.render.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tb.api.RevolverUpgrade;
|
||||
import tb.common.item.ItemRevolver;
|
||||
import DummyCore.Utils.Pair;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -14,148 +9,155 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tb.api.RevolverUpgrade;
|
||||
import tb.common.item.ItemRevolver;
|
||||
|
||||
public class RenderRevolver implements IItemRenderer
|
||||
{
|
||||
public class RenderRevolver implements IItemRenderer {
|
||||
|
||||
public static final IModelCustom model = AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases","models/revolver/revolver.obj"));
|
||||
public static final ResourceLocation handle = new ResourceLocation("thaumicbases","textures/items/revolver/revolverHandleUV.png");
|
||||
public static final ResourceLocation barrel = new ResourceLocation("thaumicbases","textures/items/revolver/revolverBarrelUV.png");
|
||||
public static final ResourceLocation metal = new ResourceLocation("thaumicbases","textures/items/revolver/revolverDarkMetal.png");
|
||||
public static final ResourceLocation gun = new ResourceLocation("thaumicbases","textures/items/revolver/revolverGunUV.png");
|
||||
public static final ResourceLocation press = new ResourceLocation("thaumicbases","textures/items/revolver/revolverPressUV.png");
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
public static final IModelCustom model =
|
||||
AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases", "models/revolver/revolver.obj"));
|
||||
public static final ResourceLocation handle =
|
||||
new ResourceLocation("thaumicbases", "textures/items/revolver/revolverHandleUV.png");
|
||||
public static final ResourceLocation barrel =
|
||||
new ResourceLocation("thaumicbases", "textures/items/revolver/revolverBarrelUV.png");
|
||||
public static final ResourceLocation metal =
|
||||
new ResourceLocation("thaumicbases", "textures/items/revolver/revolverDarkMetal.png");
|
||||
public static final ResourceLocation gun =
|
||||
new ResourceLocation("thaumicbases", "textures/items/revolver/revolverGunUV.png");
|
||||
public static final ResourceLocation press =
|
||||
new ResourceLocation("thaumicbases", "textures/items/revolver/revolverPressUV.png");
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
{
|
||||
if(Minecraft.getMinecraft().thePlayer.isSneaking())
|
||||
{
|
||||
GL11.glScaled(0.4D, 0.4D, 0.4D);
|
||||
GL11.glRotated(-45, 0, 1, 0);
|
||||
GL11.glTranslated(-1.73D, 0D, 4D);
|
||||
}else
|
||||
{
|
||||
GL11.glScaled(0.4D, 0.4D, 0.4D);
|
||||
GL11.glRotated(-45, 0, 1, 0);
|
||||
GL11.glTranslated(4, -1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(type == ItemRenderType.INVENTORY)
|
||||
{
|
||||
GL11.glScaled(0.2D, 0.2D, 0.2D);
|
||||
GL11.glTranslated(-5, -5, 0);
|
||||
}
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED)
|
||||
{
|
||||
Entity e = (Entity) data[1];
|
||||
if(e.isSneaking())
|
||||
{
|
||||
GL11.glScaled(0.2D, 0.2D, 0.2D);
|
||||
GL11.glRotated(45, 0, 1, 0);
|
||||
GL11.glRotated(25, 1, 0, 0);
|
||||
GL11.glTranslated(0, 4, 6);
|
||||
}else
|
||||
{
|
||||
GL11.glScaled(0.2D, 0.2D, 0.2D);
|
||||
GL11.glRotated(45, 0, 1, 0);
|
||||
GL11.glTranslated(0, 2, 6);
|
||||
}
|
||||
}
|
||||
|
||||
if(type == ItemRenderType.ENTITY)
|
||||
{
|
||||
GL11.glScaled(0.2D, 0.2D, 0.2D);
|
||||
GL11.glTranslated(0, 0, 5);
|
||||
}
|
||||
|
||||
ResourceLocation handle = RenderRevolver.handle;
|
||||
ResourceLocation barrel = RenderRevolver.barrel;
|
||||
ResourceLocation metal = RenderRevolver.metal;
|
||||
ResourceLocation gun = RenderRevolver.gun;
|
||||
ResourceLocation press = RenderRevolver.press;
|
||||
|
||||
ArrayList<Pair<RevolverUpgrade,Integer>> upgrades = ItemRevolver.getAllUpgradesFor(item);
|
||||
for(Pair<RevolverUpgrade,Integer> p : upgrades)
|
||||
{
|
||||
RevolverUpgrade ru = p.getFirst();
|
||||
handle = ru.getOverridePartTexture(item, 0, p.getSecond()) == null ? handle : ru.getOverridePartTexture(item, 0, p.getSecond());
|
||||
barrel = ru.getOverridePartTexture(item, 1, p.getSecond()) == null ? barrel : ru.getOverridePartTexture(item, 1, p.getSecond());
|
||||
metal = ru.getOverridePartTexture(item, 2, p.getSecond()) == null ? metal : ru.getOverridePartTexture(item, 2, p.getSecond());
|
||||
gun = ru.getOverridePartTexture(item, 3, p.getSecond()) == null ? gun : ru.getOverridePartTexture(item, 3, p.getSecond());
|
||||
press = ru.getOverridePartTexture(item, 4, p.getSecond()) == null ? press : ru.getOverridePartTexture(item, 4, p.getSecond());
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(handle);
|
||||
model.renderPart("Cylinder");
|
||||
model.renderPart("Plane");
|
||||
|
||||
double rotation = item.hasTagCompound() ? item.getTagCompound().getDouble("renderedRotation") : 0;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0, 2.9D, 0);
|
||||
GL11.glTranslated(0, -Math.cos(Math.toRadians(rotation))*2.8D, 0);
|
||||
GL11.glTranslated(Math.sin(Math.toRadians(rotation))*2.8D, 0, 0);
|
||||
GL11.glRotated(rotation, 0, 0, 1);
|
||||
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(barrel);
|
||||
model.renderPart("rBarrel_Cube.001");
|
||||
GL11.glPopMatrix();
|
||||
//GL11.glRotated(-rotation, 0, 0, 1);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(metal);
|
||||
model.renderPart("Cube.003_Cube.004");
|
||||
model.renderPart("Cube.002_Cube.003");
|
||||
model.renderPart("Cube_Cube.001");
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(gun);
|
||||
model.renderPart("Cylinder.002");
|
||||
model.renderPart("Plane.001");
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(press);
|
||||
model.renderPart("Cube.001_Cube.005");
|
||||
|
||||
if(type == ItemRenderType.EQUIPPED_FIRST_PERSON && item.getTagCompound() != null && item.getTagCompound().getBoolean("hasJar"))
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScaled(1.1, 1.1, 1.1);
|
||||
GL11.glTranslated(-0.11D, -0.25D, 1);
|
||||
|
||||
double tickIndex = (double)Minecraft.getMinecraft().thePlayer.ticksExisted % 40 / 20;
|
||||
if(tickIndex > 1)
|
||||
tickIndex = -tickIndex+2;
|
||||
|
||||
GL11.glColor4d(1, 0, 0, tickIndex);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(metal);
|
||||
model.renderPart("Cube_Cube.001");
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
|
||||
if (Minecraft.getMinecraft().thePlayer.isSneaking()) {
|
||||
GL11.glScaled(0.4D, 0.4D, 0.4D);
|
||||
GL11.glRotated(-45, 0, 1, 0);
|
||||
GL11.glTranslated(-1.73D, 0D, 4D);
|
||||
} else {
|
||||
GL11.glScaled(0.4D, 0.4D, 0.4D);
|
||||
GL11.glRotated(-45, 0, 1, 0);
|
||||
GL11.glTranslated(4, -1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
GL11.glScaled(0.2D, 0.2D, 0.2D);
|
||||
GL11.glTranslated(-5, -5, 0);
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.EQUIPPED) {
|
||||
Entity e = (Entity) data[1];
|
||||
if (e.isSneaking()) {
|
||||
GL11.glScaled(0.2D, 0.2D, 0.2D);
|
||||
GL11.glRotated(45, 0, 1, 0);
|
||||
GL11.glRotated(25, 1, 0, 0);
|
||||
GL11.glTranslated(0, 4, 6);
|
||||
} else {
|
||||
GL11.glScaled(0.2D, 0.2D, 0.2D);
|
||||
GL11.glRotated(45, 0, 1, 0);
|
||||
GL11.glTranslated(0, 2, 6);
|
||||
}
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.ENTITY) {
|
||||
GL11.glScaled(0.2D, 0.2D, 0.2D);
|
||||
GL11.glTranslated(0, 0, 5);
|
||||
}
|
||||
|
||||
ResourceLocation handle = RenderRevolver.handle;
|
||||
ResourceLocation barrel = RenderRevolver.barrel;
|
||||
ResourceLocation metal = RenderRevolver.metal;
|
||||
ResourceLocation gun = RenderRevolver.gun;
|
||||
ResourceLocation press = RenderRevolver.press;
|
||||
|
||||
ArrayList<Pair<RevolverUpgrade, Integer>> upgrades = ItemRevolver.getAllUpgradesFor(item);
|
||||
for (Pair<RevolverUpgrade, Integer> p : upgrades) {
|
||||
RevolverUpgrade ru = p.getFirst();
|
||||
handle = ru.getOverridePartTexture(item, 0, p.getSecond()) == null
|
||||
? handle
|
||||
: ru.getOverridePartTexture(item, 0, p.getSecond());
|
||||
barrel = ru.getOverridePartTexture(item, 1, p.getSecond()) == null
|
||||
? barrel
|
||||
: ru.getOverridePartTexture(item, 1, p.getSecond());
|
||||
metal = ru.getOverridePartTexture(item, 2, p.getSecond()) == null
|
||||
? metal
|
||||
: ru.getOverridePartTexture(item, 2, p.getSecond());
|
||||
gun = ru.getOverridePartTexture(item, 3, p.getSecond()) == null
|
||||
? gun
|
||||
: ru.getOverridePartTexture(item, 3, p.getSecond());
|
||||
press = ru.getOverridePartTexture(item, 4, p.getSecond()) == null
|
||||
? press
|
||||
: ru.getOverridePartTexture(item, 4, p.getSecond());
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(handle);
|
||||
model.renderPart("Cylinder");
|
||||
model.renderPart("Plane");
|
||||
|
||||
double rotation = item.hasTagCompound() ? item.getTagCompound().getDouble("renderedRotation") : 0;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(0, 2.9D, 0);
|
||||
GL11.glTranslated(0, -Math.cos(Math.toRadians(rotation)) * 2.8D, 0);
|
||||
GL11.glTranslated(Math.sin(Math.toRadians(rotation)) * 2.8D, 0, 0);
|
||||
GL11.glRotated(rotation, 0, 0, 1);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(barrel);
|
||||
model.renderPart("rBarrel_Cube.001");
|
||||
GL11.glPopMatrix();
|
||||
// GL11.glRotated(-rotation, 0, 0, 1);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(metal);
|
||||
model.renderPart("Cube.003_Cube.004");
|
||||
model.renderPart("Cube.002_Cube.003");
|
||||
model.renderPart("Cube_Cube.001");
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(gun);
|
||||
model.renderPart("Cylinder.002");
|
||||
model.renderPart("Plane.001");
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(press);
|
||||
model.renderPart("Cube.001_Cube.005");
|
||||
|
||||
if (type == ItemRenderType.EQUIPPED_FIRST_PERSON
|
||||
&& item.getTagCompound() != null
|
||||
&& item.getTagCompound().getBoolean("hasJar")) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glScaled(1.1, 1.1, 1.1);
|
||||
GL11.glTranslated(-0.11D, -0.25D, 1);
|
||||
|
||||
double tickIndex = (double) Minecraft.getMinecraft().thePlayer.ticksExisted % 40 / 20;
|
||||
if (tickIndex > 1) tickIndex = -tickIndex + 2;
|
||||
|
||||
GL11.glColor4d(1, 0, 0, tickIndex);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(metal);
|
||||
model.renderPart("Cube_Cube.001");
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package tb.client.render.tile;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tb.common.tile.TileEntityDeconstructor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
@@ -10,41 +7,51 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tb.common.tile.TileEntityDeconstructor;
|
||||
|
||||
public class RenderEntityDeconstructor extends TileEntitySpecialRenderer{
|
||||
public class RenderEntityDeconstructor extends TileEntitySpecialRenderer {
|
||||
|
||||
public static final IModelCustom model = AdvancedModelLoader.loadModel(
|
||||
new ResourceLocation("thaumicbases", "models/entityDeconstructor/deconstructor.obj"));
|
||||
public static final ResourceLocation frameIcon =
|
||||
new ResourceLocation("thaumicbases", "textures/blocks/entityDeconstructor/goldbase.png");
|
||||
public static final ResourceLocation glassIcon =
|
||||
new ResourceLocation("thaumicbases", "textures/blocks/entityDeconstructor/glass.png");
|
||||
|
||||
public static final ResourceLocation air = new ResourceLocation("thaumicbases", "textures/blocks/crystal/air.png");
|
||||
public static final ResourceLocation fire =
|
||||
new ResourceLocation("thaumicbases", "textures/blocks/crystal/fire.png");
|
||||
public static final ResourceLocation water =
|
||||
new ResourceLocation("thaumicbases", "textures/blocks/crystal/water.png");
|
||||
public static final ResourceLocation earth =
|
||||
new ResourceLocation("thaumicbases", "textures/blocks/crystal/earth.png");
|
||||
public static final ResourceLocation ordo =
|
||||
new ResourceLocation("thaumicbases", "textures/blocks/crystal/order.png");
|
||||
public static final ResourceLocation entropy =
|
||||
new ResourceLocation("thaumicbases", "textures/blocks/crystal/entropy.png");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(
|
||||
TileEntity tile, double screenX, double screenY, double screenZ, float partialTicks) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
TileEntityDeconstructor d = (TileEntityDeconstructor) tile;
|
||||
|
||||
GL11.glTranslated(screenX + 0.5D, screenY, screenZ + 0.5D);
|
||||
GL11.glScalef(0.3F, 0.4F, 0.3F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(frameIcon);
|
||||
model.renderPart("Cube_Cube.001");
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(glassIcon);
|
||||
model.renderPart("Plane");
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
public static final IModelCustom model = AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases","models/entityDeconstructor/deconstructor.obj"));
|
||||
public static final ResourceLocation frameIcon = new ResourceLocation("thaumicbases","textures/blocks/entityDeconstructor/goldbase.png");
|
||||
public static final ResourceLocation glassIcon = new ResourceLocation("thaumicbases","textures/blocks/entityDeconstructor/glass.png");
|
||||
|
||||
public static final ResourceLocation air = new ResourceLocation("thaumicbases","textures/blocks/crystal/air.png");
|
||||
public static final ResourceLocation fire = new ResourceLocation("thaumicbases","textures/blocks/crystal/fire.png");
|
||||
public static final ResourceLocation water = new ResourceLocation("thaumicbases","textures/blocks/crystal/water.png");
|
||||
public static final ResourceLocation earth = new ResourceLocation("thaumicbases","textures/blocks/crystal/earth.png");
|
||||
public static final ResourceLocation ordo = new ResourceLocation("thaumicbases","textures/blocks/crystal/order.png");
|
||||
public static final ResourceLocation entropy = new ResourceLocation("thaumicbases","textures/blocks/crystal/entropy.png");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double screenX, double screenY, double screenZ, float partialTicks)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
TileEntityDeconstructor d = (TileEntityDeconstructor) tile;
|
||||
|
||||
GL11.glTranslated(screenX+0.5D, screenY, screenZ+0.5D);
|
||||
GL11.glScalef(0.3F, 0.4F, 0.3F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(frameIcon);
|
||||
model.renderPart("Cube_Cube.001");
|
||||
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(glassIcon);
|
||||
model.renderPart("Plane");
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -52,49 +59,42 @@ public class RenderEntityDeconstructor extends TileEntitySpecialRenderer{
|
||||
char c0 = 61680;
|
||||
int j = c0 % 65536;
|
||||
int k = c0 / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
if(d.hasAir)
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(air);
|
||||
model.renderPart("Sphere");
|
||||
}
|
||||
|
||||
if(d.hasFire)
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(fire);
|
||||
model.renderPart("Sphere.001");
|
||||
}
|
||||
|
||||
if(d.hasWater)
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(water);
|
||||
model.renderPart("Sphere.002");
|
||||
}
|
||||
|
||||
if(d.hasEarth)
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(earth);
|
||||
model.renderPart("Sphere.003");
|
||||
}
|
||||
|
||||
if(d.hasOrdo)
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ordo);
|
||||
model.renderPart("Sphere.004");
|
||||
}
|
||||
|
||||
if(d.hasEntropy)
|
||||
{
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(entropy);
|
||||
model.renderPart("Sphere.005");
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
if (d.hasAir) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(air);
|
||||
model.renderPart("Sphere");
|
||||
}
|
||||
|
||||
if (d.hasFire) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(fire);
|
||||
model.renderPart("Sphere.001");
|
||||
}
|
||||
|
||||
if (d.hasWater) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(water);
|
||||
model.renderPart("Sphere.002");
|
||||
}
|
||||
|
||||
if (d.hasEarth) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(earth);
|
||||
model.renderPart("Sphere.003");
|
||||
}
|
||||
|
||||
if (d.hasOrdo) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ordo);
|
||||
model.renderPart("Sphere.004");
|
||||
}
|
||||
|
||||
if (d.hasEntropy) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(entropy);
|
||||
model.renderPart("Sphere.005");
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,30 @@
|
||||
package tb.client.render.tile;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderNodeLinker extends TileEntitySpecialRenderer{
|
||||
public class RenderNodeLinker extends TileEntitySpecialRenderer {
|
||||
|
||||
public static final IModelCustom model = AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases","models/nodeLinker/nodeLinker.obj"));
|
||||
public static final ResourceLocation genIcon = new ResourceLocation("thaumicbases","textures/blocks/nodeLinker/nodeLinkerUV.png");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double screenX, double screenY, double screenZ, float partialTicks)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(screenX+0.5D, screenY, screenZ+0.5D);
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(genIcon);
|
||||
model.renderAll();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
public static final IModelCustom model =
|
||||
AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases", "models/nodeLinker/nodeLinker.obj"));
|
||||
public static final ResourceLocation genIcon =
|
||||
new ResourceLocation("thaumicbases", "textures/blocks/nodeLinker/nodeLinkerUV.png");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(
|
||||
TileEntity tile, double screenX, double screenY, double screenZ, float partialTicks) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(screenX + 0.5D, screenY, screenZ + 0.5D);
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(genIcon);
|
||||
model.renderAll();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package tb.client.render.tile;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import tb.common.item.ItemNodeFoci;
|
||||
import DummyCore.Utils.MiscUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
@@ -10,35 +7,38 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tb.common.item.ItemNodeFoci;
|
||||
|
||||
public class RenderNodeManipulator extends TileEntitySpecialRenderer{
|
||||
public class RenderNodeManipulator extends TileEntitySpecialRenderer {
|
||||
|
||||
public static final IModelCustom model = AdvancedModelLoader.loadModel(new ResourceLocation("thaumicbases","models/nodeManipulator/nodeManipulator.obj"));
|
||||
public static final ResourceLocation genIcon = new ResourceLocation("thaumicbases","textures/blocks/nodeManipulator/baseUVMap.png");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double screenX, double screenY, double screenZ, float partialTicks)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(screenX+0.5D, screenY+1, screenZ+0.5D);
|
||||
GL11.glRotated(180, 1, 0, 0);
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(genIcon);
|
||||
model.renderPart("base_Cube.001");
|
||||
model.renderPart("handle_0_Cube.002");
|
||||
model.renderPart("handle_1_Cube.002");
|
||||
model.renderPart("handle_2_Cube.002");
|
||||
model.renderPart("handle_3_Cube.002");
|
||||
|
||||
int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
if(meta != 0)
|
||||
{
|
||||
MiscUtils.bindTexture("thaumicbases", "textures/blocks/nodeManipulator/foci_"+ItemNodeFoci.names[meta-1]+".png");
|
||||
model.renderPart("foci_Cube.003");
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
public static final IModelCustom model = AdvancedModelLoader.loadModel(
|
||||
new ResourceLocation("thaumicbases", "models/nodeManipulator/nodeManipulator.obj"));
|
||||
public static final ResourceLocation genIcon =
|
||||
new ResourceLocation("thaumicbases", "textures/blocks/nodeManipulator/baseUVMap.png");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(
|
||||
TileEntity tile, double screenX, double screenY, double screenZ, float partialTicks) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(screenX + 0.5D, screenY + 1, screenZ + 0.5D);
|
||||
GL11.glRotated(180, 1, 0, 0);
|
||||
GL11.glScaled(0.5D, 0.5D, 0.5D);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(genIcon);
|
||||
model.renderPart("base_Cube.001");
|
||||
model.renderPart("handle_0_Cube.002");
|
||||
model.renderPart("handle_1_Cube.002");
|
||||
model.renderPart("handle_2_Cube.002");
|
||||
model.renderPart("handle_3_Cube.002");
|
||||
|
||||
int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
if (meta != 0) {
|
||||
MiscUtils.bindTexture(
|
||||
"thaumicbases", "textures/blocks/nodeManipulator/foci_" + ItemNodeFoci.names[meta - 1] + ".png");
|
||||
model.renderPart("foci_Cube.003");
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,6 @@
|
||||
package tb.client.render.tile;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import DummyCore.Utils.MiscUtils;
|
||||
import tb.common.tile.TileOverchanter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@@ -14,24 +9,26 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import tb.common.tile.TileOverchanter;
|
||||
|
||||
public class RenderOverchanter extends TileEntitySpecialRenderer{
|
||||
public class RenderOverchanter extends TileEntitySpecialRenderer {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double screenX, double screenY, double screenZ, float partialTicks)
|
||||
{
|
||||
TileOverchanter overchanter = (TileOverchanter) tile;
|
||||
|
||||
/*if(overchanter.inventory != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
MiscUtils.renderItemStack_Full(overchanter.inventory, 0, 0, 0, screenX, screenY, screenZ, tile.getWorldObj().getWorldTime()%360, 0, 1, 1, 1, 0.5F, 0.9F, 0.5F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}*/
|
||||
|
||||
GL11.glPushMatrix();
|
||||
@Override
|
||||
public void renderTileEntityAt(
|
||||
TileEntity tile, double screenX, double screenY, double screenZ, float partialTicks) {
|
||||
TileOverchanter overchanter = (TileOverchanter) tile;
|
||||
|
||||
/*if(overchanter.inventory != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
MiscUtils.renderItemStack_Full(overchanter.inventory, 0, 0, 0, screenX, screenY, screenZ, tile.getWorldObj().getWorldTime()%360, 0, 1, 1, 1, 0.5F, 0.9F, 0.5F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}*/
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(screenX, screenY + 0.75, screenZ);
|
||||
|
||||
ItemStack item = overchanter.inventory;
|
||||
@@ -55,24 +52,24 @@ public class RenderOverchanter extends TileEntitySpecialRenderer{
|
||||
float f1 = icon.getMaxU();
|
||||
float f2 = icon.getMinV();
|
||||
float f3 = icon.getMaxV();
|
||||
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
ItemRenderer.renderItemIn2D(
|
||||
Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
||||
GL11.glColor3f(1F, 1F, 1F);
|
||||
}
|
||||
renderPass++;
|
||||
} while (renderPass < item.getItem().getRenderPasses(item.getItemDamage()));
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
/*if(overchanter.renderedLightning != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
overchanter.renderedLightning.render(screenX+0.5D, screenY+1D, screenZ+0.5D, partialTicks);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
/*if(overchanter.renderedLightning != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
overchanter.renderedLightning.render(screenX+0.5D, screenY+1D, screenZ+0.5D, partialTicks);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import DummyCore.Utils.MiscUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -17,209 +18,176 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import tb.common.tile.TileAdvAlchemicalFurnace;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.tiles.TileAlchemyFurnace;
|
||||
|
||||
public class BlockAdvAlchemicalFurnace extends BlockContainer{
|
||||
public class BlockAdvAlchemicalFurnace extends BlockContainer {
|
||||
|
||||
public IIcon[] icons = new IIcon[6];
|
||||
|
||||
public BlockAdvAlchemicalFurnace()
|
||||
{
|
||||
super(Material.rock);
|
||||
this.setHardness(2);
|
||||
this.setResistance(3);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister ir)
|
||||
{
|
||||
icons[0] = ir.registerIcon("thaumicbases:tFurnace/side");
|
||||
icons[1] = ir.registerIcon("thaumicbases:tFurnace/top");
|
||||
icons[2] = ir.registerIcon("thaumicbases:tFurnace/top_filled");
|
||||
icons[3] = ir.registerIcon("thaumicbases:tFurnace/front_off");
|
||||
icons[4] = ir.registerIcon("thaumicbases:tFurnace/front_on");
|
||||
icons[5] = ir.registerIcon("thaumicbases:tFurnace/bottom");
|
||||
}
|
||||
public IIcon[] icons = new IIcon[6];
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileAdvAlchemicalFurnace();
|
||||
}
|
||||
|
||||
public IIcon getIcon(int side, int md)
|
||||
{
|
||||
return side == 0 || side == 1 ? icons[1] : side == 3 ? icons[3] : icons[0];
|
||||
}
|
||||
|
||||
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int side)
|
||||
{
|
||||
TileAdvAlchemicalFurnace tile = (TileAdvAlchemicalFurnace) w.getTileEntity(x, y, z);
|
||||
if(side == w.getBlockMetadata(x, y, z))
|
||||
{
|
||||
if(tile.isBurning())
|
||||
{
|
||||
return icons[4];
|
||||
}else
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
}
|
||||
|
||||
if(side == 0) {
|
||||
return icons[5];
|
||||
}
|
||||
|
||||
if(side == 1)
|
||||
{
|
||||
if(tile.vis > 0)
|
||||
{
|
||||
return icons[2];
|
||||
}else
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
}
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
public int getLightValue(IBlockAccess w, int x, int y, int z)
|
||||
{
|
||||
TileAdvAlchemicalFurnace tile = (TileAdvAlchemicalFurnace) w.getTileEntity(x, y, z);
|
||||
return tile.isBurning() ? 12 : 0;
|
||||
}
|
||||
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getComparatorInputOverride(World w, int x, int y, int z, int rs)
|
||||
{
|
||||
return Container.calcRedstoneFromInventory((IInventory)w.getTileEntity(x, y, z));
|
||||
}
|
||||
|
||||
public void breakBlock(World w, int x, int y, int z, Block b, int meta)
|
||||
{
|
||||
MiscUtils.dropItemsOnBlockBreak(w, x, y, z, b, meta);
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block changed)
|
||||
{
|
||||
((TileAdvAlchemicalFurnace) w.getTileEntity(x, y, z)).getBellows();
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9)
|
||||
{
|
||||
if (w.isRemote) return true;
|
||||
TileEntity tileEntity = w.getTileEntity(x, y, z);
|
||||
|
||||
if(!player.isSneaking() && tileEntity instanceof TileAdvAlchemicalFurnace)
|
||||
{
|
||||
player.openGui(Thaumcraft.instance, 9, w, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBlockAdded(World w, int x, int y, int z)
|
||||
{
|
||||
public BlockAdvAlchemicalFurnace() {
|
||||
super(Material.rock);
|
||||
this.setHardness(2);
|
||||
this.setResistance(3);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister ir) {
|
||||
icons[0] = ir.registerIcon("thaumicbases:tFurnace/side");
|
||||
icons[1] = ir.registerIcon("thaumicbases:tFurnace/top");
|
||||
icons[2] = ir.registerIcon("thaumicbases:tFurnace/top_filled");
|
||||
icons[3] = ir.registerIcon("thaumicbases:tFurnace/front_off");
|
||||
icons[4] = ir.registerIcon("thaumicbases:tFurnace/front_on");
|
||||
icons[5] = ir.registerIcon("thaumicbases:tFurnace/bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileAdvAlchemicalFurnace();
|
||||
}
|
||||
|
||||
public IIcon getIcon(int side, int md) {
|
||||
return side == 0 || side == 1 ? icons[1] : side == 3 ? icons[3] : icons[0];
|
||||
}
|
||||
|
||||
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int side) {
|
||||
TileAdvAlchemicalFurnace tile = (TileAdvAlchemicalFurnace) w.getTileEntity(x, y, z);
|
||||
if (side == w.getBlockMetadata(x, y, z)) {
|
||||
if (tile.isBurning()) {
|
||||
return icons[4];
|
||||
} else {
|
||||
return icons[3];
|
||||
}
|
||||
}
|
||||
|
||||
if (side == 0) {
|
||||
return icons[5];
|
||||
}
|
||||
|
||||
if (side == 1) {
|
||||
if (tile.vis > 0) {
|
||||
return icons[2];
|
||||
} else {
|
||||
return icons[1];
|
||||
}
|
||||
}
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
public int getLightValue(IBlockAccess w, int x, int y, int z) {
|
||||
TileAdvAlchemicalFurnace tile = (TileAdvAlchemicalFurnace) w.getTileEntity(x, y, z);
|
||||
return tile.isBurning() ? 12 : 0;
|
||||
}
|
||||
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getComparatorInputOverride(World w, int x, int y, int z, int rs) {
|
||||
return Container.calcRedstoneFromInventory((IInventory) w.getTileEntity(x, y, z));
|
||||
}
|
||||
|
||||
public void breakBlock(World w, int x, int y, int z, Block b, int meta) {
|
||||
MiscUtils.dropItemsOnBlockBreak(w, x, y, z, b, meta);
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block changed) {
|
||||
((TileAdvAlchemicalFurnace) w.getTileEntity(x, y, z)).getBellows();
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(
|
||||
World w, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) {
|
||||
if (w.isRemote) return true;
|
||||
TileEntity tileEntity = w.getTileEntity(x, y, z);
|
||||
|
||||
if (!player.isSneaking() && tileEntity instanceof TileAdvAlchemicalFurnace) {
|
||||
player.openGui(Thaumcraft.instance, 9, w, x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBlockAdded(World w, int x, int y, int z) {
|
||||
super.onBlockAdded(w, x, y, z);
|
||||
this.determineOrientation(w, x, y, z);
|
||||
}
|
||||
|
||||
private void determineOrientation(World w, int x, int y, int z)
|
||||
{
|
||||
if (!w.isRemote)
|
||||
{
|
||||
|
||||
private void determineOrientation(World w, int x, int y, int z) {
|
||||
if (!w.isRemote) {
|
||||
Block block = w.getBlock(x, y, z - 1);
|
||||
Block block1 = w.getBlock(x, y, z + 1);
|
||||
Block block2 = w.getBlock(x - 1, y, z);
|
||||
Block block3 = w.getBlock(x + 1, y, z);
|
||||
byte b0 = 3;
|
||||
|
||||
if (block.func_149730_j() && !block1.func_149730_j())
|
||||
{
|
||||
if (block.func_149730_j() && !block1.func_149730_j()) {
|
||||
b0 = 3;
|
||||
}
|
||||
|
||||
if (block1.func_149730_j() && !block.func_149730_j())
|
||||
{
|
||||
if (block1.func_149730_j() && !block.func_149730_j()) {
|
||||
b0 = 2;
|
||||
}
|
||||
|
||||
if (block2.func_149730_j() && !block3.func_149730_j())
|
||||
{
|
||||
if (block2.func_149730_j() && !block3.func_149730_j()) {
|
||||
b0 = 5;
|
||||
}
|
||||
|
||||
if (block3.func_149730_j() && !block2.func_149730_j())
|
||||
{
|
||||
if (block3.func_149730_j() && !block2.func_149730_j()) {
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
w.setBlockMetadataWithNotify(x, y, z, b0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy(World w, int x, int y, int z, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
|
||||
{
|
||||
int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
if (l == 0)
|
||||
{
|
||||
public void onBlockPlacedBy(World w, int x, int y, int z, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) {
|
||||
int l = MathHelper.floor_double((double) (p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
|
||||
if (l == 0) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
}
|
||||
|
||||
if (l == 1)
|
||||
{
|
||||
if (l == 1) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||
}
|
||||
|
||||
if (l == 2)
|
||||
{
|
||||
if (l == 2) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
}
|
||||
|
||||
if (l == 3)
|
||||
{
|
||||
if (l == 3) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(final World w, final int x, final int y, final int z, final Random r) {
|
||||
final TileEntity te = w.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof TileAlchemyFurnace && ((TileAlchemyFurnace)te).isBurning()) {
|
||||
if (te != null && te instanceof TileAlchemyFurnace && ((TileAlchemyFurnace) te).isBurning()) {
|
||||
final float f = x + 0.5f;
|
||||
final float f2 = y + 0.2f + r.nextFloat() * 5.0f / 16.0f;
|
||||
final float f3 = z + 0.5f;
|
||||
final float f4 = 0.52f;
|
||||
final float f5 = r.nextFloat() * 0.5f - 0.25f;
|
||||
|
||||
if (w.getBlockMetadata(x, y, z) == 4) {
|
||||
w.spawnParticle("smoke", (double)(f - f4), (double)f2, (double)(f3 + f5), 0.0, 0.0, 0.0);
|
||||
w.spawnParticle("flame", (double)(f - f4), (double)f2, (double)(f3 + f5), 0.0, 0.0, 0.0);
|
||||
|
||||
if (w.getBlockMetadata(x, y, z) == 4) {
|
||||
w.spawnParticle("smoke", (double) (f - f4), (double) f2, (double) (f3 + f5), 0.0, 0.0, 0.0);
|
||||
w.spawnParticle("flame", (double) (f - f4), (double) f2, (double) (f3 + f5), 0.0, 0.0, 0.0);
|
||||
}
|
||||
if (w.getBlockMetadata(x, y, z) == 5) {
|
||||
w.spawnParticle("smoke", (double)(f + f4), (double)f2, (double)(f3 + f5), 0.0, 0.0, 0.0);
|
||||
w.spawnParticle("flame", (double)(f + f4), (double)f2, (double)(f3 + f5), 0.0, 0.0, 0.0);
|
||||
w.spawnParticle("smoke", (double) (f + f4), (double) f2, (double) (f3 + f5), 0.0, 0.0, 0.0);
|
||||
w.spawnParticle("flame", (double) (f + f4), (double) f2, (double) (f3 + f5), 0.0, 0.0, 0.0);
|
||||
}
|
||||
if (w.getBlockMetadata(x, y, z) == 2) {
|
||||
w.spawnParticle("smoke", (double)(f + f5), (double)f2, (double)(f3 - f4), 0.0, 0.0, 0.0);
|
||||
w.spawnParticle("flame", (double)(f + f5), (double)f2, (double)(f3 - f4), 0.0, 0.0, 0.0);
|
||||
w.spawnParticle("smoke", (double) (f + f5), (double) f2, (double) (f3 - f4), 0.0, 0.0, 0.0);
|
||||
w.spawnParticle("flame", (double) (f + f5), (double) f2, (double) (f3 - f4), 0.0, 0.0, 0.0);
|
||||
}
|
||||
if (w.getBlockMetadata(x, y, z) == 3) {
|
||||
w.spawnParticle("smoke", (double)(f + f5), (double)f2, (double)(f3 + f4), 0.0, 0.0, 0.0);
|
||||
w.spawnParticle("flame", (double)(f + f5), (double)f2, (double)(f3 + f4), 0.0, 0.0, 0.0);
|
||||
w.spawnParticle("smoke", (double) (f + f5), (double) f2, (double) (f3 + f4), 0.0, 0.0, 0.0);
|
||||
w.spawnParticle("flame", (double) (f + f5), (double) f2, (double) (f3 + f4), 0.0, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,56 +2,53 @@ package tb.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.entities.EntityAspectOrb;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.entities.EntityAspectOrb;
|
||||
|
||||
public class BlockAshroom extends BlockTBPlant {
|
||||
|
||||
public BlockAshroom(int stages, int delay, boolean isCrop) {
|
||||
super(stages, delay, isCrop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_149853_b(World w, Random r,int x, int y, int z)
|
||||
{
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
w.setBlockMetadataWithNotify(x, y, z, Math.min(growthStages,meta+1), 3);
|
||||
}
|
||||
|
||||
protected boolean func_150109_e(World p_150109_1_, int p_150109_2_, int p_150109_3_, int p_150109_4_)
|
||||
{
|
||||
if (!this.canPlaceBlockAt(p_150109_1_, p_150109_2_, p_150109_3_, p_150109_4_))
|
||||
{
|
||||
if (p_150109_1_.getBlock(p_150109_2_, p_150109_3_, p_150109_4_) == this)
|
||||
{
|
||||
this.dropBlockAsItem(p_150109_1_, p_150109_2_, p_150109_3_, p_150109_4_, p_150109_1_.getBlockMetadata(p_150109_2_, p_150109_3_, p_150109_4_), 0);
|
||||
public BlockAshroom(int stages, int delay, boolean isCrop) {
|
||||
super(stages, delay, isCrop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_149853_b(World w, Random r, int x, int y, int z) {
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
w.setBlockMetadataWithNotify(x, y, z, Math.min(growthStages, meta + 1), 3);
|
||||
}
|
||||
|
||||
protected boolean func_150109_e(World p_150109_1_, int p_150109_2_, int p_150109_3_, int p_150109_4_) {
|
||||
if (!this.canPlaceBlockAt(p_150109_1_, p_150109_2_, p_150109_3_, p_150109_4_)) {
|
||||
if (p_150109_1_.getBlock(p_150109_2_, p_150109_3_, p_150109_4_) == this) {
|
||||
this.dropBlockAsItem(
|
||||
p_150109_1_,
|
||||
p_150109_2_,
|
||||
p_150109_3_,
|
||||
p_150109_4_,
|
||||
p_150109_1_.getBlockMetadata(p_150109_2_, p_150109_3_, p_150109_4_),
|
||||
0);
|
||||
p_150109_1_.setBlockToAir(p_150109_2_, p_150109_3_, p_150109_4_);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
||||
{
|
||||
if(metadata >= this.growthStages - 1)
|
||||
{
|
||||
for(int i = 0; i < 8 + world.rand.nextInt(32); ++i) //Nerf for the shrooms
|
||||
{
|
||||
Aspect primal = Aspect.getPrimalAspects().get(world.rand.nextInt(Aspect.getPrimalAspects().size()));
|
||||
EntityAspectOrb orb = new EntityAspectOrb(world, x, y, z, primal, 1);
|
||||
if(!world.isRemote)
|
||||
world.spawnEntityInWorld(orb);
|
||||
}
|
||||
}
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
if (metadata >= this.growthStages - 1) {
|
||||
for (int i = 0; i < 8 + world.rand.nextInt(32); ++i) // Nerf for the shrooms
|
||||
{
|
||||
Aspect primal = Aspect.getPrimalAspects()
|
||||
.get(world.rand.nextInt(Aspect.getPrimalAspects().size()));
|
||||
EntityAspectOrb orb = new EntityAspectOrb(world, x, y, z, primal, 1);
|
||||
if (!world.isRemote) world.spawnEntityInWorld(orb);
|
||||
}
|
||||
}
|
||||
return super.getDrops(world, x, y, z, metadata, fortune);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +1,43 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import tb.init.TBItems;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import tb.init.TBItems;
|
||||
|
||||
public class BlockAureliaLeaf extends Block{
|
||||
public class BlockAureliaLeaf extends Block {
|
||||
|
||||
public BlockAureliaLeaf()
|
||||
{
|
||||
super(Material.plants);
|
||||
this.setBlockBounds(0.25F, 0, 0.25F, 0.75F, 0.25F, 0.75F);
|
||||
this.setLightLevel(0.3F);
|
||||
}
|
||||
|
||||
public int damageDropped(int meta)
|
||||
{
|
||||
return 5;
|
||||
public BlockAureliaLeaf() {
|
||||
super(Material.plants);
|
||||
this.setBlockBounds(0.25F, 0, 0.25F, 0.75F, 0.25F, 0.75F);
|
||||
this.setLightLevel(0.3F);
|
||||
}
|
||||
|
||||
public Item getItemDropped(int meta, Random rnd, int fort)
|
||||
{
|
||||
return TBItems.resource;
|
||||
|
||||
public int damageDropped(int meta) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
|
||||
{
|
||||
|
||||
public Item getItemDropped(int meta, Random rnd, int fort) {
|
||||
return TBItems.resource;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(
|
||||
World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
public int getRenderType() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import tb.init.TBBlocks;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDirt;
|
||||
import net.minecraft.block.BlockGrass;
|
||||
@@ -15,140 +13,121 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tb.init.TBBlocks;
|
||||
|
||||
public class BlockAureliaPlant extends Block{
|
||||
public class BlockAureliaPlant extends Block {
|
||||
|
||||
public BlockAureliaPlant() {
|
||||
super(Material.plants);
|
||||
this.setTickRandomly(true);
|
||||
this.setBlockBounds(0.25F, 0, 0.25F, 0.75F, 0.85F, 0.75F);
|
||||
this.setLightLevel(0.5F);
|
||||
}
|
||||
|
||||
public static IIcon[] icons = new IIcon[2];
|
||||
|
||||
public BlockAureliaPlant()
|
||||
{
|
||||
super(Material.plants);
|
||||
this.setTickRandomly(true);
|
||||
this.setBlockBounds(0.25F, 0, 0.25F, 0.75F, 0.85F, 0.75F);
|
||||
this.setLightLevel(0.5F);
|
||||
}
|
||||
|
||||
public static IIcon[] icons = new IIcon[2];
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
icons[0] = reg.registerIcon(textureName+"closed");
|
||||
icons[1] = reg.registerIcon(textureName+"open");
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
icons[0] = reg.registerIcon(textureName + "closed");
|
||||
icons[1] = reg.registerIcon(textureName + "open");
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
protected boolean canPlaceBlockOn(Block b)
|
||||
{
|
||||
return b != null && (b == Blocks.grass || b == Blocks.dirt || b instanceof BlockGrass || b instanceof BlockDirt);
|
||||
|
||||
protected boolean canPlaceBlockOn(Block b) {
|
||||
return b != null
|
||||
&& (b == Blocks.grass || b == Blocks.dirt || b instanceof BlockGrass || b instanceof BlockDirt);
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
checkForMoonlight(w,x,y,z);
|
||||
if(w.getBlockMetadata(x, y, z) == 1)
|
||||
{
|
||||
int rndX = x + rnd.nextInt(5) - rnd.nextInt(5);
|
||||
int rndZ = z + rnd.nextInt(5) - rnd.nextInt(5);
|
||||
//int rndY = findSutableGround(w,rndX,y+2,rndZ)+1;
|
||||
//if(rndY > 2)
|
||||
//w.setBlock(rndX, rndY, rndZ, TBBlocks.aureliaPetal,0,3);
|
||||
|
||||
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[2+w.rand.nextInt(4)];
|
||||
//int newX = x+dir.offsetX;
|
||||
//int newZ = z+dir.offsetZ;
|
||||
int newY = findSutableY(w,rndX,y,rndZ);
|
||||
if(canPlaceBlockOn(w.getBlock(rndX, newY-1, rndZ)) && w.isAirBlock(rndX, newY, rndZ)) //fix for the Sweeds destroying blocks. Totally not copy-pasted code...
|
||||
w.setBlock(rndX, newY, rndZ, TBBlocks.aureliaPetal, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public int findSutableGround(World w, int x, int y, int z)
|
||||
{
|
||||
while(w.isAirBlock(x, y, z) && y > 0 && !w.isSideSolid(x, y, z, ForgeDirection.UP))
|
||||
--y;
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
public int findSutableY(World w, int x, int y, int z)
|
||||
{
|
||||
int bY = y;
|
||||
y += 1;
|
||||
while(!canPlaceBlockOn(w.getBlock(x, y, z)) && y > bY - 2)
|
||||
--y;
|
||||
|
||||
return y+1;
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd) {
|
||||
checkForMoonlight(w, x, y, z);
|
||||
if (w.getBlockMetadata(x, y, z) == 1) {
|
||||
int rndX = x + rnd.nextInt(5) - rnd.nextInt(5);
|
||||
int rndZ = z + rnd.nextInt(5) - rnd.nextInt(5);
|
||||
// int rndY = findSutableGround(w,rndX,y+2,rndZ)+1;
|
||||
// if(rndY > 2)
|
||||
// w.setBlock(rndX, rndY, rndZ, TBBlocks.aureliaPetal,0,3);
|
||||
|
||||
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[2 + w.rand.nextInt(4)];
|
||||
// int newX = x+dir.offsetX;
|
||||
// int newZ = z+dir.offsetZ;
|
||||
int newY = findSutableY(w, rndX, y, rndZ);
|
||||
if (canPlaceBlockOn(w.getBlock(rndX, newY - 1, rndZ))
|
||||
&& w.isAirBlock(
|
||||
rndX, newY, rndZ)) // fix for the Sweeds destroying blocks. Totally not copy-pasted code...
|
||||
w.setBlock(rndX, newY, rndZ, TBBlocks.aureliaPetal, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public int tickRate(World w)
|
||||
{
|
||||
return 10;
|
||||
|
||||
public int findSutableGround(World w, int x, int y, int z) {
|
||||
while (w.isAirBlock(x, y, z) && y > 0 && !w.isSideSolid(x, y, z, ForgeDirection.UP)) --y;
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block updated)
|
||||
{
|
||||
if(!canGrowOn(w,x,y-1,z))
|
||||
w.setBlockToAir(x, y, z);
|
||||
else
|
||||
checkForMoonlight(w,x,y,z);
|
||||
|
||||
}
|
||||
|
||||
public int damageDropped(int meta)
|
||||
{
|
||||
return 0;
|
||||
|
||||
public int findSutableY(World w, int x, int y, int z) {
|
||||
int bY = y;
|
||||
y += 1;
|
||||
while (!canPlaceBlockOn(w.getBlock(x, y, z)) && y > bY - 2) --y;
|
||||
|
||||
return y + 1;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
|
||||
{
|
||||
|
||||
public int tickRate(World w) {
|
||||
return 10;
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block updated) {
|
||||
if (!canGrowOn(w, x, y - 1, z)) w.setBlockToAir(x, y, z);
|
||||
else checkForMoonlight(w, x, y, z);
|
||||
}
|
||||
|
||||
public int damageDropped(int meta) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(
|
||||
World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
public int getRenderType() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void checkForMoonlight(World w, int x, int y, int z)
|
||||
{
|
||||
boolean underSky = w.canBlockSeeTheSky(x, y+1, z);
|
||||
boolean night = !w.isDaytime();
|
||||
boolean isFullMoon = w.provider.getMoonPhase(w.getWorldTime()) == 0;
|
||||
boolean isOpen = w.getBlockMetadata(x, y, z) == 1;
|
||||
|
||||
if(underSky && night && isFullMoon)
|
||||
{
|
||||
if(!isOpen)
|
||||
{
|
||||
w.setBlockMetadataWithNotify(x, y, z, 1, 3);
|
||||
w.markBlockRangeForRenderUpdate(x-1, y-1, z-1, x+1, y+1, z+1);
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(isOpen)
|
||||
{
|
||||
w.setBlockMetadataWithNotify(x, y, z, 0, 3);
|
||||
w.markBlockRangeForRenderUpdate(x-1, y-1, z-1, x+1, y+1, z+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canGrowOn(World w, int x, int y, int z)
|
||||
{
|
||||
return !w.isAirBlock(x, y, z) && (w.getBlock(x, y, z).isReplaceableOreGen(w, x, y, z, Blocks.grass) || w.getBlock(x, y, z).isReplaceableOreGen(w, x, y, z, Blocks.dirt));
|
||||
}
|
||||
public void checkForMoonlight(World w, int x, int y, int z) {
|
||||
boolean underSky = w.canBlockSeeTheSky(x, y + 1, z);
|
||||
boolean night = !w.isDaytime();
|
||||
boolean isFullMoon = w.provider.getMoonPhase(w.getWorldTime()) == 0;
|
||||
boolean isOpen = w.getBlockMetadata(x, y, z) == 1;
|
||||
|
||||
if (underSky && night && isFullMoon) {
|
||||
if (!isOpen) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, 1, 3);
|
||||
w.markBlockRangeForRenderUpdate(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
|
||||
}
|
||||
} else {
|
||||
if (isOpen) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, 0, 3);
|
||||
w.markBlockRangeForRenderUpdate(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canGrowOn(World w, int x, int y, int z) {
|
||||
return !w.isAirBlock(x, y, z)
|
||||
&& (w.getBlock(x, y, z).isReplaceableOreGen(w, x, y, z, Blocks.grass)
|
||||
|| w.getBlock(x, y, z).isReplaceableOreGen(w, x, y, z, Blocks.dirt));
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package tb.common.block;
|
||||
|
||||
import DummyCore.Utils.MathUtils;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tb.common.tile.TileBrazier;
|
||||
import DummyCore.Utils.MathUtils;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -12,56 +10,70 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tb.common.tile.TileBrazier;
|
||||
|
||||
public class BlockBrazier extends BlockContainer
|
||||
{
|
||||
public class BlockBrazier extends BlockContainer {
|
||||
|
||||
public BlockBrazier()
|
||||
{
|
||||
super(Material.rock);
|
||||
setHardness(1F);
|
||||
setResistance(1F);
|
||||
}
|
||||
public BlockBrazier() {
|
||||
super(Material.rock);
|
||||
setHardness(1F);
|
||||
setResistance(1F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta)
|
||||
{
|
||||
return new TileBrazier();
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileBrazier();
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
return 0x1242fd;
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
TileEntity tile = w.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof TileBrazier && ((TileBrazier)tile).burning)
|
||||
{
|
||||
w.spawnParticle("flame", x+0.5D+MathUtils.randomDouble(r)/4, y+0.875D, z+0.5D+MathUtils.randomDouble(r)/4, 0, 0.04D, 0);
|
||||
for(int i = 0; i < 10; ++i)
|
||||
w.spawnParticle("smoke", x+0.5D+MathUtils.randomDouble(r)/4, y+1D, z+0.5D+MathUtils.randomDouble(r)/4, 0, r.nextDouble()/20, 0);
|
||||
|
||||
w.playSound(x+0.5D, y+0.5D, z+0.5D, "thaumicbases:fire.loop", 0.1F, 0.1F, false);
|
||||
}
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addCollisionBoxesToList(final World world, final int i, final int j, final int k, final AxisAlignedBB axisalignedbb, final List arraylist, final Entity par7Entity) {
|
||||
|
||||
public int getRenderType() {
|
||||
return 0x1242fd;
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r) {
|
||||
TileEntity tile = w.getTileEntity(x, y, z);
|
||||
if (tile != null && tile instanceof TileBrazier && ((TileBrazier) tile).burning) {
|
||||
w.spawnParticle(
|
||||
"flame",
|
||||
x + 0.5D + MathUtils.randomDouble(r) / 4,
|
||||
y + 0.875D,
|
||||
z + 0.5D + MathUtils.randomDouble(r) / 4,
|
||||
0,
|
||||
0.04D,
|
||||
0);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
w.spawnParticle(
|
||||
"smoke",
|
||||
x + 0.5D + MathUtils.randomDouble(r) / 4,
|
||||
y + 1D,
|
||||
z + 0.5D + MathUtils.randomDouble(r) / 4,
|
||||
0,
|
||||
r.nextDouble() / 20,
|
||||
0);
|
||||
|
||||
w.playSound(x + 0.5D, y + 0.5D, z + 0.5D, "thaumicbases:fire.loop", 0.1F, 0.1F, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void addCollisionBoxesToList(
|
||||
final World world,
|
||||
final int i,
|
||||
final int j,
|
||||
final int k,
|
||||
final AxisAlignedBB axisalignedbb,
|
||||
final List arraylist,
|
||||
final Entity par7Entity) {
|
||||
this.setBlockBounds(0.0625f, 0.0f, 0.0625f, 0.9375f, 1f, 0.9375f);
|
||||
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
|
||||
}
|
||||
|
||||
|
||||
public void setBlockBoundsBasedOnState(final IBlockAccess world, final int i, final int j, final int k) {
|
||||
|
||||
this.setBlockBounds(0.0625f, 0.0f, 0.0625f, 0.9375f, 1f, 0.9375f);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import tb.init.TBItems;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.BlockBush;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -17,183 +15,152 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tb.init.TBItems;
|
||||
|
||||
public class BlockBriar extends BlockBush implements IGrowable{
|
||||
public class BlockBriar extends BlockBush implements IGrowable {
|
||||
private IIcon[] doublePlantBottomIcons;
|
||||
private IIcon[] doublePlantTopIcons;
|
||||
public int growthStages;
|
||||
public int growthDelay;
|
||||
|
||||
public BlockBriar(int stages, int g)
|
||||
{
|
||||
|
||||
public BlockBriar(int stages, int g) {
|
||||
super(Material.plants);
|
||||
this.setHardness(0.0F);
|
||||
this.setStepSound(soundTypeGrass);
|
||||
growthStages = stages;
|
||||
growthDelay = g;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
|
||||
public int getRenderType() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
super.updateTick(w, x, y, z, rnd);
|
||||
|
||||
if(w.getBlock(x, y, z)==this)
|
||||
{
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if(isTopBlock(meta))
|
||||
{
|
||||
if(meta-8 < growthStages-1 && w.rand.nextInt(growthDelay) == 0)
|
||||
{
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta+1, 3);
|
||||
w.setBlockMetadataWithNotify(x, y-1, z, meta-7, 3);
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(meta < growthStages-1 && w.rand.nextInt(growthDelay) == 0)
|
||||
{
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta+1, 3);
|
||||
w.setBlockMetadataWithNotify(x, y+1, z, meta+9, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd) {
|
||||
super.updateTick(w, x, y, z, rnd);
|
||||
|
||||
if (w.getBlock(x, y, z) == this) {
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if (isTopBlock(meta)) {
|
||||
if (meta - 8 < growthStages - 1 && w.rand.nextInt(growthDelay) == 0) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta + 1, 3);
|
||||
w.setBlockMetadataWithNotify(x, y - 1, z, meta - 7, 3);
|
||||
}
|
||||
} else {
|
||||
if (meta < growthStages - 1 && w.rand.nextInt(growthDelay) == 0) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta + 1, 3);
|
||||
w.setBlockMetadataWithNotify(x, y + 1, z, meta + 9, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z)
|
||||
{
|
||||
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess w, int x, int y, int z) {
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
public boolean canPlaceBlockAt(World w, int x, int y, int z)
|
||||
{
|
||||
|
||||
public boolean canPlaceBlockAt(World w, int x, int y, int z) {
|
||||
return super.canPlaceBlockAt(w, x, y, z) && w.isAirBlock(x, y + 1, z);
|
||||
}
|
||||
|
||||
protected void checkAndDropBlock(World w, int x, int y, int z)
|
||||
{
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if(isTopBlock(meta))
|
||||
{
|
||||
if(w.getBlock(x, y-1, z) != this)
|
||||
{
|
||||
w.setBlockToAir(x, y, z);
|
||||
this.dropBlockAsItem(w, x, y, z, meta, 0);
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(w.getBlock(x, y+1, z) != this)
|
||||
{
|
||||
this.dropBlockAsItem(w, x, y, z, meta, 0);
|
||||
w.setBlockToAir(x, y, z);
|
||||
return;
|
||||
}
|
||||
if(!canBlockStay(w, x, y, z))
|
||||
{
|
||||
this.dropBlockAsItem(w, x, y+1, z, meta, 0);
|
||||
w.setBlockToAir(x, y+1, z);
|
||||
this.dropBlockAsItem(w, x, y, z, meta, 0);
|
||||
w.setBlockToAir(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkAndDropBlock(World w, int x, int y, int z) {
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if (isTopBlock(meta)) {
|
||||
if (w.getBlock(x, y - 1, z) != this) {
|
||||
w.setBlockToAir(x, y, z);
|
||||
this.dropBlockAsItem(w, x, y, z, meta, 0);
|
||||
}
|
||||
} else {
|
||||
if (w.getBlock(x, y + 1, z) != this) {
|
||||
this.dropBlockAsItem(w, x, y, z, meta, 0);
|
||||
w.setBlockToAir(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (!canBlockStay(w, x, y, z)) {
|
||||
this.dropBlockAsItem(w, x, y + 1, z, meta, 0);
|
||||
w.setBlockToAir(x, y + 1, z);
|
||||
this.dropBlockAsItem(w, x, y, z, meta, 0);
|
||||
w.setBlockToAir(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
||||
{
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
if(!isTopBlock(metadata))
|
||||
{
|
||||
ret.add(new ItemStack(this,1,0));
|
||||
return ret;
|
||||
}else
|
||||
{
|
||||
metadata -= 8;
|
||||
if(metadata >= this.growthStages - 1)
|
||||
{
|
||||
ret.add(new ItemStack(TBItems.resource,1+world.rand.nextInt(4),6));
|
||||
return ret;
|
||||
}else
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
if (!isTopBlock(metadata)) {
|
||||
ret.add(new ItemStack(this, 1, 0));
|
||||
return ret;
|
||||
} else {
|
||||
metadata -= 8;
|
||||
if (metadata >= this.growthStages - 1) {
|
||||
ret.add(new ItemStack(TBItems.resource, 1 + world.rand.nextInt(4), 6));
|
||||
return ret;
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canBlockStay(World w, int x, int y, int z)
|
||||
{
|
||||
return !w.isAirBlock(x, y-1, z) && (w.getBlock(x, y-1, z).isReplaceableOreGen(w, x, y-1, z, Blocks.grass) || w.getBlock(x, y-1, z).isReplaceableOreGen(w, x, y, z, Blocks.dirt) || w.getBlock(x, y-1, z).canSustainPlant(w, x, y-1, z, ForgeDirection.UP, this));
|
||||
|
||||
public boolean canBlockStay(World w, int x, int y, int z) {
|
||||
return !w.isAirBlock(x, y - 1, z)
|
||||
&& (w.getBlock(x, y - 1, z).isReplaceableOreGen(w, x, y - 1, z, Blocks.grass)
|
||||
|| w.getBlock(x, y - 1, z).isReplaceableOreGen(w, x, y, z, Blocks.dirt)
|
||||
|| w.getBlock(x, y - 1, z).canSustainPlant(w, x, y - 1, z, ForgeDirection.UP, this));
|
||||
}
|
||||
|
||||
public boolean isTopBlock(int meta)
|
||||
{
|
||||
return meta > 7;
|
||||
|
||||
public boolean isTopBlock(int meta) {
|
||||
return meta > 7;
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy(World w, int x, int y, int z, EntityLivingBase placer, ItemStack stack)
|
||||
{
|
||||
w.setBlock(x, y+1, z, this,8,3);
|
||||
|
||||
public void onBlockPlacedBy(World w, int x, int y, int z, EntityLivingBase placer, ItemStack stack) {
|
||||
w.setBlock(x, y + 1, z, this, 8, 3);
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
doublePlantBottomIcons = new IIcon[growthStages];
|
||||
doublePlantTopIcons = new IIcon[growthStages];
|
||||
|
||||
for(int i = 0; i < growthStages; ++i)
|
||||
{
|
||||
doublePlantBottomIcons[i] = reg.registerIcon(textureName+"stage_"+i+"_bot");
|
||||
doublePlantTopIcons[i] = reg.registerIcon(textureName+"stage_"+i+"_top");
|
||||
}
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
doublePlantBottomIcons = new IIcon[growthStages];
|
||||
doublePlantTopIcons = new IIcon[growthStages];
|
||||
|
||||
for (int i = 0; i < growthStages; ++i) {
|
||||
doublePlantBottomIcons[i] = reg.registerIcon(textureName + "stage_" + i + "_bot");
|
||||
doublePlantTopIcons[i] = reg.registerIcon(textureName + "stage_" + i + "_top");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
return isTopBlock(meta) ? doublePlantTopIcons[meta-8] : doublePlantBottomIcons[meta];
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return isTopBlock(meta) ? doublePlantTopIcons[meta - 8] : doublePlantBottomIcons[meta];
|
||||
}
|
||||
|
||||
|
||||
//canApplyBonemeal
|
||||
@Override
|
||||
public boolean func_149851_a(World w, int x,int y, int z, boolean remote) {
|
||||
return w.getBlockMetadata(x, y, z) % 8 < growthStages-1;
|
||||
}
|
||||
|
||||
//canGrowPlant
|
||||
@Override
|
||||
public boolean func_149852_a(World w, Random r, int x, int y, int z) {
|
||||
return w.getBlockLightValue(x, y + 1, z) >= 9;
|
||||
}
|
||||
// canApplyBonemeal
|
||||
@Override
|
||||
public boolean func_149851_a(World w, int x, int y, int z, boolean remote) {
|
||||
return w.getBlockMetadata(x, y, z) % 8 < growthStages - 1;
|
||||
}
|
||||
|
||||
//growPlant
|
||||
@Override
|
||||
public void func_149853_b(World w, Random r,int x, int y, int z)
|
||||
{
|
||||
if(w.getBlock(x, y, z)==this)
|
||||
{
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if(isTopBlock(meta))
|
||||
{
|
||||
if(meta-8 < growthStages-1 && w.rand.nextInt(growthDelay) == 0)
|
||||
{
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta+1, 3);
|
||||
w.setBlockMetadataWithNotify(x, y-1, z, meta-7, 3);
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(meta < growthStages-1 && w.rand.nextInt(growthDelay) == 0)
|
||||
{
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta+1, 3);
|
||||
w.setBlockMetadataWithNotify(x, y+1, z, meta+9, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// canGrowPlant
|
||||
@Override
|
||||
public boolean func_149852_a(World w, Random r, int x, int y, int z) {
|
||||
return w.getBlockLightValue(x, y + 1, z) >= 9;
|
||||
}
|
||||
|
||||
// growPlant
|
||||
@Override
|
||||
public void func_149853_b(World w, Random r, int x, int y, int z) {
|
||||
if (w.getBlock(x, y, z) == this) {
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if (isTopBlock(meta)) {
|
||||
if (meta - 8 < growthStages - 1 && w.rand.nextInt(growthDelay) == 0) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta + 1, 3);
|
||||
w.setBlockMetadataWithNotify(x, y - 1, z, meta - 7, 3);
|
||||
}
|
||||
} else {
|
||||
if (meta < growthStages - 1 && w.rand.nextInt(growthDelay) == 0) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta + 1, 3);
|
||||
w.setBlockMetadataWithNotify(x, y + 1, z, meta + 9, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package tb.common.block;
|
||||
|
||||
import DummyCore.Utils.MathUtils;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tb.common.tile.TileCampfire;
|
||||
import DummyCore.Utils.MathUtils;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -14,82 +12,92 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tb.common.tile.TileCampfire;
|
||||
|
||||
public class BlockCampfire extends BlockContainer
|
||||
{
|
||||
public class BlockCampfire extends BlockContainer {
|
||||
|
||||
public BlockCampfire()
|
||||
{
|
||||
super(Material.wood);
|
||||
setHardness(1F);
|
||||
setResistance(1F);
|
||||
setStepSound(soundTypeWood);
|
||||
}
|
||||
public BlockCampfire() {
|
||||
super(Material.wood);
|
||||
setHardness(1F);
|
||||
setResistance(1F);
|
||||
setStepSound(soundTypeWood);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta)
|
||||
{
|
||||
return new TileCampfire();
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileCampfire();
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
return 0x1242fe;
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
if(w.getBlockMetadata(x, y, z) > 1)
|
||||
{
|
||||
w.spawnParticle("flame", x+0.5D+MathUtils.randomDouble(r)/4, y, z+0.5D+MathUtils.randomDouble(r)/4, 0, 0.04D, 0);
|
||||
for(int i = 0; i < 10; ++i)
|
||||
w.spawnParticle("smoke", x+0.5D+MathUtils.randomDouble(r)/4, y+0.1D, z+0.5D+MathUtils.randomDouble(r)/4, 0, r.nextDouble()/20, 0);
|
||||
|
||||
w.playSound(x+0.5D, y+0.5D, z+0.5D, "thaumicbases:fire.loop", 0.1F, 0.1F, false);
|
||||
}
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ)
|
||||
{
|
||||
if(w.isRemote)
|
||||
return true;
|
||||
|
||||
TileCampfire fire = (TileCampfire) w.getTileEntity(x, y, z);
|
||||
ItemStack stk = p.getCurrentEquippedItem();
|
||||
boolean added = fire.addLog(stk);
|
||||
if(!added)
|
||||
added = fire.addFuel(stk);
|
||||
|
||||
if(added)
|
||||
{
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
if(p.openContainer != null)
|
||||
p.openContainer.detectAndSendChanges();
|
||||
p.inventory.markDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
public int getRenderType() {
|
||||
return 0x1242fe;
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r) {
|
||||
if (w.getBlockMetadata(x, y, z) > 1) {
|
||||
w.spawnParticle(
|
||||
"flame",
|
||||
x + 0.5D + MathUtils.randomDouble(r) / 4,
|
||||
y,
|
||||
z + 0.5D + MathUtils.randomDouble(r) / 4,
|
||||
0,
|
||||
0.04D,
|
||||
0);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
w.spawnParticle(
|
||||
"smoke",
|
||||
x + 0.5D + MathUtils.randomDouble(r) / 4,
|
||||
y + 0.1D,
|
||||
z + 0.5D + MathUtils.randomDouble(r) / 4,
|
||||
0,
|
||||
r.nextDouble() / 20,
|
||||
0);
|
||||
|
||||
w.playSound(x + 0.5D, y + 0.5D, z + 0.5D, "thaumicbases:fire.loop", 0.1F, 0.1F, false);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(
|
||||
World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ) {
|
||||
if (w.isRemote) return true;
|
||||
|
||||
TileCampfire fire = (TileCampfire) w.getTileEntity(x, y, z);
|
||||
ItemStack stk = p.getCurrentEquippedItem();
|
||||
boolean added = fire.addLog(stk);
|
||||
if (!added) added = fire.addFuel(stk);
|
||||
|
||||
if (added) {
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
if (p.openContainer != null) p.openContainer.detectAndSendChanges();
|
||||
p.inventory.markDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addCollisionBoxesToList(
|
||||
final World world,
|
||||
final int i,
|
||||
final int j,
|
||||
final int k,
|
||||
final AxisAlignedBB axisalignedbb,
|
||||
final List arraylist,
|
||||
final Entity par7Entity) {
|
||||
this.setBlockBounds(0.0625f, 0.0f, 0.0625f, 0.9375f, 0.5f, 0.9375f);
|
||||
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
|
||||
}
|
||||
|
||||
public void setBlockBoundsBasedOnState(final IBlockAccess world, final int i, final int j, final int k) {
|
||||
|
||||
this.setBlockBounds(0.0625f, 0.0f, 0.0625f, 0.9375f, 0.5f, 0.9375f);
|
||||
super.setBlockBoundsBasedOnState(world, i, j, k);
|
||||
}
|
||||
|
||||
public void addCollisionBoxesToList(final World world, final int i, final int j, final int k, final AxisAlignedBB axisalignedbb, final List arraylist, final Entity par7Entity) {
|
||||
this.setBlockBounds(0.0625f, 0.0f, 0.0625f, 0.9375f, 0.5f, 0.9375f);
|
||||
super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity);
|
||||
}
|
||||
|
||||
public void setBlockBoundsBasedOnState(final IBlockAccess world, final int i, final int j, final int k) {
|
||||
|
||||
this.setBlockBounds(0.0625f, 0.0f, 0.0625f, 0.9375f, 0.5f, 0.9375f);
|
||||
super.setBlockBoundsBasedOnState(world, i, j, k);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import DummyCore.Utils.MathUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBed;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -20,90 +19,101 @@ import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCryingObelisk extends Block{
|
||||
public class BlockCryingObelisk extends Block {
|
||||
|
||||
public IIcon topbotIcon;
|
||||
public IIcon genericIcon;
|
||||
public IIcon topSide;
|
||||
public IIcon botSide;
|
||||
|
||||
public BlockCryingObelisk()
|
||||
{
|
||||
super(Material.rock);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int side)
|
||||
{
|
||||
if(w.getBlock(x, y+1, z) == this && w.getBlock(x, y+2, z) != this && w.getBlock(x, y-1, z) != this)
|
||||
return side == 0 || side == 1 ? topbotIcon : botSide;
|
||||
|
||||
if(w.getBlock(x, y-1, z) == this && w.getBlock(x, y-2, z) != this && w.getBlock(x, y+1, z) != this)
|
||||
return side == 0 || side == 1 ? topbotIcon : topSide;
|
||||
|
||||
return genericIcon;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata)
|
||||
{
|
||||
return genericIcon;
|
||||
public IIcon topbotIcon;
|
||||
public IIcon genericIcon;
|
||||
public IIcon topSide;
|
||||
public IIcon botSide;
|
||||
|
||||
public BlockCryingObelisk() {
|
||||
super(Material.rock);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
if((w.getBlock(x, y+1, z) == this && w.getBlock(x, y+2, z) != this && w.getBlock(x, y-1, z) != this) || (w.getBlock(x, y-1, z) == this && w.getBlock(x, y-2, z) != this && w.getBlock(x, y+1, z) != this))
|
||||
{
|
||||
for(int i = 0; i < 10; ++i)
|
||||
{
|
||||
double rndY = rnd.nextDouble()*3;
|
||||
w.spawnParticle("portal", x+0.5D+MathUtils.randomDouble(rnd), y-3+rndY, z+0.5D+MathUtils.randomDouble(rnd), 0, rndY, 0);
|
||||
}
|
||||
}
|
||||
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int side) {
|
||||
if (w.getBlock(x, y + 1, z) == this && w.getBlock(x, y + 2, z) != this && w.getBlock(x, y - 1, z) != this)
|
||||
return side == 0 || side == 1 ? topbotIcon : botSide;
|
||||
|
||||
if (w.getBlock(x, y - 1, z) == this && w.getBlock(x, y - 2, z) != this && w.getBlock(x, y + 1, z) != this)
|
||||
return side == 0 || side == 1 ? topbotIcon : topSide;
|
||||
|
||||
return genericIcon;
|
||||
}
|
||||
|
||||
public boolean isBed(IBlockAccess world, int x, int y, int z, EntityLivingBase player)
|
||||
{
|
||||
return ((world.getBlock(x, y+1, z) == this && world.getBlock(x, y+2, z) != this && world.getBlock(x, y-1, z) != this) || (world.getBlock(x, y-1, z) == this && world.getBlock(x, y-2, z) != this && world.getBlock(x, y+1, z) != this));
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return genericIcon;
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ)
|
||||
{
|
||||
if((w.getBlock(x, y+1, z) == this && w.getBlock(x, y+2, z) != this && w.getBlock(x, y-1, z) != this) || (w.getBlock(x, y-1, z) == this && w.getBlock(x, y-2, z) != this && w.getBlock(x, y+1, z) != this))
|
||||
{
|
||||
w.playSound(x+0.5D, y+0.5D, z+0.5D, "portal.travel", 1, 2, false);
|
||||
p.setSpawnChunk(new ChunkCoordinates(x,y,z), false,p.dimension);
|
||||
if(p.worldObj.isRemote)
|
||||
p.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.spawnSet")).setChatStyle(new ChatStyle().setItalic(true).setColor(EnumChatFormatting.AQUA)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random rnd) {
|
||||
if ((w.getBlock(x, y + 1, z) == this && w.getBlock(x, y + 2, z) != this && w.getBlock(x, y - 1, z) != this)
|
||||
|| (w.getBlock(x, y - 1, z) == this
|
||||
&& w.getBlock(x, y - 2, z) != this
|
||||
&& w.getBlock(x, y + 1, z) != this)) {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
double rndY = rnd.nextDouble() * 3;
|
||||
w.spawnParticle(
|
||||
"portal",
|
||||
x + 0.5D + MathUtils.randomDouble(rnd),
|
||||
y - 3 + rndY,
|
||||
z + 0.5D + MathUtils.randomDouble(rnd),
|
||||
0,
|
||||
rndY,
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ChunkCoordinates getBedSpawnPosition(IBlockAccess world, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
for(int dy = 0; dy > -3; --dy)
|
||||
for(int dx = -2; dx <= 2; ++dx)
|
||||
{
|
||||
for(int dz = -2; dz <= 2; ++dz)
|
||||
{
|
||||
if (World.doesBlockHaveSolidTopSurface(world,x+dx, y+dy, z+dz) && !world.getBlock(x+dx, y+dy, z+dz).getMaterial().isOpaque() && !world.getBlock(x+dx, y+dy+1, z+dz).getMaterial().isOpaque())
|
||||
{
|
||||
return new ChunkCoordinates(x+dx, y+dy+1,z+dz);
|
||||
|
||||
public boolean isBed(IBlockAccess world, int x, int y, int z, EntityLivingBase player) {
|
||||
return ((world.getBlock(x, y + 1, z) == this
|
||||
&& world.getBlock(x, y + 2, z) != this
|
||||
&& world.getBlock(x, y - 1, z) != this)
|
||||
|| (world.getBlock(x, y - 1, z) == this
|
||||
&& world.getBlock(x, y - 2, z) != this
|
||||
&& world.getBlock(x, y + 1, z) != this));
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(
|
||||
World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ) {
|
||||
if ((w.getBlock(x, y + 1, z) == this && w.getBlock(x, y + 2, z) != this && w.getBlock(x, y - 1, z) != this)
|
||||
|| (w.getBlock(x, y - 1, z) == this
|
||||
&& w.getBlock(x, y - 2, z) != this
|
||||
&& w.getBlock(x, y + 1, z) != this)) {
|
||||
w.playSound(x + 0.5D, y + 0.5D, z + 0.5D, "portal.travel", 1, 2, false);
|
||||
p.setSpawnChunk(new ChunkCoordinates(x, y, z), false, p.dimension);
|
||||
if (p.worldObj.isRemote)
|
||||
p.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.spawnSet"))
|
||||
.setChatStyle(new ChatStyle().setItalic(true).setColor(EnumChatFormatting.AQUA)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ChunkCoordinates getBedSpawnPosition(IBlockAccess world, int x, int y, int z, EntityPlayer player) {
|
||||
for (int dy = 0; dy > -3; --dy)
|
||||
for (int dx = -2; dx <= 2; ++dx) {
|
||||
for (int dz = -2; dz <= 2; ++dz) {
|
||||
if (World.doesBlockHaveSolidTopSurface(world, x + dx, y + dy, z + dz)
|
||||
&& !world.getBlock(x + dx, y + dy, z + dz)
|
||||
.getMaterial()
|
||||
.isOpaque()
|
||||
&& !world.getBlock(x + dx, y + dy + 1, z + dz)
|
||||
.getMaterial()
|
||||
.isOpaque()) {
|
||||
return new ChunkCoordinates(x + dx, y + dy + 1, z + dz);
|
||||
}
|
||||
}
|
||||
}
|
||||
return BlockBed.func_149977_a((World) world, x, y, z, 0);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
genericIcon = reg.registerIcon(this.getTextureName()+"cryingObsidian");
|
||||
topbotIcon = reg.registerIcon(this.getTextureName()+"cryingObelisk_TB");
|
||||
topSide = reg.registerIcon(this.getTextureName()+"cryingObelisk_sideT");
|
||||
botSide = reg.registerIcon(this.getTextureName()+"cryingObelisk_sideB");
|
||||
}
|
||||
}
|
||||
return BlockBed.func_149977_a((World) world, x, y, z, 0);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
genericIcon = reg.registerIcon(this.getTextureName() + "cryingObsidian");
|
||||
topbotIcon = reg.registerIcon(this.getTextureName() + "cryingObelisk_TB");
|
||||
topSide = reg.registerIcon(this.getTextureName() + "cryingObelisk_sideT");
|
||||
botSide = reg.registerIcon(this.getTextureName() + "cryingObelisk_sideB");
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import thaumcraft.common.blocks.CustomStepSound;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -14,60 +11,44 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import thaumcraft.common.blocks.CustomStepSound;
|
||||
|
||||
public class BlockCrystalBlock extends Block implements IInfusionStabiliser{
|
||||
|
||||
public static IIcon[] icons = new IIcon[8];
|
||||
public static final String[] names = new String[]{
|
||||
"air",
|
||||
"fire",
|
||||
"water",
|
||||
"earth",
|
||||
"order",
|
||||
"entropy",
|
||||
"mixed",
|
||||
"tainted"
|
||||
};
|
||||
|
||||
public BlockCrystalBlock()
|
||||
{
|
||||
super(Material.glass);
|
||||
setHardness(0.7F);
|
||||
setResistance(1.0F);
|
||||
setLightLevel(0.5F);
|
||||
setStepSound(new CustomStepSound("crystal", 1.0F, 1.0F));
|
||||
}
|
||||
public class BlockCrystalBlock extends Block implements IInfusionStabiliser {
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for(int i = 0; i < 8; ++i)
|
||||
par3List.add(new ItemStack(par1,1,i));
|
||||
}
|
||||
|
||||
|
||||
public void registerBlockIcons(IIconRegister ir)
|
||||
{
|
||||
for(int i = 0; i < 8; ++i)
|
||||
icons[i] = ir.registerIcon("thaumicbases:crystal/"+names[i]);
|
||||
}
|
||||
|
||||
public int damageDropped(int par1)
|
||||
{
|
||||
return par1;
|
||||
}
|
||||
public static IIcon[] icons = new IIcon[8];
|
||||
public static final String[] names =
|
||||
new String[] {"air", "fire", "water", "earth", "order", "entropy", "mixed", "tainted"};
|
||||
|
||||
public BlockCrystalBlock() {
|
||||
super(Material.glass);
|
||||
setHardness(0.7F);
|
||||
setResistance(1.0F);
|
||||
setLightLevel(0.5F);
|
||||
setStepSound(new CustomStepSound("crystal", 1.0F, 1.0F));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
for (int i = 0; i < 8; ++i) par3List.add(new ItemStack(par1, 1, i));
|
||||
}
|
||||
|
||||
public void registerBlockIcons(IIconRegister ir) {
|
||||
for (int i = 0; i < 8; ++i) icons[i] = ir.registerIcon("thaumicbases:crystal/" + names[i]);
|
||||
}
|
||||
|
||||
public int damageDropped(int par1) {
|
||||
return par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
if(meta >= 8)
|
||||
meta = 7;
|
||||
return icons[meta];
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
if (meta >= 8) meta = 7;
|
||||
return icons[meta];
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tb.init.TBBlocks;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import thaumcraft.common.blocks.CustomStepSound;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -15,58 +11,53 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tb.init.TBBlocks;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import thaumcraft.common.blocks.CustomStepSound;
|
||||
|
||||
public class BlockCrystalSlab extends BlockSlab implements IInfusionStabiliser{
|
||||
public class BlockCrystalSlab extends BlockSlab implements IInfusionStabiliser {
|
||||
|
||||
public BlockCrystalSlab(boolean fullBlock, Material material)
|
||||
{
|
||||
super(fullBlock, material);
|
||||
setHardness(0.7F);
|
||||
setResistance(1.0F);
|
||||
setLightLevel(0.5F);
|
||||
setStepSound(new CustomStepSound("crystal", 1.0F, 1.0F));
|
||||
}
|
||||
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
||||
{
|
||||
public BlockCrystalSlab(boolean fullBlock, Material material) {
|
||||
super(fullBlock, material);
|
||||
setHardness(0.7F);
|
||||
setResistance(1.0F);
|
||||
setLightLevel(0.5F);
|
||||
setStepSound(new CustomStepSound("crystal", 1.0F, 1.0F));
|
||||
}
|
||||
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
|
||||
return Item.getItemFromBlock(TBBlocks.crystalSlab);
|
||||
}
|
||||
|
||||
protected ItemStack createStackedBlock(int p_149644_1_)
|
||||
{
|
||||
protected ItemStack createStackedBlock(int p_149644_1_) {
|
||||
return new ItemStack(Item.getItemFromBlock(TBBlocks.crystalSlab), 2, p_149644_1_ & 7);
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World w, int x, int y, int z)
|
||||
{
|
||||
return Item.getItemFromBlock(TBBlocks.crystalSlab);
|
||||
public Item getItem(World w, int x, int y, int z) {
|
||||
return Item.getItemFromBlock(TBBlocks.crystalSlab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_150002_b(int meta) {
|
||||
return super.getUnlocalizedName() + BlockCrystalBlock.names[meta & 7];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_150002_b(int meta) {
|
||||
return super.getUnlocalizedName()+BlockCrystalBlock.names[meta & 7];
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
return TBBlocks.crystalBlock.getIcon(side, meta & 7);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item itm, CreativeTabs tab, List lst)
|
||||
{
|
||||
for(int i = 0; i < 8; ++i)
|
||||
{
|
||||
lst.add(new ItemStack(itm,1,i));
|
||||
}
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return TBBlocks.crystalBlock.getIcon(side, meta & 7);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item itm, CreativeTabs tab, List lst) {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
lst.add(new ItemStack(itm, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package tb.common.block;
|
||||
|
||||
import tb.common.itemblock.ItemBlockCrystal;
|
||||
import tb.common.tile.TileEntityDeconstructor;
|
||||
import thaumcraft.common.lib.research.ResearchManager;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -12,119 +9,100 @@ import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import tb.common.itemblock.ItemBlockCrystal;
|
||||
import tb.common.tile.TileEntityDeconstructor;
|
||||
import thaumcraft.common.lib.research.ResearchManager;
|
||||
|
||||
public class BlockEntityDeconstructor extends BlockContainer{
|
||||
public class BlockEntityDeconstructor extends BlockContainer {
|
||||
|
||||
public BlockEntityDeconstructor()
|
||||
{
|
||||
super(Material.rock);
|
||||
float f = 0.1F;
|
||||
this.setBlockBounds(0, 0, 0, 1, f, 1);
|
||||
}
|
||||
public BlockEntityDeconstructor() {
|
||||
super(Material.rock);
|
||||
float f = 0.1F;
|
||||
this.setBlockBounds(0, 0, 0, 1, f, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileEntityDeconstructor();
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileEntityDeconstructor();
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ)
|
||||
{
|
||||
if(p.getCurrentEquippedItem() != null)
|
||||
{
|
||||
if(p.getCurrentEquippedItem().getItem() instanceof ItemBlockCrystal)
|
||||
{
|
||||
if(ResearchManager.isResearchComplete(p.getCommandSenderName(), "TB.EntityDecAdv"))
|
||||
if(p.getCurrentEquippedItem().getItemDamage() < 6)
|
||||
{
|
||||
TileEntityDeconstructor d = TileEntityDeconstructor.class.cast(w.getTileEntity(x, y, z));
|
||||
switch(p.getCurrentEquippedItem().getItemDamage())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if(!d.hasAir)
|
||||
{
|
||||
d.hasAir = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if(!d.hasFire)
|
||||
{
|
||||
d.hasFire = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if(!d.hasWater)
|
||||
{
|
||||
d.hasWater = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
if(!d.hasEarth)
|
||||
{
|
||||
d.hasEarth = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
if(!d.hasOrdo)
|
||||
{
|
||||
d.hasOrdo = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
if(!d.hasEntropy)
|
||||
{
|
||||
d.hasEntropy = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(p.worldObj.isRemote)
|
||||
p.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.linkEntDecon")).setChatStyle(new ChatStyle().setItalic(true).setColor(EnumChatFormatting.AQUA)));
|
||||
|
||||
TileEntityDeconstructor.class.cast(w.getTileEntity(x, y, z)).placerName = p.getCommandSenderName();
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(
|
||||
World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ) {
|
||||
if (p.getCurrentEquippedItem() != null) {
|
||||
if (p.getCurrentEquippedItem().getItem() instanceof ItemBlockCrystal) {
|
||||
if (ResearchManager.isResearchComplete(p.getCommandSenderName(), "TB.EntityDecAdv"))
|
||||
if (p.getCurrentEquippedItem().getItemDamage() < 6) {
|
||||
TileEntityDeconstructor d = TileEntityDeconstructor.class.cast(w.getTileEntity(x, y, z));
|
||||
switch (p.getCurrentEquippedItem().getItemDamage()) {
|
||||
case 0: {
|
||||
if (!d.hasAir) {
|
||||
d.hasAir = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
if (!d.hasFire) {
|
||||
d.hasFire = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if (!d.hasWater) {
|
||||
d.hasWater = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if (!d.hasEarth) {
|
||||
d.hasEarth = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
if (!d.hasOrdo) {
|
||||
d.hasOrdo = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if (!d.hasEntropy) {
|
||||
d.hasEntropy = true;
|
||||
p.inventory.decrStackSize(p.inventory.currentItem, 1);
|
||||
d.tickTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p.worldObj.isRemote)
|
||||
p.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.linkEntDecon"))
|
||||
.setChatStyle(new ChatStyle().setItalic(true).setColor(EnumChatFormatting.AQUA)));
|
||||
|
||||
TileEntityDeconstructor.class.cast(w.getTileEntity(x, y, z)).placerName = p.getCommandSenderName();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +1,52 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBush;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
|
||||
public class BlockFlaxium extends BlockBush{
|
||||
public class BlockFlaxium extends BlockBush {
|
||||
|
||||
public BlockFlaxium() {
|
||||
super(Material.plants);
|
||||
this.setTickRandomly(true);
|
||||
this.setBlockBounds(0.25F, 0, 0.25F, 0.75F, 0.85F, 0.75F);
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
if(w.isAirBlock(x, y+1, z))
|
||||
w.setBlock(x, y+1, z, ConfigBlocks.blockFluxGas, 0, 3);
|
||||
|
||||
if(!canGrowOn(w,x,y-1,z))
|
||||
w.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block updated)
|
||||
{
|
||||
if(!canGrowOn(w,x,y-1,z))
|
||||
w.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
|
||||
{
|
||||
public BlockFlaxium() {
|
||||
super(Material.plants);
|
||||
this.setTickRandomly(true);
|
||||
this.setBlockBounds(0.25F, 0, 0.25F, 0.75F, 0.85F, 0.75F);
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd) {
|
||||
if (w.isAirBlock(x, y + 1, z)) w.setBlock(x, y + 1, z, ConfigBlocks.blockFluxGas, 0, 3);
|
||||
|
||||
if (!canGrowOn(w, x, y - 1, z)) w.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block updated) {
|
||||
if (!canGrowOn(w, x, y - 1, z)) w.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(
|
||||
World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
public int getRenderType() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static boolean canGrowOn(World w, int x, int y, int z)
|
||||
{
|
||||
return !w.isAirBlock(x, y, z) && (w.getBlock(x, y, z).isReplaceableOreGen(w, x, y, z, Blocks.grass) || w.getBlock(x, y, z).isReplaceableOreGen(w, x, y, z, Blocks.dirt));
|
||||
}
|
||||
|
||||
public static boolean canGrowOn(World w, int x, int y, int z) {
|
||||
return !w.isAirBlock(x, y, z)
|
||||
&& (w.getBlock(x, y, z).isReplaceableOreGen(w, x, y, z, Blocks.grass)
|
||||
|| w.getBlock(x, y, z).isReplaceableOreGen(w, x, y, z, Blocks.dirt));
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tb.init.TBBlocks;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -15,65 +12,61 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tb.init.TBBlocks;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
|
||||
public class BlockHalfSlab extends BlockSlab implements IInfusionStabiliser{
|
||||
|
||||
public static Block[] parents = new Block[]{
|
||||
TBBlocks.eldritchArk,
|
||||
TBBlocks.oldBrick,
|
||||
TBBlocks.oldCobble,
|
||||
TBBlocks.oldCobbleMossy,
|
||||
TBBlocks.oldDiamond,
|
||||
TBBlocks.oldGold,
|
||||
TBBlocks.oldIron,
|
||||
TBBlocks.oldLapis
|
||||
};
|
||||
public class BlockHalfSlab extends BlockSlab implements IInfusionStabiliser {
|
||||
|
||||
public BlockHalfSlab(boolean fullBlock, Material material)
|
||||
{
|
||||
super(fullBlock, material);
|
||||
}
|
||||
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
||||
{
|
||||
public static Block[] parents = new Block[] {
|
||||
TBBlocks.eldritchArk,
|
||||
TBBlocks.oldBrick,
|
||||
TBBlocks.oldCobble,
|
||||
TBBlocks.oldCobbleMossy,
|
||||
TBBlocks.oldDiamond,
|
||||
TBBlocks.oldGold,
|
||||
TBBlocks.oldIron,
|
||||
TBBlocks.oldLapis
|
||||
};
|
||||
|
||||
public BlockHalfSlab(boolean fullBlock, Material material) {
|
||||
super(fullBlock, material);
|
||||
}
|
||||
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
|
||||
return Item.getItemFromBlock(TBBlocks.genericSlab);
|
||||
}
|
||||
|
||||
protected ItemStack createStackedBlock(int p_149644_1_)
|
||||
{
|
||||
protected ItemStack createStackedBlock(int p_149644_1_) {
|
||||
return new ItemStack(Item.getItemFromBlock(TBBlocks.genericSlab), 2, p_149644_1_ & 7);
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World w, int x, int y, int z)
|
||||
{
|
||||
return Item.getItemFromBlock(TBBlocks.genericSlab);
|
||||
public Item getItem(World w, int x, int y, int z) {
|
||||
return Item.getItemFromBlock(TBBlocks.genericSlab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_150002_b(int meta) {
|
||||
return super.getUnlocalizedName()+parents[meta].getUnlocalizedName();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
return parents[meta & 7].getIcon(side, 0);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item itm, CreativeTabs tab, List lst)
|
||||
{
|
||||
for(int i = 0; i < parents.length; ++i)
|
||||
{
|
||||
lst.add(new ItemStack(itm,1,i));
|
||||
}
|
||||
@Override
|
||||
public String func_150002_b(int meta) {
|
||||
return super.getUnlocalizedName() + parents[meta].getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World world, int x, int y, int z) {
|
||||
int meta = world.getBlockMetadata(x, y, z) & 7;
|
||||
return parents[meta] instanceof IInfusionStabiliser && ((IInfusionStabiliser) parents[meta]).canStabaliseInfusion(world, x, y, z);
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return parents[meta & 7].getIcon(side, 0);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item itm, CreativeTabs tab, List lst) {
|
||||
for (int i = 0; i < parents.length; ++i) {
|
||||
lst.add(new ItemStack(itm, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World world, int x, int y, int z) {
|
||||
int meta = world.getBlockMetadata(x, y, z) & 7;
|
||||
return parents[meta] instanceof IInfusionStabiliser
|
||||
&& ((IInfusionStabiliser) parents[meta]).canStabaliseInfusion(world, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +1,41 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import tb.init.TBBlocks;
|
||||
import tb.init.TBItems;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tb.init.TBBlocks;
|
||||
import tb.init.TBItems;
|
||||
|
||||
public class BlockKnose extends BlockTBPlant {
|
||||
|
||||
public BlockKnose(int stages, int delay, boolean isCrop) {
|
||||
super(stages, delay, isCrop);
|
||||
}
|
||||
|
||||
public boolean canBlockStay(World w, int x, int y, int z)
|
||||
{
|
||||
return !w.isAirBlock(x, y-1, z) && canPlaceBlockOn(w.getBlock(x, y-1, z));
|
||||
public BlockKnose(int stages, int delay, boolean isCrop) {
|
||||
super(stages, delay, isCrop);
|
||||
}
|
||||
|
||||
protected boolean canPlaceBlockOn(Block b)
|
||||
{
|
||||
return b == TBBlocks.crystalBlock;
|
||||
public boolean canBlockStay(World w, int x, int y, int z) {
|
||||
return !w.isAirBlock(x, y - 1, z) && canPlaceBlockOn(w.getBlock(x, y - 1, z));
|
||||
}
|
||||
|
||||
|
||||
protected boolean canPlaceBlockOn(Block b) {
|
||||
return b == TBBlocks.crystalBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
||||
{
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
if (metadata >= growthStages-1)
|
||||
{
|
||||
if(dropSeed != null)
|
||||
ret.add(dropSeed.copy());
|
||||
Block b = world.getBlock(x, y-1, z);
|
||||
if(b == TBBlocks.crystalBlock)
|
||||
{
|
||||
int md = world.getBlockMetadata(x, y-1, z);
|
||||
ret.add(new ItemStack(TBItems.knoseFragment,1,md));
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(dropSeed != null)
|
||||
ret.add(dropSeed.copy());
|
||||
}
|
||||
|
||||
return ret;
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
if (metadata >= growthStages - 1) {
|
||||
if (dropSeed != null) ret.add(dropSeed.copy());
|
||||
Block b = world.getBlock(x, y - 1, z);
|
||||
if (b == TBBlocks.crystalBlock) {
|
||||
int md = world.getBlockMetadata(x, y - 1, z);
|
||||
ret.add(new ItemStack(TBItems.knoseFragment, 1, md));
|
||||
}
|
||||
} else {
|
||||
if (dropSeed != null) ret.add(dropSeed.copy());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -2,45 +2,39 @@ package tb.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import tb.init.TBBlocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import tb.init.TBBlocks;
|
||||
|
||||
public class BlockLucritePlant extends BlockTBPlant {
|
||||
|
||||
public BlockLucritePlant(int stages, int delay, boolean isCrop) {
|
||||
super(stages, delay, isCrop);
|
||||
}
|
||||
|
||||
//growPlant
|
||||
@Override
|
||||
public void func_149853_b(World w, Random r,int x, int y, int z)
|
||||
{
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
w.setBlockMetadataWithNotify(x, y, z, Math.min(growthStages,meta+1), 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockStay(World w, int x, int y, int z)
|
||||
{
|
||||
return super.canBlockStay(w, x, y, z) && w.getBlock(x, y-2, z) == TBBlocks.dustBlock;
|
||||
public BlockLucritePlant(int stages, int delay, boolean isCrop) {
|
||||
super(stages, delay, isCrop);
|
||||
}
|
||||
|
||||
|
||||
// growPlant
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
||||
{
|
||||
public void func_149853_b(World w, Random r, int x, int y, int z) {
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
w.setBlockMetadataWithNotify(x, y, z, Math.min(growthStages, meta + 1), 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockStay(World w, int x, int y, int z) {
|
||||
return super.canBlockStay(w, x, y, z) && w.getBlock(x, y - 2, z) == TBBlocks.dustBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> ret = super.getDrops(world, x, y, z, metadata, fortune);
|
||||
|
||||
if (metadata >= growthStages-1)
|
||||
{
|
||||
if (world.rand.nextInt(16) == 0)
|
||||
{
|
||||
ret.add(new ItemStack(Items.golden_carrot,1,0));
|
||||
if (metadata >= growthStages - 1) {
|
||||
if (world.rand.nextInt(16) == 0) {
|
||||
ret.add(new ItemStack(Items.golden_carrot, 1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,31 @@
|
||||
package tb.common.block;
|
||||
|
||||
import tb.common.tile.TileNodeLinker;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import tb.common.tile.TileNodeLinker;
|
||||
|
||||
public class BlockNodeLinker extends BlockContainer{
|
||||
public class BlockNodeLinker extends BlockContainer {
|
||||
|
||||
public BlockNodeLinker()
|
||||
{
|
||||
super(Material.rock);
|
||||
}
|
||||
public BlockNodeLinker() {
|
||||
super(Material.rock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileNodeLinker();
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileNodeLinker();
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
|
||||
public int getRenderType() {
|
||||
return 0x421922;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package tb.common.block;
|
||||
|
||||
import tb.common.item.ItemNodeFoci;
|
||||
import tb.common.tile.TileNodeManipulator;
|
||||
import tb.init.TBItems;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -11,80 +8,69 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import tb.common.item.ItemNodeFoci;
|
||||
import tb.common.tile.TileNodeManipulator;
|
||||
import tb.init.TBItems;
|
||||
|
||||
public class BlockNodeManipulator extends BlockContainer{
|
||||
public class BlockNodeManipulator extends BlockContainer {
|
||||
|
||||
public BlockNodeManipulator()
|
||||
{
|
||||
super(Material.rock);
|
||||
}
|
||||
public BlockNodeManipulator() {
|
||||
super(Material.rock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileNodeManipulator();
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileNodeManipulator();
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
|
||||
public int getRenderType() {
|
||||
return 0x421922;
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ)
|
||||
{
|
||||
if(p.getCurrentEquippedItem() != null)
|
||||
{
|
||||
ItemStack current = p.getCurrentEquippedItem();
|
||||
if(current.getItem() instanceof ItemNodeFoci)
|
||||
{
|
||||
if(w.getBlockMetadata(x, y, z) != 0)
|
||||
{
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
ItemStack stk = new ItemStack(TBItems.nodeFoci,1,meta-1);
|
||||
EntityItem itm = new EntityItem(w,x+0.5D,y,z+0.5D,stk);
|
||||
if(!w.isRemote)
|
||||
w.spawnEntityInWorld(itm);
|
||||
}
|
||||
w.setBlockMetadataWithNotify(x, y, z, current.getItemDamage()+1, 3);
|
||||
p.destroyCurrentEquippedItem();
|
||||
|
||||
return true;
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(w.getBlockMetadata(x, y, z) != 0)
|
||||
{
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
ItemStack stk = new ItemStack(TBItems.nodeFoci,1,meta-1);
|
||||
EntityItem itm = new EntityItem(w,x+0.5D,y,z+0.5D,stk);
|
||||
if(!w.isRemote)
|
||||
w.spawnEntityInWorld(itm);
|
||||
}
|
||||
w.setBlockMetadataWithNotify(x, y, z, 0, 3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World w, int x, int y, int z, Block b, int meta)
|
||||
{
|
||||
if(meta > 0) //Fix for the manipulator not dropping the foci.
|
||||
{
|
||||
ItemStack foci = new ItemStack(TBItems.nodeFoci,1,meta-1);
|
||||
EntityItem itm = new EntityItem(w,x+0.5D,y+0.5D,z+0.5D,foci);
|
||||
if(!w.isRemote)
|
||||
w.spawnEntityInWorld(itm);
|
||||
}
|
||||
super.breakBlock(w, x, y, z, b, meta);
|
||||
|
||||
public boolean onBlockActivated(
|
||||
World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ) {
|
||||
if (p.getCurrentEquippedItem() != null) {
|
||||
ItemStack current = p.getCurrentEquippedItem();
|
||||
if (current.getItem() instanceof ItemNodeFoci) {
|
||||
if (w.getBlockMetadata(x, y, z) != 0) {
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
ItemStack stk = new ItemStack(TBItems.nodeFoci, 1, meta - 1);
|
||||
EntityItem itm = new EntityItem(w, x + 0.5D, y, z + 0.5D, stk);
|
||||
if (!w.isRemote) w.spawnEntityInWorld(itm);
|
||||
}
|
||||
w.setBlockMetadataWithNotify(x, y, z, current.getItemDamage() + 1, 3);
|
||||
p.destroyCurrentEquippedItem();
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (w.getBlockMetadata(x, y, z) != 0) {
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
ItemStack stk = new ItemStack(TBItems.nodeFoci, 1, meta - 1);
|
||||
EntityItem itm = new EntityItem(w, x + 0.5D, y, z + 0.5D, stk);
|
||||
if (!w.isRemote) w.spawnEntityInWorld(itm);
|
||||
}
|
||||
w.setBlockMetadataWithNotify(x, y, z, 0, 3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World w, int x, int y, int z, Block b, int meta) {
|
||||
if (meta > 0) // Fix for the manipulator not dropping the foci.
|
||||
{
|
||||
ItemStack foci = new ItemStack(TBItems.nodeFoci, 1, meta - 1);
|
||||
EntityItem itm = new EntityItem(w, x + 0.5D, y + 0.5D, z + 0.5D, foci);
|
||||
if (!w.isRemote) w.spawnEntityInWorld(itm);
|
||||
}
|
||||
super.breakBlock(w, x, y, z, b, meta);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package tb.common.block;
|
||||
|
||||
import DummyCore.Utils.MiscUtils;
|
||||
import tb.common.tile.TileOverchanter;
|
||||
import tb.core.TBCore;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -13,68 +11,61 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tb.common.tile.TileOverchanter;
|
||||
import tb.core.TBCore;
|
||||
|
||||
public class BlockOverchanter extends BlockContainer{
|
||||
|
||||
public IIcon topIcon;
|
||||
public IIcon botIcon;
|
||||
public IIcon sideIcon;
|
||||
public class BlockOverchanter extends BlockContainer {
|
||||
|
||||
public BlockOverchanter()
|
||||
{
|
||||
super(Material.rock);
|
||||
this.setHarvestLevel("pickaxe", 3);
|
||||
public IIcon topIcon;
|
||||
public IIcon botIcon;
|
||||
public IIcon sideIcon;
|
||||
|
||||
public BlockOverchanter() {
|
||||
super(Material.rock);
|
||||
this.setHarvestLevel("pickaxe", 3);
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F);
|
||||
this.setLightOpacity(0);
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
return side == 0 ? botIcon : side == 1 ? topIcon : sideIcon;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
topIcon = reg.registerIcon("thaumicbases:overchanter/top");
|
||||
botIcon = reg.registerIcon("thaumicbases:overchanter/bottom");
|
||||
sideIcon = reg.registerIcon("thaumicbases:overchanter/side");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileOverchanter();
|
||||
}
|
||||
|
||||
public void breakBlock(World w, int x, int y, int z, Block b, int meta)
|
||||
{
|
||||
MiscUtils.dropItemsOnBlockBreak(w, x, y, z, b, meta);
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ)
|
||||
{
|
||||
if(!p.isSneaking())
|
||||
{
|
||||
if(!w.isRemote)
|
||||
{
|
||||
p.openGui(TBCore.instance, 0x421922, w, x, y, z);
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return side == 0 ? botIcon : side == 1 ? topIcon : sideIcon;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
topIcon = reg.registerIcon("thaumicbases:overchanter/top");
|
||||
botIcon = reg.registerIcon("thaumicbases:overchanter/bottom");
|
||||
sideIcon = reg.registerIcon("thaumicbases:overchanter/side");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileOverchanter();
|
||||
}
|
||||
|
||||
public void breakBlock(World w, int x, int y, int z, Block b, int meta) {
|
||||
MiscUtils.dropItemsOnBlockBreak(w, x, y, z, b, meta);
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(
|
||||
World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ) {
|
||||
if (!p.isSneaking()) {
|
||||
if (!w.isRemote) {
|
||||
p.openGui(TBCore.instance, 0x421922, w, x, y, z);
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
package tb.common.block;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tb.utils.TBConfig;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -18,138 +16,140 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tb.utils.TBConfig;
|
||||
|
||||
public class BlockPyrofluid extends Block{
|
||||
|
||||
public static IIcon fluidIcon;
|
||||
public static IIcon staticIcon;
|
||||
public class BlockPyrofluid extends Block {
|
||||
|
||||
public BlockPyrofluid()
|
||||
{
|
||||
super(Material.lava);
|
||||
public static IIcon fluidIcon;
|
||||
public static IIcon staticIcon;
|
||||
|
||||
public BlockPyrofluid() {
|
||||
super(Material.lava);
|
||||
float f = 0.0F;
|
||||
float f1 = 0.0F;
|
||||
this.setBlockBounds(0.0F + f1, 0.0F + f, 0.0F + f1, 1.0F + f1, 1.0F + f, 1.0F + f1);
|
||||
this.setTickRandomly(true);
|
||||
}
|
||||
|
||||
public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
public int getRenderType() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
|
||||
public int idDropped(int par1, Random par2Random, int par3) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int quantityDropped(Random par1Random)
|
||||
{
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int tickRate(World par1World)
|
||||
{
|
||||
|
||||
public int tickRate(World par1World) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
|
||||
{
|
||||
|
||||
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
|
||||
double d5;
|
||||
double d6;
|
||||
double d7;
|
||||
d5 = (double)((float)par2 + par5Random.nextFloat());
|
||||
d7 = (double)par3-0.5D + this.maxY;
|
||||
d6 = (double)((float)par4 + par5Random.nextFloat());
|
||||
if (this.blockMaterial == Material.lava && par1World.getBlock(par2, par3 + 1, par4).getMaterial() == Material.air && !par1World.getBlock(par2, par3 + 1, par4).isOpaqueCube())
|
||||
{
|
||||
if (par5Random.nextInt(100) == 0)
|
||||
{
|
||||
d5 = (double)((float)par2 + par5Random.nextFloat());
|
||||
d7 = (double)par3 + this.maxY;
|
||||
d6 = (double)((float)par4 + par5Random.nextFloat());
|
||||
d5 = (double) ((float) par2 + par5Random.nextFloat());
|
||||
d7 = (double) par3 - 0.5D + this.maxY;
|
||||
d6 = (double) ((float) par4 + par5Random.nextFloat());
|
||||
if (this.blockMaterial == Material.lava
|
||||
&& par1World.getBlock(par2, par3 + 1, par4).getMaterial() == Material.air
|
||||
&& !par1World.getBlock(par2, par3 + 1, par4).isOpaqueCube()) {
|
||||
if (par5Random.nextInt(100) == 0) {
|
||||
d5 = (double) ((float) par2 + par5Random.nextFloat());
|
||||
d7 = (double) par3 + this.maxY;
|
||||
d6 = (double) ((float) par4 + par5Random.nextFloat());
|
||||
par1World.spawnParticle("lava", d5, d7, d6, 0.0D, 0.0D, 0.0D);
|
||||
par1World.playSound(d5, d7, d6, "liquid.lavapop", 0.2F + par5Random.nextFloat() * 0.2F, 0.9F + par5Random.nextFloat() * 0.15F, false);
|
||||
par1World.playSound(
|
||||
d5,
|
||||
d7,
|
||||
d6,
|
||||
"liquid.lavapop",
|
||||
0.2F + par5Random.nextFloat() * 0.2F,
|
||||
0.9F + par5Random.nextFloat() * 0.15F,
|
||||
false);
|
||||
}
|
||||
|
||||
if (par5Random.nextInt(200) == 0)
|
||||
{
|
||||
par1World.playSound((double)par2, (double)par3, (double)par4, "liquid.lava", 0.2F + par5Random.nextFloat() * 0.2F, 0.9F + par5Random.nextFloat() * 0.15F, false);
|
||||
if (par5Random.nextInt(200) == 0) {
|
||||
par1World.playSound(
|
||||
(double) par2,
|
||||
(double) par3,
|
||||
(double) par4,
|
||||
"liquid.lava",
|
||||
0.2F + par5Random.nextFloat() * 0.2F,
|
||||
0.9F + par5Random.nextFloat() * 0.15F,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
if (par5Random.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4) && !par1World.getBlock(par2, par3 - 2, par4).getBlocksMovement(par1World, par2, par3, par4))
|
||||
{
|
||||
if (par5Random.nextInt(10) == 0
|
||||
&& World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4)
|
||||
&& !par1World.getBlock(par2, par3 - 2, par4).getBlocksMovement(par1World, par2, par3, par4)) {
|
||||
par1World.spawnParticle("dripLava", d5, d7, d6, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
int meta = w.getBlockMetadata(x, y, z) + 1;
|
||||
if(meta > 15)
|
||||
return;
|
||||
|
||||
if(meta >= 8)
|
||||
meta = 15;
|
||||
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta, 3);
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd) {
|
||||
int meta = w.getBlockMetadata(x, y, z) + 1;
|
||||
if (meta > 15) return;
|
||||
|
||||
if (meta >= 8) meta = 15;
|
||||
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta, 3);
|
||||
}
|
||||
|
||||
public void registerBlockIcons(IIconRegister ir)
|
||||
{
|
||||
fluidIcon = ir.registerIcon("thaumicbases:blazingFluid/block");
|
||||
staticIcon = ir.registerIcon("thaumicbases:blazingFluid/leftovers");
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
/*for(int i = 0; i < 8; ++i)
|
||||
par3List.add(new ItemStack(par1,1,i));*/
|
||||
|
||||
par3List.add(new ItemStack(par1,1,0));
|
||||
|
||||
//par3List.add(new ItemStack(par1,1,15));
|
||||
}
|
||||
|
||||
|
||||
public void registerBlockIcons(IIconRegister ir) {
|
||||
fluidIcon = ir.registerIcon("thaumicbases:blazingFluid/block");
|
||||
staticIcon = ir.registerIcon("thaumicbases:blazingFluid/leftovers");
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
/*for(int i = 0; i < 8; ++i)
|
||||
par3List.add(new ItemStack(par1,1,i));*/
|
||||
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
|
||||
// par3List.add(new ItemStack(par1,1,15));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
return meta == 15 ? staticIcon : fluidIcon;
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return meta == 15 ? staticIcon : fluidIcon;
|
||||
}
|
||||
|
||||
public float getBlockHardness(World w, int x, int y, int z)
|
||||
{
|
||||
return w.getBlockMetadata(x, y, z) == 15 ? 5 : -1;
|
||||
|
||||
public float getBlockHardness(World w, int x, int y, int z) {
|
||||
return w.getBlockMetadata(x, y, z) == 15 ? 5 : -1;
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
||||
{
|
||||
ArrayList<ItemStack> retLst = new ArrayList<ItemStack>();
|
||||
|
||||
retLst.add(new ItemStack(Items.blaze_powder,TBConfig.minBlazePowderFromPyrofluid+world.rand.nextInt(TBConfig.maxBlazePowderFromPyrofluid-TBConfig.minBlazePowderFromPyrofluid),0));
|
||||
|
||||
return retLst;
|
||||
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> retLst = new ArrayList<ItemStack>();
|
||||
|
||||
retLst.add(new ItemStack(
|
||||
Items.blaze_powder,
|
||||
TBConfig.minBlazePowderFromPyrofluid
|
||||
+ world.rand.nextInt(
|
||||
TBConfig.maxBlazePowderFromPyrofluid - TBConfig.minBlazePowderFromPyrofluid),
|
||||
0));
|
||||
|
||||
return retLst;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCactus;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -20,62 +19,55 @@ public class BlockRainbowCactus extends BlockCactus {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon field_150041_a;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon field_150040_b;
|
||||
|
||||
public BlockRainbowCactus()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_)
|
||||
{
|
||||
|
||||
|
||||
public BlockRainbowCactus() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public void onEntityCollidedWithBlock(
|
||||
World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) {}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
||||
{
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
if(world.getBlock(x, y-1, z) != this)
|
||||
{
|
||||
ret.add(new ItemStack(this,1,0));
|
||||
return ret;
|
||||
|
||||
if (world.getBlock(x, y - 1, z) != this) {
|
||||
ret.add(new ItemStack(this, 1, 0));
|
||||
return ret;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 3+world.rand.nextInt(8); ++i)
|
||||
ret.add(new ItemStack(Items.dye,1,allowedDyes[world.rand.nextInt(allowedDyes.length)]));
|
||||
|
||||
|
||||
for (int i = 0; i < 3 + world.rand.nextInt(8); ++i)
|
||||
ret.add(new ItemStack(Items.dye, 1, allowedDyes[world.rand.nextInt(allowedDyes.length)]));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static final int[] allowedDyes = new int[]{1,2,5,2,6,7,2,8,9,10,2,11,12,13,14,2};
|
||||
|
||||
|
||||
public static final int[] allowedDyes = new int[] {1, 2, 5, 2, 6, 7, 2, 8, 9, 10, 2, 11, 12, 13, 14, 2};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister p_149651_1_)
|
||||
{
|
||||
public void registerBlockIcons(IIconRegister p_149651_1_) {
|
||||
this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "side");
|
||||
this.field_150041_a = p_149651_1_.registerIcon(this.getTextureName() + "top");
|
||||
this.field_150040_b = p_149651_1_.registerIcon(this.getTextureName() + "bottom");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_)
|
||||
{
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
|
||||
return p_149691_1_ == 1 ? this.field_150041_a : (p_149691_1_ == 0 ? this.field_150040_b : this.blockIcon);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable)
|
||||
{
|
||||
public boolean canSustainPlant(
|
||||
IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) {
|
||||
Block plant = plantable.getPlant(world, x, y + 1, z);
|
||||
|
||||
if (plant == this)
|
||||
{
|
||||
|
||||
if (plant == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return super.canSustainPlant(world, x, y, z, direction, plantable);
|
||||
}
|
||||
}
|
||||
@@ -2,160 +2,155 @@ package tb.common.block;
|
||||
|
||||
import static net.minecraftforge.common.util.ForgeDirection.UP;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import tb.init.TBItems;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tb.init.TBItems;
|
||||
|
||||
public class BlockRedlonStem extends BlockStem{
|
||||
public class BlockRedlonStem extends BlockStem {
|
||||
|
||||
private Block field_149877_a;
|
||||
|
||||
public BlockRedlonStem(Block created)
|
||||
{
|
||||
super(created);
|
||||
field_149877_a = created;
|
||||
}
|
||||
|
||||
public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
|
||||
{
|
||||
this.checkAndDropBlock(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
|
||||
private Block field_149877_a;
|
||||
|
||||
if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9)
|
||||
{
|
||||
public BlockRedlonStem(Block created) {
|
||||
super(created);
|
||||
field_149877_a = created;
|
||||
}
|
||||
|
||||
public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) {
|
||||
this.checkAndDropBlock(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
|
||||
|
||||
if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9) {
|
||||
float f = this.func_149875_n(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
|
||||
|
||||
if (p_149674_5_.nextInt((int)(25.0F / f) + 1) == 0)
|
||||
{
|
||||
if (p_149674_5_.nextInt((int) (25.0F / f) + 1) == 0) {
|
||||
int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
|
||||
|
||||
if (l < 7)
|
||||
{
|
||||
if (l < 7) {
|
||||
++l;
|
||||
p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p_149674_1_.getBlock(p_149674_2_ - 1, p_149674_3_, p_149674_4_) == this.field_149877_a)
|
||||
{
|
||||
} else {
|
||||
if (p_149674_1_.getBlock(p_149674_2_ - 1, p_149674_3_, p_149674_4_) == this.field_149877_a) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_149674_1_.getBlock(p_149674_2_ + 1, p_149674_3_, p_149674_4_) == this.field_149877_a)
|
||||
{
|
||||
if (p_149674_1_.getBlock(p_149674_2_ + 1, p_149674_3_, p_149674_4_) == this.field_149877_a) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_, p_149674_4_ - 1) == this.field_149877_a)
|
||||
{
|
||||
if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_, p_149674_4_ - 1) == this.field_149877_a) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_, p_149674_4_ + 1) == this.field_149877_a)
|
||||
{
|
||||
if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_, p_149674_4_ + 1) == this.field_149877_a) {
|
||||
return;
|
||||
}
|
||||
|
||||
int i1 = p_149674_5_.nextInt(4);
|
||||
int j1 = p_149674_2_;
|
||||
int k1 = p_149674_4_;
|
||||
|
||||
if(p_149674_5_.nextInt(4) != 0)
|
||||
return;
|
||||
|
||||
if (i1 == 0)
|
||||
{
|
||||
if (p_149674_5_.nextInt(4) != 0) return;
|
||||
|
||||
if (i1 == 0) {
|
||||
j1 = p_149674_2_ - 1;
|
||||
}
|
||||
|
||||
if (i1 == 1)
|
||||
{
|
||||
if (i1 == 1) {
|
||||
++j1;
|
||||
}
|
||||
|
||||
if (i1 == 2)
|
||||
{
|
||||
if (i1 == 2) {
|
||||
k1 = p_149674_4_ - 1;
|
||||
}
|
||||
|
||||
if (i1 == 3)
|
||||
{
|
||||
if (i1 == 3) {
|
||||
++k1;
|
||||
}
|
||||
|
||||
if (p_149674_1_.isAirBlock(j1, p_149674_3_, k1))
|
||||
{
|
||||
if (p_149674_1_.isAirBlock(j1, p_149674_3_, k1)) {
|
||||
p_149674_1_.setBlock(j1, p_149674_3_, k1, this.field_149877_a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_)
|
||||
{
|
||||
public void randomDisplayTick(
|
||||
World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) {
|
||||
this.func_150186_m(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_);
|
||||
}
|
||||
|
||||
private void func_150186_m(World p_150186_1_, int p_150186_2_, int p_150186_3_, int p_150186_4_)
|
||||
{
|
||||
private void func_150186_m(World p_150186_1_, int p_150186_2_, int p_150186_3_, int p_150186_4_) {
|
||||
Random random = p_150186_1_.rand;
|
||||
double d0 = 0.0625D;
|
||||
|
||||
for (int l = 0; l < 6; ++l)
|
||||
{
|
||||
double d1 = (double)((float)p_150186_2_ + random.nextFloat());
|
||||
double d2 = (double)((float)p_150186_3_ + random.nextFloat());
|
||||
double d3 = (double)((float)p_150186_4_ + random.nextFloat());
|
||||
for (int l = 0; l < 6; ++l) {
|
||||
double d1 = (double) ((float) p_150186_2_ + random.nextFloat());
|
||||
double d2 = (double) ((float) p_150186_3_ + random.nextFloat());
|
||||
double d3 = (double) ((float) p_150186_4_ + random.nextFloat());
|
||||
|
||||
if (l == 0 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_ + 1, p_150186_4_).isOpaqueCube())
|
||||
{
|
||||
d2 = (double)(p_150186_3_ + 1) + d0;
|
||||
if (l == 0
|
||||
&& !p_150186_1_
|
||||
.getBlock(p_150186_2_, p_150186_3_ + 1, p_150186_4_)
|
||||
.isOpaqueCube()) {
|
||||
d2 = (double) (p_150186_3_ + 1) + d0;
|
||||
}
|
||||
|
||||
if (l == 1 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_ - 1, p_150186_4_).isOpaqueCube())
|
||||
{
|
||||
d2 = (double)(p_150186_3_ + 0) - d0;
|
||||
if (l == 1
|
||||
&& !p_150186_1_
|
||||
.getBlock(p_150186_2_, p_150186_3_ - 1, p_150186_4_)
|
||||
.isOpaqueCube()) {
|
||||
d2 = (double) (p_150186_3_ + 0) - d0;
|
||||
}
|
||||
|
||||
if (l == 2 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_, p_150186_4_ + 1).isOpaqueCube())
|
||||
{
|
||||
d3 = (double)(p_150186_4_ + 1) + d0;
|
||||
if (l == 2
|
||||
&& !p_150186_1_
|
||||
.getBlock(p_150186_2_, p_150186_3_, p_150186_4_ + 1)
|
||||
.isOpaqueCube()) {
|
||||
d3 = (double) (p_150186_4_ + 1) + d0;
|
||||
}
|
||||
|
||||
if (l == 3 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_, p_150186_4_ - 1).isOpaqueCube())
|
||||
{
|
||||
d3 = (double)(p_150186_4_ + 0) - d0;
|
||||
if (l == 3
|
||||
&& !p_150186_1_
|
||||
.getBlock(p_150186_2_, p_150186_3_, p_150186_4_ - 1)
|
||||
.isOpaqueCube()) {
|
||||
d3 = (double) (p_150186_4_ + 0) - d0;
|
||||
}
|
||||
|
||||
if (l == 4 && !p_150186_1_.getBlock(p_150186_2_ + 1, p_150186_3_, p_150186_4_).isOpaqueCube())
|
||||
{
|
||||
d1 = (double)(p_150186_2_ + 1) + d0;
|
||||
if (l == 4
|
||||
&& !p_150186_1_
|
||||
.getBlock(p_150186_2_ + 1, p_150186_3_, p_150186_4_)
|
||||
.isOpaqueCube()) {
|
||||
d1 = (double) (p_150186_2_ + 1) + d0;
|
||||
}
|
||||
|
||||
if (l == 5 && !p_150186_1_.getBlock(p_150186_2_ - 1, p_150186_3_, p_150186_4_).isOpaqueCube())
|
||||
{
|
||||
d1 = (double)(p_150186_2_ + 0) - d0;
|
||||
if (l == 5
|
||||
&& !p_150186_1_
|
||||
.getBlock(p_150186_2_ - 1, p_150186_3_, p_150186_4_)
|
||||
.isOpaqueCube()) {
|
||||
d1 = (double) (p_150186_2_ + 0) - d0;
|
||||
}
|
||||
|
||||
if (d1 < (double)p_150186_2_ || d1 > (double)(p_150186_2_ + 1) || d2 < 0.0D || d2 > (double)(p_150186_3_ + 1) || d3 < (double)p_150186_4_ || d3 > (double)(p_150186_4_ + 1))
|
||||
{
|
||||
if (d1 < (double) p_150186_2_
|
||||
|| d1 > (double) (p_150186_2_ + 1)
|
||||
|| d2 < 0.0D
|
||||
|| d2 > (double) (p_150186_3_ + 1)
|
||||
|| d3 < (double) p_150186_4_
|
||||
|| d3 > (double) (p_150186_4_ + 1)) {
|
||||
p_150186_1_.spawnParticle("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float func_149875_n(World p_149875_1_, int p_149875_2_, int p_149875_3_, int p_149875_4_)
|
||||
{
|
||||
|
||||
private float func_149875_n(World p_149875_1_, int p_149875_2_, int p_149875_3_, int p_149875_4_) {
|
||||
float f = 1.0F;
|
||||
Block block = p_149875_1_.getBlock(p_149875_2_, p_149875_3_, p_149875_4_ - 1);
|
||||
Block block1 = p_149875_1_.getBlock(p_149875_2_, p_149875_3_, p_149875_4_ + 1);
|
||||
@@ -169,25 +164,20 @@ public class BlockRedlonStem extends BlockStem{
|
||||
boolean flag1 = block == this || block1 == this;
|
||||
boolean flag2 = block4 == this || block5 == this || block6 == this || block7 == this;
|
||||
|
||||
for (int l = p_149875_2_ - 1; l <= p_149875_2_ + 1; ++l)
|
||||
{
|
||||
for (int i1 = p_149875_4_ - 1; i1 <= p_149875_4_ + 1; ++i1)
|
||||
{
|
||||
for (int l = p_149875_2_ - 1; l <= p_149875_2_ + 1; ++l) {
|
||||
for (int i1 = p_149875_4_ - 1; i1 <= p_149875_4_ + 1; ++i1) {
|
||||
Block block8 = p_149875_1_.getBlock(l, p_149875_3_ - 1, i1);
|
||||
float f1 = 0.0F;
|
||||
|
||||
if (block8.canSustainPlant(p_149875_1_, l, p_149875_3_ - 1, i1, UP, this))
|
||||
{
|
||||
if (block8.canSustainPlant(p_149875_1_, l, p_149875_3_ - 1, i1, UP, this)) {
|
||||
f1 = 1.0F;
|
||||
|
||||
if (block8.isFertile(p_149875_1_, l, p_149875_3_ - 1, i1))
|
||||
{
|
||||
if (block8.isFertile(p_149875_1_, l, p_149875_3_ - 1, i1)) {
|
||||
f1 = 3.0F;
|
||||
}
|
||||
}
|
||||
|
||||
if (l != p_149875_2_ || i1 != p_149875_4_)
|
||||
{
|
||||
if (l != p_149875_2_ || i1 != p_149875_4_) {
|
||||
f1 /= 4.0F;
|
||||
}
|
||||
|
||||
@@ -195,8 +185,7 @@ public class BlockRedlonStem extends BlockStem{
|
||||
}
|
||||
}
|
||||
|
||||
if (flag2 || flag && flag1)
|
||||
{
|
||||
if (flag2 || flag && flag1) {
|
||||
f /= 2.0F;
|
||||
}
|
||||
|
||||
@@ -204,37 +193,29 @@ public class BlockRedlonStem extends BlockStem{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune)
|
||||
{
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
Item item = TBItems.redlonSeeds;
|
||||
for (int i = 0; item != null && i < 3; i++)
|
||||
{
|
||||
if (world.rand.nextInt(15) <= meta)
|
||||
ret.add(new ItemStack(item));
|
||||
for (int i = 0; item != null && i < 3; i++) {
|
||||
if (world.rand.nextInt(15) <= meta) ret.add(new ItemStack(item));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_)
|
||||
{
|
||||
return TBItems.redlonSeeds;
|
||||
public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) {
|
||||
return TBItems.redlonSeeds;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_)
|
||||
{
|
||||
return 0xffffff;
|
||||
public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) {
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderColor(int p_149741_1_)
|
||||
{
|
||||
return 0xffffff;
|
||||
public int getRenderColor(int p_149741_1_) {
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import DummyCore.Utils.MathUtils;
|
||||
import tb.common.tile.TileRelocator;
|
||||
import tb.core.TBCore;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -21,167 +18,146 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tb.common.tile.TileRelocator;
|
||||
import tb.core.TBCore;
|
||||
|
||||
public class BlockRelocator extends BlockContainer{
|
||||
public class BlockRelocator extends BlockContainer {
|
||||
|
||||
public IIcon[] icons = new IIcon[5];
|
||||
|
||||
public BlockRelocator()
|
||||
{
|
||||
super(Material.wood);
|
||||
setHardness(2.5F);
|
||||
setResistance(15.0F);
|
||||
setStepSound(soundTypeWood);
|
||||
}
|
||||
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
meta %= 6;
|
||||
if(meta == 0)
|
||||
return icons[side == 0 ? 0 : side == 1 ? 1 : 2];
|
||||
|
||||
if(meta == 1)
|
||||
return icons[side == 1 ? 0 : side == 0 ? 1 : 2];
|
||||
|
||||
if(meta == 2)
|
||||
return icons[side == 2 ? 0 : side == 3 ? 1 : side == 0 || side == 1 ? 2 : 4];
|
||||
|
||||
if(meta == 3)
|
||||
return icons[side == 3 ? 0 : side == 2 ? 1 : side == 0 || side == 1 ? 2 : 4];
|
||||
|
||||
if(meta == 4)
|
||||
return icons[side == 4 ? 0 : side == 5 ? 1 : 4];
|
||||
|
||||
if(meta == 5)
|
||||
return icons[side == 5 ? 0 : side == 4 ? 1 : 4];
|
||||
|
||||
return icons[0];
|
||||
public IIcon[] icons = new IIcon[5];
|
||||
|
||||
public BlockRelocator() {
|
||||
super(Material.wood);
|
||||
setHardness(2.5F);
|
||||
setResistance(15.0F);
|
||||
setStepSound(soundTypeWood);
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister r)
|
||||
{
|
||||
icons[0] = r.registerIcon("thaumcraft:liftertop");
|
||||
icons[1] = r.registerIcon("thaumcraft:arcaneearbottom");
|
||||
icons[2]= r.registerIcon("thaumcraft:lifterside");
|
||||
icons[3] = r.registerIcon("thaumcraft:animatedglow");
|
||||
icons[4]= r.registerIcon("thaumicbases:relocator/rotatedside");
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
return 0x1242ff;
|
||||
}
|
||||
|
||||
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return world.getBlockMetadata(x, y, z)%6 != side.ordinal();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta)
|
||||
{
|
||||
return new TileRelocator();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_)
|
||||
{
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
meta %= 6;
|
||||
if (meta == 0) return icons[side == 0 ? 0 : side == 1 ? 1 : 2];
|
||||
|
||||
if (meta == 1) return icons[side == 1 ? 0 : side == 0 ? 1 : 2];
|
||||
|
||||
if (meta == 2) return icons[side == 2 ? 0 : side == 3 ? 1 : side == 0 || side == 1 ? 2 : 4];
|
||||
|
||||
if (meta == 3) return icons[side == 3 ? 0 : side == 2 ? 1 : side == 0 || side == 1 ? 2 : 4];
|
||||
|
||||
if (meta == 4) return icons[side == 4 ? 0 : side == 5 ? 1 : 4];
|
||||
|
||||
if (meta == 5) return icons[side == 5 ? 0 : side == 4 ? 1 : 4];
|
||||
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister r) {
|
||||
icons[0] = r.registerIcon("thaumcraft:liftertop");
|
||||
icons[1] = r.registerIcon("thaumcraft:arcaneearbottom");
|
||||
icons[2] = r.registerIcon("thaumcraft:lifterside");
|
||||
icons[3] = r.registerIcon("thaumcraft:animatedglow");
|
||||
icons[4] = r.registerIcon("thaumicbases:relocator/rotatedside");
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType() {
|
||||
return 0x1242ff;
|
||||
}
|
||||
|
||||
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
|
||||
return world.getBlockMetadata(x, y, z) % 6 != side.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World w, int meta) {
|
||||
return new TileRelocator();
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) {
|
||||
p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0));
|
||||
p_149666_3_.add(new ItemStack(p_149666_1_, 1, 6));
|
||||
}
|
||||
|
||||
public int damageDropped(int meta)
|
||||
{
|
||||
return meta < 6 ? 0 : 6;
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
TileRelocator tile = (TileRelocator) w.getTileEntity(x, y, z);
|
||||
int meta = w.getBlockMetadata(x, y, z) % 6;
|
||||
boolean doColor = w.getBlockMetadata(x, y, z) >= 6;
|
||||
if(!tile.isBlockPowered())
|
||||
{
|
||||
if(meta == 0)
|
||||
{
|
||||
|
||||
double dx = x+0.5D+MathUtils.randomDouble(r)/2;
|
||||
double dy = y;
|
||||
double dz = z+0.5D+MathUtils.randomDouble(r)/2;
|
||||
TBCore.proxy.sparkle(w,dx,doColor ? dy-3 : dy,dz,dx,doColor ? dy : dy - 3,dz,doColor ? 2 : 1, 1F);
|
||||
}
|
||||
if(meta == 1)
|
||||
{
|
||||
double dx = x+0.5D+MathUtils.randomDouble(r)/2;
|
||||
double dy = y+1;
|
||||
double dz = z+0.5D+MathUtils.randomDouble(r)/2;
|
||||
TBCore.proxy.sparkle(w,dx,doColor ? dy+3 : dy,dz,dx,doColor ? dy : dy+3,dz,doColor ? 2 : 1,1);
|
||||
}
|
||||
if(meta == 2)
|
||||
{
|
||||
double dx = x+0.5D+MathUtils.randomDouble(r)/2;
|
||||
double dy = y+0.5D+MathUtils.randomDouble(r)/2;
|
||||
double dz = z;
|
||||
TBCore.proxy.sparkle(w,dx,dy,doColor ? dz-3 : dz,dx,dy,doColor ? dz : dz-3,doColor ? 2 : 1,1);
|
||||
}
|
||||
if(meta == 3)
|
||||
{
|
||||
double dx = x+0.5D+MathUtils.randomDouble(r)/2;
|
||||
double dy = y+0.5D+MathUtils.randomDouble(r)/2;
|
||||
double dz = z+1;
|
||||
TBCore.proxy.sparkle(w,dx,dy,doColor ? dz+3 : dz,dx,dy,doColor ? dz : dz+3,doColor ? 2 : 1,1);
|
||||
}
|
||||
if(meta == 4)
|
||||
{
|
||||
double dx = x;
|
||||
double dy = y+0.5D+MathUtils.randomDouble(r)/2;
|
||||
double dz = z+0.5D+MathUtils.randomDouble(r)/2;
|
||||
TBCore.proxy.sparkle(w,doColor ? dx-3 : dx,dy,dz,doColor ? dx : dx-3,dy,dz,doColor ? 2 : 1,1);
|
||||
}
|
||||
if(meta == 5)
|
||||
{
|
||||
double dx = x+1;
|
||||
double dy = y+0.5D+MathUtils.randomDouble(r)/2;
|
||||
double dz = z+0.5D+MathUtils.randomDouble(r)/2;
|
||||
TBCore.proxy.sparkle(w,doColor ? dx+3 : dx,dy,dz,doColor ? dx : dx+3,dy,dz,doColor ? 2 : 1,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy(World w, int x, int y, int z, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
|
||||
{
|
||||
int l = determineOrientation(w, x, y, z, p_149689_5_);
|
||||
w.setBlockMetadataWithNotify(x, y, z, w.getBlockMetadata(x, y, z)+l, 3);
|
||||
}
|
||||
|
||||
public static int determineOrientation(World p_150071_0_, int p_150071_1_, int p_150071_2_, int p_150071_3_, EntityLivingBase p_150071_4_)
|
||||
{
|
||||
if (MathHelper.abs((float)p_150071_4_.posX - (float)p_150071_1_) < 2.0F && MathHelper.abs((float)p_150071_4_.posZ - (float)p_150071_3_) < 2.0F)
|
||||
{
|
||||
double d0 = p_150071_4_.posY + 1.82D - (double)p_150071_4_.yOffset;
|
||||
|
||||
if (d0 - (double)p_150071_2_ > 2.0D)
|
||||
{
|
||||
public int damageDropped(int meta) {
|
||||
return meta < 6 ? 0 : 6;
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r) {
|
||||
TileRelocator tile = (TileRelocator) w.getTileEntity(x, y, z);
|
||||
int meta = w.getBlockMetadata(x, y, z) % 6;
|
||||
boolean doColor = w.getBlockMetadata(x, y, z) >= 6;
|
||||
if (!tile.isBlockPowered()) {
|
||||
if (meta == 0) {
|
||||
|
||||
double dx = x + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
double dy = y;
|
||||
double dz = z + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
TBCore.proxy.sparkle(
|
||||
w, dx, doColor ? dy - 3 : dy, dz, dx, doColor ? dy : dy - 3, dz, doColor ? 2 : 1, 1F);
|
||||
}
|
||||
if (meta == 1) {
|
||||
double dx = x + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
double dy = y + 1;
|
||||
double dz = z + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
TBCore.proxy.sparkle(
|
||||
w, dx, doColor ? dy + 3 : dy, dz, dx, doColor ? dy : dy + 3, dz, doColor ? 2 : 1, 1);
|
||||
}
|
||||
if (meta == 2) {
|
||||
double dx = x + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
double dy = y + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
double dz = z;
|
||||
TBCore.proxy.sparkle(
|
||||
w, dx, dy, doColor ? dz - 3 : dz, dx, dy, doColor ? dz : dz - 3, doColor ? 2 : 1, 1);
|
||||
}
|
||||
if (meta == 3) {
|
||||
double dx = x + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
double dy = y + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
double dz = z + 1;
|
||||
TBCore.proxy.sparkle(
|
||||
w, dx, dy, doColor ? dz + 3 : dz, dx, dy, doColor ? dz : dz + 3, doColor ? 2 : 1, 1);
|
||||
}
|
||||
if (meta == 4) {
|
||||
double dx = x;
|
||||
double dy = y + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
double dz = z + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
TBCore.proxy.sparkle(
|
||||
w, doColor ? dx - 3 : dx, dy, dz, doColor ? dx : dx - 3, dy, dz, doColor ? 2 : 1, 1);
|
||||
}
|
||||
if (meta == 5) {
|
||||
double dx = x + 1;
|
||||
double dy = y + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
double dz = z + 0.5D + MathUtils.randomDouble(r) / 2;
|
||||
TBCore.proxy.sparkle(
|
||||
w, doColor ? dx + 3 : dx, dy, dz, doColor ? dx : dx + 3, dy, dz, doColor ? 2 : 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockPlacedBy(World w, int x, int y, int z, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) {
|
||||
int l = determineOrientation(w, x, y, z, p_149689_5_);
|
||||
w.setBlockMetadataWithNotify(x, y, z, w.getBlockMetadata(x, y, z) + l, 3);
|
||||
}
|
||||
|
||||
public static int determineOrientation(
|
||||
World p_150071_0_, int p_150071_1_, int p_150071_2_, int p_150071_3_, EntityLivingBase p_150071_4_) {
|
||||
if (MathHelper.abs((float) p_150071_4_.posX - (float) p_150071_1_) < 2.0F
|
||||
&& MathHelper.abs((float) p_150071_4_.posZ - (float) p_150071_3_) < 2.0F) {
|
||||
double d0 = p_150071_4_.posY + 1.82D - (double) p_150071_4_.yOffset;
|
||||
|
||||
if (d0 - (double) p_150071_2_ > 2.0D) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((double)p_150071_2_ - d0 > 0.0D)
|
||||
{
|
||||
if ((double) p_150071_2_ - d0 > 0.0D) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int l = MathHelper.floor_double((double)(p_150071_4_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
int l = MathHelper.floor_double((double) (p_150071_4_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
return l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +1,10 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import tb.init.TBItems;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumcraft.common.items.armor.ItemVoidArmor;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -27,156 +21,124 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import tb.init.TBItems;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumcraft.common.items.armor.ItemVoidArmor;
|
||||
|
||||
public class BlockSpike extends Block{
|
||||
public class BlockSpike extends Block {
|
||||
|
||||
public static final String[] spikeNames = new String[]{
|
||||
"iron",
|
||||
"iron_bloody",
|
||||
"thaumic",
|
||||
"thaumic_bloody",
|
||||
"void",
|
||||
"void_bloody"
|
||||
};
|
||||
|
||||
public static IIcon[] icons = new IIcon[spikeNames.length];
|
||||
|
||||
public BlockSpike()
|
||||
{
|
||||
super(Material.iron);
|
||||
float f = 0.0625F;
|
||||
this.setBlockBounds(0, 0, 0, 1, 1-f, 1);
|
||||
}
|
||||
public static final String[] spikeNames =
|
||||
new String[] {"iron", "iron_bloody", "thaumic", "thaumic_bloody", "void", "void_bloody"};
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
public static IIcon[] icons = new IIcon[spikeNames.length];
|
||||
|
||||
public BlockSpike() {
|
||||
super(Material.iron);
|
||||
float f = 0.0625F;
|
||||
this.setBlockBounds(0, 0, 0, 1, 1 - f, 1);
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
public int getRenderType() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block changed)
|
||||
{
|
||||
if(w.isAirBlock(x, y-1, z))
|
||||
{
|
||||
this.dropBlockAsItem(w, x, y, z, w.getBlockMetadata(x, y, z), 0);
|
||||
w.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block changed) {
|
||||
if (w.isAirBlock(x, y - 1, z)) {
|
||||
this.dropBlockAsItem(w, x, y, z, w.getBlockMetadata(x, y, z), 0);
|
||||
w.setBlockToAir(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
for(int i = 0; i < icons.length; ++i)
|
||||
icons[i] = reg.registerIcon("thaumicbases:spike/"+spikeNames[i]);
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
for (int i = 0; i < icons.length; ++i) icons[i] = reg.registerIcon("thaumicbases:spike/" + spikeNames[i]);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(new ItemStack(par1,1,0));
|
||||
par3List.add(new ItemStack(par1,1,2));
|
||||
par3List.add(new ItemStack(par1,1,4));
|
||||
}
|
||||
|
||||
public void onEntityCollidedWithBlock(World w, int x, int y, int z, Entity collider)
|
||||
{
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if(meta == 0 || meta == 1)
|
||||
{
|
||||
collider.attackEntityFrom(DamageSource.cactus, 8);
|
||||
|
||||
if(meta == 0 && collider instanceof EntityLivingBase && ((EntityLivingBase) collider).getHealth() <= 0)
|
||||
{
|
||||
w.setBlockMetadataWithNotify(x, y, z, 1, 3);
|
||||
}
|
||||
}
|
||||
if(meta == 2 || meta == 3)
|
||||
{
|
||||
if(w.isBlockIndirectlyGettingPowered(x, y, z))
|
||||
return;
|
||||
|
||||
if(!(collider instanceof EntityItem))
|
||||
collider.attackEntityFrom(DamageSource.cactus, 14);
|
||||
|
||||
if(meta == 2 && collider instanceof EntityLivingBase && ((EntityLivingBase) collider).getHealth() <= 0)
|
||||
{
|
||||
w.setBlockMetadataWithNotify(x, y, z, 3, 3);
|
||||
}
|
||||
}
|
||||
if(meta == 4 || meta == 5)
|
||||
{
|
||||
if(w.isBlockIndirectlyGettingPowered(x, y, z))
|
||||
return;
|
||||
|
||||
if(collider instanceof EntityPlayer)
|
||||
{
|
||||
ItemStack boots = ((EntityPlayer) collider).inventory.armorInventory[0];
|
||||
if(boots != null && boots.getItem() instanceof ItemVoidArmor)
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(collider instanceof EntityItem) && !(collider instanceof EntityXPOrb))
|
||||
{
|
||||
if(!w.isRemote)
|
||||
{
|
||||
FakePlayer fake = new FakePlayer((WorldServer) w, fakeSpikeProfile);
|
||||
collider.attackEntityFrom(DamageSource.causePlayerDamage(fake), 20);
|
||||
fake.setDead();
|
||||
fake = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(meta == 4 && collider instanceof EntityLivingBase && ((EntityLivingBase) collider).getHealth() <= 0)
|
||||
{
|
||||
w.setBlockMetadataWithNotify(x, y, z, 5, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer player, int side, float vecX, float vecY, float vecZ)
|
||||
{
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if(meta != 1 && meta != 3 && meta != 5)
|
||||
return false;
|
||||
|
||||
ItemStack cI = player.getCurrentEquippedItem();
|
||||
if(cI == null)
|
||||
return false;
|
||||
|
||||
if(cI.getItem() != ConfigItems.itemResource)
|
||||
return false;
|
||||
|
||||
if(cI.getItemDamage() != 7)
|
||||
return false;
|
||||
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
if(!player.inventory.addItemStackToInventory(new ItemStack(TBItems.resource,1,8)))
|
||||
player.dropPlayerItemWithRandomChoice(new ItemStack(TBItems.resource,1,8), false);
|
||||
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta-1, 3);
|
||||
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 2));
|
||||
par3List.add(new ItemStack(par1, 1, 4));
|
||||
}
|
||||
|
||||
public void onEntityCollidedWithBlock(World w, int x, int y, int z, Entity collider) {
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if (meta == 0 || meta == 1) {
|
||||
collider.attackEntityFrom(DamageSource.cactus, 8);
|
||||
|
||||
if (meta == 0 && collider instanceof EntityLivingBase && ((EntityLivingBase) collider).getHealth() <= 0) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, 1, 3);
|
||||
}
|
||||
}
|
||||
if (meta == 2 || meta == 3) {
|
||||
if (w.isBlockIndirectlyGettingPowered(x, y, z)) return;
|
||||
|
||||
if (!(collider instanceof EntityItem)) collider.attackEntityFrom(DamageSource.cactus, 14);
|
||||
|
||||
if (meta == 2 && collider instanceof EntityLivingBase && ((EntityLivingBase) collider).getHealth() <= 0) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, 3, 3);
|
||||
}
|
||||
}
|
||||
if (meta == 4 || meta == 5) {
|
||||
if (w.isBlockIndirectlyGettingPowered(x, y, z)) return;
|
||||
|
||||
if (collider instanceof EntityPlayer) {
|
||||
ItemStack boots = ((EntityPlayer) collider).inventory.armorInventory[0];
|
||||
if (boots != null && boots.getItem() instanceof ItemVoidArmor) return;
|
||||
}
|
||||
|
||||
if (!(collider instanceof EntityItem) && !(collider instanceof EntityXPOrb)) {
|
||||
if (!w.isRemote) {
|
||||
FakePlayer fake = new FakePlayer((WorldServer) w, fakeSpikeProfile);
|
||||
collider.attackEntityFrom(DamageSource.causePlayerDamage(fake), 20);
|
||||
fake.setDead();
|
||||
fake = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (meta == 4 && collider instanceof EntityLivingBase && ((EntityLivingBase) collider).getHealth() <= 0) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, 5, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(
|
||||
World w, int x, int y, int z, EntityPlayer player, int side, float vecX, float vecY, float vecZ) {
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if (meta != 1 && meta != 3 && meta != 5) return false;
|
||||
|
||||
ItemStack cI = player.getCurrentEquippedItem();
|
||||
if (cI == null) return false;
|
||||
|
||||
if (cI.getItem() != ConfigItems.itemResource) return false;
|
||||
|
||||
if (cI.getItemDamage() != 7) return false;
|
||||
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
if (!player.inventory.addItemStackToInventory(new ItemStack(TBItems.resource, 1, 8)))
|
||||
player.dropPlayerItemWithRandomChoice(new ItemStack(TBItems.resource, 1, 8), false);
|
||||
|
||||
w.setBlockMetadataWithNotify(x, y, z, meta - 1, 3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int damageDropped(int par1)
|
||||
{
|
||||
return par1 == 1 ? 0 : par1 == 3 ? 2 : par1 == 5 ? 4 : par1;
|
||||
}
|
||||
|
||||
public static final GameProfile fakeSpikeProfile = new GameProfile(UUID.randomUUID(),"[TB]Spikes");
|
||||
|
||||
public int damageDropped(int par1) {
|
||||
return par1 == 1 ? 0 : par1 == 3 ? 2 : par1 == 5 ? 4 : par1;
|
||||
}
|
||||
|
||||
public static final GameProfile fakeSpikeProfile = new GameProfile(UUID.randomUUID(), "[TB]Spikes");
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package tb.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDirt;
|
||||
import net.minecraft.block.BlockGrass;
|
||||
@@ -14,60 +13,48 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockSweed extends BlockTBPlant {
|
||||
|
||||
public BlockSweed(int stages, int delay, boolean isCrop) {
|
||||
super(stages, delay, isCrop);
|
||||
}
|
||||
|
||||
protected boolean canPlaceBlockOn(Block b)
|
||||
{
|
||||
return b != null && (b == Blocks.grass || b == Blocks.dirt || b instanceof BlockGrass || b instanceof BlockDirt);
|
||||
public BlockSweed(int stages, int delay, boolean isCrop) {
|
||||
super(stages, delay, isCrop);
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
|
||||
protected boolean canPlaceBlockOn(Block b) {
|
||||
return b != null
|
||||
&& (b == Blocks.grass || b == Blocks.dirt || b instanceof BlockGrass || b instanceof BlockDirt);
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd) {
|
||||
super.updateTick(w, x, y, z, rnd);
|
||||
if(w.getBlockMetadata(x, y, z) == growthStages-1 && !w.isRemote)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[2+w.rand.nextInt(4)];
|
||||
int newX = x+dir.offsetX;
|
||||
int newZ = z+dir.offsetZ;
|
||||
int newY = findSutableY(w,newX,y,newZ);
|
||||
if(canPlaceBlockOn(w.getBlock(newX, newY-1, newZ)) && w.isAirBlock(newX, newY, newZ)) //fix for the Sweeds destroying blocks
|
||||
w.setBlock(newX, newY, newZ, this, 0, 3);
|
||||
if (w.getBlockMetadata(x, y, z) == growthStages - 1 && !w.isRemote) {
|
||||
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[2 + w.rand.nextInt(4)];
|
||||
int newX = x + dir.offsetX;
|
||||
int newZ = z + dir.offsetZ;
|
||||
int newY = findSutableY(w, newX, y, newZ);
|
||||
if (canPlaceBlockOn(w.getBlock(newX, newY - 1, newZ))
|
||||
&& w.isAirBlock(newX, newY, newZ)) // fix for the Sweeds destroying blocks
|
||||
w.setBlock(newX, newY, newZ, this, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public int findSutableY(World w, int x, int y, int z)
|
||||
{
|
||||
int bY = y;
|
||||
y += 1;
|
||||
while(!canPlaceBlockOn(w.getBlock(x, y, z)) && y > bY - 2)
|
||||
--y;
|
||||
|
||||
return y+1;
|
||||
|
||||
public int findSutableY(World w, int x, int y, int z) {
|
||||
int bY = y;
|
||||
y += 1;
|
||||
while (!canPlaceBlockOn(w.getBlock(x, y, z)) && y > bY - 2) --y;
|
||||
|
||||
return y + 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
||||
{
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
if (metadata >= growthStages-1)
|
||||
{
|
||||
if (world.rand.nextInt(growthStages) <= metadata)
|
||||
if (dropSeed != null)
|
||||
ret.add(dropSeed.copy());
|
||||
|
||||
for (int i = 0; i < 3 + fortune; ++i)
|
||||
if (world.rand.nextBoolean())
|
||||
ret.add(new ItemStack(Items.sugar));
|
||||
if (metadata >= growthStages - 1) {
|
||||
if (world.rand.nextInt(growthStages) <= metadata) if (dropSeed != null) ret.add(dropSeed.copy());
|
||||
|
||||
if (world.rand.nextBoolean())
|
||||
ret.add(new ItemStack(Items.reeds));
|
||||
|
||||
}else
|
||||
if(dropSeed != null)
|
||||
ret.add(dropSeed.copy());
|
||||
for (int i = 0; i < 3 + fortune; ++i) if (world.rand.nextBoolean()) ret.add(new ItemStack(Items.sugar));
|
||||
|
||||
if (world.rand.nextBoolean()) ret.add(new ItemStack(Items.reeds));
|
||||
|
||||
} else if (dropSeed != null) ret.add(dropSeed.copy());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import DummyCore.Utils.MathUtils;
|
||||
import tb.core.TBCore;
|
||||
import tb.init.TBBlocks;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDirt;
|
||||
import net.minecraft.block.BlockGrass;
|
||||
@@ -37,385 +34,339 @@ import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import tb.core.TBCore;
|
||||
import tb.init.TBBlocks;
|
||||
|
||||
public class BlockTBLeaves extends BlockOldLeaf{
|
||||
|
||||
public static final String[] names = new String[]{
|
||||
"goldenOakLeaves",
|
||||
"peacefullTreeLeaves",
|
||||
"netherTreeLeaves",
|
||||
"enderTreeLeaves"
|
||||
};
|
||||
|
||||
public static final String[] textures = new String[]{
|
||||
"goldenOak/leaves",
|
||||
"peacefullTree/leaves",
|
||||
"netherTree/leaves",
|
||||
"enderTree/leaves"
|
||||
};
|
||||
|
||||
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%8==3)
|
||||
if(entity instanceof EntityDragon)
|
||||
return false;
|
||||
|
||||
return super.canEntityDestroy(world, x, y, z, entity);
|
||||
public class BlockTBLeaves extends BlockOldLeaf {
|
||||
|
||||
public static final String[] names =
|
||||
new String[] {"goldenOakLeaves", "peacefullTreeLeaves", "netherTreeLeaves", "enderTreeLeaves"};
|
||||
|
||||
public static final String[] textures =
|
||||
new String[] {"goldenOak/leaves", "peacefullTree/leaves", "netherTree/leaves", "enderTree/leaves"};
|
||||
|
||||
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
|
||||
if (world.getBlockMetadata(x, y, z) % 8 == 3) if (entity instanceof EntityDragon) return false;
|
||||
|
||||
return super.canEntityDestroy(world, x, y, z, entity);
|
||||
}
|
||||
|
||||
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%8==2)
|
||||
return true;
|
||||
|
||||
return super.isFlammable(world, x, y, z, face);
|
||||
|
||||
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
||||
if (world.getBlockMetadata(x, y, z) % 8 == 2) return true;
|
||||
|
||||
return super.isFlammable(world, x, y, z, face);
|
||||
}
|
||||
|
||||
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%8==2)
|
||||
return 0;
|
||||
|
||||
return super.getFlammability(world, x, y, z, face);
|
||||
|
||||
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
||||
if (world.getBlockMetadata(x, y, z) % 8 == 2) return 0;
|
||||
|
||||
return super.getFlammability(world, x, y, z, face);
|
||||
}
|
||||
|
||||
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%8==2)
|
||||
return 0;
|
||||
|
||||
return super.getFlammability(world, x, y, z, face);
|
||||
|
||||
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
||||
if (world.getBlockMetadata(x, y, z) % 8 == 2) return 0;
|
||||
|
||||
return super.getFlammability(world, x, y, z, face);
|
||||
}
|
||||
|
||||
public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%8==2)
|
||||
return true;
|
||||
|
||||
return super.isFireSource(world, x, y, z, side);
|
||||
|
||||
public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) {
|
||||
if (world.getBlockMetadata(x, y, z) % 8 == 2) return true;
|
||||
|
||||
return super.isFireSource(world, x, y, z, side);
|
||||
}
|
||||
|
||||
public static IIcon[] icons = new IIcon[names.length];
|
||||
|
||||
public static IIcon[] icons = new IIcon[names.length];
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBlockColor()
|
||||
{
|
||||
return 0xffffff;
|
||||
public int getBlockColor() {
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%8 != 3)
|
||||
return super.getLightValue(world, x, y, z);
|
||||
else
|
||||
return 11;
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
if (world.getBlockMetadata(x, y, z) % 8 != 3) return super.getLightValue(world, x, y, z);
|
||||
else return 11;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockAccess w, int x, int y, int z, int meta)
|
||||
{
|
||||
public boolean shouldSideBeRendered(IBlockAccess w, int x, int y, int z, int meta) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
super.randomDisplayTick(w, x, y, z, rnd);
|
||||
|
||||
if(w.getBlockMetadata(x, y, z)%8 == 0)
|
||||
w.spawnParticle("reddust", x+rnd.nextDouble(), y+rnd.nextDouble(), z+rnd.nextDouble(), 1, 1, 0);
|
||||
|
||||
if(w.getBlockMetadata(x, y, z)%8 == 1 && rnd.nextFloat() <= 0.01F)
|
||||
w.spawnParticle("heart", x+rnd.nextDouble(), y+rnd.nextDouble(), z+rnd.nextDouble(), 0, 10, 0);
|
||||
|
||||
if(w.getBlockMetadata(x, y, z)%8 == 2)
|
||||
{
|
||||
if(w.isAirBlock(x, y-1, z))
|
||||
w.spawnParticle("dripLava", x+rnd.nextDouble(), y, z+rnd.nextDouble(), 0, 0, 0);
|
||||
}
|
||||
|
||||
if(w.getBlockMetadata(x, y, z)%8 == 3)
|
||||
w.spawnParticle("portal", x+rnd.nextDouble(), y+rnd.nextDouble(), z+rnd.nextDouble(), MathUtils.randomDouble(rnd), MathUtils.randomDouble(rnd), MathUtils.randomDouble(rnd));
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random rnd) {
|
||||
super.randomDisplayTick(w, x, y, z, rnd);
|
||||
|
||||
if (w.getBlockMetadata(x, y, z) % 8 == 0)
|
||||
w.spawnParticle("reddust", x + rnd.nextDouble(), y + rnd.nextDouble(), z + rnd.nextDouble(), 1, 1, 0);
|
||||
|
||||
if (w.getBlockMetadata(x, y, z) % 8 == 1 && rnd.nextFloat() <= 0.01F)
|
||||
w.spawnParticle("heart", x + rnd.nextDouble(), y + rnd.nextDouble(), z + rnd.nextDouble(), 0, 10, 0);
|
||||
|
||||
if (w.getBlockMetadata(x, y, z) % 8 == 2) {
|
||||
if (w.isAirBlock(x, y - 1, z))
|
||||
w.spawnParticle("dripLava", x + rnd.nextDouble(), y, z + rnd.nextDouble(), 0, 0, 0);
|
||||
}
|
||||
|
||||
if (w.getBlockMetadata(x, y, z) % 8 == 3)
|
||||
w.spawnParticle(
|
||||
"portal",
|
||||
x + rnd.nextDouble(),
|
||||
y + rnd.nextDouble(),
|
||||
z + rnd.nextDouble(),
|
||||
MathUtils.randomDouble(rnd),
|
||||
MathUtils.randomDouble(rnd),
|
||||
MathUtils.randomDouble(rnd));
|
||||
}
|
||||
|
||||
public Item getItemDropped(int meta, Random rnd, int fortune)
|
||||
{
|
||||
|
||||
public Item getItemDropped(int meta, Random rnd, int fortune) {
|
||||
return Item.getItemFromBlock(TBBlocks.sapling);
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderColor(int p_149741_1_)
|
||||
{
|
||||
return 0xffffff;
|
||||
public int getRenderColor(int p_149741_1_) {
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
super.updateTick(w, x, y, z, rnd);
|
||||
if(w.getBlockMetadata(x, y, z)%8 == 1)
|
||||
{
|
||||
if(rnd.nextDouble() > 0.03D)
|
||||
return;
|
||||
|
||||
int dy = y;
|
||||
BiomeGenBase base = w.getBiomeGenForCoords(x, z);
|
||||
if(base != null)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SpawnListEntry> l = base.getSpawnableList(EnumCreatureType.creature);
|
||||
if(l != null && !l.isEmpty())
|
||||
{
|
||||
SpawnListEntry entry = l.get(rnd.nextInt(l.size()));
|
||||
if(entry != null && entry.entityClass != null)
|
||||
{
|
||||
Class<?> c = entry.entityClass;
|
||||
if(EntityLiving.class.isAssignableFrom(c))
|
||||
{
|
||||
try
|
||||
{
|
||||
EntityLiving el = EntityLiving.class.cast(c.getConstructor(World.class).newInstance(w));
|
||||
while(--y >= dy-6)
|
||||
{
|
||||
el.setPositionAndRotation(x+0.5D, y, z+0.5D, 0, 0);
|
||||
if(el.getCanSpawnHere())
|
||||
{
|
||||
w.spawnEntityInWorld(el);
|
||||
break;
|
||||
}else
|
||||
continue;
|
||||
}
|
||||
}catch(Exception e)
|
||||
{
|
||||
FMLLog.warning("[TB]Tried to create an entity of class "+c+" but failed! The exception is listed below:",new Object[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(w.getBlockMetadata(x, y, z)%8 == 2)
|
||||
{
|
||||
int dy = y;
|
||||
while(--y >= dy-8)
|
||||
{
|
||||
Block b = w.getBlock(x, y, z);
|
||||
if(!b.isAir(w, x, y, z))
|
||||
{
|
||||
boolean netheric = b instanceof BlockNetherrack || b instanceof BlockSoulSand || b == Blocks.quartz_ore;
|
||||
if(netheric && rnd.nextDouble() <= 0.05D)
|
||||
{
|
||||
BiomeGenBase hellBiome = BiomeGenBase.hell;
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SpawnListEntry> l = rnd.nextBoolean() ? hellBiome.getSpawnableList(EnumCreatureType.creature) : hellBiome.getSpawnableList(EnumCreatureType.monster);
|
||||
if(l != null && !l.isEmpty())
|
||||
{
|
||||
SpawnListEntry entry = l.get(rnd.nextInt(l.size()));
|
||||
if(entry != null && entry.entityClass != null)
|
||||
{
|
||||
Class<?> c = entry.entityClass;
|
||||
if(EntityLiving.class.isAssignableFrom(c))
|
||||
{
|
||||
try
|
||||
{
|
||||
EntityLiving el = EntityLiving.class.cast(c.getConstructor(World.class).newInstance(w));
|
||||
|
||||
el.setPositionAndRotation(x+0.5D, y+1, z+0.5D, 0, 0);
|
||||
el.onSpawnWithEgg(null);
|
||||
|
||||
if(el.getCanSpawnHere())
|
||||
{
|
||||
w.spawnEntityInWorld(el);
|
||||
break;
|
||||
}
|
||||
|
||||
}catch(Exception e)
|
||||
{
|
||||
FMLLog.warning("[TB]Tried to create an entity of class "+c+" but failed! The exception is listed below:",new Object[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean flag = b instanceof BlockDirt || b instanceof BlockGrass || b instanceof BlockGravel || b instanceof BlockSand || b instanceof BlockStone;
|
||||
if(!flag)
|
||||
{
|
||||
ItemStack stk = new ItemStack(b,1,w.getBlockMetadata(x, y, z));
|
||||
if(OreDictionary.getOreIDs(stk) != null && OreDictionary.getOreIDs(stk).length > 0)
|
||||
{
|
||||
OreDict:for(int i = 0; i < OreDictionary.getOreIDs(stk).length; ++i)
|
||||
{
|
||||
int id = OreDictionary.getOreIDs(stk)[i];
|
||||
if(id != -1)
|
||||
{
|
||||
String ore = OreDictionary.getOreName(id);
|
||||
if(ore != null && ! ore.isEmpty())
|
||||
{
|
||||
flag = ore.contains("dirt") || ore.contains("grass") || ore.contains("sand") || ore.contains("gravel") || ore.contains("stone");
|
||||
if(flag)
|
||||
break OreDict;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(flag)
|
||||
{
|
||||
double random = rnd.nextDouble();
|
||||
Block setTo = random <= 0.6D ? Blocks.netherrack : random <= 0.9D ? Blocks.soul_sand : Blocks.quartz_ore;
|
||||
w.setBlock(x, y, z, setTo, 0, 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(w.getBlockMetadata(x, y, z)%8 == 3)
|
||||
{
|
||||
int dy = y;
|
||||
while(--y >= dy-11)
|
||||
{
|
||||
Block b = w.getBlock(x, y, z);
|
||||
if(!b.isAir(w, x, y, z))
|
||||
{
|
||||
boolean end = b == Blocks.end_stone || b instanceof BlockObsidian;
|
||||
if(end && rnd.nextDouble() <= 0.02D)
|
||||
{
|
||||
BiomeGenBase hellBiome = BiomeGenBase.sky;
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SpawnListEntry> l = rnd.nextBoolean() ? hellBiome.getSpawnableList(EnumCreatureType.creature) : hellBiome.getSpawnableList(EnumCreatureType.monster);
|
||||
if(l != null && !l.isEmpty())
|
||||
{
|
||||
SpawnListEntry entry = l.get(rnd.nextInt(l.size()));
|
||||
if(entry != null && entry.entityClass != null)
|
||||
{
|
||||
Class<?> c = entry.entityClass;
|
||||
if(EntityLiving.class.isAssignableFrom(c))
|
||||
{
|
||||
try
|
||||
{
|
||||
EntityLiving el = EntityLiving.class.cast(c.getConstructor(World.class).newInstance(w));
|
||||
|
||||
el.setPositionAndRotation(x+0.5D, y+1, z+0.5D, 0, 0);
|
||||
el.onSpawnWithEgg(null);
|
||||
|
||||
if(w.isAirBlock(x, y+1, z))
|
||||
{
|
||||
w.spawnEntityInWorld(el);
|
||||
break;
|
||||
}
|
||||
|
||||
}catch(Exception e)
|
||||
{
|
||||
FMLLog.warning("[TB]Tried to create an entity of class "+c+" but failed! The exception is listed below:",new Object[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean flag = b instanceof BlockDirt || b instanceof BlockGrass || b instanceof BlockGravel || b instanceof BlockSand || b instanceof BlockStone && !(b instanceof BlockObsidian) && !(b == Blocks.end_stone);
|
||||
if(!flag)
|
||||
{
|
||||
ItemStack stk = new ItemStack(b,1,w.getBlockMetadata(x, y, z));
|
||||
if(OreDictionary.getOreIDs(stk) != null && OreDictionary.getOreIDs(stk).length > 0)
|
||||
{
|
||||
OreDict:for(int i = 0; i < OreDictionary.getOreIDs(stk).length; ++i)
|
||||
{
|
||||
int id = OreDictionary.getOreIDs(stk)[i];
|
||||
if(id != -1)
|
||||
{
|
||||
String ore = OreDictionary.getOreName(id);
|
||||
if(ore != null && ! ore.isEmpty())
|
||||
{
|
||||
flag = ore.contains("dirt") || ore.contains("grass") || ore.contains("sand") || ore.contains("gravel") || ore.contains("stone");
|
||||
if(flag)
|
||||
break OreDict;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(flag)
|
||||
{
|
||||
double random = rnd.nextDouble();
|
||||
Block setTo = random <= 0.9D ? Blocks.end_stone : Blocks.obsidian;
|
||||
w.setBlock(x, y, z, setTo, 0, 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd) {
|
||||
super.updateTick(w, x, y, z, rnd);
|
||||
if (w.getBlockMetadata(x, y, z) % 8 == 1) {
|
||||
if (rnd.nextDouble() > 0.03D) return;
|
||||
|
||||
int dy = y;
|
||||
BiomeGenBase base = w.getBiomeGenForCoords(x, z);
|
||||
if (base != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SpawnListEntry> l = base.getSpawnableList(EnumCreatureType.creature);
|
||||
if (l != null && !l.isEmpty()) {
|
||||
SpawnListEntry entry = l.get(rnd.nextInt(l.size()));
|
||||
if (entry != null && entry.entityClass != null) {
|
||||
Class<?> c = entry.entityClass;
|
||||
if (EntityLiving.class.isAssignableFrom(c)) {
|
||||
try {
|
||||
EntityLiving el = EntityLiving.class.cast(
|
||||
c.getConstructor(World.class).newInstance(w));
|
||||
while (--y >= dy - 6) {
|
||||
el.setPositionAndRotation(x + 0.5D, y, z + 0.5D, 0, 0);
|
||||
if (el.getCanSpawnHere()) {
|
||||
w.spawnEntityInWorld(el);
|
||||
break;
|
||||
} else continue;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FMLLog.warning(
|
||||
"[TB]Tried to create an entity of class " + c
|
||||
+ " but failed! The exception is listed below:",
|
||||
new Object[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (w.getBlockMetadata(x, y, z) % 8 == 2) {
|
||||
int dy = y;
|
||||
while (--y >= dy - 8) {
|
||||
Block b = w.getBlock(x, y, z);
|
||||
if (!b.isAir(w, x, y, z)) {
|
||||
boolean netheric =
|
||||
b instanceof BlockNetherrack || b instanceof BlockSoulSand || b == Blocks.quartz_ore;
|
||||
if (netheric && rnd.nextDouble() <= 0.05D) {
|
||||
BiomeGenBase hellBiome = BiomeGenBase.hell;
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SpawnListEntry> l = rnd.nextBoolean()
|
||||
? hellBiome.getSpawnableList(EnumCreatureType.creature)
|
||||
: hellBiome.getSpawnableList(EnumCreatureType.monster);
|
||||
if (l != null && !l.isEmpty()) {
|
||||
SpawnListEntry entry = l.get(rnd.nextInt(l.size()));
|
||||
if (entry != null && entry.entityClass != null) {
|
||||
Class<?> c = entry.entityClass;
|
||||
if (EntityLiving.class.isAssignableFrom(c)) {
|
||||
try {
|
||||
EntityLiving el = EntityLiving.class.cast(
|
||||
c.getConstructor(World.class).newInstance(w));
|
||||
|
||||
el.setPositionAndRotation(x + 0.5D, y + 1, z + 0.5D, 0, 0);
|
||||
el.onSpawnWithEgg(null);
|
||||
|
||||
if (el.getCanSpawnHere()) {
|
||||
w.spawnEntityInWorld(el);
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
FMLLog.warning(
|
||||
"[TB]Tried to create an entity of class " + c
|
||||
+ " but failed! The exception is listed below:",
|
||||
new Object[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
boolean flag = b instanceof BlockDirt
|
||||
|| b instanceof BlockGrass
|
||||
|| b instanceof BlockGravel
|
||||
|| b instanceof BlockSand
|
||||
|| b instanceof BlockStone;
|
||||
if (!flag) {
|
||||
ItemStack stk = new ItemStack(b, 1, w.getBlockMetadata(x, y, z));
|
||||
if (OreDictionary.getOreIDs(stk) != null && OreDictionary.getOreIDs(stk).length > 0) {
|
||||
OreDict:
|
||||
for (int i = 0; i < OreDictionary.getOreIDs(stk).length; ++i) {
|
||||
int id = OreDictionary.getOreIDs(stk)[i];
|
||||
if (id != -1) {
|
||||
String ore = OreDictionary.getOreName(id);
|
||||
if (ore != null && !ore.isEmpty()) {
|
||||
flag = ore.contains("dirt")
|
||||
|| ore.contains("grass")
|
||||
|| ore.contains("sand")
|
||||
|| ore.contains("gravel")
|
||||
|| ore.contains("stone");
|
||||
if (flag) break OreDict;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
double random = rnd.nextDouble();
|
||||
Block setTo = random <= 0.6D
|
||||
? Blocks.netherrack
|
||||
: random <= 0.9D ? Blocks.soul_sand : Blocks.quartz_ore;
|
||||
w.setBlock(x, y, z, setTo, 0, 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (w.getBlockMetadata(x, y, z) % 8 == 3) {
|
||||
int dy = y;
|
||||
while (--y >= dy - 11) {
|
||||
Block b = w.getBlock(x, y, z);
|
||||
if (!b.isAir(w, x, y, z)) {
|
||||
boolean end = b == Blocks.end_stone || b instanceof BlockObsidian;
|
||||
if (end && rnd.nextDouble() <= 0.02D) {
|
||||
BiomeGenBase hellBiome = BiomeGenBase.sky;
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SpawnListEntry> l = rnd.nextBoolean()
|
||||
? hellBiome.getSpawnableList(EnumCreatureType.creature)
|
||||
: hellBiome.getSpawnableList(EnumCreatureType.monster);
|
||||
if (l != null && !l.isEmpty()) {
|
||||
SpawnListEntry entry = l.get(rnd.nextInt(l.size()));
|
||||
if (entry != null && entry.entityClass != null) {
|
||||
Class<?> c = entry.entityClass;
|
||||
if (EntityLiving.class.isAssignableFrom(c)) {
|
||||
try {
|
||||
EntityLiving el = EntityLiving.class.cast(
|
||||
c.getConstructor(World.class).newInstance(w));
|
||||
|
||||
el.setPositionAndRotation(x + 0.5D, y + 1, z + 0.5D, 0, 0);
|
||||
el.onSpawnWithEgg(null);
|
||||
|
||||
if (w.isAirBlock(x, y + 1, z)) {
|
||||
w.spawnEntityInWorld(el);
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
FMLLog.warning(
|
||||
"[TB]Tried to create an entity of class " + c
|
||||
+ " but failed! The exception is listed below:",
|
||||
new Object[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
boolean flag = b instanceof BlockDirt
|
||||
|| b instanceof BlockGrass
|
||||
|| b instanceof BlockGravel
|
||||
|| b instanceof BlockSand
|
||||
|| b instanceof BlockStone && !(b instanceof BlockObsidian) && !(b == Blocks.end_stone);
|
||||
if (!flag) {
|
||||
ItemStack stk = new ItemStack(b, 1, w.getBlockMetadata(x, y, z));
|
||||
if (OreDictionary.getOreIDs(stk) != null && OreDictionary.getOreIDs(stk).length > 0) {
|
||||
OreDict:
|
||||
for (int i = 0; i < OreDictionary.getOreIDs(stk).length; ++i) {
|
||||
int id = OreDictionary.getOreIDs(stk)[i];
|
||||
if (id != -1) {
|
||||
String ore = OreDictionary.getOreName(id);
|
||||
if (ore != null && !ore.isEmpty()) {
|
||||
flag = ore.contains("dirt")
|
||||
|| ore.contains("grass")
|
||||
|| ore.contains("sand")
|
||||
|| ore.contains("gravel")
|
||||
|| ore.contains("stone");
|
||||
if (flag) break OreDict;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
double random = rnd.nextDouble();
|
||||
Block setTo = random <= 0.9D ? Blocks.end_stone : Blocks.obsidian;
|
||||
w.setBlock(x, y, z, setTo, 0, 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_)
|
||||
{
|
||||
return 0xffffff;
|
||||
public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) {
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
//getSaplingDropRate
|
||||
protected int func_150123_b(int meta)
|
||||
{
|
||||
|
||||
// getSaplingDropRate
|
||||
protected int func_150123_b(int meta) {
|
||||
return meta == 0 ? 50 : 30;
|
||||
}
|
||||
|
||||
//dropRareItem
|
||||
protected void func_150124_c(World w, int x, int y, int z, int meta, int chance)
|
||||
{
|
||||
if (meta == 0 && w.rand.nextInt(chance) == 0)
|
||||
{
|
||||
|
||||
// dropRareItem
|
||||
protected void func_150124_c(World w, int x, int y, int z, int meta, int chance) {
|
||||
if (meta == 0 && w.rand.nextInt(chance) == 0) {
|
||||
this.dropBlockAsItem(w, x, y, z, new ItemStack(Items.golden_apple, 1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
return icons[meta % 8];
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return icons[meta % 8];
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item i, CreativeTabs p_149666_2_, List p_149666_3_)
|
||||
{
|
||||
for(int f = 0; f < names.length; ++f)
|
||||
p_149666_3_.add(new ItemStack(i,1,f));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
for(int i = 0; i < icons.length; ++i)
|
||||
icons[i] = reg.registerIcon(TBCore.modid+":"+textures[i]);
|
||||
|
||||
blockIcon = reg.registerIcon(getTextureName());
|
||||
public void getSubBlocks(Item i, CreativeTabs p_149666_2_, List p_149666_3_) {
|
||||
for (int f = 0; f < names.length; ++f) p_149666_3_.add(new ItemStack(i, 1, f));
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
for (int i = 0; i < icons.length; ++i) icons[i] = reg.registerIcon(TBCore.modid + ":" + textures[i]);
|
||||
|
||||
blockIcon = reg.registerIcon(getTextureName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%8 == 1)
|
||||
return new ArrayList<ItemStack>();
|
||||
else
|
||||
return super.onSheared(item, world, x, y, z, fortune);
|
||||
public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) {
|
||||
if (world.getBlockMetadata(x, y, z) % 8 == 1) return new ArrayList<ItemStack>();
|
||||
else return super.onSheared(item, world, x, y, z, fortune);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tb.core.TBCore;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.BlockOldLog;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -16,87 +14,63 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tb.core.TBCore;
|
||||
|
||||
public class BlockTBLog extends BlockOldLog{
|
||||
|
||||
public static final String[] names = new String[]{
|
||||
"peacefullTreeLog",
|
||||
"netherTreeLog",
|
||||
"enderTreeLog"
|
||||
};
|
||||
|
||||
public static final String[] textures = new String[]{
|
||||
"peacefullTree/log",
|
||||
"netherTree/log",
|
||||
"enderTree/log"
|
||||
};
|
||||
|
||||
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%4==2)
|
||||
if(entity instanceof EntityDragon)
|
||||
return false;
|
||||
|
||||
return super.canEntityDestroy(world, x, y, z, entity);
|
||||
public class BlockTBLog extends BlockOldLog {
|
||||
|
||||
public static final String[] names = new String[] {"peacefullTreeLog", "netherTreeLog", "enderTreeLog"};
|
||||
|
||||
public static final String[] textures = new String[] {"peacefullTree/log", "netherTree/log", "enderTree/log"};
|
||||
|
||||
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
|
||||
if (world.getBlockMetadata(x, y, z) % 4 == 2) if (entity instanceof EntityDragon) return false;
|
||||
|
||||
return super.canEntityDestroy(world, x, y, z, entity);
|
||||
}
|
||||
|
||||
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%4==1)
|
||||
return true;
|
||||
|
||||
return super.isFlammable(world, x, y, z, face);
|
||||
|
||||
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
||||
if (world.getBlockMetadata(x, y, z) % 4 == 1) return true;
|
||||
|
||||
return super.isFlammable(world, x, y, z, face);
|
||||
}
|
||||
|
||||
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%4==1)
|
||||
return 0;
|
||||
|
||||
return super.getFlammability(world, x, y, z, face);
|
||||
|
||||
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
||||
if (world.getBlockMetadata(x, y, z) % 4 == 1) return 0;
|
||||
|
||||
return super.getFlammability(world, x, y, z, face);
|
||||
}
|
||||
|
||||
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%4==1)
|
||||
return 0;
|
||||
|
||||
return super.getFlammability(world, x, y, z, face);
|
||||
|
||||
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
|
||||
if (world.getBlockMetadata(x, y, z) % 4 == 1) return 0;
|
||||
|
||||
return super.getFlammability(world, x, y, z, face);
|
||||
}
|
||||
|
||||
public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
if(world.getBlockMetadata(x, y, z)%4==1)
|
||||
return true;
|
||||
|
||||
return super.isFireSource(world, x, y, z, side);
|
||||
|
||||
public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) {
|
||||
if (world.getBlockMetadata(x, y, z) % 4 == 1) return true;
|
||||
|
||||
return super.isFireSource(world, x, y, z, side);
|
||||
}
|
||||
|
||||
public BlockTBLog()
|
||||
{
|
||||
super();
|
||||
this.setHarvestLevel("axe", 0);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item itm, CreativeTabs tab, List lst)
|
||||
{
|
||||
for(int i = 0; i < names.length; ++i)
|
||||
lst.add(new ItemStack(itm,1,i));
|
||||
|
||||
public BlockTBLog() {
|
||||
super();
|
||||
this.setHarvestLevel("axe", 0);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
public void getSubBlocks(Item itm, CreativeTabs tab, List lst) {
|
||||
for (int i = 0; i < names.length; ++i) lst.add(new ItemStack(itm, 1, i));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
this.field_150167_a = new IIcon[textures.length];
|
||||
this.field_150166_b = new IIcon[textures.length];
|
||||
|
||||
for (int i = 0; i < textures.length; ++i)
|
||||
{
|
||||
this.field_150167_a[i] = reg.registerIcon(TBCore.modid+":"+textures[i]);
|
||||
this.field_150166_b[i] = reg.registerIcon(TBCore.modid+":"+textures[i] + "_top");
|
||||
for (int i = 0; i < textures.length; ++i) {
|
||||
this.field_150167_a[i] = reg.registerIcon(TBCore.modid + ":" + textures[i]);
|
||||
this.field_150166_b[i] = reg.registerIcon(TBCore.modid + ":" + textures[i] + "_top");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,15 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBush;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -19,74 +17,62 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockTBPlant extends BlockBush implements IGrowable
|
||||
{
|
||||
|
||||
public int growthStages;
|
||||
public int growthDelay;
|
||||
public boolean requiresFarmland;
|
||||
public IIcon[] growthIcons;
|
||||
public ItemStack dropItem;
|
||||
public ItemStack dropSeed;
|
||||
public class BlockTBPlant extends BlockBush implements IGrowable {
|
||||
|
||||
public BlockTBPlant(int stages, int delay, boolean isCrop)
|
||||
{
|
||||
super();
|
||||
growthStages = stages;
|
||||
growthDelay = delay;
|
||||
requiresFarmland = isCrop;
|
||||
public int growthStages;
|
||||
public int growthDelay;
|
||||
public boolean requiresFarmland;
|
||||
public IIcon[] growthIcons;
|
||||
public ItemStack dropItem;
|
||||
public ItemStack dropSeed;
|
||||
|
||||
public BlockTBPlant(int stages, int delay, boolean isCrop) {
|
||||
super();
|
||||
growthStages = stages;
|
||||
growthDelay = delay;
|
||||
requiresFarmland = isCrop;
|
||||
this.setTickRandomly(true);
|
||||
float f = 0.5F;
|
||||
if(isCrop)
|
||||
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
|
||||
else
|
||||
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.75F, 0.75F);
|
||||
|
||||
if (isCrop) this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
|
||||
else this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.75F, 0.75F);
|
||||
|
||||
this.setHardness(0.0F);
|
||||
this.setStepSound(soundTypeGrass);
|
||||
this.disableStats();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World w, int x, int y, int z)
|
||||
{
|
||||
public Item getItem(World w, int x, int y, int z) {
|
||||
return dropSeed != null ? dropSeed.getItem() : Item.getItemFromBlock(this);
|
||||
}
|
||||
|
||||
protected boolean canPlaceBlockOn(Block b)
|
||||
{
|
||||
|
||||
protected boolean canPlaceBlockOn(Block b) {
|
||||
return requiresFarmland ? b == Blocks.farmland : true;
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd) {
|
||||
super.updateTick(w, x, y, z, rnd);
|
||||
|
||||
if (w.getBlockLightValue(x, y + 1, z) >= 9)
|
||||
{
|
||||
if (w.getBlockLightValue(x, y + 1, z) >= 9) {
|
||||
int l = w.getBlockMetadata(x, y, z);
|
||||
|
||||
if (l < growthStages)
|
||||
{
|
||||
if (l < growthStages) {
|
||||
float f = this.calculateGrowth(w, x, y, z);
|
||||
|
||||
if (rnd.nextInt((int)((float)growthDelay / f) + 1) == 0)
|
||||
{
|
||||
if (rnd.nextInt((int) ((float) growthDelay / f) + 1) == 0) {
|
||||
++l;
|
||||
w.setBlockMetadataWithNotify(x, y, z, l, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return this.requiresFarmland ? EnumPlantType.Crop : EnumPlantType.Plains;
|
||||
public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) {
|
||||
return this.requiresFarmland ? EnumPlantType.Crop : EnumPlantType.Plains;
|
||||
}
|
||||
|
||||
private float calculateGrowth(World w, int x, int y, int z)
|
||||
{
|
||||
|
||||
private float calculateGrowth(World w, int x, int y, int z) {
|
||||
float f = 1.0F;
|
||||
Block block = w.getBlock(x, y, z - 1);
|
||||
Block block1 = w.getBlock(x, y, z + 1);
|
||||
@@ -100,24 +86,19 @@ public class BlockTBPlant extends BlockBush implements IGrowable
|
||||
boolean flag1 = block == this || block1 == this;
|
||||
boolean flag2 = block4 == this || block5 == this || block6 == this || block7 == this;
|
||||
|
||||
for (int l = x - 1; l <= x + 1; ++l)
|
||||
{
|
||||
for (int i1 = z - 1; i1 <= z + 1; ++i1)
|
||||
{
|
||||
for (int l = x - 1; l <= x + 1; ++l) {
|
||||
for (int i1 = z - 1; i1 <= z + 1; ++i1) {
|
||||
float f1 = 0.0F;
|
||||
|
||||
if (w.getBlock(l, y - 1, i1).canSustainPlant(w, l, y - 1, i1, ForgeDirection.UP, this))
|
||||
{
|
||||
if (w.getBlock(l, y - 1, i1).canSustainPlant(w, l, y - 1, i1, ForgeDirection.UP, this)) {
|
||||
f1 = 1.0F;
|
||||
|
||||
if (w.getBlock(l, y - 1, i1).isFertile(w, l, y - 1, i1))
|
||||
{
|
||||
if (w.getBlock(l, y - 1, i1).isFertile(w, l, y - 1, i1)) {
|
||||
f1 = 3.0F;
|
||||
}
|
||||
}
|
||||
|
||||
if (l != x || i1 != z)
|
||||
{
|
||||
if (l != x || i1 != z) {
|
||||
f1 /= 4.0F;
|
||||
}
|
||||
|
||||
@@ -125,73 +106,61 @@ public class BlockTBPlant extends BlockBush implements IGrowable
|
||||
}
|
||||
}
|
||||
|
||||
if (flag2 || flag && flag1)
|
||||
{
|
||||
if (flag2 || flag && flag1) {
|
||||
f /= 2.0F;
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
//canApplyBonemeal
|
||||
@Override
|
||||
public boolean func_149851_a(World w, int x,int y, int z, boolean remote) {
|
||||
return w.getBlockMetadata(x, y, z) < growthStages-1;
|
||||
}
|
||||
|
||||
//canGrowPlant
|
||||
@Override
|
||||
public boolean func_149852_a(World w, Random r, int x, int y, int z) {
|
||||
return w.getBlockLightValue(x, y + 1, z) >= 9;
|
||||
}
|
||||
// canApplyBonemeal
|
||||
@Override
|
||||
public boolean func_149851_a(World w, int x, int y, int z, boolean remote) {
|
||||
return w.getBlockMetadata(x, y, z) < growthStages - 1;
|
||||
}
|
||||
|
||||
//growPlant
|
||||
@Override
|
||||
public void func_149853_b(World w, Random r,int x, int y, int z)
|
||||
{
|
||||
w.setBlockMetadataWithNotify(x, y, z, Math.min(growthStages-1, w.getBlockMetadata(x, y, z)+r.nextInt(3)+1), 3);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
growthIcons = new IIcon[growthStages];
|
||||
for(int i = 0; i < growthStages; ++i)
|
||||
growthIcons[i] = reg.registerIcon(textureName+"stage_"+i);
|
||||
// canGrowPlant
|
||||
@Override
|
||||
public boolean func_149852_a(World w, Random r, int x, int y, int z) {
|
||||
return w.getBlockLightValue(x, y + 1, z) >= 9;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
return growthIcons[meta >= growthIcons.length ? growthIcons.length-1 : meta];
|
||||
|
||||
// growPlant
|
||||
@Override
|
||||
public void func_149853_b(World w, Random r, int x, int y, int z) {
|
||||
w.setBlockMetadataWithNotify(
|
||||
x, y, z, Math.min(growthStages - 1, w.getBlockMetadata(x, y, z) + r.nextInt(3) + 1), 3);
|
||||
}
|
||||
|
||||
public int getRenderType()
|
||||
{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
growthIcons = new IIcon[growthStages];
|
||||
for (int i = 0; i < growthStages; ++i) growthIcons[i] = reg.registerIcon(textureName + "stage_" + i);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return growthIcons[meta >= growthIcons.length ? growthIcons.length - 1 : meta];
|
||||
}
|
||||
|
||||
public int getRenderType() {
|
||||
return requiresFarmland ? 6 : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
||||
{
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
if (metadata >= growthStages-1)
|
||||
{
|
||||
for (int i = 0; i < 1 + world.rand.nextInt(fortune+1); ++i) //Change for the resource drop
|
||||
if (metadata >= growthStages - 1) {
|
||||
for (int i = 0; i < 1 + world.rand.nextInt(fortune + 1); ++i) // Change for the resource drop
|
||||
{
|
||||
if (world.rand.nextInt(growthStages) <= metadata)
|
||||
{
|
||||
if(dropItem != null)
|
||||
ret.add(dropItem.copy());
|
||||
if (world.rand.nextInt(growthStages) <= metadata) {
|
||||
if (dropItem != null) ret.add(dropItem.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(dropSeed != null)
|
||||
ret.add(dropSeed.copy());
|
||||
if (dropSeed != null) ret.add(dropSeed.copy());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import tb.common.event.WorldGenBigOak;
|
||||
import tb.common.event.WorldGenOak;
|
||||
import tb.init.TBBlocks;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -16,92 +12,73 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tb.common.event.WorldGenBigOak;
|
||||
import tb.common.event.WorldGenOak;
|
||||
import tb.init.TBBlocks;
|
||||
|
||||
public class BlockTBSapling extends BlockSapling{
|
||||
public class BlockTBSapling extends BlockSapling {
|
||||
|
||||
public IIcon[] icons = new IIcon[8];
|
||||
public static final String[] names =
|
||||
new String[] {"goldenOakSapling", "peacefullTreeSapling", "netherTreeSapling", "enderTreeSapling"};
|
||||
|
||||
public static final String[] textures = new String[] {
|
||||
"thaumicbases:goldenOak/sapling",
|
||||
"thaumicbases:peacefullTree/sapling",
|
||||
"thaumicbases:netherTree/sapling",
|
||||
"thaumicbases:enderTree/sapling"
|
||||
};
|
||||
|
||||
public IIcon[] icons = new IIcon[8];
|
||||
public static final String[] names = new String[]{
|
||||
"goldenOakSapling",
|
||||
"peacefullTreeSapling",
|
||||
"netherTreeSapling",
|
||||
"enderTreeSapling"
|
||||
};
|
||||
|
||||
public static final String[] textures = new String[]{
|
||||
"thaumicbases:goldenOak/sapling",
|
||||
"thaumicbases:peacefullTree/sapling",
|
||||
"thaumicbases:netherTree/sapling",
|
||||
"thaumicbases:enderTree/sapling"
|
||||
};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
return icons[meta%8];
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return icons[meta % 8];
|
||||
}
|
||||
|
||||
//doGrowTree
|
||||
public void func_149878_d(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
int meta = w.getBlockMetadata(x, y, z)%8;
|
||||
if(w.getBlockMetadata(x, y, z)%8 == 0)
|
||||
{
|
||||
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(w, rnd, x, y, z))
|
||||
return;
|
||||
|
||||
w.setBlockToAir(x, y, z);
|
||||
|
||||
new WorldGenOak(true, 5, 0, 0, false, Blocks.log, TBBlocks.genLeaves).generate(w, rnd, x, y, z);
|
||||
}
|
||||
if(w.getBlockMetadata(x, y, z)%8 == 1)
|
||||
{
|
||||
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(w, rnd, x, y, z))
|
||||
return;
|
||||
|
||||
w.setBlockToAir(x, y, z);
|
||||
|
||||
new WorldGenOak(true, 6, 0, 1, false, TBBlocks.genLogs, TBBlocks.genLeaves).generate(w, rnd, x, y, z);
|
||||
}
|
||||
if(w.getBlockMetadata(x, y, z)%8 == 2)
|
||||
{
|
||||
WorldGenBigOak tree = new WorldGenBigOak(true,6,1,2,1,TBBlocks.genLogs,TBBlocks.genLeaves);
|
||||
|
||||
w.setBlockToAir(x, y, z);
|
||||
|
||||
if(!tree.generate(w, rnd, x, y, z))
|
||||
w.setBlock(x, y, z, this, meta, 4);
|
||||
}
|
||||
if(w.getBlockMetadata(x, y, z)%8 == 3)
|
||||
{
|
||||
WorldGenBigOak tree = new WorldGenBigOak(true,4,2,3,3,TBBlocks.genLogs,TBBlocks.genLeaves);
|
||||
|
||||
w.setBlockToAir(x, y, z);
|
||||
|
||||
if(!tree.generate(w, rnd, x, y, z))
|
||||
w.setBlock(x, y, z, this, meta, 4);
|
||||
}
|
||||
|
||||
// doGrowTree
|
||||
public void func_149878_d(World w, int x, int y, int z, Random rnd) {
|
||||
int meta = w.getBlockMetadata(x, y, z) % 8;
|
||||
if (w.getBlockMetadata(x, y, z) % 8 == 0) {
|
||||
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(w, rnd, x, y, z)) return;
|
||||
|
||||
w.setBlockToAir(x, y, z);
|
||||
|
||||
new WorldGenOak(true, 5, 0, 0, false, Blocks.log, TBBlocks.genLeaves).generate(w, rnd, x, y, z);
|
||||
}
|
||||
if (w.getBlockMetadata(x, y, z) % 8 == 1) {
|
||||
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(w, rnd, x, y, z)) return;
|
||||
|
||||
w.setBlockToAir(x, y, z);
|
||||
|
||||
new WorldGenOak(true, 6, 0, 1, false, TBBlocks.genLogs, TBBlocks.genLeaves).generate(w, rnd, x, y, z);
|
||||
}
|
||||
if (w.getBlockMetadata(x, y, z) % 8 == 2) {
|
||||
WorldGenBigOak tree = new WorldGenBigOak(true, 6, 1, 2, 1, TBBlocks.genLogs, TBBlocks.genLeaves);
|
||||
|
||||
w.setBlockToAir(x, y, z);
|
||||
|
||||
if (!tree.generate(w, rnd, x, y, z)) w.setBlock(x, y, z, this, meta, 4);
|
||||
}
|
||||
if (w.getBlockMetadata(x, y, z) % 8 == 3) {
|
||||
WorldGenBigOak tree = new WorldGenBigOak(true, 4, 2, 3, 3, TBBlocks.genLogs, TBBlocks.genLeaves);
|
||||
|
||||
w.setBlockToAir(x, y, z);
|
||||
|
||||
if (!tree.generate(w, rnd, x, y, z)) w.setBlock(x, y, z, this, meta, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public int damageDropped(int meta)
|
||||
{
|
||||
return meta%8;
|
||||
|
||||
public int damageDropped(int meta) {
|
||||
return meta % 8;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_)
|
||||
{
|
||||
for(int i = 0; i < names.length; ++i)
|
||||
p_149666_3_.add(new ItemStack(p_149666_1_, 1, i));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
for(int i = 0; i < names.length; ++i)
|
||||
icons[i] = reg.registerIcon(textures[i]);
|
||||
public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) {
|
||||
for (int i = 0; i < names.length; ++i) p_149666_3_.add(new ItemStack(p_149666_1_, 1, i));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
for (int i = 0; i < names.length; ++i) icons[i] = reg.registerIcon(textures[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package tb.common.block;
|
||||
|
||||
import tb.core.TBCore;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.BlockAnvil;
|
||||
@@ -9,55 +7,48 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tb.core.TBCore;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
|
||||
public class BlockThaumicAnvil extends BlockAnvil implements IInfusionStabiliser {
|
||||
|
||||
public class BlockThaumicAnvil extends BlockAnvil implements IInfusionStabiliser
|
||||
{
|
||||
|
||||
public static final String[] anvilDamageNames = new String[] {"intact", "slightlyDamaged", "veryDamaged"};
|
||||
private static final String[] anvilIconNames = new String[] {"top_damaged_0", "top_damaged_1", "top_damaged_2"};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] anvilIcons;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_)
|
||||
{
|
||||
if (this.anvilRenderSide == 3 && p_149691_1_ == 1)
|
||||
{
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
|
||||
if (this.anvilRenderSide == 3 && p_149691_1_ == 1) {
|
||||
int k = (p_149691_2_ >> 2) % this.anvilIcons.length;
|
||||
return this.anvilIcons[k];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return this.blockIcon;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister p_149651_1_)
|
||||
{
|
||||
this.blockIcon = p_149651_1_.registerIcon(this.getTextureName()+"base");
|
||||
public void registerBlockIcons(IIconRegister p_149651_1_) {
|
||||
this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "base");
|
||||
this.anvilIcons = new IIcon[anvilIconNames.length];
|
||||
|
||||
for (int i = 0; i < this.anvilIcons.length; ++i)
|
||||
{
|
||||
this.anvilIcons[i] = p_149651_1_.registerIcon(this.getTextureName()+anvilIconNames[i]);
|
||||
for (int i = 0; i < this.anvilIcons.length; ++i) {
|
||||
this.anvilIcons[i] = p_149651_1_.registerIcon(this.getTextureName() + anvilIconNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ)
|
||||
{
|
||||
if(w.isRemote)
|
||||
return true;
|
||||
|
||||
p.openGui(TBCore.instance, 0x421921, w, x, y, z);
|
||||
|
||||
return true;
|
||||
|
||||
public boolean onBlockActivated(
|
||||
World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ) {
|
||||
if (w.isRemote) return true;
|
||||
|
||||
p.openGui(TBCore.instance, 0x421921, w, x, y, z);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World w, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World w, int x,int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +1,31 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
|
||||
public class BlockVoid extends Block implements IInfusionStabiliser{
|
||||
public class BlockVoid extends Block implements IInfusionStabiliser {
|
||||
|
||||
public BlockVoid()
|
||||
{
|
||||
super(Material.iron);
|
||||
this.setTickRandomly(true);
|
||||
this.setHardness(5);
|
||||
this.setResistance(Float.MAX_VALUE);
|
||||
this.setHarvestLevel("pickaxe", 3);
|
||||
this.setBlockTextureName("thaumicbases:voidblock");
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
Thaumcraft.proxy.sparkle(x+r.nextFloat(), y+r.nextFloat(), z+r.nextFloat(), 2, 5, -0.1F);
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
|
||||
public BlockVoid() {
|
||||
super(Material.iron);
|
||||
this.setTickRandomly(true);
|
||||
this.setHardness(5);
|
||||
this.setResistance(Float.MAX_VALUE);
|
||||
this.setHarvestLevel("pickaxe", 3);
|
||||
this.setBlockTextureName("thaumicbases:voidblock");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World w, int x,int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r) {
|
||||
Thaumcraft.proxy.sparkle(x + r.nextFloat(), y + r.nextFloat(), z + r.nextFloat(), 2, 5, -0.1F);
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd) {}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World w, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,92 +1,78 @@
|
||||
package tb.common.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import tb.core.TBCore;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockAnvil;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import tb.core.TBCore;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
|
||||
public class BlockVoidAnvil extends BlockAnvil implements IInfusionStabiliser {
|
||||
|
||||
public class BlockVoidAnvil extends BlockAnvil implements IInfusionStabiliser
|
||||
{
|
||||
|
||||
public static final String[] anvilDamageNames = new String[] {"intact", "slightlyDamaged", "veryDamaged"};
|
||||
private static final String[] anvilIconNames = new String[] {"top_damaged_0", "top_damaged_1", "top_damaged_2"};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] anvilIcons;
|
||||
|
||||
public BlockVoidAnvil()
|
||||
{
|
||||
super();
|
||||
this.setHardness(12);
|
||||
this.setResistance(Float.MAX_VALUE);
|
||||
this.setTickRandomly(true);
|
||||
this.setStepSound(Block.soundTypeAnvil);
|
||||
this.setHarvestLevel("pickaxe", 3);
|
||||
public BlockVoidAnvil() {
|
||||
super();
|
||||
this.setHardness(12);
|
||||
this.setResistance(Float.MAX_VALUE);
|
||||
this.setTickRandomly(true);
|
||||
this.setStepSound(Block.soundTypeAnvil);
|
||||
this.setHarvestLevel("pickaxe", 3);
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd)
|
||||
{
|
||||
super.updateTick(w, x, y, z, rnd);
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if(meta / 4 > 0)
|
||||
{
|
||||
w.setBlockMetadataWithNotify(x, y, z, w.getBlockMetadata(x, y, z)-4, 3);
|
||||
}
|
||||
|
||||
public void updateTick(World w, int x, int y, int z, Random rnd) {
|
||||
super.updateTick(w, x, y, z, rnd);
|
||||
int meta = w.getBlockMetadata(x, y, z);
|
||||
if (meta / 4 > 0) {
|
||||
w.setBlockMetadataWithNotify(x, y, z, w.getBlockMetadata(x, y, z) - 4, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
Thaumcraft.proxy.sparkle(x+r.nextFloat(), y+r.nextFloat(), z+r.nextFloat(), 2, 5, -0.1F);
|
||||
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r) {
|
||||
Thaumcraft.proxy.sparkle(x + r.nextFloat(), y + r.nextFloat(), z + r.nextFloat(), 2, 5, -0.1F);
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_)
|
||||
{
|
||||
if (this.anvilRenderSide == 3 && p_149691_1_ == 1)
|
||||
{
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
|
||||
if (this.anvilRenderSide == 3 && p_149691_1_ == 1) {
|
||||
int k = (p_149691_2_ >> 2) % this.anvilIcons.length;
|
||||
return this.anvilIcons[k];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return this.blockIcon;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister p_149651_1_)
|
||||
{
|
||||
this.blockIcon = p_149651_1_.registerIcon(this.getTextureName()+"base");
|
||||
public void registerBlockIcons(IIconRegister p_149651_1_) {
|
||||
this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "base");
|
||||
this.anvilIcons = new IIcon[anvilIconNames.length];
|
||||
|
||||
for (int i = 0; i < this.anvilIcons.length; ++i)
|
||||
{
|
||||
this.anvilIcons[i] = p_149651_1_.registerIcon(this.getTextureName()+anvilIconNames[i]);
|
||||
for (int i = 0; i < this.anvilIcons.length; ++i) {
|
||||
this.anvilIcons[i] = p_149651_1_.registerIcon(this.getTextureName() + anvilIconNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ)
|
||||
{
|
||||
if(w.isRemote)
|
||||
return true;
|
||||
|
||||
p.openGui(TBCore.instance, 0x421920, w, x, y, z);
|
||||
|
||||
return true;
|
||||
|
||||
public boolean onBlockActivated(
|
||||
World w, int x, int y, int z, EntityPlayer p, int side, float vecX, float vecY, float vecZ) {
|
||||
if (w.isRemote) return true;
|
||||
|
||||
p.openGui(TBCore.instance, 0x421920, w, x, y, z);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World w, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World w, int x,int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package tb.common.block;
|
||||
|
||||
import tb.init.TBBlocks;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -10,50 +8,45 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tb.init.TBBlocks;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
|
||||
public class TBBlock extends Block implements IInfusionStabiliser{
|
||||
|
||||
boolean isGlass;
|
||||
boolean stabilise;
|
||||
|
||||
public TBBlock(Material m,boolean b)
|
||||
{
|
||||
super(m);
|
||||
isGlass = b;
|
||||
}
|
||||
|
||||
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if(entity instanceof EntityDragon)
|
||||
return this != TBBlocks.enderPlanks;
|
||||
|
||||
return super.canEntityDestroy(world, x, y, z, entity);
|
||||
public class TBBlock extends Block implements IInfusionStabiliser {
|
||||
|
||||
boolean isGlass;
|
||||
boolean stabilise;
|
||||
|
||||
public TBBlock(Material m, boolean b) {
|
||||
super(m);
|
||||
isGlass = b;
|
||||
}
|
||||
|
||||
public Block stabilise()
|
||||
{
|
||||
stabilise = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
|
||||
if (entity instanceof EntityDragon) return this != TBBlocks.enderPlanks;
|
||||
|
||||
return super.canEntityDestroy(world, x, y, z, entity);
|
||||
}
|
||||
|
||||
public Block stabilise() {
|
||||
stabilise = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return !isGlass;
|
||||
}
|
||||
|
||||
public int getLightOpacity()
|
||||
{
|
||||
|
||||
public int getLightOpacity() {
|
||||
return isGlass ? 7 : 15;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
public int getRenderBlockPass() {
|
||||
return isGlass ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World world, int x, int y, int z) {
|
||||
return stabilise;
|
||||
}
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World world, int x, int y, int z) {
|
||||
return stabilise;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package tb.common.block;
|
||||
|
||||
import tb.init.TBBlocks;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -10,40 +8,39 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import tb.init.TBBlocks;
|
||||
import thaumcraft.api.crafting.IInfusionStabiliser;
|
||||
|
||||
public class TBBlockDeco extends Block {
|
||||
|
||||
boolean isGlass;
|
||||
|
||||
public TBBlockDeco(Material m,boolean b)
|
||||
{
|
||||
super(m);
|
||||
isGlass = b;
|
||||
}
|
||||
|
||||
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if(entity instanceof EntityDragon)
|
||||
return this != TBBlocks.enderPlanks;
|
||||
|
||||
return super.canEntityDestroy(world, x, y, z, entity);
|
||||
public class TBBlockDeco extends Block implements IInfusionStabiliser {
|
||||
|
||||
boolean isGlass;
|
||||
|
||||
public TBBlockDeco(Material m, boolean b) {
|
||||
super(m);
|
||||
isGlass = b;
|
||||
}
|
||||
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
|
||||
if (entity instanceof EntityDragon) return this != TBBlocks.enderPlanks;
|
||||
|
||||
return super.canEntityDestroy(world, x, y, z, entity);
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return !isGlass;
|
||||
}
|
||||
|
||||
public int getLightOpacity()
|
||||
{
|
||||
|
||||
public int getLightOpacity() {
|
||||
return isGlass ? 7 : 15;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
public int getRenderBlockPass() {
|
||||
return isGlass ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStabaliseInfusion(World var1, int var2, int var3, int var4) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,22 +8,20 @@ import net.minecraft.util.IIcon;
|
||||
|
||||
public class TBSidedBlock extends TBBlock {
|
||||
|
||||
public IIcon sideIcon;
|
||||
|
||||
public TBSidedBlock(Material m, boolean b) {
|
||||
super(m, b);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
return side == 0 || side == 1 ? super.getIcon(side, meta) : sideIcon;
|
||||
public IIcon sideIcon;
|
||||
|
||||
public TBSidedBlock(Material m, boolean b) {
|
||||
super(m, b);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg)
|
||||
{
|
||||
super.registerBlockIcons(reg);
|
||||
sideIcon = reg.registerIcon(getTextureName()+"_side");
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return side == 0 || side == 1 ? super.getIcon(side, meta) : sideIcon;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
super.registerBlockIcons(reg);
|
||||
sideIcon = reg.registerIcon(getTextureName() + "_side");
|
||||
}
|
||||
}
|
||||
@@ -3,26 +3,24 @@ package tb.common.enchantment;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnumEnchantmentType;
|
||||
|
||||
public class EnchantmentElderKnowledge extends Enchantment{
|
||||
public class EnchantmentElderKnowledge extends Enchantment {
|
||||
|
||||
public EnchantmentElderKnowledge(int id, int weight, EnumEnchantmentType type)
|
||||
{
|
||||
super(id, weight, type);
|
||||
}
|
||||
public EnchantmentElderKnowledge(int id, int weight, EnumEnchantmentType type) {
|
||||
super(id, weight, type);
|
||||
}
|
||||
|
||||
public int getMinEnchantability(int lvl)
|
||||
{
|
||||
public int getMinEnchantability(int lvl) {
|
||||
return 1 + lvl * 5;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
|
||||
public int getMaxLevel() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return !(ench instanceof EnchantmentElderKnowledge) && !(ench instanceof EnchantmentMagicTouch) && !(ench instanceof EnchantmentTainted) && !(ench instanceof EnchantmentVaporising);
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench) {
|
||||
return !(ench instanceof EnchantmentElderKnowledge)
|
||||
&& !(ench instanceof EnchantmentMagicTouch)
|
||||
&& !(ench instanceof EnchantmentTainted)
|
||||
&& !(ench instanceof EnchantmentVaporising);
|
||||
}
|
||||
}
|
||||
@@ -4,26 +4,25 @@ import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentDamage;
|
||||
import net.minecraft.enchantment.EnumEnchantmentType;
|
||||
|
||||
public class EnchantmentEldritchBane extends Enchantment{
|
||||
public class EnchantmentEldritchBane extends Enchantment {
|
||||
|
||||
public EnchantmentEldritchBane(int id, int weight, EnumEnchantmentType type)
|
||||
{
|
||||
super(id, weight, type);
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
public EnchantmentEldritchBane(int id, int weight, EnumEnchantmentType type) {
|
||||
super(id, weight, type);
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
public int getMinEnchantability(int lvl)
|
||||
{
|
||||
|
||||
public int getMinEnchantability(int lvl) {
|
||||
return 1 + lvl * 5;
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return this != ench && ench != Enchantment.smite && ench != Enchantment.baneOfArthropods && ench != Enchantment.sharpness && !(ench instanceof EnchantmentDamage);
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench) {
|
||||
return this != ench
|
||||
&& ench != Enchantment.smite
|
||||
&& ench != Enchantment.baneOfArthropods
|
||||
&& ench != Enchantment.sharpness
|
||||
&& !(ench instanceof EnchantmentDamage);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,24 @@
|
||||
package tb.common.enchantment;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.item.ItemExpireEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import tb.init.TBEnchant;
|
||||
import tb.utils.TBUtils;
|
||||
import thaumcraft.api.ThaumcraftApi;
|
||||
@@ -21,199 +37,169 @@ import thaumcraft.common.items.ItemCrystalEssence;
|
||||
import thaumcraft.common.lib.research.ResearchManager;
|
||||
import thaumcraft.common.lib.research.ScanManager;
|
||||
import thaumcraft.common.tiles.TileNode;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.EntityEnderman;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.item.ItemExpireEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
|
||||
public class EnchantmentHandler {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SubscribeEvent
|
||||
public void itemExpire(ItemExpireEvent event)
|
||||
{
|
||||
if(event.entityItem != null && event.entityItem.getEntityItem() != null && !event.entityItem.worldObj.isRemote)
|
||||
{
|
||||
int x = MathHelper.floor_double(event.entityItem.posX);
|
||||
int y = MathHelper.floor_double(event.entityItem.posY);
|
||||
int z = MathHelper.floor_double(event.entityItem.posZ);
|
||||
World w = event.entityItem.worldObj;
|
||||
ItemStack is = event.entityItem.getEntityItem();
|
||||
Block b = w.getBlock(x, y, z);
|
||||
if(b != null && b instanceof BlockAiry)
|
||||
{
|
||||
TileEntity t = w.getTileEntity(x, y, z);
|
||||
if(t != null && t instanceof TileNode)
|
||||
{
|
||||
if(TileNode.class.cast(t).getNodeType() == NodeType.TAINTED)
|
||||
{
|
||||
if(is.getItem() instanceof ItemSword)
|
||||
{
|
||||
if(EnchantmentHelper.getEnchantmentLevel(TBEnchant.tainted.effectId, is) <= 0)
|
||||
{
|
||||
LinkedHashMap<Integer,Integer> lhm = (LinkedHashMap<Integer,Integer>)EnchantmentHelper.getEnchantments(is);
|
||||
boolean canApply = true;
|
||||
if(!lhm.isEmpty())
|
||||
{
|
||||
Iterator<Integer> $i = lhm.keySet().iterator();
|
||||
while($i.hasNext())
|
||||
{
|
||||
int i = $i.next();
|
||||
if(i < Enchantment.enchantmentsList.length && Enchantment.enchantmentsList[i] != null)
|
||||
{
|
||||
Enchantment ench = Enchantment.enchantmentsList[i];
|
||||
if(!ench.canApplyTogether(TBEnchant.tainted))
|
||||
{
|
||||
canApply = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(canApply)
|
||||
{
|
||||
is.addEnchantment(TBEnchant.tainted, 1+w.rand.nextInt(3));
|
||||
event.extraLife = 1000;
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMobDeath(LivingDeathEvent event)
|
||||
{
|
||||
if(event.entityLiving != null && !event.entityLiving.worldObj.isRemote && event.source != null && event.source.getSourceOfDamage() != null && event.source.getSourceOfDamage() instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = EntityPlayer.class.cast(event.source.getSourceOfDamage());
|
||||
EntityLivingBase dyingMob = event.entityLiving;
|
||||
ItemStack currentItem = player.getCurrentEquippedItem();
|
||||
if(currentItem != null)
|
||||
{
|
||||
if(EnchantmentHelper.getEnchantmentLevel(TBEnchant.elderKnowledge.effectId, currentItem) > 0)
|
||||
{
|
||||
int enchLevel = EnchantmentHelper.getEnchantmentLevel(TBEnchant.elderKnowledge.effectId, currentItem);
|
||||
if(player.worldObj.rand.nextInt(Math.max(1, 7-enchLevel)) == 0)
|
||||
{
|
||||
EntityTags eTags = null;
|
||||
for(int i = 0; i < ThaumcraftApi.scanEntities.size(); ++i)
|
||||
{
|
||||
EntityTags tags = ThaumcraftApi.scanEntities.get(i);
|
||||
if(tags != null && EntityList.getEntityString(dyingMob) != null && EntityList.getEntityString(dyingMob).equalsIgnoreCase(tags.entityName))
|
||||
{
|
||||
eTags = tags;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(eTags != null)
|
||||
{
|
||||
AspectList al = eTags.aspects;
|
||||
for(int i = 0; i < al.size(); ++i)
|
||||
{
|
||||
TBUtils.addAspectToKnowledgePool(player, al.getAspects()[i], (short) 1);
|
||||
if(player.worldObj.rand.nextBoolean())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(EnchantmentHelper.getEnchantmentLevel(TBEnchant.magicTouch.effectId, currentItem) > 0)
|
||||
{
|
||||
int enchLevel = EnchantmentHelper.getEnchantmentLevel(TBEnchant.magicTouch.effectId, currentItem);
|
||||
AspectList aspectsCompound = ScanManager.generateEntityAspects(dyingMob);
|
||||
if ((aspectsCompound != null) && (aspectsCompound.size() > 0))
|
||||
{
|
||||
AspectList aspects = ResearchManager.reduceToPrimals(aspectsCompound);
|
||||
for(int i = 0; i < enchLevel; ++i)
|
||||
{
|
||||
for (Aspect aspect : aspects.getAspects())
|
||||
if (event.entityLiving.worldObj.rand.nextBoolean())
|
||||
{
|
||||
EntityAspectOrb orb = new EntityAspectOrb(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, aspect, 1 + event.entityLiving.worldObj.rand.nextInt(aspects.getAmount(aspect)));
|
||||
event.entityLiving.worldObj.spawnEntityInWorld(orb);
|
||||
}
|
||||
|
||||
if(player.worldObj.rand.nextBoolean())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(EnchantmentHelper.getEnchantmentLevel(TBEnchant.vaporising.effectId, currentItem) > 0)
|
||||
{
|
||||
int enchLevel = EnchantmentHelper.getEnchantmentLevel(TBEnchant.vaporising.effectId, currentItem);
|
||||
if(event.entity.worldObj.rand.nextInt(Math.max(1, 5 - enchLevel)) == 0)
|
||||
{
|
||||
AspectList aspects = ScanManager.generateEntityAspects(event.entityLiving);
|
||||
if ((aspects != null) && (aspects.size() > 0))
|
||||
for (Aspect aspect : aspects.getAspects())
|
||||
{
|
||||
if (!event.entity.worldObj.rand.nextBoolean())
|
||||
{
|
||||
int size = 1 + event.entity.worldObj.rand.nextInt(aspects.getAmount(aspect));
|
||||
size = Math.max(1, size / 2);
|
||||
ItemStack stack = new ItemStack(ConfigItems.itemCrystalEssence, size, 0);
|
||||
((ItemCrystalEssence)stack.getItem()).setAspects(stack, new AspectList().add(aspect, 1));
|
||||
EntityItem cEs = new EntityItem(event.entity.worldObj, event.entityLiving.posX, event.entityLiving.posY + event.entityLiving.getEyeHeight(), event.entityLiving.posZ, stack);
|
||||
event.entity.worldObj.spawnEntityInWorld(cEs);
|
||||
}
|
||||
if(event.entity.worldObj.rand.nextInt(2+enchLevel) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMobDamage(LivingHurtEvent event)
|
||||
{
|
||||
if(event.entityLiving != null && !event.entityLiving.worldObj.isRemote && event.source != null && event.source.getSourceOfDamage() != null && event.source.getSourceOfDamage() instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = EntityPlayer.class.cast(event.source.getSourceOfDamage());
|
||||
EntityLivingBase mob = event.entityLiving;
|
||||
ItemStack currentItem = player.getCurrentEquippedItem();
|
||||
if(currentItem != null)
|
||||
{
|
||||
if(mob instanceof EntityEnderman || mob instanceof IEldritchMob)
|
||||
{
|
||||
if(EnchantmentHelper.getEnchantmentLevel(TBEnchant.eldritchBane.effectId, currentItem) > 0)
|
||||
{
|
||||
int enchLevel = EnchantmentHelper.getEnchantmentLevel(TBEnchant.eldritchBane.effectId, currentItem);
|
||||
event.ammount += enchLevel*5F;
|
||||
}
|
||||
}
|
||||
if(EnchantmentHelper.getEnchantmentLevel(TBEnchant.tainted.effectId, currentItem) > 0)
|
||||
{
|
||||
int enchLevel = EnchantmentHelper.getEnchantmentLevel(TBEnchant.tainted.effectId, currentItem);
|
||||
if(!(mob instanceof ITaintedMob))
|
||||
{
|
||||
event.ammount += enchLevel*3F;
|
||||
if(player.worldObj.rand.nextInt(Math.max(1,4-enchLevel)) == 0)
|
||||
{
|
||||
mob.addPotionEffect(new PotionEffect(Config.potionTaintPoisonID,200,enchLevel-1,true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SubscribeEvent
|
||||
public void itemExpire(ItemExpireEvent event) {
|
||||
if (event.entityItem != null
|
||||
&& event.entityItem.getEntityItem() != null
|
||||
&& !event.entityItem.worldObj.isRemote) {
|
||||
int x = MathHelper.floor_double(event.entityItem.posX);
|
||||
int y = MathHelper.floor_double(event.entityItem.posY);
|
||||
int z = MathHelper.floor_double(event.entityItem.posZ);
|
||||
World w = event.entityItem.worldObj;
|
||||
ItemStack is = event.entityItem.getEntityItem();
|
||||
Block b = w.getBlock(x, y, z);
|
||||
if (b != null && b instanceof BlockAiry) {
|
||||
TileEntity t = w.getTileEntity(x, y, z);
|
||||
if (t != null && t instanceof TileNode) {
|
||||
if (TileNode.class.cast(t).getNodeType() == NodeType.TAINTED) {
|
||||
if (is.getItem() instanceof ItemSword) {
|
||||
if (EnchantmentHelper.getEnchantmentLevel(TBEnchant.tainted.effectId, is) <= 0) {
|
||||
LinkedHashMap<Integer, Integer> lhm =
|
||||
(LinkedHashMap<Integer, Integer>) EnchantmentHelper.getEnchantments(is);
|
||||
boolean canApply = true;
|
||||
if (!lhm.isEmpty()) {
|
||||
Iterator<Integer> $i = lhm.keySet().iterator();
|
||||
while ($i.hasNext()) {
|
||||
int i = $i.next();
|
||||
if (i < Enchantment.enchantmentsList.length
|
||||
&& Enchantment.enchantmentsList[i] != null) {
|
||||
Enchantment ench = Enchantment.enchantmentsList[i];
|
||||
if (!ench.canApplyTogether(TBEnchant.tainted)) {
|
||||
canApply = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (canApply) {
|
||||
is.addEnchantment(TBEnchant.tainted, 1 + w.rand.nextInt(3));
|
||||
event.extraLife = 1000;
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMobDeath(LivingDeathEvent event) {
|
||||
if (event.entityLiving != null
|
||||
&& !event.entityLiving.worldObj.isRemote
|
||||
&& event.source != null
|
||||
&& event.source.getSourceOfDamage() != null
|
||||
&& event.source.getSourceOfDamage() instanceof EntityPlayer) {
|
||||
EntityPlayer player = EntityPlayer.class.cast(event.source.getSourceOfDamage());
|
||||
EntityLivingBase dyingMob = event.entityLiving;
|
||||
ItemStack currentItem = player.getCurrentEquippedItem();
|
||||
if (currentItem != null) {
|
||||
if (EnchantmentHelper.getEnchantmentLevel(TBEnchant.elderKnowledge.effectId, currentItem) > 0) {
|
||||
int enchLevel =
|
||||
EnchantmentHelper.getEnchantmentLevel(TBEnchant.elderKnowledge.effectId, currentItem);
|
||||
if (player.worldObj.rand.nextInt(Math.max(1, 7 - enchLevel)) == 0) {
|
||||
EntityTags eTags = null;
|
||||
for (int i = 0; i < ThaumcraftApi.scanEntities.size(); ++i) {
|
||||
EntityTags tags = ThaumcraftApi.scanEntities.get(i);
|
||||
if (tags != null
|
||||
&& EntityList.getEntityString(dyingMob) != null
|
||||
&& EntityList.getEntityString(dyingMob).equalsIgnoreCase(tags.entityName)) {
|
||||
eTags = tags;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (eTags != null) {
|
||||
AspectList al = eTags.aspects;
|
||||
for (int i = 0; i < al.size(); ++i) {
|
||||
TBUtils.addAspectToKnowledgePool(player, al.getAspects()[i], (short) 1);
|
||||
if (player.worldObj.rand.nextBoolean()) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (EnchantmentHelper.getEnchantmentLevel(TBEnchant.magicTouch.effectId, currentItem) > 0) {
|
||||
int enchLevel = EnchantmentHelper.getEnchantmentLevel(TBEnchant.magicTouch.effectId, currentItem);
|
||||
AspectList aspectsCompound = ScanManager.generateEntityAspects(dyingMob);
|
||||
if ((aspectsCompound != null) && (aspectsCompound.size() > 0)) {
|
||||
AspectList aspects = ResearchManager.reduceToPrimals(aspectsCompound);
|
||||
for (int i = 0; i < enchLevel; ++i) {
|
||||
for (Aspect aspect : aspects.getAspects())
|
||||
if (event.entityLiving.worldObj.rand.nextBoolean()) {
|
||||
EntityAspectOrb orb = new EntityAspectOrb(
|
||||
event.entityLiving.worldObj,
|
||||
event.entityLiving.posX,
|
||||
event.entityLiving.posY,
|
||||
event.entityLiving.posZ,
|
||||
aspect,
|
||||
1 + event.entityLiving.worldObj.rand.nextInt(aspects.getAmount(aspect)));
|
||||
event.entityLiving.worldObj.spawnEntityInWorld(orb);
|
||||
}
|
||||
|
||||
if (player.worldObj.rand.nextBoolean()) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (EnchantmentHelper.getEnchantmentLevel(TBEnchant.vaporising.effectId, currentItem) > 0) {
|
||||
int enchLevel = EnchantmentHelper.getEnchantmentLevel(TBEnchant.vaporising.effectId, currentItem);
|
||||
if (event.entity.worldObj.rand.nextInt(Math.max(1, 5 - enchLevel)) == 0) {
|
||||
AspectList aspects = ScanManager.generateEntityAspects(event.entityLiving);
|
||||
if ((aspects != null) && (aspects.size() > 0))
|
||||
for (Aspect aspect : aspects.getAspects()) {
|
||||
if (!event.entity.worldObj.rand.nextBoolean()) {
|
||||
int size = 1 + event.entity.worldObj.rand.nextInt(aspects.getAmount(aspect));
|
||||
size = Math.max(1, size / 2);
|
||||
ItemStack stack = new ItemStack(ConfigItems.itemCrystalEssence, size, 0);
|
||||
((ItemCrystalEssence) stack.getItem())
|
||||
.setAspects(stack, new AspectList().add(aspect, 1));
|
||||
EntityItem cEs = new EntityItem(
|
||||
event.entity.worldObj,
|
||||
event.entityLiving.posX,
|
||||
event.entityLiving.posY + event.entityLiving.getEyeHeight(),
|
||||
event.entityLiving.posZ,
|
||||
stack);
|
||||
event.entity.worldObj.spawnEntityInWorld(cEs);
|
||||
}
|
||||
if (event.entity.worldObj.rand.nextInt(2 + enchLevel) == 0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMobDamage(LivingHurtEvent event) {
|
||||
if (event.entityLiving != null
|
||||
&& !event.entityLiving.worldObj.isRemote
|
||||
&& event.source != null
|
||||
&& event.source.getSourceOfDamage() != null
|
||||
&& event.source.getSourceOfDamage() instanceof EntityPlayer) {
|
||||
EntityPlayer player = EntityPlayer.class.cast(event.source.getSourceOfDamage());
|
||||
EntityLivingBase mob = event.entityLiving;
|
||||
ItemStack currentItem = player.getCurrentEquippedItem();
|
||||
if (currentItem != null) {
|
||||
if (mob instanceof EntityEnderman || mob instanceof IEldritchMob) {
|
||||
if (EnchantmentHelper.getEnchantmentLevel(TBEnchant.eldritchBane.effectId, currentItem) > 0) {
|
||||
int enchLevel =
|
||||
EnchantmentHelper.getEnchantmentLevel(TBEnchant.eldritchBane.effectId, currentItem);
|
||||
event.ammount += enchLevel * 5F;
|
||||
}
|
||||
}
|
||||
if (EnchantmentHelper.getEnchantmentLevel(TBEnchant.tainted.effectId, currentItem) > 0) {
|
||||
int enchLevel = EnchantmentHelper.getEnchantmentLevel(TBEnchant.tainted.effectId, currentItem);
|
||||
if (!(mob instanceof ITaintedMob)) {
|
||||
event.ammount += enchLevel * 3F;
|
||||
if (player.worldObj.rand.nextInt(Math.max(1, 4 - enchLevel)) == 0) {
|
||||
mob.addPotionEffect(new PotionEffect(Config.potionTaintPoisonID, 200, enchLevel - 1, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,20 +3,20 @@ package tb.common.enchantment;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnumEnchantmentType;
|
||||
|
||||
public class EnchantmentMagicTouch extends Enchantment{
|
||||
public class EnchantmentMagicTouch extends Enchantment {
|
||||
|
||||
public EnchantmentMagicTouch(int id, int weight, EnumEnchantmentType type)
|
||||
{
|
||||
super(id, weight, type);
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
public EnchantmentMagicTouch(int id, int weight, EnumEnchantmentType type) {
|
||||
super(id, weight, type);
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return !(ench instanceof EnchantmentElderKnowledge) && !(ench instanceof EnchantmentMagicTouch) && !(ench instanceof EnchantmentTainted) && !(ench instanceof EnchantmentVaporising);
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench) {
|
||||
return !(ench instanceof EnchantmentElderKnowledge)
|
||||
&& !(ench instanceof EnchantmentMagicTouch)
|
||||
&& !(ench instanceof EnchantmentTainted)
|
||||
&& !(ench instanceof EnchantmentVaporising);
|
||||
}
|
||||
}
|
||||
@@ -4,27 +4,26 @@ import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnumEnchantmentType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class EnchantmentTainted extends Enchantment{
|
||||
public class EnchantmentTainted extends Enchantment {
|
||||
|
||||
public EnchantmentTainted(int id, int weight, EnumEnchantmentType type)
|
||||
{
|
||||
super(id, weight, type);
|
||||
}
|
||||
public EnchantmentTainted(int id, int weight, EnumEnchantmentType type) {
|
||||
super(id, weight, type);
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
public int getMaxLevel() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return !(ench instanceof EnchantmentElderKnowledge) && !(ench instanceof EnchantmentMagicTouch) && !(ench instanceof EnchantmentTainted) && !(ench instanceof EnchantmentVaporising);
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench) {
|
||||
return !(ench instanceof EnchantmentElderKnowledge)
|
||||
&& !(ench instanceof EnchantmentMagicTouch)
|
||||
&& !(ench instanceof EnchantmentTainted)
|
||||
&& !(ench instanceof EnchantmentVaporising);
|
||||
}
|
||||
|
||||
//do I even want to know why this is here?
|
||||
|
||||
public boolean canApply(ItemStack itemStack)
|
||||
{
|
||||
return false;
|
||||
// do I even want to know why this is here?
|
||||
|
||||
public boolean canApply(ItemStack itemStack) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -3,21 +3,20 @@ package tb.common.enchantment;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnumEnchantmentType;
|
||||
|
||||
public class EnchantmentVaporising extends Enchantment{
|
||||
public class EnchantmentVaporising extends Enchantment {
|
||||
|
||||
public EnchantmentVaporising(int id, int weight, EnumEnchantmentType type)
|
||||
{
|
||||
super(id, weight, type);
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
public EnchantmentVaporising(int id, int weight, EnumEnchantmentType type) {
|
||||
super(id, weight, type);
|
||||
}
|
||||
|
||||
public int getMaxLevel() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench)
|
||||
{
|
||||
return !(ench instanceof EnchantmentElderKnowledge) && !(ench instanceof EnchantmentMagicTouch) && !(ench instanceof EnchantmentTainted) && !(ench instanceof EnchantmentVaporising);
|
||||
}
|
||||
|
||||
public boolean canApplyTogether(Enchantment ench) {
|
||||
return !(ench instanceof EnchantmentElderKnowledge)
|
||||
&& !(ench instanceof EnchantmentMagicTouch)
|
||||
&& !(ench instanceof EnchantmentTainted)
|
||||
&& !(ench instanceof EnchantmentVaporising);
|
||||
}
|
||||
}
|
||||
@@ -8,82 +8,69 @@ import net.minecraft.pathfinding.PathNavigate;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityAIAvoidCampfire extends EntityAIBase
|
||||
{
|
||||
public boolean isScared;
|
||||
public int scareTimer;
|
||||
public int campfireX;
|
||||
public int campfireY;
|
||||
public int campfireZ;
|
||||
public World worldObj;
|
||||
public EntityCreature entityObj;
|
||||
public class EntityAIAvoidCampfire extends EntityAIBase {
|
||||
public boolean isScared;
|
||||
public int scareTimer;
|
||||
public int campfireX;
|
||||
public int campfireY;
|
||||
public int campfireZ;
|
||||
public World worldObj;
|
||||
public EntityCreature entityObj;
|
||||
/** The PathEntity of our entity */
|
||||
private PathEntity entityPathEntity;
|
||||
/** The PathNavigate of our entity */
|
||||
private PathNavigate entityPathNavigate;
|
||||
|
||||
private double farSpeed;
|
||||
private double nearSpeed;
|
||||
|
||||
public EntityAIAvoidCampfire(EntityCreature creature)
|
||||
{
|
||||
scareTimer = 100;
|
||||
worldObj = creature.worldObj;
|
||||
entityObj = creature;
|
||||
this.setMutexBits(1);
|
||||
this.entityPathNavigate = creature.getNavigator();
|
||||
nearSpeed = 2;
|
||||
farSpeed = nearSpeed*2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if(isScared)
|
||||
{
|
||||
Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.entityObj, 16, 10, Vec3.createVectorHelper(campfireX+0.5D, campfireY, campfireZ+0.5D));
|
||||
|
||||
if(vec3 == null)
|
||||
return false;
|
||||
|
||||
public EntityAIAvoidCampfire(EntityCreature creature) {
|
||||
scareTimer = 100;
|
||||
worldObj = creature.worldObj;
|
||||
entityObj = creature;
|
||||
this.setMutexBits(1);
|
||||
this.entityPathNavigate = creature.getNavigator();
|
||||
nearSpeed = 2;
|
||||
farSpeed = nearSpeed * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
if (isScared) {
|
||||
Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(
|
||||
this.entityObj, 16, 10, Vec3.createVectorHelper(campfireX + 0.5D, campfireY, campfireZ + 0.5D));
|
||||
|
||||
if (vec3 == null) return false;
|
||||
|
||||
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord);
|
||||
return this.entityPathEntity == null ? false : this.entityPathEntity.isDestinationSame(vec3);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean continueExecuting() {
|
||||
return !this.entityObj.getNavigator().noPath() && scareTimer > 0;
|
||||
}
|
||||
|
||||
public void resetTask()
|
||||
{
|
||||
}
|
||||
|
||||
public void updateTask()
|
||||
{
|
||||
if(entityPathNavigate != null && (entityPathNavigate.getPath() == null || entityPathNavigate.getPath() != entityPathEntity))
|
||||
{
|
||||
this.entityPathNavigate.setPath(this.entityPathEntity, nearSpeed);
|
||||
}
|
||||
|
||||
--scareTimer;
|
||||
if(scareTimer <= 0)
|
||||
isScared = false;
|
||||
|
||||
if (this.entityObj.getDistanceSq(campfireX+0.5D,campfireY,campfireZ+0.5D) < 49.0D)
|
||||
{
|
||||
this.entityObj.getNavigator().setSpeed(this.nearSpeed);
|
||||
|
||||
public void resetTask() {}
|
||||
|
||||
public void updateTask() {
|
||||
if (entityPathNavigate != null
|
||||
&& (entityPathNavigate.getPath() == null || entityPathNavigate.getPath() != entityPathEntity)) {
|
||||
this.entityPathNavigate.setPath(this.entityPathEntity, nearSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
--scareTimer;
|
||||
if (scareTimer <= 0) isScared = false;
|
||||
|
||||
if (this.entityObj.getDistanceSq(campfireX + 0.5D, campfireY, campfireZ + 0.5D) < 49.0D) {
|
||||
this.entityObj.getNavigator().setSpeed(this.nearSpeed);
|
||||
} else {
|
||||
this.entityObj.getNavigator().setSpeed(this.farSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
public void startExecuting()
|
||||
{
|
||||
this.entityPathNavigate.setPath(this.entityPathEntity, nearSpeed);
|
||||
}
|
||||
|
||||
public void startExecuting() {
|
||||
this.entityPathNavigate.setPath(this.entityPathEntity, nearSpeed);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,7 @@
|
||||
package tb.common.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import DummyCore.Utils.Pair;
|
||||
import tb.api.RevolverUpgrade;
|
||||
import tb.common.item.ItemRevolver;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -17,163 +13,156 @@ import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||
import net.minecraft.world.World;
|
||||
import tb.api.RevolverUpgrade;
|
||||
import tb.common.item.ItemRevolver;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
|
||||
public class EntityRevolverBullet extends EntityThrowable
|
||||
{
|
||||
public Entity shooter;
|
||||
public ItemStack revolver;
|
||||
ArrayList<Pair<RevolverUpgrade,Integer>> upgrades;
|
||||
boolean isPrimal;
|
||||
|
||||
public EntityRevolverBullet(World w)
|
||||
{
|
||||
super(w);
|
||||
}
|
||||
|
||||
public EntityRevolverBullet(World w, EntityLivingBase shooter)
|
||||
{
|
||||
super(w, shooter);
|
||||
revolver = shooter.getHeldItem();
|
||||
this.shooter = shooter;
|
||||
if(revolver != null && revolver.getItem() instanceof ItemRevolver)
|
||||
{
|
||||
upgrades = ItemRevolver.getAllUpgradesFor(revolver);
|
||||
boolean allowNoclip = false;
|
||||
float speedIndex = 1;
|
||||
for(Pair<RevolverUpgrade,Integer> p : upgrades)
|
||||
{
|
||||
if(!allowNoclip)
|
||||
allowNoclip = p.getFirst().bulletNoclip((EntityPlayer) shooter, revolver, p.getSecond());
|
||||
|
||||
speedIndex = (float) p.getFirst().modifySpeed((EntityPlayer) shooter, revolver, speedIndex, p.getSecond());
|
||||
|
||||
if(p.getFirst() == RevolverUpgrade.primal)
|
||||
isPrimal = true;
|
||||
}
|
||||
if(allowNoclip)
|
||||
noClip = true;
|
||||
|
||||
this.motionX *=3;
|
||||
this.motionY *=3;
|
||||
this.motionZ *=3;
|
||||
|
||||
this.motionX *= speedIndex;
|
||||
this.motionY *= speedIndex;
|
||||
this.motionZ *= speedIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate()
|
||||
{
|
||||
if(this.worldObj.isRemote)
|
||||
Thaumcraft.proxy.sparkle((float)posX, (float)posY, (float)posZ, 4);
|
||||
|
||||
if(this.worldObj.isRemote)
|
||||
Thaumcraft.proxy.sparkle((float)(posX-motionX/20), (float)(posY-motionY/20), (float)(posZ-motionZ/20), 4);
|
||||
|
||||
if(this.ticksExisted >= 200) //<- loop exit for primal
|
||||
this.setDead();
|
||||
|
||||
super.onUpdate();
|
||||
|
||||
if(isPrimal && !isDead)
|
||||
{
|
||||
++ticksExisted;
|
||||
onUpdate(); //<- loop to turn into a hit-scan
|
||||
}
|
||||
public class EntityRevolverBullet extends EntityThrowable {
|
||||
public Entity shooter;
|
||||
public ItemStack revolver;
|
||||
ArrayList<Pair<RevolverUpgrade, Integer>> upgrades;
|
||||
boolean isPrimal;
|
||||
|
||||
public EntityRevolverBullet(World w) {
|
||||
super(w);
|
||||
}
|
||||
|
||||
protected float getGravityVelocity()
|
||||
{
|
||||
|
||||
public EntityRevolverBullet(World w, EntityLivingBase shooter) {
|
||||
super(w, shooter);
|
||||
revolver = shooter.getHeldItem();
|
||||
this.shooter = shooter;
|
||||
if (revolver != null && revolver.getItem() instanceof ItemRevolver) {
|
||||
upgrades = ItemRevolver.getAllUpgradesFor(revolver);
|
||||
boolean allowNoclip = false;
|
||||
float speedIndex = 1;
|
||||
for (Pair<RevolverUpgrade, Integer> p : upgrades) {
|
||||
if (!allowNoclip)
|
||||
allowNoclip = p.getFirst().bulletNoclip((EntityPlayer) shooter, revolver, p.getSecond());
|
||||
|
||||
speedIndex =
|
||||
(float) p.getFirst().modifySpeed((EntityPlayer) shooter, revolver, speedIndex, p.getSecond());
|
||||
|
||||
if (p.getFirst() == RevolverUpgrade.primal) isPrimal = true;
|
||||
}
|
||||
if (allowNoclip) noClip = true;
|
||||
|
||||
this.motionX *= 3;
|
||||
this.motionY *= 3;
|
||||
this.motionZ *= 3;
|
||||
|
||||
this.motionX *= speedIndex;
|
||||
this.motionY *= speedIndex;
|
||||
this.motionZ *= speedIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
if (this.worldObj.isRemote) Thaumcraft.proxy.sparkle((float) posX, (float) posY, (float) posZ, 4);
|
||||
|
||||
if (this.worldObj.isRemote)
|
||||
Thaumcraft.proxy.sparkle(
|
||||
(float) (posX - motionX / 20), (float) (posY - motionY / 20), (float) (posZ - motionZ / 20), 4);
|
||||
|
||||
if (this.ticksExisted >= 200) // <- loop exit for primal
|
||||
this.setDead();
|
||||
|
||||
super.onUpdate();
|
||||
|
||||
if (isPrimal && !isDead) {
|
||||
++ticksExisted;
|
||||
onUpdate(); // <- loop to turn into a hit-scan
|
||||
}
|
||||
}
|
||||
|
||||
protected float getGravityVelocity() {
|
||||
return isPrimal ? 0 : 0.01F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition object)
|
||||
{
|
||||
if(this.isDead)
|
||||
return;
|
||||
|
||||
if(!this.worldObj.isRemote && object.typeOfHit == MovingObjectType.BLOCK)
|
||||
{
|
||||
if(noClip)
|
||||
return;
|
||||
if(this.worldObj.isBlockNormalCubeDefault(object.blockX, object.blockY, object.blockZ, true))
|
||||
this.setDead();
|
||||
else
|
||||
{
|
||||
Block b = this.worldObj.getBlock(object.blockX, object.blockY, object.blockZ);
|
||||
int meta = this.worldObj.getBlockMetadata(object.blockX, object.blockY, object.blockZ);
|
||||
|
||||
for(int i = 0; i < 100; ++i)
|
||||
this.worldObj.spawnParticle("blockcrack_"+Block.getIdFromBlock(b)+"_"+meta, object.blockX+worldObj.rand.nextDouble(), object.blockY+worldObj.rand.nextDouble(), object.blockZ+worldObj.rand.nextDouble(), 0, 0, 0);
|
||||
|
||||
worldObj.playSound(object.blockX+0.5D, object.blockY+0.5D, object.blockZ+0.5D, b.stepSound.getBreakSound(), 1, 1, false);
|
||||
}
|
||||
}
|
||||
if(object.typeOfHit == MovingObjectType.ENTITY)
|
||||
{
|
||||
Entity e = object.entityHit;
|
||||
if(e instanceof EntityLivingBase && e != this.shooter && !(e instanceof EntityRevolverBullet))
|
||||
{
|
||||
EntityLivingBase elb = (EntityLivingBase) e;
|
||||
float initialDamage = 14;
|
||||
for(Pair<RevolverUpgrade,Integer> p : upgrades)
|
||||
initialDamage = p.getFirst().modifyDamage_start(elb, revolver, initialDamage, p.getSecond());
|
||||
|
||||
for(Pair<RevolverUpgrade,Integer> p : upgrades)
|
||||
initialDamage = p.getFirst().modifyDamage_end(elb, revolver, initialDamage, p.getSecond());
|
||||
|
||||
elb.attackEntityFrom(new RevolverDamage("revolver"), initialDamage);
|
||||
|
||||
boolean destroy = true;
|
||||
|
||||
for(Pair<RevolverUpgrade,Integer> p : upgrades)
|
||||
{
|
||||
if(destroy)
|
||||
destroy = p.getFirst().afterhit(elb, (EntityPlayer) shooter, revolver, initialDamage, p.getSecond());
|
||||
else
|
||||
p.getFirst().afterhit(elb, (EntityPlayer) shooter, revolver, initialDamage, p.getSecond());
|
||||
}
|
||||
|
||||
if(destroy)
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class RevolverDamage extends DamageSource
|
||||
{
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition object) {
|
||||
if (this.isDead) return;
|
||||
|
||||
public RevolverDamage(String damage) {
|
||||
super(damage);
|
||||
}
|
||||
|
||||
}
|
||||
if (!this.worldObj.isRemote && object.typeOfHit == MovingObjectType.BLOCK) {
|
||||
if (noClip) return;
|
||||
if (this.worldObj.isBlockNormalCubeDefault(object.blockX, object.blockY, object.blockZ, true))
|
||||
this.setDead();
|
||||
else {
|
||||
Block b = this.worldObj.getBlock(object.blockX, object.blockY, object.blockZ);
|
||||
int meta = this.worldObj.getBlockMetadata(object.blockX, object.blockY, object.blockZ);
|
||||
|
||||
public void writeEntityToNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.writeEntityToNBT(tag);
|
||||
if(revolver != null)
|
||||
{
|
||||
NBTTagCompound revolverTag = new NBTTagCompound();
|
||||
revolver.writeToNBT(revolverTag);
|
||||
tag.setTag("revolverTag", revolverTag);
|
||||
}
|
||||
tag.setBoolean("noclip", noClip);
|
||||
tag.setBoolean("primal", isPrimal);
|
||||
for (int i = 0; i < 100; ++i)
|
||||
this.worldObj.spawnParticle(
|
||||
"blockcrack_" + Block.getIdFromBlock(b) + "_" + meta,
|
||||
object.blockX + worldObj.rand.nextDouble(),
|
||||
object.blockY + worldObj.rand.nextDouble(),
|
||||
object.blockZ + worldObj.rand.nextDouble(),
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
worldObj.playSound(
|
||||
object.blockX + 0.5D,
|
||||
object.blockY + 0.5D,
|
||||
object.blockZ + 0.5D,
|
||||
b.stepSound.getBreakSound(),
|
||||
1,
|
||||
1,
|
||||
false);
|
||||
}
|
||||
}
|
||||
if (object.typeOfHit == MovingObjectType.ENTITY) {
|
||||
Entity e = object.entityHit;
|
||||
if (e instanceof EntityLivingBase && e != this.shooter && !(e instanceof EntityRevolverBullet)) {
|
||||
EntityLivingBase elb = (EntityLivingBase) e;
|
||||
float initialDamage = 14;
|
||||
for (Pair<RevolverUpgrade, Integer> p : upgrades)
|
||||
initialDamage = p.getFirst().modifyDamage_start(elb, revolver, initialDamage, p.getSecond());
|
||||
|
||||
for (Pair<RevolverUpgrade, Integer> p : upgrades)
|
||||
initialDamage = p.getFirst().modifyDamage_end(elb, revolver, initialDamage, p.getSecond());
|
||||
|
||||
elb.attackEntityFrom(new RevolverDamage("revolver"), initialDamage);
|
||||
|
||||
boolean destroy = true;
|
||||
|
||||
for (Pair<RevolverUpgrade, Integer> p : upgrades) {
|
||||
if (destroy)
|
||||
destroy = p.getFirst()
|
||||
.afterhit(elb, (EntityPlayer) shooter, revolver, initialDamage, p.getSecond());
|
||||
else p.getFirst().afterhit(elb, (EntityPlayer) shooter, revolver, initialDamage, p.getSecond());
|
||||
}
|
||||
|
||||
if (destroy) this.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void readEntityFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
super.readEntityFromNBT(tag);
|
||||
|
||||
if(tag.hasKey("revolverTag"))
|
||||
{
|
||||
revolver = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("revolverTag"));
|
||||
upgrades = ItemRevolver.getAllUpgradesFor(revolver);
|
||||
}
|
||||
noClip = tag.getBoolean("noclip");
|
||||
isPrimal = tag.getBoolean("primal");
|
||||
|
||||
public static class RevolverDamage extends DamageSource {
|
||||
|
||||
public RevolverDamage(String damage) {
|
||||
super(damage);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeEntityToNBT(NBTTagCompound tag) {
|
||||
super.writeEntityToNBT(tag);
|
||||
if (revolver != null) {
|
||||
NBTTagCompound revolverTag = new NBTTagCompound();
|
||||
revolver.writeToNBT(revolverTag);
|
||||
tag.setTag("revolverTag", revolverTag);
|
||||
}
|
||||
tag.setBoolean("noclip", noClip);
|
||||
tag.setBoolean("primal", isPrimal);
|
||||
}
|
||||
|
||||
public void readEntityFromNBT(NBTTagCompound tag) {
|
||||
super.readEntityFromNBT(tag);
|
||||
|
||||
if (tag.hasKey("revolverTag")) {
|
||||
revolver = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("revolverTag"));
|
||||
upgrades = ItemRevolver.getAllUpgradesFor(revolver);
|
||||
}
|
||||
noClip = tag.getBoolean("noclip");
|
||||
isPrimal = tag.getBoolean("primal");
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,12 @@
|
||||
package tb.common.event;
|
||||
|
||||
import tb.common.item.ItemHerobrinesScythe;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent.NameFormat;
|
||||
|
||||
public class TBEventHandler {
|
||||
/*
|
||||
@SubscribeEvent
|
||||
public void nameFormatEvent(NameFormat event)
|
||||
{
|
||||
if(event.entityPlayer != null && event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemHerobrinesScythe)
|
||||
event.displayname = "Herobrine";
|
||||
}
|
||||
*/
|
||||
/*
|
||||
@SubscribeEvent
|
||||
public void nameFormatEvent(NameFormat event)
|
||||
{
|
||||
if(event.entityPlayer != null && event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemHerobrinesScythe)
|
||||
event.displayname = "Herobrine";
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -1,18 +1,16 @@
|
||||
package tb.common.event;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import tb.init.TBBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenAbstractTree;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tb.init.TBBlocks;
|
||||
|
||||
public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
{
|
||||
static final byte[] otherCoordPairs = new byte[] {(byte)2, (byte)0, (byte)0, (byte)1, (byte)2, (byte)1};
|
||||
public class WorldGenBigOak extends WorldGenAbstractTree {
|
||||
static final byte[] otherCoordPairs = new byte[] {(byte) 2, (byte) 0, (byte) 0, (byte) 1, (byte) 2, (byte) 1};
|
||||
Random rand = new Random();
|
||||
World worldObj;
|
||||
int[] basePos = new int[] {0, 0, 0};
|
||||
@@ -27,37 +25,40 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
int heightLimitLimit = 12;
|
||||
int leafDistanceLimit = 4;
|
||||
int[][] leafNodes;
|
||||
public Block leavesBlock;
|
||||
public Block trunkBlock;
|
||||
public int leavesMeta;
|
||||
public int trunkMeta;
|
||||
public Block leavesBlock;
|
||||
public Block trunkBlock;
|
||||
public int leavesMeta;
|
||||
public int trunkMeta;
|
||||
|
||||
public WorldGenBigOak(boolean doBlockNotify, int minHeight,int metaWood, int metaLeaves, int treeSize, Block tree, Block leaves)
|
||||
{
|
||||
public WorldGenBigOak(
|
||||
boolean doBlockNotify,
|
||||
int minHeight,
|
||||
int metaWood,
|
||||
int metaLeaves,
|
||||
int treeSize,
|
||||
Block tree,
|
||||
Block leaves) {
|
||||
super(doBlockNotify);
|
||||
trunkMeta = metaWood;
|
||||
leavesMeta = metaLeaves;
|
||||
leavesBlock = leaves;
|
||||
trunkBlock = tree;
|
||||
height = minHeight;
|
||||
trunkMeta = metaWood;
|
||||
leavesMeta = metaLeaves;
|
||||
leavesBlock = leaves;
|
||||
trunkBlock = tree;
|
||||
height = minHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a list of leaf nodes for the tree, to be populated by generateLeaves.
|
||||
*/
|
||||
void generateLeafNodeList()
|
||||
{
|
||||
this.height = (int)((double)this.heightLimit * this.heightAttenuation);
|
||||
void generateLeafNodeList() {
|
||||
this.height = (int) ((double) this.heightLimit * this.heightAttenuation);
|
||||
|
||||
if (this.height >= this.heightLimit)
|
||||
{
|
||||
if (this.height >= this.heightLimit) {
|
||||
this.height = this.heightLimit - 1;
|
||||
}
|
||||
|
||||
int i = (int)(1.382D + Math.pow(this.leafDensity * (double)this.heightLimit / 13.0D, 2.0D));
|
||||
int i = (int) (1.382D + Math.pow(this.leafDensity * (double) this.heightLimit / 13.0D, 2.0D));
|
||||
|
||||
if (i < 1)
|
||||
{
|
||||
if (i < 1) {
|
||||
i = 1;
|
||||
}
|
||||
|
||||
@@ -72,44 +73,35 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
aint[0][3] = l;
|
||||
--j;
|
||||
|
||||
while (i1 >= 0)
|
||||
{
|
||||
while (i1 >= 0) {
|
||||
int j1 = 0;
|
||||
float f = this.layerSize(i1);
|
||||
|
||||
if (f < 0.0F)
|
||||
{
|
||||
if (f < 0.0F) {
|
||||
--j;
|
||||
--i1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (double d0 = 0.5D; j1 < i; ++j1)
|
||||
{
|
||||
double d1 = this.scaleWidth * (double)f * ((double)this.rand.nextFloat() + 0.328D);
|
||||
double d2 = (double)this.rand.nextFloat() * 2.0D * Math.PI;
|
||||
int k1 = MathHelper.floor_double(d1 * Math.sin(d2) + (double)this.basePos[0] + d0);
|
||||
int l1 = MathHelper.floor_double(d1 * Math.cos(d2) + (double)this.basePos[2] + d0);
|
||||
} else {
|
||||
for (double d0 = 0.5D; j1 < i; ++j1) {
|
||||
double d1 = this.scaleWidth * (double) f * ((double) this.rand.nextFloat() + 0.328D);
|
||||
double d2 = (double) this.rand.nextFloat() * 2.0D * Math.PI;
|
||||
int k1 = MathHelper.floor_double(d1 * Math.sin(d2) + (double) this.basePos[0] + d0);
|
||||
int l1 = MathHelper.floor_double(d1 * Math.cos(d2) + (double) this.basePos[2] + d0);
|
||||
int[] aint1 = new int[] {k1, j, l1};
|
||||
int[] aint2 = new int[] {k1, j + this.leafDistanceLimit, l1};
|
||||
|
||||
if (this.checkBlockLine(aint1, aint2) == -1)
|
||||
{
|
||||
if (this.checkBlockLine(aint1, aint2) == -1) {
|
||||
int[] aint3 = new int[] {this.basePos[0], this.basePos[1], this.basePos[2]};
|
||||
double d3 = Math.sqrt(Math.pow((double)Math.abs(this.basePos[0] - aint1[0]), 2.0D) + Math.pow((double)Math.abs(this.basePos[2] - aint1[2]), 2.0D));
|
||||
double d3 = Math.sqrt(Math.pow((double) Math.abs(this.basePos[0] - aint1[0]), 2.0D)
|
||||
+ Math.pow((double) Math.abs(this.basePos[2] - aint1[2]), 2.0D));
|
||||
double d4 = d3 * this.branchSlope;
|
||||
|
||||
if ((double)aint1[1] - d4 > (double)l)
|
||||
{
|
||||
if ((double) aint1[1] - d4 > (double) l) {
|
||||
aint3[1] = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
aint3[1] = (int)((double)aint1[1] - d4);
|
||||
} else {
|
||||
aint3[1] = (int) ((double) aint1[1] - d4);
|
||||
}
|
||||
|
||||
if (this.checkBlockLine(aint3, aint1) == -1)
|
||||
{
|
||||
if (this.checkBlockLine(aint3, aint1) == -1) {
|
||||
aint[k][0] = k1;
|
||||
aint[k][1] = j;
|
||||
aint[k][2] = l1;
|
||||
@@ -128,9 +120,9 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
System.arraycopy(aint, 0, this.leafNodes, 0, k);
|
||||
}
|
||||
|
||||
void func_150529_a(int p_150529_1_, int p_150529_2_, int p_150529_3_, float p_150529_4_, byte p_150529_5_, Block p_150529_6_)
|
||||
{
|
||||
int l = (int)((double)p_150529_4_ + 0.618D);
|
||||
void func_150529_a(
|
||||
int p_150529_1_, int p_150529_2_, int p_150529_3_, float p_150529_4_, byte p_150529_5_, Block p_150529_6_) {
|
||||
int l = (int) ((double) p_150529_4_ + 0.618D);
|
||||
byte b1 = otherCoordPairs[p_150529_5_];
|
||||
byte b2 = otherCoordPairs[p_150529_5_ + 3];
|
||||
int[] aint = new int[] {p_150529_1_, p_150529_2_, p_150529_3_};
|
||||
@@ -138,31 +130,25 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
int i1 = -l;
|
||||
int j1 = -l;
|
||||
|
||||
for (aint1[p_150529_5_] = aint[p_150529_5_]; i1 <= l; ++i1)
|
||||
{
|
||||
for (aint1[p_150529_5_] = aint[p_150529_5_]; i1 <= l; ++i1) {
|
||||
aint1[b1] = aint[b1] + i1;
|
||||
j1 = -l;
|
||||
|
||||
while (j1 <= l)
|
||||
{
|
||||
double d0 = Math.pow((double)Math.abs(i1) + 0.5D, 2.0D) + Math.pow((double)Math.abs(j1) + 0.5D, 2.0D);
|
||||
while (j1 <= l) {
|
||||
double d0 = Math.pow((double) Math.abs(i1) + 0.5D, 2.0D) + Math.pow((double) Math.abs(j1) + 0.5D, 2.0D);
|
||||
|
||||
if (d0 > (double)(p_150529_4_ * p_150529_4_))
|
||||
{
|
||||
if (d0 > (double) (p_150529_4_ * p_150529_4_)) {
|
||||
++j1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
aint1[b2] = aint[b2] + j1;
|
||||
Block block1 = this.worldObj.getBlock(aint1[0], aint1[1], aint1[2]);
|
||||
|
||||
if (!block1.isAir(worldObj, aint1[0], aint1[1], aint1[2]) && !block1.isLeaves(worldObj, aint1[0], aint1[1], aint1[2]))
|
||||
{
|
||||
if (!block1.isAir(worldObj, aint1[0], aint1[1], aint1[2])
|
||||
&& !block1.isLeaves(worldObj, aint1[0], aint1[1], aint1[2])) {
|
||||
++j1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(this.worldObj, aint1[0], aint1[1], aint1[2], p_150529_6_, this.leavesMeta);
|
||||
} else {
|
||||
this.setBlockAndNotifyAdequately(
|
||||
this.worldObj, aint1[0], aint1[1], aint1[2], p_150529_6_, this.leavesMeta);
|
||||
++j1;
|
||||
}
|
||||
}
|
||||
@@ -173,29 +159,20 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
/**
|
||||
* Gets the rough size of a layer of the tree.
|
||||
*/
|
||||
float layerSize(int p_76490_1_)
|
||||
{
|
||||
if ((double)p_76490_1_ < (double)((float)this.heightLimit) * 0.3D)
|
||||
{
|
||||
float layerSize(int p_76490_1_) {
|
||||
if ((double) p_76490_1_ < (double) ((float) this.heightLimit) * 0.3D) {
|
||||
return -1.618F;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (float)this.heightLimit / 2.0F;
|
||||
float f1 = (float)this.heightLimit / 2.0F - (float)p_76490_1_;
|
||||
} else {
|
||||
float f = (float) this.heightLimit / 2.0F;
|
||||
float f1 = (float) this.heightLimit / 2.0F - (float) p_76490_1_;
|
||||
float f2;
|
||||
|
||||
if (f1 == 0.0F)
|
||||
{
|
||||
if (f1 == 0.0F) {
|
||||
f2 = f;
|
||||
}
|
||||
else if (Math.abs(f1) >= f)
|
||||
{
|
||||
} else if (Math.abs(f1) >= f) {
|
||||
f2 = 0.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
f2 = (float)Math.sqrt(Math.pow((double)Math.abs(f), 2.0D) - Math.pow((double)Math.abs(f1), 2.0D));
|
||||
} else {
|
||||
f2 = (float) Math.sqrt(Math.pow((double) Math.abs(f), 2.0D) - Math.pow((double) Math.abs(f1), 2.0D));
|
||||
}
|
||||
|
||||
f2 *= 0.5F;
|
||||
@@ -203,79 +180,66 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
}
|
||||
}
|
||||
|
||||
float leafSize(int p_76495_1_)
|
||||
{
|
||||
return p_76495_1_ >= 0 && p_76495_1_ < this.leafDistanceLimit ? (p_76495_1_ != 0 && p_76495_1_ != this.leafDistanceLimit - 1 ? 3.0F : 2.0F) : -1.0F;
|
||||
float leafSize(int p_76495_1_) {
|
||||
return p_76495_1_ >= 0 && p_76495_1_ < this.leafDistanceLimit
|
||||
? (p_76495_1_ != 0 && p_76495_1_ != this.leafDistanceLimit - 1 ? 3.0F : 2.0F)
|
||||
: -1.0F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the leaves surrounding an individual entry in the leafNodes list.
|
||||
*/
|
||||
void generateLeafNode(int p_76491_1_, int p_76491_2_, int p_76491_3_)
|
||||
{
|
||||
void generateLeafNode(int p_76491_1_, int p_76491_2_, int p_76491_3_) {
|
||||
int l = p_76491_2_;
|
||||
|
||||
for (int i1 = p_76491_2_ + this.leafDistanceLimit; l < i1; ++l)
|
||||
{
|
||||
for (int i1 = p_76491_2_ + this.leafDistanceLimit; l < i1; ++l) {
|
||||
float f = this.leafSize(l - p_76491_2_);
|
||||
this.func_150529_a(p_76491_1_, l, p_76491_3_, f, (byte)1, this.leavesBlock);
|
||||
this.func_150529_a(p_76491_1_, l, p_76491_3_, f, (byte) 1, this.leavesBlock);
|
||||
}
|
||||
}
|
||||
|
||||
void func_150530_a(int[] p_150530_1_, int[] p_150530_2_, Block p_150530_3_)
|
||||
{
|
||||
void func_150530_a(int[] p_150530_1_, int[] p_150530_2_, Block p_150530_3_) {
|
||||
int[] aint2 = new int[] {0, 0, 0};
|
||||
byte b0 = 0;
|
||||
byte b1;
|
||||
|
||||
for (b1 = 0; b0 < 3; ++b0)
|
||||
{
|
||||
for (b1 = 0; b0 < 3; ++b0) {
|
||||
aint2[b0] = p_150530_2_[b0] - p_150530_1_[b0];
|
||||
|
||||
if (Math.abs(aint2[b0]) > Math.abs(aint2[b1]))
|
||||
{
|
||||
if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) {
|
||||
b1 = b0;
|
||||
}
|
||||
}
|
||||
|
||||
if (aint2[b1] != 0)
|
||||
{
|
||||
if (aint2[b1] != 0) {
|
||||
byte b2 = otherCoordPairs[b1];
|
||||
byte b3 = otherCoordPairs[b1 + 3];
|
||||
byte b4;
|
||||
|
||||
if (aint2[b1] > 0)
|
||||
{
|
||||
if (aint2[b1] > 0) {
|
||||
b4 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
b4 = -1;
|
||||
}
|
||||
|
||||
double d0 = (double)aint2[b2] / (double)aint2[b1];
|
||||
double d1 = (double)aint2[b3] / (double)aint2[b1];
|
||||
double d0 = (double) aint2[b2] / (double) aint2[b1];
|
||||
double d1 = (double) aint2[b3] / (double) aint2[b1];
|
||||
int[] aint3 = new int[] {0, 0, 0};
|
||||
int i = 0;
|
||||
|
||||
for (int j = aint2[b1] + b4; i != j; i += b4)
|
||||
{
|
||||
aint3[b1] = MathHelper.floor_double((double)(p_150530_1_[b1] + i) + 0.5D);
|
||||
aint3[b2] = MathHelper.floor_double((double)p_150530_1_[b2] + (double)i * d0 + 0.5D);
|
||||
aint3[b3] = MathHelper.floor_double((double)p_150530_1_[b3] + (double)i * d1 + 0.5D);
|
||||
for (int j = aint2[b1] + b4; i != j; i += b4) {
|
||||
aint3[b1] = MathHelper.floor_double((double) (p_150530_1_[b1] + i) + 0.5D);
|
||||
aint3[b2] = MathHelper.floor_double((double) p_150530_1_[b2] + (double) i * d0 + 0.5D);
|
||||
aint3[b3] = MathHelper.floor_double((double) p_150530_1_[b3] + (double) i * d1 + 0.5D);
|
||||
byte b5 = (byte) this.trunkMeta;
|
||||
int k = Math.abs(aint3[0] - p_150530_1_[0]);
|
||||
int l = Math.abs(aint3[2] - p_150530_1_[2]);
|
||||
int i1 = Math.max(k, l);
|
||||
|
||||
if (i1 > 0)
|
||||
{
|
||||
if (k == i1)
|
||||
{
|
||||
if (i1 > 0) {
|
||||
if (k == i1) {
|
||||
b5 += 4;
|
||||
}
|
||||
else if (l == i1)
|
||||
{
|
||||
} else if (l == i1) {
|
||||
b5 += 8;
|
||||
}
|
||||
}
|
||||
@@ -288,12 +252,10 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
/**
|
||||
* Generates the leaf portion of the tree as specified by the leafNodes list.
|
||||
*/
|
||||
void generateLeaves()
|
||||
{
|
||||
void generateLeaves() {
|
||||
int i = 0;
|
||||
|
||||
for (int j = this.leafNodes.length; i < j; ++i)
|
||||
{
|
||||
for (int j = this.leafNodes.length; i < j; ++i) {
|
||||
int k = this.leafNodes[i][0];
|
||||
int l = this.leafNodes[i][1];
|
||||
int i1 = this.leafNodes[i][2];
|
||||
@@ -304,17 +266,15 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
/**
|
||||
* Indicates whether or not a leaf node requires additional wood to be added to preserve integrity.
|
||||
*/
|
||||
boolean leafNodeNeedsBase(int p_76493_1_)
|
||||
{
|
||||
return (double)p_76493_1_ >= (double)this.heightLimit * 0.2D;
|
||||
boolean leafNodeNeedsBase(int p_76493_1_) {
|
||||
return (double) p_76493_1_ >= (double) this.heightLimit * 0.2D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Places the trunk for the big tree that is being generated. Able to generate double-sized trunks by changing a
|
||||
* field that is always 1 to 2.
|
||||
*/
|
||||
void generateTrunk()
|
||||
{
|
||||
void generateTrunk() {
|
||||
int i = this.basePos[0];
|
||||
int j = this.basePos[1];
|
||||
int k = this.basePos[1] + this.height;
|
||||
@@ -323,8 +283,7 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
int[] aint1 = new int[] {i, k, l};
|
||||
this.func_150530_a(aint, aint1, this.trunkBlock);
|
||||
|
||||
if (this.trunkSize == 2)
|
||||
{
|
||||
if (this.trunkSize == 2) {
|
||||
++aint[0];
|
||||
++aint1[0];
|
||||
this.func_150530_a(aint, aint1, this.trunkBlock);
|
||||
@@ -340,20 +299,17 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
/**
|
||||
* Generates additional wood blocks to fill out the bases of different leaf nodes that would otherwise degrade.
|
||||
*/
|
||||
void generateLeafNodeBases()
|
||||
{
|
||||
void generateLeafNodeBases() {
|
||||
int i = 0;
|
||||
int j = this.leafNodes.length;
|
||||
|
||||
for (int[] aint = new int[] {this.basePos[0], this.basePos[1], this.basePos[2]}; i < j; ++i)
|
||||
{
|
||||
for (int[] aint = new int[] {this.basePos[0], this.basePos[1], this.basePos[2]}; i < j; ++i) {
|
||||
int[] aint1 = this.leafNodes[i];
|
||||
int[] aint2 = new int[] {aint1[0], aint1[1], aint1[2]};
|
||||
aint[1] = aint1[3];
|
||||
int k = aint[1] - this.basePos[1];
|
||||
|
||||
if (this.leafNodeNeedsBase(k))
|
||||
{
|
||||
if (this.leafNodeNeedsBase(k)) {
|
||||
this.func_150530_a(aint, aint2, this.trunkBlock);
|
||||
}
|
||||
}
|
||||
@@ -363,54 +319,43 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
* Checks a line of blocks in the world from the first coordinate to triplet to the second, returning the distance
|
||||
* (in blocks) before a non-air, non-leaf block is encountered and/or the end is encountered.
|
||||
*/
|
||||
int checkBlockLine(int[] p_76496_1_, int[] p_76496_2_)
|
||||
{
|
||||
int checkBlockLine(int[] p_76496_1_, int[] p_76496_2_) {
|
||||
int[] aint2 = new int[] {0, 0, 0};
|
||||
byte b0 = 0;
|
||||
byte b1;
|
||||
|
||||
for (b1 = 0; b0 < 3; ++b0)
|
||||
{
|
||||
for (b1 = 0; b0 < 3; ++b0) {
|
||||
aint2[b0] = p_76496_2_[b0] - p_76496_1_[b0];
|
||||
|
||||
if (Math.abs(aint2[b0]) > Math.abs(aint2[b1]))
|
||||
{
|
||||
if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) {
|
||||
b1 = b0;
|
||||
}
|
||||
}
|
||||
|
||||
if (aint2[b1] == 0)
|
||||
{
|
||||
if (aint2[b1] == 0) {
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
byte b2 = otherCoordPairs[b1];
|
||||
byte b3 = otherCoordPairs[b1 + 3];
|
||||
byte b4;
|
||||
|
||||
if (aint2[b1] > 0)
|
||||
{
|
||||
if (aint2[b1] > 0) {
|
||||
b4 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
b4 = -1;
|
||||
}
|
||||
|
||||
double d0 = (double)aint2[b2] / (double)aint2[b1];
|
||||
double d1 = (double)aint2[b3] / (double)aint2[b1];
|
||||
double d0 = (double) aint2[b2] / (double) aint2[b1];
|
||||
double d1 = (double) aint2[b3] / (double) aint2[b1];
|
||||
int[] aint3 = new int[] {0, 0, 0};
|
||||
int i = 0;
|
||||
int j;
|
||||
|
||||
for (j = aint2[b1] + b4; i != j; i += b4)
|
||||
{
|
||||
for (j = aint2[b1] + b4; i != j; i += b4) {
|
||||
aint3[b1] = p_76496_1_[b1] + i;
|
||||
aint3[b2] = MathHelper.floor_double((double)p_76496_1_[b2] + (double)i * d0);
|
||||
aint3[b3] = MathHelper.floor_double((double)p_76496_1_[b3] + (double)i * d1);
|
||||
if (!this.isReplaceable(worldObj, aint3[0], aint3[1], aint3[2]))
|
||||
{
|
||||
aint3[b2] = MathHelper.floor_double((double) p_76496_1_[b2] + (double) i * d0);
|
||||
aint3[b3] = MathHelper.floor_double((double) p_76496_1_[b3] + (double) i * d1);
|
||||
if (!this.isReplaceable(worldObj, aint3[0], aint3[1], aint3[2])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -423,31 +368,23 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
* Returns a boolean indicating whether or not the current location for the tree, spanning basePos to to the height
|
||||
* limit, is valid.
|
||||
*/
|
||||
boolean validTreeLocation()
|
||||
{
|
||||
boolean validTreeLocation() {
|
||||
int[] aint = new int[] {this.basePos[0], this.basePos[1], this.basePos[2]};
|
||||
int[] aint1 = new int[] {this.basePos[0], this.basePos[1] + this.heightLimit - 1, this.basePos[2]};
|
||||
Block block = this.worldObj.getBlock(this.basePos[0], this.basePos[1] - 1, this.basePos[2]);
|
||||
|
||||
boolean isSoil = block.canSustainPlant(worldObj, basePos[0], basePos[1] - 1, basePos[2], ForgeDirection.UP, (IPlantable) TBBlocks.sapling);
|
||||
if (!isSoil)
|
||||
{
|
||||
boolean isSoil = block.canSustainPlant(
|
||||
worldObj, basePos[0], basePos[1] - 1, basePos[2], ForgeDirection.UP, (IPlantable) TBBlocks.sapling);
|
||||
if (!isSoil) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int i = this.checkBlockLine(aint, aint1);
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
if (i == -1) {
|
||||
return true;
|
||||
}
|
||||
else if (i < 6)
|
||||
{
|
||||
} else if (i < 6) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.heightLimit = i;
|
||||
return true;
|
||||
}
|
||||
@@ -457,12 +394,10 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
/**
|
||||
* Rescales the generator settings, only used in WorldGenBigTree
|
||||
*/
|
||||
public void setScale(double p_76487_1_, double p_76487_3_, double p_76487_5_)
|
||||
{
|
||||
this.heightLimitLimit = (int)(p_76487_1_ * 12.0D);
|
||||
public void setScale(double p_76487_1_, double p_76487_3_, double p_76487_5_) {
|
||||
this.heightLimitLimit = (int) (p_76487_1_ * 12.0D);
|
||||
|
||||
if (p_76487_1_ > 0.5D)
|
||||
{
|
||||
if (p_76487_1_ > 0.5D) {
|
||||
this.leafDistanceLimit = 5;
|
||||
}
|
||||
|
||||
@@ -470,8 +405,7 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
this.leafDensity = p_76487_5_;
|
||||
}
|
||||
|
||||
public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_)
|
||||
{
|
||||
public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_) {
|
||||
this.worldObj = p_76484_1_;
|
||||
long l = p_76484_2_.nextLong();
|
||||
this.rand.setSeed(l);
|
||||
@@ -479,24 +413,20 @@ public class WorldGenBigOak extends WorldGenAbstractTree
|
||||
this.basePos[1] = p_76484_4_;
|
||||
this.basePos[2] = p_76484_5_;
|
||||
|
||||
if (this.heightLimit == 0)
|
||||
{
|
||||
if (this.heightLimit == 0) {
|
||||
this.heightLimit = 5 + this.rand.nextInt(this.heightLimitLimit);
|
||||
}
|
||||
|
||||
if (!this.validTreeLocation())
|
||||
{
|
||||
this.worldObj = null; //Fix vanilla Mem leak, holds latest world
|
||||
if (!this.validTreeLocation()) {
|
||||
this.worldObj = null; // Fix vanilla Mem leak, holds latest world
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.generateLeafNodeList();
|
||||
this.generateLeaves();
|
||||
this.generateTrunk();
|
||||
this.generateLeafNodeBases();
|
||||
this.worldObj = null; //Fix vanilla Mem leak, holds latest world
|
||||
this.worldObj = null; // Fix vanilla Mem leak, holds latest world
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package tb.common.event;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -9,81 +8,72 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenTrees;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class WorldGenOak extends WorldGenTrees{
|
||||
|
||||
public Block leavesBlock;
|
||||
public Block trunkBlock;
|
||||
public int leavesMeta;
|
||||
public int trunkMeta;
|
||||
public int minTreeHeight;
|
||||
public class WorldGenOak extends WorldGenTrees {
|
||||
|
||||
public WorldGenOak(boolean doBlockNotify, int minHeight,int metaWood, int metaLeaves, boolean doVines, Block tree, Block leaves) {
|
||||
super(doBlockNotify, minHeight, metaWood, metaLeaves, doVines);
|
||||
trunkMeta = metaWood;
|
||||
leavesMeta = metaLeaves;
|
||||
leavesBlock = leaves;
|
||||
trunkBlock = tree;
|
||||
minTreeHeight = minHeight;
|
||||
}
|
||||
|
||||
public boolean generate(World w, Random rnd, int x, int y, int z)
|
||||
{
|
||||
int height = rnd.nextInt(3) + this.minTreeHeight;
|
||||
boolean flag = true;
|
||||
|
||||
if (y >= 1 && y + height + 1 <= 256)
|
||||
{
|
||||
public Block leavesBlock;
|
||||
public Block trunkBlock;
|
||||
public int leavesMeta;
|
||||
public int trunkMeta;
|
||||
public int minTreeHeight;
|
||||
|
||||
public WorldGenOak(
|
||||
boolean doBlockNotify,
|
||||
int minHeight,
|
||||
int metaWood,
|
||||
int metaLeaves,
|
||||
boolean doVines,
|
||||
Block tree,
|
||||
Block leaves) {
|
||||
super(doBlockNotify, minHeight, metaWood, metaLeaves, doVines);
|
||||
trunkMeta = metaWood;
|
||||
leavesMeta = metaLeaves;
|
||||
leavesBlock = leaves;
|
||||
trunkBlock = tree;
|
||||
minTreeHeight = minHeight;
|
||||
}
|
||||
|
||||
public boolean generate(World w, Random rnd, int x, int y, int z) {
|
||||
int height = rnd.nextInt(3) + this.minTreeHeight;
|
||||
boolean flag = true;
|
||||
|
||||
if (y >= 1 && y + height + 1 <= 256) {
|
||||
byte b0;
|
||||
int k1;
|
||||
Block block;
|
||||
|
||||
for (int i1 = y; i1 <= y + 1 + height; ++i1)
|
||||
{
|
||||
|
||||
for (int i1 = y; i1 <= y + 1 + height; ++i1) {
|
||||
b0 = 1;
|
||||
|
||||
if (i1 == y)
|
||||
{
|
||||
if (i1 == y) {
|
||||
b0 = 0;
|
||||
}
|
||||
|
||||
if (i1 >= y + 1 + height - 2)
|
||||
{
|
||||
if (i1 >= y + 1 + height - 2) {
|
||||
b0 = 2;
|
||||
}
|
||||
|
||||
for (int j1 = x - b0; j1 <= x + b0 && flag; ++j1)
|
||||
{
|
||||
for (k1 = z - b0; k1 <= z + b0 && flag; ++k1)
|
||||
{
|
||||
if (i1 >= 0 && i1 < 256)
|
||||
{
|
||||
for (int j1 = x - b0; j1 <= x + b0 && flag; ++j1) {
|
||||
for (k1 = z - b0; k1 <= z + b0 && flag; ++k1) {
|
||||
if (i1 >= 0 && i1 < 256) {
|
||||
block = w.getBlock(j1, i1, k1);
|
||||
|
||||
if (!this.isReplaceable(w, j1, i1, k1))
|
||||
{
|
||||
|
||||
if (!this.isReplaceable(w, j1, i1, k1)) {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
|
||||
if (!flag) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Block block2 = w.getBlock(x, y - 1, z);
|
||||
|
||||
boolean isSoil = block2.canSustainPlant(w, x, y - 1, z, ForgeDirection.UP, (BlockSapling)Blocks.sapling);
|
||||
if (isSoil && y < 256 - height - 1)
|
||||
{
|
||||
boolean isSoil =
|
||||
block2.canSustainPlant(w, x, y - 1, z, ForgeDirection.UP, (BlockSapling) Blocks.sapling);
|
||||
if (isSoil && y < 256 - height - 1) {
|
||||
block2.onPlantGrow(w, x, y - 1, z, x, y, z);
|
||||
b0 = 3;
|
||||
byte b1 = 0;
|
||||
@@ -92,51 +82,42 @@ public class WorldGenOak extends WorldGenTrees{
|
||||
int j2;
|
||||
int i3;
|
||||
|
||||
for (k1 = y - b0 + height; k1 <= y + height; ++k1)
|
||||
{
|
||||
for (k1 = y - b0 + height; k1 <= y + height; ++k1) {
|
||||
i3 = k1 - (y + height);
|
||||
l1 = b1 + 1 - i3 / 2;
|
||||
|
||||
for (i2 = x - l1; i2 <= x + l1; ++i2)
|
||||
{
|
||||
for (i2 = x - l1; i2 <= x + l1; ++i2) {
|
||||
j2 = i2 - x;
|
||||
|
||||
for (int k2 = z - l1; k2 <= z + l1; ++k2)
|
||||
{
|
||||
for (int k2 = z - l1; k2 <= z + l1; ++k2) {
|
||||
int l2 = k2 - z;
|
||||
|
||||
if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || rnd.nextInt(2) != 0 && i3 != 0)
|
||||
{
|
||||
if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || rnd.nextInt(2) != 0 && i3 != 0) {
|
||||
Block block1 = w.getBlock(i2, k1, k2);
|
||||
|
||||
if (block1.isAir(w, i2, k1, k2) || block1.isLeaves(w, i2, k1, k2))
|
||||
{
|
||||
this.setBlockAndNotifyAdequately(w, i2, k1, k2, this.leavesBlock, this.leavesMeta);
|
||||
if (block1.isAir(w, i2, k1, k2) || block1.isLeaves(w, i2, k1, k2)) {
|
||||
this.setBlockAndNotifyAdequately(
|
||||
w, i2, k1, k2, this.leavesBlock, this.leavesMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (k1 = 0; k1 < height; ++k1)
|
||||
{
|
||||
for (k1 = 0; k1 < height; ++k1) {
|
||||
block = w.getBlock(x, y + k1, z);
|
||||
|
||||
if (block.isAir(w, x, y + k1, z) || block.isLeaves(w, x, y + k1, z))
|
||||
{
|
||||
if (block.isAir(w, x, y + k1, z) || block.isLeaves(w, x, y + k1, z)) {
|
||||
this.setBlockAndNotifyAdequately(w, x, y + k1, z, this.trunkBlock, this.trunkMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2,71 +2,61 @@ package tb.common.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class ContainerOverchanter extends Container{
|
||||
public class ContainerOverchanter extends Container {
|
||||
|
||||
public ContainerOverchanter(InventoryPlayer playerInv, TileEntity blockInv)
|
||||
{
|
||||
this.addSlotToContainer(new Slot((IInventory) blockInv,0,80,20));
|
||||
public ContainerOverchanter(InventoryPlayer playerInv, TileEntity blockInv) {
|
||||
this.addSlotToContainer(new Slot((IInventory) blockInv, 0, 80, 20));
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
public ItemStack transferStackInSlot(EntityPlayer p, int slot)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)this.inventorySlots.get(par2);
|
||||
if ((slot != null) && (slot.getHasStack()))
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
if (par2 < 1)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 1, this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 0, 1, false)) {
|
||||
return null;
|
||||
}
|
||||
if (itemstack1.stackSize == 0) {
|
||||
slot.putStack((ItemStack)null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(par2);
|
||||
if ((slot != null) && (slot.getHasStack())) {
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
if (par2 < 1) {
|
||||
if (!mergeItemStack(itemstack1, 1, this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if (!mergeItemStack(itemstack1, 0, 1, false)) {
|
||||
return null;
|
||||
}
|
||||
if (itemstack1.stackSize == 0) {
|
||||
slot.putStack((ItemStack) null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
@@ -9,210 +9,171 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ContainerRevolver extends Container
|
||||
{
|
||||
public World worldObj;
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
public IInventory input = new InventoryRevolver(this);
|
||||
public ItemStack stack = null;
|
||||
public EntityPlayer player = null;
|
||||
|
||||
public int blockedSlot;
|
||||
public class ContainerRevolver extends Container {
|
||||
public World worldObj;
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
public IInventory input = new InventoryRevolver(this);
|
||||
public ItemStack stack = null;
|
||||
public EntityPlayer player = null;
|
||||
|
||||
public ContainerRevolver(InventoryPlayer inv, World w, int ix, int iy, int iz)
|
||||
{
|
||||
this.worldObj = w;
|
||||
this.x = ix;
|
||||
this.y = iy;
|
||||
this.z = iz;
|
||||
this.player = inv.player;
|
||||
this.stack = inv.getCurrentItem();
|
||||
this.blockedSlot = inv.currentItem + 28;
|
||||
public int blockedSlot;
|
||||
|
||||
addSlotToContainer(new Slot(this.input, 0, 80, 32));
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 9; j++)
|
||||
addSlotToContainer(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
addSlotToContainer(new Slot(inv, i, 8 + i * 18, 142));
|
||||
|
||||
if (!w.isRemote)
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemStack jar = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("jar"));
|
||||
this.input.setInventorySlotContents(0, jar);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//...
|
||||
}
|
||||
}
|
||||
|
||||
onCraftMatrixChanged(this.input);
|
||||
}
|
||||
public ContainerRevolver(InventoryPlayer inv, World w, int ix, int iy, int iz) {
|
||||
this.worldObj = w;
|
||||
this.x = ix;
|
||||
this.y = iy;
|
||||
this.z = iz;
|
||||
this.player = inv.player;
|
||||
this.stack = inv.getCurrentItem();
|
||||
this.blockedSlot = inv.currentItem + 28;
|
||||
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slot)
|
||||
{
|
||||
if (slot == this.blockedSlot)
|
||||
return null;
|
||||
|
||||
ItemStack stack = null;
|
||||
Slot slotObject = (Slot)this.inventorySlots.get(slot);
|
||||
addSlotToContainer(new Slot(this.input, 0, 80, 32));
|
||||
|
||||
if (slotObject != null && slotObject.getHasStack())
|
||||
{
|
||||
ItemStack stackInSlot = slotObject.getStack();
|
||||
stack = stackInSlot.copy();
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 9; j++) addSlotToContainer(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
|
||||
if (slot == 0)
|
||||
{
|
||||
if (!this.input.isItemValidForSlot(slot, stackInSlot) || !mergeItemStack(stackInSlot, 1, this.inventorySlots.size(), true, 64))
|
||||
return null;
|
||||
}
|
||||
else if (!this.input.isItemValidForSlot(slot, stackInSlot) || !mergeItemStack(stackInSlot, 0, 1, false, 1))
|
||||
return null;
|
||||
|
||||
if (stackInSlot.stackSize == 0)
|
||||
slotObject.putStack(null);
|
||||
else
|
||||
slotObject.onSlotChanged();
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
for (int i = 0; i < 9; i++) addSlotToContainer(new Slot(inv, i, 8 + i * 18, 142));
|
||||
|
||||
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer)
|
||||
{
|
||||
if (par1 == this.blockedSlot)
|
||||
return null;
|
||||
|
||||
InventoryPlayer inventoryplayer = par4EntityPlayer.inventory;
|
||||
if (par1 != 0 || this.input.isItemValidForSlot(par1, inventoryplayer.getItemStack()) || (par1 == 0 && inventoryplayer.getItemStack() == null))
|
||||
return super.slotClick(par1, par2, par3, par4EntityPlayer);
|
||||
|
||||
return null;
|
||||
}
|
||||
if (!w.isRemote) {
|
||||
try {
|
||||
ItemStack jar = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("jar"));
|
||||
this.input.setInventorySlotContents(0, jar);
|
||||
} catch (Exception e) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canInteractWith(EntityPlayer p)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
onCraftMatrixChanged(this.input);
|
||||
}
|
||||
|
||||
public void putStackInSlot(int slot, ItemStack stk)
|
||||
{
|
||||
if (this.input.isItemValidForSlot(slot, stk))
|
||||
super.putStackInSlot(slot, stk);
|
||||
}
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slot) {
|
||||
if (slot == this.blockedSlot) return null;
|
||||
|
||||
public void onContainerClosed(EntityPlayer p)
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
ItemStack var3 = this.input.getStackInSlotOnClosing(0);
|
||||
if (var3 != null)
|
||||
{
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var3.writeToNBT(var4);
|
||||
this.stack.setTagInfo("jar", var4);
|
||||
this.stack.getTagCompound().setBoolean("hasJar", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.stack.setTagInfo("jar", new NBTTagCompound());
|
||||
this.stack.getTagCompound().setBoolean("hasJar", false);
|
||||
}
|
||||
|
||||
if (this.player == null)
|
||||
return;
|
||||
|
||||
if (this.player.getHeldItem() != null && this.player.getHeldItem().isItemEqual(this.stack))
|
||||
this.player.setCurrentItemOrArmor(0, this.stack);
|
||||
|
||||
this.player.inventory.markDirty();
|
||||
}
|
||||
}
|
||||
ItemStack stack = null;
|
||||
Slot slotObject = (Slot) this.inventorySlots.get(slot);
|
||||
|
||||
protected boolean mergeItemStack(ItemStack par1ItemStack, int par2, int par3, boolean par4, int limit)
|
||||
{
|
||||
boolean var5 = false;
|
||||
int var6 = par2;
|
||||
|
||||
if (par4)
|
||||
{
|
||||
var6 = par3 - 1;
|
||||
}
|
||||
if (slotObject != null && slotObject.getHasStack()) {
|
||||
ItemStack stackInSlot = slotObject.getStack();
|
||||
stack = stackInSlot.copy();
|
||||
|
||||
if (par1ItemStack.isStackable())
|
||||
{
|
||||
while (par1ItemStack.stackSize > 0 && ((!par4 && var6 < par3) || (par4 && var6 >= par2)))
|
||||
{
|
||||
Slot var7 = (Slot)this.inventorySlots.get(var6);
|
||||
ItemStack var8 = var7.getStack();
|
||||
if (slot == 0) {
|
||||
if (!this.input.isItemValidForSlot(slot, stackInSlot)
|
||||
|| !mergeItemStack(stackInSlot, 1, this.inventorySlots.size(), true, 64)) return null;
|
||||
} else if (!this.input.isItemValidForSlot(slot, stackInSlot)
|
||||
|| !mergeItemStack(stackInSlot, 0, 1, false, 1)) return null;
|
||||
|
||||
if (var8 != null && var8.getItem() == par1ItemStack.getItem() && (!par1ItemStack.getHasSubtypes() || par1ItemStack.getItemDamage() == var8.getItemDamage()) && ItemStack.areItemStackTagsEqual(par1ItemStack, var8))
|
||||
{
|
||||
int var9 = var8.stackSize + par1ItemStack.stackSize;
|
||||
if (stackInSlot.stackSize == 0) slotObject.putStack(null);
|
||||
else slotObject.onSlotChanged();
|
||||
}
|
||||
|
||||
if (var9 <= Math.min(par1ItemStack.getMaxStackSize(), limit))
|
||||
{
|
||||
par1ItemStack.stackSize = 0;
|
||||
var8.stackSize = var9;
|
||||
var7.onSlotChanged();
|
||||
var5 = true;
|
||||
}
|
||||
else if (var8.stackSize < Math.min(par1ItemStack.getMaxStackSize(), limit))
|
||||
{
|
||||
par1ItemStack.stackSize -= Math.min(par1ItemStack.getMaxStackSize(), limit) - var8.stackSize;
|
||||
var8.stackSize = Math.min(par1ItemStack.getMaxStackSize(), limit);
|
||||
var7.onSlotChanged();
|
||||
var5 = true;
|
||||
}
|
||||
}
|
||||
if (par4)
|
||||
{
|
||||
var6--;
|
||||
}
|
||||
else
|
||||
{
|
||||
var6++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackSize > 0)
|
||||
{
|
||||
if (par4)
|
||||
var6 = par3 - 1;
|
||||
else
|
||||
var6 = par2;
|
||||
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) {
|
||||
if (par1 == this.blockedSlot) return null;
|
||||
|
||||
while ((!par4 && var6 < par3) || (par4 && var6 >= par2))
|
||||
{
|
||||
Slot var7 = (Slot)this.inventorySlots.get(var6);
|
||||
ItemStack var8 = var7.getStack();
|
||||
InventoryPlayer inventoryplayer = par4EntityPlayer.inventory;
|
||||
if (par1 != 0
|
||||
|| this.input.isItemValidForSlot(par1, inventoryplayer.getItemStack())
|
||||
|| (par1 == 0 && inventoryplayer.getItemStack() == null))
|
||||
return super.slotClick(par1, par2, par3, par4EntityPlayer);
|
||||
|
||||
if (var8 == null)
|
||||
{
|
||||
ItemStack res = par1ItemStack.copy();
|
||||
res.stackSize = Math.min(res.stackSize, limit);
|
||||
var7.putStack(res);
|
||||
var7.onSlotChanged();
|
||||
par1ItemStack.stackSize -= res.stackSize;
|
||||
var5 = true;
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (par4)
|
||||
var6--;
|
||||
else
|
||||
var6++;
|
||||
}
|
||||
}
|
||||
return var5;
|
||||
}
|
||||
}
|
||||
public boolean canInteractWith(EntityPlayer p) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void putStackInSlot(int slot, ItemStack stk) {
|
||||
if (this.input.isItemValidForSlot(slot, stk)) super.putStackInSlot(slot, stk);
|
||||
}
|
||||
|
||||
public void onContainerClosed(EntityPlayer p) {
|
||||
if (!this.worldObj.isRemote) {
|
||||
ItemStack var3 = this.input.getStackInSlotOnClosing(0);
|
||||
if (var3 != null) {
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var3.writeToNBT(var4);
|
||||
this.stack.setTagInfo("jar", var4);
|
||||
this.stack.getTagCompound().setBoolean("hasJar", true);
|
||||
} else {
|
||||
this.stack.setTagInfo("jar", new NBTTagCompound());
|
||||
this.stack.getTagCompound().setBoolean("hasJar", false);
|
||||
}
|
||||
|
||||
if (this.player == null) return;
|
||||
|
||||
if (this.player.getHeldItem() != null && this.player.getHeldItem().isItemEqual(this.stack))
|
||||
this.player.setCurrentItemOrArmor(0, this.stack);
|
||||
|
||||
this.player.inventory.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean mergeItemStack(ItemStack par1ItemStack, int par2, int par3, boolean par4, int limit) {
|
||||
boolean var5 = false;
|
||||
int var6 = par2;
|
||||
|
||||
if (par4) {
|
||||
var6 = par3 - 1;
|
||||
}
|
||||
|
||||
if (par1ItemStack.isStackable()) {
|
||||
while (par1ItemStack.stackSize > 0 && ((!par4 && var6 < par3) || (par4 && var6 >= par2))) {
|
||||
Slot var7 = (Slot) this.inventorySlots.get(var6);
|
||||
ItemStack var8 = var7.getStack();
|
||||
|
||||
if (var8 != null
|
||||
&& var8.getItem() == par1ItemStack.getItem()
|
||||
&& (!par1ItemStack.getHasSubtypes() || par1ItemStack.getItemDamage() == var8.getItemDamage())
|
||||
&& ItemStack.areItemStackTagsEqual(par1ItemStack, var8)) {
|
||||
int var9 = var8.stackSize + par1ItemStack.stackSize;
|
||||
|
||||
if (var9 <= Math.min(par1ItemStack.getMaxStackSize(), limit)) {
|
||||
par1ItemStack.stackSize = 0;
|
||||
var8.stackSize = var9;
|
||||
var7.onSlotChanged();
|
||||
var5 = true;
|
||||
} else if (var8.stackSize < Math.min(par1ItemStack.getMaxStackSize(), limit)) {
|
||||
par1ItemStack.stackSize -= Math.min(par1ItemStack.getMaxStackSize(), limit) - var8.stackSize;
|
||||
var8.stackSize = Math.min(par1ItemStack.getMaxStackSize(), limit);
|
||||
var7.onSlotChanged();
|
||||
var5 = true;
|
||||
}
|
||||
}
|
||||
if (par4) {
|
||||
var6--;
|
||||
} else {
|
||||
var6++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (par1ItemStack.stackSize > 0) {
|
||||
if (par4) var6 = par3 - 1;
|
||||
else var6 = par2;
|
||||
|
||||
while ((!par4 && var6 < par3) || (par4 && var6 >= par2)) {
|
||||
Slot var7 = (Slot) this.inventorySlots.get(var6);
|
||||
ItemStack var8 = var7.getStack();
|
||||
|
||||
if (var8 == null) {
|
||||
ItemStack res = par1ItemStack.copy();
|
||||
res.stackSize = Math.min(res.stackSize, limit);
|
||||
var7.putStack(res);
|
||||
var7.onSlotChanged();
|
||||
par1ItemStack.stackSize -= res.stackSize;
|
||||
var5 = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (par4) var6--;
|
||||
else var6++;
|
||||
}
|
||||
}
|
||||
return var5;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
package tb.common.inventory;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import tb.init.TBBlocks;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -22,14 +18,14 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import tb.init.TBBlocks;
|
||||
|
||||
public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
public class ContainerThaumicAnvil extends ContainerRepair {
|
||||
|
||||
private IInventory outputSlot = new InventoryCraftResult();
|
||||
private IInventory inputSlots = new InventoryBasic("Repair", true, 2)
|
||||
{
|
||||
public void markDirty()
|
||||
{
|
||||
private IInventory outputSlot = new InventoryCraftResult();
|
||||
private IInventory inputSlots = new InventoryBasic("Repair", true, 2) {
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
ContainerThaumicAnvil.this.onCraftMatrixChanged(this);
|
||||
}
|
||||
@@ -40,138 +36,124 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public ContainerThaumicAnvil(InventoryPlayer inv, World w,int x, int y, int z,EntityPlayer p)
|
||||
{
|
||||
super(inv, w, x, y, z, p);
|
||||
thePlayer = p;
|
||||
|
||||
this.crafters.clear();
|
||||
this.inventoryItemStacks.clear();
|
||||
this.inventorySlots.clear();
|
||||
|
||||
this.w = w;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
final World fw = w;
|
||||
final int fx = x;
|
||||
final int fy = y;
|
||||
final int fz = z;
|
||||
|
||||
|
||||
public ContainerThaumicAnvil(InventoryPlayer inv, World w, int x, int y, int z, EntityPlayer p) {
|
||||
super(inv, w, x, y, z, p);
|
||||
thePlayer = p;
|
||||
|
||||
this.crafters.clear();
|
||||
this.inventoryItemStacks.clear();
|
||||
this.inventorySlots.clear();
|
||||
|
||||
this.w = w;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
final World fw = w;
|
||||
final int fx = x;
|
||||
final int fy = y;
|
||||
final int fz = z;
|
||||
|
||||
this.addSlotToContainer(new Slot(this.inputSlots, 0, 27, 47));
|
||||
this.addSlotToContainer(new Slot(this.inputSlots, 1, 76, 47));
|
||||
this.addSlotToContainer(new Slot(this.outputSlot, 2, 134, 47)
|
||||
{
|
||||
public boolean isItemValid(ItemStack stk)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(this.outputSlot, 2, 134, 47) {
|
||||
public boolean isItemValid(ItemStack stk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canTakeStack(EntityPlayer p_82869_1_)
|
||||
{
|
||||
return (p_82869_1_.capabilities.isCreativeMode || p_82869_1_.experienceLevel >= ContainerThaumicAnvil.this.maximumCost) && ContainerThaumicAnvil.this.maximumCost > 0 && this.getHasStack();
|
||||
|
||||
public boolean canTakeStack(EntityPlayer p_82869_1_) {
|
||||
return (p_82869_1_.capabilities.isCreativeMode
|
||||
|| p_82869_1_.experienceLevel >= ContainerThaumicAnvil.this.maximumCost)
|
||||
&& ContainerThaumicAnvil.this.maximumCost > 0
|
||||
&& this.getHasStack();
|
||||
}
|
||||
public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_)
|
||||
{
|
||||
if (!p_82870_1_.capabilities.isCreativeMode)
|
||||
{
|
||||
|
||||
public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_) {
|
||||
if (!p_82870_1_.capabilities.isCreativeMode) {
|
||||
p_82870_1_.addExperienceLevel(-ContainerThaumicAnvil.this.maximumCost);
|
||||
}
|
||||
|
||||
float breakChance = ForgeHooks.onAnvilRepair(p_82870_1_, p_82870_2_, ContainerThaumicAnvil.this.inputSlots.getStackInSlot(0), ContainerThaumicAnvil.this.inputSlots.getStackInSlot(1))/3;
|
||||
float breakChance = ForgeHooks.onAnvilRepair(
|
||||
p_82870_1_,
|
||||
p_82870_2_,
|
||||
ContainerThaumicAnvil.this.inputSlots.getStackInSlot(0),
|
||||
ContainerThaumicAnvil.this.inputSlots.getStackInSlot(1))
|
||||
/ 3;
|
||||
|
||||
ContainerThaumicAnvil.this.inputSlots.setInventorySlotContents(0, (ItemStack)null);
|
||||
ContainerThaumicAnvil.this.inputSlots.setInventorySlotContents(0, (ItemStack) null);
|
||||
|
||||
if (ContainerThaumicAnvil.this.stackSizeToBeUsedInRepair > 0)
|
||||
{
|
||||
if (ContainerThaumicAnvil.this.stackSizeToBeUsedInRepair > 0) {
|
||||
ItemStack itemstack1 = ContainerThaumicAnvil.this.inputSlots.getStackInSlot(1);
|
||||
|
||||
if (itemstack1 != null && itemstack1.stackSize > ContainerThaumicAnvil.this.stackSizeToBeUsedInRepair)
|
||||
{
|
||||
if (itemstack1 != null
|
||||
&& itemstack1.stackSize > ContainerThaumicAnvil.this.stackSizeToBeUsedInRepair) {
|
||||
itemstack1.stackSize -= ContainerThaumicAnvil.this.stackSizeToBeUsedInRepair;
|
||||
ContainerThaumicAnvil.this.inputSlots.setInventorySlotContents(1, itemstack1);
|
||||
} else {
|
||||
ContainerThaumicAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
ContainerThaumicAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack)null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ContainerThaumicAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack)null);
|
||||
} else {
|
||||
ContainerThaumicAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack) null);
|
||||
}
|
||||
|
||||
ContainerThaumicAnvil.this.maximumCost = 0;
|
||||
|
||||
if (!p_82870_1_.capabilities.isCreativeMode && !fw.isRemote && fw.getBlock(fx, fy, fz) == TBBlocks.thaumicAnvil && p_82870_1_.getRNG().nextFloat() < breakChance)
|
||||
{
|
||||
if (!p_82870_1_.capabilities.isCreativeMode
|
||||
&& !fw.isRemote
|
||||
&& fw.getBlock(fx, fy, fz) == TBBlocks.thaumicAnvil
|
||||
&& p_82870_1_.getRNG().nextFloat() < breakChance) {
|
||||
int i1 = fw.getBlockMetadata(fx, fy, fz);
|
||||
int k = i1 & 3;
|
||||
int l = i1 >> 2;
|
||||
++l;
|
||||
|
||||
if (l > 2)
|
||||
{
|
||||
if (l > 2) {
|
||||
fw.setBlockToAir(fx, fy, fz);
|
||||
fw.playAuxSFX(1020, fx, fy, fz, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fw.setBlockMetadataWithNotify(fx, fy, fz, k | l << 2, 2);
|
||||
fw.playAuxSFX(1021, fx, fy, fz, 0);
|
||||
}
|
||||
}
|
||||
else if (!fw.isRemote)
|
||||
{
|
||||
} else if (!fw.isRemote) {
|
||||
fw.playAuxSFX(1021, fx, fy, fz, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(inv, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
public void onCraftMatrixChanged(IInventory p_75130_1_)
|
||||
{
|
||||
}
|
||||
|
||||
public void onCraftMatrixChanged(IInventory p_75130_1_) {
|
||||
super.onCraftMatrixChanged(p_75130_1_);
|
||||
|
||||
if (p_75130_1_ == this.inputSlots)
|
||||
{
|
||||
if (p_75130_1_ == this.inputSlots) {
|
||||
this.updateRepairOutput();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void updateRepairOutput()
|
||||
{
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void updateRepairOutput() {
|
||||
ItemStack itemstack = this.inputSlots.getStackInSlot(0);
|
||||
this.maximumCost = 0;
|
||||
int i = 0;
|
||||
byte b0 = 0;
|
||||
int j = 0;
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack)null);
|
||||
if (itemstack == null) {
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack) null);
|
||||
this.maximumCost = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
ItemStack itemstack2 = this.inputSlots.getStackInSlot(1);
|
||||
Map map = EnchantmentHelper.getEnchantments(itemstack1);
|
||||
@@ -186,24 +168,21 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
Iterator iterator1;
|
||||
Enchantment enchantment;
|
||||
|
||||
if (itemstack2 != null)
|
||||
{
|
||||
if (itemstack2 != null) {
|
||||
if (!ForgeHooks.onAnvilChange(this, itemstack, itemstack2, outputSlot, repairedItemName, k2)) return;
|
||||
flag = itemstack2.getItem() == Items.enchanted_book && Items.enchanted_book.func_92110_g(itemstack2).tagCount() > 0;
|
||||
flag = itemstack2.getItem() == Items.enchanted_book
|
||||
&& Items.enchanted_book.func_92110_g(itemstack2).tagCount() > 0;
|
||||
|
||||
if (itemstack1.isItemStackDamageable() && itemstack1.getItem().getIsRepairable(itemstack, itemstack2))
|
||||
{
|
||||
if (itemstack1.isItemStackDamageable() && itemstack1.getItem().getIsRepairable(itemstack, itemstack2)) {
|
||||
k = Math.min(itemstack1.getItemDamageForDisplay(), itemstack1.getMaxDamage() / 4);
|
||||
|
||||
if (k <= 0)
|
||||
{
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack)null);
|
||||
if (k <= 0) {
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack) null);
|
||||
this.maximumCost = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
for (l = 0; k > 0 && l < itemstack2.stackSize; ++l)
|
||||
{
|
||||
for (l = 0; k > 0 && l < itemstack2.stackSize; ++l) {
|
||||
i1 = itemstack1.getItemDamageForDisplay() - k;
|
||||
itemstack1.setItemDamage(i1);
|
||||
i += Math.max(1, k / 100) + map.size();
|
||||
@@ -211,31 +190,26 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
}
|
||||
|
||||
this.stackSizeToBeUsedInRepair = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.isItemStackDamageable()))
|
||||
{
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack)null);
|
||||
} else {
|
||||
if (!flag
|
||||
&& (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.isItemStackDamageable())) {
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack) null);
|
||||
this.maximumCost = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemstack1.isItemStackDamageable() && !flag)
|
||||
{
|
||||
if (itemstack1.isItemStackDamageable() && !flag) {
|
||||
k = itemstack.getMaxDamage() - itemstack.getItemDamageForDisplay();
|
||||
l = itemstack2.getMaxDamage() - itemstack2.getItemDamageForDisplay();
|
||||
i1 = l + itemstack1.getMaxDamage() * 12 / 100;
|
||||
int j1 = k + i1;
|
||||
k1 = itemstack1.getMaxDamage() - j1;
|
||||
|
||||
if (k1 < 0)
|
||||
{
|
||||
if (k1 < 0) {
|
||||
k1 = 0;
|
||||
}
|
||||
|
||||
if (k1 < itemstack1.getItemDamage())
|
||||
{
|
||||
if (k1 < itemstack1.getItemDamage()) {
|
||||
itemstack1.setItemDamage(k1);
|
||||
i += Math.max(1, i1 / 100);
|
||||
}
|
||||
@@ -244,21 +218,19 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
Map map1 = EnchantmentHelper.getEnchantments(itemstack2);
|
||||
iterator1 = map1.keySet().iterator();
|
||||
|
||||
while (iterator1.hasNext())
|
||||
{
|
||||
i1 = ((Integer)iterator1.next()).intValue();
|
||||
while (iterator1.hasNext()) {
|
||||
i1 = ((Integer) iterator1.next()).intValue();
|
||||
enchantment = Enchantment.enchantmentsList[i1];
|
||||
k1 = map.containsKey(Integer.valueOf(i1)) ? ((Integer)map.get(Integer.valueOf(i1))).intValue() : 0;
|
||||
l1 = ((Integer)map1.get(Integer.valueOf(i1))).intValue();
|
||||
k1 = map.containsKey(Integer.valueOf(i1))
|
||||
? ((Integer) map.get(Integer.valueOf(i1))).intValue()
|
||||
: 0;
|
||||
l1 = ((Integer) map1.get(Integer.valueOf(i1))).intValue();
|
||||
int i3;
|
||||
|
||||
if (k1 == l1)
|
||||
{
|
||||
if (k1 == l1) {
|
||||
++l1;
|
||||
i3 = l1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
i3 = Math.max(l1, k1);
|
||||
}
|
||||
|
||||
@@ -266,37 +238,36 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
int i2 = l1 - k1;
|
||||
boolean flag1 = enchantment.canApply(itemstack);
|
||||
|
||||
if (this.thePlayer.capabilities.isCreativeMode || itemstack.getItem() == Items.enchanted_book)
|
||||
{
|
||||
if (this.thePlayer.capabilities.isCreativeMode || itemstack.getItem() == Items.enchanted_book) {
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
Iterator iterator = map.keySet().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
int j2 = ((Integer)iterator.next()).intValue();
|
||||
while (iterator.hasNext()) {
|
||||
int j2 = ((Integer) iterator.next()).intValue();
|
||||
|
||||
Enchantment e2 = Enchantment.enchantmentsList[j2];
|
||||
if (j2 != i1 && !(enchantment.canApplyTogether(e2) && e2.canApplyTogether(enchantment))) //Forge BugFix: Let Both enchantments veto being together
|
||||
if (j2 != i1
|
||||
&& !(enchantment.canApplyTogether(e2)
|
||||
&& e2.canApplyTogether(
|
||||
enchantment))) // Forge BugFix: Let Both enchantments veto being
|
||||
// together
|
||||
{
|
||||
flag1 = false;
|
||||
i += i2;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
if (l1 > enchantment.getMaxLevel())
|
||||
{
|
||||
if (flag1) {
|
||||
if (l1 > enchantment.getMaxLevel()) {
|
||||
l1 = enchantment.getMaxLevel();
|
||||
}
|
||||
|
||||
map.put(Integer.valueOf(i1), Integer.valueOf(l1));
|
||||
int l2 = 0;
|
||||
|
||||
switch (enchantment.getWeight())
|
||||
{
|
||||
switch (enchantment.getWeight()) {
|
||||
case 1:
|
||||
l2 = 8;
|
||||
break;
|
||||
@@ -317,8 +288,7 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
l2 = 1;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
l2 = Math.max(1, l2 / 2);
|
||||
}
|
||||
|
||||
@@ -328,22 +298,17 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(this.repairedItemName))
|
||||
{
|
||||
if (itemstack.hasDisplayName())
|
||||
{
|
||||
if (StringUtils.isBlank(this.repairedItemName)) {
|
||||
if (itemstack.hasDisplayName()) {
|
||||
j = itemstack.isItemStackDamageable() ? 7 : itemstack.stackSize * 5;
|
||||
i += j;
|
||||
itemstack1.func_135074_t();
|
||||
}
|
||||
}
|
||||
else if (!this.repairedItemName.equals(itemstack.getDisplayName()))
|
||||
{
|
||||
} else if (!this.repairedItemName.equals(itemstack.getDisplayName())) {
|
||||
j = itemstack.isItemStackDamageable() ? 7 : itemstack.stackSize * 5;
|
||||
i += j;
|
||||
|
||||
if (itemstack.hasDisplayName())
|
||||
{
|
||||
if (itemstack.hasDisplayName()) {
|
||||
k2 += j / 2;
|
||||
}
|
||||
|
||||
@@ -352,16 +317,14 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
|
||||
k = 0;
|
||||
|
||||
for (iterator1 = map.keySet().iterator(); iterator1.hasNext(); k2 += k + k1 * l1)
|
||||
{
|
||||
i1 = ((Integer)iterator1.next()).intValue();
|
||||
for (iterator1 = map.keySet().iterator(); iterator1.hasNext(); k2 += k + k1 * l1) {
|
||||
i1 = ((Integer) iterator1.next()).intValue();
|
||||
enchantment = Enchantment.enchantmentsList[i1];
|
||||
k1 = ((Integer)map.get(Integer.valueOf(i1))).intValue();
|
||||
k1 = ((Integer) map.get(Integer.valueOf(i1))).intValue();
|
||||
l1 = 0;
|
||||
++k;
|
||||
|
||||
switch (enchantment.getWeight())
|
||||
{
|
||||
switch (enchantment.getWeight()) {
|
||||
case 1:
|
||||
l1 = 8;
|
||||
break;
|
||||
@@ -382,14 +345,12 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
l1 = 1;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
l1 = Math.max(1, l1 / 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
k2 = Math.max(1, k2 / 2);
|
||||
}
|
||||
|
||||
@@ -397,42 +358,35 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
|
||||
this.maximumCost = k2 + i;
|
||||
|
||||
if (i <= 0)
|
||||
{
|
||||
if (i <= 0) {
|
||||
itemstack1 = null;
|
||||
}
|
||||
|
||||
if (j == i && j > 0 && this.maximumCost >= 60)
|
||||
{
|
||||
if (j == i && j > 0 && this.maximumCost >= 60) {
|
||||
this.maximumCost = 59;
|
||||
}
|
||||
|
||||
if (this.maximumCost >= 60 && !this.thePlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
if (this.maximumCost >= 60 && !this.thePlayer.capabilities.isCreativeMode) {
|
||||
itemstack1 = null;
|
||||
}
|
||||
|
||||
if (itemstack1 != null)
|
||||
{
|
||||
if (itemstack1 != null) {
|
||||
l = itemstack1.getRepairCost();
|
||||
|
||||
if (itemstack2 != null && l < itemstack2.getRepairCost())
|
||||
{
|
||||
if (itemstack2 != null && l < itemstack2.getRepairCost()) {
|
||||
l = itemstack2.getRepairCost();
|
||||
}
|
||||
|
||||
if (itemstack1.hasDisplayName())
|
||||
{
|
||||
if (itemstack1.hasDisplayName()) {
|
||||
l -= 9;
|
||||
}
|
||||
|
||||
if (l < 0)
|
||||
{
|
||||
if (l < 0) {
|
||||
l = 0;
|
||||
}
|
||||
|
||||
l += 2;
|
||||
|
||||
|
||||
EnchantmentHelper.setEnchantments(map, itemstack1);
|
||||
}
|
||||
|
||||
@@ -440,87 +394,69 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void addCraftingToCrafters(ICrafting p_75132_1_)
|
||||
{
|
||||
|
||||
public void addCraftingToCrafters(ICrafting p_75132_1_) {
|
||||
super.addCraftingToCrafters(p_75132_1_);
|
||||
p_75132_1_.sendProgressBarUpdate(this, 0, this.maximumCost);
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int p_75137_1_, int p_75137_2_)
|
||||
{
|
||||
if (p_75137_1_ == 0)
|
||||
{
|
||||
public void updateProgressBar(int p_75137_1_, int p_75137_2_) {
|
||||
if (p_75137_1_ == 0) {
|
||||
this.maximumCost = p_75137_2_;
|
||||
}
|
||||
}
|
||||
|
||||
public void onContainerClosed(EntityPlayer p_75134_1_)
|
||||
{
|
||||
|
||||
public void onContainerClosed(EntityPlayer p_75134_1_) {
|
||||
super.onContainerClosed(p_75134_1_);
|
||||
|
||||
if (!this.w.isRemote)
|
||||
{
|
||||
for (int i = 0; i < this.inputSlots.getSizeInventory(); ++i)
|
||||
{
|
||||
if (!this.w.isRemote) {
|
||||
for (int i = 0; i < this.inputSlots.getSizeInventory(); ++i) {
|
||||
ItemStack itemstack = this.inputSlots.getStackInSlotOnClosing(i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
if (itemstack != null) {
|
||||
p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canInteractWith(EntityPlayer p_75145_1_)
|
||||
{
|
||||
return this.w.getBlock(this.x, this.y, this.z) != TBBlocks.thaumicAnvil ? false : p_75145_1_.getDistanceSq((double)this.x + 0.5D, (double)this.y + 0.5D, (double)this.z + 0.5D) <= 64.0D;
|
||||
|
||||
public boolean canInteractWith(EntityPlayer p_75145_1_) {
|
||||
return this.w.getBlock(this.x, this.y, this.z) != TBBlocks.thaumicAnvil
|
||||
? false
|
||||
: p_75145_1_.getDistanceSq((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D)
|
||||
<= 64.0D;
|
||||
}
|
||||
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_)
|
||||
{
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)this.inventorySlots.get(p_82846_2_);
|
||||
Slot slot = (Slot) this.inventorySlots.get(p_82846_2_);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (p_82846_2_ == 2)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 3, 39, true))
|
||||
{
|
||||
if (p_82846_2_ == 2) {
|
||||
if (!this.mergeItemStack(itemstack1, 3, 39, true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (p_82846_2_ != 0 && p_82846_2_ != 1)
|
||||
{
|
||||
if (p_82846_2_ >= 3 && p_82846_2_ < 39 && !this.mergeItemStack(itemstack1, 0, 2, false))
|
||||
{
|
||||
} else if (p_82846_2_ != 0 && p_82846_2_ != 1) {
|
||||
if (p_82846_2_ >= 3 && p_82846_2_ < 39 && !this.mergeItemStack(itemstack1, 0, 2, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 3, 39, false))
|
||||
{
|
||||
} else if (!this.mergeItemStack(itemstack1, 3, 39, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack)null);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (itemstack1.stackSize == 0) {
|
||||
slot.putStack((ItemStack) null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
if (itemstack1.stackSize == itemstack.stackSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -529,26 +465,20 @@ public class ContainerThaumicAnvil extends ContainerRepair{
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
public void updateItemName(String p_82850_1_)
|
||||
{
|
||||
|
||||
public void updateItemName(String p_82850_1_) {
|
||||
this.repairedItemName = p_82850_1_;
|
||||
|
||||
if (this.getSlot(2).getHasStack())
|
||||
{
|
||||
if (this.getSlot(2).getHasStack()) {
|
||||
ItemStack itemstack = this.getSlot(2).getStack();
|
||||
|
||||
if (StringUtils.isBlank(p_82850_1_))
|
||||
{
|
||||
if (StringUtils.isBlank(p_82850_1_)) {
|
||||
itemstack.func_135074_t();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
itemstack.setStackDisplayName(this.repairedItemName);
|
||||
}
|
||||
}
|
||||
|
||||
this.updateRepairOutput();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
package tb.common.inventory;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import tb.init.TBBlocks;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -22,14 +18,14 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import tb.init.TBBlocks;
|
||||
|
||||
public class ContainerVoidAnvil extends ContainerRepair{
|
||||
public class ContainerVoidAnvil extends ContainerRepair {
|
||||
|
||||
private IInventory outputSlot = new InventoryCraftResult();
|
||||
private IInventory inputSlots = new InventoryBasic("Repair", true, 2)
|
||||
{
|
||||
public void markDirty()
|
||||
{
|
||||
private IInventory outputSlot = new InventoryCraftResult();
|
||||
private IInventory inputSlots = new InventoryBasic("Repair", true, 2) {
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
ContainerVoidAnvil.this.onCraftMatrixChanged(this);
|
||||
}
|
||||
@@ -40,138 +36,123 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public ContainerVoidAnvil(InventoryPlayer inv, World w,int x, int y, int z,EntityPlayer p)
|
||||
{
|
||||
super(inv, w, x, y, z, p);
|
||||
thePlayer = p;
|
||||
|
||||
this.crafters.clear();
|
||||
this.inventoryItemStacks.clear();
|
||||
this.inventorySlots.clear();
|
||||
|
||||
this.w = w;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
final World wrld = w;
|
||||
final int ax = x;
|
||||
final int ay = y;
|
||||
final int az = z;
|
||||
|
||||
|
||||
public ContainerVoidAnvil(InventoryPlayer inv, World w, int x, int y, int z, EntityPlayer p) {
|
||||
super(inv, w, x, y, z, p);
|
||||
thePlayer = p;
|
||||
|
||||
this.crafters.clear();
|
||||
this.inventoryItemStacks.clear();
|
||||
this.inventorySlots.clear();
|
||||
|
||||
this.w = w;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
final World wrld = w;
|
||||
final int ax = x;
|
||||
final int ay = y;
|
||||
final int az = z;
|
||||
|
||||
this.addSlotToContainer(new Slot(this.inputSlots, 0, 27, 47));
|
||||
this.addSlotToContainer(new Slot(this.inputSlots, 1, 76, 47));
|
||||
this.addSlotToContainer(new Slot(this.outputSlot, 2, 134, 47)
|
||||
{
|
||||
public boolean isItemValid(ItemStack stk)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(this.outputSlot, 2, 134, 47) {
|
||||
public boolean isItemValid(ItemStack stk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canTakeStack(EntityPlayer p_82869_1_)
|
||||
{
|
||||
return (p_82869_1_.capabilities.isCreativeMode || p_82869_1_.experienceLevel >= ContainerVoidAnvil.this.maximumCost) && ContainerVoidAnvil.this.maximumCost > 0 && this.getHasStack();
|
||||
|
||||
public boolean canTakeStack(EntityPlayer p_82869_1_) {
|
||||
return (p_82869_1_.capabilities.isCreativeMode
|
||||
|| p_82869_1_.experienceLevel >= ContainerVoidAnvil.this.maximumCost)
|
||||
&& ContainerVoidAnvil.this.maximumCost > 0
|
||||
&& this.getHasStack();
|
||||
}
|
||||
public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_)
|
||||
{
|
||||
if (!p_82870_1_.capabilities.isCreativeMode)
|
||||
{
|
||||
|
||||
public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_) {
|
||||
if (!p_82870_1_.capabilities.isCreativeMode) {
|
||||
p_82870_1_.addExperienceLevel(-ContainerVoidAnvil.this.maximumCost);
|
||||
}
|
||||
|
||||
float breakChance = ForgeHooks.onAnvilRepair(p_82870_1_, p_82870_2_, ContainerVoidAnvil.this.inputSlots.getStackInSlot(0), ContainerVoidAnvil.this.inputSlots.getStackInSlot(1));
|
||||
float breakChance = ForgeHooks.onAnvilRepair(
|
||||
p_82870_1_,
|
||||
p_82870_2_,
|
||||
ContainerVoidAnvil.this.inputSlots.getStackInSlot(0),
|
||||
ContainerVoidAnvil.this.inputSlots.getStackInSlot(1));
|
||||
|
||||
ContainerVoidAnvil.this.inputSlots.setInventorySlotContents(0, (ItemStack)null);
|
||||
ContainerVoidAnvil.this.inputSlots.setInventorySlotContents(0, (ItemStack) null);
|
||||
|
||||
if (ContainerVoidAnvil.this.stackSizeToBeUsedInRepair > 0)
|
||||
{
|
||||
if (ContainerVoidAnvil.this.stackSizeToBeUsedInRepair > 0) {
|
||||
ItemStack itemstack1 = ContainerVoidAnvil.this.inputSlots.getStackInSlot(1);
|
||||
|
||||
if (itemstack1 != null && itemstack1.stackSize > ContainerVoidAnvil.this.stackSizeToBeUsedInRepair)
|
||||
{
|
||||
if (itemstack1 != null
|
||||
&& itemstack1.stackSize > ContainerVoidAnvil.this.stackSizeToBeUsedInRepair) {
|
||||
itemstack1.stackSize -= ContainerVoidAnvil.this.stackSizeToBeUsedInRepair;
|
||||
ContainerVoidAnvil.this.inputSlots.setInventorySlotContents(1, itemstack1);
|
||||
} else {
|
||||
ContainerVoidAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
ContainerVoidAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack)null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ContainerVoidAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack)null);
|
||||
} else {
|
||||
ContainerVoidAnvil.this.inputSlots.setInventorySlotContents(1, (ItemStack) null);
|
||||
}
|
||||
|
||||
ContainerVoidAnvil.this.maximumCost = 0;
|
||||
|
||||
if (!p_82870_1_.capabilities.isCreativeMode && !wrld.isRemote && wrld.getBlock(ax, ay, az) == TBBlocks.thaumicAnvil && p_82870_1_.getRNG().nextFloat() < breakChance)
|
||||
{
|
||||
if (!p_82870_1_.capabilities.isCreativeMode
|
||||
&& !wrld.isRemote
|
||||
&& wrld.getBlock(ax, ay, az) == TBBlocks.thaumicAnvil
|
||||
&& p_82870_1_.getRNG().nextFloat() < breakChance) {
|
||||
int i1 = wrld.getBlockMetadata(ax, ay, az);
|
||||
int k = i1 & 3;
|
||||
int l = i1 >> 2;
|
||||
++l;
|
||||
|
||||
if (l > 2)
|
||||
{
|
||||
wrld.setBlockToAir(ax, ay, az);
|
||||
wrld.playAuxSFX(1020, ax, ay, az, 0);
|
||||
if (l > 2) {
|
||||
wrld.setBlockToAir(ax, ay, az);
|
||||
wrld.playAuxSFX(1020, ax, ay, az, 0);
|
||||
} else {
|
||||
wrld.setBlockMetadataWithNotify(ax, ay, az, k | l << 2, 2);
|
||||
wrld.playAuxSFX(1021, ax, ay, az, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
wrld.setBlockMetadataWithNotify(ax, ay, az, k | l << 2, 2);
|
||||
wrld.playAuxSFX(1021, ax, ay, az, 0);
|
||||
}
|
||||
}
|
||||
else if (!wrld.isRemote)
|
||||
{
|
||||
wrld.playAuxSFX(1021, ax, ay, az, 0);
|
||||
} else if (!wrld.isRemote) {
|
||||
wrld.playAuxSFX(1021, ax, ay, az, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(inv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(inv, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
public void onCraftMatrixChanged(IInventory p_75130_1_)
|
||||
{
|
||||
}
|
||||
|
||||
public void onCraftMatrixChanged(IInventory p_75130_1_) {
|
||||
super.onCraftMatrixChanged(p_75130_1_);
|
||||
|
||||
if (p_75130_1_ == this.inputSlots)
|
||||
{
|
||||
if (p_75130_1_ == this.inputSlots) {
|
||||
this.updateRepairOutput();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void updateRepairOutput()
|
||||
{
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void updateRepairOutput() {
|
||||
ItemStack itemstack = this.inputSlots.getStackInSlot(0);
|
||||
this.maximumCost = 0;
|
||||
int i = 0;
|
||||
byte b0 = 0;
|
||||
int j = 0;
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack)null);
|
||||
if (itemstack == null) {
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack) null);
|
||||
this.maximumCost = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
ItemStack itemstack2 = this.inputSlots.getStackInSlot(1);
|
||||
Map map = EnchantmentHelper.getEnchantments(itemstack1);
|
||||
@@ -186,24 +167,21 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
Iterator iterator1;
|
||||
Enchantment enchantment;
|
||||
|
||||
if (itemstack2 != null)
|
||||
{
|
||||
if (itemstack2 != null) {
|
||||
if (!ForgeHooks.onAnvilChange(this, itemstack, itemstack2, outputSlot, repairedItemName, k2)) return;
|
||||
flag = itemstack2.getItem() == Items.enchanted_book && Items.enchanted_book.func_92110_g(itemstack2).tagCount() > 0;
|
||||
flag = itemstack2.getItem() == Items.enchanted_book
|
||||
&& Items.enchanted_book.func_92110_g(itemstack2).tagCount() > 0;
|
||||
|
||||
if (itemstack1.isItemStackDamageable() && itemstack1.getItem().getIsRepairable(itemstack, itemstack2))
|
||||
{
|
||||
if (itemstack1.isItemStackDamageable() && itemstack1.getItem().getIsRepairable(itemstack, itemstack2)) {
|
||||
k = Math.min(itemstack1.getItemDamageForDisplay(), itemstack1.getMaxDamage() / 4);
|
||||
|
||||
if (k <= 0)
|
||||
{
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack)null);
|
||||
if (k <= 0) {
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack) null);
|
||||
this.maximumCost = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
for (l = 0; k > 0 && l < itemstack2.stackSize; ++l)
|
||||
{
|
||||
for (l = 0; k > 0 && l < itemstack2.stackSize; ++l) {
|
||||
i1 = itemstack1.getItemDamageForDisplay() - k;
|
||||
itemstack1.setItemDamage(i1);
|
||||
i += Math.max(1, k / 100) + map.size();
|
||||
@@ -211,31 +189,26 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
}
|
||||
|
||||
this.stackSizeToBeUsedInRepair = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.isItemStackDamageable()))
|
||||
{
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack)null);
|
||||
} else {
|
||||
if (!flag
|
||||
&& (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.isItemStackDamageable())) {
|
||||
this.outputSlot.setInventorySlotContents(0, (ItemStack) null);
|
||||
this.maximumCost = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemstack1.isItemStackDamageable() && !flag)
|
||||
{
|
||||
if (itemstack1.isItemStackDamageable() && !flag) {
|
||||
k = itemstack.getMaxDamage() - itemstack.getItemDamageForDisplay();
|
||||
l = itemstack2.getMaxDamage() - itemstack2.getItemDamageForDisplay();
|
||||
i1 = l + itemstack1.getMaxDamage() * 12 / 100;
|
||||
int j1 = k + i1;
|
||||
k1 = itemstack1.getMaxDamage() - j1;
|
||||
|
||||
if (k1 < 0)
|
||||
{
|
||||
if (k1 < 0) {
|
||||
k1 = 0;
|
||||
}
|
||||
|
||||
if (k1 < itemstack1.getItemDamage())
|
||||
{
|
||||
if (k1 < itemstack1.getItemDamage()) {
|
||||
itemstack1.setItemDamage(k1);
|
||||
i += Math.max(1, i1 / 100);
|
||||
}
|
||||
@@ -244,21 +217,19 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
Map map1 = EnchantmentHelper.getEnchantments(itemstack2);
|
||||
iterator1 = map1.keySet().iterator();
|
||||
|
||||
while (iterator1.hasNext())
|
||||
{
|
||||
i1 = ((Integer)iterator1.next()).intValue();
|
||||
while (iterator1.hasNext()) {
|
||||
i1 = ((Integer) iterator1.next()).intValue();
|
||||
enchantment = Enchantment.enchantmentsList[i1];
|
||||
k1 = map.containsKey(Integer.valueOf(i1)) ? ((Integer)map.get(Integer.valueOf(i1))).intValue() : 0;
|
||||
l1 = ((Integer)map1.get(Integer.valueOf(i1))).intValue();
|
||||
k1 = map.containsKey(Integer.valueOf(i1))
|
||||
? ((Integer) map.get(Integer.valueOf(i1))).intValue()
|
||||
: 0;
|
||||
l1 = ((Integer) map1.get(Integer.valueOf(i1))).intValue();
|
||||
int i3;
|
||||
|
||||
if (k1 == l1)
|
||||
{
|
||||
if (k1 == l1) {
|
||||
++l1;
|
||||
i3 = l1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
i3 = Math.max(l1, k1);
|
||||
}
|
||||
|
||||
@@ -266,37 +237,36 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
int i2 = l1 - k1;
|
||||
boolean flag1 = enchantment.canApply(itemstack);
|
||||
|
||||
if (this.thePlayer.capabilities.isCreativeMode || itemstack.getItem() == Items.enchanted_book)
|
||||
{
|
||||
if (this.thePlayer.capabilities.isCreativeMode || itemstack.getItem() == Items.enchanted_book) {
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
Iterator iterator = map.keySet().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
int j2 = ((Integer)iterator.next()).intValue();
|
||||
while (iterator.hasNext()) {
|
||||
int j2 = ((Integer) iterator.next()).intValue();
|
||||
|
||||
Enchantment e2 = Enchantment.enchantmentsList[j2];
|
||||
if (j2 != i1 && !(enchantment.canApplyTogether(e2) && e2.canApplyTogether(enchantment))) //Forge BugFix: Let Both enchantments veto being together
|
||||
if (j2 != i1
|
||||
&& !(enchantment.canApplyTogether(e2)
|
||||
&& e2.canApplyTogether(
|
||||
enchantment))) // Forge BugFix: Let Both enchantments veto being
|
||||
// together
|
||||
{
|
||||
flag1 = false;
|
||||
i += i2;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
if (l1 > enchantment.getMaxLevel())
|
||||
{
|
||||
if (flag1) {
|
||||
if (l1 > enchantment.getMaxLevel()) {
|
||||
l1 = enchantment.getMaxLevel();
|
||||
}
|
||||
|
||||
map.put(Integer.valueOf(i1), Integer.valueOf(l1));
|
||||
int l2 = 0;
|
||||
|
||||
switch (enchantment.getWeight())
|
||||
{
|
||||
switch (enchantment.getWeight()) {
|
||||
case 1:
|
||||
l2 = 8;
|
||||
break;
|
||||
@@ -317,8 +287,7 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
l2 = 1;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
l2 = Math.max(1, l2 / 2);
|
||||
}
|
||||
|
||||
@@ -328,22 +297,17 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(this.repairedItemName))
|
||||
{
|
||||
if (itemstack.hasDisplayName())
|
||||
{
|
||||
if (StringUtils.isBlank(this.repairedItemName)) {
|
||||
if (itemstack.hasDisplayName()) {
|
||||
j = itemstack.isItemStackDamageable() ? 7 : itemstack.stackSize * 5;
|
||||
i += j;
|
||||
itemstack1.func_135074_t();
|
||||
}
|
||||
}
|
||||
else if (!this.repairedItemName.equals(itemstack.getDisplayName()))
|
||||
{
|
||||
} else if (!this.repairedItemName.equals(itemstack.getDisplayName())) {
|
||||
j = itemstack.isItemStackDamageable() ? 7 : itemstack.stackSize * 5;
|
||||
i += j;
|
||||
|
||||
if (itemstack.hasDisplayName())
|
||||
{
|
||||
if (itemstack.hasDisplayName()) {
|
||||
k2 += j / 2;
|
||||
}
|
||||
|
||||
@@ -352,16 +316,14 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
|
||||
k = 0;
|
||||
|
||||
for (iterator1 = map.keySet().iterator(); iterator1.hasNext(); k2 += k + k1 * l1)
|
||||
{
|
||||
i1 = ((Integer)iterator1.next()).intValue();
|
||||
for (iterator1 = map.keySet().iterator(); iterator1.hasNext(); k2 += k + k1 * l1) {
|
||||
i1 = ((Integer) iterator1.next()).intValue();
|
||||
enchantment = Enchantment.enchantmentsList[i1];
|
||||
k1 = ((Integer)map.get(Integer.valueOf(i1))).intValue();
|
||||
k1 = ((Integer) map.get(Integer.valueOf(i1))).intValue();
|
||||
l1 = 0;
|
||||
++k;
|
||||
|
||||
switch (enchantment.getWeight())
|
||||
{
|
||||
switch (enchantment.getWeight()) {
|
||||
case 1:
|
||||
l1 = 8;
|
||||
break;
|
||||
@@ -382,14 +344,12 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
l1 = 1;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
l1 = Math.max(1, l1 / 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
k2 = Math.max(1, k2 / 2);
|
||||
}
|
||||
|
||||
@@ -397,27 +357,23 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
|
||||
this.maximumCost = 3;
|
||||
|
||||
if (i <= 0)
|
||||
{
|
||||
if (i <= 0) {
|
||||
itemstack1 = null;
|
||||
}
|
||||
|
||||
if (itemstack1 != null)
|
||||
{
|
||||
if (itemstack1 != null) {
|
||||
l = 3;
|
||||
|
||||
if (itemstack1.hasDisplayName())
|
||||
{
|
||||
if (itemstack1.hasDisplayName()) {
|
||||
l -= 9;
|
||||
}
|
||||
|
||||
if (l < 0)
|
||||
{
|
||||
if (l < 0) {
|
||||
l = 0;
|
||||
}
|
||||
|
||||
l += 2;
|
||||
|
||||
|
||||
EnchantmentHelper.setEnchantments(map, itemstack1);
|
||||
}
|
||||
|
||||
@@ -425,87 +381,69 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void addCraftingToCrafters(ICrafting p_75132_1_)
|
||||
{
|
||||
|
||||
public void addCraftingToCrafters(ICrafting p_75132_1_) {
|
||||
super.addCraftingToCrafters(p_75132_1_);
|
||||
p_75132_1_.sendProgressBarUpdate(this, 0, this.maximumCost);
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int p_75137_1_, int p_75137_2_)
|
||||
{
|
||||
if (p_75137_1_ == 0)
|
||||
{
|
||||
public void updateProgressBar(int p_75137_1_, int p_75137_2_) {
|
||||
if (p_75137_1_ == 0) {
|
||||
this.maximumCost = p_75137_2_;
|
||||
}
|
||||
}
|
||||
|
||||
public void onContainerClosed(EntityPlayer p_75134_1_)
|
||||
{
|
||||
|
||||
public void onContainerClosed(EntityPlayer p_75134_1_) {
|
||||
super.onContainerClosed(p_75134_1_);
|
||||
|
||||
if (!this.w.isRemote)
|
||||
{
|
||||
for (int i = 0; i < this.inputSlots.getSizeInventory(); ++i)
|
||||
{
|
||||
if (!this.w.isRemote) {
|
||||
for (int i = 0; i < this.inputSlots.getSizeInventory(); ++i) {
|
||||
ItemStack itemstack = this.inputSlots.getStackInSlotOnClosing(i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
if (itemstack != null) {
|
||||
p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canInteractWith(EntityPlayer p_75145_1_)
|
||||
{
|
||||
return this.w.getBlock(this.x, this.y, this.z) != TBBlocks.voidAnvil ? false : p_75145_1_.getDistanceSq((double)this.x + 0.5D, (double)this.y + 0.5D, (double)this.z + 0.5D) <= 64.0D;
|
||||
|
||||
public boolean canInteractWith(EntityPlayer p_75145_1_) {
|
||||
return this.w.getBlock(this.x, this.y, this.z) != TBBlocks.voidAnvil
|
||||
? false
|
||||
: p_75145_1_.getDistanceSq((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D)
|
||||
<= 64.0D;
|
||||
}
|
||||
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_)
|
||||
{
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)this.inventorySlots.get(p_82846_2_);
|
||||
Slot slot = (Slot) this.inventorySlots.get(p_82846_2_);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (p_82846_2_ == 2)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 3, 39, true))
|
||||
{
|
||||
if (p_82846_2_ == 2) {
|
||||
if (!this.mergeItemStack(itemstack1, 3, 39, true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (p_82846_2_ != 0 && p_82846_2_ != 1)
|
||||
{
|
||||
if (p_82846_2_ >= 3 && p_82846_2_ < 39 && !this.mergeItemStack(itemstack1, 0, 2, false))
|
||||
{
|
||||
} else if (p_82846_2_ != 0 && p_82846_2_ != 1) {
|
||||
if (p_82846_2_ >= 3 && p_82846_2_ < 39 && !this.mergeItemStack(itemstack1, 0, 2, false)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, 3, 39, false))
|
||||
{
|
||||
} else if (!this.mergeItemStack(itemstack1, 3, 39, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack)null);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (itemstack1.stackSize == 0) {
|
||||
slot.putStack((ItemStack) null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
if (itemstack1.stackSize == itemstack.stackSize) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -514,26 +452,20 @@ public class ContainerVoidAnvil extends ContainerRepair{
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
public void updateItemName(String p_82850_1_)
|
||||
{
|
||||
|
||||
public void updateItemName(String p_82850_1_) {
|
||||
this.repairedItemName = p_82850_1_;
|
||||
|
||||
if (this.getSlot(2).getHasStack())
|
||||
{
|
||||
if (this.getSlot(2).getHasStack()) {
|
||||
ItemStack itemstack = this.getSlot(2).getStack();
|
||||
|
||||
if (StringUtils.isBlank(p_82850_1_))
|
||||
{
|
||||
if (StringUtils.isBlank(p_82850_1_)) {
|
||||
itemstack.func_135074_t();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
itemstack.setStackDisplayName(this.repairedItemName);
|
||||
}
|
||||
}
|
||||
|
||||
this.updateRepairOutput();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,112 +1,93 @@
|
||||
package tb.common.inventory;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.blocks.ItemJarFilled;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.blocks.ItemJarFilled;
|
||||
|
||||
public class InventoryRevolver implements IInventory
|
||||
{
|
||||
public ItemStack[] inventory;
|
||||
public Container revolverContainer;
|
||||
|
||||
public InventoryRevolver(Container revolver)
|
||||
{
|
||||
this.inventory = new ItemStack[1];
|
||||
this.revolverContainer = revolver;
|
||||
}
|
||||
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
return inventory[0];
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlotOnClosing(int slot)
|
||||
{
|
||||
if (this.inventory[0] != null)
|
||||
{
|
||||
ItemStack stk = this.inventory[0];
|
||||
this.inventory[0] = null;
|
||||
return stk;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize(int slot, int amount)
|
||||
{
|
||||
if (inventory[0] != null)
|
||||
{
|
||||
if (inventory[0].stackSize <= amount)
|
||||
{
|
||||
ItemStack stk = inventory[0];
|
||||
inventory[0] = null;
|
||||
revolverContainer.onCraftMatrixChanged(this);
|
||||
return stk;
|
||||
}
|
||||
|
||||
ItemStack var3 = this.inventory[0].splitStack(amount);
|
||||
|
||||
if (inventory[0].stackSize == 0)
|
||||
{
|
||||
inventory[0] = null;
|
||||
}
|
||||
|
||||
revolverContainer.onCraftMatrixChanged(this);
|
||||
return var3;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
inventory[0] = stack;
|
||||
revolverContainer.onCraftMatrixChanged(this);
|
||||
}
|
||||
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isUseableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isItemValidForSlot(int slot, ItemStack jar)
|
||||
{
|
||||
if (jar != null && jar.getItem() instanceof ItemJarFilled && jar.hasTagCompound())
|
||||
{
|
||||
AspectList aspects = ((ItemJarFilled)jar.getItem()).getAspects(jar);
|
||||
if (aspects != null && aspects.size() > 0 && aspects.getAmount(Aspect.WEAPON) > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getInventoryName()
|
||||
{
|
||||
return "container.revolver";
|
||||
}
|
||||
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void openInventory(){}
|
||||
|
||||
public void closeInventory(){}
|
||||
public class InventoryRevolver implements IInventory {
|
||||
public ItemStack[] inventory;
|
||||
public Container revolverContainer;
|
||||
|
||||
@Override
|
||||
public void markDirty(){}
|
||||
|
||||
public InventoryRevolver(Container revolver) {
|
||||
this.inventory = new ItemStack[1];
|
||||
this.revolverContainer = revolver;
|
||||
}
|
||||
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory[0];
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (this.inventory[0] != null) {
|
||||
ItemStack stk = this.inventory[0];
|
||||
this.inventory[0] = null;
|
||||
return stk;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
if (inventory[0] != null) {
|
||||
if (inventory[0].stackSize <= amount) {
|
||||
ItemStack stk = inventory[0];
|
||||
inventory[0] = null;
|
||||
revolverContainer.onCraftMatrixChanged(this);
|
||||
return stk;
|
||||
}
|
||||
|
||||
ItemStack var3 = this.inventory[0].splitStack(amount);
|
||||
|
||||
if (inventory[0].stackSize == 0) {
|
||||
inventory[0] = null;
|
||||
}
|
||||
|
||||
revolverContainer.onCraftMatrixChanged(this);
|
||||
return var3;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory[0] = stack;
|
||||
revolverContainer.onCraftMatrixChanged(this);
|
||||
}
|
||||
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isItemValidForSlot(int slot, ItemStack jar) {
|
||||
if (jar != null && jar.getItem() instanceof ItemJarFilled && jar.hasTagCompound()) {
|
||||
AspectList aspects = ((ItemJarFilled) jar.getItem()).getAspects(jar);
|
||||
if (aspects != null && aspects.size() > 0 && aspects.getAmount(Aspect.WEAPON) > 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getInventoryName() {
|
||||
return "container.revolver";
|
||||
}
|
||||
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void openInventory() {}
|
||||
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public void markDirty() {}
|
||||
}
|
||||
@@ -1,15 +1,9 @@
|
||||
package tb.common.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IRunicArmor;
|
||||
import thaumcraft.api.IVisDiscountGear;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
@@ -19,72 +13,78 @@ import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IRunicArmor;
|
||||
import thaumcraft.api.IVisDiscountGear;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
|
||||
public class ItemBloodyArmor extends ItemArmor implements IRepairable, IVisDiscountGear, IRunicArmor{
|
||||
public class ItemBloodyArmor extends ItemArmor implements IRepairable, IVisDiscountGear, IRunicArmor {
|
||||
|
||||
int aType;
|
||||
|
||||
public ItemBloodyArmor(ArmorMaterial mat,int aType) {
|
||||
super(mat, 0, aType);
|
||||
this.aType = aType;
|
||||
}
|
||||
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
|
||||
{
|
||||
return slot == 2 ? "thaumicbases:textures/items/armor/bloody/bloody_2.png" : "thaumicbases:textures/items/armor/bloody/bloody_1.png";
|
||||
int aType;
|
||||
|
||||
public ItemBloodyArmor(ArmorMaterial mat, int aType) {
|
||||
super(mat, 0, aType);
|
||||
this.aType = aType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVisDiscount(ItemStack stack, EntityPlayer player,
|
||||
Aspect aspect) {
|
||||
return discount[aType];
|
||||
}
|
||||
|
||||
static final int[] discount = new int[]{5,4,3,2};
|
||||
|
||||
@Override
|
||||
public int getRunicCharge(ItemStack itemstack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack itemstack)
|
||||
{
|
||||
return EnumRarity.uncommon; //
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("tc.visdiscount") + ": " + getVisDiscount(stack, player, null) + "%");
|
||||
super.addInformation(stack, player, list, par4);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Multimap getAttributeModifiers(ItemStack stack)
|
||||
{
|
||||
HashMultimap map = HashMultimap.create();
|
||||
|
||||
switch(aType)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
map.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(UUID.fromString("96042c45-dfe3-4366-b93b-84663c4d828d"), "maxHealth", 0.2F, 2));
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
map.put(SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(), new AttributeModifier(UUID.fromString("e4e1d8b2-87f2-44f5-8f24-e1876060a04c"), "knockback", 0.5F, 2));
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
map.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(UUID.fromString("f6d1384c-74c3-4cce-9a80-11b91dbd4ff4"), "moveSpeed", 0.1F, 2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
return slot == 2
|
||||
? "thaumicbases:textures/items/armor/bloody/bloody_2.png"
|
||||
: "thaumicbases:textures/items/armor/bloody/bloody_1.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVisDiscount(ItemStack stack, EntityPlayer player, Aspect aspect) {
|
||||
return discount[aType];
|
||||
}
|
||||
|
||||
static final int[] discount = new int[] {5, 4, 3, 2};
|
||||
|
||||
@Override
|
||||
public int getRunicCharge(ItemStack itemstack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack itemstack) {
|
||||
return EnumRarity.uncommon; //
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("tc.visdiscount") + ": "
|
||||
+ getVisDiscount(stack, player, null) + "%");
|
||||
super.addInformation(stack, player, list, par4);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public Multimap getAttributeModifiers(ItemStack stack) {
|
||||
HashMultimap map = HashMultimap.create();
|
||||
|
||||
switch (aType) {
|
||||
case 1: {
|
||||
map.put(
|
||||
SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(),
|
||||
new AttributeModifier(
|
||||
UUID.fromString("96042c45-dfe3-4366-b93b-84663c4d828d"), "maxHealth", 0.2F, 2));
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
map.put(
|
||||
SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(),
|
||||
new AttributeModifier(
|
||||
UUID.fromString("e4e1d8b2-87f2-44f5-8f24-e1876060a04c"), "knockback", 0.5F, 2));
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
map.put(
|
||||
SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(),
|
||||
new AttributeModifier(
|
||||
UUID.fromString("f6d1384c-74c3-4cce-9a80-11b91dbd4ff4"), "moveSpeed", 0.1F, 2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package tb.common.item;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -24,246 +23,208 @@ import thaumcraft.common.config.ConfigItems;
|
||||
import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
import thaumcraft.common.items.wands.WandManager;
|
||||
|
||||
public class ItemCastingBracelet extends ItemWandCasting //<- I hope no one will tell things like "OMG, You've stolen Azanor's code!!!, since that is not true. It is very similar in some places, since I need this item to do exactly the same his does.
|
||||
public class ItemCastingBracelet
|
||||
extends ItemWandCasting // <- I hope no one will tell things like "OMG, You've stolen Azanor's code!!!, since
|
||||
// that is not true. It is very similar in some places, since I need this item to do
|
||||
// exactly the same his does.
|
||||
{
|
||||
public static String[] names = new String[]{
|
||||
"iron",
|
||||
"gold",
|
||||
"greatwood",
|
||||
"thaumium",
|
||||
"silverwood",
|
||||
"reed",
|
||||
"bone",
|
||||
"obsidian",
|
||||
"blaze",
|
||||
"ice",
|
||||
"quartz",
|
||||
"void",
|
||||
"primal"
|
||||
};
|
||||
|
||||
public static ResourceLocation[] braceletTextures = new ResourceLocation[]{
|
||||
loc("thaumcraft","textures/blocks/metalbase.png"),
|
||||
loc("thaumcraft","textures/blocks/goldbase.png"),
|
||||
loc("thaumcraft","textures/blocks/planks_greatwood.png"),
|
||||
loc("thaumcraft","textures/blocks/thaumiumblock.png"),
|
||||
loc("thaumcraft","textures/blocks/planks_silverwood.png"),
|
||||
loc("thaumicbases","textures/blocks/sugarcaneblock.png"),
|
||||
loc("thaumicbases","textures/blocks/boneblock.png"),
|
||||
loc("minecraft","textures/blocks/obsidian.png"),
|
||||
loc("thaumicbases","textures/blocks/blazeblock.png"),
|
||||
loc("minecraft","textures/blocks/ice_packed.png"),
|
||||
loc("minecraft","textures/blocks/quartz_block_bottom.png"),
|
||||
loc("thaumicbases","textures/blocks/voidblock.png"),
|
||||
loc("thaumcraft","textures/blocks/deco_3.png")
|
||||
};
|
||||
|
||||
public static WandCap[] caps = new WandCap[]{
|
||||
ConfigItems.WAND_CAP_IRON,
|
||||
ConfigItems.WAND_CAP_GOLD,
|
||||
ConfigItems.WAND_CAP_GOLD,
|
||||
TBItems.WAND_CAP_THAUMINITE,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_VOID
|
||||
};
|
||||
|
||||
public static WandRod[] rods = new WandRod[]{
|
||||
ConfigItems.WAND_ROD_WOOD,
|
||||
ConfigItems.WAND_ROD_WOOD,
|
||||
ConfigItems.WAND_ROD_GREATWOOD,
|
||||
TBItems.WAND_ROD_THAUMIUM,
|
||||
ConfigItems.WAND_ROD_SILVERWOOD,
|
||||
ConfigItems.WAND_ROD_REED,
|
||||
ConfigItems.WAND_ROD_BONE,
|
||||
ConfigItems.WAND_ROD_OBSIDIAN,
|
||||
ConfigItems.WAND_ROD_BLAZE,
|
||||
ConfigItems.WAND_ROD_ICE,
|
||||
ConfigItems.WAND_ROD_QUARTZ,
|
||||
TBItems.WAND_ROD_VOID,
|
||||
ConfigItems.STAFF_ROD_PRIMAL
|
||||
};
|
||||
|
||||
public static int[] capacity = new int[]{
|
||||
10,
|
||||
15,
|
||||
17,
|
||||
20,
|
||||
23,
|
||||
23,
|
||||
25,
|
||||
25,
|
||||
25,
|
||||
25,
|
||||
25,
|
||||
27,
|
||||
30
|
||||
};
|
||||
|
||||
public ItemCastingBracelet()
|
||||
{
|
||||
super();
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
public int getMaxVis(ItemStack stack) {
|
||||
return capacity[Math.min(names.length-1,stack.getItemDamage())]*100;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void getSubItems(Item item, CreativeTabs tab, List lst)
|
||||
{
|
||||
for(int i = 0; i < names.length; ++i)
|
||||
lst.add(new ItemStack(item,1,i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
|
||||
{
|
||||
MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, player, true);
|
||||
if (movingobjectposition != null)
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
int x = movingobjectposition.blockX;
|
||||
int y = movingobjectposition.blockY;
|
||||
int z = movingobjectposition.blockZ;
|
||||
Block b = world.getBlock(x, y, z);
|
||||
|
||||
if (b instanceof IWandable)
|
||||
{
|
||||
ItemStack is = ((IWandable)b).onWandRightClick(world, itemstack, player);
|
||||
if (is != null)
|
||||
return is;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile != null && tile instanceof IWandable)
|
||||
{
|
||||
ItemStack is = ((IWandable)tile).onWandRightClick(world, itemstack, player);
|
||||
if (is != null)
|
||||
return is;
|
||||
}
|
||||
}
|
||||
|
||||
ItemFocusBasic focus = getFocus(itemstack);
|
||||
if (focus != null && !isOnCooldown(player))
|
||||
{
|
||||
WandManager.setCooldown(player, focus.getActivationCooldown(getFocusItem(itemstack))/2);
|
||||
ItemStack ret = focus.onFocusRightClick(itemstack, world, player, movingobjectposition);
|
||||
if (ret != null)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
public boolean isOnCooldown(EntityLivingBase base)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<WandManager> manager = WandManager.class;
|
||||
Method method = manager.getDeclaredMethod("isOnCooldown", EntityLivingBase.class);
|
||||
boolean access = method.isAccessible();
|
||||
if(!access)
|
||||
method.setAccessible(true);
|
||||
|
||||
boolean ret = Boolean.class.cast(method.invoke(null, base));
|
||||
|
||||
if(!access)
|
||||
method.setAccessible(false);
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stk)
|
||||
{
|
||||
return StatCollector.translateToLocal(getUnlocalizedName(stk));
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack stk)
|
||||
{
|
||||
return super.getUnlocalizedName(stk) + "." + names[Math.min(names.length-1,stk.getItemDamage())];
|
||||
public static String[] names = new String[] {
|
||||
"iron",
|
||||
"gold",
|
||||
"greatwood",
|
||||
"thaumium",
|
||||
"silverwood",
|
||||
"reed",
|
||||
"bone",
|
||||
"obsidian",
|
||||
"blaze",
|
||||
"ice",
|
||||
"quartz",
|
||||
"void",
|
||||
"primal"
|
||||
};
|
||||
|
||||
public static ResourceLocation[] braceletTextures = new ResourceLocation[] {
|
||||
loc("thaumcraft", "textures/blocks/metalbase.png"),
|
||||
loc("thaumcraft", "textures/blocks/goldbase.png"),
|
||||
loc("thaumcraft", "textures/blocks/planks_greatwood.png"),
|
||||
loc("thaumcraft", "textures/blocks/thaumiumblock.png"),
|
||||
loc("thaumcraft", "textures/blocks/planks_silverwood.png"),
|
||||
loc("thaumicbases", "textures/blocks/sugarcaneblock.png"),
|
||||
loc("thaumicbases", "textures/blocks/boneblock.png"),
|
||||
loc("minecraft", "textures/blocks/obsidian.png"),
|
||||
loc("thaumicbases", "textures/blocks/blazeblock.png"),
|
||||
loc("minecraft", "textures/blocks/ice_packed.png"),
|
||||
loc("minecraft", "textures/blocks/quartz_block_bottom.png"),
|
||||
loc("thaumicbases", "textures/blocks/voidblock.png"),
|
||||
loc("thaumcraft", "textures/blocks/deco_3.png")
|
||||
};
|
||||
|
||||
public static WandCap[] caps = new WandCap[] {
|
||||
ConfigItems.WAND_CAP_IRON,
|
||||
ConfigItems.WAND_CAP_GOLD,
|
||||
ConfigItems.WAND_CAP_GOLD,
|
||||
TBItems.WAND_CAP_THAUMINITE,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_THAUMIUM,
|
||||
ConfigItems.WAND_CAP_VOID
|
||||
};
|
||||
|
||||
public static WandRod[] rods = new WandRod[] {
|
||||
ConfigItems.WAND_ROD_WOOD,
|
||||
ConfigItems.WAND_ROD_WOOD,
|
||||
ConfigItems.WAND_ROD_GREATWOOD,
|
||||
TBItems.WAND_ROD_THAUMIUM,
|
||||
ConfigItems.WAND_ROD_SILVERWOOD,
|
||||
ConfigItems.WAND_ROD_REED,
|
||||
ConfigItems.WAND_ROD_BONE,
|
||||
ConfigItems.WAND_ROD_OBSIDIAN,
|
||||
ConfigItems.WAND_ROD_BLAZE,
|
||||
ConfigItems.WAND_ROD_ICE,
|
||||
ConfigItems.WAND_ROD_QUARTZ,
|
||||
TBItems.WAND_ROD_VOID,
|
||||
ConfigItems.STAFF_ROD_PRIMAL
|
||||
};
|
||||
|
||||
public static int[] capacity = new int[] {10, 15, 17, 20, 23, 23, 25, 25, 25, 25, 25, 27, 30};
|
||||
|
||||
public ItemCastingBracelet() {
|
||||
super();
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
|
||||
public int getMaxVis(ItemStack stack) {
|
||||
return capacity[Math.min(names.length - 1, stack.getItemDamage())] * 100;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void getSubItems(Item item, CreativeTabs tab, List lst) {
|
||||
for (int i = 0; i < names.length; ++i) lst.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getConsumptionModifier(ItemStack is, EntityPlayer player, Aspect aspect, boolean crafting)
|
||||
{
|
||||
float consumptionModifier = 0.5F;
|
||||
|
||||
if ((getCap(is).getSpecialCostModifierAspects() != null) && (getCap(is).getSpecialCostModifierAspects().contains(aspect)))
|
||||
consumptionModifier = getCap(is).getSpecialCostModifier()/1.5F;
|
||||
else
|
||||
consumptionModifier = getCap(is).getBaseCostModifier()/1.5F;
|
||||
|
||||
if (player != null)
|
||||
consumptionModifier -= WandManager.getTotalVisDiscount(player, aspect);
|
||||
|
||||
if (getFocus(is) != null && !crafting)
|
||||
consumptionModifier -= getFocusFrugal(is) / 11.0F;
|
||||
|
||||
return Math.max(consumptionModifier, 0.1F);
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) {
|
||||
MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, player, true);
|
||||
if (movingobjectposition != null)
|
||||
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
int x = movingobjectposition.blockX;
|
||||
int y = movingobjectposition.blockY;
|
||||
int z = movingobjectposition.blockZ;
|
||||
Block b = world.getBlock(x, y, z);
|
||||
|
||||
if (b instanceof IWandable) {
|
||||
ItemStack is = ((IWandable) b).onWandRightClick(world, itemstack, player);
|
||||
if (is != null) return is;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile != null && tile instanceof IWandable) {
|
||||
ItemStack is = ((IWandable) tile).onWandRightClick(world, itemstack, player);
|
||||
if (is != null) return is;
|
||||
}
|
||||
}
|
||||
|
||||
ItemFocusBasic focus = getFocus(itemstack);
|
||||
if (focus != null && !isOnCooldown(player)) {
|
||||
WandManager.setCooldown(player, focus.getActivationCooldown(getFocusItem(itemstack)) / 2);
|
||||
ItemStack ret = focus.onFocusRightClick(itemstack, world, player, movingobjectposition);
|
||||
if (ret != null) return ret;
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
|
||||
public boolean isOnCooldown(EntityLivingBase base) {
|
||||
try {
|
||||
Class<WandManager> manager = WandManager.class;
|
||||
Method method = manager.getDeclaredMethod("isOnCooldown", EntityLivingBase.class);
|
||||
boolean access = method.isAccessible();
|
||||
if (!access) method.setAccessible(true);
|
||||
|
||||
boolean ret = Boolean.class.cast(method.invoke(null, base));
|
||||
|
||||
if (!access) method.setAccessible(false);
|
||||
|
||||
return ret;
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WandRod getRod(ItemStack stack)
|
||||
{
|
||||
return stack.getItemDamage() == 3 ? TBItems.WAND_ROD_THAUMIUM : stack.getItemDamage() == 11 ? TBItems.WAND_ROD_VOID : rods[Math.min(rods.length-1, stack.getItemDamage())];
|
||||
public String getItemStackDisplayName(ItemStack stk) {
|
||||
return StatCollector.translateToLocal(getUnlocalizedName(stk));
|
||||
}
|
||||
|
||||
|
||||
public String getUnlocalizedName(ItemStack stk) {
|
||||
return super.getUnlocalizedName(stk) + "." + names[Math.min(names.length - 1, stk.getItemDamage())];
|
||||
}
|
||||
|
||||
@Override
|
||||
public WandCap getCap(ItemStack stack)
|
||||
{
|
||||
return stack.getItemDamage() == 3 ? TBItems.WAND_CAP_THAUMINITE : caps[Math.min(caps.length-1, stack.getItemDamage())];
|
||||
public float getConsumptionModifier(ItemStack is, EntityPlayer player, Aspect aspect, boolean crafting) {
|
||||
float consumptionModifier = 0.5F;
|
||||
|
||||
if ((getCap(is).getSpecialCostModifierAspects() != null)
|
||||
&& (getCap(is).getSpecialCostModifierAspects().contains(aspect)))
|
||||
consumptionModifier = getCap(is).getSpecialCostModifier() / 1.5F;
|
||||
else consumptionModifier = getCap(is).getBaseCostModifier() / 1.5F;
|
||||
|
||||
if (player != null) consumptionModifier -= WandManager.getTotalVisDiscount(player, aspect);
|
||||
|
||||
if (getFocus(is) != null && !crafting) consumptionModifier -= getFocusFrugal(is) / 11.0F;
|
||||
|
||||
return Math.max(consumptionModifier, 0.1F);
|
||||
}
|
||||
|
||||
public boolean isStaff(ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
|
||||
@Override
|
||||
public WandRod getRod(ItemStack stack) {
|
||||
return stack.getItemDamage() == 3
|
||||
? TBItems.WAND_ROD_THAUMIUM
|
||||
: stack.getItemDamage() == 11
|
||||
? TBItems.WAND_ROD_VOID
|
||||
: rods[Math.min(rods.length - 1, stack.getItemDamage())];
|
||||
}
|
||||
|
||||
public boolean isSceptre(ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
|
||||
@Override
|
||||
public WandCap getCap(ItemStack stack) {
|
||||
return stack.getItemDamage() == 3
|
||||
? TBItems.WAND_CAP_THAUMINITE
|
||||
: caps[Math.min(caps.length - 1, stack.getItemDamage())];
|
||||
}
|
||||
|
||||
public void onUsingTick(ItemStack stack, EntityPlayer player, int count)
|
||||
{
|
||||
IWandable wandable = getObjectInUse(stack, player.worldObj);
|
||||
if (wandable != null)
|
||||
{
|
||||
this.animation = ItemFocusBasic.WandFocusAnimation.WAVE;
|
||||
wandable.onUsingWandTick(stack, player, count);
|
||||
++count;
|
||||
wandable.onUsingWandTick(stack, player, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemFocusBasic focus = getFocus(stack);
|
||||
if (focus != null && !isOnCooldown(player))
|
||||
{
|
||||
WandManager.setCooldown(player, focus.getActivationCooldown(getFocusItem(stack))/2);
|
||||
focus.onUsingFocusTick(stack, player, count);
|
||||
++count;
|
||||
focus.onUsingFocusTick(stack, player, count);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isStaff(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final ResourceLocation loc(String mod, String path)
|
||||
{
|
||||
return new ResourceLocation(mod,path);
|
||||
|
||||
public boolean isSceptre(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
|
||||
IWandable wandable = getObjectInUse(stack, player.worldObj);
|
||||
if (wandable != null) {
|
||||
this.animation = ItemFocusBasic.WandFocusAnimation.WAVE;
|
||||
wandable.onUsingWandTick(stack, player, count);
|
||||
++count;
|
||||
wandable.onUsingWandTick(stack, player, count);
|
||||
} else {
|
||||
ItemFocusBasic focus = getFocus(stack);
|
||||
if (focus != null && !isOnCooldown(player)) {
|
||||
WandManager.setCooldown(player, focus.getActivationCooldown(getFocusItem(stack)) / 2);
|
||||
focus.onUsingFocusTick(stack, player, count);
|
||||
++count;
|
||||
focus.onUsingFocusTick(stack, player, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final ResourceLocation loc(String mod, String path) {
|
||||
return new ResourceLocation(mod, path);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,20 +2,6 @@ package tb.common.item;
|
||||
|
||||
import DummyCore.Utils.MathUtils;
|
||||
import DummyCore.Utils.MiscUtils;
|
||||
import tb.utils.TBUtils;
|
||||
import thaumcraft.api.damagesource.DamageSourceThaumcraft;
|
||||
import thaumcraft.api.entities.ITaintedMob;
|
||||
import thaumcraft.api.nodes.INode;
|
||||
import thaumcraft.api.nodes.NodeType;
|
||||
import thaumcraft.codechicken.lib.math.MathHelper;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumcraft.common.lib.network.PacketHandler;
|
||||
import thaumcraft.common.lib.network.playerdata.PacketResearchComplete;
|
||||
import thaumcraft.common.lib.research.ResearchManager;
|
||||
import thaumcraft.common.lib.world.ThaumcraftWorldGenerator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@@ -32,142 +18,153 @@ import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import tb.utils.TBUtils;
|
||||
import thaumcraft.api.damagesource.DamageSourceThaumcraft;
|
||||
import thaumcraft.api.entities.ITaintedMob;
|
||||
import thaumcraft.api.nodes.INode;
|
||||
import thaumcraft.api.nodes.NodeType;
|
||||
import thaumcraft.codechicken.lib.math.MathHelper;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import thaumcraft.common.lib.network.PacketHandler;
|
||||
import thaumcraft.common.lib.network.playerdata.PacketResearchComplete;
|
||||
import thaumcraft.common.lib.research.ResearchManager;
|
||||
import thaumcraft.common.lib.world.ThaumcraftWorldGenerator;
|
||||
|
||||
public class ItemConcentratedTaint extends Item{
|
||||
public class ItemConcentratedTaint extends Item {
|
||||
|
||||
public boolean onItemUse(ItemStack stk, EntityPlayer user, World w, int x, int y, int z, int side, float vecX, float vecY, float vecZ)
|
||||
{
|
||||
--stk.stackSize;
|
||||
w.playSound(x, y, z, "break.glass", 1, 1, false);
|
||||
|
||||
Block b = w.getBlock(x, y, z);
|
||||
if(b == ConfigBlocks.blockAiry)
|
||||
{
|
||||
TileEntity tile = w.getTileEntity(x, y, z);
|
||||
if(tile instanceof INode)
|
||||
{
|
||||
INode.class.cast(tile).setNodeType(NodeType.TAINTED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 100; ++i)
|
||||
{
|
||||
int dX = x + MathHelper.floor_double(MathUtils.randomDouble(w.rand)*16);
|
||||
int dZ = z + MathHelper.floor_double(MathUtils.randomDouble(w.rand)*16);
|
||||
int dY = y + w.rand.nextInt(2) - w.rand.nextInt(2);
|
||||
MiscUtils.changeBiome(w, ThaumcraftWorldGenerator.biomeTaint, dX, dZ);
|
||||
if (w.isBlockNormalCubeDefault(dX, dY - 1, dZ, false) && w.getBlock(dX, dY, dZ).isReplaceable(w, dX, dY, dZ))
|
||||
{
|
||||
w.setBlock(dX, dY, dZ, ConfigBlocks.blockTaintFibres, 0, 3);
|
||||
}
|
||||
Thaumcraft.proxy.bottleTaintBreak(w, dX, dY, dZ);
|
||||
}
|
||||
|
||||
return true;
|
||||
public boolean onItemUse(
|
||||
ItemStack stk,
|
||||
EntityPlayer user,
|
||||
World w,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float vecX,
|
||||
float vecY,
|
||||
float vecZ) {
|
||||
--stk.stackSize;
|
||||
w.playSound(x, y, z, "break.glass", 1, 1, false);
|
||||
|
||||
Block b = w.getBlock(x, y, z);
|
||||
if (b == ConfigBlocks.blockAiry) {
|
||||
TileEntity tile = w.getTileEntity(x, y, z);
|
||||
if (tile instanceof INode) {
|
||||
INode.class.cast(tile).setNodeType(NodeType.TAINTED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
int dX = x + MathHelper.floor_double(MathUtils.randomDouble(w.rand) * 16);
|
||||
int dZ = z + MathHelper.floor_double(MathUtils.randomDouble(w.rand) * 16);
|
||||
int dY = y + w.rand.nextInt(2) - w.rand.nextInt(2);
|
||||
MiscUtils.changeBiome(w, ThaumcraftWorldGenerator.biomeTaint, dX, dZ);
|
||||
if (w.isBlockNormalCubeDefault(dX, dY - 1, dZ, false)
|
||||
&& w.getBlock(dX, dY, dZ).isReplaceable(w, dX, dY, dZ)) {
|
||||
w.setBlock(dX, dY, dZ, ConfigBlocks.blockTaintFibres, 0, 3);
|
||||
}
|
||||
Thaumcraft.proxy.bottleTaintBreak(w, dX, dY, dZ);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean itemInteractionForEntity(ItemStack stk, EntityPlayer user, EntityLivingBase usedOn)
|
||||
{
|
||||
if(!(usedOn instanceof ITaintedMob))
|
||||
{
|
||||
--stk.stackSize;
|
||||
user.swingItem();
|
||||
|
||||
usedOn.addPotionEffect(new PotionEffect(Config.potionTaintPoisonID,200,1,true));
|
||||
|
||||
if(usedOn instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer victum = (EntityPlayer) usedOn;
|
||||
for(int i = 0; i < victum.inventory.armorInventory.length; ++i)
|
||||
{
|
||||
ItemStack armor = victum.inventory.armorInventory[i];
|
||||
if(armor != null)
|
||||
{
|
||||
ItemStack newArmor = armor.copy();
|
||||
EntityItem actualArmor = new EntityItem(victum.worldObj,victum.posX,victum.posY,victum.posZ,newArmor);
|
||||
actualArmor.delayBeforeCanPickup = 1200;
|
||||
if(!victum.worldObj.isRemote)
|
||||
victum.worldObj.spawnEntityInWorld(actualArmor);
|
||||
|
||||
armor = null;
|
||||
victum.inventory.armorInventory[i] = null;
|
||||
}
|
||||
}
|
||||
victum.addPotionEffect(new PotionEffect(Potion.blindness.id,200,0,true));
|
||||
victum.addPotionEffect(new PotionEffect(Potion.nightVision.id,200,0,true));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
public boolean itemInteractionForEntity(ItemStack stk, EntityPlayer user, EntityLivingBase usedOn) {
|
||||
if (!(usedOn instanceof ITaintedMob)) {
|
||||
--stk.stackSize;
|
||||
user.swingItem();
|
||||
|
||||
usedOn.addPotionEffect(new PotionEffect(Config.potionTaintPoisonID, 200, 1, true));
|
||||
|
||||
if (usedOn instanceof EntityPlayer) {
|
||||
EntityPlayer victum = (EntityPlayer) usedOn;
|
||||
for (int i = 0; i < victum.inventory.armorInventory.length; ++i) {
|
||||
ItemStack armor = victum.inventory.armorInventory[i];
|
||||
if (armor != null) {
|
||||
ItemStack newArmor = armor.copy();
|
||||
EntityItem actualArmor =
|
||||
new EntityItem(victum.worldObj, victum.posX, victum.posY, victum.posZ, newArmor);
|
||||
actualArmor.delayBeforeCanPickup = 1200;
|
||||
if (!victum.worldObj.isRemote) victum.worldObj.spawnEntityInWorld(actualArmor);
|
||||
|
||||
armor = null;
|
||||
victum.inventory.armorInventory[i] = null;
|
||||
}
|
||||
}
|
||||
victum.addPotionEffect(new PotionEffect(Potion.blindness.id, 200, 0, true));
|
||||
victum.addPotionEffect(new PotionEffect(Potion.nightVision.id, 200, 0, true));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer player)
|
||||
{
|
||||
if(ResearchManager.isResearchComplete(player.getCommandSenderName(), "TB.TaintMinor"))
|
||||
player.setItemInUse(stack, getMaxItemUseDuration(stack));
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer player) {
|
||||
if (ResearchManager.isResearchComplete(player.getCommandSenderName(), "TB.TaintMinor"))
|
||||
player.setItemInUse(stack, getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
|
||||
public EnumAction getItemUseAction(ItemStack stack) {
|
||||
return EnumAction.drink;
|
||||
}
|
||||
|
||||
public int getMaxItemUseDuration(ItemStack stack)
|
||||
{
|
||||
public int getMaxItemUseDuration(ItemStack stack) {
|
||||
return 32;
|
||||
}
|
||||
|
||||
public ItemStack onEaten(ItemStack stack, World w, EntityPlayer player)
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
|
||||
public ItemStack onEaten(ItemStack stack, World w, EntityPlayer player) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
--stack.stackSize;
|
||||
if(stack.stackSize > 0)
|
||||
{
|
||||
if(!player.inventory.addItemStackToInventory(new ItemStack(ConfigItems.itemEssence,1,0)))
|
||||
player.dropPlayerItemWithRandomChoice(new ItemStack(ConfigItems.itemEssence,1,0), false);
|
||||
if (stack.stackSize > 0) {
|
||||
if (!player.inventory.addItemStackToInventory(new ItemStack(ConfigItems.itemEssence, 1, 0)))
|
||||
player.dropPlayerItemWithRandomChoice(new ItemStack(ConfigItems.itemEssence, 1, 0), false);
|
||||
}
|
||||
}
|
||||
|
||||
if(player.getHealth() < player.getMaxHealth())
|
||||
{
|
||||
for(int i = 0; i < 99; ++i)
|
||||
player.attackEntityFrom(DamageSourceThaumcraft.taint, Integer.MAX_VALUE);
|
||||
}else
|
||||
{
|
||||
player.setHealth(1);
|
||||
player.addPotionEffect(new PotionEffect(Potion.blindness.getId(),600,0,true));
|
||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.getId(),600,0,true));
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(),600,4,true));
|
||||
player.addPotionEffect(new PotionEffect(Potion.weakness.getId(),600,4,true));
|
||||
player.addPotionEffect(new PotionEffect(Potion.confusion.getId(),100,0,true));
|
||||
|
||||
if(player.posY > 6)
|
||||
{
|
||||
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.howlBelow")).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_PURPLE).setItalic(true)));
|
||||
TBUtils.addWarpToPlayer(player, 6, 0);
|
||||
}else
|
||||
{
|
||||
if(player.worldObj.provider != null && player.worldObj.provider.dimensionId == -1)
|
||||
{
|
||||
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.taintDevelop")).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_PURPLE).setItalic(true)));
|
||||
TBUtils.addWarpToPlayer(player, 18, 0);
|
||||
TBUtils.addWarpToPlayer(player, 6, 1);
|
||||
TBUtils.addWarpToPlayer(player, 1, 2);
|
||||
if(!ResearchManager.isResearchComplete(player.getCommandSenderName(), "TB.TaintProgress"))
|
||||
PacketHandler.INSTANCE.sendTo(new PacketResearchComplete("@TB.TaintProgress"), (EntityPlayerMP)player);
|
||||
}else
|
||||
{
|
||||
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.howlDeeper")).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_PURPLE).setItalic(true)));
|
||||
TBUtils.addWarpToPlayer(player, 12, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (player.getHealth() < player.getMaxHealth()) {
|
||||
for (int i = 0; i < 99; ++i) player.attackEntityFrom(DamageSourceThaumcraft.taint, Integer.MAX_VALUE);
|
||||
} else {
|
||||
player.setHealth(1);
|
||||
player.addPotionEffect(new PotionEffect(Potion.blindness.getId(), 600, 0, true));
|
||||
player.addPotionEffect(new PotionEffect(Potion.nightVision.getId(), 600, 0, true));
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 600, 4, true));
|
||||
player.addPotionEffect(new PotionEffect(Potion.weakness.getId(), 600, 4, true));
|
||||
player.addPotionEffect(new PotionEffect(Potion.confusion.getId(), 100, 0, true));
|
||||
|
||||
if (player.posY > 6) {
|
||||
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.howlBelow"))
|
||||
.setChatStyle(new ChatStyle()
|
||||
.setColor(EnumChatFormatting.DARK_PURPLE)
|
||||
.setItalic(true)));
|
||||
TBUtils.addWarpToPlayer(player, 6, 0);
|
||||
} else {
|
||||
if (player.worldObj.provider != null && player.worldObj.provider.dimensionId == -1) {
|
||||
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.taintDevelop"))
|
||||
.setChatStyle(new ChatStyle()
|
||||
.setColor(EnumChatFormatting.DARK_PURPLE)
|
||||
.setItalic(true)));
|
||||
TBUtils.addWarpToPlayer(player, 18, 0);
|
||||
TBUtils.addWarpToPlayer(player, 6, 1);
|
||||
TBUtils.addWarpToPlayer(player, 1, 2);
|
||||
if (!ResearchManager.isResearchComplete(player.getCommandSenderName(), "TB.TaintProgress"))
|
||||
PacketHandler.INSTANCE.sendTo(
|
||||
new PacketResearchComplete("@TB.TaintProgress"), (EntityPlayerMP) player);
|
||||
} else {
|
||||
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.howlDeeper"))
|
||||
.setChatStyle(new ChatStyle()
|
||||
.setColor(EnumChatFormatting.DARK_PURPLE)
|
||||
.setItalic(true)));
|
||||
TBUtils.addWarpToPlayer(player, 12, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stack.stackSize <= 0 ? new ItemStack(ConfigItems.itemEssence,1,0) : stack;
|
||||
return stack.stackSize <= 0 ? new ItemStack(ConfigItems.itemEssence, 1, 0) : stack;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +1,13 @@
|
||||
package tb.common.item;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import tb.core.TBCore;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -36,120 +30,135 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import tb.core.TBCore;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
|
||||
public class ItemHerobrinesScythe extends ItemSword implements IRepairable,IWarpingGear{
|
||||
public class ItemHerobrinesScythe extends ItemSword implements IRepairable, IWarpingGear {
|
||||
|
||||
public ItemHerobrinesScythe()
|
||||
{
|
||||
super(ToolMaterial.EMERALD);
|
||||
}
|
||||
|
||||
public EnumRarity getRarity(ItemStack itemstack)
|
||||
{
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List lst, boolean held)
|
||||
{
|
||||
lst.add(EnumChatFormatting.ITALIC+"Well, they're nothing..."); //Do not translate this line, it is a reference to TheAtlanticCraft's song - The Herobrine
|
||||
public ItemHerobrinesScythe() {
|
||||
super(ToolMaterial.EMERALD);
|
||||
}
|
||||
|
||||
public void onUpdate(ItemStack stk, World w, Entity entity, int slot, boolean held)
|
||||
{
|
||||
super.onUpdate(stk, w, entity, slot, held);
|
||||
if ((stk.isItemDamaged()) && (entity != null) && (entity.ticksExisted % 20 == 0) && ((entity instanceof EntityLivingBase)))
|
||||
stk.damageItem(-1, (EntityLivingBase)entity);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void attack(EntityPlayer attacker, List<EntityLivingBase> doNotAttack, EntityLivingBase attacked)
|
||||
{
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(attacked.posX-1, attacked.posY-1, attacked.posZ-1, attacked.posX+1, attacked.posY+1, attacked.posZ+1).expand(6, 6, 6);
|
||||
|
||||
List<EntityLivingBase> mobs = attacked.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, aabb);
|
||||
|
||||
Random rnd = attacker.worldObj.rand;
|
||||
|
||||
mobs.removeAll(doNotAttack);
|
||||
|
||||
if(!mobs.isEmpty())
|
||||
{
|
||||
while(!mobs.isEmpty())
|
||||
{
|
||||
int index = rnd.nextInt(mobs.size());
|
||||
if(mobs.get(index) != null && mobs.get(index).isEntityAlive() && mobs.get(index) instanceof IMob && !(mobs.get(index) instanceof EntityPlayer))
|
||||
{
|
||||
performPlayerAttackAt(attacker,mobs.get(index));
|
||||
|
||||
TBCore.proxy.lightning(attacker.worldObj, attacked.posX, attacked.posY+rnd.nextDouble()*attacked.getEyeHeight(), attacked.posZ, mobs.get(index).posX, mobs.get(index).posY+rnd.nextDouble()*mobs.get(index).getEyeHeight(), mobs.get(index).posZ, 20, 2F, 10, 0);
|
||||
attacker.worldObj.playSoundAtEntity(mobs.get(index), "thaumcraft:zap", 1F, 0.8F);
|
||||
|
||||
doNotAttack.add(mobs.get(index));
|
||||
|
||||
attack(attacker,doNotAttack,mobs.get(index));
|
||||
|
||||
break;
|
||||
|
||||
}else
|
||||
{
|
||||
mobs.remove(index);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stk, EntityPlayer attacker, Entity attacked)
|
||||
{
|
||||
if(attacked.isEntityAlive() && attacked instanceof IMob)
|
||||
{
|
||||
attack(attacker,new ArrayList<EntityLivingBase>(),(EntityLivingBase) attacked);
|
||||
}
|
||||
return super.onLeftClickEntity(stk, attacker, attacked);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copied from {@link EntityPlayer#attackTargetEntityWithCurrentItem(Entity)} to not call the {@link #onLeftClickEntity(ItemStack, EntityPlayer, Entity)}
|
||||
* @param p the player
|
||||
* @param p_71059_1_ attacked entity
|
||||
*/
|
||||
public static void performPlayerAttackAt(EntityPlayer p, Entity p_71059_1_)
|
||||
{
|
||||
if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(p, p_71059_1_)))
|
||||
{
|
||||
|
||||
public EnumRarity getRarity(ItemStack itemstack) {
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List lst, boolean held) {
|
||||
lst.add(EnumChatFormatting.ITALIC
|
||||
+ "Well, they're nothing..."); // Do not translate this line, it is a reference to TheAtlanticCraft's
|
||||
// song - The Herobrine
|
||||
}
|
||||
|
||||
public void onUpdate(ItemStack stk, World w, Entity entity, int slot, boolean held) {
|
||||
super.onUpdate(stk, w, entity, slot, held);
|
||||
if ((stk.isItemDamaged())
|
||||
&& (entity != null)
|
||||
&& (entity.ticksExisted % 20 == 0)
|
||||
&& ((entity instanceof EntityLivingBase))) stk.damageItem(-1, (EntityLivingBase) entity);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void attack(EntityPlayer attacker, List<EntityLivingBase> doNotAttack, EntityLivingBase attacked) {
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(
|
||||
attacked.posX - 1,
|
||||
attacked.posY - 1,
|
||||
attacked.posZ - 1,
|
||||
attacked.posX + 1,
|
||||
attacked.posY + 1,
|
||||
attacked.posZ + 1)
|
||||
.expand(6, 6, 6);
|
||||
|
||||
List<EntityLivingBase> mobs = attacked.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, aabb);
|
||||
|
||||
Random rnd = attacker.worldObj.rand;
|
||||
|
||||
mobs.removeAll(doNotAttack);
|
||||
|
||||
if (!mobs.isEmpty()) {
|
||||
while (!mobs.isEmpty()) {
|
||||
int index = rnd.nextInt(mobs.size());
|
||||
if (mobs.get(index) != null
|
||||
&& mobs.get(index).isEntityAlive()
|
||||
&& mobs.get(index) instanceof IMob
|
||||
&& !(mobs.get(index) instanceof EntityPlayer)) {
|
||||
performPlayerAttackAt(attacker, mobs.get(index));
|
||||
|
||||
TBCore.proxy.lightning(
|
||||
attacker.worldObj,
|
||||
attacked.posX,
|
||||
attacked.posY + rnd.nextDouble() * attacked.getEyeHeight(),
|
||||
attacked.posZ,
|
||||
mobs.get(index).posX,
|
||||
mobs.get(index).posY
|
||||
+ rnd.nextDouble() * mobs.get(index).getEyeHeight(),
|
||||
mobs.get(index).posZ,
|
||||
20,
|
||||
2F,
|
||||
10,
|
||||
0);
|
||||
attacker.worldObj.playSoundAtEntity(mobs.get(index), "thaumcraft:zap", 1F, 0.8F);
|
||||
|
||||
doNotAttack.add(mobs.get(index));
|
||||
|
||||
attack(attacker, doNotAttack, mobs.get(index));
|
||||
|
||||
break;
|
||||
|
||||
} else {
|
||||
mobs.remove(index);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stk, EntityPlayer attacker, Entity attacked) {
|
||||
if (attacked.isEntityAlive() && attacked instanceof IMob) {
|
||||
attack(attacker, new ArrayList<EntityLivingBase>(), (EntityLivingBase) attacked);
|
||||
}
|
||||
return super.onLeftClickEntity(stk, attacker, attacked);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from {@link EntityPlayer#attackTargetEntityWithCurrentItem(Entity)} to not call the {@link #onLeftClickEntity(ItemStack, EntityPlayer, Entity)}
|
||||
* @param p the player
|
||||
* @param p_71059_1_ attacked entity
|
||||
*/
|
||||
public static void performPlayerAttackAt(EntityPlayer p, Entity p_71059_1_) {
|
||||
if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(p, p_71059_1_))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_71059_1_.canAttackWithItem())
|
||||
{
|
||||
if (!p_71059_1_.hitByEntity(p))
|
||||
{
|
||||
float f = (float)p.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
|
||||
|
||||
if (p_71059_1_.canAttackWithItem()) {
|
||||
if (!p_71059_1_.hitByEntity(p)) {
|
||||
float f = (float) p.getEntityAttribute(SharedMonsterAttributes.attackDamage)
|
||||
.getAttributeValue();
|
||||
int i = 0;
|
||||
float f1 = 0.0F;
|
||||
|
||||
if (p_71059_1_ instanceof EntityLivingBase)
|
||||
{
|
||||
f1 = EnchantmentHelper.getEnchantmentModifierLiving(p, (EntityLivingBase)p_71059_1_);
|
||||
i += EnchantmentHelper.getKnockbackModifier(p, (EntityLivingBase)p_71059_1_);
|
||||
if (p_71059_1_ instanceof EntityLivingBase) {
|
||||
f1 = EnchantmentHelper.getEnchantmentModifierLiving(p, (EntityLivingBase) p_71059_1_);
|
||||
i += EnchantmentHelper.getKnockbackModifier(p, (EntityLivingBase) p_71059_1_);
|
||||
}
|
||||
|
||||
if (p.isSprinting())
|
||||
{
|
||||
if (p.isSprinting()) {
|
||||
++i;
|
||||
}
|
||||
|
||||
if (f > 0.0F || f1 > 0.0F)
|
||||
{
|
||||
boolean flag = p.fallDistance > 0.0F && !p.onGround && !p.isOnLadder() && !p.isInWater() && !p.isPotionActive(Potion.blindness) && p.ridingEntity == null && p_71059_1_ instanceof EntityLivingBase;
|
||||
if (f > 0.0F || f1 > 0.0F) {
|
||||
boolean flag = p.fallDistance > 0.0F
|
||||
&& !p.onGround
|
||||
&& !p.isOnLadder()
|
||||
&& !p.isInWater()
|
||||
&& !p.isPotionActive(Potion.blindness)
|
||||
&& p.ridingEntity == null
|
||||
&& p_71059_1_ instanceof EntityLivingBase;
|
||||
|
||||
if (flag && f > 0.0F)
|
||||
{
|
||||
if (flag && f > 0.0F) {
|
||||
f *= 1.5F;
|
||||
}
|
||||
|
||||
@@ -157,110 +166,104 @@ public class ItemHerobrinesScythe extends ItemSword implements IRepairable,IWarp
|
||||
boolean flag1 = false;
|
||||
int j = EnchantmentHelper.getFireAspectModifier(p);
|
||||
|
||||
if (p_71059_1_ instanceof EntityLivingBase && j > 0 && !p_71059_1_.isBurning())
|
||||
{
|
||||
if (p_71059_1_ instanceof EntityLivingBase && j > 0 && !p_71059_1_.isBurning()) {
|
||||
flag1 = true;
|
||||
p_71059_1_.setFire(1);
|
||||
}
|
||||
|
||||
boolean flag2 = p_71059_1_.attackEntityFrom(DamageSource.causePlayerDamage(p), f);
|
||||
|
||||
if (flag2)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
p_71059_1_.addVelocity((double)(-MathHelper.sin(p.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F), 0.1D, (double)(MathHelper.cos(p.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F));
|
||||
if (flag2) {
|
||||
if (i > 0) {
|
||||
p_71059_1_.addVelocity(
|
||||
(double) (-MathHelper.sin(p.rotationYaw * (float) Math.PI / 180.0F)
|
||||
* (float) i
|
||||
* 0.5F),
|
||||
0.1D,
|
||||
(double) (MathHelper.cos(p.rotationYaw * (float) Math.PI / 180.0F)
|
||||
* (float) i
|
||||
* 0.5F));
|
||||
p.motionX *= 0.6D;
|
||||
p.motionZ *= 0.6D;
|
||||
p.setSprinting(false);
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
p.onCriticalHit(p_71059_1_);
|
||||
}
|
||||
|
||||
if (f1 > 0.0F)
|
||||
{
|
||||
if (f1 > 0.0F) {
|
||||
p.onEnchantmentCritical(p_71059_1_);
|
||||
}
|
||||
|
||||
if (f >= 18.0F)
|
||||
{
|
||||
if (f >= 18.0F) {
|
||||
p.triggerAchievement(AchievementList.overkill);
|
||||
}
|
||||
|
||||
p.setLastAttacker(p_71059_1_);
|
||||
|
||||
if (p_71059_1_ instanceof EntityLivingBase)
|
||||
{
|
||||
EnchantmentHelper.func_151384_a((EntityLivingBase)p_71059_1_, p);
|
||||
if (p_71059_1_ instanceof EntityLivingBase) {
|
||||
EnchantmentHelper.func_151384_a((EntityLivingBase) p_71059_1_, p);
|
||||
}
|
||||
|
||||
EnchantmentHelper.func_151385_b(p, p_71059_1_);
|
||||
ItemStack itemstack = p.getCurrentEquippedItem();
|
||||
Object object = p_71059_1_;
|
||||
|
||||
if (p_71059_1_ instanceof EntityDragonPart)
|
||||
{
|
||||
IEntityMultiPart ientitymultipart = ((EntityDragonPart)p_71059_1_).entityDragonObj;
|
||||
if (p_71059_1_ instanceof EntityDragonPart) {
|
||||
IEntityMultiPart ientitymultipart = ((EntityDragonPart) p_71059_1_).entityDragonObj;
|
||||
|
||||
if (ientitymultipart != null && ientitymultipart instanceof EntityLivingBase)
|
||||
{
|
||||
object = (EntityLivingBase)ientitymultipart;
|
||||
if (ientitymultipart != null && ientitymultipart instanceof EntityLivingBase) {
|
||||
object = (EntityLivingBase) ientitymultipart;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemstack != null && object instanceof EntityLivingBase)
|
||||
{
|
||||
itemstack.hitEntity((EntityLivingBase)object, p);
|
||||
if (itemstack != null && object instanceof EntityLivingBase) {
|
||||
itemstack.hitEntity((EntityLivingBase) object, p);
|
||||
|
||||
if (itemstack.stackSize <= 0)
|
||||
{
|
||||
if (itemstack.stackSize <= 0) {
|
||||
p.destroyCurrentEquippedItem();
|
||||
}
|
||||
}
|
||||
|
||||
if (p_71059_1_ instanceof EntityLivingBase)
|
||||
{
|
||||
if (p_71059_1_ instanceof EntityLivingBase) {
|
||||
p.addStat(StatList.damageDealtStat, Math.round(f * 10.0F));
|
||||
|
||||
if (j > 0)
|
||||
{
|
||||
if (j > 0) {
|
||||
p_71059_1_.setFire(j * 4);
|
||||
}
|
||||
}
|
||||
|
||||
p.addExhaustion(0.3F);
|
||||
}
|
||||
else if (flag1)
|
||||
{
|
||||
} else if (flag1) {
|
||||
p_71059_1_.extinguish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getWarp(ItemStack itemstack, EntityPlayer player)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Multimap getAttributeModifiers(ItemStack stack)
|
||||
{
|
||||
Multimap attribs = HashMultimap.create();
|
||||
|
||||
attribs.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"), "Weapon modifier", 14.5F, 0));
|
||||
attribs.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CE"), "Speed modifier", 0.5F, 2));
|
||||
|
||||
return attribs;
|
||||
}
|
||||
|
||||
public boolean isItemTool(ItemStack stk)
|
||||
{
|
||||
return true;
|
||||
|
||||
public int getWarp(ItemStack itemstack, EntityPlayer player) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public Multimap getAttributeModifiers(ItemStack stack) {
|
||||
Multimap attribs = HashMultimap.create();
|
||||
|
||||
attribs.put(
|
||||
SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(),
|
||||
new AttributeModifier(
|
||||
UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"), "Weapon modifier", 14.5F, 0));
|
||||
attribs.put(
|
||||
SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(),
|
||||
new AttributeModifier(
|
||||
UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CE"), "Speed modifier", 0.5F, 2));
|
||||
|
||||
return attribs;
|
||||
}
|
||||
|
||||
public boolean isItemTool(ItemStack stk) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,8 @@
|
||||
package tb.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import tb.utils.TBUtils;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -16,130 +12,106 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import tb.utils.TBUtils;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
|
||||
public class ItemKnoseFragment extends Item
|
||||
{
|
||||
|
||||
public static final String names[] = new String[]{
|
||||
"air",
|
||||
"fire",
|
||||
"aqua",
|
||||
"terra",
|
||||
"order",
|
||||
"entropy",
|
||||
"mixed",
|
||||
"tainted"
|
||||
};
|
||||
|
||||
public static final AspectList[] addedAspects = new AspectList[]{
|
||||
lst(8,Aspect.AIR),
|
||||
lst(8,Aspect.FIRE),
|
||||
lst(8,Aspect.WATER),
|
||||
lst(8,Aspect.EARTH),
|
||||
lst(8,Aspect.ORDER),
|
||||
lst(8,Aspect.ENTROPY),
|
||||
lst(2,Aspect.FIRE,Aspect.WATER,Aspect.EARTH,Aspect.AIR,Aspect.ORDER,Aspect.ENTROPY)
|
||||
};
|
||||
|
||||
public static IIcon[] icons = new IIcon[names.length];
|
||||
public class ItemKnoseFragment extends Item {
|
||||
|
||||
public static final String names[] =
|
||||
new String[] {"air", "fire", "aqua", "terra", "order", "entropy", "mixed", "tainted"};
|
||||
|
||||
public static final AspectList[] addedAspects = new AspectList[] {
|
||||
lst(8, Aspect.AIR),
|
||||
lst(8, Aspect.FIRE),
|
||||
lst(8, Aspect.WATER),
|
||||
lst(8, Aspect.EARTH),
|
||||
lst(8, Aspect.ORDER),
|
||||
lst(8, Aspect.ENTROPY),
|
||||
lst(2, Aspect.FIRE, Aspect.WATER, Aspect.EARTH, Aspect.AIR, Aspect.ORDER, Aspect.ENTROPY)
|
||||
};
|
||||
|
||||
public static IIcon[] icons = new IIcon[names.length];
|
||||
|
||||
public ItemKnoseFragment() {
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
public static final AspectList lst(int num, Aspect... aspect) {
|
||||
AspectList aLst = new AspectList();
|
||||
|
||||
for (int i = 0; i < aspect.length; ++i) aLst.add(aspect[i], num);
|
||||
|
||||
return aLst;
|
||||
}
|
||||
|
||||
public ItemKnoseFragment()
|
||||
{
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
public static final AspectList lst(int num,Aspect... aspect)
|
||||
{
|
||||
AspectList aLst = new AspectList();
|
||||
|
||||
for(int i = 0; i < aspect.length; ++i)
|
||||
aLst.add(aspect[i], num);
|
||||
|
||||
return aLst;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
public int getMetadata(int meta)
|
||||
{
|
||||
return meta;
|
||||
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
return super.getUnlocalizedName(is)+names[is.getItemDamage()].replace('/', '.');
|
||||
|
||||
public String getUnlocalizedName(ItemStack is) {
|
||||
return super.getUnlocalizedName(is) + names[is.getItemDamage()].replace('/', '.');
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg)
|
||||
{
|
||||
for(int i = 0; i < names.length; ++i)
|
||||
icons[i] = reg.registerIcon(iconString+names[i]+"Fragment");
|
||||
public void registerIcons(IIconRegister reg) {
|
||||
for (int i = 0; i < names.length; ++i) icons[i] = reg.registerIcon(iconString + names[i] + "Fragment");
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item itm, CreativeTabs tab, List lst)
|
||||
{
|
||||
for(int i = 0; i < names.length; ++i)
|
||||
lst.add(new ItemStack(itm,1,i));
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item itm, CreativeTabs tab, List lst) {
|
||||
for (int i = 0; i < names.length; ++i) lst.add(new ItemStack(itm, 1, i));
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stk, World w, EntityPlayer player)
|
||||
{
|
||||
int meta = stk.getItemDamage();
|
||||
if(!player.worldObj.isRemote)
|
||||
if(meta < 7)
|
||||
{
|
||||
for(int i = 0; i < addedAspects[meta].size(); ++i)
|
||||
TBUtils.addAspectToKnowledgePool(player, addedAspects[meta].getAspects()[i], (short) addedAspects[meta].getAmount(addedAspects[meta].getAspects()[i]));
|
||||
}else
|
||||
{
|
||||
//if(!ResearchManager.isResearchComplete(player.getCommandSenderName(), "TB.TaintMinor"))
|
||||
// PacketHandler.INSTANCE.sendTo(new PacketResearchComplete("@TB.TaintMinor"), (EntityPlayerMP)player);
|
||||
int overhaulAddedAspects = 0;
|
||||
for(int i = 0; i < Aspect.getCompoundAspects().size(); ++i)
|
||||
{
|
||||
Aspect a = Aspect.getCompoundAspects().get(i);
|
||||
if(a == Aspect.TAINT)
|
||||
{
|
||||
TBUtils.addAspectToKnowledgePool(player, a, (short) 8);
|
||||
TBUtils.addWarpToPlayer(player, 2, 0);
|
||||
++overhaulAddedAspects;
|
||||
}else
|
||||
{
|
||||
if(player.worldObj.rand.nextBoolean())
|
||||
{
|
||||
TBUtils.addAspectToKnowledgePool(player, a, (short) 1);
|
||||
++overhaulAddedAspects;
|
||||
}
|
||||
if(player.worldObj.rand.nextInt(24) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < overhaulAddedAspects; ++i)
|
||||
if(w.rand.nextFloat() <= 0.1F)
|
||||
TBUtils.addWarpToPlayer(player, 1, w.rand.nextFloat() <= 0.15F ? 0 : 1);
|
||||
}
|
||||
//player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
|
||||
//1.7 old
|
||||
//return stk.stackSize <= 0 ? null : stk;
|
||||
|
||||
//1.8 change
|
||||
--stk.stackSize;
|
||||
return stk;
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stk, World w, EntityPlayer player) {
|
||||
int meta = stk.getItemDamage();
|
||||
if (!player.worldObj.isRemote)
|
||||
if (meta < 7) {
|
||||
for (int i = 0; i < addedAspects[meta].size(); ++i)
|
||||
TBUtils.addAspectToKnowledgePool(player, addedAspects[meta].getAspects()[i], (short)
|
||||
addedAspects[meta].getAmount(addedAspects[meta].getAspects()[i]));
|
||||
} else {
|
||||
// if(!ResearchManager.isResearchComplete(player.getCommandSenderName(), "TB.TaintMinor"))
|
||||
// PacketHandler.INSTANCE.sendTo(new PacketResearchComplete("@TB.TaintMinor"), (EntityPlayerMP)player);
|
||||
int overhaulAddedAspects = 0;
|
||||
for (int i = 0; i < Aspect.getCompoundAspects().size(); ++i) {
|
||||
Aspect a = Aspect.getCompoundAspects().get(i);
|
||||
if (a == Aspect.TAINT) {
|
||||
TBUtils.addAspectToKnowledgePool(player, a, (short) 8);
|
||||
TBUtils.addWarpToPlayer(player, 2, 0);
|
||||
++overhaulAddedAspects;
|
||||
} else {
|
||||
if (player.worldObj.rand.nextBoolean()) {
|
||||
TBUtils.addAspectToKnowledgePool(player, a, (short) 1);
|
||||
++overhaulAddedAspects;
|
||||
}
|
||||
if (player.worldObj.rand.nextInt(24) == 0) break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < overhaulAddedAspects; ++i)
|
||||
if (w.rand.nextFloat() <= 0.1F)
|
||||
TBUtils.addWarpToPlayer(player, 1, w.rand.nextFloat() <= 0.15F ? 0 : 1);
|
||||
}
|
||||
// player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
|
||||
// 1.7 old
|
||||
// return stk.stackSize <= 0 ? null : stk;
|
||||
|
||||
// 1.8 change
|
||||
--stk.stackSize;
|
||||
return stk;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List lst, boolean held)
|
||||
{
|
||||
lst.add(EnumChatFormatting.AQUA+StatCollector.translateToLocal("tb.txt.knoseFragment"));
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List lst, boolean held) {
|
||||
lst.add(EnumChatFormatting.AQUA + StatCollector.translateToLocal("tb.txt.knoseFragment"));
|
||||
}
|
||||
}
|
||||
@@ -2,43 +2,49 @@ package tb.common.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemSeeds;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemKnoseSeeds extends ItemSeeds{
|
||||
public class ItemKnoseSeeds extends ItemSeeds {
|
||||
|
||||
private Block cropBlock;
|
||||
private Block soilBlockID;
|
||||
|
||||
public ItemKnoseSeeds(Block crop, Block soil) {
|
||||
super(crop, soil);
|
||||
|
||||
public ItemKnoseSeeds(Block crop, Block soil) {
|
||||
super(crop, soil);
|
||||
this.cropBlock = crop;
|
||||
this.soilBlockID = soil;
|
||||
}
|
||||
|
||||
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float fx, float fy, float fz)
|
||||
{
|
||||
if (side != 1) {
|
||||
return false;
|
||||
}
|
||||
else if (player.canPlayerEdit(x, y, z, side, itemStack) && player.canPlayerEdit(x, y + 1, z, side, itemStack)) {
|
||||
if (world.getBlock(x, y, z) == soilBlockID) {
|
||||
if (world.isAirBlock(x, y+1, z)) { /*world.getBlock(x, y + 1, z) == Blocks.air*/
|
||||
world.setBlock(x, y + 1, z, this.cropBlock);
|
||||
--itemStack.stackSize;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onItemUse(
|
||||
ItemStack itemStack,
|
||||
EntityPlayer player,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float fx,
|
||||
float fy,
|
||||
float fz) {
|
||||
if (side != 1) {
|
||||
return false;
|
||||
} else if (player.canPlayerEdit(x, y, z, side, itemStack)
|
||||
&& player.canPlayerEdit(x, y + 1, z, side, itemStack)) {
|
||||
if (world.getBlock(x, y, z) == soilBlockID) {
|
||||
if (world.isAirBlock(x, y + 1, z)) {
|
||||
/*world.getBlock(x, y + 1, z) == Blocks.air*/
|
||||
world.setBlock(x, y + 1, z, this.cropBlock);
|
||||
--itemStack.stackSize;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -3,27 +3,24 @@ package tb.common.item;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemMortarAndPestle extends Item{
|
||||
|
||||
public ItemMortarAndPestle()
|
||||
{
|
||||
this.setMaxDamage(256);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
public boolean hasContainerItem(ItemStack stack)
|
||||
{
|
||||
return !(stack.getItemDamage() >= stack.getMaxDamage());
|
||||
}
|
||||
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
{
|
||||
return itemStack.getItemDamage() >= itemStack.getMaxDamage() ? null : new ItemStack(itemStack.getItem(),1,itemStack.getItemDamage()+1);
|
||||
}
|
||||
|
||||
public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
public class ItemMortarAndPestle extends Item {
|
||||
|
||||
public ItemMortarAndPestle() {
|
||||
this.setMaxDamage(256);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
public boolean hasContainerItem(ItemStack stack) {
|
||||
return !(stack.getItemDamage() >= stack.getMaxDamage());
|
||||
}
|
||||
|
||||
public ItemStack getContainerItem(ItemStack itemStack) {
|
||||
return itemStack.getItemDamage() >= itemStack.getMaxDamage()
|
||||
? null
|
||||
: new ItemStack(itemStack.getItem(), 1, itemStack.getItemDamage() + 1);
|
||||
}
|
||||
|
||||
public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +1,45 @@
|
||||
package tb.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemNodeFoci extends Item{
|
||||
public class ItemNodeFoci extends Item {
|
||||
|
||||
public static final String names[] = new String[]{
|
||||
"brightness",
|
||||
"destruction",
|
||||
"efficiency",
|
||||
"hunger",
|
||||
"instability",
|
||||
"purity",
|
||||
"sinister",
|
||||
"speed",
|
||||
"stability",
|
||||
"taint"
|
||||
};
|
||||
|
||||
public ItemNodeFoci()
|
||||
{
|
||||
super();
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
public int getMetadata(int meta)
|
||||
{
|
||||
return meta;
|
||||
public static final String names[] = new String[] {
|
||||
"brightness",
|
||||
"destruction",
|
||||
"efficiency",
|
||||
"hunger",
|
||||
"instability",
|
||||
"purity",
|
||||
"sinister",
|
||||
"speed",
|
||||
"stability",
|
||||
"taint"
|
||||
};
|
||||
|
||||
public ItemNodeFoci() {
|
||||
super();
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
return super.getUnlocalizedName(is)+names[is.getItemDamage()].replace('/', '.');
|
||||
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item itm, CreativeTabs tab, List lst)
|
||||
{
|
||||
for(int i = 0; i < names.length; ++i)
|
||||
lst.add(new ItemStack(itm,1,i));
|
||||
|
||||
public String getUnlocalizedName(ItemStack is) {
|
||||
return super.getUnlocalizedName(is) + names[is.getItemDamage()].replace('/', '.');
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item itm, CreativeTabs tab, List lst) {
|
||||
for (int i = 0; i < names.length; ++i) lst.add(new ItemStack(itm, 1, i));
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,34 @@
|
||||
package tb.common.item;
|
||||
|
||||
import tb.init.TBBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import tb.init.TBBlocks;
|
||||
|
||||
public class ItemPyrofluidBucket extends Item{
|
||||
public class ItemPyrofluidBucket extends Item {
|
||||
|
||||
public ItemPyrofluidBucket()
|
||||
{
|
||||
super();
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
public boolean onItemUse(ItemStack stk, EntityPlayer player, World w, int x, int y, int z, int side, float vecX, float vecY, float vecZ)
|
||||
{
|
||||
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[side];
|
||||
w.setBlock(x+dir.offsetX, y+dir.offsetY, z+dir.offsetZ, TBBlocks.pyrofluid, 0, 3);
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.bucket,1,0));
|
||||
return true;
|
||||
public ItemPyrofluidBucket() {
|
||||
super();
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
public boolean onItemUse(
|
||||
ItemStack stk,
|
||||
EntityPlayer player,
|
||||
World w,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float vecX,
|
||||
float vecY,
|
||||
float vecZ) {
|
||||
ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[side];
|
||||
w.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, TBBlocks.pyrofluid, 0, 3);
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.bucket, 1, 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +1,10 @@
|
||||
package tb.common.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import DummyCore.Utils.Pair;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import DummyCore.Utils.Pair;
|
||||
import tb.api.RevolverUpgrade;
|
||||
import tb.common.entity.EntityRevolverBullet;
|
||||
import tb.core.TBCore;
|
||||
import tb.network.proxy.TBNetworkManager;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.codechicken.lib.math.MathHelper;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.blocks.ItemJarFilled;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
@@ -32,294 +18,271 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import tb.api.RevolverUpgrade;
|
||||
import tb.common.entity.EntityRevolverBullet;
|
||||
import tb.core.TBCore;
|
||||
import tb.network.proxy.TBNetworkManager;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.codechicken.lib.math.MathHelper;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.blocks.ItemJarFilled;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
|
||||
public class ItemRevolver extends Item implements IRepairable,IWarpingGear
|
||||
{
|
||||
public static void addUpgrade(ItemStack stk, RevolverUpgrade upgrade, int level)
|
||||
{
|
||||
if(stk.hasTagCompound() && stk.getTagCompound().hasKey("tb.upgrades"))
|
||||
{
|
||||
NBTTagList upgrades = stk.getTagCompound().getTagList("tb.upgrades",10);
|
||||
for(int i = 0; i < upgrades.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound tag = upgrades.getCompoundTagAt(i);
|
||||
int id = tag.getInteger("id");
|
||||
int llevel = tag.getInteger("level");
|
||||
if(upgrade.id == id)
|
||||
{
|
||||
llevel = level;
|
||||
tag.setInteger("level", llevel);
|
||||
return;
|
||||
}
|
||||
}
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("id", upgrade.id);
|
||||
tag.setInteger("level", level);
|
||||
upgrades.appendTag(tag);
|
||||
|
||||
}else
|
||||
{
|
||||
if(!stk.hasTagCompound())
|
||||
stk.setTagCompound(new NBTTagCompound());
|
||||
|
||||
if(!stk.getTagCompound().hasKey("tb.upgrades"))
|
||||
stk.getTagCompound().setTag("tb.upgrades", new NBTTagList());
|
||||
|
||||
addUpgrade(stk,upgrade,level);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getUpgradeLevel(ItemStack stk, RevolverUpgrade upgrade)
|
||||
{
|
||||
if(stk.hasTagCompound() && stk.getTagCompound().hasKey("tb.upgrades"))
|
||||
{
|
||||
NBTTagList upgrades = stk.getTagCompound().getTagList("tb.upgrades",10);
|
||||
for(int i = 0; i < upgrades.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound tag = upgrades.getCompoundTagAt(i);
|
||||
int id = tag.getInteger("id");
|
||||
int level = tag.getInteger("level");
|
||||
if(id < RevolverUpgrade.allUpgrades.length && RevolverUpgrade.allUpgrades[id] != null && RevolverUpgrade.allUpgrades[id].equals(upgrade))
|
||||
return level;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ArrayList<Pair<RevolverUpgrade,Integer>> getAllUpgradesFor(ItemStack stk)
|
||||
{
|
||||
ArrayList<Pair<RevolverUpgrade,Integer>> retLst = new ArrayList<Pair<RevolverUpgrade,Integer>>();
|
||||
|
||||
if(stk.hasTagCompound() && stk.getTagCompound().hasKey("tb.upgrades"))
|
||||
{
|
||||
NBTTagList upgrades = stk.getTagCompound().getTagList("tb.upgrades",10);
|
||||
for(int i = 0; i < upgrades.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound tag = upgrades.getCompoundTagAt(i);
|
||||
int id = tag.getInteger("id");
|
||||
int level = tag.getInteger("level");
|
||||
if(id < RevolverUpgrade.allUpgrades.length && RevolverUpgrade.allUpgrades[id] != null)
|
||||
retLst.add(new Pair<RevolverUpgrade,Integer>(RevolverUpgrade.allUpgrades[id],level));
|
||||
}
|
||||
}
|
||||
|
||||
return retLst;
|
||||
}
|
||||
|
||||
public boolean hitEntity(ItemStack stk, EntityLivingBase attacker, EntityLivingBase attacked)
|
||||
{
|
||||
stk.damageItem(2, attacked);
|
||||
public class ItemRevolver extends Item implements IRepairable, IWarpingGear {
|
||||
public static void addUpgrade(ItemStack stk, RevolverUpgrade upgrade, int level) {
|
||||
if (stk.hasTagCompound() && stk.getTagCompound().hasKey("tb.upgrades")) {
|
||||
NBTTagList upgrades = stk.getTagCompound().getTagList("tb.upgrades", 10);
|
||||
for (int i = 0; i < upgrades.tagCount(); ++i) {
|
||||
NBTTagCompound tag = upgrades.getCompoundTagAt(i);
|
||||
int id = tag.getInteger("id");
|
||||
int llevel = tag.getInteger("level");
|
||||
if (upgrade.id == id) {
|
||||
llevel = level;
|
||||
tag.setInteger("level", llevel);
|
||||
return;
|
||||
}
|
||||
}
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("id", upgrade.id);
|
||||
tag.setInteger("level", level);
|
||||
upgrades.appendTag(tag);
|
||||
|
||||
} else {
|
||||
if (!stk.hasTagCompound()) stk.setTagCompound(new NBTTagCompound());
|
||||
|
||||
if (!stk.getTagCompound().hasKey("tb.upgrades"))
|
||||
stk.getTagCompound().setTag("tb.upgrades", new NBTTagList());
|
||||
|
||||
addUpgrade(stk, upgrade, level);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getUpgradeLevel(ItemStack stk, RevolverUpgrade upgrade) {
|
||||
if (stk.hasTagCompound() && stk.getTagCompound().hasKey("tb.upgrades")) {
|
||||
NBTTagList upgrades = stk.getTagCompound().getTagList("tb.upgrades", 10);
|
||||
for (int i = 0; i < upgrades.tagCount(); ++i) {
|
||||
NBTTagCompound tag = upgrades.getCompoundTagAt(i);
|
||||
int id = tag.getInteger("id");
|
||||
int level = tag.getInteger("level");
|
||||
if (id < RevolverUpgrade.allUpgrades.length
|
||||
&& RevolverUpgrade.allUpgrades[id] != null
|
||||
&& RevolverUpgrade.allUpgrades[id].equals(upgrade)) return level;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ArrayList<Pair<RevolverUpgrade, Integer>> getAllUpgradesFor(ItemStack stk) {
|
||||
ArrayList<Pair<RevolverUpgrade, Integer>> retLst = new ArrayList<Pair<RevolverUpgrade, Integer>>();
|
||||
|
||||
if (stk.hasTagCompound() && stk.getTagCompound().hasKey("tb.upgrades")) {
|
||||
NBTTagList upgrades = stk.getTagCompound().getTagList("tb.upgrades", 10);
|
||||
for (int i = 0; i < upgrades.tagCount(); ++i) {
|
||||
NBTTagCompound tag = upgrades.getCompoundTagAt(i);
|
||||
int id = tag.getInteger("id");
|
||||
int level = tag.getInteger("level");
|
||||
if (id < RevolverUpgrade.allUpgrades.length && RevolverUpgrade.allUpgrades[id] != null)
|
||||
retLst.add(new Pair<RevolverUpgrade, Integer>(RevolverUpgrade.allUpgrades[id], level));
|
||||
}
|
||||
}
|
||||
|
||||
return retLst;
|
||||
}
|
||||
|
||||
public boolean hitEntity(ItemStack stk, EntityLivingBase attacker, EntityLivingBase attacked) {
|
||||
stk.damageItem(2, attacked);
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stk, World w, EntityPlayer user)
|
||||
{
|
||||
if(w.isRemote)
|
||||
return stk;
|
||||
|
||||
if(!stk.hasTagCompound())
|
||||
stk.setTagCompound(new NBTTagCompound());
|
||||
|
||||
if(stk.getTagCompound().getInteger("shots") > 0)
|
||||
{
|
||||
EntityRevolverBullet b = new EntityRevolverBullet(w,user);
|
||||
if(!w.isRemote)
|
||||
w.spawnEntityInWorld(b);
|
||||
|
||||
stk.damageItem(1, user);
|
||||
if(stk == null || stk.getItemDamage() > stk.getMaxDamage())
|
||||
return null;
|
||||
|
||||
TBNetworkManager.playSoundOnServer(w, "thaumicbases:revolver.shot", user.posX, user.posY, user.posZ, 3, 1F);
|
||||
|
||||
stk.getTagCompound().setDouble("barrelRotation", stk.getTagCompound().getDouble("barrelRotation")+45);
|
||||
|
||||
stk.getTagCompound().setInteger("shots", stk.getTagCompound().getInteger("shots")-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stk.hasTagCompound() && stk.getTagCompound().hasKey("jar"))
|
||||
{
|
||||
ItemStack jar = ItemStack.loadItemStackFromNBT(stk.stackTagCompound.getCompoundTag("jar"));
|
||||
|
||||
if(jar == null)
|
||||
{
|
||||
TBNetworkManager.playSoundOnServer(w, "thaumicbases:revolver.click", user.posX, user.posY, user.posZ, 3, 2F);
|
||||
stk.getTagCompound().setDouble("barrelRotation", stk.getTagCompound().getDouble("barrelRotation")+45);
|
||||
|
||||
return super.onItemRightClick(stk, w, user);
|
||||
}
|
||||
|
||||
ArrayList<Pair<RevolverUpgrade,Integer>> upgrades = getAllUpgradesFor(stk);
|
||||
boolean hasPrimal = false;
|
||||
for(Pair<RevolverUpgrade,Integer> p : upgrades)
|
||||
{
|
||||
if(p.getFirst() == RevolverUpgrade.primal)
|
||||
hasPrimal = true;
|
||||
|
||||
if(hasPrimal)
|
||||
break;
|
||||
}
|
||||
|
||||
int addedShots = hasPrimal ? 1 : 2;
|
||||
for(Pair<RevolverUpgrade,Integer> p : upgrades)
|
||||
{
|
||||
addedShots = p.getFirst().modifyShots(user, stk, p.getSecond(), addedShots, hasPrimal);
|
||||
}
|
||||
|
||||
boolean addShots = false;
|
||||
|
||||
if(!(jar.getItem() instanceof ItemJarFilled))
|
||||
return super.onItemRightClick(stk, w, user);
|
||||
|
||||
AspectList aspects = ((ItemJarFilled)jar.getItem()).getAspects(jar);
|
||||
if (aspects != null && aspects.size() > 0)
|
||||
{
|
||||
for (Aspect tag : aspects.getAspectsSorted())
|
||||
{
|
||||
if(tag == Aspect.WEAPON)
|
||||
{
|
||||
int required = addedShots < 0 ? 2 : 1;
|
||||
if(aspects.getAmount(tag) >= required)
|
||||
{
|
||||
aspects.reduce(tag, required);
|
||||
addShots = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(addShots)
|
||||
{
|
||||
stk.getTagCompound().setInteger("shots", addedShots < 0 ? 1 : addedShots);
|
||||
TBNetworkManager.playSoundOnServer(w, "thaumicbases:revolver.reload", user.posX, user.posY, user.posZ, 3, 2F);
|
||||
}
|
||||
|
||||
if(aspects.visSize() > 0)
|
||||
{
|
||||
((ItemJarFilled)jar.getItem()).setAspects(jar, aspects);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
jar.writeToNBT(tag);
|
||||
stk.setTagInfo("jar", tag);
|
||||
}else
|
||||
{
|
||||
ItemStack emptyJar = new ItemStack(ConfigBlocks.blockJar,1,0);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
emptyJar.writeToNBT(tag);
|
||||
stk.setTagInfo("jar", tag);
|
||||
}
|
||||
}else
|
||||
{
|
||||
TBNetworkManager.playSoundOnServer(w, "thaumicbases:revolver.click", user.posX, user.posY, user.posZ, 3, 2F);
|
||||
}
|
||||
}
|
||||
return super.onItemRightClick(stk, w, user);
|
||||
}
|
||||
|
||||
public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack)
|
||||
{
|
||||
if(!entityLiving.worldObj.isRemote)
|
||||
{
|
||||
if(entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
if(EntityPlayer.class.cast(entityLiving).openContainer instanceof ContainerPlayer && entityLiving.isSneaking())
|
||||
{
|
||||
EntityPlayer.class.cast(entityLiving).openGui(TBCore.instance, 0x421919, entityLiving.worldObj, MathHelper.floor_double(entityLiving.posX), MathHelper.floor_double(entityLiving.posY), MathHelper.floor_double(entityLiving.posZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stk, World w, EntityPlayer user) {
|
||||
if (w.isRemote) return stk;
|
||||
|
||||
if (!stk.hasTagCompound()) stk.setTagCompound(new NBTTagCompound());
|
||||
|
||||
if (stk.getTagCompound().getInteger("shots") > 0) {
|
||||
EntityRevolverBullet b = new EntityRevolverBullet(w, user);
|
||||
if (!w.isRemote) w.spawnEntityInWorld(b);
|
||||
|
||||
stk.damageItem(1, user);
|
||||
if (stk == null || stk.getItemDamage() > stk.getMaxDamage()) return null;
|
||||
|
||||
TBNetworkManager.playSoundOnServer(w, "thaumicbases:revolver.shot", user.posX, user.posY, user.posZ, 3, 1F);
|
||||
|
||||
stk.getTagCompound()
|
||||
.setDouble("barrelRotation", stk.getTagCompound().getDouble("barrelRotation") + 45);
|
||||
|
||||
stk.getTagCompound().setInteger("shots", stk.getTagCompound().getInteger("shots") - 1);
|
||||
} else {
|
||||
if (stk.hasTagCompound() && stk.getTagCompound().hasKey("jar")) {
|
||||
ItemStack jar = ItemStack.loadItemStackFromNBT(stk.stackTagCompound.getCompoundTag("jar"));
|
||||
|
||||
if (jar == null) {
|
||||
TBNetworkManager.playSoundOnServer(
|
||||
w, "thaumicbases:revolver.click", user.posX, user.posY, user.posZ, 3, 2F);
|
||||
stk.getTagCompound()
|
||||
.setDouble("barrelRotation", stk.getTagCompound().getDouble("barrelRotation") + 45);
|
||||
|
||||
return super.onItemRightClick(stk, w, user);
|
||||
}
|
||||
|
||||
ArrayList<Pair<RevolverUpgrade, Integer>> upgrades = getAllUpgradesFor(stk);
|
||||
boolean hasPrimal = false;
|
||||
for (Pair<RevolverUpgrade, Integer> p : upgrades) {
|
||||
if (p.getFirst() == RevolverUpgrade.primal) hasPrimal = true;
|
||||
|
||||
if (hasPrimal) break;
|
||||
}
|
||||
|
||||
int addedShots = hasPrimal ? 1 : 2;
|
||||
for (Pair<RevolverUpgrade, Integer> p : upgrades) {
|
||||
addedShots = p.getFirst().modifyShots(user, stk, p.getSecond(), addedShots, hasPrimal);
|
||||
}
|
||||
|
||||
boolean addShots = false;
|
||||
|
||||
if (!(jar.getItem() instanceof ItemJarFilled)) return super.onItemRightClick(stk, w, user);
|
||||
|
||||
AspectList aspects = ((ItemJarFilled) jar.getItem()).getAspects(jar);
|
||||
if (aspects != null && aspects.size() > 0) {
|
||||
for (Aspect tag : aspects.getAspectsSorted()) {
|
||||
if (tag == Aspect.WEAPON) {
|
||||
int required = addedShots < 0 ? 2 : 1;
|
||||
if (aspects.getAmount(tag) >= required) {
|
||||
aspects.reduce(tag, required);
|
||||
addShots = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addShots) {
|
||||
stk.getTagCompound().setInteger("shots", addedShots < 0 ? 1 : addedShots);
|
||||
TBNetworkManager.playSoundOnServer(
|
||||
w, "thaumicbases:revolver.reload", user.posX, user.posY, user.posZ, 3, 2F);
|
||||
}
|
||||
|
||||
if (aspects.visSize() > 0) {
|
||||
((ItemJarFilled) jar.getItem()).setAspects(jar, aspects);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
jar.writeToNBT(tag);
|
||||
stk.setTagInfo("jar", tag);
|
||||
} else {
|
||||
ItemStack emptyJar = new ItemStack(ConfigBlocks.blockJar, 1, 0);
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
emptyJar.writeToNBT(tag);
|
||||
stk.setTagInfo("jar", tag);
|
||||
}
|
||||
} else {
|
||||
TBNetworkManager.playSoundOnServer(
|
||||
w, "thaumicbases:revolver.click", user.posX, user.posY, user.posZ, 3, 2F);
|
||||
}
|
||||
}
|
||||
return super.onItemRightClick(stk, w, user);
|
||||
}
|
||||
|
||||
public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) {
|
||||
if (!entityLiving.worldObj.isRemote) {
|
||||
if (entityLiving instanceof EntityPlayer) {
|
||||
if (EntityPlayer.class.cast(entityLiving).openContainer instanceof ContainerPlayer
|
||||
&& entityLiving.isSneaking()) {
|
||||
EntityPlayer.class
|
||||
.cast(entityLiving)
|
||||
.openGui(
|
||||
TBCore.instance,
|
||||
0x421919,
|
||||
entityLiving.worldObj,
|
||||
MathHelper.floor_double(entityLiving.posX),
|
||||
MathHelper.floor_double(entityLiving.posY),
|
||||
MathHelper.floor_double(entityLiving.posZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void addInformation(ItemStack stk, EntityPlayer p, List lst, boolean isCurrentItem)
|
||||
{
|
||||
super.addInformation(stk, p, lst, isCurrentItem);
|
||||
iLabel:if (stk.hasTagCompound() && stk.getTagCompound().hasKey("jar"))
|
||||
{
|
||||
ItemStack jar = ItemStack.loadItemStackFromNBT(stk.stackTagCompound.getCompoundTag("jar"));
|
||||
|
||||
try
|
||||
{
|
||||
if(!(jar.getItem() instanceof ItemJarFilled))
|
||||
break iLabel;
|
||||
|
||||
AspectList aspects = ((ItemJarFilled)jar.getItem()).getAspects(jar);
|
||||
|
||||
if (aspects != null && aspects.size() > 0)
|
||||
for (Aspect tag : aspects.getAspectsSorted())
|
||||
if (Thaumcraft.proxy.playerKnowledge.hasDiscoveredAspect(p.getCommandSenderName(), tag))
|
||||
lst.add(tag.getName() + " x " + aspects.getAmount(tag));
|
||||
else
|
||||
lst.add(StatCollector.translateToLocal("tc.aspect.unknown"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//...
|
||||
}
|
||||
}
|
||||
if(stk.hasTagCompound() && stk.getTagCompound().hasKey("tb.upgrades"))
|
||||
{
|
||||
ArrayList<Pair<RevolverUpgrade,Integer>> upgrades = getAllUpgradesFor(stk);
|
||||
for(Pair<RevolverUpgrade,Integer> pr : upgrades)
|
||||
{
|
||||
lst.add(pr.getFirst().getName()+" "+StatCollector.translateToLocal("enchantment.level."+pr.getSecond()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public EnumRarity getRarity(ItemStack stk)
|
||||
{
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void addInformation(ItemStack stk, EntityPlayer p, List lst, boolean isCurrentItem) {
|
||||
super.addInformation(stk, p, lst, isCurrentItem);
|
||||
iLabel:
|
||||
if (stk.hasTagCompound() && stk.getTagCompound().hasKey("jar")) {
|
||||
ItemStack jar = ItemStack.loadItemStackFromNBT(stk.stackTagCompound.getCompoundTag("jar"));
|
||||
|
||||
try {
|
||||
if (!(jar.getItem() instanceof ItemJarFilled)) break iLabel;
|
||||
|
||||
AspectList aspects = ((ItemJarFilled) jar.getItem()).getAspects(jar);
|
||||
|
||||
if (aspects != null && aspects.size() > 0)
|
||||
for (Aspect tag : aspects.getAspectsSorted())
|
||||
if (Thaumcraft.proxy.playerKnowledge.hasDiscoveredAspect(p.getCommandSenderName(), tag))
|
||||
lst.add(tag.getName() + " x " + aspects.getAmount(tag));
|
||||
else lst.add(StatCollector.translateToLocal("tc.aspect.unknown"));
|
||||
} catch (Exception e) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
if (stk.hasTagCompound() && stk.getTagCompound().hasKey("tb.upgrades")) {
|
||||
ArrayList<Pair<RevolverUpgrade, Integer>> upgrades = getAllUpgradesFor(stk);
|
||||
for (Pair<RevolverUpgrade, Integer> pr : upgrades) {
|
||||
lst.add(pr.getFirst().getName() + " "
|
||||
+ StatCollector.translateToLocal("enchantment.level." + pr.getSecond()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public EnumRarity getRarity(ItemStack stk) {
|
||||
return EnumRarity.rare;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public Multimap getAttributeModifiers(ItemStack stack)
|
||||
{
|
||||
HashMultimap retMap = HashMultimap.create();
|
||||
|
||||
retMap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", 5.0F+(getUpgradeLevel(stack, RevolverUpgrade.heavy)*2), 0));
|
||||
|
||||
return retMap;
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
public Multimap getAttributeModifiers(ItemStack stack) {
|
||||
HashMultimap retMap = HashMultimap.create();
|
||||
|
||||
retMap.put(
|
||||
SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(),
|
||||
new AttributeModifier(
|
||||
field_111210_e,
|
||||
"Weapon modifier",
|
||||
5.0F + (getUpgradeLevel(stack, RevolverUpgrade.heavy) * 2),
|
||||
0));
|
||||
|
||||
return retMap;
|
||||
}
|
||||
|
||||
public void onUpdate(ItemStack stk, World w, Entity entity, int slot, boolean held)
|
||||
{
|
||||
super.onUpdate(stk, w, entity, slot, held);
|
||||
int u = getUpgradeLevel(stk, RevolverUpgrade.uvoid);
|
||||
if(u > 0)
|
||||
if ((stk.isItemDamaged()) && (entity != null) && (entity.ticksExisted % 100/u == 0) && ((entity instanceof EntityLivingBase)))
|
||||
stk.damageItem(-1, (EntityLivingBase)entity);
|
||||
|
||||
if(stk.getTagCompound() != null)
|
||||
{
|
||||
double rotation = stk.getTagCompound().getDouble("barrelRotation");
|
||||
double renderedRotation = stk.getTagCompound().getDouble("renderedRotation");
|
||||
|
||||
if(rotation >= 3600000)
|
||||
rotation -= 3600000;
|
||||
|
||||
if(renderedRotation >= 3600000)
|
||||
renderedRotation -= 3600000;
|
||||
|
||||
if(renderedRotation < rotation)
|
||||
renderedRotation += 10;
|
||||
|
||||
renderedRotation = Math.min(rotation, renderedRotation);
|
||||
|
||||
stk.getTagCompound().setDouble("barrelRotation", rotation);
|
||||
stk.getTagCompound().setDouble("renderedRotation", renderedRotation);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarp(ItemStack stk, EntityPlayer player)
|
||||
{
|
||||
return getUpgradeLevel(stk, RevolverUpgrade.uvoid);
|
||||
}
|
||||
public void onUpdate(ItemStack stk, World w, Entity entity, int slot, boolean held) {
|
||||
super.onUpdate(stk, w, entity, slot, held);
|
||||
int u = getUpgradeLevel(stk, RevolverUpgrade.uvoid);
|
||||
if (u > 0)
|
||||
if ((stk.isItemDamaged())
|
||||
&& (entity != null)
|
||||
&& (entity.ticksExisted % 100 / u == 0)
|
||||
&& ((entity instanceof EntityLivingBase))) stk.damageItem(-1, (EntityLivingBase) entity);
|
||||
|
||||
if (stk.getTagCompound() != null) {
|
||||
double rotation = stk.getTagCompound().getDouble("barrelRotation");
|
||||
double renderedRotation = stk.getTagCompound().getDouble("renderedRotation");
|
||||
|
||||
if (rotation >= 3600000) rotation -= 3600000;
|
||||
|
||||
if (renderedRotation >= 3600000) renderedRotation -= 3600000;
|
||||
|
||||
if (renderedRotation < rotation) renderedRotation += 10;
|
||||
|
||||
renderedRotation = Math.min(rotation, renderedRotation);
|
||||
|
||||
stk.getTagCompound().setDouble("barrelRotation", rotation);
|
||||
stk.getTagCompound().setDouble("renderedRotation", renderedRotation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWarp(ItemStack stk, EntityPlayer player) {
|
||||
return getUpgradeLevel(stk, RevolverUpgrade.uvoid);
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,6 @@ package tb.common.item;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -13,107 +10,104 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.config.ConfigItems;
|
||||
|
||||
public class ItemRosehipSyrup extends Item{
|
||||
public class ItemRosehipSyrup extends Item {
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer player)
|
||||
{
|
||||
player.setItemInUse(stack, getMaxItemUseDuration(stack));
|
||||
public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer player) {
|
||||
player.setItemInUse(stack, getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
|
||||
public EnumAction getItemUseAction(ItemStack stack) {
|
||||
return EnumAction.drink;
|
||||
}
|
||||
|
||||
public int getMaxItemUseDuration(ItemStack stack)
|
||||
{
|
||||
public int getMaxItemUseDuration(ItemStack stack) {
|
||||
return 32;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ItemStack onEaten(ItemStack stack, World w, EntityPlayer player)
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
public ItemStack onEaten(ItemStack stack, World w, EntityPlayer player) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
--stack.stackSize;
|
||||
if(stack.stackSize > 0)
|
||||
{
|
||||
if(!player.inventory.addItemStackToInventory(new ItemStack(ConfigItems.itemEssence,1,0)))
|
||||
player.dropPlayerItemWithRandomChoice(new ItemStack(ConfigItems.itemEssence,1,0), false);
|
||||
if (stack.stackSize > 0) {
|
||||
if (!player.inventory.addItemStackToInventory(new ItemStack(ConfigItems.itemEssence, 1, 0)))
|
||||
player.dropPlayerItemWithRandomChoice(new ItemStack(ConfigItems.itemEssence, 1, 0), false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!w.isRemote)
|
||||
{
|
||||
Collection<PotionEffect> c = player.getActivePotionEffects();
|
||||
Iterator<PotionEffect> $i = c.iterator();
|
||||
ArrayList<Integer> removeEffects = new ArrayList<Integer>();
|
||||
while($i.hasNext())
|
||||
{
|
||||
PotionEffect effect = $i.next();
|
||||
int i = processPotion(player,effect);
|
||||
if(i != -1)
|
||||
removeEffects.add(i);
|
||||
}
|
||||
|
||||
for(int i = 0; i < removeEffects.size(); ++i)
|
||||
{
|
||||
int j = removeEffects.get(i);
|
||||
if(j != -1 && j < Potion.potionTypes.length && Potion.potionTypes[j] != null)
|
||||
{
|
||||
if(player.getActivePotionEffect(Potion.potionTypes[j]) != null)
|
||||
{
|
||||
player.removePotionEffect(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!w.isRemote) {
|
||||
Collection<PotionEffect> c = player.getActivePotionEffects();
|
||||
Iterator<PotionEffect> $i = c.iterator();
|
||||
ArrayList<Integer> removeEffects = new ArrayList<Integer>();
|
||||
while ($i.hasNext()) {
|
||||
PotionEffect effect = $i.next();
|
||||
int i = processPotion(player, effect);
|
||||
if (i != -1) removeEffects.add(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < removeEffects.size(); ++i) {
|
||||
int j = removeEffects.get(i);
|
||||
if (j != -1 && j < Potion.potionTypes.length && Potion.potionTypes[j] != null) {
|
||||
if (player.getActivePotionEffect(Potion.potionTypes[j]) != null) {
|
||||
player.removePotionEffect(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stack.stackSize <= 0 ? new ItemStack(ConfigItems.itemEssence,1,0) : stack;
|
||||
return stack.stackSize <= 0 ? new ItemStack(ConfigItems.itemEssence, 1, 0) : stack;
|
||||
}
|
||||
|
||||
public static int processPotion(EntityPlayer p, PotionEffect effect)
|
||||
{
|
||||
if(effect != null && effect.getPotionID() < Potion.potionTypes.length && Potion.potionTypes[effect.getPotionID()] != null)
|
||||
{
|
||||
if(isBadEffect(Potion.potionTypes[effect.getPotionID()]))
|
||||
return effect.getPotionID();
|
||||
|
||||
if(canDecreaseLevel(Potion.potionTypes[effect.getPotionID()]))
|
||||
{
|
||||
if(effect.getAmplifier() == 0)
|
||||
return effect.getPotionID();
|
||||
else
|
||||
{
|
||||
reflectPotionEffect(p,effect);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
public static int processPotion(EntityPlayer p, PotionEffect effect) {
|
||||
if (effect != null
|
||||
&& effect.getPotionID() < Potion.potionTypes.length
|
||||
&& Potion.potionTypes[effect.getPotionID()] != null) {
|
||||
if (isBadEffect(Potion.potionTypes[effect.getPotionID()])) return effect.getPotionID();
|
||||
|
||||
if (canDecreaseLevel(Potion.potionTypes[effect.getPotionID()])) {
|
||||
if (effect.getAmplifier() == 0) return effect.getPotionID();
|
||||
else {
|
||||
reflectPotionEffect(p, effect);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static boolean isBadEffect(Potion p)
|
||||
{
|
||||
return p != null && (p == Potion.blindness || p == Potion.confusion || p == Potion.digSlowdown || p == Potion.hunger || p == Potion.moveSlowdown || p == Potion.poison || p == Potion.weakness || p == Potion.wither);
|
||||
|
||||
public static boolean isBadEffect(Potion p) {
|
||||
return p != null
|
||||
&& (p == Potion.blindness
|
||||
|| p == Potion.confusion
|
||||
|| p == Potion.digSlowdown
|
||||
|| p == Potion.hunger
|
||||
|| p == Potion.moveSlowdown
|
||||
|| p == Potion.poison
|
||||
|| p == Potion.weakness
|
||||
|| p == Potion.wither);
|
||||
}
|
||||
|
||||
public static boolean canDecreaseLevel(Potion p)
|
||||
{
|
||||
int id = p.getId();
|
||||
return p != null && (id == Config.potionBlurredID || id == Config.potionInfVisExhaustID || id == Config.potionTaintPoisonID || id == Config.potionThaumarhiaID || id == Config.potionUnHungerID || id == Config.potionVisExhaustID);
|
||||
|
||||
public static boolean canDecreaseLevel(Potion p) {
|
||||
int id = p.getId();
|
||||
return p != null
|
||||
&& (id == Config.potionBlurredID
|
||||
|| id == Config.potionInfVisExhaustID
|
||||
|| id == Config.potionTaintPoisonID
|
||||
|| id == Config.potionThaumarhiaID
|
||||
|| id == Config.potionUnHungerID
|
||||
|| id == Config.potionVisExhaustID);
|
||||
}
|
||||
|
||||
public static void reflectPotionEffect(EntityPlayer p, PotionEffect effect)
|
||||
{
|
||||
int amp = effect.getAmplifier()-1;
|
||||
int id = effect.getPotionID();
|
||||
int dur = effect.getDuration();
|
||||
boolean transparent = effect.getIsAmbient();
|
||||
p.removePotionEffect(effect.getPotionID());
|
||||
p.addPotionEffect(new PotionEffect(id,dur,amp,transparent));
|
||||
|
||||
public static void reflectPotionEffect(EntityPlayer p, PotionEffect effect) {
|
||||
int amp = effect.getAmplifier() - 1;
|
||||
int id = effect.getPotionID();
|
||||
int dur = effect.getDuration();
|
||||
boolean transparent = effect.getIsAmbient();
|
||||
p.removePotionEffect(effect.getPotionID());
|
||||
p.addPotionEffect(new PotionEffect(id, dur, amp, transparent));
|
||||
}
|
||||
}
|
||||
@@ -1,93 +1,78 @@
|
||||
package tb.common.item;
|
||||
|
||||
import tb.api.ITobacco;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import tb.api.ITobacco;
|
||||
|
||||
public class ItemSmokingPipe extends Item
|
||||
{
|
||||
public boolean isSilverwood;
|
||||
|
||||
public ItemSmokingPipe(boolean silverwood)
|
||||
{
|
||||
super();
|
||||
isSilverwood = silverwood;
|
||||
this.setFull3D();
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
public ItemStack getTobacco(EntityPlayer p)
|
||||
{
|
||||
for(int i = 0; i < p.inventory.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack stk = p.inventory.getStackInSlot(i);
|
||||
if(stk != null && stk.getItem() != null && stk.getItem() instanceof ITobacco)
|
||||
return stk;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer player)
|
||||
{
|
||||
if(this.getTobacco(player) != null)
|
||||
player.setItemInUse(stack, getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
return EnumAction.bow;
|
||||
}
|
||||
public class ItemSmokingPipe extends Item {
|
||||
public boolean isSilverwood;
|
||||
|
||||
public int getMaxItemUseDuration(ItemStack stack)
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
public void onUsingTick(ItemStack stack, EntityPlayer player, int count)
|
||||
{
|
||||
Vec3 look = player.getLookVec();
|
||||
double x = player.posX+look.xCoord/5;
|
||||
double y = player.posY+player.getEyeHeight()+look.yCoord/5;
|
||||
double z = player.posZ+look.zCoord/5;
|
||||
if(count < 32)
|
||||
player.worldObj.spawnParticle(isSilverwood ? "explode" : "smoke", x, y, z, look.xCoord/10, look.yCoord/10, look.zCoord/10);
|
||||
public ItemSmokingPipe(boolean silverwood) {
|
||||
super();
|
||||
isSilverwood = silverwood;
|
||||
this.setFull3D();
|
||||
this.setMaxStackSize(1);
|
||||
}
|
||||
|
||||
public ItemStack onEaten(ItemStack stack, World w, EntityPlayer player)
|
||||
{
|
||||
ItemStack tobacco = getTobacco(player);
|
||||
//1.8 NPE patch
|
||||
if(tobacco == null)
|
||||
return stack;
|
||||
|
||||
ITobacco t = ITobacco.class.cast(tobacco.getItem());
|
||||
t.performTobaccoEffect(player, tobacco.getItemDamage(), isSilverwood);
|
||||
for(int i = 0; i < player.inventory.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack stk = player.inventory.getStackInSlot(i);
|
||||
if(stk != null && stk.getItem() != null && stk.getItem() instanceof ITobacco)
|
||||
{
|
||||
player.inventory.decrStackSize(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Vec3 look = player.getLookVec();
|
||||
for(int i = 0; i < 100; ++i)
|
||||
{
|
||||
double x = player.posX+look.xCoord/5;
|
||||
double y = player.posY+player.getEyeHeight()+look.yCoord/5;
|
||||
double z = player.posZ+look.zCoord/5;
|
||||
|
||||
player.worldObj.spawnParticle(isSilverwood ? "explode" : "smoke", x, y, z, look.xCoord/10, look.yCoord/10, look.zCoord/10);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack getTobacco(EntityPlayer p) {
|
||||
for (int i = 0; i < p.inventory.getSizeInventory(); ++i) {
|
||||
ItemStack stk = p.inventory.getStackInSlot(i);
|
||||
if (stk != null && stk.getItem() != null && stk.getItem() instanceof ITobacco) return stk;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer player) {
|
||||
if (this.getTobacco(player) != null) player.setItemInUse(stack, getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction(ItemStack stack) {
|
||||
return EnumAction.bow;
|
||||
}
|
||||
|
||||
public int getMaxItemUseDuration(ItemStack stack) {
|
||||
return 64;
|
||||
}
|
||||
|
||||
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
|
||||
Vec3 look = player.getLookVec();
|
||||
double x = player.posX + look.xCoord / 5;
|
||||
double y = player.posY + player.getEyeHeight() + look.yCoord / 5;
|
||||
double z = player.posZ + look.zCoord / 5;
|
||||
if (count < 32)
|
||||
player.worldObj.spawnParticle(
|
||||
isSilverwood ? "explode" : "smoke", x, y, z, look.xCoord / 10, look.yCoord / 10, look.zCoord / 10);
|
||||
}
|
||||
|
||||
public ItemStack onEaten(ItemStack stack, World w, EntityPlayer player) {
|
||||
ItemStack tobacco = getTobacco(player);
|
||||
// 1.8 NPE patch
|
||||
if (tobacco == null) return stack;
|
||||
|
||||
ITobacco t = ITobacco.class.cast(tobacco.getItem());
|
||||
t.performTobaccoEffect(player, tobacco.getItemDamage(), isSilverwood);
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
|
||||
ItemStack stk = player.inventory.getStackInSlot(i);
|
||||
if (stk != null && stk.getItem() != null && stk.getItem() instanceof ITobacco) {
|
||||
player.inventory.decrStackSize(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Vec3 look = player.getLookVec();
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
double x = player.posX + look.xCoord / 5;
|
||||
double y = player.posY + player.getEyeHeight() + look.yCoord / 5;
|
||||
double z = player.posZ + look.zCoord / 5;
|
||||
|
||||
player.worldObj.spawnParticle(
|
||||
isSilverwood ? "explode" : "smoke", x, y, z, look.xCoord / 10, look.yCoord / 10, look.zCoord / 10);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,48 @@
|
||||
package tb.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IRunicArmor;
|
||||
import thaumcraft.api.IVisDiscountGear;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IRunicArmor;
|
||||
import thaumcraft.api.IVisDiscountGear;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
|
||||
public class ItemThauminiteArmor extends ItemArmor implements IRepairable, IVisDiscountGear, IRunicArmor{
|
||||
public class ItemThauminiteArmor extends ItemArmor implements IRepairable, IVisDiscountGear, IRunicArmor {
|
||||
|
||||
int aType;
|
||||
|
||||
public ItemThauminiteArmor(ArmorMaterial mat,int aType) {
|
||||
super(mat, 0, aType);
|
||||
this.aType = aType;
|
||||
}
|
||||
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
|
||||
{
|
||||
return slot == 2 ? "thaumicbases:textures/items/armor/thauminite/thauminite_2.png" : "thaumicbases:textures/items/armor/thauminite/thauminite_1.png";
|
||||
int aType;
|
||||
|
||||
public ItemThauminiteArmor(ArmorMaterial mat, int aType) {
|
||||
super(mat, 0, aType);
|
||||
this.aType = aType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVisDiscount(ItemStack stack, EntityPlayer player,
|
||||
Aspect aspect) {
|
||||
return discount[aType];
|
||||
}
|
||||
|
||||
static final int[] discount = new int[]{5,2,3,1};
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
return slot == 2
|
||||
? "thaumicbases:textures/items/armor/thauminite/thauminite_2.png"
|
||||
: "thaumicbases:textures/items/armor/thauminite/thauminite_1.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRunicCharge(ItemStack itemstack) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getVisDiscount(ItemStack stack, EntityPlayer player, Aspect aspect) {
|
||||
return discount[aType];
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("tc.visdiscount") + ": " + getVisDiscount(stack, player, null) + "%");
|
||||
super.addInformation(stack, player, list, par4);
|
||||
}
|
||||
static final int[] discount = new int[] {5, 2, 3, 1};
|
||||
|
||||
@Override
|
||||
public int getRunicCharge(ItemStack itemstack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
list.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("tc.visdiscount") + ": "
|
||||
+ getVisDiscount(stack, player, null) + "%");
|
||||
super.addInformation(stack, player, list, par4);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package tb.common.item;
|
||||
|
||||
import thaumcraft.api.IRepairable;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import thaumcraft.api.IRepairable;
|
||||
|
||||
public class ItemThauminiteAxe extends ItemAxe implements IRepairable{
|
||||
|
||||
public ItemThauminiteAxe(ToolMaterial mat) {
|
||||
super(mat);
|
||||
}
|
||||
public class ItemThauminiteAxe extends ItemAxe implements IRepairable {
|
||||
|
||||
public ItemThauminiteAxe(ToolMaterial mat) {
|
||||
super(mat);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package tb.common.item;
|
||||
|
||||
import thaumcraft.api.IRepairable;
|
||||
import net.minecraft.item.ItemHoe;
|
||||
import thaumcraft.api.IRepairable;
|
||||
|
||||
public class ItemThauminiteHoe extends ItemHoe implements IRepairable{
|
||||
|
||||
public ItemThauminiteHoe(ToolMaterial mat) {
|
||||
super(mat);
|
||||
}
|
||||
public class ItemThauminiteHoe extends ItemHoe implements IRepairable {
|
||||
|
||||
public ItemThauminiteHoe(ToolMaterial mat) {
|
||||
super(mat);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package tb.common.item;
|
||||
|
||||
import thaumcraft.api.IRepairable;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import thaumcraft.api.IRepairable;
|
||||
|
||||
public class ItemThauminitePickaxe extends ItemPickaxe implements IRepairable{
|
||||
|
||||
public ItemThauminitePickaxe(ToolMaterial mat) {
|
||||
super(mat);
|
||||
}
|
||||
public class ItemThauminitePickaxe extends ItemPickaxe implements IRepairable {
|
||||
|
||||
public ItemThauminitePickaxe(ToolMaterial mat) {
|
||||
super(mat);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package tb.common.item;
|
||||
|
||||
import thaumcraft.api.IRepairable;
|
||||
import net.minecraft.item.ItemShears;
|
||||
import thaumcraft.api.IRepairable;
|
||||
|
||||
public class ItemThauminiteShears extends ItemShears implements IRepairable
|
||||
{
|
||||
|
||||
public ItemThauminiteShears() {
|
||||
super();
|
||||
}
|
||||
public class ItemThauminiteShears extends ItemShears implements IRepairable {
|
||||
|
||||
public ItemThauminiteShears() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package tb.common.item;
|
||||
|
||||
import thaumcraft.api.IRepairable;
|
||||
import net.minecraft.item.ItemSpade;
|
||||
import thaumcraft.api.IRepairable;
|
||||
|
||||
public class ItemThauminiteShovel extends ItemSpade implements IRepairable{
|
||||
|
||||
public ItemThauminiteShovel(ToolMaterial mat) {
|
||||
super(mat);
|
||||
}
|
||||
public class ItemThauminiteShovel extends ItemSpade implements IRepairable {
|
||||
|
||||
public ItemThauminiteShovel(ToolMaterial mat) {
|
||||
super(mat);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package tb.common.item;
|
||||
|
||||
import thaumcraft.api.IRepairable;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import thaumcraft.api.IRepairable;
|
||||
|
||||
public class ItemThauminiteSword extends ItemSword implements IRepairable{
|
||||
|
||||
public ItemThauminiteSword(ToolMaterial mat) {
|
||||
super(mat);
|
||||
}
|
||||
public class ItemThauminiteSword extends ItemSword implements IRepairable {
|
||||
|
||||
public ItemThauminiteSword(ToolMaterial mat) {
|
||||
super(mat);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package tb.common.item;
|
||||
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -9,24 +7,24 @@ import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemFlintAndSteel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
|
||||
public class ItemVoidFlintAndSteel extends ItemFlintAndSteel implements IRepairable,IWarpingGear
|
||||
{
|
||||
|
||||
public EnumRarity getRarity(ItemStack itemstack)
|
||||
{
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
|
||||
public void onUpdate(ItemStack stk, World w, Entity entity, int slot, boolean held)
|
||||
{
|
||||
super.onUpdate(stk, w, entity, slot, held);
|
||||
if ((stk.isItemDamaged()) && (entity != null) && (entity.ticksExisted % 20 == 0) && ((entity instanceof EntityLivingBase)))
|
||||
stk.damageItem(-1, (EntityLivingBase)entity);
|
||||
}
|
||||
|
||||
public int getWarp(ItemStack itemstack, EntityPlayer player)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
public class ItemVoidFlintAndSteel extends ItemFlintAndSteel implements IRepairable, IWarpingGear {
|
||||
|
||||
public EnumRarity getRarity(ItemStack itemstack) {
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
|
||||
public void onUpdate(ItemStack stk, World w, Entity entity, int slot, boolean held) {
|
||||
super.onUpdate(stk, w, entity, slot, held);
|
||||
if ((stk.isItemDamaged())
|
||||
&& (entity != null)
|
||||
&& (entity.ticksExisted % 20 == 0)
|
||||
&& ((entity instanceof EntityLivingBase))) stk.damageItem(-1, (EntityLivingBase) entity);
|
||||
}
|
||||
|
||||
public int getWarp(ItemStack itemstack, EntityPlayer player) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package tb.common.item;
|
||||
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -9,23 +7,24 @@ import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemShears;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.IRepairable;
|
||||
import thaumcraft.api.IWarpingGear;
|
||||
|
||||
public class ItemVoidShears extends ItemShears implements IRepairable,IWarpingGear{
|
||||
|
||||
public EnumRarity getRarity(ItemStack itemstack)
|
||||
{
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
|
||||
public void onUpdate(ItemStack stk, World w, Entity entity, int slot, boolean held)
|
||||
{
|
||||
super.onUpdate(stk, w, entity, slot, held);
|
||||
if ((stk.isItemDamaged()) && (entity != null) && (entity.ticksExisted % 20 == 0) && ((entity instanceof EntityLivingBase)))
|
||||
stk.damageItem(-1, (EntityLivingBase)entity);
|
||||
}
|
||||
|
||||
public int getWarp(ItemStack itemstack, EntityPlayer player)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
public class ItemVoidShears extends ItemShears implements IRepairable, IWarpingGear {
|
||||
|
||||
public EnumRarity getRarity(ItemStack itemstack) {
|
||||
return EnumRarity.uncommon;
|
||||
}
|
||||
|
||||
public void onUpdate(ItemStack stk, World w, Entity entity, int slot, boolean held) {
|
||||
super.onUpdate(stk, w, entity, slot, held);
|
||||
if ((stk.isItemDamaged())
|
||||
&& (entity != null)
|
||||
&& (entity.ticksExisted % 20 == 0)
|
||||
&& ((entity instanceof EntityLivingBase))) stk.damageItem(-1, (EntityLivingBase) entity);
|
||||
}
|
||||
|
||||
public int getWarp(ItemStack itemstack, EntityPlayer player) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,56 @@
|
||||
package tb.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import tb.core.TBCore;
|
||||
import tb.utils.TBConfig;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import tb.core.TBCore;
|
||||
|
||||
public class TBResource extends Item{
|
||||
|
||||
public TBResource()
|
||||
{
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
public static final String names[] = new String[]{
|
||||
"nuggetthauminite",
|
||||
"thauminite/thauminite_ingot",
|
||||
"thauminite/wand_cap_thauminite",
|
||||
"thaumium_wand_core",
|
||||
"void_wand_core",
|
||||
"aurelia_petal",
|
||||
"briar_seedbag",
|
||||
"tobacco_leaves",
|
||||
"bloodycloth"
|
||||
};
|
||||
|
||||
public static IIcon[] icons = new IIcon[names.length];
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
public int getMetadata(int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
return super.getUnlocalizedName(is)+names[is.getItemDamage()].replace('/', '.');
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg)
|
||||
{
|
||||
for(int i = 0; i < names.length; ++i)
|
||||
icons[i] = reg.registerIcon(TBCore.modid+":"+names[i]);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item itm, CreativeTabs tab, List lst)
|
||||
{
|
||||
for(int i = 0; i < names.length; ++i)
|
||||
lst.add(new ItemStack(itm,1,i));
|
||||
public class TBResource extends Item {
|
||||
|
||||
public TBResource() {
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
public static final String names[] = new String[] {
|
||||
"nuggetthauminite",
|
||||
"thauminite/thauminite_ingot",
|
||||
"thauminite/wand_cap_thauminite",
|
||||
"thaumium_wand_core",
|
||||
"void_wand_core",
|
||||
"aurelia_petal",
|
||||
"briar_seedbag",
|
||||
"tobacco_leaves",
|
||||
"bloodycloth"
|
||||
};
|
||||
|
||||
public static IIcon[] icons = new IIcon[names.length];
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack is) {
|
||||
return super.getUnlocalizedName(is) + names[is.getItemDamage()].replace('/', '.');
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg) {
|
||||
for (int i = 0; i < names.length; ++i) icons[i] = reg.registerIcon(TBCore.modid + ":" + names[i]);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item itm, CreativeTabs tab, List lst) {
|
||||
for (int i = 0; i < names.length; ++i) lst.add(new ItemStack(itm, 1, i));
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,10 @@
|
||||
package tb.common.item;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import tb.api.ITobacco;
|
||||
import tb.core.TBCore;
|
||||
import tb.utils.TBUtils;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.entities.monster.EntityWisp;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -20,193 +13,158 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.IIcon;
|
||||
import tb.api.ITobacco;
|
||||
import tb.core.TBCore;
|
||||
import tb.utils.TBUtils;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.entities.monster.EntityWisp;
|
||||
|
||||
public class TBTobacco extends Item implements ITobacco{
|
||||
|
||||
public TBTobacco()
|
||||
{
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
public static final String names[] = new String[]{
|
||||
"tobacco_pile",
|
||||
"tobacco_eldritch",
|
||||
"tobacco_fighting",
|
||||
"tobacco_hunger",
|
||||
"tobacco_knowledge",
|
||||
"tobacco_mining",
|
||||
"tobacco_sanity",
|
||||
"tobacco_tainted",
|
||||
"tobacco_wispy"
|
||||
};
|
||||
|
||||
|
||||
public void performTobaccoEffect(EntityPlayer smoker, int metadata, boolean isSilverwood)
|
||||
{
|
||||
switch(metadata)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if(isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.3F)
|
||||
TBUtils.addWarpToPlayer(smoker, -1, 0);
|
||||
|
||||
if(!isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.1F)
|
||||
TBUtils.addWarpToPlayer(smoker, -1, 0);
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if(!smoker.worldObj.isRemote)
|
||||
{
|
||||
smoker.addPotionEffect(new PotionEffect(Config.potionDeathGazeID,2000,0,true));
|
||||
if(!isSilverwood)
|
||||
TBUtils.addWarpToPlayer(smoker, 3, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if(!smoker.worldObj.isRemote)
|
||||
{
|
||||
smoker.addPotionEffect(new PotionEffect(Potion.damageBoost.id,8000,1,true));
|
||||
if(isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.1F)
|
||||
smoker.addPotionEffect(new PotionEffect(Potion.resistance.id,8000,0,true));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
if(!smoker.worldObj.isRemote)
|
||||
{
|
||||
smoker.getFoodStats().addStats(3, 3);
|
||||
if(!isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.4F)
|
||||
smoker.addPotionEffect(new PotionEffect(Potion.confusion.id,200,0,true));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
if(!smoker.worldObj.isRemote)
|
||||
{
|
||||
ArrayList<Aspect> aspects = new ArrayList<Aspect>();
|
||||
Collection<Aspect> pa = Aspect.aspects.values();
|
||||
for (Aspect aspect:pa)
|
||||
{
|
||||
aspects.add(aspect);
|
||||
}
|
||||
|
||||
for(int i = 0; i < (isSilverwood ? 20 : 10); ++i)
|
||||
{
|
||||
Aspect a = aspects.get(smoker.worldObj.rand.nextInt(aspects.size()));
|
||||
TBUtils.addAspectToKnowledgePool(smoker, a, (short) (isSilverwood ? 2 : 1));
|
||||
if(a == Aspect.TAINT && !isSilverwood)
|
||||
TBUtils.addWarpToPlayer(smoker, 1, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
if(!smoker.worldObj.isRemote)
|
||||
{
|
||||
smoker.addPotionEffect(new PotionEffect(Potion.digSpeed.id,8000,1,true));
|
||||
if(isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.3F)
|
||||
smoker.addPotionEffect(new PotionEffect(Potion.nightVision.id,8000,0,true));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
if(!smoker.worldObj.isRemote)
|
||||
{
|
||||
if(smoker.worldObj.rand.nextFloat() <= (isSilverwood ? 0.6F : 0.4F))
|
||||
{
|
||||
TBUtils.addWarpToPlayer(smoker, -1, 0);
|
||||
}
|
||||
if(isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.1F)
|
||||
TBUtils.addWarpToPlayer(smoker, -1, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
if(!smoker.worldObj.isRemote)
|
||||
{
|
||||
if(!isSilverwood)
|
||||
{
|
||||
TBUtils.addWarpToPlayer(smoker, 1+smoker.worldObj.rand.nextInt(3), 0);
|
||||
if(smoker.worldObj.rand.nextFloat() <= 0.4F)
|
||||
TBUtils.addWarpToPlayer(smoker, 1, 1);
|
||||
}else
|
||||
{
|
||||
ItemStack stk = smoker.getCurrentEquippedItem();
|
||||
if(stk != null)
|
||||
{
|
||||
smoker.renderBrokenItemStack(stk);
|
||||
smoker.inventory.setInventorySlotContents(smoker.inventory.currentItem, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
ArrayList<Aspect> aspects = new ArrayList<Aspect>();
|
||||
Collection<Aspect> pa = Aspect.aspects.values();
|
||||
for (Aspect aspect:pa)
|
||||
{
|
||||
aspects.add(aspect);
|
||||
}
|
||||
|
||||
if(isSilverwood)
|
||||
aspects.remove(Aspect.TAINT);
|
||||
|
||||
EntityWisp wisp = new EntityWisp(smoker.worldObj);
|
||||
wisp.setPositionAndRotation(smoker.posX, smoker.posY, smoker.posZ, 0, 0);
|
||||
if(!smoker.worldObj.isRemote)
|
||||
{
|
||||
wisp.setType(aspects.get(smoker.worldObj.rand.nextInt(aspects.size())).getTag());
|
||||
smoker.worldObj.spawnEntityInWorld(wisp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IIcon[] icons = new IIcon[names.length];
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta)
|
||||
{
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
public int getMetadata(int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
return super.getUnlocalizedName(is)+"."+names[is.getItemDamage()].replace('/', '.');
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg)
|
||||
{
|
||||
for(int i = 0; i < names.length; ++i)
|
||||
icons[i] = reg.registerIcon(TBCore.modid+":"+names[i]);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item itm, CreativeTabs tab, List lst)
|
||||
{
|
||||
for(int i = 0; i < names.length; ++i)
|
||||
lst.add(new ItemStack(itm,1,i));
|
||||
public class TBTobacco extends Item implements ITobacco {
|
||||
|
||||
public TBTobacco() {
|
||||
this.setHasSubtypes(true);
|
||||
}
|
||||
|
||||
public static final String names[] = new String[] {
|
||||
"tobacco_pile",
|
||||
"tobacco_eldritch",
|
||||
"tobacco_fighting",
|
||||
"tobacco_hunger",
|
||||
"tobacco_knowledge",
|
||||
"tobacco_mining",
|
||||
"tobacco_sanity",
|
||||
"tobacco_tainted",
|
||||
"tobacco_wispy"
|
||||
};
|
||||
|
||||
public void performTobaccoEffect(EntityPlayer smoker, int metadata, boolean isSilverwood) {
|
||||
switch (metadata) {
|
||||
case 0: {
|
||||
if (isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.3F) TBUtils.addWarpToPlayer(smoker, -1, 0);
|
||||
|
||||
if (!isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.1F) TBUtils.addWarpToPlayer(smoker, -1, 0);
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
if (!smoker.worldObj.isRemote) {
|
||||
smoker.addPotionEffect(new PotionEffect(Config.potionDeathGazeID, 2000, 0, true));
|
||||
if (!isSilverwood) TBUtils.addWarpToPlayer(smoker, 3, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if (!smoker.worldObj.isRemote) {
|
||||
smoker.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 8000, 1, true));
|
||||
if (isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.1F)
|
||||
smoker.addPotionEffect(new PotionEffect(Potion.resistance.id, 8000, 0, true));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if (!smoker.worldObj.isRemote) {
|
||||
smoker.getFoodStats().addStats(3, 3);
|
||||
if (!isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.4F)
|
||||
smoker.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0, true));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
if (!smoker.worldObj.isRemote) {
|
||||
ArrayList<Aspect> aspects = new ArrayList<Aspect>();
|
||||
Collection<Aspect> pa = Aspect.aspects.values();
|
||||
for (Aspect aspect : pa) {
|
||||
aspects.add(aspect);
|
||||
}
|
||||
|
||||
for (int i = 0; i < (isSilverwood ? 20 : 10); ++i) {
|
||||
Aspect a = aspects.get(smoker.worldObj.rand.nextInt(aspects.size()));
|
||||
TBUtils.addAspectToKnowledgePool(smoker, a, (short) (isSilverwood ? 2 : 1));
|
||||
if (a == Aspect.TAINT && !isSilverwood) TBUtils.addWarpToPlayer(smoker, 1, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if (!smoker.worldObj.isRemote) {
|
||||
smoker.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 8000, 1, true));
|
||||
if (isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.3F)
|
||||
smoker.addPotionEffect(new PotionEffect(Potion.nightVision.id, 8000, 0, true));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
if (!smoker.worldObj.isRemote) {
|
||||
if (smoker.worldObj.rand.nextFloat() <= (isSilverwood ? 0.6F : 0.4F)) {
|
||||
TBUtils.addWarpToPlayer(smoker, -1, 0);
|
||||
}
|
||||
if (isSilverwood && smoker.worldObj.rand.nextFloat() <= 0.1F)
|
||||
TBUtils.addWarpToPlayer(smoker, -1, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
if (!smoker.worldObj.isRemote) {
|
||||
if (!isSilverwood) {
|
||||
TBUtils.addWarpToPlayer(smoker, 1 + smoker.worldObj.rand.nextInt(3), 0);
|
||||
if (smoker.worldObj.rand.nextFloat() <= 0.4F) TBUtils.addWarpToPlayer(smoker, 1, 1);
|
||||
} else {
|
||||
ItemStack stk = smoker.getCurrentEquippedItem();
|
||||
if (stk != null) {
|
||||
smoker.renderBrokenItemStack(stk);
|
||||
smoker.inventory.setInventorySlotContents(smoker.inventory.currentItem, null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
ArrayList<Aspect> aspects = new ArrayList<Aspect>();
|
||||
Collection<Aspect> pa = Aspect.aspects.values();
|
||||
for (Aspect aspect : pa) {
|
||||
aspects.add(aspect);
|
||||
}
|
||||
|
||||
if (isSilverwood) aspects.remove(Aspect.TAINT);
|
||||
|
||||
EntityWisp wisp = new EntityWisp(smoker.worldObj);
|
||||
wisp.setPositionAndRotation(smoker.posX, smoker.posY, smoker.posZ, 0, 0);
|
||||
if (!smoker.worldObj.isRemote) {
|
||||
wisp.setType(aspects.get(smoker.worldObj.rand.nextInt(aspects.size()))
|
||||
.getTag());
|
||||
smoker.worldObj.spawnEntityInWorld(wisp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IIcon[] icons = new IIcon[names.length];
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack is) {
|
||||
return super.getUnlocalizedName(is) + "." + names[is.getItemDamage()].replace('/', '.');
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg) {
|
||||
for (int i = 0; i < names.length; ++i) icons[i] = reg.registerIcon(TBCore.modid + ":" + names[i]);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item itm, CreativeTabs tab, List lst) {
|
||||
for (int i = 0; i < names.length; ++i) lst.add(new ItemStack(itm, 1, i));
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package tb.common.item.foci;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import DummyCore.Utils.MiscUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -12,8 +11,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
@@ -22,131 +21,123 @@ import thaumcraft.api.wands.FocusUpgradeType;
|
||||
import thaumcraft.api.wands.ItemFocusBasic;
|
||||
import thaumcraft.common.items.wands.WandManager;
|
||||
|
||||
public class FociActivation extends ItemFocusBasic
|
||||
{
|
||||
public class FociActivation extends ItemFocusBasic {
|
||||
|
||||
public int getFocusColor(ItemStack focusstack) {
|
||||
return 0xaaaaaa;
|
||||
}
|
||||
|
||||
public String getSortingHelper(ItemStack focusstack) {
|
||||
String out="AC";
|
||||
for (short id:this.getAppliedUpgrades(focusstack)) {
|
||||
out = out + id;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public AspectList getVisCost(ItemStack focusstack) {
|
||||
return new AspectList().add(Aspect.ORDER, 5).add(Aspect.EARTH, 10);
|
||||
|
||||
}
|
||||
|
||||
public int getActivationCooldown(ItemStack focusstack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
|
||||
return new FocusUpgradeType[]{FocusUpgradeType.frugal,FocusUpgradeType.potency};
|
||||
}
|
||||
|
||||
public ItemStack onFocusRightClick(ItemStack wandstack, World world,EntityPlayer player, MovingObjectPosition movingobjectposition) {
|
||||
|
||||
if(wandstack == null)
|
||||
return wandstack;
|
||||
|
||||
if(player == null)
|
||||
return wandstack;
|
||||
|
||||
if(player.isSneaking())
|
||||
{
|
||||
if(movingobjectposition != null && movingobjectposition.typeOfHit == MovingObjectType.BLOCK)
|
||||
{
|
||||
NBTTagCompound fociTag = MiscUtils.getStackTag(wandstack).getCompoundTag("focus").getCompoundTag("tag");
|
||||
fociTag.setInteger("blockX", movingobjectposition.blockX);
|
||||
fociTag.setInteger("blockY", movingobjectposition.blockY);
|
||||
fociTag.setInteger("blockZ", movingobjectposition.blockZ);
|
||||
fociTag.setInteger("dim", player.dimension);
|
||||
((NBTTagCompound)(MiscUtils.getStackTag(wandstack).getTag("focus"))).setTag("tag", fociTag);
|
||||
player.swingItem();
|
||||
WandManager.consumeVisFromInventory(player, new AspectList().add(Aspect.ORDER, 100));
|
||||
}
|
||||
}else
|
||||
{
|
||||
NBTTagCompound fociTag = MiscUtils.getStackTag(wandstack).getCompoundTag("focus").getCompoundTag("tag");
|
||||
if(fociTag.hasKey("blockX"))
|
||||
{
|
||||
int x = fociTag.getInteger("blockX");
|
||||
int y = fociTag.getInteger("blockY");
|
||||
int z = fociTag.getInteger("blockZ");
|
||||
|
||||
ItemStack foci = ItemStack.loadItemStackFromNBT(MiscUtils.getStackTag(wandstack).getCompoundTag("focus"));
|
||||
|
||||
int potencyLevel = this.getUpgradeLevel(foci, FocusUpgradeType.potency);
|
||||
|
||||
int maxRange = 32 * (potencyLevel+1);
|
||||
|
||||
double range = player.getDistance(x, y, z);
|
||||
|
||||
int aspectCost = 10;
|
||||
|
||||
if(!WandManager.consumeVisFromInventory(player, new AspectList().add(Aspect.EARTH, aspectCost).add(Aspect.ORDER, aspectCost/2)))
|
||||
return wandstack;
|
||||
|
||||
if(range > maxRange)
|
||||
{
|
||||
if(player.worldObj.isRemote)
|
||||
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.tooFar")));
|
||||
return wandstack;
|
||||
}
|
||||
|
||||
int dim = fociTag.getInteger("dim");
|
||||
|
||||
if(dim != player.dimension)
|
||||
{
|
||||
if(player.worldObj.isRemote)
|
||||
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.wrongDimension")));
|
||||
return wandstack;
|
||||
}else
|
||||
{
|
||||
if(world.checkChunksExist(x-1, y-1, z-1, x+1, y+1, z+1))
|
||||
{
|
||||
if(world.blockExists(x, y, z))
|
||||
{
|
||||
Block b = world.getBlock(x, y, z);
|
||||
Vec3 vec = player.getLookVec();
|
||||
b.onBlockActivated(world, x, y, z, player, 0, (float)vec.xCoord, (float)vec.yCoord, (float)vec.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foci = null;
|
||||
}
|
||||
}
|
||||
return wandstack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg)
|
||||
{
|
||||
super.registerIcons(reg);
|
||||
this.icon = reg.registerIcon(getIconString());
|
||||
public int getFocusColor(ItemStack focusstack) {
|
||||
return 0xaaaaaa;
|
||||
}
|
||||
|
||||
public String getSortingHelper(ItemStack focusstack) {
|
||||
String out = "AC";
|
||||
for (short id : this.getAppliedUpgrades(focusstack)) {
|
||||
out = out + id;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public AspectList getVisCost(ItemStack focusstack) {
|
||||
return new AspectList().add(Aspect.ORDER, 5).add(Aspect.EARTH, 10);
|
||||
}
|
||||
|
||||
public int getActivationCooldown(ItemStack focusstack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
|
||||
return new FocusUpgradeType[] {FocusUpgradeType.frugal, FocusUpgradeType.potency};
|
||||
}
|
||||
|
||||
public ItemStack onFocusRightClick(
|
||||
ItemStack wandstack, World world, EntityPlayer player, MovingObjectPosition movingobjectposition) {
|
||||
|
||||
if (wandstack == null) return wandstack;
|
||||
|
||||
if (player == null) return wandstack;
|
||||
|
||||
if (player.isSneaking()) {
|
||||
if (movingobjectposition != null && movingobjectposition.typeOfHit == MovingObjectType.BLOCK) {
|
||||
NBTTagCompound fociTag =
|
||||
MiscUtils.getStackTag(wandstack).getCompoundTag("focus").getCompoundTag("tag");
|
||||
fociTag.setInteger("blockX", movingobjectposition.blockX);
|
||||
fociTag.setInteger("blockY", movingobjectposition.blockY);
|
||||
fociTag.setInteger("blockZ", movingobjectposition.blockZ);
|
||||
fociTag.setInteger("dim", player.dimension);
|
||||
((NBTTagCompound) (MiscUtils.getStackTag(wandstack).getTag("focus"))).setTag("tag", fociTag);
|
||||
player.swingItem();
|
||||
WandManager.consumeVisFromInventory(player, new AspectList().add(Aspect.ORDER, 100));
|
||||
}
|
||||
} else {
|
||||
NBTTagCompound fociTag =
|
||||
MiscUtils.getStackTag(wandstack).getCompoundTag("focus").getCompoundTag("tag");
|
||||
if (fociTag.hasKey("blockX")) {
|
||||
int x = fociTag.getInteger("blockX");
|
||||
int y = fociTag.getInteger("blockY");
|
||||
int z = fociTag.getInteger("blockZ");
|
||||
|
||||
ItemStack foci = ItemStack.loadItemStackFromNBT(
|
||||
MiscUtils.getStackTag(wandstack).getCompoundTag("focus"));
|
||||
|
||||
int potencyLevel = this.getUpgradeLevel(foci, FocusUpgradeType.potency);
|
||||
|
||||
int maxRange = 32 * (potencyLevel + 1);
|
||||
|
||||
double range = player.getDistance(x, y, z);
|
||||
|
||||
int aspectCost = 10;
|
||||
|
||||
if (!WandManager.consumeVisFromInventory(
|
||||
player, new AspectList().add(Aspect.EARTH, aspectCost).add(Aspect.ORDER, aspectCost / 2)))
|
||||
return wandstack;
|
||||
|
||||
if (range > maxRange) {
|
||||
if (player.worldObj.isRemote)
|
||||
player.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("tb.txt.tooFar")));
|
||||
return wandstack;
|
||||
}
|
||||
|
||||
int dim = fociTag.getInteger("dim");
|
||||
|
||||
if (dim != player.dimension) {
|
||||
if (player.worldObj.isRemote)
|
||||
player.addChatMessage(
|
||||
new ChatComponentText(StatCollector.translateToLocal("tb.txt.wrongDimension")));
|
||||
return wandstack;
|
||||
} else {
|
||||
if (world.checkChunksExist(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1)) {
|
||||
if (world.blockExists(x, y, z)) {
|
||||
Block b = world.getBlock(x, y, z);
|
||||
Vec3 vec = player.getLookVec();
|
||||
b.onBlockActivated(
|
||||
world, x, y, z, player, 0, (float) vec.xCoord, (float) vec.yCoord, (float)
|
||||
vec.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foci = null;
|
||||
}
|
||||
}
|
||||
return wandstack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg) {
|
||||
super.registerIcons(reg);
|
||||
this.icon = reg.registerIcon(getIconString());
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
super.addInformation(stack, player, list, par4);
|
||||
|
||||
NBTTagCompound tag = MiscUtils.getStackTag(stack);
|
||||
|
||||
if (tag.hasKey("blockX")) {
|
||||
list.add("X: " + tag.getInteger("blockX"));
|
||||
list.add("Y: " + tag.getInteger("blockY"));
|
||||
list.add("Z: " + tag.getInteger("blockZ"));
|
||||
list.add("Dim: " + tag.getInteger("dim"));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void addInformation(ItemStack stack,EntityPlayer player, List list, boolean par4) {
|
||||
super.addInformation(stack, player, list, par4);
|
||||
|
||||
NBTTagCompound tag = MiscUtils.getStackTag(stack);
|
||||
|
||||
if(tag.hasKey("blockX"))
|
||||
{
|
||||
list.add("X: "+tag.getInteger("blockX"));
|
||||
list.add("Y: "+tag.getInteger("blockY"));
|
||||
list.add("Z: "+tag.getInteger("blockZ"));
|
||||
list.add("Dim: "+tag.getInteger("dim"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,8 +12,8 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import tb.init.TBFociUpgrades;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
@@ -25,149 +25,210 @@ import thaumcraft.common.config.ConfigItems;
|
||||
import thaumcraft.common.items.ItemCrystalEssence;
|
||||
import thaumcraft.common.items.wands.WandManager;
|
||||
|
||||
public class FociDrain extends ItemFocusBasic
|
||||
{
|
||||
public class FociDrain extends ItemFocusBasic {
|
||||
|
||||
Object beam = null;
|
||||
|
||||
public int getFocusColor(ItemStack focusstack) {
|
||||
return 0x191770;
|
||||
}
|
||||
|
||||
public String getSortingHelper(ItemStack focusstack) {
|
||||
String out = "DR";
|
||||
for (short id : this.getAppliedUpgrades(focusstack)) {
|
||||
out = out + id;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public boolean isVisCostPerTick(ItemStack focusstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public AspectList getVisCost(ItemStack focusstack) {
|
||||
return new AspectList().add(Aspect.WATER, 5);
|
||||
}
|
||||
|
||||
public WandFocusAnimation getAnimation(ItemStack focusstack) {
|
||||
return WandFocusAnimation.CHARGE;
|
||||
}
|
||||
|
||||
public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
|
||||
|
||||
switch (rank) {
|
||||
case 3: {
|
||||
return new FocusUpgradeType[] {FocusUpgradeType.frugal, TBFociUpgrades.aquatic, TBFociUpgrades.netheric
|
||||
};
|
||||
}
|
||||
default: {
|
||||
return new FocusUpgradeType[] {FocusUpgradeType.frugal};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack onFocusRightClick(
|
||||
ItemStack wandstack, World world, EntityPlayer player, MovingObjectPosition movingobjectposition) {
|
||||
player.setItemInUse(wandstack, 2147483647);
|
||||
return wandstack;
|
||||
}
|
||||
|
||||
public void onUsingFocusTick(ItemStack wandstack, EntityPlayer player, int count) {
|
||||
|
||||
ItemStack foci =
|
||||
ItemStack.loadItemStackFromNBT(MiscUtils.getStackTag(wandstack).getCompoundTag("focus"));
|
||||
|
||||
if (!WandManager.consumeVisFromInventory(player, this.getVisCost(foci))) {
|
||||
player.stopUsingItem();
|
||||
return;
|
||||
}
|
||||
|
||||
Object beam = null;
|
||||
|
||||
public int getFocusColor(ItemStack focusstack) {
|
||||
return 0x191770;
|
||||
}
|
||||
|
||||
public String getSortingHelper(ItemStack focusstack) {
|
||||
String out="DR";
|
||||
for (short id:this.getAppliedUpgrades(focusstack)) {
|
||||
out = out + id;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public boolean isVisCostPerTick(ItemStack focusstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public AspectList getVisCost(ItemStack focusstack) {
|
||||
return new AspectList().add(Aspect.WATER, 5);
|
||||
|
||||
}
|
||||
|
||||
public WandFocusAnimation getAnimation(ItemStack focusstack) {
|
||||
return WandFocusAnimation.CHARGE;
|
||||
}
|
||||
|
||||
public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
|
||||
|
||||
switch(rank)
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
return new FocusUpgradeType[]{FocusUpgradeType.frugal,TBFociUpgrades.aquatic,TBFociUpgrades.netheric};
|
||||
}
|
||||
default:
|
||||
{
|
||||
return new FocusUpgradeType[]{FocusUpgradeType.frugal};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack onFocusRightClick(ItemStack wandstack, World world,EntityPlayer player, MovingObjectPosition movingobjectposition) {
|
||||
player.setItemInUse(wandstack, 2147483647);
|
||||
return wandstack;
|
||||
}
|
||||
|
||||
|
||||
public void onUsingFocusTick(ItemStack wandstack, EntityPlayer player,int count) {
|
||||
|
||||
ItemStack foci = ItemStack.loadItemStackFromNBT(MiscUtils.getStackTag(wandstack).getCompoundTag("focus"));
|
||||
|
||||
if(!WandManager.consumeVisFromInventory(player, this.getVisCost(foci)))
|
||||
{
|
||||
player.stopUsingItem();
|
||||
return;
|
||||
}
|
||||
|
||||
float f = 1.0F;
|
||||
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
|
||||
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
|
||||
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double)f;
|
||||
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double)f + (double)(player.worldObj.isRemote ? player.getEyeHeight() - player.getDefaultEyeHeight() : player.getEyeHeight());
|
||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double)f;
|
||||
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
|
||||
double d1 = player.prevPosY
|
||||
+ (player.posY - player.prevPosY) * (double) f
|
||||
+ (double)
|
||||
(player.worldObj.isRemote
|
||||
? player.getEyeHeight() - player.getDefaultEyeHeight()
|
||||
: player.getEyeHeight());
|
||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
|
||||
Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
|
||||
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
|
||||
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
|
||||
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
|
||||
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
|
||||
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
|
||||
float f6 = MathHelper.sin(-f1 * 0.017453292F);
|
||||
float f7 = f4 * f5;
|
||||
float f8 = f3 * f5;
|
||||
double d3 = 5.0D;
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
d3 = ((EntityPlayerMP)player).theItemInWorldManager.getBlockReachDistance();
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3);
|
||||
MovingObjectPosition pos = player.worldObj.func_147447_a(vec3, vec31, true, false, true);
|
||||
|
||||
if(pos != null && pos.typeOfHit == MovingObjectType.BLOCK)
|
||||
{
|
||||
Block b = player.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
int meta = player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
|
||||
if(b != null)
|
||||
{
|
||||
if(b == Blocks.water)
|
||||
{
|
||||
if(player.worldObj.isRemote)
|
||||
beam = Thaumcraft.proxy.beamCont(player.worldObj, player, pos.hitVec.xCoord, pos.hitVec.yCoord, pos.hitVec.zCoord, 1, 0x5555ff, true, 2, beam, 2);
|
||||
|
||||
if(this.getUpgradeLevel(foci, TBFociUpgrades.aquatic) > 0 || player.ticksExisted % 5 == 0)
|
||||
{
|
||||
b.onBlockDestroyedByPlayer(player.worldObj, pos.blockX, pos.blockY, pos.blockZ, player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ));
|
||||
player.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ,Blocks.air,0,2);
|
||||
player.worldObj.playSound(pos.blockX+0.5D, pos.blockY+0.5D, pos.blockZ+0.5D, b.stepSound.getBreakSound(), 1, 1, false);
|
||||
for(int i = 0; i < 100; ++i)
|
||||
player.worldObj.spawnParticle("blockcrack_"+Block.getIdFromBlock(b)+"_"+meta, pos.blockX+player.worldObj.rand.nextDouble(), pos.blockY+player.worldObj.rand.nextDouble(), pos.blockZ+player.worldObj.rand.nextDouble(), 0, 0, 0);
|
||||
|
||||
if(this.getUpgradeLevel(foci, TBFociUpgrades.aquatic) > 0 && player.worldObj.rand.nextDouble() < 0.4D)
|
||||
{
|
||||
ItemStack waterCrystal = new ItemStack(ConfigItems.itemCrystalEssence,1,0);
|
||||
ItemCrystalEssence cEssence = (ItemCrystalEssence) waterCrystal.getItem();
|
||||
cEssence.setAspects(waterCrystal, new AspectList().add((player.worldObj.rand.nextDouble() < 0.1D ? Aspect.POISON : Aspect.WATER),1));
|
||||
EntityItem crystal = new EntityItem(player.worldObj, pos.blockX+0.5D, pos.blockY+0.5D, pos.blockZ+0.5D, waterCrystal);
|
||||
if(!player.worldObj.isRemote)
|
||||
player.worldObj.spawnEntityInWorld(crystal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(b == Blocks.lava && this.getUpgradeLevel(foci, TBFociUpgrades.netheric) > 0)
|
||||
{
|
||||
if(player.worldObj.isRemote)
|
||||
beam = Thaumcraft.proxy.beamCont(player.worldObj, player, pos.hitVec.xCoord, pos.hitVec.yCoord, pos.hitVec.zCoord, 1, 0xff5555, true, 2, beam, 2);
|
||||
|
||||
if(player.ticksExisted % 5 == 0 && WandManager.consumeVisFromInventory(player, new AspectList().add(Aspect.FIRE, 3)))
|
||||
{
|
||||
b.onBlockDestroyedByPlayer(player.worldObj, pos.blockX, pos.blockY, pos.blockZ, player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ));
|
||||
player.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ,Blocks.air,0,2);
|
||||
player.worldObj.playSound(pos.blockX+0.5D, pos.blockY+0.5D, pos.blockZ+0.5D, b.stepSound.getBreakSound(), 1, 1, false);
|
||||
for(int i = 0; i < 100; ++i)
|
||||
player.worldObj.spawnParticle("blockcrack_"+Block.getIdFromBlock(b)+"_"+meta, pos.blockX+player.worldObj.rand.nextDouble(), pos.blockY+player.worldObj.rand.nextDouble(), pos.blockZ+player.worldObj.rand.nextDouble(), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
||||
MovingObjectPosition pos = player.worldObj.func_147447_a(vec3, vec31, true, false, true);
|
||||
|
||||
if (pos != null && pos.typeOfHit == MovingObjectType.BLOCK) {
|
||||
Block b = player.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
int meta = player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
|
||||
if (b != null) {
|
||||
if (b == Blocks.water) {
|
||||
if (player.worldObj.isRemote)
|
||||
beam = Thaumcraft.proxy.beamCont(
|
||||
player.worldObj,
|
||||
player,
|
||||
pos.hitVec.xCoord,
|
||||
pos.hitVec.yCoord,
|
||||
pos.hitVec.zCoord,
|
||||
1,
|
||||
0x5555ff,
|
||||
true,
|
||||
2,
|
||||
beam,
|
||||
2);
|
||||
|
||||
if (this.getUpgradeLevel(foci, TBFociUpgrades.aquatic) > 0 || player.ticksExisted % 5 == 0) {
|
||||
b.onBlockDestroyedByPlayer(
|
||||
player.worldObj,
|
||||
pos.blockX,
|
||||
pos.blockY,
|
||||
pos.blockZ,
|
||||
player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ));
|
||||
player.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air, 0, 2);
|
||||
player.worldObj.playSound(
|
||||
pos.blockX + 0.5D,
|
||||
pos.blockY + 0.5D,
|
||||
pos.blockZ + 0.5D,
|
||||
b.stepSound.getBreakSound(),
|
||||
1,
|
||||
1,
|
||||
false);
|
||||
for (int i = 0; i < 100; ++i)
|
||||
player.worldObj.spawnParticle(
|
||||
"blockcrack_" + Block.getIdFromBlock(b) + "_" + meta,
|
||||
pos.blockX + player.worldObj.rand.nextDouble(),
|
||||
pos.blockY + player.worldObj.rand.nextDouble(),
|
||||
pos.blockZ + player.worldObj.rand.nextDouble(),
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
if (this.getUpgradeLevel(foci, TBFociUpgrades.aquatic) > 0
|
||||
&& player.worldObj.rand.nextDouble() < 0.4D) {
|
||||
ItemStack waterCrystal = new ItemStack(ConfigItems.itemCrystalEssence, 1, 0);
|
||||
ItemCrystalEssence cEssence = (ItemCrystalEssence) waterCrystal.getItem();
|
||||
cEssence.setAspects(
|
||||
waterCrystal,
|
||||
new AspectList()
|
||||
.add(
|
||||
(player.worldObj.rand.nextDouble() < 0.1D
|
||||
? Aspect.POISON
|
||||
: Aspect.WATER),
|
||||
1));
|
||||
EntityItem crystal = new EntityItem(
|
||||
player.worldObj,
|
||||
pos.blockX + 0.5D,
|
||||
pos.blockY + 0.5D,
|
||||
pos.blockZ + 0.5D,
|
||||
waterCrystal);
|
||||
if (!player.worldObj.isRemote) player.worldObj.spawnEntityInWorld(crystal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (b == Blocks.lava && this.getUpgradeLevel(foci, TBFociUpgrades.netheric) > 0) {
|
||||
if (player.worldObj.isRemote)
|
||||
beam = Thaumcraft.proxy.beamCont(
|
||||
player.worldObj,
|
||||
player,
|
||||
pos.hitVec.xCoord,
|
||||
pos.hitVec.yCoord,
|
||||
pos.hitVec.zCoord,
|
||||
1,
|
||||
0xff5555,
|
||||
true,
|
||||
2,
|
||||
beam,
|
||||
2);
|
||||
|
||||
if (player.ticksExisted % 5 == 0
|
||||
&& WandManager.consumeVisFromInventory(player, new AspectList().add(Aspect.FIRE, 3))) {
|
||||
b.onBlockDestroyedByPlayer(
|
||||
player.worldObj,
|
||||
pos.blockX,
|
||||
pos.blockY,
|
||||
pos.blockZ,
|
||||
player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ));
|
||||
player.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air, 0, 2);
|
||||
player.worldObj.playSound(
|
||||
pos.blockX + 0.5D,
|
||||
pos.blockY + 0.5D,
|
||||
pos.blockZ + 0.5D,
|
||||
b.stepSound.getBreakSound(),
|
||||
1,
|
||||
1,
|
||||
false);
|
||||
for (int i = 0; i < 100; ++i)
|
||||
player.worldObj.spawnParticle(
|
||||
"blockcrack_" + Block.getIdFromBlock(b) + "_" + meta,
|
||||
pos.blockX + player.worldObj.rand.nextDouble(),
|
||||
pos.blockY + player.worldObj.rand.nextDouble(),
|
||||
pos.blockZ + player.worldObj.rand.nextDouble(),
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer p, int count)
|
||||
{
|
||||
beam = null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg)
|
||||
{
|
||||
super.registerIcons(reg);
|
||||
this.icon = reg.registerIcon(getIconString());
|
||||
}
|
||||
|
||||
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer p, int count) {
|
||||
beam = null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg) {
|
||||
super.registerIcons(reg);
|
||||
this.icon = reg.registerIcon(getIconString());
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package tb.common.item.foci;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import DummyCore.Utils.MiscUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -19,8 +18,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import tb.init.TBFociUpgrades;
|
||||
import tb.init.TBThaumonomicon;
|
||||
@@ -35,170 +34,191 @@ import thaumcraft.common.items.ItemCrystalEssence;
|
||||
import thaumcraft.common.items.wands.WandManager;
|
||||
import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager;
|
||||
|
||||
public class FociExperience extends ItemFocusBasic
|
||||
{
|
||||
public class FociExperience extends ItemFocusBasic {
|
||||
|
||||
public int getFocusColor(ItemStack focusstack) {
|
||||
return 0xf8ffdc;
|
||||
}
|
||||
|
||||
public String getSortingHelper(ItemStack focusstack) {
|
||||
String out="XP";
|
||||
for (short id:this.getAppliedUpgrades(focusstack)) {
|
||||
out = out + id;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public boolean isVisCostPerTick(ItemStack focusstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public AspectList getVisCost(ItemStack focusstack) {
|
||||
return new AspectList().add(Aspect.ORDER, 500).add(Aspect.ENTROPY, 500);
|
||||
|
||||
}
|
||||
|
||||
public WandFocusAnimation getAnimation(ItemStack focusstack) {
|
||||
return WandFocusAnimation.CHARGE;
|
||||
}
|
||||
|
||||
public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
|
||||
|
||||
switch(rank)
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
return new FocusUpgradeType[]{FocusUpgradeType.potency,FocusUpgradeType.frugal,TBFociUpgrades.vaporizing,TBFociUpgrades.decomposing};
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
if(this.getUpgradeLevel(focusstack, TBFociUpgrades.decomposing) > 0)
|
||||
return new FocusUpgradeType[]{FocusUpgradeType.potency,FocusUpgradeType.frugal,TBFociUpgrades.decomposing};
|
||||
else if(this.getUpgradeLevel(focusstack, TBFociUpgrades.vaporizing) > 0)
|
||||
return new FocusUpgradeType[]{FocusUpgradeType.potency,FocusUpgradeType.frugal,TBFociUpgrades.vaporizing};
|
||||
else
|
||||
return new FocusUpgradeType[]{FocusUpgradeType.potency,FocusUpgradeType.frugal,TBFociUpgrades.vaporizing,TBFociUpgrades.decomposing};
|
||||
}
|
||||
default:
|
||||
{
|
||||
return new FocusUpgradeType[]{FocusUpgradeType.frugal,FocusUpgradeType.potency};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ItemStack onFocusRightClick(ItemStack wandstack, World world,EntityPlayer player, MovingObjectPosition movingobjectposition) {
|
||||
|
||||
ItemStack foci = ItemStack.loadItemStackFromNBT(MiscUtils.getStackTag(wandstack).getCompoundTag("focus"));
|
||||
|
||||
int vaporisingLevel = this.getUpgradeLevel(foci, TBFociUpgrades.vaporizing);
|
||||
int decomposingLevel = this.getUpgradeLevel(foci, TBFociUpgrades.decomposing);
|
||||
|
||||
if(decomposingLevel > 0)
|
||||
{
|
||||
|
||||
Vec3 vec = player.getLookVec();
|
||||
ArrayList<Entity> mobs = (ArrayList<Entity>) world.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(player.posX+vec.xCoord-0.3D, player.posY+player.getEyeHeight()+vec.yCoord-0.3D, player.posZ+vec.zCoord-0.3D, player.posX+vec.xCoord+0.3D, player.posY+player.getEyeHeight()+vec.yCoord+0.3D, player.posZ+vec.zCoord+0.3D));
|
||||
|
||||
if(mobs != null && !mobs.isEmpty())
|
||||
{
|
||||
Entity e = mobs.get(world.rand.nextInt(mobs.size()));
|
||||
if(e instanceof EntityLivingBase)
|
||||
{
|
||||
EntityLivingBase eaten = (EntityLivingBase) e;
|
||||
if(e instanceof EntityPlayer)
|
||||
return wandstack;
|
||||
|
||||
if(e instanceof IBossDisplayData)
|
||||
return wandstack;
|
||||
|
||||
double hp = eaten.getHealth();
|
||||
|
||||
if(WandManager.consumeVisFromInventory(player, TBThaumonomicon.primals(MathHelper.floor_double(hp*100/decomposingLevel))))
|
||||
{
|
||||
eaten.attackEntityFrom(DamageSource.outOfWorld, Integer.MAX_VALUE);
|
||||
int xp = MathHelper.floor_double(hp*3);
|
||||
|
||||
EntityXPOrb orb = new EntityXPOrb(world, eaten.posX, eaten.posY, eaten.posZ, xp);
|
||||
if(!world.isRemote)
|
||||
world.spawnEntityInWorld(orb);
|
||||
|
||||
return wandstack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(movingobjectposition != null && movingobjectposition.typeOfHit == MovingObjectType.BLOCK)
|
||||
{
|
||||
Block b = world.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
|
||||
int meta = world.getBlockMetadata(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
|
||||
int xp = b.getExpDrop(world, meta, this.getUpgradeLevel(foci, FocusUpgradeType.potency));
|
||||
if(xp <= 0)
|
||||
xp = this.getUpgradeLevel(foci, FocusUpgradeType.potency)+1;
|
||||
|
||||
MovingObjectPosition pos = movingobjectposition;
|
||||
|
||||
if(b.getBlockHardness(world, pos.blockX, pos.blockY, pos.blockZ) <= 0)
|
||||
return wandstack;
|
||||
|
||||
if(!WandManager.consumeVisFromInventory(player, TBThaumonomicon.primals(MathHelper.floor_double(b.getBlockHardness(world, pos.blockX, pos.blockY, pos.blockZ)*100))))
|
||||
return wandstack;
|
||||
|
||||
if(vaporisingLevel > 0)
|
||||
{
|
||||
boolean doWork = vaporisingLevel == 1 ? world.rand.nextBoolean() : true;
|
||||
if(doWork)
|
||||
{
|
||||
if(ThaumcraftApi.exists(Item.getItemFromBlock(b), meta))
|
||||
{
|
||||
AspectList aspects = ThaumcraftCraftingManager.getObjectTags(new ItemStack(Item.getItemFromBlock(b),1, meta));
|
||||
if(aspects != null && aspects.size() > 0)
|
||||
{
|
||||
for(int i = 0; i < aspects.getAspects().length; ++i)
|
||||
{
|
||||
Aspect a = aspects.getAspects()[i];
|
||||
int amount = aspects.getAmount(a);
|
||||
|
||||
ItemStack crystalStack = new ItemStack(ConfigItems.itemCrystalEssence,1,0);
|
||||
ItemCrystalEssence cEssence = (ItemCrystalEssence) crystalStack.getItem();
|
||||
cEssence.setAspects(crystalStack, new AspectList().add(a,amount));
|
||||
|
||||
EntityItem crystal = new EntityItem(player.worldObj, pos.blockX+0.5D, pos.blockY+0.5D, pos.blockZ+0.5D, crystalStack);
|
||||
if(!player.worldObj.isRemote)
|
||||
player.worldObj.spawnEntityInWorld(crystal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b.onBlockDestroyedByPlayer(player.worldObj, pos.blockX, pos.blockY, pos.blockZ, player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ));
|
||||
player.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ,Blocks.air,0,3);
|
||||
player.worldObj.playSound(pos.blockX+0.5D, pos.blockY+0.5D, pos.blockZ+0.5D, b.stepSound.getBreakSound(), 1, 1, false);
|
||||
for(int i = 0; i < 100; ++i)
|
||||
player.worldObj.spawnParticle("blockcrack_"+Block.getIdFromBlock(b)+"_"+meta, pos.blockX+player.worldObj.rand.nextDouble(), pos.blockY+player.worldObj.rand.nextDouble(), pos.blockZ+player.worldObj.rand.nextDouble(), 0, 0, 0);
|
||||
|
||||
xp *= 2;
|
||||
|
||||
EntityXPOrb orb = new EntityXPOrb(world, pos.blockX+0.5D, pos.blockY+0.5D, pos.blockZ+0.5D, xp);
|
||||
if(!world.isRemote)
|
||||
world.spawnEntityInWorld(orb);
|
||||
|
||||
player.swingItem();
|
||||
}
|
||||
|
||||
return wandstack;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg)
|
||||
{
|
||||
super.registerIcons(reg);
|
||||
this.icon = reg.registerIcon(getIconString());
|
||||
public int getFocusColor(ItemStack focusstack) {
|
||||
return 0xf8ffdc;
|
||||
}
|
||||
|
||||
|
||||
public String getSortingHelper(ItemStack focusstack) {
|
||||
String out = "XP";
|
||||
for (short id : this.getAppliedUpgrades(focusstack)) {
|
||||
out = out + id;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public boolean isVisCostPerTick(ItemStack focusstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public AspectList getVisCost(ItemStack focusstack) {
|
||||
return new AspectList().add(Aspect.ORDER, 500).add(Aspect.ENTROPY, 500);
|
||||
}
|
||||
|
||||
public WandFocusAnimation getAnimation(ItemStack focusstack) {
|
||||
return WandFocusAnimation.CHARGE;
|
||||
}
|
||||
|
||||
public FocusUpgradeType[] getPossibleUpgradesByRank(ItemStack focusstack, int rank) {
|
||||
|
||||
switch (rank) {
|
||||
case 3: {
|
||||
return new FocusUpgradeType[] {
|
||||
FocusUpgradeType.potency,
|
||||
FocusUpgradeType.frugal,
|
||||
TBFociUpgrades.vaporizing,
|
||||
TBFociUpgrades.decomposing
|
||||
};
|
||||
}
|
||||
case 5: {
|
||||
if (this.getUpgradeLevel(focusstack, TBFociUpgrades.decomposing) > 0)
|
||||
return new FocusUpgradeType[] {
|
||||
FocusUpgradeType.potency, FocusUpgradeType.frugal, TBFociUpgrades.decomposing
|
||||
};
|
||||
else if (this.getUpgradeLevel(focusstack, TBFociUpgrades.vaporizing) > 0)
|
||||
return new FocusUpgradeType[] {
|
||||
FocusUpgradeType.potency, FocusUpgradeType.frugal, TBFociUpgrades.vaporizing
|
||||
};
|
||||
else
|
||||
return new FocusUpgradeType[] {
|
||||
FocusUpgradeType.potency,
|
||||
FocusUpgradeType.frugal,
|
||||
TBFociUpgrades.vaporizing,
|
||||
TBFociUpgrades.decomposing
|
||||
};
|
||||
}
|
||||
default: {
|
||||
return new FocusUpgradeType[] {FocusUpgradeType.frugal, FocusUpgradeType.potency};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ItemStack onFocusRightClick(
|
||||
ItemStack wandstack, World world, EntityPlayer player, MovingObjectPosition movingobjectposition) {
|
||||
|
||||
ItemStack foci =
|
||||
ItemStack.loadItemStackFromNBT(MiscUtils.getStackTag(wandstack).getCompoundTag("focus"));
|
||||
|
||||
int vaporisingLevel = this.getUpgradeLevel(foci, TBFociUpgrades.vaporizing);
|
||||
int decomposingLevel = this.getUpgradeLevel(foci, TBFociUpgrades.decomposing);
|
||||
|
||||
if (decomposingLevel > 0) {
|
||||
|
||||
Vec3 vec = player.getLookVec();
|
||||
ArrayList<Entity> mobs = (ArrayList<Entity>) world.getEntitiesWithinAABBExcludingEntity(
|
||||
player,
|
||||
AxisAlignedBB.getBoundingBox(
|
||||
player.posX + vec.xCoord - 0.3D,
|
||||
player.posY + player.getEyeHeight() + vec.yCoord - 0.3D,
|
||||
player.posZ + vec.zCoord - 0.3D,
|
||||
player.posX + vec.xCoord + 0.3D,
|
||||
player.posY + player.getEyeHeight() + vec.yCoord + 0.3D,
|
||||
player.posZ + vec.zCoord + 0.3D));
|
||||
|
||||
if (mobs != null && !mobs.isEmpty()) {
|
||||
Entity e = mobs.get(world.rand.nextInt(mobs.size()));
|
||||
if (e instanceof EntityLivingBase) {
|
||||
EntityLivingBase eaten = (EntityLivingBase) e;
|
||||
if (e instanceof EntityPlayer) return wandstack;
|
||||
|
||||
if (e instanceof IBossDisplayData) return wandstack;
|
||||
|
||||
double hp = eaten.getHealth();
|
||||
|
||||
if (WandManager.consumeVisFromInventory(
|
||||
player, TBThaumonomicon.primals(MathHelper.floor_double(hp * 100 / decomposingLevel)))) {
|
||||
eaten.attackEntityFrom(DamageSource.outOfWorld, Integer.MAX_VALUE);
|
||||
int xp = MathHelper.floor_double(hp * 3);
|
||||
|
||||
EntityXPOrb orb = new EntityXPOrb(world, eaten.posX, eaten.posY, eaten.posZ, xp);
|
||||
if (!world.isRemote) world.spawnEntityInWorld(orb);
|
||||
|
||||
return wandstack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (movingobjectposition != null && movingobjectposition.typeOfHit == MovingObjectType.BLOCK) {
|
||||
Block b = world.getBlock(
|
||||
movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
|
||||
int meta = world.getBlockMetadata(
|
||||
movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);
|
||||
int xp = b.getExpDrop(world, meta, this.getUpgradeLevel(foci, FocusUpgradeType.potency));
|
||||
if (xp <= 0) xp = this.getUpgradeLevel(foci, FocusUpgradeType.potency) + 1;
|
||||
|
||||
MovingObjectPosition pos = movingobjectposition;
|
||||
|
||||
if (b.getBlockHardness(world, pos.blockX, pos.blockY, pos.blockZ) <= 0) return wandstack;
|
||||
|
||||
if (!WandManager.consumeVisFromInventory(
|
||||
player,
|
||||
TBThaumonomicon.primals(MathHelper.floor_double(
|
||||
b.getBlockHardness(world, pos.blockX, pos.blockY, pos.blockZ) * 100)))) return wandstack;
|
||||
|
||||
if (vaporisingLevel > 0) {
|
||||
boolean doWork = vaporisingLevel == 1 ? world.rand.nextBoolean() : true;
|
||||
if (doWork) {
|
||||
if (ThaumcraftApi.exists(Item.getItemFromBlock(b), meta)) {
|
||||
AspectList aspects = ThaumcraftCraftingManager.getObjectTags(
|
||||
new ItemStack(Item.getItemFromBlock(b), 1, meta));
|
||||
if (aspects != null && aspects.size() > 0) {
|
||||
for (int i = 0; i < aspects.getAspects().length; ++i) {
|
||||
Aspect a = aspects.getAspects()[i];
|
||||
int amount = aspects.getAmount(a);
|
||||
|
||||
ItemStack crystalStack = new ItemStack(ConfigItems.itemCrystalEssence, 1, 0);
|
||||
ItemCrystalEssence cEssence = (ItemCrystalEssence) crystalStack.getItem();
|
||||
cEssence.setAspects(crystalStack, new AspectList().add(a, amount));
|
||||
|
||||
EntityItem crystal = new EntityItem(
|
||||
player.worldObj,
|
||||
pos.blockX + 0.5D,
|
||||
pos.blockY + 0.5D,
|
||||
pos.blockZ + 0.5D,
|
||||
crystalStack);
|
||||
if (!player.worldObj.isRemote) player.worldObj.spawnEntityInWorld(crystal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
b.onBlockDestroyedByPlayer(
|
||||
player.worldObj,
|
||||
pos.blockX,
|
||||
pos.blockY,
|
||||
pos.blockZ,
|
||||
player.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ));
|
||||
player.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air, 0, 3);
|
||||
player.worldObj.playSound(
|
||||
pos.blockX + 0.5D, pos.blockY + 0.5D, pos.blockZ + 0.5D, b.stepSound.getBreakSound(), 1, 1, false);
|
||||
for (int i = 0; i < 100; ++i)
|
||||
player.worldObj.spawnParticle(
|
||||
"blockcrack_" + Block.getIdFromBlock(b) + "_" + meta,
|
||||
pos.blockX + player.worldObj.rand.nextDouble(),
|
||||
pos.blockY + player.worldObj.rand.nextDouble(),
|
||||
pos.blockZ + player.worldObj.rand.nextDouble(),
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
|
||||
xp *= 2;
|
||||
|
||||
EntityXPOrb orb = new EntityXPOrb(world, pos.blockX + 0.5D, pos.blockY + 0.5D, pos.blockZ + 0.5D, xp);
|
||||
if (!world.isRemote) world.spawnEntityInWorld(orb);
|
||||
|
||||
player.swingItem();
|
||||
}
|
||||
|
||||
return wandstack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister reg) {
|
||||
super.registerIcons(reg);
|
||||
this.icon = reg.registerIcon(getIconString());
|
||||
}
|
||||
}
|
||||
Loaded 100 of 135 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user