Compare commits

...
Author SHA1 Message Date
Martin Robertz f4291635b2 fix dependencies 2023-11-12 11:11:48 +01:00
Martin Robertz 739e5fc9c3 fix 2023-11-12 11:09:00 +01:00
Martin Robertz 0aab92fe6c sa 2023-11-11 22:23:15 +01:00
Martin Robertz 52b110a0da Merge branch 'master' into emissive_microblocks 2023-11-11 22:20:41 +01:00
Martin Robertz afb21dcf8c fix wci 2023-11-11 12:07:34 +01:00
Martin Robertz c0dd868ca6 update bs+deps+gradle 2023-11-11 11:49:26 +01:00
Pelotrio 966fad56ca Clear render block instances on world unload to not leak the world 2023-11-10 18:11:53 -08:00
bombcar 9beab25b7a Update for spotlessApply 2023-11-07 15:32:25 -06:00
iamblackornot f471a0c094 - updated dependencies (promoted ForgeMultipart from CompileOnly to implementation)
- updated BuildScript
2023-11-07 14:00:27 +03:00
iamblackornot 2150548111 - forge microblocks of neonite, antiblock and glotek are now emissive when using shaders 2023-11-06 16:12:00 +03:00
Martin Robertz df216f68b4 Merge pull request #32 from GTNewHorizons/sb-fix-chisel-ui-priority
Fix Chisel opening its UI instead of looked at TE
2023-08-18 10:31:30 +02:00
serenibyss 834beb5ac8 humongous spotless apply to make CI happy 2023-08-18 03:10:44 -05:00
serenibyss a0f11f404a Fix chisel opening its UI instead of looked at TE 2023-08-18 02:55:49 -05:00
serenibyss 9899ca1177 bs + deps 2023-08-18 02:39:29 -05:00
Martin Robertz 1d94ff613d Merge pull request #31 from Darkmaxsas/disable-default-hempcrete-recipe
disable default hempcrete smelting
2023-06-17 08:51:15 +02:00
Darkmaxsas 494addb994 disable default hempcrete smelting 2023-06-16 22:03:34 +02:00
Martin Robertz e17147a14c Merge pull request #30 from chochem/fix-hempcrete-(yes,-again!)
Fix broken recipe for hempcrete powder (yes, again!)
2023-06-15 19:25:39 +02:00
chochem 605d47eeed move to coremod 2023-06-14 20:28:15 +01:00
chochem 0147be4afb revert broken change 2023-06-14 20:17:43 +01:00
Martin Robertz f5d9bee22e Merge pull request #29 from GTNewHorizons/hempcrete_recipe
Change hempcrete recipe from fern to wheat to actually be automatable
2023-06-10 21:31:01 +02:00
Sampsa aa90eb92a4 Change hempcrete recipe from fern to wheat to actually be automatable 2023-06-10 22:23:01 +03:00
Martin Robertz 0f7113c3dc Merge pull request #28 from chochem/master
Fix broken recipes for hempcrete and hempcrete powder
2023-04-28 15:58:52 +02:00
chochem fe46a1208f sa 2023-04-28 14:10:21 +01:00
chochem 529bb240a2 actual fix 2023-04-28 14:10:01 +01:00
chochem 7d0672aa09 all caps 2023-04-28 12:51:57 +01:00
Connor-Colenso 65d2a18875 Merge pull request #27 from Jimbno/master
Added 7 new sets of blocks
2023-04-25 20:04:25 +01:00
Jimbno 3c419d6524 Delete src/main/resources/assets/chisel/textures/blocks/Glotek directory
folder name change,
changed glotek and neonite to lower case
2023-04-25 19:26:25 +02:00
Jimbno dd8f34a6ec Delete src/main/resources/assets/chisel/textures/blocks/Neonite directory
folder name change
2023-04-25 19:25:41 +02:00
Jimbno aaaf548ff4 Add files via upload
folder name change
2023-04-25 19:24:16 +02:00
Jimbno 03c60ef024 Update SubmapManagerSpecialMaterial.java
hopefully this does it
2023-04-24 21:44:22 +02:00
Jimbno 41d38fc263 merge carvable classes
merged glowtek and neonite carvable into one calss
2023-04-24 20:45:10 +02:00
Jimbno bfbdcb07cf final fixes
Added the rest of suggestions,
made one class for glotek and neonite, made variable names more descriptive and removed SideOnly
2023-04-24 19:16:33 +02:00
Jimbno 1be95d427a Merge branch 'master' of https://github.com/Jimbno/Chisel 2023-04-23 22:18:56 +02:00
Jimbno 5759cddae3 Fixes
implemented some of glowredmans suggestions
2023-04-23 22:18:16 +02:00
Jimbno 3bfa3b4dc6 Update BlockCarvableGlotek.java 2023-04-23 22:13:56 +02:00
Jimbno 35b56b65b6 Merge pull request #1 from GTNewHorizons/dev
update bs+sa
2023-04-23 17:54:09 +02:00
Martin Robertz b64693d439 update bs+sa 2023-04-23 17:22:15 +02:00
Jimbno 305cc21c46 New Blocks
Added 7 new sets of chisel blocks
2023-04-23 14:01:31 +02:00
Martin Robertz e97ca89b15 bs+sa 2023-01-31 19:26:10 +01:00
Martin Robertz 1578bba172 Merge pull request #26 from Zereff06/disableMobSpawn
Disable mob spawn on the chisel blocks
2023-01-31 19:24:15 +01:00
Zereff06 85c0301dba spotlessAplly 2023-01-31 20:14:32 +02:00
Zereff06 68a00eea9d Merge remote-tracking branch 'Zereff06/disableMobSpawn' into disableMobSpawn 2023-01-31 20:11:02 +02:00
Zereff06 ad20e3f2ad Remove redundant variables 2023-01-31 20:09:20 +02:00
Raven Szewczyk dc80d5dd81 [ci skip] upgraded build system 2023-01-31 09:51:48 +00:00
Zereff06 c86b27646e Merge branch 'master' into disableMobSpawn 2023-01-29 23:46:31 +02:00
Zereff06 79e853ad0b spotlessApply 2023-01-29 23:41:53 +02:00
Zereff06 82de7905b1 add setting in config
by default mobs cannot Spawn
2023-01-29 23:02:26 +02:00
Jason Mitchell 33c845e2bf [ci skip] Add git-blame-ignore-revs for spotlessApply 2023-01-29 10:09:36 -08:00
Jason Mitchell 8f026dad8f [ci skip] spotlessApply with the new settings 2023-01-29 10:09:28 -08:00
Jason Mitchell a314fccd1b [ci skip] Update buildscript to RetroFuturaGradle 2023-01-29 10:03:56 -08:00
Zereff06 c2f1c134bd add info to tooltip
"Mobs cannot Spawn on this Block"
2023-01-29 00:44:14 +02:00
Zereff06 9b92e3aee9 Disable mob spawn on the chisel blocks 2023-01-28 23:08:44 +02:00
Martin Robertz 958f306252 Merge pull request #25 from Kiwi233/1.7/release
Update zh_CN.lang
2022-09-24 12:40:25 +02:00
[Kiwi233] 150cf1e42d Update zh_CN.lang 2022-09-24 11:31:40 +08:00
Martin Robertz 2e2d7e2879 Merge pull request #24 from GTNewHorizons/update-ctmlib
Update CTMLib
2022-08-17 11:17:59 +02:00
Vladislav Laetansky f13c2c0ddc Update CTMLib 2022-08-17 12:03:21 +03:00
boubou19 37b8bf7eca Merge pull request #23 from repo-alt/feature/overflow
Chisel GUI allows shift click when inventory is full, resulting in the voiding of the stack
2022-07-30 16:55:15 +02:00
repo_alt 1407b34861 Chisel GUI allows shift click when inventory is full, resulting in the voiding of the stack
https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10867
2022-07-30 18:48:38 +04:00
Jason Mitchell 90077cdea5 [ci skip] Migrate github actions to GTNH-Actions-Workflows 2022-07-16 10:47:23 -07:00
Connor-Colenso 32d5e538fd Merge pull request #22 from repo-alt/feature/present
Validate present GUI
2022-06-26 19:16:49 +01:00
repo_alt 3a6d40b550 Validate present GUI 2022-06-26 19:39:19 +04:00
boubou19 dfe8f5e56d Merge pull request #21 from GTNewHorizons/shade-ctmlib
Shade CTMLib
2022-06-19 21:33:19 +02:00
350 changed files with 16766 additions and 13632 deletions

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# Ignore spotlessApply reformat
8f026dad8fb7dcb86b68aaedf52ce12775b2af8d
+44
View File
@@ -0,0 +1,44 @@
* text eol=lf
*.[jJ][aA][rR] binary
*.[pP][nN][gG] binary
*.[jJ][pP][gG] binary
*.[jJ][pP][eE][gG] binary
*.[gG][iI][fF] binary
*.[tT][iI][fF] binary
*.[tT][iI][fF][fF] binary
*.[iI][cC][oO] binary
*.[sS][vV][gG] text
*.[eE][pP][sS] binary
*.[xX][cC][fF] binary
*.[kK][aA][rR] binary
*.[mM]4[aA] binary
*.[mM][iI][dD] binary
*.[mM][iI][dD][iI] binary
*.[mM][pP]3 binary
*.[oO][gG][gG] binary
*.[rR][aA] binary
*.7[zZ] binary
*.[gG][zZ] binary
*.[tT][aA][rR] binary
*.[tT][gG][zZ] binary
*.[zZ][iI][pP] binary
*.[tT][cC][nN] binary
*.[sS][oO] binary
*.[dD][lL][lL] binary
*.[dD][yY][lL][iI][bB] binary
*.[pP][sS][dD] binary
*.[tT][tT][fF] binary
*.[oO][tT][fF] binary
*.[pP][aA][tT][cC][hH] -text
*.[bB][aA][tT] text eol=crlf
*.[cC][mM][dD] text eol=crlf
*.[pP][sS]1 text eol=crlf
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
+2 -34
View File
@@ -1,5 +1,3 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Build and test name: Build and test
@@ -11,35 +9,5 @@ on:
jobs: jobs:
build-and-test: build-and-test:
runs-on: ubuntu-latest uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
steps: secrets: inherit
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
- name: Build the mod
run: ./gradlew build
- name: Run server for 1.5 minutes
run: |
mkdir run
echo "eula=true" > run/eula.txt
timeout 90 ./gradlew runServer 2>&1 | tee -a server.log || true
- name: Test no errors reported during server run
run: |
chmod +x .github/scripts/test_no_error_reports
.github/scripts/test_no_error_reports
+7 -44
View File
@@ -1,51 +1,14 @@
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Release tagged build name: Release tagged build
on: on:
push: push:
tags: tags: [ '*' ]
- '*'
permissions:
contents: write
jobs: jobs:
build: release-tags:
runs-on: ubuntu-latest uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
steps: secrets: inherit
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set release version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup the workspace
run: ./gradlew setupCIWorkspace
- name: Build the mod
run: ./gradlew build
- name: Release under current tag
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
prerelease: false
title: "${{ env.RELEASE_VERSION }}"
files: build/libs/*.jar
- name: Publish to Maven
run: ./gradlew publish
env:
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
-4
View File
@@ -1,4 +0,0 @@
compileJava {
options.encoding = "UTF-8"
}
+1284 -409
View File
File diff suppressed because it is too large. Load diff
+7 -8
View File
@@ -1,18 +1,17 @@
// Add your dependencies here // Add your dependencies here
dependencies { dependencies {
compile("com.github.GTNewHorizons:CodeChickenCore:1.1.5:dev") implementation("com.github.GTNewHorizons:CodeChickenCore:1.1.11:dev")
compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev") implementation("com.github.GTNewHorizons:CodeChickenLib:1.1.8:dev")
compile("com.github.GTNewHorizons:NotEnoughItems:2.2.8-GTNH:dev") implementation("com.github.GTNewHorizons:NotEnoughItems:2.4.12-GTNH:dev")
implementation("com.github.GTNewHorizons:ForgeMultipart:1.4.0:dev")
compileOnly("org.projectlombok:lombok:1.18.24") compileOnly("org.projectlombok:lombok:1.18.24")
annotationProcessor("org.projectlombok:lombok:1.18.24") annotationProcessor("org.projectlombok:lombok:1.18.24")
shadeCompile("com.github.GTNewHorizons:CTMLib:1.4.2:dev") shadowImplementation("com.github.GTNewHorizons:CTMLib:1.4.4:dev")
compileOnly("com.github.GTNewHorizons:waila:1.5.19:dev") { compileOnly("com.github.GTNewHorizons:waila:1.6.2:dev") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:ForgeMultipart:1.2.7:dev") {
transitive = false transitive = false
} }
+1 -1
View File
@@ -57,7 +57,7 @@ containsMixinsAndOrCoreModOnly = false
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your # If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your
# responsibility check the licence and request permission for distribution, if required. # responsibility check the licence and request permission for distribution, if required.
usesShadowedDependencies = false usesShadowedDependencies = true
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older # Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
# projects. New projects should not use this parameter. # projects. New projects should not use this parameter.
Binary file not shown.
+2 -1
View File
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
Vendored
+171 -115
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env sh #!/bin/sh
# #
# Copyright 2015 the original author or authors. # Copyright © 2015-2021 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -17,78 +17,113 @@
# #
############################################################################## ##############################################################################
## #
## Gradle start up script for UN*X # Gradle start up script for POSIX generated by Gradle.
## #
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
############################################################################## ##############################################################################
# Attempt to set APP_HOME # Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" # Resolve links: $0 may be a link
APP_BASE_NAME=`basename "$0"` app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD=maximum
warn () { warn () {
echo "$*" echo "$*"
} } >&2
die () { die () {
echo echo
echo "$*" echo "$*"
echo echo
exit 1 exit 1
} } >&2
# OS specific support (must be 'true' or 'false'). # OS specific support (must be 'true' or 'false').
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false nonstop=false
case "`uname`" in case "$( uname )" in #(
CYGWIN* ) CYGWIN* ) cygwin=true ;; #(
cygwin=true Darwin* ) darwin=true ;; #(
;; MSYS* | MINGW* ) msys=true ;; #(
Darwin* ) NONSTOP* ) nonstop=true ;;
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables # IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java" JAVACMD=$JAVA_HOME/jre/sh/java
else else
JAVACMD="$JAVA_HOME/bin/java" JAVACMD=$JAVA_HOME/bin/java
fi fi
if [ ! -x "$JAVACMD" ] ; then if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
else else
JAVACMD="java" JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
@@ -105,84 +140,105 @@ location of your Java installation."
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
MAX_FD_LIMIT=`ulimit -H -n` case $MAX_FD in #(
if [ $? -eq 0 ] ; then max*)
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
MAX_FD="$MAX_FD_LIMIT" # shellcheck disable=SC3045
fi MAX_FD=$( ulimit -H -n ) ||
ulimit -n $MAX_FD warn "Could not query maximum file descriptor limit"
if [ $? -ne 0 ] ; then esac
warn "Could not set maximum file descriptor limit: $MAX_FD" case $MAX_FD in #(
fi '' | soft) :;; #(
else *)
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
fi # shellcheck disable=SC3045
fi ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac esac
fi fi
# Escape application args # Collect all arguments for the java command, stacking in reverse order:
save () { # * args from the command line
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done # * the main class name
echo " " # * -classpath
} # * -D...appname settings
APP_ARGS=$(save "$@") # * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules # For Cygwin or MSYS, switch paths to Windows format before running java
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong JAVACMD=$( cygpath --unix "$JAVACMD" )
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")" # Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@" exec "$JAVACMD" "$@"
Vendored
+15 -23
View File
@@ -14,7 +14,7 @@
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@@ -25,10 +25,14 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@@ -37,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if %ERRORLEVEL% equ 0 goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -51,7 +55,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -61,38 +65,26 @@ echo location of your Java installation.
goto fail goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal
-10
View File
@@ -1,14 +1,4 @@
// Add any additional repositories for your dependencies here // Add any additional repositories for your dependencies here
repositories { repositories {
maven {
name = "GTNH"
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
}
maven {
url "https://cursemaven.com"
}
maven {
url = "https://jitpack.io"
}
} }
+28
View File
@@ -0,0 +1,28 @@
pluginManagement {
repositories {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
mavenContent {
includeGroup("com.gtnewhorizons.retrofuturagradle")
}
}
gradlePluginPortal()
mavenCentral()
mavenLocal()
}
}
plugins {
id 'com.diffplug.blowdryerSetup' version '1.6.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
}
blowdryerSetup {
repoSubfolder 'gtnhShared'
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.2')
//devLocal '.' // Use this when testing config updates locally
}
@@ -2,6 +2,6 @@ package com.cricketcraft.chisel.api;
public class ChiselAPIProps { public class ChiselAPIProps {
public static final String VERSION = "0.1.1"; public static final String VERSION = "0.1.1";
public static String MOD_ID = null; // Set by Chisel public static String MOD_ID = null; // Set by Chisel
} }
@@ -3,64 +3,63 @@ package com.cricketcraft.chisel.api;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class ChiselTabs { public class ChiselTabs {
public static class CustomCreativeTab extends CreativeTabs { public static class CustomCreativeTab extends CreativeTabs {
private boolean search; private boolean search;
private ItemStack stack; private ItemStack stack;
public CustomCreativeTab(String label, boolean searchbar) { public CustomCreativeTab(String label, boolean searchbar) {
super(label); super(label);
this.search = searchbar; this.search = searchbar;
} }
@Override @Override
public Item getTabIconItem() { public Item getTabIconItem() {
return stack.getItem(); return stack.getItem();
} }
public void setTabIconItemStack(ItemStack stack) { public void setTabIconItemStack(ItemStack stack) {
this.stack = stack; this.stack = stack;
} }
@Override @Override
public ItemStack getIconItemStack() { public ItemStack getIconItemStack() {
return stack; return stack;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public String getBackgroundImageName() { public String getBackgroundImageName() {
return search ? "item_search.png" : super.getBackgroundImageName(); return search ? "item_search.png" : super.getBackgroundImageName();
} }
@Override @Override
public int getSearchbarWidth() { public int getSearchbarWidth() {
return 89; return 89;
} }
@Override @Override
public boolean hasSearchBar() { public boolean hasSearchBar() {
return search; return search;
} }
} }
public static final CustomCreativeTab tabChisel = new CustomCreativeTab("tabChisel", false);
public static final CustomCreativeTab tabStoneChiselBlocks = new CustomCreativeTab("tabStoneChiselBlocks", true);
public static final CustomCreativeTab tabWoodChiselBlocks = new CustomCreativeTab("tabWoodChiselBlocks", true);
public static final CustomCreativeTab tabMetalChiselBlocks = new CustomCreativeTab("tabMetalChiselBlocks", true);
public static final CustomCreativeTab tabOtherChiselBlocks = new CustomCreativeTab("tabOtherChiselBlocks", true);
public static final CustomCreativeTab tabModdedChiselBlocks = new CustomCreativeTab("tabModdedChiselBlocks", true);
public static final CustomCreativeTab tabStairChiselBlocks = new CustomCreativeTab("tabStairChiselBlocks", true);
public static final CustomCreativeTab tabChisel = new CustomCreativeTab("tabChisel", false);
public static final CustomCreativeTab tabStoneChiselBlocks = new CustomCreativeTab("tabStoneChiselBlocks", true);
public static final CustomCreativeTab tabWoodChiselBlocks = new CustomCreativeTab("tabWoodChiselBlocks", true);
public static final CustomCreativeTab tabMetalChiselBlocks = new CustomCreativeTab("tabMetalChiselBlocks", true);
public static final CustomCreativeTab tabOtherChiselBlocks = new CustomCreativeTab("tabOtherChiselBlocks", true);
public static final CustomCreativeTab tabModdedChiselBlocks = new CustomCreativeTab("tabModdedChiselBlocks", true);
public static final CustomCreativeTab tabStairChiselBlocks = new CustomCreativeTab("tabStairChiselBlocks", true);
} }
@@ -2,21 +2,22 @@ package com.cricketcraft.chisel.api;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLInterModComms;
public class FMPIMC { public class FMPIMC {
public static void registerFMP(Block block) { public static void registerFMP(Block block) {
registerFMP(block, 0, 15); registerFMP(block, 0, 15);
} }
public static void registerFMP(Block block, int minMeta, int maxMeta) { public static void registerFMP(Block block, int minMeta, int maxMeta) {
for (int c = minMeta; c <= maxMeta; c++) { for (int c = minMeta; c <= maxMeta; c++) {
registerFMP(block, c); registerFMP(block, c);
} }
} }
public static void registerFMP(Block block, int meta) { public static void registerFMP(Block block, int meta) {
FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(block, 1, meta)); FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(block, 1, meta));
} }
} }
@@ -9,25 +9,21 @@ import com.cricketcraft.chisel.api.carving.IChiselMode;
*/ */
public interface IAdvancedChisel { public interface IAdvancedChisel {
/** /**
* Gets the next mode the button in the GUI should switch to given the current mode. * Gets the next mode the button in the GUI should switch to given the current mode.
* *
* @param stack * @param stack The {@link ItemStack} representing the chisel
* The {@link ItemStack} representing the chisel * @param current The {@link IChiselMode} that is currently active
* @param current * @return The next {@link IChiselMode} in the loop
* The {@link IChiselMode} that is currently active */
* @return The next {@link IChiselMode} in the loop public IChiselMode getNextMode(ItemStack stack, IChiselMode current);
*/
public IChiselMode getNextMode(ItemStack stack, IChiselMode current);
/** /**
* Gets an {@link IChiselMode} instance from a String name * Gets an {@link IChiselMode} instance from a String name
* *
* @param chisel * @param chisel The {@link ItemStack} representing the chisel
* The {@link ItemStack} representing the chisel * @param name The name of the {@link IChiselMode mode}
* @param name * @return An {@link IChiselMode} that has the name {@code name}
* The name of the {@link IChiselMode mode} */
* @return An {@link IChiselMode} that has the name {@code name} public IChiselMode getMode(ItemStack chisel, String name);
*/
public IChiselMode getMode(ItemStack chisel, String name);
} }
@@ -1,44 +1,42 @@
package com.cricketcraft.chisel.api; package com.cricketcraft.chisel.api;
import team.chisel.ctmlib.ICTMBlock;
import team.chisel.ctmlib.ISubmapManager;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import com.cricketcraft.chisel.api.carving.CarvableHelper; import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo; import com.cricketcraft.chisel.api.carving.IVariationInfo;
import team.chisel.ctmlib.ICTMBlock;
import team.chisel.ctmlib.ISubmapManager;
/** /**
* To be implemented on blocks that can be chiseled and need advanced metadata to variation mapping. Currently not very usable without internal classes. * To be implemented on blocks that can be chiseled and need advanced metadata to variation mapping. Currently not very
* usable without internal classes.
*/ */
public interface ICarvable extends ICTMBlock<IVariationInfo> { public interface ICarvable extends ICTMBlock<IVariationInfo> {
/** /**
* Gets a {@link ISubmapManager} from this block, based on metadata. * Gets a {@link ISubmapManager} from this block, based on metadata.
* <p> * <p>
* Typically you can refer this method to {@link CarvableHelper#getVariation(int)} but this method is provided for more complex metadata handling. * Typically you can refer this method to {@link CarvableHelper#getVariation(int)} but this method is provided for
* * more complex metadata handling.
* @param metadata *
* The metadata of the block * @param metadata The metadata of the block
* @param world * @param world {@link IBlockAccess} object, usually a world. Use of {@link IBlockAccess} Is necessary due to
* {@link IBlockAccess} object, usually a world. Use of {@link IBlockAccess} Is necessary due to this method's use in rendering. * this method's use in rendering.
* @param x * @param x X coord of the block
* X coord of the block * @param y Y coord of the block
* @param y * @param z Z coord of the block
* Y coord of the block * @param metadata The metadata of the block
* @param z * @return The {@link ISubmapManager} that represents this block in the world.
* Z coord of the block */
* @param metadata @Override
* The metadata of the block public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata);
* @return The {@link ISubmapManager} that represents this block in the world.
*/
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata);
/** /**
* Gets the {@link ISubmapManager} for this block when it is in item form. * Gets the {@link ISubmapManager} for this block when it is in item form.
* *
* @return A {@link ISubmapManager} * @return A {@link ISubmapManager}
*/ */
@Override @Override
public IVariationInfo getManager(int meta); public IVariationInfo getManager(int meta);
} }
@@ -12,74 +12,60 @@ import com.cricketcraft.chisel.api.carving.ICarvingVariation;
*/ */
public interface IChiselItem { public interface IChiselItem {
/** /**
* Checks whether the chisel can have its GUI opened * Checks whether the chisel can have its GUI opened
* *
* @param world * @param world {@link World} object
* {@link World} object * @param player The player holding the chisel. It can always be assumed that the player's current item will be
* @param player * this.
* The player holding the chisel. It can always be assumed that the player's current item will be this. * @param chisel The {@link ItemStack} representing your chisel
* @param chisel * @return True if the GUI should open. False otherwise.
* The {@link ItemStack} representing your chisel */
* @return True if the GUI should open. False otherwise. boolean canOpenGui(World world, EntityPlayer player, ItemStack chisel);
*/
boolean canOpenGui(World world, EntityPlayer player, ItemStack chisel);
/** /**
* Called when an item is chiseled using this chisel * Called when an item is chiseled using this chisel
* *
* @param world * @param world {@link World} object
* {@link World} object * @param chisel The {@link ItemStack} representing the chisel
* @param chisel * @param target The {@link ICarvingVariation} representing the target item
* The {@link ItemStack} representing the chisel * @return True if the chisel should be damaged. False otherwise.
* @param target */
* The {@link ICarvingVariation} representing the target item boolean onChisel(World world, ItemStack chisel, ICarvingVariation target);
* @return True if the chisel should be damaged. False otherwise.
*/
boolean onChisel(World world, ItemStack chisel, ICarvingVariation target);
/** /**
* Called to check if this {@link ItemStack} can be chiseled in this chisel. If not, there will be no possible variants displayed in the GUI. * Called to check if this {@link ItemStack} can be chiseled in this chisel. If not, there will be no possible
* <p> * variants displayed in the GUI.
* It is not necessary to take into account whether this item <i>has</i> any variants, this method will only be called after that check. * <p>
* * It is not necessary to take into account whether this item <i>has</i> any variants, this method will only be
* @param world * called after that check.
* {@link World} object *
* @param chisel * @param world {@link World} object
* The {@link ItemStack} representing the chisel * @param chisel The {@link ItemStack} representing the chisel
* @param target * @param target The {@link ICarvingVariation} representing the target item
* The {@link ICarvingVariation} representing the target item * @return True if the current target can be chiseled into anything. False otherwise.
* @return True if the current target can be chiseled into anything. False otherwise. */
*/ boolean canChisel(World world, ItemStack chisel, ICarvingVariation target);
boolean canChisel(World world, ItemStack chisel, ICarvingVariation target);
/** /**
* Allows you to control if your item can chisel this block in the world. * Allows you to control if your item can chisel this block in the world.
* *
* @param world * @param world World object
* World object * @param player {@link EntityPlayer The player} holding the chisel.
* @param player * @param x X coord of the block being chiseled
* {@link EntityPlayer The player} holding the chisel. * @param y Y coord of the block being chiseled
* @param x * @param z Z coord of the block being chiseled
* X coord of the block being chiseled * @param block The {@link Block} being chiseled
* @param y * @param metadata The blocks' metadata
* Y coord of the block being chiseled * @return True if the chiseling should take place. False otherwise.
* @param z */
* Z coord of the block being chiseled boolean canChiselBlock(World world, EntityPlayer player, int x, int y, int z, Block block, int metadata);
* @param block
* The {@link Block} being chiseled
* @param metadata
* The blocks' metadata
* @return True if the chiseling should take place. False otherwise.
*/
boolean canChiselBlock(World world, EntityPlayer player, int x, int y, int z, Block block, int metadata);
/** /**
* Allows you to control if your item has chiseling modes. * Allows you to control if your item has chiseling modes.
* *
* @param chisel * @param chisel The {@link ItemStack} representing the chisel.
* The {@link ItemStack} representing the chisel. * @return True if the chisel supports modes. False otherwise.
* @return True if the chisel supports modes. False otherwise. */
*/ boolean hasModes(ItemStack chisel);
boolean hasModes(ItemStack chisel);
} }
@@ -7,20 +7,16 @@ import net.minecraft.world.IBlockAccess;
*/ */
public interface IConnectable { public interface IConnectable {
/** /**
* Determines whether other CTM blocks can connect to this one. * Determines whether other CTM blocks can connect to this one.
* *
* @param world * @param world
* @param x * @param x The X position of the block that is connecting to this one. NOT the position of your block.
* The X position of the block that is connecting to this one. NOT the position of your block. * @param y The Y position of the block that is connecting to this one. NOT the position of your block.
* @param y * @param z The Z position of the block that is connecting to this one. NOT the position of your block.
* The Y position of the block that is connecting to this one. NOT the position of your block. * @param side The side being drawn.
* @param z * @return True if a block can connect to this one from the given direction. False otherwise.
* The Z position of the block that is connecting to this one. NOT the position of your block. */
* @param side boolean canConnectCTM(IBlockAccess world, int x, int y, int z, int side);
* The side being drawn.
* @return True if a block can connect to this one from the given direction. False otherwise.
*/
boolean canConnectCTM(IBlockAccess world, int x, int y, int z, int side);
} }
@@ -9,41 +9,31 @@ import net.minecraft.world.World;
*/ */
public interface IFacade { public interface IFacade {
/** /**
* Gets the block this facade is acting as. * Gets the block this facade is acting as.
* *
* @param world * @param world {@link World}
* {@link World} * @param x X coord of your block
* @param x * @param y Y coord of your block
* X coord of your block * @param z Z coord of your block
* @param y * @param side The side being rendered, NOT the side being connected from.
* Y coord of your block * <p>
* @param z * This value can be -1 if no side is specified. Please handle this appropriately.
* Z coord of your block * @return The block inside of your facade block.
* @param side */
* The side being rendered, NOT the side being connected from. Block getFacade(IBlockAccess world, int x, int y, int z, int side);
* <p>
* This value can be -1 if no side is specified. Please handle this appropriately.
* @return The block inside of your facade block.
*/
Block getFacade(IBlockAccess world, int x, int y, int z, int side);
/** /**
* Gets the metadata of the block that this facade is acting as. * Gets the metadata of the block that this facade is acting as.
* *
* @param world * @param world {@link World}
* {@link World} * @param x X coord of your block
* @param x * @param y Y coord of your block
* X coord of your block * @param z Z coord of your block
* @param y * @param side The side being rendered, NOT the side being connected from.
* Y coord of your block * <p>
* @param z * This value can be -1 if no side is specified. Please handle this appropriately.
* Z coord of your block * @return The metadata of your facade block.
* @param side */
* The side being rendered, NOT the side being connected from. int getFacadeMetadata(IBlockAccess world, int x, int y, int z, int side);
* <p> }
* This value can be -1 if no side is specified. Please handle this appropriately.
* @return The metadata of your facade block.
*/
int getFacadeMetadata(IBlockAccess world, int x, int y, int z, int side);
}
@@ -1,64 +1,69 @@
package com.cricketcraft.chisel.api; package com.cricketcraft.chisel.api;
/** /**
* Use the enum constants (using {@link #key} or calling {@link #toString()}) in this class as keys for IMC messages sent to chisel * Use the enum constants (using {@link #key} or calling {@link #toString()}) in this class as keys for IMC messages
* sent to chisel
* <p> * <p>
* It is also acceptable to copy the Strings in this class to avoid referencing this API. * It is also acceptable to copy the Strings in this class to avoid referencing this API.
*/ */
public enum IMC { public enum IMC {
/** /**
* Adds a variation to a group. * Adds a variation to a group.
* *
* Use this to add a variation to a group. String syntax: * Use this to add a variation to a group. String syntax:
* <p> * <p>
* groupname|blockname|meta * groupname|blockname|meta
* <p> * <p>
* An example would be {@code "mygroup|minecraft:dirt|1"} and this will add the vanilla dirt block with metadata 1 to the "mygroup" group, creating that group if need be. * An example would be {@code "mygroup|minecraft:dirt|1"} and this will add the vanilla dirt block with metadata 1
*/ * to the "mygroup" group, creating that group if need be.
ADD_VARIATION("variation:add"), */
ADD_VARIATION("variation:add"),
/** /**
* Removes a variation from a group. * Removes a variation from a group.
* *
* Use this to remove a variation from a group. String syntax: * Use this to remove a variation from a group. String syntax:
* <p> * <p>
* groupname|blockname|meta * groupname|blockname|meta
* <p> * <p>
* An example would be {@code "mygroup|minecraft:dirt|1"} and this will add the vanilla dirt block with metadata 1 to the "mygroup" group, creating that group if need be. * An example would be {@code "mygroup|minecraft:dirt|1"} and this will add the vanilla dirt block with metadata 1
*/ * to the "mygroup" group, creating that group if need be.
REMOVE_VARIATION("variation:remove"), */
REMOVE_VARIATION("variation:remove"),
/** /**
* Registers an oredict name to a group. This can be used to automatically add all blocks with this oredict name to a group. String syntax: * Registers an oredict name to a group. This can be used to automatically add all blocks with this oredict name to
* <p> * a group. String syntax:
* groupname|oredictname * <p>
* <p> * groupname|oredictname
* An example would be {@code "mygroup|plankWood"} which will add all blocks registered in the oredict as "plankWood" to your group called "mygroup". * <p>
*/ * An example would be {@code "mygroup|plankWood"} which will add all blocks registered in the oredict as
REGISTER_GROUP_ORE("group:ore"); * "plankWood" to your group called "mygroup".
*/
REGISTER_GROUP_ORE("group:ore");
/** /**
* The IMC message key for this message type. * The IMC message key for this message type.
*/ */
public final String key; public final String key;
IMC(String key) { IMC(String key) {
this.key = key; this.key = key;
} }
@Override @Override
public String toString() { public String toString() {
return key; return key;
} }
/** /**
* The modid of Chisel so you can easily send IMC to this mod. * The modid of Chisel so you can easily send IMC to this mod.
*/ */
@Deprecated @Deprecated
public static final String CHISEL_MODID = "chisel"; public static final String CHISEL_MODID = "chisel";
public static final String getModid() { public static final String getModid() {
return ChiselAPIProps.MOD_ID; return ChiselAPIProps.MOD_ID;
} }
} }
@@ -6,10 +6,12 @@ import net.minecraft.util.ChatComponentTranslation;
public class Statistics { public class Statistics {
public static StatBase blocksChiseled = (new StatBasic("stat.blockChiseled", new ChatComponentTranslation("stat.blockChiseled", new Object[0]))); public static StatBase blocksChiseled = (new StatBasic(
"stat.blockChiseled",
new ChatComponentTranslation("stat.blockChiseled", new Object[0])));
public static void init() { public static void init() {
blocksChiseled.initIndependentStat(); blocksChiseled.initIndependentStat();
blocksChiseled.registerStat(); blocksChiseled.registerStat();
} }
} }
@@ -14,210 +14,235 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import team.chisel.ctmlib.ISubmapManager;
import com.cricketcraft.chisel.api.ChiselAPIProps; import com.cricketcraft.chisel.api.ChiselAPIProps;
import com.cricketcraft.chisel.api.FMPIMC; import com.cricketcraft.chisel.api.FMPIMC;
import com.cricketcraft.chisel.api.rendering.TextureType; import com.cricketcraft.chisel.api.rendering.TextureType;
import codechicken.microblock.MicroMaterialRegistry;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.block.BlockCarvableGlowie;
import team.chisel.client.render.FullBrightMicroMaterial;
import team.chisel.ctmlib.ISubmapManager;
public class CarvableHelper { public class CarvableHelper {
public static Class<? extends ItemBlock> itemCarvableClass = null; public static Class<? extends ItemBlock> itemCarvableClass = null;
private Block theBlock; private Block theBlock;
public ArrayList<IVariationInfo> infoList = new ArrayList<IVariationInfo>(); public ArrayList<IVariationInfo> infoList = new ArrayList<IVariationInfo>();
IVariationInfo[] infoMap = new IVariationInfo[16]; IVariationInfo[] infoMap = new IVariationInfo[16];
public boolean forbidChiseling = false; public boolean forbidChiseling = false;
public CarvableHelper(Block block) { public CarvableHelper(Block block) {
this.theBlock = block; this.theBlock = block;
} }
public void addVariation(String description, int metadata, ISubmapManager manager) { public void addVariation(String description, int metadata, ISubmapManager manager) {
addVariation(description, metadata, null, manager); addVariation(description, metadata, null, manager);
} }
public void addVariation(String description, int metadata, Block bb) { public void addVariation(String description, int metadata, Block bb) {
addVariation(description, metadata, null, bb, 0, ChiselAPIProps.MOD_ID); addVariation(description, metadata, null, bb, 0, ChiselAPIProps.MOD_ID);
} }
public void addVariation(String description, int metadata, Block bb, int blockMeta) { public void addVariation(String description, int metadata, Block bb, int blockMeta) {
addVariation(description, metadata, null, bb, blockMeta, ChiselAPIProps.MOD_ID); addVariation(description, metadata, null, bb, blockMeta, ChiselAPIProps.MOD_ID);
} }
public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material) { public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material) {
addVariation(description, metadata, null, bb, blockMeta, ChiselAPIProps.MOD_ID); addVariation(description, metadata, null, bb, blockMeta, ChiselAPIProps.MOD_ID);
} }
public void addVariation(String description, int metadata, String texture) { public void addVariation(String description, int metadata, String texture) {
addVariation(description, metadata, texture, (ISubmapManager) null); addVariation(description, metadata, texture, (ISubmapManager) null);
} }
public void addVariation(String description, int metadata, String texture, ISubmapManager manager) { public void addVariation(String description, int metadata, String texture, ISubmapManager manager) {
addVariation(description, metadata, texture, null, 0, ChiselAPIProps.MOD_ID, manager, metadata); addVariation(description, metadata, texture, null, 0, ChiselAPIProps.MOD_ID, manager, metadata);
} }
public void addVariation(String description, int metadata, Block bb, String modid) { public void addVariation(String description, int metadata, Block bb, String modid) {
addVariation(description, metadata, null, bb, 0, modid); addVariation(description, metadata, null, bb, 0, modid);
} }
public void addVariation(String description, int metadata, Block bb, int blockMeta, String modid) { public void addVariation(String description, int metadata, Block bb, int blockMeta, String modid) {
addVariation(description, metadata, null, bb, blockMeta, modid); addVariation(description, metadata, null, bb, blockMeta, modid);
} }
public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material, String modid) { public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material,
addVariation(description, metadata, null, bb, blockMeta, modid); String modid) {
} addVariation(description, metadata, null, bb, blockMeta, modid);
}
public void addVariation(String description, int metadata, String texture, String modid) { public void addVariation(String description, int metadata, String texture, String modid) {
addVariation(description, metadata, texture, null, 0, modid); addVariation(description, metadata, texture, null, 0, modid);
} }
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid) { public void addVariation(String description, int metadata, String texture, Block block, int blockMeta,
addVariation(description, metadata, texture, block, blockMeta, modid, null, metadata); String modid) {
} addVariation(description, metadata, texture, block, blockMeta, modid, null, metadata);
}
public void addVariation(String description, int metadata, String texture, int order) { public void addVariation(String description, int metadata, String texture, int order) {
addVariation(description, metadata, texture, null, 0, ChiselAPIProps.MOD_ID, (ISubmapManager) null, order); addVariation(description, metadata, texture, null, 0, ChiselAPIProps.MOD_ID, (ISubmapManager) null, order);
} }
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid, ISubmapManager customManager, int order) { public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid,
ISubmapManager customManager, int order) {
if (infoList.size() >= 16) if (infoList.size() >= 16) return;
return;
IVariationInfo info = FMLCommonHandler.instance().getSide().isClient() ? getClientInfo(modid, texture, description, metadata, block, blockMeta, customManager, order) : getServerInfo(modid, IVariationInfo info = FMLCommonHandler.instance()
texture, description, metadata, block, blockMeta, customManager, order); .getSide()
.isClient() ? getClientInfo(modid, texture, description, metadata, block, blockMeta, customManager, order)
: getServerInfo(modid, texture, description, metadata, block, blockMeta, customManager, order);
infoList.add(info); infoList.add(info);
infoMap[metadata] = info; infoMap[metadata] = info;
} }
private IVariationInfo getClientInfo(String modid, String texture, String description, int metadata, Block block, int blockMeta, ISubmapManager customManager, int order) { private IVariationInfo getClientInfo(String modid, String texture, String description, int metadata, Block block,
ICarvingVariation var = CarvingUtils.getDefaultVariationFor(getBlock(), metadata, order); int blockMeta, ISubmapManager customManager, int order) {
TextureType type = TextureType.getTypeFor(this, modid, texture); ICarvingVariation var = CarvingUtils.getDefaultVariationFor(getBlock(), metadata, order);
if (type == TextureType.CUSTOM && customManager == null && block == null) { TextureType type = TextureType.getTypeFor(this, modid, texture);
throw new IllegalArgumentException(String.format("Could not find texture %s, and no custom texture manager was provided.", texture)); if (type == TextureType.CUSTOM && customManager == null && block == null) {
} throw new IllegalArgumentException(
String.format("Could not find texture %s, and no custom texture manager was provided.", texture));
}
ISubmapManager manager; ISubmapManager manager;
if (customManager != null) { if (customManager != null) {
manager = customManager; manager = customManager;
} else if (block != null) { } else if (block != null) {
manager = type.createManagerFor(var, block, blockMeta); manager = type.createManagerFor(var, block, blockMeta);
} else { } else {
manager = type.createManagerFor(var, texture); manager = type.createManagerFor(var, texture);
} }
return new VariationInfoBase(var, description, manager, type); return new VariationInfoBase(var, description, manager, type);
} }
private IVariationInfo getServerInfo(String modid, String texture, String description, int metadata, Block block, int blockMeta, ISubmapManager customManager, int order) { private IVariationInfo getServerInfo(String modid, String texture, String description, int metadata, Block block,
ICarvingVariation var = CarvingUtils.getDefaultVariationFor(getBlock(), metadata, order); int blockMeta, ISubmapManager customManager, int order) {
return new VariationInfoBase(var, description, null); ICarvingVariation var = CarvingUtils.getDefaultVariationFor(getBlock(), metadata, order);
} return new VariationInfoBase(var, description, null);
}
public IVariationInfo getVariation(int metadata) { public IVariationInfo getVariation(int metadata) {
if (metadata < 0 || metadata > 15) if (metadata < 0 || metadata > 15) metadata = 0;
metadata = 0;
IVariationInfo info = infoMap[metadata]; IVariationInfo info = infoMap[metadata];
if (info == null) if (info == null) return null;
return null;
return info; return info;
} }
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
if (metadata < 0 || metadata > 15) if (metadata < 0 || metadata > 15) metadata = 0;
metadata = 0;
IVariationInfo info = infoMap[metadata]; IVariationInfo info = infoMap[metadata];
if (info == null) if (info == null) return getMissingIcon();
return getMissingIcon();
return info.getIcon(side, metadata); return info.getIcon(side, metadata);
} }
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int metadata = world.getBlockMetadata(x, y, z); int metadata = world.getBlockMetadata(x, y, z);
if (metadata < 0 || metadata > 15) if (metadata < 0 || metadata > 15) metadata = 0;
metadata = 0;
IVariationInfo info = infoMap[metadata]; IVariationInfo info = infoMap[metadata];
if (info == null) if (info == null) return getMissingIcon();
return getMissingIcon();
return info.getIcon(world, x, y, z, side); return info.getIcon(world, x, y, z, side);
} }
public void registerAll(Block block, String name) { public void registerAll(Block block, String name) {
registerAll(block, name, itemCarvableClass); registerAll(block, name, itemCarvableClass);
} }
public void registerBlock(Block block, String name) { public void registerBlock(Block block, String name) {
registerBlock(block, name, itemCarvableClass); registerBlock(block, name, itemCarvableClass);
} }
void registerBlock(Block block, String name, Class<? extends ItemBlock> cl) { void registerBlock(Block block, String name, Class<? extends ItemBlock> cl) {
block.setBlockName("chisel." + name); block.setBlockName("chisel." + name);
GameRegistry.registerBlock(block, cl, name); GameRegistry.registerBlock(block, cl, name);
} }
public void registerAll(Block block, String name, Class<? extends ItemBlock> cl) { public void registerAll(Block block, String name, Class<? extends ItemBlock> cl) {
registerBlock(block, name, cl); registerBlock(block, name, cl);
registerVariations(name); registerVariations(name);
} }
public void registerVariations(String name) { public void registerVariations(String name) {
for (IVariationInfo info : infoList) { for (IVariationInfo info : infoList) {
registerVariation(name, info); registerVariation(name, info);
} }
} }
public void registerVariation(String name, IVariationInfo info) { public void registerVariation(String name, IVariationInfo info) {
Block block = info.getVariation().getBlock(); Block block = info.getVariation()
.getBlock();
if (block.renderAsNormalBlock() || block.isOpaqueCube() || block.isNormalCube()) { if (block instanceof BlockCarvableGlowie) {
FMPIMC.registerFMP(block, info.getVariation().getBlockMeta()); int meta = info.getVariation()
} .getBlockMeta();
if (forbidChiseling) MicroMaterialRegistry.registerMaterial(
return; new FullBrightMicroMaterial(block, meta),
block.getUnlocalizedName() + ((meta > 0) ? ("_" + meta) : ""));
CarvingUtils.getChiselRegistry().addVariation(name, info.getVariation()); } else {
} if (block.renderAsNormalBlock() || block.isOpaqueCube() || block.isNormalCube()) {
FMPIMC.registerFMP(
block,
info.getVariation()
.getBlockMeta());
}
}
@SideOnly(Side.CLIENT) if (forbidChiseling) return;
public void registerBlockIcons(String modName, Block block, IIconRegister register) {
for (IVariationInfo info : infoList) {
info.registerIcons(modName, block, register);
}
}
public void registerSubBlocks(Block block, CreativeTabs tabs, List<ItemStack> list) { CarvingUtils.getChiselRegistry()
for (IVariationInfo info : infoList) { .addVariation(name, info.getVariation());
list.add(new ItemStack(block, 1, info.getVariation().getItemMeta())); }
}
}
public void registerOre(String ore) { @SideOnly(Side.CLIENT)
OreDictionary.registerOre(ore, getBlock()); public void registerBlockIcons(String modName, Block block, IIconRegister register) {
} for (IVariationInfo info : infoList) {
info.registerIcons(modName, block, register);
}
}
@SideOnly(Side.CLIENT) public void registerSubBlocks(Block block, CreativeTabs tabs, List<ItemStack> list) {
public IIcon getMissingIcon() { for (IVariationInfo info : infoList) {
return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); list.add(
} new ItemStack(
block,
public Block getBlock() { 1,
return theBlock; info.getVariation()
} .getItemMeta()));
}
}
public void registerOre(String ore) {
OreDictionary.registerOre(ore, getBlock());
}
@SideOnly(Side.CLIENT)
public IIcon getMissingIcon() {
return ((TextureMap) Minecraft.getMinecraft()
.getTextureManager()
.getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
}
public Block getBlock() {
return theBlock;
}
} }
@@ -11,166 +11,163 @@ import com.google.common.collect.Lists;
public class CarvingUtils { public class CarvingUtils {
/** /**
* A simple way to compare two {@link ICarvingVariation} objects based on the {@link ICarvingVariation#getOrder() getOrder()} method. * A simple way to compare two {@link ICarvingVariation} objects based on the {@link ICarvingVariation#getOrder()
* * getOrder()} method.
* @param v1 *
* The first {@link ICarvingVariation variation}. * @param v1 The first {@link ICarvingVariation variation}.
* @param v2 * @param v2 The second {@link ICarvingVariation variation}.
* The second {@link ICarvingVariation variation}. * @return A positive integer if the first's order is greater, a negative integer if the second's is greater, and 0
* @return A positive integer if the first's order is greater, a negative integer if the second's is greater, and 0 if they are equal. * if they are equal.
*/ */
public static int compare(ICarvingVariation v1, ICarvingVariation v2) { public static int compare(ICarvingVariation v1, ICarvingVariation v2) {
return v1.getOrder() - v2.getOrder(); return v1.getOrder() - v2.getOrder();
} }
/** /**
* Gets an {@link ItemStack} representing the passed {@link ICarvingVariation}. * Gets an {@link ItemStack} representing the passed {@link ICarvingVariation}.
* *
* @param variation * @param variation An {@link ICarvingVariation}
* An {@link ICarvingVariation} * @return An {@link ItemStack}
* @return An {@link ItemStack} */
*/ public static ItemStack getStack(ICarvingVariation variation) {
public static ItemStack getStack(ICarvingVariation variation) { return new ItemStack(variation.getBlock(), 1, variation.getItemMeta());
return new ItemStack(variation.getBlock(), 1, variation.getItemMeta()); }
}
public static ICarvingRegistry chisel; public static ICarvingRegistry chisel;
/** /**
* @return The instance of the chisel carving registry from the chisel mod. * @return The instance of the chisel carving registry from the chisel mod.
* <p> * <p>
* If chisel is not installed this will return null. * If chisel is not installed this will return null.
*/ */
public static ICarvingRegistry getChiselRegistry() { public static ICarvingRegistry getChiselRegistry() {
return chisel; return chisel;
} }
/** /**
* Creates a standard {@link ICarvingVariation} for the given data. Use this if you do not need any custom behavior in your own variation. * Creates a standard {@link ICarvingVariation} for the given data. Use this if you do not need any custom behavior
* * in your own variation.
* @param block *
* The block of the variation * @param block The block of the variation
* @param metadata * @param metadata The metadata of both the block and item
* The metadata of both the block and item * @param order The sorting order.
* @param order * @return A standard {@link ICarvingVariation} instance.
* The sorting order. */
* @return A standard {@link ICarvingVariation} instance. public static ICarvingVariation getDefaultVariationFor(Block block, int metadata, int order) {
*/ return new SimpleCarvingVariation(block, metadata, order);
public static ICarvingVariation getDefaultVariationFor(Block block, int metadata, int order) { }
return new SimpleCarvingVariation(block, metadata, order);
}
/** /**
* Creates a standard {@link ICarvingGroup} for the given name. Use this if you do not need any custom behavior in your own group. * Creates a standard {@link ICarvingGroup} for the given name. Use this if you do not need any custom behavior in
* * your own group.
* @param name *
* The name of the group. * @param name The name of the group.
* @return A standard {@link ICarvingGroup} instance. * @return A standard {@link ICarvingGroup} instance.
*/ */
public static ICarvingGroup getDefaultGroupFor(String name) { public static ICarvingGroup getDefaultGroupFor(String name) {
return new SimpleCarvingGroup(name); return new SimpleCarvingGroup(name);
} }
public static class SimpleCarvingVariation implements ICarvingVariation { public static class SimpleCarvingVariation implements ICarvingVariation {
private int order; private int order;
private Block block; private Block block;
private int meta; private int meta;
private int damage; private int damage;
public SimpleCarvingVariation(Block block, int metadata, int order) { public SimpleCarvingVariation(Block block, int metadata, int order) {
this.order = order; this.order = order;
this.block = block; this.block = block;
this.meta = metadata; this.meta = metadata;
this.damage = metadata; this.damage = metadata;
} }
@Override @Override
public Block getBlock() { public Block getBlock() {
return block; return block;
} }
@Override @Override
public int getBlockMeta() { public int getBlockMeta() {
return meta; return meta;
} }
@Override @Override
public int getItemMeta() { public int getItemMeta() {
return damage; return damage;
} }
@Override @Override
public int getOrder() { public int getOrder() {
return order; return order;
} }
} }
public static class SimpleCarvingGroup implements ICarvingGroup { public static class SimpleCarvingGroup implements ICarvingGroup {
private String name; private String name;
private String sound; private String sound;
private String oreName; private String oreName;
private List<ICarvingVariation> variations = Lists.newArrayList(); private List<ICarvingVariation> variations = Lists.newArrayList();
public SimpleCarvingGroup(String name) { public SimpleCarvingGroup(String name) {
this.name = name; this.name = name;
} }
@Override @Override
public List<ICarvingVariation> getVariations() { public List<ICarvingVariation> getVariations() {
return Lists.newArrayList(variations); return Lists.newArrayList(variations);
} }
@Override @Override
public void addVariation(ICarvingVariation variation) { public void addVariation(ICarvingVariation variation) {
variations.add(variation); variations.add(variation);
Collections.sort(variations, new Comparator<ICarvingVariation>() { Collections.sort(variations, new Comparator<ICarvingVariation>() {
@Override @Override
public int compare(ICarvingVariation o1, ICarvingVariation o2) { public int compare(ICarvingVariation o1, ICarvingVariation o2) {
return CarvingUtils.compare(o1, o2); return CarvingUtils.compare(o1, o2);
} }
}); });
} }
@Override @Override
public boolean removeVariation(ICarvingVariation variation) { public boolean removeVariation(ICarvingVariation variation) {
ICarvingVariation toRemove = null; ICarvingVariation toRemove = null;
for (ICarvingVariation v : variations) { for (ICarvingVariation v : variations) {
if (v.getBlock() == variation.getBlock() && v.getBlockMeta() == variation.getBlockMeta()) { if (v.getBlock() == variation.getBlock() && v.getBlockMeta() == variation.getBlockMeta()) {
toRemove = v; toRemove = v;
} }
} }
return toRemove == null ? false : variations.remove(toRemove); return toRemove == null ? false : variations.remove(toRemove);
} }
@Override @Override
public String getName() { public String getName() {
return name; return name;
} }
@Override @Override
public String getSound() { public String getSound() {
return sound; return sound;
} }
@Override @Override
public void setSound(String sound) { public void setSound(String sound) {
this.sound = sound; this.sound = sound;
} }
@Override @Override
public String getOreName() { public String getOreName() {
return oreName; return oreName;
} }
@Override @Override
public void setOreName(String oreName) { public void setOreName(String oreName) {
this.oreName = oreName; this.oreName = oreName;
} }
} }
} }
@@ -5,70 +5,69 @@ import java.util.List;
/** /**
* Represents a group of chiselable blocks. * Represents a group of chiselable blocks.
* <p> * <p>
* This is an object that contains a collection of {@link ICarvingVariation} objects, and keeps them sorted. You may sort them in any way (or not at all), and {@link ICarvingVariation#getOrder()} will * This is an object that contains a collection of {@link ICarvingVariation} objects, and keeps them sorted. You may
* likely be of use to do so. * sort them in any way (or not at all), and {@link ICarvingVariation#getOrder()} will likely be of use to do so.
* <p> * <p>
* It also defines what sound and oredict name the group as a whole has. * It also defines what sound and oredict name the group as a whole has.
*/ */
public interface ICarvingGroup { public interface ICarvingGroup {
/** /**
* The name of this group. Used for internal identification. * The name of this group. Used for internal identification.
* *
* @return A string name for the group * @return A string name for the group
*/ */
String getName(); String getName();
/** /**
* Can return null. If null, fallback sound will be used (the standard chisel sound). * Can return null. If null, fallback sound will be used (the standard chisel sound).
* *
* @return The string resource path of the sound to use for chiseling items in this group * @return The string resource path of the sound to use for chiseling items in this group
*/ */
String getSound(); String getSound();
/** /**
* Sets the sound of this group * Sets the sound of this group
* *
* @param sound * @param sound A string resource path for the sound this group makes when chiseled
* A string resource path for the sound this group makes when chiseled */
*/ void setSound(String sound);
void setSound(String sound);
/** /**
* The oredict name to match to this group. All items with this oredict name will be assumed to be part of this group. * The oredict name to match to this group. All items with this oredict name will be assumed to be part of this
* * group.
* @return An ore dictionary name *
*/ * @return An ore dictionary name
String getOreName(); */
String getOreName();
/** /**
* Sets the oredict name for this group. * Sets the oredict name for this group.
* *
* @param oreName * @param oreName The String oredict name to be associated with this group.
* The String oredict name to be associated with this group. */
*/ void setOreName(String oreName);
void setOreName(String oreName);
/** /**
* Gets all carving variations associated with this group. * Gets all carving variations associated with this group.
* *
* @return A {@link List} of {@link ICarvingVariation}s * @return A {@link List} of {@link ICarvingVariation}s
*/ */
List<ICarvingVariation> getVariations(); List<ICarvingVariation> getVariations();
/** /**
* Adds a variation to this group. Do not call this from external code, as it will fail to remove the inverse lookup from the registry. * Adds a variation to this group. Do not call this from external code, as it will fail to remove the inverse lookup
* * from the registry.
* @param variation *
* An {@link ICarvingVariation} to add to this group * @param variation An {@link ICarvingVariation} to add to this group
*/ */
void addVariation(ICarvingVariation variation); void addVariation(ICarvingVariation variation);
/** /**
* Removes a variation to this group. Do not call this from external code, as it will fail to remove the inverse lookup from the registry. * Removes a variation to this group. Do not call this from external code, as it will fail to remove the inverse
* * lookup from the registry.
* @param variation *
* An {@link ICarvingVariation} to add to this group * @param variation An {@link ICarvingVariation} to add to this group
*/ */
boolean removeVariation(ICarvingVariation variation); boolean removeVariation(ICarvingVariation variation);
} }
@@ -14,191 +14,168 @@ import net.minecraft.world.World;
*/ */
public interface ICarvingRegistry { public interface ICarvingRegistry {
/* Getters */ /* Getters */
/** /**
* Finds the group the block/meta pair belongs to in the registry. * Finds the group the block/meta pair belongs to in the registry.
* *
* @param block * @param block The block of the variation
* The block of the variation * @param meta The metadata of the variation
* @param meta * @return The {@link ICarvingGroup} that the block/meta pair belongs to
* The metadata of the variation */
* @return The {@link ICarvingGroup} that the block/meta pair belongs to ICarvingGroup getGroup(Block block, int meta);
*/
ICarvingGroup getGroup(Block block, int meta);
/** /**
* Gets an {@link ICarvingGroup} by its name. * Gets an {@link ICarvingGroup} by its name.
* *
* @param name * @param name The name of the group
* The name of the group * @return An {@link ICarvingGroup}
* @return An {@link ICarvingGroup} */
*/ ICarvingGroup getGroup(String name);
ICarvingGroup getGroup(String name);
/** /**
* Gets the {@link ICarvingVariation} instance represented by this block/meta pair. * Gets the {@link ICarvingVariation} instance represented by this block/meta pair.
* *
* @param block * @param block The block of the variatoin
* The block of the variatoin * @param meta The metadata of the variation
* @param meta * @return The {@link ICarvingVariation} containing this block/meta pair
* The metadata of the variation */
* @return The {@link ICarvingVariation} containing this block/meta pair ICarvingVariation getVariation(Block block, int meta);
*/
ICarvingVariation getVariation(Block block, int meta);
/** /**
* Gets the list of {@link ICarvingVariation}s from the group that contains this block/meta pair. * Gets the list of {@link ICarvingVariation}s from the group that contains this block/meta pair.
* *
* @param block * @param block The block of the variation
* The block of the variation * @param meta The metadata of the variation
* @param meta * @return All of the {@link ICarvingVariation}s in the group that contains this block/meta pair
* The metadata of the variation */
* @return All of the {@link ICarvingVariation}s in the group that contains this block/meta pair List<ICarvingVariation> getGroupVariations(Block block, int meta);
*/
List<ICarvingVariation> getGroupVariations(Block block, int meta);
/** /**
* Gets the oredict name for the group that contains this block/meta pair. * Gets the oredict name for the group that contains this block/meta pair.
* *
* @param block * @param block The block of the variation
* The block of the variation * @param meta The metadata of the variation
* @param meta * @return A string oredict name for the group
* The metadata of the variation */
* @return A string oredict name for the group String getOreName(Block block, int meta);
*/
String getOreName(Block block, int meta);
/** /**
* Gets the possible output items for this {@link ItemStack}. To be used for machines/GUIs that chisel items. * Gets the possible output items for this {@link ItemStack}. To be used for machines/GUIs that chisel items.
* *
* @param chiseled * @param chiseled The {@link ItemStack} being chiseled
* The {@link ItemStack} being chiseled * @return A list of stacks that can be chiseled from the passed {@link ItemStack stack}
* @return A list of stacks that can be chiseled from the passed {@link ItemStack stack} */
*/ List<ItemStack> getItemsForChiseling(ItemStack chiseled);
List<ItemStack> getItemsForChiseling(ItemStack chiseled);
/** /**
* Gets the sound resource string for the group represented by this block/meta pair. * Gets the sound resource string for the group represented by this block/meta pair.
* *
* @param block * @param block The block of the variation
* The block of the variation * @param metadata The metadata of the variation
* @param metadata * @return The string resource for the sound that can be used in
* The metadata of the variation * {@link World#playSound(double, double, double, String, float, float, boolean)} and other methods.
* @return The string resource for the sound that can be used in {@link World#playSound(double, double, double, String, float, float, boolean)} and other methods. */
*/ public String getVariationSound(Block block, int metadata);
public String getVariationSound(Block block, int metadata);
/** /**
* Gets the sound resource string for the group represented by this item/meta pair. * Gets the sound resource string for the group represented by this item/meta pair.
* <p> * <p>
* Mostly a convenience for calling {@link #getVariationSound(Block, int)} with {@link Block#getBlockFromItem(Item)}. * Mostly a convenience for calling {@link #getVariationSound(Block, int)} with
* * {@link Block#getBlockFromItem(Item)}.
* @param item *
* The item of the variation * @param item The item of the variation
* @param metadata * @param metadata The metadata of the variation
* The metadata of the variation * @return The string resource for the sound that can be used in
* @return The string resource for the sound that can be used in {@link World#playSound(double, double, double, String, float, float, boolean)} and other methods. * {@link World#playSound(double, double, double, String, float, float, boolean)} and other methods.
*/ */
public String getVariationSound(Item item, int metadata); public String getVariationSound(Item item, int metadata);
/** /**
* @return A list of all registered group names, sorted alphabetically. * @return A list of all registered group names, sorted alphabetically.
*/ */
List<String> getSortedGroupNames(); List<String> getSortedGroupNames();
/* Setters */ /* Setters */
/** /**
* Adds a variation to the registry. * Adds a variation to the registry.
* *
* @param groupName * @param groupName The name of the group to add to.
* The name of the group to add to. * @param block The block of the variation
* @param block * @param metadata The metadata of the variation
* The block of the variation * @param order The order of the variation in the list of all variations in the group. Higher numbers are sorted
* @param metadata * at the end.
* The metadata of the variation */
* @param order void addVariation(String groupName, Block block, int metadata, int order);
* The order of the variation in the list of all variations in the group. Higher numbers are sorted at the end.
*/
void addVariation(String groupName, Block block, int metadata, int order);
/** /**
* Adds a variation to the registry. * Adds a variation to the registry.
* *
* @param groupName * @param groupName The name of the group to add to
* The name of the group to add to * @param variation The {@link ICarvingVariation} to add
* @param variation */
* The {@link ICarvingVariation} to add void addVariation(String groupName, ICarvingVariation variation);
*/
void addVariation(String groupName, ICarvingVariation variation);
/** /**
* Adds a group to the registry. * Adds a group to the registry.
* *
* @param group * @param group The {@link ICarvingGroup} to add.
* The {@link ICarvingGroup} to add. */
*/ void addGroup(ICarvingGroup group);
void addGroup(ICarvingGroup group);
/** /**
* Removes a group from the registry. * Removes a group from the registry.
* <p> * <p>
* This in effect removes all variations associated with the group, though they are not explicitly removed from the object. If you maintain a reference to the {@link ICarvingGroup} that is * This in effect removes all variations associated with the group, though they are not explicitly removed from the
* removed, it will still contain its variations. * object. If you maintain a reference to the {@link ICarvingGroup} that is removed, it will still contain its
* * variations.
* @param groupName *
* The name of the group to remove. * @param groupName The name of the group to remove.
* @return The {@link ICarvingGroup} that was removed. * @return The {@link ICarvingGroup} that was removed.
*/ */
ICarvingGroup removeGroup(String groupName); ICarvingGroup removeGroup(String groupName);
/** /**
* Removes a varaition with the passed {@link Block} and metadata from the registry. If this variation is registered with mutiple groups, it will remove it from all of them. * Removes a varaition with the passed {@link Block} and metadata from the registry. If this variation is registered
* * with mutiple groups, it will remove it from all of them.
* @param block *
* The {@link Block} of the {@link ICarvingVariation variation} * @param block The {@link Block} of the {@link ICarvingVariation variation}
* @param metadata * @param metadata The metadata of the {@link ICarvingVariation variation}
* The metadata of the {@link ICarvingVariation variation} * @return The ICarvingVariation that was removed. Null if nothing was removed.
* @return The ICarvingVariation that was removed. Null if nothing was removed. */
*/ ICarvingVariation removeVariation(Block block, int metadata);
ICarvingVariation removeVariation(Block block, int metadata);
/** /**
* Removes a varaition with the passed {@link Block} and metadata from the registry, but only from the specified {@link ICarvingGroup} name. * Removes a varaition with the passed {@link Block} and metadata from the registry, but only from the specified
* * {@link ICarvingGroup} name.
* @param block *
* The {@link Block} of the {@link ICarvingVariation variation} * @param block The {@link Block} of the {@link ICarvingVariation variation}
* @param metadata * @param metadata The metadata of the {@link ICarvingVariation variation}
* The metadata of the {@link ICarvingVariation variation} * @param group The name of the group that the variation should be removed from
* @param group * @return The ICarvingVariation that was removed. Null if nothing was removed.
* The name of the group that the variation should be removed from */
* @return The ICarvingVariation that was removed. Null if nothing was removed. ICarvingVariation removeVariation(Block block, int metadata, String group);
*/
ICarvingVariation removeVariation(Block block, int metadata, String group);
/** /**
* Registers a group to an oredict name. * Registers a group to an oredict name.
* <p> * <p>
* Doing this means that all blocks that are registered to this oredict name will act as if they are a part of this group. * Doing this means that all blocks that are registered to this oredict name will act as if they are a part of this
* * group.
* @param groupName *
* The name of the group * @param groupName The name of the group
* @param oreName * @param oreName The oredict name
* The oredict name */
*/ void registerOre(String groupName, String oreName);
void registerOre(String groupName, String oreName);
/** /**
* Sets the sound resource for a group. * Sets the sound resource for a group.
* <p> * <p>
* This is the sound that is used when a block from this group is chiseled. <br/> * This is the sound that is used when a block from this group is chiseled. <br/>
* Does <i>not</i> need to be explicitly set. * Does <i>not</i> need to be explicitly set.
* *
* @param name * @param name The name of the group
* The name of the group * @param sound The resource string for the sound
* @param sound */
* The resource string for the sound void setVariationSound(String name, String sound);
*/
void setVariationSound(String name, String sound);
} }
@@ -8,31 +8,31 @@ import net.minecraft.item.Item;
*/ */
public interface ICarvingVariation { public interface ICarvingVariation {
/** /**
* The base block of this variation. * The base block of this variation.
* *
* @return A {@link Block} that is the base of this variation * @return A {@link Block} that is the base of this variation
*/ */
Block getBlock(); Block getBlock();
/** /**
* The metadata of this variation * The metadata of this variation
* *
* @return An int representing the metadata of this variation's {@link Block} in the world. * @return An int representing the metadata of this variation's {@link Block} in the world.
*/ */
int getBlockMeta(); int getBlockMeta();
/** /**
* The item metadata of this variation * The item metadata of this variation
* *
* @return An int representing the metadata of this variations's {@link Item}. * @return An int representing the metadata of this variations's {@link Item}.
*/ */
int getItemMeta(); int getItemMeta();
/** /**
* The "order" of this variation. Represents its position in the list of variations held by a group. * The "order" of this variation. Represents its position in the list of variations held by a group.
* *
* @return An integer to represent the position of this variation in the list of all variations in the group * @return An integer to represent the position of this variation in the list of all variations in the group
*/ */
int getOrder(); int getOrder();
} }
@@ -6,15 +6,17 @@ import net.minecraftforge.common.util.ForgeDirection;
public interface IChiselMode { public interface IChiselMode {
/** /**
* NOTE: This method is responsible for increasing the "Blocks Chiseled" statistic found in the Statistics class. * NOTE: This method is responsible for increasing the "Blocks Chiseled" statistic found in the Statistics class.
*/ */
void chiselAll(EntityPlayer player, World world, int x, int y, int z, ForgeDirection side, ICarvingVariation variation); void chiselAll(EntityPlayer player, World world, int x, int y, int z, ForgeDirection side,
ICarvingVariation variation);
/** /**
* Implemented implicitly by enums. If your IChiselMode is not an enum constant, this needs to be implemented explicitly. * Implemented implicitly by enums. If your IChiselMode is not an enum constant, this needs to be implemented
* * explicitly.
* @return The name of the mode. *
*/ * @return The name of the mode.
String name(); */
String name();
} }
@@ -1,14 +1,14 @@
package com.cricketcraft.chisel.api.carving; package com.cricketcraft.chisel.api.carving;
import team.chisel.ctmlib.ISubmapManager;
import com.cricketcraft.chisel.api.rendering.TextureType; import com.cricketcraft.chisel.api.rendering.TextureType;
import team.chisel.ctmlib.ISubmapManager;
public interface IVariationInfo extends ISubmapManager { public interface IVariationInfo extends ISubmapManager {
ICarvingVariation getVariation(); ICarvingVariation getVariation();
String getDescription(); String getDescription();
TextureType getType(); TextureType getType();
} }
@@ -1,6 +1,5 @@
package com.cricketcraft.chisel.api.carving; package com.cricketcraft.chisel.api.carving;
import team.chisel.ctmlib.ISubmapManager;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -11,68 +10,70 @@ import net.minecraftforge.common.util.ForgeDirection;
import com.cricketcraft.chisel.api.rendering.TextureType; import com.cricketcraft.chisel.api.rendering.TextureType;
import team.chisel.ctmlib.ISubmapManager;
public class VariationInfoBase implements IVariationInfo { public class VariationInfoBase implements IVariationInfo {
private ICarvingVariation variation; private ICarvingVariation variation;
private String unlocDesc; private String unlocDesc;
private ISubmapManager manager; private ISubmapManager manager;
private TextureType type; private TextureType type;
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager manager) { public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager manager) {
this(variation, unlocDesc, manager, TextureType.CUSTOM); this(variation, unlocDesc, manager, TextureType.CUSTOM);
} }
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager manager, TextureType type) { public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager manager, TextureType type) {
this.variation = variation; this.variation = variation;
this.unlocDesc = unlocDesc; this.unlocDesc = unlocDesc;
this.manager = manager; this.manager = manager;
this.type = type; this.type = type;
} }
@Override @Override
public ICarvingVariation getVariation() { public ICarvingVariation getVariation() {
return variation; return variation;
} }
@Override @Override
public String getDescription() { public String getDescription() {
return StatCollector.translateToLocal(unlocDesc); return StatCollector.translateToLocal(unlocDesc);
} }
@Override @Override
public TextureType getType() { public TextureType getType() {
return type; return type;
} }
// ISubmapManager delegation // ISubmapManager delegation
@Override @Override
public IIcon getIcon(int side, int meta) { public IIcon getIcon(int side, int meta) {
return manager.getIcon(side, meta); return manager.getIcon(side, meta);
} }
@Override @Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return manager.getIcon(world, x, y, z, side); return manager.getIcon(world, x, y, z, side);
} }
@Override @Override
public void registerIcons(String modName, Block block, IIconRegister register) { public void registerIcons(String modName, Block block, IIconRegister register) {
manager.registerIcons(modName, block, register); manager.registerIcons(modName, block, register);
} }
@Override @Override
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) { public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
return manager.createRenderContext(rendererOld, block, world); return manager.createRenderContext(rendererOld, block, world);
} }
@Override @Override
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) { public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
manager.preRenderSide(renderer, world, x, y, z, side); manager.preRenderSide(renderer, world, x, y, z, side);
} }
@Override @Override
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) { public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
manager.postRenderSide(renderer, world, x, y, z, side); manager.postRenderSide(renderer, world, x, y, z, side);
} }
} }
@@ -4,4 +4,3 @@ package com.cricketcraft.chisel.api.carving;
import com.cricketcraft.chisel.api.ChiselAPIProps; import com.cricketcraft.chisel.api.ChiselAPIProps;
import cpw.mods.fml.common.API; import cpw.mods.fml.common.API;
@@ -2,4 +2,3 @@
package com.cricketcraft.chisel.api; package com.cricketcraft.chisel.api;
import cpw.mods.fml.common.API; import cpw.mods.fml.common.API;
@@ -2,6 +2,6 @@ package com.cricketcraft.chisel.api.rendering;
public class ClientUtils { public class ClientUtils {
public static int renderCTMId; public static int renderCTMId;
} }
@@ -15,17 +15,16 @@ import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple; import org.apache.commons.lang3.tuple.Triple;
import team.chisel.ctmlib.CTM;
import team.chisel.ctmlib.ISubmapManager;
import team.chisel.ctmlib.RenderBlocksCTM;
import team.chisel.ctmlib.RenderBlocksColumn;
import team.chisel.ctmlib.TextureSubmap;
import com.cricketcraft.chisel.api.carving.CarvableHelper; import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.ICarvingVariation; import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.ctmlib.CTM;
import team.chisel.ctmlib.ISubmapManager;
import team.chisel.ctmlib.RenderBlocksCTM;
import team.chisel.ctmlib.RenderBlocksColumn;
import team.chisel.ctmlib.TextureSubmap;
/** /**
* Handles all default {@link ISubmapManager} behavior * Handles all default {@link ISubmapManager} behavior
@@ -33,7 +32,7 @@ import cpw.mods.fml.relauncher.SideOnly;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public enum TextureType { public enum TextureType {
// @formatter:off // @formatter:off
TOPBOTSIDE("top", "bottom", "side"){ TOPBOTSIDE("top", "bottom", "side"){
@Override @Override
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) { protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
@@ -43,7 +42,7 @@ public enum TextureType {
register.registerIcon(modName + ":" + texturePath + "-top") register.registerIcon(modName + ":" + texturePath + "-top")
}; };
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
IIcon[] icons = (IIcon[]) cachedObject; IIcon[] icons = (IIcon[]) cachedObject;
@@ -58,7 +57,7 @@ public enum TextureType {
register.registerIcon(modName + ":" + texturePath + "-top") register.registerIcon(modName + ":" + texturePath + "-top")
}; };
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
IIcon[] icons = (IIcon[]) cachedObject; IIcon[] icons = (IIcon[]) cachedObject;
@@ -66,18 +65,18 @@ public enum TextureType {
} }
}, },
CTMV("ctmv", "top"){ CTMV("ctmv", "top"){
@Override @Override
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) { protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return Pair.of(new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-ctmv"), 2, 2), register.registerIcon(modName + ":" + texturePath + "-top")); return Pair.of(new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-ctmv"), 2, 2), register.registerIcon(modName + ":" + texturePath + "-top"));
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject; Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject;
return side < 2 ? data.getRight() : data.getLeft().getSubIcon(0, 0); return side < 2 ? data.getRight() : data.getLeft().getSubIcon(0, 0);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject; Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject;
@@ -97,13 +96,13 @@ public enum TextureType {
return map.getSubIcon(1, 0); return map.getSubIcon(1, 0);
return map.getSubIcon(0, 0); return map.getSubIcon(0, 0);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) { protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
RenderBlocksColumn ret = theRenderBlocksColumn; RenderBlocksColumn ret = theRenderBlocksColumn;
Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject; Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject;
ret.blockAccess = world; ret.blockAccess = world;
ret.renderMaxX = 1.0; ret.renderMaxX = 1.0;
ret.renderMaxY = 1.0; ret.renderMaxY = 1.0;
@@ -118,13 +117,13 @@ public enum TextureType {
@Override @Override
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) { protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return Pair.of(new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-ctmh"), 2, 2), register.registerIcon(modName + ":" + texturePath + "-top")); return Pair.of(new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-ctmh"), 2, 2), register.registerIcon(modName + ":" + texturePath + "-top"));
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return CTMV.getIcon(variation, cachedObject, side, meta); return CTMV.getIcon(variation, cachedObject, side, meta);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject; Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject;
@@ -144,7 +143,7 @@ public enum TextureType {
p = ctm.isConnected(world, x, y, z - 1, side, block, meta); p = ctm.isConnected(world, x, y, z - 1, side, block, meta);
n = ctm.isConnected(world, x, y, z + 1, side, block, meta); n = ctm.isConnected(world, x, y, z + 1, side, block, meta);
} }
TextureSubmap map = data.getLeft(); TextureSubmap map = data.getLeft();
if (p && n) if (p && n)
return map.getSubIcon(1, 0); return map.getSubIcon(1, 0);
@@ -160,14 +159,14 @@ public enum TextureType {
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) { protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-v9"), 3, 3); return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-v9"), 3, 3);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return ((TextureSubmap)cachedObject).getSubIcon(1, 1); return ((TextureSubmap)cachedObject).getSubIcon(1, 1);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
return getVIcon(this, (TextureSubmap) cachedObject, x, y, z, side); return getVIcon(this, (TextureSubmap) cachedObject, x, y, z, side);
} }
}, },
@@ -176,12 +175,12 @@ public enum TextureType {
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) { protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-v4"), 2, 2); return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-v4"), 2, 2);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return ((TextureSubmap)cachedObject).getSubIcon(0, 0); return ((TextureSubmap)cachedObject).getSubIcon(0, 0);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
return getVIcon(this, (TextureSubmap) cachedObject, x, y, z, side); return getVIcon(this, (TextureSubmap) cachedObject, x, y, z, side);
@@ -197,12 +196,12 @@ public enum TextureType {
new TextureSubmap(baseIcon, 2, 2) new TextureSubmap(baseIcon, 2, 2)
); );
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return ((Triple<IIcon, ?, ?>)cachedObject).getLeft(); return ((Triple<IIcon, ?, ?>)cachedObject).getLeft();
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) { protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
@@ -221,13 +220,13 @@ public enum TextureType {
@Override @Override
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) { protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r16"), 4, 4); return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r16"), 4, 4);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return V9.getIcon(variation, cachedObject, side, meta); return V9.getIcon(variation, cachedObject, side, meta);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
return getRIcon(this, (TextureSubmap) cachedObject, x, y, z, side); return getRIcon(this, (TextureSubmap) cachedObject, x, y, z, side);
@@ -237,30 +236,30 @@ public enum TextureType {
@Override @Override
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) { protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r9"), 3, 3); return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r9"), 3, 3);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return V9.getIcon(variation, cachedObject, side, meta); return V9.getIcon(variation, cachedObject, side, meta);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
return getRIcon(this, (TextureSubmap) cachedObject, x, y, z, side); return getRIcon(this, (TextureSubmap) cachedObject, x, y, z, side);
} }
}, },
R4("r4"){ R4("r4"){
@Override @Override
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) { protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r4"), 2, 2); return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r4"), 2, 2);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return V4.getIcon(variation, cachedObject, side, meta); return V4.getIcon(variation, cachedObject, side, meta);
} }
@Override @Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
return getRIcon(this, (TextureSubmap) cachedObject, x, y, z, side); return getRIcon(this, (TextureSubmap) cachedObject, x, y, z, side);
@@ -268,9 +267,9 @@ public enum TextureType {
}, },
NORMAL, NORMAL,
CUSTOM; CUSTOM;
/* Some util stuff for shared code between v* and r* */ /* Some util stuff for shared code between v* and r* */
public static IIcon getVIcon(TextureType type, TextureSubmap map, int x, int y, int z, int side) { public static IIcon getVIcon(TextureType type, TextureSubmap map, int x, int y, int z, int side) {
int variationSize = (type == TextureType.V9) ? 3 : 2; int variationSize = (type == TextureType.V9) ? 3 : 2;
@@ -305,23 +304,23 @@ public enum TextureType {
return map.getSubIcon(index % variationSize, index / variationSize); return map.getSubIcon(index % variationSize, index / variationSize);
} }
public static IIcon getRIcon(TextureType type, TextureSubmap map, int x, int y, int z, int side) { public static IIcon getRIcon(TextureType type, TextureSubmap map, int x, int y, int z, int side) {
rand.setSeed(getCoordinateRandom(x, y, z)); rand.setSeed(getCoordinateRandom(x, y, z));
rand.nextBoolean(); rand.nextBoolean();
int size = type == TextureType.R4 ? 2 : type == TextureType.R9 ? 3 : 4; int size = type == TextureType.R4 ? 2 : type == TextureType.R9 ? 3 : 4;
return map.getSubIcon(rand.nextInt(size), rand.nextInt(size)); return map.getSubIcon(rand.nextInt(size), rand.nextInt(size));
} }
private static long getCoordinateRandom(int x, int y, int z) { private static long getCoordinateRandom(int x, int y, int z) {
// MC 1.8 code... // MC 1.8 code...
long l = (x * 3129871) ^ z * 116129781L ^ y; long l = (x * 3129871) ^ z * 116129781L ^ y;
l = l * l * 42317861L + l * 11L; l = l * l * 42317861L + l * 11L;
return l; return l;
} }
/* End of that mess */ /* End of that mess */
private static final TextureType[] VALUES; private static final TextureType[] VALUES;
private static final CTM ctm = CTM.getInstance(); private static final CTM ctm = CTM.getInstance();
private static final Random rand = new Random(); private static final Random rand = new Random();
@@ -338,31 +337,31 @@ public enum TextureType {
private TextureType(String... suffixes) { private TextureType(String... suffixes) {
this.suffixes = suffixes.length == 0 ? new String[] { "" } : suffixes; this.suffixes = suffixes.length == 0 ? new String[] { "" } : suffixes;
} }
private static void initStatics() { private static void initStatics() {
if (theRenderBlocksCTM == null) { if (theRenderBlocksCTM == null) {
theRenderBlocksCTM = new RenderBlocksCTM(); theRenderBlocksCTM = new RenderBlocksCTM();
theRenderBlocksColumn = new RenderBlocksColumn(); theRenderBlocksColumn = new RenderBlocksColumn();
} }
} }
public ISubmapManager createManagerFor(ICarvingVariation variation, String texturePath) { public ISubmapManager createManagerFor(ICarvingVariation variation, String texturePath) {
return new SubmapManagerDefault(this, variation, texturePath); return new SubmapManagerDefault(this, variation, texturePath);
} }
public ISubmapManager createManagerFor(ICarvingVariation variation, Block block, int meta) { public ISubmapManager createManagerFor(ICarvingVariation variation, Block block, int meta) {
return new SubmapManagerExistingIcon(this, variation, block, meta); return new SubmapManagerExistingIcon(this, variation, block, meta);
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) { protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return register.registerIcon(modName + ":" + texturePath); return register.registerIcon(modName + ":" + texturePath);
} }
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return (IIcon) cachedObject; return (IIcon) cachedObject;
} }
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) { protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, IBlockAccess world, int x, int y, int z, int side, int meta) {
return getIcon(variation, cachedObject, side, meta); return getIcon(variation, cachedObject, side, meta);
} }
@@ -371,7 +370,7 @@ public enum TextureType {
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) { protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
return rendererOld; return rendererOld;
} }
public static TextureType getTypeFor(CarvableHelper inst, String modid, String path) { public static TextureType getTypeFor(CarvableHelper inst, String modid, String path) {
if (path == null) { if (path == null) {
return CUSTOM; return CUSTOM;
@@ -389,7 +388,7 @@ public enum TextureType {
} }
return CUSTOM; return CUSTOM;
} }
// This is ugly, but faster than class.getResource // This is ugly, but faster than class.getResource
private static boolean exists(String modid, String path, String postfix) { private static boolean exists(String modid, String path, String postfix) {
ResourceLocation rl = new ResourceLocation(modid, "textures/blocks/" + path + postfix + ".png"); ResourceLocation rl = new ResourceLocation(modid, "textures/blocks/" + path + postfix + ".png");
@@ -400,18 +399,18 @@ public enum TextureType {
return false; return false;
} }
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public abstract static class AbstractSubmapManager implements ISubmapManager { public abstract static class AbstractSubmapManager implements ISubmapManager {
protected final TextureType type; protected final TextureType type;
protected ICarvingVariation variation; protected ICarvingVariation variation;
protected Object cachedObject; protected Object cachedObject;
private AbstractSubmapManager(TextureType type, ICarvingVariation variation) { private AbstractSubmapManager(TextureType type, ICarvingVariation variation) {
this.type = type; this.type = type;
this.variation = variation; this.variation = variation;
} }
@Override @Override
public IIcon getIcon(int side, int meta) { public IIcon getIcon(int side, int meta) {
return type.getIcon(variation, cachedObject, side, meta); return type.getIcon(variation, cachedObject, side, meta);
@@ -421,7 +420,7 @@ public enum TextureType {
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return type.getIcon(variation, cachedObject, world, x, y, z, side, world.getBlockMetadata(x, y, z)); return type.getIcon(variation, cachedObject, world, x, y, z, side, world.getBlockMetadata(x, y, z));
} }
@Override @Override
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) { public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
initStatics(); initStatics();
@@ -429,15 +428,15 @@ public enum TextureType {
rb.setRenderBoundsFromBlock(block); rb.setRenderBoundsFromBlock(block);
return rb; return rb;
} }
@Override @Override
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) { public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
} }
@Override @Override
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) { public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
} }
public Object getCachedObject() { public Object getCachedObject() {
return cachedObject; return cachedObject;
} }
@@ -447,7 +446,7 @@ public enum TextureType {
private static class SubmapManagerDefault extends AbstractSubmapManager { private static class SubmapManagerDefault extends AbstractSubmapManager {
private String texturePath; private String texturePath;
private SubmapManagerDefault(TextureType type, ICarvingVariation variation, String texturePath) { private SubmapManagerDefault(TextureType type, ICarvingVariation variation, String texturePath) {
super(type, variation); super(type, variation);
this.texturePath = texturePath; this.texturePath = texturePath;
@@ -458,24 +457,24 @@ public enum TextureType {
cachedObject = type.registerIcons(variation, modName, texturePath, register); cachedObject = type.registerIcons(variation, modName, texturePath, register);
} }
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private static class SubmapManagerExistingIcon extends AbstractSubmapManager { private static class SubmapManagerExistingIcon extends AbstractSubmapManager {
private Block block; private Block block;
private int meta; private int meta;
private SubmapManagerExistingIcon(TextureType type, ICarvingVariation variation, Block block, int meta) { private SubmapManagerExistingIcon(TextureType type, ICarvingVariation variation, Block block, int meta) {
super(type, variation); super(type, variation);
this.block = block; this.block = block;
this.meta = meta; this.meta = meta;
} }
@Override @Override
public IIcon getIcon(int side, int meta) { public IIcon getIcon(int side, int meta) {
return block.getIcon(side, this.meta); return block.getIcon(side, this.meta);
} }
@Override @Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return getIcon(side, world.getBlockMetadata(x, y, z)); return getIcon(side, world.getBlockMetadata(x, y, z));
@@ -485,4 +484,4 @@ public enum TextureType {
public void registerIcons(String modName, Block block, IIconRegister register) { public void registerIcons(String modName, Block block, IIconRegister register) {
} }
} }
} }
@@ -4,4 +4,3 @@ package com.cricketcraft.chisel.api.rendering;
import com.cricketcraft.chisel.api.ChiselAPIProps; import com.cricketcraft.chisel.api.ChiselAPIProps;
import cpw.mods.fml.common.API; import cpw.mods.fml.common.API;
@@ -2,107 +2,117 @@ package team.chisel;
import java.util.HashMap; import java.util.HashMap;
import team.chisel.utils.General;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import team.chisel.utils.General;
public class BlockNameConversion { public class BlockNameConversion {
static final private HashMap<String, String> namingConversion = new HashMap<String, String>(); static final private HashMap<String, String> namingConversion = new HashMap<String, String>();
public static class NameConversions { public static class NameConversions {
public final static int MAX = 5; public final static int MAX = 5;
protected static String conversion(String oldname, int step) { protected static String conversion(String oldname, int step) {
oldname = General.cleanTags(oldname); oldname = General.cleanTags(oldname);
String newname = null; String newname = null;
switch (step) { switch (step) {
case 0: // lookup list case 0: // lookup list
return namingConversion.get(oldname); return namingConversion.get(oldname);
case 1: // remove Chisel: case 1: // remove Chisel:
if (oldname.startsWith("Chisel:")) { if (oldname.startsWith("Chisel:")) {
newname = oldname.replaceAll("(?i)" + "Chisel:", ""); newname = oldname.replaceAll("(?i)" + "Chisel:", "");
} }
return newname; return newname;
case 2: // rename "marbleSlab" -> "marble_slab", "redstone" -> case 2: // rename "marbleSlab" -> "marble_slab", "redstone" ->
// "redstone_block" // "redstone_block"
newname = oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2").toLowerCase(); newname = oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2")
.toLowerCase();
if (newname.startsWith("block_")) { if (newname.startsWith("block_")) {
newname = newname.replaceFirst("block_([a-z_]+)", "$1_block"); newname = newname.replaceFirst("block_([a-z_]+)", "$1_block");
} else if (newname.startsWith("snakestone_")) { } else if (newname.startsWith("snakestone_")) {
newname = newname.replaceFirst("snakestone_([a-z_]+)", "$1_snakestone"); newname = newname.replaceFirst("snakestone_([a-z_]+)", "$1_snakestone");
} }
return newname; return newname;
case 3: // rename "wood-dark-oak" -> "dark_oak_planks" case 3: // rename "wood-dark-oak" -> "dark_oak_planks"
newname = oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2").toLowerCase().replace('-', '_'); newname = oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2")
if (newname.contains("wood_")) { .toLowerCase()
newname = newname.replaceFirst("wood_([a-z_]+)", "$1_planks"); .replace('-', '_');
} if (newname.contains("wood_")) {
return newname; newname = newname.replaceFirst("wood_([a-z_]+)", "$1_planks");
case (MAX - 1): // ALWAYS last: rename "blockYxx" -> "yxx" (e.g. }
// "dirt" -> "dirt"). return newname;
// This can be dangerous in cases like "carpet" (a block) -> case (MAX - 1): // ALWAYS last: rename "blockYxx" -> "yxx" (e.g.
// "carpet" (NO block) // "dirt" -> "dirt").
return oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2").toLowerCase().replaceFirst("block_", ""); // This can be dangerous in cases like "carpet" (a block) ->
default: // "carpet" (NO block)
throw new IndexOutOfBoundsException("conversion got invalid parameter step=" + step); return oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2")
} .toLowerCase()
} .replaceFirst("block_", "");
} default:
throw new IndexOutOfBoundsException("conversion got invalid parameter step=" + step);
}
}
}
static public void init() { static public void init() {
namingConversion.put("blockCobble", "cobblestone"); namingConversion.put("blockCobble", "cobblestone");
namingConversion.put("iron", "iron_block"); namingConversion.put("iron", "iron_block");
namingConversion.put("gold", "gold_block"); namingConversion.put("gold", "gold_block");
namingConversion.put("diamond", "diamond_block"); namingConversion.put("diamond", "diamond_block");
namingConversion.put("lightstone", "glowstone"); namingConversion.put("lightstone", "glowstone");
namingConversion.put("lapis", "lapis_block"); namingConversion.put("lapis", "lapis_block");
namingConversion.put("emerald", "emerald_block"); namingConversion.put("emerald", "emerald_block");
namingConversion.put("hellrock", "netherrack"); namingConversion.put("hellrock", "netherrack");
namingConversion.put("stoneMoss", "mossy_cobblestone"); namingConversion.put("stoneMoss", "mossy_cobblestone");
namingConversion.put("stoneBrick", "stonebrick"); namingConversion.put("stoneBrick", "stonebrick");
namingConversion.put("fenceIron", "iron_bars"); namingConversion.put("fenceIron", "iron_bars");
namingConversion.put("fantasy", "fantasyblock"); namingConversion.put("fantasy", "fantasyblock");
namingConversion.put("carpetFloor", "carpet"); namingConversion.put("carpetFloor", "carpet");
namingConversion.put("temple", "templeblock"); namingConversion.put("temple", "templeblock");
namingConversion.put("templeMossy", "mossy_templeblock"); namingConversion.put("templeMossy", "mossy_templeblock");
namingConversion.put("factory", "factoryblock"); namingConversion.put("factory", "factoryblock");
namingConversion.put("laboratory", "laboratoryblock"); namingConversion.put("laboratory", "laboratoryblock");
// "LightGray" is unfortunately converted to "light_gray" // "LightGray" is unfortunately converted to "light_gray"
namingConversion.put("stainedGlassLightGray", "stained_glass_lightgray"); namingConversion.put("stainedGlassLightGray", "stained_glass_lightgray");
namingConversion.put("stainedGlassPaneLightGray", "stained_glass_pane_lightgray"); namingConversion.put("stainedGlassPaneLightGray", "stained_glass_pane_lightgray");
namingConversion.put("blockTemple", "templeblock"); namingConversion.put("blockTemple", "templeblock");
namingConversion.put("stoneBrick", "stonebricksmooth"); namingConversion.put("stoneBrick", "stonebricksmooth");
namingConversion.put("blockTempleMossy", "mossy_templeblock"); namingConversion.put("blockTempleMossy", "mossy_templeblock");
namingConversion.put("blockFactory", "factoryblock"); namingConversion.put("blockFactory", "factoryblock");
namingConversion.put("blockFft", "fantasyblock"); namingConversion.put("blockFft", "fantasyblock");
namingConversion.put("blockCarpetFloor", "carpet"); namingConversion.put("blockCarpetFloor", "carpet");
namingConversion.put("blockLaboratory", "laboratoryblock"); namingConversion.put("blockLaboratory", "laboratoryblock");
} }
public static Item findItem(String oldname) { public static Item findItem(String oldname) {
FMLLog.getLogger().trace("[Chisel 2] findItem() START " + oldname); FMLLog.getLogger()
Item item = null; .trace("[Chisel 2] findItem() START " + oldname);
for (int i = 0; i < NameConversions.MAX && item == null; i++) { Item item = null;
FMLLog.getLogger().trace("[Chisel 2] findItem() Checking for " + NameConversions.conversion(oldname, i)); for (int i = 0; i < NameConversions.MAX && item == null; i++) {
item = GameRegistry.findItem(Chisel.MOD_ID, NameConversions.conversion(oldname, i)); FMLLog.getLogger()
} .trace("[Chisel 2] findItem() Checking for " + NameConversions.conversion(oldname, i));
item = GameRegistry.findItem(Chisel.MOD_ID, NameConversions.conversion(oldname, i));
}
return item; return item;
} }
public static Block findBlock(String oldname) { public static Block findBlock(String oldname) {
FMLLog.getLogger().trace("[Chisel 2] findBlock() START: " + oldname); FMLLog.getLogger()
Block block = null; .trace("[Chisel 2] findBlock() START: " + oldname);
for (int i = 0; i < NameConversions.MAX && block == null; i++) { Block block = null;
FMLLog.getLogger().trace("[Chisel 2] findBlock() Checking for " + NameConversions.conversion(oldname, i)); for (int i = 0; i < NameConversions.MAX && block == null; i++) {
block = GameRegistry.findBlock(Chisel.MOD_ID, NameConversions.conversion(oldname, i)); FMLLog.getLogger()
} .trace("[Chisel 2] findBlock() Checking for " + NameConversions.conversion(oldname, i));
block = GameRegistry.findBlock(Chisel.MOD_ID, NameConversions.conversion(oldname, i));
}
return block; return block;
} }
} }
+151 -135
View File
@@ -10,23 +10,6 @@ import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import team.chisel.block.BlockCarvable;
import team.chisel.carving.Carving;
import team.chisel.compat.Compatibility;
import team.chisel.compat.IMCHandler;
import team.chisel.compat.fmp.FMPCompat;
import team.chisel.config.Configurations;
import team.chisel.entity.EntityChiselSnowman;
import team.chisel.init.ChiselBlocks;
import team.chisel.init.TabsInit;
import team.chisel.item.ItemCarvable;
import team.chisel.item.chisel.ChiselController;
import team.chisel.network.ChiselGuiHandler;
import team.chisel.network.PacketHandler;
import team.chisel.proxy.CommonProxy;
import team.chisel.utils.General;
import team.chisel.world.GeneratorChisel;
import com.cricketcraft.chisel.api.ChiselAPIProps; import com.cricketcraft.chisel.api.ChiselAPIProps;
import com.cricketcraft.chisel.api.Statistics; import com.cricketcraft.chisel.api.Statistics;
import com.cricketcraft.chisel.api.carving.CarvableHelper; import com.cricketcraft.chisel.api.carving.CarvableHelper;
@@ -52,150 +35,183 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.Type; import cpw.mods.fml.common.registry.GameRegistry.Type;
import team.chisel.block.BlockCarvable;
import team.chisel.carving.Carving;
import team.chisel.compat.Compatibility;
import team.chisel.compat.IMCHandler;
import team.chisel.compat.fmp.FMPCompat;
import team.chisel.config.Configurations;
import team.chisel.entity.EntityChiselSnowman;
import team.chisel.init.ChiselBlocks;
import team.chisel.init.TabsInit;
import team.chisel.item.ItemCarvable;
import team.chisel.item.chisel.ChiselController;
import team.chisel.network.ChiselGuiHandler;
import team.chisel.network.PacketHandler;
import team.chisel.proxy.CommonProxy;
import team.chisel.utils.General;
import team.chisel.world.GeneratorChisel;
@Mod(modid = Chisel.MOD_ID, name = Chisel.MOD_NAME, version = Chisel.VERSION, guiFactory = "team.chisel.client.gui.GuiFactory", dependencies = "after:EE3;after:ForgeMultipart;after:Thaumcraft;after:appliedenergistics2;after:Railcraft;after:AWWayofTime;after:TwilightForest") @Mod(
modid = Chisel.MOD_ID,
name = Chisel.MOD_NAME,
version = Chisel.VERSION,
guiFactory = "team.chisel.client.gui.GuiFactory",
dependencies = "after:EE3;after:ForgeMultipart;after:Thaumcraft;after:appliedenergistics2;after:Railcraft;after:AWWayofTime;after:TwilightForest")
public class Chisel { public class Chisel {
public static final String MOD_ID = "chisel"; public static final String MOD_ID = "chisel";
public static final BlockCarvable.SoundType soundTempleFootstep = new BlockCarvable.SoundType("dig.stone", MOD_ID + ":step.templeblock", 1.0f, 1.0f); public static final BlockCarvable.SoundType soundTempleFootstep = new BlockCarvable.SoundType(
public static final String MOD_NAME = "Chisel"; "dig.stone",
public static final String VERSION = "GRADLETOKEN_VERSION"; MOD_ID + ":step.templeblock",
public static final BlockCarvable.SoundType soundHolystoneFootstep = new BlockCarvable.SoundType("holystone", 1.0f, 1.0f); 1.0f,
public static final BlockCarvable.SoundType soundMetalFootstep = new BlockCarvable.SoundType("metal", 1.0f, 1.0f); 1.0f);
public static boolean multipartLoaded = false; public static final String MOD_NAME = "Chisel";
public static boolean gtnhLoaded = false; public static final String VERSION = "GRADLETOKEN_VERSION";
public static int renderEldritchId; public static final BlockCarvable.SoundType soundHolystoneFootstep = new BlockCarvable.SoundType(
public static int renderAutoChiselId; "holystone",
public static int renderGlowId; 1.0f,
public static int renderLayeredId; 1.0f);
public static int roadLineId; public static final BlockCarvable.SoundType soundMetalFootstep = new BlockCarvable.SoundType("metal", 1.0f, 1.0f);
public static boolean multipartLoaded = false;
public static boolean gtnhLoaded = false;
public static int renderEldritchId;
public static int renderAutoChiselId;
public static int renderGlowId;
public static int renderLayeredId;
public static int roadLineId;
public static final Logger logger = LogManager.getLogger(MOD_NAME); public static final Logger logger = LogManager.getLogger(MOD_NAME);
@Instance(MOD_ID) @Instance(MOD_ID)
public static Chisel instance; public static Chisel instance;
public Chisel() { public Chisel() {
ChiselAPIProps.MOD_ID = MOD_ID; ChiselAPIProps.MOD_ID = MOD_ID;
CarvableHelper.itemCarvableClass = ItemCarvable.class; CarvableHelper.itemCarvableClass = ItemCarvable.class;
Carving.construct(); Carving.construct();
} }
@SidedProxy(clientSide = "team.chisel.proxy.ClientProxy", serverSide = "team.chisel.proxy.CommonProxy") @SidedProxy(clientSide = "team.chisel.proxy.ClientProxy", serverSide = "team.chisel.proxy.CommonProxy")
public static CommonProxy proxy; public static CommonProxy proxy;
@EventHandler @EventHandler
public void missingMapping(FMLMissingMappingsEvent event) { public void missingMapping(FMLMissingMappingsEvent event) {
BlockNameConversion.init(); BlockNameConversion.init();
for (MissingMapping m : event.get()) { for (MissingMapping m : event.get()) {
// This bug was introduced along with Chisel 1.5.2, and was fixed in // This bug was introduced along with Chisel 1.5.2, and was fixed in
// 1.5.3. // 1.5.3.
// Ice Stairs were called null.0-7 instead of other names, and // Ice Stairs were called null.0-7 instead of other names, and
// Marble/Limestone stairs did not exist. // Marble/Limestone stairs did not exist.
// This fixes the bug. // This fixes the bug.
if (m.name.startsWith("null.") && m.name.length() == 6 && m.type == Type.BLOCK) { if (m.name.startsWith("null.") && m.name.length() == 6 && m.type == Type.BLOCK) {
m.warn();// (Action.WARN); m.warn();// (Action.WARN);
} }
// Fix mapping of snakestoneSand, snakestoneStone, limestoneStairs, // Fix mapping of snakestoneSand, snakestoneStone, limestoneStairs,
// marbleStairs when loading an old (1.5.4) save // marbleStairs when loading an old (1.5.4) save
else if (m.type == Type.BLOCK) { else if (m.type == Type.BLOCK) {
final Block block = BlockNameConversion.findBlock(m.name); final Block block = BlockNameConversion.findBlock(m.name);
if (block != null) { if (block != null) {
m.remap(block); m.remap(block);
FMLLog.getLogger().info("Remapping block " + m.name + " to " + General.getName(block)); FMLLog.getLogger()
} else .info("Remapping block " + m.name + " to " + General.getName(block));
FMLLog.getLogger().warn("Block " + m.name + " could not get remapped."); } else FMLLog.getLogger()
} else if (m.type == Type.ITEM) { .warn("Block " + m.name + " could not get remapped.");
final Item item = BlockNameConversion.findItem(m.name); } else if (m.type == Type.ITEM) {
final Item item = BlockNameConversion.findItem(m.name);
if (item != null) { if (item != null) {
m.remap(item); m.remap(item);
FMLLog.getLogger().info("Remapping item " + m.name + " to " + General.getName(item)); FMLLog.getLogger()
.info("Remapping item " + m.name + " to " + General.getName(item));
} else } else FMLLog.getLogger()
FMLLog.getLogger().warn("Item " + m.name + " could not get remapped."); .warn("Item " + m.name + " could not get remapped.");
} }
} }
} }
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent event) { public void preInit(FMLPreInitializationEvent event) {
FMLCommonHandler.instance().registerCrashCallable(new ChiselCrashCallable()); FMLCommonHandler.instance()
.registerCrashCallable(new ChiselCrashCallable());
File configFile = event.getSuggestedConfigurationFile();
Configurations.configExists = configFile.exists(); File configFile = event.getSuggestedConfigurationFile();
Configurations.config = new Configuration(configFile); Configurations.configExists = configFile.exists();
Configurations.config.load(); Configurations.config = new Configuration(configFile);
Configurations.refreshConfig(); Configurations.config.load();
Configurations.refreshConfig();
if (Loader.isModLoaded("dreamcraft")) { if (Loader.isModLoaded("dreamcraft")) {
gtnhLoaded = true; gtnhLoaded = true;
} }
TabsInit.preInit(); TabsInit.preInit();
Features.preInit(); Features.preInit();
Statistics.init(); Statistics.init();
PacketHandler.init(); PacketHandler.init();
ChiselController.INSTANCE.preInit(); ChiselController.INSTANCE.preInit();
if (Loader.isModLoaded("ForgeMultipart")) { if (Loader.isModLoaded("ForgeMultipart")) {
new FMPCompat().init(); new FMPCompat().init();
} }
proxy.preInit(); proxy.preInit();
} }
@EventHandler @EventHandler
public void init(FMLInitializationEvent event) { public void init(FMLInitializationEvent event) {
Features.init(); Features.init();
NetworkRegistry.INSTANCE.registerGuiHandler(this, new ChiselGuiHandler()); NetworkRegistry.INSTANCE.registerGuiHandler(this, new ChiselGuiHandler());
addWorldgen(Features.MARBLE, ChiselBlocks.marble, Configurations.marbleAmount); addWorldgen(Features.MARBLE, ChiselBlocks.marble, Configurations.marbleAmount);
addWorldgen(Features.LIMESTONE, ChiselBlocks.limestone, Configurations.limestoneAmount); addWorldgen(Features.LIMESTONE, ChiselBlocks.limestone, Configurations.limestoneAmount);
addWorldgen(Features.ANDESITE, ChiselBlocks.andesite, Configurations.andesiteAmount, 40, 100, 0.5); addWorldgen(Features.ANDESITE, ChiselBlocks.andesite, Configurations.andesiteAmount, 40, 100, 0.5);
addWorldgen(Features.GRANITE, ChiselBlocks.granite, Configurations.graniteAmount, 40, 100, 0.5); addWorldgen(Features.GRANITE, ChiselBlocks.granite, Configurations.graniteAmount, 40, 100, 0.5);
addWorldgen(Features.DIORITE, ChiselBlocks.diorite, Configurations.dioriteAmount, 40, 100, 0.5); addWorldgen(Features.DIORITE, ChiselBlocks.diorite, Configurations.dioriteAmount, 40, 100, 0.5);
GameRegistry.registerWorldGenerator(GeneratorChisel.INSTANCE, 1000); GameRegistry.registerWorldGenerator(GeneratorChisel.INSTANCE, 1000);
EntityRegistry.registerModEntity(EntityChiselSnowman.class, "snowman", 0, this, 80, 1, true); EntityRegistry.registerModEntity(EntityChiselSnowman.class, "snowman", 0, this, 80, 1, true);
proxy.init(); proxy.init();
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(instance); FMLCommonHandler.instance()
.bus()
.register(instance);
FMLInterModComms.sendMessage("Waila", "register", "team.chisel.compat.WailaCompat.register"); FMLInterModComms.sendMessage("Waila", "register", "team.chisel.compat.WailaCompat.register");
} }
private void addWorldgen(Features feature, Block block, double... data) { private void addWorldgen(Features feature, Block block, double... data) {
if (feature.enabled()) { if (feature.enabled()) {
if (data.length == 1) { if (data.length == 1) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0]); GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0]);
} else if (data.length > 1 && data.length < 4) { } else if (data.length > 1 && data.length < 4) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2]); GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2]);
} else if (data.length == 4) { } else if (data.length == 4) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2], data[3]); GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2], data[3]);
} }
} }
} }
@EventHandler @EventHandler
public void postInit(FMLPostInitializationEvent event) { public void postInit(FMLPostInitializationEvent event) {
TabsInit.postInit(); TabsInit.postInit();
Compatibility.init(event); Compatibility.init(event);
} }
@EventHandler @EventHandler
public void onIMC(IMCEvent event) { public void onIMC(IMCEvent event) {
for (IMCMessage msg : event.getMessages()) { for (IMCMessage msg : event.getMessages()) {
IMCHandler.INSTANCE.handleMessage(msg); IMCHandler.INSTANCE.handleMessage(msg);
} }
} }
@SubscribeEvent @SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.modID.equals("chisel")) { if (event.modID.equals("chisel")) {
Configurations.refreshConfig(); Configurations.refreshConfig();
} }
} }
} }
@@ -4,14 +4,14 @@ import cpw.mods.fml.common.ICrashCallable;
public class ChiselCrashCallable implements ICrashCallable { public class ChiselCrashCallable implements ICrashCallable {
@Override @Override
public String call() throws Exception { public String call() throws Exception {
return "Errors like \"[FML]: Unable to lookup ...\" are NOT the cause of this crash. " return "Errors like \"[FML]: Unable to lookup ...\" are NOT the cause of this crash. "
+ "You can safely ignore these errors. And update forge while you're at it."; + "You can safely ignore these errors. And update forge while you're at it.";
} }
@Override @Override
public String getLabel() { public String getLabel() {
return Chisel.MOD_NAME; return Chisel.MOD_NAME;
} }
} }
File diff suppressed because it is too large. Load diff
@@ -1,7 +1,5 @@
package team.chisel.block; package team.chisel.block;
import team.chisel.Chisel;
import team.chisel.block.tileentity.TileEntityAutoChisel;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@@ -10,67 +8,70 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import team.chisel.Chisel;
import team.chisel.block.tileentity.TileEntityAutoChisel;
public class BlockAutoChisel extends BlockContainer { public class BlockAutoChisel extends BlockContainer {
public BlockAutoChisel() { public BlockAutoChisel() {
super(Material.rock); super(Material.rock);
setHardness(1F); setHardness(1F);
setBlockBounds(0.125f, 0, 0.125f, 0.875f, 0.8125f, 0.875f); setBlockBounds(0.125f, 0, 0.125f, 0.875f, 0.8125f, 0.875f);
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return Chisel.renderAutoChiselId; return Chisel.renderAutoChiselId;
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float x1, float y1, float z1) { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float x1,
TileEntity tile = world.getTileEntity(x, y, z); float y1, float z1) {
if (world.isRemote) TileEntity tile = world.getTileEntity(x, y, z);
return true; if (world.isRemote) return true;
if (tile != null && tile instanceof TileEntityAutoChisel && !player.isSneaking()) { if (tile != null && tile instanceof TileEntityAutoChisel && !player.isSneaking()) {
player.openGui(Chisel.instance, 1, world, x, y, z); player.openGui(Chisel.instance, 1, world, x, y, z);
} }
return true; return true;
} }
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6) { public void breakBlock(World world, int x, int y, int z, Block block, int par6) {
dropItems(world, x, y, z); dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, block, par6); super.breakBlock(world, x, y, z, block, par6);
} }
private void dropItems(World world, int x, int y, int z) { private void dropItems(World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z); TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof TileEntityAutoChisel)) { if (!(tileEntity instanceof TileEntityAutoChisel)) {
return; return;
} }
TileEntityAutoChisel inventory = (TileEntityAutoChisel) world.getTileEntity(x, y, z); TileEntityAutoChisel inventory = (TileEntityAutoChisel) world.getTileEntity(x, y, z);
for (int c = 0; c < inventory.getSizeInventory(); c++) { for (int c = 0; c < inventory.getSizeInventory(); c++) {
ItemStack stack = inventory.getStackInSlot(c); ItemStack stack = inventory.getStackInSlot(c);
if (stack != null) { if (stack != null) {
dropBlockAsItem(world, x, y, z, stack); dropBlockAsItem(world, x, y, z, stack);
} }
} }
} }
@Override @Override
public TileEntity createNewTileEntity(World var1, int var2) { public TileEntity createNewTileEntity(World var1, int var2) {
return new TileEntityAutoChisel(); return new TileEntityAutoChisel();
} }
} }
@@ -8,16 +8,16 @@ import net.minecraft.world.IBlockAccess;
*/ */
public class BlockBeaconBase extends BlockCarvable { public class BlockBeaconBase extends BlockCarvable {
public BlockBeaconBase() { public BlockBeaconBase() {
super(); super();
} }
public BlockBeaconBase(Material mat) { public BlockBeaconBase(Material mat) {
super(mat); super(mat);
} }
@Override @Override
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) {
return true; return true;
} }
} }
+142 -147
View File
@@ -2,181 +2,176 @@ package team.chisel.block;
import java.util.List; import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import com.cricketcraft.chisel.api.ChiselTabs;
import com.cricketcraft.chisel.api.ICarvable; import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper; import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo; import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.api.rendering.ClientUtils; import com.cricketcraft.chisel.api.rendering.ClientUtils;
import team.chisel.Chisel;
import com.cricketcraft.chisel.api.ChiselTabs;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
import team.chisel.config.Configurations;
public class BlockCarvable extends Block implements ICarvable { public class BlockCarvable extends Block implements ICarvable {
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
private boolean isAlpha; private boolean isAlpha;
public BlockCarvable() { public BlockCarvable() {
this(Material.rock); this(Material.rock);
} }
public BlockCarvable(Material m) { public BlockCarvable(Material m) {
super(m); super(m);
if (m == Material.rock || m == Material.iron) { if (m == Material.rock || m == Material.iron) {
setHarvestLevel("pickaxe", 0); setHarvestLevel("pickaxe", 0);
} }
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
setResistance(10.0F); setResistance(10.0F);
setHardness(2.0F); setHardness(2.0F);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks); setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
} }
public BlockCarvable setStained(boolean a) { public BlockCarvable setStained(boolean a) {
this.isAlpha = a; this.isAlpha = a;
return this; return this;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getRenderBlockPass() { public int getRenderBlockPass() {
return isAlpha ? 1 : 0; return isAlpha ? 1 : 0;
} }
@Override @Override
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata); return carverHelper.getIcon(side, metadata);
} }
@Override @Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return carverHelper.getIcon(world, x, y, z, side); return carverHelper.getIcon(world, x, y, z, side);
} }
@Override @Override
public int damageDropped(int i) { public int damageDropped(int i) {
return i; return i;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons(Chisel.MOD_ID, this, register); carverHelper.registerBlockIcons(Chisel.MOD_ID, this, register);
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@Override @Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) { public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list); carverHelper.registerSubBlocks(this, tabs, list);
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return ClientUtils.renderCTMId; return ClientUtils.renderCTMId;
} }
@Override @Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata); return carverHelper.getVariation(metadata);
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(meta);
} }
public static class SoundType extends Block.SoundType { public static class SoundType extends Block.SoundType {
public final String soundNameStep; public final String soundNameStep;
public final String soundNameBreak; public final String soundNameBreak;
public final String soundNamePlace; public final String soundNamePlace;
/** /**
* Creates a SoundType with automatic names for step and break sounds. Sound names dig.soundName and step.soundName must be specified in the sounds.json * Creates a SoundType with automatic names for step and break sounds. Sound names dig.soundName and
* * step.soundName must be specified in the sounds.json
* @param soundName *
* block of the sound. Will automatically be expanded to "mod:dig.soundName" and "mod:step.soundName" respectively) * @param soundName block of the sound. Will automatically be expanded to "mod:dig.soundName" and
* @param volume * "mod:step.soundName" respectively)
* default 1.0f * @param volume default 1.0f
* @param frequency * @param frequency default 1.0f
* default 1.0f */
*/ public SoundType(String soundName, float volume, float frequency) {
public SoundType(String soundName, float volume, float frequency) { super(soundName, volume, frequency);
super(soundName, volume, frequency); this.soundNameStep = null;
this.soundNameStep = null; this.soundNameBreak = null;
this.soundNameBreak = null; this.soundNamePlace = null;
this.soundNamePlace = null; }
}
/** /**
* Creates a SoundType with manual names for step and break sounds. Sound names must be specified in the sounds.json * Creates a SoundType with manual names for step and break sounds. Sound names must be specified in the
* * sounds.json
* @param soundNameBreak *
* block break sound * @param soundNameBreak block break sound
* @param soundNameStep * @param soundNameStep block step sound
* block step sound * @param volume default 1.0f
* @param volume * @param frequency default 1.0f
* default 1.0f */
* @param frequency public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) {
* default 1.0f super(soundNameStep, volume, frequency);
*/ this.soundNameStep = soundNameStep;
public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) { this.soundNameBreak = soundNameBreak;
super(soundNameStep, volume, frequency); this.soundNamePlace = null;
this.soundNameStep = soundNameStep; }
this.soundNameBreak = soundNameBreak;
this.soundNamePlace = null;
}
/** /**
* Creates a SoundType with manual names for step, break and place sounds. Sound names must be specified in the sounds.json * Creates a SoundType with manual names for step, break and place sounds. Sound names must be specified in the
* * sounds.json
* @param soundNameBreak *
* block break sound * @param soundNameBreak block break sound
* @param soundNameStep * @param soundNameStep block step sound
* block step sound * @param soundNamePlace block place sound
* @param soundNamePlace * @param volume default 1.0f
* block place sound * @param frequency default 1.0f
* @param volume */
* default 1.0f public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume,
* @param frequency float frequency) {
* default 1.0f super(soundNameStep, volume, frequency);
*/ this.soundNameStep = soundNameStep;
public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume, float frequency) { this.soundNameBreak = soundNameBreak;
super(soundNameStep, volume, frequency); this.soundNamePlace = soundNamePlace;
this.soundNameStep = soundNameStep; }
this.soundNameBreak = soundNameBreak;
this.soundNamePlace = soundNamePlace;
}
@Override @Override
public String getBreakSound() { public String getBreakSound() {
if (soundNameBreak == null) if (soundNameBreak == null) return Chisel.MOD_ID + ":dig." + this.soundName;
return Chisel.MOD_ID + ":dig." + this.soundName; else return this.soundNameBreak;
else }
return this.soundNameBreak;
}
@Override @Override
public String getStepResourcePath() { public String getStepResourcePath() {
if (soundNameStep == null) if (soundNameStep == null) return Chisel.MOD_ID + ":step." + this.soundName;
return Chisel.MOD_ID + ":step." + this.soundName; else return this.soundNameStep;
else }
return this.soundNameStep;
}
@Override @Override
public String func_150496_b() { public String func_150496_b() {
if (soundNamePlace == null) if (soundNamePlace == null) return getBreakSound();
return getBreakSound(); else return this.soundNamePlace;
else }
return this.soundNamePlace; }
}
} @Override
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return Configurations.canMobsSpawnOnTheChiselBlocks;
}
} }
@@ -1,19 +1,19 @@
package team.chisel.block; package team.chisel.block;
import com.cricketcraft.chisel.api.ICarvable;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import com.cricketcraft.chisel.api.ICarvable;
public class BlockCarvableAntiBlock extends BlockCarvableColor implements ICarvable { public class BlockCarvableAntiBlock extends BlockCarvableColor implements ICarvable {
public BlockCarvableAntiBlock() { public BlockCarvableAntiBlock() {
super(Material.rock); super(Material.rock);
} }
@Override @Override
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return false; return false;
} }
} }
@@ -12,87 +12,89 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import team.chisel.block.tileentity.TileEntityCarvableBeacon;
import team.chisel.init.ChiselBlocks;
import com.cricketcraft.chisel.api.ChiselTabs; import com.cricketcraft.chisel.api.ChiselTabs;
import com.cricketcraft.chisel.api.ICarvable; import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper; import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo; import com.cricketcraft.chisel.api.carving.IVariationInfo;
import team.chisel.block.tileentity.TileEntityCarvableBeacon;
import team.chisel.init.ChiselBlocks;
public class BlockCarvableBeacon extends BlockBeacon implements ICarvable { public class BlockCarvableBeacon extends BlockBeacon implements ICarvable {
public static int renderId; public static int renderId;
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
public BlockCarvableBeacon() { public BlockCarvableBeacon() {
super(); super();
setCreativeTab(ChiselTabs.tabOtherChiselBlocks); setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
setLightLevel(5.0F); setLightLevel(5.0F);
setBlockTextureName("beacon"); setBlockTextureName("beacon");
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
} }
@Override @Override
public TileEntity createNewTileEntity(World world, int meta) { public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityCarvableBeacon(); return new TileEntityCarvableBeacon();
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par5, float hitX, float hitY, float hitZ) { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par5, float hitX,
if (world.isRemote) { float hitY, float hitZ) {
return true; if (world.isRemote) {
} else { return true;
TileEntityCarvableBeacon tileentitybeacon = (TileEntityCarvableBeacon) world.getTileEntity(x, y, z); } else {
TileEntityCarvableBeacon tileentitybeacon = (TileEntityCarvableBeacon) world.getTileEntity(x, y, z);
if (tileentitybeacon != null) { if (tileentitybeacon != null) {
player.func_146104_a(tileentitybeacon); player.func_146104_a(tileentitybeacon);
} }
return true; return true;
} }
} }
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
@Override @Override
public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) { public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
list.add(new ItemStack(item, 1, i)); list.add(new ItemStack(item, 1, i));
} }
} }
@Override @Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(ChiselBlocks.beacon, 1, world.getBlockMetadata(x, y, z)); return new ItemStack(ChiselBlocks.beacon, 1, world.getBlockMetadata(x, y, z));
} }
@Override
public int damageDropped(int meta) {
return meta;
}
@Override @Override
public int getRenderType() { public int damageDropped(int meta) {
return renderId; return meta;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { public int getRenderType() {
super.onBlockPlacedBy(world, x, y, z, player, stack); return renderId;
}
if (stack.hasDisplayName()) { @Override
((TileEntityCarvableBeacon) world.getTileEntity(x, y, z)).func_145999_a(stack.getDisplayName()); public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
} super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override if (stack.hasDisplayName()) {
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { ((TileEntityCarvableBeacon) world.getTileEntity(x, y, z)).func_145999_a(stack.getDisplayName());
return carverHelper.getVariation(metadata); }
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(metadata);
} }
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
} }
@@ -9,53 +9,52 @@ import net.minecraft.item.Item;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class BlockCarvableBookshelf extends BlockCarvable { public class BlockCarvableBookshelf extends BlockCarvable {
public BlockCarvableBookshelf() { public BlockCarvableBookshelf() {
super(Material.wood); super(Material.wood);
setHarvestLevel("axe", 0); setHarvestLevel("axe", 0);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
if (side < 2) if (side < 2) return Blocks.planks.getBlockTextureFromSide(side);
return Blocks.planks.getBlockTextureFromSide(side); return super.getIcon(side, metadata);
return super.getIcon(side, metadata); }
}
@Override @Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
if (side < 2) if (side < 2) return Blocks.planks.getBlockTextureFromSide(side);
return Blocks.planks.getBlockTextureFromSide(side); return super.getIcon(world, x, y, z, side);
return super.getIcon(world, x, y, z, side); }
}
@Override @Override
public int quantityDropped(Random random) { public int quantityDropped(Random random) {
return 3; return 3;
} }
@Override @Override
public Item getItemDropped(int ammount, Random random, int meta) { public Item getItemDropped(int ammount, Random random, int meta) {
return Items.book; return Items.book;
} }
@Override @Override
public int damageDropped(int damage) { public int damageDropped(int damage) {
return 0; return 0;
} }
@Override @Override
public int getDamageValue(World world, int x, int y, int z) { public int getDamageValue(World world, int x, int y, int z) {
return world.getBlockMetadata(x, y, z); return world.getBlockMetadata(x, y, z);
} }
@Override @Override
public float getEnchantPowerBonus(World world, int x, int y, int z) { public float getEnchantPowerBonus(World world, int x, int y, int z) {
return 1; return 1;
} }
} }
@@ -2,11 +2,6 @@ package team.chisel.block;
import java.util.List; import java.util.List;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.api.rendering.ClientUtils;
import net.minecraft.block.BlockCarpet; import net.minecraft.block.BlockCarpet;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -15,52 +10,57 @@ import net.minecraft.item.Item;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.api.rendering.ClientUtils;
public class BlockCarvableCarpet extends BlockCarpet implements ICarvable { public class BlockCarvableCarpet extends BlockCarpet implements ICarvable {
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
public BlockCarvableCarpet(Material m) { public BlockCarvableCarpet(Material m) {
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
} }
@Override @Override
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata); return carverHelper.getIcon(side, metadata);
} }
@Override @Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return carverHelper.getIcon(world, x, y, z, side); return carverHelper.getIcon(world, x, y, z, side);
} }
@Override @Override
public int damageDropped(int i) { public int damageDropped(int i) {
return i; return i;
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register); carverHelper.registerBlockIcons("Chisel", this, register);
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@Override @Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) { public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list); carverHelper.registerSubBlocks(this, tabs, list);
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return ClientUtils.renderCTMId; return ClientUtils.renderCTMId;
} }
@Override @Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata); return carverHelper.getVariation(metadata);
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(meta);
} }
} }
@@ -6,21 +6,21 @@ import net.minecraftforge.common.util.ForgeDirection;
public class BlockCarvableColor extends BlockCarvable { public class BlockCarvableColor extends BlockCarvable {
public BlockCarvableColor() { public BlockCarvableColor() {
this(Material.rock); this(Material.rock);
} }
public BlockCarvableColor(Material m) { public BlockCarvableColor(Material m) {
super(m); super(m);
} }
@Override @Override
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int color) { public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int color) {
int newColor = 15 - color; int newColor = 15 - color;
if (world.getBlockMetadata(x, y, z) != newColor) { if (world.getBlockMetadata(x, y, z) != newColor) {
world.setBlockMetadataWithNotify(x, y, z, newColor, 3); world.setBlockMetadataWithNotify(x, y, z, newColor, 3);
return true; return true;
} }
return false; return false;
} }
} }
@@ -11,7 +11,6 @@ import net.minecraft.item.Item;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import team.chisel.ctmlib.CTM;
import com.cricketcraft.chisel.api.ChiselTabs; import com.cricketcraft.chisel.api.ChiselTabs;
import com.cricketcraft.chisel.api.ICarvable; import com.cricketcraft.chisel.api.ICarvable;
@@ -21,87 +20,89 @@ import com.cricketcraft.chisel.api.rendering.ClientUtils;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.ctmlib.CTM;
public class BlockCarvableGlass extends BlockGlass implements ICarvable { public class BlockCarvableGlass extends BlockGlass implements ICarvable {
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
private boolean isAlpha = false; private boolean isAlpha = false;
private CTM ctm = CTM.getInstance(); private CTM ctm = CTM.getInstance();
public BlockCarvableGlass() { public BlockCarvableGlass() {
super(Material.glass, false); super(Material.glass, false);
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks); setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
} }
public BlockCarvableGlass setStained(boolean a) { public BlockCarvableGlass setStained(boolean a) {
this.isAlpha = a; this.isAlpha = a;
return this; return this;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
public boolean isNormalCube() { public boolean isNormalCube() {
return true; return true;
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return ClientUtils.renderCTMId; return ClientUtils.renderCTMId;
} }
@Override @Override
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata); return carverHelper.getIcon(side, metadata);
} }
@Override
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
ForgeDirection face = ForgeDirection.getOrientation(side).getOpposite();
int meX = x + face.offsetX;
int meY = y + face.offsetY;
int meZ = z + face.offsetZ;
Block block = world.getBlock(meX, meY, meZ);
int meta = world.getBlockMetadata(meX, meY, meZ);
Block otherBlock = ctm.getBlockOrFacade(world, x, y, z, face.ordinal());
int otherMeta = ctm.getBlockOrFacadeMetadata(world, x, y, z, face.ordinal());
return block != otherBlock || meta != otherMeta;
}
@Override @Override
public int damageDropped(int i) { public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
return i; ForgeDirection face = ForgeDirection.getOrientation(side)
} .getOpposite();
int meX = x + face.offsetX;
int meY = y + face.offsetY;
int meZ = z + face.offsetZ;
Block block = world.getBlock(meX, meY, meZ);
int meta = world.getBlockMetadata(meX, meY, meZ);
Block otherBlock = ctm.getBlockOrFacade(world, x, y, z, face.ordinal());
int otherMeta = ctm.getBlockOrFacadeMetadata(world, x, y, z, face.ordinal());
return block != otherBlock || meta != otherMeta;
}
@Override @Override
public void registerBlockIcons(IIconRegister register) { public int damageDropped(int i) {
carverHelper.registerBlockIcons("Chisel", this, register); return i;
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override
@Override public void registerBlockIcons(IIconRegister register) {
public void getSubBlocks(Item item, CreativeTabs tabs, List list) { carverHelper.registerBlockIcons("Chisel", this, register);
carverHelper.registerSubBlocks(this, tabs, list); }
}
@Override @SuppressWarnings({ "unchecked", "rawtypes" })
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { @Override
return carverHelper.getVariation(metadata); public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
} carverHelper.registerSubBlocks(this, tabs, list);
}
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(metadata);
} }
@Override @Override
@SideOnly(Side.CLIENT) public IVariationInfo getManager(int meta) {
public int getRenderBlockPass() { return carverHelper.getVariation(meta);
return isAlpha ? 1 : 0; }
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return isAlpha ? 1 : 0;
}
} }
@@ -1,58 +1,59 @@
package team.chisel.block; package team.chisel.block;
import team.chisel.Chisel;
import team.chisel.client.render.SubmapManagerBase;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
import team.chisel.client.render.SubmapManagerBase;
public class BlockCarvableGlow extends BlockCarvableColor { public class BlockCarvableGlow extends BlockCarvableColor {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon glowTexture; private IIcon glowTexture;
private SubmapManagerBase submapManagerBase; private SubmapManagerBase submapManagerBase;
private String glowTexturePath; private String glowTexturePath;
public BlockCarvableGlow(String glowTexture) { public BlockCarvableGlow(String glowTexture) {
super(); super();
setLightLevel(0.5f); setLightLevel(0.5f);
this.glowTexturePath = glowTexture; this.glowTexturePath = glowTexture;
} }
public BlockCarvableGlow(Material mat, String glowTexture) { public BlockCarvableGlow(Material mat, String glowTexture) {
super(mat); super(mat);
this.glowTexturePath = glowTexture; this.glowTexturePath = glowTexture;
} }
public BlockCarvableGlow(Material material, String glowTexture, SubmapManagerBase submapManagerBase) { public BlockCarvableGlow(Material material, String glowTexture, SubmapManagerBase submapManagerBase) {
super(material); super(material);
this.glowTexturePath = glowTexture; this.glowTexturePath = glowTexture;
this.submapManagerBase = submapManagerBase; this.submapManagerBase = submapManagerBase;
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register); super.registerBlockIcons(register);
glowTexture = register.registerIcon(Chisel.MOD_ID + ":" + glowTexturePath); glowTexture = register.registerIcon(Chisel.MOD_ID + ":" + glowTexturePath);
} }
public boolean hasSubmapManager() { public boolean hasSubmapManager() {
return submapManagerBase == null; return submapManagerBase == null;
} }
public SubmapManagerBase getSubmapManager() { public SubmapManagerBase getSubmapManager() {
return hasSubmapManager() ? submapManagerBase : null; return hasSubmapManager() ? submapManagerBase : null;
} }
public IIcon getGlowTexture() { public IIcon getGlowTexture() {
return glowTexture; return glowTexture;
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return Chisel.renderGlowId; return Chisel.renderGlowId;
} }
} }
@@ -0,0 +1,17 @@
package team.chisel.block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.IBlockAccess;
public class BlockCarvableGlowie extends BlockCarvable {
public BlockCarvableGlowie(Material material) {
super(material);
}
@Override
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return false;
}
}
@@ -14,29 +14,29 @@ import net.minecraft.world.World;
public class BlockCarvableGlowstone extends BlockCarvable { public class BlockCarvableGlowstone extends BlockCarvable {
public BlockCarvableGlowstone() { public BlockCarvableGlowstone() {
super(Material.glass); super(Material.glass);
} }
@Override @Override
public int quantityDropped(Random random) { public int quantityDropped(Random random) {
return Blocks.glowstone.quantityDropped(random); return Blocks.glowstone.quantityDropped(random);
} }
@Override @Override
public Item getItemDropped(int i, Random random, int a) { public Item getItemDropped(int i, Random random, int a) {
return Items.glowstone_dust; return Items.glowstone_dust;
} }
@Override @Override
public int damageDropped(int i) { public int damageDropped(int i) {
return 0; return 0;
} }
@Override @Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
Block glowstone = world.getBlock(x, y, z); Block glowstone = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
return new ItemStack(Item.getItemFromBlock(glowstone), 1, meta); return new ItemStack(Item.getItemFromBlock(glowstone), 1, meta);
} }
} }
@@ -2,11 +2,6 @@ package team.chisel.block;
import java.util.List; import java.util.List;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.api.rendering.ClientUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockIce; import net.minecraft.block.BlockIce;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -18,58 +13,63 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.api.rendering.ClientUtils;
public class BlockCarvableIce extends BlockIce implements ICarvable { public class BlockCarvableIce extends BlockIce implements ICarvable {
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
public BlockCarvableIce() { public BlockCarvableIce() {
super(); super();
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return ClientUtils.renderCTMId; return ClientUtils.renderCTMId;
} }
@Override @Override
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata); return carverHelper.getIcon(side, metadata);
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register); carverHelper.registerBlockIcons("Chisel", this, register);
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@Override @Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) { public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list); carverHelper.registerSubBlocks(this, tabs, list);
} }
@Override @Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1); par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
par2EntityPlayer.addExhaustion(0.025F); par2EntityPlayer.addExhaustion(0.025F);
/* /*
* if(this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack = * if(this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) &&
* this.createStackedBlock(par6); * EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack =
* * this.createStackedBlock(par6); if(itemstack != null) { this.dropBlockAsItem(par1World, par3, par4, par5,
* if(itemstack != null) { this.dropBlockAsItem(par1World, par3, par4, par5, itemstack); } } * itemstack); } }
*/ */
} }
@Override @Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata); return carverHelper.getVariation(metadata);
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(meta);
} }
} }
@@ -2,44 +2,45 @@ package team.chisel.block;
import java.util.Random; import java.util.Random;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import team.chisel.init.ChiselBlocks;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import team.chisel.init.ChiselBlocks;
public class BlockCarvableIceStairs extends BlockCarvableStairs { public class BlockCarvableIceStairs extends BlockCarvableStairs {
public BlockCarvableIceStairs(Block block, int meta, CarvableHelper helper) { public BlockCarvableIceStairs(Block block, int meta, CarvableHelper helper) {
super(block, meta, helper); super(block, meta, helper);
slipperiness = 0.98F; slipperiness = 0.98F;
setTickRandomly(true); setTickRandomly(true);
} }
@Override @Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
ChiselBlocks.ice.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); ChiselBlocks.ice.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
} }
@Override @Override
public int quantityDropped(Random par1Random) { public int quantityDropped(Random par1Random) {
return ChiselBlocks.ice.quantityDropped(par1Random); return ChiselBlocks.ice.quantityDropped(par1Random);
} }
@Override @Override
public int damageDropped(int i) { public int damageDropped(int i) {
return 0; return 0;
} }
@Override @Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
ChiselBlocks.ice.updateTick(par1World, par2, par3, par4, par5Random); ChiselBlocks.ice.updateTick(par1World, par2, par3, par4, par5Random);
} }
@Override @Override
public int getMobilityFlag() { public int getMobilityFlag() {
return 0; return 0;
} }
} }
@@ -11,71 +11,70 @@ import net.minecraft.world.World;
public class BlockCarvableLamp extends BlockCarvable { public class BlockCarvableLamp extends BlockCarvable {
BlockCarvableLamp blockUnpowered; BlockCarvableLamp blockUnpowered;
BlockCarvableLamp blockPowered; BlockCarvableLamp blockPowered;
boolean powered; boolean powered;
public BlockCarvableLamp() { public BlockCarvableLamp() {
super(Material.redstoneLight); super(Material.redstoneLight);
powered = false; powered = false;
blockUnpowered = this; blockUnpowered = this;
blockPowered = new BlockCarvableLamp(this); blockPowered = new BlockCarvableLamp(this);
setHardness(0.3F); setHardness(0.3F);
} }
public BlockCarvableLamp(BlockCarvableLamp unpoweredVersion) { public BlockCarvableLamp(BlockCarvableLamp unpoweredVersion) {
super(Material.redstoneLight); super(Material.redstoneLight);
carverHelper = unpoweredVersion.carverHelper; carverHelper = unpoweredVersion.carverHelper;
powered = true; powered = true;
blockUnpowered = unpoweredVersion; blockUnpowered = unpoweredVersion;
blockPowered = this; blockPowered = this;
setLightLevel(1.0F); setLightLevel(1.0F);
setHardness(0.3F); setHardness(0.3F);
} }
public void checkPower(World world, int x, int y, int z) { public void checkPower(World world, int x, int y, int z) {
if (world.isRemote) if (world.isRemote) return;
return;
boolean isGettingPower = world.isBlockIndirectlyGettingPowered(x, y, z); boolean isGettingPower = world.isBlockIndirectlyGettingPowered(x, y, z);
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
if (powered && !isGettingPower) { if (powered && !isGettingPower) {
world.setBlock(x, y, z, blockUnpowered, meta, 2); world.setBlock(x, y, z, blockUnpowered, meta, 2);
} else if (!powered && isGettingPower) { } else if (!powered && isGettingPower) {
world.setBlock(x, y, z, blockPowered, meta, 2); world.setBlock(x, y, z, blockPowered, meta, 2);
} }
} }
@Override @Override
public void onBlockAdded(World world, int x, int y, int z) { public void onBlockAdded(World world, int x, int y, int z) {
checkPower(world, x, y, z); checkPower(world, x, y, z);
} }
@Override @Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
checkPower(world, x, y, z); checkPower(world, x, y, z);
} }
/* /*
* @Override public void updateTick(World world, int x, int y, int z, Random rand){ if (world.isRemote) return; * @Override public void updateTick(World world, int x, int y, int z, Random rand){ if (world.isRemote) return;
* * if(powered && !world.isBlockIndirectlyGettingPowered(x, y, z)){ int meta=world.getBlockMetadata(x, y, z);
* if(powered && !world.isBlockIndirectlyGettingPowered(x, y, z)){ int meta=world.getBlockMetadata(x, y, z); world.setBlock(x, y, z, Block.redstoneLampIdle.blockID, meta, 2); } } * world.setBlock(x, y, z, Block.redstoneLampIdle.blockID, meta, 2); } }
*/ */
@Override @Override
public Item getItemDropped(int par1, Random par2Random, int par3) { public Item getItemDropped(int par1, Random par2Random, int par3) {
return Item.getItemFromBlock(blockUnpowered); return Item.getItemFromBlock(blockUnpowered);
} }
@Override @Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(blockUnpowered, 1, world.getBlockMetadata(x, y, z)); return new ItemStack(blockUnpowered, 1, world.getBlockMetadata(x, y, z));
} }
} }
@@ -1,35 +1,36 @@
package team.chisel.block; package team.chisel.block;
import team.chisel.Chisel;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
public class BlockCarvableLayered extends BlockCarvable { public class BlockCarvableLayered extends BlockCarvable {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon baseTexture; private IIcon baseTexture;
private String baseTexLocation; private String baseTexLocation;
public BlockCarvableLayered(Material mat, String baseTexLocation) { public BlockCarvableLayered(Material mat, String baseTexLocation) {
super(mat); super(mat);
this.baseTexLocation = baseTexLocation; this.baseTexLocation = baseTexLocation;
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register); super.registerBlockIcons(register);
baseTexture = register.registerIcon(Chisel.MOD_ID + ":" + baseTexLocation); baseTexture = register.registerIcon(Chisel.MOD_ID + ":" + baseTexLocation);
} }
public IIcon getBaseTex() { public IIcon getBaseTex() {
return baseTexture; return baseTexture;
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return Chisel.renderLayeredId; return Chisel.renderLayeredId;
} }
} }
@@ -3,11 +3,6 @@ package team.chisel.block;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.api.rendering.ClientUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -20,64 +15,69 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.api.rendering.ClientUtils;
public class BlockCarvablePackedIce extends Block implements ICarvable { public class BlockCarvablePackedIce extends Block implements ICarvable {
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
public BlockCarvablePackedIce() { public BlockCarvablePackedIce() {
super(Material.ice); super(Material.ice);
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
this.slipperiness = Blocks.packed_ice.slipperiness; this.slipperiness = Blocks.packed_ice.slipperiness;
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return ClientUtils.renderCTMId; return ClientUtils.renderCTMId;
} }
@Override @Override
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata); return carverHelper.getIcon(side, metadata);
} }
@Override @Override
public int quantityDropped(int meta, int fortune, Random random) { public int quantityDropped(int meta, int fortune, Random random) {
return 0; return 0;
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register); carverHelper.registerBlockIcons("Chisel", this, register);
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@Override @Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) { public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list); carverHelper.registerSubBlocks(this, tabs, list);
} }
@Override @Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1); par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
par2EntityPlayer.addExhaustion(0.025F); par2EntityPlayer.addExhaustion(0.025F);
/* /*
* if(this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack = * if(this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) &&
* this.createStackedBlock(par6); * EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack =
* * this.createStackedBlock(par6); if(itemstack != null) { this.dropBlockAsItem(par1World, par3, par4, par5,
* if(itemstack != null) { this.dropBlockAsItem(par1World, par3, par4, par5, itemstack); } } * itemstack); } }
*/ */
} }
@Override @Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata); return carverHelper.getVariation(metadata);
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(meta);
} }
} }
@@ -2,44 +2,45 @@ package team.chisel.block;
import java.util.Random; import java.util.Random;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import team.chisel.init.ChiselBlocks;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import team.chisel.init.ChiselBlocks;
public class BlockCarvablePackedIceStairs extends BlockCarvableStairs { public class BlockCarvablePackedIceStairs extends BlockCarvableStairs {
public BlockCarvablePackedIceStairs(Block block, int meta, CarvableHelper helper) { public BlockCarvablePackedIceStairs(Block block, int meta, CarvableHelper helper) {
super(block, meta, helper); super(block, meta, helper);
slipperiness = 0.98F; slipperiness = 0.98F;
setTickRandomly(true); setTickRandomly(true);
} }
@Override @Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
ChiselBlocks.packedice.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); ChiselBlocks.packedice.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
} }
@Override @Override
public int quantityDropped(Random par1Random) { public int quantityDropped(Random par1Random) {
return ChiselBlocks.packedice.quantityDropped(par1Random); return ChiselBlocks.packedice.quantityDropped(par1Random);
} }
@Override @Override
public int damageDropped(int i) { public int damageDropped(int i) {
return 0; return 0;
} }
@Override @Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
ChiselBlocks.packedice.updateTick(par1World, par2, par3, par4, par5Random); ChiselBlocks.packedice.updateTick(par1World, par2, par3, par4, par5Random);
} }
@Override @Override
public int getMobilityFlag() { public int getMobilityFlag() {
return 0; return 0;
} }
} }
@@ -2,12 +2,6 @@ package team.chisel.block;
import java.util.List; import java.util.List;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import team.chisel.client.render.RendererCTMPane;
import com.cricketcraft.chisel.api.ChiselTabs;
import net.minecraft.block.BlockPane; import net.minecraft.block.BlockPane;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -15,66 +9,73 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import com.cricketcraft.chisel.api.ChiselTabs;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.client.render.RendererCTMPane;
public class BlockCarvablePane extends BlockPane implements ICarvable { public class BlockCarvablePane extends BlockPane implements ICarvable {
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
public boolean isAlpha; public boolean isAlpha;
public BlockCarvablePane(Material material, boolean drops) { public BlockCarvablePane(Material material, boolean drops) {
super("", "", material, drops); super("", "", material, drops);
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks); setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
} }
public BlockCarvablePane setStained(boolean a) { public BlockCarvablePane setStained(boolean a) {
this.isAlpha = a; this.isAlpha = a;
return this; return this;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getRenderBlockPass() { public int getRenderBlockPass() {
return isAlpha ? 1 : 0; return isAlpha ? 1 : 0;
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return RendererCTMPane.id; return RendererCTMPane.id;
} }
@Override @Override
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata); return carverHelper.getIcon(side, metadata);
} }
@Override @Override
public int damageDropped(int i) { public int damageDropped(int i) {
return i; return i;
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register); carverHelper.registerBlockIcons("Chisel", this, register);
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@Override @Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) { public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list); carverHelper.registerSubBlocks(this, tabs, list);
} }
@Override @Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata); return carverHelper.getVariation(metadata);
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(meta);
} }
} }
@@ -5,25 +5,26 @@ import net.minecraft.world.IBlockAccess;
public class BlockCarvablePowered extends BlockCarvable { public class BlockCarvablePowered extends BlockCarvable {
public BlockCarvablePowered(Material m) { public BlockCarvablePowered(Material m) {
super(m); super(m);
} }
/** /**
* Can this block provide power. Only wire currently seems to have this change based on its state. * Can this block provide power. Only wire currently seems to have this change based on its state.
*/ */
@Override @Override
public boolean canProvidePower() { public boolean canProvidePower() {
return true; return true;
} }
/** /**
* Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube returns true, standard redstone propagation rules will apply instead and this will * Returns true if the block is emitting indirect/weak redstone power on the specified side. If isBlockNormalCube
* not be called. Args: World, X, Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block. * returns true, standard redstone propagation rules will apply instead and this will not be called. Args: World, X,
*/ * Y, Z, side. Note that the side is reversed - eg it is 1 (up) when checking the bottom of the block.
@Override */
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { @Override
return 15; public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
} return 15;
}
} }
@@ -1,11 +1,5 @@
package team.chisel.block; package team.chisel.block;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import team.chisel.Chisel;
import team.chisel.entity.EntityChiselSnowman;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockPumpkin; import net.minecraft.block.BlockPumpkin;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -15,111 +9,130 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
import team.chisel.entity.EntityChiselSnowman;
public class BlockCarvablePumpkin extends BlockPumpkin implements ICarvable { public class BlockCarvablePumpkin extends BlockPumpkin implements ICarvable {
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon top, face; private IIcon top, face;
private String faceLocation; private String faceLocation;
public BlockCarvablePumpkin(boolean isOn) { public BlockCarvablePumpkin(boolean isOn) {
super(isOn); super(isOn);
this.setStepSound(Block.soundTypeWood); this.setStepSound(Block.soundTypeWood);
if (isOn) if (isOn) setLightLevel(10.0F);
setLightLevel(10.0F); carverHelper = new CarvableHelper(this);
carverHelper = new CarvableHelper(this); }
}
@Override @Override
public void onBlockAdded(World world, int x, int y, int z) { public void onBlockAdded(World world, int x, int y, int z) {
if (world.getBlock(x, y - 1, z) == Blocks.snow && world.getBlock(x, y - 2, z) == Blocks.snow) { if (world.getBlock(x, y - 1, z) == Blocks.snow && world.getBlock(x, y - 2, z) == Blocks.snow) {
if (!world.isRemote) { if (!world.isRemote) {
// Let's grab the pumpkin before we start // Let's grab the pumpkin before we start
ItemStack pumpkin = new ItemStack(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z)); ItemStack pumpkin = new ItemStack(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
world.setBlock(x, y, z, Blocks.air, 0, 2); world.setBlock(x, y, z, Blocks.air, 0, 2);
world.setBlock(x, y - 1, z, Blocks.air, 0, 2); world.setBlock(x, y - 1, z, Blocks.air, 0, 2);
world.setBlock(x, y - 2, z, Blocks.air, 0, 2); world.setBlock(x, y - 2, z, Blocks.air, 0, 2);
EntityChiselSnowman snowman = new EntityChiselSnowman(world); EntityChiselSnowman snowman = new EntityChiselSnowman(world);
snowman.setCurrentItemOrArmor(2, pumpkin); snowman.setCurrentItemOrArmor(2, pumpkin);
snowman.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F); snowman.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F);
world.spawnEntityInWorld(snowman); world.spawnEntityInWorld(snowman);
world.notifyBlockChange(x, y, z, Blocks.air); world.notifyBlockChange(x, y, z, Blocks.air);
world.notifyBlockChange(x, y - 1, z, Blocks.air); world.notifyBlockChange(x, y - 1, z, Blocks.air);
world.notifyBlockChange(x, y - 2, z, Blocks.air); world.notifyBlockChange(x, y - 2, z, Blocks.air);
} }
// Spawn some lovely particles // Spawn some lovely particles
for (int c = 0; c < 120; ++c) { for (int c = 0; c < 120; ++c) {
world.spawnParticle("snowshovel", x + world.rand.nextDouble(), y - 2 + world.rand.nextDouble() * 2.5D, z + world.rand.nextDouble(), 0.0D, 0.0D, 0.0D); world.spawnParticle(
} "snowshovel",
} else if (world.getBlock(x, y - 1, z) == Blocks.iron_block || world.getBlock(x, y - 2, z) == Blocks.iron_block) { x + world.rand.nextDouble(),
boolean flag = world.getBlock(x - 1, y - 1, z) == Blocks.iron_block && world.getBlock(x + 1, y - 1, z) == Blocks.iron_block; y - 2 + world.rand.nextDouble() * 2.5D,
boolean flag1 = world.getBlock(x, y - 1, z - 1) == Blocks.iron_block && world.getBlock(x, y - 1, z + 1) == Blocks.iron_block; z + world.rand.nextDouble(),
0.0D,
0.0D,
0.0D);
}
} else
if (world.getBlock(x, y - 1, z) == Blocks.iron_block || world.getBlock(x, y - 2, z) == Blocks.iron_block) {
boolean flag = world.getBlock(x - 1, y - 1, z) == Blocks.iron_block
&& world.getBlock(x + 1, y - 1, z) == Blocks.iron_block;
boolean flag1 = world.getBlock(x, y - 1, z - 1) == Blocks.iron_block
&& world.getBlock(x, y - 1, z + 1) == Blocks.iron_block;
if (flag || flag1) { if (flag || flag1) {
world.setBlock(x, y, z, Blocks.air, 0, 2); world.setBlock(x, y, z, Blocks.air, 0, 2);
world.setBlock(x, y - 1, z, Blocks.air, 0, 2); world.setBlock(x, y - 1, z, Blocks.air, 0, 2);
world.setBlock(x, y - 2, z, Blocks.air, 0, 2); world.setBlock(x, y - 2, z, Blocks.air, 0, 2);
if (flag) { if (flag) {
world.setBlock(x - 1, y - 1, z, Blocks.air, 0, 2); world.setBlock(x - 1, y - 1, z, Blocks.air, 0, 2);
world.setBlock(x + 1, y - 1, z, Blocks.air, 0, 2); world.setBlock(x + 1, y - 1, z, Blocks.air, 0, 2);
} else { } else {
world.setBlock(x, y - 1, z - 1, Blocks.air, 0, 2); world.setBlock(x, y - 1, z - 1, Blocks.air, 0, 2);
world.setBlock(x, y - 1, z + 1, Blocks.air, 0, 2); world.setBlock(x, y - 1, z + 1, Blocks.air, 0, 2);
} }
EntityIronGolem ironGolem = new EntityIronGolem(world); EntityIronGolem ironGolem = new EntityIronGolem(world);
ironGolem.setPlayerCreated(true); ironGolem.setPlayerCreated(true);
ironGolem.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F); ironGolem.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F);
world.spawnEntityInWorld(ironGolem); world.spawnEntityInWorld(ironGolem);
world.notifyBlockChange(x, y, z, Blocks.air); world.notifyBlockChange(x, y, z, Blocks.air);
world.notifyBlockChange(x, y - 1, z, Blocks.air); world.notifyBlockChange(x, y - 1, z, Blocks.air);
world.notifyBlockChange(x, y - 2, z, Blocks.air); world.notifyBlockChange(x, y - 2, z, Blocks.air);
if (flag) { if (flag) {
world.notifyBlockChange(x - 1, y - 1, z, Blocks.air); world.notifyBlockChange(x - 1, y - 1, z, Blocks.air);
world.notifyBlockChange(x + 1, y - 1, z, Blocks.air); world.notifyBlockChange(x + 1, y - 1, z, Blocks.air);
} else { } else {
world.notifyBlockChange(x, y - 1, z - 1, Blocks.air); world.notifyBlockChange(x, y - 1, z - 1, Blocks.air);
world.notifyBlockChange(x, y - 1, z + 1, Blocks.air); world.notifyBlockChange(x, y - 1, z + 1, Blocks.air);
} }
} }
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) { public IIcon getIcon(int side, int meta) {
return side == 1 ? top : (side == 0 ? top : (meta == 2 && side == 2 ? face : (meta == 3 && side == 5 ? face return side == 1 ? top
: (meta == 0 && side == 3 ? face : (meta == 1 && side == 4 ? face : this.blockIcon))))); : (side == 0 ? top
} : (meta == 2 && side == 2 ? face
: (meta == 3 && side == 5 ? face
: (meta == 0 && side == 3 ? face : (meta == 1 && side == 4 ? face : this.blockIcon)))));
}
@Override @Override
public void registerBlockIcons(IIconRegister icon) { public void registerBlockIcons(IIconRegister icon) {
top = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_top"); top = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_top");
face = icon.registerIcon(Chisel.MOD_ID + ":" + faceLocation); face = icon.registerIcon(Chisel.MOD_ID + ":" + faceLocation);
this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_side"); this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_side");
} }
@Override @Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata); return carverHelper.getVariation(metadata);
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(meta);
} }
public void setInformation(String textureLocation) { public void setInformation(String textureLocation) {
this.faceLocation = textureLocation; this.faceLocation = textureLocation;
} }
} }
@@ -2,13 +2,6 @@ package team.chisel.block;
import java.util.List; import java.util.List;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.api.rendering.ClientUtils;
import team.chisel.Chisel;
import com.cricketcraft.chisel.api.ChiselTabs;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockSand; import net.minecraft.block.BlockSand;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -16,158 +9,153 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import com.cricketcraft.chisel.api.ChiselTabs;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import com.cricketcraft.chisel.api.rendering.ClientUtils;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
public class BlockCarvableSand extends BlockSand implements ICarvable { public class BlockCarvableSand extends BlockSand implements ICarvable {
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
private boolean isAlpha; private boolean isAlpha;
public BlockCarvableSand() { public BlockCarvableSand() {
super(); super();
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks); setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
} }
public BlockCarvableSand setStained(boolean a) { public BlockCarvableSand setStained(boolean a) {
this.isAlpha = a; this.isAlpha = a;
return this; return this;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getRenderBlockPass() { public int getRenderBlockPass() {
return isAlpha ? 1 : 0; return isAlpha ? 1 : 0;
} }
@Override @Override
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata); return carverHelper.getIcon(side, metadata);
} }
@Override @Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return carverHelper.getIcon(world, x, y, z, side); return carverHelper.getIcon(world, x, y, z, side);
} }
@Override @Override
public int damageDropped(int i) { public int damageDropped(int i) {
return i; return i;
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register); carverHelper.registerBlockIcons("Chisel", this, register);
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@Override @Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) { public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list); carverHelper.registerSubBlocks(this, tabs, list);
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return ClientUtils.renderCTMId; return ClientUtils.renderCTMId;
} }
@Override @Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata); return carverHelper.getVariation(metadata);
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(meta);
} }
public static class SoundType extends Block.SoundType { public static class SoundType extends Block.SoundType {
public final String soundNameStep; public final String soundNameStep;
public final String soundNameBreak; public final String soundNameBreak;
public final String soundNamePlace; public final String soundNamePlace;
/** /**
* Creates a SoundType with automatic names for step and break sounds. Sound names dig.soundName and step.soundName must be specified in the sounds.json * Creates a SoundType with automatic names for step and break sounds. Sound names dig.soundName and
* * step.soundName must be specified in the sounds.json
* @param soundName *
* block of the sound. Will automatically be expanded to "mod:dig.soundName" and "mod:step.soundName" respectively) * @param soundName block of the sound. Will automatically be expanded to "mod:dig.soundName" and
* @param volume * "mod:step.soundName" respectively)
* default 1.0f * @param volume default 1.0f
* @param frequency * @param frequency default 1.0f
* default 1.0f */
*/ public SoundType(String soundName, float volume, float frequency) {
public SoundType(String soundName, float volume, float frequency) { super(soundName, volume, frequency);
super(soundName, volume, frequency); this.soundNameStep = null;
this.soundNameStep = null; this.soundNameBreak = null;
this.soundNameBreak = null; this.soundNamePlace = null;
this.soundNamePlace = null; }
}
/** /**
* Creates a SoundType with manual names for step and break sounds. Sound names must be specified in the sounds.json * Creates a SoundType with manual names for step and break sounds. Sound names must be specified in the
* * sounds.json
* @param soundNameBreak *
* block break sound * @param soundNameBreak block break sound
* @param soundNameStep * @param soundNameStep block step sound
* block step sound * @param volume default 1.0f
* @param volume * @param frequency default 1.0f
* default 1.0f */
* @param frequency public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) {
* default 1.0f super(soundNameStep, volume, frequency);
*/ this.soundNameStep = soundNameStep;
public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) { this.soundNameBreak = soundNameBreak;
super(soundNameStep, volume, frequency); this.soundNamePlace = null;
this.soundNameStep = soundNameStep; }
this.soundNameBreak = soundNameBreak;
this.soundNamePlace = null;
}
/** /**
* Creates a SoundType with manual names for step, break and place sounds. Sound names must be specified in the sounds.json * Creates a SoundType with manual names for step, break and place sounds. Sound names must be specified in the
* * sounds.json
* @param soundNameBreak *
* block break sound * @param soundNameBreak block break sound
* @param soundNameStep * @param soundNameStep block step sound
* block step sound * @param soundNamePlace block place sound
* @param soundNamePlace * @param volume default 1.0f
* block place sound * @param frequency default 1.0f
* @param volume */
* default 1.0f public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume,
* @param frequency float frequency) {
* default 1.0f super(soundNameStep, volume, frequency);
*/ this.soundNameStep = soundNameStep;
public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume, float frequency) { this.soundNameBreak = soundNameBreak;
super(soundNameStep, volume, frequency); this.soundNamePlace = soundNamePlace;
this.soundNameStep = soundNameStep; }
this.soundNameBreak = soundNameBreak;
this.soundNamePlace = soundNamePlace;
}
@Override @Override
public String getBreakSound() { public String getBreakSound() {
if (soundNameBreak == null) if (soundNameBreak == null) return Chisel.MOD_ID + ":dig." + this.soundName;
return Chisel.MOD_ID + ":dig." + this.soundName; else return this.soundNameBreak;
else }
return this.soundNameBreak;
}
@Override @Override
public String getStepResourcePath() { public String getStepResourcePath() {
if (soundNameStep == null) if (soundNameStep == null) return Chisel.MOD_ID + ":step." + this.soundName;
return Chisel.MOD_ID + ":step." + this.soundName; else return this.soundNameStep;
else }
return this.soundNameStep;
}
@Override @Override
public String func_150496_b() { public String func_150496_b() {
if (soundNamePlace == null) if (soundNamePlace == null) return getBreakSound();
return getBreakSound(); else return this.soundNamePlace;
else }
return this.soundNamePlace; }
}
}
} }
@@ -1,5 +1,7 @@
package team.chisel.block; package team.chisel.block;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@@ -14,126 +16,121 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import static net.minecraftforge.common.util.ForgeDirection.UP;
public class BlockCarvableSlab extends BlockCarvable { public class BlockCarvableSlab extends BlockCarvable {
public Block master; public Block master;
public BlockCarvableSlab bottom; public BlockCarvableSlab bottom;
public BlockCarvableSlab top; public BlockCarvableSlab top;
public boolean isBottom; public boolean isBottom;
public BlockCarvableSlab(BlockCarvable marble) { public BlockCarvableSlab(BlockCarvable marble) {
opaque = true; opaque = true;
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
master = marble; master = marble;
bottom = this; bottom = this;
top = new BlockCarvableSlab(this); top = new BlockCarvableSlab(this);
isBottom = true; isBottom = true;
} }
public BlockCarvableSlab(BlockCarvableSlab bottomBlock) { public BlockCarvableSlab(BlockCarvableSlab bottomBlock) {
super(); super();
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
master = bottomBlock.master; master = bottomBlock.master;
bottom = bottomBlock; bottom = bottomBlock;
top = this; top = this;
carverHelper = bottomBlock.carverHelper; carverHelper = bottomBlock.carverHelper;
isBottom = false; isBottom = false;
} }
@Override @Override
public Block setBlockName(String p_149663_1_) { public Block setBlockName(String p_149663_1_) {
if (this != top) { if (this != top) {
top.setBlockName(p_149663_1_); top.setBlockName(p_149663_1_);
} }
return super.setBlockName(p_149663_1_); return super.setBlockName(p_149663_1_);
} }
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
if (isBottom) { if (isBottom) {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
} else { } else {
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
} }
} }
@Override @Override
public void setBlockBoundsForItemRender() { public void setBlockBoundsForItemRender() {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @Override
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB,
setBlockBoundsBasedOnState(par1World, par2, par3, par4); List par6List, Entity par7Entity) {
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); setBlockBoundsBasedOnState(par1World, par2, par3, par4);
} super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public int damageDropped(int meta) { public int damageDropped(int meta) {
return meta; return meta;
} }
@Override @Override
public Item getItemDropped(int par1, Random par2Random, int par3) { public Item getItemDropped(int par1, Random par2Random, int par3) {
return Item.getItemFromBlock(bottom); return Item.getItemFromBlock(bottom);
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public ItemStack getPickBlock(MovingObjectPosition mop, World world, int x, int y, int z) { public ItemStack getPickBlock(MovingObjectPosition mop, World world, int x, int y, int z) {
return new ItemStack(bottom, 1, world.getBlockMetadata(x, y, z)); return new ItemStack(bottom, 1, world.getBlockMetadata(x, y, z));
} }
@Override @Override
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata); return carverHelper.getIcon(side, metadata);
// return master.getIcon(side, metadata); // return master.getIcon(side, metadata);
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) { public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
if (isBottom) if (isBottom) super.getSubBlocks(block, tabs, list);
super.getSubBlocks(block, tabs, list); }
}
/** /**
* Checks if the block is a solid face on the given side, used by placement logic. * Checks if the block is a solid face on the given side, used by placement logic.
* *
* @param world * @param world The current world
* The current world * @param x X Position
* @param x * @param y Y position
* X Position * @param z Z position
* @param y * @param side The side to check
* Y position * @return True if the block is solid on the specified side.
* @param z */
* Z position @Override
* @param side public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
* The side to check return !isBottom && (side == UP);
* @return True if the block is solid on the specified side. }
*/
@Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
return !isBottom && (side == UP);
}
} }
@@ -2,11 +2,6 @@ package team.chisel.block;
import java.util.List; import java.util.List;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import team.chisel.client.render.RendererStairs;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs; import net.minecraft.block.BlockStairs;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -19,75 +14,81 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import team.chisel.client.render.RendererStairs;
public class BlockCarvableStairs extends BlockStairs implements ICarvable { public class BlockCarvableStairs extends BlockStairs implements ICarvable {
CarvableHelper carverHelper; CarvableHelper carverHelper;
int blockMeta; int blockMeta;
public BlockCarvableStairs(Block block, int meta, CarvableHelper helper) { public BlockCarvableStairs(Block block, int meta, CarvableHelper helper) {
super(block, meta); super(block, meta);
this.useNeighborBrightness = true; this.useNeighborBrightness = true;
carverHelper = helper; carverHelper = helper;
blockMeta = meta; blockMeta = meta;
} }
@Override @Override
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, blockMeta + metadata / 8); return carverHelper.getIcon(side, blockMeta + metadata / 8);
} }
@Override @Override
public int damageDropped(int i) { public int damageDropped(int i) {
return i / 8; return i / 8;
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
if (blockMeta == 0) if (blockMeta == 0) carverHelper.registerBlockIcons("Chisel", this, register);
carverHelper.registerBlockIcons("Chisel", this, register); }
}
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@Override @Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) { public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
list.add(new ItemStack(block, 1, 0)); list.add(new ItemStack(block, 1, 0));
list.add(new ItemStack(block, 1, 8)); list.add(new ItemStack(block, 1, 8));
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return RendererStairs.id; return RendererStairs.id;
} }
@Override @Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) { public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving,
int meta = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; ItemStack par6ItemStack) {
int meta = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
// 0->2 2->3 3->0 1->1 // 0->2 2->3 3->0 1->1
meta = meta == 0 ? 2 : meta == 2 ? 3 : meta == 3 ? 0 : 1; meta = meta == 0 ? 2 : meta == 2 ? 3 : meta == 3 ? 0 : 1;
meta += par1World.getBlockMetadata(par2, par3, par4) % 8; // add upside-down-ness meta += par1World.getBlockMetadata(par2, par3, par4) % 8; // add upside-down-ness
if (par6ItemStack.getItemDamage() >= 8) { if (par6ItemStack.getItemDamage() >= 8) {
meta += 8; meta += 8;
} }
par1World.setBlockMetadataWithNotify(par2, par3, par4, meta, 2); par1World.setBlockMetadataWithNotify(par2, par3, par4, meta, 2);
} }
@Override @Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float hx, float hy, float hz, int damage) { public int onBlockPlaced(World world, int x, int y, int z, int side, float hx, float hy, float hz, int damage) {
return side != 0 && (side == 1 || hy <= 0.5D) ? damage : damage + 4; return side != 0 && (side == 1 || hy <= 0.5D) ? damage : damage + 4;
} }
@Override @Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(blockMeta + (metadata / 8)); return carverHelper.getVariation(blockMeta + (metadata / 8));
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(blockMeta + (meta / 8)); return carverHelper.getVariation(blockMeta + (meta / 8));
} }
} }
@@ -2,83 +2,85 @@ package team.chisel.block;
import java.util.Random; import java.util.Random;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import team.chisel.Chisel;
import com.cricketcraft.chisel.api.ChiselTabs;
import net.minecraft.block.BlockTorch; import net.minecraft.block.BlockTorch;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.cricketcraft.chisel.api.ChiselTabs;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
public class BlockCarvableTorch extends BlockTorch implements ICarvable { public class BlockCarvableTorch extends BlockTorch implements ICarvable {
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
private String texLocation; private String texLocation;
protected boolean emitsParticles = true; protected boolean emitsParticles = true;
public int idx; public int idx;
public BlockCarvableTorch(int idx, String tex) { public BlockCarvableTorch(int idx, String tex) {
super(); super();
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks); setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
setLightLevel(0.9375F); setLightLevel(0.9375F);
setBlockName("torch"); setBlockName("torch");
this.idx = idx; this.idx = idx;
this.texLocation = tex; this.texLocation = tex;
} }
@Override @Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata); return carverHelper.getVariation(metadata);
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(meta);
} }
@Override @Override
public void registerBlockIcons(IIconRegister icon) { public void registerBlockIcons(IIconRegister icon) {
this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":torch/" + texLocation); this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":torch/" + texLocation);
} }
public BlockCarvableTorch disableParticles() { public BlockCarvableTorch disableParticles() {
this.emitsParticles = false; this.emitsParticles = false;
return this; return this;
} }
@Override @Override
@SideOnly(Side.CLIENT) @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_,
if (emitsParticles) { Random p_149734_5_) {
int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_); if (emitsParticles) {
double d0 = p_149734_2_ + 0.5F; int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_);
double d1 = p_149734_3_ + 0.7F; double d0 = p_149734_2_ + 0.5F;
double d2 = p_149734_4_ + 0.5F; double d1 = p_149734_3_ + 0.7F;
double d3 = 0.2199999988079071D; double d2 = p_149734_4_ + 0.5F;
double d4 = 0.27000001072883606D; double d3 = 0.2199999988079071D;
double d4 = 0.27000001072883606D;
if (l == 1) { if (l == 1) {
p_149734_1_.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
p_149734_1_.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
} else if (l == 2) { } else if (l == 2) {
p_149734_1_.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
p_149734_1_.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
} else if (l == 3) { } else if (l == 3) {
p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
} else if (l == 4) { } else if (l == 4) {
p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
} else { } else {
p_149734_1_.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
p_149734_1_.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); p_149734_1_.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
} }
} }
} }
} }
@@ -2,8 +2,6 @@ package team.chisel.block;
import java.util.List; import java.util.List;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockWall; import net.minecraft.block.BlockWall;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -11,34 +9,36 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
public class BlockCarvableWall extends BlockWall { public class BlockCarvableWall extends BlockWall {
CarvableHelper carverHelper; CarvableHelper carverHelper;
public BlockCarvableWall(Block block) { public BlockCarvableWall(Block block) {
super(block); super(block);
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
} }
@Override @Override
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata); return carverHelper.getIcon(side, metadata);
} }
@Override @Override
public int damageDropped(int i) { public int damageDropped(int i) {
return i; return i;
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register); carverHelper.registerBlockIcons("Chisel", this, register);
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@Override @Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) { public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list); carverHelper.registerSubBlocks(this, tabs, list);
} }
} }
+48 -47
View File
@@ -2,7 +2,6 @@ package team.chisel.block;
import java.util.Random; import java.util.Random;
import team.chisel.config.Configurations;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@@ -10,65 +9,67 @@ import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.config.Configurations;
public class BlockCloud extends BlockCarvable { public class BlockCloud extends BlockCarvable {
public BlockCloud() { public BlockCloud() {
super(Material.ice); super(Material.ice);
useNeighborBrightness = true; useNeighborBrightness = true;
} }
@Override @Override
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) { public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) {
entity.fallDistance = 0.0F; entity.fallDistance = 0.0F;
if (entity.motionY < 0.0D) { if (entity.motionY < 0.0D) {
entity.motionY *= 0.0050000000000000001D; entity.motionY *= 0.0050000000000000001D;
} else if (entity.motionY > 0) { } else if (entity.motionY > 0) {
entity.motionY += 0.0285; entity.motionY += 0.0285;
} }
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public int getRenderBlockPass() { public int getRenderBlockPass() {
return Configurations.ghostCloud ? 1 : 0; return Configurations.ghostCloud ? 1 : 0;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
Block block = world.getBlock(x, y, z); Block block = world.getBlock(x, y, z);
if (block == this) { if (block == this) {
return false; return false;
} }
return super.shouldSideBeRendered(world, x, y, z, side); return super.shouldSideBeRendered(world, x, y, z, side);
} }
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) { public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) {
return AxisAlignedBB.getBoundingBox(i + 0.2, j, k + 0.2, i + 0.8, j + 0.2, k + 0.8); return AxisAlignedBB.getBoundingBox(i + 0.2, j, k + 0.2, i + 0.8, j + 0.2, k + 0.8);
} }
@Override @Override
public Item getItemDropped(int par1, Random rand, int par3) { public Item getItemDropped(int par1, Random rand, int par3) {
return Item.getItemFromBlock(this); return Item.getItemFromBlock(this);
} }
@Override @Override
public int quantityDropped(Random rand) { public int quantityDropped(Random rand) {
return rand.nextInt(2); return rand.nextInt(2);
} }
@Override @Override
public int damageDropped(int meta) { public int damageDropped(int meta) {
return meta; return meta;
} }
} }
@@ -6,40 +6,48 @@ import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.MovementInput; import net.minecraft.util.MovementInput;
import net.minecraft.util.MovementInputFromOptions; import net.minecraft.util.MovementInputFromOptions;
import team.chisel.config.Configurations;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.config.Configurations;
public class BlockConcrete extends BlockCarvable { public class BlockConcrete extends BlockCarvable {
public BlockConcrete() { public BlockConcrete() {
super(); super();
FMLCommonHandler.instance().bus().register(this); FMLCommonHandler.instance()
} .bus()
.register(this);
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private static MovementInput manualInputCheck; private static MovementInput manualInputCheck;
@SubscribeEvent @SubscribeEvent
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void speedupPlayer(PlayerTickEvent event) { public void speedupPlayer(PlayerTickEvent event) {
if (event.phase == Phase.START && event.side.isClient() && event.player.onGround && event.player instanceof EntityPlayerSP) { if (event.phase == Phase.START && event.side.isClient()
if (manualInputCheck == null) { && event.player.onGround
manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings); && event.player instanceof EntityPlayerSP) {
} if (manualInputCheck == null) {
EntityPlayerSP player = (EntityPlayerSP) event.player; manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings);
Block below = player.worldObj.getBlock(MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY) - 2, MathHelper.floor_double(player.posZ)); }
if (below == this) { EntityPlayerSP player = (EntityPlayerSP) event.player;
manualInputCheck.updatePlayerMoveState(); Block below = player.worldObj.getBlock(
if (manualInputCheck.moveForward != 0 || manualInputCheck.moveStrafe != 0) { MathHelper.floor_double(player.posX),
player.motionX *= Configurations.concreteVelocityMult + 0.05; MathHelper.floor_double(player.posY) - 2,
player.motionZ *= Configurations.concreteVelocityMult + 0.05; MathHelper.floor_double(player.posZ));
} if (below == this) {
} manualInputCheck.updatePlayerMoveState();
} if (manualInputCheck.moveForward != 0 || manualInputCheck.moveStrafe != 0) {
} player.motionX *= Configurations.concreteVelocityMult + 0.05;
player.motionZ *= Configurations.concreteVelocityMult + 0.05;
}
}
}
}
} }
@@ -4,13 +4,13 @@ import team.chisel.Chisel;
public class BlockEldritch extends BlockCarvable { public class BlockEldritch extends BlockCarvable {
public BlockEldritch() { public BlockEldritch() {
super(); super();
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return Chisel.renderEldritchId; return Chisel.renderEldritchId;
} }
} }
@@ -2,33 +2,33 @@ package team.chisel.block;
import java.util.Random; import java.util.Random;
import team.chisel.Chisel;
import team.chisel.client.GeneralChiselClient;
import team.chisel.utils.General;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import team.chisel.Chisel;
import team.chisel.client.GeneralChiselClient;
import team.chisel.utils.General;
public class BlockGrimstone extends BlockCarvable { public class BlockGrimstone extends BlockCarvable {
public IIcon iconStar; public IIcon iconStar;
public BlockGrimstone(Material m) { public BlockGrimstone(Material m) {
super(m); super(m);
} }
@Override @Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) { public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (General.rand.nextInt(4) == 0 && world.isRemote) if (General.rand.nextInt(4) == 0 && world.isRemote) GeneralChiselClient.spawnGrimstoneFX(world, this, x, y, z);
GeneralChiselClient.spawnGrimstoneFX(world, this, x, y, z); }
}
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register); super.registerBlockIcons(register);
iconStar = register.registerIcon(Chisel.MOD_ID + ":grimstone/particles/star"); iconStar = register.registerIcon(Chisel.MOD_ID + ":grimstone/particles/star");
} }
} }
@@ -2,34 +2,34 @@ package team.chisel.block;
import java.util.Random; import java.util.Random;
import team.chisel.client.GeneralChiselClient;
import team.chisel.utils.General;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import team.chisel.client.GeneralChiselClient;
import team.chisel.utils.General;
public class BlockHolystone extends BlockCarvable { public class BlockHolystone extends BlockCarvable {
public IIcon iconStar; public IIcon iconStar;
public BlockHolystone(Material m) { public BlockHolystone(Material m) {
super(m); super(m);
this.setLightLevel(0.25F); this.setLightLevel(0.25F);
} }
@Override @Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) { public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (General.rand.nextInt(4) == 0 && world.isRemote) if (General.rand.nextInt(4) == 0 && world.isRemote) GeneralChiselClient.spawnHolystoneFX(world, this, x, y, z);
GeneralChiselClient.spawnHolystoneFX(world, this, x, y, z); }
}
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register); super.registerBlockIcons(register);
iconStar = register.registerIcon("Chisel:holystone/particles/star"); iconStar = register.registerIcon("Chisel:holystone/particles/star");
} }
} }
@@ -2,26 +2,26 @@ package team.chisel.block;
import java.util.Random; import java.util.Random;
import team.chisel.client.GeneralChiselClient;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.world.World; import net.minecraft.world.World;
import team.chisel.client.GeneralChiselClient;
public class BlockLavastone extends BlockMultiLayer { public class BlockLavastone extends BlockMultiLayer {
public BlockLavastone(Material mat, String baseIcon) { public BlockLavastone(Material mat, String baseIcon) {
super(mat, baseIcon); super(mat, baseIcon);
setLightLevel(1F); setLightLevel(1F);
} }
@Override @Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) { public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (random.nextInt(8) == 0 && world.isRemote) if (random.nextInt(8) == 0 && world.isRemote) GeneralChiselClient.spawnLavastoneFX(world, this, x, y, z);
GeneralChiselClient.spawnLavastoneFX(world, this, x, y, z); }
}
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return true; return true;
} }
} }
@@ -5,12 +5,12 @@ import net.minecraft.init.Blocks;
public class BlockLeaf extends BlockCarvable { public class BlockLeaf extends BlockCarvable {
public BlockLeaf(Material material) { public BlockLeaf(Material material) {
super(material); super(material);
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return Blocks.leaves.isOpaqueCube(); return Blocks.leaves.isOpaqueCube();
} }
} }
@@ -2,10 +2,6 @@ package team.chisel.block;
import java.util.List; import java.util.List;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -14,52 +10,56 @@ import net.minecraft.item.Item;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
public class BlockMultiLayer extends BlockMultiLayerBase implements ICarvable { public class BlockMultiLayer extends BlockMultiLayerBase implements ICarvable {
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
public BlockMultiLayer(Material mat, String baseIcon) { public BlockMultiLayer(Material mat, String baseIcon) {
super(mat, baseIcon); super(mat, baseIcon);
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
} }
public BlockMultiLayer(Material mat, Block block) { public BlockMultiLayer(Material mat, Block block) {
super(mat, block); super(mat, block);
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
} }
@Override @Override
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata); return carverHelper.getIcon(side, metadata);
} }
@Override @Override
public int damageDropped(int i) { public int damageDropped(int i) {
return i; return i;
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register); super.registerBlockIcons(register);
carverHelper.registerBlockIcons("Chisel", this, register); carverHelper.registerBlockIcons("Chisel", this, register);
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@Override @Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) { public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list); carverHelper.registerSubBlocks(this, tabs, list);
} }
@Override @Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata); return carverHelper.getVariation(metadata);
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(meta);
} }
} }
@@ -1,55 +1,55 @@
package team.chisel.block; package team.chisel.block;
import team.chisel.client.render.RendererMultiLayer;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.ForgeHooksClient;
import team.chisel.client.render.RendererMultiLayer;
public abstract class BlockMultiLayerBase extends Block { public abstract class BlockMultiLayerBase extends Block {
public Block base; public Block base;
public IIcon icon; public IIcon icon;
String iconFile; String iconFile;
public BlockMultiLayerBase(Material mat, Block base) { public BlockMultiLayerBase(Material mat, Block base) {
super(mat); super(mat);
this.base = base; this.base = base;
} }
public BlockMultiLayerBase(Material mat, String iconFile) { public BlockMultiLayerBase(Material mat, String iconFile) {
super(mat); super(mat);
this.iconFile = iconFile; this.iconFile = iconFile;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return RendererMultiLayer.id; return RendererMultiLayer.id;
} }
@Override @Override
public int getRenderBlockPass() { public int getRenderBlockPass() {
return 1; return 1;
} }
@Override @Override
public boolean canRenderInPass(int pass) { public boolean canRenderInPass(int pass) {
ForgeHooksClient.setRenderPass(pass); ForgeHooksClient.setRenderPass(pass);
return pass == 1 || pass == 0; return pass == 1 || pass == 0;
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
if (iconFile != null) if (iconFile != null) icon = register.registerIcon(iconFile);
icon = register.registerIcon(iconFile); }
}
} }
+189 -176
View File
@@ -2,12 +2,6 @@ package team.chisel.block;
import java.util.List; import java.util.List;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import team.chisel.Chisel;
import team.chisel.block.tileentity.TileEntityPresent;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -24,206 +18,225 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import com.cricketcraft.chisel.api.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
import team.chisel.block.tileentity.TileEntityPresent;
public class BlockPresent extends Block implements ICarvable { public class BlockPresent extends Block implements ICarvable {
public CarvableHelper carverHelper; public CarvableHelper carverHelper;
private float minX, minY, minZ, maxX, maxY, maxZ; private float minX, minY, minZ, maxX, maxY, maxZ;
public BlockPresent() { public BlockPresent() {
super(Material.wood); super(Material.wood);
carverHelper = new CarvableHelper(this); carverHelper = new CarvableHelper(this);
minX = 0.0625F; minX = 0.0625F;
minZ = 0.0625F; minZ = 0.0625F;
maxX = 0.9375F; maxX = 0.9375F;
maxY = 0.875F; maxY = 0.875F;
maxZ = 0.9375F; maxZ = 0.9375F;
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ); setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
} }
public String getModelTexture(int type) { public String getModelTexture(int type) {
return "textures/blocks/present/presentChest" + type; return "textures/blocks/present/presentChest" + type;
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@Override @Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) { public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
list.add(new ItemStack(item, 1, i)); list.add(new ItemStack(item, 1, i));
} }
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return -1; return -1;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, x, y, z, player, stack);
int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z); TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3); world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3);
te.setRotation(heading); te.setRotation(heading);
te.findConnections(); te.findConnections();
if (te.isConnected()) { if (te.isConnected()) {
TileEntityPresent other = te.getConnection(); TileEntityPresent other = te.getConnection();
other.setRotation(heading); other.setRotation(heading);
} }
world.markBlockForUpdate(x, y, z); world.markBlockForUpdate(x, y, z);
} }
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block present, int meta) { public void breakBlock(World world, int x, int y, int z, Block present, int meta) {
TileEntityPresent tileEntityPresent = (TileEntityPresent) world.getTileEntity(x, y, z); TileEntityPresent tileEntityPresent = (TileEntityPresent) world.getTileEntity(x, y, z);
if (tileEntityPresent != null) { if (tileEntityPresent != null) {
for (int c = 0; c < tileEntityPresent.getTrueSizeInventory(); c++) { for (int c = 0; c < tileEntityPresent.getTrueSizeInventory(); c++) {
ItemStack itemStack = tileEntityPresent.getTrueStackInSlot(c); ItemStack itemStack = tileEntityPresent.getTrueStackInSlot(c);
if (itemStack != null) { if (itemStack != null) {
dropBlockAsItem(world, x, y, z, itemStack); dropBlockAsItem(world, x, y, z, itemStack);
} }
} }
world.func_147453_f(x, y, z, this); world.func_147453_f(x, y, z, this);
} }
super.breakBlock(world, x, y, z, this, meta); super.breakBlock(world, x, y, z, this, meta);
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitX, float hitY, float hitZ, float p_149727_9_) { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitX, float hitY,
if (!world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) { float hitZ, float p_149727_9_) {
if (!world.isRemote) { if (!world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) {
player.openGui(Chisel.instance, 2, world, x, y, z); if (!world.isRemote) {
} player.openGui(Chisel.instance, 2, world, x, y, z);
return true; }
} return true;
return false; }
} return false;
}
@Override @Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) { public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
if (world.getTileEntity(x, y, z) instanceof TileEntityPresent) if (world.getTileEntity(x, y, z) instanceof TileEntityPresent)
return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z)); return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z));
else else return null;
return null; }
}
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
if (world.getTileEntity(x, y, z) instanceof TileEntityPresent) if (world.getTileEntity(x, y, z) instanceof TileEntityPresent)
return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z)); return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z));
else else return null;
return null; }
}
public AxisAlignedBB getBoundingBox(TileEntityPresent me) { public AxisAlignedBB getBoundingBox(TileEntityPresent me) {
if (me == null) { if (me == null) {
return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
} }
int x = me.xCoord, y = me.yCoord, z = me.zCoord; int x = me.xCoord, y = me.yCoord, z = me.zCoord;
if (me.isConnected()) { if (me.isConnected()) {
ForgeDirection dir = me.getConnectionDir(); ForgeDirection dir = me.getConnectionDir();
// warning: magic below! Do not change this conditional // warning: magic below! Do not change this conditional
if (dir == ForgeDirection.EAST || (me.isParent() && dir == ForgeDirection.SOUTH) || (!me.isParent() && dir == ForgeDirection.SOUTH)) { if (dir == ForgeDirection.EAST || (me.isParent() && dir == ForgeDirection.SOUTH)
return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX + dir.offsetX, y + maxY, z + maxZ + dir.offsetZ); || (!me.isParent() && dir == ForgeDirection.SOUTH)) {
} else { return AxisAlignedBB.getBoundingBox(
return AxisAlignedBB.getBoundingBox(x + dir.offsetX + minX, y + minY, z + dir.offsetZ + minZ, x + maxX, y + maxY, z + maxZ); x + minX,
} y + minY,
} z + minZ,
return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ); x + maxX + dir.offsetX,
} y + maxY,
z + maxZ + dir.offsetZ);
} else {
return AxisAlignedBB.getBoundingBox(
x + dir.offsetX + minX,
y + minY,
z + dir.offsetZ + minZ,
x + maxX,
y + maxY,
z + maxZ);
}
}
return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, x + maxX, y + maxY, z + maxZ);
}
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z); TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
if (!te.isConnected()) { if (!te.isConnected()) {
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F); setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
} else { } else {
ForgeDirection dir = te.getConnectionDir(); ForgeDirection dir = te.getConnectionDir();
switch (dir) { switch (dir) {
case EAST: case EAST:
setBlockBounds(0.0625F, 0, 0.0625F, 1, 0.875F, 0.9365F); setBlockBounds(0.0625F, 0, 0.0625F, 1, 0.875F, 0.9365F);
break; break;
case NORTH: case NORTH:
setBlockBounds(0.0625F, 0, 0, 0.9375F, 0.875F, 0.9365F); setBlockBounds(0.0625F, 0, 0, 0.9375F, 0.875F, 0.9365F);
break; break;
case SOUTH: case SOUTH:
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 1); setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 1);
break; break;
case WEST: case WEST:
setBlockBounds(0, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F); setBlockBounds(0, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
break; break;
default: default:
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F); setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
break; break;
} }
} }
} }
@Override @Override
public boolean hasTileEntity(int metadata) { public boolean hasTileEntity(int metadata) {
return true; return true;
} }
@Override @Override
public TileEntity createTileEntity(World world, int metadata) { public TileEntity createTileEntity(World world, int metadata) {
return new TileEntityPresent(); return new TileEntityPresent();
} }
@Override @Override
public boolean hasComparatorInputOverride() { public boolean hasComparatorInputOverride() {
return true; return true;
} }
@Override @Override
public int getComparatorInputOverride(World world, int x, int y, int z, int strength) { public int getComparatorInputOverride(World world, int x, int y, int z, int strength) {
TileEntity te = world.getTileEntity(x, y, z); TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityPresent) { if (te instanceof TileEntityPresent) {
return Container.calcRedstoneFromInventory((TileEntityPresent) te); return Container.calcRedstoneFromInventory((TileEntityPresent) te);
} }
return 0; return 0;
} }
@Override @Override
public int damageDropped(int meta) { public int damageDropped(int meta) {
return meta; return meta;
} }
@Override @Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); return new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
this.blockIcon = register.registerIcon("planks_oak"); this.blockIcon = register.registerIcon("planks_oak");
} }
@Override @Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) { public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata); return carverHelper.getVariation(metadata);
} }
@Override @Override
public IVariationInfo getManager(int meta) { public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta); return carverHelper.getVariation(meta);
} }
} }
@@ -1,7 +1,5 @@
package team.chisel.block; package team.chisel.block;
import team.chisel.Chisel;
import team.chisel.config.Configurations;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@@ -10,83 +8,87 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
import team.chisel.config.Configurations;
public class BlockRoadLine extends BlockCarvable { public class BlockRoadLine extends BlockCarvable {
public IIcon aloneIcon[] = new IIcon[4]; public IIcon aloneIcon[] = new IIcon[5];
public IIcon halfLineIcon[] = new IIcon[4]; public IIcon halfLineIcon[] = new IIcon[5];
public IIcon fullLineIcon[] = new IIcon[4]; public IIcon fullLineIcon[] = new IIcon[5];
public BlockRoadLine() { public BlockRoadLine() {
super(Material.circuits); super(Material.circuits);
if (Configurations.useRoadLineTool) { if (Configurations.useRoadLineTool) {
this.setHarvestLevel(Configurations.getRoadLineTool, Configurations.roadLineToolLevel); this.setHarvestLevel(Configurations.getRoadLineTool, Configurations.roadLineToolLevel);
} }
this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.00390625f, 1.0f); this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.00390625f, 1.0f);
// this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); // this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
} }
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
return null; return null;
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
public int getRenderType() { public int getRenderType() {
return Chisel.roadLineId; return Chisel.roadLineId;
} }
@Override @Override
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) { public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
return World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4) || par1World.getBlock(par2, par3 - 1, par4).equals(Blocks.glowstone); return World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4)
} || par1World.getBlock(par2, par3 - 1, par4)
.equals(Blocks.glowstone);
}
@Override @Override
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block block) { public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block block) {
if (par1World.isRemote) if (par1World.isRemote) return;
return;
if (!this.canPlaceBlockAt(par1World, par2, par3, par4)) { if (!this.canPlaceBlockAt(par1World, par2, par3, par4)) {
this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0); this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
par1World.setBlockToAir(par2, par3, par4); par1World.setBlockToAir(par2, par3, par4);
} }
super.onNeighborBlockChange(par1World, par2, par3, par4, block); super.onNeighborBlockChange(par1World, par2, par3, par4, block);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) { public void registerBlockIcons(IIconRegister reg) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 5; i++) {
String[] texNames = { "white", "yellow", "double-white", "double-yellow" }; String[] texNames = { "white", "yellow", "double-white", "double-yellow", "warning" };
aloneIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-center"); aloneIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-center");
halfLineIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-side"); halfLineIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-side");
fullLineIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-long"); fullLineIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-long");
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
return aloneIcon[metadata % aloneIcon.length]; return aloneIcon[metadata % aloneIcon.length];
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return getIcon(side, world.getBlockMetadata(x, y, z)); return getIcon(side, world.getBlockMetadata(x, y, z));
} }
} }
File diff suppressed because it is too large. Load diff
@@ -2,34 +2,35 @@ package team.chisel.block;
import java.util.Random; import java.util.Random;
import team.chisel.client.GeneralChiselClient;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import team.chisel.client.GeneralChiselClient;
public class BlockSnakestoneObsidian extends BlockSnakestone { public class BlockSnakestoneObsidian extends BlockSnakestone {
public static IIcon[] particles = new IIcon[8]; public static IIcon[] particles = new IIcon[8];
public BlockSnakestoneObsidian(String iconPrefix) { public BlockSnakestoneObsidian(String iconPrefix) {
super(iconPrefix); super(iconPrefix);
flipTopTextures = true; flipTopTextures = true;
} }
@Override @Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) { public void randomDisplayTick(World world, int x, int y, int z, Random random) {
GeneralChiselClient.spawnSnakestoneObsidianFX(world, this, x, y, z); GeneralChiselClient.spawnSnakestoneObsidianFX(world, this, x, y, z);
} }
@Override @Override
public void registerBlockIcons(IIconRegister register) { public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register); super.registerBlockIcons(register);
for (int i = 0; i < particles.length; i++) { for (int i = 0; i < particles.length; i++) {
particles[i] = register.registerIcon(iconPrefix + "particles/" + i); particles[i] = register.registerIcon(iconPrefix + "particles/" + i);
} }
} }
} }
@@ -4,12 +4,12 @@ import net.minecraft.block.material.Material;
public class BlockWaterstone extends BlockMultiLayer { public class BlockWaterstone extends BlockMultiLayer {
public BlockWaterstone(Material mat, String baseIcon) { public BlockWaterstone(Material mat, String baseIcon) {
super(mat, baseIcon); super(mat, baseIcon);
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return true; return true;
} }
} }
@@ -2,41 +2,49 @@ package team.chisel.block;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import team.chisel.carving.Carving;
import team.chisel.item.ItemCarvable;
import com.cricketcraft.chisel.api.ChiselTabs; import com.cricketcraft.chisel.api.ChiselTabs;
import com.cricketcraft.chisel.api.carving.CarvableHelper; import com.cricketcraft.chisel.api.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.CarvingUtils; import com.cricketcraft.chisel.api.carving.CarvingUtils;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import team.chisel.carving.Carving;
import team.chisel.item.ItemCarvable;
public class CarvableStairsMaker { public class CarvableStairsMaker {
public final CarvableHelper carverHelper; public final CarvableHelper carverHelper;
private Block blockBase; private Block blockBase;
public CarvableStairsMaker(Block base) { public CarvableStairsMaker(Block base) {
blockBase = base; blockBase = base;
carverHelper = new CarvableHelper(base); carverHelper = new CarvableHelper(base);
} }
public void create(String name, Block[] blocks) { public void create(String name, Block[] blocks) {
create(null, name, blocks); create(null, name, blocks);
} }
public void create(IStairsCreator creator, String name, Block[] blocks) { public void create(IStairsCreator creator, String name, Block[] blocks) {
for (int i = 0; i < blocks.length; i++) { for (int i = 0; i < blocks.length; i++) {
String n = name + "." + i; String n = name + "." + i;
blocks[i] = creator == null ? new BlockCarvableStairs(blockBase, i * 2, carverHelper) : creator.create(blockBase, i * 2, carverHelper); blocks[i] = creator == null ? new BlockCarvableStairs(blockBase, i * 2, carverHelper)
: creator.create(blockBase, i * 2, carverHelper);
blocks[i].setBlockName("chisel." + n).setCreativeTab(ChiselTabs.tabStairChiselBlocks); blocks[i].setBlockName("chisel." + n)
GameRegistry.registerBlock(blocks[i], ItemCarvable.class, n); .setCreativeTab(ChiselTabs.tabStairChiselBlocks);
GameRegistry.registerBlock(blocks[i], ItemCarvable.class, n);
for (int meta = 0; meta < 2 && i * 2 + meta < carverHelper.infoList.size(); meta++) { for (int meta = 0; meta < 2 && i * 2 + meta < carverHelper.infoList.size(); meta++) {
Carving.chisel.addVariation(name, CarvingUtils.getDefaultVariationFor(blocks[i], meta * 8, i)); Carving.chisel.addVariation(name, CarvingUtils.getDefaultVariationFor(blocks[i], meta * 8, i));
GameRegistry.addRecipe(new ItemStack(blocks[i], 4, meta * 8), "* ", "** ", "***", '*', new ItemStack(blockBase, 1, i * 2 + meta)); GameRegistry.addRecipe(
} new ItemStack(blocks[i], 4, meta * 8),
} "* ",
} "** ",
"***",
'*',
new ItemStack(blockBase, 1, i * 2 + meta));
}
}
}
} }
@@ -1,10 +1,10 @@
package team.chisel.block; package team.chisel.block;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
public interface IStairsCreator { public interface IStairsCreator {
public BlockCarvableStairs create(Block block, int meta, CarvableHelper helper); public BlockCarvableStairs create(Block block, int meta, CarvableHelper helper);
} }
@@ -4,26 +4,23 @@ import net.minecraft.item.ItemStack;
public interface IDoubleChest { public interface IDoubleChest {
/** /**
* @return The size of this specific chest's inventory. Does not account for the connection. * @return The size of this specific chest's inventory. Does not account for the connection.
*/ */
int getTrueSizeInventory(); int getTrueSizeInventory();
/** /**
* @param slot * @param slot The true slot index.
* The true slot index. * @return The actual stack in this chest's slot. Does not account for the connection.
* @return The actual stack in this chest's slot. Does not account for the connection. */
*/ ItemStack getTrueStackInSlot(int slot);
ItemStack getTrueStackInSlot(int slot);
/** /**
* Puts a stack in this chest's real slot at the given true index. * Puts a stack in this chest's real slot at the given true index.
* *
* @param slot * @param slot The true slot index.
* The true slot index. * @param stack The ItemStack to place in the slot.
* @param stack */
* The ItemStack to place in the slot. void putStackInTrueSlot(int slot, ItemStack stack);
*/
void putStackInTrueSlot(int slot, ItemStack stack);
} }
@@ -14,6 +14,11 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import com.cricketcraft.chisel.api.IChiselItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Features; import team.chisel.Features;
import team.chisel.carving.Carving; import team.chisel.carving.Carving;
import team.chisel.client.GeneralChiselClient; import team.chisel.client.GeneralChiselClient;
@@ -23,444 +28,457 @@ import team.chisel.network.message.MessageAutoChisel;
import team.chisel.network.message.MessageSlotUpdate; import team.chisel.network.message.MessageSlotUpdate;
import team.chisel.utils.General; import team.chisel.utils.General;
import com.cricketcraft.chisel.api.IChiselItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileEntityAutoChisel extends TileEntity implements ISidedInventory { public class TileEntityAutoChisel extends TileEntity implements ISidedInventory {
public enum Upgrade { public enum Upgrade {
SPEED,
AUTOMATION, SPEED,
STACK, AUTOMATION,
REVERSION; STACK,
REVERSION;
public String getUnlocalizedName() {
if (Features.AUTO_CHISEL_UPGRADES.enabled()) { public String getUnlocalizedName() {
return "item.upgrade_" + this.name().toLowerCase(); if (Features.AUTO_CHISEL_UPGRADES.enabled()) {
} return "item.upgrade_" + this.name()
return "chisel.autochisel.upgrade.disabled"; .toLowerCase();
} }
return "chisel.autochisel.upgrade.disabled";
public String getLocalizedName() { }
String ret = StatCollector.translateToLocal("autochisel.slot." + this.name().toLowerCase() + ".tooltip");
if (!Features.AUTO_CHISEL_UPGRADES.enabled()) { public String getLocalizedName() {
ret = EnumChatFormatting.RED.toString().concat(ret); String ret = StatCollector.translateToLocal(
} "autochisel.slot." + this.name()
return ret; .toLowerCase() + ".tooltip");
} if (!Features.AUTO_CHISEL_UPGRADES.enabled()) {
} ret = EnumChatFormatting.RED.toString()
.concat(ret);
public static final int BASE = 0, TARGET = 1, OUTPUT = 2, CHISEL = 3, MIN_UPGRADE = 4; }
private static final int FAST_SPEED = 1, SLOW_SPEED = 4; return ret;
}
private int progress = 0; }
private static EntityItem ghostItem; public static final int BASE = 0, TARGET = 1, OUTPUT = 2, CHISEL = 3, MIN_UPGRADE = 4;
boolean equal = false; private static final int FAST_SPEED = 1, SLOW_SPEED = 4;
private ItemStack[] inventory = new ItemStack[8];
private String name = "autoChisel"; private int progress = 0;
// client animation fields private static EntityItem ghostItem;
boolean equal = false;
// used for floating target private ItemStack[] inventory = new ItemStack[8];
public float xRot, yRot, zRot; private String name = "autoChisel";
// used for chisel item rotation // client animation fields
public static final int maxRot = 60;
public static final int rotAmnt = 15; // used for floating target
public float chiselRot; public float xRot, yRot, zRot;
public boolean chiseling = false, breakChisel = false;;
public int toChisel = 1; // used for chisel item rotation
public static final int maxRot = 60;
private ItemStack lastBase; public static final int rotAmnt = 15;
public float chiselRot;
@Override public boolean chiseling = false, breakChisel = false;;
public boolean canUpdate() { public int toChisel = 1;
return true;
} private ItemStack lastBase;
@Override @Override
public ItemStack decrStackSize(int slot, int size) { public boolean canUpdate() {
if (inventory[slot] != null) { return true;
ItemStack is; }
if (inventory[slot].stackSize <= size) {
is = inventory[slot]; @Override
inventory[slot] = null; public ItemStack decrStackSize(int slot, int size) {
return is; if (inventory[slot] != null) {
} else { ItemStack is;
is = inventory[slot].splitStack(size); if (inventory[slot].stackSize <= size) {
if (inventory[slot].stackSize == 0) is = inventory[slot];
inventory[slot] = null; inventory[slot] = null;
return is; return is;
} } else {
} else { is = inventory[slot].splitStack(size);
return null; if (inventory[slot].stackSize == 0) inventory[slot] = null;
} return is;
} }
} else {
@Override return null;
public void readFromNBT(NBTTagCompound nbt) { }
super.readFromNBT(nbt); }
NBTTagList tags = nbt.getTagList("Items", 10);
inventory = new ItemStack[getSizeInventory()]; @Override
public void readFromNBT(NBTTagCompound nbt) {
for (int i = 0; i < tags.tagCount(); i++) { super.readFromNBT(nbt);
NBTTagCompound data = tags.getCompoundTagAt(i); NBTTagList tags = nbt.getTagList("Items", 10);
int j = data.getByte("Slot") & 255; inventory = new ItemStack[getSizeInventory()];
if (j >= 0 && j < inventory.length) { for (int i = 0; i < tags.tagCount(); i++) {
inventory[j] = ItemStack.loadItemStackFromNBT(data); NBTTagCompound data = tags.getCompoundTagAt(i);
} int j = data.getByte("Slot") & 255;
}
if (j >= 0 && j < inventory.length) {
if (nbt.hasKey("CustomName", 8)) { inventory[j] = ItemStack.loadItemStackFromNBT(data);
this.name = nbt.getString("CustomName"); }
} }
}
if (nbt.hasKey("CustomName", 8)) {
@Override this.name = nbt.getString("CustomName");
public void updateEntity() { }
}
ItemStack base = inventory[BASE], target = getTarget(), output = inventory[OUTPUT];
@Override
if (!worldObj.isRemote && hasChisel() && base != null && target != null) { public void updateEntity() {
if (canBeMadeFrom(base, target)) {
if (progress >= (hasUpgrade(Upgrade.SPEED) ? FAST_SPEED : SLOW_SPEED)) { ItemStack base = inventory[BASE], target = getTarget(), output = inventory[OUTPUT];
// reset progress if (!worldObj.isRemote && hasChisel() && base != null && target != null) {
progress = 0; if (canBeMadeFrom(base, target)) {
if (progress >= (hasUpgrade(Upgrade.SPEED) ? FAST_SPEED : SLOW_SPEED)) {
// the max possible for this craft
int canBeMade = target.getMaxStackSize(); // reset progress
progress = 0;
// if there are items in the output, they count towards the max we can make
if (output != null) { // the max possible for this craft
canBeMade -= output.stackSize; int canBeMade = target.getMaxStackSize();
}
// if there are items in the output, they count towards the max we can make
// can't make more than we have if (output != null) {
canBeMade = Math.min(base.stackSize, canBeMade); canBeMade -= output.stackSize;
}
// if we can't make any, forget it
if (canBeMade <= 0) { // can't make more than we have
return; canBeMade = Math.min(base.stackSize, canBeMade);
}
// if we can't make any, forget it
// result will always be a copy of the target if (canBeMade <= 0) {
ItemStack chiseled = target.copy(); return;
}
// if we have the stack upgrade, boost the stack size to the max possible, otherwise just one
chiseled.stackSize = hasUpgrade(Upgrade.STACK) ? canBeMade : 1; // result will always be a copy of the target
ItemStack chiseled = target.copy();
if (canChisel(chiseled)) {
// if our output is empty, just use the current result // if we have the stack upgrade, boost the stack size to the max possible, otherwise just one
if (output == null) { chiseled.stackSize = hasUpgrade(Upgrade.STACK) ? canBeMade : 1;
setInventorySlotContents(OUTPUT, chiseled);
} else { if (canChisel(chiseled)) {
// otherwise just add our result to the existing stack // if our output is empty, just use the current result
inventory[OUTPUT].stackSize += chiseled.stackSize; if (output == null) {
slotChanged(OUTPUT); setInventorySlotContents(OUTPUT, chiseled);
} } else {
// otherwise just add our result to the existing stack
chiselItem(chiseled.stackSize, target); inventory[OUTPUT].stackSize += chiseled.stackSize;
slotChanged(OUTPUT);
// remove what we made from the stack }
base.stackSize -= chiseled.stackSize;
if (base.stackSize <= 0) { chiselItem(chiseled.stackSize, target);
setInventorySlotContents(BASE, null); // clear out 0 size itemstacks
} // remove what we made from the stack
} base.stackSize -= chiseled.stackSize;
} else if (worldObj.getTotalWorldTime() % 10 == 0) { if (base.stackSize <= 0) {
progress++; setInventorySlotContents(BASE, null); // clear out 0 size itemstacks
} }
} }
} else if (worldObj.isRemote) { } else if (worldObj.getTotalWorldTime() % 10 == 0) {
if (chiseling) { progress++;
chiselRot += rotAmnt; }
if (chiselRot >= maxRot) { }
chiselItem(0, getTarget()); } else if (worldObj.isRemote) {
} if (chiseling) {
} else { chiselRot += rotAmnt;
chiselRot = Math.max(chiselRot - rotAmnt, 0); if (chiselRot >= maxRot) {
} chiselItem(0, getTarget());
} }
} } else {
chiselRot = Math.max(chiselRot - rotAmnt, 0);
private ItemStack getTarget() { }
if (inventory[BASE] != null && hasUpgrade(Upgrade.REVERSION)) { }
// if we have a reversion upgrade, use that for the target }
List<ItemStack> possible = Carving.chisel.getItemsForChiseling(inventory[BASE]);
return possible.isEmpty() ? null : possible.get(0); private ItemStack getTarget() {
} else { if (inventory[BASE] != null && hasUpgrade(Upgrade.REVERSION)) {
return inventory[TARGET]; // if we have a reversion upgrade, use that for the target
} List<ItemStack> possible = Carving.chisel.getItemsForChiseling(inventory[BASE]);
} return possible.isEmpty() ? null : possible.get(0);
} else {
// lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target return inventory[TARGET];
private boolean canBeMadeFrom(ItemStack from, ItemStack to) { }
List<ItemStack> results = Carving.chisel.getItemsForChiseling(from); }
for (ItemStack s : results) {
if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) { // lets make sure the user isn't trying to make something from a block that doesn't have this as a valid target
return true; private boolean canBeMadeFrom(ItemStack from, ItemStack to) {
} List<ItemStack> results = Carving.chisel.getItemsForChiseling(from);
} for (ItemStack s : results) {
return false; if (s.getItem() == to.getItem() && s.getItemDamage() == to.getItemDamage()) {
} return true;
}
private boolean canChisel(ItemStack toMerge) { }
// if the output slot is empty we can merge without checking return false;
if (inventory[OUTPUT] == null) { }
return true;
} private boolean canChisel(ItemStack toMerge) {
// if the output slot is empty we can merge without checking
// need to check NBT as well as item if (inventory[OUTPUT] == null) {
if (!toMerge.isItemEqual(inventory[OUTPUT]) || !ItemStack.areItemStackTagsEqual(toMerge, inventory[OUTPUT])) { return true;
return false; }
}
// need to check NBT as well as item
// we only care about metadata if the item has subtypes if (!toMerge.isItemEqual(inventory[OUTPUT]) || !ItemStack.areItemStackTagsEqual(toMerge, inventory[OUTPUT])) {
if (toMerge.getHasSubtypes() && toMerge.getItemDamage() != inventory[OUTPUT].getItemDamage()) { return false;
return false; }
}
// we only care about metadata if the item has subtypes
return ((IChiselItem) inventory[CHISEL].getItem()).canChisel(worldObj, inventory[CHISEL], General.getVariation(getTarget())); if (toMerge.getHasSubtypes() && toMerge.getItemDamage() != inventory[OUTPUT].getItemDamage()) {
} return false;
}
private boolean hasChisel() {
return inventory[CHISEL] != null && inventory[CHISEL].getItem() instanceof IChiselItem && inventory[CHISEL].stackSize >= 1; return ((IChiselItem) inventory[CHISEL].getItem())
} .canChisel(worldObj, inventory[CHISEL], General.getVariation(getTarget()));
}
/** Calls IChiselItem#onChisel() and sends the chisel packet for sound/animation */
private void chiselItem(int chiseled, ItemStack target) { private boolean hasChisel() {
if (!worldObj.isRemote) { return inventory[CHISEL] != null && inventory[CHISEL].getItem() instanceof IChiselItem
boolean breakChisel = false; && inventory[CHISEL].stackSize >= 1;
if (((IChiselItem) inventory[CHISEL].getItem()).onChisel(worldObj, inventory[CHISEL], General.getVariation(target))) { }
inventory[CHISEL].setItemDamage(inventory[CHISEL].getItemDamage() + 1);
if (inventory[CHISEL].getItemDamage() >= inventory[CHISEL].getMaxDamage()) { /** Calls IChiselItem#onChisel() and sends the chisel packet for sound/animation */
setInventorySlotContents(CHISEL, null); private void chiselItem(int chiseled, ItemStack target) {
breakChisel = true; if (!worldObj.isRemote) {
} boolean breakChisel = false;
} if (((IChiselItem) inventory[CHISEL].getItem())
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, chiseled, true, breakChisel), worldObj.provider.dimensionId); .onChisel(worldObj, inventory[CHISEL], General.getVariation(target))) {
} else { inventory[CHISEL].setItemDamage(inventory[CHISEL].getItemDamage() + 1);
if (breakChisel) { if (inventory[CHISEL].getItemDamage() >= inventory[CHISEL].getMaxDamage()) {
worldObj.playSound(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "random.break", 0.8F, 0.8F + worldObj.rand.nextFloat() * 0.4F, false); setInventorySlotContents(CHISEL, null);
} breakChisel = true;
GeneralChiselClient.spawnAutoChiselFX(this, lastBase != null ? lastBase : inventory[BASE]); }
chiseling = false; }
if (lastBase != null) { PacketHandler.INSTANCE.sendToDimension(
lastBase.stackSize -= toChisel; new MessageAutoChisel(this, chiseled, true, breakChisel),
if (lastBase.stackSize <= 0) { worldObj.provider.dimensionId);
lastBase = null; } else {
} if (breakChisel) {
} worldObj.playSound(
} xCoord + 0.5,
} yCoord + 0.5,
zCoord + 0.5,
@Override "random.break",
public void writeToNBT(NBTTagCompound nbt) { 0.8F,
super.writeToNBT(nbt); 0.8F + worldObj.rand.nextFloat() * 0.4F,
NBTTagList tags = new NBTTagList(); false);
}
for (int i = 0; i < inventory.length; i++) { GeneralChiselClient.spawnAutoChiselFX(this, lastBase != null ? lastBase : inventory[BASE]);
if (inventory[i] != null) { chiseling = false;
NBTTagCompound data = new NBTTagCompound(); if (lastBase != null) {
data.setByte("Slot", (byte) i); lastBase.stackSize -= toChisel;
inventory[i].writeToNBT(data); if (lastBase.stackSize <= 0) {
tags.appendTag(data); lastBase = null;
} }
} }
}
nbt.setTag("Items", tags); }
if (this.hasCustomInventoryName()) { @Override
nbt.setString("CustomName", this.name); public void writeToNBT(NBTTagCompound nbt) {
} super.writeToNBT(nbt);
} NBTTagList tags = new NBTTagList();
@Override for (int i = 0; i < inventory.length; i++) {
public int getSizeInventory() { if (inventory[i] != null) {
return inventory.length; NBTTagCompound data = new NBTTagCompound();
} data.setByte("Slot", (byte) i);
inventory[i].writeToNBT(data);
@Override tags.appendTag(data);
public ItemStack getStackInSlot(int slot) { }
return inventory[slot]; }
}
nbt.setTag("Items", tags);
@Override
public ItemStack getStackInSlotOnClosing(int slot) { if (this.hasCustomInventoryName()) {
if (inventory[slot] != null) { nbt.setString("CustomName", this.name);
ItemStack is = inventory[slot]; }
inventory[slot] = null; }
return is;
} else @Override
return null; public int getSizeInventory() {
} return inventory.length;
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) { @Override
inventory[slot] = stack; public ItemStack getStackInSlot(int slot) {
return inventory[slot];
if (stack != null && stack.stackSize > getInventoryStackLimit()) { }
stack.stackSize = getInventoryStackLimit();
} @Override
public ItemStack getStackInSlotOnClosing(int slot) {
if (worldObj.isRemote && slot == BASE && stack != null) { if (inventory[slot] != null) {
lastBase = stack.copy(); ItemStack is = inventory[slot];
} inventory[slot] = null;
return is;
if (!worldObj.isRemote) { } else return null;
slotChanged(slot); }
}
} @Override
public void setInventorySlotContents(int slot, ItemStack stack) {
private void slotChanged(int slot) { inventory[slot] = stack;
PacketHandler.INSTANCE.sendToDimension(new MessageSlotUpdate(this, slot, inventory[slot]), worldObj.provider.dimensionId);
markDirty(); if (stack != null && stack.stackSize > getInventoryStackLimit()) {
} stack.stackSize = getInventoryStackLimit();
}
@Override
public String getInventoryName() { if (worldObj.isRemote && slot == BASE && stack != null) {
return name; lastBase = stack.copy();
} }
@Override if (!worldObj.isRemote) {
public final boolean isUseableByPlayer(EntityPlayer player) { slotChanged(slot);
return true; }
} }
@Override private void slotChanged(int slot) {
public int getInventoryStackLimit() { PacketHandler.INSTANCE
return 64; .sendToDimension(new MessageSlotUpdate(this, slot, inventory[slot]), worldObj.provider.dimensionId);
} markDirty();
}
@Override
public boolean hasCustomInventoryName() { @Override
return false; public String getInventoryName() {
} return name;
}
@Override
public int[] getAccessibleSlotsFromSide(int side) { @Override
return new int[] { BASE, TARGET, OUTPUT, CHISEL }; public final boolean isUseableByPlayer(EntityPlayer player) {
} return true;
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemStack) { @Override
if (itemStack == null) { public int getInventoryStackLimit() {
return false; return 64;
} }
switch (slot) { @Override
case BASE: public boolean hasCustomInventoryName() {
case TARGET: return false;
return !Carving.chisel.getItemsForChiseling(itemStack).isEmpty(); }
case OUTPUT:
return false; @Override
case CHISEL: public int[] getAccessibleSlotsFromSide(int side) {
return itemStack.getItem() instanceof IChiselItem; return new int[] { BASE, TARGET, OUTPUT, CHISEL };
default: }
return Features.AUTO_CHISEL_UPGRADES.enabled() && itemStack.getItem() == ChiselItems.upgrade && Upgrade.values()[slot - MIN_UPGRADE].ordinal() == itemStack.getItemDamage();
} @Override
} public boolean isItemValidForSlot(int slot, ItemStack itemStack) {
if (itemStack == null) {
@Override return false;
public boolean canInsertItem(int slot, ItemStack itemStack, int side) { }
return hasUpgrade(Upgrade.AUTOMATION) && (slot == BASE || slot == TARGET || slot == CHISEL);
} switch (slot) {
case BASE:
@Override case TARGET:
public boolean canExtractItem(int slot, ItemStack itemStack, int side) { return !Carving.chisel.getItemsForChiseling(itemStack)
return hasUpgrade(Upgrade.AUTOMATION) && slot == OUTPUT; .isEmpty();
} case OUTPUT:
return false;
@Override case CHISEL:
public void openInventory() { return itemStack.getItem() instanceof IChiselItem;
; default:
} return Features.AUTO_CHISEL_UPGRADES.enabled() && itemStack.getItem() == ChiselItems.upgrade
&& Upgrade.values()[slot - MIN_UPGRADE].ordinal() == itemStack.getItemDamage();
@Override }
public void closeInventory() { }
;
} @Override
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
@SideOnly(Side.CLIENT) return hasUpgrade(Upgrade.AUTOMATION) && (slot == BASE || slot == TARGET || slot == CHISEL);
public EntityItem getItemForRendering(int slot) { }
if (ghostItem == null) {
ghostItem = new EntityItem(worldObj); @Override
ghostItem.hoverStart = 0.0F; public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
} return hasUpgrade(Upgrade.AUTOMATION) && slot == OUTPUT;
}
if (slot == BASE && lastBase != null) {
ghostItem.setEntityItemStack(lastBase.copy()); @Override
return ghostItem; public void openInventory() {
} else if (slot == TARGET) { ;
ItemStack target = getTarget(); }
if (target != null) {
ghostItem.setEntityItemStack(target); @Override
return ghostItem; public void closeInventory() {
} ;
return null; }
} else if (inventory[slot] == null) {
return null; @SideOnly(Side.CLIENT)
} else { public EntityItem getItemForRendering(int slot) {
ghostItem.setEntityItemStack(inventory[slot].copy()); if (ghostItem == null) {
return ghostItem; ghostItem = new EntityItem(worldObj);
} ghostItem.hoverStart = 0.0F;
} }
@Override if (slot == BASE && lastBase != null) {
public Packet getDescriptionPacket() { ghostItem.setEntityItemStack(lastBase.copy());
NBTTagCompound tag = new NBTTagCompound(); return ghostItem;
writeToNBT(tag); } else if (slot == TARGET) {
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); ItemStack target = getTarget();
} if (target != null) {
ghostItem.setEntityItemStack(target);
@Override return ghostItem;
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { }
readFromNBT(packet.func_148857_g()); return null;
} } else if (inventory[slot] == null) {
return null;
public boolean hasUpgrade(Upgrade upgrade) { } else {
if (Features.AUTO_CHISEL_UPGRADES.enabled()) { ghostItem.setEntityItemStack(inventory[slot].copy());
ItemStack stack = inventory[MIN_UPGRADE + upgrade.ordinal()]; return ghostItem;
if (stack != null) { }
return stack.getItem() == ChiselItems.upgrade && stack.getItemDamage() == upgrade.ordinal(); }
}
return false; @Override
} public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
return upgrade == Upgrade.REVERSION ? false : true; writeToNBT(tag);
} return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}
public String getSlotTooltipUnloc(int slotNumber) {
String base = "autochisel.slot.%s.tooltip"; @Override
String name = null; public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
if (slotNumber < MIN_UPGRADE) { readFromNBT(packet.func_148857_g());
if (slotNumber == TARGET) { }
name = "target";
} else if (slotNumber == CHISEL) { public boolean hasUpgrade(Upgrade upgrade) {
name = "chisel"; if (Features.AUTO_CHISEL_UPGRADES.enabled()) {
} ItemStack stack = inventory[MIN_UPGRADE + upgrade.ordinal()];
String unloc = name == null ? null : String.format(base, name); if (stack != null) {
return StatCollector.translateToLocal(unloc); return stack.getItem() == ChiselItems.upgrade && stack.getItemDamage() == upgrade.ordinal();
} else { }
return Upgrade.values()[slotNumber - MIN_UPGRADE].getLocalizedName(); return false;
} }
}
return upgrade == Upgrade.REVERSION ? false : true;
public void doChiselAnim(ItemStack lastChiseled, int chiseled, boolean playSound, boolean breakChisel) { }
this.lastBase = lastChiseled == null ? null : lastChiseled.copy();
this.toChisel = chiseled; public String getSlotTooltipUnloc(int slotNumber) {
if (playSound) { String base = "autochisel.slot.%s.tooltip";
this.chiseling = true; String name = null;
} if (slotNumber < MIN_UPGRADE) {
this.breakChisel = breakChisel; if (slotNumber == TARGET) {
} name = "target";
} else if (slotNumber == CHISEL) {
public ItemStack getLastBase() { name = "chisel";
return lastBase == null ? null : lastBase.copy(); }
} String unloc = name == null ? null : String.format(base, name);
return StatCollector.translateToLocal(unloc);
} else {
return Upgrade.values()[slotNumber - MIN_UPGRADE].getLocalizedName();
}
}
public void doChiselAnim(ItemStack lastChiseled, int chiseled, boolean playSound, boolean breakChisel) {
this.lastBase = lastChiseled == null ? null : lastChiseled.copy();
this.toChisel = chiseled;
if (playSound) {
this.chiseling = true;
}
this.breakChisel = breakChisel;
}
public ItemStack getLastBase() {
return lastBase == null ? null : lastBase.copy();
}
} }
@@ -2,14 +2,15 @@ package team.chisel.block.tileentity;
import net.minecraft.tileentity.TileEntityBeacon; import net.minecraft.tileentity.TileEntityBeacon;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class TileEntityCarvableBeacon extends TileEntityBeacon { public class TileEntityCarvableBeacon extends TileEntityBeacon {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
return INFINITE_EXTENT_AABB; return INFINITE_EXTENT_AABB;
} }
} }
@@ -1,8 +1,5 @@
package team.chisel.block.tileentity; package team.chisel.block.tileentity;
import team.chisel.init.ChiselBlocks;
import team.chisel.network.PacketHandler;
import team.chisel.network.message.MessagePresentConnect;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
@@ -17,349 +14,358 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import team.chisel.init.ChiselBlocks;
import team.chisel.network.PacketHandler;
import team.chisel.network.message.MessagePresentConnect;
public class TileEntityPresent extends TileEntity implements IInventory, IDoubleChest { public class TileEntityPresent extends TileEntity implements IInventory, IDoubleChest {
private TileEntityPresent connection = null; private TileEntityPresent connection = null;
// If cachedDir is non-null, but connection is null, this present must be // If cachedDir is non-null, but connection is null, this present must be
// connected to an unloaded present. This is handled appropriately. // connected to an unloaded present. This is handled appropriately.
private ForgeDirection cachedDir = null; private ForgeDirection cachedDir = null;
private boolean isParent; private boolean isParent;
private final ItemStack[] inventory = new ItemStack[27]; private final ItemStack[] inventory = new ItemStack[27];
private int rotation; private int rotation;
private boolean autoSearch = true; private boolean autoSearch = true;
@Override @Override
public void updateEntity() { public void updateEntity() {
if (!isConnected() && autoSearch && worldObj != null /* ugh */) { if (!isConnected() && autoSearch && worldObj != null /* ugh */) {
if (cachedDir != null) { if (cachedDir != null) {
connectTo(cachedDir); connectTo(cachedDir);
} else if (!worldObj.isRemote) { } else if (!worldObj.isRemote) {
findConnections(); findConnections();
} }
autoSearch = false; autoSearch = false;
} }
} }
public boolean isConnected() { public boolean isConnected() {
return connection != null; return connection != null;
} }
private boolean connectTo(TileEntityPresent present, ForgeDirection dir) { private boolean connectTo(TileEntityPresent present, ForgeDirection dir) {
if (present.getBlockMetadata() == getBlockMetadata() && !present.isConnected() && (present.cachedDir == null || present.cachedDir == dir.getOpposite()) if (present.getBlockMetadata() == getBlockMetadata() && !present.isConnected()
&& Math.abs(present.xCoord - xCoord + present.yCoord - yCoord + present.zCoord - zCoord) == 1) { && (present.cachedDir == null || present.cachedDir == dir.getOpposite())
connection = present; && Math.abs(present.xCoord - xCoord + present.yCoord - yCoord + present.zCoord - zCoord) == 1) {
connection.connection = this; connection = present;
connection.cachedDir = dir.getOpposite(); connection.connection = this;
connection.markDirty(); connection.cachedDir = dir.getOpposite();
cachedDir = dir; connection.markDirty();
isParent = !present.isParent; cachedDir = dir;
markDirty(); isParent = !present.isParent;
PacketHandler.INSTANCE.sendToDimension(new MessagePresentConnect(this, dir, true), worldObj.provider.dimensionId); markDirty();
return true; PacketHandler.INSTANCE
} .sendToDimension(new MessagePresentConnect(this, dir, true), worldObj.provider.dimensionId);
return false; return true;
} }
return false;
}
public boolean connectTo(ForgeDirection dir) { public boolean connectTo(ForgeDirection dir) {
int x = xCoord + dir.offsetX, y = yCoord + dir.offsetY, z = zCoord + dir.offsetZ; int x = xCoord + dir.offsetX, y = yCoord + dir.offsetY, z = zCoord + dir.offsetZ;
TileEntity te = getTileSafe(x, y, z); TileEntity te = getTileSafe(x, y, z);
if (te instanceof TileEntityPresent) { if (te instanceof TileEntityPresent) {
return connectTo((TileEntityPresent) te, dir); return connectTo((TileEntityPresent) te, dir);
} }
return !exists(x, y, z); return !exists(x, y, z);
} }
/** /**
* @param preserveDir * @param preserveDir If true, this is only a virtual disconnect, meaning the other chest still exists, but is still
* If true, this is only a virtual disconnect, meaning the other chest still exists, but is still loaded, so maintain a cachedDir for reconnection upon chunk load. * loaded, so maintain a cachedDir for reconnection upon chunk load.
*/ */
public void disconnect(boolean preserveDir) { public void disconnect(boolean preserveDir) {
if (isConnected()) { if (isConnected()) {
if (!preserveDir) { if (!preserveDir) {
this.connection.cachedDir = null; this.connection.cachedDir = null;
this.cachedDir = null; this.cachedDir = null;
} }
this.connection.connection = null; this.connection.connection = null;
this.connection.markDirty(); this.connection.markDirty();
this.connection = null; this.connection = null;
this.markDirty(); this.markDirty();
PacketHandler.INSTANCE.sendToDimension(new MessagePresentConnect(this, ForgeDirection.UNKNOWN, false, preserveDir), worldObj.provider.dimensionId); PacketHandler.INSTANCE.sendToDimension(
} new MessagePresentConnect(this, ForgeDirection.UNKNOWN, false, preserveDir),
} worldObj.provider.dimensionId);
}
}
public TileEntityPresent getConnection() { public TileEntityPresent getConnection() {
return connection; return connection;
} }
public ForgeDirection getConnectionDir() { public ForgeDirection getConnectionDir() {
return cachedDir == null ? ForgeDirection.UNKNOWN : cachedDir; return cachedDir == null ? ForgeDirection.UNKNOWN : cachedDir;
} }
public boolean isParent() { public boolean isParent() {
return isParent || !isConnected(); return isParent || !isConnected();
} }
public int getRotation() { public int getRotation() {
return rotation; return rotation;
} }
public void setRotation(int rot) { public void setRotation(int rot) {
this.rotation = rot; this.rotation = rot;
} }
public void findConnections() { public void findConnections() {
if (!isConnected()) { if (!isConnected()) {
if (cachedDir != null) { if (cachedDir != null) {
if (connectTo(cachedDir)) { if (connectTo(cachedDir)) {
return; return;
} }
} }
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) { if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) {
if (connectTo(dir)) { if (connectTo(dir)) {
return; return;
} }
} }
} }
} }
} }
public TileEntityPresent getParent() { public TileEntityPresent getParent() {
return isParent || connection == null ? this : connection; return isParent || connection == null ? this : connection;
} }
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
return ChiselBlocks.present.getBoundingBox(this); return ChiselBlocks.present.getBoundingBox(this);
} }
@Override @Override
public void writeToNBT(NBTTagCompound tag) { public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag); super.writeToNBT(tag);
NBTTagList nbttaglist = new NBTTagList(); NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < getTrueSizeInventory(); ++i) { for (int i = 0; i < getTrueSizeInventory(); ++i) {
if (inventory[i] != null) { if (inventory[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i); nbttagcompound1.setByte("Slot", (byte) i);
inventory[i].writeToNBT(nbttagcompound1); inventory[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1);
} }
} }
tag.setTag("Items", nbttaglist); tag.setTag("Items", nbttaglist);
tag.setBoolean("isParent", isParent); tag.setBoolean("isParent", isParent);
tag.setInteger("rotation", rotation); tag.setInteger("rotation", rotation);
if (cachedDir != null) { if (cachedDir != null) {
tag.setInteger("conDir", cachedDir.ordinal()); tag.setInteger("conDir", cachedDir.ordinal());
} }
} }
@Override @Override
public void readFromNBT(NBTTagCompound tag) { public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag); super.readFromNBT(tag);
NBTTagList nbttaglist = tag.getTagList("Items", 10); NBTTagList nbttaglist = tag.getTagList("Items", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i) { for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound1.getByte("Slot") & 255; int j = nbttagcompound1.getByte("Slot") & 255;
if (j >= 0 && j < getTrueSizeInventory()) { if (j >= 0 && j < getTrueSizeInventory()) {
inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
} }
} }
this.isParent = tag.getBoolean("isParent"); this.isParent = tag.getBoolean("isParent");
this.rotation = tag.getInteger("rotation"); this.rotation = tag.getInteger("rotation");
if (tag.hasKey("conDir")) { if (tag.hasKey("conDir")) {
cachedDir = ForgeDirection.values()[tag.getInteger("conDir")]; cachedDir = ForgeDirection.values()[tag.getInteger("conDir")];
} }
autoSearch = true; autoSearch = true;
} }
@Override @Override
public Packet getDescriptionPacket() { public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag); writeToNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
} }
@Override @Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
readFromNBT(packet.func_148857_g()); readFromNBT(packet.func_148857_g());
} }
@Override @Override
public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) { public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y,
// prevent losing TE data when in-world chiseling int z) {
return oldBlock != newBlock; // prevent losing TE data when in-world chiseling
} return oldBlock != newBlock;
}
@Override @Override
public void invalidate() { public void invalidate() {
super.invalidate(); super.invalidate();
if (isConnected()) { if (isConnected()) {
disconnect(false); disconnect(false);
} }
} }
@Override @Override
public void onChunkUnload() { public void onChunkUnload() {
super.onChunkUnload(); super.onChunkUnload();
if (isConnected()) { if (isConnected()) {
disconnect(true); disconnect(true);
} }
} }
private int getAdjustedSlot(int slot) { private int getAdjustedSlot(int slot) {
slot %= getSizeInventory(); slot %= getSizeInventory();
if (isConnected() && !isParent) { if (isConnected() && !isParent) {
slot = (slot + getTrueSizeInventory()) % getSizeInventory(); slot = (slot + getTrueSizeInventory()) % getSizeInventory();
} }
return slot; return slot;
} }
private TileEntity getTileSafe(int x, int y, int z) { private TileEntity getTileSafe(int x, int y, int z) {
if (exists(x, y, z)) { if (exists(x, y, z)) {
return worldObj.getTileEntity(x, y, z); return worldObj.getTileEntity(x, y, z);
} }
return null; return null;
} }
// private Block getBlockSafe(int x, int y, int z) { // private Block getBlockSafe(int x, int y, int z) {
// if (exists(x, y, z)) { // if (exists(x, y, z)) {
// return worldObj.getBlock(x, y, z); // return worldObj.getBlock(x, y, z);
// } // }
// return null; // return null;
// } // }
// //
// private int getMetaSafe(int x, int y, int z) { // private int getMetaSafe(int x, int y, int z) {
// if (exists(x, y, z)) { // if (exists(x, y, z)) {
// return worldObj.getBlockMetadata(x, y, z); // return worldObj.getBlockMetadata(x, y, z);
// } // }
// return 0; // return 0;
// } // }
// //
private boolean exists(int x, int y, int z) { private boolean exists(int x, int y, int z) {
return worldObj.blockExists(x, y, z); return worldObj.blockExists(x, y, z);
} }
/* IInventory */ /* IInventory */
@Override @Override
public int getSizeInventory() { public int getSizeInventory() {
return isConnected() ? getTrueSizeInventory() + connection.getTrueSizeInventory() : getTrueSizeInventory(); return isConnected() ? getTrueSizeInventory() + connection.getTrueSizeInventory() : getTrueSizeInventory();
} }
@Override @Override
public ItemStack getStackInSlot(int slot) { public ItemStack getStackInSlot(int slot) {
slot = getAdjustedSlot(slot); slot = getAdjustedSlot(slot);
if (slot >= getTrueSizeInventory()) { if (slot >= getTrueSizeInventory()) {
return isConnected() ? connection.inventory[slot % getTrueSizeInventory()] : null; return isConnected() ? connection.inventory[slot % getTrueSizeInventory()] : null;
} else { } else {
return inventory[slot]; return inventory[slot];
} }
} }
@Override @Override
public ItemStack decrStackSize(int slot, int amount) { public ItemStack decrStackSize(int slot, int amount) {
slot = getAdjustedSlot(slot); slot = getAdjustedSlot(slot);
ItemStack[] inv = inventory; ItemStack[] inv = inventory;
if (isConnected() && slot >= getTrueSizeInventory()) { if (isConnected() && slot >= getTrueSizeInventory()) {
inv = connection.inventory; inv = connection.inventory;
slot %= getTrueSizeInventory(); slot %= getTrueSizeInventory();
connection.markDirty(); connection.markDirty();
} }
if (inv[slot] != null) { if (inv[slot] != null) {
ItemStack itemstack; ItemStack itemstack;
if (inv[slot].stackSize <= amount) { if (inv[slot].stackSize <= amount) {
itemstack = inv[slot]; itemstack = inv[slot];
inv[slot] = null; inv[slot] = null;
this.markDirty(); this.markDirty();
return itemstack; return itemstack;
} else { } else {
itemstack = inv[slot].splitStack(amount); itemstack = inv[slot].splitStack(amount);
if (inv[slot].stackSize == 0) { if (inv[slot].stackSize == 0) {
inv[slot] = null; inv[slot] = null;
} }
this.markDirty(); this.markDirty();
return itemstack; return itemstack;
} }
} else { } else {
return null; return null;
} }
} }
@Override @Override
public ItemStack getStackInSlotOnClosing(int slot) { public ItemStack getStackInSlotOnClosing(int slot) {
return getStackInSlot(slot); return getStackInSlot(slot);
} }
@Override @Override
public void setInventorySlotContents(int slot, ItemStack stack) { public void setInventorySlotContents(int slot, ItemStack stack) {
slot = getAdjustedSlot(slot); slot = getAdjustedSlot(slot);
if (slot < getTrueSizeInventory()) { if (slot < getTrueSizeInventory()) {
inventory[slot] = stack; inventory[slot] = stack;
} else if (isConnected()) { } else if (isConnected()) {
connection.inventory[slot % getTrueSizeInventory()] = stack; connection.inventory[slot % getTrueSizeInventory()] = stack;
connection.markDirty(); connection.markDirty();
} }
} }
@Override @Override
public String getInventoryName() { public String getInventoryName() {
return "chisel.present"; return "chisel.present";
} }
@Override @Override
public boolean hasCustomInventoryName() { public boolean hasCustomInventoryName() {
return false; return false;
} }
@Override @Override
public int getInventoryStackLimit() { public int getInventoryStackLimit() {
return 64; return 64;
} }
@Override @Override
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
return true; return true;
} }
@Override @Override
public void openInventory() { public void openInventory() {
; ;
} }
@Override @Override
public void closeInventory() { public void closeInventory() {
; ;
} }
@Override @Override
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
return true; return true;
} }
/* IDoubleChest */ /* IDoubleChest */
@Override @Override
public int getTrueSizeInventory() { public int getTrueSizeInventory() {
return inventory.length; return inventory.length;
} }
@Override @Override
public ItemStack getTrueStackInSlot(int slot) { public ItemStack getTrueStackInSlot(int slot) {
return inventory[slot % getTrueSizeInventory()]; return inventory[slot % getTrueSizeInventory()];
} }
@Override @Override
public void putStackInTrueSlot(int slot, ItemStack stack) { public void putStackInTrueSlot(int slot, ItemStack stack) {
inventory[slot % getTrueSizeInventory()] = stack; inventory[slot % getTrueSizeInventory()] = stack;
} }
} }
+166 -165
View File
@@ -1,6 +1,14 @@
package team.chisel.carving; package team.chisel.carving;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import com.cricketcraft.chisel.api.carving.CarvingUtils; import com.cricketcraft.chisel.api.carving.CarvingUtils;
import com.cricketcraft.chisel.api.carving.ICarvingGroup; import com.cricketcraft.chisel.api.carving.ICarvingGroup;
@@ -8,208 +16,201 @@ import com.cricketcraft.chisel.api.carving.ICarvingRegistry;
import com.cricketcraft.chisel.api.carving.ICarvingVariation; import com.cricketcraft.chisel.api.carving.ICarvingVariation;
import team.chisel.Chisel; import team.chisel.Chisel;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class Carving implements ICarvingRegistry { public class Carving implements ICarvingRegistry {
GroupList groups = new GroupList(); GroupList groups = new GroupList();
public static final ICarvingRegistry chisel = new Carving(); public static final ICarvingRegistry chisel = new Carving();
public static final Carving needle = new Carving(); public static final Carving needle = new Carving();
static { static {
CarvingUtils.chisel = chisel; CarvingUtils.chisel = chisel;
} }
public static void construct() { public static void construct() {
/* do nothing */ /* do nothing */
} }
private Carving() { private Carving() {
/* do nothing */ /* do nothing */
} }
@Override @Override
public ICarvingVariation getVariation(Block block, int metadata) { public ICarvingVariation getVariation(Block block, int metadata) {
ICarvingGroup g = getGroup(block, metadata); ICarvingGroup g = getGroup(block, metadata);
if (g != null) { if (g != null) {
for (ICarvingVariation v : g.getVariations()) { for (ICarvingVariation v : g.getVariations()) {
if (v.getBlock() == block && v.getBlockMeta() == metadata) { if (v.getBlock() == block && v.getBlockMeta() == metadata) {
return v; return v;
} }
} }
} }
return null; return null;
} }
@Override @Override
public List<ICarvingVariation> getGroupVariations(Block block, int metadata) { public List<ICarvingVariation> getGroupVariations(Block block, int metadata) {
ICarvingGroup group = getGroup(block, metadata); ICarvingGroup group = getGroup(block, metadata);
if (group == null) if (group == null) return Collections.emptyList();
return Collections.emptyList();
return group.getVariations(); return group.getVariations();
} }
@Override @Override
public String getOreName(Block block, int metadata) { public String getOreName(Block block, int metadata) {
ICarvingGroup group = getGroup(block, metadata); ICarvingGroup group = getGroup(block, metadata);
if (group == null) if (group == null) return null;
return null;
return group.getOreName(); return group.getOreName();
} }
@Override @Override
public List<ItemStack> getItemsForChiseling(ItemStack chiseledItem) { public List<ItemStack> getItemsForChiseling(ItemStack chiseledItem) {
ArrayList<ItemStack> items = new ArrayList<>(); ArrayList<ItemStack> items = new ArrayList<>();
ICarvingGroup group = null; ICarvingGroup group = null;
int[] oreIDs = OreDictionary.getOreIDs(chiseledItem); int[] oreIDs = OreDictionary.getOreIDs(chiseledItem);
for (int i : oreIDs) { for (int i : oreIDs) {
group = groups.getGroupByOre(OreDictionary.getOreName(i)); group = groups.getGroupByOre(OreDictionary.getOreName(i));
if (group != null) { if (group != null) {
break; break;
} }
} }
if (group == null) { if (group == null) {
group = getGroup(Block.getBlockFromItem(chiseledItem.getItem()), chiseledItem.getItemDamage()); group = getGroup(Block.getBlockFromItem(chiseledItem.getItem()), chiseledItem.getItemDamage());
} }
if (group == null) if (group == null) return items;
return items;
HashSet<String> mapping = new HashSet<>(); HashSet<String> mapping = new HashSet<>();
List<ICarvingVariation> variations = group.getVariations(); List<ICarvingVariation> variations = group.getVariations();
for (ICarvingVariation v : variations) { for (ICarvingVariation v : variations) {
String key = Block.getIdFromBlock(v.getBlock()) + "|" + v.getItemMeta(); String key = Block.getIdFromBlock(v.getBlock()) + "|" + v.getItemMeta();
if (mapping.add(key)) items.add(new ItemStack(v.getBlock(), 1, v.getItemMeta())); if (mapping.add(key)) items.add(new ItemStack(v.getBlock(), 1, v.getItemMeta()));
} }
String oreName = group.getOreName(); String oreName = group.getOreName();
if (oreName != null) { if (oreName != null) {
ArrayList<ItemStack> ores = OreDictionary.getOres(oreName); ArrayList<ItemStack> ores = OreDictionary.getOres(oreName);
for (ItemStack stack : ores) { for (ItemStack stack : ores) {
String key = Item.getIdFromItem(stack.getItem()) + "|" + stack.getItemDamage(); String key = Item.getIdFromItem(stack.getItem()) + "|" + stack.getItemDamage();
if (mapping.add(key)) items.add(stack); if (mapping.add(key)) items.add(stack);
} }
} }
return items; return items;
} }
@Override @Override
public ICarvingGroup getGroup(Block block, int metadata) { public ICarvingGroup getGroup(Block block, int metadata) {
int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, metadata)); int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, metadata));
if (ids.length > 0) { if (ids.length > 0) {
for (int id : ids) { for (int id : ids) {
ICarvingGroup oreGroup = groups.getGroupByOre(OreDictionary.getOreName(id)); ICarvingGroup oreGroup = groups.getGroupByOre(OreDictionary.getOreName(id));
if (oreGroup != null) { if (oreGroup != null) {
return oreGroup; return oreGroup;
} }
} }
} }
return groups.getGroup(block, metadata); return groups.getGroup(block, metadata);
} }
@Override @Override
public ICarvingGroup getGroup(String name) { public ICarvingGroup getGroup(String name) {
return groups.getGroupByName(name); return groups.getGroupByName(name);
} }
@Override @Override
public ICarvingGroup removeGroup(String groupName) { public ICarvingGroup removeGroup(String groupName) {
ICarvingGroup g = groups.getGroupByName(groupName); ICarvingGroup g = groups.getGroupByName(groupName);
return groups.remove(g) ? g : null; return groups.remove(g) ? g : null;
} }
@Override @Override
public ICarvingVariation removeVariation(Block block, int metadata) { public ICarvingVariation removeVariation(Block block, int metadata) {
return removeVariation(block, metadata, null); return removeVariation(block, metadata, null);
} }
@Override @Override
public ICarvingVariation removeVariation(Block block, int metadata, String group) { public ICarvingVariation removeVariation(Block block, int metadata, String group) {
return groups.removeVariation(block, metadata, group); return groups.removeVariation(block, metadata, group);
} }
@Override @Override
public void addVariation(String groupName, Block block, int metadata, int order) { public void addVariation(String groupName, Block block, int metadata, int order) {
if (block == null) { if (block == null) {
throw new NullPointerException("Cannot add variation in group " + groupName + " for null block."); throw new NullPointerException("Cannot add variation in group " + groupName + " for null block.");
} }
ICarvingVariation variation = CarvingUtils.getDefaultVariationFor(block, metadata, order); ICarvingVariation variation = CarvingUtils.getDefaultVariationFor(block, metadata, order);
addVariation(groupName, variation); addVariation(groupName, variation);
} }
@Override @Override
public void addVariation(String groupName, ICarvingVariation variation) { public void addVariation(String groupName, ICarvingVariation variation) {
if (groupName == null) { if (groupName == null) {
throw new NullPointerException("Cannot add variation to null group name."); throw new NullPointerException("Cannot add variation to null group name.");
} else if (variation == null) { } else if (variation == null) {
throw new NullPointerException("Cannot add variation in group " + groupName + " for null variation."); throw new NullPointerException("Cannot add variation in group " + groupName + " for null variation.");
} }
ICarvingGroup group = groups.getGroupByName(groupName); ICarvingGroup group = groups.getGroupByName(groupName);
if (group == null) { if (group == null) {
group = CarvingUtils.getDefaultGroupFor(groupName); group = CarvingUtils.getDefaultGroupFor(groupName);
addGroup(group); addGroup(group);
} }
groups.addVariation(groupName, variation); groups.addVariation(groupName, variation);
} }
@Override @Override
public void addGroup(ICarvingGroup group) { public void addGroup(ICarvingGroup group) {
groups.add(group); groups.add(group);
} }
@Override @Override
public void registerOre(String name, String oreName) { public void registerOre(String name, String oreName) {
ICarvingGroup group = groups.getGroupByName(name); ICarvingGroup group = groups.getGroupByName(name);
if (group != null) { if (group != null) {
group.setOreName(oreName); group.setOreName(oreName);
} else { } else {
throw new NullPointerException("Cannot register ore name for group " + name + ", as it does not exist."); throw new NullPointerException("Cannot register ore name for group " + name + ", as it does not exist.");
} }
} }
@Override @Override
public void setVariationSound(String name, String sound) { public void setVariationSound(String name, String sound) {
ICarvingGroup group = groups.getGroupByName(name); ICarvingGroup group = groups.getGroupByName(name);
if (group != null) { if (group != null) {
group.setSound(sound); group.setSound(sound);
} else { } else {
throw new NullPointerException("Cannot set sound for group " + name + ", as it does not exist."); throw new NullPointerException("Cannot set sound for group " + name + ", as it does not exist.");
} }
} }
@Override @Override
public String getVariationSound(Block block, int metadata) { public String getVariationSound(Block block, int metadata) {
return getVariationSound(Item.getItemFromBlock(block), metadata); return getVariationSound(Item.getItemFromBlock(block), metadata);
} }
@Override @Override
public String getVariationSound(Item item, int metadata) { public String getVariationSound(Item item, int metadata) {
ICarvingGroup group = groups.getGroup(Block.getBlockFromItem(item), metadata); ICarvingGroup group = groups.getGroup(Block.getBlockFromItem(item), metadata);
String sound = group == null ? null : group.getSound(); String sound = group == null ? null : group.getSound();
return sound == null ? Chisel.MOD_ID + ":chisel.fallback" : sound; return sound == null ? Chisel.MOD_ID + ":chisel.fallback" : sound;
} }
@Override @Override
public List<String> getSortedGroupNames() { public List<String> getSortedGroupNames() {
List<String> names = new ArrayList<>(groups.getNames()); List<String> names = new ArrayList<>(groups.getNames());
Collections.sort(names); Collections.sort(names);
return names; return names;
} }
} }
+202 -192
View File
@@ -17,229 +17,239 @@ import com.google.common.collect.Maps;
public class GroupList implements Set<ICarvingGroup> { public class GroupList implements Set<ICarvingGroup> {
private class VariationWrapper { private class VariationWrapper {
private ICarvingVariation v; private ICarvingVariation v;
private VariationWrapper(ICarvingVariation v) { private VariationWrapper(ICarvingVariation v) {
this.v = v; this.v = v;
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof ICarvingVariation) { if (obj instanceof ICarvingVariation) {
ICarvingVariation v2 = (ICarvingVariation) obj; ICarvingVariation v2 = (ICarvingVariation) obj;
return v.getBlock() == v2.getBlock() && (v.getBlockMeta() == v2.getBlockMeta() || v.getItemMeta() == v2.getItemMeta()); return v.getBlock() == v2.getBlock()
} else if (obj instanceof VariationWrapper) { && (v.getBlockMeta() == v2.getBlockMeta() || v.getItemMeta() == v2.getItemMeta());
return equals(((VariationWrapper) obj).v); } else if (obj instanceof VariationWrapper) {
} return equals(((VariationWrapper) obj).v);
return false; }
} return false;
}
@Override @Override
public int hashCode() { public int hashCode() {
return v.getBlock().hashCode(); return v.getBlock()
} .hashCode();
} }
}
private class VariationKey implements ICarvingVariation { private class VariationKey implements ICarvingVariation {
Pair<Block, Integer> data; Pair<Block, Integer> data;
private VariationKey(Block block, int blockMeta) { private VariationKey(Block block, int blockMeta) {
data = Pair.of(block, blockMeta); data = Pair.of(block, blockMeta);
} }
@Override @Override
public Block getBlock() { public Block getBlock() {
return data.getLeft(); return data.getLeft();
} }
@Override @Override
public int getBlockMeta() { public int getBlockMeta() {
return data.getRight(); return data.getRight();
} }
@Override @Override
public int getItemMeta() { public int getItemMeta() {
return data.getRight(); return data.getRight();
} }
@Override @Override
public int getOrder() { public int getOrder() {
return 0; return 0;
} }
@Override @Override
public String toString() { public String toString() {
return data.toString(); return data.toString();
} }
} }
private HashMap<String, ICarvingGroup> groups = Maps.newHashMap(); private HashMap<String, ICarvingGroup> groups = Maps.newHashMap();
private HashMap<VariationWrapper, ICarvingGroup> lookup = Maps.newHashMap(); private HashMap<VariationWrapper, ICarvingGroup> lookup = Maps.newHashMap();
@Override @Override
public int size() { public int size() {
return groups.size(); return groups.size();
} }
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
return groups.isEmpty(); return groups.isEmpty();
} }
@Override @Override
public boolean contains(Object o) { public boolean contains(Object o) {
if (o instanceof ICarvingGroup) { if (o instanceof ICarvingGroup) {
return groups.containsKey(((ICarvingGroup) o).getName()); return groups.containsKey(((ICarvingGroup) o).getName());
} }
return false; return false;
} }
@Override @Override
public Iterator<ICarvingGroup> iterator() { public Iterator<ICarvingGroup> iterator() {
return groups.values().iterator(); return groups.values()
} .iterator();
}
@Override @Override
public Object[] toArray() { public Object[] toArray() {
return groups.values().toArray(); return groups.values()
} .toArray();
}
@Override @Override
public <T> T[] toArray(T[] arr) { public <T> T[] toArray(T[] arr) {
return groups.values().toArray(arr); return groups.values()
} .toArray(arr);
}
@Override @Override
public boolean add(ICarvingGroup group) { public boolean add(ICarvingGroup group) {
String key = group.getName(); String key = group.getName();
if (groups.containsKey(key)) { if (groups.containsKey(key)) {
return false; return false;
} }
for (ICarvingVariation v : group.getVariations()) { for (ICarvingVariation v : group.getVariations()) {
ICarvingGroup g = lookup.get(v); ICarvingGroup g = lookup.get(v);
if (g == null) { if (g == null) {
lookup.put(new VariationWrapper(v), group); lookup.put(new VariationWrapper(v), group);
} }
} }
groups.put(key, group); groups.put(key, group);
return true; return true;
} }
@Override @Override
public boolean remove(Object o) { public boolean remove(Object o) {
if (o instanceof ICarvingGroup) { if (o instanceof ICarvingGroup) {
List<VariationWrapper> toRemove = Lists.newArrayList(); List<VariationWrapper> toRemove = Lists.newArrayList();
for (VariationWrapper v : lookup.keySet()) { for (VariationWrapper v : lookup.keySet()) {
if (lookup.get(v).getName().equals(((ICarvingGroup) o).getName())) { if (lookup.get(v)
toRemove.add(v); .getName()
} .equals(((ICarvingGroup) o).getName())) {
} toRemove.add(v);
for (VariationWrapper v : toRemove) { }
lookup.remove(v); }
} for (VariationWrapper v : toRemove) {
return groups.remove(((ICarvingGroup) o).getName()) != null; lookup.remove(v);
} }
return false; return groups.remove(((ICarvingGroup) o).getName()) != null;
} }
return false;
}
@Override @Override
public boolean containsAll(Collection<?> c) { public boolean containsAll(Collection<?> c) {
for (Object o : c) { for (Object o : c) {
if (!(o instanceof ICarvingGroup)) { if (!(o instanceof ICarvingGroup)) {
return false; return false;
} }
if (!groups.containsKey(((ICarvingGroup) o).getName())) { if (!groups.containsKey(((ICarvingGroup) o).getName())) {
return false; return false;
} }
} }
return true; return true;
} }
@Override @Override
public boolean addAll(Collection<? extends ICarvingGroup> c) { public boolean addAll(Collection<? extends ICarvingGroup> c) {
boolean ret = false; boolean ret = false;
for (ICarvingGroup g : c) { for (ICarvingGroup g : c) {
ret |= add(g); ret |= add(g);
} }
return ret; return ret;
} }
@Override @Override
public boolean removeAll(Collection<?> c) { public boolean removeAll(Collection<?> c) {
boolean ret = false; boolean ret = false;
for (Object o : c) { for (Object o : c) {
ret |= remove(o); ret |= remove(o);
} }
return ret; return ret;
} }
@Override @Override
public boolean retainAll(Collection<?> c) { public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException(); // not using it, not gonna bother throw new UnsupportedOperationException(); // not using it, not gonna bother
} }
@Override @Override
public void clear() { public void clear() {
groups.clear(); groups.clear();
} }
public ICarvingGroup getGroup(Block block, int metadata) { public ICarvingGroup getGroup(Block block, int metadata) {
return lookup.get(new VariationWrapper(new VariationKey(block, metadata))); return lookup.get(new VariationWrapper(new VariationKey(block, metadata)));
} }
public void addVariation(String name, ICarvingVariation variation) { public void addVariation(String name, ICarvingVariation variation) {
ICarvingGroup g = groups.get(name); ICarvingGroup g = groups.get(name);
if (g == null) { if (g == null) {
throw new NullPointerException("No group exists for name " + name); throw new NullPointerException("No group exists for name " + name);
} }
g.addVariation(variation); g.addVariation(variation);
lookup.put(new VariationWrapper(variation), g); lookup.put(new VariationWrapper(variation), g);
} }
public ICarvingGroup getGroupByName(String groupName) { public ICarvingGroup getGroupByName(String groupName) {
return groups.get(groupName); return groups.get(groupName);
} }
public ICarvingGroup getGroupByOre(String oreName) { public ICarvingGroup getGroupByOre(String oreName) {
for (ICarvingGroup group : groups.values()) { for (ICarvingGroup group : groups.values()) {
if (oreName.equals(group.getOreName())) { if (oreName.equals(group.getOreName())) {
return group; return group;
} }
} }
return null; return null;
} }
public Collection<? extends String> getNames() { public Collection<? extends String> getNames() {
return groups.keySet(); return groups.keySet();
} }
public ICarvingVariation removeVariation(Block block, int metadata, String group) { public ICarvingVariation removeVariation(Block block, int metadata, String group) {
ICarvingGroup g = null; ICarvingGroup g = null;
if (group != null) { if (group != null) {
g = groups.get(group); g = groups.get(group);
if (g == null) { if (g == null) {
throw new IllegalArgumentException("No such group " + group); throw new IllegalArgumentException("No such group " + group);
} }
groups.remove(g.getName()); groups.remove(g.getName());
} }
List<VariationWrapper> toRemove = Lists.newArrayList(); List<VariationWrapper> toRemove = Lists.newArrayList();
for (VariationWrapper v : lookup.keySet()) { for (VariationWrapper v : lookup.keySet()) {
if ((g == null || lookup.get(v).getName().equals(g.getName())) && v.equals(new VariationWrapper(new VariationKey(block, metadata)))) { if ((g == null || lookup.get(v)
lookup.get(v).removeVariation(v.v); .getName()
toRemove.add(v); .equals(g.getName())) && v.equals(new VariationWrapper(new VariationKey(block, metadata)))) {
} lookup.get(v)
} .removeVariation(v.v);
for (VariationWrapper v : toRemove) { toRemove.add(v);
lookup.remove(v); }
} }
return toRemove.isEmpty() ? null : toRemove.get(0).v; for (VariationWrapper v : toRemove) {
} lookup.remove(v);
}
return toRemove.isEmpty() ? null : toRemove.get(0).v;
}
@Override @Override
public String toString() { public String toString() {
return groups.toString(); return groups.toString();
} }
} }
@@ -9,6 +9,7 @@ import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.client.particle.EntityLavaFX; import net.minecraft.client.particle.EntityLavaFX;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import team.chisel.block.BlockGrimstone; import team.chisel.block.BlockGrimstone;
import team.chisel.block.BlockHolystone; import team.chisel.block.BlockHolystone;
import team.chisel.block.BlockLavastone; import team.chisel.block.BlockLavastone;
@@ -24,226 +25,270 @@ import team.chisel.utils.GeneralClient;
public class GeneralChiselClient { public class GeneralChiselClient {
public static Random rand = new Random(); public static Random rand = new Random();
public static int tick = 0; public static int tick = 0;
public static void spawnLavastoneFX(World world, BlockLavastone block, int x, int y, int z) { public static void spawnLavastoneFX(World world, BlockLavastone block, int x, int y, int z) {
if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0 || Minecraft.getMinecraft().gameSettings.particleSetting != 0) if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0
return; || Minecraft.getMinecraft().gameSettings.particleSetting != 0) return;
float f = 0.15F; float f = 0.15F;
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX(); double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F)
double y1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY(); + f
double z1 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ(); + block.getBlockBoundsMinX();
double y1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F)
+ f
+ block.getBlockBoundsMinY();
double z1 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F)
+ f
+ block.getBlockBoundsMinZ();
switch (rand.nextInt(6)) { switch (rand.nextInt(6)) {
case 0: case 0:
y1 = y + block.getBlockBoundsMinY() - f; y1 = y + block.getBlockBoundsMinY() - f;
y--; y--;
break; break;
case 1: case 1:
y1 = y + block.getBlockBoundsMaxY() + f; y1 = y + block.getBlockBoundsMaxY() + f;
y++; y++;
break; break;
case 2: case 2:
z1 = z + block.getBlockBoundsMinZ() - f; z1 = z + block.getBlockBoundsMinZ() - f;
z--; z--;
break; break;
case 3: case 3:
z1 = z + block.getBlockBoundsMaxZ() + f; z1 = z + block.getBlockBoundsMaxZ() + f;
z++; z++;
break; break;
case 4: case 4:
x1 = x + block.getBlockBoundsMinX() - f; x1 = x + block.getBlockBoundsMinX() - f;
x--; x--;
break; break;
case 5: case 5:
x1 = x + block.getBlockBoundsMaxX() + f; x1 = x + block.getBlockBoundsMaxX() + f;
x++; x++;
break; break;
} }
if (world.getBlock(x, y, z).isOpaqueCube()) if (world.getBlock(x, y, z)
return; .isOpaqueCube()) return;
EntityLavaFX res = new EntityLavaFX(world, x1, y1, z1); EntityLavaFX res = new EntityLavaFX(world, x1, y1, z1);
double multiplier = 0.45; double multiplier = 0.45;
res.motionX = -multiplier * (x1 - x - 0.5); res.motionX = -multiplier * (x1 - x - 0.5);
res.motionY = multiplier * (y1 - y - 0.5); res.motionY = multiplier * (y1 - y - 0.5);
res.motionZ = -multiplier * (z1 - z - 0.5); res.motionZ = -multiplier * (z1 - z - 0.5);
Minecraft.getMinecraft().effectRenderer.addEffect(res); Minecraft.getMinecraft().effectRenderer.addEffect(res);
} }
public static void spawnHolystoneFX(World world, BlockHolystone block, int x, int y, int z) { public static void spawnHolystoneFX(World world, BlockHolystone block, int x, int y, int z) {
if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0 || Minecraft.getMinecraft().gameSettings.particleSetting != 0) if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0
return; || Minecraft.getMinecraft().gameSettings.particleSetting != 0) return;
float f = 0.15F; float f = 0.15F;
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX(); double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F)
double y1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY(); + f
double z1 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ(); + block.getBlockBoundsMinX();
double y1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F)
+ f
+ block.getBlockBoundsMinY();
double z1 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F)
+ f
+ block.getBlockBoundsMinZ();
switch (rand.nextInt(6)) { switch (rand.nextInt(6)) {
case 0: case 0:
y1 = y + block.getBlockBoundsMinY() - f; y1 = y + block.getBlockBoundsMinY() - f;
y--; y--;
break; break;
case 1: case 1:
y1 = y + block.getBlockBoundsMaxY() + f; y1 = y + block.getBlockBoundsMaxY() + f;
y++; y++;
break; break;
case 2: case 2:
z1 = z + block.getBlockBoundsMinZ() - f; z1 = z + block.getBlockBoundsMinZ() - f;
z--; z--;
break; break;
case 3: case 3:
z1 = z + block.getBlockBoundsMaxZ() + f; z1 = z + block.getBlockBoundsMaxZ() + f;
z++; z++;
break; break;
case 4: case 4:
x1 = x + block.getBlockBoundsMinX() - f; x1 = x + block.getBlockBoundsMinX() - f;
x--; x--;
break; break;
case 5: case 5:
x1 = x + block.getBlockBoundsMaxX() + f; x1 = x + block.getBlockBoundsMaxX() + f;
x++; x++;
break; break;
} }
if (world.getBlock(x, y, z).isOpaqueCube()) if (world.getBlock(x, y, z)
return; .isOpaqueCube()) return;
EntityHolystoneFX res = new EntityHolystoneFX(world, block, x1, y1, z1); EntityHolystoneFX res = new EntityHolystoneFX(world, block, x1, y1, z1);
Minecraft.getMinecraft().effectRenderer.addEffect(res); Minecraft.getMinecraft().effectRenderer.addEffect(res);
} }
public static void spawnGrimstoneFX(World world, BlockGrimstone block, int x, int y, int z) { public static void spawnGrimstoneFX(World world, BlockGrimstone block, int x, int y, int z) {
if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0) if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0) return;
return;
float f = 0.15F; float f = 0.15F;
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX(); double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F)
double y1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY(); + f
double z1 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ(); + block.getBlockBoundsMinX();
double y1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F)
+ f
+ block.getBlockBoundsMinY();
double z1 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F)
+ f
+ block.getBlockBoundsMinZ();
switch (rand.nextInt(6)) { switch (rand.nextInt(6)) {
case 0: case 0:
y1 = y + block.getBlockBoundsMinY() - f; y1 = y + block.getBlockBoundsMinY() - f;
y--; y--;
break; break;
case 1: case 1:
y1 = y + block.getBlockBoundsMaxY() + f; y1 = y + block.getBlockBoundsMaxY() + f;
y++; y++;
break; break;
case 2: case 2:
z1 = z + block.getBlockBoundsMinZ() - f; z1 = z + block.getBlockBoundsMinZ() - f;
z--; z--;
break; break;
case 3: case 3:
z1 = z + block.getBlockBoundsMaxZ() + f; z1 = z + block.getBlockBoundsMaxZ() + f;
z++; z++;
break; break;
case 4: case 4:
x1 = x + block.getBlockBoundsMinX() - f; x1 = x + block.getBlockBoundsMinX() - f;
x--; x--;
break; break;
case 5: case 5:
x1 = x + block.getBlockBoundsMaxX() + f; x1 = x + block.getBlockBoundsMaxX() + f;
x++; x++;
break; break;
} }
if (world.getBlock(x, y, z).isOpaqueCube()) if (world.getBlock(x, y, z)
return; .isOpaqueCube()) return;
EntityGrimstoneFX res = new EntityGrimstoneFX(world, block, x1, y1, z1); EntityGrimstoneFX res = new EntityGrimstoneFX(world, block, x1, y1, z1);
Minecraft.getMinecraft().effectRenderer.addEffect(res); Minecraft.getMinecraft().effectRenderer.addEffect(res);
} }
public static void spawnSnakestoneObsidianFX(World world, BlockSnakestoneObsidian block, int x, int y, int z) { public static void spawnSnakestoneObsidianFX(World world, BlockSnakestoneObsidian block, int x, int y, int z) {
if (Configurations.particlesTickrate != 0 || tick++ % Configurations.particlesTickrate != 0 || Minecraft.getMinecraft().gameSettings.particleSetting != 0) { if (Configurations.particlesTickrate != 0 || tick++ % Configurations.particlesTickrate != 0
EntitySnakestoneObsidianFX res = new EntitySnakestoneObsidianFX(world, block, x, y, z); || Minecraft.getMinecraft().gameSettings.particleSetting != 0) {
Minecraft.getMinecraft().effectRenderer.addEffect(res); EntitySnakestoneObsidianFX res = new EntitySnakestoneObsidianFX(world, block, x, y, z);
} Minecraft.getMinecraft().effectRenderer.addEffect(res);
} }
}
public static void spawnBallOMossFX(World world, double x, double y, double z) { public static void spawnBallOMossFX(World world, double x, double y, double z) {
if (Configurations.particlesTickrate == 0 || tick++ % Configurations.particlesTickrate == 0 || Minecraft.getMinecraft().gameSettings.particleSetting != 0) { if (Configurations.particlesTickrate == 0 || tick++ % Configurations.particlesTickrate == 0
EntityBallOMossFX res = new EntityBallOMossFX(world, x, y, z); || Minecraft.getMinecraft().gameSettings.particleSetting != 0) {
Minecraft.getMinecraft().effectRenderer.addEffect(res); EntityBallOMossFX res = new EntityBallOMossFX(world, x, y, z);
} Minecraft.getMinecraft().effectRenderer.addEffect(res);
} }
}
public static EntityDiggingFX addBlockHitEffects(World world, int x, int y, int z, int side) { public static EntityDiggingFX addBlockHitEffects(World world, int x, int y, int z, int side) {
Block block = world.getBlock(x, y, z); Block block = world.getBlock(x, y, z);
if (block.isAir(world, x, y, z) || Minecraft.getMinecraft().gameSettings.particleSetting != 0) if (block.isAir(world, x, y, z) || Minecraft.getMinecraft().gameSettings.particleSetting != 0) return null;
return null;
EffectRenderer renderer = Minecraft.getMinecraft().effectRenderer; EffectRenderer renderer = Minecraft.getMinecraft().effectRenderer;
float f = 0.1F; float f = 0.1F;
double d0 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + block.getBlockBoundsMinX(); double d0 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F)
double d1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F) + f + block.getBlockBoundsMinY(); + f
double d2 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F) + f + block.getBlockBoundsMinZ(); + block.getBlockBoundsMinX();
double d1 = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - f * 2.0F)
+ f
+ block.getBlockBoundsMinY();
double d2 = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - f * 2.0F)
+ f
+ block.getBlockBoundsMinZ();
switch (side) { switch (side) {
case 0: case 0:
d1 = y + block.getBlockBoundsMinY() - f; d1 = y + block.getBlockBoundsMinY() - f;
break; break;
case 1: case 1:
d1 = y + block.getBlockBoundsMaxY() + f; d1 = y + block.getBlockBoundsMaxY() + f;
break; break;
case 2: case 2:
d2 = z + block.getBlockBoundsMinZ() - f; d2 = z + block.getBlockBoundsMinZ() - f;
break; break;
case 3: case 3:
d2 = z + block.getBlockBoundsMaxZ() + f; d2 = z + block.getBlockBoundsMaxZ() + f;
break; break;
case 4: case 4:
d0 = x + block.getBlockBoundsMinX() - f; d0 = x + block.getBlockBoundsMinX() - f;
break; break;
case 5: case 5:
d0 = x + block.getBlockBoundsMaxX() + f; d0 = x + block.getBlockBoundsMaxX() + f;
break; break;
} }
EntityDiggingFX res = new EntityDiggingFX(world, d0, d1, d2, 0.0D, 0.0D, 0.0D, block, world.getBlockMetadata(x, y, z), side); EntityDiggingFX res = new EntityDiggingFX(
res.motionX = d0 - (x + 0.5); world,
res.motionY = d1 - (y + 0.5); d0,
res.motionZ = d2 - (z + 0.5); d1,
d2,
0.0D,
0.0D,
0.0D,
block,
world.getBlockMetadata(x, y, z),
side);
res.motionX = d0 - (x + 0.5);
res.motionY = d1 - (y + 0.5);
res.motionZ = d2 - (z + 0.5);
renderer.addEffect(res); renderer.addEffect(res);
return res; return res;
} }
public static void spawnChiselEffect(int x, int y, int z, String sound) { public static void spawnChiselEffect(int x, int y, int z, String sound) {
World world = Minecraft.getMinecraft().theWorld; World world = Minecraft.getMinecraft().theWorld;
for (int side = 0; side < 6; side++) { for (int side = 0; side < 6; side++) {
for (int j = 0; j < 16; j++) { for (int j = 0; j < 16; j++) {
EntityDiggingFX fx = addBlockHitEffects(Minecraft.getMinecraft().theWorld, x, y, z, side); EntityDiggingFX fx = addBlockHitEffects(Minecraft.getMinecraft().theWorld, x, y, z, side);
if (fx == null) if (fx == null) return;
return;
fx.multipleParticleScaleBy(0.25f + 0.5f * rand.nextFloat()); fx.multipleParticleScaleBy(0.25f + 0.5f * rand.nextFloat());
fx.multiplyVelocity(0.3f * rand.nextFloat()); fx.multiplyVelocity(0.3f * rand.nextFloat());
} }
} }
GeneralClient.playChiselSound(world, x, y, z, sound); GeneralClient.playChiselSound(world, x, y, z, sound);
} }
public static void spawnAutoChiselFX(TileEntityAutoChisel te, ItemStack base) { public static void spawnAutoChiselFX(TileEntityAutoChisel te, ItemStack base) {
if (base != null && Minecraft.getMinecraft().gameSettings.particleSetting == 0) { if (base != null && Minecraft.getMinecraft().gameSettings.particleSetting == 0) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
EntityDiggingFX particle = new EntityDiggingFX(te.getWorldObj(), te.xCoord + 0.5, te.yCoord + 0.95, te.zCoord + 0.5, 0, 0, 0, Block.getBlockFromItem(base.getItem()), EntityDiggingFX particle = new EntityDiggingFX(
base.getItemDamage()); te.getWorldObj(),
particle.setVelocity((te.getWorldObj().rand.nextDouble() / 4) - 0.125, te.getWorldObj().rand.nextDouble() / 8, (te.getWorldObj().rand.nextDouble() / 4) - 0.125); te.xCoord + 0.5,
Minecraft.getMinecraft().effectRenderer.addEffect(particle); te.yCoord + 0.95,
} te.zCoord + 0.5,
String sound = Carving.chisel.getVariationSound(base.getItem(), base.getItemDamage()); 0,
GeneralClient.playChiselSound(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, sound); 0,
} 0,
} Block.getBlockFromItem(base.getItem()),
base.getItemDamage());
particle.setVelocity(
(te.getWorldObj().rand.nextDouble() / 4) - 0.125,
te.getWorldObj().rand.nextDouble() / 8,
(te.getWorldObj().rand.nextDouble() / 4) - 0.125);
Minecraft.getMinecraft().effectRenderer.addEffect(particle);
}
String sound = Carving.chisel.getVariationSound(base.getItem(), base.getItemDamage());
GeneralClient.playChiselSound(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, sound);
}
}
} }
@@ -10,74 +10,82 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import team.chisel.block.tileentity.TileEntityAutoChisel;
import team.chisel.inventory.ContainerAutoChisel;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import team.chisel.block.tileentity.TileEntityAutoChisel;
import team.chisel.inventory.ContainerAutoChisel;
public class GuiAutoChisel extends GuiContainer { public class GuiAutoChisel extends GuiContainer {
private static final ResourceLocation gui = new ResourceLocation("chisel:textures/autochisel-gui.png"); private static final ResourceLocation gui = new ResourceLocation("chisel:textures/autochisel-gui.png");
private TileEntityAutoChisel autochisel; private TileEntityAutoChisel autochisel;
public GuiAutoChisel(InventoryPlayer inventoryPlayer, TileEntityAutoChisel tileEntityAutoChisel) { public GuiAutoChisel(InventoryPlayer inventoryPlayer, TileEntityAutoChisel tileEntityAutoChisel) {
super(new ContainerAutoChisel(inventoryPlayer, tileEntityAutoChisel)); super(new ContainerAutoChisel(inventoryPlayer, tileEntityAutoChisel));
autochisel = tileEntityAutoChisel; autochisel = tileEntityAutoChisel;
} }
@Override @Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY); super.drawGuiContainerForegroundLayer(mouseX, mouseY);
} }
@SuppressWarnings("unchecked")
@Override
public void drawScreen(int mouseX, int mouseY, float partialTick) {
super.drawScreen(mouseX, mouseY, partialTick);
int x = (this.width - this.xSize) / 2; @SuppressWarnings("unchecked")
int y = (this.height - this.ySize) / 2; @Override
public void drawScreen(int mouseX, int mouseY, float partialTick) {
super.drawScreen(mouseX, mouseY, partialTick);
for (Slot slot : (List<Slot>) inventorySlots.inventorySlots) { int x = (this.width - this.xSize) / 2;
if (!slot.getHasStack() && mouseInside(slot, mouseX - x, mouseY - y)) { int y = (this.height - this.ySize) / 2;
if (slot.slotNumber < autochisel.getSizeInventory()) {
String tt = autochisel.getSlotTooltipUnloc(slot.slotNumber);
if (!Strings.isNullOrEmpty(tt)) {
this.func_146283_a(Lists.newArrayList(tt), mouseX, mouseY);
}
}
}
}
RenderHelper.enableGUIStandardItemLighting();
}
private boolean mouseInside(Slot slot, int x, int y) { for (Slot slot : (List<Slot>) inventorySlots.inventorySlots) {
return x >= slot.xDisplayPosition && x <= slot.xDisplayPosition + 16 && y >= slot.yDisplayPosition && y <= slot.yDisplayPosition + 16; if (!slot.getHasStack() && mouseInside(slot, mouseX - x, mouseY - y)) {
} if (slot.slotNumber < autochisel.getSizeInventory()) {
String tt = autochisel.getSlotTooltipUnloc(slot.slotNumber);
if (!Strings.isNullOrEmpty(tt)) {
this.func_146283_a(Lists.newArrayList(tt), mouseX, mouseY);
}
}
}
}
RenderHelper.enableGUIStandardItemLighting();
}
@Override private boolean mouseInside(Slot slot, int x, int y) {
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { return x >= slot.xDisplayPosition && x <= slot.xDisplayPosition + 16
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); && y >= slot.yDisplayPosition
this.mc.renderEngine.bindTexture(gui); && y <= slot.yDisplayPosition + 16;
int x = (width - xSize) / 2; }
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
for (int i = TileEntityAutoChisel.BASE; i < TileEntityAutoChisel.CHISEL; i++) { @Override
if (autochisel.getStackInSlot(i) == null) { protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
drawSlotOverlay(this, x, y, inventorySlots.getSlot(i), xSize, 0, 8); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
} this.mc.renderEngine.bindTexture(gui);
} int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
if (autochisel.getStackInSlot(TileEntityAutoChisel.CHISEL) == null) { for (int i = TileEntityAutoChisel.BASE; i < TileEntityAutoChisel.CHISEL; i++) {
drawSlotOverlay(this, x, y, inventorySlots.getSlot(TileEntityAutoChisel.CHISEL), xSize, 24, 0); if (autochisel.getStackInSlot(i) == null) {
} drawSlotOverlay(this, x, y, inventorySlots.getSlot(i), xSize, 0, 8);
} }
}
public static void drawSlotOverlay(GuiContainer gui, int x, int y, Slot slot, int u, int v, int padding) { if (autochisel.getStackInSlot(TileEntityAutoChisel.CHISEL) == null) {
padding /= 2; drawSlotOverlay(this, x, y, inventorySlots.getSlot(TileEntityAutoChisel.CHISEL), xSize, 24, 0);
gui.drawTexturedModalRect(x + (slot.xDisplayPosition - padding), y + (slot.yDisplayPosition - padding), u, v, 18 + padding, 18 + padding); }
} }
public static void drawSlotOverlay(GuiContainer gui, int x, int y, Slot slot, int u, int v, int padding) {
padding /= 2;
gui.drawTexturedModalRect(
x + (slot.xDisplayPosition - padding),
y + (slot.yDisplayPosition - padding),
u,
v,
18 + padding,
18 + padding);
}
} }
@@ -1,10 +1,7 @@
package team.chisel.client.gui; package team.chisel.client.gui;
import com.cricketcraft.chisel.api.IAdvancedChisel; import static team.chisel.Chisel.MOD_ID;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.api.carving.IChiselMode;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
@@ -13,8 +10,16 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.cricketcraft.chisel.api.IAdvancedChisel;
import com.cricketcraft.chisel.api.IChiselItem;
import com.cricketcraft.chisel.api.carving.IChiselMode;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.client.gui.widgets.GuiButtonChiselMode; import team.chisel.client.gui.widgets.GuiButtonChiselMode;
import team.chisel.inventory.ContainerChisel; import team.chisel.inventory.ContainerChisel;
import team.chisel.inventory.InventoryChiselSelection; import team.chisel.inventory.InventoryChiselSelection;
@@ -24,12 +29,12 @@ import team.chisel.network.PacketHandler;
import team.chisel.network.message.MessageChiselMode; import team.chisel.network.message.MessageChiselMode;
import team.chisel.utils.General; import team.chisel.utils.General;
import static team.chisel.Chisel.MOD_ID;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GuiChisel extends GuiContainer { public class GuiChisel extends GuiContainer {
public static final ResourceLocation TEXTURE_RESOURCE_LOCATION = new ResourceLocation(MOD_ID, "textures/chisel2GuiScroll.png"); public static final ResourceLocation TEXTURE_RESOURCE_LOCATION = new ResourceLocation(
MOD_ID,
"textures/chisel2GuiScroll.png");
public static final int TEXTURE_WIDTH = 266; public static final int TEXTURE_WIDTH = 266;
public static final int TEXTURE_HEIGHT = 250; public static final int TEXTURE_HEIGHT = 250;
public static final int GUI_WIDTH = 266; public static final int GUI_WIDTH = 266;
@@ -84,9 +89,8 @@ public class GuiChisel extends GuiContainer {
} }
private boolean showMode() { private boolean showMode() {
return container.chisel != null return container.chisel != null && container.chisel.getItem() instanceof IChiselItem
&& container.chisel.getItem() instanceof IChiselItem && ((IChiselItem) container.chisel.getItem()).hasModes(container.chisel);
&& ((IChiselItem) container.chisel.getItem()).hasModes(container.chisel);
} }
@Override @Override
@@ -94,11 +98,16 @@ public class GuiChisel extends GuiContainer {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
final String titleText = I18n.format(container.inventory.getInventoryName() + ".title"); final String titleText = I18n.format(container.inventory.getInventoryName() + ".title");
fontRendererObj.drawSplitString(titleText, 50 - fontRendererObj.getStringWidth(titleText) / 2, 60, 40, 0x404040); fontRendererObj
.drawSplitString(titleText, 50 - fontRendererObj.getStringWidth(titleText) / 2, 60, 40, 0x404040);
if (showMode()) { if (showMode()) {
final String modeText = I18n.format(container.inventory.getInventoryName() + ".mode"); final String modeText = I18n.format(container.inventory.getInventoryName() + ".mode");
fontRendererObj.drawString(modeText, 12 + (GuiButtonChiselMode.BUTTON_WIDTH - fontRendererObj.getStringWidth(modeText)) / 2, 122, 0x404040); fontRendererObj.drawString(
modeText,
12 + (GuiButtonChiselMode.BUTTON_WIDTH - fontRendererObj.getStringWidth(modeText)) / 2,
122,
0x404040);
} }
scrollBar.draw(this); scrollBar.draw(this);
@@ -109,13 +118,22 @@ public class GuiChisel extends GuiContainer {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHTING);
mc.getTextureManager().bindTexture(TEXTURE_RESOURCE_LOCATION); mc.getTextureManager()
.bindTexture(TEXTURE_RESOURCE_LOCATION);
// drawModalRectWithCustomSizedTexture: x, y, u, v, width, height, textureWidth, textureHeight // drawModalRectWithCustomSizedTexture: x, y, u, v, width, height, textureWidth, textureHeight
func_146110_a(guiLeft, guiTop, 0, 0, xSize, ySize, TEXTURE_WIDTH, TEXTURE_HEIGHT); func_146110_a(guiLeft, guiTop, 0, 0, xSize, ySize, TEXTURE_WIDTH, TEXTURE_HEIGHT);
Slot main = (Slot) container.inventorySlots.get(InventoryChiselSelection.normalSlots); Slot main = (Slot) container.inventorySlots.get(InventoryChiselSelection.normalSlots);
if (main.getStack() == null) { if (main.getStack() == null) {
func_146110_a(guiLeft + 8, guiTop + 8, 0, GUI_HEIGHT, CHISEL_INPUT_SIZE, CHISEL_INPUT_SIZE, TEXTURE_WIDTH, TEXTURE_HEIGHT); func_146110_a(
guiLeft + 8,
guiTop + 8,
0,
GUI_HEIGHT,
CHISEL_INPUT_SIZE,
CHISEL_INPUT_SIZE,
TEXTURE_WIDTH,
TEXTURE_HEIGHT);
} }
} }
@@ -1,17 +1,24 @@
package team.chisel.client.gui; package team.chisel.client.gui;
import team.chisel.Chisel;
import team.chisel.config.Configurations;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.ConfigElement; import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.client.config.GuiConfig; import cpw.mods.fml.client.config.GuiConfig;
import team.chisel.Chisel;
import team.chisel.config.Configurations;
public class GuiChiselConfig extends GuiConfig { public class GuiChiselConfig extends GuiConfig {
public GuiChiselConfig(GuiScreen parent) { public GuiChiselConfig(GuiScreen parent) {
super(parent, new ConfigElement<ConfigCategory>(Configurations.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), Chisel.MOD_ID, false, false, GuiConfig super(
.getAbridgedConfigPath(Configurations.config.toString())); parent,
} new ConfigElement<ConfigCategory>(Configurations.config.getCategory(Configuration.CATEGORY_GENERAL))
.getChildElements(),
Chisel.MOD_ID,
false,
false,
GuiConfig.getAbridgedConfigPath(Configurations.config.toString()));
}
} }
@@ -4,27 +4,28 @@ import java.util.Set;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import cpw.mods.fml.client.IModGuiFactory; import cpw.mods.fml.client.IModGuiFactory;
public class GuiFactory implements IModGuiFactory { public class GuiFactory implements IModGuiFactory {
@Override @Override
public void initialize(Minecraft minecraftInstance) { public void initialize(Minecraft minecraftInstance) {
} }
@Override @Override
public Class<? extends GuiScreen> mainConfigGuiClass() { public Class<? extends GuiScreen> mainConfigGuiClass() {
return GuiChiselConfig.class; return GuiChiselConfig.class;
} }
@Override @Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() { public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
return null; return null;
} }
@Override @Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
return null; return null;
} }
} }
@@ -11,22 +11,23 @@ import team.chisel.inventory.ContainerPresent;
public class GuiPresent extends GuiContainer { public class GuiPresent extends GuiContainer {
private static final ResourceLocation gui = new ResourceLocation("chisel:textures/present-gui.png"); private static final ResourceLocation gui = new ResourceLocation("chisel:textures/present-gui.png");
private int rows; private int rows;
public GuiPresent(InventoryPlayer inventoryPlayer, TileEntityPresent tileEntityPresent) { public GuiPresent(InventoryPlayer inventoryPlayer, TileEntityPresent tileEntityPresent) {
super(new ContainerPresent(inventoryPlayer, tileEntityPresent)); super(new ContainerPresent(inventoryPlayer, tileEntityPresent));
rows = tileEntityPresent.getSizeInventory() / 9; rows = tileEntityPresent.getSizeInventory() / 9;
this.ySize = 114 + rows * 18; this.ySize = 114 + rows * 18;
} }
@Override @Override
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); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(gui); this.mc.getTextureManager()
int x = (this.width - this.xSize) / 2; .bindTexture(gui);
int y = (this.height - this.ySize) / 2; int x = (this.width - this.xSize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.rows * 18 + 17); int y = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(x, y + this.rows * 18 + 17, 0, 126, this.xSize, 96); this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.rows * 18 + 17);
} this.drawTexturedModalRect(x, y + this.rows * 18 + 17, 0, 126, this.xSize, 96);
}
} }
@@ -1,13 +1,18 @@
package team.chisel.client.gui; package team.chisel.client.gui;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import team.chisel.inventory.ContainerChisel; import team.chisel.inventory.ContainerChisel;
import team.chisel.network.PacketHandler; import team.chisel.network.PacketHandler;
import team.chisel.network.message.MessageScrollUpdate; import team.chisel.network.message.MessageScrollUpdate;
public class GuiScrollbar { public class GuiScrollbar {
public static final ResourceLocation TEXTURE_RESOURCE_LOCATION = new ResourceLocation("minecraft", "textures/gui/container/creative_inventory/tabs.png");
public static final ResourceLocation TEXTURE_RESOURCE_LOCATION = new ResourceLocation(
"minecraft",
"textures/gui/container/creative_inventory/tabs.png");
private int displayX = 0; private int displayX = 0;
private int displayY = 0; private int displayY = 0;
@@ -21,8 +26,10 @@ public class GuiScrollbar {
private ContainerChisel container; private ContainerChisel container;
public void draw(GuiChisel g) { public void draw(GuiChisel g) {
// chisel2GuiScroll scroll button texture coordinates work strange (maybe because of alignment) so taking vanilla one // chisel2GuiScroll scroll button texture coordinates work strange (maybe because of alignment) so taking
g.mc.getTextureManager().bindTexture(TEXTURE_RESOURCE_LOCATION); // vanilla one
g.mc.getTextureManager()
.bindTexture(TEXTURE_RESOURCE_LOCATION);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
if (getMaxScroll() == 0) { if (getMaxScroll() == 0) {
@@ -1,106 +1,122 @@
package team.chisel.client.gui.widgets; package team.chisel.client.gui.widgets;
import static team.chisel.client.gui.GuiChisel.TEXTURE_HEIGHT;
import static team.chisel.client.gui.GuiChisel.TEXTURE_RESOURCE_LOCATION;
import static team.chisel.client.gui.GuiChisel.TEXTURE_WIDTH;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import org.lwjgl.opengl.GL11;
import team.chisel.client.gui.GuiChisel; import team.chisel.client.gui.GuiChisel;
import team.chisel.item.chisel.ChiselMode; import team.chisel.item.chisel.ChiselMode;
import static team.chisel.client.gui.GuiChisel.*;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GuiButtonChiselMode extends GuiButton { public class GuiButtonChiselMode extends GuiButton {
public static final int BUTTON_WIDTH = 48;
public static final int BUTTON_HEIGHT = 48;
private static final float BUTTON_BACKGROUND_U = 48;
private static final float BUTTON_BACKGROUND_V = 202;
private static final float MODE_VIGNETTE_U = BUTTON_BACKGROUND_U + 2 * BUTTON_WIDTH + 3;
private static final float MODE_VIGNETTE_V = BUTTON_BACKGROUND_V + 3;
private static final int MODE_VIGNETTE_WIDTH = 14;
private static final int MODE_VIGNETTE_ROW_WIDTH = 3 * MODE_VIGNETTE_WIDTH;
private static final int MODE_VIGNETTE_HEIGHT = 14;
private static final int MODE_VIGNETTE_COL_HEIGHT = 3 * MODE_VIGNETTE_HEIGHT;
private final GuiChisel guiChisel;
public GuiButtonChiselMode(int id, int x, int y, GuiChisel guiChisel) { public static final int BUTTON_WIDTH = 48;
super(id, x, y, BUTTON_WIDTH, BUTTON_HEIGHT, ""); public static final int BUTTON_HEIGHT = 48;
this.guiChisel = guiChisel; private static final float BUTTON_BACKGROUND_U = 48;
} private static final float BUTTON_BACKGROUND_V = 202;
private static final float MODE_VIGNETTE_U = BUTTON_BACKGROUND_U + 2 * BUTTON_WIDTH + 3;
private static final float MODE_VIGNETTE_V = BUTTON_BACKGROUND_V + 3;
private static final int MODE_VIGNETTE_WIDTH = 14;
private static final int MODE_VIGNETTE_ROW_WIDTH = 3 * MODE_VIGNETTE_WIDTH;
private static final int MODE_VIGNETTE_HEIGHT = 14;
private static final int MODE_VIGNETTE_COL_HEIGHT = 3 * MODE_VIGNETTE_HEIGHT;
private final GuiChisel guiChisel;
/** public GuiButtonChiselMode(int id, int x, int y, GuiChisel guiChisel) {
* Draws this button to the screen. super(id, x, y, BUTTON_WIDTH, BUTTON_HEIGHT, "");
* this.guiChisel = guiChisel;
* @param mc The Minecraft instance }
* @param mouseX The horizontal location of the mouse within the GuiScreen
* @param mouseY The vertical location of the mouse relative to the GuiScreen
*/
@Override
public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) {
if (this.visible) {
mc.getTextureManager().bindTexture(TEXTURE_RESOURCE_LOCATION);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
// Mouse Hover State
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height;
drawButtonBackgroundLayer();
drawButtonForegroundLayer();
}
}
private void drawButtonBackgroundLayer() { /**
final float u = BUTTON_BACKGROUND_U + (this.field_146123_n ? BUTTON_WIDTH : 0); * Draws this button to the screen.
// drawModalRectWithCustomSizedTexture: x, y, u, v, width, height, textureWidth, textureHeight *
func_146110_a(this.xPosition, this.yPosition, u, BUTTON_BACKGROUND_V, this.width, this.height, TEXTURE_WIDTH, TEXTURE_HEIGHT); * @param mc The Minecraft instance
} * @param mouseX The horizontal location of the mouse within the GuiScreen
* @param mouseY The vertical location of the mouse relative to the GuiScreen
*/
@Override
public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) {
if (this.visible) {
mc.getTextureManager()
.bindTexture(TEXTURE_RESOURCE_LOCATION);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
// Mouse Hover State
this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition
&& mouseX < this.xPosition + this.width
&& mouseY < this.yPosition + this.height;
drawButtonBackgroundLayer();
drawButtonForegroundLayer();
}
}
private void drawButtonForegroundLayer() { private void drawButtonBackgroundLayer() {
final int xBase = this.xPosition + 3; final float u = BUTTON_BACKGROUND_U + (this.field_146123_n ? BUTTON_WIDTH : 0);
final int yBase = this.yPosition + 3; // drawModalRectWithCustomSizedTexture: x, y, u, v, width, height, textureWidth, textureHeight
final float uBase = MODE_VIGNETTE_U + (this.field_146123_n ? BUTTON_WIDTH : 0); func_146110_a(
final float u; this.xPosition,
final float v; this.yPosition,
final int w; u,
final int h; BUTTON_BACKGROUND_V,
final int x; this.width,
final int y; this.height,
switch ((ChiselMode) guiChisel.getCurrentMode()) { TEXTURE_WIDTH,
case SINGLE: TEXTURE_HEIGHT);
x = xBase + MODE_VIGNETTE_WIDTH; }
y = yBase + MODE_VIGNETTE_HEIGHT;
u = uBase + MODE_VIGNETTE_WIDTH; private void drawButtonForegroundLayer() {
v = MODE_VIGNETTE_V + MODE_VIGNETTE_HEIGHT; final int xBase = this.xPosition + 3;
w = MODE_VIGNETTE_WIDTH; final int yBase = this.yPosition + 3;
h = MODE_VIGNETTE_HEIGHT; final float uBase = MODE_VIGNETTE_U + (this.field_146123_n ? BUTTON_WIDTH : 0);
break; final float u;
case ROW: final float v;
x = xBase; final int w;
y = yBase + MODE_VIGNETTE_HEIGHT; final int h;
u = uBase; final int x;
v = MODE_VIGNETTE_V + MODE_VIGNETTE_HEIGHT; final int y;
w = MODE_VIGNETTE_ROW_WIDTH; switch ((ChiselMode) guiChisel.getCurrentMode()) {
h = MODE_VIGNETTE_HEIGHT; case SINGLE:
break; x = xBase + MODE_VIGNETTE_WIDTH;
case COLUMN: y = yBase + MODE_VIGNETTE_HEIGHT;
x = xBase + MODE_VIGNETTE_WIDTH; u = uBase + MODE_VIGNETTE_WIDTH;
y = yBase; v = MODE_VIGNETTE_V + MODE_VIGNETTE_HEIGHT;
u = uBase + MODE_VIGNETTE_WIDTH; w = MODE_VIGNETTE_WIDTH;
v = MODE_VIGNETTE_V; h = MODE_VIGNETTE_HEIGHT;
w = MODE_VIGNETTE_WIDTH; break;
h = MODE_VIGNETTE_COL_HEIGHT; case ROW:
break; x = xBase;
case PANEL: y = yBase + MODE_VIGNETTE_HEIGHT;
x = xBase; u = uBase;
y = yBase; v = MODE_VIGNETTE_V + MODE_VIGNETTE_HEIGHT;
u = uBase; w = MODE_VIGNETTE_ROW_WIDTH;
v = MODE_VIGNETTE_V; h = MODE_VIGNETTE_HEIGHT;
w = MODE_VIGNETTE_ROW_WIDTH; break;
h = MODE_VIGNETTE_COL_HEIGHT; case COLUMN:
break; x = xBase + MODE_VIGNETTE_WIDTH;
default: y = yBase;
return; u = uBase + MODE_VIGNETTE_WIDTH;
} v = MODE_VIGNETTE_V;
// drawModalRectWithCustomSizedTexture: x, y, u, v, width, height, textureWidth, textureHeight w = MODE_VIGNETTE_WIDTH;
func_146110_a(x, y, u, v, w, h, TEXTURE_WIDTH, TEXTURE_HEIGHT); h = MODE_VIGNETTE_COL_HEIGHT;
} break;
case PANEL:
x = xBase;
y = yBase;
u = uBase;
v = MODE_VIGNETTE_V;
w = MODE_VIGNETTE_ROW_WIDTH;
h = MODE_VIGNETTE_COL_HEIGHT;
break;
default:
return;
}
// drawModalRectWithCustomSizedTexture: x, y, u, v, width, height, textureWidth, textureHeight
func_146110_a(x, y, u, v, w, h, TEXTURE_WIDTH, TEXTURE_HEIGHT);
}
} }
@@ -0,0 +1,35 @@
package team.chisel.client.render;
import codechicken.lib.render.CCRenderState;
public class FullBrightLighting implements CCRenderState.IVertexOperation {
public static FullBrightLighting instance = new FullBrightLighting();
public int id;
public boolean load() {
if (!CCRenderState.computeLighting) {
return false;
}
CCRenderState.pipeline.addDependency(CCRenderState.colourAttrib);
CCRenderState.pipeline.addDependency(CCRenderState.lightCoordAttrib);
return true;
}
public void operate() {
CCRenderState.setBrightness(FULL_BRIGHT_BLOCK_BRIGHTNESS);
}
public int operationID() {
return id;
}
{
id = CCRenderState.registerOperation();
}
// magic number from 'RenderBlocksCTMFullbright'
// this is the brightness of the neonite, anti, glotek blocks
// so we use it for custom microblock lighting
private final static int FULL_BRIGHT_BLOCK_BRIGHTNESS = 0xF000F0;
}
@@ -0,0 +1,33 @@
package team.chisel.client.render;
import net.minecraft.block.Block;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.ColourMultiplier;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.BlockMicroMaterial;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class FullBrightMicroMaterial extends BlockMicroMaterial {
public FullBrightMicroMaterial(final Block block, final int meta) {
super(block, meta);
}
@SideOnly(Side.CLIENT)
public void renderMicroFace(final Vector3 pos, final int pass, final Cuboid6 bounds) {
CCRenderState.pipeline.builder()
.add((CCRenderState.IVertexOperation) pos.translation())
.add((CCRenderState.IVertexOperation) this.icont())
.add((CCRenderState.IVertexOperation) ColourMultiplier.instance(FULL_BRIGHT_COLOR_MULTIPLIER))
.add((CCRenderState.IVertexOperation) FullBrightLighting.instance)
.render();
}
// magic number from 'RenderBlocksCTMFullbright'
// this is what makes the neonite, anti, glotek blocks burn bright as my ass does
// so we use it for custom microblock render
private final static int FULL_BRIGHT_COLOR_MULTIPLIER = 0xFFFFFFFF;
}
@@ -7,288 +7,296 @@ import net.minecraft.util.IIcon;
public class RenderBlocksEldritch extends RenderBlocks { public class RenderBlocksEldritch extends RenderBlocks {
RenderBlocksEldritch() { RenderBlocksEldritch() {
super(); super();
} }
static double displacementMap[] = { +0.1165, -0.0352, -0.1208, +0.0906, -0.0295, +0.0302, -0.0973, +0.0548, -0.1077, +0.0662, -0.0932, -0.0925, -0.1161, +0.0073, -0.1084, +0.1136, +0.0307, static double displacementMap[] = { +0.1165, -0.0352, -0.1208, +0.0906, -0.0295, +0.0302, -0.0973, +0.0548, -0.1077,
+0.0316, -0.1066, -0.0237, +0.0614, -0.0864, +0.0837, +0.1218, +0.0502, -0.0529, -0.0942, +0.1209, -0.0418, +0.1035, +0.0066, -0.0255, +0.0830, -0.0361, +0.0965, +0.0646, +0.1124, +0.0662, -0.0932, -0.0925, -0.1161, +0.0073, -0.1084, +0.1136, +0.0307, +0.0316, -0.1066, -0.0237, +0.0614,
+0.0890, -0.0037, +0.0467, +0.1025, +0.1161, +0.0014, +0.0365, +0.0755, -0.0025, +0.0739, +0.0656, +0.0571, -0.0813, -0.0062, -0.0904, -0.0005, +0.0612, -0.0227, +0.0138, -0.0899, -0.0864, +0.0837, +0.1218, +0.0502, -0.0529, -0.0942, +0.1209, -0.0418, +0.1035, +0.0066, -0.0255, +0.0830,
-0.0019, -0.1047, +0.1191, -0.1197, -0.1123, +0.0999, +0.0638, +0.0865, +0.0029, -0.0084, +0.1132, -0.0433, +0.0115, +0.0850, +0.0439, +0.0748, +0.0460, -0.0441, +0.0839, +0.0162, -0.0361, +0.0965, +0.0646, +0.1124, +0.0890, -0.0037, +0.0467, +0.1025, +0.1161, +0.0014, +0.0365, +0.0755,
-0.0229, +0.0774, -0.0647, -0.0636, -0.0709, -0.0719, -0.0194, +0.1070, -0.0466, -0.1200, -0.0996, -0.0298, -0.1035, -0.0006, +0.0530, -0.0939, -0.1210, +0.0176, +0.0924, +0.0343, -0.0025, +0.0739, +0.0656, +0.0571, -0.0813, -0.0062, -0.0904, -0.0005, +0.0612, -0.0227, +0.0138, -0.0899,
-0.0777, +0.1050, -0.0729, -0.0062, -0.1107, -0.0434, -0.0042, +0.0232, +0.0269, +0.0709, -0.0388, +0.0342, +0.0240, -0.0192, +0.0491, +0.0017, -0.1240, +0.0687, -0.1160, +0.1123, -0.0019, -0.1047, +0.1191, -0.1197, -0.1123, +0.0999, +0.0638, +0.0865, +0.0029, -0.0084, +0.1132, -0.0433,
-0.0332, -0.0260, +0.0476, -0.0049, -0.0893, -0.0243, -0.0371, -0.0230, +0.0656, +0.1080, +0.0781, -0.0648, +0.0082, -0.1086, -0.0451, -0.0594, -0.1155, -0.0623, -0.0152, +0.0131, +0.0115, +0.0850, +0.0439, +0.0748, +0.0460, -0.0441, +0.0839, +0.0162, -0.0229, +0.0774, -0.0647, -0.0636,
-0.0754, +0.0607, +0.0876, -0.0657, +0.0366, -0.0981, +0.1164, -0.0623, +0.0181, -0.0475, +0.0722, -0.0293, +0.0486, -0.0195, +0.1041, +0.1011, +0.0042, -0.0045, -0.1031, +0.0110, -0.0709, -0.0719, -0.0194, +0.1070, -0.0466, -0.1200, -0.0996, -0.0298, -0.1035, -0.0006, +0.0530, -0.0939,
+0.0058, +0.0083, -0.0782, -0.1003, -0.0082, -0.0304, -0.0971, -0.0097, -0.0208, -0.1059, -0.0239, -0.0385, +0.0505, +0.0537, -0.1098, -0.0022, -0.0165, -0.0027, -0.0208, +0.0305, -0.1210, +0.0176, +0.0924, +0.0343, -0.0777, +0.1050, -0.0729, -0.0062, -0.1107, -0.0434, -0.0042, +0.0232,
+0.0592, +0.0301, +0.0055, +0.1138, -0.0338, -0.0901, +0.1015, +0.0061, +0.0861, -0.1057, -0.0889, -0.0972, +0.0783, -0.1052, -0.0932, -0.1103, +0.0497, +0.1222, -0.0146, +0.0632, +0.0269, +0.0709, -0.0388, +0.0342, +0.0240, -0.0192, +0.0491, +0.0017, -0.1240, +0.0687, -0.1160, +0.1123,
-0.0240, -0.0193, +0.0676, -0.1128, -0.0886, +0.0926, +0.0538, -0.0175, -0.0966, -0.0369, +0.1124, -0.0820, -0.1013, -0.0836, -0.0981, -0.0502, +0.0573, +0.0616, -0.0458, +0.0294, -0.0332, -0.0260, +0.0476, -0.0049, -0.0893, -0.0243, -0.0371, -0.0230, +0.0656, +0.1080, +0.0781, -0.0648,
+0.0108, -0.0782, +0.0692, +0.0234, -0.0178, -0.0171, -0.0505, -0.0313, +0.0538, +0.0462, -0.0758, +0.0556, -0.0023, -0.1086, -0.0100, -0.0897, -0.0409, -0.1161, +0.0212, +0.1229, +0.0082, -0.1086, -0.0451, -0.0594, -0.1155, -0.0623, -0.0152, +0.0131, -0.0754, +0.0607, +0.0876, -0.0657,
-0.0945, +0.0341, +0.1238, +0.0893, -0.1189, -0.1098, -0.0125, +0.1137, -0.0202, +0.0239, -0.0408, +0.0920, +0.0777, -0.0085, -0.0572, -0.0293, -0.0131, +0.0272, +0.0991, }; +0.0366, -0.0981, +0.1164, -0.0623, +0.0181, -0.0475, +0.0722, -0.0293, +0.0486, -0.0195, +0.1041, +0.1011,
+0.0042, -0.0045, -0.1031, +0.0110, +0.0058, +0.0083, -0.0782, -0.1003, -0.0082, -0.0304, -0.0971, -0.0097,
-0.0208, -0.1059, -0.0239, -0.0385, +0.0505, +0.0537, -0.1098, -0.0022, -0.0165, -0.0027, -0.0208, +0.0305,
+0.0592, +0.0301, +0.0055, +0.1138, -0.0338, -0.0901, +0.1015, +0.0061, +0.0861, -0.1057, -0.0889, -0.0972,
+0.0783, -0.1052, -0.0932, -0.1103, +0.0497, +0.1222, -0.0146, +0.0632, -0.0240, -0.0193, +0.0676, -0.1128,
-0.0886, +0.0926, +0.0538, -0.0175, -0.0966, -0.0369, +0.1124, -0.0820, -0.1013, -0.0836, -0.0981, -0.0502,
+0.0573, +0.0616, -0.0458, +0.0294, +0.0108, -0.0782, +0.0692, +0.0234, -0.0178, -0.0171, -0.0505, -0.0313,
+0.0538, +0.0462, -0.0758, +0.0556, -0.0023, -0.1086, -0.0100, -0.0897, -0.0409, -0.1161, +0.0212, +0.1229,
-0.0945, +0.0341, +0.1238, +0.0893, -0.1189, -0.1098, -0.0125, +0.1137, -0.0202, +0.0239, -0.0408, +0.0920,
+0.0777, -0.0085, -0.0572, -0.0293, -0.0131, +0.0272, +0.0991, };
static int dmap1 = displacementMap.length * 1 / 6; static int dmap1 = displacementMap.length * 1 / 6;
static int dmap2 = displacementMap.length * 2 / 6; static int dmap2 = displacementMap.length * 2 / 6;
static int dmap3 = displacementMap.length * 3 / 6; static int dmap3 = displacementMap.length * 3 / 6;
static int dmap4 = displacementMap.length * 4 / 6; static int dmap4 = displacementMap.length * 4 / 6;
static int dmap5 = displacementMap.length * 5 / 6; static int dmap5 = displacementMap.length * 5 / 6;
static int dmap = displacementMap.length; static int dmap = displacementMap.length;
Tessellator tessellator; Tessellator tessellator;
double[] X = new double[14]; double[] X = new double[14];
double[] Y = new double[14]; double[] Y = new double[14];
double[] Z = new double[14]; double[] Z = new double[14];
double[] U = new double[14]; double[] U = new double[14];
double[] V = new double[14]; double[] V = new double[14];
int[] L = new int[14]; int[] L = new int[14];
float[] R = new float[14]; float[] R = new float[14];
float[] G = new float[14]; float[] G = new float[14];
float[] B = new float[14]; float[] B = new float[14];
@Override @Override
public boolean renderStandardBlock(Block block, int x, int y, int z) { public boolean renderStandardBlock(Block block, int x, int y, int z) {
int index = x + y * 34573 + z * 32465781; int index = x + y * 34573 + z * 32465781;
if (index < 0) if (index < 0) index = -index;
index = -index;
X[0] = x; X[0] = x;
Z[0] = z; Z[0] = z;
Y[0] = y; Y[0] = y;
X[1] = x; X[1] = x;
Z[1] = z; Z[1] = z;
Y[1] = y + 1; Y[1] = y + 1;
X[2] = x + 1; X[2] = x + 1;
Z[2] = z; Z[2] = z;
Y[2] = y + 1; Y[2] = y + 1;
X[3] = x + 1; X[3] = x + 1;
Z[3] = z; Z[3] = z;
Y[3] = y; Y[3] = y;
X[4] = x; X[4] = x;
Z[4] = z + 1; Z[4] = z + 1;
Y[4] = y; Y[4] = y;
X[5] = x; X[5] = x;
Z[5] = z + 1; Z[5] = z + 1;
Y[5] = y + 1; Y[5] = y + 1;
X[6] = x + 1; X[6] = x + 1;
Z[6] = z + 1; Z[6] = z + 1;
Y[6] = y + 1; Y[6] = y + 1;
X[7] = x + 1; X[7] = x + 1;
Z[7] = z + 1; Z[7] = z + 1;
Y[7] = y; Y[7] = y;
X[8] = x + 0.5 + displacementMap[(index + 0) % dmap]; X[8] = x + 0.5 + displacementMap[(index + 0) % dmap];
Z[8] = z - displacementMap[(index + 10) % dmap]; Z[8] = z - displacementMap[(index + 10) % dmap];
Y[8] = y + 0.5 + displacementMap[(index + 20) % dmap]; Y[8] = y + 0.5 + displacementMap[(index + 20) % dmap];
X[9] = x - displacementMap[(index + 0 + dmap1) % dmap]; X[9] = x - displacementMap[(index + 0 + dmap1) % dmap];
Z[9] = z + 0.5 + displacementMap[(index + 10 + dmap1) % dmap]; Z[9] = z + 0.5 + displacementMap[(index + 10 + dmap1) % dmap];
Y[9] = y + 0.5 + displacementMap[(index + 20 + dmap1) % dmap]; Y[9] = y + 0.5 + displacementMap[(index + 20 + dmap1) % dmap];
X[10] = x + 0.5 + displacementMap[(index + 0 + dmap2) % dmap]; X[10] = x + 0.5 + displacementMap[(index + 0 + dmap2) % dmap];
Z[10] = z + 1 + displacementMap[(index + 10 + dmap2) % dmap]; Z[10] = z + 1 + displacementMap[(index + 10 + dmap2) % dmap];
Y[10] = y + 0.5 + displacementMap[(index + 20 + dmap2) % dmap]; Y[10] = y + 0.5 + displacementMap[(index + 20 + dmap2) % dmap];
X[11] = x + 1 + displacementMap[(index + 0 + dmap3) % dmap]; X[11] = x + 1 + displacementMap[(index + 0 + dmap3) % dmap];
Z[11] = z + 0.5 + displacementMap[(index + 10 + dmap3) % dmap]; Z[11] = z + 0.5 + displacementMap[(index + 10 + dmap3) % dmap];
Y[11] = y + 0.5 + displacementMap[(index + 20 + dmap3) % dmap]; Y[11] = y + 0.5 + displacementMap[(index + 20 + dmap3) % dmap];
X[12] = x + 0.5 + displacementMap[(index + 0 + dmap4) % dmap]; X[12] = x + 0.5 + displacementMap[(index + 0 + dmap4) % dmap];
Z[12] = z + 0.5 + displacementMap[(index + 10 + dmap4) % dmap]; Z[12] = z + 0.5 + displacementMap[(index + 10 + dmap4) % dmap];
Y[12] = y + 1;// +displacementMap[(index+20+dmap4)%dmap]; Y[12] = y + 1;// +displacementMap[(index+20+dmap4)%dmap];
X[13] = x + 0.5 + displacementMap[(index + 0 + dmap5) % dmap]; X[13] = x + 0.5 + displacementMap[(index + 0 + dmap5) % dmap];
Z[13] = z + 0.5 + displacementMap[(index + 10 + dmap5) % dmap]; Z[13] = z + 0.5 + displacementMap[(index + 10 + dmap5) % dmap];
Y[13] = y + 0;// +displacementMap[(index+20+dmap5)%dmap]; Y[13] = y + 0;// +displacementMap[(index+20+dmap5)%dmap];
tessellator = Tessellator.instance; tessellator = Tessellator.instance;
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
return super.renderStandardBlock(block, x, y, z); return super.renderStandardBlock(block, x, y, z);
} }
void setupSides(IIcon icon, int a, int b, int c, int d, int e, int ta, int tb, int tc, int td) { void setupSides(IIcon icon, int a, int b, int c, int d, int e, int ta, int tb, int tc, int td) {
L[a] = brightnessBottomLeft; L[a] = brightnessBottomLeft;
L[b] = brightnessBottomRight; L[b] = brightnessBottomRight;
L[c] = brightnessTopRight; L[c] = brightnessTopRight;
L[d] = brightnessTopLeft; L[d] = brightnessTopLeft;
L[e] = (brightnessBottomLeft + brightnessTopLeft + brightnessTopRight + brightnessBottomRight) / 4; L[e] = (brightnessBottomLeft + brightnessTopLeft + brightnessTopRight + brightnessBottomRight) / 4;
R[a] = colorRedBottomLeft; R[a] = colorRedBottomLeft;
R[b] = colorRedBottomRight; R[b] = colorRedBottomRight;
R[c] = colorRedTopRight; R[c] = colorRedTopRight;
R[d] = colorRedTopLeft; R[d] = colorRedTopLeft;
R[e] = (colorRedBottomLeft + colorRedTopLeft + colorRedTopRight + colorRedBottomRight) / 4; R[e] = (colorRedBottomLeft + colorRedTopLeft + colorRedTopRight + colorRedBottomRight) / 4;
G[a] = colorGreenBottomLeft; G[a] = colorGreenBottomLeft;
G[b] = colorGreenBottomRight; G[b] = colorGreenBottomRight;
G[c] = colorGreenTopRight; G[c] = colorGreenTopRight;
G[d] = colorGreenTopLeft; G[d] = colorGreenTopLeft;
G[e] = (colorGreenBottomLeft + colorGreenTopLeft + colorGreenTopRight + colorGreenBottomRight) / 4; G[e] = (colorGreenBottomLeft + colorGreenTopLeft + colorGreenTopRight + colorGreenBottomRight) / 4;
B[a] = colorBlueBottomLeft; B[a] = colorBlueBottomLeft;
B[b] = colorBlueBottomRight; B[b] = colorBlueBottomRight;
B[c] = colorBlueTopRight; B[c] = colorBlueTopRight;
B[d] = colorBlueTopLeft; B[d] = colorBlueTopLeft;
B[e] = (colorBlueBottomLeft + colorBlueTopLeft + colorBlueTopRight + colorBlueBottomRight) / 4; B[e] = (colorBlueBottomLeft + colorBlueTopLeft + colorBlueTopRight + colorBlueBottomRight) / 4;
double u0 = icon.getMaxU(); double u0 = icon.getMaxU();
double u1 = icon.getMinU(); double u1 = icon.getMinU();
double v0 = icon.getMaxV(); double v0 = icon.getMaxV();
double v1 = icon.getMinV(); double v1 = icon.getMinV();
U[ta] = u0; U[ta] = u0;
U[tb] = u0; U[tb] = u0;
U[tc] = u1; U[tc] = u1;
U[td] = u1; U[td] = u1;
U[e] = icon.getInterpolatedU(8.0D); U[e] = icon.getInterpolatedU(8.0D);
V[ta] = v0; V[ta] = v0;
V[tb] = v1; V[tb] = v1;
V[tc] = v1; V[tc] = v1;
V[td] = v0; V[td] = v0;
V[e] = icon.getInterpolatedV(8.0D); V[e] = icon.getInterpolatedV(8.0D);
} }
void vert(int index) { void vert(int index) {
if (enableAO) { if (enableAO) {
tessellator.setColorOpaque_F(R[index], G[index], B[index]); tessellator.setColorOpaque_F(R[index], G[index], B[index]);
tessellator.setBrightness(L[index]); tessellator.setBrightness(L[index]);
} }
tessellator.addVertexWithUV(X[index], Y[index], Z[index], U[index], V[index]); tessellator.addVertexWithUV(X[index], Y[index], Z[index], U[index], V[index]);
} }
@Override @Override
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) { public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
setupSides(icon, 1, 0, 4, 5, 9, 4, 5, 1, 0); setupSides(icon, 1, 0, 4, 5, 9, 4, 5, 1, 0);
vert(1); vert(1);
vert(0); vert(0);
vert(9); vert(9);
vert(9); vert(9);
vert(0); vert(0);
vert(4); vert(4);
vert(9); vert(9);
vert(9); vert(9);
vert(4); vert(4);
vert(5); vert(5);
vert(9); vert(9);
vert(9); vert(9);
vert(5); vert(5);
vert(1); vert(1);
vert(9); vert(9);
vert(9); vert(9);
} }
@Override @Override
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) { public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
setupSides(icon, 3, 2, 6, 7, 11, 3, 2, 6, 7); setupSides(icon, 3, 2, 6, 7, 11, 3, 2, 6, 7);
vert(6); vert(6);
vert(7); vert(7);
vert(11); vert(11);
vert(11); vert(11);
vert(7); vert(7);
vert(3); vert(3);
vert(11); vert(11);
vert(11); vert(11);
vert(3); vert(3);
vert(2); vert(2);
vert(11); vert(11);
vert(11); vert(11);
vert(2); vert(2);
vert(6); vert(6);
vert(11); vert(11);
vert(11); vert(11);
} }
@Override @Override
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) { public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
setupSides(icon, 2, 3, 0, 1, 8, 0, 1, 2, 3); setupSides(icon, 2, 3, 0, 1, 8, 0, 1, 2, 3);
vert(0); vert(0);
vert(1); vert(1);
vert(8); vert(8);
vert(8); vert(8);
vert(1); vert(1);
vert(2); vert(2);
vert(8); vert(8);
vert(8); vert(8);
vert(2); vert(2);
vert(3); vert(3);
vert(8); vert(8);
vert(8); vert(8);
vert(3); vert(3);
vert(0); vert(0);
vert(8); vert(8);
vert(8); vert(8);
} }
@Override @Override
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) { public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
setupSides(icon, 4, 7, 6, 5, 10, 7, 6, 5, 4); setupSides(icon, 4, 7, 6, 5, 10, 7, 6, 5, 4);
vert(5); vert(5);
vert(4); vert(4);
vert(10); vert(10);
vert(10); vert(10);
vert(6); vert(6);
vert(5); vert(5);
vert(10); vert(10);
vert(10); vert(10);
vert(7); vert(7);
vert(6); vert(6);
vert(10); vert(10);
vert(10); vert(10);
vert(4); vert(4);
vert(7); vert(7);
vert(10); vert(10);
vert(10); vert(10);
} }
@Override @Override
public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) { public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) {
setupSides(icon, 0, 3, 7, 4, 13, 0, 3, 7, 4); setupSides(icon, 0, 3, 7, 4, 13, 0, 3, 7, 4);
vert(0); vert(0);
vert(3); vert(3);
vert(13); vert(13);
vert(13); vert(13);
vert(3); vert(3);
vert(7); vert(7);
vert(13); vert(13);
vert(13); vert(13);
vert(7); vert(7);
vert(4); vert(4);
vert(13); vert(13);
vert(13); vert(13);
vert(4); vert(4);
vert(0); vert(0);
vert(13); vert(13);
vert(13); vert(13);
} }
@Override @Override
public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) { public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) {
setupSides(icon, 2, 1, 5, 6, 12, 2, 1, 5, 6); setupSides(icon, 2, 1, 5, 6, 12, 2, 1, 5, 6);
vert(2); vert(2);
vert(1); vert(1);
vert(12); vert(12);
vert(12); vert(12);
vert(1); vert(1);
vert(5); vert(5);
vert(12); vert(12);
vert(12); vert(12);
vert(5); vert(5);
vert(6); vert(6);
vert(12); vert(12);
vert(12); vert(12);
vert(6); vert(6);
vert(2); vert(2);
vert(12); vert(12);
vert(12); vert(12);
} }
} }
Loaded 100 of 350 files, more files were not shown because too many files have changed in this diff. Show more