Compare commits

..

No commits in common. "master" and "MEMEPACK-8" have entirely different histories.

9300 changed files with 373047 additions and 1329843 deletions

View File

@ -1,16 +0,0 @@
root = true
[*]
charset = utf-8
end_of_line = crlf
indent_style = tab
indent_size = tab
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = off
[{*.info,*.json,*.mcmeta,*.md,*.cfg,*.yml,*.toml}]
tab_width = 2
[{*.info,*.mcmeta,*.cfg}]
end_of_line = lf

View File

@ -1,12 +0,0 @@
---
name: Issue template (mandatory)
about: Template for mod-related issues
title: ''
labels: ''
assignees: ''
---
### Describe the bug
Please describe the issue in as much detail as possible. Also mention the version of the mod you're running, if it's not the newest. In the case of a crash, please attach a crash log.

View File

@ -1,62 +0,0 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# 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://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
# Yes this is a mostly untouched Github actions template
name: Java CI with Gradle
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin' # Temurin because it's default :P
# Calculate days since 10/10/10
- name: Calculate days since 10/10/10
id: calculate_days
run: |
start_date="2010-10-10"
current_date=$(date +%Y-%m-%d)
days_since=$(( ($(date -d "$current_date" +%s) - $(date -d "$start_date" +%s)) / 86400 ))
echo "days=$days_since" >> $GITHUB_OUTPUT
# Update version files with proper sed syntax
- name: Update version files
run: |
days=${{ steps.calculate_days.outputs.days }}
# Use proper sed syntax for Linux runners
sed -i "s/public static final String VERSION = \".*\";/public static final String VERSION = \"1.0.27 BETA ($days)\";/" src/main/java/com/hbm/lib/RefStrings.java
sed -i "s/mod_build_number=.*/mod_build_number=$days/" gradle.properties
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
- name: Build with Gradle Wrapper
run: ./gradlew build
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.0
with:
# A file, directory or wildcard pattern that describes what to upload
path: ./build/libs

36
.gitignore vendored
View File

@ -1,31 +1,11 @@
# eclipse
/eclipse
/bin
/*.launch
/.settings
/.metadata
/.gradle/
/bin/
/build/
/eclipse/
/lib/
/.git/
/.gradle/
/.settings/
/.classpath
/.project
# idea
/out
/*.ipr
/*.iws
/*.iml
/.idea
# gradle
/build
/.gradle
# vscode
/.vscode
# other
/run
# CurseForge configuration
/curseforge.properties
# Changelog backup
/changelog.bak

View File

@ -1,43 +0,0 @@
# NTM Contribution Guidelines, Version 1
## Keep it concise
The best PRs are the ones that are small and to the point. The entire PR should focus on the thing you're trying to do, whether it's a fix or a feature PR. If your PR adds the Super Weldtronic 9000, there's no reason to include changes and tweaks to other things that have nothing to do with the Super Weldtronic 9000. If you think those changes are still necessary, open a new PR.
## Keep it clean
While admittedly my own code isn't the cleanest on earth, please try to keep terrible practices at a minimum. Also avoid things like unused variables and imports, mixed indentation styles or changes that have a high likelihood of breaking things.
Things you should also avoid include:
* new libraries (unless your PR absolutely needs it like for special mod compat)
* duplicate util functions (just use what we have, man)
* unused or half finished util functions (for obvious reasons)
* half finished or obviously broken features (à la "bob will fix it, i'm sure of it", please don't do that)
* updating the changelog (you're guaranteed to cause a merge conflict with that)
* any use of `I18n`, use `I18nUtil` instead
## Test your code
This should go without saying, but please don't PR code that was never actually tested or has obvious compiler errors in it.
**Addendum:** Because apparently some people think that testing is somehow optional, it is now **mandatory** to test the code both on a client and on a server. If the PR contains compat code, the game has to work **with and without** the mod that the compat is for.
## No refactor PRs
Your refactors suck ass and usually something ends up breaking.
## Communication
If you're planning on adding some new thing or doing a grand change, it's best to ask whether that's a good idea before spending 50 hours on a project that won't end up getting merged, due to issues that could have been entirely avoidable with communication.
## No guarantees
This ties together with the previous point - there's no guarantees that your PR gets merged no matter how hard or long you've worked on it. However, if you follow these guidelines, there's a good chance that your PR will be accepted.
## I want to help but don't know where to start
If you want to help the project, consider getting involved with the [wiki](https://nucleartech.wiki/) first. Writing an article is the easiest and quickest way of helping, and requires no programming knowledge. If you do know Java and want to help, consider these places first:
* Localization, i.e. translations in different language are always accepted.
* `IConfigurableMachine`, an interface that allows machines to be added to the `hbmMachines.json` config, is still not used by many machines.
* F1 Presentations, also known as "Stare" or "Jar Presentations", is a neat system of creating a short movie explaining functionality. All the relevant code can be found in `com.hbm.wiaj`.
* Adding tooltips to more machines, explaining some of the basics.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

162
README.md
View File

@ -1,144 +1,42 @@
# HBM's Nuclear Tech Mod for Minecraft 1.7.10
# Hbm-s-Nuclear-Tech-GIT
[NTM on Modrinth](https://modrinth.com/mod/ntm)
https://minecraft.curseforge.com/projects/hbms-nuclear-tech-mod?gameCategorySlug=mc-mods&projectID=235439
[NTM on CurseForge](https://www.curseforge.com/minecraft/mc-mods/hbms-nuclear-tech-mod)
For a 1.12 fork, check this link: https://github.com/Drillgon200/Hbm-s-Nuclear-Tech-GIT/releases
[Official NTM Wiki](https://nucleartech.wiki/wiki/Main_Page)
[Bobcat's Blog (the blag)](https://hbmmods.github.io/), you can find lengthy yapping, upcoming features and some secrets here.
**This is for 1.7.10!** For 1.12, check out these projects:
* NTM Community Edition (WarFactory): https://github.com/MisterNorwood/Hbm-s-Nuclear-Tech-CE
* NTM Extended Edition (Alcater): https://github.com/Alcatergit/Hbm-s-Nuclear-Tech-GIT/releases
* NTM Reloaded: https://github.com/TheOriginalGolem/Hbm-s-Nuclear-Tech-GIT/releases
For 1.18, try Martin's remake: https://codeberg.org/MartinTheDragon/Nuclear-Tech-Mod-Remake/releases
## Downloading pre-compiled versions from GitHub
Simply navigate to "Releases" on the right side of the page, download links for the compiled JAR as well as the corresponding source code are under the "Assets" category below the changelog. Make sure to review all changelogs when updating!
## Building from source
## Installation Instructions
Tired of waiting until the next version comes out? Here is a tutorial on how to compile the very newest version yourself:
Please note that these installation instructions are assuming you're running Microsoft Windows operating system. Linux users should know what to do by looking at the same guide.
1. Make sure you have JDK8 installed. If not, download it from [adoptium.net](https://adoptium.net/temurin/releases?version=8)
2. If you don't have git installed, download&install it from [here](https://git-scm.com/downloads).
3. Open up "Git Bash":
* Press Windows Button, type "Git Bash" and press ENTER
4. Enter the directory where you would like the sources to be (advanced users can use any directory)
```bash
cd $HOME/Downloads
```
5. Download the source code:
```bash
git clone https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
```
4. Enter the source code directory
```bash
cd Hbm-s-Nuclear-Tech-GIT
```
5. Build the mod
```bash
./gradlew build
```
6. Locate the mod file.
1. Open up your file explorer.
2. Navigate to the location where you downloaded the sources.
* If you exactly followed step 1, it should be `C:/Users/%USER%/Downloads`.
3. Enter the downloaded source tree.
4. Navigate to `build/libs`.
5. Grab the "HBM-NTM-<version>.jar" one.
* This is your mod file. You can install it like any other mod by putting it into your mods directory.
## Contributing
If you want to make some changes to the mod, follow this guide:
1. Follow steps 1-2 from *Building from source* section
2. Create a directory where the repository will reside, using a name that is not "Hbm-s-Nuclear-Tech-GIT"
3. Download the forge src from [here](https://files.minecraftforge.net/net/minecraftforge/forge/index_1.7.10.html) and extract it into the directory.
4. Download the source code:
* Using Git Bash, enter wherever your directory is located:
```bash
cd $HOME/Downloads
1. Download minecraft forge 1.7.10 src
2. Unpack it somewhere
3. Download the source and insert it into the same folder. This will overwrite a couple of files, for example build.gradle
4. Run `gradlew setupDecompWorkspace` on windows or `./gradlew setupDecompWorkspace` on linux (remember: do not take the name of root in vain). Running this command on a blank forge workspace will yield errors, so it's important you insert the mod's source in step 3. The source has corrected versions of guild.gradle and the gradle wrapper, if done correctly it should run just fine.
5. The `build.gradle` file will reference these following files:
```
* Download the source code:
```bash
git clone https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
```
* Move or copy every file within the new folder into your directory, making sure to overwrite any files.
* Feel free to delete the remaining folder and rename your directory (such as "Hbm-s-Nuclear-Tech-GIT")
5. Enter the source directory
```bash
cd Hbm-s-Nuclear-Tech-GIT
compile files('lib/CodeChickenCore-1.7.10-1.0.4.29-dev.jar')
compile files('lib/CodeChickenLib-1.7.10-1.1.3.140-dev.jar')
compile files('lib/NotEnoughItems-1.7.10-1.0.3.74-dev.jar')
```
6. Setup forge decompilation workspace
```bash
./gradlew setupDecompWorkspace
```
### Necessary for Eclipse users
7. Generate eclipse files
```bash
./gradlew eclipse
```
8. Switch to the **eclipse** folder inside your directory as a workspace.
9. If necessary, make sure that Eclipse is using the JDK8.
* On Linux, enter Windows>Preferences>Java>Installed JREs.
* Click search to navigate to /usr/lib/jvm and open it. Select the Java 8 JDK (e.g., java-8-openjdk).
* Afterwards, enter Execution Environment, select JavaSE-1.8, and select the jre listed as a **[perfect match]**
* On Windows, you may need to set your JAVA_HOME.
* Search for Environment Variables and click Edit the System Environment Variables.
* Click Environment Variables. Click new under System Variables.
* Enter **JAVA_HOME** under Variable Name and enter the path to your JDK 8 under Variable Value (e.g., C:\Program-Files\Java\jdk1.8.0_102).
* In Eclipse, now enter Windows>Preferences>Java>Installed JREs.
* Click **Add Standard VM**; in the JRE home, navigate to the directory where the JDK is installed, then click finish and select it.
10. Code!
which means you need to do one of the following things:
1) Find these exact versions of the dependencies, download them and put them into a folder called `libs` in your project's root folder. You can download a zip containing all files here: https://bit.ly/3fBxMq0
2) Find other versions, change the `build.gradle` file to reflect this difference and fix any potential errors this could cause (unlikely but not impossible)
3) Remove these dependencies from `build.gradle` along with all the API code. Note that this will break NEI-integration.
7. Open up the CMD in the root directory and run `gradlew build` on windows or `./gradlew build` on linux
8. Head over to `build/libs` and get the jar (named modid.jar)
9. Open the jar file with an archieve manager of your choice and insert the mod's asset folder into the jar's main directory
## Contributing animations
Weapon animations in NTM are stored in JSON files, which are used alongside OBJ models to produce high quality animations with reasonable filesizes. Import/Export Blender addons are available for versions 2.79, 3.2, and 4.0 in `tools`, and they should function reasonably well in newer versions as well. See the comments in the header of the export scripts for usage instructions.
If you want to do some changes in the code yourself, start here after 6. and continue with 7. once you are done:
1) Get the IDE of your choice and prepare the workspace (for eclipse, it's `gradlew eclipse` or `./gradlew eclipse`, then use the eclipse folder as workspace directory in eclipse)
2) Meddle with the code, you can always test the code in the IDE (eclipse has a convenient green play button)
3) Save changes, close the IDE and continue with 7. of the previous list
## Compatibility notice
NTM has certain behaviors intended to fix vanilla code or to increase compatibility in certain cases where it otherwise would not be possible. These behaviors have the potential of not playing well with other mods, and while no such cases are currently known, here's a list of them.
## Installation Instructions for a non-standard Workspace
### Thermos
Thermos servers (along with its forks such as Crucible) have a "performance" feature that causes all tile entity ticking to slow down if there's no player present in the same chunk. For obvious reasons, this will heavily impact machines and cause phantom issues that, not having knowledge of this "performance" feature, are near impossible to diagnose. By default, NTM will crash on servers running the Thermos base code and print a lengthy message informing server owners about this "performance" feature as well as how to fix the issues it causes. The error message is printed in plain English on the top of the crash log, failure to read (as well as understand) it will leave the server inoperable.
### Shaders
Shaders (loaded by either Optifine, Iris or otherwise) will in all likelihood break when a gun is held. This is because guns need to skip vanilla's first person item setup for the rendering, however shaders apparently use the setup step for setting certain GL states, and skipping that will break rendering. [Shader Fixer](https://modrinth.com/mod/shader-fixer) is a mod with various fixes, among which is explicit compatibility for NTM's guns.
### Optifine
One of the most common "performance" mods on 1.7.10, Optifine, achieves an increase in performance by breaking small things in spots that are usually hard to notice, although this can cause severe issues with NTM. A short list of problems, along with some solutions, follows:
* Get rid of Optifine and use one of the many [other, less intrusive performance mods](https://gist.github.com/makamys/7cb74cd71d93a4332d2891db2624e17c).
* Blocks with connected textures may become invisible. This can be fixed by toggling triangulation (I do not know what or where this setting is, I just have been told that it exists and that it can fix the problem) or multicore chunk rendering (same here).
* Entity "optimization" has a tendency to break chunkloading, this is especially noticeable with missiles which rely heavily on chunkloading to work, causing them to freeze mid-air. It's unclear what setting might fix this, and analysis of Optifine's source code (or rather, lack thereof) has not proven useful either.
### Angelica
In older versions, Angelica caused issues regarding model rendering, often times making 3D models transparent. Ever since the switch to VBOs, models work fine. Another issue was blocks with connected textures not rendering at all, but this too was fixed, meaning as of time of writing there are no major incompatibilities known with Angelica. However there a few minor issues that persist, but those can be fixed:
* Often times when making a new world, all items appear as white squares. Somehow, scrolling though the NEI pages fixes this permanently
* Reeds will render weirdly, this is an incompatibility with the "Compact Vertex Format" feature. Disabling it will make reeds look normal. Alternatively, reed rendering can be disabled by using `/ntmclient set RENDER_REEDS false`, which works around the issue by not rendering the underwater portion of reeds at all.
### Skybox chainloader
NTM adds a few small things to the skybox using a custom skybox renderer. Minecraft can only have a single skybox renderer loaded, so setting the skybox to the NTM custom one would break compatibility with other mods' skyboxes. To mend this, NTM employs a **chainloader**. This chainloader will detect if a different skybox is loaded, save a reference to that skybox and then use NTM's skybox, which when used will also make sure to run the previous modded skybox renderer. In the event that NTM's skybox were to cause trouble, it can be disabled with the config option `1.31_enableSkyboxes`.
### Custom world provider
A world provider is a piece of code that minecraft can load to determine certain aspects of how the world should be handled, like light levels, sky color, day/night cycle, etc. In order for the Tom impact effects to work, NTM employs such a world provider, although this is known to cause issues with Hardcore Darkness. The world provider can be disabled with the config option `1.32_enableImpactWorldProvider`.
### Stat re-registering
An often overlooked aspect of Minecraft is its stats, the game keeps track of how many of an item were crafted, placed, broken, etc. By default, Minecraft can only handle vanilla items, modded items would not show up in the stats window. Forge does little to fix this, and since NTM has to keep track of certain things (such as the use of an acidizer for spawning Mask Man) it will run its own code which re-registers all stats for all modded items. In the event that re-registering causes issues, or another mod already does this better already, this behavior can be disabled with the config option `1.33_enableStatReRegistering`.
### Keybind overlap
An often annoying aspect of modded Minecraft is its keybinds. Even though multiple binds can be assigned the same key, all but one will show up as "conflicting" and only the non-conflicting one will work. Which one this is is usually arbitrary, and there is no reason to have such limitation. Often times keybinds are only applicable in certain scenarios, and a commonly found degree of overlap is within reason. Therefore, NTM will run its own key handling code which allows conflicting keybinds to work. If there should be any issues with this behavior, it can be disabled with the config option `1.34_enableKeybindOverlap`.
### Render distance capping
There is a common crash caused by Minecraft's render distance slider going out of bounds, this usually happens when uninstalling a mod that extends the render distance (like Optifine) or when downgrading the Minecraft version (newer versions have higher render distance caps). To prevent crashes, the mod will attempt to decrease the render distance if it's above 16 unless Optifine is installed. If this behavior is not desired (for example, because another mod that allows higher render distance is being used), it can be disabled with the config option `1.25_enableRenderDistCheck`.
### Log spam caused by ComparableStack
In some modpacks (exact mods needed to replicate this are unknown), it's possible that invalid registered items may cause problems for NEI handlers. To prevent crashes, the ComparableStack class used to represent stacks will default to a safe registered item, and print a log message. In certain situations, this may cause dozens of errors to be printed at once, potentially even lagging the game. If that happens, the log message (but not the error handling) can be disabled with the config option `1.28_enableSilentCompStackErrors`.
### Sound system limit
By default, the sound system only allows a limited amount of sounds to run at once (28 regular sounds and 4 streaming sounds), this causes issues when there's many machines running at once, since their looped sounds will constantly interrupt each other, causing them to immediately restart, which in some isolated cases has proven to cause massive lagspikes. To prevent this, NTM will increase the sound limit to 1000 regular sounds and 50 streaming sounds, this can be disabled with the config option `1.39_enableSoundExtension`.
I cannot offer any help on compiling the mod in a GregTech-workspace as I never managed to get it to work myself, here's a rough guide on how it might be possible:
1. Prepare the workspace
2. Slap this mod's `src` into the project's root directory
3. Pray
# License
This software is licensed under the GNU Lesser General Public License version 3. In short: This software is free, you may run the software freely, create modified versions, distribute this software and distribute modified versions, as long as the modified software too has a free software license (with an exception for linking to this software, as stated by the "Lesser" part of the LGPL, where this may not be required). You win this round, Stallman. The full license can be found in the `LICENSE` and `LICENSE.LESSER` files.
This software is licensed under the GNU Public License version 3. In short: This software is free, you may run the software freely, create modified versions, distribute this software and distribute modified versions, as long as the modified software too has a free software license. You win this round, Stallman. The full license can be found in the `LICENSE` file.

View File

@ -1,189 +1,62 @@
import org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
buildscript {
repositories {
maven { url = 'https://maven.ntmr.dev/proxy/' }
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://plugins.gradle.org/m2' }
mavenCentral()
}
dependencies {
classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.0.+') {changing = true}
}
repositories {
mavenCentral()
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url = "https://repo1.maven.org/maven2/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}
apply plugin: 'forge'
apply plugin: 'curseforge'
if(Files.exists(Paths.get("curseforge.properties"))) {
// Load CurseForge configuration
ext.cfprops = parseConfig(file("curseforge.properties"))
}
def version_name = version = mod_version
if(!mod_build_number.isEmpty()) {
version_name = mod_version + "_X" + mod_build_number
version = "[${version_name}]"
}
group = "com.hbm" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "HBM-NTM"
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
version = "1.0"
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "modid"
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "eclipse"
}
// A little hack to fix codechicken's crazy maven structure (at least in 1.7.10)
eclipse.classpath.file.whenMerged { cp ->
// Find all codechicken source jars
def srcent = cp.entries.findAll { entry -> entry.path.contains("codechicken") && entry.path.endsWith("-src.jar") }
// Remove them from classpath
cp.entries.removeAll srcent
// Map the source entries to their dev counterparts based on basename
Map<String, File> srcmap = new HashMap<String, File>()
srcent.forEach { entry ->
def file = new File(entry.path)
srcmap.put(file.getName().replace("-src.jar", "-dev.jar"), file)
}
// Create file reference factory
def fileref = new FileReferenceFactory()
// Find all codechicken development jars
cp.entries.findAll { entry -> entry.path.contains("codechicken") && entry.path.endsWith("-dev.jar") }.forEach { entry ->
File srcmapping = new File(entry.path) // Initialize the srcmapping from the dev jar path
srcmapping = srcmap.get(srcmapping.getName()) // Transform it using the sourcemap
entry.sourcePath = fileref.fromFile(srcmapping) // Set the source path
}
}
repositories {
maven {
name = 'Blerg'
url = 'https://maven.ntmr.dev/proxy/'
}
maven {
name = 'ModMaven'
url = 'https://modmaven.dev'
}
maven {
name = "gt"
url = "https://gregtech.mechaenetia.com/"
}
//maven {
// name = "CurseForge"
// url = "https://minecraft.curseforge.com/api/maven/"
//}
maven {
name = "Jitpack"
url = "https://jitpack.io"
}
maven {
name = "CurseMaven"
url = "https://cursemaven.com"
}
maven {
name = "OpenComputers"
url = "https://maven.cil.li/"
}
version = "1.7.10-10.13.4.1558-1.7.10"
runDir = "eclipse"
}
dependencies {
implementation 'codechicken:CodeChickenCore:1.7.10-1.0.4.29:dev'
compileOnly 'codechicken:CodeChickenCore:1.7.10-1.0.4.29:src'
implementation 'codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev'
compileOnly 'codechicken:CodeChickenLib:1.7.10-1.1.3.140:src'
implementation 'codechicken:NotEnoughItems:1.7.10-1.0.3.74:dev'
compileOnly 'codechicken:NotEnoughItems:1.7.10-1.0.3.74:src'
compileOnly "inventorytweaks:InventoryTweaks:1.59-dev:deobf"
implementation "li.cil.oc:OpenComputers:MC1.7.10-1.5.+:api"
compileOnly "com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta.56-GTNH:dev"
compile files('lib/CodeChickenCore-1.7.10-1.0.4.29-dev.jar')
compile files('lib/CodeChickenLib-1.7.10-1.1.3.140-dev.jar')
compile files('lib/NotEnoughItems-1.7.10-1.0.3.74-dev.jar')
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
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
filesMatching('mcmod.info') {
// replace version, mcversion and credits
expand([
version: version_name,
credits: project.credits
])
}
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
// add AT to meta-inf
jar {
manifest {
attributes 'FMLAT': 'HBM_at.cfg'
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
task version {
doFirst {
println project.version
}
}
if(Files.exists(Paths.get("curseforge.properties"))) {
curse {
apiKey = cfprops.api_key
projectId = cfprops.project_id
releaseType = "release"
displayName = "Hbm's Nuclear Tech Mod " + version_name.replace("_", "") + " for Minecraft 1.7.10"
gameVersions.addAll([
"Forge",
"Java 8",
"Client", "Server"
])
if (Files.exists(Paths.get("changelog"))) {
changelog = String.join("\r\n", Files.readAllLines(Paths.get("changelog")))
// Perform a backup of the changelog and create a new file for next changes
doLast {
Files.move(Paths.get("changelog"), Paths.get("changelog.bak"), StandardCopyOption.REPLACE_EXISTING)
Files.createFile(Paths.get("changelog"))
}
}
}
}
// Properties file parsing helper
static def parseConfig(File config) {
config.withReader {
def prop = new Properties()
prop.load(it)
return (new ConfigSlurper().parse(prop))
}
apply plugin: 'java'
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

View File

@ -1,27 +0,0 @@
## Changed
* Updated russian localization
* Rad absorbers now use metadata, existing blocks will be converted automatically
* Fissure bombs that go off in crater biomes now create fissures with metadata 1 which creates radioactive volcanic lava
* If a crater biome is created on top of an existing fissure, it will keep producing normal volcanic lava
* Simplified the battery socket's client packets, reducing CPU load
* Muzzle flashes on guns now work in third person mode, including on other players and on NPCs, making it more apparent when you're being fired at
* This includes non-standard special effects like the .44 gap flash and the .35-800 ejector plume
* Removed the old unused satelite deco blocks, freeing up 6 block IDs
* Crucibles that smelt metal with no template set will no place the metal in the recipe stack instead of the waste stack, this should make it easier to get a recipe to work in the many, many cases where people add the template after smelting the material
* Battery sockets and the FENSU now support the copy tool
* Removed unused displaylist support from the model loader
* DLs have been long phased out in favor of VBOs anyway
* Rebranded canned horse slime
* Now with extra bone marrow
* Updated the deuterium tower's model
* Increased the energy requirement for welding osmiridium
# Fixed
* Potentially fixed yet another issue regarding crates
* Fixed battery socket `fillpercent` RoR function always assuming a max power of 1
* Fixed issue where multiblock ports would generate many OpenComputers component entries
* Fixed RBMK automatic control rods having incorrect settings when using the copy tool
* Fixed battery sockets producing junk debug data in the logs
* Fixed an issue where the charging station would crash when trying to charge certain items
* Fixed the DFC's core component not dropping its contents when mined
* Fixed audio problems with guns

View File

@ -1,5 +0,0 @@
# CurseForge API token (obtainable from https://legacy.curseforge.com/account/api-tokens)
api_key=
# CurseForge project ID
project_id=

View File

@ -1,80 +0,0 @@
mod_version=1.0.27
# Empty build number makes a release type
mod_build_number=5572
credits=HbMinecraft,\
\ rodolphito (explosion algorithms),\
\ grangerave (explosion algorithms),\
\ Hoboy (textures, models),\
\ Drillgon200 (effects, models),\
\ MartinTheDragon (calculator, chunk-based fallout, bendable cranes, pipe improvements, PWR sounds),\
\ Alcater (GUI textures),\
\ MellowArpeggiation (new animation system, turbine sounds, sound fixes, industrial lights, conveyor wand, NBT structures, MSU displays),\
\ Pheo (textures, various machines, models, weapons),\
\ Vær (gas centrifuges, better worldgen, ZIRNOX, CP-1 parts, starter guide, new cyclotron, weapon animations),\
\ UFFR (RTG pellets, guns, casings, euphemium capacitor, nucleartech.wiki),\
\ LePeep (coilgun model, BDCL QC),\
\ Adam29 (liquid petroleum, ethanol, electric furnace),\
\ Pvndols (thorium fuel recipe, gas turbine),\
\ JamesH2 (blood mechanics, nitric acid, particle emitter),\
\ Lazzzycat (structures, mob gear),\
\ PastaBaguette (coal horse decal),\
\ Doctor17 (russian localization)),\
\ Pashtet (russian localization),\
\ 7H40 (russian localization),\
\ RayzerHan (russian localization),\
\ Bismarck (chinese localization),\
\ Creeper-banner (chinese localization),\
\ 5467864 (chinese localization),\
\ eeeeee0a (chinese localization),\
\ hz0909adc (chinese localization),\
\ LSKLW (chinese localization),\
\ R-Kaenbyou (chinese localization),\
\ scp-000000000 (chinese localization),\
\ UnnameTokiko (chinese localization),\
\ Herobrine 457985 (chinese localization),\
\ xxwinhere (chinese localization),\
\ Nycticoraxnightheron (chinese localization),\
\ NarekoMichigami810 (chinese localization),\
\ Maksymisio (polish localization)\
\ el3ctro4ndre (italian localization),\
\ Goaty1208 (italian localization),\
\ Pu-238 (Tom impact effects),\
\ Frooz (gun models),\
\ VT-6/24 (models, textures),\
\ Nos (models),\
\ WushiThe (models),\
\ Minecreep (models),\
\ ackbarcrowbars (models),\
\ haru315 (spiral point algorithm),\
\ mlbv (threaded MK5),\
\ 70k (textures, glyphid AI, strand caster, electrolyzer changes, cryolite),\
\ instantnootles (concept artist),\
\ Sten89 (models),\
\ Pixelguru26 (textures),\
\ TheBlueHat (textures),\
\ Burningwater202 (laminate glass),\
\ TehTemmie (reacher radiation function),\
\ Silly541 (config for safe ME drives),\
\ Voxelstice (OpenComputers integration, turbine spinup),\
\ BallOfEnergy1 (OpenComputers integration, RBMK and packet optimization, crate backpacks),\
\ PewPewCricket (OpenComputers integration),\
\ kelllllen (OpenComputers integration),\
\ sdddddf80 (recipe configs, chinese localization, custom machine holograms),\
\ Abel1502 (abilities GUI, optimization, crate upgrade recipes, strand caster improvements, varous tweaks),\
\ Darek505 (armor rendering compatibility fix),\
\ ranch21 (improved HUD gauges),\
\ SuperCraftAlex (tooltips)\
\ Ice-Arrow (research reactor tweaks),\
\ 245tt (anvil GUI improvements),\
\ KoblizekXD (doors),\
\ FOlkvangrField (custom machine parts),\
\ RosaTryp (centrifuge config),\
\ Toshayo (satellite loot system, project settings, gradle curse task, OpenComputers integration, fluid counter valve),\
\ Dash (PA particle serialization fix),\
\ archiecarrot123 (armor rendering compatibility fix),\
\ mikkerlo (mining laser & builder's jetpack improvements),\
\ icomet (refactoring),\
\ martemen (project settings),\
\ OvermindDL1 (project settings),\
\ impbk2002 (project settings)\

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip

View File

@ -1,10 +0,0 @@
package api.hbm.block;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IBlowable { //sloppy toppy
/** Called server-side when a fan blows on an IBlowable in range every tick. */
public void applyFan(World world, int x, int y, int z, ForgeDirection dir, int dist);
}

View File

@ -1,25 +0,0 @@
package api.hbm.block;
import com.hbm.inventory.material.Mats.MaterialStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface ICrucibleAcceptor {
/*
* Pouring: The metal leaves the channel/crucible and usually (but not always) falls down. The additional double coords give a more precise impact location.
* Also useful for entities like large crucibles since they are filled from the top.
*/
//public boolean canAcceptPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack);
public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack);
public MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack);
/*
* Flowing: The "safe" transfer of metal using a channel or other means, usually from block to block and usually horizontally (but not necessarily).
* May also be used for entities like minecarts that could be loaded from the side.
*/
//public boolean canAcceptFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack);
public boolean canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack);
public MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack);
}

View File

@ -1,43 +0,0 @@
package api.hbm.block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@Deprecated
public interface IDrillInteraction {
/**
* Whether the breaking of the block should be successful. Will destroy the block and not drop anything from clusters.
* Should use a random function, otherwise the clusters will stay there indefinitely printing free ore.
* @param world
* @param x
* @param y
* @param z
* @param drill Might be a tool, tile entity or anything that breaks blocks
* @return
*/
public boolean canBreak(World world, int x, int y, int z, int meta, IMiningDrill drill);
/**
* Returns an itemstack, usually when the block is not destroyed. Laser drills may drop this and mechanical drills will add it to their inventories.
* @param world
* @param x
* @param y
* @param z
* @param drill Might be a tool, tile entity or anything that breaks blocks
* @return
*/
public ItemStack extractResource(World world, int x, int y, int z, int meta, IMiningDrill drill);
/**
* The hardness that should be considered instead of the hardness value of the block itself
* @param world
* @param x
* @param y
* @param z
* @param meta
* @param drill
* @return
*/
public float getRelativeHardness(World world, int x, int y, int z, int meta, IMiningDrill drill);
}

View File

@ -1,15 +0,0 @@
package api.hbm.block;
import com.hbm.entity.item.EntityTNTPrimedBase;
import net.minecraft.world.World;
public interface IFuckingExplode {
// Anything that can be detonated by another explosion should implement this and spawn an EntityTNTPrimedBase when hit by an explosion
// This prevents chained explosions causing a stack overflow
// Note that the block can still safely immediately explode, as long as the source isn't another explosion
public void explodeEntity(World world, double x, double y, double z, EntityTNTPrimedBase entity);
}

View File

@ -1,10 +0,0 @@
package api.hbm.block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IInsertable { //uwu
public boolean insertItem(World world, int x, int y, int z, ForgeDirection dir, ItemStack stack);
}

View File

@ -1,11 +0,0 @@
package api.hbm.block;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
//applicable to blocks and tile entities
public interface ILaserable {
public void addEnergy(World world, int x, int y, int z, long energy, ForgeDirection dir);
}

View File

@ -1,23 +0,0 @@
package api.hbm.block;
@Deprecated
public interface IMiningDrill {
/**
* What era the drill belongs to, usually for IDrillInteraction to adjust outputs
* @return
*/
public DrillType getDrillTier();
/**
* An arbitrary "rating" of the drill. Hand powered pre-industrial drills would be <10, the auto mining drill is 50 and the laser miner is 100.
* @return
*/
public int getDrillRating();
public static enum DrillType {
PRIMITIVE,
INDUSTRIAL,
HITECH
}
}

View File

@ -1,6 +0,0 @@
package api.hbm.block;
public interface IPileNeutronReceiver {
public void receiveNeutrons(int n);
}

View File

@ -1,9 +0,0 @@
package api.hbm.block;
import net.minecraft.world.World;
public interface IRadioControllable {
public String[] getVariables(World world, int x, int y, int z);
public void receiveSignal(World world, int x, int y, int z, String channel, String signal);
}

View File

@ -0,0 +1,9 @@
package api.hbm.block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public interface IScrewable {
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ);
}

View File

@ -1,47 +0,0 @@
package api.hbm.block;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IToolable {
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool);
public static enum ToolType {
SCREWDRIVER,
HAND_DRILL,
DEFUSER,
WRENCH,
TORCH,
BOLT;
public List<ItemStack> stacksForDisplay = new ArrayList();
private static HashMap<ComparableStack, ToolType> map = new HashMap();
public void register(ItemStack stack) {
stacksForDisplay.add(stack);
}
public static ToolType getType(ItemStack stack) {
if(!map.isEmpty()) {
return map.get(new ComparableStack(stack));
}
for(ToolType type : ToolType.values()) {
for(ItemStack tool : type.stacksForDisplay) {
map.put(new ComparableStack(tool), type);
}
}
return map.get(new ComparableStack(stack));
}
}
}

View File

@ -1,12 +0,0 @@
package api.hbm.conveyor;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public interface IConveyorBelt {
/** Returns true if the item should stay on the conveyor, false if the item should drop off */
public boolean canItemStay(World world, int x, int y, int z, Vec3 itemPos);
public Vec3 getTravelLocation(World world, int x, int y, int z, Vec3 itemPos, double speed);
public Vec3 getClosestSnappingPosition(World world, int x, int y, int z, Vec3 itemPos);
}

View File

@ -1,8 +0,0 @@
package api.hbm.conveyor;
import net.minecraft.item.ItemStack;
public interface IConveyorItem {
public ItemStack getItemStack();
}

View File

@ -1,8 +0,0 @@
package api.hbm.conveyor;
import net.minecraft.item.ItemStack;
public interface IConveyorPackage {
public ItemStack[] getItemStacks();
}

View File

@ -1,23 +0,0 @@
package api.hbm.conveyor;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnterableBlock {
/**
* Returns true of the moving item can enter from the given side. When this happens, the IConveyorItem will call onEnter and despawn
* @param world
* @param x
* @param y
* @param z
* @param dir
* @param entity
* @return
*/
public boolean canItemEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorItem entity);
public void onItemEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorItem entity);
public boolean canPackageEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorPackage entity);
public void onPackageEnter(World world, int x, int y, int z, ForgeDirection dir, IConveyorPackage entity);
}

View File

@ -0,0 +1,14 @@
package api.hbm.energy;
import net.minecraft.item.ItemStack;
public interface IBatteryItem {
public void chargeBattery(ItemStack stack, long i);
public void setCharge(ItemStack stack, long i);
public void dischargeBattery(ItemStack stack, long i);
public long getCharge(ItemStack stack);
public long getMaxCharge();
public long getChargeRate();
public long getDischargeRate();
}

View File

@ -0,0 +1,12 @@
package api.hbm.energy;
/**
* For compatible cables with no buffer, using the IPowertNet. You can make your own cables with IEnergyConnector as well, but they won't join their power network.
* @author hbm
*/
public interface IEnergyConductor extends IEnergyConnector {
public IPowerNet getPowerNet();
public void setPowerNet(IPowerNet network);
}

View File

@ -0,0 +1,36 @@
package api.hbm.energy;
import net.minecraftforge.common.util.ForgeDirection;
/**
* For anything that connects to power and can be transferred power to, the bottom-level interface.
* @author hbm
*/
public interface IEnergyConnector {
/**
* Returns the amount of power that was added
* @param power
* @return
*/
public long transferPower(long power);
/**
* Whether the given side can be connected to
* @param dir
* @return
*/
public boolean canConnect(ForgeDirection dir);
/**
* The current power of either the machine or an entire network
* @return
*/
public long getPower();
/**
* The capacity of either the machine or an entire network
* @return
*/
public long getMaxPower();
}

View File

@ -0,0 +1,13 @@
package api.hbm.energy;
/**
* For machines and things that have an energy buffer and are affected by EMPs
* @author hbm
*/
public interface IEnergyUser extends IEnergyConnector {
/**
* Not to be used for actual energy transfer, rather special external things like EMPs
*/
public void setPower();
}

View File

@ -0,0 +1,22 @@
package api.hbm.energy;
import java.util.List;
/**
* Not mandatory to use, but making your cables IPowerNet-compliant will allow them to connect to NTM cables.
* Cables will still work without it as long as they implement IEnergyConductor (or even IEnergyConnector) + self-built network code
* @author hbm
*/
public interface IPowerNet {
public void join(IPowerNet network);
public IPowerNet subscribe(IEnergyConductor conductor);
public void unsubscribe(IEnergyConductor conductor);
public void destroy();
public boolean isValid();
public List<IEnergyConductor> getSubscribers();
}

View File

@ -0,0 +1,50 @@
package api.hbm.energy;
import java.util.ArrayList;
import java.util.List;
/**
* Basic IPowerNet implementation. The behavior of this demo might change inbetween releases, but the API remains the same.
* For more consistency please implement your own IPowerNet.
* @author hbm
*/
public class PowerNet implements IPowerNet {
private boolean valid = true;
private List<IEnergyConductor> subscribers = new ArrayList();
@Override
public void join(IPowerNet network) { }
@Override
public IPowerNet subscribe(IEnergyConductor conductor) {
if(conductor.getPowerNet() != null)
conductor.getPowerNet().unsubscribe(conductor);
conductor.setPowerNet(this);
this.getSubscribers().add(conductor);
return this;
}
@Override
public void unsubscribe(IEnergyConductor conductor) {
conductor.setPowerNet(null);
this.getSubscribers().remove(conductor);
}
@Override
public List<IEnergyConductor> getSubscribers() {
return null;
}
@Override
public void destroy() {
this.valid = false;
}
@Override
public boolean isValid() {
return this.valid;
}
}

View File

@ -1,43 +0,0 @@
package api.hbm.energymk2;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public interface IBatteryItem {
public void chargeBattery(ItemStack stack, long i);
public void setCharge(ItemStack stack, long i);
public void dischargeBattery(ItemStack stack, long i);
public long getCharge(ItemStack stack);
public long getMaxCharge(ItemStack stack);
public long getChargeRate(ItemStack stack);
public long getDischargeRate(ItemStack stack);
/** Returns a string for the NBT tag name of the long storing power */
public default String getChargeTagName() {
return "charge";
}
/** Returns a string for the NBT tag name of the long storing power */
public static String getChargeTagName(ItemStack stack) {
return ((IBatteryItem) stack.getItem()).getChargeTagName();
}
/** Returns an empty battery stack from the passed ItemStack, the original won't be modified */
public static ItemStack emptyBattery(ItemStack stack) {
if(stack != null && stack.getItem() instanceof IBatteryItem) {
String keyName = getChargeTagName(stack);
ItemStack stackOut = stack.copy();
stackOut.stackTagCompound = new NBTTagCompound();
stackOut.stackTagCompound.setLong(keyName, 0);
return stackOut.copy();
}
return null;
}
/** Returns an empty battery stack from the passed Item */
public static ItemStack emptyBattery(Item item) {
return item instanceof IBatteryItem ? emptyBattery(new ItemStack(item)) : null;
}
}

View File

@ -1,23 +0,0 @@
package api.hbm.energymk2;
import com.hbm.lib.Library;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energymk2.Nodespace.PowerNode;
import net.minecraft.tileentity.TileEntity;
public interface IEnergyConductorMK2 extends IEnergyConnectorMK2 {
public default PowerNode createNode() {
TileEntity tile = (TileEntity) this;
return new PowerNode(new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord)).setConnections(
new DirPos(tile.xCoord + 1, tile.yCoord, tile.zCoord, Library.POS_X),
new DirPos(tile.xCoord - 1, tile.yCoord, tile.zCoord, Library.NEG_X),
new DirPos(tile.xCoord, tile.yCoord + 1, tile.zCoord, Library.POS_Y),
new DirPos(tile.xCoord, tile.yCoord - 1, tile.zCoord, Library.NEG_Y),
new DirPos(tile.xCoord, tile.yCoord, tile.zCoord + 1, Library.POS_Z),
new DirPos(tile.xCoord, tile.yCoord, tile.zCoord - 1, Library.NEG_Z)
);
}
}

View File

@ -1,24 +0,0 @@
package api.hbm.energymk2;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Interface for all blocks that should visually connect to cables without having an IEnergyConnector tile entity.
* This is meant for BLOCKS
* @author hbm
*
*/
public interface IEnergyConnectorBlock {
/**
* Same as IEnergyConnector's method but for regular blocks that might not even have TEs. Used for rendering only!
* @param world
* @param x
* @param y
* @param z
* @param dir
* @return
*/
public boolean canConnect(IBlockAccess world, int x, int y, int z, ForgeDirection dir);
}

View File

@ -1,16 +0,0 @@
package api.hbm.energymk2;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyConnectorMK2 {
/**
* Whether the given side can be connected to
* dir refers to the side of this block, not the connecting block doing the check
* @param dir
* @return
*/
public default boolean canConnect(ForgeDirection dir) {
return dir != ForgeDirection.UNKNOWN;
}
}

View File

@ -1,29 +0,0 @@
package api.hbm.energymk2;
import com.hbm.util.CompatEnergyControl;
import api.hbm.tile.ILoadedTile;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
/** DO NOT USE DIRECTLY! This is simply the common ancestor to providers and receivers, because all this behavior has to be excluded from conductors! */
public interface IEnergyHandlerMK2 extends IEnergyConnectorMK2, ILoadedTile {
public long getPower();
public void setPower(long power);
public long getMaxPower();
public static final boolean particleDebug = false;
public default Vec3 getDebugParticlePosMK2() {
TileEntity te = (TileEntity) this;
Vec3 vec = Vec3.createVectorHelper(te.xCoord + 0.5, te.yCoord + 1, te.zCoord + 0.5);
return vec;
}
public default void provideInfoForECMK2(NBTTagCompound data) {
data.setLong(CompatEnergyControl.L_ENERGY_HE, this.getPower());
data.setLong(CompatEnergyControl.L_CAPACITY_HE, this.getMaxPower());
}
}

View File

@ -1,67 +0,0 @@
package api.hbm.energymk2;
import com.hbm.handler.threading.PacketThreading;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import api.hbm.energymk2.Nodespace.PowerNode;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/** If it sends energy, use this */
public interface IEnergyProviderMK2 extends IEnergyHandlerMK2 {
/** Uses up available power, default implementation has no sanity checking, make sure that the requested power is lequal to the current power */
public default void usePower(long power) {
this.setPower(this.getPower() - power);
}
public default long getProviderSpeed() {
return this.getMaxPower();
}
public default void tryProvide(World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = TileAccessCache.getTileOrCache(world, x, y, z);
boolean red = false;
if(te instanceof IEnergyConductorMK2) {
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
if(con.canConnect(dir.getOpposite())) {
PowerNode node = Nodespace.getNode(world, x, y, z);
if(node != null && node.net != null) {
node.net.addProvider(this);
red = true;
}
}
}
if(te instanceof IEnergyReceiverMK2 && te != this) {
IEnergyReceiverMK2 rec = (IEnergyReceiverMK2) te;
if(rec.canConnect(dir.getOpposite()) && rec.allowDirectProvision()) {
long provides = Math.min(this.getPower(), this.getProviderSpeed());
long receives = Math.min(rec.getMaxPower() - rec.getPower(), rec.getReceiverSpeed());
long toTransfer = Math.min(provides, receives);
toTransfer -= rec.transferPower(toTransfer);
this.usePower(toTransfer);
}
}
if(particleDebug) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "network");
data.setString("mode", "power");
double posX = x + 0.5 - dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posY = y + 0.5 - dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posZ = z + 0.5 - dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
data.setDouble("mX", dir.offsetX * (red ? 0.025 : 0.1));
data.setDouble("mY", dir.offsetY * (red ? 0.025 : 0.1));
data.setDouble("mZ", dir.offsetZ * (red ? 0.025 : 0.1));
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
}
}
}

View File

@ -1,95 +0,0 @@
package api.hbm.energymk2;
import com.hbm.handler.threading.PacketThreading;
import com.hbm.interfaces.NotableComments;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energymk2.Nodespace.PowerNode;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/** If it receives energy, use this */
@NotableComments
public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 {
public default long transferPower(long power) {
if(power + this.getPower() <= this.getMaxPower()) {
this.setPower(power + this.getPower());
return 0;
}
long capacity = this.getMaxPower() - this.getPower();
long overshoot = power - capacity;
this.setPower(this.getMaxPower());
return overshoot;
}
public default long getReceiverSpeed() {
return this.getMaxPower();
}
/** Whether a provider can provide power by touching the block (i.e. via proxies), bypassing the need for a network entirely */
public default boolean allowDirectProvision() { return true; }
public default void trySubscribe(World world, DirPos pos) { trySubscribe(world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); }
public default void trySubscribe(World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = TileAccessCache.getTileOrCache(world, x, y, z);
boolean red = false;
if(te instanceof IEnergyConductorMK2) {
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
if(!con.canConnect(dir.getOpposite())) return;
PowerNode node = Nodespace.getNode(world, x, y, z);
if(node != null && node.net != null) {
node.net.addReceiver(this);
red = true;
}
}
if(particleDebug) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "network");
data.setString("mode", "power");
double posX = x + 0.5 + dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posY = y + 0.5 + dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posZ = z + 0.5 + dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
data.setDouble("mX", -dir.offsetX * (red ? 0.025 : 0.1));
data.setDouble("mY", -dir.offsetY * (red ? 0.025 : 0.1));
data.setDouble("mZ", -dir.offsetZ * (red ? 0.025 : 0.1));
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
}
}
public default void tryUnsubscribe(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof IEnergyConductorMK2) {
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
PowerNode node = con.createNode();
if(node != null && node.net != null) {
node.net.removeReceiver(this);
}
}
}
public enum ConnectionPriority {
LOWEST,
LOW,
NORMAL,
HIGH,
HIGHEST
}
public default ConnectionPriority getPriority() {
return ConnectionPriority.NORMAL;
}
}

View File

@ -1,62 +0,0 @@
package api.hbm.energymk2;
import com.hbm.interfaces.NotableComments;
import com.hbm.uninos.GenNode;
import com.hbm.uninos.UniNodespace;
import com.hbm.uninos.networkproviders.PowerNetProvider;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import net.minecraft.world.World;
/**
* The dead fucking corpse of nodespace MK1.
* A fantastic proof of concept, but ultimately it was killed for being just not that versatile.
* This class is mostly just a compatibility husk that should allow uninodespace to slide into the mod with as much lubrication as it deserves.
*
* @author hbm
*/
@NotableComments
public class Nodespace {
public static final PowerNetProvider THE_POWER_PROVIDER = new PowerNetProvider();
@Deprecated public static PowerNode getNode(World world, int x, int y, int z) {
return (PowerNode) UniNodespace.getNode(world, x, y, z, THE_POWER_PROVIDER);
}
@Deprecated public static void createNode(World world, PowerNode node) {
UniNodespace.createNode(world, node);
}
@Deprecated public static void destroyNode(World world, int x, int y, int z) {
UniNodespace.destroyNode(world, x, y, z, THE_POWER_PROVIDER);
}
@NotableComments
public static class PowerNode extends GenNode<PowerNetMK2> {
/**
* Okay so here's the deal: The code has shit idiot brain fungus. I don't know why. I re-tested every part involved several times.
* I don't know why. But for some reason, during neighbor checks, on certain arbitrary fucking places, the joining operation just fails.
* Disallowing nodes to create new networks fixed the problem completely, which is hardly surprising since they wouldn't be able to make
* a new net anyway and they will re-check neighbors until a net is found, so the solution is tautological in nature. So I tried limiting
* creation of new networks. Didn't work. So what's there left to do? Hand out a mark to any node that has changed networks, and let those
* recently modified nodes do another re-check. This creates a second layer of redundant operations, and in theory doubles (in practice,
* it might be an extra 20% due to break-off section sizes) the amount of CPU time needed for re-building the networks after joining or
* breaking, but it seems to allow those parts to connect back to their neighbor nets as they are supposed to. I am not proud of this solution,
* this issue shouldn't exist to begin with and I am going fucking insane but it is what it is.
*/
public PowerNode(BlockPos... positions) {
super(THE_POWER_PROVIDER, positions);
this.positions = positions;
}
@Override
public PowerNode setConnections(DirPos... connections) {
super.setConnections(connections);
return this;
}
}
}

View File

@ -1,156 +0,0 @@
package api.hbm.energymk2;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.hbm.uninos.NodeNet;
import com.hbm.util.Tuple.Pair;
import java.util.Map.Entry;
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
import api.hbm.energymk2.Nodespace.PowerNode;
/**
* Technically MK3 since it's now UNINOS compatible, although UNINOS was build out of 95% nodespace code
*
* @author hbm
*/
public class PowerNetMK2 extends NodeNet<IEnergyReceiverMK2, IEnergyProviderMK2, PowerNode> {
public long energyTracker = 0L;
protected static int timeout = 3_000;
@Override public void resetTrackers() { this.energyTracker = 0; }
@Override
public void update() {
if(providerEntries.isEmpty()) return;
if(receiverEntries.isEmpty()) return;
long timestamp = System.currentTimeMillis();
List<Pair<IEnergyProviderMK2, Long>> providers = new ArrayList();
long powerAvailable = 0;
// sum up available power
Iterator<Entry<IEnergyProviderMK2, Long>> provIt = providerEntries.entrySet().iterator();
while(provIt.hasNext()) {
Entry<IEnergyProviderMK2, Long> entry = provIt.next();
if(timestamp - entry.getValue() > timeout || isBadLink(entry.getKey())) { provIt.remove(); continue; }
long src = Math.min(entry.getKey().getPower(), entry.getKey().getProviderSpeed());
if(src > 0) {
providers.add(new Pair(entry.getKey(), src));
powerAvailable += src;
}
}
// sum up total demand, categorized by priority
List<Pair<IEnergyReceiverMK2, Long>>[] receivers = new ArrayList[ConnectionPriority.values().length];
for(int i = 0; i < receivers.length; i++) receivers[i] = new ArrayList();
long[] demand = new long[ConnectionPriority.values().length];
long totalDemand = 0;
Iterator<Entry<IEnergyReceiverMK2, Long>> recIt = receiverEntries.entrySet().iterator();
while(recIt.hasNext()) {
Entry<IEnergyReceiverMK2, Long> entry = recIt.next();
if(timestamp - entry.getValue() > timeout || isBadLink(entry.getKey())) { recIt.remove(); continue; }
long rec = Math.min(entry.getKey().getMaxPower() - entry.getKey().getPower(), entry.getKey().getReceiverSpeed());
if(rec > 0) {
int p = entry.getKey().getPriority().ordinal();
receivers[p].add(new Pair(entry.getKey(), rec));
demand[p] += rec;
totalDemand += rec;
}
}
long toTransfer = Math.min(powerAvailable, totalDemand);
long energyUsed = 0;
// add power to receivers, ordered by priority
for(int i = ConnectionPriority.values().length - 1; i >= 0; i--) {
List<Pair<IEnergyReceiverMK2, Long>> list = receivers[i];
long priorityDemand = demand[i];
for(Pair<IEnergyReceiverMK2, Long> entry : list) {
double weight = (double) entry.getValue() / (double) (priorityDemand);
long toSend = (long) Math.min(Math.max(toTransfer * weight, 0D), entry.getValue());
energyUsed += (toSend - entry.getKey().transferPower(toSend)); //leftovers are subtracted from the intended amount to use up
}
toTransfer -= energyUsed;
}
this.energyTracker += energyUsed;
long leftover = energyUsed;
// remove power from providers
for(Pair<IEnergyProviderMK2, Long> entry : providers) {
double weight = (double) entry.getValue() / (double) powerAvailable;
long toUse = (long) Math.max(energyUsed * weight, 0D);
entry.getKey().usePower(toUse);
leftover -= toUse;
}
// rounding error compensation, detects surplus that hasn't been used and removes it from random providers
int iterationsLeft = 100; // whiles without emergency brakes are a bad idea
while(iterationsLeft > 0 && leftover > 0 && providers.size() > 0) {
iterationsLeft--;
Pair<IEnergyProviderMK2, Long> selected = providers.get(rand.nextInt(providers.size()));
IEnergyProviderMK2 scapegoat = selected.getKey();
long toUse = Math.min(leftover, scapegoat.getPower());
scapegoat.usePower(toUse);
leftover -= toUse;
}
}
public long sendPowerDiode(long power) {
if(receiverEntries.isEmpty()) return power;
long timestamp = System.currentTimeMillis();
List<Pair<IEnergyReceiverMK2, Long>>[] receivers = new ArrayList[ConnectionPriority.values().length];
for(int i = 0; i < receivers.length; i++) receivers[i] = new ArrayList();
long[] demand = new long[ConnectionPriority.values().length];
long totalDemand = 0;
Iterator<Entry<IEnergyReceiverMK2, Long>> recIt = receiverEntries.entrySet().iterator();
while(recIt.hasNext()) {
Entry<IEnergyReceiverMK2, Long> entry = recIt.next();
if(timestamp - entry.getValue() > timeout) { recIt.remove(); continue; }
long rec = Math.min(entry.getKey().getMaxPower() - entry.getKey().getPower(), entry.getKey().getReceiverSpeed());
int p = entry.getKey().getPriority().ordinal();
receivers[p].add(new Pair(entry.getKey(), rec));
demand[p] += rec;
totalDemand += rec;
}
long toTransfer = Math.min(power, totalDemand);
long energyUsed = 0;
for(int i = ConnectionPriority.values().length - 1; i >= 0; i--) {
List<Pair<IEnergyReceiverMK2, Long>> list = receivers[i];
long priorityDemand = demand[i];
for(Pair<IEnergyReceiverMK2, Long> entry : list) {
double weight = (double) entry.getValue() / (double) (priorityDemand);
long toSend = (long) Math.max(toTransfer * weight, 0D);
energyUsed += (toSend - entry.getKey().transferPower(toSend)); //leftovers are subtracted from the intended amount to use up
}
toTransfer -= energyUsed;
}
this.energyTracker += energyUsed;
return power - energyUsed;
}
}

View File

@ -1,33 +0,0 @@
/**
*
*/
/**
* @author hbm
*
*/
package api.hbm.energymk2;
// i have snorted two lines of pure caffeine and taken one large paracetamol laced with even more caffine, let's fucking go
//most of the new classes are just copy pasted mashed up shit from yesteryear, what a productive segment that was
/*
before my caffine high ends entirely and i black out, here's the gist:
* diodes are handled like energy receiver and simply chain-load the power net they output into in a recursive function, this might be a bit laggy compared to the rest of the system, but it's still way less laggy than the old one
* instead of power nets being bound to tile entities directly, tiles spawn ethereal "nodes" similar to the drone waypoints which can be saved using world data, meaning that breaking cables will delete nodes, but unloading them will keep them alive in "node space" which is what's actually used to check for connections
* power nets may cache some positional info in order to limit the amount of nodes, this should prevent horrific freezes in the unlikely event that some retard makes a superflat world out of cables
* general energy transmission will work in a similar fashion as martin explained his, but somewhat simplified; the system will determine supply and demand and then split those evenly if possible, retrying within one operation is only necessary for minor restrictions like priority, any leftovers from rounding don't have to be re-tried because the next tick will already take care of that
* invest funds in more coal mare nudes
* battery "fair share" transfer will most likely no longer work, but that's not really as relevant these days considering there's capacitors and because batteries have transfer speed limits anyway
* most of the machine's functions will be repurposed, the "sendPower" method will no longer send power directly but register the machine to the network as a power source
* if all else fails and martin still hasn't surrendered his code, i will beg greg for his wisdom (but without loss or tiering because fuck that)
*
* | | ||
* ____|____
* |
* || | |_
*
* ...i said WITHOUT loss
*/

View File

@ -1,6 +1,5 @@
package api.hbm.entity;
@Deprecated //Use IRadarDetectableNT instead, old interface will still work though
public interface IRadarDetectable {
public static enum RadarTargetType {
@ -15,8 +14,7 @@ public interface IRadarDetectable {
MISSILE_15_20("Size 15/20 Custom Missile"), //size 15/20 custom missiles
MISSILE_20("Size 20 Custom Missile"), //size 20 custom missiles
MISSILE_AB("Anti-Ballistic Missile"), //anti ballistic missile
PLAYER("Player"), //airborne players
ARTILLERY("Artillery Shell"); //artillery shells
PLAYER("Player"); //airborne players
public String name;

View File

@ -1,45 +0,0 @@
package api.hbm.entity;
public interface IRadarDetectableNT {
public static final int TIER0 = 0;
public static final int TIER1 = 1;
public static final int TIER2 = 2;
public static final int TIER3 = 3;
public static final int TIER4 = 4;
public static final int TIER10 = 5;
public static final int TIER10_15 = 6;
public static final int TIER15 = 7;
public static final int TIER15_20 = 8;
public static final int TIER20 = 9;
public static final int TIER_AB = 10;
public static final int PLAYER = 11;
public static final int ARTY = 12;
/** Reserved type that shows a unique purple blip. Used for when nothing else applies. */
public static final int SPECIAL = 13;
/** Name use for radar display, uses I18n for lookup */
public String getUnlocalizedName();
/** The type of dot to show on the radar as well as the redstone level in tier mode */
public int getBlipLevel();
/** Whether the object can be seen by this type of radar */
public boolean canBeSeenBy(Object radar);
/** Whether the object is currently visible, as well as whether the radar's setting allow for picking this up */
public boolean paramsApplicable(RadarScanParams params);
/** Whether this radar entry should be counted for the redstone output */
public boolean suppliesRedstone(RadarScanParams params);
public static class RadarScanParams {
public boolean scanMissiles = true;
public boolean scanShells = true;
public boolean scanPlayers = true;
public boolean smartMode = true;
public RadarScanParams(boolean m, boolean s, boolean p, boolean smart) {
this.scanMissiles = m;
this.scanShells = s;
this.scanPlayers = p;
this.smartMode = smart;
}
}
}

View File

@ -1,3 +1,5 @@
package api.hbm.entity;
public interface IRadiationImmune { }
public interface IRadiationImmune {
}

View File

@ -1,16 +0,0 @@
package api.hbm.entity;
import net.minecraft.util.DamageSource;
/**
* Allows custom entities to specify threshold and resistance values based on incoming damage, type and piercing values, along with whatever other internal stats
* the entity has (like glyphid armor). Obviously only works for our own custom entities implementing this, everything else will have to work with the less powerful
* (but still very useful) entity stats in the DamageResistanceHandler.
*
* @author hbm
*/
public interface IResistanceProvider {
public float[] getCurrentDTDR(DamageSource damage, float amount, float pierceDT, float pierce);
public void onDamageDealt(DamageSource damage, float amount);
}

View File

@ -1,66 +0,0 @@
package api.hbm.entity;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
public class RadarEntry {
/** Name use for radar display, uses I18n for lookup */
public String unlocalizedName;
/** The type of dot to show on the radar as well as the redstone level in tier mode */
public int blipLevel;
public int posX;
public int posY;
public int posZ;
public int dim;
public int entityID;
/** Whether this radar entry should be counted for the redstone output */
public boolean redstone;
public RadarEntry() { } //blank ctor for packets
public RadarEntry(String name, int level, int x, int y, int z, int dim, int entityID, boolean redstone) {
this.unlocalizedName = name;
this.blipLevel = level;
this.posX = x;
this.posY = y;
this.posZ = z;
this.dim = dim;
this.entityID = entityID;
this.redstone = redstone;
}
public RadarEntry(IRadarDetectableNT detectable, Entity entity, boolean redstone) {
this(detectable.getUnlocalizedName(), detectable.getBlipLevel(), (int) Math.floor(entity.posX), (int) Math.floor(entity.posY), (int) Math.floor(entity.posZ), entity.dimension, entity.getEntityId(), redstone);
}
public RadarEntry(IRadarDetectable detectable, Entity entity) {
this(detectable.getTargetType().name, detectable.getTargetType().ordinal(), (int) Math.floor(entity.posX), (int) Math.floor(entity.posY), (int) Math.floor(entity.posZ), entity.dimension, entity.getEntityId(), entity.motionY < 0);
}
public RadarEntry(EntityPlayer player) {
this(player.getDisplayName(), IRadarDetectableNT.PLAYER, (int) Math.floor(player.posX), (int) Math.floor(player.posY), (int) Math.floor(player.posZ), player.dimension, player.getEntityId(), true);
}
public void fromBytes(ByteBuf buf) {
this.unlocalizedName = ByteBufUtils.readUTF8String(buf);
this.blipLevel = buf.readShort();
this.posX = buf.readInt();
this.posY = buf.readInt();
this.posZ = buf.readInt();
this.dim = buf.readShort();
this.entityID = buf.readInt();
}
public void toBytes(ByteBuf buf) {
ByteBufUtils.writeUTF8String(buf, this.unlocalizedName);
buf.writeShort(this.blipLevel);
buf.writeInt(this.posX);
buf.writeInt(this.posY);
buf.writeInt(this.posZ);
buf.writeShort(this.dim);
buf.writeInt(this.entityID);
}
}

View File

@ -1,6 +0,0 @@
package api.hbm.fluid;
import api.hbm.fluidmk2.IFluidConnectorMK2;
@Deprecated
public interface IFluidConnector extends IFluidConnectorMK2 { }

View File

@ -1,6 +0,0 @@
package api.hbm.fluid;
import api.hbm.fluidmk2.IFluidConnectorBlockMK2;
@Deprecated
public interface IFluidConnectorBlock extends IFluidConnectorBlockMK2 { }

View File

@ -1,35 +0,0 @@
package api.hbm.fluid;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.uninos.GenNode;
import com.hbm.uninos.UniNodespace;
import api.hbm.fluidmk2.IFluidStandardReceiverMK2;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@Deprecated
public interface IFluidStandardReceiver extends IFluidStandardReceiverMK2 {
public default void subscribeToAllAround(FluidType type, TileEntity tile) {
subscribeToAllAround(type, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord);
}
public default void subscribeToAllAround(FluidType type, World world, int x, int y, int z) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
trySubscribe(type, world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir);
}
}
public default void tryUnsubscribe(FluidType type, World world, int x, int y, int z) {
GenNode node = UniNodespace.getNode(world, x, y, z, type.getNetworkProvider());
if(node != null && node.net != null) node.net.removeReceiver(this);
}
public default void unsubscribeToAllAround(FluidType type, TileEntity tile) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
tryUnsubscribe(type, tile.getWorldObj(), tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ);
}
}
}

View File

@ -1,22 +0,0 @@
package api.hbm.fluid;
import com.hbm.inventory.fluid.tank.FluidTank;
import api.hbm.fluidmk2.IFluidStandardSenderMK2;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@Deprecated
public interface IFluidStandardSender extends IFluidStandardSenderMK2 {
public default void sendFluid(FluidTank tank, World world, int x, int y, int z, ForgeDirection dir) {
tryProvide(tank, world, x, y, z, dir);
}
public default void sendFluidToAll(FluidTank tank, TileEntity tile) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
tryProvide(tank, tile.getWorldObj(), tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ, dir);
}
}
}

View File

@ -1,4 +0,0 @@
package api.hbm.fluid;
@Deprecated
public interface IFluidStandardTransceiver extends IFluidStandardReceiver, IFluidStandardSender { }

View File

@ -1,152 +0,0 @@
package api.hbm.fluidmk2;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.uninos.NodeNet;
import com.hbm.util.Tuple.Pair;
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
public class FluidNetMK2 extends NodeNet<IFluidReceiverMK2, IFluidProviderMK2, FluidNode> {
public long fluidTracker = 0L;
protected static int timeout = 3_000;
protected static long currentTime = 0;
protected FluidType type;
public FluidNetMK2(FluidType type) {
this.type = type;
for(int i = 0; i < IFluidUserMK2.HIGHEST_VALID_PRESSURE + 1; i++) providers[i] = new ArrayList();
for(int i = 0; i < IFluidUserMK2.HIGHEST_VALID_PRESSURE + 1; i++) for(int j = 0; j < ConnectionPriority.values().length; j++) receivers[i][j] = new ArrayList();
}
@Override public void resetTrackers() { this.fluidTracker = 0; }
@Override
public void update() {
if(providerEntries.isEmpty()) return;
if(receiverEntries.isEmpty()) return;
currentTime = System.currentTimeMillis();
setupFluidProviders();
setupFluidReceivers();
transferFluid();
cleanUp();
}
//this sucks ass, but it makes the code just a smidge more structured
public long[] fluidAvailable = new long[IFluidUserMK2.HIGHEST_VALID_PRESSURE + 1];
public List<Pair<IFluidProviderMK2, Long>>[] providers = new ArrayList[IFluidUserMK2.HIGHEST_VALID_PRESSURE + 1];
public long[][] fluidDemand = new long[IFluidUserMK2.HIGHEST_VALID_PRESSURE + 1][ConnectionPriority.values().length];
public List<Pair<IFluidReceiverMK2, Long>>[][] receivers = new ArrayList[IFluidUserMK2.HIGHEST_VALID_PRESSURE + 1][ConnectionPriority.values().length];
public long[] transfered = new long[IFluidUserMK2.HIGHEST_VALID_PRESSURE + 1];
public void setupFluidProviders() {
Iterator<Entry<IFluidProviderMK2, Long>> iterator = providerEntries.entrySet().iterator();
while(iterator.hasNext()) {
Entry<IFluidProviderMK2, Long> entry = iterator.next();
if(currentTime - entry.getValue() > timeout || isBadLink(entry.getKey())) { iterator.remove(); continue; }
IFluidProviderMK2 provider = entry.getKey();
int[] pressureRange = provider.getProvidingPressureRange(type);
for(int p = pressureRange[0]; p <= pressureRange[1]; p++) {
long available = Math.min(provider.getFluidAvailable(type, p), provider.getProviderSpeed(type, p));
providers[p].add(new Pair(provider, available));
fluidAvailable[p] += available;
}
}
}
public void setupFluidReceivers() {
Iterator<Entry<IFluidReceiverMK2, Long>> iterator = receiverEntries.entrySet().iterator();
while(iterator.hasNext()) {
Entry<IFluidReceiverMK2, Long> entry = iterator.next();
if(currentTime - entry.getValue() > timeout || isBadLink(entry.getKey())) { iterator.remove(); continue; }
IFluidReceiverMK2 receiver = entry.getKey();
int[] pressureRange = receiver.getReceivingPressureRange(type);
for(int p = pressureRange[0]; p <= pressureRange[1]; p++) {
long required = Math.min(receiver.getDemand(type, p), receiver.getReceiverSpeed(type, p));
int priority = receiver.getFluidPriority().ordinal();
receivers[p][priority].add(new Pair(receiver, required));
fluidDemand[p][priority] += required;
}
}
}
public void transferFluid() {
long[] received = new long[IFluidUserMK2.HIGHEST_VALID_PRESSURE + 1];
long[] notAccountedFor = new long[IFluidUserMK2.HIGHEST_VALID_PRESSURE + 1];
for(int p = 0; p <= IFluidUserMK2.HIGHEST_VALID_PRESSURE; p++) { // if the pressure range were ever to increase, we might have to rethink this
long totalAvailable = fluidAvailable[p];
for(int i = ConnectionPriority.values().length - 1; i >= 0; i--) {
long toTransfer = Math.min(fluidDemand[p][i], totalAvailable);
if(toTransfer <= 0) continue;
long priorityDemand = fluidDemand[p][i];
for(Pair<IFluidReceiverMK2, Long> entry : receivers[p][i]) {
double weight = (double) entry.getValue() / (double) (priorityDemand);
long toSend = (long) Math.max(toTransfer * weight, 0D);
toSend -= entry.getKey().transferFluid(type, p, toSend);
received[p] += toSend;
fluidTracker += toSend;
}
totalAvailable -= received[p];
}
notAccountedFor[p] = received[p];
}
for(int p = 0; p <= IFluidUserMK2.HIGHEST_VALID_PRESSURE; p++) {
for(Pair<IFluidProviderMK2, Long> entry : providers[p]) {
double weight = (double) entry.getValue() / (double) fluidAvailable[p];
long toUse = (long) Math.max(received[p] * weight, 0D);
entry.getKey().useUpFluid(type, p, toUse);
notAccountedFor[p] -= toUse;
}
}
for(int p = 0; p <= IFluidUserMK2.HIGHEST_VALID_PRESSURE; p++) {
int iterationsLeft = 100;
while(iterationsLeft > 0 && notAccountedFor[p] > 0 && providers[p].size() > 0) {
iterationsLeft--;
Pair<IFluidProviderMK2, Long> selected = providers[p].get(rand.nextInt(providers[p].size()));
IFluidProviderMK2 scapegoat = selected.getKey();
long toUse = Math.min(notAccountedFor[p], scapegoat.getFluidAvailable(type, p));
scapegoat.useUpFluid(type, p, toUse);
notAccountedFor[p] -= toUse;
}
}
}
public void cleanUp() {
for(int i = 0; i < IFluidUserMK2.HIGHEST_VALID_PRESSURE + 1; i++) {
fluidAvailable[i] = 0;
providers[i].clear();
transfered[i] = 0;
for(int j = 0; j < ConnectionPriority.values().length; j++) {
fluidDemand[i][j] = 0;
receivers[i][j].clear();
}
}
}
}

View File

@ -1,19 +0,0 @@
package api.hbm.fluidmk2;
import com.hbm.uninos.GenNode;
import com.hbm.uninos.INetworkProvider;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
public class FluidNode extends GenNode<FluidNetMK2> {
public FluidNode(INetworkProvider<FluidNetMK2> provider, BlockPos... positions) {
super(provider, positions);
}
@Override
public FluidNode setConnections(DirPos... connections) {
super.setConnections(connections);
return this;
}
}

View File

@ -1,21 +0,0 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
import net.minecraft.item.ItemStack;
public interface IFillableItem {
/** Whether this stack can be filled with this type. Not particularly useful for normal operations */
public boolean acceptsFluid(FluidType type, ItemStack stack);
/** Tries to fill the stack, returns the remainder that couldn't be added */
public int tryFill(FluidType type, int amount, ItemStack stack);
/** Whether this stack can fill tiles with this type. Not particularly useful for normal operations */
public boolean providesFluid(FluidType type, ItemStack stack);
/** Provides fluid with the maximum being the requested amount */
public int tryEmpty(FluidType type, int amount, ItemStack stack);
/** Returns the first (or only) corrently held type, may return null. Currently only used for setting bedrock ores */
public FluidType getFirstFluidType(ItemStack stack);
/** Returns the fillstate for the specified fluid. Currently only used for setting bedrock ores */
public int getFill(ItemStack stack);
}

View File

@ -1,12 +0,0 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
public interface IFluidConnectorBlockMK2 {
/** dir is the face that is connected to, the direction going outwards from the block */
public boolean canConnect(FluidType type, IBlockAccess world, int x, int y, int z, ForgeDirection dir);
}

View File

@ -1,17 +0,0 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
import net.minecraftforge.common.util.ForgeDirection;
public interface IFluidConnectorMK2 {
/**
* Whether the given side can be connected to
* @param dir
* @return
*/
public default boolean canConnect(FluidType type, ForgeDirection dir) {
return dir != ForgeDirection.UNKNOWN;
}
}

View File

@ -1,27 +0,0 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.lib.Library;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import net.minecraft.tileentity.TileEntity;
/**
* IFluidConductorMK2 with added node creation method
* @author hbm
*/
public interface IFluidPipeMK2 extends IFluidConnectorMK2 {
public default FluidNode createNode(FluidType type) {
TileEntity tile = (TileEntity) this;
return new FluidNode(type.getNetworkProvider(), new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord)).setConnections(
new DirPos(tile.xCoord + 1, tile.yCoord, tile.zCoord, Library.POS_X),
new DirPos(tile.xCoord - 1, tile.yCoord, tile.zCoord, Library.NEG_X),
new DirPos(tile.xCoord, tile.yCoord + 1, tile.zCoord, Library.POS_Y),
new DirPos(tile.xCoord, tile.yCoord - 1, tile.zCoord, Library.NEG_Y),
new DirPos(tile.xCoord, tile.yCoord, tile.zCoord + 1, Library.POS_Z),
new DirPos(tile.xCoord, tile.yCoord, tile.zCoord - 1, Library.NEG_Z)
);
}
}

View File

@ -1,12 +0,0 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
public interface IFluidProviderMK2 extends IFluidUserMK2 {
public void useUpFluid(FluidType type, int pressure, long amount);
public default long getProviderSpeed(FluidType type, int pressure) { return 1_000_000_000; }
public long getFluidAvailable(FluidType type, int pressure);
public default int[] getProvidingPressureRange(FluidType type) { return DEFAULT_PRESSURE_RANGE; }
}

View File

@ -1,63 +0,0 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.uninos.GenNode;
import com.hbm.uninos.UniNodespace;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IFluidReceiverMK2 extends IFluidUserMK2 {
/** Sends fluid of the desired type and pressure to the receiver, returns the remainder */
public long transferFluid(FluidType type, int pressure, long amount);
public default long getReceiverSpeed(FluidType type, int pressure) { return 1_000_000_000; }
public long getDemand(FluidType type, int pressure);
public default int[] getReceivingPressureRange(FluidType type) { return DEFAULT_PRESSURE_RANGE; }
public default void trySubscribe(FluidType type, World world, DirPos pos) { trySubscribe(type, world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); }
public default void trySubscribe(FluidType type, World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = TileAccessCache.getTileOrCache(world, x, y, z);
boolean red = false;
if(te instanceof IFluidConnectorMK2) {
IFluidConnectorMK2 con = (IFluidConnectorMK2) te;
if(!con.canConnect(type, dir.getOpposite())) return;
GenNode node = UniNodespace.getNode(world, x, y, z, type.getNetworkProvider());
if(node != null && node.net != null) {
node.net.addReceiver(this);
red = true;
}
}
if(particleDebug) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "network");
data.setString("mode", "fluid");
data.setInteger("color", type.getColor());
double posX = x + 0.5 + dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posY = y + 0.5 + dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posZ = z + 0.5 + dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
data.setDouble("mX", -dir.offsetX * (red ? 0.025 : 0.1));
data.setDouble("mY", -dir.offsetY * (red ? 0.025 : 0.1));
data.setDouble("mZ", -dir.offsetZ * (red ? 0.025 : 0.1));
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
}
}
public default ConnectionPriority getFluidPriority() {
return ConnectionPriority.NORMAL;
}
}

View File

@ -1,9 +0,0 @@
package api.hbm.fluidmk2;
public interface IFluidRegisterListener {
/**
* Called when the fluid registry initializes all fluids. Use CompatFluidRegistry to create new instances of FluidType, which are automatically registered.
*/
public void onFluidsLoad();
}

View File

@ -1,68 +0,0 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.tank.FluidTank;
/**
* IFluidReceiverMK2 with standard implementation for transfer and demand getter.
* @author hbm
*/
public interface IFluidStandardReceiverMK2 extends IFluidReceiverMK2 {
public FluidTank[] getReceivingTanks();
@Override
public default long getDemand(FluidType type, int pressure) {
long amount = 0;
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) amount += (tank.getMaxFill() - tank.getFill());
}
return amount;
}
@Override
public default long transferFluid(FluidType type, int pressure, long amount) {
int tanks = 0;
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) tanks++;
}
if(tanks > 1) {
int firstRound = (int) Math.floor((double) amount / (double) tanks);
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
int toAdd = Math.min(firstRound, tank.getMaxFill() - tank.getFill());
tank.setFill(tank.getFill() + toAdd);
amount -= toAdd;
}
}
}
if(amount > 0) for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
int toAdd = (int) Math.min(amount, tank.getMaxFill() - tank.getFill());
tank.setFill(tank.getFill() + toAdd);
amount -= toAdd;
}
}
return amount;
}
@Override
public default int[] getReceivingPressureRange(FluidType type) {
int lowest = HIGHEST_VALID_PRESSURE;
int highest = 0;
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type) {
if(tank.getPressure() < lowest) lowest = tank.getPressure();
if(tank.getPressure() > highest) highest = tank.getPressure();
}
}
return lowest <= highest ? new int[] {lowest, highest} : DEFAULT_PRESSURE_RANGE;
}
@Override
public default long getReceiverSpeed(FluidType type, int pressure) {
return 1_000_000_000;
}
}

View File

@ -1,129 +0,0 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.uninos.GenNode;
import com.hbm.uninos.UniNodespace;
import com.hbm.util.fauxpointtwelve.DirPos;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/**
* IFluidProviderMK2 with standard implementation for fluid provision and fluid removal.
* @author hbm
*/
public interface IFluidStandardSenderMK2 extends IFluidProviderMK2 {
public default void tryProvide(FluidTank tank, World world, DirPos pos) { tryProvide(tank.getTankType(), tank.getPressure(), world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); }
public default void tryProvide(FluidType type, World world, DirPos pos) { tryProvide(type, 0, world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); }
public default void tryProvide(FluidType type, int pressure, World world, DirPos pos) { tryProvide(type, pressure, world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); }
public default void tryProvide(FluidTank tank, World world, int x, int y, int z, ForgeDirection dir) { tryProvide(tank.getTankType(), tank.getPressure(), world, x, y, z, dir); }
public default void tryProvide(FluidType type, World world, int x, int y, int z, ForgeDirection dir) { tryProvide(type, 0, world, x, y, z, dir); }
public default void tryProvide(FluidType type, int pressure, World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = TileAccessCache.getTileOrCache(world, x, y, z);
boolean red = false;
if(te instanceof IFluidConnectorMK2) {
IFluidConnectorMK2 con = (IFluidConnectorMK2) te;
if(con.canConnect(type, dir.getOpposite())) {
GenNode<FluidNetMK2> node = UniNodespace.getNode(world, x, y, z, type.getNetworkProvider());
if(node != null && node.net != null) {
node.net.addProvider(this);
red = true;
}
}
}
if(te != this && te instanceof IFluidReceiverMK2) {
IFluidReceiverMK2 rec = (IFluidReceiverMK2) te;
if(rec.canConnect(type, dir.getOpposite())) {
long provides = Math.min(this.getFluidAvailable(type, pressure), this.getProviderSpeed(type, pressure));
long receives = Math.min(rec.getDemand(type, pressure), rec.getReceiverSpeed(type, pressure));
long toTransfer = Math.min(provides, receives);
toTransfer -= rec.transferFluid(type, pressure, toTransfer);
this.useUpFluid(type, pressure, toTransfer);
}
}
if(particleDebug) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "network");
data.setString("mode", "fluid");
data.setInteger("color", type.getColor());
double posX = x + 0.5 - dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posY = y + 0.5 - dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posZ = z + 0.5 - dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
data.setDouble("mX", dir.offsetX * (red ? 0.025 : 0.1));
data.setDouble("mY", dir.offsetY * (red ? 0.025 : 0.1));
data.setDouble("mZ", dir.offsetZ * (red ? 0.025 : 0.1));
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
}
}
public FluidTank[] getSendingTanks();
@Override
public default long getFluidAvailable(FluidType type, int pressure) {
long amount = 0;
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) amount += tank.getFill();
}
return amount;
}
@Override
public default void useUpFluid(FluidType type, int pressure, long amount) {
int tanks = 0;
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) tanks++;
}
if(tanks > 1) {
int firstRound = (int) Math.floor((double) amount / (double) tanks);
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
int toRem = Math.min(firstRound, tank.getFill());
tank.setFill(tank.getFill() - toRem);
amount -= toRem;
}
}
}
if(amount > 0) for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
int toRem = (int) Math.min(amount, tank.getFill());
tank.setFill(tank.getFill() - toRem);
amount -= toRem;
}
}
}
@Override
public default int[] getProvidingPressureRange(FluidType type) {
int lowest = HIGHEST_VALID_PRESSURE;
int highest = 0;
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type) {
if(tank.getPressure() < lowest) lowest = tank.getPressure();
if(tank.getPressure() > highest) highest = tank.getPressure();
}
}
return lowest <= highest ? new int[] {lowest, highest} : DEFAULT_PRESSURE_RANGE;
}
@Override
public default long getProviderSpeed(FluidType type, int pressure) {
return 1_000_000_000;
}
}

View File

@ -1,5 +0,0 @@
package api.hbm.fluidmk2;
public interface IFluidStandardTransceiverMK2 extends IFluidStandardReceiverMK2, IFluidStandardSenderMK2 {
}

View File

@ -1,15 +0,0 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.tank.FluidTank;
import api.hbm.tile.ILoadedTile;
public interface IFluidUserMK2 extends IFluidConnectorMK2, ILoadedTile {
public static final int HIGHEST_VALID_PRESSURE = 5;
public static final int[] DEFAULT_PRESSURE_RANGE = new int[] {0, 0};
public static final boolean particleDebug = false;
public FluidTank[] getAllTanks();
}

View File

@ -1,24 +0,0 @@
package api.hbm.fluidmk2;
/*
It's rather shrimple: the shiny new energy system using universal nodespace, but hit with a hammer until it works with fluids.
Has a few extra bits and pieces for handling, but the concept is basically the same.
Sounds good?
*/
/*
Quick explanation for implementing new fluids via addon:
Fluids are subject to /ntmreload so they get wiped and rebuilt using the init function in Fluids, which means that if fluids
are simply added externally during startup, they are removed permanently until the game restarts. Same concept as with recipes, really.
To fix this we need to make sure that externally registered fluids are re-registered during reload, for that purpose we have
IFluidRegisterListener, a simple interface with a small method that runs whenever the fluid list is reloaded. IFluidRegisterListeners
need to be registered with CompatExternal.registerFluidRegisterListener to be used, make sure to do this during PreInit.
Inside the IFluidRegisterListener, fluids can be added using CompatFluidRegistry.registerFluid, which will generate a Fluid instance
using the supplied arguments and automatically register it. Do note that like with custom fluids, fluids need numeric IDs assigned manually.
To prevent collisions with stock fluids when NTM updates, make sure to choose a high starting ID (e.g. 10,000).
The fluid created by registerFluid can have traits added to them, just like how NTM does it with its stock fluids.
*/

View File

@ -1,22 +0,0 @@
package api.hbm.item;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IDepthRockTool {
/**
* Whether our item can break depthrock, has a couple of params so we can restrict mining for certain blocks, dimensions or positions
* @param world
* @param player
* @param tool
* @param block
* @param x
* @param y
* @param z
* @return
*/
public boolean canBreakRock(World world, EntityPlayer player, ItemStack tool, Block block, int x, int y, int z);
}

View File

@ -1,30 +0,0 @@
package api.hbm.item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public interface IDesignatorItem {
/**
* Whether the target is valid
* @param world for things like restricting dimensions or getting entities
* @param stack to check NBT and metadata
* @param x position of the launch pad
* @param y position of the launch pad
* @param z position of the launch pad
* @return
*/
public boolean isReady(World world, ItemStack stack, int x, int y, int z);
/**
* The target position if the designator is ready
* @param world
* @param stack
* @param x
* @param y
* @param z
* @return the target
*/
public Vec3 getCoords(World world, ItemStack stack, int x, int y, int z);
}

View File

@ -1,52 +0,0 @@
package api.hbm.item;
import java.util.ArrayList;
import com.hbm.util.ArmorRegistry.HazardClass;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
public interface IGasMask {
/**
* Returns a list of HazardClasses which can not be protected against by this mask (e.g. chlorine gas for half masks)
* @param stack
* @param entity
* @return an empty list if there's no blacklist
*/
public ArrayList<HazardClass> getBlacklist(ItemStack stack, EntityLivingBase entity);
/**
* Returns the loaded filter, if there is any
* @param stack
* @param entity
* @return null if no filter is installed
*/
public ItemStack getFilter(ItemStack stack, EntityLivingBase entity);
/**
* Checks whether the provided filter can be screwed into the mask, does not take already applied filters into account (those get ejected)
* @param stack
* @param entity
* @param filter
* @return
*/
public boolean isFilterApplicable(ItemStack stack, EntityLivingBase entity, ItemStack filter);
/**
* This will write the filter to the stack's NBT, it ignores any previously installed filter and won't eject those
* @param stack
* @param entity
* @param filter
*/
public void installFilter(ItemStack stack, EntityLivingBase entity, ItemStack filter);
/**
* Damages the installed filter, if there is one
* @param stack
* @param entity
* @param damage
*/
public void damageFilter(ItemStack stack, EntityLivingBase entity, int damage);
}

View File

@ -1,31 +0,0 @@
package api.hbm.item;
import java.util.List;
import com.hbm.util.Tuple.Pair;
import com.hbm.util.Tuple.Triplet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
public interface IGunHUDProvider {
/**
* Gets the progress for the status bar right of the toolbar. Usually reserved for durability.
* It's now a list! More bars for stuff like overheating and special charges!
* @param stack
* @param player
* @return a list of triplets holding progress, foreground and background color.
*/
public List<Triplet<Double, Integer, Integer>> getStatusBars(ItemStack stack, EntityPlayer player);
/**
* Gets a list of any size containing a preview icon for loaded ammo as well as text indicating the ammo count.
* Can also be used for any kind of tooltip or maybe a built-in compass of sorts.
* @param stack
* @param player
* @return
*/
public List<Pair<IIcon, String>> getAmmoInfo(ItemStack stack, EntityPlayer player);
}

View File

@ -1,6 +0,0 @@
package api.hbm.ntl;
public enum EnumStorageType {
CLUTTER, //potentially unsorted storage (like crates) with many slots that have low capacity
MASS //storage with very few lots (usually 1) and very high capacity
}

View File

@ -1,29 +0,0 @@
package api.hbm.ntl;
import net.minecraft.item.ItemStack;
public interface IStorageComponent {
/**
* @return The type of storage this tile entity represents.
*/
public EnumStorageType getType();
/**
* @return A StorageManifest instance containing all managed stacks
*/
public StorageManifest getManifest();
/**
* @return An integer representing the version of the manifest. The higher the numberm, the more recent the manifest
* (i.e. always count up), the version has to change every time the manifest updates.
*/
public int getManifestVersion();
/**
* @param stack The stack to be stored
* @param simulate Whether the changes should actually be written or if the operation is only for checking
* @return The remainder of the stack after being stored, null if nothing remains
*/
public ItemStack storeStack(ItemStack stack, boolean simulate);
}

View File

@ -1,68 +0,0 @@
package api.hbm.ntl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class StorageManifest {
public HashMap<Integer, MetaNode> itemMeta = new HashMap();
public void writeStack(ItemStack stack) {
int id = Item.getIdFromItem(stack.getItem());
MetaNode meta = itemMeta.get(id);
if(meta == null) {
meta = new MetaNode();
itemMeta.put(id, meta);
}
NBTNode nbt = meta.metaNBT.get(stack.getItemDamage());
if(nbt == null) {
nbt = new NBTNode();
meta.metaNBT.put(stack.getItemDamage(), nbt);
}
NBTTagCompound compound = stack.hasTagCompound() ? (NBTTagCompound) stack.stackTagCompound.copy() : null;
long amount = nbt.nbtAmount.containsKey(compound) ? nbt.nbtAmount.get(compound) : 0;
amount += stack.stackSize;
nbt.nbtAmount.put(compound, amount);
}
public List<StorageStack> getStacks() {
List<StorageStack> stacks = new ArrayList();
for(Entry<Integer, MetaNode> itemNode : itemMeta.entrySet()) {
for(Entry<Integer, NBTNode> metaNode : itemNode.getValue().metaNBT.entrySet()) {
for(Entry<NBTTagCompound, Long> nbtNode : metaNode.getValue().nbtAmount.entrySet()) {
ItemStack itemStack = new ItemStack(Item.getItemById(itemNode.getKey()), 1, metaNode.getKey());
itemStack.stackTagCompound = nbtNode.getKey();
StorageStack stack = new StorageStack(itemStack, nbtNode.getValue());
stacks.add(stack);
}
}
}
return stacks;
}
public class MetaNode {
public HashMap<Integer, NBTNode> metaNBT = new HashMap();
}
public class NBTNode {
public HashMap<NBTTagCompound, Long> nbtAmount = new HashMap();
}
}

View File

@ -1,27 +0,0 @@
package api.hbm.ntl;
import net.minecraft.item.ItemStack;
public class StorageStack {
private ItemStack type;
private long amount;
public StorageStack(ItemStack type) {
this(type, type.stackSize);
}
public StorageStack(ItemStack type, long amount) {
this.type = type.copy();
this.amount = amount;
this.type.stackSize = 0;
}
public ItemStack getType() {
return this.type.copy();
}
public long getAmount() {
return this.amount;
}
}

View File

@ -1,13 +0,0 @@
package api.hbm.recipe;
public interface IRecipeRegisterListener {
/**
* Called during SerializableRecipe.initialize(), after the defaults are loaded but before the template is written.
* Due to the way the recipes are handled, calling it once is not enough, it has to be called once for every SerializableRecipe
* instance handled, therefore the load operation passes the type name of the recipe, so that the listeners know what type of recipe
* to register at that point. Note that the actual SerializableRecipe instance is irrelevant, since recipes are static anyway,
* and direct tampering with SerializableRecipes is not recommended.
*/
public void onRecipeLoad(String recipeClassName);
}

View File

@ -1,17 +0,0 @@
package api.hbm.recipe;
/*
Quick guide on how to make robust and safe recipe integration:
* Implement IRecipeRegisterListener, the resulting class will handle all recipes, and the onRecipeLoad method is called every time the SerializableRecipe system updates
* Register your IRecipeRegisterListener using CompatExternal.registerRecipeRegisterListener, this has to happen before the SerializableRecipe initializes, doing this during PreInit should be safe
* In your IRecipeRegisterListener, check the supplied recipe type string (which will be the class name of the SerializableRecipe currently being registered) and register your custom recipes accordingly using CompatRecipeRegistry
Explanation:
* Order of operations is important for the recipes to work, if recipes are loaded outside the scope of SerializableRecipe.initialize, they will not work correctly
* If recipes are registered before the init, they are deleted, if they are registered after the init, they will not be part of the config template file, and get deleted when running /ntmreload
* Machines change all the time, so the recipe classes should not be considered API, since the compat would break immediately if a machine is changed or removed
* CompatRecipeRegistry promises to never change its method signatures, and have solid sanity checking when recipes are registered, allowing it to make the bst of whatever data is thrown at it
* Using this dedicated registry class means that even if a machine is changed or removed, the recipes will continue to work to the best of its abilities
*/

View File

@ -1,9 +0,0 @@
package api.hbm.redstoneoverradio;
public interface IRORInfo {
public static String PREFIX_VALUE = "VAL:";
public static String PREFIX_FUNCTION = "FUN:";
public String[] getFunctionInfo();
}

View File

@ -1,41 +0,0 @@
package api.hbm.redstoneoverradio;
public interface IRORInteractive extends IRORInfo {
public static String NAME_SEPARATOR = "!";
public static String PARAM_SEPARATOR = ":";
public static String EX_NULL = "Exception: Null Command";
public static String EX_NAME = "Exception: Multiple Name Separators";
public static String EX_FORMAT = "Exception: Parameter in Invalid Format";
/** Runs a function on the ROR component, usually causing the component to change or do something. Returns are optional. */
public String runRORFunction(String name, String[] params);
/** Extracts the command name from a full command string */
public static String getCommand(String input) {
if(input == null || input.isEmpty()) throw new RORFunctionException(EX_NULL);
String[] parts = input.split(NAME_SEPARATOR);
if(parts.length <= 0 || parts.length > 2) throw new RORFunctionException(EX_NAME);
if(parts[0].isEmpty()) throw new RORFunctionException(EX_NULL);
return parts[0];
}
/** Extracts the param list from a full command string */
public static String[] getParams(String input) {
if(input == null || input.isEmpty()) throw new RORFunctionException(EX_NULL);
String[] parts = input.split(NAME_SEPARATOR);
if(parts.length <= 0 || parts.length > 2) throw new RORFunctionException(EX_NAME);
if(parts.length == 1) return new String[0];
String paramList = parts[1];
String[] params = paramList.split(PARAM_SEPARATOR);
return params;
}
public static int parseInt(String val, int min, int max) {
int result = 0;
try { result = Integer.parseInt(val); } catch(Exception x) { throw new RORFunctionException(EX_FORMAT); };
if(result < min || result > max) throw new RORFunctionException(EX_FORMAT);
return result;
}
}

View File

@ -1,7 +0,0 @@
package api.hbm.redstoneoverradio;
public interface IRORValueProvider extends IRORInfo {
/** Grabs the specified value from this ROR component, operations should not cause any changes with the component itself */
public String provideRORValue(String name);
}

View File

@ -1,8 +0,0 @@
package api.hbm.redstoneoverradio;
public class RORFunctionException extends RuntimeException {
public RORFunctionException(String message) {
super(message);
}
}

View File

@ -1,49 +0,0 @@
/**
* @author hbm
*
*/
package api.hbm.redstoneoverradio;
/*
__ __ __ _________ ________ __ __ __ __ ______ __
/_/| /_/\ /_/| /________/\ /_______/| /_/| /_/| /_/|_____ /_/| /_____/| /_/|
| || | \\ | || | ___ \ \ | ______|/ | |\_| || | |/_____| || |___ || | ||
| || | \ \\ | || | || \ \/ | ||___ | \/_/ |/ | ______ || /__| || | ||__
| || | |\ \\| || | || \ || | |/__/| \ // | |/_____| || | ___|/ | |/_/|
| || | ||\ \| || | || | || | ____|/ > </\ |____ ____|/_ | |/__/| | __|/
| || | || \ | || | ||___/ |/ | ||_____ / __ \/| /_____| |______/| |______|/ | ||
| || | || \ || | |/__/ / | |/____/| | /| \ || |________________|/ | ||
|__|/ |__|/ \__|/ |_________/ |________|/ |__|/ |__|/ |__|/
(not AN index, INDEX is just the codename)
(also no i did not use an ASCII font generator i spent like half an hour on this)
INDEX includes Redstone-over-Radio APIs for interacting with ROR torches in ways more complex than simple comparator output,
simply put, certain ROR torches may run functions on the ROR component or read more complex values. This means that with the ROR
system alone, one can make complex monitoring and logic systems controlling machines via redstone automation.
INDEX includes:
- IRORInfo, an interface that provides a list of all valid functions. This interface should never be implemented directly because
it is worthless on its own, rather it is extended by all other ROR API interfaces
- IRORValueProvider, a simple interface that returns values based on names, serving as a simple getter. Get operations should never
cause changes within the ROR component, and should be kept simple
- IRORInteractive, an interface providing functions equivalent to java, usually performing a state change within the component and
optionally returning a value
On the implementation side we can expect:
- ROR readers, torches which have a list of named values which are read, as well as frequencies on which these values are broadcasted
- ROR controllers, torches which have one frequency and can receive commands with parameters which will be executed on the component
- ROR programmers, torches which have a list of frequencies and return frequencies which can receive commands with parameters and
then send the return value on the return frequency
- ROR logic receivers, torches which can turn signals into redstone based on various factors like arithmetic comparison and string
operators like matches, matches not and substring (thanks to vær for taking care of that)
ROR programmers can indeed do everything that the readers and controllers can, but their added complexity requires more GUI elements
which are more time-consuming to set up and limits the amount of command channels available, hence why readers and controllers exist
when only a simple solution is required
Addendum: While the RTTY system can support any arbitrary object as a signal, INDEX will strictly use strings, since that simplifies
things regarding serialization and saving signals to NBT. Counters already use a parse to int32 function, so this still checks out.
*/

View File

@ -1,12 +0,0 @@
package api.hbm.tile;
public interface IHeatSource {
public int getHeatStored();
/**
* Removes heat from the system. Implementation has to include the checks preventing the heat from going into the negative.
* @param heat
*/
public void useUpHeat(int heat);
}

View File

@ -1,20 +0,0 @@
package api.hbm.tile;
import net.minecraft.nbt.NBTTagCompound;
/**
* Info providers for ENERGY CONTROL
*
* For EC's implementation, refer to:
* https://github.com/Zuxelus/Energy-Control/blob/1.7.10/src/main/java/com/zuxelus/energycontrol/crossmod/CrossHBM.java
* https://github.com/Zuxelus/Energy-Control/blob/1.7.10/src/main/java/com/zuxelus/energycontrol/items/cards/ItemCardHBM.java
* https://github.com/Zuxelus/Energy-Control/blob/1.7.10/src/main/java/com/zuxelus/energycontrol/utils/DataHelper.java
*
* (keys are from DataHelper.java and CrossHBM.java)
*
* */
public interface IInfoProviderEC {
/** Adds any custom data that isn't covered by the standard energy and fluid implementations. */
public void provideExtraInfo(NBTTagCompound data);
}

View File

@ -1,55 +0,0 @@
package api.hbm.tile;
import java.util.HashMap;
import java.util.Map;
import com.hbm.util.Compat;
import com.hbm.util.Tuple.Quartet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
/** For anything that should be removed off networks when considered unloaded, only affects providers and receivers, not links. Must not necessarily be a tile. */
public interface ILoadedTile {
public boolean isLoaded();
// should we gunk this into the API? no, but i don't care
public static class TileAccessCache {
public static Map<Quartet, TileAccessCache> cache = new HashMap();
public static int NULL_CACHE = 20;
public static int NONNULL_CACHE = 60;
public TileEntity tile;
public long expiresOn;
public TileAccessCache(TileEntity tile, long expiresOn) {
this.tile = tile;
this.expiresOn = expiresOn;
}
public boolean hasExpired(long worldTime) {
if(tile != null && tile.isInvalid()) return true;
if(worldTime >= expiresOn) return true;
if(tile instanceof ILoadedTile && !((ILoadedTile) tile).isLoaded()) return true;
return false;
}
public static Quartet publicCumRag = new Quartet(0, 0, 0, 0);
public static TileEntity getTileOrCache(World world, int x, int y, int z) {
publicCumRag.mangle(x, y, z, world.provider.dimensionId);
TileAccessCache cache = TileAccessCache.cache.get(publicCumRag);
if(cache == null || cache.hasExpired(world.getTotalWorldTime())) {
TileEntity tile = Compat.getTileStandard(world, x, y, z);
cache = new TileAccessCache(tile, world.getTotalWorldTime() + (tile == null ? NULL_CACHE : NONNULL_CACHE));
TileAccessCache.cache.put(publicCumRag.clone(), cache);
return tile;
} else {
return cache.tile;
}
}
}
}

View File

@ -1,153 +0,0 @@
package com.hbm.animloader;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import com.hbm.util.BobMathUtil;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.util.MathHelper;
public class AnimatedModel {
public static FloatBuffer auxGLMatrix = GLAllocation.createDirectFloatBuffer(16);
//Pointless...
public AnimationController controller;
public String name = "";
public float[] transform;
boolean hasGeometry = true;
boolean hasTransform = false;
public String geo_name = "";
public AnimatedModel parent;
public List<AnimatedModel> children = new ArrayList<AnimatedModel>();
int callList;
public AnimatedModel() {
}
public void renderAnimated(long sysTime) {
renderAnimated(sysTime, null);
}
public void renderAnimated(long sysTime, IAnimatedModelCallback c) {
if(controller.activeAnim == AnimationWrapper.EMPTY) {
render(c);
return;
}
AnimationWrapper activeAnim = controller.activeAnim;
int numKeyFrames = activeAnim.anim.numKeyFrames;
int diff = (int) (sysTime - activeAnim.startTime);
diff *= activeAnim.speedScale;
if(diff > activeAnim.anim.length) {
int diff2 = diff % activeAnim.anim.length;
switch(activeAnim.endResult.type) {
case END:
controller.activeAnim = AnimationWrapper.EMPTY;
render(c);
return;
case REPEAT:
activeAnim.startTime = sysTime - diff2;
break;
case REPEAT_REVERSE:
activeAnim.startTime = sysTime - diff2;
activeAnim.reverse = !activeAnim.reverse;
break;
case START_NEW:
activeAnim.cloneStats(activeAnim.endResult.next);
activeAnim.startTime = sysTime - diff2;
break;
case STAY:
activeAnim.startTime = sysTime - activeAnim.anim.length;
break;
}
}
diff = (int) (sysTime - activeAnim.startTime);
if(activeAnim.reverse)
diff = activeAnim.anim.length - diff;
diff *= activeAnim.speedScale;
float remappedTime = MathHelper.clamp_float(BobMathUtil.remap(diff, 0, activeAnim.anim.length, 0, numKeyFrames - 1), 0, numKeyFrames - 1);
float diffN = BobMathUtil.remap01_clamp(diff, 0, activeAnim.anim.length);
int index = (int) remappedTime;
int first = index;
int next;
if(index < numKeyFrames - 1) {
next = index + 1;
} else {
next = first;
}
renderWithIndex((float) fract(remappedTime), first, next, diffN, c);
controller.activeAnim.prevFrame = first;
}
protected void renderWithIndex(float inter, int firstIndex, int nextIndex, float diffN, IAnimatedModelCallback c) {
GL11.glPushMatrix();
boolean hidden = false;
if(hasTransform) {
Transform[] transforms = controller.activeAnim.anim.objectTransforms.get(name);
if(transforms != null) {
hidden = transforms[firstIndex].hidden;
transforms[firstIndex].interpolateAndApply(transforms[nextIndex], inter);
} else {
auxGLMatrix.put(transform);
auxGLMatrix.rewind();
GL11.glMultMatrix(auxGLMatrix);
}
}
if(c != null)
hidden |= c.onRender(controller.activeAnim.prevFrame, firstIndex, callList, diffN, name);
if(hasGeometry && !hidden) {
GL11.glCallList(callList);
}
if(c != null)
c.postRender(controller.activeAnim.prevFrame, firstIndex, callList, diffN, name);
for(AnimatedModel m : children) {
m.renderWithIndex(inter, firstIndex, nextIndex, diffN, c);
}
GL11.glPopMatrix();
}
public void render() {
render(null);
}
public void render(IAnimatedModelCallback c) {
GL11.glPushMatrix();
if(hasTransform) {
auxGLMatrix.put(transform);
auxGLMatrix.rewind();
GL11.glMultMatrix(auxGLMatrix);
}
boolean hidden = false;
if(c != null)
hidden = c.onRender(-1, -1, callList, -1, name);
if(hasGeometry && !hidden) {
GL11.glCallList(callList);
}
if(c != null)
c.postRender(-1, -1, callList, -1, name);
for(AnimatedModel m : children) {
m.render(c);
}
GL11.glPopMatrix();
}
private static float fract(float number) {
return (float) (number - Math.floor(number));
}
public static interface IAnimatedModelCallback {
//(prevFrame, currentFrame, model, diffN, modelName)
public boolean onRender(int prevFrame, int currentFrame, int model, float diffN, String modelName);
public default void postRender(int prevFrame, int currentFrame, int model, float diffN, String modelName){};
}
}

View File

@ -1,22 +0,0 @@
package com.hbm.animloader;
import java.util.HashMap;
import java.util.Map;
public class Animation {
public static final Animation EMPTY = createBlankAnimation();
public int length;
public int numKeyFrames;
public Map<String, Transform[]> objectTransforms = new HashMap<String, Transform[]>();
private static Animation createBlankAnimation(){
Animation anim = new Animation();
anim.numKeyFrames = 0;
anim.length = 0;
anim.objectTransforms = new HashMap<String, Transform[]>();
return anim;
}
}

View File

@ -1,22 +0,0 @@
package com.hbm.animloader;
public class AnimationController {
//Drillgon200: You know what? I'm pretty sure this class is entirely pointless and just acts as a stupid getter/setter for the wrapper.
//TODO delete
protected AnimationWrapper activeAnim = AnimationWrapper.EMPTY;
public void setAnim(AnimationWrapper w) {
activeAnim = w;
}
public void stopAnim() {
activeAnim = AnimationWrapper.EMPTY;
}
public AnimationWrapper getAnim() {
return activeAnim;
}
}

View File

@ -1,87 +0,0 @@
package com.hbm.animloader;
import javax.annotation.Nullable;
public class AnimationWrapper {
public static final AnimationWrapper EMPTY = new AnimationWrapper(Animation.EMPTY){
public AnimationWrapper onEnd(EndResult res) {
return this;
};
};
public Animation anim;
public long startTime;
public float speedScale = 1;
public boolean reverse;
public EndResult endResult = EndResult.END;
public int prevFrame = 0;
public AnimationWrapper(Animation a){
this.anim = a;
this.startTime = System.currentTimeMillis();
}
public AnimationWrapper(long startTime, Animation a){
this.anim = a;
this.startTime = startTime;
}
public AnimationWrapper(long startTime, float scale, Animation a){
this.anim = a;
this.speedScale = scale;
this.startTime = startTime;
}
public AnimationWrapper onEnd(EndResult res){
this.endResult = res;
return this;
}
public AnimationWrapper reverse(){
this.reverse = !reverse;
return this;
}
public AnimationWrapper cloneStats(AnimationWrapper other){
this.anim = other.anim;
this.startTime = other.startTime;
this.reverse = other.reverse;
this.endResult = other.endResult;
return this;
}
public AnimationWrapper cloneStatsWithoutTime(AnimationWrapper other){
this.anim = other.anim;
this.reverse = other.reverse;
this.endResult = other.endResult;
return this;
}
public enum EndType {
END,
REPEAT,
REPEAT_REVERSE,
START_NEW,
STAY;
}
public static class EndResult {
public static final EndResult END = new EndResult(EndType.END, null);
EndType type;
AnimationWrapper next;
public EndResult(EndType type) {
this(type, null);
}
public EndResult(EndType type, @Nullable AnimationWrapper next) {
this.type = type;
this.next = next;
}
}
}

View File

@ -1,445 +0,0 @@
package com.hbm.animloader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.logging.log4j.Level;
import org.lwjgl.opengl.GL11;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import com.hbm.main.MainRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
@SideOnly(Side.CLIENT)
public class ColladaLoader {
//Drillgon200: This code is only slightly less terrible than the first time. I hate XML.
/*
* My attempt at making a collada loader.
* Some things to note: You can't use child of constraints with it with complete accuracy,
* as this will break the linear interpolation and I don't know how to fix it
* To get around this, you can put multiple objects with different parents or origins and toggle their visibility.
* It's hacky, but it works, at least if you don't need an object affected by multiple bones at the same time.
*/
//Bob:
/*
* I walk to Burger King, then I walk back home from Burger King
* walk to Burger King, then I walk back home I walk back
* I walk, then I walk back home from Burger King
* I walk, then I walk back home from Burger King
* then I walk back home from Burger King
* I walk, I walk
* walk walk, walk walk
* I walk, I walk
* Burger King
*/
public static AnimatedModel load(ResourceLocation file) {
return load(file, false);
}
public static AnimatedModel load(ResourceLocation file, boolean flipV) {
IResource res;
try {
res = Minecraft.getMinecraft().getResourceManager().getResource(file);
Document doc;
try {
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(res.getInputStream());
return parse(doc.getDocumentElement(), flipV);
} catch(SAXException e) {
e.printStackTrace();
} catch(IOException e) {
e.printStackTrace();
} catch(ParserConfigurationException e) {
e.printStackTrace();
}
} catch(IOException e) {
e.printStackTrace();
}
MainRegistry.logger.log(Level.ERROR, "FAILED TO LOAD MODEL: " + file);
return null;
}
//Model loading section
private static AnimatedModel parse(Element root, boolean flipV){
//Should get the first bone
Element scene = getFirstElement((Element)root.getElementsByTagName("library_visual_scenes").item(0));
AnimatedModel structure = new AnimatedModel(){
@Override
protected void renderWithIndex(float inter, int firstIndex, int nextIndex, float diffN, IAnimatedModelCallback c) {
for(AnimatedModel m : children){
m.renderWithIndex(inter, firstIndex, nextIndex, diffN, c);
}
}
@Override
public void render() {
for(AnimatedModel m : children){
m.render();
}
}
};
for(Element node : getChildElements(scene)){
if(node.getElementsByTagName("instance_geometry").getLength() > 0){
structure.children.add(parseStructure(node));
}
}
Map<String, Integer> geometry = parseGeometry((Element)root.getElementsByTagName("library_geometries").item(0), flipV);
addGeometry(structure, geometry);
setAnimationController(structure, new AnimationController());
return structure;
}
private static void setAnimationController(AnimatedModel model, AnimationController control){
model.controller = control;
for(AnimatedModel m : model.children)
setAnimationController(m, control);
}
private static Element getFirstElement(Node root){
NodeList nodes = root.getChildNodes();
for(int i = 0; i < nodes.getLength(); i ++){
Node node = nodes.item(i);
if(node.getNodeType() == Node.ELEMENT_NODE){
return (Element)node;
}
}
return null;
}
private static List<Element> getElementsByName(Element e, String name){
List<Element> elements = new ArrayList<Element>();
NodeList n = e.getChildNodes();
for(int i = 0; i < n.getLength(); i ++){
Node node = n.item(i);
if(node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals(name)){
elements.add((Element) node);
}
}
return elements;
}
private static List<Element> getChildElements(Element e){
List<Element> elements = new ArrayList<Element>();
if(e == null)
return elements;
NodeList n = e.getChildNodes();
for(int i = 0; i < n.getLength(); i ++){
Node node = n.item(i);
if(node.getNodeType() == Node.ELEMENT_NODE){
elements.add((Element) node);
}
}
return elements;
}
private static AnimatedModel parseStructure(Element root){
AnimatedModel model = new AnimatedModel();
model.name = root.getAttribute("name");
NodeList children = root.getChildNodes();
for(int i = 0; i < children.getLength(); i ++){
Node node = children.item(i);
if(node.getNodeType() != Node.ELEMENT_NODE)
continue;
Element ele = (Element) node;
if("transform".equals(ele.getAttribute("sid"))){
//Do I even need to flip the matrix here? No idea!
model.transform = flipMatrix(parseFloatArray(ele.getTextContent()));
model.hasTransform = true;
} else if("instance_geometry".equals(ele.getTagName())){
model.geo_name = ele.getAttribute("url").substring(1);
} else if(ele.getElementsByTagName("instance_geometry").getLength() > 0){
AnimatedModel childModel = parseStructure(ele);
childModel.parent = model;
model.children.add(childModel);
}
}
return model;
}
/*private static void addStructureChildren(Element root, AnimatedModel model){
NodeList children = root.getChildNodes();
for(int i = 0; i < children.getLength(); i ++){
Node node = children.item(i);
if(node.getNodeType() == Node.ELEMENT_NODE){
Element element = (Element) node;if(getElementsByName(element, "instance_geometry").size() > 0){
addGeoNamesToModel(element, model);
} else if(getElementsByName(element, "node").size() > 0 && "JOINT".equals(((Element)getElementsByName(element, "node").get(0)).getAttribute("type"))){
AnimatedModel m = parseStructure(element);
model.children.add(m);
m.parent = model;
}
}
}
}
private static void addGeoNamesToModel(Element root, AnimatedModel model){
List<Element> geo_names = getElementsByName(root, "instance_geometry");
for(Element e : geo_names){
String name = e.getAttribute("url").substring(1);
model.geo_names.add(name);
}
}*/
//Geometry loading section
//Map of geometry name to display list id
private static Map<String, Integer> parseGeometry(Element root, boolean flipV){
Map<String, Integer> allGeometry = new HashMap<String, Integer>();
for(Element e : getElementsByName(root, "geometry")){
String name = e.getAttribute("id");
Element mesh = getElementsByName(e, "mesh").get(0);
float[] positions = new float[0];
float[] normals = new float[0];
float[] texCoords = new float[0];
int[] indices = new int[0];
for(Element section : getChildElements(mesh)){
String id = section.getAttribute("id");
if(id.endsWith("mesh-positions")){
positions = parsePositions(section);
} else if(id.endsWith("mesh-normals")){
normals = parseNormals(section);
} else if(id.endsWith("mesh-map-0")){
texCoords = parseTexCoords(section);
} else if(section.getNodeName().equals("triangles")){
indices = ArrayUtils.addAll(indices, parseIndices(section));
}
}
if(positions.length == 0)
continue;
int displayList = GL11.glGenLists(1);
GL11.glNewList(displayList, GL11.GL_COMPILE);
Tessellator tess = Tessellator.instance;
tess.startDrawing(GL11.GL_TRIANGLES);
if(indices.length > 0){
for(int i = 0; i < indices.length; i += 3){
float v = texCoords[indices[i + 2] * 2 + 1];
if(flipV){
v = 1 - v;
}
tess.setNormal(normals[indices[i + 1] * 3], normals[indices[i + 1] * 3 + 1], normals[indices[i + 1] * 3 + 2]);
tess.setTextureUV(texCoords[indices[i + 2] * 2], v);
tess.addVertex(positions[indices[i] * 3], positions[indices[i] * 3 + 1], positions[indices[i] * 3 + 2]);
}
}
//ORIGINAL:
/*BufferBuilder buf = Tessellator.getInstance().getBuffer();
buf.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_TEX_NORMAL);
if(indices.length > 0){
for(int i = 0; i < indices.length; i += 3){
float v = texCoords[indices[i+2]*2+1];
if(flipV){
v = 1-v;
}
buf.pos(positions[indices[i]*3], positions[indices[i]*3+1], positions[indices[i]*3+2])
.tex(texCoords[indices[i+2]*2], v)
.normal(normals[indices[i+1]*3], normals[indices[i+1]*3+1], normals[indices[i+1]*3+2])
.endVertex();
}
} else {
}*/
tess.draw();
GL11.glEndList();
allGeometry.put(name, displayList);
}
return allGeometry;
}
private static float[] parsePositions(Element root){
String content = root.getElementsByTagName("float_array").item(0).getTextContent();
return parseFloatArray(content);
}
private static float[] parseNormals(Element root){
String content = root.getElementsByTagName("float_array").item(0).getTextContent();
return parseFloatArray(content);
}
private static float[] parseTexCoords(Element root){
String content = root.getElementsByTagName("float_array").item(0).getTextContent();
return parseFloatArray(content);
}
private static int[] parseIndices(Element root){
String content = root.getElementsByTagName("p").item(0).getTextContent();
return parseIntegerArray(content);
}
private static float[] parseFloatArray(String s){
if(s.isEmpty()){
return new float[0];
}
String[] numbers = s.split(" ");
float[] arr = new float[numbers.length];
for(int i = 0; i < numbers.length; i ++){
arr[i] = Float.parseFloat(numbers[i]);
}
return arr;
}
private static int[] parseIntegerArray(String s){
String[] numbers = s.split(" ");
int[] arr = new int[numbers.length];
for(int i = 0; i < numbers.length; i ++){
arr[i] = Integer.parseInt(numbers[i]);
}
return arr;
}
private static void addGeometry(AnimatedModel m, Map<String, Integer> geometry){
if(!"".equals(m.geo_name) && geometry.containsKey(m.geo_name))
m.callList = geometry.get(m.geo_name);
else {
m.hasGeometry = false;
m.callList = -1;
}
for(AnimatedModel child : m.children){
addGeometry(child, geometry);
}
}
//Animation loading section
public static Animation loadAnim(int length, ResourceLocation file){
IResource res;
try {
res = Minecraft.getMinecraft().getResourceManager().getResource(file);
Document doc;
try {
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(res.getInputStream());
return parseAnim(doc.getDocumentElement(), length);
} catch(SAXException e) {
e.printStackTrace();
} catch(IOException e) {
e.printStackTrace();
} catch(ParserConfigurationException e) {
e.printStackTrace();
}
} catch(IOException e) {
e.printStackTrace();
}
MainRegistry.logger.log(Level.ERROR, "FAILED TO LOAD MODEL: " + file);
return null;
}
private static Animation parseAnim(Element root, int length){
Element anim_section = (Element)root.getElementsByTagName("library_animations").item(0);
Animation anim = new Animation();
anim.length = length;
for(Element e : getChildElements(anim_section)){
if("animation".equals(e.getNodeName())){
String name = e.getAttribute("name");
Transform[] t = null;
List<Element> elements2 = getChildElements(e);
if(elements2.isEmpty()){
continue;
}
for(Element e2 : elements2){
if(e2.getAttribute("id").endsWith("transform")){
t = parseTransforms(e2);
} else if(e2.getAttribute("id").endsWith("hide_viewport")){
setViewportHiddenKeyframes(t, e2);
}
}
anim.objectTransforms.put(name, t);
anim.numKeyFrames = t.length;
}
}
return anim;
}
private static Transform[] parseTransforms(Element root){
String output = getOutputLocation(root);
for(Element e : getChildElements(root)){
if(e.getAttribute("id").equals(output)){
return parseTransformsFromText(e.getElementsByTagName("float_array").item(0).getTextContent());
}
}
System.out.println("Failed to parse transforms! This will not work!");
System.out.println("Node name: " + root.getTagName());
return null;
}
private static void setViewportHiddenKeyframes(Transform[] t, Element root){
String output = getOutputLocation(root);
for(Element e : getChildElements(root)){
if(e.getAttribute("id").equals(output)){
int[] hiddenFrames = parseIntegerArray(e.getElementsByTagName("float_array").item(0).getTextContent());
for(int i = 0; i < hiddenFrames.length; i ++){
t[i].hidden = hiddenFrames[i] > 0 ? true : false;
}
}
}
}
private static String getOutputLocation(Element root){
Element sampler = (Element) root.getElementsByTagName("sampler").item(0);
for(Element e : getChildElements(sampler)){
if("OUTPUT".equals(e.getAttribute("semantic"))){
return e.getAttribute("source").substring(1);
}
}
return null;
}
private static Transform[] parseTransformsFromText(String data){
float[] floats = parseFloatArray(data);
Transform[] transforms = new Transform[floats.length/16];
for(int i = 0; i < floats.length/16; i++){
float[] rawTransform = new float[16];
for(int j = 0; j < 16; j ++)
rawTransform[j] = floats[i*16 + j];
transforms[i] = new Transform(rawTransform);
}
return transforms;
}
private static float[] flipMatrix(float[] f){
if(f.length != 16){
System.out.println("Error flipping matrix: array length not 16. This will not work!");
System.out.println("Matrix: " + f);
}
return new float[]{
f[0], f[4], f[8], f[12],
f[1], f[5], f[9], f[13],
f[2], f[6], f[10], f[14],
f[3], f[7], f[11], f[15]
};
}
}

View File

@ -1,176 +0,0 @@
package com.hbm.animloader;
import java.nio.FloatBuffer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Quaternion;
import com.hbm.util.BobMathUtil;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.util.Vec3;
/**
* Bob:
* Ported from 1.12.2.
* Mostly gibberish to me, probably written in the ancient egyptian language.
* Any unmarked code comments are probably from Drillgon or code I had to throw out myself.
*
* @author Drillgon200 for the most part
*
*/
public class Transform {
protected static FloatBuffer auxGLMatrix = GLAllocation.createDirectFloatBuffer(16);
Vec3 scale;
Vec3 translation;
Quaternion rotation;
boolean hidden = false;
public Transform(float[] matrix){
scale = getScaleFromMatrix(matrix);
auxGLMatrix.put(matrix);
auxGLMatrix.rewind();
rotation = new Quaternion().setFromMatrix((Matrix4f) new Matrix4f().load(auxGLMatrix));
translation = Vec3.createVectorHelper(matrix[0*4+3], matrix[1*4+3], matrix[2*4+3]);
auxGLMatrix.rewind();
}
private Vec3 getScaleFromMatrix(float[] matrix){
float scaleX = (float) Vec3.createVectorHelper(matrix[0], matrix[1], matrix[2]).lengthVector();
float scaleY = (float) Vec3.createVectorHelper(matrix[4], matrix[5], matrix[6]).lengthVector();
float scaleZ = (float) Vec3.createVectorHelper(matrix[8], matrix[9], matrix[10]).lengthVector();
matrix[0] = matrix[0]/scaleX;
matrix[1] = matrix[1]/scaleX;
matrix[2] = matrix[2]/scaleX;
matrix[4] = matrix[4]/scaleY;
matrix[5] = matrix[5]/scaleY;
matrix[6] = matrix[6]/scaleY;
matrix[8] = matrix[8]/scaleZ;
matrix[9] = matrix[9]/scaleZ;
matrix[10] = matrix[10]/scaleZ;
return Vec3.createVectorHelper(scaleX, scaleY, scaleZ);
}
public void interpolateAndApply(Transform other, float inter){
Vec3 trans = BobMathUtil.interpVec(this.translation, other.translation, inter);
Vec3 scale = BobMathUtil.interpVec(this.scale, other.scale, inter);
Quaternion rot = slerp(rotation, other.rotation, inter);
quatToGlMatrix(auxGLMatrix, rot);
scale(auxGLMatrix, scale);
auxGLMatrix.put(12, (float) trans.xCoord);
auxGLMatrix.put(13, (float) trans.yCoord);
auxGLMatrix.put(14, (float) trans.zCoord);
GL11.glMultMatrix(auxGLMatrix);
}
public static FloatBuffer quatToGlMatrix(FloatBuffer buf, Quaternion q) {
buf.clear();
float xx = q.x * q.x;
float xy = q.x * q.y;
float xz = q.x * q.z;
float xw = q.x * q.w;
float yy = q.y * q.y;
float yz = q.y * q.z;
float yw = q.y * q.w;
float zz = q.z * q.z;
float zw = q.z * q.w;
//Bob: i may not know what a quarternion is but grouping these in parts of 4 looks nice
buf.put(1.0F - 2.0F * (yy + zz));
buf.put(2.0F * (xy + zw));
buf.put(2.0F * (xz - yw));
buf.put(0.0F);
buf.put(2.0F * (xy - zw));
buf.put(1.0F - 2.0F * (xx + zz));
buf.put(2.0F * (yz + xw));
buf.put(0.0F);
buf.put(2.0F * (xz + yw));
buf.put(2.0F * (yz - xw));
buf.put(1.0F - 2.0F * (xx + yy));
buf.put(0.0F);
buf.put(0.0F);
buf.put(0.0F);
buf.put(0.0F);
buf.put(1.0F);
buf.rewind();
return buf;
}
private void scale(FloatBuffer matrix, Vec3 scale) {
matrix.put(0, (float) (matrix.get(0) * scale.xCoord));
matrix.put(4, (float) (matrix.get(4) * scale.xCoord));
matrix.put(8, (float) (matrix.get(8) * scale.xCoord));
matrix.put(12, (float) (matrix.get(12) * scale.xCoord));
matrix.put(1, (float) (matrix.get(1) * scale.yCoord));
matrix.put(5, (float) (matrix.get(5) * scale.yCoord));
matrix.put(9, (float) (matrix.get(9) * scale.yCoord));
matrix.put(13, (float) (matrix.get(13) * scale.yCoord));
matrix.put(2, (float) (matrix.get(2) * scale.zCoord));
matrix.put(6, (float) (matrix.get(6) * scale.zCoord));
matrix.put(10, (float) (matrix.get(10) * scale.zCoord));
matrix.put(14, (float) (matrix.get(14) * scale.zCoord));
}
//Thanks, wikipedia
//God, I wish java had operator overloads. Those are one of my favorite things about c and glsl.
protected Quaternion slerp(Quaternion v0, Quaternion v1, float t) {
// Only unit quaternions are valid rotations.
// Normalize to avoid undefined behavior.
//Drillgon200: Any quaternions loaded from blender should be normalized already
//v0.normalise();
//v1.normalise();
// Compute the cosine of the angle between the two vectors.
double dot = Quaternion.dot(v0, v1);
// If the dot product is negative, slerp won't take
// the shorter path. Note that v1 and -v1 are equivalent when
// the negation is applied to all four components. Fix by
// reversing one quaternion.
if (dot < 0.0f) {
v1 = new Quaternion(-v1.x, -v1.y, -v1.z, -v1.w);
dot = -dot;
}
final double DOT_THRESHOLD = 0.9999999;
if (dot > DOT_THRESHOLD) {
// If the inputs are too close for comfort, linearly interpolate
// and normalize the result.
Quaternion result = new Quaternion(v0.x + t*v1.x,
v0.y + t*v1.y,
v0.z + t*v1.z,
v0.w + t*v1.w);
result.normalise();
return result;
}
// Since dot is in range [0, DOT_THRESHOLD], acos is safe
double theta_0 = Math.acos(dot); // theta_0 = angle between input vectors
double theta = theta_0*t; // theta = angle between v0 and result
double sin_theta = Math.sin(theta); // compute this value only once
double sin_theta_0 = Math.sin(theta_0); // compute this value only once
float s0 = (float) (Math.cos(theta) - dot * sin_theta / sin_theta_0); // == sin(theta_0 - theta) / sin(theta_0)
float s1 = (float) (sin_theta / sin_theta_0);
return new Quaternion(s0 * v0.x + s1 * v1.x,
s0 * v0.y + s1 * v1.y,
s0 * v0.z + s1 * v1.z,
s0 * v0.w + s1 * v1.w);
}
}

View File

@ -1,82 +0,0 @@
package com.hbm.blocks;
import com.hbm.lib.RefStrings;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockBase extends Block {
private boolean beaconable = false;
private boolean canSpawn = true;
public BlockBase() {
super(Material.rock);
}
public BlockBase(Material material) {
super(material);
}
@Override
public Block setBlockName(String name) {
super.setBlockName(name);
this.setBlockTextureName(RefStrings.MODID + ":" + name);
return this;
}
/**
* Daisychainable setter for making the block a beacon base block
* @return
*/
public BlockBase setBeaconable() {
this.beaconable = true;
return this;
}
public BlockBase noMobSpawn() {
this.canSpawn = false;
return this;
}
@Override
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return this.canSpawn ? super.canCreatureSpawn(type, world, x, y, z) : false;
}
@Override
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) {
return this.beaconable;
}
/**
* Sets the block to air and drops it
* @param world
* @param x
* @param y
* @param z
*/
public void dismantle(World world, int x, int y, int z) {
world.setBlockToAir(x, y, z);
ItemStack itemstack = new ItemStack(this, 1);
float f = world.rand.nextFloat() * 0.6F + 0.2F;
float f1 = world.rand.nextFloat() * 0.2F;
float f2 = world.rand.nextFloat() * 0.6F + 0.2F;
EntityItem entityitem = new EntityItem(world, x + f, y + f1 + 1, z + f2, itemstack);
float f3 = 0.05F;
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
if(!world.isRemote)
world.spawnEntityInWorld(entityitem);
}
}

View File

@ -1,26 +0,0 @@
package com.hbm.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public abstract class BlockContainerBase extends BlockBase implements ITileEntityProvider {
protected BlockContainerBase(Material material) {
super(material);
this.isBlockContainer = true;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
super.breakBlock(world, x, y, z, block, meta);
world.removeTileEntity(x, y, z);
}
public boolean onBlockEventReceived(World world, int x, int y, int z, int eventNo, int eventArg) {
super.onBlockEventReceived(world, x, y, z, eventNo, eventArg);
TileEntity tileentity = world.getTileEntity(x, y, z);
return tileentity != null ? tileentity.receiveClientEvent(eventNo, eventArg) : false;
}
}

View File

@ -1,20 +1,15 @@
package com.hbm.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.handler.ThreeInts;
import com.hbm.interfaces.ICopiable;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IPersistentNBT;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@ -22,22 +17,12 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public abstract class BlockDummyable extends BlockContainer implements ICustomBlockHighlight, ICopiable, INBTBlockTransformable {
public abstract class BlockDummyable extends BlockContainer {
public BlockDummyable(Material mat) {
super(mat);
@ -55,42 +40,35 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
// meta offset from dummy to extra rotation
public static final int extra = 6;
/*
* An extra integer that can be set before block set operations (such as makeExtra) and intercepted in createNewTileEntity.
* This way we can inelegantly add variation to the tiles created even if the metadata would be the same.
* Why createNewTileEntity only takes two args or why it is used by the chunk's setBlock implementation is beyond me but any
* other solution feels like putting in way too much effort to achieve the same thing, really.
*/
public static int overrideTileMeta = 0;
public static boolean safeRem = false;
public static void setOverride(int i) {
overrideTileMeta = i;
}
public static void resetOverride() {
overrideTileMeta = 0;
}
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block);
if(safeRem)
if(world.isRemote || safeRem)
return;
destroyIfOrphan(world, x, y, z);
int metadata = world.getBlockMetadata(x, y, z);
// if it's an extra, remove the extra-ness
if(metadata >= extra)
metadata -= extra;
ForgeDirection dir = ForgeDirection.getOrientation(metadata).getOpposite();
Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if(b != this) {
world.setBlockToAir(x, y, z);
// world.setBlock(x, y, z, ModBlocks.dfc_injector, dir.ordinal(),
// 3);
}
}
public void updateTick(World world, int x, int y, int z, Random rand) {
super.updateTick(world, x, y, z, rand);
destroyIfOrphan(world, x, y, z);
}
private void destroyIfOrphan(World world, int x, int y, int z) {
if(world.isRemote)
return;
@ -103,32 +81,10 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
ForgeDirection dir = ForgeDirection.getOrientation(metadata).getOpposite();
Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
// An extra precaution against multiblocks on chunk borders being erroneously deleted.
// Technically, this might be used to persist ghost dummy blocks by manipulating
// loaded chunks and block destruction, but this gives no benefit to the player,
// cannot be done accidentally, and is definitely preferable to multiblocks
// just vanishing when their chunks are unloaded in an unlucky way.
if(b != this && world.checkChunksExist(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1)) {
if (isLegacyMonoblock(world, x, y, z)) {
fixLegacyMonoblock(world, x, y, z);
} else {
world.setBlockToAir(x, y, z);
}
if(b != this) {
world.setBlockToAir(x, y, z);
}
}
// Override this when turning a single block into a pseudo-multiblock.
// If this returns true, instead of being deleted as an orphan, the block
// will be promoted to a core of a dummyable, however without any dummies.
// This is only called if the block is presumed an orphan, so you don't
// need to check that here.
protected boolean isLegacyMonoblock(World world, int x, int y, int z) {
return false;
}
protected void fixLegacyMonoblock(World world, int x, int y, int z) {
// Promote to a lone core block with the same effective rotation as before the change
world.setBlockMetadataWithNotify(x, y, z, offset + world.getBlockMetadata(x, y, z), 3);
}
public int[] findCore(World world, int x, int y, int z) {
@ -136,7 +92,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return findCoreRec(world, x, y, z);
}
List<ThreeInts> positions = new ArrayList<>();
List<ThreeInts> positions = new ArrayList();
public int[] findCoreRec(World world, int x, int y, int z) {
@ -174,9 +130,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
if(!(player instanceof EntityPlayer))
return;
safeRem = true;
world.setBlockToAir(x, y, z);
safeRem = false;
EntityPlayer pl = (EntityPlayer) player;
@ -198,7 +152,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
if(i == 3) {
dir = ForgeDirection.getOrientation(4);
}
dir = getDirModified(dir);
if(!checkRequirement(world, x, y, z, dir, o)) {
@ -222,11 +176,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
}
if(!world.isRemote) {
//this is separate because the multiblock rotation and the final meta might not be the same
int meta = getMetaForCore(world, x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o, (EntityPlayer) player, dir.ordinal() + offset);
//lastCore = new BlockPos(x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o);
world.setBlock(x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o, this, meta, 3);
IPersistentNBT.restoreData(world, x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o, itemStack);
world.setBlock(x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o, this, dir.ordinal() + offset, 3);
fillSpace(world, x, y, z, dir, o);
}
y -= getHeightOffset();
@ -235,29 +185,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
super.onBlockPlacedBy(world, x, y, z, player, itemStack);
}
/**
* A bit more advanced than the dir modifier, but it is important that the resulting direction meta is in the core range.
* Using the "extra" metas is technically possible but requires a bit of tinkering, e.g. preventing a recursive loop
* in the core finder and making sure the TE uses the right metas.
* @param world
* @param x
* @param y
* @param z
* @param player
* @param original
* @return
*/
protected int getMetaForCore(World world, int x, int y, int z, EntityPlayer player, int original) {
return original;
}
/**
* Allows to modify the general placement direction as if the player had another rotation.
* Quite basic due to only having 1 param but it's more meant to fix/limit the amount of directions
* @param dir
* @return
*/
protected ForgeDirection getDirModified(ForgeDirection dir) {
return dir;
}
@ -267,6 +195,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
}
protected void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(), this, dir);
}
@ -282,29 +211,15 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return;
// world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3);
safeRem = true;
this.safeRem = true;
world.setBlock(x, y, z, this, meta + extra, 3);
safeRem = false;
}
this.safeRem = false;
public void removeExtra(World world, int x, int y, int z) {
if(world.getBlock(x, y, z) != this)
return;
int meta = world.getBlockMetadata(x, y, z);
if(meta <= 5 || meta >= 12)
return;
// world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3);
safeRem = true;
world.setBlock(x, y, z, this, meta - extra, 3);
safeRem = false;
}
// checks if the dummy metadata is within the extra range
public boolean hasExtra(int meta) {
return meta > 5 && meta < 12;
}
@ -323,8 +238,9 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
// if(pos != null) {
// TODO: run extensive tests on whether this change doesn't break anything
ForgeDirection d = ForgeDirection.getOrientation(i);
if(world.getBlock(x - d.offsetX, y - d.offsetY, z - d.offsetZ) == this)
world.setBlockToAir(x - d.offsetX, y - d.offsetY, z - d.offsetZ);
// }
@ -398,208 +314,4 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return 0;
}
protected boolean standardOpenBehavior(World world, int x, int y, int z, EntityPlayer player, int id) {
if(world.isRemote) {
return true;
} else if(!player.isSneaking()) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return false;
FMLNetworkHandler.openGui(player, MainRegistry.instance, id, world, pos[0], pos[1], pos[2]);
return true;
} else {
return true;
}
}
@Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
if(!player.capabilities.isCreativeMode) {
harvesters.set(player);
this.dropBlockAsItem(world, x, y, z, meta, 0);
harvesters.set(null);
}
}
/*
* Called after the block and TE are already gone, so this method is of no use to us.
*/
@Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
player.addExhaustion(0.025F);
}
public boolean useDetailedHitbox() {
return !bounding.isEmpty();
}
public List<AxisAlignedBB> bounding = new ArrayList<>();
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB entityBounding, List list, Entity entity) {
if(!this.useDetailedHitbox()) {
super.addCollisionBoxesToList(world, x, y, z, entityBounding, list, entity);
return;
}
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return;
x = pos[0];
y = pos[1];
z = pos[2];
ForgeDirection rot = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) - offset).getRotation(ForgeDirection.UP);
for(AxisAlignedBB aabb : this.bounding) {
AxisAlignedBB boxlet = getAABBRotationOffset(aabb, x + 0.5, y, z + 0.5, rot);
if(entityBounding.intersectsWith(boxlet)) {
list.add(boxlet);
}
}
}
public static AxisAlignedBB getAABBRotationOffset(AxisAlignedBB aabb, double x, double y, double z, ForgeDirection dir) {
AxisAlignedBB newBox = null;
if(dir == ForgeDirection.NORTH) newBox = AxisAlignedBB.getBoundingBox(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ);
if(dir == ForgeDirection.EAST) newBox = AxisAlignedBB.getBoundingBox(-aabb.maxZ, aabb.minY, aabb.minX, -aabb.minZ, aabb.maxY, aabb.maxX);
if(dir == ForgeDirection.SOUTH) newBox = AxisAlignedBB.getBoundingBox(-aabb.maxX, aabb.minY, -aabb.maxZ, -aabb.minX, aabb.maxY, -aabb.minZ);
if(dir == ForgeDirection.WEST) newBox = AxisAlignedBB.getBoundingBox(aabb.minZ, aabb.minY, -aabb.maxX, aabb.maxZ, aabb.maxY, -aabb.minX);
if(newBox != null) {
newBox.offset(x, y, z);
return newBox;
}
return AxisAlignedBB.getBoundingBox(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ).offset(x + 0.5, y + 0.5, z + 0.5);
}
// Don't mutate the xyz parameters, or the interaction max distance will bite you
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) {
if(!this.useDetailedHitbox()) {
return super.collisionRayTrace(world, x, y, z, startVec, endVec);
}
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return super.collisionRayTrace(world, x, y, z, startVec, endVec);
ForgeDirection rot = ForgeDirection.getOrientation(world.getBlockMetadata(pos[0], pos[1], pos[2]) - offset).getRotation(ForgeDirection.UP);
for(AxisAlignedBB aabb : this.bounding) {
AxisAlignedBB boxlet = getAABBRotationOffset(aabb, pos[0] + 0.5, pos[1], pos[2] + 0.5, rot);
MovingObjectPosition intercept = boxlet.calculateIntercept(startVec, endVec);
if(intercept != null) {
return new MovingObjectPosition(x, y, z, intercept.sideHit, intercept.hitVec);
}
}
return null;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
if(!this.useDetailedHitbox()) {
super.setBlockBoundsBasedOnState(world, x, y, z);
} else {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.999F, 1.0F); //for some fucking reason setting maxY to something that isn't 1 magically fixes item collisions
}
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldDrawHighlight(World world, int x, int y, int z) {
return !this.bounding.isEmpty();
}
@Override
@SideOnly(Side.CLIENT)
public void drawHighlight(DrawBlockHighlightEvent event, World world, int x, int y, int z) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null) return;
x = pos[0];
y = pos[1];
z = pos[2];
EntityPlayer player = event.player;
float interp = event.partialTicks;
double dX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) interp;
double dY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) interp;
double dZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)interp;
float exp = 0.002F;
ForgeDirection rot = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) - offset).getRotation(ForgeDirection.UP);
ICustomBlockHighlight.setup();
for(AxisAlignedBB aabb : this.bounding) RenderGlobal.drawOutlinedBoundingBox(getAABBRotationOffset(aabb.expand(exp, exp, exp), 0, 0, 0, rot).getOffsetBoundingBox(x - dX + 0.5, y - dY, z - dZ + 0.5), -1);
ICustomBlockHighlight.cleanup();
}
@Override
public NBTTagCompound getSettings(World world, int x, int y, int z) {
int[] pos = findCore(world, x, y, z);
TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]);
if (tile instanceof ICopiable)
return ((ICopiable) tile).getSettings(world, pos[0], pos[1], pos[2]);
else
return null;
}
@Override
public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) {
int[] pos = findCore(world, x, y, z);
if(pos == null) return;
TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]);
if (tile instanceof ICopiable)
((ICopiable) tile).pasteSettings(nbt, index, world, player, pos[0], pos[1], pos[2]);
}
@Override
public String[] infoForDisplay(World world, int x, int y, int z) {
int[] pos = findCore(world, x, y, z);
TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]);
if (tile instanceof ICopiable)
return ((ICopiable) tile).infoForDisplay(world, x, y, z);
return null;
}
@Override
public int transformMeta(int meta, int coordBaseMode) {
boolean isOffset = meta >= 12; // squishing causes issues
boolean isExtra = !isOffset && meta >= extra;
if(isOffset) {
meta -= offset;
} else if(isExtra) {
meta -= extra;
}
meta = INBTBlockTransformable.transformMetaDeco(meta, coordBaseMode);
if(isOffset) {
meta += offset;
} else if(isExtra) {
meta += extra;
}
return meta;
}
}
}

View File

@ -1,73 +0,0 @@
package com.hbm.blocks;
import com.hbm.util.EnumUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import java.util.Locale;
public class BlockEnumMulti extends BlockMulti {
public Class<? extends Enum> theEnum;
public boolean multiName;
private boolean multiTexture;
public BlockEnumMulti(Material mat, Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) {
super(mat);
this.theEnum = theEnum;
this.multiName = multiName;
this.multiTexture = multiTexture;
}
protected IIcon[] icons;
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
if(multiTexture) {
Enum[] enums = theEnum.getEnumConstants();
this.icons = new IIcon[enums.length];
for(int i = 0; i < icons.length; i++) {
Enum num = enums[i];
this.icons[i] = reg.registerIcon(this.getTextureMultiName(num));
}
} else {
this.blockIcon = reg.registerIcon(this.getTextureName());
}
}
public String getUnlocalizedName(ItemStack stack) {
if(this.multiName) {
Enum num = EnumUtil.grabEnumSafely(this.theEnum, stack.getItemDamage());
return getUnlocalizedMultiName(num);
}
return this.getUnlocalizedName();
}
public String getTextureMultiName(Enum num) {
return this.getTextureName() + "." + num.name().toLowerCase(Locale.US);
}
public String getUnlocalizedMultiName(Enum num) {
return super.getUnlocalizedName() + "." + num.name().toLowerCase(Locale.US);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return multiTexture ? this.icons[meta % this.icons.length] : this.blockIcon;
}
@Override
public int getSubCount() {
return this.theEnum.getEnumConstants().length;
}
}

View File

@ -1,84 +0,0 @@
package com.hbm.blocks;
public class BlockEnums {
public static enum EnumStoneType {
SULFUR,
ASBESTOS,
HEMATITE,
MALACHITE,
LIMESTONE,
BAUXITE
}
public static enum EnumMeteorType {
IRON,
COPPER,
ALUMINIUM,
RAREEARTH,
COBALT
}
public static enum EnumBiomeType {
DESERT,
WOODLAND
}
public static enum EnumStalagmiteType {
SULFUR,
ASBESTOS
}
public static enum EnumCMMaterials {
STEEL,
ALLOY,
DESH,
TCALLOY
}
public static enum EnumCMEngines {
STANDARD,
DESH,
BISMUTH
}
public static enum EnumCMCircuit {
ALUMINIUM,
COPPER,
RED_COPPER,
GOLD,
SCHRABIDIUM
}
/** DECO / STRUCTURE ENUMS */
//i apologize in advance
public static enum TileType {
LARGE,
SMALL
}
public static enum LightstoneType {
UNREFINED,
TILE,
BRICKS,
BRICKS_CHISELED,
CHISELED
}
public static enum DecoComputerEnum {
IBM_300PL
}
public static enum DecoCabinetEnum {
GREEN,
STEEL
}
public static enum LightType {
INCANDESCENT,
FLUORESCENT,
HALOGEN
}
}

View File

@ -1,95 +0,0 @@
package com.hbm.blocks;
import com.hbm.entity.item.EntityFallingBlockNT;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import java.util.Random;
public class BlockFallingNT extends Block {
public static boolean fallInstantly;
public BlockFallingNT() {
super(Material.sand);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public BlockFallingNT(Material mat) {
super(mat);
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
if(!world.isRemote) {
this.fall(world, x, y, z);
}
}
protected void fall(World world, int x, int y, int z) {
if(canFallThrough(world, x, y - 1, z) && y >= 0) {
byte range = 32;
if(!fallInstantly && world.checkChunksExist(x - range, y - range, z - range, x + range, y + range, z + range)) {
if(!world.isRemote) {
EntityFallingBlockNT entityfallingblock = new EntityFallingBlockNT(world, x + 0.5D, y + 0.5D, z + 0.5D, this, world.getBlockMetadata(x, y, z));
this.modifyFallingBlock(entityfallingblock);
world.spawnEntityInWorld(entityfallingblock);
}
} else {
world.setBlockToAir(x, y, z);
while(canFallThrough(world, x, y - 1, z) && y > 0) {
--y;
}
if(y > 0) {
world.setBlock(x, y, z, this);
}
}
}
}
protected void modifyFallingBlock(EntityFallingBlockNT falling) { }
@Override
public int tickRate(World world) {
return 2;
}
public static boolean canFallThrough(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
if(block.isAir(world, x, y, z)) {
return true;
} else if(block == Blocks.fire) {
return true;
} else {
Material material = block.getMaterial();
return material == Material.water ? true : material == Material.lava;
}
}
public void onLand(World world, int x, int y, int z, int meta) { }
@SideOnly(Side.CLIENT) public boolean shouldOverrideRenderer() { return false; }
@SideOnly(Side.CLIENT) public void overrideRenderer(EntityFallingBlockNT falling, RenderBlocks renderBlocks, Tessellator tessellator) { }
}

View File

@ -1,34 +0,0 @@
package com.hbm.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import java.util.List;
public abstract class BlockMulti extends BlockBase implements IBlockMulti {
public BlockMulti() {
super();
}
public BlockMulti(Material mat) {
super(mat);
}
@Override
public int damageDropped(int meta) {
return rectify(meta);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for(int i = 0; i < getSubCount(); ++i) {
list.add(new ItemStack(item, 1, i));
}
}
}

View File

@ -1,47 +0,0 @@
package com.hbm.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import java.util.ArrayList;
import java.util.Random;
public class BlockRemap extends Block implements ILookOverlay {
public Block remapBlock;
public int remapMeta;
protected BlockRemap(Block block, int meta) {
super(Material.tnt);
this.remapBlock = block;
this.remapMeta = meta;
this.setTickRandomly(true);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int meta, int side) {
return this.remapBlock.getIcon(meta, side);
}
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
return this.remapBlock.getItemDropped(meta, rand, fortune);
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
world.setBlock(x, y, z, this.remapBlock, this.remapMeta, 2);
}
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
ILookOverlay.printGeneric(event, "Compatibility block, will convert on update tick.", 0xffff00, 0x404000, new ArrayList());
}
}

View File

@ -1,10 +0,0 @@
package com.hbm.blocks;
import net.minecraft.world.World;
import java.util.List;
public interface IAnalyzable {
public List<String> getDebugInfo(World world, int x, int y, int z);
}

Some files were not shown because too many files have changed in this diff Show More