Compare commits

..
115 Commits
Author SHA1 Message Date
Dream Master 2415e17583 update 2024-08-04 19:47:45 +07:00
Lyft 0cabe335dd fix aiob when opening chisel in some slots (#51) 2024-08-01 07:41:25 +07:00
Dream Master 568e405e25 update 2024-07-08 12:17:56 +07:00
DrParadox7 e851556159 Fix Glotek and Neonite being only obtainable with allowChiselCrossColors (#49)
Remove Glotek and Neonite from being affected by:
```
# Should someone be able to chisel something into a different color.
    B:allowChiselCrossColors=false
```
They do not have recipes for each color variation, making them unobtainable should `allowChiselCrossColors` be false.
2024-07-08 12:12:57 +07:00
DrParadox7 b610b590a2 Fix Transparent Technical Blocks requiring Silk Touch (#50)
No other of the 30 Technical Block Chisel block set have this requirement.
2024-07-08 08:38:23 +07:00
Martin Robertz 6788f10a3e update 2024-05-13 20:22:48 +02:00
GirixK 691d3a2962 spotlessApply 2024-05-13 20:21:05 +02:00
GirixK a99686e3a8 Change former assets to comply with minecraft's EULA
- Removed assets for variations 0-8
- Replaced 0-8 with different themed assets
- Added variation 9
2024-05-13 20:21:05 +02:00
GirixK 6064b7bc3d Fix typo in en_US 2024-05-13 20:21:05 +02:00
GirixK 3b8a85a20d Backport Froglights
Backported 3 froglights and added 6 more

Pearlescent, Ochre, Veridium, and the 6 custom ones meant to look like Osmium, Tungstensteel, Iron, Titanium, Aluminium, and Grisium
2024-05-13 20:21:05 +02:00
Jason Mitchell 772987a4f2 Fixes an NPE thrown with NEI 2024-02-20 09:28:57 -08:00
Jason Mitchell 33f240c73a Null saftey (#45) 2024-02-20 18:18:12 +01:00
Jason Mitchell 06ec360694 Angelica Thread Safety 2024-02-20 08:25:02 -08:00
Jason Mitchell e9e63d6fc5 Merge CTMLib 2024-02-20 08:25:02 -08:00
Jason Mitchell 83cd16061f Update BS & remove gradletoken_version 2024-02-20 08:25:02 -08:00
Raven Szewczyk 13ecd240fe [ci skip] upgraded build system 2024-02-04 19:57:32 +00:00
bombcar 64b5b41f02 [bs] update buildscript 2024-01-11 22:22:29 +01:00
bombcar 15a0f7f6c6 update for CCC/L 1.2.0 2024-01-11 22:22:29 +01:00
bombcar 66fb9ddbb3 udpate dependencies 2024-01-11 22:22:29 +01:00
Raven Szewczyk 0fff3926fe [ci skip] upgraded build system 2024-01-08 21:24:38 +00:00
Martin Robertz 2e62cb2a32 update deps 2024-01-02 11:29:29 +01:00
chochem 2db573f5c3 also fix mining level for obsidian snakestone 2024-01-02 01:32:50 +01:00
chochem ff494012ed update dep 2024-01-01 21:45:12 +01:00
chochem d5dbfe5f6d fix mining levels with iguana 2024-01-01 21:45:12 +01:00
Martin Robertz a2b32f4d73 update bs+deps 2024-01-01 20:13:10 +01:00
Caedis 2a93fbd33d spotless 2024-01-01 19:28:34 +01:00
Caedis 52496b770a add vanilla mining levels 2024-01-01 19:28:34 +01:00
Martin Robertz c964972006 backdate deps 2023-12-28 19:12:30 +01:00
Martin Robertz cd20d23b1b update gradle + deps + bs 2023-12-28 18:42:39 +01:00
makamys 631c562f34 Make Forge Multipart dependency optional
Fixes regression in 2150548
2023-12-28 08:59:15 -08:00
makamys 3e6930d1f1 Don't relocate CTMLib
Fixes Techguns compat
2023-12-28 08:58:54 -08:00
Martin Robertz 82955ad34d update waila dep 2023-11-16 13:57:16 +01:00
Pelotrio d726351abc Add method to clear static textures on world unload 2023-11-16 13:52:58 +01:00
Pelotrio ea103bcc80 Remove static keyword from render block variables
The static keyword was removed from several instances of RenderBlocksCTM and RenderBlocksCTMFullbright variables in various SubmapManager classes and ChiselController class. This was done to fix a potential memory leak issue where these static objects could persist in memory even when they're no longer needed. Also, related to this change, the onWorldUnload method that used to clear static reference of RenderBlocksCTMFullbright has been removed from ChiselController.
2023-11-16 13:52:58 +01:00
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
glowredman e8d9d77299 Shade CTMLib 2022-06-11 16:08:12 +02:00
Martin Robertz 91a5d63a24 Merge pull request #20 from GTNewHorizons/chisel-name-fix
Name "Nether Star Chisel" only "Bedrockium Chisel" if in GTNH
2022-06-09 17:00:24 +02:00
glowredman ddd7f5ec2e Move GTNH check before Features#preInit 2022-06-09 11:41:03 +02:00
glowredman 423f72ab21 name "Nether Star Chisel" only "Bedrockium Chisel" if in GTNH 2022-06-07 22:52:12 +02:00
Martin Robertz 3c0729591f Merge pull request #19 from GTNewHorizons/fixrelease
fix release
2022-02-27 22:51:55 +01:00
bombcar b809eb9d0b fix release 2022-02-27 15:44:43 -06:00
Martin Robertz 9db6baf768 Update build.gradle 2022-02-27 22:37:24 +01:00
Martin Robertz 52915ac97f Merge pull request #18 from Kiwi233/1.7/release
Update zh_CN.lang
2022-02-06 19:29:26 +01:00
[Kiwi233] 00cf0d5229 Update zh_CN.lang 2022-02-06 22:18:36 +08:00
Martin Robertz 1ce8c85dce Merge pull request #17 from MrAkells/master
fix small lang typo
2022-01-24 07:08:28 +01:00
MrAkells e903c37913 fix small lang typo
It was the Cyrillic letter "C". I noticed due to the fact that in 1.7.10 the Cyrillic alphabet is displayed small. Altogether a miracle.
2022-01-24 01:29:57 +02:00
Martin Robertz 1a9e366204 Merge pull request #16 from GTNewHorizons/fixrunclient
fix runclient for now
2022-01-22 23:34:51 +01:00
bombcar 0dfa701ae3 fix runclient for now 2022-01-22 11:25:52 -06:00
Jason Mitchell 802295bb6a update to explicit dependencies 2022-01-17 23:34:45 -08:00
Jason Mitchell 5d6b5c945d maven publish buildscript update 2022-01-17 23:33:27 -08:00
Martin Robertz 764885d239 Merge pull request #15 from Eldrinn-Elantey/master
Update en_US.lang, ru_RU.lang
2022-01-10 14:51:28 +01:00
Eldrinn_Elantey baf3c712bd Update ru_RU.lang
tile.beacon.lightblue.desc=Маяк со голубым лучом
2022-01-10 17:07:42 +04:00
Eldrinn_Elantey bd2fe1d272 Update ru_RU.lang
Synchronization of the file structure with English, fine translation, elimination of incorrectly displayed characters
2022-01-09 05:46:27 +04:00
Eldrinn_Elantey f2447d415b Update en_US.lang
Adjustment of the name of the tool, taking into account the recipe for its manufacture
2022-01-09 05:45:01 +04:00
383 changed files with 17363 additions and 15194 deletions

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
# This is the universal Text Editor Configuration
# for all GTNewHorizons projects
# See: https://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.{bat,ini}]
end_of_line = crlf
[*.{dtd,json,info,mcmeta,md,sh,svg,xml,xsd,xsl,yaml,yml}]
indent_size = 2
+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
-9
View File
@@ -1,9 +0,0 @@
directory="run/crash-reports"
if [ -d $directory ]; then
echo "Crash reports detected:"
cat $directory/*
exit 1
else
echo "No crash reports detected"
exit 0
fi
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
# bashsupport disable=BP5006 # Global environment variables
RUNDIR="run" \
CRASH="crash-reports" \
SERVERLOG="server.log"
# enable nullglob to get 0 results when no match rather than the pattern
shopt -s nullglob
# store matches in array
crash_reports=("$RUNDIR/$CRASH/crash"*.txt)
# if array not empty there are crash_reports
if [ "${#crash_reports[@]}" -gt 0 ]; then
# get the latest crash_report from array
latest_crash_report="${crash_reports[-1]}"
{
printf 'Latest crash report detected %s:\n' "${latest_crash_report##*/}"
cat "$latest_crash_report"
} >&2
exit 1
fi
if grep --quiet --fixed-strings 'Fatal errors were detected' "$SERVERLOG"; then
{
printf 'Fatal errors detected:\n'
cat server.log
} >&2
exit 1
fi
if grep --quiet --fixed-strings 'The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED' \
"$SERVERLOG"; then
{
printf 'Server force stopped:'
cat server.log
} >&2
exit 1
fi
if ! grep --quiet --perl-regexp --only-matching '.+Done \(.+\)\! For help, type "help" or "\?"' "$SERVERLOG"; then
{
printf 'Server did not finish startup:'
cat server.log
} >&2
exit 1
fi
printf 'No crash reports detected'
exit 0
+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
@@ -11,35 +9,5 @@ on:
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- 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 minute
run: |
mkdir run
echo "eula=true" > run/eula.txt
timeout 60 ./gradlew runServer || true
- name: Test no crashes happend
run: |
chmod +x .github/scripts/test-no-crash-reports.sh
.github/scripts/test-no-crash-reports.sh
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
secrets: inherit
+7 -38
View File
@@ -1,45 +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
on:
push:
tags:
- '*'
tags: [ '*' ]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- 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
release-tags:
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
secrets: inherit
+3
View File
@@ -0,0 +1,3 @@
# Any Github changes require admin approval
/.github/** @GTNewHorizons/admin
+2 -3
View File
@@ -15,7 +15,7 @@ To set up the mod as to allow you to make changes, do the following:
### IntelliJ IDEA
1. Run `gradlew idea`.
2. Open IntelliJ and point to either the project folder or the build.gradle file.
2. Open IntelliJ and point to either the project folder or the `build.gradle` file.
3. After opening the project in IntelliJ, run `gradlew genIntellijRuns` in the command terminal you opened earlier.
### Eclipse
@@ -24,9 +24,8 @@ To set up the mod as to allow you to make changes, do the following:
2. Open Eclipse and import the folder as a project.
You now have a functional local copy of Chisel, ready to develop on.
___
Formatting
----------
When coding for Chisel 2, please use the provided [formatter settings](eclipseFormat.xml) to format your code. Poorly formatted code, or PRs which reformat existing code will likely not be accepted.
When coding for the GTNH branch, please run `gradlew spotlessApply` before posting a PR.
+5 -8
View File
@@ -1,6 +1,6 @@
Chisel
=======
Chisel is a mod for Minecraft which adds aesthetic blocks to the game through the use of a chisel.
Chisel is a mod for Minecraft which adds aesthetic blocks to the game through the use of a chisel.
Originally created by AUTOMATIC_MAIDEN, it was ported to Minecraft 1.7.2 by asie, and maintained by Pokefenn/Cricket during 1.7.10.
@@ -12,9 +12,7 @@ It was previously maintained by [tterrag](http://github.com/tterrag1098), [Drull
Pull Requests
---------------
Pull requests with new features, translations, and bugfixes are very welcome. Please make sure to always submit PRs against the ***dev*** branch, not master.
Do not make PRs that are solely formatting or other aesthetic things.
Pull requests with new features, translations, and bugfixes are very welcome.
If your PR is going to take a lot of work, it may be best to make an issue so we can discuss the feature before you create it.
@@ -22,10 +20,9 @@ See the [CONTRIBUTING](CONTRIBUTING.md) file for more details.
Issue Reporting
----------------
If you wish to report an issue with the mod, please submit one to the issue tracker in this repository. When creating an
If you wish to report an issue with this version of the mod, please submit one to the [GTNH issue tracker](https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues). When creating an
issue, please be sure to include:
- The version of Chisel you are using ("latest" is not an acceptable version)
- The version of Forge you are using
- If applicable, the crash report (preferably via [Pastebin](http://pastebin.com/)). generated by the error
- The version of Chisel or GTNH you are using ("latest" is not an acceptable version)
- The crash report (preferably via [Pastebin](http://pastebin.com/)) generated by the error, if any
- Depending on the error, an image of the problem
-4
View File
@@ -1,4 +0,0 @@
compileJava {
options.encoding = "UTF-8"
}
+2 -526
View File
@@ -1,529 +1,5 @@
//version: 928ecf7feb33a1149538b0e2cd17e3bc5f281428
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Please check https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle for updates.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.util.concurrent.TimeUnit
buildscript {
repositories {
maven {
name = "forge"
url = "https://maven.minecraftforge.net"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
name = "Scala CI dependencies"
url = "https://repo1.maven.org/maven2/"
}
maven {
name = "jitpack"
url = "https://jitpack.io"
}
}
dependencies {
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4'
}
}
//version: 1707058017
plugins {
id 'idea'
id 'scala'
id("org.ajoberstar.grgit") version("3.1.1")
id("com.github.johnrengelman.shadow") version("4.0.4")
id("com.palantir.git-version") version("0.12.3")
}
apply plugin: 'forge'
def projectJavaVersion = JavaLanguageVersion.of(8)
java {
toolchain {
languageVersion.set(projectJavaVersion)
}
}
idea {
module {
inheritOutputDirs = true
downloadJavadoc = true
downloadSources = true
}
}
if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
}
checkPropertyExists("modName")
checkPropertyExists("modId")
checkPropertyExists("modGroup")
checkPropertyExists("autoUpdateBuildScript")
checkPropertyExists("minecraftVersion")
checkPropertyExists("forgeVersion")
checkPropertyExists("replaceGradleTokenInFile")
checkPropertyExists("gradleTokenModId")
checkPropertyExists("gradleTokenModName")
checkPropertyExists("gradleTokenVersion")
checkPropertyExists("gradleTokenGroupName")
checkPropertyExists("apiPackage")
checkPropertyExists("accessTransformersFile")
checkPropertyExists("usesMixins")
checkPropertyExists("mixinPlugin")
checkPropertyExists("mixinsPackage")
checkPropertyExists("coreModClass")
checkPropertyExists("containsMixinsAndOrCoreModOnly")
checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) {
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
}
if(apiPackage) {
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) {
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
}
}
if(accessTransformersFile) {
String targetFile = "src/main/resources/META-INF/" + accessTransformersFile
if(getFile(targetFile).exists() == false) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
}
}
if(usesMixins.toBoolean()) {
if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!")
}
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) {
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
}
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
if((getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists()) == false) {
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava)
}
}
if(coreModClass) {
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
if((getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists()) == false) {
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava)
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
// Make sure GregTech build won't time out
System.setProperty("org.gradle.internal.http.connectionTimeout", 120000 as String)
System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String)
}
// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version
'git config core.fileMode false'.execute()
// Pulls version from git tag
try {
version = minecraftVersion + "-" + gitVersion()
}
catch (Exception e) {
throw new IllegalStateException("This mod must be version controlled by Git AND the repository must provide at least one tag!");
}
group = modGroup
if(project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
archivesBaseName = customArchiveBaseName
}
else {
archivesBaseName = modId
}
minecraft {
version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion
runDir = "run"
if (replaceGradleTokenInFile) {
replaceIn replaceGradleTokenInFile
if(gradleTokenModId) {
replace gradleTokenModId, modId
}
if(gradleTokenModName) {
replace gradleTokenModName, modName
}
if(gradleTokenVersion) {
replace gradleTokenVersion, versionDetails().lastTag
}
if(gradleTokenGroupName) {
replace gradleTokenGroupName, modGroup
}
}
}
if(file("addon.gradle").exists()) {
apply from: "addon.gradle"
}
apply from: 'repositories.gradle'
configurations {
implementation.extendsFrom(shadowImplementation)
}
repositories {
maven {
name = "Overmind forge repo mirror"
url = "https://gregtech.overminddl1.com/"
}
if(usesMixins.toBoolean()) {
maven {
name = "sponge"
url = "https://repo.spongepowered.org/repository/maven-public"
}
maven {
url = "https://jitpack.io"
}
}
}
dependencies {
if(usesMixins.toBoolean()) {
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
annotationProcessor("com.google.guava:guava:24.1.1-jre")
annotationProcessor("com.google.code.gson:gson:2.8.6")
annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT")
// using 0.8 to workaround a issue in 0.7 which fails mixin application
compile("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: "launchwrapper"
exclude module: "guava"
exclude module: "gson"
exclude module: "commons-io"
exclude module: "log4j-core"
}
compile("com.github.GTNewHorizons:SpongeMixins:1.3.3:dev")
}
}
apply from: 'dependencies.gradle'
def mixingConfigRefMap = "mixins." + modId + ".refmap.json"
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
task generateAssets {
if(usesMixins.toBoolean()) {
getFile("/src/main/resources/mixins." + modId + ".json").text = """{
"required": true,
"minVersion": "0.7.11",
"package": "${modGroup}.${mixinsPackage}",
"plugin": "${modGroup}.${mixinPlugin}",
"refmap": "${mixingConfigRefMap}",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"
}
"""
}
}
task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = modGroup + ".shadow"
}
shadowJar {
manifest {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation]
dependsOn(relocateShadowJar)
}
jar {
manifest {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
dependsOn(shadowJar)
enabled = false
}
}
reobf {
if(usesMixins.toBoolean()) {
addExtraSrgFile mixinSrg
}
}
afterEvaluate {
if(usesMixins.toBoolean()) {
tasks.compileJava {
options.compilerArgs += [
"-AreobfSrgFile=${tasks.reobf.srg}",
"-AoutSrgFile=${mixinSrg}",
"-AoutRefMapFile=${refMap}",
// Elan: from what I understand they are just some linter configs so you get some warning on how to properly code
"-XDenableSunApiLintControl",
"-XDignore.symbol.file"
]
}
}
}
runClient {
def arguments = []
if(usesMixins.toBoolean()) {
arguments += [
"--mods=../build/libs/$modId-${version}.jar",
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
}
if(developmentEnvironmentUserName) {
arguments += [
"--username",
developmentEnvironmentUserName
]
}
args(arguments)
}
runServer {
def arguments = []
if (usesMixins.toBoolean()) {
arguments += [
"--mods=../build/libs/$modId-${version}.jar",
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
}
args(arguments)
}
tasks.withType(JavaExec).configureEach {
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion = projectJavaVersion
}
)
}
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand "minecraftVersion": project.minecraft.version,
"modVersion": versionDetails().lastTag,
"modId": modId,
"modName": modName
}
if(usesMixins.toBoolean()) {
from refMap
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
def getManifestAttributes() {
def manifestAttributes = [:]
if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) {
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
}
if(accessTransformersFile) {
manifestAttributes += ["FMLAT" : accessTransformersFile.toString()]
}
if(coreModClass) {
manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass]
}
if(usesMixins.toBoolean()) {
manifestAttributes += [
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
"MixinConfigs" : "mixins." + modId + ".json",
"ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
]
}
return manifestAttributes
}
task sourcesJar(type: Jar) {
from (sourceSets.main.allJava)
from (file("$projectDir/LICENSE"))
getArchiveClassifier().set('sources')
}
task shadowDevJar(type: ShadowJar) {
from sourceSets.main.output
getArchiveClassifier().set("dev")
manifest {
attributes(getManifestAttributes())
}
minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation]
}
task relocateShadowDevJar(type: ConfigureShadowRelocation) {
target = tasks.shadowDevJar
prefix = modGroup + ".shadow"
}
task circularResolverJar(type: Jar) {
dependsOn(relocateShadowDevJar)
dependsOn(shadowDevJar)
enabled = false
}
task devJar(type: Jar) {
from sourceSets.main.output
getArchiveClassifier().set("dev")
manifest {
attributes(getManifestAttributes())
}
if(usesShadowedDependencies.toBoolean()) {
dependsOn(circularResolverJar)
enabled = false
}
}
task apiJar(type: Jar) {
from (sourceSets.main.allJava) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
from (sourceSets.main.output) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
from (sourceSets.main.resources.srcDirs) {
include("LICENSE")
}
getArchiveClassifier().set('api')
}
artifacts {
archives sourcesJar
archives devJar
if(apiPackage) {
archives apiJar
}
}
// Updating
task updateBuildScript {
doLast {
if (performBuildScriptUpdate(projectDir.toString())) return
print("Build script already up-to-date!")
}
}
if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (autoUpdateBuildScript.toBoolean()) {
performBuildScriptUpdate(projectDir.toString())
} else {
println("Build script update available! Run 'gradle updateBuildScript'")
}
}
static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/SinTh0r4s/ExampleMod1.7.10/main/build.gradle")
}
boolean performBuildScriptUpdate(String projectDir) {
if (isNewBuildScriptVersionAvailable(projectDir)) {
def buildscriptFile = getFile("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
return true
}
return false
}
boolean isNewBuildScriptVersionAvailable(String projectDir) {
Map parameters = ["connectTimeout": 2000, "readTimeout": 2000]
String currentBuildScript = getFile("build.gradle").getText()
String currentBuildScriptHash = getVersionHash(currentBuildScript)
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
String availableBuildScriptHash = getVersionHash(availableBuildScript)
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
return !isUpToDate
}
static String getVersionHash(String buildScriptContent) {
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
if(versionLine != null) {
return versionLine.split(": ").last()
}
return ""
}
configure(updateBuildScript) {
group = 'forgegradle'
description = 'Updates the build script to the latest version'
}
// Helper methods
def checkPropertyExists(String propertyName) {
if (project.hasProperty(propertyName) == false) {
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/gradle.properties")
}
}
def getFile(String relativePath) {
return new File(projectDir, relativePath)
id 'com.gtnewhorizons.gtnhconvention'
}
+12 -6
View File
@@ -1,18 +1,24 @@
// Add your dependencies here
dependencies {
compile("com.github.GTNewHorizons:NotEnoughItems:master-SNAPSHOT:dev")
implementation("com.github.GTNewHorizons:CodeChickenCore:1.3.6:dev")
implementation("com.github.GTNewHorizons:CodeChickenLib:1.3.0:dev")
implementation("com.github.GTNewHorizons:NotEnoughItems:2.6.19-GTNH:dev")
implementation("com.github.GTNewHorizons:ForgeMultipart:1.5.0:dev")
compile("org.projectlombok:lombok:1.16.4")
compileOnly("org.projectlombok:lombok:1.18.24")
annotationProcessor("org.projectlombok:lombok:1.18.24")
compileOnly("com.github.GTNewHorizons:waila:master-SNAPSHOT:dev") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:ForgeMultipart:master-SNAPSHOT:dev") {
devOnlyNonPublishable("com.github.GTNewHorizons:waila:1.8.1:dev") {
transitive = false
}
devOnlyNonPublishable("com.github.GTNewHorizons:WailaHarvestability:1.2.1-GTNH:dev")
compileOnly("curse.maven:ee3-65509:2305023") { // https://www.curseforge.com/minecraft/mc-mods/ee3/files/2305023
transitive = false
}
compileOnly("com.github.GTNewHorizons:Angelica:1.0.0-beta2:api") {
transitive = false
}
}
+166 -27
View File
@@ -1,64 +1,203 @@
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
# LOCAL to test local config updates.
gtnh.settings.blowdryerTag = 0.2.2
# Human-readable mod name, available for mcmod.info population.
modName = Chisel
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
# Conventionally lowercase.
modId = chisel
# Root package of the mod, used to find various classes in other properties,
# mcmod.info substitution, enabling assertions in run tasks, etc.
modGroup = com.cricketcraft.chisel
# WHY is there no version field?
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
# Whether to use modGroup as the maven publishing group.
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
useModGroupForPublishing = false
# Will update your build.gradle automatically whenever an update is available
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
autoUpdateBuildScript = false
# Version of Minecraft to target
minecraftVersion = 1.7.10
# Version of Minecraft Forge to target
forgeVersion = 10.13.4.1614
# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
channel = stable
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
mappingsVersion = 12
# Defines other MCP mappings for dependency deobfuscation.
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
# Select a default username for testing your mod. You can always override this per-run by running
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
developmentEnvironmentUserName = "Developer"
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = Chisel.java
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = false
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
generateGradleTokenClass = team.chisel.Tags
# Name of the token containing the project's current version to generate/replace.
gradleTokenVersion = VERSION
# [DEPRECATED] Mod ID replacement token.
gradleTokenModId =
# [DEPRECATED] Mod name replacement token.
gradleTokenModName =
gradleTokenVersion = GRADLETOKEN_VERSION
# [DEPRECATED] Mod Group replacement token.
gradleTokenGroupName =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can
# [DEPRECATED]
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
# public static final String VERSION = "GRADLETOKEN_VERSION";
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
# version in @Mod([...], version = VERSION, [...]).
# Leave these properties empty to skip individual token replacements.
replaceGradleTokenInFile =
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
apiPackage = api
# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
# There can be multiple files in a space-separated list.
# Example value: mymodid_at.cfg nei_at.cfg
accessTransformersFile = chisel_compile_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =
# Adds some debug arguments like verbose output and class export.
usesMixinDebug = false
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin =
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatability only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
# This parameter is for legacy compatibility only
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
coreModClass =
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
containsMixinsAndOrCoreModOnly = false
# 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.
usesShadowedDependencies = false
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = false
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
# responsibility to check the license and request permission for distribution if required.
usesShadowedDependencies = true
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
# their own classes, making the minimization unreliable.
minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = false
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
usesMavenPublishing = true
# Maven repository to publish the mod to.
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
#
# The project's ID on Modrinth. Can be either the slug or the ID.
# Leave this empty if you don't want to publish to Modrinth.
modrinthProjectId =
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
# Syntax: scope1-type1:name1;scope2-type2:name2;...
# Where scope can be one of [required, optional, incompatible, embedded],
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
#
# The project's numeric ID on CurseForge. You can find this in the About Project box.
# Leave this empty if you don't want to publish on CurseForge.
curseForgeProjectId =
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
# Syntax: type1:name1;type2:name2;...
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
# and the name is the CurseForge project slug of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
curseForgeRelations =
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
# projects. New projects should not use this parameter.
#customArchiveBaseName =
# customArchiveBaseName =
# Optional parameter to have the build automatically fail if an illegal version is used.
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
# The check is ONLY performed if the version is a git tag.
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
# versionPattern =
# Uncomment to prevent the source code from being published.
# noPublishedSources = true
# Uncomment this to disable Spotless checks.
# This should only be uncommented to keep it easier to sync with upstream/other forks.
# That is, if there is no other active fork/upstream, NEVER change this.
# disableSpotless = true
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
# disableCheckstyle = true
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
# (force use delegated build).
# This is meant to be set in $HOME/.gradle/gradle.properties.
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
# ideaOverrideBuildType = idea
# Whether IDEA should run spotless checks when pressing the Build button.
# This is meant to be set in $HOME/.gradle/gradle.properties.
# ideaCheckSpotlessOnBuild = true
Binary file not shown.
+3 -1
View File
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+181 -117
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");
# you may not use this file except in compliance with the License.
@@ -15,80 +15,116 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
##
## 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/platforms/jvm/plugins-application/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
# 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
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
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
MAX_FD=maximum
warn () {
echo "$*"
}
} >&2
die () {
echo
echo "$*"
echo
exit 1
}
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -97,92 +133,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
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.
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
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
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# 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" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --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
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
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
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
JAVACMD=$( cygpath --unix "$JAVACMD" )
# 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
# 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"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
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" "$@"
Vendored
+27 -33
View File
@@ -13,8 +13,10 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,10 +27,14 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@@ -37,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@@ -51,48 +57,36 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
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
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@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
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
-6
View File
@@ -1,10 +1,4 @@
// Add any additional repositories for your dependencies here
repositories {
maven {
url "https://cursemaven.com"
}
maven {
url = "https://jitpack.io"
}
}
+23
View File
@@ -0,0 +1,23 @@
pluginManagement {
repositories {
maven {
// RetroFuturaGradle
name "GTNH Maven"
url "https://nexus.gtnewhorizons.com/repository/public/"
mavenContent {
includeGroup("com.gtnewhorizons")
includeGroupByRegex("com\\.gtnewhorizons\\..+")
}
}
gradlePluginPortal()
mavenCentral()
mavenLocal()
}
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.25'
}
@@ -2,6 +2,6 @@ package com.cricketcraft.chisel.api;
public class ChiselAPIProps {
public static final String VERSION = "0.1.1";
public static String MOD_ID = null; // Set by Chisel
public static final String VERSION = "0.1.1";
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.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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) {
super(label);
this.search = searchbar;
}
public CustomCreativeTab(String label, boolean searchbar) {
super(label);
this.search = searchbar;
}
@Override
public Item getTabIconItem() {
return stack.getItem();
}
@Override
public Item getTabIconItem() {
return stack.getItem();
}
public void setTabIconItemStack(ItemStack stack) {
this.stack = stack;
}
public void setTabIconItemStack(ItemStack stack) {
this.stack = stack;
}
@Override
public ItemStack getIconItemStack() {
return stack;
}
@Override
public ItemStack getIconItemStack() {
return stack;
}
@Override
@SideOnly(Side.CLIENT)
public String getBackgroundImageName() {
@Override
@SideOnly(Side.CLIENT)
public String getBackgroundImageName() {
return search ? "item_search.png" : super.getBackgroundImageName();
}
return search ? "item_search.png" : super.getBackgroundImageName();
}
@Override
public int getSearchbarWidth() {
@Override
public int getSearchbarWidth() {
return 89;
}
return 89;
}
@Override
public boolean hasSearchBar() {
@Override
public boolean hasSearchBar() {
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);
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);
}
@@ -2,21 +2,22 @@ package com.cricketcraft.chisel.api;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.event.FMLInterModComms;
public class FMPIMC {
public static void registerFMP(Block block) {
registerFMP(block, 0, 15);
}
public static void registerFMP(Block block) {
registerFMP(block, 0, 15);
}
public static void registerFMP(Block block, int minMeta, int maxMeta) {
for (int c = minMeta; c <= maxMeta; c++) {
registerFMP(block, c);
}
}
public static void registerFMP(Block block, int minMeta, int maxMeta) {
for (int c = minMeta; c <= maxMeta; c++) {
registerFMP(block, c);
}
}
public static void registerFMP(Block block, int meta) {
FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(block, 1, meta));
}
public static void registerFMP(Block block, int meta) {
FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(block, 1, meta));
}
}
@@ -9,25 +9,21 @@ import com.cricketcraft.chisel.api.carving.IChiselMode;
*/
public interface IAdvancedChisel {
/**
* Gets the next mode the button in the GUI should switch to given the current mode.
*
* @param stack
* The {@link ItemStack} representing the chisel
* @param current
* The {@link IChiselMode} that is currently active
* @return The next {@link IChiselMode} in the loop
*/
public IChiselMode getNextMode(ItemStack stack, IChiselMode current);
/**
* Gets the next mode the button in the GUI should switch to given the current mode.
*
* @param stack The {@link ItemStack} representing the chisel
* @param current The {@link IChiselMode} that is currently active
* @return The next {@link IChiselMode} in the loop
*/
public IChiselMode getNextMode(ItemStack stack, IChiselMode current);
/**
* Gets an {@link IChiselMode} instance from a String name
*
* @param chisel
* The {@link ItemStack} representing the chisel
* @param 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);
/**
* Gets an {@link IChiselMode} instance from a String name
*
* @param chisel The {@link ItemStack} representing the chisel
* @param 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);
}
@@ -1,44 +1,42 @@
package com.cricketcraft.chisel.api;
import team.chisel.ctmlib.ICTMBlock;
import team.chisel.ctmlib.ISubmapManager;
import net.minecraft.world.IBlockAccess;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
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> {
/**
* Gets a {@link ISubmapManager} from this block, based on metadata.
* <p>
* 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 world
* {@link IBlockAccess} object, usually a world. Use of {@link IBlockAccess} Is necessary due to this method's use in rendering.
* @param x
* X coord of the block
* @param y
* Y coord of the block
* @param z
* Z coord of the block
* @param metadata
* The metadata of the block
* @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 a {@link ISubmapManager} from this block, based on metadata.
* <p>
* 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 world {@link IBlockAccess} object, usually a world. Use of {@link IBlockAccess} Is necessary due to
* this method's use in rendering.
* @param x X coord of the block
* @param y Y coord of the block
* @param z Z coord of the block
* @param metadata The metadata of the block
* @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.
*
* @return A {@link ISubmapManager}
*/
@Override
public IVariationInfo getManager(int meta);
/**
* Gets the {@link ISubmapManager} for this block when it is in item form.
*
* @return A {@link ISubmapManager}
*/
@Override
public IVariationInfo getManager(int meta);
}
@@ -12,74 +12,60 @@ import com.cricketcraft.chisel.api.carving.ICarvingVariation;
*/
public interface IChiselItem {
/**
* Checks whether the chisel can have its GUI opened
*
* @param world
* {@link World} object
* @param player
* 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
* @return True if the GUI should open. False otherwise.
*/
boolean canOpenGui(World world, EntityPlayer player, ItemStack chisel);
/**
* Checks whether the chisel can have its GUI opened
*
* @param world {@link World} object
* @param player 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
* @return True if the GUI should open. False otherwise.
*/
boolean canOpenGui(World world, EntityPlayer player, ItemStack chisel);
/**
* Called when an item is chiseled using this chisel
*
* @param world
* {@link World} object
* @param chisel
* The {@link ItemStack} representing the chisel
* @param target
* The {@link ICarvingVariation} representing the target item
* @return True if the chisel should be damaged. False otherwise.
*/
boolean onChisel(World world, ItemStack chisel, ICarvingVariation target);
/**
* Called when an item is chiseled using this chisel
*
* @param world {@link World} object
* @param chisel The {@link ItemStack} representing the chisel
* @param target The {@link ICarvingVariation} representing the target item
* @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.
* <p>
* 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.
*
* @param world
* {@link World} object
* @param chisel
* The {@link ItemStack} representing the chisel
* @param target
* The {@link ICarvingVariation} representing the target item
* @return True if the current target can be chiseled into anything. False otherwise.
*/
boolean canChisel(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.
* <p>
* 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.
*
* @param world {@link World} object
* @param chisel The {@link ItemStack} representing the chisel
* @param target The {@link ICarvingVariation} representing the target item
* @return True if the current target can be chiseled into anything. False otherwise.
*/
boolean canChisel(World world, ItemStack chisel, ICarvingVariation target);
/**
* Allows you to control if your item can chisel this block in the world.
*
* @param world
* World object
* @param player
* {@link EntityPlayer The player} holding the chisel.
* @param x
* X coord of the block being chiseled
* @param y
* Y coord of the block being chiseled
* @param z
* Z coord of the block being chiseled
* @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 can chisel this block in the world.
*
* @param world World object
* @param player {@link EntityPlayer The player} holding the chisel.
* @param x X coord of the block being chiseled
* @param y Y coord of the block being chiseled
* @param z Z coord of the block being chiseled
* @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.
*
* @param chisel
* The {@link ItemStack} representing the chisel.
* @return True if the chisel supports modes. False otherwise.
*/
boolean hasModes(ItemStack chisel);
/**
* Allows you to control if your item has chiseling modes.
*
* @param chisel The {@link ItemStack} representing the chisel.
* @return True if the chisel supports modes. False otherwise.
*/
boolean hasModes(ItemStack chisel);
}
@@ -7,20 +7,16 @@ import net.minecraft.world.IBlockAccess;
*/
public interface IConnectable {
/**
* Determines whether other CTM blocks can connect to this one.
*
* @param world
* @param x
* 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 z
* The Z position of the block that is connecting to this one. NOT the position of your block.
* @param 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);
/**
* Determines whether other CTM blocks can connect to this one.
*
* @param world
* @param x 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 z The Z position of the block that is connecting to this one. NOT the position of your block.
* @param 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 {
/**
* Gets the block this facade is acting as.
*
* @param world
* {@link World}
* @param x
* X coord of your block
* @param y
* Y coord of your block
* @param z
* Z coord of your block
* @param side
* The side being rendered, NOT the side being connected from.
* <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 block this facade is acting as.
*
* @param world {@link World}
* @param x X coord of your block
* @param y Y coord of your block
* @param z Z coord of your block
* @param side The side being rendered, NOT the side being connected from.
* <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.
*
* @param world
* {@link World}
* @param x
* X coord of your block
* @param y
* Y coord of your block
* @param z
* Z coord of your block
* @param side
* The side being rendered, NOT the side being connected from.
* <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);
}
/**
* Gets the metadata of the block that this facade is acting as.
*
* @param world {@link World}
* @param x X coord of your block
* @param y Y coord of your block
* @param z Z coord of your block
* @param side The side being rendered, NOT the side being connected from.
* <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;
/**
* 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>
* It is also acceptable to copy the Strings in this class to avoid referencing this API.
*/
public enum IMC {
/**
* Adds a variation to a group.
*
* Use this to add a variation to a group. String syntax:
* <p>
* groupname|blockname|meta
* <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.
*/
ADD_VARIATION("variation:add"),
/**
* Adds a variation to a group.
*
* Use this to add a variation to a group. String syntax:
* <p>
* groupname|blockname|meta
* <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.
*/
ADD_VARIATION("variation:add"),
/**
* Removes a variation from a group.
*
* Use this to remove a variation from a group. String syntax:
* <p>
* groupname|blockname|meta
* <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.
*/
REMOVE_VARIATION("variation:remove"),
/**
* Removes a variation from a group.
*
* Use this to remove a variation from a group. String syntax:
* <p>
* groupname|blockname|meta
* <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.
*/
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:
* <p>
* groupname|oredictname
* <p>
* An example would be {@code "mygroup|plankWood"} which will add all blocks registered in the oredict as "plankWood" to your group called "mygroup".
*/
REGISTER_GROUP_ORE("group:ore");
/**
* 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:
* <p>
* groupname|oredictname
* <p>
* An example would be {@code "mygroup|plankWood"} which will add all blocks registered in the oredict as
* "plankWood" to your group called "mygroup".
*/
REGISTER_GROUP_ORE("group:ore");
/**
* The IMC message key for this message type.
*/
public final String key;
/**
* The IMC message key for this message type.
*/
public final String key;
IMC(String key) {
this.key = key;
}
IMC(String key) {
this.key = key;
}
@Override
public String toString() {
return key;
}
@Override
public String toString() {
return key;
}
/**
* The modid of Chisel so you can easily send IMC to this mod.
*/
@Deprecated
public static final String CHISEL_MODID = "chisel";
/**
* The modid of Chisel so you can easily send IMC to this mod.
*/
@Deprecated
public static final String CHISEL_MODID = "chisel";
public static final String getModid() {
return ChiselAPIProps.MOD_ID;
}
public static final String getModid() {
return ChiselAPIProps.MOD_ID;
}
}
@@ -6,10 +6,12 @@ import net.minecraft.util.ChatComponentTranslation;
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() {
blocksChiseled.initIndependentStat();
blocksChiseled.registerStat();
}
public static void init() {
blocksChiseled.initIndependentStat();
blocksChiseled.registerStat();
}
}
@@ -14,210 +14,229 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.oredict.OreDictionary;
import team.chisel.ctmlib.ISubmapManager;
import com.cricketcraft.chisel.api.ChiselAPIProps;
import com.cricketcraft.chisel.api.FMPIMC;
import com.cricketcraft.chisel.api.rendering.TextureType;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.block.BlockCarvableGlowie;
import team.chisel.compat.fmp.FMPCompat;
import team.chisel.ctmlib.ISubmapManager;
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>();
IVariationInfo[] infoMap = new IVariationInfo[16];
public boolean forbidChiseling = false;
public ArrayList<IVariationInfo> infoList = new ArrayList<IVariationInfo>();
IVariationInfo[] infoMap = new IVariationInfo[16];
public boolean forbidChiseling = false;
public CarvableHelper(Block block) {
this.theBlock = block;
}
public CarvableHelper(Block block) {
this.theBlock = block;
}
public void addVariation(String description, int metadata, ISubmapManager manager) {
addVariation(description, metadata, null, manager);
}
public void addVariation(String description, int metadata, ISubmapManager manager) {
addVariation(description, metadata, null, manager);
}
public void addVariation(String description, int metadata, Block bb) {
addVariation(description, metadata, null, bb, 0, ChiselAPIProps.MOD_ID);
}
public void addVariation(String description, int metadata, Block bb) {
addVariation(description, metadata, null, bb, 0, ChiselAPIProps.MOD_ID);
}
public void addVariation(String description, int metadata, Block bb, int blockMeta) {
addVariation(description, metadata, null, bb, blockMeta, ChiselAPIProps.MOD_ID);
}
public void addVariation(String description, int metadata, Block bb, int blockMeta) {
addVariation(description, metadata, null, bb, blockMeta, ChiselAPIProps.MOD_ID);
}
public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material) {
addVariation(description, metadata, null, bb, blockMeta, ChiselAPIProps.MOD_ID);
}
public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material) {
addVariation(description, metadata, null, bb, blockMeta, ChiselAPIProps.MOD_ID);
}
public void addVariation(String description, int metadata, String texture) {
addVariation(description, metadata, texture, (ISubmapManager) null);
}
public void addVariation(String description, int metadata, String texture) {
addVariation(description, metadata, texture, (ISubmapManager) null);
}
public void addVariation(String description, int metadata, String texture, ISubmapManager manager) {
addVariation(description, metadata, texture, null, 0, ChiselAPIProps.MOD_ID, manager, metadata);
}
public void addVariation(String description, int metadata, String texture, ISubmapManager manager) {
addVariation(description, metadata, texture, null, 0, ChiselAPIProps.MOD_ID, manager, metadata);
}
public void addVariation(String description, int metadata, Block bb, String modid) {
addVariation(description, metadata, null, bb, 0, modid);
}
public void addVariation(String description, int metadata, Block bb, String modid) {
addVariation(description, metadata, null, bb, 0, modid);
}
public void addVariation(String description, int metadata, Block bb, int blockMeta, String modid) {
addVariation(description, metadata, null, bb, blockMeta, modid);
}
public void addVariation(String description, int metadata, Block bb, int blockMeta, String modid) {
addVariation(description, metadata, null, bb, blockMeta, modid);
}
public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material, String modid) {
addVariation(description, metadata, null, bb, blockMeta, modid);
}
public void addVariation(String description, int metadata, Block bb, int blockMeta, Material material,
String modid) {
addVariation(description, metadata, null, bb, blockMeta, modid);
}
public void addVariation(String description, int metadata, String texture, String modid) {
addVariation(description, metadata, texture, null, 0, modid);
}
public void addVariation(String description, int metadata, String texture, String modid) {
addVariation(description, metadata, texture, null, 0, modid);
}
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid) {
addVariation(description, metadata, texture, block, blockMeta, modid, null, metadata);
}
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta,
String modid) {
addVariation(description, metadata, texture, block, blockMeta, modid, null, metadata);
}
public void addVariation(String description, int metadata, String texture, int order) {
addVariation(description, metadata, texture, null, 0, ChiselAPIProps.MOD_ID, (ISubmapManager) null, order);
}
public void addVariation(String description, int metadata, String texture, int 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)
return;
if (infoList.size() >= 16) return;
IVariationInfo info = FMLCommonHandler.instance().getSide().isClient() ? getClientInfo(modid, texture, description, metadata, block, blockMeta, customManager, order) : getServerInfo(modid,
texture, description, metadata, block, blockMeta, customManager, order);
IVariationInfo info = FMLCommonHandler.instance()
.getSide()
.isClient() ? getClientInfo(modid, texture, description, metadata, block, blockMeta, customManager, order)
: getServerInfo(modid, texture, description, metadata, block, blockMeta, customManager, order);
infoList.add(info);
infoMap[metadata] = info;
}
infoList.add(info);
infoMap[metadata] = info;
}
private IVariationInfo getClientInfo(String modid, String texture, String description, int metadata, Block block, int blockMeta, ISubmapManager customManager, int order) {
ICarvingVariation var = CarvingUtils.getDefaultVariationFor(getBlock(), metadata, order);
TextureType type = TextureType.getTypeFor(this, modid, 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));
}
private IVariationInfo getClientInfo(String modid, String texture, String description, int metadata, Block block,
int blockMeta, ISubmapManager customManager, int order) {
ICarvingVariation var = CarvingUtils.getDefaultVariationFor(getBlock(), metadata, order);
TextureType type = TextureType.getTypeFor(this, modid, 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;
if (customManager != null) {
manager = customManager;
} else if (block != null) {
manager = type.createManagerFor(var, block, blockMeta);
} else {
manager = type.createManagerFor(var, texture);
}
return new VariationInfoBase(var, description, manager, type);
}
ISubmapManager manager;
if (customManager != null) {
manager = customManager;
} else if (block != null) {
manager = type.createManagerFor(var, block, blockMeta);
} else {
manager = type.createManagerFor(var, texture);
}
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) {
ICarvingVariation var = CarvingUtils.getDefaultVariationFor(getBlock(), metadata, order);
return new VariationInfoBase(var, description, null);
}
private IVariationInfo getServerInfo(String modid, String texture, String description, int metadata, Block block,
int blockMeta, ISubmapManager customManager, int order) {
ICarvingVariation var = CarvingUtils.getDefaultVariationFor(getBlock(), metadata, order);
return new VariationInfoBase(var, description, null);
}
public IVariationInfo getVariation(int metadata) {
if (metadata < 0 || metadata > 15)
metadata = 0;
public IVariationInfo getVariation(int metadata) {
if (metadata < 0 || metadata > 15) metadata = 0;
IVariationInfo info = infoMap[metadata];
if (info == null)
return null;
IVariationInfo info = infoMap[metadata];
if (info == null) return null;
return info;
}
return info;
}
public IIcon getIcon(int side, int metadata) {
if (metadata < 0 || metadata > 15)
metadata = 0;
public IIcon getIcon(int side, int metadata) {
if (metadata < 0 || metadata > 15) metadata = 0;
IVariationInfo info = infoMap[metadata];
if (info == null)
return getMissingIcon();
IVariationInfo info = infoMap[metadata];
if (info == null) 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) {
int metadata = world.getBlockMetadata(x, y, z);
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int metadata = world.getBlockMetadata(x, y, z);
if (metadata < 0 || metadata > 15)
metadata = 0;
if (metadata < 0 || metadata > 15) metadata = 0;
IVariationInfo info = infoMap[metadata];
if (info == null)
return getMissingIcon();
IVariationInfo info = infoMap[metadata];
if (info == null) 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) {
registerAll(block, name, itemCarvableClass);
}
public void registerAll(Block block, String name) {
registerAll(block, name, itemCarvableClass);
}
public void registerBlock(Block block, String name) {
registerBlock(block, name, itemCarvableClass);
}
public void registerBlock(Block block, String name) {
registerBlock(block, name, itemCarvableClass);
}
void registerBlock(Block block, String name, Class<? extends ItemBlock> cl) {
block.setBlockName("chisel." + name);
GameRegistry.registerBlock(block, cl, name);
}
void registerBlock(Block block, String name, Class<? extends ItemBlock> cl) {
block.setBlockName("chisel." + name);
GameRegistry.registerBlock(block, cl, name);
}
public void registerAll(Block block, String name, Class<? extends ItemBlock> cl) {
registerBlock(block, name, cl);
registerVariations(name);
}
public void registerAll(Block block, String name, Class<? extends ItemBlock> cl) {
registerBlock(block, name, cl);
registerVariations(name);
}
public void registerVariations(String name) {
for (IVariationInfo info : infoList) {
registerVariation(name, info);
}
}
public void registerVariations(String name) {
for (IVariationInfo info : infoList) {
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()) {
FMPIMC.registerFMP(block, info.getVariation().getBlockMeta());
}
if (Loader.isModLoaded("ForgeMultipart") && block instanceof BlockCarvableGlowie) {
FMPCompat.registerGlowieVariation(info, block);
} else {
if (block.renderAsNormalBlock() || block.isOpaqueCube() || block.isNormalCube()) {
FMPIMC.registerFMP(
block,
info.getVariation()
.getBlockMeta());
}
}
if (forbidChiseling)
return;
if (forbidChiseling) return;
CarvingUtils.getChiselRegistry().addVariation(name, info.getVariation());
}
CarvingUtils.getChiselRegistry()
.addVariation(name, info.getVariation());
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(String modName, Block block, IIconRegister register) {
for (IVariationInfo info : infoList) {
info.registerIcons(modName, block, register);
}
}
@SideOnly(Side.CLIENT)
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) {
for (IVariationInfo info : infoList) {
list.add(new ItemStack(block, 1, info.getVariation().getItemMeta()));
}
}
public void registerSubBlocks(Block block, CreativeTabs tabs, List<ItemStack> list) {
for (IVariationInfo info : infoList) {
list.add(
new ItemStack(
block,
1,
info.getVariation()
.getItemMeta()));
}
}
public void registerOre(String ore) {
OreDictionary.registerOre(ore, getBlock());
}
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;
}
@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 {
/**
* 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 v2
* 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 if they are equal.
*/
public static int compare(ICarvingVariation v1, ICarvingVariation v2) {
return v1.getOrder() - v2.getOrder();
}
/**
* 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 v2 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
* if they are equal.
*/
public static int compare(ICarvingVariation v1, ICarvingVariation v2) {
return v1.getOrder() - v2.getOrder();
}
/**
* Gets an {@link ItemStack} representing the passed {@link ICarvingVariation}.
*
* @param variation
* An {@link ICarvingVariation}
* @return An {@link ItemStack}
*/
public static ItemStack getStack(ICarvingVariation variation) {
return new ItemStack(variation.getBlock(), 1, variation.getItemMeta());
}
/**
* Gets an {@link ItemStack} representing the passed {@link ICarvingVariation}.
*
* @param variation An {@link ICarvingVariation}
* @return An {@link ItemStack}
*/
public static ItemStack getStack(ICarvingVariation variation) {
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.
* <p>
* If chisel is not installed this will return null.
*/
public static ICarvingRegistry getChiselRegistry() {
return chisel;
}
/**
* @return The instance of the chisel carving registry from the chisel mod.
* <p>
* If chisel is not installed this will return null.
*/
public static ICarvingRegistry getChiselRegistry() {
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.
*
* @param block
* The block of the variation
* @param metadata
* The metadata of both the block and item
* @param order
* 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);
}
/**
* 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 metadata The metadata of both the block and item
* @param order 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);
}
/**
* 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.
* @return A standard {@link ICarvingGroup} instance.
*/
public static ICarvingGroup getDefaultGroupFor(String name) {
return new SimpleCarvingGroup(name);
}
/**
* 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.
* @return A standard {@link ICarvingGroup} instance.
*/
public static ICarvingGroup getDefaultGroupFor(String name) {
return new SimpleCarvingGroup(name);
}
public static class SimpleCarvingVariation implements ICarvingVariation {
public static class SimpleCarvingVariation implements ICarvingVariation {
private int order;
private Block block;
private int meta;
private int damage;
private int order;
private Block block;
private int meta;
private int damage;
public SimpleCarvingVariation(Block block, int metadata, int order) {
this.order = order;
this.block = block;
this.meta = metadata;
this.damage = metadata;
}
public SimpleCarvingVariation(Block block, int metadata, int order) {
this.order = order;
this.block = block;
this.meta = metadata;
this.damage = metadata;
}
@Override
public Block getBlock() {
return block;
}
@Override
public Block getBlock() {
return block;
}
@Override
public int getBlockMeta() {
return meta;
}
@Override
public int getBlockMeta() {
return meta;
}
@Override
public int getItemMeta() {
return damage;
}
@Override
public int getItemMeta() {
return damage;
}
@Override
public int getOrder() {
return order;
}
}
@Override
public int getOrder() {
return order;
}
}
public static class SimpleCarvingGroup implements ICarvingGroup {
public static class SimpleCarvingGroup implements ICarvingGroup {
private String name;
private String sound;
private String oreName;
private String name;
private String sound;
private String oreName;
private List<ICarvingVariation> variations = Lists.newArrayList();
private List<ICarvingVariation> variations = Lists.newArrayList();
public SimpleCarvingGroup(String name) {
this.name = name;
}
public SimpleCarvingGroup(String name) {
this.name = name;
}
@Override
public List<ICarvingVariation> getVariations() {
return Lists.newArrayList(variations);
}
@Override
public List<ICarvingVariation> getVariations() {
return Lists.newArrayList(variations);
}
@Override
public void addVariation(ICarvingVariation variation) {
variations.add(variation);
Collections.sort(variations, new Comparator<ICarvingVariation>() {
@Override
public void addVariation(ICarvingVariation variation) {
variations.add(variation);
Collections.sort(variations, new Comparator<ICarvingVariation>() {
@Override
public int compare(ICarvingVariation o1, ICarvingVariation o2) {
return CarvingUtils.compare(o1, o2);
}
});
}
@Override
public int compare(ICarvingVariation o1, ICarvingVariation o2) {
return CarvingUtils.compare(o1, o2);
}
});
}
@Override
public boolean removeVariation(ICarvingVariation variation) {
ICarvingVariation toRemove = null;
for (ICarvingVariation v : variations) {
if (v.getBlock() == variation.getBlock() && v.getBlockMeta() == variation.getBlockMeta()) {
toRemove = v;
}
}
return toRemove == null ? false : variations.remove(toRemove);
}
@Override
public boolean removeVariation(ICarvingVariation variation) {
ICarvingVariation toRemove = null;
for (ICarvingVariation v : variations) {
if (v.getBlock() == variation.getBlock() && v.getBlockMeta() == variation.getBlockMeta()) {
toRemove = v;
}
}
return toRemove == null ? false : variations.remove(toRemove);
}
@Override
public String getName() {
return name;
}
@Override
public String getName() {
return name;
}
@Override
public String getSound() {
return sound;
}
@Override
public String getSound() {
return sound;
}
@Override
public void setSound(String sound) {
this.sound = sound;
}
@Override
public void setSound(String sound) {
this.sound = sound;
}
@Override
public String getOreName() {
return oreName;
}
@Override
public String getOreName() {
return oreName;
}
@Override
public void setOreName(String oreName) {
this.oreName = oreName;
}
}
@Override
public void setOreName(String oreName) {
this.oreName = oreName;
}
}
}
@@ -5,70 +5,69 @@ import java.util.List;
/**
* Represents a group of chiselable blocks.
* <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
* likely be of use to do so.
* 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 likely be of use to do so.
* <p>
* It also defines what sound and oredict name the group as a whole has.
*/
public interface ICarvingGroup {
/**
* The name of this group. Used for internal identification.
*
* @return A string name for the group
*/
String getName();
/**
* The name of this group. Used for internal identification.
*
* @return A string name for the group
*/
String getName();
/**
* 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
*/
String getSound();
/**
* 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
*/
String getSound();
/**
* Sets the sound of this group
*
* @param sound
* A string resource path for the sound this group makes when chiseled
*/
void setSound(String sound);
/**
* Sets the sound of this group
*
* @param sound A string resource path for the sound this group makes when chiseled
*/
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.
*
* @return An ore dictionary name
*/
String getOreName();
/**
* 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
*/
String getOreName();
/**
* Sets the oredict name for this group.
*
* @param oreName
* The String oredict name to be associated with this group.
*/
void setOreName(String oreName);
/**
* Sets the oredict name for this group.
*
* @param oreName The String oredict name to be associated with this group.
*/
void setOreName(String oreName);
/**
* Gets all carving variations associated with this group.
*
* @return A {@link List} of {@link ICarvingVariation}s
*/
List<ICarvingVariation> getVariations();
/**
* Gets all carving variations associated with this group.
*
* @return A {@link List} of {@link ICarvingVariation}s
*/
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.
*
* @param variation
* An {@link ICarvingVariation} to add to this group
*/
void addVariation(ICarvingVariation variation);
/**
* 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
*/
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.
*
* @param variation
* An {@link ICarvingVariation} to add to this group
*/
boolean removeVariation(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.
*
* @param variation An {@link ICarvingVariation} to add to this group
*/
boolean removeVariation(ICarvingVariation variation);
}
@@ -14,191 +14,168 @@ import net.minecraft.world.World;
*/
public interface ICarvingRegistry {
/* Getters */
/* Getters */
/**
* Finds the group the block/meta pair belongs to in the registry.
*
* @param block
* The block of the variation
* @param meta
* The metadata of the variation
* @return The {@link ICarvingGroup} that the block/meta pair belongs to
*/
ICarvingGroup getGroup(Block block, int meta);
/**
* Finds the group the block/meta pair belongs to in the registry.
*
* @param block The block of the variation
* @param meta The metadata of the variation
* @return The {@link ICarvingGroup} that the block/meta pair belongs to
*/
ICarvingGroup getGroup(Block block, int meta);
/**
* Gets an {@link ICarvingGroup} by its name.
*
* @param name
* The name of the group
* @return An {@link ICarvingGroup}
*/
ICarvingGroup getGroup(String name);
/**
* Gets an {@link ICarvingGroup} by its name.
*
* @param name The name of the group
* @return An {@link ICarvingGroup}
*/
ICarvingGroup getGroup(String name);
/**
* Gets the {@link ICarvingVariation} instance represented by this block/meta pair.
*
* @param block
* The block of the variatoin
* @param meta
* The metadata of the variation
* @return The {@link ICarvingVariation} containing this block/meta pair
*/
ICarvingVariation getVariation(Block block, int meta);
/**
* Gets the {@link ICarvingVariation} instance represented by this block/meta pair.
*
* @param block The block of the variatoin
* @param meta The metadata of the variation
* @return The {@link ICarvingVariation} containing this block/meta pair
*/
ICarvingVariation getVariation(Block block, int meta);
/**
* Gets the list of {@link ICarvingVariation}s from the group that contains this block/meta pair.
*
* @param block
* The block of the variation
* @param meta
* 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);
/**
* Gets the list of {@link ICarvingVariation}s from the group that contains this block/meta pair.
*
* @param block The block of the variation
* @param meta 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);
/**
* Gets the oredict name for the group that contains this block/meta pair.
*
* @param block
* The block of the variation
* @param meta
* The metadata of the variation
* @return A string oredict name for the group
*/
String getOreName(Block block, int meta);
/**
* Gets the oredict name for the group that contains this block/meta pair.
*
* @param block The block of the variation
* @param meta The metadata of the variation
* @return A string oredict name for the group
*/
String getOreName(Block block, int meta);
/**
* Gets the possible output items for this {@link ItemStack}. To be used for machines/GUIs that chisel items.
*
* @param chiseled
* The {@link ItemStack} being chiseled
* @return A list of stacks that can be chiseled from the passed {@link ItemStack stack}
*/
List<ItemStack> getItemsForChiseling(ItemStack chiseled);
/**
* Gets the possible output items for this {@link ItemStack}. To be used for machines/GUIs that chisel items.
*
* @param chiseled The {@link ItemStack} being chiseled
* @return A list of stacks that can be chiseled from the passed {@link ItemStack stack}
*/
List<ItemStack> getItemsForChiseling(ItemStack chiseled);
/**
* Gets the sound resource string for the group represented by this block/meta pair.
*
* @param block
* The block of the variation
* @param metadata
* The metadata of the variation
* @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);
/**
* Gets the sound resource string for the group represented by this block/meta pair.
*
* @param block The block of the variation
* @param metadata The metadata of the variation
* @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);
/**
* Gets the sound resource string for the group represented by this item/meta pair.
* <p>
* Mostly a convenience for calling {@link #getVariationSound(Block, int)} with {@link Block#getBlockFromItem(Item)}.
*
* @param item
* The item of the variation
* @param metadata
* The metadata of the variation
* @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(Item item, int metadata);
/**
* Gets the sound resource string for the group represented by this item/meta pair.
* <p>
* Mostly a convenience for calling {@link #getVariationSound(Block, int)} with
* {@link Block#getBlockFromItem(Item)}.
*
* @param item The item of the variation
* @param metadata The metadata of the variation
* @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(Item item, int metadata);
/**
* @return A list of all registered group names, sorted alphabetically.
*/
List<String> getSortedGroupNames();
/**
* @return A list of all registered group names, sorted alphabetically.
*/
List<String> getSortedGroupNames();
/* Setters */
/* Setters */
/**
* Adds a variation to the registry.
*
* @param groupName
* The name of the group to add to.
* @param block
* The block of the variation
* @param metadata
* The metadata of the variation
* @param 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.
*
* @param groupName The name of the group to add to.
* @param block The block of the variation
* @param metadata The metadata of the variation
* @param 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.
*
* @param groupName
* The name of the group to add to
* @param variation
* The {@link ICarvingVariation} to add
*/
void addVariation(String groupName, ICarvingVariation variation);
/**
* Adds a variation to the registry.
*
* @param groupName The name of the group to add to
* @param variation The {@link ICarvingVariation} to add
*/
void addVariation(String groupName, ICarvingVariation variation);
/**
* Adds a group to the registry.
*
* @param group
* The {@link ICarvingGroup} to add.
*/
void addGroup(ICarvingGroup group);
/**
* Adds a group to the registry.
*
* @param group The {@link ICarvingGroup} to add.
*/
void addGroup(ICarvingGroup group);
/**
* Removes a group from the registry.
* <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
* removed, it will still contain its variations.
*
* @param groupName
* The name of the group to remove.
* @return The {@link ICarvingGroup} that was removed.
*/
ICarvingGroup removeGroup(String groupName);
/**
* Removes a group from the registry.
* <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 removed, it will still contain its
* variations.
*
* @param groupName The name of the group to remove.
* @return The {@link ICarvingGroup} that was removed.
*/
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.
*
* @param block
* The {@link Block} of the {@link ICarvingVariation variation}
* @param metadata
* The metadata of the {@link ICarvingVariation variation}
* @return The ICarvingVariation that was removed. Null if nothing was removed.
*/
ICarvingVariation removeVariation(Block block, int metadata);
/**
* 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 metadata The metadata of the {@link ICarvingVariation variation}
* @return The ICarvingVariation that was removed. Null if nothing was removed.
*/
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.
*
* @param block
* The {@link Block} of the {@link ICarvingVariation variation}
* @param metadata
* The metadata of the {@link ICarvingVariation variation}
* @param group
* 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);
/**
* 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 metadata The metadata of the {@link ICarvingVariation variation}
* @param group 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);
/**
* Registers a group to an oredict name.
* <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.
*
* @param groupName
* The name of the group
* @param oreName
* The oredict name
*/
void registerOre(String groupName, String oreName);
/**
* Registers a group to an oredict name.
* <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.
*
* @param groupName The name of the group
* @param oreName The oredict name
*/
void registerOre(String groupName, String oreName);
/**
* Sets the sound resource for a group.
* <p>
* 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.
*
* @param name
* The name of the group
* @param sound
* The resource string for the sound
*/
void setVariationSound(String name, String sound);
/**
* Sets the sound resource for a group.
* <p>
* 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.
*
* @param name The name of the group
* @param sound The resource string for the sound
*/
void setVariationSound(String name, String sound);
}
@@ -8,31 +8,31 @@ import net.minecraft.item.Item;
*/
public interface ICarvingVariation {
/**
* The base block of this variation.
*
* @return A {@link Block} that is the base of this variation
*/
Block getBlock();
/**
* The base block of this variation.
*
* @return A {@link Block} that is the base of this variation
*/
Block getBlock();
/**
* The metadata of this variation
*
* @return An int representing the metadata of this variation's {@link Block} in the world.
*/
int getBlockMeta();
/**
* The metadata of this variation
*
* @return An int representing the metadata of this variation's {@link Block} in the world.
*/
int getBlockMeta();
/**
* The item metadata of this variation
*
* @return An int representing the metadata of this variations's {@link Item}.
*/
int getItemMeta();
/**
* The item metadata of this variation
*
* @return An int representing the metadata of this variations's {@link Item}.
*/
int getItemMeta();
/**
* 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
*/
int getOrder();
/**
* 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
*/
int getOrder();
}
@@ -6,15 +6,17 @@ import net.minecraftforge.common.util.ForgeDirection;
public interface IChiselMode {
/**
* 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);
/**
* 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);
/**
* Implemented implicitly by enums. If your IChiselMode is not an enum constant, this needs to be implemented explicitly.
*
* @return The name of the mode.
*/
String name();
/**
* Implemented implicitly by enums. If your IChiselMode is not an enum constant, this needs to be implemented
* explicitly.
*
* @return The name of the mode.
*/
String name();
}
@@ -1,14 +1,14 @@
package com.cricketcraft.chisel.api.carving;
import team.chisel.ctmlib.ISubmapManager;
import com.cricketcraft.chisel.api.rendering.TextureType;
import team.chisel.ctmlib.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;
import team.chisel.ctmlib.ISubmapManager;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
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 team.chisel.ctmlib.ISubmapManager;
public class VariationInfoBase implements IVariationInfo {
private ICarvingVariation variation;
private String unlocDesc;
private ISubmapManager manager;
private TextureType type;
private ICarvingVariation variation;
private String unlocDesc;
private ISubmapManager manager;
private TextureType type;
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager manager) {
this(variation, unlocDesc, manager, TextureType.CUSTOM);
}
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager manager) {
this(variation, unlocDesc, manager, TextureType.CUSTOM);
}
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager manager, TextureType type) {
this.variation = variation;
this.unlocDesc = unlocDesc;
this.manager = manager;
this.type = type;
}
public VariationInfoBase(ICarvingVariation variation, String unlocDesc, ISubmapManager manager, TextureType type) {
this.variation = variation;
this.unlocDesc = unlocDesc;
this.manager = manager;
this.type = type;
}
@Override
public ICarvingVariation getVariation() {
return variation;
}
@Override
public ICarvingVariation getVariation() {
return variation;
}
@Override
public String getDescription() {
return StatCollector.translateToLocal(unlocDesc);
}
@Override
public String getDescription() {
return StatCollector.translateToLocal(unlocDesc);
}
@Override
public TextureType getType() {
return type;
}
@Override
public TextureType getType() {
return type;
}
// ISubmapManager delegation
// ISubmapManager delegation
@Override
public IIcon getIcon(int side, int meta) {
return manager.getIcon(side, meta);
}
@Override
public IIcon getIcon(int side, int meta) {
return manager.getIcon(side, meta);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return manager.getIcon(world, x, y, z, side);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return manager.getIcon(world, x, y, z, side);
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
manager.registerIcons(modName, block, register);
}
@Override
public void registerIcons(String modName, Block block, IIconRegister register) {
manager.registerIcons(modName, block, register);
}
@Override
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
return manager.createRenderContext(rendererOld, block, world);
}
@Override
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
return manager.createRenderContext(rendererOld, block, world);
}
@Override
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
manager.preRenderSide(renderer, world, x, y, z, side);
}
@Override
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
manager.preRenderSide(renderer, world, x, y, z, side);
}
@Override
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
manager.postRenderSide(renderer, world, x, y, z, side);
}
@Override
public void postRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection 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 cpw.mods.fml.common.API;
@@ -2,4 +2,3 @@
package com.cricketcraft.chisel.api;
import cpw.mods.fml.common.API;
@@ -2,6 +2,6 @@ package com.cricketcraft.chisel.api.rendering;
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.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.ICarvingVariation;
import cpw.mods.fml.relauncher.Side;
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
@@ -33,7 +32,7 @@ import cpw.mods.fml.relauncher.SideOnly;
@SuppressWarnings("unchecked")
public enum TextureType {
// @formatter:off
// @formatter:off
TOPBOTSIDE("top", "bottom", "side"){
@Override
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
@@ -43,7 +42,7 @@ public enum TextureType {
register.registerIcon(modName + ":" + texturePath + "-top")
};
}
@Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
IIcon[] icons = (IIcon[]) cachedObject;
@@ -58,7 +57,7 @@ public enum TextureType {
register.registerIcon(modName + ":" + texturePath + "-top")
};
}
@Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
IIcon[] icons = (IIcon[]) cachedObject;
@@ -66,18 +65,18 @@ public enum TextureType {
}
},
CTMV("ctmv", "top"){
@Override
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"));
}
@Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject;
return side < 2 ? data.getRight() : data.getLeft().getSubIcon(0, 0);
}
@Override
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;
@@ -97,13 +96,14 @@ public enum TextureType {
return map.getSubIcon(1, 0);
return map.getSubIcon(0, 0);
}
@Override
@SideOnly(Side.CLIENT)
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
RenderBlocksColumn ret = theRenderBlocksColumn;
TextureType.initStatics();
RenderBlocksColumn ret = theRenderBlocksColumn.get();
Pair<TextureSubmap, IIcon> data = (Pair<TextureSubmap, IIcon>) cachedObject;
ret.blockAccess = world;
ret.renderMaxX = 1.0;
ret.renderMaxY = 1.0;
@@ -118,13 +118,13 @@ public enum TextureType {
@Override
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"));
}
}
@Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return CTMV.getIcon(variation, cachedObject, side, meta);
}
@Override
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;
@@ -144,7 +144,7 @@ public enum TextureType {
p = 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();
if (p && n)
return map.getSubIcon(1, 0);
@@ -160,14 +160,14 @@ public enum TextureType {
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-v9"), 3, 3);
}
@Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return ((TextureSubmap)cachedObject).getSubIcon(1, 1);
}
@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);
}
},
@@ -176,12 +176,12 @@ public enum TextureType {
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-v4"), 2, 2);
}
@Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return ((TextureSubmap)cachedObject).getSubIcon(0, 0);
}
@Override
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);
@@ -197,16 +197,17 @@ public enum TextureType {
new TextureSubmap(baseIcon, 2, 2)
);
}
@Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return ((Triple<IIcon, ?, ?>)cachedObject).getLeft();
}
@Override
@SideOnly(Side.CLIENT)
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
RenderBlocksCTM ret = theRenderBlocksCTM;
TextureType.initStatics();
RenderBlocksCTM ret = theRenderBlocksCTM.get();
Triple<?, TextureSubmap, TextureSubmap> data = (Triple<?, TextureSubmap, TextureSubmap>) cachedObject;
ret.blockAccess = world;
@@ -221,13 +222,13 @@ public enum TextureType {
@Override
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r16"), 4, 4);
}
}
@Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return V9.getIcon(variation, cachedObject, side, meta);
}
@Override
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);
@@ -237,30 +238,30 @@ public enum TextureType {
@Override
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r9"), 3, 3);
}
}
@Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return V9.getIcon(variation, cachedObject, side, meta);
}
@Override
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);
}
},
R4("r4"){
@Override
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return new TextureSubmap(register.registerIcon(modName + ":" + texturePath + "-r4"), 2, 2);
}
}
@Override
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return V4.getIcon(variation, cachedObject, side, meta);
}
@Override
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);
@@ -268,9 +269,9 @@ public enum TextureType {
},
NORMAL,
CUSTOM;
/* 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) {
int variationSize = (type == TextureType.V9) ? 3 : 2;
@@ -305,30 +306,30 @@ public enum TextureType {
return map.getSubIcon(index % variationSize, index / variationSize);
}
public static IIcon getRIcon(TextureType type, TextureSubmap map, int x, int y, int z, int side) {
rand.setSeed(getCoordinateRandom(x, y, z));
rand.nextBoolean();
int size = type == TextureType.R4 ? 2 : type == TextureType.R9 ? 3 : 4;
return map.getSubIcon(rand.nextInt(size), rand.nextInt(size));
}
private static long getCoordinateRandom(int x, int y, int z) {
// MC 1.8 code...
long l = (x * 3129871) ^ z * 116129781L ^ y;
l = l * l * 42317861L + l * 11L;
return l;
}
/* End of that mess */
private static final TextureType[] VALUES;
private static final CTM ctm = CTM.getInstance();
private static final Random rand = new Random();
@SideOnly(Side.CLIENT)
private static RenderBlocksCTM theRenderBlocksCTM;
private static ThreadLocal<RenderBlocksCTM> theRenderBlocksCTM;
@SideOnly(Side.CLIENT)
private static RenderBlocksColumn theRenderBlocksColumn;
private static ThreadLocal<RenderBlocksColumn> theRenderBlocksColumn;
private String[] suffixes;
static {
@@ -338,31 +339,37 @@ public enum TextureType {
private TextureType(String... suffixes) {
this.suffixes = suffixes.length == 0 ? new String[] { "" } : suffixes;
}
private static void initStatics() {
if (theRenderBlocksCTM == null) {
theRenderBlocksCTM = new RenderBlocksCTM();
theRenderBlocksColumn = new RenderBlocksColumn();
}
}
public ISubmapManager createManagerFor(ICarvingVariation variation, String texturePath) {
private static void initStatics() {
if (theRenderBlocksCTM == null) {
theRenderBlocksCTM = ThreadLocal.withInitial(RenderBlocksCTM::new);
theRenderBlocksColumn = ThreadLocal.withInitial(RenderBlocksColumn::new);
}
}
@SideOnly(Side.CLIENT)
public static void clearStatics() {
if(theRenderBlocksCTM != null) theRenderBlocksCTM.remove();
if(theRenderBlocksColumn != null) theRenderBlocksColumn.remove();
}
public ISubmapManager createManagerFor(ICarvingVariation variation, String texturePath) {
return new SubmapManagerDefault(this, variation, texturePath);
}
public ISubmapManager createManagerFor(ICarvingVariation variation, Block block, int meta) {
return new SubmapManagerExistingIcon(this, variation, block, meta);
}
@SideOnly(Side.CLIENT)
protected Object registerIcons(ICarvingVariation variation, String modName, String texturePath, IIconRegister register) {
return register.registerIcon(modName + ":" + texturePath);
}
protected IIcon getIcon(ICarvingVariation variation, Object cachedObject, int side, int meta) {
return (IIcon) cachedObject;
}
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);
}
@@ -371,7 +378,7 @@ public enum TextureType {
protected RenderBlocks createRenderContext(RenderBlocks rendererOld, IBlockAccess world, Object cachedObject) {
return rendererOld;
}
public static TextureType getTypeFor(CarvableHelper inst, String modid, String path) {
if (path == null) {
return CUSTOM;
@@ -389,7 +396,7 @@ public enum TextureType {
}
return CUSTOM;
}
// This is ugly, but faster than class.getResource
private static boolean exists(String modid, String path, String postfix) {
ResourceLocation rl = new ResourceLocation(modid, "textures/blocks/" + path + postfix + ".png");
@@ -400,18 +407,18 @@ public enum TextureType {
return false;
}
}
@SideOnly(Side.CLIENT)
public abstract static class AbstractSubmapManager implements ISubmapManager {
protected final TextureType type;
protected ICarvingVariation variation;
protected Object cachedObject;
private AbstractSubmapManager(TextureType type, ICarvingVariation variation) {
this.type = type;
this.variation = variation;
}
@Override
public IIcon getIcon(int side, int meta) {
return type.getIcon(variation, cachedObject, side, meta);
@@ -421,23 +428,22 @@ public enum TextureType {
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));
}
@Override
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
initStatics();
RenderBlocks rb = type.createRenderContext(rendererOld, world, cachedObject);
rb.setRenderBoundsFromBlock(block);
return rb;
}
@Override
public void preRenderSide(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, ForgeDirection side) {
}
@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() {
return cachedObject;
}
@@ -447,7 +453,7 @@ public enum TextureType {
private static class SubmapManagerDefault extends AbstractSubmapManager {
private String texturePath;
private SubmapManagerDefault(TextureType type, ICarvingVariation variation, String texturePath) {
super(type, variation);
this.texturePath = texturePath;
@@ -458,24 +464,24 @@ public enum TextureType {
cachedObject = type.registerIcons(variation, modName, texturePath, register);
}
}
@SideOnly(Side.CLIENT)
private static class SubmapManagerExistingIcon extends AbstractSubmapManager {
private Block block;
private int meta;
private SubmapManagerExistingIcon(TextureType type, ICarvingVariation variation, Block block, int meta) {
super(type, variation);
this.block = block;
this.meta = meta;
}
@Override
public IIcon getIcon(int side, int meta) {
return block.getIcon(side, this.meta);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return getIcon(side, world.getBlockMetadata(x, y, z));
@@ -485,4 +491,4 @@ public enum TextureType {
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 cpw.mods.fml.common.API;
@@ -2,107 +2,117 @@ package team.chisel;
import java.util.HashMap;
import team.chisel.utils.General;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.registry.GameRegistry;
import team.chisel.utils.General;
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) {
oldname = General.cleanTags(oldname);
String newname = null;
switch (step) {
case 0: // lookup list
return namingConversion.get(oldname);
case 1: // remove Chisel:
if (oldname.startsWith("Chisel:")) {
newname = oldname.replaceAll("(?i)" + "Chisel:", "");
}
return newname;
case 2: // rename "marbleSlab" -> "marble_slab", "redstone" ->
// "redstone_block"
newname = oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2").toLowerCase();
protected static String conversion(String oldname, int step) {
oldname = General.cleanTags(oldname);
String newname = null;
switch (step) {
case 0: // lookup list
return namingConversion.get(oldname);
case 1: // remove Chisel:
if (oldname.startsWith("Chisel:")) {
newname = oldname.replaceAll("(?i)" + "Chisel:", "");
}
return newname;
case 2: // rename "marbleSlab" -> "marble_slab", "redstone" ->
// "redstone_block"
newname = oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2")
.toLowerCase();
if (newname.startsWith("block_")) {
newname = newname.replaceFirst("block_([a-z_]+)", "$1_block");
} else if (newname.startsWith("snakestone_")) {
newname = newname.replaceFirst("snakestone_([a-z_]+)", "$1_snakestone");
}
return newname;
case 3: // rename "wood-dark-oak" -> "dark_oak_planks"
newname = oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2").toLowerCase().replace('-', '_');
if (newname.contains("wood_")) {
newname = newname.replaceFirst("wood_([a-z_]+)", "$1_planks");
}
return newname;
case (MAX - 1): // ALWAYS last: rename "blockYxx" -> "yxx" (e.g.
// "dirt" -> "dirt").
// This can be dangerous in cases like "carpet" (a block) ->
// "carpet" (NO block)
return oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2").toLowerCase().replaceFirst("block_", "");
default:
throw new IndexOutOfBoundsException("conversion got invalid parameter step=" + step);
}
}
}
if (newname.startsWith("block_")) {
newname = newname.replaceFirst("block_([a-z_]+)", "$1_block");
} else if (newname.startsWith("snakestone_")) {
newname = newname.replaceFirst("snakestone_([a-z_]+)", "$1_snakestone");
}
return newname;
case 3: // rename "wood-dark-oak" -> "dark_oak_planks"
newname = oldname.replaceAll("([a-z]+)([A-Z])", "$1_$2")
.toLowerCase()
.replace('-', '_');
if (newname.contains("wood_")) {
newname = newname.replaceFirst("wood_([a-z_]+)", "$1_planks");
}
return newname;
case (MAX - 1): // ALWAYS last: rename "blockYxx" -> "yxx" (e.g.
// "dirt" -> "dirt").
// This can be dangerous in cases like "carpet" (a block) ->
// "carpet" (NO block)
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() {
namingConversion.put("blockCobble", "cobblestone");
namingConversion.put("iron", "iron_block");
namingConversion.put("gold", "gold_block");
namingConversion.put("diamond", "diamond_block");
namingConversion.put("lightstone", "glowstone");
namingConversion.put("lapis", "lapis_block");
namingConversion.put("emerald", "emerald_block");
namingConversion.put("hellrock", "netherrack");
namingConversion.put("stoneMoss", "mossy_cobblestone");
namingConversion.put("stoneBrick", "stonebrick");
namingConversion.put("fenceIron", "iron_bars");
namingConversion.put("fantasy", "fantasyblock");
namingConversion.put("carpetFloor", "carpet");
namingConversion.put("temple", "templeblock");
namingConversion.put("templeMossy", "mossy_templeblock");
namingConversion.put("factory", "factoryblock");
namingConversion.put("laboratory", "laboratoryblock");
// "LightGray" is unfortunately converted to "light_gray"
namingConversion.put("stainedGlassLightGray", "stained_glass_lightgray");
namingConversion.put("stainedGlassPaneLightGray", "stained_glass_pane_lightgray");
namingConversion.put("blockTemple", "templeblock");
namingConversion.put("stoneBrick", "stonebricksmooth");
namingConversion.put("blockTempleMossy", "mossy_templeblock");
namingConversion.put("blockFactory", "factoryblock");
namingConversion.put("blockFft", "fantasyblock");
namingConversion.put("blockCarpetFloor", "carpet");
namingConversion.put("blockLaboratory", "laboratoryblock");
}
static public void init() {
namingConversion.put("blockCobble", "cobblestone");
namingConversion.put("iron", "iron_block");
namingConversion.put("gold", "gold_block");
namingConversion.put("diamond", "diamond_block");
namingConversion.put("lightstone", "glowstone");
namingConversion.put("lapis", "lapis_block");
namingConversion.put("emerald", "emerald_block");
namingConversion.put("hellrock", "netherrack");
namingConversion.put("stoneMoss", "mossy_cobblestone");
namingConversion.put("stoneBrick", "stonebrick");
namingConversion.put("fenceIron", "iron_bars");
namingConversion.put("fantasy", "fantasyblock");
namingConversion.put("carpetFloor", "carpet");
namingConversion.put("temple", "templeblock");
namingConversion.put("templeMossy", "mossy_templeblock");
namingConversion.put("factory", "factoryblock");
namingConversion.put("laboratory", "laboratoryblock");
// "LightGray" is unfortunately converted to "light_gray"
namingConversion.put("stainedGlassLightGray", "stained_glass_lightgray");
namingConversion.put("stainedGlassPaneLightGray", "stained_glass_pane_lightgray");
namingConversion.put("blockTemple", "templeblock");
namingConversion.put("stoneBrick", "stonebricksmooth");
namingConversion.put("blockTempleMossy", "mossy_templeblock");
namingConversion.put("blockFactory", "factoryblock");
namingConversion.put("blockFft", "fantasyblock");
namingConversion.put("blockCarpetFloor", "carpet");
namingConversion.put("blockLaboratory", "laboratoryblock");
}
public static Item findItem(String oldname) {
FMLLog.getLogger().trace("[Chisel 2] findItem() START " + oldname);
Item item = null;
for (int i = 0; i < NameConversions.MAX && item == null; i++) {
FMLLog.getLogger().trace("[Chisel 2] findItem() Checking for " + NameConversions.conversion(oldname, i));
item = GameRegistry.findItem(Chisel.MOD_ID, NameConversions.conversion(oldname, i));
}
public static Item findItem(String oldname) {
FMLLog.getLogger()
.trace("[Chisel 2] findItem() START " + oldname);
Item item = null;
for (int i = 0; i < NameConversions.MAX && item == null; 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) {
FMLLog.getLogger().trace("[Chisel 2] findBlock() START: " + oldname);
Block block = null;
for (int i = 0; i < NameConversions.MAX && block == null; i++) {
FMLLog.getLogger().trace("[Chisel 2] findBlock() Checking for " + NameConversions.conversion(oldname, i));
block = GameRegistry.findBlock(Chisel.MOD_ID, NameConversions.conversion(oldname, i));
}
public static Block findBlock(String oldname) {
FMLLog.getLogger()
.trace("[Chisel 2] findBlock() START: " + oldname);
Block block = null;
for (int i = 0; i < NameConversions.MAX && block == null; 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;
}
}
+157 -133
View File
@@ -10,23 +10,6 @@ import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.LogManager;
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.Statistics;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
@@ -52,146 +35,187 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
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 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 String MOD_NAME = "Chisel";
public static final String VERSION = "GRADLETOKEN_VERSION";
public static final BlockCarvable.SoundType soundHolystoneFootstep = new BlockCarvable.SoundType("holystone", 1.0f, 1.0f);
public static final BlockCarvable.SoundType soundMetalFootstep = new BlockCarvable.SoundType("metal", 1.0f, 1.0f);
public static boolean multipartLoaded = false;
public static int renderEldritchId;
public static int renderAutoChiselId;
public static int renderGlowId;
public static int renderLayeredId;
public static int roadLineId;
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 String MOD_NAME = "Chisel";
public static final String VERSION = Tags.VERSION;
public static final BlockCarvable.SoundType soundHolystoneFootstep = new BlockCarvable.SoundType(
"holystone",
1.0f,
1.0f);
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 boolean iguanaTweaksLoaded = 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)
public static Chisel instance;
@Instance(MOD_ID)
public static Chisel instance;
public Chisel() {
ChiselAPIProps.MOD_ID = MOD_ID;
CarvableHelper.itemCarvableClass = ItemCarvable.class;
Carving.construct();
}
public Chisel() {
ChiselAPIProps.MOD_ID = MOD_ID;
CarvableHelper.itemCarvableClass = ItemCarvable.class;
Carving.construct();
}
@SidedProxy(clientSide = "team.chisel.proxy.ClientProxy", serverSide = "team.chisel.proxy.CommonProxy")
public static CommonProxy proxy;
@SidedProxy(clientSide = "team.chisel.proxy.ClientProxy", serverSide = "team.chisel.proxy.CommonProxy")
public static CommonProxy proxy;
@EventHandler
public void missingMapping(FMLMissingMappingsEvent event) {
BlockNameConversion.init();
@EventHandler
public void missingMapping(FMLMissingMappingsEvent event) {
BlockNameConversion.init();
for (MissingMapping m : event.get()) {
// This bug was introduced along with Chisel 1.5.2, and was fixed in
// 1.5.3.
// Ice Stairs were called null.0-7 instead of other names, and
// Marble/Limestone stairs did not exist.
// This fixes the bug.
if (m.name.startsWith("null.") && m.name.length() == 6 && m.type == Type.BLOCK) {
m.warn();// (Action.WARN);
}
for (MissingMapping m : event.get()) {
// This bug was introduced along with Chisel 1.5.2, and was fixed in
// 1.5.3.
// Ice Stairs were called null.0-7 instead of other names, and
// Marble/Limestone stairs did not exist.
// This fixes the bug.
if (m.name.startsWith("null.") && m.name.length() == 6 && m.type == Type.BLOCK) {
m.warn();// (Action.WARN);
}
// Fix mapping of snakestoneSand, snakestoneStone, limestoneStairs,
// marbleStairs when loading an old (1.5.4) save
else if (m.type == Type.BLOCK) {
final Block block = BlockNameConversion.findBlock(m.name);
// Fix mapping of snakestoneSand, snakestoneStone, limestoneStairs,
// marbleStairs when loading an old (1.5.4) save
else if (m.type == Type.BLOCK) {
final Block block = BlockNameConversion.findBlock(m.name);
if (block != null) {
m.remap(block);
FMLLog.getLogger().info("Remapping block " + m.name + " to " + General.getName(block));
} else
FMLLog.getLogger().warn("Block " + m.name + " could not get remapped.");
} else if (m.type == Type.ITEM) {
final Item item = BlockNameConversion.findItem(m.name);
if (block != null) {
m.remap(block);
FMLLog.getLogger()
.info("Remapping block " + m.name + " to " + General.getName(block));
} else FMLLog.getLogger()
.warn("Block " + m.name + " could not get remapped.");
} else if (m.type == Type.ITEM) {
final Item item = BlockNameConversion.findItem(m.name);
if (item != null) {
m.remap(item);
FMLLog.getLogger().info("Remapping item " + m.name + " to " + General.getName(item));
if (item != null) {
m.remap(item);
FMLLog.getLogger()
.info("Remapping item " + m.name + " to " + General.getName(item));
} else
FMLLog.getLogger().warn("Item " + m.name + " could not get remapped.");
}
}
}
} else FMLLog.getLogger()
.warn("Item " + m.name + " could not get remapped.");
}
}
}
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
FMLCommonHandler.instance().registerCrashCallable(new ChiselCrashCallable());
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
FMLCommonHandler.instance()
.registerCrashCallable(new ChiselCrashCallable());
File configFile = event.getSuggestedConfigurationFile();
Configurations.configExists = configFile.exists();
Configurations.config = new Configuration(configFile);
Configurations.config.load();
Configurations.refreshConfig();
File configFile = event.getSuggestedConfigurationFile();
Configurations.configExists = configFile.exists();
Configurations.config = new Configuration(configFile);
Configurations.config.load();
Configurations.refreshConfig();
TabsInit.preInit();
Features.preInit();
Statistics.init();
PacketHandler.init();
ChiselController.INSTANCE.preInit();
if (Loader.isModLoaded("ForgeMultipart")) {
new FMPCompat().init();
}
proxy.preInit();
}
if (Loader.isModLoaded("dreamcraft")) {
gtnhLoaded = true;
}
if (Loader.isModLoaded("IguanaTweaksTConstruct")) {
iguanaTweaksLoaded = true;
}
TabsInit.preInit();
Features.preInit();
Statistics.init();
PacketHandler.init();
ChiselController.INSTANCE.preInit();
if (Loader.isModLoaded("ForgeMultipart")) {
new FMPCompat().init();
}
proxy.preInit();
}
@EventHandler
public void init(FMLInitializationEvent event) {
Features.init();
@EventHandler
public void init(FMLInitializationEvent event) {
Features.init();
NetworkRegistry.INSTANCE.registerGuiHandler(this, new ChiselGuiHandler());
NetworkRegistry.INSTANCE.registerGuiHandler(this, new ChiselGuiHandler());
addWorldgen(Features.MARBLE, ChiselBlocks.marble, Configurations.marbleAmount);
addWorldgen(Features.LIMESTONE, ChiselBlocks.limestone, Configurations.limestoneAmount);
addWorldgen(Features.ANDESITE, ChiselBlocks.andesite, Configurations.andesiteAmount, 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);
GameRegistry.registerWorldGenerator(GeneratorChisel.INSTANCE, 1000);
addWorldgen(Features.MARBLE, ChiselBlocks.marble, Configurations.marbleAmount);
addWorldgen(Features.LIMESTONE, ChiselBlocks.limestone, Configurations.limestoneAmount);
addWorldgen(Features.ANDESITE, ChiselBlocks.andesite, Configurations.andesiteAmount, 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);
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();
MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(instance);
proxy.init();
MinecraftForge.EVENT_BUS.register(this);
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) {
if (feature.enabled()) {
if (data.length == 1) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0]);
} else if (data.length > 1 && data.length < 4) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2]);
} else if (data.length == 4) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2], data[3]);
}
}
}
private void addWorldgen(Features feature, Block block, double... data) {
if (feature.enabled()) {
if (data.length == 1) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0]);
} else if (data.length > 1 && data.length < 4) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2]);
} else if (data.length == 4) {
GeneratorChisel.INSTANCE.addFeature(block, 32, (int) data[0], (int) data[1], (int) data[2], data[3]);
}
}
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
TabsInit.postInit();
Compatibility.init(event);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
TabsInit.postInit();
Compatibility.init(event);
}
@EventHandler
public void onIMC(IMCEvent event) {
for (IMCMessage msg : event.getMessages()) {
IMCHandler.INSTANCE.handleMessage(msg);
}
}
@EventHandler
public void onIMC(IMCEvent event) {
for (IMCMessage msg : event.getMessages()) {
IMCHandler.INSTANCE.handleMessage(msg);
}
}
@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.modID.equals("chisel")) {
Configurations.refreshConfig();
}
}
@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.modID.equals("chisel")) {
Configurations.refreshConfig();
}
}
}
@@ -4,14 +4,14 @@ import cpw.mods.fml.common.ICrashCallable;
public class ChiselCrashCallable implements ICrashCallable {
@Override
public String call() throws Exception {
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.";
}
@Override
public String call() throws Exception {
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.";
}
@Override
public String getLabel() {
return Chisel.MOD_NAME;
}
@Override
public String getLabel() {
return Chisel.MOD_NAME;
}
}
File diff suppressed because it is too large. Load diff
@@ -1,7 +1,5 @@
package team.chisel.block;
import team.chisel.Chisel;
import team.chisel.block.tileentity.TileEntityAutoChisel;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -10,67 +8,70 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import team.chisel.Chisel;
import team.chisel.block.tileentity.TileEntityAutoChisel;
public class BlockAutoChisel extends BlockContainer {
public BlockAutoChisel() {
super(Material.rock);
setHardness(1F);
setBlockBounds(0.125f, 0, 0.125f, 0.875f, 0.8125f, 0.875f);
}
public BlockAutoChisel() {
super(Material.rock);
setHardness(1F);
setBlockBounds(0.125f, 0, 0.125f, 0.875f, 0.8125f, 0.875f);
}
@Override
public int getRenderType() {
return Chisel.renderAutoChiselId;
}
@Override
public int getRenderType() {
return Chisel.renderAutoChiselId;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float x1, float y1, float z1) {
TileEntity tile = world.getTileEntity(x, y, z);
if (world.isRemote)
return true;
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float x1,
float y1, float z1) {
TileEntity tile = world.getTileEntity(x, y, z);
if (world.isRemote) return true;
if (tile != null && tile instanceof TileEntityAutoChisel && !player.isSneaking()) {
player.openGui(Chisel.instance, 1, world, x, y, z);
}
if (tile != null && tile instanceof TileEntityAutoChisel && !player.isSneaking()) {
player.openGui(Chisel.instance, 1, world, x, y, z);
}
return true;
}
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6) {
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, block, par6);
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6) {
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, block, par6);
}
private void dropItems(World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
private void dropItems(World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof TileEntityAutoChisel)) {
return;
}
if (!(tileEntity instanceof TileEntityAutoChisel)) {
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++) {
ItemStack stack = inventory.getStackInSlot(c);
if (stack != null) {
dropBlockAsItem(world, x, y, z, stack);
}
}
}
for (int c = 0; c < inventory.getSizeInventory(); c++) {
ItemStack stack = inventory.getStackInSlot(c);
if (stack != null) {
dropBlockAsItem(world, x, y, z, stack);
}
}
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileEntityAutoChisel();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileEntityAutoChisel();
}
}
@@ -8,16 +8,16 @@ import net.minecraft.world.IBlockAccess;
*/
public class BlockBeaconBase extends BlockCarvable {
public BlockBeaconBase() {
super();
}
public BlockBeaconBase() {
super();
}
public BlockBeaconBase(Material mat) {
super(mat);
}
public BlockBeaconBase(Material mat) {
super(mat);
}
@Override
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) {
return true;
}
@Override
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) {
return true;
}
}
+142 -147
View File
@@ -2,181 +2,176 @@ package team.chisel.block;
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.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.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.SideOnly;
import team.chisel.Chisel;
import team.chisel.config.Configurations;
public class BlockCarvable extends Block implements ICarvable {
public CarvableHelper carverHelper;
private boolean isAlpha;
public CarvableHelper carverHelper;
private boolean isAlpha;
public BlockCarvable() {
this(Material.rock);
}
public BlockCarvable() {
this(Material.rock);
}
public BlockCarvable(Material m) {
super(m);
if (m == Material.rock || m == Material.iron) {
setHarvestLevel("pickaxe", 0);
}
carverHelper = new CarvableHelper(this);
setResistance(10.0F);
setHardness(2.0F);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
}
public BlockCarvable(Material m) {
super(m);
if (m == Material.rock || m == Material.iron) {
setHarvestLevel("pickaxe", 0);
}
carverHelper = new CarvableHelper(this);
setResistance(10.0F);
setHardness(2.0F);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
}
public BlockCarvable setStained(boolean a) {
this.isAlpha = a;
return this;
}
public BlockCarvable setStained(boolean a) {
this.isAlpha = a;
return this;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return isAlpha ? 1 : 0;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return isAlpha ? 1 : 0;
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return carverHelper.getIcon(world, x, y, z, side);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return carverHelper.getIcon(world, x, y, z, side);
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons(Chisel.MOD_ID, this, register);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons(Chisel.MOD_ID, this, register);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public IVariationInfo getManager(int 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 soundNameBreak;
public final String soundNamePlace;
public final String soundNameStep;
public final String soundNameBreak;
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
*
* @param soundName
* block of the sound. Will automatically be expanded to "mod:dig.soundName" and "mod:step.soundName" respectively)
* @param volume
* default 1.0f
* @param frequency
* default 1.0f
*/
public SoundType(String soundName, float volume, float frequency) {
super(soundName, volume, frequency);
this.soundNameStep = null;
this.soundNameBreak = null;
this.soundNamePlace = null;
}
/**
* 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 volume default 1.0f
* @param frequency default 1.0f
*/
public SoundType(String soundName, float volume, float frequency) {
super(soundName, volume, frequency);
this.soundNameStep = null;
this.soundNameBreak = null;
this.soundNamePlace = null;
}
/**
* 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 soundNameStep
* block step sound
* @param volume
* default 1.0f
* @param frequency
* default 1.0f
*/
public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) {
super(soundNameStep, volume, frequency);
this.soundNameStep = soundNameStep;
this.soundNameBreak = soundNameBreak;
this.soundNamePlace = null;
}
/**
* 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 soundNameStep block step sound
* @param volume default 1.0f
* @param frequency default 1.0f
*/
public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) {
super(soundNameStep, volume, frequency);
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
*
* @param soundNameBreak
* block break sound
* @param soundNameStep
* block step sound
* @param soundNamePlace
* block place sound
* @param volume
* default 1.0f
* @param frequency
* default 1.0f
*/
public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume, float frequency) {
super(soundNameStep, volume, frequency);
this.soundNameStep = soundNameStep;
this.soundNameBreak = soundNameBreak;
this.soundNamePlace = soundNamePlace;
}
/**
* 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 soundNameStep block step sound
* @param soundNamePlace block place sound
* @param volume default 1.0f
* @param frequency default 1.0f
*/
public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume,
float frequency) {
super(soundNameStep, volume, frequency);
this.soundNameStep = soundNameStep;
this.soundNameBreak = soundNameBreak;
this.soundNamePlace = soundNamePlace;
}
@Override
public String getBreakSound() {
if (soundNameBreak == null)
return Chisel.MOD_ID + ":dig." + this.soundName;
else
return this.soundNameBreak;
}
@Override
public String getBreakSound() {
if (soundNameBreak == null) return Chisel.MOD_ID + ":dig." + this.soundName;
else return this.soundNameBreak;
}
@Override
public String getStepResourcePath() {
if (soundNameStep == null)
return Chisel.MOD_ID + ":step." + this.soundName;
else
return this.soundNameStep;
}
@Override
public String getStepResourcePath() {
if (soundNameStep == null) return Chisel.MOD_ID + ":step." + this.soundName;
else return this.soundNameStep;
}
@Override
public String func_150496_b() {
if (soundNamePlace == null)
return getBreakSound();
else
return this.soundNamePlace;
}
}
@Override
public String func_150496_b() {
if (soundNamePlace == null) return getBreakSound();
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;
import com.cricketcraft.chisel.api.ICarvable;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.IBlockAccess;
import com.cricketcraft.chisel.api.ICarvable;
public class BlockCarvableAntiBlock extends BlockCarvableColor implements ICarvable {
public BlockCarvableAntiBlock() {
super(Material.rock);
}
public BlockCarvableAntiBlock() {
super(Material.rock);
}
@Override
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return false;
}
@Override
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return false;
}
}
@@ -12,87 +12,89 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
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.ICarvable;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
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 static int renderId;
public static int renderId;
public CarvableHelper carverHelper;
public CarvableHelper carverHelper;
public BlockCarvableBeacon() {
super();
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
setLightLevel(5.0F);
setBlockTextureName("beacon");
carverHelper = new CarvableHelper(this);
}
public BlockCarvableBeacon() {
super();
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
setLightLevel(5.0F);
setBlockTextureName("beacon");
carverHelper = new CarvableHelper(this);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityCarvableBeacon();
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityCarvableBeacon();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par5, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return true;
} else {
TileEntityCarvableBeacon tileentitybeacon = (TileEntityCarvableBeacon) world.getTileEntity(x, y, z);
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par5, float hitX,
float hitY, float hitZ) {
if (world.isRemote) {
return true;
} else {
TileEntityCarvableBeacon tileentitybeacon = (TileEntityCarvableBeacon) world.getTileEntity(x, y, z);
if (tileentitybeacon != null) {
player.func_146104_a(tileentitybeacon);
}
if (tileentitybeacon != null) {
player.func_146104_a(tileentitybeacon);
}
return true;
}
}
return true;
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) {
for (int i = 0; i < 16; i++) {
list.add(new ItemStack(item, 1, i));
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) {
for (int i = 0; i < 16; i++) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(ChiselBlocks.beacon, 1, world.getBlockMetadata(x, y, z));
}
@Override
public int damageDropped(int meta) {
return meta;
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(ChiselBlocks.beacon, 1, world.getBlockMetadata(x, y, z));
}
@Override
public int getRenderType() {
return renderId;
}
@Override
public int damageDropped(int meta) {
return meta;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, player, stack);
@Override
public int getRenderType() {
return renderId;
}
if (stack.hasDisplayName()) {
((TileEntityCarvableBeacon) world.getTileEntity(x, y, z)).func_145999_a(stack.getDisplayName());
}
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, player, stack);
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
if (stack.hasDisplayName()) {
((TileEntityCarvableBeacon) world.getTileEntity(x, y, z)).func_145999_a(stack.getDisplayName());
}
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
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.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCarvableBookshelf extends BlockCarvable {
public BlockCarvableBookshelf() {
super(Material.wood);
setHarvestLevel("axe", 0);
}
public BlockCarvableBookshelf() {
super(Material.wood);
setHarvestLevel("axe", 0);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
if (side < 2)
return Blocks.planks.getBlockTextureFromSide(side);
return super.getIcon(side, metadata);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
if (side < 2) return Blocks.planks.getBlockTextureFromSide(side);
return super.getIcon(side, metadata);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
if (side < 2)
return Blocks.planks.getBlockTextureFromSide(side);
return super.getIcon(world, x, y, z, side);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
if (side < 2) return Blocks.planks.getBlockTextureFromSide(side);
return super.getIcon(world, x, y, z, side);
}
@Override
public int quantityDropped(Random random) {
return 3;
}
@Override
public int quantityDropped(Random random) {
return 3;
}
@Override
public Item getItemDropped(int ammount, Random random, int meta) {
return Items.book;
}
@Override
public Item getItemDropped(int ammount, Random random, int meta) {
return Items.book;
}
@Override
public int damageDropped(int damage) {
return 0;
}
@Override
public int damageDropped(int damage) {
return 0;
}
@Override
public int getDamageValue(World world, int x, int y, int z) {
return world.getBlockMetadata(x, y, z);
}
@Override
public int getDamageValue(World world, int x, int y, int z) {
return world.getBlockMetadata(x, y, z);
}
@Override
public float getEnchantPowerBonus(World world, int x, int y, int z) {
return 1;
}
@Override
public float getEnchantPowerBonus(World world, int x, int y, int z) {
return 1;
}
}
@@ -2,11 +2,6 @@ package team.chisel.block;
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.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -15,52 +10,57 @@ import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
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 CarvableHelper carverHelper;
public CarvableHelper carverHelper;
public BlockCarvableCarpet(Material m) {
carverHelper = new CarvableHelper(this);
}
public BlockCarvableCarpet(Material m) {
carverHelper = new CarvableHelper(this);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return carverHelper.getIcon(world, x, y, z, side);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return carverHelper.getIcon(world, x, y, z, side);
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
}
@@ -6,21 +6,21 @@ import net.minecraftforge.common.util.ForgeDirection;
public class BlockCarvableColor extends BlockCarvable {
public BlockCarvableColor() {
this(Material.rock);
}
public BlockCarvableColor() {
this(Material.rock);
}
public BlockCarvableColor(Material m) {
super(m);
}
public BlockCarvableColor(Material m) {
super(m);
}
@Override
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int color) {
int newColor = 15 - color;
if (world.getBlockMetadata(x, y, z) != newColor) {
world.setBlockMetadataWithNotify(x, y, z, newColor, 3);
return true;
}
return false;
}
@Override
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int color) {
int newColor = 15 - color;
if (world.getBlockMetadata(x, y, z) != newColor) {
world.setBlockMetadataWithNotify(x, y, z, newColor, 3);
return true;
}
return false;
}
}
@@ -1,6 +1,8 @@
package team.chisel.block;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockGlass;
@@ -11,7 +13,6 @@ import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import team.chisel.ctmlib.CTM;
import com.cricketcraft.chisel.api.ChiselTabs;
import com.cricketcraft.chisel.api.ICarvable;
@@ -21,87 +22,94 @@ import com.cricketcraft.chisel.api.rendering.ClientUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.ctmlib.CTM;
public class BlockCarvableGlass extends BlockGlass implements ICarvable {
public CarvableHelper carverHelper;
private boolean isAlpha = false;
private CTM ctm = CTM.getInstance();
public CarvableHelper carverHelper;
private boolean isAlpha = false;
private CTM ctm = CTM.getInstance();
public BlockCarvableGlass() {
super(Material.glass, false);
public BlockCarvableGlass() {
super(Material.glass, false);
carverHelper = new CarvableHelper(this);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
}
carverHelper = new CarvableHelper(this);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
}
public BlockCarvableGlass setStained(boolean a) {
this.isAlpha = a;
return this;
}
public BlockCarvableGlass setStained(boolean a) {
this.isAlpha = a;
return this;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isNormalCube() {
return true;
}
@Override
public boolean isNormalCube() {
return true;
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public IIcon getIcon(int side, int 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
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public int damageDropped(int i) {
return i;
}
@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
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@Override
public int damageDropped(int i) {
return i;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return isAlpha ? 1 : 0;
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return isAlpha ? 1 : 0;
}
@Override
public int quantityDropped(Random random) {
return Objects.equals(this.getUnlocalizedName(), "tile.chisel.technical2") ? 1 : 0;
}
}
@@ -1,58 +1,59 @@
package team.chisel.block;
import team.chisel.Chisel;
import team.chisel.client.render.SubmapManagerBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
import team.chisel.client.render.SubmapManagerBase;
public class BlockCarvableGlow extends BlockCarvableColor {
@SideOnly(Side.CLIENT)
private IIcon glowTexture;
@SideOnly(Side.CLIENT)
private IIcon glowTexture;
private SubmapManagerBase submapManagerBase;
private String glowTexturePath;
private SubmapManagerBase submapManagerBase;
private String glowTexturePath;
public BlockCarvableGlow(String glowTexture) {
super();
setLightLevel(0.5f);
this.glowTexturePath = glowTexture;
}
public BlockCarvableGlow(String glowTexture) {
super();
setLightLevel(0.5f);
this.glowTexturePath = glowTexture;
}
public BlockCarvableGlow(Material mat, String glowTexture) {
super(mat);
this.glowTexturePath = glowTexture;
}
public BlockCarvableGlow(Material mat, String glowTexture) {
super(mat);
this.glowTexturePath = glowTexture;
}
public BlockCarvableGlow(Material material, String glowTexture, SubmapManagerBase submapManagerBase) {
super(material);
this.glowTexturePath = glowTexture;
this.submapManagerBase = submapManagerBase;
}
public BlockCarvableGlow(Material material, String glowTexture, SubmapManagerBase submapManagerBase) {
super(material);
this.glowTexturePath = glowTexture;
this.submapManagerBase = submapManagerBase;
}
@Override
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
glowTexture = register.registerIcon(Chisel.MOD_ID + ":" + glowTexturePath);
}
@Override
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
glowTexture = register.registerIcon(Chisel.MOD_ID + ":" + glowTexturePath);
}
public boolean hasSubmapManager() {
return submapManagerBase == null;
}
public boolean hasSubmapManager() {
return submapManagerBase == null;
}
public SubmapManagerBase getSubmapManager() {
return hasSubmapManager() ? submapManagerBase : null;
}
public SubmapManagerBase getSubmapManager() {
return hasSubmapManager() ? submapManagerBase : null;
}
public IIcon getGlowTexture() {
return glowTexture;
}
public IIcon getGlowTexture() {
return glowTexture;
}
@Override
public int getRenderType() {
return Chisel.renderGlowId;
}
@Override
public int getRenderType() {
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 BlockCarvableGlowstone() {
super(Material.glass);
}
public BlockCarvableGlowstone() {
super(Material.glass);
}
@Override
public int quantityDropped(Random random) {
return Blocks.glowstone.quantityDropped(random);
}
@Override
public int quantityDropped(Random random) {
return Blocks.glowstone.quantityDropped(random);
}
@Override
public Item getItemDropped(int i, Random random, int a) {
return Items.glowstone_dust;
}
@Override
public Item getItemDropped(int i, Random random, int a) {
return Items.glowstone_dust;
}
@Override
public int damageDropped(int i) {
return 0;
}
@Override
public int damageDropped(int i) {
return 0;
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
Block glowstone = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
return new ItemStack(Item.getItemFromBlock(glowstone), 1, meta);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
Block glowstone = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
return new ItemStack(Item.getItemFromBlock(glowstone), 1, meta);
}
}
@@ -2,11 +2,6 @@ package team.chisel.block;
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.BlockIce;
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.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 CarvableHelper carverHelper;
public CarvableHelper carverHelper;
public BlockCarvableIce() {
super();
carverHelper = new CarvableHelper(this);
}
public BlockCarvableIce() {
super();
carverHelper = new CarvableHelper(this);
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
par2EntityPlayer.addExhaustion(0.025F);
par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
par2EntityPlayer.addExhaustion(0.025F);
/*
* if(this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack =
* this.createStackedBlock(par6);
*
* if(itemstack != null) { this.dropBlockAsItem(par1World, par3, par4, par5, itemstack); } }
*/
}
/*
* if(this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) &&
* EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack =
* this.createStackedBlock(par6); if(itemstack != null) { this.dropBlockAsItem(par1World, par3, par4, par5,
* itemstack); } }
*/
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
}
@@ -2,44 +2,45 @@ package team.chisel.block;
import java.util.Random;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import team.chisel.init.ChiselBlocks;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import team.chisel.init.ChiselBlocks;
public class BlockCarvableIceStairs extends BlockCarvableStairs {
public BlockCarvableIceStairs(Block block, int meta, CarvableHelper helper) {
super(block, meta, helper);
public BlockCarvableIceStairs(Block block, int meta, CarvableHelper helper) {
super(block, meta, helper);
slipperiness = 0.98F;
setTickRandomly(true);
}
slipperiness = 0.98F;
setTickRandomly(true);
}
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
ChiselBlocks.ice.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
}
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
ChiselBlocks.ice.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
}
@Override
public int quantityDropped(Random par1Random) {
return ChiselBlocks.ice.quantityDropped(par1Random);
}
@Override
public int quantityDropped(Random par1Random) {
return ChiselBlocks.ice.quantityDropped(par1Random);
}
@Override
public int damageDropped(int i) {
return 0;
}
@Override
public int damageDropped(int i) {
return 0;
}
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
ChiselBlocks.ice.updateTick(par1World, par2, par3, par4, par5Random);
}
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
ChiselBlocks.ice.updateTick(par1World, par2, par3, par4, par5Random);
}
@Override
public int getMobilityFlag() {
return 0;
}
@Override
public int getMobilityFlag() {
return 0;
}
}
@@ -11,71 +11,70 @@ import net.minecraft.world.World;
public class BlockCarvableLamp extends BlockCarvable {
BlockCarvableLamp blockUnpowered;
BlockCarvableLamp blockPowered;
boolean powered;
BlockCarvableLamp blockUnpowered;
BlockCarvableLamp blockPowered;
boolean powered;
public BlockCarvableLamp() {
super(Material.redstoneLight);
public BlockCarvableLamp() {
super(Material.redstoneLight);
powered = false;
blockUnpowered = this;
blockPowered = new BlockCarvableLamp(this);
powered = false;
blockUnpowered = this;
blockPowered = new BlockCarvableLamp(this);
setHardness(0.3F);
}
setHardness(0.3F);
}
public BlockCarvableLamp(BlockCarvableLamp unpoweredVersion) {
super(Material.redstoneLight);
public BlockCarvableLamp(BlockCarvableLamp unpoweredVersion) {
super(Material.redstoneLight);
carverHelper = unpoweredVersion.carverHelper;
carverHelper = unpoweredVersion.carverHelper;
powered = true;
blockUnpowered = unpoweredVersion;
blockPowered = this;
powered = true;
blockUnpowered = unpoweredVersion;
blockPowered = this;
setLightLevel(1.0F);
setHardness(0.3F);
}
setLightLevel(1.0F);
setHardness(0.3F);
}
public void checkPower(World world, int x, int y, int z) {
if (world.isRemote)
return;
public void checkPower(World world, int x, int y, int z) {
if (world.isRemote) return;
boolean isGettingPower = world.isBlockIndirectlyGettingPowered(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
boolean isGettingPower = world.isBlockIndirectlyGettingPowered(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (powered && !isGettingPower) {
world.setBlock(x, y, z, blockUnpowered, meta, 2);
} else if (!powered && isGettingPower) {
world.setBlock(x, y, z, blockPowered, meta, 2);
}
}
if (powered && !isGettingPower) {
world.setBlock(x, y, z, blockUnpowered, meta, 2);
} else if (!powered && isGettingPower) {
world.setBlock(x, y, z, blockPowered, meta, 2);
}
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
checkPower(world, x, y, z);
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
checkPower(world, x, y, z);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
checkPower(world, x, y, z);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
checkPower(world, x, y, z);
}
/*
* @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); world.setBlock(x, y, z, Block.redstoneLampIdle.blockID, meta, 2); } }
*/
/*
* @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);
* world.setBlock(x, y, z, Block.redstoneLampIdle.blockID, meta, 2); } }
*/
@Override
public Item getItemDropped(int par1, Random par2Random, int par3) {
return Item.getItemFromBlock(blockUnpowered);
}
@Override
public Item getItemDropped(int par1, Random par2Random, int par3) {
return Item.getItemFromBlock(blockUnpowered);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(blockUnpowered, 1, world.getBlockMetadata(x, y, z));
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(blockUnpowered, 1, world.getBlockMetadata(x, y, z));
}
}
@@ -1,35 +1,36 @@
package team.chisel.block;
import team.chisel.Chisel;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
public class BlockCarvableLayered extends BlockCarvable {
@SideOnly(Side.CLIENT)
private IIcon baseTexture;
private String baseTexLocation;
@SideOnly(Side.CLIENT)
private IIcon baseTexture;
private String baseTexLocation;
public BlockCarvableLayered(Material mat, String baseTexLocation) {
super(mat);
this.baseTexLocation = baseTexLocation;
}
public BlockCarvableLayered(Material mat, String baseTexLocation) {
super(mat);
this.baseTexLocation = baseTexLocation;
}
@Override
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
baseTexture = register.registerIcon(Chisel.MOD_ID + ":" + baseTexLocation);
}
@Override
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
baseTexture = register.registerIcon(Chisel.MOD_ID + ":" + baseTexLocation);
}
public IIcon getBaseTex() {
return baseTexture;
}
public IIcon getBaseTex() {
return baseTexture;
}
@Override
public int getRenderType() {
return Chisel.renderLayeredId;
}
@Override
public int getRenderType() {
return Chisel.renderLayeredId;
}
}
@@ -3,11 +3,6 @@ package team.chisel.block;
import java.util.List;
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.material.Material;
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.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 CarvableHelper carverHelper;
public CarvableHelper carverHelper;
public BlockCarvablePackedIce() {
super(Material.ice);
carverHelper = new CarvableHelper(this);
this.slipperiness = Blocks.packed_ice.slipperiness;
}
public BlockCarvablePackedIce() {
super(Material.ice);
carverHelper = new CarvableHelper(this);
this.slipperiness = Blocks.packed_ice.slipperiness;
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public int quantityDropped(int meta, int fortune, Random random) {
return 0;
}
@Override
public int quantityDropped(int meta, int fortune, Random random) {
return 0;
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
par2EntityPlayer.addExhaustion(0.025F);
par2EntityPlayer.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1);
par2EntityPlayer.addExhaustion(0.025F);
/*
* if(this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) && EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack =
* this.createStackedBlock(par6);
*
* if(itemstack != null) { this.dropBlockAsItem(par1World, par3, par4, par5, itemstack); } }
*/
}
/*
* if(this.canSilkHarvest(par1World, par2EntityPlayer, par3, par4, par5, par6) &&
* EnchantmentHelper.getSilkTouchModifier(par2EntityPlayer)) { ItemStack itemstack =
* this.createStackedBlock(par6); if(itemstack != null) { this.dropBlockAsItem(par1World, par3, par4, par5,
* itemstack); } }
*/
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
}
@@ -2,44 +2,45 @@ package team.chisel.block;
import java.util.Random;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import team.chisel.init.ChiselBlocks;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import team.chisel.init.ChiselBlocks;
public class BlockCarvablePackedIceStairs extends BlockCarvableStairs {
public BlockCarvablePackedIceStairs(Block block, int meta, CarvableHelper helper) {
super(block, meta, helper);
public BlockCarvablePackedIceStairs(Block block, int meta, CarvableHelper helper) {
super(block, meta, helper);
slipperiness = 0.98F;
setTickRandomly(true);
}
slipperiness = 0.98F;
setTickRandomly(true);
}
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
ChiselBlocks.packedice.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
}
@Override
public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) {
ChiselBlocks.packedice.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6);
}
@Override
public int quantityDropped(Random par1Random) {
return ChiselBlocks.packedice.quantityDropped(par1Random);
}
@Override
public int quantityDropped(Random par1Random) {
return ChiselBlocks.packedice.quantityDropped(par1Random);
}
@Override
public int damageDropped(int i) {
return 0;
}
@Override
public int damageDropped(int i) {
return 0;
}
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
ChiselBlocks.packedice.updateTick(par1World, par2, par3, par4, par5Random);
}
@Override
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
ChiselBlocks.packedice.updateTick(par1World, par2, par3, par4, par5Random);
}
@Override
public int getMobilityFlag() {
return 0;
}
@Override
public int getMobilityFlag() {
return 0;
}
}
@@ -2,12 +2,6 @@ package team.chisel.block;
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.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -15,66 +9,73 @@ import net.minecraft.creativetab.CreativeTabs;
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.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.IVariationInfo;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.client.render.RendererCTMPane;
public class BlockCarvablePane extends BlockPane implements ICarvable {
public CarvableHelper carverHelper;
public boolean isAlpha;
public CarvableHelper carverHelper;
public boolean isAlpha;
public BlockCarvablePane(Material material, boolean drops) {
super("", "", material, drops);
public BlockCarvablePane(Material material, boolean drops) {
super("", "", material, drops);
carverHelper = new CarvableHelper(this);
carverHelper = new CarvableHelper(this);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
}
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
}
public BlockCarvablePane setStained(boolean a) {
this.isAlpha = a;
return this;
}
public BlockCarvablePane setStained(boolean a) {
this.isAlpha = a;
return this;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return isAlpha ? 1 : 0;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return isAlpha ? 1 : 0;
}
@Override
public int getRenderType() {
return RendererCTMPane.id;
}
@Override
public int getRenderType() {
return RendererCTMPane.id;
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
}
@@ -5,25 +5,26 @@ import net.minecraft.world.IBlockAccess;
public class BlockCarvablePowered extends BlockCarvable {
public BlockCarvablePowered(Material m) {
super(m);
}
public BlockCarvablePowered(Material m) {
super(m);
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
@Override
public boolean canProvidePower() {
return true;
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
@Override
public boolean canProvidePower() {
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
* 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) {
return 15;
}
/**
* 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 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) {
return 15;
}
}
@@ -1,11 +1,5 @@
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.BlockPumpkin;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -15,111 +9,130 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
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.SideOnly;
import team.chisel.Chisel;
import team.chisel.entity.EntityChiselSnowman;
public class BlockCarvablePumpkin extends BlockPumpkin implements ICarvable {
public CarvableHelper carverHelper;
public CarvableHelper carverHelper;
@SideOnly(Side.CLIENT)
private IIcon top, face;
@SideOnly(Side.CLIENT)
private IIcon top, face;
private String faceLocation;
private String faceLocation;
public BlockCarvablePumpkin(boolean isOn) {
super(isOn);
this.setStepSound(Block.soundTypeWood);
if (isOn)
setLightLevel(10.0F);
carverHelper = new CarvableHelper(this);
}
public BlockCarvablePumpkin(boolean isOn) {
super(isOn);
this.setStepSound(Block.soundTypeWood);
if (isOn) setLightLevel(10.0F);
carverHelper = new CarvableHelper(this);
}
@Override
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.isRemote) {
// Let's grab the pumpkin before we start
ItemStack pumpkin = new ItemStack(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
@Override
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.isRemote) {
// Let's grab the pumpkin before we start
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 - 1, z, Blocks.air, 0, 2);
world.setBlock(x, y - 2, z, Blocks.air, 0, 2);
EntityChiselSnowman snowman = new EntityChiselSnowman(world);
snowman.setCurrentItemOrArmor(2, pumpkin);
snowman.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F);
world.spawnEntityInWorld(snowman);
world.notifyBlockChange(x, y, z, Blocks.air);
world.notifyBlockChange(x, y - 1, z, Blocks.air);
world.notifyBlockChange(x, y - 2, z, Blocks.air);
}
world.setBlock(x, y, 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);
EntityChiselSnowman snowman = new EntityChiselSnowman(world);
snowman.setCurrentItemOrArmor(2, pumpkin);
snowman.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F);
world.spawnEntityInWorld(snowman);
world.notifyBlockChange(x, y, z, Blocks.air);
world.notifyBlockChange(x, y - 1, z, Blocks.air);
world.notifyBlockChange(x, y - 2, z, Blocks.air);
}
// Spawn some lovely particles
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);
}
} 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;
// Spawn some lovely particles
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);
}
} 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) {
world.setBlock(x, y, 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);
if (flag || flag1) {
world.setBlock(x, y, 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);
if (flag) {
world.setBlock(x - 1, y - 1, z, Blocks.air, 0, 2);
world.setBlock(x + 1, y - 1, z, Blocks.air, 0, 2);
} else {
world.setBlock(x, y - 1, z - 1, Blocks.air, 0, 2);
world.setBlock(x, y - 1, z + 1, Blocks.air, 0, 2);
}
if (flag) {
world.setBlock(x - 1, y - 1, z, Blocks.air, 0, 2);
world.setBlock(x + 1, y - 1, z, Blocks.air, 0, 2);
} else {
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);
ironGolem.setPlayerCreated(true);
ironGolem.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F);
world.spawnEntityInWorld(ironGolem);
EntityIronGolem ironGolem = new EntityIronGolem(world);
ironGolem.setPlayerCreated(true);
ironGolem.setLocationAndAngles(x + 0.5D, y - 1.95D, z + 0.5D, 0.0F, 0.0F);
world.spawnEntityInWorld(ironGolem);
world.notifyBlockChange(x, y, z, Blocks.air);
world.notifyBlockChange(x, y - 1, z, Blocks.air);
world.notifyBlockChange(x, y - 2, z, Blocks.air);
world.notifyBlockChange(x, y, z, Blocks.air);
world.notifyBlockChange(x, y - 1, z, Blocks.air);
world.notifyBlockChange(x, y - 2, z, Blocks.air);
if (flag) {
world.notifyBlockChange(x - 1, y - 1, z, Blocks.air);
world.notifyBlockChange(x + 1, y - 1, z, Blocks.air);
} else {
world.notifyBlockChange(x, y - 1, z - 1, Blocks.air);
world.notifyBlockChange(x, y - 1, z + 1, Blocks.air);
}
}
}
}
if (flag) {
world.notifyBlockChange(x - 1, y - 1, z, Blocks.air);
world.notifyBlockChange(x + 1, y - 1, z, Blocks.air);
} else {
world.notifyBlockChange(x, y - 1, z - 1, Blocks.air);
world.notifyBlockChange(x, y - 1, z + 1, Blocks.air);
}
}
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return side == 1 ? top : (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
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return side == 1 ? top
: (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
public void registerBlockIcons(IIconRegister icon) {
top = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_top");
face = icon.registerIcon(Chisel.MOD_ID + ":" + faceLocation);
this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_side");
}
@Override
public void registerBlockIcons(IIconRegister icon) {
top = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_top");
face = icon.registerIcon(Chisel.MOD_ID + ":" + faceLocation);
this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":pumpkin/pumpkin_side");
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
public void setInformation(String textureLocation) {
this.faceLocation = textureLocation;
}
public void setInformation(String textureLocation) {
this.faceLocation = textureLocation;
}
}
@@ -2,13 +2,6 @@ package team.chisel.block;
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.BlockSand;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -16,158 +9,153 @@ import net.minecraft.creativetab.CreativeTabs;
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.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.SideOnly;
import team.chisel.Chisel;
public class BlockCarvableSand extends BlockSand implements ICarvable {
public CarvableHelper carverHelper;
private boolean isAlpha;
public CarvableHelper carverHelper;
private boolean isAlpha;
public BlockCarvableSand() {
super();
carverHelper = new CarvableHelper(this);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
}
public BlockCarvableSand() {
super();
carverHelper = new CarvableHelper(this);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
}
public BlockCarvableSand setStained(boolean a) {
this.isAlpha = a;
return this;
}
public BlockCarvableSand setStained(boolean a) {
this.isAlpha = a;
return this;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return isAlpha ? 1 : 0;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return isAlpha ? 1 : 0;
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return carverHelper.getIcon(world, x, y, z, side);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return carverHelper.getIcon(world, x, y, z, side);
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public int getRenderType() {
return ClientUtils.renderCTMId;
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public IVariationInfo getManager(int 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 soundNameBreak;
public final String soundNamePlace;
public final String soundNameStep;
public final String soundNameBreak;
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
*
* @param soundName
* block of the sound. Will automatically be expanded to "mod:dig.soundName" and "mod:step.soundName" respectively)
* @param volume
* default 1.0f
* @param frequency
* default 1.0f
*/
public SoundType(String soundName, float volume, float frequency) {
super(soundName, volume, frequency);
this.soundNameStep = null;
this.soundNameBreak = null;
this.soundNamePlace = null;
}
/**
* 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 volume default 1.0f
* @param frequency default 1.0f
*/
public SoundType(String soundName, float volume, float frequency) {
super(soundName, volume, frequency);
this.soundNameStep = null;
this.soundNameBreak = null;
this.soundNamePlace = null;
}
/**
* 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 soundNameStep
* block step sound
* @param volume
* default 1.0f
* @param frequency
* default 1.0f
*/
public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) {
super(soundNameStep, volume, frequency);
this.soundNameStep = soundNameStep;
this.soundNameBreak = soundNameBreak;
this.soundNamePlace = null;
}
/**
* 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 soundNameStep block step sound
* @param volume default 1.0f
* @param frequency default 1.0f
*/
public SoundType(String soundNameBreak, String soundNameStep, float volume, float frequency) {
super(soundNameStep, volume, frequency);
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
*
* @param soundNameBreak
* block break sound
* @param soundNameStep
* block step sound
* @param soundNamePlace
* block place sound
* @param volume
* default 1.0f
* @param frequency
* default 1.0f
*/
public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume, float frequency) {
super(soundNameStep, volume, frequency);
this.soundNameStep = soundNameStep;
this.soundNameBreak = soundNameBreak;
this.soundNamePlace = soundNamePlace;
}
/**
* 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 soundNameStep block step sound
* @param soundNamePlace block place sound
* @param volume default 1.0f
* @param frequency default 1.0f
*/
public SoundType(String soundNameBreak, String soundNameStep, String soundNamePlace, float volume,
float frequency) {
super(soundNameStep, volume, frequency);
this.soundNameStep = soundNameStep;
this.soundNameBreak = soundNameBreak;
this.soundNamePlace = soundNamePlace;
}
@Override
public String getBreakSound() {
if (soundNameBreak == null)
return Chisel.MOD_ID + ":dig." + this.soundName;
else
return this.soundNameBreak;
}
@Override
public String getBreakSound() {
if (soundNameBreak == null) return Chisel.MOD_ID + ":dig." + this.soundName;
else return this.soundNameBreak;
}
@Override
public String getStepResourcePath() {
if (soundNameStep == null)
return Chisel.MOD_ID + ":step." + this.soundName;
else
return this.soundNameStep;
}
@Override
public String getStepResourcePath() {
if (soundNameStep == null) return Chisel.MOD_ID + ":step." + this.soundName;
else return this.soundNameStep;
}
@Override
public String func_150496_b() {
if (soundNamePlace == null)
return getBreakSound();
else
return this.soundNamePlace;
}
}
@Override
public String func_150496_b() {
if (soundNamePlace == null) return getBreakSound();
else return this.soundNamePlace;
}
}
}
@@ -1,5 +1,7 @@
package team.chisel.block;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.List;
import java.util.Random;
@@ -14,126 +16,121 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import static net.minecraftforge.common.util.ForgeDirection.UP;
public class BlockCarvableSlab extends BlockCarvable {
public Block master;
public BlockCarvableSlab bottom;
public BlockCarvableSlab top;
public boolean isBottom;
public Block master;
public BlockCarvableSlab bottom;
public BlockCarvableSlab top;
public boolean isBottom;
public BlockCarvableSlab(BlockCarvable marble) {
opaque = true;
public BlockCarvableSlab(BlockCarvable marble) {
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;
bottom = this;
top = new BlockCarvableSlab(this);
master = marble;
bottom = this;
top = new BlockCarvableSlab(this);
isBottom = true;
}
isBottom = true;
}
public BlockCarvableSlab(BlockCarvableSlab bottomBlock) {
super();
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
master = bottomBlock.master;
bottom = bottomBlock;
top = this;
public BlockCarvableSlab(BlockCarvableSlab bottomBlock) {
super();
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
master = bottomBlock.master;
bottom = bottomBlock;
top = this;
carverHelper = bottomBlock.carverHelper;
isBottom = false;
}
carverHelper = bottomBlock.carverHelper;
isBottom = false;
}
@Override
public Block setBlockName(String p_149663_1_) {
if (this != top) {
top.setBlockName(p_149663_1_);
}
return super.setBlockName(p_149663_1_);
}
@Override
public Block setBlockName(String p_149663_1_) {
if (this != top) {
top.setBlockName(p_149663_1_);
}
return super.setBlockName(p_149663_1_);
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
if (isBottom) {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
} else {
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
if (isBottom) {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
} else {
setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
@Override
public void setBlockBoundsForItemRender() {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
@Override
public void setBlockBoundsForItemRender() {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
@SuppressWarnings("rawtypes")
@Override
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {
setBlockBoundsBasedOnState(par1World, par2, par3, par4);
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
@SuppressWarnings("rawtypes")
@Override
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB,
List par6List, Entity par7Entity) {
setBlockBoundsBasedOnState(par1World, par2, par3, par4);
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int damageDropped(int meta) {
return meta;
}
@Override
public int damageDropped(int meta) {
return meta;
}
@Override
public Item getItemDropped(int par1, Random par2Random, int par3) {
return Item.getItemFromBlock(bottom);
}
@Override
public Item getItemDropped(int par1, Random par2Random, int par3) {
return Item.getItemFromBlock(bottom);
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public ItemStack getPickBlock(MovingObjectPosition mop, World world, int x, int y, int z) {
return new ItemStack(bottom, 1, world.getBlockMetadata(x, y, z));
}
@Override
@SideOnly(Side.CLIENT)
public ItemStack getPickBlock(MovingObjectPosition mop, World world, int x, int y, int z) {
return new ItemStack(bottom, 1, world.getBlockMetadata(x, y, z));
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
// return master.getIcon(side, metadata);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
// return master.getIcon(side, metadata);
}
@SuppressWarnings("rawtypes")
@Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
if (isBottom)
super.getSubBlocks(block, tabs, list);
}
@SuppressWarnings("rawtypes")
@Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
if (isBottom) super.getSubBlocks(block, tabs, list);
}
/**
* Checks if the block is a solid face on the given side, used by placement logic.
*
* @param world
* The current world
* @param x
* X Position
* @param y
* Y position
* @param z
* Z position
* @param side
* The side to check
* @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);
}
/**
* Checks if the block is a solid face on the given side, used by placement logic.
*
* @param world The current world
* @param x X Position
* @param y Y position
* @param z Z position
* @param side The side to check
* @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 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.BlockStairs;
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.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 {
CarvableHelper carverHelper;
int blockMeta;
CarvableHelper carverHelper;
int blockMeta;
public BlockCarvableStairs(Block block, int meta, CarvableHelper helper) {
super(block, meta);
public BlockCarvableStairs(Block block, int meta, CarvableHelper helper) {
super(block, meta);
this.useNeighborBrightness = true;
carverHelper = helper;
blockMeta = meta;
}
this.useNeighborBrightness = true;
carverHelper = helper;
blockMeta = meta;
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, blockMeta + metadata / 8);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, blockMeta + metadata / 8);
}
@Override
public int damageDropped(int i) {
return i / 8;
}
@Override
public int damageDropped(int i) {
return i / 8;
}
@Override
public void registerBlockIcons(IIconRegister register) {
if (blockMeta == 0)
carverHelper.registerBlockIcons("Chisel", this, register);
}
@Override
public void registerBlockIcons(IIconRegister register) {
if (blockMeta == 0) carverHelper.registerBlockIcons("Chisel", this, register);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
list.add(new ItemStack(block, 1, 0));
list.add(new ItemStack(block, 1, 8));
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
list.add(new ItemStack(block, 1, 0));
list.add(new ItemStack(block, 1, 8));
}
@Override
public int getRenderType() {
return RendererStairs.id;
}
@Override
public int getRenderType() {
return RendererStairs.id;
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack) {
int meta = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving,
ItemStack par6ItemStack) {
int meta = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
// 0->2 2->3 3->0 1->1
meta = meta == 0 ? 2 : meta == 2 ? 3 : meta == 3 ? 0 : 1;
// 0->2 2->3 3->0 1->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) {
meta += 8;
}
if (par6ItemStack.getItemDamage() >= 8) {
meta += 8;
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, meta, 2);
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, meta, 2);
}
@Override
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;
}
@Override
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;
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(blockMeta + (metadata / 8));
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(blockMeta + (metadata / 8));
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(blockMeta + (meta / 8));
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(blockMeta + (meta / 8));
}
}
@@ -2,83 +2,85 @@ package team.chisel.block;
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.client.renderer.texture.IIconRegister;
import net.minecraft.world.IBlockAccess;
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.SideOnly;
import team.chisel.Chisel;
public class BlockCarvableTorch extends BlockTorch implements ICarvable {
public CarvableHelper carverHelper;
private String texLocation;
protected boolean emitsParticles = true;
public int idx;
public CarvableHelper carverHelper;
private String texLocation;
protected boolean emitsParticles = true;
public int idx;
public BlockCarvableTorch(int idx, String tex) {
super();
carverHelper = new CarvableHelper(this);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
setLightLevel(0.9375F);
setBlockName("torch");
this.idx = idx;
this.texLocation = tex;
}
public BlockCarvableTorch(int idx, String tex) {
super();
carverHelper = new CarvableHelper(this);
setCreativeTab(ChiselTabs.tabOtherChiselBlocks);
setLightLevel(0.9375F);
setBlockName("torch");
this.idx = idx;
this.texLocation = tex;
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public void registerBlockIcons(IIconRegister icon) {
this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":torch/" + texLocation);
}
@Override
public void registerBlockIcons(IIconRegister icon) {
this.blockIcon = icon.registerIcon(Chisel.MOD_ID + ":torch/" + texLocation);
}
public BlockCarvableTorch disableParticles() {
this.emitsParticles = false;
return this;
}
public BlockCarvableTorch disableParticles() {
this.emitsParticles = false;
return this;
}
@Override
@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_) {
if (emitsParticles) {
int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_);
double d0 = p_149734_2_ + 0.5F;
double d1 = p_149734_3_ + 0.7F;
double d2 = p_149734_4_ + 0.5F;
double d3 = 0.2199999988079071D;
double d4 = 0.27000001072883606D;
@Override
@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_) {
if (emitsParticles) {
int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_);
double d0 = p_149734_2_ + 0.5F;
double d1 = p_149734_3_ + 0.7F;
double d2 = p_149734_4_ + 0.5F;
double d3 = 0.2199999988079071D;
double d4 = 0.27000001072883606D;
if (l == 1) {
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);
} else if (l == 2) {
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);
} else if (l == 3) {
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);
} else if (l == 4) {
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);
} else {
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);
}
}
}
}
if (l == 1) {
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);
} else if (l == 2) {
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);
} else if (l == 3) {
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);
} else if (l == 4) {
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);
} else {
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);
}
}
}
}
@@ -2,8 +2,6 @@ package team.chisel.block;
import java.util.List;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockWall;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -11,34 +9,36 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
public class BlockCarvableWall extends BlockWall {
CarvableHelper carverHelper;
CarvableHelper carverHelper;
public BlockCarvableWall(Block block) {
super(block);
public BlockCarvableWall(Block block) {
super(block);
carverHelper = new CarvableHelper(this);
}
carverHelper = new CarvableHelper(this);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@Override
public void registerBlockIcons(IIconRegister register) {
carverHelper.registerBlockIcons("Chisel", this, register);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
}
+48 -47
View File
@@ -2,7 +2,6 @@ package team.chisel.block;
import java.util.Random;
import team.chisel.config.Configurations;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
@@ -10,65 +9,67 @@ import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.config.Configurations;
public class BlockCloud extends BlockCarvable {
public BlockCloud() {
super(Material.ice);
useNeighborBrightness = true;
}
public BlockCloud() {
super(Material.ice);
useNeighborBrightness = true;
}
@Override
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) {
entity.fallDistance = 0.0F;
@Override
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) {
entity.fallDistance = 0.0F;
if (entity.motionY < 0.0D) {
entity.motionY *= 0.0050000000000000001D;
} else if (entity.motionY > 0) {
entity.motionY += 0.0285;
}
}
if (entity.motionY < 0.0D) {
entity.motionY *= 0.0050000000000000001D;
} else if (entity.motionY > 0) {
entity.motionY += 0.0285;
}
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderBlockPass() {
return Configurations.ghostCloud ? 1 : 0;
}
@Override
public int getRenderBlockPass() {
return Configurations.ghostCloud ? 1 : 0;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
Block block = world.getBlock(x, y, z);
if (block == this) {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
Block block = world.getBlock(x, y, z);
if (block == this) {
return false;
}
return super.shouldSideBeRendered(world, x, y, z, side);
}
return super.shouldSideBeRendered(world, x, y, z, side);
}
@Override
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);
}
@Override
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);
}
@Override
public Item getItemDropped(int par1, Random rand, int par3) {
return Item.getItemFromBlock(this);
}
@Override
public Item getItemDropped(int par1, Random rand, int par3) {
return Item.getItemFromBlock(this);
}
@Override
public int quantityDropped(Random rand) {
return rand.nextInt(2);
}
@Override
public int quantityDropped(Random rand) {
return rand.nextInt(2);
}
@Override
public int damageDropped(int meta) {
return meta;
}
@Override
public int damageDropped(int meta) {
return meta;
}
}
@@ -6,40 +6,48 @@ import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovementInput;
import net.minecraft.util.MovementInputFromOptions;
import team.chisel.config.Configurations;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.config.Configurations;
public class BlockConcrete extends BlockCarvable {
public BlockConcrete() {
super();
FMLCommonHandler.instance().bus().register(this);
}
public BlockConcrete() {
super();
FMLCommonHandler.instance()
.bus()
.register(this);
}
@SideOnly(Side.CLIENT)
private static MovementInput manualInputCheck;
@SideOnly(Side.CLIENT)
private static MovementInput manualInputCheck;
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void speedupPlayer(PlayerTickEvent event) {
if (event.phase == Phase.START && event.side.isClient() && event.player.onGround && event.player instanceof EntityPlayerSP) {
if (manualInputCheck == null) {
manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings);
}
EntityPlayerSP player = (EntityPlayerSP) event.player;
Block below = player.worldObj.getBlock(MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY) - 2, 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;
}
}
}
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void speedupPlayer(PlayerTickEvent event) {
if (event.phase == Phase.START && event.side.isClient()
&& event.player.onGround
&& event.player instanceof EntityPlayerSP) {
if (manualInputCheck == null) {
manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings);
}
EntityPlayerSP player = (EntityPlayerSP) event.player;
Block below = player.worldObj.getBlock(
MathHelper.floor_double(player.posX),
MathHelper.floor_double(player.posY) - 2,
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 BlockEldritch() {
super();
}
public BlockEldritch() {
super();
}
@Override
public int getRenderType() {
return Chisel.renderEldritchId;
}
@Override
public int getRenderType() {
return Chisel.renderEldritchId;
}
}
@@ -2,33 +2,33 @@ package team.chisel.block;
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.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
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 IIcon iconStar;
public IIcon iconStar;
public BlockGrimstone(Material m) {
super(m);
}
public BlockGrimstone(Material m) {
super(m);
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (General.rand.nextInt(4) == 0 && world.isRemote)
GeneralChiselClient.spawnGrimstoneFX(world, this, x, y, z);
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (General.rand.nextInt(4) == 0 && world.isRemote) GeneralChiselClient.spawnGrimstoneFX(world, this, x, y, z);
}
@Override
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
@Override
public void registerBlockIcons(IIconRegister 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 team.chisel.client.GeneralChiselClient;
import team.chisel.utils.General;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import team.chisel.client.GeneralChiselClient;
import team.chisel.utils.General;
public class BlockHolystone extends BlockCarvable {
public IIcon iconStar;
public IIcon iconStar;
public BlockHolystone(Material m) {
super(m);
public BlockHolystone(Material m) {
super(m);
this.setLightLevel(0.25F);
}
this.setLightLevel(0.25F);
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (General.rand.nextInt(4) == 0 && world.isRemote)
GeneralChiselClient.spawnHolystoneFX(world, this, x, y, z);
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (General.rand.nextInt(4) == 0 && world.isRemote) GeneralChiselClient.spawnHolystoneFX(world, this, x, y, z);
}
@Override
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
@Override
public void registerBlockIcons(IIconRegister 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 team.chisel.client.GeneralChiselClient;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;
import team.chisel.client.GeneralChiselClient;
public class BlockLavastone extends BlockMultiLayer {
public BlockLavastone(Material mat, String baseIcon) {
super(mat, baseIcon);
setLightLevel(1F);
}
public BlockLavastone(Material mat, String baseIcon) {
super(mat, baseIcon);
setLightLevel(1F);
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (random.nextInt(8) == 0 && world.isRemote)
GeneralChiselClient.spawnLavastoneFX(world, this, x, y, z);
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (random.nextInt(8) == 0 && world.isRemote) GeneralChiselClient.spawnLavastoneFX(world, this, x, y, z);
}
@Override
public boolean renderAsNormalBlock() {
return true;
}
@Override
public boolean renderAsNormalBlock() {
return true;
}
}
@@ -5,12 +5,12 @@ import net.minecraft.init.Blocks;
public class BlockLeaf extends BlockCarvable {
public BlockLeaf(Material material) {
super(material);
}
public BlockLeaf(Material material) {
super(material);
}
@Override
public boolean isOpaqueCube() {
return Blocks.leaves.isOpaqueCube();
}
@Override
public boolean isOpaqueCube() {
return Blocks.leaves.isOpaqueCube();
}
}
@@ -2,10 +2,6 @@ package team.chisel.block;
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.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -14,52 +10,56 @@ import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
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 CarvableHelper carverHelper;
public CarvableHelper carverHelper;
public BlockMultiLayer(Material mat, String baseIcon) {
super(mat, baseIcon);
public BlockMultiLayer(Material mat, String baseIcon) {
super(mat, baseIcon);
carverHelper = new CarvableHelper(this);
}
carverHelper = new CarvableHelper(this);
}
public BlockMultiLayer(Material mat, Block block) {
super(mat, block);
public BlockMultiLayer(Material mat, Block block) {
super(mat, block);
carverHelper = new CarvableHelper(this);
}
carverHelper = new CarvableHelper(this);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public IIcon getIcon(int side, int metadata) {
return carverHelper.getIcon(side, metadata);
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
public int damageDropped(int i) {
return i;
}
@Override
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
@Override
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
carverHelper.registerBlockIcons("Chisel", this, register);
}
carverHelper.registerBlockIcons("Chisel", this, register);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item block, CreativeTabs tabs, List list) {
carverHelper.registerSubBlocks(this, tabs, list);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
}
@@ -1,55 +1,55 @@
package team.chisel.block;
import team.chisel.client.render.RendererMultiLayer;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.ForgeHooksClient;
import team.chisel.client.render.RendererMultiLayer;
public abstract class BlockMultiLayerBase extends Block {
public Block base;
public IIcon icon;
String iconFile;
public Block base;
public IIcon icon;
String iconFile;
public BlockMultiLayerBase(Material mat, Block base) {
super(mat);
public BlockMultiLayerBase(Material mat, Block base) {
super(mat);
this.base = base;
}
this.base = base;
}
public BlockMultiLayerBase(Material mat, String iconFile) {
super(mat);
public BlockMultiLayerBase(Material mat, String iconFile) {
super(mat);
this.iconFile = iconFile;
}
this.iconFile = iconFile;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType() {
return RendererMultiLayer.id;
}
@Override
public int getRenderType() {
return RendererMultiLayer.id;
}
@Override
public int getRenderBlockPass() {
return 1;
}
@Override
public int getRenderBlockPass() {
return 1;
}
@Override
public boolean canRenderInPass(int pass) {
ForgeHooksClient.setRenderPass(pass);
return pass == 1 || pass == 0;
}
@Override
public boolean canRenderInPass(int pass) {
ForgeHooksClient.setRenderPass(pass);
return pass == 1 || pass == 0;
}
@Override
public void registerBlockIcons(IIconRegister register) {
if (iconFile != null)
icon = register.registerIcon(iconFile);
}
@Override
public void registerBlockIcons(IIconRegister register) {
if (iconFile != null) icon = register.registerIcon(iconFile);
}
}
+189 -176
View File
@@ -2,12 +2,6 @@ package team.chisel.block;
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.material.Material;
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.World;
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.SideOnly;
import team.chisel.Chisel;
import team.chisel.block.tileentity.TileEntityPresent;
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() {
super(Material.wood);
carverHelper = new CarvableHelper(this);
minX = 0.0625F;
minZ = 0.0625F;
maxX = 0.9375F;
maxY = 0.875F;
maxZ = 0.9375F;
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
public BlockPresent() {
super(Material.wood);
carverHelper = new CarvableHelper(this);
minX = 0.0625F;
minZ = 0.0625F;
maxX = 0.9375F;
maxY = 0.875F;
maxZ = 0.9375F;
setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
public String getModelTexture(int type) {
return "textures/blocks/present/presentChest" + type;
}
public String getModelTexture(int type) {
return "textures/blocks/present/presentChest" + type;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 16; i++) {
list.add(new ItemStack(item, 1, i));
}
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 16; i++) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType() {
return -1;
}
@Override
public int getRenderType() {
return -1;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, player, stack);
int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3);
te.setRotation(heading);
te.findConnections();
if (te.isConnected()) {
TileEntityPresent other = te.getConnection();
other.setRotation(heading);
}
world.markBlockForUpdate(x, y, z);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
super.onBlockPlacedBy(world, x, y, z, player, stack);
int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
world.setBlockMetadataWithNotify(x, y, z, stack.getItemDamage(), 3);
te.setRotation(heading);
te.findConnections();
if (te.isConnected()) {
TileEntityPresent other = te.getConnection();
other.setRotation(heading);
}
world.markBlockForUpdate(x, y, z);
}
@Override
public void breakBlock(World world, int x, int y, int z, Block present, int meta) {
@Override
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) {
for (int c = 0; c < tileEntityPresent.getTrueSizeInventory(); c++) {
ItemStack itemStack = tileEntityPresent.getTrueStackInSlot(c);
if (tileEntityPresent != null) {
for (int c = 0; c < tileEntityPresent.getTrueSizeInventory(); c++) {
ItemStack itemStack = tileEntityPresent.getTrueStackInSlot(c);
if (itemStack != null) {
dropBlockAsItem(world, x, y, z, itemStack);
}
}
if (itemStack != null) {
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
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitX, float hitY, float hitZ, float p_149727_9_) {
if (!world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) {
if (!world.isRemote) {
player.openGui(Chisel.instance, 2, world, x, y, z);
}
return true;
}
return false;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitX, float hitY,
float hitZ, float p_149727_9_) {
if (!world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) {
if (!world.isRemote) {
player.openGui(Chisel.instance, 2, world, x, y, z);
}
return true;
}
return false;
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
if (world.getTileEntity(x, y, z) instanceof TileEntityPresent)
return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z));
else
return null;
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
if (world.getTileEntity(x, y, z) instanceof TileEntityPresent)
return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z));
else return null;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
if (world.getTileEntity(x, y, z) instanceof TileEntityPresent)
return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z));
else
return null;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
if (world.getTileEntity(x, y, z) instanceof TileEntityPresent)
return getBoundingBox((TileEntityPresent) world.getTileEntity(x, y, z));
else return null;
}
public AxisAlignedBB getBoundingBox(TileEntityPresent me) {
if (me == null) {
return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
int x = me.xCoord, y = me.yCoord, z = me.zCoord;
if (me.isConnected()) {
ForgeDirection dir = me.getConnectionDir();
// warning: magic below! Do not change this conditional
if (dir == ForgeDirection.EAST || (me.isParent() && dir == ForgeDirection.SOUTH) || (!me.isParent() && dir == ForgeDirection.SOUTH)) {
return AxisAlignedBB.getBoundingBox(x + minX, y + minY, z + minZ, 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);
}
public AxisAlignedBB getBoundingBox(TileEntityPresent me) {
if (me == null) {
return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
int x = me.xCoord, y = me.yCoord, z = me.zCoord;
if (me.isConnected()) {
ForgeDirection dir = me.getConnectionDir();
// warning: magic below! Do not change this conditional
if (dir == ForgeDirection.EAST || (me.isParent() && dir == ForgeDirection.SOUTH)
|| (!me.isParent() && dir == ForgeDirection.SOUTH)) {
return AxisAlignedBB.getBoundingBox(
x + minX,
y + minY,
z + minZ,
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
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
if (!te.isConnected()) {
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
} else {
ForgeDirection dir = te.getConnectionDir();
switch (dir) {
case EAST:
setBlockBounds(0.0625F, 0, 0.0625F, 1, 0.875F, 0.9365F);
break;
case NORTH:
setBlockBounds(0.0625F, 0, 0, 0.9375F, 0.875F, 0.9365F);
break;
case SOUTH:
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 1);
break;
case WEST:
setBlockBounds(0, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
break;
default:
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
break;
}
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntityPresent te = (TileEntityPresent) world.getTileEntity(x, y, z);
if (!te.isConnected()) {
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
} else {
ForgeDirection dir = te.getConnectionDir();
switch (dir) {
case EAST:
setBlockBounds(0.0625F, 0, 0.0625F, 1, 0.875F, 0.9365F);
break;
case NORTH:
setBlockBounds(0.0625F, 0, 0, 0.9375F, 0.875F, 0.9365F);
break;
case SOUTH:
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 1);
break;
case WEST:
setBlockBounds(0, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
break;
default:
setBlockBounds(0.0625F, 0, 0.0625F, 0.9375F, 0.875F, 0.9365F);
break;
}
}
}
@Override
public boolean hasTileEntity(int metadata) {
return true;
}
@Override
public boolean hasTileEntity(int metadata) {
return true;
}
@Override
public TileEntity createTileEntity(World world, int metadata) {
return new TileEntityPresent();
}
@Override
public TileEntity createTileEntity(World world, int metadata) {
return new TileEntityPresent();
}
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int strength) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityPresent) {
return Container.calcRedstoneFromInventory((TileEntityPresent) te);
}
return 0;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int strength) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityPresent) {
return Container.calcRedstoneFromInventory((TileEntityPresent) te);
}
return 0;
}
@Override
public int damageDropped(int meta) {
return meta;
}
@Override
public int damageDropped(int meta) {
return meta;
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
return new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
this.blockIcon = register.registerIcon("planks_oak");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
this.blockIcon = register.registerIcon("planks_oak");
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(IBlockAccess world, int x, int y, int z, int metadata) {
return carverHelper.getVariation(metadata);
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
}
@Override
public IVariationInfo getManager(int meta) {
return carverHelper.getVariation(meta);
}
}
@@ -1,7 +1,5 @@
package team.chisel.block;
import team.chisel.Chisel;
import team.chisel.config.Configurations;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -10,83 +8,87 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import team.chisel.Chisel;
import team.chisel.config.Configurations;
public class BlockRoadLine extends BlockCarvable {
public IIcon aloneIcon[] = new IIcon[4];
public IIcon halfLineIcon[] = new IIcon[4];
public IIcon fullLineIcon[] = new IIcon[4];
public IIcon aloneIcon[] = new IIcon[5];
public IIcon halfLineIcon[] = new IIcon[5];
public IIcon fullLineIcon[] = new IIcon[5];
public BlockRoadLine() {
super(Material.circuits);
public BlockRoadLine() {
super(Material.circuits);
if (Configurations.useRoadLineTool) {
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.0625F, 1.0F);
}
if (Configurations.useRoadLineTool) {
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.0625F, 1.0F);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
return null;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
return null;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType() {
return Chisel.roadLineId;
}
@Override
public int getRenderType() {
return Chisel.roadLineId;
}
@Override
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);
}
@Override
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);
}
@Override
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block block) {
if (par1World.isRemote)
return;
@Override
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block block) {
if (par1World.isRemote) return;
if (!this.canPlaceBlockAt(par1World, par2, par3, par4)) {
this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
par1World.setBlockToAir(par2, par3, par4);
}
if (!this.canPlaceBlockAt(par1World, par2, par3, par4)) {
this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
par1World.setBlockToAir(par2, par3, par4);
}
super.onNeighborBlockChange(par1World, par2, par3, par4, block);
}
super.onNeighborBlockChange(par1World, par2, par3, par4, block);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
for (int i = 0; i < 4; i++) {
String[] texNames = { "white", "yellow", "double-white", "double-yellow" };
aloneIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-center");
halfLineIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-side");
fullLineIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-long");
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
for (int i = 0; i < 5; i++) {
String[] texNames = { "white", "yellow", "double-white", "double-yellow", "warning" };
aloneIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-center");
halfLineIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-side");
fullLineIcon[i] = reg.registerIcon("Chisel:line-marking/" + texNames[i] + "-long");
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return aloneIcon[metadata % aloneIcon.length];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return aloneIcon[metadata % aloneIcon.length];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
return getIcon(side, world.getBlockMetadata(x, y, z));
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
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 team.chisel.client.GeneralChiselClient;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import team.chisel.client.GeneralChiselClient;
public class BlockSnakestoneObsidian extends BlockSnakestone {
public static IIcon[] particles = new IIcon[8];
public static IIcon[] particles = new IIcon[8];
public BlockSnakestoneObsidian(String iconPrefix) {
super(iconPrefix);
public BlockSnakestoneObsidian(String iconPrefix) {
super(iconPrefix);
flipTopTextures = true;
flipTopTextures = true;
}
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
GeneralChiselClient.spawnSnakestoneObsidianFX(world, this, x, y, z);
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
GeneralChiselClient.spawnSnakestoneObsidianFX(world, this, x, y, z);
}
@Override
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
@Override
public void registerBlockIcons(IIconRegister register) {
super.registerBlockIcons(register);
for (int i = 0; i < particles.length; i++) {
particles[i] = register.registerIcon(iconPrefix + "particles/" + i);
}
}
for (int i = 0; i < particles.length; i++) {
particles[i] = register.registerIcon(iconPrefix + "particles/" + i);
}
}
}
@@ -4,12 +4,12 @@ import net.minecraft.block.material.Material;
public class BlockWaterstone extends BlockMultiLayer {
public BlockWaterstone(Material mat, String baseIcon) {
super(mat, baseIcon);
}
public BlockWaterstone(Material mat, String baseIcon) {
super(mat, baseIcon);
}
@Override
public boolean renderAsNormalBlock() {
return true;
}
@Override
public boolean renderAsNormalBlock() {
return true;
}
}
@@ -2,41 +2,49 @@ package team.chisel.block;
import net.minecraft.block.Block;
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.carving.CarvableHelper;
import com.cricketcraft.chisel.api.carving.CarvingUtils;
import cpw.mods.fml.common.registry.GameRegistry;
import team.chisel.carving.Carving;
import team.chisel.item.ItemCarvable;
public class CarvableStairsMaker {
public final CarvableHelper carverHelper;
private Block blockBase;
public final CarvableHelper carverHelper;
private Block blockBase;
public CarvableStairsMaker(Block base) {
blockBase = base;
carverHelper = new CarvableHelper(base);
}
public CarvableStairsMaker(Block base) {
blockBase = base;
carverHelper = new CarvableHelper(base);
}
public void create(String name, Block[] blocks) {
create(null, name, blocks);
}
public void create(String name, Block[] blocks) {
create(null, name, blocks);
}
public void create(IStairsCreator creator, String name, Block[] blocks) {
for (int i = 0; i < blocks.length; i++) {
String n = name + "." + i;
blocks[i] = creator == null ? new BlockCarvableStairs(blockBase, i * 2, carverHelper) : creator.create(blockBase, i * 2, carverHelper);
public void create(IStairsCreator creator, String name, Block[] blocks) {
for (int i = 0; i < blocks.length; i++) {
String n = name + "." + i;
blocks[i] = creator == null ? new BlockCarvableStairs(blockBase, i * 2, carverHelper)
: creator.create(blockBase, i * 2, carverHelper);
blocks[i].setBlockName("chisel." + n).setCreativeTab(ChiselTabs.tabStairChiselBlocks);
GameRegistry.registerBlock(blocks[i], ItemCarvable.class, n);
blocks[i].setBlockName("chisel." + n)
.setCreativeTab(ChiselTabs.tabStairChiselBlocks);
GameRegistry.registerBlock(blocks[i], ItemCarvable.class, n);
for (int meta = 0; meta < 2 && i * 2 + meta < carverHelper.infoList.size(); meta++) {
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));
}
}
}
for (int meta = 0; meta < 2 && i * 2 + meta < carverHelper.infoList.size(); meta++) {
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));
}
}
}
}
@@ -1,10 +1,10 @@
package team.chisel.block;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
import net.minecraft.block.Block;
import com.cricketcraft.chisel.api.carving.CarvableHelper;
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 {
/**
* @return The size of this specific chest's inventory. Does not account for the connection.
*/
int getTrueSizeInventory();
/**
* @return The size of this specific chest's inventory. Does not account for the connection.
*/
int getTrueSizeInventory();
/**
* @param slot
* The true slot index.
* @return The actual stack in this chest's slot. Does not account for the connection.
*/
ItemStack getTrueStackInSlot(int slot);
/**
* @param slot The true slot index.
* @return The actual stack in this chest's slot. Does not account for the connection.
*/
ItemStack getTrueStackInSlot(int slot);
/**
* Puts a stack in this chest's real slot at the given true index.
*
* @param slot
* The true slot index.
* @param stack
* The ItemStack to place in the slot.
*/
void putStackInTrueSlot(int slot, ItemStack stack);
/**
* Puts a stack in this chest's real slot at the given true index.
*
* @param slot The true slot index.
* @param stack The ItemStack to place in the slot.
*/
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.util.EnumChatFormatting;
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.carving.Carving;
import team.chisel.client.GeneralChiselClient;
@@ -23,444 +28,457 @@ import team.chisel.network.message.MessageAutoChisel;
import team.chisel.network.message.MessageSlotUpdate;
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 enum Upgrade {
SPEED,
AUTOMATION,
STACK,
REVERSION;
public String getUnlocalizedName() {
if (Features.AUTO_CHISEL_UPGRADES.enabled()) {
return "item.upgrade_" + this.name().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()) {
ret = EnumChatFormatting.RED.toString().concat(ret);
}
return 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;
private int progress = 0;
private static EntityItem ghostItem;
boolean equal = false;
private ItemStack[] inventory = new ItemStack[8];
private String name = "autoChisel";
// client animation fields
// used for floating target
public float xRot, yRot, zRot;
// used for chisel item rotation
public static final int maxRot = 60;
public static final int rotAmnt = 15;
public float chiselRot;
public boolean chiseling = false, breakChisel = false;;
public int toChisel = 1;
private ItemStack lastBase;
@Override
public boolean canUpdate() {
return true;
}
@Override
public ItemStack decrStackSize(int slot, int size) {
if (inventory[slot] != null) {
ItemStack is;
if (inventory[slot].stackSize <= size) {
is = inventory[slot];
inventory[slot] = null;
return is;
} else {
is = inventory[slot].splitStack(size);
if (inventory[slot].stackSize == 0)
inventory[slot] = null;
return is;
}
} else {
return null;
}
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
NBTTagList tags = nbt.getTagList("Items", 10);
inventory = new ItemStack[getSizeInventory()];
for (int i = 0; i < tags.tagCount(); i++) {
NBTTagCompound data = tags.getCompoundTagAt(i);
int j = data.getByte("Slot") & 255;
if (j >= 0 && j < inventory.length) {
inventory[j] = ItemStack.loadItemStackFromNBT(data);
}
}
if (nbt.hasKey("CustomName", 8)) {
this.name = nbt.getString("CustomName");
}
}
@Override
public void updateEntity() {
ItemStack base = inventory[BASE], target = getTarget(), output = inventory[OUTPUT];
if (!worldObj.isRemote && hasChisel() && base != null && target != null) {
if (canBeMadeFrom(base, target)) {
if (progress >= (hasUpgrade(Upgrade.SPEED) ? FAST_SPEED : SLOW_SPEED)) {
// reset progress
progress = 0;
// the max possible for this craft
int canBeMade = target.getMaxStackSize();
// if there are items in the output, they count towards the max we can make
if (output != null) {
canBeMade -= output.stackSize;
}
// can't make more than we have
canBeMade = Math.min(base.stackSize, canBeMade);
// if we can't make any, forget it
if (canBeMade <= 0) {
return;
}
// result will always be a copy of the target
ItemStack chiseled = target.copy();
// if we have the stack upgrade, boost the stack size to the max possible, otherwise just one
chiseled.stackSize = hasUpgrade(Upgrade.STACK) ? canBeMade : 1;
if (canChisel(chiseled)) {
// if our output is empty, just use the current result
if (output == null) {
setInventorySlotContents(OUTPUT, chiseled);
} else {
// otherwise just add our result to the existing stack
inventory[OUTPUT].stackSize += chiseled.stackSize;
slotChanged(OUTPUT);
}
chiselItem(chiseled.stackSize, target);
// remove what we made from the stack
base.stackSize -= chiseled.stackSize;
if (base.stackSize <= 0) {
setInventorySlotContents(BASE, null); // clear out 0 size itemstacks
}
}
} else if (worldObj.getTotalWorldTime() % 10 == 0) {
progress++;
}
}
} else if (worldObj.isRemote) {
if (chiseling) {
chiselRot += rotAmnt;
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);
} else {
return inventory[TARGET];
}
}
// lets make sure the user isn't trying to make something from a block that doesn't have this as a valid 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()) {
return true;
}
}
return false;
}
private boolean canChisel(ItemStack toMerge) {
// if the output slot is empty we can merge without checking
if (inventory[OUTPUT] == null) {
return true;
}
// need to check NBT as well as item
if (!toMerge.isItemEqual(inventory[OUTPUT]) || !ItemStack.areItemStackTagsEqual(toMerge, inventory[OUTPUT])) {
return false;
}
// we only care about metadata if the item has subtypes
if (toMerge.getHasSubtypes() && toMerge.getItemDamage() != inventory[OUTPUT].getItemDamage()) {
return false;
}
return ((IChiselItem) inventory[CHISEL].getItem()).canChisel(worldObj, inventory[CHISEL], General.getVariation(getTarget()));
}
private boolean hasChisel() {
return inventory[CHISEL] != null && inventory[CHISEL].getItem() instanceof IChiselItem && inventory[CHISEL].stackSize >= 1;
}
/** Calls IChiselItem#onChisel() and sends the chisel packet for sound/animation */
private void chiselItem(int chiseled, ItemStack target) {
if (!worldObj.isRemote) {
boolean breakChisel = false;
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()) {
setInventorySlotContents(CHISEL, null);
breakChisel = true;
}
}
PacketHandler.INSTANCE.sendToDimension(new MessageAutoChisel(this, chiseled, true, breakChisel), worldObj.provider.dimensionId);
} else {
if (breakChisel) {
worldObj.playSound(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "random.break", 0.8F, 0.8F + worldObj.rand.nextFloat() * 0.4F, false);
}
GeneralChiselClient.spawnAutoChiselFX(this, lastBase != null ? lastBase : inventory[BASE]);
chiseling = false;
if (lastBase != null) {
lastBase.stackSize -= toChisel;
if (lastBase.stackSize <= 0) {
lastBase = null;
}
}
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
NBTTagList tags = new NBTTagList();
for (int i = 0; i < inventory.length; i++) {
if (inventory[i] != null) {
NBTTagCompound data = new NBTTagCompound();
data.setByte("Slot", (byte) i);
inventory[i].writeToNBT(data);
tags.appendTag(data);
}
}
nbt.setTag("Items", tags);
if (this.hasCustomInventoryName()) {
nbt.setString("CustomName", this.name);
}
}
@Override
public int getSizeInventory() {
return inventory.length;
}
@Override
public ItemStack getStackInSlot(int slot) {
return inventory[slot];
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
if (inventory[slot] != null) {
ItemStack is = inventory[slot];
inventory[slot] = null;
return is;
} else
return null;
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
inventory[slot] = stack;
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
stack.stackSize = getInventoryStackLimit();
}
if (worldObj.isRemote && slot == BASE && stack != null) {
lastBase = stack.copy();
}
if (!worldObj.isRemote) {
slotChanged(slot);
}
}
private void slotChanged(int slot) {
PacketHandler.INSTANCE.sendToDimension(new MessageSlotUpdate(this, slot, inventory[slot]), worldObj.provider.dimensionId);
markDirty();
}
@Override
public String getInventoryName() {
return name;
}
@Override
public final boolean isUseableByPlayer(EntityPlayer player) {
return true;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return new int[] { BASE, TARGET, OUTPUT, CHISEL };
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemStack) {
if (itemStack == null) {
return false;
}
switch (slot) {
case BASE:
case TARGET:
return !Carving.chisel.getItemsForChiseling(itemStack).isEmpty();
case OUTPUT:
return false;
case CHISEL:
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 boolean canInsertItem(int slot, ItemStack itemStack, int side) {
return hasUpgrade(Upgrade.AUTOMATION) && (slot == BASE || slot == TARGET || slot == CHISEL);
}
@Override
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
return hasUpgrade(Upgrade.AUTOMATION) && slot == OUTPUT;
}
@Override
public void openInventory() {
;
}
@Override
public void closeInventory() {
;
}
@SideOnly(Side.CLIENT)
public EntityItem getItemForRendering(int slot) {
if (ghostItem == null) {
ghostItem = new EntityItem(worldObj);
ghostItem.hoverStart = 0.0F;
}
if (slot == BASE && lastBase != null) {
ghostItem.setEntityItemStack(lastBase.copy());
return ghostItem;
} else if (slot == TARGET) {
ItemStack target = getTarget();
if (target != null) {
ghostItem.setEntityItemStack(target);
return ghostItem;
}
return null;
} else if (inventory[slot] == null) {
return null;
} else {
ghostItem.setEntityItemStack(inventory[slot].copy());
return ghostItem;
}
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
readFromNBT(packet.func_148857_g());
}
public boolean hasUpgrade(Upgrade upgrade) {
if (Features.AUTO_CHISEL_UPGRADES.enabled()) {
ItemStack stack = inventory[MIN_UPGRADE + upgrade.ordinal()];
if (stack != null) {
return stack.getItem() == ChiselItems.upgrade && stack.getItemDamage() == upgrade.ordinal();
}
return false;
}
return upgrade == Upgrade.REVERSION ? false : true;
}
public String getSlotTooltipUnloc(int slotNumber) {
String base = "autochisel.slot.%s.tooltip";
String name = null;
if (slotNumber < MIN_UPGRADE) {
if (slotNumber == TARGET) {
name = "target";
} else if (slotNumber == CHISEL) {
name = "chisel";
}
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();
}
public enum Upgrade {
SPEED,
AUTOMATION,
STACK,
REVERSION;
public String getUnlocalizedName() {
if (Features.AUTO_CHISEL_UPGRADES.enabled()) {
return "item.upgrade_" + this.name()
.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()) {
ret = EnumChatFormatting.RED.toString()
.concat(ret);
}
return 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;
private int progress = 0;
private static EntityItem ghostItem;
boolean equal = false;
private ItemStack[] inventory = new ItemStack[8];
private String name = "autoChisel";
// client animation fields
// used for floating target
public float xRot, yRot, zRot;
// used for chisel item rotation
public static final int maxRot = 60;
public static final int rotAmnt = 15;
public float chiselRot;
public boolean chiseling = false, breakChisel = false;;
public int toChisel = 1;
private ItemStack lastBase;
@Override
public boolean canUpdate() {
return true;
}
@Override
public ItemStack decrStackSize(int slot, int size) {
if (inventory[slot] != null) {
ItemStack is;
if (inventory[slot].stackSize <= size) {
is = inventory[slot];
inventory[slot] = null;
return is;
} else {
is = inventory[slot].splitStack(size);
if (inventory[slot].stackSize == 0) inventory[slot] = null;
return is;
}
} else {
return null;
}
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
NBTTagList tags = nbt.getTagList("Items", 10);
inventory = new ItemStack[getSizeInventory()];
for (int i = 0; i < tags.tagCount(); i++) {
NBTTagCompound data = tags.getCompoundTagAt(i);
int j = data.getByte("Slot") & 255;
if (j >= 0 && j < inventory.length) {
inventory[j] = ItemStack.loadItemStackFromNBT(data);
}
}
if (nbt.hasKey("CustomName", 8)) {
this.name = nbt.getString("CustomName");
}
}
@Override
public void updateEntity() {
ItemStack base = inventory[BASE], target = getTarget(), output = inventory[OUTPUT];
if (!worldObj.isRemote && hasChisel() && base != null && target != null) {
if (canBeMadeFrom(base, target)) {
if (progress >= (hasUpgrade(Upgrade.SPEED) ? FAST_SPEED : SLOW_SPEED)) {
// reset progress
progress = 0;
// the max possible for this craft
int canBeMade = target.getMaxStackSize();
// if there are items in the output, they count towards the max we can make
if (output != null) {
canBeMade -= output.stackSize;
}
// can't make more than we have
canBeMade = Math.min(base.stackSize, canBeMade);
// if we can't make any, forget it
if (canBeMade <= 0) {
return;
}
// result will always be a copy of the target
ItemStack chiseled = target.copy();
// if we have the stack upgrade, boost the stack size to the max possible, otherwise just one
chiseled.stackSize = hasUpgrade(Upgrade.STACK) ? canBeMade : 1;
if (canChisel(chiseled)) {
// if our output is empty, just use the current result
if (output == null) {
setInventorySlotContents(OUTPUT, chiseled);
} else {
// otherwise just add our result to the existing stack
inventory[OUTPUT].stackSize += chiseled.stackSize;
slotChanged(OUTPUT);
}
chiselItem(chiseled.stackSize, target);
// remove what we made from the stack
base.stackSize -= chiseled.stackSize;
if (base.stackSize <= 0) {
setInventorySlotContents(BASE, null); // clear out 0 size itemstacks
}
}
} else if (worldObj.getTotalWorldTime() % 10 == 0) {
progress++;
}
}
} else if (worldObj.isRemote) {
if (chiseling) {
chiselRot += rotAmnt;
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);
} else {
return inventory[TARGET];
}
}
// lets make sure the user isn't trying to make something from a block that doesn't have this as a valid 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()) {
return true;
}
}
return false;
}
private boolean canChisel(ItemStack toMerge) {
// if the output slot is empty we can merge without checking
if (inventory[OUTPUT] == null) {
return true;
}
// need to check NBT as well as item
if (!toMerge.isItemEqual(inventory[OUTPUT]) || !ItemStack.areItemStackTagsEqual(toMerge, inventory[OUTPUT])) {
return false;
}
// we only care about metadata if the item has subtypes
if (toMerge.getHasSubtypes() && toMerge.getItemDamage() != inventory[OUTPUT].getItemDamage()) {
return false;
}
return ((IChiselItem) inventory[CHISEL].getItem())
.canChisel(worldObj, inventory[CHISEL], General.getVariation(getTarget()));
}
private boolean hasChisel() {
return inventory[CHISEL] != null && inventory[CHISEL].getItem() instanceof IChiselItem
&& inventory[CHISEL].stackSize >= 1;
}
/** Calls IChiselItem#onChisel() and sends the chisel packet for sound/animation */
private void chiselItem(int chiseled, ItemStack target) {
if (!worldObj.isRemote) {
boolean breakChisel = false;
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()) {
setInventorySlotContents(CHISEL, null);
breakChisel = true;
}
}
PacketHandler.INSTANCE.sendToDimension(
new MessageAutoChisel(this, chiseled, true, breakChisel),
worldObj.provider.dimensionId);
} else {
if (breakChisel) {
worldObj.playSound(
xCoord + 0.5,
yCoord + 0.5,
zCoord + 0.5,
"random.break",
0.8F,
0.8F + worldObj.rand.nextFloat() * 0.4F,
false);
}
GeneralChiselClient.spawnAutoChiselFX(this, lastBase != null ? lastBase : inventory[BASE]);
chiseling = false;
if (lastBase != null) {
lastBase.stackSize -= toChisel;
if (lastBase.stackSize <= 0) {
lastBase = null;
}
}
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
NBTTagList tags = new NBTTagList();
for (int i = 0; i < inventory.length; i++) {
if (inventory[i] != null) {
NBTTagCompound data = new NBTTagCompound();
data.setByte("Slot", (byte) i);
inventory[i].writeToNBT(data);
tags.appendTag(data);
}
}
nbt.setTag("Items", tags);
if (this.hasCustomInventoryName()) {
nbt.setString("CustomName", this.name);
}
}
@Override
public int getSizeInventory() {
return inventory.length;
}
@Override
public ItemStack getStackInSlot(int slot) {
return inventory[slot];
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
if (inventory[slot] != null) {
ItemStack is = inventory[slot];
inventory[slot] = null;
return is;
} else return null;
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
inventory[slot] = stack;
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
stack.stackSize = getInventoryStackLimit();
}
if (worldObj.isRemote && slot == BASE && stack != null) {
lastBase = stack.copy();
}
if (!worldObj.isRemote) {
slotChanged(slot);
}
}
private void slotChanged(int slot) {
PacketHandler.INSTANCE
.sendToDimension(new MessageSlotUpdate(this, slot, inventory[slot]), worldObj.provider.dimensionId);
markDirty();
}
@Override
public String getInventoryName() {
return name;
}
@Override
public final boolean isUseableByPlayer(EntityPlayer player) {
return true;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public int[] getAccessibleSlotsFromSide(int side) {
return new int[] { BASE, TARGET, OUTPUT, CHISEL };
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack itemStack) {
if (itemStack == null) {
return false;
}
switch (slot) {
case BASE:
case TARGET:
return !Carving.chisel.getItemsForChiseling(itemStack)
.isEmpty();
case OUTPUT:
return false;
case CHISEL:
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 boolean canInsertItem(int slot, ItemStack itemStack, int side) {
return hasUpgrade(Upgrade.AUTOMATION) && (slot == BASE || slot == TARGET || slot == CHISEL);
}
@Override
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
return hasUpgrade(Upgrade.AUTOMATION) && slot == OUTPUT;
}
@Override
public void openInventory() {
;
}
@Override
public void closeInventory() {
;
}
@SideOnly(Side.CLIENT)
public EntityItem getItemForRendering(int slot) {
if (ghostItem == null) {
ghostItem = new EntityItem(worldObj);
ghostItem.hoverStart = 0.0F;
}
if (slot == BASE && lastBase != null) {
ghostItem.setEntityItemStack(lastBase.copy());
return ghostItem;
} else if (slot == TARGET) {
ItemStack target = getTarget();
if (target != null) {
ghostItem.setEntityItemStack(target);
return ghostItem;
}
return null;
} else if (inventory[slot] == null) {
return null;
} else {
ghostItem.setEntityItemStack(inventory[slot].copy());
return ghostItem;
}
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
readFromNBT(packet.func_148857_g());
}
public boolean hasUpgrade(Upgrade upgrade) {
if (Features.AUTO_CHISEL_UPGRADES.enabled()) {
ItemStack stack = inventory[MIN_UPGRADE + upgrade.ordinal()];
if (stack != null) {
return stack.getItem() == ChiselItems.upgrade && stack.getItemDamage() == upgrade.ordinal();
}
return false;
}
return upgrade == Upgrade.REVERSION ? false : true;
}
public String getSlotTooltipUnloc(int slotNumber) {
String base = "autochisel.slot.%s.tooltip";
String name = null;
if (slotNumber < MIN_UPGRADE) {
if (slotNumber == TARGET) {
name = "target";
} else if (slotNumber == CHISEL) {
name = "chisel";
}
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.util.AxisAlignedBB;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TileEntityCarvableBeacon extends TileEntityBeacon {
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
return INFINITE_EXTENT_AABB;
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
return INFINITE_EXTENT_AABB;
}
}
@@ -1,8 +1,5 @@
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.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
@@ -17,349 +14,358 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
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 {
private TileEntityPresent connection = null;
// If cachedDir is non-null, but connection is null, this present must be
// connected to an unloaded present. This is handled appropriately.
private ForgeDirection cachedDir = null;
private boolean isParent;
private final ItemStack[] inventory = new ItemStack[27];
private int rotation;
private boolean autoSearch = true;
private TileEntityPresent connection = null;
// If cachedDir is non-null, but connection is null, this present must be
// connected to an unloaded present. This is handled appropriately.
private ForgeDirection cachedDir = null;
private boolean isParent;
private final ItemStack[] inventory = new ItemStack[27];
private int rotation;
private boolean autoSearch = true;
@Override
public void updateEntity() {
if (!isConnected() && autoSearch && worldObj != null /* ugh */) {
if (cachedDir != null) {
connectTo(cachedDir);
} else if (!worldObj.isRemote) {
findConnections();
}
autoSearch = false;
}
}
@Override
public void updateEntity() {
if (!isConnected() && autoSearch && worldObj != null /* ugh */) {
if (cachedDir != null) {
connectTo(cachedDir);
} else if (!worldObj.isRemote) {
findConnections();
}
autoSearch = false;
}
}
public boolean isConnected() {
return connection != null;
}
public boolean isConnected() {
return connection != null;
}
private boolean connectTo(TileEntityPresent present, ForgeDirection dir) {
if (present.getBlockMetadata() == getBlockMetadata() && !present.isConnected() && (present.cachedDir == null || present.cachedDir == dir.getOpposite())
&& Math.abs(present.xCoord - xCoord + present.yCoord - yCoord + present.zCoord - zCoord) == 1) {
connection = present;
connection.connection = this;
connection.cachedDir = dir.getOpposite();
connection.markDirty();
cachedDir = dir;
isParent = !present.isParent;
markDirty();
PacketHandler.INSTANCE.sendToDimension(new MessagePresentConnect(this, dir, true), worldObj.provider.dimensionId);
return true;
}
return false;
}
private boolean connectTo(TileEntityPresent present, ForgeDirection dir) {
if (present.getBlockMetadata() == getBlockMetadata() && !present.isConnected()
&& (present.cachedDir == null || present.cachedDir == dir.getOpposite())
&& Math.abs(present.xCoord - xCoord + present.yCoord - yCoord + present.zCoord - zCoord) == 1) {
connection = present;
connection.connection = this;
connection.cachedDir = dir.getOpposite();
connection.markDirty();
cachedDir = dir;
isParent = !present.isParent;
markDirty();
PacketHandler.INSTANCE
.sendToDimension(new MessagePresentConnect(this, dir, true), worldObj.provider.dimensionId);
return true;
}
return false;
}
public boolean connectTo(ForgeDirection dir) {
int x = xCoord + dir.offsetX, y = yCoord + dir.offsetY, z = zCoord + dir.offsetZ;
TileEntity te = getTileSafe(x, y, z);
if (te instanceof TileEntityPresent) {
return connectTo((TileEntityPresent) te, dir);
}
return !exists(x, y, z);
}
public boolean connectTo(ForgeDirection dir) {
int x = xCoord + dir.offsetX, y = yCoord + dir.offsetY, z = zCoord + dir.offsetZ;
TileEntity te = getTileSafe(x, y, z);
if (te instanceof TileEntityPresent) {
return connectTo((TileEntityPresent) te, dir);
}
return !exists(x, y, z);
}
/**
* @param preserveDir
* 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.
*/
public void disconnect(boolean preserveDir) {
if (isConnected()) {
if (!preserveDir) {
this.connection.cachedDir = null;
this.cachedDir = null;
}
this.connection.connection = null;
this.connection.markDirty();
this.connection = null;
this.markDirty();
PacketHandler.INSTANCE.sendToDimension(new MessagePresentConnect(this, ForgeDirection.UNKNOWN, false, preserveDir), worldObj.provider.dimensionId);
}
}
/**
* @param preserveDir 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.
*/
public void disconnect(boolean preserveDir) {
if (isConnected()) {
if (!preserveDir) {
this.connection.cachedDir = null;
this.cachedDir = null;
}
this.connection.connection = null;
this.connection.markDirty();
this.connection = null;
this.markDirty();
PacketHandler.INSTANCE.sendToDimension(
new MessagePresentConnect(this, ForgeDirection.UNKNOWN, false, preserveDir),
worldObj.provider.dimensionId);
}
}
public TileEntityPresent getConnection() {
return connection;
}
public TileEntityPresent getConnection() {
return connection;
}
public ForgeDirection getConnectionDir() {
return cachedDir == null ? ForgeDirection.UNKNOWN : cachedDir;
}
public ForgeDirection getConnectionDir() {
return cachedDir == null ? ForgeDirection.UNKNOWN : cachedDir;
}
public boolean isParent() {
return isParent || !isConnected();
}
public boolean isParent() {
return isParent || !isConnected();
}
public int getRotation() {
return rotation;
}
public int getRotation() {
return rotation;
}
public void setRotation(int rot) {
this.rotation = rot;
}
public void setRotation(int rot) {
this.rotation = rot;
}
public void findConnections() {
if (!isConnected()) {
if (cachedDir != null) {
if (connectTo(cachedDir)) {
return;
}
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) {
if (connectTo(dir)) {
return;
}
}
}
}
}
public void findConnections() {
if (!isConnected()) {
if (cachedDir != null) {
if (connectTo(cachedDir)) {
return;
}
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) {
if (connectTo(dir)) {
return;
}
}
}
}
}
public TileEntityPresent getParent() {
return isParent || connection == null ? this : connection;
}
public TileEntityPresent getParent() {
return isParent || connection == null ? this : connection;
}
@Override
public AxisAlignedBB getRenderBoundingBox() {
return ChiselBlocks.present.getBoundingBox(this);
}
@Override
public AxisAlignedBB getRenderBoundingBox() {
return ChiselBlocks.present.getBoundingBox(this);
}
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
NBTTagList nbttaglist = new NBTTagList();
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < getTrueSizeInventory(); ++i) {
if (inventory[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i);
inventory[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
for (int i = 0; i < getTrueSizeInventory(); ++i) {
if (inventory[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setByte("Slot", (byte) i);
inventory[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
tag.setTag("Items", nbttaglist);
tag.setBoolean("isParent", isParent);
tag.setInteger("rotation", rotation);
if (cachedDir != null) {
tag.setInteger("conDir", cachedDir.ordinal());
}
}
tag.setTag("Items", nbttaglist);
tag.setBoolean("isParent", isParent);
tag.setInteger("rotation", rotation);
if (cachedDir != null) {
tag.setInteger("conDir", cachedDir.ordinal());
}
}
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
NBTTagList nbttaglist = tag.getTagList("Items", 10);
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
NBTTagList nbttaglist = tag.getTagList("Items", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound1.getByte("Slot") & 255;
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound1.getByte("Slot") & 255;
if (j >= 0 && j < getTrueSizeInventory()) {
inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
if (j >= 0 && j < getTrueSizeInventory()) {
inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
this.isParent = tag.getBoolean("isParent");
this.isParent = tag.getBoolean("isParent");
this.rotation = tag.getInteger("rotation");
if (tag.hasKey("conDir")) {
cachedDir = ForgeDirection.values()[tag.getInteger("conDir")];
}
autoSearch = true;
}
this.rotation = tag.getInteger("rotation");
if (tag.hasKey("conDir")) {
cachedDir = ForgeDirection.values()[tag.getInteger("conDir")];
}
autoSearch = true;
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
writeToNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
readFromNBT(packet.func_148857_g());
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
readFromNBT(packet.func_148857_g());
}
@Override
public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) {
// prevent losing TE data when in-world chiseling
return oldBlock != newBlock;
}
@Override
public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y,
int z) {
// prevent losing TE data when in-world chiseling
return oldBlock != newBlock;
}
@Override
public void invalidate() {
super.invalidate();
if (isConnected()) {
disconnect(false);
}
}
@Override
public void invalidate() {
super.invalidate();
if (isConnected()) {
disconnect(false);
}
}
@Override
public void onChunkUnload() {
super.onChunkUnload();
if (isConnected()) {
disconnect(true);
}
}
@Override
public void onChunkUnload() {
super.onChunkUnload();
if (isConnected()) {
disconnect(true);
}
}
private int getAdjustedSlot(int slot) {
slot %= getSizeInventory();
if (isConnected() && !isParent) {
slot = (slot + getTrueSizeInventory()) % getSizeInventory();
}
return slot;
}
private int getAdjustedSlot(int slot) {
slot %= getSizeInventory();
if (isConnected() && !isParent) {
slot = (slot + getTrueSizeInventory()) % getSizeInventory();
}
return slot;
}
private TileEntity getTileSafe(int x, int y, int z) {
if (exists(x, y, z)) {
return worldObj.getTileEntity(x, y, z);
}
return null;
}
private TileEntity getTileSafe(int x, int y, int z) {
if (exists(x, y, z)) {
return worldObj.getTileEntity(x, y, z);
}
return null;
}
// private Block getBlockSafe(int x, int y, int z) {
// if (exists(x, y, z)) {
// return worldObj.getBlock(x, y, z);
// }
// return null;
// }
//
// private int getMetaSafe(int x, int y, int z) {
// if (exists(x, y, z)) {
// return worldObj.getBlockMetadata(x, y, z);
// }
// return 0;
// }
//
private boolean exists(int x, int y, int z) {
return worldObj.blockExists(x, y, z);
}
// private Block getBlockSafe(int x, int y, int z) {
// if (exists(x, y, z)) {
// return worldObj.getBlock(x, y, z);
// }
// return null;
// }
//
// private int getMetaSafe(int x, int y, int z) {
// if (exists(x, y, z)) {
// return worldObj.getBlockMetadata(x, y, z);
// }
// return 0;
// }
//
private boolean exists(int x, int y, int z) {
return worldObj.blockExists(x, y, z);
}
/* IInventory */
/* IInventory */
@Override
public int getSizeInventory() {
return isConnected() ? getTrueSizeInventory() + connection.getTrueSizeInventory() : getTrueSizeInventory();
}
@Override
public int getSizeInventory() {
return isConnected() ? getTrueSizeInventory() + connection.getTrueSizeInventory() : getTrueSizeInventory();
}
@Override
public ItemStack getStackInSlot(int slot) {
slot = getAdjustedSlot(slot);
if (slot >= getTrueSizeInventory()) {
return isConnected() ? connection.inventory[slot % getTrueSizeInventory()] : null;
} else {
return inventory[slot];
}
}
@Override
public ItemStack getStackInSlot(int slot) {
slot = getAdjustedSlot(slot);
if (slot >= getTrueSizeInventory()) {
return isConnected() ? connection.inventory[slot % getTrueSizeInventory()] : null;
} else {
return inventory[slot];
}
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
slot = getAdjustedSlot(slot);
ItemStack[] inv = inventory;
if (isConnected() && slot >= getTrueSizeInventory()) {
inv = connection.inventory;
slot %= getTrueSizeInventory();
connection.markDirty();
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
slot = getAdjustedSlot(slot);
ItemStack[] inv = inventory;
if (isConnected() && slot >= getTrueSizeInventory()) {
inv = connection.inventory;
slot %= getTrueSizeInventory();
connection.markDirty();
}
if (inv[slot] != null) {
ItemStack itemstack;
if (inv[slot] != null) {
ItemStack itemstack;
if (inv[slot].stackSize <= amount) {
itemstack = inv[slot];
inv[slot] = null;
this.markDirty();
return itemstack;
} else {
itemstack = inv[slot].splitStack(amount);
if (inv[slot].stackSize <= amount) {
itemstack = inv[slot];
inv[slot] = null;
this.markDirty();
return itemstack;
} else {
itemstack = inv[slot].splitStack(amount);
if (inv[slot].stackSize == 0) {
inv[slot] = null;
}
if (inv[slot].stackSize == 0) {
inv[slot] = null;
}
this.markDirty();
return itemstack;
}
} else {
return null;
}
}
this.markDirty();
return itemstack;
}
} else {
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return getStackInSlot(slot);
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return getStackInSlot(slot);
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
slot = getAdjustedSlot(slot);
if (slot < getTrueSizeInventory()) {
inventory[slot] = stack;
} else if (isConnected()) {
connection.inventory[slot % getTrueSizeInventory()] = stack;
connection.markDirty();
}
}
@Override
public void setInventorySlotContents(int slot, ItemStack stack) {
slot = getAdjustedSlot(slot);
if (slot < getTrueSizeInventory()) {
inventory[slot] = stack;
} else if (isConnected()) {
connection.inventory[slot % getTrueSizeInventory()] = stack;
connection.markDirty();
}
}
@Override
public String getInventoryName() {
return "chisel.present";
}
@Override
public String getInventoryName() {
return "chisel.present";
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
return true;
}
@Override
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
return true;
}
@Override
public void openInventory() {
;
}
@Override
public void openInventory() {
;
}
@Override
public void closeInventory() {
;
}
@Override
public void closeInventory() {
;
}
@Override
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
return true;
}
@Override
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
return true;
}
/* IDoubleChest */
/* IDoubleChest */
@Override
public int getTrueSizeInventory() {
return inventory.length;
}
@Override
public int getTrueSizeInventory() {
return inventory.length;
}
@Override
public ItemStack getTrueStackInSlot(int slot) {
return inventory[slot % getTrueSizeInventory()];
}
@Override
public ItemStack getTrueStackInSlot(int slot) {
return inventory[slot % getTrueSizeInventory()];
}
@Override
public void putStackInTrueSlot(int slot, ItemStack stack) {
inventory[slot % getTrueSizeInventory()] = stack;
}
@Override
public void putStackInTrueSlot(int slot, ItemStack stack) {
inventory[slot % getTrueSizeInventory()] = stack;
}
}
+166 -165
View File
@@ -1,6 +1,14 @@
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.ICarvingGroup;
@@ -8,208 +16,201 @@ import com.cricketcraft.chisel.api.carving.ICarvingRegistry;
import com.cricketcraft.chisel.api.carving.ICarvingVariation;
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 {
GroupList groups = new GroupList();
GroupList groups = new GroupList();
public static final ICarvingRegistry chisel = new Carving();
public static final Carving needle = new Carving();
public static final ICarvingRegistry chisel = new Carving();
public static final Carving needle = new Carving();
static {
CarvingUtils.chisel = chisel;
}
static {
CarvingUtils.chisel = chisel;
}
public static void construct() {
/* do nothing */
}
public static void construct() {
/* do nothing */
}
private Carving() {
/* do nothing */
}
private Carving() {
/* do nothing */
}
@Override
public ICarvingVariation getVariation(Block block, int metadata) {
ICarvingGroup g = getGroup(block, metadata);
if (g != null) {
for (ICarvingVariation v : g.getVariations()) {
if (v.getBlock() == block && v.getBlockMeta() == metadata) {
return v;
}
}
}
return null;
}
@Override
public ICarvingVariation getVariation(Block block, int metadata) {
ICarvingGroup g = getGroup(block, metadata);
if (g != null) {
for (ICarvingVariation v : g.getVariations()) {
if (v.getBlock() == block && v.getBlockMeta() == metadata) {
return v;
}
}
}
return null;
}
@Override
public List<ICarvingVariation> getGroupVariations(Block block, int metadata) {
ICarvingGroup group = getGroup(block, metadata);
if (group == null)
return Collections.emptyList();
@Override
public List<ICarvingVariation> getGroupVariations(Block block, int metadata) {
ICarvingGroup group = getGroup(block, metadata);
if (group == null) return Collections.emptyList();
return group.getVariations();
}
return group.getVariations();
}
@Override
public String getOreName(Block block, int metadata) {
ICarvingGroup group = getGroup(block, metadata);
if (group == null)
return null;
@Override
public String getOreName(Block block, int metadata) {
ICarvingGroup group = getGroup(block, metadata);
if (group == null) return null;
return group.getOreName();
}
return group.getOreName();
}
@Override
public List<ItemStack> getItemsForChiseling(ItemStack chiseledItem) {
ArrayList<ItemStack> items = new ArrayList<>();
@Override
public List<ItemStack> getItemsForChiseling(ItemStack chiseledItem) {
ArrayList<ItemStack> items = new ArrayList<>();
ICarvingGroup group = null;
ICarvingGroup group = null;
int[] oreIDs = OreDictionary.getOreIDs(chiseledItem);
for (int i : oreIDs) {
group = groups.getGroupByOre(OreDictionary.getOreName(i));
if (group != null) {
break;
}
}
int[] oreIDs = OreDictionary.getOreIDs(chiseledItem);
for (int i : oreIDs) {
group = groups.getGroupByOre(OreDictionary.getOreName(i));
if (group != null) {
break;
}
}
if (group == null) {
group = getGroup(Block.getBlockFromItem(chiseledItem.getItem()), chiseledItem.getItemDamage());
}
if (group == null) {
group = getGroup(Block.getBlockFromItem(chiseledItem.getItem()), chiseledItem.getItemDamage());
}
if (group == null)
return items;
if (group == null) 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) {
String key = Block.getIdFromBlock(v.getBlock()) + "|" + v.getItemMeta();
if (mapping.add(key)) items.add(new ItemStack(v.getBlock(), 1, v.getItemMeta()));
}
for (ICarvingVariation v : variations) {
String key = Block.getIdFromBlock(v.getBlock()) + "|" + v.getItemMeta();
if (mapping.add(key)) items.add(new ItemStack(v.getBlock(), 1, v.getItemMeta()));
}
String oreName = group.getOreName();
if (oreName != null) {
ArrayList<ItemStack> ores = OreDictionary.getOres(oreName);
for (ItemStack stack : ores) {
String key = Item.getIdFromItem(stack.getItem()) + "|" + stack.getItemDamage();
if (mapping.add(key)) items.add(stack);
}
}
String oreName = group.getOreName();
if (oreName != null) {
ArrayList<ItemStack> ores = OreDictionary.getOres(oreName);
for (ItemStack stack : ores) {
String key = Item.getIdFromItem(stack.getItem()) + "|" + stack.getItemDamage();
if (mapping.add(key)) items.add(stack);
}
}
return items;
}
return items;
}
@Override
public ICarvingGroup getGroup(Block block, int metadata) {
int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, metadata));
if (ids.length > 0) {
for (int id : ids) {
ICarvingGroup oreGroup = groups.getGroupByOre(OreDictionary.getOreName(id));
if (oreGroup != null) {
return oreGroup;
}
}
}
@Override
public ICarvingGroup getGroup(Block block, int metadata) {
int[] ids = OreDictionary.getOreIDs(new ItemStack(block, 1, metadata));
if (ids.length > 0) {
for (int id : ids) {
ICarvingGroup oreGroup = groups.getGroupByOre(OreDictionary.getOreName(id));
if (oreGroup != null) {
return oreGroup;
}
}
}
return groups.getGroup(block, metadata);
}
return groups.getGroup(block, metadata);
}
@Override
public ICarvingGroup getGroup(String name) {
return groups.getGroupByName(name);
}
@Override
public ICarvingGroup getGroup(String name) {
return groups.getGroupByName(name);
}
@Override
public ICarvingGroup removeGroup(String groupName) {
ICarvingGroup g = groups.getGroupByName(groupName);
return groups.remove(g) ? g : null;
}
@Override
public ICarvingGroup removeGroup(String groupName) {
ICarvingGroup g = groups.getGroupByName(groupName);
return groups.remove(g) ? g : null;
}
@Override
public ICarvingVariation removeVariation(Block block, int metadata) {
return removeVariation(block, metadata, null);
}
@Override
public ICarvingVariation removeVariation(Block block, int metadata) {
return removeVariation(block, metadata, null);
}
@Override
public ICarvingVariation removeVariation(Block block, int metadata, String group) {
return groups.removeVariation(block, metadata, group);
}
@Override
public ICarvingVariation removeVariation(Block block, int metadata, String group) {
return groups.removeVariation(block, metadata, group);
}
@Override
public void addVariation(String groupName, Block block, int metadata, int order) {
if (block == null) {
throw new NullPointerException("Cannot add variation in group " + groupName + " for null block.");
}
@Override
public void addVariation(String groupName, Block block, int metadata, int order) {
if (block == null) {
throw new NullPointerException("Cannot add variation in group " + groupName + " for null block.");
}
ICarvingVariation variation = CarvingUtils.getDefaultVariationFor(block, metadata, order);
addVariation(groupName, variation);
}
ICarvingVariation variation = CarvingUtils.getDefaultVariationFor(block, metadata, order);
addVariation(groupName, variation);
}
@Override
public void addVariation(String groupName, ICarvingVariation variation) {
if (groupName == null) {
throw new NullPointerException("Cannot add variation to null group name.");
} else if (variation == null) {
throw new NullPointerException("Cannot add variation in group " + groupName + " for null variation.");
}
@Override
public void addVariation(String groupName, ICarvingVariation variation) {
if (groupName == null) {
throw new NullPointerException("Cannot add variation to null group name.");
} else if (variation == null) {
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) {
group = CarvingUtils.getDefaultGroupFor(groupName);
addGroup(group);
}
if (group == null) {
group = CarvingUtils.getDefaultGroupFor(groupName);
addGroup(group);
}
groups.addVariation(groupName, variation);
}
groups.addVariation(groupName, variation);
}
@Override
public void addGroup(ICarvingGroup group) {
groups.add(group);
}
@Override
public void addGroup(ICarvingGroup group) {
groups.add(group);
}
@Override
public void registerOre(String name, String oreName) {
ICarvingGroup group = groups.getGroupByName(name);
if (group != null) {
group.setOreName(oreName);
} else {
throw new NullPointerException("Cannot register ore name for group " + name + ", as it does not exist.");
}
}
@Override
public void registerOre(String name, String oreName) {
ICarvingGroup group = groups.getGroupByName(name);
if (group != null) {
group.setOreName(oreName);
} else {
throw new NullPointerException("Cannot register ore name for group " + name + ", as it does not exist.");
}
}
@Override
public void setVariationSound(String name, String sound) {
ICarvingGroup group = groups.getGroupByName(name);
if (group != null) {
group.setSound(sound);
} else {
throw new NullPointerException("Cannot set sound for group " + name + ", as it does not exist.");
}
}
@Override
public void setVariationSound(String name, String sound) {
ICarvingGroup group = groups.getGroupByName(name);
if (group != null) {
group.setSound(sound);
} else {
throw new NullPointerException("Cannot set sound for group " + name + ", as it does not exist.");
}
}
@Override
public String getVariationSound(Block block, int metadata) {
return getVariationSound(Item.getItemFromBlock(block), metadata);
}
@Override
public String getVariationSound(Block block, int metadata) {
return getVariationSound(Item.getItemFromBlock(block), metadata);
}
@Override
public String getVariationSound(Item item, int metadata) {
ICarvingGroup group = groups.getGroup(Block.getBlockFromItem(item), metadata);
String sound = group == null ? null : group.getSound();
return sound == null ? Chisel.MOD_ID + ":chisel.fallback" : sound;
}
@Override
public String getVariationSound(Item item, int metadata) {
ICarvingGroup group = groups.getGroup(Block.getBlockFromItem(item), metadata);
String sound = group == null ? null : group.getSound();
return sound == null ? Chisel.MOD_ID + ":chisel.fallback" : sound;
}
@Override
public List<String> getSortedGroupNames() {
List<String> names = new ArrayList<>(groups.getNames());
Collections.sort(names);
return names;
}
@Override
public List<String> getSortedGroupNames() {
List<String> names = new ArrayList<>(groups.getNames());
Collections.sort(names);
return names;
}
}
+202 -192
View File
@@ -17,229 +17,239 @@ import com.google.common.collect.Maps;
public class GroupList implements Set<ICarvingGroup> {
private class VariationWrapper {
private class VariationWrapper {
private ICarvingVariation v;
private ICarvingVariation v;
private VariationWrapper(ICarvingVariation v) {
this.v = v;
}
private VariationWrapper(ICarvingVariation v) {
this.v = v;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof ICarvingVariation) {
ICarvingVariation v2 = (ICarvingVariation) obj;
return v.getBlock() == v2.getBlock() && (v.getBlockMeta() == v2.getBlockMeta() || v.getItemMeta() == v2.getItemMeta());
} else if (obj instanceof VariationWrapper) {
return equals(((VariationWrapper) obj).v);
}
return false;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof ICarvingVariation) {
ICarvingVariation v2 = (ICarvingVariation) obj;
return v.getBlock() == v2.getBlock()
&& (v.getBlockMeta() == v2.getBlockMeta() || v.getItemMeta() == v2.getItemMeta());
} else if (obj instanceof VariationWrapper) {
return equals(((VariationWrapper) obj).v);
}
return false;
}
@Override
public int hashCode() {
return v.getBlock().hashCode();
}
}
@Override
public int 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) {
data = Pair.of(block, blockMeta);
}
private VariationKey(Block block, int blockMeta) {
data = Pair.of(block, blockMeta);
}
@Override
public Block getBlock() {
return data.getLeft();
}
@Override
public Block getBlock() {
return data.getLeft();
}
@Override
public int getBlockMeta() {
return data.getRight();
}
@Override
public int getBlockMeta() {
return data.getRight();
}
@Override
public int getItemMeta() {
return data.getRight();
}
@Override
public int getItemMeta() {
return data.getRight();
}
@Override
public int getOrder() {
return 0;
}
@Override
public int getOrder() {
return 0;
}
@Override
public String toString() {
return data.toString();
}
}
@Override
public String toString() {
return data.toString();
}
}
private HashMap<String, ICarvingGroup> groups = Maps.newHashMap();
private HashMap<VariationWrapper, ICarvingGroup> lookup = Maps.newHashMap();
private HashMap<String, ICarvingGroup> groups = Maps.newHashMap();
private HashMap<VariationWrapper, ICarvingGroup> lookup = Maps.newHashMap();
@Override
public int size() {
return groups.size();
}
@Override
public int size() {
return groups.size();
}
@Override
public boolean isEmpty() {
return groups.isEmpty();
}
@Override
public boolean isEmpty() {
return groups.isEmpty();
}
@Override
public boolean contains(Object o) {
if (o instanceof ICarvingGroup) {
return groups.containsKey(((ICarvingGroup) o).getName());
}
return false;
}
@Override
public boolean contains(Object o) {
if (o instanceof ICarvingGroup) {
return groups.containsKey(((ICarvingGroup) o).getName());
}
return false;
}
@Override
public Iterator<ICarvingGroup> iterator() {
return groups.values().iterator();
}
@Override
public Iterator<ICarvingGroup> iterator() {
return groups.values()
.iterator();
}
@Override
public Object[] toArray() {
return groups.values().toArray();
}
@Override
public Object[] toArray() {
return groups.values()
.toArray();
}
@Override
public <T> T[] toArray(T[] arr) {
return groups.values().toArray(arr);
}
@Override
public <T> T[] toArray(T[] arr) {
return groups.values()
.toArray(arr);
}
@Override
public boolean add(ICarvingGroup group) {
String key = group.getName();
if (groups.containsKey(key)) {
return false;
}
for (ICarvingVariation v : group.getVariations()) {
ICarvingGroup g = lookup.get(v);
if (g == null) {
lookup.put(new VariationWrapper(v), group);
}
}
groups.put(key, group);
return true;
}
@Override
public boolean add(ICarvingGroup group) {
String key = group.getName();
if (groups.containsKey(key)) {
return false;
}
for (ICarvingVariation v : group.getVariations()) {
ICarvingGroup g = lookup.get(v);
if (g == null) {
lookup.put(new VariationWrapper(v), group);
}
}
groups.put(key, group);
return true;
}
@Override
public boolean remove(Object o) {
if (o instanceof ICarvingGroup) {
List<VariationWrapper> toRemove = Lists.newArrayList();
for (VariationWrapper v : lookup.keySet()) {
if (lookup.get(v).getName().equals(((ICarvingGroup) o).getName())) {
toRemove.add(v);
}
}
for (VariationWrapper v : toRemove) {
lookup.remove(v);
}
return groups.remove(((ICarvingGroup) o).getName()) != null;
}
return false;
}
@Override
public boolean remove(Object o) {
if (o instanceof ICarvingGroup) {
List<VariationWrapper> toRemove = Lists.newArrayList();
for (VariationWrapper v : lookup.keySet()) {
if (lookup.get(v)
.getName()
.equals(((ICarvingGroup) o).getName())) {
toRemove.add(v);
}
}
for (VariationWrapper v : toRemove) {
lookup.remove(v);
}
return groups.remove(((ICarvingGroup) o).getName()) != null;
}
return false;
}
@Override
public boolean containsAll(Collection<?> c) {
for (Object o : c) {
if (!(o instanceof ICarvingGroup)) {
return false;
}
if (!groups.containsKey(((ICarvingGroup) o).getName())) {
return false;
}
}
return true;
}
@Override
public boolean containsAll(Collection<?> c) {
for (Object o : c) {
if (!(o instanceof ICarvingGroup)) {
return false;
}
if (!groups.containsKey(((ICarvingGroup) o).getName())) {
return false;
}
}
return true;
}
@Override
public boolean addAll(Collection<? extends ICarvingGroup> c) {
boolean ret = false;
for (ICarvingGroup g : c) {
ret |= add(g);
}
return ret;
}
@Override
public boolean addAll(Collection<? extends ICarvingGroup> c) {
boolean ret = false;
for (ICarvingGroup g : c) {
ret |= add(g);
}
return ret;
}
@Override
public boolean removeAll(Collection<?> c) {
boolean ret = false;
for (Object o : c) {
ret |= remove(o);
}
return ret;
}
@Override
public boolean removeAll(Collection<?> c) {
boolean ret = false;
for (Object o : c) {
ret |= remove(o);
}
return ret;
}
@Override
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException(); // not using it, not gonna bother
}
@Override
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException(); // not using it, not gonna bother
}
@Override
public void clear() {
groups.clear();
}
@Override
public void clear() {
groups.clear();
}
public ICarvingGroup getGroup(Block block, int metadata) {
return lookup.get(new VariationWrapper(new VariationKey(block, metadata)));
}
public ICarvingGroup getGroup(Block block, int metadata) {
return lookup.get(new VariationWrapper(new VariationKey(block, metadata)));
}
public void addVariation(String name, ICarvingVariation variation) {
ICarvingGroup g = groups.get(name);
if (g == null) {
throw new NullPointerException("No group exists for name " + name);
}
g.addVariation(variation);
lookup.put(new VariationWrapper(variation), g);
}
public void addVariation(String name, ICarvingVariation variation) {
ICarvingGroup g = groups.get(name);
if (g == null) {
throw new NullPointerException("No group exists for name " + name);
}
g.addVariation(variation);
lookup.put(new VariationWrapper(variation), g);
}
public ICarvingGroup getGroupByName(String groupName) {
return groups.get(groupName);
}
public ICarvingGroup getGroupByName(String groupName) {
return groups.get(groupName);
}
public ICarvingGroup getGroupByOre(String oreName) {
for (ICarvingGroup group : groups.values()) {
if (oreName.equals(group.getOreName())) {
return group;
}
}
return null;
}
public ICarvingGroup getGroupByOre(String oreName) {
for (ICarvingGroup group : groups.values()) {
if (oreName.equals(group.getOreName())) {
return group;
}
}
return null;
}
public Collection<? extends String> getNames() {
return groups.keySet();
}
public Collection<? extends String> getNames() {
return groups.keySet();
}
public ICarvingVariation removeVariation(Block block, int metadata, String group) {
ICarvingGroup g = null;
if (group != null) {
g = groups.get(group);
if (g == null) {
throw new IllegalArgumentException("No such group " + group);
}
groups.remove(g.getName());
}
List<VariationWrapper> toRemove = Lists.newArrayList();
for (VariationWrapper v : lookup.keySet()) {
if ((g == null || lookup.get(v).getName().equals(g.getName())) && v.equals(new VariationWrapper(new VariationKey(block, metadata)))) {
lookup.get(v).removeVariation(v.v);
toRemove.add(v);
}
}
for (VariationWrapper v : toRemove) {
lookup.remove(v);
}
return toRemove.isEmpty() ? null : toRemove.get(0).v;
}
public ICarvingVariation removeVariation(Block block, int metadata, String group) {
ICarvingGroup g = null;
if (group != null) {
g = groups.get(group);
if (g == null) {
throw new IllegalArgumentException("No such group " + group);
}
groups.remove(g.getName());
}
List<VariationWrapper> toRemove = Lists.newArrayList();
for (VariationWrapper v : lookup.keySet()) {
if ((g == null || lookup.get(v)
.getName()
.equals(g.getName())) && v.equals(new VariationWrapper(new VariationKey(block, metadata)))) {
lookup.get(v)
.removeVariation(v.v);
toRemove.add(v);
}
}
for (VariationWrapper v : toRemove) {
lookup.remove(v);
}
return toRemove.isEmpty() ? null : toRemove.get(0).v;
}
@Override
public String toString() {
return groups.toString();
}
@Override
public String toString() {
return groups.toString();
}
}
@@ -9,6 +9,7 @@ import net.minecraft.client.particle.EntityDiggingFX;
import net.minecraft.client.particle.EntityLavaFX;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import team.chisel.block.BlockGrimstone;
import team.chisel.block.BlockHolystone;
import team.chisel.block.BlockLavastone;
@@ -24,226 +25,270 @@ import team.chisel.utils.GeneralClient;
public class GeneralChiselClient {
public static Random rand = new Random();
public static int tick = 0;
public static Random rand = new Random();
public static int tick = 0;
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)
return;
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) return;
float f = 0.15F;
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + 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();
float f = 0.15F;
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F)
+ f
+ 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)) {
case 0:
y1 = y + block.getBlockBoundsMinY() - f;
y--;
break;
case 1:
y1 = y + block.getBlockBoundsMaxY() + f;
y++;
break;
case 2:
z1 = z + block.getBlockBoundsMinZ() - f;
z--;
break;
case 3:
z1 = z + block.getBlockBoundsMaxZ() + f;
z++;
break;
case 4:
x1 = x + block.getBlockBoundsMinX() - f;
x--;
break;
case 5:
x1 = x + block.getBlockBoundsMaxX() + f;
x++;
break;
}
switch (rand.nextInt(6)) {
case 0:
y1 = y + block.getBlockBoundsMinY() - f;
y--;
break;
case 1:
y1 = y + block.getBlockBoundsMaxY() + f;
y++;
break;
case 2:
z1 = z + block.getBlockBoundsMinZ() - f;
z--;
break;
case 3:
z1 = z + block.getBlockBoundsMaxZ() + f;
z++;
break;
case 4:
x1 = x + block.getBlockBoundsMinX() - f;
x--;
break;
case 5:
x1 = x + block.getBlockBoundsMaxX() + f;
x++;
break;
}
if (world.getBlock(x, y, z).isOpaqueCube())
return;
if (world.getBlock(x, y, z)
.isOpaqueCube()) return;
EntityLavaFX res = new EntityLavaFX(world, x1, y1, z1);
double multiplier = 0.45;
res.motionX = -multiplier * (x1 - x - 0.5);
res.motionY = multiplier * (y1 - y - 0.5);
res.motionZ = -multiplier * (z1 - z - 0.5);
EntityLavaFX res = new EntityLavaFX(world, x1, y1, z1);
double multiplier = 0.45;
res.motionX = -multiplier * (x1 - x - 0.5);
res.motionY = multiplier * (y1 - y - 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) {
if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0 || Minecraft.getMinecraft().gameSettings.particleSetting != 0)
return;
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) return;
float f = 0.15F;
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + 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();
float f = 0.15F;
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F)
+ f
+ 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)) {
case 0:
y1 = y + block.getBlockBoundsMinY() - f;
y--;
break;
case 1:
y1 = y + block.getBlockBoundsMaxY() + f;
y++;
break;
case 2:
z1 = z + block.getBlockBoundsMinZ() - f;
z--;
break;
case 3:
z1 = z + block.getBlockBoundsMaxZ() + f;
z++;
break;
case 4:
x1 = x + block.getBlockBoundsMinX() - f;
x--;
break;
case 5:
x1 = x + block.getBlockBoundsMaxX() + f;
x++;
break;
}
switch (rand.nextInt(6)) {
case 0:
y1 = y + block.getBlockBoundsMinY() - f;
y--;
break;
case 1:
y1 = y + block.getBlockBoundsMaxY() + f;
y++;
break;
case 2:
z1 = z + block.getBlockBoundsMinZ() - f;
z--;
break;
case 3:
z1 = z + block.getBlockBoundsMaxZ() + f;
z++;
break;
case 4:
x1 = x + block.getBlockBoundsMinX() - f;
x--;
break;
case 5:
x1 = x + block.getBlockBoundsMaxX() + f;
x++;
break;
}
if (world.getBlock(x, y, z).isOpaqueCube())
return;
if (world.getBlock(x, y, z)
.isOpaqueCube()) return;
EntityHolystoneFX res = new EntityHolystoneFX(world, block, x1, y1, z1);
Minecraft.getMinecraft().effectRenderer.addEffect(res);
}
EntityHolystoneFX res = new EntityHolystoneFX(world, block, x1, y1, z1);
Minecraft.getMinecraft().effectRenderer.addEffect(res);
}
public static void spawnGrimstoneFX(World world, BlockGrimstone block, int x, int y, int z) {
if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0)
return;
public static void spawnGrimstoneFX(World world, BlockGrimstone block, int x, int y, int z) {
if (Configurations.particlesTickrate != 0 && tick++ % Configurations.particlesTickrate != 0) return;
float f = 0.15F;
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + 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();
float f = 0.15F;
double x1 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F)
+ f
+ 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)) {
case 0:
y1 = y + block.getBlockBoundsMinY() - f;
y--;
break;
case 1:
y1 = y + block.getBlockBoundsMaxY() + f;
y++;
break;
case 2:
z1 = z + block.getBlockBoundsMinZ() - f;
z--;
break;
case 3:
z1 = z + block.getBlockBoundsMaxZ() + f;
z++;
break;
case 4:
x1 = x + block.getBlockBoundsMinX() - f;
x--;
break;
case 5:
x1 = x + block.getBlockBoundsMaxX() + f;
x++;
break;
}
switch (rand.nextInt(6)) {
case 0:
y1 = y + block.getBlockBoundsMinY() - f;
y--;
break;
case 1:
y1 = y + block.getBlockBoundsMaxY() + f;
y++;
break;
case 2:
z1 = z + block.getBlockBoundsMinZ() - f;
z--;
break;
case 3:
z1 = z + block.getBlockBoundsMaxZ() + f;
z++;
break;
case 4:
x1 = x + block.getBlockBoundsMinX() - f;
x--;
break;
case 5:
x1 = x + block.getBlockBoundsMaxX() + f;
x++;
break;
}
if (world.getBlock(x, y, z).isOpaqueCube())
return;
if (world.getBlock(x, y, z)
.isOpaqueCube()) return;
EntityGrimstoneFX res = new EntityGrimstoneFX(world, block, x1, y1, z1);
Minecraft.getMinecraft().effectRenderer.addEffect(res);
}
EntityGrimstoneFX res = new EntityGrimstoneFX(world, block, x1, y1, z1);
Minecraft.getMinecraft().effectRenderer.addEffect(res);
}
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) {
EntitySnakestoneObsidianFX res = new EntitySnakestoneObsidianFX(world, block, x, y, z);
Minecraft.getMinecraft().effectRenderer.addEffect(res);
}
}
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) {
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) {
if (Configurations.particlesTickrate == 0 || tick++ % Configurations.particlesTickrate == 0 || Minecraft.getMinecraft().gameSettings.particleSetting != 0) {
EntityBallOMossFX res = new EntityBallOMossFX(world, x, y, z);
Minecraft.getMinecraft().effectRenderer.addEffect(res);
}
}
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) {
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) {
Block block = world.getBlock(x, y, z);
if (block.isAir(world, x, y, z) || Minecraft.getMinecraft().gameSettings.particleSetting != 0)
return null;
public static EntityDiggingFX addBlockHitEffects(World world, int x, int y, int z, int side) {
Block block = world.getBlock(x, y, z);
if (block.isAir(world, x, y, z) || Minecraft.getMinecraft().gameSettings.particleSetting != 0) return null;
EffectRenderer renderer = Minecraft.getMinecraft().effectRenderer;
EffectRenderer renderer = Minecraft.getMinecraft().effectRenderer;
float f = 0.1F;
double d0 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F) + f + 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();
float f = 0.1F;
double d0 = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - f * 2.0F)
+ f
+ 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) {
case 0:
d1 = y + block.getBlockBoundsMinY() - f;
break;
case 1:
d1 = y + block.getBlockBoundsMaxY() + f;
break;
case 2:
d2 = z + block.getBlockBoundsMinZ() - f;
break;
case 3:
d2 = z + block.getBlockBoundsMaxZ() + f;
break;
case 4:
d0 = x + block.getBlockBoundsMinX() - f;
break;
case 5:
d0 = x + block.getBlockBoundsMaxX() + f;
break;
}
switch (side) {
case 0:
d1 = y + block.getBlockBoundsMinY() - f;
break;
case 1:
d1 = y + block.getBlockBoundsMaxY() + f;
break;
case 2:
d2 = z + block.getBlockBoundsMinZ() - f;
break;
case 3:
d2 = z + block.getBlockBoundsMaxZ() + f;
break;
case 4:
d0 = x + block.getBlockBoundsMinX() - f;
break;
case 5:
d0 = x + block.getBlockBoundsMaxX() + f;
break;
}
EntityDiggingFX res = new EntityDiggingFX(world, d0, 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);
EntityDiggingFX res = new EntityDiggingFX(
world,
d0,
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) {
World world = Minecraft.getMinecraft().theWorld;
for (int side = 0; side < 6; side++) {
for (int j = 0; j < 16; j++) {
EntityDiggingFX fx = addBlockHitEffects(Minecraft.getMinecraft().theWorld, x, y, z, side);
if (fx == null)
return;
public static void spawnChiselEffect(int x, int y, int z, String sound) {
World world = Minecraft.getMinecraft().theWorld;
for (int side = 0; side < 6; side++) {
for (int j = 0; j < 16; j++) {
EntityDiggingFX fx = addBlockHitEffects(Minecraft.getMinecraft().theWorld, x, y, z, side);
if (fx == null) return;
fx.multipleParticleScaleBy(0.25f + 0.5f * rand.nextFloat());
fx.multiplyVelocity(0.3f * rand.nextFloat());
}
}
fx.multipleParticleScaleBy(0.25f + 0.5f * 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) {
if (base != null && Minecraft.getMinecraft().gameSettings.particleSetting == 0) {
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()),
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);
}
}
public static void spawnAutoChiselFX(TileEntityAutoChisel te, ItemStack base) {
if (base != null && Minecraft.getMinecraft().gameSettings.particleSetting == 0) {
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()),
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 team.chisel.block.tileentity.TileEntityAutoChisel;
import team.chisel.inventory.ContainerAutoChisel;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import team.chisel.block.tileentity.TileEntityAutoChisel;
import team.chisel.inventory.ContainerAutoChisel;
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) {
super(new ContainerAutoChisel(inventoryPlayer, tileEntityAutoChisel));
autochisel = tileEntityAutoChisel;
}
public GuiAutoChisel(InventoryPlayer inventoryPlayer, TileEntityAutoChisel tileEntityAutoChisel) {
super(new ContainerAutoChisel(inventoryPlayer, tileEntityAutoChisel));
autochisel = tileEntityAutoChisel;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@SuppressWarnings("unchecked")
@Override
public void drawScreen(int mouseX, int mouseY, float partialTick) {
super.drawScreen(mouseX, mouseY, partialTick);
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
@SuppressWarnings("unchecked")
@Override
public void drawScreen(int mouseX, int mouseY, float partialTick) {
super.drawScreen(mouseX, mouseY, partialTick);
for (Slot slot : (List<Slot>) inventorySlots.inventorySlots) {
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();
}
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
private boolean mouseInside(Slot slot, int x, int y) {
return x >= slot.xDisplayPosition && x <= slot.xDisplayPosition + 16 && y >= slot.yDisplayPosition && y <= slot.yDisplayPosition + 16;
}
for (Slot slot : (List<Slot>) inventorySlots.inventorySlots) {
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
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
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);
private boolean mouseInside(Slot slot, int x, int y) {
return x >= slot.xDisplayPosition && x <= slot.xDisplayPosition + 16
&& y >= slot.yDisplayPosition
&& y <= slot.yDisplayPosition + 16;
}
for (int i = TileEntityAutoChisel.BASE; i < TileEntityAutoChisel.CHISEL; i++) {
if (autochisel.getStackInSlot(i) == null) {
drawSlotOverlay(this, x, y, inventorySlots.getSlot(i), xSize, 0, 8);
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
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) {
drawSlotOverlay(this, x, y, inventorySlots.getSlot(TileEntityAutoChisel.CHISEL), xSize, 24, 0);
}
}
for (int i = TileEntityAutoChisel.BASE; i < TileEntityAutoChisel.CHISEL; i++) {
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) {
padding /= 2;
gui.drawTexturedModalRect(x + (slot.xDisplayPosition - padding), y + (slot.yDisplayPosition - padding), u, v, 18 + padding, 18 + padding);
}
if (autochisel.getStackInSlot(TileEntityAutoChisel.CHISEL) == null) {
drawSlotOverlay(this, x, y, inventorySlots.getSlot(TileEntityAutoChisel.CHISEL), xSize, 24, 0);
}
}
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;
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 static team.chisel.Chisel.MOD_ID;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
@@ -13,8 +10,16 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Mouse;
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.inventory.ContainerChisel;
import team.chisel.inventory.InventoryChiselSelection;
@@ -24,12 +29,12 @@ import team.chisel.network.PacketHandler;
import team.chisel.network.message.MessageChiselMode;
import team.chisel.utils.General;
import static team.chisel.Chisel.MOD_ID;
@SideOnly(Side.CLIENT)
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_HEIGHT = 250;
public static final int GUI_WIDTH = 266;
@@ -84,9 +89,8 @@ public class GuiChisel extends GuiContainer {
}
private boolean showMode() {
return container.chisel != null
&& container.chisel.getItem() instanceof IChiselItem
&& ((IChiselItem) container.chisel.getItem()).hasModes(container.chisel);
return container.chisel != null && container.chisel.getItem() instanceof IChiselItem
&& ((IChiselItem) container.chisel.getItem()).hasModes(container.chisel);
}
@Override
@@ -94,11 +98,16 @@ public class GuiChisel extends GuiContainer {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
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()) {
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);
@@ -109,13 +118,22 @@ public class GuiChisel extends GuiContainer {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
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
func_146110_a(guiLeft, guiTop, 0, 0, xSize, ySize, TEXTURE_WIDTH, TEXTURE_HEIGHT);
Slot main = (Slot) container.inventorySlots.get(InventoryChiselSelection.normalSlots);
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;
import team.chisel.Chisel;
import team.chisel.config.Configurations;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.client.config.GuiConfig;
import team.chisel.Chisel;
import team.chisel.config.Configurations;
public class GuiChiselConfig extends GuiConfig {
public GuiChiselConfig(GuiScreen parent) {
super(parent, new ConfigElement<ConfigCategory>(Configurations.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), Chisel.MOD_ID, false, false, GuiConfig
.getAbridgedConfigPath(Configurations.config.toString()));
}
public GuiChiselConfig(GuiScreen parent) {
super(
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.gui.GuiScreen;
import cpw.mods.fml.client.IModGuiFactory;
public class GuiFactory implements IModGuiFactory {
@Override
public void initialize(Minecraft minecraftInstance) {
@Override
public void initialize(Minecraft minecraftInstance) {
}
}
@Override
public Class<? extends GuiScreen> mainConfigGuiClass() {
return GuiChiselConfig.class;
}
@Override
public Class<? extends GuiScreen> mainConfigGuiClass() {
return GuiChiselConfig.class;
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
return null;
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
return null;
}
@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
return null;
}
}
@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
return null;
}
}
Loaded 100 of 383 files, more files were not shown because too many files have changed in this diff. Show more