Merge remote-tracking branch 'origin/master'

This commit is contained in:
Pvndols 2025-07-13 22:23:37 +02:00
commit e4f980e21c
3470 changed files with 378440 additions and 341414 deletions

16
.editorconfig Normal file
View File

@ -0,0 +1,16 @@
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

45
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,45 @@
# 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 * * *"
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
# 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

33
.gitignore vendored
View File

@ -1,25 +1,28 @@
# 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 configuration
/curseforge.properties /curseforge.properties

View File

@ -13,6 +13,8 @@ Things you should also avoid include:
* duplicate util functions (just use what we have, man) * duplicate util functions (just use what we have, man)
* unused or half finished util functions (for obvious reasons) * 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) * 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 ## Test your code
@ -20,6 +22,9 @@ This should go without saying, but please don't PR code that was never actually
**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. **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 ## 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. 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.

View File

@ -6,10 +6,13 @@
[Official NTM Wiki](https://nucleartech.wiki/wiki/Main_Page) [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: **This is for 1.7.10!** For 1.12, check out these projects:
* NTM Reloaded: https://github.com/TheOriginalGolem/Hbm-s-Nuclear-Tech-GIT/releases * NTM Reloaded: https://github.com/TheOriginalGolem/Hbm-s-Nuclear-Tech-GIT/releases
* NTM Extended Edition (Alcater): https://github.com/Alcatergit/Hbm-s-Nuclear-Tech-GIT/releases * NTM Extended Edition (Alcater): https://github.com/Alcatergit/Hbm-s-Nuclear-Tech-GIT/releases
* NTM Community Edition (WarFactory): https://github.com/MisterNorwood/Hbm-s-Nuclear-Tech-CE
For 1.18, try Martin's remake: https://codeberg.org/MartinTheDragon/Nuclear-Tech-Mod-Remake/releases For 1.18, try Martin's remake: https://codeberg.org/MartinTheDragon/Nuclear-Tech-Mod-Remake/releases
@ -93,12 +96,18 @@ If you want to make some changes to the mod, follow this guide:
* Click **Add Standard VM**; in the JRE home, navigate to the directory where the JDK is installed, then click finish and select it. * 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! 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 ## 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. 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
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. 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 ### 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: 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). * Get rid of Optifine and use one of the many [other, less intrusive performance mods](https://gist.github.com/makamys/7cb74cd71d93a4332d2891db2624e17c).
@ -108,7 +117,7 @@ One of the most common "performance" mods on 1.7.10, Optifine, achieves an incre
### Angelica ### 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: 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 * 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 * 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 ### 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`. 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`.

View File

@ -79,6 +79,18 @@ repositories {
// 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 {
@ -94,6 +106,8 @@ dependencies {
compileOnly "inventorytweaks:InventoryTweaks:1.59-dev:deobf" compileOnly "inventorytweaks:InventoryTweaks:1.59-dev:deobf"
implementation "li.cil.oc:OpenComputers:MC1.7.10-1.5.+: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 {

View File

@ -1,12 +1,19 @@
## Added
* New assembler
* Features a brand new animated model, GUI and the new recipe selection system
* Many recipes have been reworked, with the microcrafting complexity reduced
* The redcoil didn't get a recipe. It's gonna die soon.
## Changed ## Changed
* Changed the multi fluid ID recipe, they now use analog circuits instead of silicon based ones, no longer requiring plastic to make * Removed levitation unit
* Decreased the connection speed for all battery blocks, a full discharge now takes 30 seconds instead of 1 second, and charging now takes 10 seconds * Many of NTM's regular building blocks now have forge microblock support
* Capacitors have also been nerfed but they are twice as fast as battery blocks, 5 seconds for charging and 15 seconds for discharging * RBMK crane models now conform to the dimensions of the room they're in
* Removed forgotten bricks * Projectile resistance for armor has been renamed to "physical" and now also extends to all direct forms of attack by other entities that don't fall into any other categories (mostly melee attacks)
* Updated CMB brick texture * This should fix the issue where most armors are quite weak against swords
* The ICF machine block now renders with its 3d model in the creative inventory * Electric attacks (i.e. tesla cannon) are now in the "energy damage" category
* This means that armors that have energy resistance actually properly work against the tesla cannon
## Fixed ## Fixed
* Fixed pumpjack gauges not syncing properly * Fixed gas centrifuge sound persisting when broken or when unloaded
* Fixed some concrete variants not being revertable into uncolored concrete * Fixed all centrifuge sounds trying to play even when the player is far away, using up audio slots
* Fixed the ore density scanner not using proper translations for the HUD * Fixed guns that don't have durability always displaying a condition of 0%

View File

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

Binary file not shown.

View File

@ -1,7 +1,7 @@
package api.hbm.energymk2; package api.hbm.energymk2;
import com.hbm.packet.AuxParticlePacketNT; import com.hbm.handler.threading.PacketThreading;
import com.hbm.packet.PacketDispatcher; import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.util.Compat; import com.hbm.util.Compat;
import api.hbm.energymk2.Nodespace.PowerNode; import api.hbm.energymk2.Nodespace.PowerNode;
@ -18,29 +18,29 @@ public interface IEnergyProviderMK2 extends IEnergyHandlerMK2 {
public default void usePower(long power) { public default void usePower(long power) {
this.setPower(this.getPower() - power); this.setPower(this.getPower() - power);
} }
public default long getProviderSpeed() { public default long getProviderSpeed() {
return this.getMaxPower(); return this.getMaxPower();
} }
public default void tryProvide(World world, int x, int y, int z, ForgeDirection dir) { public default void tryProvide(World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = Compat.getTileStandard(world, x, y, z); TileEntity te = Compat.getTileStandard(world, x, y, z);
boolean red = false; boolean red = false;
if(te instanceof IEnergyConductorMK2) { if(te instanceof IEnergyConductorMK2) {
IEnergyConductorMK2 con = (IEnergyConductorMK2) te; IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
if(con.canConnect(dir.getOpposite())) { if(con.canConnect(dir.getOpposite())) {
PowerNode node = Nodespace.getNode(world, x, y, z); PowerNode node = Nodespace.getNode(world, x, y, z);
if(node != null && node.net != null) { if(node != null && node.net != null) {
node.net.addProvider(this); node.net.addProvider(this);
red = true; red = true;
} }
} }
} }
if(te instanceof IEnergyReceiverMK2 && te != this) { if(te instanceof IEnergyReceiverMK2 && te != this) {
IEnergyReceiverMK2 rec = (IEnergyReceiverMK2) te; IEnergyReceiverMK2 rec = (IEnergyReceiverMK2) te;
if(rec.canConnect(dir.getOpposite())) { if(rec.canConnect(dir.getOpposite())) {
@ -51,7 +51,7 @@ public interface IEnergyProviderMK2 extends IEnergyHandlerMK2 {
this.usePower(toTransfer); this.usePower(toTransfer);
} }
} }
if(particleDebug) { if(particleDebug) {
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
data.setString("type", "network"); data.setString("type", "network");
@ -62,7 +62,7 @@ public interface IEnergyProviderMK2 extends IEnergyHandlerMK2 {
data.setDouble("mX", dir.offsetX * (red ? 0.025 : 0.1)); data.setDouble("mX", dir.offsetX * (red ? 0.025 : 0.1));
data.setDouble("mY", dir.offsetY * (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)); 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)); PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
} }
} }
} }

View File

@ -1,8 +1,10 @@
package api.hbm.energymk2; package api.hbm.energymk2;
import com.hbm.packet.AuxParticlePacketNT; import com.hbm.handler.threading.PacketThreading;
import com.hbm.packet.PacketDispatcher; import com.hbm.interfaces.NotableComments;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.util.Compat; import com.hbm.util.Compat;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energymk2.Nodespace.PowerNode; import api.hbm.energymk2.Nodespace.PowerNode;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
@ -12,6 +14,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
/** If it receives energy, use this */ /** If it receives energy, use this */
@NotableComments
public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 { public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 {
public default long transferPower(long power) { public default long transferPower(long power) {
@ -24,28 +27,30 @@ public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 {
this.setPower(this.getMaxPower()); this.setPower(this.getMaxPower());
return overshoot; return overshoot;
} }
public default long getReceiverSpeed() { public default long getReceiverSpeed() {
return this.getMaxPower(); return this.getMaxPower();
} }
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) { public default void trySubscribe(World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = Compat.getTileStandard(world, x, y, z); TileEntity te = Compat.getTileStandard(world, x, y, z);
boolean red = false; boolean red = false;
if(te instanceof IEnergyConductorMK2) { if(te instanceof IEnergyConductorMK2) {
IEnergyConductorMK2 con = (IEnergyConductorMK2) te; IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
if(!con.canConnect(dir.getOpposite())) return; if(!con.canConnect(dir.getOpposite())) return;
PowerNode node = Nodespace.getNode(world, x, y, z); PowerNode node = Nodespace.getNode(world, x, y, z);
if(node != null && node.net != null) { if(node != null && node.net != null) {
node.net.addReceiver(this); node.net.addReceiver(this);
red = true; red = true;
} }
} }
if(particleDebug) { if(particleDebug) {
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
data.setString("type", "network"); data.setString("type", "network");
@ -56,49 +61,24 @@ public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 {
data.setDouble("mX", -dir.offsetX * (red ? 0.025 : 0.1)); data.setDouble("mX", -dir.offsetX * (red ? 0.025 : 0.1));
data.setDouble("mY", -dir.offsetY * (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)); 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)); 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) { public default void tryUnsubscribe(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z); TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof IEnergyConductorMK2) { if(te instanceof IEnergyConductorMK2) {
IEnergyConductorMK2 con = (IEnergyConductorMK2) te; IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
PowerNode node = con.createNode(); PowerNode node = con.createNode();
if(node != null && node.net != null) { if(node != null && node.net != null) {
node.net.removeReceiver(this); node.net.removeReceiver(this);
} }
} }
} }
/**
* Project MKUltra was an illegal human experiments program designed and undertaken by the U.S. Central Intelligence Agency (CIA)
* to develop procedures and identify drugs that could be used during interrogations to weaken people and force confessions through
* brainwashing and psychological torture. It began in 1953 and was halted in 1973. MKUltra used numerous methods to manipulate
* its subjects' mental states and brain functions, such as the covert administration of high doses of psychoactive drugs (especially LSD)
* and other chemicals without the subjects' consent, electroshocks, hypnosis, sensory deprivation, isolation, verbal and sexual
* abuse, and other forms of torture.
* MKUltra was preceded by Project Artichoke. It was organized through the CIA's Office of Scientific Intelligence and coordinated
* with the United States Army Biological Warfare Laboratories. The program engaged in illegal activities, including the
* use of U.S. and Canadian citizens as unwitting test subjects. MKUltra's scope was broad, with activities carried
* out under the guise of research at more than 80 institutions aside from the military, including colleges and universities,
* hospitals, prisons, and pharmaceutical companies. The CIA operated using front organizations, although some top officials at these
* institutions were aware of the CIA's involvement.
* MKUltra was revealed to the public in 1975 by the Church Committee of the United States Congress and Gerald Ford's United States
* President's Commission on CIA activities within the United States (the Rockefeller Commission). Investigative efforts were hampered
* by CIA Director Richard Helms's order that all MKUltra files be destroyed in 1973; the Church Committee and Rockefeller Commission
* investigations relied on the sworn testimony of direct participants and on the small number of documents that survived Helms's order.
* In 1977, a Freedom of Information Act request uncovered a cache of 20,000 documents relating to MKUltra, which led to Senate hearings.
* Some surviving information about MKUltra was declassified in 2001.
* */
public default ConnectionPriority getPriority() {
return ConnectionPriority.NORMAL;
}
/** More is better-er */
public enum ConnectionPriority { public enum ConnectionPriority {
LOWEST, LOWEST,
LOW, LOW,
@ -106,4 +86,8 @@ public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 {
HIGH, HIGH,
HIGHEST HIGHEST
} }
public default ConnectionPriority getPriority() {
return ConnectionPriority.NORMAL;
}
} }

View File

@ -1,159 +1,40 @@
package api.hbm.energymk2; package api.hbm.energymk2;
import java.util.HashMap; import com.hbm.interfaces.NotableComments;
import java.util.HashSet; import com.hbm.uninos.GenNode;
import java.util.Map.Entry; import com.hbm.uninos.UniNodespace;
import java.util.Set; import com.hbm.uninos.networkproviders.PowerNetProvider;
import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.fauxpointtwelve.DirPos;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World; import net.minecraft.world.World;
/** /**
* The "Nodespace" is an intermediate, "ethereal" layer of abstraction that tracks nodes (i.e. cables) even when they are no longer loaded, allowing continued operation even when unloaded * 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 * @author hbm
*
*/ */
public class Nodespace { public class Nodespace {
/** Contains all "NodeWorld" instances, i.e. lists of nodes existing per world */ public static final PowerNetProvider THE_POWER_PROVIDER = new PowerNetProvider();
public static HashMap<World, NodeWorld> worlds = new HashMap<>();
public static Set<PowerNetMK2> activePowerNets = new HashSet<>();
public static PowerNode getNode(World world, int x, int y, int z) { @Deprecated public static PowerNode getNode(World world, int x, int y, int z) {
NodeWorld nodeWorld = worlds.get(world); return (PowerNode) UniNodespace.getNode(world, x, y, z, THE_POWER_PROVIDER);
if(nodeWorld != null) return nodeWorld.nodes.get(new BlockPos(x, y, z));
return null;
} }
public static void createNode(World world, PowerNode node) { @Deprecated public static void createNode(World world, PowerNode node) {
NodeWorld nodeWorld = worlds.get(world); UniNodespace.createNode(world, node);
if(nodeWorld == null) {
nodeWorld = new NodeWorld();
worlds.put(world, nodeWorld);
}
nodeWorld.pushNode(node);
} }
public static void destroyNode(World world, int x, int y, int z) { @Deprecated public static void destroyNode(World world, int x, int y, int z) {
PowerNode node = getNode(world, x, y, z); UniNodespace.destroyNode(world, x, y, z, THE_POWER_PROVIDER);
if(node != null) {
worlds.get(world).popNode(node);
}
} }
/** Goes over each node and manages connections */
public static void updateNodespace() {
for(World world : MinecraftServer.getServer().worldServers) {
NodeWorld nodes = worlds.get(world);
if(nodes == null) @NotableComments
continue; public static class PowerNode extends GenNode<PowerNetMK2> {
for(Entry<BlockPos, PowerNode> entry : nodes.nodes.entrySet()) {
PowerNode node = entry.getValue();
if(!node.hasValidNet() || node.recentlyChanged) {
checkNodeConnection(world, node);
node.recentlyChanged = false;
}
}
}
updatePowerNets();
}
private static void updatePowerNets() {
for(PowerNetMK2 net : activePowerNets) net.resetEnergyTracker(); //reset has to be done before everything else
for(PowerNetMK2 net : activePowerNets) net.transferPower();
}
/** Goes over each connection point of the given node, tries to find neighbor nodes and to join networks with them */
private static void checkNodeConnection(World world, PowerNode node) {
for(DirPos con : node.connections) {
PowerNode conNode = getNode(world, con.getX(), con.getY(), con.getZ()); // get whatever neighbor node intersects with that connection
if(conNode != null) { // if there is a node at that place
if(conNode.hasValidNet() && conNode.net == node.net) continue; // if the net is valid and both nodes have the same net, skip
if(checkConnection(conNode, con, false)) {
connectToNode(node, conNode);
}
}
}
if(node.net == null || !node.net.isValid()) new PowerNetMK2().joinLink(node);
}
public static boolean checkConnection(PowerNode connectsTo, DirPos connectFrom, boolean skipSideCheck) {
for(DirPos revCon : connectsTo.connections) {
if(revCon.getX() - revCon.getDir().offsetX == connectFrom.getX() && revCon.getY() - revCon.getDir().offsetY == connectFrom.getY() && revCon.getZ() - revCon.getDir().offsetZ == connectFrom.getZ() && (revCon.getDir() == connectFrom.getDir().getOpposite() || skipSideCheck)) {
return true;
}
}
return false;
}
/** Links two nodes with different or potentially no networks */
private static void connectToNode(PowerNode origin, PowerNode connection) {
if(origin.hasValidNet() && connection.hasValidNet()) { // both nodes have nets, but the nets are different (previous assumption), join networks
if(origin.net.links.size() > connection.net.links.size()) {
origin.net.joinNetworks(connection.net);
} else {
connection.net.joinNetworks(origin.net);
}
} else if(!origin.hasValidNet() && connection.hasValidNet()) { // origin has no net, connection does, have origin join connection's net
connection.net.joinLink(origin);
} else if(origin.hasValidNet() && !connection.hasValidNet()) { // ...and vice versa
origin.net.joinLink(connection);
}
}
public static class NodeWorld {
/** Contains a map showing where each node is, a node is every spot that a cable exists at.
* Instead of the old proxy system, things like substation now create multiple nodes at their connection points */
public HashMap<BlockPos, PowerNode> nodes = new HashMap<>();
/** Adds a node at all its positions to the nodespace */
public void pushNode(PowerNode node) {
for(BlockPos pos : node.positions) {
nodes.put(pos, node);
}
}
/** Removes the specified node from all positions from nodespace */
public void popNode(PowerNode node) {
if(node.net != null) node.net.destroy();
for(BlockPos pos : node.positions) {
nodes.remove(pos);
node.expired = true;
}
}
/** Grabs the node at one position, then removes it from all positions it occupies */
public void popNode(BlockPos pos) {
PowerNode node = nodes.get(pos);
if(node != null) popNode(node);
}
}
public static class PowerNode {
public BlockPos[] positions;
public DirPos[] connections;
public PowerNetMK2 net;
public boolean expired = false;
/** /**
* 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. * 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. * I don't know why. But for some reason, during neighbor checks, on certain arbitrary fucking places, the joining operation just fails.
@ -165,32 +46,16 @@ public class Nodespace {
* 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, * 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. * this issue shouldn't exist to begin with and I am going fucking insane but it is what it is.
*/ */
public boolean recentlyChanged = true;
public PowerNode(BlockPos... positions) { public PowerNode(BlockPos... positions) {
super(THE_POWER_PROVIDER, positions);
this.positions = positions; this.positions = positions;
} }
@Override
public PowerNode setConnections(DirPos... connections) { public PowerNode setConnections(DirPos... connections) {
this.connections = connections; super.setConnections(connections);
return this; return this;
} }
public PowerNode addConnection(DirPos connection) {
DirPos[] newCons = new DirPos[this.connections.length + 1];
for(int i = 0; i < this.connections.length; i++) newCons[i] = this.connections[i];
newCons[newCons.length - 1] = connection;
this.connections = newCons;
return this;
}
public boolean hasValidNet() {
return this.net != null && this.net.isValid();
}
public void setNet(PowerNetMK2 net) {
this.net = net;
this.recentlyChanged = true;
}
} }
} }

View File

@ -1,125 +1,32 @@
package api.hbm.energymk2; package api.hbm.energymk2;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import com.hbm.uninos.NodeNet;
import com.hbm.util.Tuple.Pair; import com.hbm.util.Tuple.Pair;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Random;
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority; import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
import api.hbm.energymk2.Nodespace.PowerNode; import api.hbm.energymk2.Nodespace.PowerNode;
public class PowerNetMK2 { /**
* Technically MK3 since it's now UNINOS compatible, although UNINOS was build out of 95% nodespace code
public static Random rand = new Random(); *
public boolean valid = true; * @author hbm
public Set<PowerNode> links = new HashSet(); */
public class PowerNetMK2 extends NodeNet<IEnergyReceiverMK2, IEnergyProviderMK2, PowerNode> {
/** Maps all active subscribers to a timestamp, handy for handling timeouts. In a good system this shouldn't be necessary, but the previous system taught me to be cautious anyway */
public HashMap<IEnergyReceiverMK2, Long> receiverEntries = new HashMap();
public HashMap<IEnergyProviderMK2, Long> providerEntries = new HashMap();
public long energyTracker = 0L; public long energyTracker = 0L;
public PowerNetMK2() {
Nodespace.activePowerNets.add(this);
}
/// SUBSCRIBER HANDLING ///
public boolean isSubscribed(IEnergyReceiverMK2 receiver) {
return this.receiverEntries.containsKey(receiver);
}
public void addReceiver(IEnergyReceiverMK2 receiver) {
this.receiverEntries.put(receiver, System.currentTimeMillis());
}
public void removeReceiver(IEnergyReceiverMK2 receiver) {
this.receiverEntries.remove(receiver);
}
/// PROVIDER HANDLING ///
public boolean isProvider(IEnergyProviderMK2 provider) {
return this.providerEntries.containsKey(provider);
}
public void addProvider(IEnergyProviderMK2 provider) {
this.providerEntries.put(provider, System.currentTimeMillis());
}
public void removeProvider(IEnergyProviderMK2 provider) {
this.providerEntries.remove(provider);
}
/// LINK JOINING ///
/** Combines two networks into one */
public void joinNetworks(PowerNetMK2 network) {
if(network == this) return; //wtf?!
List<PowerNode> oldNodes = new ArrayList(network.links.size());
oldNodes.addAll(network.links); // might prevent oddities related to joining - nvm it does nothing
for(PowerNode conductor : oldNodes) forceJoinLink(conductor);
network.links.clear();
for(IEnergyReceiverMK2 connector : network.receiverEntries.keySet()) this.addReceiver(connector);
for(IEnergyProviderMK2 connector : network.providerEntries.keySet()) this.addProvider(connector);
network.destroy();
}
/** Adds the power node as part of this network's links */
public PowerNetMK2 joinLink(PowerNode node) {
if(node.net != null) node.net.leaveLink(node);
return forceJoinLink(node);
}
/** Adds the power node as part of this network's links, skips the part about removing it from existing networks */
public PowerNetMK2 forceJoinLink(PowerNode node) {
this.links.add(node);
node.setNet(this);
return this;
}
/** Removes the specified power node */
public void leaveLink(PowerNode node) {
node.setNet(null);
this.links.remove(node);
}
/// GENERAL POWER NET CONTROL ///
public void invalidate() {
this.valid = false;
Nodespace.activePowerNets.remove(this);
}
public boolean isValid() {
return this.valid;
}
public void destroy() {
this.invalidate();
for(PowerNode link : this.links) if(link.net == this) link.setNet(null);
this.links.clear();
this.receiverEntries.clear();
this.providerEntries.clear();
}
public void resetEnergyTracker() {
this.energyTracker = 0;
}
protected static int timeout = 3_000; protected static int timeout = 3_000;
public void transferPower() { @Override public void resetTrackers() { this.energyTracker = 0; }
@Override
public void update() {
if(providerEntries.isEmpty()) return; if(providerEntries.isEmpty()) return;
if(receiverEntries.isEmpty()) return; if(receiverEntries.isEmpty()) return;
@ -129,15 +36,19 @@ public class PowerNetMK2 {
List<Pair<IEnergyProviderMK2, Long>> providers = new ArrayList(); List<Pair<IEnergyProviderMK2, Long>> providers = new ArrayList();
long powerAvailable = 0; long powerAvailable = 0;
// sum up available power
Iterator<Entry<IEnergyProviderMK2, Long>> provIt = providerEntries.entrySet().iterator(); Iterator<Entry<IEnergyProviderMK2, Long>> provIt = providerEntries.entrySet().iterator();
while(provIt.hasNext()) { while(provIt.hasNext()) {
Entry<IEnergyProviderMK2, Long> entry = provIt.next(); Entry<IEnergyProviderMK2, Long> entry = provIt.next();
if(timestamp - entry.getValue() > timeout) { provIt.remove(); continue; } if(timestamp - entry.getValue() > timeout || isBadLink(entry.getKey())) { provIt.remove(); continue; }
long src = Math.min(entry.getKey().getPower(), entry.getKey().getProviderSpeed()); long src = Math.min(entry.getKey().getPower(), entry.getKey().getProviderSpeed());
providers.add(new Pair(entry.getKey(), src)); if(src > 0) {
powerAvailable += src; 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]; List<Pair<IEnergyReceiverMK2, Long>>[] receivers = new ArrayList[ConnectionPriority.values().length];
for(int i = 0; i < receivers.length; i++) receivers[i] = new ArrayList(); for(int i = 0; i < receivers.length; i++) receivers[i] = new ArrayList();
long[] demand = new long[ConnectionPriority.values().length]; long[] demand = new long[ConnectionPriority.values().length];
@ -147,17 +58,20 @@ public class PowerNetMK2 {
while(recIt.hasNext()) { while(recIt.hasNext()) {
Entry<IEnergyReceiverMK2, Long> entry = recIt.next(); Entry<IEnergyReceiverMK2, Long> entry = recIt.next();
if(timestamp - entry.getValue() > timeout) { recIt.remove(); continue; } if(timestamp - entry.getValue() > timeout || isBadLink(entry.getKey())) { recIt.remove(); continue; }
long rec = Math.min(entry.getKey().getMaxPower() - entry.getKey().getPower(), entry.getKey().getReceiverSpeed()); long rec = Math.min(entry.getKey().getMaxPower() - entry.getKey().getPower(), entry.getKey().getReceiverSpeed());
int p = entry.getKey().getPriority().ordinal(); if(rec > 0) {
receivers[p].add(new Pair(entry.getKey(), rec)); int p = entry.getKey().getPriority().ordinal();
demand[p] += rec; receivers[p].add(new Pair(entry.getKey(), rec));
totalDemand += rec; demand[p] += rec;
totalDemand += rec;
}
} }
long toTransfer = Math.min(powerAvailable, totalDemand); long toTransfer = Math.min(powerAvailable, totalDemand);
long energyUsed = 0; long energyUsed = 0;
// add power to receivers, ordered by priority
for(int i = ConnectionPriority.values().length - 1; i >= 0; i--) { for(int i = ConnectionPriority.values().length - 1; i >= 0; i--) {
List<Pair<IEnergyReceiverMK2, Long>> list = receivers[i]; List<Pair<IEnergyReceiverMK2, Long>> list = receivers[i];
long priorityDemand = demand[i]; long priorityDemand = demand[i];
@ -174,6 +88,7 @@ public class PowerNetMK2 {
this.energyTracker += energyUsed; this.energyTracker += energyUsed;
long leftover = energyUsed; long leftover = energyUsed;
// remove power from providers
for(Pair<IEnergyProviderMK2, Long> entry : providers) { for(Pair<IEnergyProviderMK2, Long> entry : providers) {
double weight = (double) entry.getValue() / (double) powerAvailable; double weight = (double) entry.getValue() / (double) powerAvailable;
long toUse = (long) Math.max(energyUsed * weight, 0D); long toUse = (long) Math.max(energyUsed * weight, 0D);
@ -181,7 +96,7 @@ public class PowerNetMK2 {
leftover -= toUse; leftover -= toUse;
} }
//rounding error compensation, detects surplus that hasn't been used and removes it from random providers // 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 int iterationsLeft = 100; // whiles without emergency brakes are a bad idea
while(iterationsLeft > 0 && leftover > 0 && providers.size() > 0) { while(iterationsLeft > 0 && leftover > 0 && providers.size() > 0) {
iterationsLeft--; iterationsLeft--;
@ -195,118 +110,6 @@ public class PowerNetMK2 {
} }
} }
@Deprecated public void transferPowerOld() {
if(providerEntries.isEmpty()) return;
if(receiverEntries.isEmpty()) return;
long timestamp = System.currentTimeMillis();
long transferCap = 100_000_000_000_000_00L; // that ought to be enough
long supply = 0;
long demand = 0;
long[] priorityDemand = new long[ConnectionPriority.values().length];
Iterator<Entry<IEnergyProviderMK2, Long>> provIt = providerEntries.entrySet().iterator();
while(provIt.hasNext()) {
Entry<IEnergyProviderMK2, Long> entry = provIt.next();
if(timestamp - entry.getValue() > timeout) { provIt.remove(); continue; }
supply += Math.min(entry.getKey().getPower(), entry.getKey().getProviderSpeed());
}
if(supply <= 0) return;
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());
demand += rec;
for(int i = 0; i <= entry.getKey().getPriority().ordinal(); i++) priorityDemand[i] += rec;
}
if(demand <= 0) return;
long toTransfer = Math.min(supply, demand);
if(toTransfer > transferCap) toTransfer = transferCap;
if(toTransfer <= 0) return;
List<IEnergyProviderMK2> buffers = new ArrayList();
List<IEnergyProviderMK2> providers = new ArrayList();
Set<IEnergyReceiverMK2> receiverSet = receiverEntries.keySet();
for(IEnergyProviderMK2 provider : providerEntries.keySet()) {
if(receiverSet.contains(provider)) {
buffers.add(provider);
} else {
providers.add(provider);
}
}
providers.addAll(buffers); //makes buffers go last
List<IEnergyReceiverMK2> receivers = new ArrayList() {{ addAll(receiverSet); }};
receivers.sort(COMP);
int maxIteration = 1000;
//how much the current sender/receiver have already sent/received
long prevSrc = 0;
long prevDest = 0;
while(!receivers.isEmpty() && !providers.isEmpty() && maxIteration > 0) {
maxIteration--;
IEnergyProviderMK2 src = providers.get(0);
IEnergyReceiverMK2 dest = receivers.get(0);
if(src.getPower() <= 0) { providers.remove(0); prevSrc = 0; continue; }
if(src == dest) { // STALEMATE DETECTED
//if this happens, a buffer will waste both its share of transfer and receiving potential and do effectively nothing, essentially breaking
//try if placing the conflicting provider at the end of the list does anything
//we do this first because providers have no priority, so we may shuffle those around as much as we want
if(providers.size() > 1) {
providers.add(providers.get(0));
providers.remove(0);
prevSrc = 0; //this might cause slight issues due to the tracking being effectively lost while there still might be pending operations
continue;
}
//if that didn't work, try shifting the receiver by one place (to minimize priority breakage)
if(receivers.size() > 1) {
receivers.add(2, receivers.get(0));
receivers.remove(0);
prevDest = 0; //ditto
continue;
}
//if neither option could be performed, the only conclusion is that this buffer mode battery is alone in the power net, in which case: not my provlem
}
long pd = priorityDemand[dest.getPriority().ordinal()];
long receiverShare = Math.min((long) Math.ceil((double) Math.min(dest.getMaxPower() - dest.getPower(), dest.getReceiverSpeed()) * (double) supply / (double) pd), dest.getReceiverSpeed()) - prevDest;
long providerShare = Math.min((long) Math.ceil((double) Math.min(src.getPower(), src.getProviderSpeed()) * (double) demand / (double) supply), src.getProviderSpeed()) - prevSrc;
long toDrain = Math.min((long) (src.getPower()), providerShare);
long toFill = Math.min(dest.getMaxPower() - dest.getPower(), receiverShare);
long finalTransfer = Math.min(toDrain, toFill);
if(toFill <= 0) { receivers.remove(0); prevDest = 0; continue; }
finalTransfer -= dest.transferPower(finalTransfer);
src.usePower(finalTransfer);
prevSrc += finalTransfer;
prevDest += finalTransfer;
if(prevSrc >= src.getProviderSpeed()) { providers.remove(0); prevSrc = 0; continue; }
if(prevDest >= dest.getReceiverSpeed()) { receivers.remove(0); prevDest = 0; continue; }
toTransfer -= finalTransfer;
this.energyTracker += finalTransfer;
}
}
public long sendPowerDiode(long power) { public long sendPowerDiode(long power) {
if(receiverEntries.isEmpty()) return power; if(receiverEntries.isEmpty()) return power;
@ -350,14 +153,4 @@ public class PowerNetMK2 {
return power - energyUsed; return power - energyUsed;
} }
public static final ReceiverComparator COMP = new ReceiverComparator();
public static class ReceiverComparator implements Comparator<IEnergyReceiverMK2> {
@Override
public int compare(IEnergyReceiverMK2 o1, IEnergyReceiverMK2 o2) {
return o2.getPriority().ordinal() - o1.getPriority().ordinal();
}
}
} }

View File

@ -0,0 +1,16 @@
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,19 +0,0 @@
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, int pressure, long amount) {
if(this.getPipeNet(type) == null)
return amount;
return this.getPipeNet(type).transferFluid(amount, pressure);
}
}

View File

@ -1,93 +1,6 @@
package api.hbm.fluid; package api.hbm.fluid;
import com.hbm.inventory.fluid.FluidType; import api.hbm.fluidmk2.IFluidConnectorMK2;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.util.Compat;
import api.hbm.tile.ILoadedTile; @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 extends ILoadedTile {
/**
* Returns the amount of fluid that remains
* @param power
* @return
*/
public long transferFluid(FluidType type, int pressure, 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, int pressure);
/**
* 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 = Compat.getTileStandard(world, 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,12 +1,6 @@
package api.hbm.fluid; package api.hbm.fluid;
import com.hbm.inventory.fluid.FluidType; import api.hbm.fluidmk2.IFluidConnectorBlockMK2;
import net.minecraft.world.IBlockAccess; @Deprecated
import net.minecraftforge.common.util.ForgeDirection; public interface IFluidConnectorBlock extends IFluidConnectorBlockMK2 { }
public interface IFluidConnectorBlock {
/** 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,49 +1,35 @@
package api.hbm.fluid; package api.hbm.fluid;
import com.hbm.inventory.fluid.FluidType; import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.uninos.GenNode;
import com.hbm.uninos.UniNodespace;
/** import api.hbm.fluidmk2.IFluidStandardReceiverMK2;
* Uses default implementation to make the underlying interfaces easier to use for the most common fluid users. import net.minecraft.tileentity.TileEntity;
* Only handles a single input tank of the same type. import net.minecraft.world.World;
* Uses standard FluidTanks which use int32. import net.minecraftforge.common.util.ForgeDirection;
* Don't use this as part of the API!
* @author hbm
*
*/
public interface IFluidStandardReceiver extends IFluidUser {
@Override
public default long transferFluid(FluidType type, int pressure, long amount) {
for(FluidTank tank : getReceivingTanks()) { @Deprecated
if(tank.getTankType() == type && tank.getPressure() == pressure) { public interface IFluidStandardReceiver extends IFluidStandardReceiverMK2 {
tank.setFill(tank.getFill() + (int) amount);
public default void subscribeToAllAround(FluidType type, TileEntity tile) {
if(tank.getFill() > tank.getMaxFill()) { subscribeToAllAround(type, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord);
long overshoot = tank.getFill() - tank.getMaxFill();
tank.setFill(tank.getMaxFill());
return overshoot;
}
return 0;
}
}
return amount;
} }
public FluidTank[] getReceivingTanks(); public default void subscribeToAllAround(FluidType type, World world, int x, int y, int z) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
@Override trySubscribe(type, world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir);
public default long getDemand(FluidType type, int pressure) { }
}
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) { public default void tryUnsubscribe(FluidType type, World world, int x, int y, int z) {
return tank.getMaxFill() - tank.getFill(); GenNode node = UniNodespace.getNode(world, x, y, z, type.getNetworkProvider());
} if(node != null && node.net != null) node.net.removeReceiver(this);
}
public default void unsubscribeToAllAround(FluidType type, TileEntity tile) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
tryUnsubscribe(type, tile.getWorldObj(), tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ);
} }
return 0;
} }
} }

View File

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

View File

@ -1,79 +1,4 @@
package api.hbm.fluid; package api.hbm.fluid;
import com.hbm.inventory.fluid.FluidType; @Deprecated
import com.hbm.inventory.fluid.tank.FluidTank; public interface IFluidStandardTransceiver extends IFluidStandardReceiver, IFluidStandardSender { }
/**
* 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, int pressure) {
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
return tank.getFill();
}
}
return 0;
}
@Override
public default void removeFluidForTransfer(FluidType type, int pressure, long amount) {
for(FluidTank tank : getSendingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
tank.setFill(tank.getFill() - (int) amount);
return;
}
}
}
@Override
public default long getDemand(FluidType type, int pressure) {
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
return tank.getMaxFill() - tank.getFill();
}
}
return 0;
}
@Override
public default long transferFluid(FluidType type, int pressure, long amount) {
for(FluidTank tank : getReceivingTanks()) {
if(tank.getTankType() == type && tank.getPressure() == pressure) {
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

@ -1,130 +0,0 @@
package api.hbm.fluid;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.util.Compat;
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(FluidTank tank, World world, int x, int y, int z, ForgeDirection dir) {
sendFluid(tank.getTankType(), tank.getPressure(), world, x, y, z, dir);
}
public default void sendFluid(FluidType type, int pressure, 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, pressure);
if(toSend > 0) {
long transfer = toSend - con.transferFluid(type, pressure, toSend);
this.removeFluidForTransfer(type, pressure, 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 static IPipeNet getPipeNet(World world, int x, int y, int z, FluidType type) {
TileEntity te = Compat.getTileStandard(world, x, y, z);
if(te instanceof IFluidConductor) {
IFluidConductor con = (IFluidConductor) te;
if(con.getPipeNet(type) != null) {
return con.getPipeNet(type);
}
}
return null;
}
/** Use more common conPos method instead */
@Deprecated public default void sendFluidToAll(FluidTank tank, TileEntity te) {
sendFluidToAll(tank.getTankType(), tank.getPressure(), te);
}
/** Use more common conPos method instead */
@Deprecated public default void sendFluidToAll(FluidType type, int pressure, TileEntity te) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
sendFluid(type, pressure, te.getWorldObj(), te.xCoord + dir.offsetX, te.yCoord + dir.offsetY, te.zCoord + dir.offsetZ, dir);
}
}
public default long getTotalFluidForSend(FluidType type, int pressure) { return 0; }
public default void removeFluidForTransfer(FluidType type, int pressure, 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);
}
/**
* Returns all internal tanks of this tile. Not used by the fluid network, it should only be used for display purposes or edge cases that can't be solved otherwise.
* The array is either composed of the original tank or outright the original tank array, so changes done to this array will extend to the IFluidUser.
* @return
*/
public FluidTank[] getAllTanks();
}

View File

@ -1,30 +0,0 @@
package api.hbm.fluid;
import java.math.BigInteger;
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, int pressure);
public FluidType getType();
public BigInteger getTotalTransfer();
}

View File

@ -1,206 +0,0 @@
package api.hbm.fluid;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.TimeZone;
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 static List<PipeNet> trackingInstances = null;
protected BigInteger totalTransfer = BigInteger.ZERO;
public List<String> debug = new ArrayList();
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, int pressure) {
subscribers.removeIf(x ->
x == null || !(x instanceof TileEntity) || ((TileEntity)x).isInvalid() || !x.isLoaded()
);
if(this.subscribers.isEmpty())
return fill;
trackingInstances = new ArrayList();
trackingInstances.add(this);
List<IFluidConnector> subList = new ArrayList(subscribers);
return fairTransfer(subList, type, pressure, fill);
}
public static long fairTransfer(List<IFluidConnector> subList, FluidType type, int pressure, long fill) {
if(fill <= 0) return 0;
List<Long> weight = new ArrayList();
long totalReq = 0;
for(IFluidConnector con : subList) {
long req = con.getDemand(type, pressure);
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);
if(given > 0) {
totalGiven += (given - con.transferFluid(type, pressure, given));
if(con instanceof TileEntity) {
TileEntity tile = (TileEntity) con;
tile.getWorldObj().markTileEntityChunkModified(tile.xCoord, tile.yCoord, tile.zCoord, tile);
}
if(trackingInstances != null) {
for(int j = 0; j < trackingInstances.size(); j++) {
PipeNet net = trackingInstances.get(j);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss:SSS");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
log(net, sdf.format(new Date(System.currentTimeMillis())) + " Sending " + given + "mB to " + conToString(con));
}
}
}
}
if(trackingInstances != null) {
for(int i = 0; i < trackingInstances.size(); i++) {
PipeNet net = trackingInstances.get(i);
net.totalTransfer = net.totalTransfer.add(BigInteger.valueOf(totalGiven));
}
}
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;
}
@Override
public BigInteger getTotalTransfer() {
return this.totalTransfer;
}
public static void log(PipeNet net, String msg) {
net.debug.add(msg);
while(net.debug.size() > 50) {
net.debug.remove(0);
}
}
public static String conToString(IFluidConnector con) {
if(con instanceof TileEntity) {
TileEntity tile = (TileEntity) con;
return tile.getClass().getSimpleName() + " @ " + tile.xCoord + "/" + tile.yCoord + "/" + tile.zCoord;
}
return "" + con;
}
}

View File

@ -0,0 +1,152 @@
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

@ -0,0 +1,19 @@
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,4 +1,4 @@
package api.hbm.fluid; package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType; import com.hbm.inventory.fluid.FluidType;

View File

@ -0,0 +1,12 @@
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

@ -0,0 +1,17 @@
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

@ -0,0 +1,27 @@
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

@ -0,0 +1,12 @@
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

@ -0,0 +1,64 @@
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.Compat;
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 = Compat.getTileStandard(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

@ -0,0 +1,9 @@
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

@ -0,0 +1,68 @@
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

@ -0,0 +1,130 @@
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.Compat;
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 = Compat.getTileStandard(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

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

View File

@ -0,0 +1,15 @@
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

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

View File

@ -1,17 +0,0 @@
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

@ -1,20 +0,0 @@
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

@ -0,0 +1,13 @@
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

@ -0,0 +1,17 @@
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

@ -7,15 +7,17 @@ public interface IRORInteractive extends IRORInfo {
public static String EX_NULL = "Exception: Null Command"; public static String EX_NULL = "Exception: Null Command";
public static String EX_NAME = "Exception: Multiple Name Separators"; 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. */ /** Runs a function on the ROR component, usually causing the component to change or do something. Returns are optional. */
public Object runRORFunction(String name, String[] params); public String runRORFunction(String name, String[] params);
/** Extracts the command name from a full command string */ /** Extracts the command name from a full command string */
public static String getCommand(String input) { public static String getCommand(String input) {
if(input == null || input.isEmpty()) throw new RORFunctionException(EX_NULL); if(input == null || input.isEmpty()) throw new RORFunctionException(EX_NULL);
String[] parts = input.split(NAME_SEPARATOR); String[] parts = input.split(NAME_SEPARATOR);
if(parts.length <= 0 || parts.length > 2) throw new RORFunctionException(EX_NAME); if(parts.length <= 0 || parts.length > 2) throw new RORFunctionException(EX_NAME);
if(parts[0].isEmpty()) throw new RORFunctionException(EX_NULL);
return parts[0]; return parts[0];
} }
@ -29,4 +31,11 @@ public interface IRORInteractive extends IRORInfo {
String[] params = paramList.split(PARAM_SEPARATOR); String[] params = paramList.split(PARAM_SEPARATOR);
return params; 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

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

View File

@ -32,7 +32,7 @@ INDEX includes:
optionally returning a value optionally returning a value
On the implementation side we can expect: 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 boradcasted - 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 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 - 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 then send the return value on the return frequency
@ -43,4 +43,7 @@ ROR programmers can indeed do everything that the readers and controllers can, b
which are more time-consuming to set up and limits the amount of command channels available, hence why readers and controllers exist 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 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,5 +1,6 @@
package api.hbm.tile; package api.hbm.tile;
/** 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 interface ILoadedTile {
public boolean isLoaded(); public boolean isLoaded();

View File

@ -1,7 +1,6 @@
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.EnumCreatureType;
@ -11,7 +10,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; 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; private boolean canSpawn = true;
@ -22,14 +21,14 @@ public class BlockBase extends Block {
public BlockBase(Material material) { public BlockBase(Material material) {
super(material); super(material);
} }
@Override @Override
public Block setBlockName(String name) { public Block setBlockName(String name) {
super.setBlockName(name); super.setBlockName(name);
this.setBlockTextureName(RefStrings.MODID + ":" + name); this.setBlockTextureName(RefStrings.MODID + ":" + name);
return this; return this;
} }
/** /**
* Daisychainable setter for making the block a beacon base block * Daisychainable setter for making the block a beacon base block
* @return * @return
@ -38,7 +37,7 @@ public class BlockBase extends Block {
this.beaconable = true; this.beaconable = true;
return this; return this;
} }
public BlockBase noMobSpawn() { public BlockBase noMobSpawn() {
this.canSpawn = false; this.canSpawn = false;
return this; return this;
@ -53,7 +52,7 @@ public class BlockBase extends Block {
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;
} }
/** /**
* Sets the block to air and drops it * Sets the block to air and drops it
* @param world * @param world
@ -62,7 +61,7 @@ public class BlockBase extends Block {
* @param z * @param z
*/ */
public void dismantle(World world, int x, int y, int z) { public void dismantle(World world, int x, int y, int z) {
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
ItemStack itemstack = new ItemStack(this, 1); ItemStack itemstack = new ItemStack(this, 1);

View File

@ -1,13 +1,11 @@
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.tileentity.IPersistentNBT;
import com.hbm.world.gen.INBTTransformable;
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.Side;
@ -15,6 +13,7 @@ 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.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
@ -27,12 +26,18 @@ import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; 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.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.event.DrawBlockHighlightEvent; import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public abstract class BlockDummyable extends BlockContainer implements ICustomBlockHighlight { import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public abstract class BlockDummyable extends BlockContainer implements ICustomBlockHighlight, ICopiable, INBTTransformable {
public BlockDummyable(Material mat) { public BlockDummyable(Material mat) {
super(mat); super(mat);
@ -49,7 +54,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
public static final int offset = 10; public static final int offset = 10;
// 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. * 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. * This way we can inelegantly add variation to the tiles created even if the metadata would be the same.
@ -59,11 +64,11 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
public static int overrideTileMeta = 0; public static int overrideTileMeta = 0;
public static boolean safeRem = false; public static boolean safeRem = false;
public static void setOverride(int i) { public static void setOverride(int i) {
overrideTileMeta = i; overrideTileMeta = i;
} }
public static void resetOverride() { public static void resetOverride() {
overrideTileMeta = 0; overrideTileMeta = 0;
} }
@ -72,27 +77,20 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
super.onNeighborBlockChange(world, x, y, z, block); super.onNeighborBlockChange(world, x, y, z, block);
if(world.isRemote || safeRem) if(safeRem)
return; return;
int metadata = world.getBlockMetadata(x, y, z); destroyIfOrphan(world, 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);
}
} }
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;
@ -105,10 +103,32 @@ 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);
if(b != this) { // An extra precaution against multiblocks on chunk borders being erroneously deleted.
world.setBlockToAir(x, y, z); // 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);
}
} }
}
// 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) {
@ -116,7 +136,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) {
@ -178,7 +198,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
if(i == 3) { if(i == 3) {
dir = ForgeDirection.getOrientation(4); dir = ForgeDirection.getOrientation(4);
} }
dir = getDirModified(dir); dir = getDirModified(dir);
if(!checkRequirement(world, x, y, z, dir, o)) { if(!checkRequirement(world, x, y, z, dir, o)) {
@ -216,11 +236,6 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
super.onBlockPlacedBy(world, x, y, z, player, itemStack); super.onBlockPlacedBy(world, x, y, z, player, itemStack);
} }
/*@Override
public void onBlockAdded(World world, int x, int y, int z) {
lastBlockSet = new BlockPos(x, y, z);
}*/
/** /**
* A bit more advanced than the dir modifier, but it is important that the resulting direction meta is in the core range. * A bit more advanced than the dir modifier, but it is important that the resulting direction meta is in the core range.
* Using the "extra" metas is technically possible but requires a bit of tinkering, e.g. preventing a recursive loop * Using the "extra" metas is technically possible but requires a bit of tinkering, e.g. preventing a recursive loop
@ -236,7 +251,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
protected int getMetaForCore(World world, int x, int y, int z, EntityPlayer player, int original) { protected int getMetaForCore(World world, int x, int y, int z, EntityPlayer player, int original) {
return original; return original;
} }
/** /**
* Allows to modify the general placement direction as if the player had another rotation. * Allows to modify the general placement direction as if the player had another rotation.
* Quite basic due to only having 1 param but it's more meant to fix/limit the amount of directions * Quite basic due to only having 1 param but it's more meant to fix/limit the amount of directions
@ -267,11 +282,11 @@ 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);
this.safeRem = true; safeRem = true;
world.setBlock(x, y, z, this, meta + extra, 3); world.setBlock(x, y, z, this, meta + extra, 3);
this.safeRem = false; safeRem = false;
} }
public void removeExtra(World world, int x, int y, int z) { public void removeExtra(World world, int x, int y, int z) {
if(world.getBlock(x, y, z) != this) if(world.getBlock(x, y, z) != this)
@ -283,9 +298,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);
this.safeRem = true; safeRem = true;
world.setBlock(x, y, z, this, meta - extra, 3); world.setBlock(x, y, z, this, meta - extra, 3);
this.safeRem = false; safeRem = false;
} }
// checks if the dummy metadata is within the extra range // checks if the dummy metadata is within the extra range
@ -309,7 +324,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
// if(pos != null) { // if(pos != null) {
ForgeDirection d = ForgeDirection.getOrientation(i); ForgeDirection d = ForgeDirection.getOrientation(i);
if(world.getBlock(x - d.offsetX, y - d.offsetY, z - d.offsetZ) == this) if(world.getBlock(x - d.offsetX, y - d.offsetY, z - d.offsetZ) == this)
world.setBlockToAir(x - d.offsetX, y - d.offsetY, z - d.offsetZ); world.setBlockToAir(x - d.offsetX, y - d.offsetY, z - d.offsetZ);
// } // }
@ -384,7 +399,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
} }
protected boolean standardOpenBehavior(World world, int x, int y, int z, EntityPlayer player, int id) { protected boolean standardOpenBehavior(World world, int x, int y, int z, EntityPlayer player, int id) {
if(world.isRemote) { if(world.isRemote) {
return true; return true;
} else if(!player.isSneaking()) { } else if(!player.isSneaking()) {
@ -402,14 +417,14 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
@Override @Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) { public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
if(!player.capabilities.isCreativeMode) { if(!player.capabilities.isCreativeMode) {
harvesters.set(player); harvesters.set(player);
this.dropBlockAsItem(world, x, y, z, meta, 0); this.dropBlockAsItem(world, x, y, z, meta, 0);
harvesters.set(null); harvesters.set(null);
} }
} }
/* /*
* Called after the block and TE are already gone, so this method is of no use to us. * Called after the block and TE are already gone, so this method is of no use to us.
*/ */
@ -418,56 +433,85 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1); player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
player.addExhaustion(0.025F); player.addExhaustion(0.025F);
} }
public boolean useDetailedHitbox() { public boolean useDetailedHitbox() {
return !bounding.isEmpty(); return !bounding.isEmpty();
} }
public List<AxisAlignedBB> bounding = new ArrayList();
public List<AxisAlignedBB> bounding = new ArrayList<>();
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override @Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB entityBounding, List list, Entity entity) { public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB entityBounding, List list, Entity entity) {
if(!this.useDetailedHitbox()) { if(!this.useDetailedHitbox()) {
super.addCollisionBoxesToList(world, x, y, z, entityBounding, list, entity); super.addCollisionBoxesToList(world, x, y, z, entityBounding, list, entity);
return; return;
} }
int[] pos = this.findCore(world, x, y, z); int[] pos = this.findCore(world, x, y, z);
if(pos == null) if(pos == null)
return; return;
x = pos[0]; x = pos[0];
y = pos[1]; y = pos[1];
z = pos[2]; z = pos[2];
for(AxisAlignedBB aabb :this.bounding) { ForgeDirection rot = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) - offset).getRotation(ForgeDirection.UP);
AxisAlignedBB boxlet = getAABBRotationOffset(aabb, x + 0.5, y, z + 0.5, ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) - this.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)) { if(entityBounding.intersectsWith(boxlet)) {
list.add(boxlet); list.add(boxlet);
} }
} }
} }
public static AxisAlignedBB getAABBRotationOffset(AxisAlignedBB aabb, double x, double y, double z, ForgeDirection dir) { public static AxisAlignedBB getAABBRotationOffset(AxisAlignedBB aabb, double x, double y, double z, ForgeDirection dir) {
AxisAlignedBB newBox = null; 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.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.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.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(dir == ForgeDirection.WEST) newBox = AxisAlignedBB.getBoundingBox(aabb.minZ, aabb.minY, -aabb.maxX, aabb.maxZ, aabb.maxY, -aabb.minX);
if(newBox != null) { if(newBox != null) {
newBox.offset(x, y, z); newBox.offset(x, y, z);
return newBox; 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); 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 @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
if(!this.useDetailedHitbox()) { if(!this.useDetailedHitbox()) {
@ -476,35 +520,85 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
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 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 @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public boolean shouldDrawHighlight(World world, int x, int y, int z) { public boolean shouldDrawHighlight(World world, int x, int y, int z) {
return !this.bounding.isEmpty(); return !this.bounding.isEmpty();
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void drawHighlight(DrawBlockHighlightEvent event, World world, int x, int y, int z) { public void drawHighlight(DrawBlockHighlightEvent event, World world, int x, int y, int z) {
int[] pos = this.findCore(world, x, y, z); int[] pos = this.findCore(world, x, y, z);
if(pos == null) return; if(pos == null) return;
x = pos[0]; x = pos[0];
y = pos[1]; y = pos[1];
z = pos[2]; z = pos[2];
EntityPlayer player = event.player; EntityPlayer player = event.player;
float interp = event.partialTicks; float interp = event.partialTicks;
double dX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) interp; double dX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) interp;
double dY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) interp; double dY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) interp;
double dZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)interp; double dZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)interp;
float exp = 0.002F; float exp = 0.002F;
int meta = world.getBlockMetadata(x, y, z); ForgeDirection rot = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) - offset).getRotation(ForgeDirection.UP);
ICustomBlockHighlight.setup(); ICustomBlockHighlight.setup();
for(AxisAlignedBB aabb : this.bounding) event.context.drawOutlinedBoundingBox(getAABBRotationOffset(aabb.expand(exp, exp, exp), 0, 0, 0, ForgeDirection.getOrientation(meta - offset).getRotation(ForgeDirection.UP)).getOffsetBoundingBox(x - dX + 0.5, y - dY, z - dZ + 0.5), -1); 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(); 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);
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 = INBTTransformable.transformMetaDeco(meta, coordBaseMode);
if(isOffset) {
meta += offset;
} else if(isExtra) {
meta += extra;
}
return meta;
}
}

View File

@ -1,9 +1,6 @@
package com.hbm.blocks; package com.hbm.blocks;
import java.util.Locale;
import com.hbm.util.EnumUtil; 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;
@ -11,6 +8,8 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack; 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,17 +22,17 @@ public class BlockEnumMulti extends BlockMulti {
this.multiName = multiName; this.multiName = multiName;
this.multiTexture = multiTexture; this.multiTexture = multiTexture;
} }
protected IIcon[] icons; protected IIcon[] icons;
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) { public void registerBlockIcons(IIconRegister reg) {
if(multiTexture) { if(multiTexture) {
Enum[] enums = theEnum.getEnumConstants(); Enum[] enums = theEnum.getEnumConstants();
this.icons = new IIcon[enums.length]; this.icons = new IIcon[enums.length];
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.getTextureMultiName(num));
@ -42,25 +41,25 @@ public class BlockEnumMulti extends BlockMulti {
this.blockIcon = reg.registerIcon(this.getTextureName()); this.blockIcon = reg.registerIcon(this.getTextureName());
} }
} }
public String getUnlocalizedName(ItemStack stack) { public String getUnlocalizedName(ItemStack stack) {
if(this.multiName) { if(this.multiName) {
Enum num = EnumUtil.grabEnumSafely(this.theEnum, stack.getItemDamage()); Enum num = EnumUtil.grabEnumSafely(this.theEnum, stack.getItemDamage());
return getUnlocalizedMultiName(num); return getUnlocalizedMultiName(num);
} }
return this.getUnlocalizedName(); return this.getUnlocalizedName();
} }
public String getTextureMultiName(Enum num) { public String getTextureMultiName(Enum num) {
return this.getTextureName() + "." + num.name().toLowerCase(Locale.US); return this.getTextureName() + "." + num.name().toLowerCase(Locale.US);
} }
public String getUnlocalizedMultiName(Enum num) { public String getUnlocalizedMultiName(Enum num) {
return super.getUnlocalizedName() + "." + num.name().toLowerCase(Locale.US); 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) {

View File

@ -58,6 +58,14 @@ public class BlockEnums {
SMALL SMALL
} }
public static enum LightstoneType {
UNREFINED,
TILE,
BRICKS,
BRICKS_CHISELED,
CHISELED
}
public static enum DecoComputerEnum { public static enum DecoComputerEnum {
IBM_300PL IBM_300PL
} }

View File

@ -1,9 +1,6 @@
package com.hbm.blocks; package com.hbm.blocks;
import java.util.Random;
import com.hbm.entity.item.EntityFallingBlockNT; import com.hbm.entity.item.EntityFallingBlockNT;
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.Block; import net.minecraft.block.Block;
@ -14,6 +11,8 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.Random;
public class BlockFallingNT extends Block { public class BlockFallingNT extends Block {
public static boolean fallInstantly; public static boolean fallInstantly;
@ -45,7 +44,7 @@ public class BlockFallingNT extends Block {
} }
protected void fall(World world, int x, int y, int z) { protected void fall(World world, int x, int y, int z) {
if(canFallThrough(world, x, y - 1, z) && y >= 0) { if(canFallThrough(world, x, y - 1, z) && y >= 0) {
byte range = 32; byte range = 32;

View File

@ -1,7 +1,5 @@
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;
@ -9,6 +7,8 @@ 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() {

View File

@ -1,8 +1,5 @@
package com.hbm.blocks; package com.hbm.blocks;
import java.util.ArrayList;
import java.util.Random;
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.Block; import net.minecraft.block.Block;
@ -12,8 +9,11 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre; import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import java.util.ArrayList;
import java.util.Random;
public class BlockRemap extends Block implements ILookOverlay { public class BlockRemap extends Block implements ILookOverlay {
public Block remapBlock; public Block remapBlock;
public int remapMeta; public int remapMeta;
@ -29,7 +29,7 @@ public class BlockRemap extends Block implements ILookOverlay {
public IIcon getIcon(int meta, int side) { public IIcon getIcon(int meta, int side) {
return this.remapBlock.getIcon(meta, side); return this.remapBlock.getIcon(meta, side);
} }
@Override @Override
public Item getItemDropped(int meta, Random rand, int fortune) { public Item getItemDropped(int meta, Random rand, int fortune) {
return this.remapBlock.getItemDropped(meta, rand, fortune); return this.remapBlock.getItemDropped(meta, rand, fortune);

View File

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

View File

@ -11,4 +11,27 @@ public interface IBlockSideRotation {
public static int getRenderType() { public static int getRenderType() {
return renderID; 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,18 +1,17 @@
package com.hbm.blocks; package com.hbm.blocks;
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.renderer.OpenGlHelper; import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.event.DrawBlockHighlightEvent; import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import org.lwjgl.opengl.GL11;
public interface ICustomBlockHighlight { public interface ICustomBlockHighlight {
@SideOnly(Side.CLIENT) public boolean shouldDrawHighlight(World world, int x, int y, int z); @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 void drawHighlight(DrawBlockHighlightEvent event, World world, int x, int y, int z);
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void setup() { public static void setup() {
GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_BLEND);
@ -22,7 +21,7 @@ public interface ICustomBlockHighlight {
GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(false); GL11.glDepthMask(false);
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void cleanup() { public static void cleanup() {
GL11.glDepthMask(true); GL11.glDepthMask(true);

View File

@ -1,9 +1,5 @@
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;
@ -11,6 +7,9 @@ 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 {
@ -33,14 +32,14 @@ public interface ILookOverlay {
try { try {
for(String line : text) { for(String line : text) {
int color = 0xFFFFFF; int color = 0xFFFFFF;
if(line.startsWith("&[")) { if(line.startsWith("&[")) {
int end = line.lastIndexOf("&]"); int end = line.lastIndexOf("&]");
color = Integer.parseInt(line.substring(2, end)); color = Integer.parseInt(line.substring(2, end));
line = line.substring(end + 2); line = line.substring(end + 2);
} }
mc.fontRenderer.drawStringWithShadow(line, pX, pZ, color); mc.fontRenderer.drawStringWithShadow(line, pX, pZ, color);
pZ += 10; pZ += 10;
} }

View File

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

View File

@ -1,23 +1,22 @@
package com.hbm.blocks; package com.hbm.blocks;
import java.util.List;
import org.lwjgl.input.Keyboard;
import com.hbm.util.I18nUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.input.Keyboard;
import com.hbm.util.i18n.I18nUtil;
import java.util.List;
public interface ITooltipProvider { public interface ITooltipProvider {
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext); public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext);
public default void addStandardInfo(ItemStack stack, EntityPlayer player, List list, boolean ext) { public default void addStandardInfo(ItemStack stack, EntityPlayer player, List list, boolean ext) {
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
for(String s : I18nUtil.resolveKeyArray(((Block)this).getUnlocalizedName() + ".desc")) list.add(EnumChatFormatting.YELLOW + s); for(String s : I18nUtil.resolveKeyArray(((Block)this).getUnlocalizedName() + ".desc")) list.add(EnumChatFormatting.YELLOW + s);
} else { } else {
@ -26,7 +25,7 @@ public interface ITooltipProvider {
EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.ITALIC + "> to display more info"); EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.ITALIC + "> to display more info");
} }
} }
public default EnumRarity getRarity(ItemStack stack) { public default EnumRarity getRarity(ItemStack stack) {
return EnumRarity.common; return EnumRarity.common;
} }

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,9 @@ import java.util.List;
import com.hbm.explosion.vanillant.ExplosionVNT; import com.hbm.explosion.vanillant.ExplosionVNT;
import com.hbm.explosion.vanillant.standard.BlockAllocatorStandard; import com.hbm.explosion.vanillant.standard.BlockAllocatorStandard;
import com.hbm.explosion.vanillant.standard.BlockProcessorStandard; import com.hbm.explosion.vanillant.standard.BlockProcessorStandard;
import com.hbm.explosion.vanillant.standard.EntityProcessorStandard;
import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard;
import com.hbm.particle.helper.ExplosionCreator;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -22,10 +25,13 @@ public class BlockChargeC4 extends BlockChargeBase {
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
safe = false; safe = false;
ExplosionVNT xnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 15F).makeStandard(); ExplosionVNT xnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 15F);
xnt.setBlockAllocator(new BlockAllocatorStandard(32)); xnt.setBlockAllocator(new BlockAllocatorStandard(32));
xnt.setBlockProcessor(new BlockProcessorStandard().setNoDrop()); xnt.setBlockProcessor(new BlockProcessorStandard().setNoDrop());
xnt.setEntityProcessor(new EntityProcessorStandard());
xnt.setPlayerProcessor(new PlayerProcessorStandard());
xnt.explode(); xnt.explode();
ExplosionCreator.composeEffectSmall(world, x + 0.5, y + 1, z + 0.5);
return BombReturnCode.DETONATED; return BombReturnCode.DETONATED;
} }

View File

@ -1,7 +1,7 @@
package com.hbm.blocks.bomb; package com.hbm.blocks.bomb;
import com.hbm.explosion.ExplosionLarge;
import com.hbm.explosion.ExplosionNT; import com.hbm.explosion.ExplosionNT;
import com.hbm.particle.helper.ExplosionSmallCreator;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -17,7 +17,7 @@ public class BlockChargeDynamite extends BlockChargeBase {
safe = false; safe = false;
ExplosionNT exp = new ExplosionNT(world, null, x + 0.5, y + 0.5, z + 0.5, 4F); ExplosionNT exp = new ExplosionNT(world, null, x + 0.5, y + 0.5, z + 0.5, 4F);
exp.explode(); exp.explode();
ExplosionLarge.spawnParticles(world, x + 0.5, y + 0.5, z + 0.5, 20); ExplosionSmallCreator.composeEffect(world, x + 0.5, y + 0.5, z + 0.5, 15, 3F, 1.25F);
return BombReturnCode.DETONATED; return BombReturnCode.DETONATED;
} }

View File

@ -2,9 +2,9 @@ package com.hbm.blocks.bomb;
import java.util.List; import java.util.List;
import com.hbm.explosion.ExplosionLarge;
import com.hbm.explosion.ExplosionNT; import com.hbm.explosion.ExplosionNT;
import com.hbm.explosion.ExplosionNT.ExAttrib; import com.hbm.explosion.ExplosionNT.ExAttrib;
import com.hbm.particle.helper.ExplosionSmallCreator;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -23,7 +23,7 @@ public class BlockChargeMiner extends BlockChargeBase {
ExplosionNT exp = new ExplosionNT(world, null, x + 0.5, y + 0.5, z + 0.5, 4F); ExplosionNT exp = new ExplosionNT(world, null, x + 0.5, y + 0.5, z + 0.5, 4F);
exp.addAllAttrib(ExAttrib.NOHURT, ExAttrib.ALLDROP); exp.addAllAttrib(ExAttrib.NOHURT, ExAttrib.ALLDROP);
exp.explode(); exp.explode();
ExplosionLarge.spawnParticles(world, x + 0.5, y + 0.5, z + 0.5, 20); ExplosionSmallCreator.composeEffect(world, x + 0.5, y + 0.5, z + 0.5, 15, 3F, 1.25F);
return BombReturnCode.DETONATED; return BombReturnCode.DETONATED;
} }

View File

@ -5,7 +5,7 @@ import java.util.List;
import com.hbm.explosion.vanillant.ExplosionVNT; import com.hbm.explosion.vanillant.ExplosionVNT;
import com.hbm.explosion.vanillant.standard.BlockAllocatorStandard; import com.hbm.explosion.vanillant.standard.BlockAllocatorStandard;
import com.hbm.explosion.vanillant.standard.BlockProcessorStandard; import com.hbm.explosion.vanillant.standard.BlockProcessorStandard;
import com.hbm.explosion.vanillant.standard.ExplosionEffectStandard; import com.hbm.particle.helper.ExplosionCreator;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -27,8 +27,8 @@ public class BlockChargeSemtex extends BlockChargeBase {
xnt.setBlockProcessor(new BlockProcessorStandard() xnt.setBlockProcessor(new BlockProcessorStandard()
.setAllDrop() .setAllDrop()
.setFortune(3)); .setFortune(3));
xnt.setSFX(new ExplosionEffectStandard());
xnt.explode(); xnt.explode();
ExplosionCreator.composeEffectSmall(world, x + 0.5, y + 1, z + 0.5);
return BombReturnCode.DETONATED; return BombReturnCode.DETONATED;
} }

View File

@ -1,91 +1,77 @@
package com.hbm.blocks.bomb; package com.hbm.blocks.bomb;
import java.util.Random; import com.hbm.blocks.BlockEnumMulti;
import com.hbm.blocks.ModBlocks;
import com.hbm.config.BombConfig; import com.hbm.config.BombConfig;
import com.hbm.entity.logic.EntityBalefire; import com.hbm.entity.logic.EntityBalefire;
import com.hbm.entity.logic.EntityNukeExplosionMK5;
import com.hbm.explosion.vanillant.ExplosionVNT;
import com.hbm.explosion.vanillant.standard.BlockAllocatorStandard;
import com.hbm.explosion.vanillant.standard.BlockProcessorStandard;
import com.hbm.explosion.vanillant.standard.EntityProcessorCross;
import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard;
import com.hbm.handler.threading.PacketThreading;
import com.hbm.interfaces.IBomb; import com.hbm.interfaces.IBomb;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.packet.AuxParticlePacketNT; import com.hbm.main.MainRegistry;
import com.hbm.packet.PacketDispatcher; import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.particle.helper.ExplosionCreator;
import com.hbm.tileentity.bomb.TileEntityCrashedBomb; import com.hbm.tileentity.bomb.TileEntityCrashedBomb;
import com.hbm.util.EnumUtil;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.block.BlockContainer; import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
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;
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.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockCrashedBomb extends BlockContainer implements IBomb { public class BlockCrashedBomb extends BlockEnumMulti implements ITileEntityProvider, IBomb {
public static enum EnumDudType {
BALEFIRE, CONVENTIONAL, NUKE, SALTED
}
public BlockCrashedBomb(Material p_i45386_1_) { public BlockCrashedBomb(Material mat) {
super(p_i45386_1_); super(mat, EnumDudType.class, false, false);
} }
@Override @Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityCrashedBomb(); return new TileEntityCrashedBomb();
} }
@Override @Override public int getRenderType() { return -1; }
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { @Override public boolean isOpaqueCube() { return false; }
return Item.getItemFromBlock(ModBlocks.crashed_balefire); @Override public boolean renderAsNormalBlock() { return false; }
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if(i == 0) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(i == 1) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(i == 2) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
if(i == 3) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float fx, float fy, float fz) { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float fx, float fy, float fz) {
if(world.isRemote) return true;
if(world.isRemote)
return true;
if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.defuser) { if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.defuser) {
EnumDudType type = EnumUtil.grabEnumSafely(EnumDudType.class, world.getBlockMetadata(x, y, z));
//TODO: make this less scummy
if(type == type.BALEFIRE) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.egg_balefire_shard)));
}
if(type == type.CONVENTIONAL) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.ball_tnt, 16)));
}
if(type == type.NUKE) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.ball_tnt, 8)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.billet_plutonium, 4)));
}
if(type == type.SALTED) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.ball_tnt, 8)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.billet_plutonium, 2)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.ingot_cobalt, 12)));
}
world.func_147480_a(x, y, z, false); world.func_147480_a(x, y, z, false);
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.egg_balefire_shard)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.plate_steel, 10 + world.rand.nextInt(15))));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.plate_titanium, 2 + world.rand.nextInt(7))));
return true; return true;
} }
@ -97,21 +83,46 @@ public class BlockCrashedBomb extends BlockContainer implements IBomb {
if(!world.isRemote) { if(!world.isRemote) {
EnumDudType type = EnumUtil.grabEnumSafely(EnumDudType.class, world.getBlockMetadata(x, y, z));
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
EntityBalefire bf = new EntityBalefire(world);
bf.posX = x;
bf.posY = y;
bf.posZ = z;
bf.destructionRange = (int) (BombConfig.fatmanRadius * 1.25);
world.spawnEntityInWorld(bf);
NBTTagCompound data = new NBTTagCompound(); if(type == type.BALEFIRE) {
data.setString("type", "muke"); EntityBalefire bf = new EntityBalefire(world);
data.setBoolean("balefire", true); bf.setPosition(x, y, z);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, x + 0.5, y + 0.5, z + 0.5), new TargetPoint(world.provider.dimensionId, x + 0.5, y + 0.5, z + 0.5, 250)); bf.destructionRange = (int) (BombConfig.fatmanRadius * 1.25);
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "hbm:weapon.mukeExplosion", 15.0F, 1.0F); world.spawnEntityInWorld(bf);
spawnMush(world, x, y, z, true);
}
if(type == type.CONVENTIONAL) {
ExplosionVNT xnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 35F);
xnt.setBlockAllocator(new BlockAllocatorStandard(24));
xnt.setBlockProcessor(new BlockProcessorStandard().setNoDrop());
xnt.setEntityProcessor(new EntityProcessorCross(5D).withRangeMod(1.5F));
xnt.setPlayerProcessor(new PlayerProcessorStandard());
xnt.explode();
ExplosionCreator.composeEffectLarge(world, x + 0.5, y + 0.5, z + 0.5);
}
if(type == type.NUKE) {
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, 35, x + 0.5, y + 0.5, z + 0.5));
spawnMush(world, x, y, z, MainRegistry.polaroidID == 11 || world.rand.nextInt(100) == 0);
}
if(type == type.SALTED) {
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, 25, x + 0.5, y + 0.5, z + 0.5).moreFallout(25));
spawnMush(world, x, y, z, MainRegistry.polaroidID == 11 || world.rand.nextInt(100) == 0);
}
} }
return BombReturnCode.DETONATED; return BombReturnCode.DETONATED;
} }
public static void spawnMush(World world, int x, int y, int z, boolean balefire) {
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "hbm:weapon.mukeExplosion", 15.0F, 1.0F);
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "muke");
data.setBoolean("balefire", balefire);
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, x + 0.5, y + 0.5, z + 0.5), new TargetPoint(world.provider.dimensionId, x + 0.5, y + 0.5, z + 0.5, 250));
}
} }

View File

@ -4,169 +4,72 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ITooltipProvider;
import com.hbm.entity.mob.EntityTaintCrab; import com.hbm.entity.mob.EntityTaintCrab;
import com.hbm.entity.mob.EntityCreeperTainted; import com.hbm.entity.mob.EntityCreeperTainted;
import com.hbm.entity.mob.EntityTeslaCrab; import com.hbm.entity.mob.EntityTeslaCrab;
import com.hbm.potion.HbmPotion; import com.hbm.potion.HbmPotion;
import cpw.mods.fml.client.registry.RenderingRegistry;
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.BlockFalling;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockTaint extends Block/*Container*/ { public class BlockTaint extends Block implements ITooltipProvider {
@SideOnly(Side.CLIENT)
private IIcon[] icons;
public BlockTaint(Material p_i45386_1_) { public BlockTaint(Material mat) {
super(p_i45386_1_); super(mat);
this.setTickRandomly(true); this.setTickRandomly(true);
} }
/*@Override @Override public MapColor getMapColor(int meta) { return MapColor.grayColor; }
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { @Override public Item getItemDropped(int i, Random rand, int j) { return null; }
return new TileEntityTaint();
}*/
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta)
{
return this.icons[meta % this.icons.length];
}
public int damageDropped(int meta)
{
return 0;
}
public static int func_150032_b(int p_150032_0_)
{
return func_150031_c(p_150032_0_);
}
public static int func_150031_c(int p_150031_0_)
{
return p_150031_0_ & 15;
}
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_)
{
for (int i = 0; i < 16; ++i)
{
p_149666_3_.add(new ItemStack(p_149666_1_, 1, i));
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_)
{
this.icons = new IIcon[16];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = p_149651_1_.registerIcon("hbm:taint_" + i);
}
}
public MapColor getMapColor(int p_149728_1_)
{
return MapColor.purpleColor;
}
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override @Override
public int getRenderType(){ public void updateTick(World world, int x, int y, int z, Random rand) {
return renderID;
int meta = world.getBlockMetadata(x, y, z);
if(meta >= 15) return;
for(int i = -3; i <= 3; i++) for(int j = -3; j <= 3; j++) for(int k = -3; k <= 3; k++) {
if(Math.abs(i) + Math.abs(j) + Math.abs(k) > 4) continue;
if(rand.nextFloat() > 0.25F) continue;
Block b = world.getBlock(x + i, y + j, z + k);
if(b.isAir(world, x + i, y + j, z + k) || b == Blocks.bedrock) continue;
int targetMeta = meta + 1;
boolean hasAir = false;
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if(world.getBlock(x + i + dir.offsetX, y + j + dir.offsetY, z + k + dir.offsetZ).isAir(world, x + i + dir.offsetX, y + j + dir.offsetY, z + k + dir.offsetZ)) {
hasAir = true;
break;
}
}
if(!hasAir) targetMeta = meta + 3;
if(targetMeta > 15) continue;
if(b == this && world.getBlockMetadata(x + i, y + j, z + k) >= targetMeta) continue;
world.setBlock(x + i, y + j, z + k, this, targetMeta, 3);
if(rand.nextFloat() < 0.25F && BlockFalling.func_149831_e(world, x + i, y + j - 1, z + k)) {
EntityFallingBlock falling = new EntityFallingBlock(world, x + i + 0.5, y + j + 0.5, z + k + 0.5, this, targetMeta);
world.spawnEntityInWorld(falling);
}
}
} }
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return null;
}
@Override @Override
public boolean isOpaqueCube() { public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return false; return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 0.75, z + 1);
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
public void onNeighborBlockChange(World world, int x, int y, int z, Block b)
{
if(!hasPosNeightbour(world, x, y, z) && !world.isRemote)
world.setBlockToAir(x, y, z);
}
public void updateTick(World world, int x, int y, int z, Random rand)
{
int meta = world.getBlockMetadata(x, y, z);
if(!world.isRemote && meta < 15) {
for(int i = 0; i < 15; i++) {
int a = rand.nextInt(11) + x - 5;
int b = rand.nextInt(11) + y - 5;
int c = rand.nextInt(11) + z - 5;
if(world.getBlock(a, b, c).isReplaceable(world, a, b, c) && hasPosNeightbour(world, a, b, c))
world.setBlock(a, b, c, ModBlocks.taint, meta + 1, 2);
}
for(int i = 0; i < 85; i++) {
int a = rand.nextInt(7) + x - 3;
int b = rand.nextInt(7) + y - 3;
int c = rand.nextInt(7) + z - 3;
if(world.getBlock(a, b, c).isReplaceable(world, a, b, c) && hasPosNeightbour(world, a, b, c))
world.setBlock(a, b, c, ModBlocks.taint, meta + 1, 2);
}
}
}
public static boolean hasPosNeightbour(World world, int x, int y, int z) {
Block b0 = world.getBlock(x + 1, y, z);
Block b1 = world.getBlock(x, y + 1, z);
Block b2 = world.getBlock(x, y, z + 1);
Block b3 = world.getBlock(x - 1, y, z);
Block b4 = world.getBlock(x, y - 1, z);
Block b5 = world.getBlock(x, y, z - 1);
boolean b = (b0.renderAsNormalBlock() && b0.getMaterial().isOpaque()) ||
(b1.renderAsNormalBlock() && b1.getMaterial().isOpaque()) ||
(b2.renderAsNormalBlock() && b2.getMaterial().isOpaque()) ||
(b3.renderAsNormalBlock() && b3.getMaterial().isOpaque()) ||
(b4.renderAsNormalBlock() && b4.getMaterial().isOpaque()) ||
(b5.renderAsNormalBlock() && b5.getMaterial().isOpaque());
return b;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return null;
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return AxisAlignedBB.getBoundingBox(par2, par3, par4, par2, par3, par4);
} }
@Override @Override
@ -174,36 +77,43 @@ public class BlockTaint extends Block/*Container*/ {
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
int level = 15 - meta; int level = 15 - meta;
List<ItemStack> list = new ArrayList<ItemStack>();
PotionEffect effect = new PotionEffect(HbmPotion.taint.id, 15 * 20, level);
effect.setCurativeItems(list);
if(entity instanceof EntityLivingBase) {
if(world.rand.nextInt(50) == 0) {
((EntityLivingBase)entity).addPotionEffect(effect);
}
}
if(entity != null && entity.getClass().equals(EntityCreeper.class)) {
EntityCreeperTainted creep = new EntityCreeperTainted(world);
creep.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if(!world.isRemote) { entity.motionX *= 0.6;
entity.setDead(); entity.motionZ *= 0.6;
world.spawnEntityInWorld(creep);
}
}
if(entity instanceof EntityTeslaCrab) {
EntityTaintCrab crab = new EntityTaintCrab(world);
crab.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if(!world.isRemote) { List<ItemStack> list = new ArrayList<ItemStack>();
entity.setDead(); PotionEffect effect = new PotionEffect(HbmPotion.taint.id, 15 * 20, level);
world.spawnEntityInWorld(crab); effect.setCurativeItems(list);
}
} if(entity instanceof EntityLivingBase) {
if(world.rand.nextInt(50) == 0) {
((EntityLivingBase) entity).addPotionEffect(effect);
}
}
if(entity != null && entity.getClass().equals(EntityCreeper.class)) {
EntityCreeperTainted creep = new EntityCreeperTainted(world);
creep.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if(!world.isRemote) {
entity.setDead();
world.spawnEntityInWorld(creep);
}
}
if(entity instanceof EntityTeslaCrab) {
EntityTaintCrab crab = new EntityTaintCrab(world);
crab.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if(!world.isRemote) {
entity.setDead();
world.spawnEntityInWorld(crab);
}
}
} }
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
list.add("DO NOT TOUCH, BREATHE OR STARE AT.");
}
} }

View File

@ -9,8 +9,8 @@ import com.hbm.blocks.ModBlocks;
import com.hbm.entity.projectile.EntityShrapnel; import com.hbm.entity.projectile.EntityShrapnel;
import com.hbm.explosion.ExplosionNT; import com.hbm.explosion.ExplosionNT;
import com.hbm.explosion.ExplosionNT.ExAttrib; import com.hbm.explosion.ExplosionNT.ExAttrib;
import com.hbm.packet.AuxParticlePacketNT; import com.hbm.handler.threading.PacketThreading;
import com.hbm.packet.PacketDispatcher; import com.hbm.packet.toclient.AuxParticlePacketNT;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -43,10 +43,10 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
public int getSubCount() { public int getSubCount() {
return 5; return 5;
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) { public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for(int i = 0; i < 5; ++i) { for(int i = 0; i < 5; ++i) {
list.add(new ItemStack(item, 1, i)); list.add(new ItemStack(item, 1, i));
} }
@ -54,14 +54,14 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
@Override @Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) { public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
int meta = stack.getItemDamage(); int meta = stack.getItemDamage();
if(meta == META_SMOLDERING) { if(meta == META_SMOLDERING) {
list.add(EnumChatFormatting.GOLD + "SHIELD VOLCANO"); list.add(EnumChatFormatting.GOLD + "SHIELD VOLCANO");
return; return;
} }
list.add(BlockVolcano.isGrowing(meta) ? (EnumChatFormatting.RED + "DOES GROW") : (EnumChatFormatting.DARK_GRAY + "DOES NOT GROW")); list.add(BlockVolcano.isGrowing(meta) ? (EnumChatFormatting.RED + "DOES GROW") : (EnumChatFormatting.DARK_GRAY + "DOES NOT GROW"));
list.add(BlockVolcano.isExtinguishing(meta) ? (EnumChatFormatting.RED + "DOES EXTINGUISH") : (EnumChatFormatting.DARK_GRAY + "DOES NOT EXTINGUISH")); list.add(BlockVolcano.isExtinguishing(meta) ? (EnumChatFormatting.RED + "DOES EXTINGUISH") : (EnumChatFormatting.DARK_GRAY + "DOES NOT EXTINGUISH"));
} }
@ -71,25 +71,25 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
public static final int META_GROWING_ACTIVE = 2; public static final int META_GROWING_ACTIVE = 2;
public static final int META_GROWING_EXTINGUISHING = 3; public static final int META_GROWING_EXTINGUISHING = 3;
public static final int META_SMOLDERING = 4; public static final int META_SMOLDERING = 4;
public static boolean isGrowing(int meta) { public static boolean isGrowing(int meta) {
return meta == META_GROWING_ACTIVE || meta == META_GROWING_EXTINGUISHING; return meta == META_GROWING_ACTIVE || meta == META_GROWING_EXTINGUISHING;
} }
public static boolean isExtinguishing(int meta) { public static boolean isExtinguishing(int meta) {
return meta == META_STATIC_EXTINGUISHING || meta == META_GROWING_EXTINGUISHING; return meta == META_STATIC_EXTINGUISHING || meta == META_GROWING_EXTINGUISHING;
} }
public static class TileEntityVolcanoCore extends TileEntity { public static class TileEntityVolcanoCore extends TileEntity {
private static List<ExAttrib> volcanoExplosion = Arrays.asList(new ExAttrib[] {ExAttrib.NODROP, ExAttrib.LAVA_V, ExAttrib.NOSOUND, ExAttrib.ALLMOD, ExAttrib.NOHURT}); private static List<ExAttrib> volcanoExplosion = Arrays.asList(new ExAttrib[] {ExAttrib.NODROP, ExAttrib.LAVA_V, ExAttrib.NOSOUND, ExAttrib.ALLMOD, ExAttrib.NOHURT});
private static List<ExAttrib> volcanoRadExplosion = Arrays.asList(new ExAttrib[] {ExAttrib.NODROP, ExAttrib.LAVA_R, ExAttrib.NOSOUND, ExAttrib.ALLMOD, ExAttrib.NOHURT}); private static List<ExAttrib> volcanoRadExplosion = Arrays.asList(new ExAttrib[] {ExAttrib.NODROP, ExAttrib.LAVA_R, ExAttrib.NOSOUND, ExAttrib.ALLMOD, ExAttrib.NOHURT});
public int volcanoTimer; public int volcanoTimer;
@Override @Override
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
this.volcanoTimer++; this.volcanoTimer++;
@ -99,24 +99,24 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
this.blastMagmaChannel(); this.blastMagmaChannel();
this.raiseMagma(); this.raiseMagma();
} }
double magmaChamber = this.magmaChamberSize(); double magmaChamber = this.magmaChamberSize();
if(magmaChamber > 0) this.blastMagmaChamber(magmaChamber); if(magmaChamber > 0) this.blastMagmaChamber(magmaChamber);
Object[] melting = this.surfaceMeltingParams(); Object[] melting = this.surfaceMeltingParams();
if(melting != null) this.meltSurface((int)melting[0], (double)melting[1], (double)melting[2]); if(melting != null) this.meltSurface((int)melting[0], (double)melting[1], (double)melting[2]);
//self-explanatory //self-explanatory
if(this.isSpewing()) this.spawnBlobs(); if(this.isSpewing()) this.spawnBlobs();
if(this.isSmoking()) this.spawnSmoke(); if(this.isSmoking()) this.spawnSmoke();
//generates a 3x3x3 cube of lava //generates a 3x3x3 cube of lava
this.surroundLava(); this.surroundLava();
} }
if(this.volcanoTimer >= this.getUpdateRate()) { if(this.volcanoTimer >= this.getUpdateRate()) {
this.volcanoTimer = 0; this.volcanoTimer = 0;
if(this.shouldGrow()) { if(this.shouldGrow()) {
worldObj.setBlock(xCoord, yCoord + 1, zCoord, this.getBlockType(), this.getBlockMetadata(), 3); worldObj.setBlock(xCoord, yCoord + 1, zCoord, this.getBlockType(), this.getBlockMetadata(), 3);
worldObj.setBlock(xCoord, yCoord, zCoord, getLava()); worldObj.setBlock(xCoord, yCoord, zCoord, getLava());
@ -128,16 +128,16 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
} }
} }
} }
public boolean isRadioacitve() { public boolean isRadioacitve() {
return this.getBlockType() == ModBlocks.volcano_rad_core; return this.getBlockType() == ModBlocks.volcano_rad_core;
} }
protected Block getLava() { protected Block getLava() {
if(isRadioacitve()) return ModBlocks.rad_lava_block; if(isRadioacitve()) return ModBlocks.rad_lava_block;
return ModBlocks.volcanic_lava_block; return ModBlocks.volcanic_lava_block;
} }
protected List<ExAttrib> getExpAttrb() { protected List<ExAttrib> getExpAttrb() {
return this.isRadioacitve() ? this.volcanoRadExplosion : this.volcanoExplosion; return this.isRadioacitve() ? this.volcanoRadExplosion : this.volcanoExplosion;
} }
@ -151,44 +151,44 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setInteger("tier", this.volcanoTimer); nbt.setInteger("timer", this.volcanoTimer);
} }
private boolean shouldGrow() { private boolean shouldGrow() {
return isGrowing() && yCoord < 200; return isGrowing() && yCoord < 200;
} }
private boolean isGrowing() { private boolean isGrowing() {
int meta = this.getBlockMetadata(); int meta = this.getBlockMetadata();
return meta == META_GROWING_ACTIVE || meta == META_GROWING_EXTINGUISHING; return meta == META_GROWING_ACTIVE || meta == META_GROWING_EXTINGUISHING;
} }
private boolean isExtinguishing() { private boolean isExtinguishing() {
int meta = this.getBlockMetadata(); int meta = this.getBlockMetadata();
return meta == META_STATIC_EXTINGUISHING || meta == META_GROWING_EXTINGUISHING; return meta == META_STATIC_EXTINGUISHING || meta == META_GROWING_EXTINGUISHING;
} }
private boolean isSmoking() { private boolean isSmoking() {
return this.getBlockMetadata() != META_SMOLDERING; return this.getBlockMetadata() != META_SMOLDERING;
} }
private boolean isSpewing() { private boolean isSpewing() {
return this.getBlockMetadata() != META_SMOLDERING; return this.getBlockMetadata() != META_SMOLDERING;
} }
private boolean hasVerticalChannel() { private boolean hasVerticalChannel() {
return this.getBlockMetadata() != META_SMOLDERING; return this.getBlockMetadata() != META_SMOLDERING;
} }
private double magmaChamberSize() { private double magmaChamberSize() {
return this.getBlockMetadata() == META_SMOLDERING ? 15 : 0; return this.getBlockMetadata() == META_SMOLDERING ? 15 : 0;
} }
/* count per tick, radius, depth */ /* count per tick, radius, depth */
private Object[] surfaceMeltingParams() { private Object[] surfaceMeltingParams() {
return this.getBlockMetadata() == META_SMOLDERING ? new Object[] {50, 50D, 10D} : null; return this.getBlockMetadata() == META_SMOLDERING ? new Object[] {50, 50D, 10D} : null;
} }
private int getUpdateRate() { private int getUpdateRate() {
switch(this.getBlockMetadata()) { switch(this.getBlockMetadata()) {
case META_STATIC_EXTINGUISHING: return 60 * 60 * 20; //once per hour case META_STATIC_EXTINGUISHING: return 60 * 60 * 20; //once per hour
@ -197,7 +197,7 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
default: return 10; default: return 10;
} }
} }
/** Causes two magma explosions, one from bedrock to the core and one from the core to 15 blocks above. */ /** Causes two magma explosions, one from bedrock to the core and one from the core to 15 blocks above. */
private void blastMagmaChannel() { private void blastMagmaChannel() {
ExplosionNT explosion = new ExplosionNT(worldObj, null, xCoord + 0.5, yCoord + worldObj.rand.nextInt(15) + 1.5, zCoord + 0.5, 7); ExplosionNT explosion = new ExplosionNT(worldObj, null, xCoord + 0.5, yCoord + worldObj.rand.nextInt(15) + 1.5, zCoord + 0.5, 7);
@ -205,53 +205,53 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
ExplosionNT explosion2 = new ExplosionNT(worldObj, null, xCoord + 0.5 + worldObj.rand.nextGaussian() * 3, worldObj.rand.nextInt(yCoord + 1), zCoord + 0.5 + worldObj.rand.nextGaussian() * 3, 10); ExplosionNT explosion2 = new ExplosionNT(worldObj, null, xCoord + 0.5 + worldObj.rand.nextGaussian() * 3, worldObj.rand.nextInt(yCoord + 1), zCoord + 0.5 + worldObj.rand.nextGaussian() * 3, 10);
explosion2.addAllAttrib(getExpAttrb()).explode(); explosion2.addAllAttrib(getExpAttrb()).explode();
} }
/** Causes two magma explosions at a random position around the core, one at normal and one at half range. */ /** Causes two magma explosions at a random position around the core, one at normal and one at half range. */
private void blastMagmaChamber(double size) { private void blastMagmaChamber(double size) {
for(int i = 0; i < 2; i++) { for(int i = 0; i < 2; i++) {
double dist = size / (double) (i + 1); double dist = size / (double) (i + 1);
ExplosionNT explosion = new ExplosionNT(worldObj, null, xCoord + 0.5 + worldObj.rand.nextGaussian() * dist, yCoord + 0.5 + worldObj.rand.nextGaussian() * dist, zCoord + 0.5 + worldObj.rand.nextGaussian() * dist, 7); ExplosionNT explosion = new ExplosionNT(worldObj, null, xCoord + 0.5 + worldObj.rand.nextGaussian() * dist, yCoord + 0.5 + worldObj.rand.nextGaussian() * dist, zCoord + 0.5 + worldObj.rand.nextGaussian() * dist, 7);
explosion.addAllAttrib(getExpAttrb()).explode(); explosion.addAllAttrib(getExpAttrb()).explode();
} }
} }
/** Randomly selects surface blocks and converts them into lava if solid or air if not solid. */ /** Randomly selects surface blocks and converts them into lava if solid or air if not solid. */
private void meltSurface(int count, double radius, double depth) { private void meltSurface(int count, double radius, double depth) {
for(int i = 0; i < count; i++) { for(int i = 0; i < count; i++) {
int x = (int) Math.floor(xCoord + worldObj.rand.nextGaussian() * radius); int x = (int) Math.floor(xCoord + worldObj.rand.nextGaussian() * radius);
int z = (int) Math.floor(zCoord + worldObj.rand.nextGaussian() * radius); int z = (int) Math.floor(zCoord + worldObj.rand.nextGaussian() * radius);
//gaussian distribution makes conversions more likely on the surface and rarer at the bottom //gaussian distribution makes conversions more likely on the surface and rarer at the bottom
int y = worldObj.getHeightValue(x, z) + 1 - (int) Math.floor(Math.abs(worldObj.rand.nextGaussian() * depth)); int y = worldObj.getHeightValue(x, z) + 1 - (int) Math.floor(Math.abs(worldObj.rand.nextGaussian() * depth));
Block b = worldObj.getBlock(x, y, z); Block b = worldObj.getBlock(x, y, z);
if(!b.isAir(worldObj, x, y, z) && b.getExplosionResistance(null) < Blocks.obsidian.getExplosionResistance(null)) { if(!b.isAir(worldObj, x, y, z) && b.getExplosionResistance(null) < Blocks.obsidian.getExplosionResistance(null)) {
//turn into lava if solid block, otherwise just break //turn into lava if solid block, otherwise just break
worldObj.setBlock(x, y, z, b.isNormalCube() ? this.getLava() : Blocks.air); worldObj.setBlock(x, y, z, b.isNormalCube() ? this.getLava() : Blocks.air);
} }
} }
} }
/** Increases the magma level in a small radius around the core. */ /** Increases the magma level in a small radius around the core. */
private void raiseMagma() { private void raiseMagma() {
int rX = xCoord - 10 + worldObj.rand.nextInt(21); int rX = xCoord - 10 + worldObj.rand.nextInt(21);
int rY = yCoord + worldObj.rand.nextInt(11); int rY = yCoord + worldObj.rand.nextInt(11);
int rZ = zCoord - 10 + worldObj.rand.nextInt(21); int rZ = zCoord - 10 + worldObj.rand.nextInt(21);
if(worldObj.getBlock(rX, rY, rZ) == Blocks.air && worldObj.getBlock(rX, rY - 1, rZ) == this.getLava()) if(worldObj.getBlock(rX, rY, rZ) == Blocks.air && worldObj.getBlock(rX, rY - 1, rZ) == this.getLava())
worldObj.setBlock(rX, rY, rZ, this.getLava()); worldObj.setBlock(rX, rY, rZ, this.getLava());
} }
/** Creates a 3x3x3 lava sphere around the core. */ /** Creates a 3x3x3 lava sphere around the core. */
private void surroundLava() { private void surroundLava() {
for(int i = -1; i <= 1; i++) { for(int i = -1; i <= 1; i++) {
for(int j = -1; j <= 1; j++) { for(int j = -1; j <= 1; j++) {
for(int k = -1; k <= 1; k++) { for(int k = -1; k <= 1; k++) {
if(i != 0 || j != 0 || k != 0) { if(i != 0 || j != 0 || k != 0) {
worldObj.setBlock(xCoord + i, yCoord + j, zCoord + k, this.getLava()); worldObj.setBlock(xCoord + i, yCoord + j, zCoord + k, this.getLava());
} }
@ -259,10 +259,10 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
} }
} }
} }
/** Spews specially tagged shrapnels which create volcanic lava and monoxide clouds. */ /** Spews specially tagged shrapnels which create volcanic lava and monoxide clouds. */
private void spawnBlobs() { private void spawnBlobs() {
for(int i = 0; i < 3; i++) { for(int i = 0; i < 3; i++) {
EntityShrapnel frag = new EntityShrapnel(worldObj); EntityShrapnel frag = new EntityShrapnel(worldObj);
frag.setLocationAndAngles(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 0.0F, 0.0F); frag.setLocationAndAngles(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 0.0F, 0.0F);
@ -277,13 +277,13 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
worldObj.spawnEntityInWorld(frag); worldObj.spawnEntityInWorld(frag);
} }
} }
/** I SEE SMOKE, AND WHERE THERE'S SMOKE THERE'S FIRE! */ /** I SEE SMOKE, AND WHERE THERE'S SMOKE THERE'S FIRE! */
private void spawnSmoke() { private void spawnSmoke() {
NBTTagCompound dPart = new NBTTagCompound(); NBTTagCompound dPart = new NBTTagCompound();
dPart.setString("type", "vanillaExt"); dPart.setString("type", "vanillaExt");
dPart.setString("mode", "volcano"); dPart.setString("mode", "volcano");
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(dPart, xCoord + 0.5, yCoord + 10, zCoord + 0.5), new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 10, zCoord + 0.5, 250)); PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(dPart, xCoord + 0.5, yCoord + 10, zCoord + 0.5), new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 10, zCoord + 0.5, 250));
} }
} }
} }

View File

@ -1,7 +1,13 @@
package com.hbm.blocks.bomb; package com.hbm.blocks.bomb;
import com.hbm.explosion.ExplosionChaos; import com.hbm.explosion.vanillant.ExplosionVNT;
import com.hbm.explosion.vanillant.standard.BlockAllocatorStandard;
import com.hbm.explosion.vanillant.standard.BlockProcessorStandard;
import com.hbm.explosion.vanillant.standard.EntityProcessorCrossSmooth;
import com.hbm.explosion.vanillant.standard.ExplosionEffectTiny;
import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard;
import com.hbm.interfaces.IBomb; import com.hbm.interfaces.IBomb;
import com.hbm.particle.helper.ExplosionCreator;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -17,9 +23,7 @@ public class BombFlameWar extends Block implements IBomb {
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) {
if(world.isBlockIndirectlyGettingPowered(x, y, z)) { if(world.isBlockIndirectlyGettingPowered(x, y, z)) {
ExplosionChaos.explode(world, x, y, z, 15); explode(world, x, y, z);
ExplosionChaos.spawnExplosion(world, x, y, z, 75);
ExplosionChaos.flameDeath(world, x, y, z, 100);
} }
} }
@ -27,9 +31,24 @@ public class BombFlameWar extends Block implements IBomb {
public BombReturnCode explode(World world, int x, int y, int z) { public BombReturnCode explode(World world, int x, int y, int z) {
if(!world.isRemote) { if(!world.isRemote) {
ExplosionChaos.explode(world, x, y, z, 15);
ExplosionChaos.spawnExplosion(world, x, y, z, 75); world.func_147480_a(x, y, z, false);
ExplosionChaos.flameDeath(world, x, y, z, 100);
for(int i = 0; i < 150; i++) {
ExplosionVNT vnt = new ExplosionVNT(world, x + world.rand.nextInt(51) - 25, y + world.rand.nextInt(11) - 5, z + world.rand.nextInt(51) - 25, 4, null);
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, 25));
vnt.setPlayerProcessor(new PlayerProcessorStandard());
vnt.setSFX(new ExplosionEffectTiny());
vnt.explode();
}
ExplosionVNT xnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 15F);
xnt.setBlockAllocator(new BlockAllocatorStandard(32));
xnt.setBlockProcessor(new BlockProcessorStandard().setNoDrop());
xnt.setEntityProcessor(new EntityProcessorCrossSmooth(2, 200));
xnt.setPlayerProcessor(new PlayerProcessorStandard());
xnt.explode();
ExplosionCreator.composeEffectSmall(world, x + 0.5, y + 0.5, z + 0.5);
} }
return BombReturnCode.DETONATED; return BombReturnCode.DETONATED;

View File

@ -18,10 +18,12 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.entity.effect.EntityMist;
import com.hbm.explosion.ExplosionChaos; import com.hbm.explosion.ExplosionChaos;
import com.hbm.explosion.ExplosionLarge; import com.hbm.explosion.ExplosionLarge;
import com.hbm.explosion.ExplosionNukeGeneric; import com.hbm.explosion.ExplosionNukeGeneric;
import com.hbm.interfaces.IBomb; import com.hbm.interfaces.IBomb;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.tileentity.bomb.TileEntityBombMulti; import com.hbm.tileentity.bomb.TileEntityBombMulti;
@ -169,7 +171,11 @@ public class BombMulti extends BlockContainer implements IBomb {
} }
if(gasCloud > 0) { if(gasCloud > 0) {
ExplosionChaos.spawnChlorine(world, x, y, z, gasCloud, gasCloud / 50, 0); EntityMist mist = new EntityMist(world);
mist.setType(Fluids.CHLORINE);
mist.setPosition(x + 0.5, y + 0.5, z + 0.5);
mist.setArea(gasCloud * 15F / 50F, gasCloud * 7.5F / 50F);
world.spawnEntityInWorld(mist);
} }
return BombReturnCode.DETONATED; return BombReturnCode.DETONATED;

View File

@ -5,10 +5,10 @@ import com.hbm.config.BombConfig;
import com.hbm.entity.effect.EntityNukeTorex; import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.entity.item.EntityTNTPrimedBase; import com.hbm.entity.item.EntityTNTPrimedBase;
import com.hbm.entity.logic.EntityNukeExplosionMK5; import com.hbm.entity.logic.EntityNukeExplosionMK5;
import com.hbm.explosion.ExplosionLarge;
import com.hbm.explosion.ExplosionNT; import com.hbm.explosion.ExplosionNT;
import com.hbm.interfaces.IBomb; import com.hbm.interfaces.IBomb;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.particle.helper.ExplosionCreator;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -65,11 +65,11 @@ public class ExplosiveCharge extends BlockDetonatable implements IBomb, IDetConn
} }
if(this == ModBlocks.det_charge) { if(this == ModBlocks.det_charge) {
new ExplosionNT(world, null, x + 0.5, y + 0.5, z + 0.5, 15).overrideResolution(64).explode(); new ExplosionNT(world, null, x + 0.5, y + 0.5, z + 0.5, 15).overrideResolution(64).explode();
ExplosionLarge.spawnParticles(world, x, y, z, ExplosionLarge.cloudFunction(15)); ExplosionCreator.composeEffectStandard(world, x + 0.5, y + 1, z + 0.5);
} }
if(this == ModBlocks.det_nuke) { if(this == ModBlocks.det_nuke) {
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.missileRadius, x + 0.5, y + 0.5, z + 0.5)); world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.missileRadius, x + 0.5, y + 0.5, z + 0.5));
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.missileRadius); EntityNukeTorex.statFacStandard(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.missileRadius);
} }
} }

View File

@ -3,20 +3,29 @@ package com.hbm.blocks.bomb;
import java.util.Random; import java.util.Random;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.config.ServerConfig;
import com.hbm.explosion.ExplosionLarge; import com.hbm.explosion.ExplosionLarge;
import com.hbm.explosion.ExplosionNukeSmall; import com.hbm.explosion.vanillant.ExplosionVNT;
import com.hbm.explosion.vanillant.standard.*;
import com.hbm.interfaces.IBomb; import com.hbm.interfaces.IBomb;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.weapon.sedna.factory.XFactoryCatapult;
import com.hbm.main.MainRegistry;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.tileentity.bomb.TileEntityLandmine; import com.hbm.tileentity.bomb.TileEntityLandmine;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockFence; import net.minecraft.block.BlockFence;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
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.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -31,7 +40,6 @@ public class Landmine extends BlockContainer implements IBomb {
public Landmine(Material mat, double range, double height) { public Landmine(Material mat, double range, double height) {
super(mat); super(mat);
this.range = range; this.range = range;
this.height = height; this.height = height;
} }
@ -41,20 +49,9 @@ public class Landmine extends BlockContainer implements IBomb {
return new TileEntityLandmine(); return new TileEntityLandmine();
} }
@Override @Override public int getRenderType() { return -1; }
public int getRenderType() { @Override public boolean isOpaqueCube() { return false; }
return -1; @Override public boolean renderAsNormalBlock() { return false; }
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override @Override
public Item getItemDropped(int i, Random rand, int j) { public Item getItemDropped(int i, Random rand, int j) {
@ -64,15 +61,10 @@ public class Landmine extends BlockContainer implements IBomb {
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
float f = 0.0625F; float f = 0.0625F;
if(this == ModBlocks.mine_ap) if(this == ModBlocks.mine_ap) this.setBlockBounds(5 * f, 0.0F, 5 * f, 11 * f, 1 * f, 11 * f);
this.setBlockBounds(6 * f, 0.0F, 6 * f, 10 * f, 2 * f, 10 * f); if(this == ModBlocks.mine_he) this.setBlockBounds(4 * f, 0.0F, 4 * f, 12 * f, 2 * f, 12 * f);
if(this == ModBlocks.mine_he) if(this == ModBlocks.mine_shrap) this.setBlockBounds(5 * f, 0.0F, 5 * f, 11 * f, 1 * f, 11 * f);
this.setBlockBounds(4 * f, 0.0F, 4 * f, 12 * f, 2 * f, 12 * f); if(this == ModBlocks.mine_fat) this.setBlockBounds(5 * f, 0.0F, 4 * f, 11 * f, 6 * f, 12 * f);}
if(this == ModBlocks.mine_shrap)
this.setBlockBounds(4 * f, 0.0F, 4 * f, 12 * f, 2 * f, 12 * f);
if(this == ModBlocks.mine_fat)
this.setBlockBounds(5 * f, 0.0F, 4 * f, 11 * f, 6 * f, 12 * f);
}
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
@ -137,6 +129,18 @@ public class Landmine extends BlockContainer implements IBomb {
return false; return false;
} }
public boolean isWaterAbove(World world, int x, int y, int z) {
for(int xo = -1; xo <= 1; xo++) {
for(int zo = -1; zo <= 1; zo++) {
Block blockAbove = world.getBlock(x + xo, y + 1, z + zo);
if(blockAbove == Blocks.water || blockAbove == Blocks.flowing_water) {
return true;
}
}
}
return false;
}
@Override @Override
public BombReturnCode explode(World world, int x, int y, int z) { public BombReturnCode explode(World world, int x, int y, int z) {
@ -147,20 +151,64 @@ public class Landmine extends BlockContainer implements IBomb {
Landmine.safeMode = false; Landmine.safeMode = false;
if(this == ModBlocks.mine_ap) { if(this == ModBlocks.mine_ap) {
world.newExplosion(null, x + 0.5, y + 0.5, z + 0.5, 2.5F, false, false); ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 3F);
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(0.5, ServerConfig.MINE_AP_DAMAGE.get()).setupPiercing(5F, 0.2F));
vnt.setPlayerProcessor(new PlayerProcessorStandard());
vnt.setSFX(new ExplosionEffectWeapon(5, 1F, 0.5F));
vnt.explode();
} else if(this == ModBlocks.mine_he) { } else if(this == ModBlocks.mine_he) {
ExplosionLarge.explode(world, x + 0.5, y + 0.5, z + 0.5, 3F, true, false, false); ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 4F);
world.newExplosion(null, x + 0.5, y + 2, z + 0.5, 15F, false, false); vnt.setBlockAllocator(new BlockAllocatorStandard());
vnt.setBlockProcessor(new BlockProcessorStandard());
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, ServerConfig.MINE_HE_DAMAGE.get()).setupPiercing(15F, 0.2F));
vnt.setPlayerProcessor(new PlayerProcessorStandard());
vnt.setSFX(new ExplosionEffectWeapon(15, 3.5F, 1.25F));
vnt.explode();
} else if(this == ModBlocks.mine_shrap) { } else if(this == ModBlocks.mine_shrap) {
ExplosionLarge.explode(world, x + 0.5, y + 0.5, z + 0.5, 1, true, false, false); ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 3F);
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(0.5, ServerConfig.MINE_SHRAP_DAMAGE.get()));
vnt.setPlayerProcessor(new PlayerProcessorStandard());
vnt.setSFX(new ExplosionEffectWeapon(5, 1F, 0.5F));
vnt.explode();
ExplosionLarge.spawnShrapnelShower(world, x + 0.5, y + 0.5, z + 0.5, 0, 1D, 0, 45, 0.2D); ExplosionLarge.spawnShrapnelShower(world, x + 0.5, y + 0.5, z + 0.5, 0, 1D, 0, 45, 0.2D);
ExplosionLarge.spawnShrapnels(world, x + 0.5, y + 0.5, z + 0.5, 5); ExplosionLarge.spawnShrapnels(world, x + 0.5, y + 0.5, z + 0.5, 5);
} else if(this == ModBlocks.mine_naval) {
ExplosionVNT vnt = new ExplosionVNT(world, x + 5, y + 5, z + 5, 25F);
vnt.setBlockAllocator(new BlockAllocatorWater(32));
vnt.setBlockProcessor(new BlockProcessorStandard());
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(0.5, ServerConfig.MINE_NAVAL_DAMAGE.get()).setupPiercing(5F, 0.2F));
vnt.setPlayerProcessor(new PlayerProcessorStandard());
vnt.setSFX(new ExplosionEffectWeapon(10, 1F, 0.5F));
vnt.explode();
ExplosionLarge.spawnParticlesRadial(world, x + 0.5, y + 2, z + 0.5, 30);
ExplosionLarge.spawnRubble(world,x + 0.5, y + 0.5, z + 0.5, 5 );
// Only spawn water effects if there's water above the mine
if (isWaterAbove(world, x, y, z)) {
ExplosionLarge.spawnFoam(world, x + 0.5, y + 0.5, z + 0.5, 60);
}
} else if(this == ModBlocks.mine_fat) { } else if(this == ModBlocks.mine_fat) {
ExplosionNukeSmall.explode(world, x + 0.5, y + 0.5, z + 0.5, ExplosionNukeSmall.PARAMS_MEDIUM);
ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 10);
vnt.setBlockAllocator(new BlockAllocatorStandard(64));
vnt.setBlockProcessor(new BlockProcessorStandard());
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(2, ServerConfig.MINE_NUKE_DAMAGE.get()).withRangeMod(1.5F));
vnt.setPlayerProcessor(new PlayerProcessorStandard());
vnt.explode();
XFactoryCatapult.incrementRad(world, x, y, z, 1.5F);
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "muke");
data.setBoolean("balefire", MainRegistry.polaroidID == 11 || world.rand.nextInt(100) == 0);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, x + 0.5, y + 0.5, z + 0.5), new TargetPoint(world.provider.dimensionId, x + 0.5, y + 0.5, z + 0.5, 250));
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "hbm:weapon.mukeExplosion", 25.0F, 0.9F); // this has to be the single worst solution ever
} }
} }
return BombReturnCode.DETONATED; return BombReturnCode.DETONATED;
} }
} }

View File

@ -179,7 +179,7 @@ public class NukeCustom extends BlockContainer implements IBomb {
dirty *= 0.25F; dirty *= 0.25F;
worldObj.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(worldObj, (int)hydro, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5).moreFallout((int)dirty)); worldObj.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(worldObj, (int)hydro, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5).moreFallout((int)dirty));
EntityNukeTorex.statFac(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, hydro); EntityNukeTorex.statFacStandard(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, hydro);
/// NUCLEAR /// /// NUCLEAR ///
} else if(nuke > 0) { } else if(nuke > 0) {
@ -188,7 +188,7 @@ public class NukeCustom extends BlockContainer implements IBomb {
nuke = Math.min(nuke, maxNuke); nuke = Math.min(nuke, maxNuke);
worldObj.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(worldObj, (int)nuke, xCoord + 0.5, yCoord + 5, zCoord + 0.5).moreFallout((int)dirty)); worldObj.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(worldObj, (int)nuke, xCoord + 0.5, yCoord + 5, zCoord + 0.5).moreFallout((int)dirty));
EntityNukeTorex.statFac(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, nuke); EntityNukeTorex.statFacStandard(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, nuke);
/// NON-NUCLEAR /// /// NON-NUCLEAR ///
} else if(tnt >= 75) { } else if(tnt >= 75) {
@ -196,7 +196,7 @@ public class NukeCustom extends BlockContainer implements IBomb {
tnt = Math.min(tnt, maxTnt); tnt = Math.min(tnt, maxTnt);
worldObj.spawnEntityInWorld(EntityNukeExplosionMK5.statFacNoRad(worldObj, (int)tnt, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5)); worldObj.spawnEntityInWorld(EntityNukeExplosionMK5.statFacNoRad(worldObj, (int)tnt, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5));
EntityNukeTorex.statFac(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, tnt); EntityNukeTorex.statFacStandard(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, tnt);
} else if(tnt > 0) { } else if(tnt > 0) {
ExplosionLarge.explode(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, tnt, true, true, true); ExplosionLarge.explode(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, tnt, true, true, true);

View File

@ -131,7 +131,7 @@ public class NukeGadget extends BlockContainer implements IBomb {
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F); world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.gadgetRadius, x + 0.5, y + 0.5, z + 0.5)); world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.gadgetRadius, x + 0.5, y + 0.5, z + 0.5));
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.gadgetRadius); EntityNukeTorex.statFacStandard(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.gadgetRadius);
} }
return false; return false;

View File

@ -124,7 +124,7 @@ public class NukeMan extends BlockContainer implements IBomb {
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F); world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.manRadius, x + 0.5, y + 0.5, z + 0.5)); world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.manRadius, x + 0.5, y + 0.5, z + 0.5));
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.manRadius); EntityNukeTorex.statFacStandard(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.manRadius);
} }
return false; return false;

View File

@ -131,7 +131,7 @@ public class NukeMike extends BlockContainer implements IBomb {
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F); world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.mikeRadius, x + 0.5, y + 0.5, z + 0.5)); world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.mikeRadius, x + 0.5, y + 0.5, z + 0.5));
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.mikeRadius); EntityNukeTorex.statFacStandard(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.mikeRadius);
} }
return false; return false;

View File

@ -120,7 +120,7 @@ public class NukeN2 extends BlockContainer implements IBomb {
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F); world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFacNoRad(world, r, x + 0.5, y + 0.5, z + 0.5)); world.spawnEntityInWorld(EntityNukeExplosionMK5.statFacNoRad(world, r, x + 0.5, y + 0.5, z + 0.5));
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, r); EntityNukeTorex.statFacStandard(world, x + 0.5, y + 0.5, z + 0.5, r);
} }
return false; return false;

View File

@ -129,7 +129,7 @@ public class NukeTsar extends BlockContainer implements IBomb {
tetn.clearSlots(); tetn.clearSlots();
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F); world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, r, x + 0.5, y + 0.5, z + 0.5)); world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, r, x + 0.5, y + 0.5, z + 0.5));
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, r); EntityNukeTorex.statFacStandard(world, x + 0.5, y + 0.5, z + 0.5, r);
} }
return false; return false;

View File

@ -3,8 +3,8 @@ package com.hbm.blocks.generic;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import com.hbm.items.ItemAmmoEnums.*;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmo;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -69,27 +69,22 @@ public class BlockAmmoCrate extends Block {
ret.add(new ItemStack(ModItems.cap_nuka, 12 + rand.nextInt(21))); ret.add(new ItemStack(ModItems.cap_nuka, 12 + rand.nextInt(21)));
ret.add(new ItemStack(ModItems.syringe_metal_stimpak, 1 + rand.nextInt(3))); ret.add(new ItemStack(ModItems.syringe_metal_stimpak, 1 + rand.nextInt(3)));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.P9_SP.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.P9_FMJ.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.M357_SP.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.M357_FMJ.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.M44_SP.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.M44_FMJ.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.R556_SP.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.R556_FMJ.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.R762_SP.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.R762_FMJ.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.G12.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 16 + rand.nextInt(17), EnumAmmo.G12_SLUG.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 2 + rand.nextInt(3), EnumAmmo.G40_HE.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_standard, 2 + rand.nextInt(3), EnumAmmo.ROCKET_HE.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_22lr, 16 + rand.nextInt(17)));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_9mm, 6 + rand.nextInt(13)));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_12gauge, 6 + rand.nextInt(4)));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_20gauge, 3 + rand.nextInt(4)));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_357, 10 + rand.nextInt(11)));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_357, 12 + rand.nextInt(15), Ammo357Magnum.IRON.ordinal()));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_50bmg, 2 + rand.nextInt(7)));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_rocket, 1));
if(rand.nextBoolean()) ret.add(new ItemStack(ModItems.ammo_grenade, 1 + rand.nextInt(2)));
if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.ammo_12gauge, 3, Ammo12Gauge.INCENDIARY.ordinal()));
if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.ammo_20gauge, 3, Ammo20Gauge.INCENDIARY.ordinal()));
if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.ammo_20gauge, 3, Ammo20Gauge.CAUSTIC.ordinal()));
if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.ammo_20gauge, 3, Ammo20Gauge.FLECHETTE.ordinal()));
if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.ammo_9mm, 7, Ammo9mm.AP.ordinal()));
if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.ammo_rocket, 1, AmmoRocket.INCENDIARY.ordinal()));
if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.ammo_rocket, 1, AmmoRocket.SLEEK.ordinal()));
if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.ammo_grenade, 1, AmmoGrenade.HE.ordinal()));
if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.ammo_grenade, 1, AmmoGrenade.INCENDIARY.ordinal()));
if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.ammo_grenade, 1, AmmoGrenade.SLEEK.ordinal()));
if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.syringe_metal_super, 2)); if(rand.nextInt(10) == 0) ret.add(new ItemStack(ModItems.syringe_metal_super, 2));
return ret; return ret;

View File

@ -0,0 +1,161 @@
package com.hbm.blocks.generic;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import com.hbm.lib.Library;
import com.hbm.render.block.ISBRHUniversal;
import com.hbm.render.util.RenderBlocksNT;
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.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockBarrier extends Block implements ISBRHUniversal {
public BlockBarrier(Material mat) {
super(mat);
}
@Override public int getRenderType() { return renderID; }
@Override public boolean isOpaqueCube() { return false; }
@Override public boolean renderAsNormalBlock() { return false; }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
if(world.getBlockMetadata(x, y, z) != 0) return;
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if(i == 0) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 5, 2);
if(i == 2) world.setBlockMetadataWithNotify(x, y, z, 3, 2);
if(i == 3) world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float fX, float fY, float fZ, int meta) {
return side >= 2 && side <= 5 ? side : meta;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
setBlockBounds(0, 0, 0, 1, 1, 1);
if(meta == Library.POS_X.ordinal()) setBlockBounds(0, 0, 0, 0.125F, 1, 1);
if(meta == Library.POS_Z.ordinal()) setBlockBounds(0, 0, 0, 1, 1, 0.125F);
if(meta == Library.NEG_X.ordinal()) setBlockBounds(0.875F, 0, 0, 1, 1, 1);
if(meta == Library.NEG_Z.ordinal()) setBlockBounds(0, 0, 0.875F, 1, 1, 1);
}
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity collider) {
int meta = world.getBlockMetadata(x, y, z);
List<AxisAlignedBB> bbs = new ArrayList();
Block nx = world.getBlock(x - 1, y, z);
Block px = world.getBlock(x + 1, y, z);
Block nz = world.getBlock(x, y, z - 1);
Block pz = world.getBlock(x, y, z + 1);
if(nx.isOpaqueCube() || nx.isNormalCube() || meta == Library.POS_X.ordinal()) bbs.add(AxisAlignedBB.getBoundingBox(x, y, z, x + 0.125, y + 1, z + 1));
if(nz.isOpaqueCube() || nz.isNormalCube() || meta == Library.POS_Z.ordinal()) bbs.add(AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 0.125));
if(px.isOpaqueCube() || px.isNormalCube() || meta == Library.NEG_X.ordinal()) bbs.add(AxisAlignedBB.getBoundingBox(x + 0.875, y, z, x + 1, y + 1, z + 1));
if(pz.isOpaqueCube() || pz.isNormalCube() || meta == Library.NEG_Z.ordinal()) bbs.add(AxisAlignedBB.getBoundingBox(x, y, z + 0.875, x + 1, y + 1, z + 1));
for(AxisAlignedBB bb : bbs) {
if(aabb.intersectsWith(bb)) {
list.add(bb);
}
}
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
return true;
}
@Override
public void renderInventoryBlock(Block block, int meta, int modelId, Object renderBlocks) {
GL11.glPushMatrix();
RenderBlocks renderer = (RenderBlocks) renderBlocks;
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
renderer.setRenderBounds(0.4375, 0D, 0.4375D, 0.5625D, 1D, 0.5625D); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0.5D, 0.0625D, 0D, 0.5625D, 0.4725, 1D); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0.5D, 0.5625D, 0D, 0.5625D, 0.9375, 1D); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
GL11.glPopMatrix();
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, Object renderBlocks) {
RenderBlocksNT renderer = RenderBlocksNT.INSTANCE.setWorld(world);
Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
tessellator.setColorOpaque_F(1, 1, 1);
int meta = world.getBlockMetadata(x, y, z);
Block nx = world.getBlock(x - 1, y, z);
Block px = world.getBlock(x + 1, y, z);
Block nz = world.getBlock(x, y, z - 1);
Block pz = world.getBlock(x, y, z + 1);
Block py = world.getBlock(x, y + 1, z);
boolean negX = nx.isOpaqueCube() || nx.isNormalCube() || meta == Library.POS_X.ordinal();
boolean negZ = nz.isOpaqueCube() || nz.isNormalCube() || meta == Library.POS_Z.ordinal();
boolean posX = px.isOpaqueCube() || px.isNormalCube() || meta == Library.NEG_X.ordinal();
boolean posZ = pz.isOpaqueCube() || pz.isNormalCube() || meta == Library.NEG_Z.ordinal();
boolean posY = py.isOpaqueCube() || py.isNormalCube();
if(negX) {
renderer.setRenderBounds(0D, 0D, 0.4375D, 0.125D, 1D, 0.5625D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0D, 0.0625D, negZ ? 0.125D : 0D, 0.0625D, 0.4375D, posZ ? 0.875D : 1D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0D, 0.5625D, negZ ? 0.125D : 0D, 0.0625D, 0.9375D, posZ ? 0.875D : 1D); renderer.renderStandardBlock(block, x, y, z);
}
if(negZ) {
renderer.setRenderBounds(0.4375D, 0D, 0D, 0.5625D, 1D, 0.125D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(negX ? 0.125D : 0D, 0.0625D, 0D, posX ? 0.875D : 1D, 0.4375D, 0.0625D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(negX ? 0.125D : 0D, 0.5625D, 0D, posX ? 0.875D : 1D, 0.9375D, 0.0625D); renderer.renderStandardBlock(block, x, y, z);
}
if(posX) {
renderer.setRenderBounds(0.875D, 0D, 0.4375D, 1D, 1D, 0.5625D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.9375D, 0.0625D, negZ ? 0.125D : 0D, 1D, 0.4375D, posZ ? 0.875D : 1D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.9375D, 0.5625D, negZ ? 0.125D : 0D, 1D, 0.9375D, posZ ? 0.875D : 1D); renderer.renderStandardBlock(block, x, y, z);
}
if(posZ) {
renderer.setRenderBounds(0.4375D, 0D, 0.875D, 0.5625D, 1D, 1D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(negX ? 0.125D : 0D, 0.0625D, 0.9375D, posX ? 0.875D : 1D, 0.4375D, 1D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(negX ? 0.125D : 0D, 0.5625D, 0.9375D, posX ? 0.875D : 1D, 0.9375D, 1D); renderer.renderStandardBlock(block, x, y, z);
}
if(posY) {
renderer.setRenderBounds(0D, 0.875D, 0D, 0.125D, 0.9375D, 1D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.875D, 0.875D, 0D, 1D, 0.9375D, 1D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0D, 0.9375D, 0.0625D, 1D, 1D, 0.4375D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0D, 0.9375D, 0.5625D, 1D, 1D, 0.9375D); renderer.renderStandardBlock(block, x, y, z);
}
return true;
}
}

View File

@ -16,9 +16,9 @@ import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.render.block.RenderBlockMultipass; import com.hbm.render.block.RenderBlockMultipass;
import com.hbm.util.EnumUtil; import com.hbm.util.EnumUtil;
import com.hbm.util.I18nUtil; import com.hbm.util.i18n.I18nUtil;
import api.hbm.fluid.IFillableItem; import api.hbm.fluidmk2.IFillableItem;
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.BlockContainer; import net.minecraft.block.BlockContainer;

View File

@ -4,12 +4,14 @@ import com.hbm.inventory.gui.GUIScreenBobble;
import com.hbm.items.special.ItemPlasticScrap.ScrapType; import com.hbm.items.special.ItemPlasticScrap.ScrapType;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IGUIProvider;
import com.hbm.world.gen.INBTTileEntityTransformable;
import com.hbm.world.gen.INBTTransformable;
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.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
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.gui.GuiScreen;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
@ -32,7 +34,7 @@ import net.minecraft.world.World;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
public class BlockBobble extends BlockContainer implements IGUIProvider { public class BlockBobble extends BlockContainer implements IGUIProvider, INBTTransformable {
public BlockBobble() { public BlockBobble() {
super(Material.iron); super(Material.iron);
@ -57,22 +59,22 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
public Item getItemDropped(int i, Random rand, int j) { public Item getItemDropped(int i, Random rand, int j) {
return null; return null;
} }
@Override @Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
TileEntityBobble entity = (TileEntityBobble) world.getTileEntity(x, y, z); TileEntityBobble entity = (TileEntityBobble) world.getTileEntity(x, y, z);
if(entity != null) { if(entity != null) {
return new ItemStack(this, 1, entity.type.ordinal()); return new ItemStack(this, 1, entity.type.ordinal());
} }
return super.getPickBlock(target, world, x, y, z, player); return super.getPickBlock(target, world, x, y, z, player);
} }
@Override @Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) { public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
if(!player.capabilities.isCreativeMode) { if(!player.capabilities.isCreativeMode) {
harvesters.set(player); harvesters.set(player);
if(!world.isRemote) { if(!world.isRemote) {
@ -88,7 +90,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
harvesters.set(null); harvesters.set(null);
} }
} }
@Override @Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) { public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1); player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
@ -97,11 +99,11 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote) { if(world.isRemote) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
return true; return true;
} else { } else {
return true; return true;
} }
@ -110,7 +112,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
@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) {
for(int i = 1; i < BobbleType.values().length; i++) for(int i = 1; i < BobbleType.values().length; i++)
list.add(new ItemStack(item, 1, i)); list.add(new ItemStack(item, 1, i));
} }
@ -119,12 +121,12 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
int meta = MathHelper.floor_double((double)((player.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15; int meta = MathHelper.floor_double((double)((player.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
world.setBlockMetadataWithNotify(x, y, z, meta, 2); world.setBlockMetadataWithNotify(x, y, z, meta, 2);
TileEntityBobble bobble = (TileEntityBobble) world.getTileEntity(x, y, z); TileEntityBobble bobble = (TileEntityBobble) world.getTileEntity(x, y, z);
bobble.type = BobbleType.values()[Math.abs(stack.getItemDamage()) % BobbleType.values().length]; bobble.type = BobbleType.values()[Math.abs(stack.getItemDamage()) % BobbleType.values().length];
bobble.markDirty(); bobble.markDirty();
} }
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
float f = 0.0625F; float f = 0.0625F;
@ -137,13 +139,18 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
} }
@Override
public int transformMeta(int meta, int coordBaseMode) {
return (meta + coordBaseMode * 4) % 16;
}
@Override @Override
public TileEntity createNewTileEntity(World world, int meta) { public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityBobble(); return new TileEntityBobble();
} }
public static class TileEntityBobble extends TileEntity { public static class TileEntityBobble extends TileEntity implements INBTTileEntityTransformable {
public BobbleType type = BobbleType.NONE; public BobbleType type = BobbleType.NONE;
@Override @Override
@ -157,7 +164,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
this.writeToNBT(nbt); this.writeToNBT(nbt);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
} }
@Override @Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
this.readFromNBT(pkt.func_148857_g()); this.readFromNBT(pkt.func_148857_g());
@ -174,10 +181,15 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setByte("type", (byte) type.ordinal()); nbt.setByte("type", (byte) type.ordinal());
} }
@Override
public void transformTE(World world, int coordBaseMode) {
type = BobbleType.values()[world.rand.nextInt(BobbleType.values().length - 1) + 1];
}
} }
public static enum BobbleType { public static enum BobbleType {
NONE( "null", "null", null, null, false, ScrapType.BOARD_BLANK), NONE( "null", "null", null, null, false, ScrapType.BOARD_BLANK),
STRENGTH( "Strength", "Strength", null, "It's essential to give your arguments impact.", false, ScrapType.BRIDGE_BIOS), STRENGTH( "Strength", "Strength", null, "It's essential to give your arguments impact.", false, ScrapType.BRIDGE_BIOS),
PERCEPTION( "Perception", "Perception", null, "Only through observation will you perceive weakness.", false, ScrapType.BRIDGE_NORTH), PERCEPTION( "Perception", "Perception", null, "Only through observation will you perceive weakness.", false, ScrapType.BRIDGE_NORTH),
@ -186,7 +198,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
INTELLIGENCE( "Intelligence", "Intelligence", null, "It takes the smartest individuals to realize$there's always more to learn.", false, ScrapType.BRIDGE_BUS), INTELLIGENCE( "Intelligence", "Intelligence", null, "It takes the smartest individuals to realize$there's always more to learn.", false, ScrapType.BRIDGE_BUS),
AGILITY( "Agility", "Agility", null, "Never be afraid to dodge the sensitive issues.", false, ScrapType.BRIDGE_CHIPSET), AGILITY( "Agility", "Agility", null, "Never be afraid to dodge the sensitive issues.", false, ScrapType.BRIDGE_CHIPSET),
LUCK( "Luck", "Luck", null, "There's only one way to give 110%.", false, ScrapType.BRIDGE_CMOS), LUCK( "Luck", "Luck", null, "There's only one way to give 110%.", false, ScrapType.BRIDGE_CMOS),
BOB( "Robert \"The Bobcat\" Katzinsky", "HbMinecraft", "Hbm's Nuclear Tech Mod", "I know where you live, " + System.getProperty("user.name"), false, ScrapType.CPU_SOCKET), BOB( "Robert \"The Bobcat\" Katzinsky", "HbMinecraft", "Hbm's Nuclear Tech Mod", "I know where you live, " + System.getProperty("user.name"), false, ScrapType.CPU_SOCKET),
FRIZZLE( "Frooz", "Frooz", "Weapon models", "BLOOD IS FUEL", true, ScrapType.CPU_CLOCK), FRIZZLE( "Frooz", "Frooz", "Weapon models", "BLOOD IS FUEL", true, ScrapType.CPU_CLOCK),
PU238( "Pu-238", "Pu-238", "Improved Tom impact mechanics", null, false, ScrapType.CPU_REGISTER), PU238( "Pu-238", "Pu-238", "Improved Tom impact mechanics", null, false, ScrapType.CPU_REGISTER),
VT( "VT-6/24", "VT-6/24", "Balefire warhead model and general texturework", "You cannot unfuck a horse.", true, ScrapType.CPU_EXT), VT( "VT-6/24", "VT-6/24", "Balefire warhead model and general texturework", "You cannot unfuck a horse.", true, ScrapType.CPU_EXT),
@ -199,9 +211,10 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
NOS( "Dr Nostalgia", "Dr Nostalgia", "SSG and Vortex models", "Take a picture, I'ma pose, paparazzi$I've been drinking, moving like a zombie", true, ScrapType.BOARD_TRANSISTOR), NOS( "Dr Nostalgia", "Dr Nostalgia", "SSG and Vortex models", "Take a picture, I'ma pose, paparazzi$I've been drinking, moving like a zombie", true, ScrapType.BOARD_TRANSISTOR),
DRILLGON( "Drillgon200", "Drillgon200", "1.12 Port", null, false, ScrapType.CPU_LOGIC), DRILLGON( "Drillgon200", "Drillgon200", "1.12 Port", null, false, ScrapType.CPU_LOGIC),
CIRNO( "Cirno", "Cirno", "the only multi layered skin i had", "No brain. Head empty.", true, ScrapType.BOARD_BLANK), CIRNO( "Cirno", "Cirno", "the only multi layered skin i had", "No brain. Head empty.", true, ScrapType.BOARD_BLANK),
MICROWAVE( "Microwave", "Microwave", "OC Compatibility", "they call me the food heater", true, ScrapType.BOARD_CONVERTER), MICROWAVE( "Microwave", "Microwave", "OC Compatibility and massive RBMK/packet optimizations", "they call me the food heater$john optimization", true, ScrapType.BOARD_CONVERTER),
PEEP( "Peep", "LePeeperSauvage", "Coilgun, Leadburster and Congo Lake models, BDCL QC", "Fluffy ears can't hide in ash, nor snow.", true, ScrapType.CARD_BOARD), PEEP( "Peep", "LePeeperSauvage", "Coilgun, Leadburster and Congo Lake models, BDCL QC", "Fluffy ears can't hide in ash, nor snow.", true, ScrapType.CARD_BOARD),
MELLOW( "MELLOWARPEGGIATION", "Mellow", "Industrial lighting, animation tools", "Make something cool now, ask for permission later.", true, ScrapType.CARD_PROCESSOR); MELLOW( "MELLOWARPEGGIATION", "Mellow", "NBT Structures, industrial lighting, animation tools", "Make something cool now, ask for permission later.", true, ScrapType.CARD_PROCESSOR),
ABEL( "Abel1502", "Abel1502", "Abilities GUI, optimizations and many QoL improvements", "NANTO SUBARASHII", true, ScrapType.CPU_REGISTER);
public String name; //the title of the tooltip public String name; //the title of the tooltip
public String label; //the name engraved in the socket public String label; //the name engraved in the socket
@ -209,7 +222,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
public String inscription; //the flavor text public String inscription; //the flavor text
public boolean skinLayers; public boolean skinLayers;
public ScrapType scrap; public ScrapType scrap;
private BobbleType(String name, String label, String contribution, String inscription, boolean layers, ScrapType scrap) { private BobbleType(String name, String label, String contribution, String inscription, boolean layers, ScrapType scrap) {
this.name = name; this.name = name;
this.label = label; this.label = label;
@ -227,7 +240,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUIScreenBobble((TileEntityBobble) world.getTileEntity(x, y, z)); return new GUIScreenBobble((TileEntityBobble) world.getTileEntity(x, y, z));
} }
} }

View File

@ -6,7 +6,7 @@ import java.util.Random;
import com.hbm.blocks.ITooltipProvider; import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.util.I18nUtil; import com.hbm.util.i18n.I18nUtil;
import api.hbm.block.IDrillInteraction; import api.hbm.block.IDrillInteraction;
import api.hbm.block.IMiningDrill; import api.hbm.block.IMiningDrill;

View File

@ -3,20 +3,12 @@ package com.hbm.blocks.generic;
import java.util.Random; import java.util.Random;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.items.tool.ItemToolAbility;
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.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemTool;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.util.Vec3;
import net.minecraft.world.Explosion;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockCoalOil extends Block { public class BlockCoalOil extends Block {
@ -24,19 +16,6 @@ public class BlockCoalOil extends Block {
super(mat); super(mat);
} }
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block b) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Block n = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if(n == ModBlocks.ore_coal_oil_burning || n == ModBlocks.balefire || n == Blocks.fire || n.getMaterial() == Material.lava) {
world.scheduleBlockUpdate(x, y, z, this, world.rand.nextInt(20) + 2);
}
}
}
@Override @Override
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) {
world.setBlock(x, y, z, ModBlocks.ore_coal_oil_burning); world.setBlock(x, y, z, ModBlocks.ore_coal_oil_burning);
@ -51,58 +30,4 @@ public class BlockCoalOil extends Block {
public int quantityDropped(Random rand) { public int quantityDropped(Random rand) {
return 2 + rand.nextInt(2); return 2 + rand.nextInt(2);
} }
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
if(doesToolIgnite(player)) {
if(world.rand.nextInt(10) == 0)
world.setBlock(x, y, z, Blocks.fire);
}
}
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
if(!world.isRemote)
return;
if(doesToolIgnite(player)) {
Random rand = world.rand;
for(int i = 0; i < 15; i++) {
Vec3 vec = Vec3.createVectorHelper(1, 0, 0);
vec.rotateAroundZ((float)(Math.PI * rand.nextDouble() * 2D));
vec.rotateAroundY((float)(Math.PI * rand.nextDouble() * 2D));
double dX = vec.xCoord;
double dY = vec.yCoord;
double dZ = vec.zCoord;
if(Math.abs(dX) > 1)
dX /= Math.abs(dX);
if(Math.abs(dY) > 1)
dY /= Math.abs(dY);
if(Math.abs(dX) > 1)
dZ /= Math.abs(dZ);
world.spawnParticle("flame", x + 0.5 + dX * 0.75, y + 0.5 + dY * 0.75, z + 0.5 + dZ * 0.75, 0.0, 0.0, 0.0);
}
}
}
public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) {
world.setBlock(x, y, z, Blocks.fire);
}
private boolean doesToolIgnite(EntityPlayer player) {
if(player.getHeldItem() == null)
return false;
if(!(player.getHeldItem().getItem() instanceof ItemTool || player.getHeldItem().getItem() instanceof ItemToolAbility))
return false;
ItemTool tool = (ItemTool) player.getHeldItem().getItem();
return tool.func_150913_i() != ToolMaterial.WOOD;
}
} }

View File

@ -5,7 +5,7 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.items.ItemAmmoEnums.Ammo44Magnum; import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmoSecret;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import net.minecraft.block.BlockFalling; import net.minecraft.block.BlockFalling;
@ -52,18 +52,6 @@ public class BlockCrate extends BlockFalling {
// Supply Crate // Supply Crate
BlockCrate.addToListWithWeight(crateList, ModItems.syringe_metal_stimpak, 10); BlockCrate.addToListWithWeight(crateList, ModItems.syringe_metal_stimpak, 10);
BlockCrate.addToListWithWeight(crateList, ModItems.syringe_antidote, 5); BlockCrate.addToListWithWeight(crateList, ModItems.syringe_antidote, 5);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_revolver_iron, 9);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_revolver, 7);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_revolver_gold, 4);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_revolver_lead, 6);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_revolver_cursed, 5);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_rpg, 5);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_fatman, 1);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_mp40, 7);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_uzi, 7);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_uboinik, 7);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_lever_action, 5);
BlockCrate.addToListWithWeight(crateList, ModItems.clip_bolt_action, 5);
BlockCrate.addToListWithWeight(crateList, ModItems.grenade_generic, 8); BlockCrate.addToListWithWeight(crateList, ModItems.grenade_generic, 8);
BlockCrate.addToListWithWeight(crateList, ModItems.grenade_strong, 6); BlockCrate.addToListWithWeight(crateList, ModItems.grenade_strong, 6);
BlockCrate.addToListWithWeight(crateList, ModItems.grenade_mk2, 4); BlockCrate.addToListWithWeight(crateList, ModItems.grenade_mk2, 4);
@ -71,21 +59,13 @@ public class BlockCrate extends BlockFalling {
BlockCrate.addToListWithWeight(crateList, ModItems.ammo_container, 2); BlockCrate.addToListWithWeight(crateList, ModItems.ammo_container, 2);
// Weapon Crate // Weapon Crate
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_revolver, 9); BlockCrate.addToListWithWeight(weaponList, ModItems.gun_light_revolver, 10);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_revolver_gold, 7); BlockCrate.addToListWithWeight(weaponList, ModItems.gun_maresleg, 7);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_revolver_cursed, 7); BlockCrate.addToListWithWeight(weaponList, ModItems.gun_heavy_revolver, 5);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_calamity, 3); BlockCrate.addToListWithWeight(weaponList, ModItems.gun_greasegun, 5);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_rpg, 7); BlockCrate.addToListWithWeight(weaponList, ModItems.gun_liberator, 2);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_karl, 4); BlockCrate.addToListWithWeight(weaponList, ModItems.gun_flaregun, 8);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_panzerschreck, 6); BlockCrate.addToListWithWeight(weaponList, ModItems.gun_panzerschreck, 1);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_hk69, 8);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_stinger, 7);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_mp40, 9);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_uzi, 6);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_uzi_silencer, 5);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_uboinik, 8);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_lever_action, 7);
BlockCrate.addToListWithWeight(weaponList, ModItems.gun_bolt_action, 7);
// Lead Crate // Lead Crate
BlockCrate.addToListWithWeight(leadList, ModItems.ingot_uranium, 10); BlockCrate.addToListWithWeight(leadList, ModItems.ingot_uranium, 10);
@ -123,7 +103,6 @@ public class BlockCrate extends BlockFalling {
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_press), 10); BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_press), 10);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_difurnace_off), 9); BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_difurnace_off), 9);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_reactor_breeding), 6); BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_reactor_breeding), 6);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_nuke_furnace_off), 7);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_wood_burner), 10); BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_wood_burner), 10);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_diesel), 8); BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_diesel), 8);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_rtg_grey), 4); BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_rtg_grey), 4);
@ -144,12 +123,12 @@ public class BlockCrate extends BlockFalling {
// Red Crate // Red Crate
BlockCrate.addToListWithWeight(redList, ModItems.mysteryshovel, 1); BlockCrate.addToListWithWeight(redList, ModItems.mysteryshovel, 1);
BlockCrate.addToListWithWeight(redList, ModItems.gun_revolver_pip, 1); BlockCrate.addToListWithWeight(redList, ModItems.gun_heavy_revolver_lilmac, 1);
BlockCrate.addToListWithWeight(redList, ModItems.gun_revolver_blackjack, 1); BlockCrate.addToListWithWeight(redList, ModItems.gun_autoshotgun_sexy, 1);
BlockCrate.addToListWithWeight(redList, ModItems.gun_revolver_silver, 1); BlockCrate.addToListWithWeight(redList, ModItems.gun_maresleg_broken, 1);
BlockCrate.addToListWithWeight(redList, ModItems.ammo_44.stackFromEnum(Ammo44Magnum.PIP), 1); BlockCrate.addToListWithWeight(redList, new ItemStack(ModItems.ammo_secret, 1, EnumAmmoSecret.M44_EQUESTRIAN.ordinal()), 1);
BlockCrate.addToListWithWeight(redList, ModItems.ammo_44.stackFromEnum(Ammo44Magnum.BJ), 1); BlockCrate.addToListWithWeight(redList, new ItemStack(ModItems.ammo_secret, 1, EnumAmmoSecret.G12_EQUESTRIAN.ordinal()), 1);
BlockCrate.addToListWithWeight(redList, ModItems.ammo_44.stackFromEnum(Ammo44Magnum.SILVER), 1); BlockCrate.addToListWithWeight(redList, new ItemStack(ModItems.ammo_secret, 1, EnumAmmoSecret.BMG50_EQUESTRIAN.ordinal()), 1);
BlockCrate.addToListWithWeight(redList, ModItems.battery_spark, 1); BlockCrate.addToListWithWeight(redList, ModItems.battery_spark, 1);
BlockCrate.addToListWithWeight(redList, ModItems.bottle_sparkle, 1); BlockCrate.addToListWithWeight(redList, ModItems.bottle_sparkle, 1);
BlockCrate.addToListWithWeight(redList, ModItems.bottle_rad, 1); BlockCrate.addToListWithWeight(redList, ModItems.bottle_rad, 1);

View File

@ -2,6 +2,7 @@ package com.hbm.blocks.generic;
import com.hbm.blocks.BlockMulti; import com.hbm.blocks.BlockMulti;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -14,7 +15,7 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockDecoCRT extends BlockMulti { public class BlockDecoCRT extends BlockMulti implements INBTTransformable {
protected String[] variants = new String[] {"crt_clean", "crt_broken", "crt_blinking", "crt_bsod"}; protected String[] variants = new String[] {"crt_clean", "crt_broken", "crt_blinking", "crt_bsod"};
@SideOnly(Side.CLIENT) protected IIcon[] icons; @SideOnly(Side.CLIENT) protected IIcon[] icons;
@ -24,17 +25,17 @@ public class BlockDecoCRT extends BlockMulti {
} }
public static int renderID = RenderingRegistry.getNextAvailableRenderId(); public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override @Override
public int getRenderType(){ public int getRenderType(){
return renderID; return renderID;
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
@ -45,12 +46,12 @@ public class BlockDecoCRT extends BlockMulti {
public void registerBlockIcons(IIconRegister reg) { public void registerBlockIcons(IIconRegister reg) {
super.registerBlockIcons(reg); super.registerBlockIcons(reg);
this.icons = new IIcon[variants.length]; this.icons = new IIcon[variants.length];
for(int i = 0; i < variants.length; i++) { for(int i = 0; i < variants.length; i++) {
this.icons[i] = reg.registerIcon(RefStrings.MODID + ":" + variants[i]); this.icons[i] = reg.registerIcon(RefStrings.MODID + ":" + variants[i]);
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) { public IIcon getIcon(int side, int meta) {
@ -61,7 +62,7 @@ public class BlockDecoCRT extends BlockMulti {
public int damageDropped(int meta) { public int damageDropped(int meta) {
return (Math.abs(meta) % 16) / 4; return (Math.abs(meta) % 16) / 4;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
@ -73,4 +74,10 @@ public class BlockDecoCRT extends BlockMulti {
public int getSubCount() { public int getSubCount() {
return 4; return 4;
} }
}
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTTransformable.transformMetaDecoModel(meta, coordBaseMode);
}
}

View File

@ -1,17 +1,19 @@
package com.hbm.blocks.generic; package com.hbm.blocks.generic;
import com.hbm.blocks.ModBlocks;
import com.hbm.render.block.ct.CT; import com.hbm.render.block.ct.CT;
import com.hbm.render.block.ct.CTStitchReceiver; import com.hbm.render.block.ct.CTStitchReceiver;
import com.hbm.render.block.ct.IBlockCT; import com.hbm.render.block.ct.IBlockCT;
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.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
public class BlockDecoCT extends BlockOre implements IBlockCT{ public class BlockDecoCT extends BlockOre implements IBlockCT {
public BlockDecoCT(Material mat) { public BlockDecoCT(Material mat) {
super(mat); super(mat);
@ -35,4 +37,12 @@ public class BlockDecoCT extends BlockOre implements IBlockCT{
public IIcon[] getFragments(IBlockAccess world, int x, int y, int z) { public IIcon[] getFragments(IBlockAccess world, int x, int y, int z) {
return rec.fragCache; return rec.fragCache;
} }
@Override
public boolean canConnect(IBlockAccess world, int x, int y, int z, Block block) {
// i don't care
if(this == ModBlocks.deco_steel && block == ModBlocks.deco_rusty_steel) return true;
if(this == ModBlocks.deco_rusty_steel && block == ModBlocks.deco_steel) return true;
return this == block;
}
} }

View File

@ -1,6 +1,7 @@
package com.hbm.blocks.generic; package com.hbm.blocks.generic;
import com.hbm.blocks.BlockEnumMulti; import com.hbm.blocks.BlockEnumMulti;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -11,14 +12,14 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockDecoModel extends BlockEnumMulti { public class BlockDecoModel extends BlockEnumMulti implements INBTTransformable {
public BlockDecoModel(Material mat, Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) { public BlockDecoModel(Material mat, Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) {
super(mat, theEnum, multiName, multiTexture); super(mat, theEnum, multiName, multiTexture);
} }
public static int renderID = RenderingRegistry.getNextAvailableRenderId(); public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override @Override
public int getRenderType() { public int getRenderType() {
return renderID; return renderID;
@ -33,18 +34,18 @@ public class BlockDecoModel extends BlockEnumMulti {
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
//Did somebody say - pain? //Did somebody say - pain?
//Alright fuckers, looks like 2/b010 = North, 3/b011 = South, 4/b100 = West, 5/b101 = East for sides. //Alright fuckers, looks like 2/b010 = North, 3/b011 = South, 4/b100 = West, 5/b101 = East for sides.
//I'll just opt for something similar (0/b00 North, 1/b01 South, 2/b10 West, 3/b11 East) //I'll just opt for something similar (0/b00 North, 1/b01 South, 2/b10 West, 3/b11 East)
//Assumes meta is using the third and fourth bits. //Assumes meta is using the third and fourth bits.
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
int meta; int meta;
if((i & 1) != 1) if((i & 1) != 1)
meta = i >> 1; //For North(b00>b00) and South(b10>b01), shift bits right by one meta = i >> 1; //For North(b00>b00) and South(b10>b01), shift bits right by one
else { else {
@ -53,15 +54,15 @@ public class BlockDecoModel extends BlockEnumMulti {
else else
meta = 3; //For East(b01>b11), just set to 3 meta = 3; //For East(b01>b11), just set to 3
} }
world.setBlockMetadataWithNotify(x, y, z, (meta << 2) | stack.getItemDamage(), 2); world.setBlockMetadataWithNotify(x, y, z, (meta << 2) | stack.getItemDamage(), 2);
} }
@Override @Override
public int damageDropped(int meta) { public int damageDropped(int meta) {
return meta & 3; return meta & 3;
} }
//These are separate because they have to be constant //These are separate because they have to be constant
private float mnX = 0.0F; //min private float mnX = 0.0F; //min
private float mnY = 0.0F; private float mnY = 0.0F;
@ -69,7 +70,7 @@ public class BlockDecoModel extends BlockEnumMulti {
private float mxX = 1.0F; //max private float mxX = 1.0F; //max
private float mxY = 1.0F; private float mxY = 1.0F;
private float mxZ = 1.0F; private float mxZ = 1.0F;
public BlockDecoModel setBlockBoundsTo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) { public BlockDecoModel setBlockBoundsTo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
mnX = minX; mnX = minX;
mnY = minY; mnY = minY;
@ -77,10 +78,10 @@ public class BlockDecoModel extends BlockEnumMulti {
mxX = maxX; mxX = maxX;
mxY = maxY; mxY = maxY;
mxZ = maxZ; mxZ = maxZ;
return this; return this;
} }
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
switch(world.getBlockMetadata(x, y, z) >> 2) { switch(world.getBlockMetadata(x, y, z) >> 2) {
@ -98,10 +99,40 @@ public class BlockDecoModel extends BlockEnumMulti {
break; break;
} }
} }
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
this.setBlockBoundsBasedOnState(world, x, y, z); this.setBlockBoundsBasedOnState(world, x, y, z);
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
} }
@Override
public int transformMeta(int meta, int coordBaseMode) {
if(coordBaseMode == 0) return meta;
//N: 0b00, S: 0b01, W: 0b10, E: 0b11
int rot = meta >> 2;
int type = meta & 3;
switch(coordBaseMode) {
default: //South
break;
case 1: //West
if((rot & 3) < 2) //N & S can just have bits toggled
rot = rot ^ 3;
else //W & E can just have first bit set to 0
rot = rot ^ 2;
break;
case 2: //North
rot = rot ^ 1; //N, W, E & S can just have first bit toggled
break;
case 3: //East
if((rot & 3) < 2)//N & S can just have second bit set to 1
rot = rot ^ 2;
else //W & E can just have bits toggled
rot = rot ^ 3;
break;
}
//genuinely like. why did i do that
return (rot << 2) | type; //To accommodate for BlockDecoModel's shift in the rotation bits; otherwise, simply bit-shift right and or any non-rotation meta after
}
} }

View File

@ -2,6 +2,7 @@ package com.hbm.blocks.generic;
import com.hbm.blocks.BlockMulti; import com.hbm.blocks.BlockMulti;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -16,7 +17,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockDecoToaster extends BlockMulti { public class BlockDecoToaster extends BlockMulti implements INBTTransformable {
protected String[] variants = new String[] {"toaster_iron", "toaster_steel", "toaster_wood"}; protected String[] variants = new String[] {"toaster_iron", "toaster_steel", "toaster_wood"};
@SideOnly(Side.CLIENT) protected IIcon[] icons; @SideOnly(Side.CLIENT) protected IIcon[] icons;
@ -26,17 +27,17 @@ public class BlockDecoToaster extends BlockMulti {
} }
public static int renderID = RenderingRegistry.getNextAvailableRenderId(); public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override @Override
public int getRenderType(){ public int getRenderType(){
return renderID; return renderID;
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
@ -47,12 +48,12 @@ public class BlockDecoToaster extends BlockMulti {
public void registerBlockIcons(IIconRegister reg) { public void registerBlockIcons(IIconRegister reg) {
super.registerBlockIcons(reg); super.registerBlockIcons(reg);
this.icons = new IIcon[variants.length]; this.icons = new IIcon[variants.length];
for(int i = 0; i < variants.length; i++) { for(int i = 0; i < variants.length; i++) {
this.icons[i] = reg.registerIcon(RefStrings.MODID + ":" + variants[i]); this.icons[i] = reg.registerIcon(RefStrings.MODID + ":" + variants[i]);
} }
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) { public IIcon getIcon(int side, int meta) {
@ -63,7 +64,7 @@ public class BlockDecoToaster extends BlockMulti {
public int damageDropped(int meta) { public int damageDropped(int meta) {
return (Math.abs(meta) % 12) / 4; return (Math.abs(meta) % 12) / 4;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
@ -90,4 +91,10 @@ public class BlockDecoToaster extends BlockMulti {
this.setBlockBoundsBasedOnState(world, x, y, z); this.setBlockBoundsBasedOnState(world, x, y, z);
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
} }
}
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTTransformable.transformMetaDecoModel(meta, coordBaseMode);
}
}

View File

@ -3,7 +3,7 @@ package com.hbm.blocks.generic;
import java.util.List; import java.util.List;
import com.hbm.blocks.ITooltipProvider; import com.hbm.blocks.ITooltipProvider;
import com.hbm.util.I18nUtil; import com.hbm.util.i18n.I18nUtil;
import api.hbm.item.IDepthRockTool; import api.hbm.item.IDepthRockTool;
import net.minecraft.block.Block; import net.minecraft.block.Block;

View File

@ -17,6 +17,8 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
@ -116,6 +118,22 @@ public class BlockDoorGeneric extends BlockDummyable implements IBomb {
return aabb; return aabb;
} }
// Enables clicking through the open door
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) {
AxisAlignedBB box = getBoundingBox(world, x, y ,z);
box = AxisAlignedBB.getBoundingBox(
Math.min(box.minX, box.maxX), Math.min(box.minY, box.maxY), Math.min(box.minZ, box.maxZ),
Math.max(box.minX, box.maxX), Math.max(box.minY, box.maxY), Math.max(box.minZ, box.maxZ)
);
MovingObjectPosition intercept = box.calculateIntercept(startVec, endVec);
if(intercept != null) {
return new MovingObjectPosition(x, y, z, intercept.sideHit, intercept.hitVec);
}
return null;
}
@Override //should fix AI pathfinding @Override //should fix AI pathfinding
public boolean getBlocksMovement(IBlockAccess world, int x, int y, int z) { //btw the method name is the exact opposite of that it's doing, check net.minecraft.pathfinding.PathNavigate#512 public boolean getBlocksMovement(IBlockAccess world, int x, int y, int z) { //btw the method name is the exact opposite of that it's doing, check net.minecraft.pathfinding.PathNavigate#512
return hasExtra(world.getBlockMetadata(x, y, z)); //if it's open return hasExtra(world.getBlockMetadata(x, y, z)); //if it's open

View File

@ -135,7 +135,7 @@ public class BlockDynamicSlag extends BlockContainer {
TileEntitySlag self = (TileEntitySlag) s; TileEntitySlag self = (TileEntitySlag) s;
/* Flow down */ /* Flow down */
if(world.getBlock(x, y - 1, z).isReplaceable(world, x, y - 1, z)) { if(world.getBlock(x, y - 1, z).isReplaceable(world, x, y - 1, z) && y > 0) {
world.setBlock(x, y - 1, z, ModBlocks.slag); world.setBlock(x, y - 1, z, ModBlocks.slag);
TileEntitySlag tile = (TileEntitySlag) Compat.getTileStandard(world, x, y - 1, z); TileEntitySlag tile = (TileEntitySlag) Compat.getTileStandard(world, x, y - 1, z);
tile.mat = self.mat; tile.mat = self.mat;

View File

@ -4,15 +4,15 @@ import java.awt.Color;
import java.util.List; import java.util.List;
import com.hbm.blocks.ITooltipProvider; import com.hbm.blocks.ITooltipProvider;
import com.hbm.packet.AuxParticlePacketNT; import com.hbm.handler.threading.PacketThreading;
import com.hbm.packet.NBTPacket; import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.INBTPacketReceiver;
import api.hbm.block.IToolable; import api.hbm.block.IToolable;
import com.hbm.tileentity.TileEntityLoadedBase;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
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 io.netty.buffer.ByteBuf;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockPistonBase; import net.minecraft.block.BlockPistonBase;
@ -41,7 +41,7 @@ public class BlockEmitter extends BlockContainer implements IToolable, ITooltipP
public TileEntity createNewTileEntity(World world, int meta) { public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityEmitter(); return new TileEntityEmitter();
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
@ -56,12 +56,12 @@ public class BlockEmitter extends BlockContainer implements IToolable, ITooltipP
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float fx, float fy, float fz) { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float fx, float fy, float fz) {
if(world.isRemote) if(world.isRemote)
return true; return true;
TileEntityEmitter te = (TileEntityEmitter)world.getTileEntity(x, y, z); TileEntityEmitter te = (TileEntityEmitter)world.getTileEntity(x, y, z);
if(player.getHeldItem() != null) { if(player.getHeldItem() != null) {
if(player.getHeldItem().getItem() instanceof ItemDye) { if(player.getHeldItem().getItem() instanceof ItemDye) {
@ -72,7 +72,7 @@ public class BlockEmitter extends BlockContainer implements IToolable, ITooltipP
return true; return true;
} }
} }
return false; return false;
} }
@ -80,31 +80,31 @@ public class BlockEmitter extends BlockContainer implements IToolable, ITooltipP
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
TileEntityEmitter te = (TileEntityEmitter)world.getTileEntity(x, y, z); TileEntityEmitter te = (TileEntityEmitter)world.getTileEntity(x, y, z);
if(tool == ToolType.SCREWDRIVER) { if(tool == ToolType.SCREWDRIVER) {
te.girth += 0.125F; te.girth += 0.125F;
te.markDirty(); te.markDirty();
return true; return true;
} }
if(tool == ToolType.DEFUSER) { if(tool == ToolType.DEFUSER) {
te.girth -= 0.125F; te.girth -= 0.125F;
if(te.girth < 0.125F) te.girth = 0.125F; if(te.girth < 0.125F) te.girth = 0.125F;
te.markDirty(); te.markDirty();
return true; return true;
} }
if(tool == ToolType.HAND_DRILL) { if(tool == ToolType.HAND_DRILL) {
te.effect = (te.effect + 1) % te.effectCount; te.effect = (te.effect + 1) % te.effectCount;
te.markDirty(); te.markDirty();
return true; return true;
} }
return false; return false;
} }
public static class TileEntityEmitter extends TileEntity implements INBTPacketReceiver { public static class TileEntityEmitter extends TileEntityLoadedBase {
public static final int range = 100; public static final int range = 100;
public int color; public int color;
public int beam; public int beam;
@ -114,39 +114,39 @@ public class BlockEmitter extends BlockContainer implements IToolable, ITooltipP
@Override @Override
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
if(worldObj.getTotalWorldTime() % 20 == 0) { if(worldObj.getTotalWorldTime() % 20 == 0) {
for(int i = 1; i <= range; i++) { for(int i = 1; i <= range; i++) {
beam = i; beam = i;
int x = xCoord + dir.offsetX * i; int x = xCoord + dir.offsetX * i;
int y = yCoord + dir.offsetY * i; int y = yCoord + dir.offsetY * i;
int z = zCoord + dir.offsetZ * i; int z = zCoord + dir.offsetZ * i;
Block b = worldObj.getBlock(x, y, z); Block b = worldObj.getBlock(x, y, z);
if(b.isBlockSolid(worldObj, x, y, z, dir.ordinal())) { if(b.isBlockSolid(worldObj, x, y, z, dir.ordinal())) {
break; break;
} }
} }
} }
if(effect == 4 && beam > 0) { if(effect == 4 && beam > 0) {
if(worldObj.getTotalWorldTime() % 5 == 0) { if(worldObj.getTotalWorldTime() % 5 == 0) {
double x = (int) (xCoord + dir.offsetX * (worldObj.getTotalWorldTime() / 5L) % beam) + 0.5; double x = (int) (xCoord + dir.offsetX * (worldObj.getTotalWorldTime() / 5L) % beam) + 0.5;
double y = (int) (yCoord + dir.offsetY * (worldObj.getTotalWorldTime() / 5L) % beam) + 0.5; double y = (int) (yCoord + dir.offsetY * (worldObj.getTotalWorldTime() / 5L) % beam) + 0.5;
double z = (int) (zCoord + dir.offsetZ * (worldObj.getTotalWorldTime() / 5L) % beam) + 0.5; double z = (int) (zCoord + dir.offsetZ * (worldObj.getTotalWorldTime() / 5L) % beam) + 0.5;
int prevColor = color; int prevColor = color;
if(color == 0) { if(color == 0) {
color = Color.HSBtoRGB(worldObj.getTotalWorldTime() / 50.0F, 0.5F, 0.25F) & 16777215; color = Color.HSBtoRGB(worldObj.getTotalWorldTime() / 50.0F, 0.5F, 0.25F) & 16777215;
} }
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
data.setString("type", "plasmablast"); data.setString("type", "plasmablast");
data.setFloat("r", ((float)((color & 0xff0000) >> 16)) / 256F); data.setFloat("r", ((float)((color & 0xff0000) >> 16)) / 256F);
@ -168,20 +168,16 @@ public class BlockEmitter extends BlockContainer implements IToolable, ITooltipP
data.setFloat("pitch", -90); data.setFloat("pitch", -90);
data.setFloat("yaw", 90); data.setFloat("yaw", 90);
} }
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, x, y, z), PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, x, y, z),
new TargetPoint(worldObj.provider.dimensionId, x, y, z, 100)); new TargetPoint(worldObj.provider.dimensionId, x, y, z, 100));
color = prevColor; color = prevColor;
} }
} }
NBTTagCompound data = new NBTTagCompound(); networkPackNT(150);
data.setInteger("beam", this.beam);
data.setInteger("color", this.color);
data.setFloat("girth", this.girth);
data.setInteger("effect", this.effect);
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(data, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 150));
} }
} }
@ -191,7 +187,7 @@ public class BlockEmitter extends BlockContainer implements IToolable, ITooltipP
this.writeToNBT(nbt); this.writeToNBT(nbt);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
} }
@Override @Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
this.readFromNBT(pkt.func_148857_g()); this.readFromNBT(pkt.func_148857_g());
@ -212,7 +208,7 @@ public class BlockEmitter extends BlockContainer implements IToolable, ITooltipP
nbt.setFloat("girth", this.girth); nbt.setFloat("girth", this.girth);
nbt.setInteger("effect", this.effect); nbt.setInteger("effect", this.effect);
} }
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
return TileEntity.INFINITE_EXTENT_AABB; return TileEntity.INFINITE_EXTENT_AABB;
@ -225,11 +221,19 @@ public class BlockEmitter extends BlockContainer implements IToolable, ITooltipP
} }
@Override @Override
public void networkUnpack(NBTTagCompound nbt) { public void serialize(ByteBuf buf) {
this.beam = nbt.getInteger("beam"); buf.writeInt(this.beam);
this.color = nbt.getInteger("color"); buf.writeInt(this.color);
this.girth = nbt.getFloat("girth"); buf.writeFloat(this.girth);
this.effect = nbt.getInteger("effect"); buf.writeInt(this.effect);
}
@Override
public void deserialize(ByteBuf buf) {
this.beam = buf.readInt();
this.color = buf.readInt();
this.girth = buf.readFloat();
this.effect = buf.readInt();
} }
} }

View File

@ -2,21 +2,28 @@ package com.hbm.blocks.generic;
import java.util.Random; import java.util.Random;
import api.hbm.fluid.IFluidStandardSender;
import com.hbm.blocks.IBlockMultiPass; import com.hbm.blocks.IBlockMultiPass;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.render.block.RenderBlockMultipass; import com.hbm.render.block.RenderBlockMultipass;
import com.hbm.tileentity.TileEntityLoadedBase;
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.Block; import net.minecraft.block.BlockContainer;
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.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockFissure extends Block implements IBlockMultiPass { public class BlockFissure extends BlockContainer implements IBlockMultiPass {
private IIcon overlay; private IIcon overlay;
@ -65,4 +72,31 @@ public class BlockFissure extends Block implements IBlockMultiPass {
public int getRenderType(){ public int getRenderType(){
return IBlockMultiPass.getRenderType(); return IBlockMultiPass.getRenderType();
} }
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityFissure();
}
public static class TileEntityFissure extends TileEntityLoadedBase implements IFluidStandardSender {
public FluidTank lava = new FluidTank(Fluids.LAVA, 1_000);
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
lava.setFill(1_000);
this.sendFluid(lava, worldObj, xCoord, yCoord + 1, zCoord, ForgeDirection.UP);
}
}
@Override
public boolean canConnect(FluidType type, ForgeDirection dir) {
return dir == ForgeDirection.DOWN && type == Fluids.LAVA;
}
@Override public FluidTank[] getAllTanks() { return new FluidTank[] {lava}; }
@Override public FluidTank[] getSendingTanks() { return new FluidTank[] {lava}; }
}
} }

View File

@ -18,6 +18,6 @@ public class BlockGenericStairs extends BlockStairs {
recipeGen.add(new Object[] {block, meta, this}); recipeGen.add(new Object[] {block, meta, this});
this.setBlockTextureName(RefStrings.MODID + ":concrete_smooth"); this.setBlockTextureName(RefStrings.MODID + ":concrete");
} }
} }

View File

@ -22,6 +22,7 @@ public class BlockGlyphid extends Block implements IBlockMulti {
public IIcon[] iconsStandard = new IIcon[2]; public IIcon[] iconsStandard = new IIcon[2];
public IIcon[] iconsInfested = new IIcon[2]; public IIcon[] iconsInfested = new IIcon[2];
public IIcon[] iconsRad = new IIcon[2];
public BlockGlyphid(Material mat) { public BlockGlyphid(Material mat) {
super(mat); super(mat);
@ -57,16 +58,19 @@ public class BlockGlyphid extends Block implements IBlockMulti {
iconsStandard[1] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_alt"); iconsStandard[1] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_alt");
iconsInfested[0] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_infested"); iconsInfested[0] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_infested");
iconsInfested[1] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_infested_alt"); iconsInfested[1] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_infested_alt");
iconsRad[0] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_rad");
iconsRad[1] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_rad_alt");
} }
protected IIcon[] getIconArray(int meta) { protected IIcon[] getIconArray(int meta) {
if(meta == 1) return this.iconsInfested; if(meta == 1) return this.iconsInfested;
if(meta == 2) return this.iconsRad;
return this.iconsStandard; return this.iconsStandard;
} }
@Override @Override
public int getSubCount() { public int getSubCount() {
return 2; return 3;
} }
@Override @Override

View File

@ -38,7 +38,7 @@ import net.minecraft.world.World;
public class BlockGlyphidSpawner extends BlockContainer implements IBlockMulti { public class BlockGlyphidSpawner extends BlockContainer implements IBlockMulti {
public IIcon[] icons = new IIcon[2]; public IIcon[] icons = new IIcon[3];
public BlockGlyphidSpawner(Material mat) { public BlockGlyphidSpawner(Material mat) {
super(mat); super(mat);
@ -61,11 +61,12 @@ public class BlockGlyphidSpawner extends BlockContainer implements IBlockMulti {
public void registerBlockIcons(IIconRegister reg) { public void registerBlockIcons(IIconRegister reg) {
icons[0] = reg.registerIcon(RefStrings.MODID + ":glyphid_eggs_alt"); icons[0] = reg.registerIcon(RefStrings.MODID + ":glyphid_eggs_alt");
icons[1] = reg.registerIcon(RefStrings.MODID + ":glyphid_eggs_infested"); icons[1] = reg.registerIcon(RefStrings.MODID + ":glyphid_eggs_infested");
icons[2] = reg.registerIcon(RefStrings.MODID + ":glyphid_eggs_rad");
} }
@Override @Override
public int getSubCount() { public int getSubCount() {
return 2; return 3;
} }
@Override @Override
@ -122,15 +123,16 @@ public class BlockGlyphidSpawner extends BlockContainer implements IBlockMulti {
List<EntityGlyphid> list = worldObj.getEntitiesWithinAABB(EntityGlyphid.class, AxisAlignedBB.getBoundingBox(xCoord - 5, yCoord + 1, zCoord - 5, xCoord + 6, yCoord + 7, zCoord + 6)); List<EntityGlyphid> list = worldObj.getEntitiesWithinAABB(EntityGlyphid.class, AxisAlignedBB.getBoundingBox(xCoord - 5, yCoord + 1, zCoord - 5, xCoord + 6, yCoord + 7, zCoord + 6));
float soot = PollutionHandler.getPollution(worldObj, xCoord, yCoord, zCoord, PollutionType.SOOT); float soot = PollutionHandler.getPollution(worldObj, xCoord, yCoord, zCoord, PollutionType.SOOT);
if(list.size() <= 3) { int subtype = this.getBlockMetadata();
if(list.size() <= 3 || subtype == EntityGlyphid.TYPE_RADIOACTIVE) {
ArrayList<EntityGlyphid> currentSwarm = createSwarm(soot, this.getBlockMetadata()); ArrayList<EntityGlyphid> currentSwarm = createSwarm(soot, subtype);
for(EntityGlyphid glyphid : currentSwarm) { for(EntityGlyphid glyphid : currentSwarm) {
trySpawnEntity(glyphid); trySpawnEntity(glyphid);
} }
if(!initialSpawn && worldObj.rand.nextInt(MobConfig.scoutSwarmSpawnChance + 1) == 0 && soot >= MobConfig.scoutThreshold) { if(!initialSpawn && worldObj.rand.nextInt(MobConfig.scoutSwarmSpawnChance + 1) == 0 && soot >= MobConfig.scoutThreshold && subtype != EntityGlyphid.TYPE_RADIOACTIVE) {
EntityGlyphidScout scout = new EntityGlyphidScout(worldObj); EntityGlyphidScout scout = new EntityGlyphidScout(worldObj);
if(this.getBlockMetadata() == 1) scout.getDataWatcher().updateObject(EntityGlyphid.DW_SUBTYPE, (byte) EntityGlyphid.TYPE_INFECTED); if(this.getBlockMetadata() == 1) scout.getDataWatcher().updateObject(EntityGlyphid.DW_SUBTYPE, (byte) EntityGlyphid.TYPE_INFECTED);
trySpawnEntity(scout); trySpawnEntity(scout);
@ -168,6 +170,7 @@ public class BlockGlyphidSpawner extends BlockContainer implements IBlockMulti {
if(soot >= chance[2] && rand.nextInt(100) <= adjustedChance) { if(soot >= chance[2] && rand.nextInt(100) <= adjustedChance) {
EntityGlyphid entity = glyphid.getKey().apply(worldObj); EntityGlyphid entity = glyphid.getKey().apply(worldObj);
if(meta == 1) entity.getDataWatcher().updateObject(EntityGlyphid.DW_SUBTYPE, (byte) EntityGlyphid.TYPE_INFECTED); if(meta == 1) entity.getDataWatcher().updateObject(EntityGlyphid.DW_SUBTYPE, (byte) EntityGlyphid.TYPE_INFECTED);
if(meta == 2) entity.getDataWatcher().updateObject(EntityGlyphid.DW_SUBTYPE, (byte) EntityGlyphid.TYPE_RADIOACTIVE);
currentSpawns.add(entity); currentSpawns.add(entity);
} }
} }

View File

@ -5,7 +5,7 @@ import java.util.List;
import com.hbm.blocks.ITooltipProvider; import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.util.I18nUtil; import com.hbm.util.i18n.I18nUtil;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;

View File

@ -0,0 +1,127 @@
package com.hbm.blocks.generic;
import java.util.ArrayList;
import com.hbm.lib.RefStrings;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockHangingVine extends Block implements IShearable {
public BlockHangingVine(Material mat) {
super(mat);
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
entity.motionX *= 0.5;
entity.motionY *= 0.5;
entity.motionZ *= 0.5;
entity.fallDistance = 0F;
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
return this.canBlockStay(world, x, y, z);
}
@Override
public boolean canBlockStay(World world, int x, int y, int z) {
Block b = world.getBlock(x, y + 1, z);
return b.isSideSolid(world, x, y + 1, z, ForgeDirection.UP) || b == this;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block);
this.checkAndDropBlock(world, x, y, z);
}
protected void checkAndDropBlock(World world, int x, int y, int z) {
if(!this.canBlockStay(world, x, y, z)) {
world.setBlock(x, y, z, Blocks.air);
}
}
@Override protected boolean canSilkHarvest() { return true; }
@Override
public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) {
return true;
}
@Override
public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ret.add(new ItemStack(this)); //placeholder
return ret;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return null;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@SideOnly(Side.CLIENT) public IIcon iconItem;
@SideOnly(Side.CLIENT) public IIcon iconGround; //when touching a solid face below
@SideOnly(Side.CLIENT) public IIcon iconHang; //when hanging mid-air
@SideOnly(Side.CLIENT) public IIcon iconGlow; //regular phosphor
@SideOnly(Side.CLIENT) public IIcon iconHangGlow; //phosphor in different position when hanging for variety
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
this.iconItem = reg.registerIcon(RefStrings.MODID + ":vine_phosphor_item");
this.blockIcon = reg.registerIcon(RefStrings.MODID + ":vine_phosphor");
this.iconGround = reg.registerIcon(RefStrings.MODID + ":vine_phosphor_ground");
this.iconHang = reg.registerIcon(RefStrings.MODID + ":vine_phosphor_hang");
this.iconGlow = reg.registerIcon(RefStrings.MODID + ":vine_phosphor_spots");
this.iconHangGlow = reg.registerIcon(RefStrings.MODID + ":vine_phosphor_spots_hang");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, boolean pass) {
Block b = world.getBlock(x, y - 1, z);
if(!pass)
return b.isSideSolid(world, x, y, z, ForgeDirection.UP) ? iconGround : b == this ? blockIcon : iconHang;
else
return b.isAir(world, x, y, z) ? iconHangGlow : iconGlow;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return this.iconItem;
}
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override
public int getRenderType() {
return renderID;
}
}

View File

@ -108,6 +108,14 @@ public class BlockKeyhole extends BlockStone {
} }
} }
if(world.rand.nextInt(1) == 0) {
int r = world.rand.nextInt(4);
if(r == 0) world.setBlock(x + width, y + 2, z, ModBlocks.stone_keyhole_meta, 4, 3);
if(r == 1) world.setBlock(x - width, y + 2, z, ModBlocks.stone_keyhole_meta, 5, 3);
if(r == 2) world.setBlock(x, y + 2, z + width, ModBlocks.stone_keyhole_meta, 2, 3);
if(r == 3) world.setBlock(x, y + 2, z - width, ModBlocks.stone_keyhole_meta, 3, 3);
}
for(int i = -width + 1; i <= width - 1; i++) { for(int i = -width + 1; i <= width - 1; i++) {
for(int j = -width + 1; j <= width - 1; j++) { for(int j = -width + 1; j <= width - 1; j++) {
//Floor and ceiling //Floor and ceiling

View File

@ -53,7 +53,7 @@ public class BlockLanternBehemoth extends BlockDummyable implements IToolable, I
if(didRepair) { if(didRepair) {
HbmPlayerProps data = HbmPlayerProps.getData(player); HbmPlayerProps data = HbmPlayerProps.getData(player);
data.reputation++; if(data.reputation < 25) data.reputation++;
} }
return didRepair; return didRepair;

View File

@ -0,0 +1,39 @@
package com.hbm.blocks.generic;
import com.hbm.blocks.BlockEnumMulti;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
public class BlockLightstone extends BlockEnumMulti {
public BlockLightstone(Material mat, Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) {
super(mat, theEnum, multiName, multiTexture);
}
protected IIcon[] topIcons;
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
Enum[] enums = theEnum.getEnumConstants();
this.icons = new IIcon[enums.length];
this.topIcons = new IIcon[enums.length];
for(int i = 0; i < icons.length; i++) {
Enum num = enums[i];
this.icons[i] = reg.registerIcon(this.getTextureMultiName(num));
if(i >= 3) this.topIcons[i] = reg.registerIcon(this.getTextureMultiName(num) + ".top");
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return (side == 0 || side == 1) && this.topIcons[meta % this.icons.length] != null ? this.topIcons[meta % this.icons.length] : this.icons[meta % this.icons.length];
}
}

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