Compare commits

..

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

8085 changed files with 438599 additions and 1050143 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,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

39
.gitignore vendored
View File

@ -1,31 +1,22 @@
# eclipse # eclipse
/eclipse eclipse
/bin bin
/*.launch *.launch
/.settings .settings
/.metadata .metadata
/.classpath .classpath
/.project .project
# idea # idea
/out out
/*.ipr *.ipr
/*.iws *.iws
/*.iml *.iml
/.idea .idea
# gradle # gradle
/build build
/.gradle .gradle
# vscode
/.vscode
# other # other
/run 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.

108
README.md
View File

@ -1,31 +1,15 @@
# 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 ## Building from source
Tired of waiting until the next version comes out? Here is a tutorial on how to compile the very newest version yourself: 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. 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) 1. Make sure you have JDK8 installed. If not, download it from [adoptium.net](https://adoptium.net/?variant=openjdk8&jvmVariant=hotspot)
2. If you don't have git installed, download&install it from [here](https://git-scm.com/downloads). 2. If you don't have git installed, download&install it from [here](https://git-scm.com/downloads).
3. Open up "Git Bash": 3. Open up "Git Bash":
* Press Windows Button, type "Git Bash" and press ENTER * Press Windows Button, type "Git Bash" and press ENTER
@ -56,89 +40,17 @@ Please note that these installation instructions are assuming you're running Mic
## Contributing ## Contributing
If you want to make some changes to the mod, follow this guide: If you want to make some changes to the mod, follow this guide:
1. Follow steps 1-2 from *Building from source* section 1. Follow steps 1-4 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" 2. Setup forge decompilation workspace
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
```
* 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
```
6. Setup forge decompilation workspace
```bash ```bash
./gradlew setupDecompWorkspace ./gradlew setupDecompWorkspace
``` ```
### Necessary for Eclipse users 3. (OPTIONAL, but needed if you use eclipse) Generate eclipse files
7. Generate eclipse files
```bash ```bash
./gradlew eclipse ./gradlew eclipse
``` ```
8. Switch to the **eclipse** folder inside your directory as a workspace. 4. Open up the project directory in eclipse using *Open existing project from file system*
9. If necessary, make sure that Eclipse is using the JDK8. 5. Code!
* 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!
## 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.
## 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.
### 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`.
# License # 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,38 +1,21 @@
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 { buildscript {
repositories { repositories {
maven { url = 'https://maven.ntmr.dev/proxy/' }
maven { url = 'https://maven.minecraftforge.net/' } maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://plugins.gradle.org/m2' } maven { url = 'https://plugins.gradle.org/m2' }
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.0.+') {changing = true} classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
} }
} }
apply plugin: 'forge' apply plugin: 'forge'
apply plugin: 'curseforge'
def jsonFile = file('./src/main/resources/mcmod.info')
if(Files.exists(Paths.get("curseforge.properties"))) { def parsedJson = new groovy.json.JsonSlurper().parseText(jsonFile.text)
// Load CurseForge configuration version = parsedJson.version
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 group = "com.hbm" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "HBM-NTM" archivesBaseName = "HBM-NTM"
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
@ -57,7 +40,7 @@ eclipse.classpath.file.whenMerged { cp ->
} }
// Create file reference factory // Create file reference factory
def fileref = new FileReferenceFactory() def fileref = new org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory()
// Find all codechicken development jars // Find all codechicken development jars
cp.entries.findAll { entry -> entry.path.contains("codechicken") && entry.path.endsWith("-dev.jar") }.forEach { entry -> cp.entries.findAll { entry -> entry.path.contains("codechicken") && entry.path.endsWith("-dev.jar") }.forEach { entry ->
@ -68,51 +51,27 @@ eclipse.classpath.file.whenMerged { cp ->
} }
repositories { repositories {
maven {
name = 'Blerg'
url = 'https://maven.ntmr.dev/proxy/'
}
maven { maven {
name = 'ModMaven' name = 'ModMaven'
url = 'https://modmaven.dev' url = 'https://modmaven.dev'
} }
maven {
name = "gt"
url = "https://gregtech.mechaenetia.com/"
}
//maven { //maven {
// name = "CurseForge" // name = "CurseForge"
// url = "https://minecraft.curseforge.com/api/maven/" // 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/"
}
} }
dependencies { dependencies {
implementation 'codechicken:CodeChickenCore:1.7.10-1.0.4.29:dev' compile 'codechicken:CodeChickenCore:1.7.10-1.0.4.29:dev'
compileOnly 'codechicken:CodeChickenCore:1.7.10-1.0.4.29:src' compileOnly 'codechicken:CodeChickenCore:1.7.10-1.0.4.29:src'
implementation 'codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev' compile 'codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev'
compileOnly 'codechicken:CodeChickenLib:1.7.10-1.1.3.140:src' compileOnly 'codechicken:CodeChickenLib:1.7.10-1.1.3.140:src'
implementation 'codechicken:NotEnoughItems:1.7.10-1.0.3.74:dev' compile 'codechicken:NotEnoughItems:1.7.10-1.0.3.74:dev'
compileOnly 'codechicken:NotEnoughItems:1.7.10-1.0.3.74:src' compileOnly 'codechicken:NotEnoughItems:1.7.10-1.0.3.74:src'
compileOnly "inventorytweaks:InventoryTweaks:1.59-dev:deobf" //compileOnly 'inventory-tweaks:InventoryTweaks:1.62+beta.84:api'
implementation "li.cil.oc:OpenComputers:MC1.7.10-1.5.+:api"
compileOnly "com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta.56-GTNH:dev"
} }
processResources { processResources {
@ -125,13 +84,7 @@ processResources {
include 'mcmod.info' include 'mcmod.info'
// replace version and mcversion // replace version and mcversion
filesMatching('mcmod.info') { expand 'version':project.version, 'mcversion':project.minecraft.version
// replace version, mcversion and credits
expand([
version: version_name,
credits: project.credits
])
}
} }
// copy everything else, thats not the mcmod.info // copy everything else, thats not the mcmod.info
@ -140,50 +93,8 @@ processResources {
} }
} }
// add AT to meta-inf
jar {
manifest {
attributes 'FMLAT': 'HBM_at.cfg'
}
}
task version { task version {
doFirst { doFirst {
println project.version 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))
}
}

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 distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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

@ -3,7 +3,6 @@ package api.hbm.block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
@Deprecated
public interface IDrillInteraction { public interface IDrillInteraction {
/** /**

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,6 +1,5 @@
package api.hbm.block; package api.hbm.block;
@Deprecated
public interface IMiningDrill { public interface IMiningDrill {
/** /**

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

@ -1,13 +1,6 @@
package api.hbm.block; 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.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
public interface IToolable { public interface IToolable {
@ -17,31 +10,6 @@ public interface IToolable {
public static enum ToolType { public static enum ToolType {
SCREWDRIVER, SCREWDRIVER,
HAND_DRILL, HAND_DRILL,
DEFUSER, 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,160 @@
package api.hbm.energy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
/**
* 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);
/**
* A unique identifier for every conductor tile. Used to prevent duplicates when loading previously persistent unloaded tiles.
* @return
*/
public default int getIdentity() {
return getIdentityFromTile((TileEntity) this);
}
public static int getIdentityFromTile(TileEntity te) {
return getIdentityFromPos(te.xCoord, te.yCoord, te.zCoord);
}
public static int getIdentityFromPos(int x, int y, int z) {
final int prime = 31;
int result = 1;
result = prime * result + x;
result = prime * result + y;
result = prime * result + z;
return result;
}
/**
* Whether the link should be part of reeval when the network is changed.
* I.e. if this link should join any of the new networks (FALSE for switches that are turned off for example)
* @return
*/
public default boolean canReevaluate() {
return !((TileEntity) this).isInvalid();
}
/**
* When a link leaves the network, the net has to manually calculate the resulting networks.
* Each link has to decide what other links will join the same net.
* @param copy
*/
public default void reevaluate(HashMap<Integer, IEnergyConductor> copy, HashMap<Integer, Integer> proxies) {
for(int[] pos : getConnectionPoints()) {
int newX = pos[0];
int newY = pos[1];
int newZ = pos[2];
int id = IEnergyConductor.getIdentityFromPos(newX, newY, newZ);
IEnergyConductor neighbor = copy.get(id);
if(neighbor == null) {
Integer newId = proxies.get(id);
if(newId != null) {
neighbor = copy.get(newId);
}
}
if(neighbor != null && this.canReevaluate() && neighbor.canReevaluate()) {
if(neighbor.getPowerNet() != null) {
//neighbor net and no self net
if(this.getPowerNet() == null) {
neighbor.getPowerNet().joinLink(this);
//neighbor net and self net
} else {
this.getPowerNet().joinNetworks(neighbor.getPowerNet());
}
//bidirectional re-eval, experimental and technically optional, only useful as a fallback
} /*else {
//no neighbor net and no self net
if(this.getPowerNet() == null) {
this.setPowerNet(new PowerNet().joinLink(this));
neighbor.setPowerNet(this.getPowerNet().joinLink(neighbor));
//no neighbor net and self net
} else {
neighbor.setPowerNet(this.getPowerNet().joinLink(neighbor));
}
}*/
//extensive debugging has shown that bidirectional re-eval ic complete shit
}
}
}
/**
* Creates a list of positions for the reeval process. In short - what positions should be considered as connected.
* Also used by pylons to quickly figure out what positions to connect to.
* DEFAULT: Connects to all six neighboring blocks.
* @return
*/
public default List<int[]> getConnectionPoints() {
List<int[]> pos = new ArrayList();
TileEntity tile = (TileEntity) this;
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
int newX = tile.xCoord + dir.offsetX;
int newY = tile.yCoord + dir.offsetY;
int newZ = tile.zCoord + dir.offsetZ;
pos.add(new int[] {newX, newY, newZ});
}
return pos;
}
/**
* Since isLoaded is only currently used for weeding out unwanted subscribers, and cables shouldn't (although technically can) be
* subscribers, we just default to true because I don't feel like wasting time implementing things that we don't actually need.
* Perhaps this indicates a minor flaw in the new API, but I physically lack the ability to worry about it.
*/
@Override
public default boolean isLoaded() {
return true;
}
//TODO: check if this standard implementation doesn't break anything (it shouldn't but right now it's a bit redundant) also: remove duplicate implementations
@Override
public default long transferPower(long power) {
if(this.getPowerNet() == null)
return power;
return this.getPowerNet().transferPower(power);
}
/**
* Returns whether the conductor has mutliblock proxies which need to be taken into consideration for re-eval.
* @return
*/
public default boolean hasProxies() {
return false;
}
/**
* Returns the identities (position-based) of proxies which resolve into the conductor's own identity.
* @return
*/
public default List<Integer> getProxies() {
return new ArrayList();
}
}

View File

@ -0,0 +1,110 @@
package api.hbm.energy;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/**
* For anything that connects to power and can be transferred power to, the bottom-level interface.
* This is mean for TILE ENTITIES
* @author hbm
*/
public interface IEnergyConnector extends ILoadedTile {
/**
* Returns the amount of power that remains in the source after transfer
* @param power
* @return
*/
public long transferPower(long power);
/**
* Whether the given side can be connected to
* @param dir
* @return
*/
public default boolean canConnect(ForgeDirection dir) {
return dir != ForgeDirection.UNKNOWN;
}
/**
* 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();
public default long getTransferWeight() {
return Math.max(getMaxPower() - getPower(), 0);
}
/**
* Basic implementation of subscribing to a nearby power grid
* @param world
* @param x
* @param y
* @param z
*/
public default void trySubscribe(World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = world.getTileEntity(x, y, z);
boolean red = false;
if(te instanceof IEnergyConductor) {
IEnergyConductor con = (IEnergyConductor) te;
if(!con.canConnect(dir.getOpposite().getOpposite()))
return;
if(con.getPowerNet() != null && !con.getPowerNet().isSubscribed(this))
con.getPowerNet().subscribe(this);
if(con.getPowerNet() != null)
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));
PacketDispatcher.wrapper.sendToAllAround(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 IEnergyConductor) {
IEnergyConductor con = (IEnergyConductor) te;
if(con.getPowerNet() != null && con.getPowerNet().isSubscribed(this))
con.getPowerNet().unsubscribe(this);
}
}
public static final boolean particleDebug = false;
public default Vec3 getDebugParticlePos() {
TileEntity te = (TileEntity) this;
Vec3 vec = Vec3.createVectorHelper(te.xCoord + 0.5, te.yCoord + 1, te.zCoord + 0.5);
return vec;
}
}

View File

@ -1,4 +1,4 @@
package api.hbm.energymk2; package api.hbm.energy;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;

View File

@ -0,0 +1,13 @@
package api.hbm.energy;
public interface IEnergyGenerator extends IEnergyUser {
/**
* Standard implementation for machines that can only send energy but never receive it.
* @param power
*/
@Override
public default long transferPower(long power) {
return power;
}
}

View File

@ -0,0 +1,111 @@
package api.hbm.energy;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
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;
/**
* 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 and sync packets
*/
public void setPower(long power);
/**
* Standard implementation for power transfer.
* Turns out you can override interfaces to provide a default implementation. Neat.
* @param long power
*/
@Override
public default long transferPower(long power) {
this.setPower(this.getPower() + power);
if(this.getPower() > this.getMaxPower()) {
long overshoot = this.getPower() - this.getMaxPower();
this.setPower(this.getMaxPower());
return overshoot;
}
return 0;
}
/**
* Standard implementation of sending power
* @param world
* @param x
* @param y
* @param z
* @param dir
*/
public default void sendPower(World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = world.getTileEntity(x, y, z);
boolean wasSubscribed = false;
boolean red = false;
// first we make sure we're not subscribed to the network that we'll be supplying
if(te instanceof IEnergyConductor) {
IEnergyConductor con = (IEnergyConductor) te;
if(con.getPowerNet() != null && con.getPowerNet().isSubscribed(this)) {
con.getPowerNet().unsubscribe(this);
wasSubscribed = true;
}
}
//then we add energy
if(te instanceof IEnergyConnector) {
IEnergyConnector con = (IEnergyConnector) te;
if(con.canConnect(dir.getOpposite())) {
long oldPower = this.getPower();
long transfer = oldPower - con.transferPower(oldPower);
this.setPower(oldPower - transfer);
red = true;
}
}
//then we subscribe if possible
if(wasSubscribed && te instanceof IEnergyConductor) {
IEnergyConductor con = (IEnergyConductor) te;
if(con.getPowerNet() != null && !con.getPowerNet().isSubscribed(this)) {
con.getPowerNet().subscribe(this);
}
}
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));
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
}
}
public default void updateStandardConnections(World world, TileEntity te) {
updateStandardConnections(world, te.xCoord, te.yCoord, te.zCoord);
}
public default void updateStandardConnections(World world, int x, int y, int z) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
this.trySubscribe(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir);
}
}

View File

@ -0,0 +1,6 @@
package api.hbm.energy;
public interface ILoadedTile {
public boolean isLoaded();
}

View File

@ -0,0 +1,37 @@
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 joinNetworks(IPowerNet network);
public IPowerNet joinLink(IEnergyConductor conductor);
public void leaveLink(IEnergyConductor conductor);
public void subscribe(IEnergyConnector connector);
public void unsubscribe(IEnergyConnector connector);
public boolean isSubscribed(IEnergyConnector connector);
public void destroy();
/**
* When a link is removed, instead of destroying the network, causing it to be recreated from currently loaded conductors,
* we re-evaluate it, creating new nets based on the previous links.
*
* NYI
*/
public void reevaluate();
public boolean isValid();
public List<IEnergyConductor> getLinks();
public List<IEnergyConnector> getSubscribers();
public long transferPower(long power);
}

View File

@ -0,0 +1,187 @@
package api.hbm.energy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
/**
* 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 HashMap<Integer, IEnergyConductor> links = new HashMap();
private HashMap<Integer, Integer> proxies = new HashMap();
private List<IEnergyConnector> subscribers = new ArrayList();
@Override
public void joinNetworks(IPowerNet network) {
if(network == this)
return; //wtf?!
for(IEnergyConductor conductor : network.getLinks()) {
joinLink(conductor);
}
network.getLinks().clear();
for(IEnergyConnector connector : network.getSubscribers()) {
this.subscribe(connector);
}
network.destroy();
}
@Override
public IPowerNet joinLink(IEnergyConductor conductor) {
if(conductor.getPowerNet() != null)
conductor.getPowerNet().leaveLink(conductor);
conductor.setPowerNet(this);
int identity = conductor.getIdentity();
this.links.put(identity, conductor);
if(conductor.hasProxies()) {
for(Integer i : conductor.getProxies()) {
this.proxies.put(i, identity);
}
}
return this;
}
@Override
public void leaveLink(IEnergyConductor conductor) {
conductor.setPowerNet(null);
int identity = conductor.getIdentity();
this.links.remove(identity);
if(conductor.hasProxies()) {
for(Integer i : conductor.getProxies()) {
this.proxies.remove(i);
}
}
}
@Override
public void subscribe(IEnergyConnector connector) {
this.subscribers.add(connector);
}
@Override
public void unsubscribe(IEnergyConnector connector) {
this.subscribers.remove(connector);
}
@Override
public boolean isSubscribed(IEnergyConnector connector) {
return this.subscribers.contains(connector);
}
@Override
public List<IEnergyConductor> getLinks() {
List<IEnergyConductor> linkList = new ArrayList();
linkList.addAll(this.links.values());
return linkList;
}
public HashMap<Integer, Integer> getProxies() {
HashMap<Integer, Integer> proxyCopy = new HashMap(proxies);
return proxyCopy;
}
@Override
public List<IEnergyConnector> getSubscribers() {
return this.subscribers;
}
@Override
public void destroy() {
this.valid = false;
this.subscribers.clear();
for(IEnergyConductor link : this.links.values()) {
link.setPowerNet(null);
}
this.links.clear();
}
@Override
public boolean isValid() {
return this.valid;
}
public long lastCleanup = System.currentTimeMillis();
@Override
public long transferPower(long power) {
if(lastCleanup + 45 < System.currentTimeMillis()) {
this.subscribers.removeIf(x ->
x == null || !(x instanceof TileEntity) || ((TileEntity)x).isInvalid() || !x.isLoaded()
);
lastCleanup = System.currentTimeMillis();
}
if(this.subscribers.isEmpty())
return power;
List<IEnergyConnector> subList = new ArrayList(subscribers);
List<Long> weight = new ArrayList();
long totalReq = 0;
for(IEnergyConnector con : subList) {
long req = con.getTransferWeight();
weight.add(req);
totalReq += req;
}
if(totalReq == 0)
return power;
long totalGiven = 0;
for(int i = 0; i < subList.size(); i++) {
IEnergyConnector con = subList.get(i);
long req = weight.get(i);
double fraction = (double)req / (double)totalReq;
long given = (long) Math.floor(fraction * power);
totalGiven += (given - con.transferPower(given));
}
return power - totalGiven;
}
@Override
public void reevaluate() {
//this.destroy();//
HashMap<Integer, IEnergyConductor> copy = new HashMap(links);
HashMap<Integer, Integer> proxyCopy = new HashMap(proxies);
for(IEnergyConductor link : copy.values()) {
this.leaveLink(link);
}
for(IEnergyConductor link : copy.values()) {
link.setPowerNet(null);
link.reevaluate(copy, proxyCopy);
if(link.getPowerNet() == null) {
link.setPowerNet(new PowerNet().joinLink(link));
}
}
}
}

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

@ -0,0 +1,19 @@
package api.hbm.fluid;
import com.hbm.inventory.fluid.FluidType;
public interface IFluidConductor extends IFluidConnector {
public IPipeNet getPipeNet(FluidType type);
public void setPipeNet(FluidType type, IPipeNet network);
@Override
public default long transferFluid(FluidType type, long amount) {
if(this.getPipeNet(type) == null)
return amount;
return this.getPipeNet(type).transferFluid(amount);
}
}

View File

@ -1,6 +1,91 @@
package api.hbm.fluid; package api.hbm.fluid;
import api.hbm.fluidmk2.IFluidConnectorMK2; import com.hbm.inventory.fluid.FluidType;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
@Deprecated import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
public interface IFluidConnector extends IFluidConnectorMK2 { } import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IFluidConnector {
/**
* Returns the amount of fluid that remains
* @param power
* @return
*/
public long transferFluid(FluidType type, long fluid);
/**
* Whether the given side can be connected to
* @param dir
* @return
*/
public default boolean canConnect(FluidType type, ForgeDirection dir) {
return dir != ForgeDirection.UNKNOWN;
}
/**
* Returns the amount of fluid that this machine is able to receive
* @param type
* @return
*/
public long getDemand(FluidType type);
/**
* Basic implementation of subscribing to a nearby power grid
* @param world
* @param x
* @param y
* @param z
*/
public default void trySubscribe(FluidType type, World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = world.getTileEntity(x, y, z);
boolean red = false;
if(te instanceof IFluidConductor) {
IFluidConductor con = (IFluidConductor) te;
if(!con.canConnect(type, dir))
return;
if(con.getPipeNet(type) != null && !con.getPipeNet(type).isSubscribed(this))
con.getPipeNet(type).subscribe(this);
if(con.getPipeNet(type) != null)
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 void tryUnsubscribe(FluidType type, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof IFluidConductor) {
IFluidConductor con = (IFluidConductor) te;
if(con.getPipeNet(type) != null && con.getPipeNet(type).isSubscribed(this))
con.getPipeNet(type).unsubscribe(this);
}
}
public static final boolean particleDebug = false;
}

View File

@ -1,6 +1,11 @@
package api.hbm.fluid; package api.hbm.fluid;
import api.hbm.fluidmk2.IFluidConnectorBlockMK2; import com.hbm.inventory.fluid.FluidType;
@Deprecated import net.minecraft.world.IBlockAccess;
public interface IFluidConnectorBlock extends IFluidConnectorBlockMK2 { } import net.minecraftforge.common.util.ForgeDirection;
public interface IFluidConnectorBlock {
public boolean canConnect(FluidType type, IBlockAccess world, int x, int y, int z, ForgeDirection dir);
}

View File

@ -1,35 +1,49 @@
package api.hbm.fluid; package api.hbm.fluid;
import com.hbm.inventory.FluidTank;
import com.hbm.inventory.fluid.FluidType; 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; * Uses default implementation to make the underlying interfaces easier to use for the most common fluid users.
import net.minecraft.world.World; * Only handles a single input tank of the same type.
import net.minecraftforge.common.util.ForgeDirection; * Uses standard FluidTanks which use int32.
* Don't use this as part of the API!
* @author hbm
*
*/
public interface IFluidStandardReceiver extends IFluidUser {
@Deprecated @Override
public interface IFluidStandardReceiver extends IFluidStandardReceiverMK2 { public default long transferFluid(FluidType type, long amount) {
public default void subscribeToAllAround(FluidType type, TileEntity tile) { for(FluidTank tank : getReceivingTanks()) {
subscribeToAllAround(type, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord); if(tank.getTankType() == type) {
tank.setFill(tank.getFill() + (int) amount);
if(tank.getFill() > tank.getMaxFill()) {
long overshoot = tank.getFill() - tank.getMaxFill();
tank.setFill(tank.getMaxFill());
return overshoot;
} }
public default void subscribeToAllAround(FluidType type, World world, int x, int y, int z) { return 0;
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) { return amount;
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) { public FluidTank[] getReceivingTanks();
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
tryUnsubscribe(type, tile.getWorldObj(), tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ); @Override
public default long getDemand(FluidType type) {
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type) {
return tank.getMaxFill() - tank.getFill();
} }
} }
return 0;
}
} }

View File

@ -1,22 +1,50 @@
package api.hbm.fluid; package api.hbm.fluid;
import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.FluidTank;
import com.hbm.inventory.fluid.FluidType;
import api.hbm.fluidmk2.IFluidStandardSenderMK2; /**
import net.minecraft.tileentity.TileEntity; * Uses default implementation to make the underlying interfaces easier to use for the most common fluid users.
import net.minecraft.world.World; * Only handles a single output tank of the same type.
import net.minecraftforge.common.util.ForgeDirection; * Uses standard FluidTanks which use int32.
* Don't use this as part of the API!
* @author hbm
*
*/
public interface IFluidStandardSender extends IFluidUser {
@Deprecated public FluidTank[] getSendingTanks();
public interface IFluidStandardSender extends IFluidStandardSenderMK2 {
public default void sendFluid(FluidTank tank, World world, int x, int y, int z, ForgeDirection dir) { @Override
tryProvide(tank, world, x, y, z, dir); public default long getTotalFluidForSend(FluidType type) {
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type) {
return tank.getFill();
}
} }
public default void sendFluidToAll(FluidTank tank, TileEntity tile) { return 0;
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { }
tryProvide(tank, tile.getWorldObj(), tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ, dir);
@Override
public default void removeFluidForTransfer(FluidType type, long amount) {
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type) {
tank.setFill(tank.getFill() - (int) amount);
return;
} }
} }
} }
@Override
public default long transferFluid(FluidType type, long fluid) {
return fluid;
}
@Override
public default long getDemand(FluidType type) {
return 0;
}
}

View File

@ -1,4 +1,79 @@
package api.hbm.fluid; package api.hbm.fluid;
@Deprecated import com.hbm.inventory.FluidTank;
public interface IFluidStandardTransceiver extends IFluidStandardReceiver, IFluidStandardSender { } import com.hbm.inventory.fluid.FluidType;
/**
* transceiver [trăn-vər], noun
*
* 1. A transmitter and receiver housed together in a single unit and having some circuits in common, often for portable or mobile use.
* 2. A combined radio transmitter and receiver.
* 3. A device that performs transmitting and receiving functions, especially if using common components.
*
* The American Heritage® Dictionary of the English Language, 5th Edition.
*
* Only supports one tank per type (for in- and output separately)
*
* @author hbm
*
*/
public interface IFluidStandardTransceiver extends IFluidUser {
public FluidTank[] getSendingTanks();
public FluidTank[] getReceivingTanks();
@Override
public default long getTotalFluidForSend(FluidType type) {
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type) {
return tank.getFill();
}
}
return 0;
}
@Override
public default void removeFluidForTransfer(FluidType type, long amount) {
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type) {
tank.setFill(tank.getFill() - (int) amount);
return;
}
}
}
@Override
public default long getDemand(FluidType type) {
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type) {
return tank.getMaxFill() - tank.getFill();
}
}
return 0;
}
@Override
public default long transferFluid(FluidType type, long amount) {
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type) {
tank.setFill(tank.getFill() + (int) amount);
if(tank.getFill() > tank.getMaxFill()) {
long overshoot = tank.getFill() - tank.getMaxFill();
tank.setFill(tank.getMaxFill());
return overshoot;
}
return 0;
}
}
return amount;
}
}

View File

@ -0,0 +1,93 @@
package api.hbm.fluid;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
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 IFluidUser extends IFluidConnector {
public default void sendFluid(FluidType type, World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = world.getTileEntity(x, y, z);
boolean wasSubscribed = false;
boolean red = false;
if(te instanceof IFluidConductor) {
IFluidConductor con = (IFluidConductor) te;
if(con.getPipeNet(type) != null && con.getPipeNet(type).isSubscribed(this)) {
con.getPipeNet(type).unsubscribe(this);
wasSubscribed = true;
}
}
if(te instanceof IFluidConnector) {
IFluidConnector con = (IFluidConnector) te;
if(con.canConnect(type, dir.getOpposite())) {
long toSend = this.getTotalFluidForSend(type);
long transfer = toSend - con.transferFluid(type, toSend);
this.removeFluidForTransfer(type, transfer);
red = true;
}
}
if(wasSubscribed && te instanceof IFluidConductor) {
IFluidConductor con = (IFluidConductor) te;
if(con.getPipeNet(type) != null && !con.getPipeNet(type).isSubscribed(this)) {
con.getPipeNet(type).subscribe(this);
}
}
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 void sendFluidToAll(FluidType type, TileEntity te) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
sendFluid(type, te.getWorldObj(), te.xCoord + dir.offsetX, te.yCoord + dir.offsetY, te.zCoord + dir.offsetZ, dir);
}
}
public default long getTotalFluidForSend(FluidType type) { return 0; }
public default void removeFluidForTransfer(FluidType type, long amount) { }
public default void subscribeToAllAround(FluidType type, TileEntity te) {
subscribeToAllAround(type, te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
}
public default void subscribeToAllAround(FluidType type, World world, int x, int y, int z) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
this.trySubscribe(type, world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir);
}
public default void unsubscribeToAllAround(FluidType type, TileEntity te) {
unsubscribeToAllAround(type, te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
}
public default void unsubscribeToAllAround(FluidType type, World world, int x, int y, int z) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
this.tryUnsubscribe(type, world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
}
}

View File

@ -0,0 +1,28 @@
package api.hbm.fluid;
import java.util.HashSet;
import java.util.List;
import com.hbm.inventory.fluid.FluidType;
public interface IPipeNet {
public void joinNetworks(IPipeNet network);
public List<IFluidConductor> getLinks();
public HashSet<IFluidConnector> getSubscribers();
public IPipeNet joinLink(IFluidConductor conductor);
public void leaveLink(IFluidConductor conductor);
public void subscribe(IFluidConnector connector);
public void unsubscribe(IFluidConnector connector);
public boolean isSubscribed(IFluidConnector connector);
public void destroy();
public boolean isValid();
public long transferFluid(long fill);
public FluidType getType();
}

View File

@ -0,0 +1,142 @@
package api.hbm.fluid;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import com.hbm.inventory.fluid.FluidType;
import net.minecraft.tileentity.TileEntity;
public class PipeNet implements IPipeNet {
private boolean valid = true;
private FluidType type;
private List<IFluidConductor> links = new ArrayList();
private HashSet<IFluidConnector> subscribers = new HashSet();
public PipeNet(FluidType type) {
this.type = type;
}
@Override
public void joinNetworks(IPipeNet network) {
if(network == this)
return;
for(IFluidConductor conductor : network.getLinks()) {
conductor.setPipeNet(type, this);
this.getLinks().add(conductor);
}
network.getLinks().clear();
for(IFluidConnector connector : network.getSubscribers()) {
this.subscribe(connector);
}
network.destroy();
}
@Override
public List<IFluidConductor> getLinks() {
return links;
}
@Override
public HashSet<IFluidConnector> getSubscribers() {
return subscribers;
}
@Override
public IPipeNet joinLink(IFluidConductor conductor) {
if(conductor.getPipeNet(type) != null)
conductor.getPipeNet(type).leaveLink(conductor);
conductor.setPipeNet(type, this);
this.links.add(conductor);
return this;
}
@Override
public void leaveLink(IFluidConductor conductor) {
conductor.setPipeNet(type, null);
this.links.remove(conductor);
}
@Override
public void subscribe(IFluidConnector connector) {
this.subscribers.add(connector);
}
@Override
public void unsubscribe(IFluidConnector connector) {
this.subscribers.remove(connector);
}
@Override
public boolean isSubscribed(IFluidConnector connector) {
return this.subscribers.contains(connector);
}
@Override
public long transferFluid(long fill) {
this.subscribers.removeIf(x ->
x == null || !(x instanceof TileEntity) || ((TileEntity)x).isInvalid()
);
if(this.subscribers.isEmpty())
return fill;
List<IFluidConnector> subList = new ArrayList(subscribers);
List<Long> weight = new ArrayList();
long totalReq = 0;
for(IFluidConnector con : subList) {
long req = con.getDemand(type);
weight.add(req);
totalReq += req;
}
if(totalReq == 0)
return fill;
long totalGiven = 0;
for(int i = 0; i < subList.size(); i++) {
IFluidConnector con = subList.get(i);
long req = weight.get(i);
double fraction = (double)req / (double)totalReq;
long given = (long) Math.floor(fraction * fill);
totalGiven += (given - con.transferFluid(type, given));
}
return fill - totalGiven;
}
@Override
public FluidType getType() {
return type;
}
@Override
public void destroy() {
this.valid = false;
this.subscribers.clear();
for(IFluidConductor con : this.links)
con.setPipeNet(type, null);
this.links.clear();
}
@Override
public boolean isValid() {
return this.valid;
}
}

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

@ -0,0 +1,17 @@
package api.hbm.item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public interface IButtonReceiver {
/**
* Called in ModEventHandlerClient for any keyboard input related to this item
* @param stack
* @param player
*/
@SideOnly(Side.CLIENT)
public void handleKeyboardInput(ItemStack stack, EntityPlayer player);
}

View File

@ -0,0 +1,20 @@
package api.hbm.item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public interface IClickReceiver {
/**
* Called in ModEventHandlerClient for any mouse input related to this item
* @param stack
* @param player
* @param button
* @param state
* @return true if the event should be canceled
*/
@SideOnly(Side.CLIENT)
public boolean handleMouseInput(ItemStack stack, EntityPlayer player, int button, boolean state);
}

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,9 +1,9 @@
package com.hbm.blocks; package com.hbm.blocks;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -12,7 +12,6 @@ import net.minecraft.world.World;
public class BlockBase extends Block { public class BlockBase extends Block {
private boolean beaconable = false; private boolean beaconable = false;
private boolean canSpawn = true;
public BlockBase() { public BlockBase() {
super(Material.rock); super(Material.rock);
@ -38,16 +37,6 @@ public class BlockBase extends Block {
return this; 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 @Override
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) {
return this.beaconable; return this.beaconable;

View File

@ -1,20 +1,17 @@
package com.hbm.blocks; 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.MultiblockHandlerXR;
import com.hbm.handler.ThreeInts; import com.hbm.handler.ThreeInts;
import com.hbm.interfaces.ICopiable;
import com.hbm.main.MainRegistry; 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.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.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; 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.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -22,22 +19,12 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper; 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.minecraft.world.World;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList; public abstract class BlockDummyable extends BlockContainer {
import java.util.List;
import java.util.Random;
public abstract class BlockDummyable extends BlockContainer implements ICustomBlockHighlight, ICopiable, INBTBlockTransformable {
public BlockDummyable(Material mat) { public BlockDummyable(Material mat) {
super(mat); super(mat);
@ -55,42 +42,35 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
// meta offset from dummy to extra rotation // meta offset from dummy to extra rotation
public static final int extra = 6; 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 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) { public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block); super.onNeighborBlockChange(world, x, y, z, block);
if(safeRem) if(world.isRemote || safeRem)
return; 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) { public void updateTick(World world, int x, int y, int z, Random rand) {
super.updateTick(world, x, y, z, 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) if(world.isRemote)
return; return;
@ -103,32 +83,10 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
ForgeDirection dir = ForgeDirection.getOrientation(metadata).getOpposite(); ForgeDirection dir = ForgeDirection.getOrientation(metadata).getOpposite();
Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
// An extra precaution against multiblocks on chunk borders being erroneously deleted. if(b != this) {
// 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); 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) { public int[] findCore(World world, int x, int y, int z) {
@ -136,7 +94,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return findCoreRec(world, x, y, z); 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) { public int[] findCoreRec(World world, int x, int y, int z) {
@ -224,9 +182,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
if(!world.isRemote) { if(!world.isRemote) {
//this is separate because the multiblock rotation and the final meta might not be the same //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); 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); 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);
fillSpace(world, x, y, z, dir, o); fillSpace(world, x, y, z, dir, o);
} }
y -= getHeightOffset(); y -= getHeightOffset();
@ -282,9 +238,9 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return; return;
// world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3); // world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3);
safeRem = true; this.safeRem = true;
world.setBlock(x, y, z, this, meta + extra, 3); 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) { public void removeExtra(World world, int x, int y, int z) {
@ -298,9 +254,9 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return; return;
// world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3); // world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3);
safeRem = true; this.safeRem = true;
world.setBlock(x, y, z, this, meta - extra, 3); world.setBlock(x, y, z, this, meta - extra, 3);
safeRem = false; this.safeRem = false;
} }
// checks if the dummy metadata is within the extra range // checks if the dummy metadata is within the extra range
@ -414,192 +370,4 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return true; 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,15 +1,11 @@
package com.hbm.blocks; package com.hbm.blocks;
import com.hbm.util.EnumUtil;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import java.util.Locale;
public class BlockEnumMulti extends BlockMulti { public class BlockEnumMulti extends BlockMulti {
public Class<? extends Enum> theEnum; public Class<? extends Enum> theEnum;
@ -23,7 +19,7 @@ public class BlockEnumMulti extends BlockMulti {
this.multiTexture = multiTexture; this.multiTexture = multiTexture;
} }
protected IIcon[] icons; private IIcon[] icons;
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -35,35 +31,17 @@ public class BlockEnumMulti extends BlockMulti {
for(int i = 0; i < icons.length; i++) { for(int i = 0; i < icons.length; i++) {
Enum num = enums[i]; Enum num = enums[i];
this.icons[i] = reg.registerIcon(this.getTextureMultiName(num)); this.icons[i] = reg.registerIcon(this.getTextureName() + "." + num.name().toLowerCase());
} }
} else { } else {
this.blockIcon = reg.registerIcon(this.getTextureName()); 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 @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) { public IIcon getIcon(int side, int meta) {
return multiTexture ? this.icons[meta % this.icons.length] : this.blockIcon; return this.icons[meta % this.icons.length];
} }
@Override @Override

View File

@ -3,82 +3,7 @@ package com.hbm.blocks;
public class BlockEnums { public class BlockEnums {
public static enum EnumStoneType { 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, SULFUR,
ASBESTOS 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,5 +1,7 @@
package com.hbm.blocks; package com.hbm.blocks;
import java.util.List;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -7,8 +9,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import java.util.List;
public abstract class BlockMulti extends BlockBase implements IBlockMulti { public abstract class BlockMulti extends BlockBase implements IBlockMulti {
public BlockMulti() { public BlockMulti() {
@ -24,6 +24,10 @@ public abstract class BlockMulti extends BlockBase implements IBlockMulti {
return rectify(meta); return rectify(meta);
} }
protected int rectify(int meta) {
return Math.abs(meta % getSubCount());
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) { public void getSubBlocks(Item item, CreativeTabs tab, List list) {

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);
}

View File

@ -1,21 +1,6 @@
package com.hbm.blocks; package com.hbm.blocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
public interface IBlockMulti { public interface IBlockMulti {
public int getSubCount(); public int getSubCount();
public default String getUnlocalizedName(ItemStack stack) {
return ((Block)this).getUnlocalizedName();
}
public default String getOverrideDisplayName(ItemStack stack) {
return null;
}
public default int rectify(int meta) {
return Math.abs(meta % getSubCount());
}
} }

View File

@ -1,6 +1,8 @@
package com.hbm.blocks; package com.hbm.blocks;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public interface IBlockMultiPass { public interface IBlockMultiPass {
@ -11,7 +13,4 @@ public interface IBlockMultiPass {
return renderID; return renderID;
} }
public default boolean shouldRenderItemMulti() {
return false;
}
} }

View File

@ -1,37 +0,0 @@
package com.hbm.blocks;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.world.IBlockAccess;
public interface IBlockSideRotation {
public int getRotationFromSide(IBlockAccess world, int x, int y, int z, int side);
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
public static int getRenderType() {
return renderID;
}
// 0 1 3 2 becomes 0 2 3 1
// I want to smoke that swedish kush because it clearly makes you fucking stupid
public static int topToBottom(int topRotation) {
switch(topRotation) {
case 1: return 2;
case 2: return 1;
default: return topRotation;
}
}
public static boolean isOpposite(int from, int to) {
switch(from) {
case 0: return to == 1;
case 1: return to == 0;
case 2: return to == 3;
case 3: return to == 2;
case 4: return to == 5;
case 5: return to == 4;
default: return false;
}
}
}

View File

@ -1,31 +0,0 @@
package com.hbm.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.world.World;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import org.lwjgl.opengl.GL11;
public interface ICustomBlockHighlight {
@SideOnly(Side.CLIENT) public boolean shouldDrawHighlight(World world, int x, int y, int z);
@SideOnly(Side.CLIENT) public void drawHighlight(DrawBlockHighlightEvent event, World world, int x, int y, int z);
@SideOnly(Side.CLIENT)
public static void setup() {
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
GL11.glLineWidth(2.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(false);
}
@SideOnly(Side.CLIENT)
public static void cleanup() {
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
}
}

View File

@ -1,5 +1,9 @@
package com.hbm.blocks; package com.hbm.blocks;
import java.util.List;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -7,9 +11,6 @@ import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent;
import org.lwjgl.opengl.GL11;
import java.util.List;
public interface ILookOverlay { public interface ILookOverlay {

View File

@ -1,12 +0,0 @@
package com.hbm.blocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import java.util.List;
public interface IPersistentInfoProvider {
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext);
}

View File

@ -1,15 +0,0 @@
package com.hbm.blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
/**
* Custom handling that tells TileEntityProxyBase where the core for a given proxy block is.
* BlockDummyable doesn't implement this since it already has its own standardized core finding code.
*
* @author hbm
*/
public interface IProxyController {
public TileEntity getCore(World world, int x, int y, int z);
}

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