Merge branch 'master' into master

This commit is contained in:
HbmMods 2024-05-05 19:14:11 +02:00 committed by GitHub
commit fadd6490e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1460 changed files with 153266 additions and 116379 deletions

View File

@ -18,6 +18,8 @@ Things you should also avoid include:
This should go without saying, but please don't PR code that was never actually tested or has obvious compiler errors in it.
**Addendum:** Because apparently some people think that testing is somehow optional, it is now **mandatory** to test the code both on a client and on a server. If the PR contains compat code, the game has to work **with and without** the mod that the compat is for.
## 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

@ -4,12 +4,14 @@
[NTM on CurseForge](https://minecraft.curseforge.com/projects/hbms-nuclear-tech-mod?gameCategorySlug=mc-mods&projectID=235439)
[Official NTM Wiki](https://nucleartech.wiki/wiki/Main_Page)
**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 Extended Edition (Alcater): https://github.com/Alcatergit/Hbm-s-Nuclear-Tech-GIT/releases
For 1.18, try Martin's remake: https://github.com/MartinTheDragon/Nuclear-Tech-Mod-Remake/releases
For 1.18, try Martin's remake: https://codeberg.org/MartinTheDragon/Nuclear-Tech-Mod-Remake/releases
## Downloading pre-compiled versions from GitHub
@ -94,6 +96,18 @@ If you want to make some changes to the mod, follow this guide:
## Compatibility notice
NTM has certain behaviors intended to fix vanilla code or to increase compatibility in certain cases where it otherwise would not be possible. These behaviors have the potential of not playing well with other mods, and while no such cases are currently known, here's a list of them.
### Thermos
Thermos servers (along with its forks such as Crucible) have a "performance" feature that causes all tile entity ticking to slow down if there's no player present in the same chunk. For obvious reasons, this will heavily impact machines and cause phantom issues that, not having knowledge of this "performance" feature, are near impossible to diagnose. By default, NTM will crash on servers running the Thermos base code and print a lengthy message informing server owners about this "performance" feature as well as how to fix the issues it causes. The error message is printed in plain English on the top of the crash log, failure to read (as well as understand) it will leave the server inoperable.
### Optifine
One of the most common "performance" mods on 1.7.10, Optifine, achieves an increase in performance by breaking small things in spots that are usually hard to notice, although this can cause severe issues with NTM. A short list of problems, along with some solutions, follows:
* Get rid of Optifine and use one of the many [other, less intrusive performance mods](https://gist.github.com/makamys/7cb74cd71d93a4332d2891db2624e17c).
* Blocks with connected textures may become invisible. This can be fixed by toggling triangulation (I do not know what or where this setting is, I just have been told that it exists and that it can fix the problem) or multicore chunk rendering (same here).
* Entity "optimization" has a tendency to break chunkloading, this is especially noticeable with missiles which rely heavily on chunkloading to work, causing them to freeze mid-air. It's unclear what setting might fix this, and analysis of Optifine's source code (or rather, lack thereof) has not proven useful either.
### Angelica
In older versions, Angelica caused issues regarding model rendering, often times making 3D models transparent. Ever since the switch to VBOs, models work fine. Another issue was blocks with connected textures not rendering at all, but this too was fixed, meaning as of time of writing there are no major incompatibilities known with Angelica.
### 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`.
@ -106,5 +120,14 @@ An often overlooked aspect of Minecraft is its stats, the game keeps track of ho
### Keybind overlap
An often annoying aspect of modded Minecraft is its keybinds. Even though multiple binds can be assigned the same key, all but one will show up as "conflicting" and only the non-conflicting one will work. Which one this is is usually arbitrary, and there is no reason to have such limitation. Often times keybinds are only applicable in certain scenarios, and a commonly found degree of overlap is within reason. Therefore, NTM will run its own key handling code which allows conflicting keybinds to work. If there should be any issues with this behavior, it can be disabled with the config option `1.34_enableKeybindOverlap`.
### Render distance capping
There is a common crash caused by Minecraft's render distance slider going out of bounds, this usually happens when uninstalling a mod that extends the render distance (like Optifine) or when downgrading the Minecraft version (newer versions have higher render distance caps). To prevent crashes, the mod will attempt to decrease the render distance if it's above 16 unless Optifine is installed. If this behavior is not desired (for example, because another mod that allows higher render distance is being used), it can be disabled with the config option `1.25_enableRenderDistCheck`.
### Log spam caused by ComparableStack
In some modpacks (exact mods needed to replicate this are unknown), it's possible that invalid registered items may cause problems for NEI handlers. To prevent crashes, the ComparableStack class used to represent stacks will default to a safe registered item, and print a log message. In certain situations, this may cause dozens of errors to be printed at once, potentially even lagging the game. If that happens, the log message (but not the error handling) can be disabled with the config option `1.28_enableSilentCompStackErrors`.
### Sound system limit
By default, the sound system only allows a limited amount of sounds to run at once (28 regular sounds and 4 streaming sounds), this causes issues when there's many machines running at once, since their looped sounds will constantly interrupt each other, causing them to immediately restart, which in some isolated cases has proven to cause massive lagspikes. To prevent this, NTM will increase the sound limit to 1000 regular sounds and 50 streaming sounds, this can be disabled with the config option `1.39_enableSoundExtension`.
# License
This software is licensed under the GNU Lesser General Public License version 3. In short: This software is free, you may run the software freely, create modified versions, distribute this software and distribute modified versions, as long as the modified software too has a free software license (with an exception for linking to this software, as stated by the "Lesser" part of the LGPL, where this may not be required). You win this round, Stallman. The full license can be found in the `LICENSE` and `LICENSE.LESSER` files.

View File

@ -1,54 +1,55 @@
## Added
* Doors!
* Your favorites from 1.12, the 7 remaining doors have finally been ported
* Thanks to KoblizekXD for biting the bullet
* Rubber boat
* Made from latex or synthetic rubber
* A much less jankier alternative to the vanilla boat. Rotations are silky smooth and done via the strafe keys instead of based on the player's orientation
* Won't break from ramming into blocks
* Faster than a regular boat, but will decelerate quicker when there's nobody sitting in it, preventing the boat from drifting off too far when empty
* Exposure chamber
* Now performs the particle transmutation recipes that were previously done in the crafting table
* Stylish as hell
* Decoy missile
* A cheap tier 1 missile that shows up on radar screens as tier 4 (eg. nuclear) missiles
* Printing press stamps
* 8 different stamps for printing certain pages
* If a meteor dungeon safe is generated without a black book inside, it will generate two random stamps instead
* With all 8 stamps, allows you to print your own black book
* New meteorite ores
* All previous meteorite ores have been removed (each took up an entire block ID...) which have been replaced with a single block that uses metadata
* There's now only five variants with the contents chosen to be especially useful in earlygame: iron, copper, aluminium, rare earth and cobalt
* Each ore smelts into 16 items, except for cobalt which yields only 4 ingots
* All meteorite ores are now equally likely to spawn
* The new ores can only be smelted, shredding or other processing is not possible
* ICF (WIP!)
* A new tier of fusion reactor that replaces the FWatz
* Powered by external lasers which are dynamic multiblocks, using fuel pellets
* Construction of lasers: Place a controller, then a straight line of cells behind it, surround those with flash tubes, those with capacitors and optionally those with turbochargers (not recommended as of now)
* Stuff left unfinished:
* Pellet creation and recycling
* Final balancing (especially for lasers and cooling)
* Uses for stellar flux
* Crafting and assembling
* Cooling this reactor is exceedingly difficult due to the limitations of heat exchangers and the relatively low heat capacitor of most available coolants, there will most likely be more powerful ICF-exclusive coolants in the future (liquid lead? sodium compounds?)
## Changed
* Reduced the blast resistance of the large doors from absurdly high to still very but not quite as high
* Custom missiles are now launchable using the radar
* NTM's structures should no longer spawn in dimensions besides the overworld. Ores will still generate, assuming the config option is set.
* Decreased M1tty's radiation resistance
* It's really damn cheap, what did you expect
* M1tty's helmet now acts like a protective mask
* Most non-custom missiles except tier 0s are now assembled in the arc welder
* Crafting complexity has been reduced, the recipes only need the three major components without any extra loose plates
* Non-custom missiles have been slightly buffed
* Explosions are now slightly larger and they use the new cross-detection entity damage code which still affects entities behind small hills that would otherwise be shielded
* Explosions now have a 2x larger entity damage radius
* Updated the digiminer recipe for mekanism compat
* Added config options to the ground water pumps
* Missile parts such as non-custom thrusters and fuselages are now made in the arc welder, recipe ingredients have been adjusted as well
* Null grenades now have a slightly larger radius, should no longer wipe playerdata and require UNDEFINED to make
* Added some breedable material to BFB PWR fuel rods, meaning that the recycling recipes now actually yield a net positive instead of being a massive waste of time
* The RBMK control panel has been upgraded
* Right.clicking the color buttons will now assign the color to the selected control rods
* There's now a new button that allows to cycle through compressor settings on RBMK steam channels
* The flux display is now functional. It will display the flux curve of the last 30 seconds, as well as labels for the total flux level.
* With the color assigning buttons and the flux display finished, the console is now finally complete
* Compressing blood at 4 PU now turns it into crude oil at a ratio of 2:1
* Increased the cap for the overdrive upgrade in acidizers, tier 2 should now yield the proper amount and tier 3 should now be better than tier 2
* The tooltip of valid upgrades now changes when a compatible machine GUI is open
* The Souyz' recipe is now available in the standard template folder
* Removed some unused crap
* UV lamps (2 IDs)
* AMS (9 IDs)
* Rotary engine (1 ID)
* FWatz (8 IDs)
* Meteorite ores (10 IDs)
* Tiny nuclear rector (1 ID)
* The small oil heaters are no longer craftable and the NEI handler has been removed, however existing ones can still be used
* The loot pool for meteorite treasure blocks has been updated
* Treasures are no longer senselessly progression breaking, radioactive or plain stupid (whole-ass machines inside meteorites)
* The treasure now consists of mainly some rarer earlygame ingots, circuits, some gear, a small selection of armor mods and alexandrite (rare)
* Schraranium processing now yields neptunium as a byproduct instead of plutonium, making neptunium easier to automate outside of the cyclotron
* Using the guide book now opens a link to the new wiki
* Certain earlygame things can now be recycled like stirling engines and gears
* Antenna part recycling has been moved to the anvil
* NTM's pickaxes now have a break speed bonus for glass
* Renamed the foundry slag outlet to foundry spill outlet because people always assume it's for slag and only slag (it is not)
* The description for heatable/coolable fluid tags is now written in the same line as the label
* Rubber can now be made from acidizing latex with sour gas (requires just 25mB)
* Heating oil can now be reformed into naphtha
* Coker naphtha can now also be reformed like the other naphtha types (yields refgas instead of petgas as a byproduct)
* Drainage pipes will now violently explode when voiding antimatter
* Seeding slurry can now place grass over dead grass
* Added an extra digit to the heat exchanger's configuration panel, allowing effective utilization of all 24,000mB per tick
## Fixed
* Fixed ancient bug where custom missiles launched using the launch table would not use the accuracy calculation and always be pin-point accurate
* Fixed RBMK heat exchangers being able to use heatable fluids that don't have heat exchanger efficiency defined like liquid sodium, heavy water and thorium salt
* Fixed RBMK heat exchangers not using the heat exchanger efficiency variable to determine cooling power
* Fixed the ballistic gauntlet spawning a client-side ghost bullet that doesn't move or despawn
* Fixed bug where different custom machine cores would merge in a stack when picked up, turning them into the same type
* Fixed radar screen blips being visible through the back of the model
* Fixed desh crate's last half of slots preventing radiation entirely
* Fixed large mining drill shift-clicking
* Fixed DFC receivers not outputting power
* Fixed the custom machine NEI handlers not working
* Fixed a potential crash caused by invalid assembly templates
* Fixed general weirdness with the schrabidium transmutator item IO
* Fixed certain tooltips using the backslash escape character despite not needing them
* Hopefully fixed the immense lag caused by tom post impact mechanics, burning grass will now only spread 20% of the time (instead of 100) and the world destruction handler will only process half the blocks per chunk
* Hopefully fixed an issue where substations would not reliably connect to cable blocks
* Fixed assembler rendering bugging out with Angelica installed and a door template loaded
* Fixed medium pylon localizations

View File

@ -1,19 +1,48 @@
mod_version=1.0.27
# Empty build number makes a release type
mod_build_number=4809
mod_build_number=4942
credits=HbMinecraft, rodolphito (explosion algorithms), grangerave (explosion algorithms),\
\ Hoboy (textures, models), Doctor17 (russian localization), Drillgon200 (effects, models,\
\ porting), UFFR (RTGs, guns, casings, euphemium capacitor), Pu-238 (Tom impact effects), Bismarck\
\ (chinese localization), Frooz (models), Minecreep (models), VT-6/24 (models, textures), Pheo (textures,\
\ various machines, models, weapons), Vær (gas centrifuges, better worldgen, ZIRNOX, CP-1 parts, starter guide),\
\ Adam29 (liquid petroleum, ethanol, electric furnace), Pashtet (russian localization), MartinTheDragon\
\ (calculator, chunk-based fallout, bendable cranes, pipe improvements), haru315 (spiral point algorithm),\
\ Sten89 (models), Pixelguru26 (textures), TheBlueHat (textures), Alcater (GUI textures, porting), impbk2002\
\ (project settings), Nos (models), Burningwater202 (laminate glass), OvermindDL1 (project settings), TehTemmie\
\ (reacher radiation function), Toshayo (satellite loot system, project settings, gradle curse task), Silly541\
\ (config for safe ME drives), Voxelstice (OpenComputers integration, turbine spinup), BallOfEnergy1\
\ (OpenComputers integration), martemen (project settings), Pvndols (thorium fuel recipe, gas turbine),\
\ JamesH2 (blood mechanics, nitric acid, particle emitter), sdddddf80 (recipe configs, chinese localization,\
\ custom machine holograms, I18n improvements), SuperCraftAlex (tooltips) LePeep (coilgun model, BDCL QC),\
\ 70k (textures), Maksymisio (polish localization) Ice-Arrow (research reactor tweaks)
credits=HbMinecraft,\
\ rodolphito (explosion algorithms),\
\ grangerave (explosion algorithms),\
\ Hoboy (textures, models),\
\ Drillgon200 (effects, models, porting),\
\ MartinTheDragon (calculator, chunk-based fallout, bendable cranes, pipe improvements, PWR sounds),\
\ Alcater (GUI textures, porting),\
\ MellowArpeggiation (new animation system, turbine sounds, sound fixes, industrial lights, better particle diodes),\
\ Pheo (textures, various machines, models, weapons),\
\ Vær (gas centrifuges, better worldgen, ZIRNOX, CP-1 parts, starter guide),\
\ LePeep (coilgun model, BDCL QC),\
\ Adam29 (liquid petroleum, ethanol, electric furnace),\
\ Pvndols (thorium fuel recipe, gas turbine),\
\ JamesH2 (blood mechanics, nitric acid, particle emitter),\
\ Doctor17 (russian localization)),\
\ Pashtet (russian localization),\
\ Bismarck (chinese localization),\
\ Maksymisio (polish localization)\
\ Pu-238 (Tom impact effects),\
\ UFFR (RTGs, guns, casings, euphemium capacitor),\
\ Frooz (models),\
\ VT-6/24 (models, textures),\
\ Nos (models),\
\ Minecreep (models),\
\ 70k (textures, glyphid AI, strand caster),\
\ haru315 (spiral point algorithm),\
\ Sten89 (models),\
\ Pixelguru26 (textures),\
\ TheBlueHat (textures),\
\ Burningwater202 (laminate glass),\
\ TehTemmie (reacher radiation function),\
\ Silly541 (config for safe ME drives),\
\ Voxelstice (OpenComputers integration, turbine spinup),\
\ BallOfEnergy1 (OpenComputers integration),\
\ martemen (project settings),\
\ sdddddf80 (recipe configs, chinese localization, custom machine holograms),\
\ SuperCraftAlex (tooltips)\
\ Ice-Arrow (research reactor tweaks),\
\ 245tt (anvil GUI improvements),\
\ KoblizekXD (doors),\
\ FOlkvangrField (custom machine parts),\
\ Toshayo (satellite loot system, project settings, gradle curse task),\
\ OvermindDL1 (project settings),\
\ impbk2002 (project settings),\

BIN
ntm-animator.blend Normal file

Binary file not shown.

View File

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

View File

@ -1,121 +0,0 @@
package api.hbm.energy;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/**
* For anything that connects to power and can be transferred power to, the bottom-level interface.
* This is mean for TILE ENTITIES
* @author hbm
*/
public interface IEnergyConnector extends ILoadedTile {
/**
* Returns the amount of power that remains in the source after transfer
* @param power
* @return
*/
public long transferPower(long power);
/**
* Whether the given side can be connected to
* dir refers to the side of this block, not the connecting block doing the check
* @param dir
* @return
*/
public default boolean canConnect(ForgeDirection dir) {
return dir != ForgeDirection.UNKNOWN;
}
/**
* The current power of either the machine or an entire network
* @return
*/
public long getPower();
/**
* The capacity of either the machine or an entire network
* @return
*/
public long getMaxPower();
public default long getTransferWeight() {
return Math.max(getMaxPower() - getPower(), 0);
}
/**
* Basic implementation of subscribing to a nearby power grid
* @param world
* @param x
* @param y
* @param z
*/
public default void trySubscribe(World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = world.getTileEntity(x, y, z);
boolean red = false;
if(te instanceof IEnergyConductor) {
IEnergyConductor con = (IEnergyConductor) te;
if(!con.canConnect(dir.getOpposite()))
return;
if(con.getPowerNet() != null && !con.getPowerNet().isSubscribed(this))
con.getPowerNet().subscribe(this);
if(con.getPowerNet() != null)
red = true;
}
if(particleDebug) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "network");
data.setString("mode", "power");
double posX = x + 0.5 + dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posY = y + 0.5 + dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posZ = z + 0.5 + dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
data.setDouble("mX", -dir.offsetX * (red ? 0.025 : 0.1));
data.setDouble("mY", -dir.offsetY * (red ? 0.025 : 0.1));
data.setDouble("mZ", -dir.offsetZ * (red ? 0.025 : 0.1));
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
}
}
public default void tryUnsubscribe(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof IEnergyConductor) {
IEnergyConductor con = (IEnergyConductor) te;
if(con.getPowerNet() != null && con.getPowerNet().isSubscribed(this))
con.getPowerNet().unsubscribe(this);
}
}
public static final boolean particleDebug = false;
public default Vec3 getDebugParticlePos() {
TileEntity te = (TileEntity) this;
Vec3 vec = Vec3.createVectorHelper(te.xCoord + 0.5, te.yCoord + 1, te.zCoord + 0.5);
return vec;
}
public default ConnectionPriority getPriority() {
return ConnectionPriority.NORMAL;
}
public enum ConnectionPriority {
LOW,
NORMAL,
HIGH
}
}

View File

@ -1,19 +0,0 @@
package api.hbm.energy;
public interface IEnergyGenerator extends IEnergyUser {
/**
* Standard implementation for machines that can only send energy but never receive it.
* @param power
*/
@Override
public default long transferPower(long power) {
return power;
}
/* should stop making non-receivers from interfering by applying their weight which doesn't even matter */
@Override
public default long getTransferWeight() {
return 0;
}
}

View File

@ -1,114 +0,0 @@
package api.hbm.energy;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/**
* For machines and things that have an energy buffer and are affected by EMPs
* @author hbm
*/
public interface IEnergyUser extends IEnergyConnector {
/**
* Not to be used for actual energy transfer, rather special external things like EMPs and sync packets
*/
public void setPower(long power);
/**
* Standard implementation for power transfer.
* Turns out you can override interfaces to provide a default implementation. Neat.
* @param long power
*/
@Override
public default long transferPower(long power) {
if(this.getPower() + power > this.getMaxPower()) {
long overshoot = this.getPower() + power - this.getMaxPower();
this.setPower(this.getMaxPower());
return overshoot;
}
if(this.getPower() + power < 0) return 0; //safeguard for negative energy or overflows
this.setPower(this.getPower() + power);
return 0;
}
/**
* Standard implementation of sending power
* @param world
* @param x
* @param y
* @param z
* @param dir
*/
public default void sendPower(World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = world.getTileEntity(x, y, z);
boolean wasSubscribed = false;
boolean red = false;
// first we make sure we're not subscribed to the network that we'll be supplying
if(te instanceof IEnergyConductor) {
IEnergyConductor con = (IEnergyConductor) te;
if(con.canConnect(dir.getOpposite()) && con.getPowerNet() != null && con.getPowerNet().isSubscribed(this)) {
con.getPowerNet().unsubscribe(this);
wasSubscribed = true;
}
}
//then we add energy
if(te instanceof IEnergyConnector) {
IEnergyConnector con = (IEnergyConnector) te;
if(con.canConnect(dir.getOpposite())) {
long oldPower = this.getPower();
long transfer = oldPower - con.transferPower(oldPower);
this.setPower(oldPower - transfer);
red = true;
}
}
//then we subscribe if possible
if(wasSubscribed && te instanceof IEnergyConductor) {
IEnergyConductor con = (IEnergyConductor) te;
if(con.getPowerNet() != null && !con.getPowerNet().isSubscribed(this)) {
con.getPowerNet().subscribe(this);
}
}
if(particleDebug) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "network");
data.setString("mode", "power");
double posX = x + 0.5 - dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posY = y + 0.5 - dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posZ = z + 0.5 - dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
data.setDouble("mX", dir.offsetX * (red ? 0.025 : 0.1));
data.setDouble("mY", dir.offsetY * (red ? 0.025 : 0.1));
data.setDouble("mZ", dir.offsetZ * (red ? 0.025 : 0.1));
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
}
}
public default void updateStandardConnections(World world, TileEntity te) {
updateStandardConnections(world, te.xCoord, te.yCoord, te.zCoord);
}
public default void updateStandardConnections(World world, int x, int y, int z) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
this.trySubscribe(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir);
}
}
}

View File

@ -1,37 +0,0 @@
package api.hbm.energy;
import java.math.BigInteger;
import java.util.List;
/**
* Not mandatory to use, but making your cables IPowerNet-compliant will allow them to connect to NTM cables.
* Cables will still work without it as long as they implement IEnergyConductor (or even IEnergyConnector) + self-built network code
* @author hbm
*/
public interface IPowerNet {
public void joinNetworks(IPowerNet network);
public IPowerNet joinLink(IEnergyConductor conductor);
public void leaveLink(IEnergyConductor conductor);
public void subscribe(IEnergyConnector connector);
public void unsubscribe(IEnergyConnector connector);
public boolean isSubscribed(IEnergyConnector connector);
public void destroy();
/**
* When a link is removed, instead of destroying the network, causing it to be recreated from currently loaded conductors,
* we re-evaluate it, creating new nets based on the previous links.
*/
public void reevaluate();
public boolean isValid();
public List<IEnergyConductor> getLinks();
public List<IEnergyConnector> getSubscribers();
public long transferPower(long power);
public BigInteger getTotalTransfer();
}

View File

@ -1,248 +0,0 @@
package api.hbm.energy;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.hbm.config.GeneralConfig;
import api.hbm.energy.IEnergyConnector.ConnectionPriority;
import net.minecraft.tileentity.TileEntity;
/**
* Basic IPowerNet implementation. The behavior of this demo might change inbetween releases, but the API remains the same.
* For more consistency please implement your own IPowerNet.
* @author hbm
*/
public class PowerNet implements IPowerNet {
private boolean valid = true;
private HashMap<Integer, IEnergyConductor> links = new HashMap();
private HashMap<Integer, Integer> proxies = new HashMap();
private List<IEnergyConnector> subscribers = new ArrayList();
public static List<PowerNet> trackingInstances = null;
protected BigInteger totalTransfer = BigInteger.ZERO;
@Override
public void joinNetworks(IPowerNet network) {
if(network == this)
return; //wtf?!
for(IEnergyConductor conductor : network.getLinks()) {
joinLink(conductor);
}
network.getLinks().clear();
for(IEnergyConnector connector : network.getSubscribers()) {
this.subscribe(connector);
}
network.destroy();
}
@Override
public IPowerNet joinLink(IEnergyConductor conductor) {
if(conductor.getPowerNet() != null)
conductor.getPowerNet().leaveLink(conductor);
conductor.setPowerNet(this);
int identity = conductor.getIdentity();
this.links.put(identity, conductor);
if(conductor.hasProxies()) {
for(Integer i : conductor.getProxies()) {
this.proxies.put(i, identity);
}
}
return this;
}
@Override
public void leaveLink(IEnergyConductor conductor) {
conductor.setPowerNet(null);
int identity = conductor.getIdentity();
this.links.remove(identity);
if(conductor.hasProxies()) {
for(Integer i : conductor.getProxies()) {
this.proxies.remove(i);
}
}
}
@Override
public void subscribe(IEnergyConnector connector) {
this.subscribers.add(connector);
}
@Override
public void unsubscribe(IEnergyConnector connector) {
this.subscribers.remove(connector);
}
@Override
public boolean isSubscribed(IEnergyConnector connector) {
return this.subscribers.contains(connector);
}
@Override
public List<IEnergyConductor> getLinks() {
List<IEnergyConductor> linkList = new ArrayList();
linkList.addAll(this.links.values());
return linkList;
}
public HashMap<Integer, Integer> getProxies() {
HashMap<Integer, Integer> proxyCopy = new HashMap(proxies);
return proxyCopy;
}
@Override
public List<IEnergyConnector> getSubscribers() {
return this.subscribers;
}
@Override
public void destroy() {
this.valid = false;
this.subscribers.clear();
for(IEnergyConductor link : this.links.values()) {
link.setPowerNet(null);
}
this.links.clear();
}
@Override
public boolean isValid() {
return this.valid;
}
@Override
public BigInteger getTotalTransfer() {
return this.totalTransfer;
}
public long lastCleanup = System.currentTimeMillis();
@Override
public long transferPower(long power) {
/*if(lastCleanup + 45 < System.currentTimeMillis()) {
cleanup(this.subscribers);
lastCleanup = System.currentTimeMillis();
}*/
trackingInstances = new ArrayList();
trackingInstances.add(this);
return fairTransfer(this.subscribers, power);
}
public static void cleanup(List<IEnergyConnector> subscribers) {
subscribers.removeIf(x ->
x == null || !(x instanceof TileEntity) || ((TileEntity)x).isInvalid() || !x.isLoaded()
);
}
public static long fairTransfer(List<IEnergyConnector> subscribers, long power) {
if(power <= 0) return 0;
if(subscribers.isEmpty())
return power;
cleanup(subscribers);
ConnectionPriority[] priorities = new ConnectionPriority[] {ConnectionPriority.HIGH, ConnectionPriority.NORMAL, ConnectionPriority.LOW};
long totalTransfer = 0;
for(ConnectionPriority p : priorities) {
List<IEnergyConnector> subList = new ArrayList();
subscribers.forEach(x -> {
if(x.getPriority() == p) {
subList.add(x);
}
});
if(subList.isEmpty())
continue;
List<Long> weight = new ArrayList();
long totalReq = 0;
for(IEnergyConnector con : subList) {
long req = con.getTransferWeight();
weight.add(req);
totalReq += req;
}
if(totalReq == 0)
continue;
long totalGiven = 0;
for(int i = 0; i < subList.size(); i++) {
IEnergyConnector con = subList.get(i);
long req = weight.get(i);
double fraction = (double)req / (double)totalReq;
long given = (long) Math.floor(fraction * power);
totalGiven += (given - con.transferPower(given));
if(con instanceof TileEntity) {
TileEntity tile = (TileEntity) con;
tile.getWorldObj().markTileEntityChunkModified(tile.xCoord, tile.yCoord, tile.zCoord, tile);
}
}
power -= totalGiven;
totalTransfer += totalGiven;
}
if(trackingInstances != null) {
for(int i = 0; i < trackingInstances.size(); i++) {
PowerNet net = trackingInstances.get(i);
net.totalTransfer = net.totalTransfer.add(BigInteger.valueOf(totalTransfer));
}
}
return power;
}
@Override
public void reevaluate() {
if(!GeneralConfig.enableReEval) {
this.destroy();
return;
}
HashMap<Integer, IEnergyConductor> copy = new HashMap(links);
HashMap<Integer, Integer> proxyCopy = new HashMap(proxies);
for(IEnergyConductor link : copy.values()) {
this.leaveLink(link);
}
for(IEnergyConductor link : copy.values()) {
link.setPowerNet(null);
link.reevaluate(copy, proxyCopy);
if(link.getPowerNet() == null) {
link.setPowerNet(new PowerNet().joinLink(link));
}
}
}
}

View File

@ -1,4 +1,4 @@
package api.hbm.energy;
package api.hbm.energymk2;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,108 @@
package api.hbm.energymk2;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import api.hbm.energymk2.Nodespace.PowerNode;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/** If it receives energy, use this */
public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 {
public default long transferPower(long power) {
if(power + this.getPower() <= this.getMaxPower()) {
this.setPower(power + this.getPower());
return 0;
}
long capacity = this.getMaxPower() - this.getPower();
long overshoot = power - capacity;
this.setPower(this.getMaxPower());
return overshoot;
}
public default long getReceiverSpeed() {
return this.getMaxPower();
}
public default void trySubscribe(World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = world.getTileEntity(x, y, z);
boolean red = false;
if(te instanceof IEnergyConductorMK2) {
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
if(!con.canConnect(dir.getOpposite())) return;
PowerNode node = Nodespace.getNode(world, x, y, z);
if(node != null && node.net != null) {
node.net.addReceiver(this);
red = true;
}
}
if(particleDebug) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "network");
data.setString("mode", "power");
double posX = x + 0.5 + dir.offsetX * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posY = y + 0.5 + dir.offsetY * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
double posZ = z + 0.5 + dir.offsetZ * 0.5 + world.rand.nextDouble() * 0.5 - 0.25;
data.setDouble("mX", -dir.offsetX * (red ? 0.025 : 0.1));
data.setDouble("mY", -dir.offsetY * (red ? 0.025 : 0.1));
data.setDouble("mZ", -dir.offsetZ * (red ? 0.025 : 0.1));
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, posX, posY, posZ), new TargetPoint(world.provider.dimensionId, posX, posY, posZ, 25));
}
}
public default void tryUnsubscribe(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof IEnergyConductorMK2) {
IEnergyConductorMK2 con = (IEnergyConductorMK2) te;
PowerNode node = con.createNode();
if(node != null && node.net != null) {
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 {
LOWEST,
LOW,
NORMAL,
HIGH,
HIGHEST
}
}

View File

@ -0,0 +1,193 @@
package api.hbm.energymk2;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import net.minecraft.server.MinecraftServer;
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
* @author hbm
*
*/
public class Nodespace {
/** Contains all "NodeWorld" instances, i.e. lists of nodes existing per world */
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) {
NodeWorld nodeWorld = worlds.get(world);
if(nodeWorld != null) return nodeWorld.nodes.get(new BlockPos(x, y, z));
return null;
}
public static void createNode(World world, PowerNode node) {
NodeWorld nodeWorld = worlds.get(world);
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) {
PowerNode node = getNode(world, x, y, z);
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);
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 static 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.
* I don't know why. But for some reason, during neighbor checks, on certain arbitrary fucking places, the joining operation just fails.
* Disallowing nodes to create new networks fixed the problem completely, which is hardly surprising since they wouldn't be able to make
* a new net anyway and they will re-check neighbors until a net is found, so the solution is tautological in nature. So I tried limiting
* creation of new networks. Didn't work. So what's there left to do? Hand out a mark to any node that has changed networks, and let those
* recently modified nodes do another re-check. This creates a second layer of redundant operations, and in theory doubles (in practice,
* it might be an extra 20% due to break-off section sizes) the amount of CPU time needed for re-building the networks after joining or
* breaking, but it seems to allow those parts to connect back to their neighbor nets as they are supposed to. I am not proud of this solution,
* this issue shouldn't exist to begin with and I am going fucking insane but it is what it is.
*/
public boolean recentlyChanged = true;
public PowerNode(BlockPos... positions) {
this.positions = positions;
}
public PowerNode setConnections(DirPos... connections) {
this.connections = connections;
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

@ -0,0 +1,349 @@
package api.hbm.energymk2;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import com.hbm.util.Tuple.Pair;
import java.util.Map.Entry;
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
import api.hbm.energymk2.Nodespace.PowerNode;
public class PowerNetMK2 {
public boolean valid = true;
public Set<PowerNode> links = new HashSet();
/** 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 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;
public void transferPower() {
if(providerEntries.isEmpty()) return;
if(receiverEntries.isEmpty()) return;
long timestamp = System.currentTimeMillis();
long transferCap = 100_000_000_000_000_00L;
List<Pair<IEnergyProviderMK2, Long>> providers = new ArrayList();
long powerAvailable = 0;
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; }
long src = Math.min(entry.getKey().getPower(), entry.getKey().getProviderSpeed());
providers.add(new Pair(entry.getKey(), src));
if(powerAvailable < transferCap) powerAvailable += src;
}
powerAvailable = Math.min(powerAvailable, transferCap);
List<Pair<IEnergyReceiverMK2, Long>>[] receivers = new ArrayList[ConnectionPriority.values().length];
for(int i = 0; i < receivers.length; i++) receivers[i] = new ArrayList();
long[] demand = new long[ConnectionPriority.values().length];
long totalDemand = 0;
Iterator<Entry<IEnergyReceiverMK2, Long>> recIt = receiverEntries.entrySet().iterator();
while(recIt.hasNext()) {
Entry<IEnergyReceiverMK2, Long> entry = recIt.next();
if(timestamp - entry.getValue() > timeout) { recIt.remove(); continue; }
long rec = Math.min(entry.getKey().getMaxPower() - entry.getKey().getPower(), entry.getKey().getReceiverSpeed());
int p = entry.getKey().getPriority().ordinal();
receivers[p].add(new Pair(entry.getKey(), rec));
demand[p] += rec;
totalDemand += rec;
}
long toTransfer = Math.min(powerAvailable, totalDemand);
long energyUsed = 0;
for(int i = ConnectionPriority.values().length - 1; i >= 0; i--) {
List<Pair<IEnergyReceiverMK2, Long>> list = receivers[i];
long priorityDemand = demand[i];
for(Pair<IEnergyReceiverMK2, Long> entry : list) {
double weight = (double) entry.getValue() / (double) (priorityDemand);
long toSend = (long) Math.max(toTransfer * weight, 0D);
energyUsed += (toSend - entry.getKey().transferPower(toSend)); //leftovers are subtracted from the intended amount to use up
}
toTransfer -= energyUsed;
}
this.energyTracker += energyUsed;
for(Pair<IEnergyProviderMK2, Long> entry : providers) {
double weight = (double) entry.getValue() / (double) powerAvailable;
long toUse = (long) Math.max(energyUsed * weight, 0D);
entry.getKey().usePower(toUse);
}
}
@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) {
if(receiverEntries.isEmpty()) return power;
long timestamp = System.currentTimeMillis();
List<Pair<IEnergyReceiverMK2, Long>>[] receivers = new ArrayList[ConnectionPriority.values().length];
for(int i = 0; i < receivers.length; i++) receivers[i] = new ArrayList();
long[] demand = new long[ConnectionPriority.values().length];
long totalDemand = 0;
Iterator<Entry<IEnergyReceiverMK2, Long>> recIt = receiverEntries.entrySet().iterator();
while(recIt.hasNext()) {
Entry<IEnergyReceiverMK2, Long> entry = recIt.next();
if(timestamp - entry.getValue() > timeout) { recIt.remove(); continue; }
long rec = Math.min(entry.getKey().getMaxPower() - entry.getKey().getPower(), entry.getKey().getReceiverSpeed());
int p = entry.getKey().getPriority().ordinal();
receivers[p].add(new Pair(entry.getKey(), rec));
demand[p] += rec;
totalDemand += rec;
}
long toTransfer = Math.min(power, totalDemand);
long energyUsed = 0;
for(int i = ConnectionPriority.values().length - 1; i >= 0; i--) {
List<Pair<IEnergyReceiverMK2, Long>> list = receivers[i];
long priorityDemand = demand[i];
for(Pair<IEnergyReceiverMK2, Long> entry : list) {
double weight = (double) entry.getValue() / (double) (priorityDemand);
long toSend = (long) Math.max(toTransfer * weight, 0D);
energyUsed += (toSend - entry.getKey().transferPower(toSend)); //leftovers are subtracted from the intended amount to use up
}
toTransfer -= energyUsed;
}
this.energyTracker += energyUsed;
return power - energyUsed;
}
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,33 @@
/**
*
*/
/**
* @author hbm
*
*/
package api.hbm.energymk2;
// i have snorted two lines of pure caffeine and taken one large paracetamol laced with even more caffine, let's fucking go
//most of the new classes are just copy pasted mashed up shit from yesteryear, what a productive segment that was
/*
before my caffine high ends entirely and i black out, here's the gist:
* diodes are handled like energy receiver and simply chain-load the power net they output into in a recursive function, this might be a bit laggy compared to the rest of the system, but it's still way less laggy than the old one
* instead of power nets being bound to tile entities directly, tiles spawn ethereal "nodes" similar to the drone waypoints which can be saved using world data, meaning that breaking cables will delete nodes, but unloading them will keep them alive in "node space" which is what's actually used to check for connections
* power nets may cache some positional info in order to limit the amount of nodes, this should prevent horrific freezes in the unlikely event that some retard makes a superflat world out of cables
* general energy transmission will work in a similar fashion as martin explained his, but somewhat simplified; the system will determine supply and demand and then split those evenly if possible, retrying within one operation is only necessary for minor restrictions like priority, any leftovers from rounding don't have to be re-tried because the next tick will already take care of that
* invest funds in more coal mare nudes
* battery "fair share" transfer will most likely no longer work, but that's not really as relevant these days considering there's capacitors and because batteries have transfer speed limits anyway
* most of the machine's functions will be repurposed, the "sendPower" method will no longer send power directly but register the machine to the network as a power source
* if all else fails and martin still hasn't surrendered his code, i will beg greg for his wisdom (but without loss or tiering because fuck that)
*
* | | ||
* ____|____
* |
* || | |_
*
* ...i said WITHOUT loss
*/

View File

@ -14,4 +14,8 @@ public interface IFillableItem {
public boolean providesFluid(FluidType type, ItemStack stack);
/** Provides fluid with the maximum being the requested amount */
public int tryEmpty(FluidType type, int amount, ItemStack stack);
/** Returns the first (or only) corrently held type, may return null. Currently only used for setting bedrock ores */
public FluidType getFirstFluidType(ItemStack stack);
/** Returns the fillstate for the specified fluid. Currently only used for setting bedrock ores */
public int getFill(ItemStack stack);
}

View File

@ -4,13 +4,14 @@ import com.hbm.inventory.fluid.FluidType;
import com.hbm.packet.AuxParticlePacketNT;
import com.hbm.packet.PacketDispatcher;
import api.hbm.tile.ILoadedTile;
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 IFluidConnector {
public interface IFluidConnector extends ILoadedTile {
/**
* Returns the amount of fluid that remains

View File

@ -90,9 +90,9 @@ public class PipeNet implements IPipeNet {
@Override
public long transferFluid(long fill, int pressure) {
this.subscribers.removeIf(x ->
x == null || !(x instanceof TileEntity) || ((TileEntity)x).isInvalid()
subscribers.removeIf(x ->
x == null || !(x instanceof TileEntity) || ((TileEntity)x).isInvalid() || !x.isLoaded()
);
if(this.subscribers.isEmpty())

View File

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

View File

@ -1,4 +1,4 @@
package api.hbm.energy;
package api.hbm.tile;
public interface ILoadedTile {

View File

@ -36,7 +36,6 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
public BlockDummyable(Material mat) {
super(mat);
this.maxY = 0.999D; //item bounce prevention
this.setTickRandomly(true);
}

View File

@ -36,7 +36,7 @@ public class BlockEnumMulti extends BlockMulti {
for(int i = 0; i < icons.length; i++) {
Enum num = enums[i];
this.icons[i] = reg.registerIcon(this.getTextureName() + "." + num.name().toLowerCase(Locale.US));
this.icons[i] = reg.registerIcon(this.getTextureMultiName(num));
}
} else {
this.blockIcon = reg.registerIcon(this.getTextureName());
@ -47,12 +47,20 @@ public class BlockEnumMulti extends BlockMulti {
if(this.multiName) {
Enum num = EnumUtil.grabEnumSafely(this.theEnum, stack.getItemDamage());
return super.getUnlocalizedName() + "." + num.name().toLowerCase(Locale.US);
return getUnlocalizedMultiName(num);
}
return this.getUnlocalizedName();
}
public String getTextureMultiName(Enum num) {
return this.getTextureName() + "." + num.name().toLowerCase(Locale.US);
}
public String getUnlocalizedMultiName(Enum num) {
return super.getUnlocalizedName() + "." + num.name().toLowerCase(Locale.US);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {

View File

@ -11,6 +11,14 @@ public class BlockEnums {
BAUXITE
}
public static enum EnumMeteorType {
IRON,
COPPER,
ALUMINIUM,
RAREEARTH,
COBALT
}
public static enum EnumBiomeType {
DESERT,
WOODLAND
@ -58,4 +66,10 @@ public class BlockEnums {
GREEN,
STEEL
}
public static enum LightType {
INCANDESCENT,
FLUORESCENT,
HALOGEN
}
}

View File

@ -3,10 +3,12 @@ package com.hbm.blocks;
import java.util.ArrayList;
import java.util.Random;
import com.hbm.lib.RefStrings;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
@ -21,12 +23,16 @@ public class BlockRemap extends Block implements ILookOverlay {
this.remapMeta = meta;
this.setTickRandomly(true);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int meta, int side) {
return this.remapBlock.getIcon(meta, side);
}
@Override
public Block setBlockName(String name) {
super.setBlockName(name);
this.setBlockTextureName(RefStrings.MODID + ":" + name);
return this;
public Item getItemDropped(int meta, Random rand, int fortune) {
return this.remapBlock.getItemDropped(meta, rand, fortune);
}
@Override

View File

@ -11,4 +11,7 @@ public interface IBlockMultiPass {
return renderID;
}
public default boolean shouldRenderItemMulti() {
return false;
}
}

View File

@ -0,0 +1,6 @@
package com.hbm.blocks;
public interface ISpotlight {
public int getBeamLength();
}

File diff suppressed because it is too large Load Diff

View File

@ -7,8 +7,10 @@ import static net.minecraftforge.common.util.ForgeDirection.SOUTH;
import static net.minecraftforge.common.util.ForgeDirection.UP;
import static net.minecraftforge.common.util.ForgeDirection.WEST;
import java.awt.Color;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.potion.HbmPotion;
import cpw.mods.fml.relauncher.Side;
@ -25,193 +27,146 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class Balefire extends BlockFire {
private IIcon icon;
public Balefire() {
super();
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
icon = register.registerIcon(this.getTextureName());
}
@SideOnly(Side.CLIENT)
public IIcon getFireIcon(int i) {
return icon;
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return icon;
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
if(world.getGameRules().getGameRuleBooleanValue("doFireTick")) {
if(!this.canPlaceBlockAt(world, x, y, z)) {
world.setBlockToAir(x, y, z);
}
int meta = world.getBlockMetadata(x, y, z);
if(meta < 15) world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world) + rand.nextInt(10));
if(!this.canNeighborBurn(world, x, y, z) && !World.doesBlockHaveSolidTopSurface(world, x, y - 1, z)) {
world.setBlockToAir(x, y, z);
} else {
if(meta < 15) {
this.tryCatchFire(world, x + 1, y, z, 500, rand, meta, WEST);
this.tryCatchFire(world, x - 1, y, z, 500, rand, meta, EAST);
this.tryCatchFire(world, x, y - 1, z, 300, rand, meta, UP);
this.tryCatchFire(world, x, y + 1, z, 300, rand, meta, DOWN);
this.tryCatchFire(world, x, y, z - 1, 500, rand, meta, SOUTH);
this.tryCatchFire(world, x, y, z + 1, 500, rand, meta, NORTH);
int h = 3;
for(int ix = x - h; ix <= x + h; ++ix) {
for(int iz = z - h; iz <= z + h; ++iz) {
for(int iy = y - 1; iy <= y + 4; ++iy) {
if(ix != x || iy != y || iz != z) {
int fireLimit = 100;
if(iy > y + 1) {
fireLimit += (iy - (y + 1)) * 100;
}
if(world.getBlock(ix, iy, iz) == ModBlocks.balefire && world.getBlockMetadata(ix, iy, iz) > meta + 1) {
world.setBlock(ix, iy, iz, this, meta + 1, 3);
continue;
}
int neighborFireChance = this.getChanceOfNeighborsEncouragingFire(world, ix, iy, iz);
if(neighborFireChance > 0) {
int adjustedFireChance = (neighborFireChance + 40 + world.difficultySetting.getDifficultyId() * 7) / (meta + 30);
if(adjustedFireChance > 0 && rand.nextInt(fireLimit) <= adjustedFireChance) {
world.setBlock(ix, iy, iz, this, meta + 1, 3);
}
}
}
}
}
}
}
}
}
}
private void tryCatchFire(World world, int x, int y, int z, int chance, Random rand, int fireMetadata, ForgeDirection face) {
int flammability = world.getBlock(x, y, z).getFlammability(world, x, y, z, face);
if(rand.nextInt(chance) < flammability) {
boolean flag = world.getBlock(x, y, z) == Blocks.tnt;
world.setBlock(x, y, z, this, fireMetadata + 1, 3);
if(flag) {
Blocks.tnt.onBlockDestroyedByPlayer(world, x, y, z, 1);
}
}
}
private boolean canNeighborBurn(World world, int x, int y, int z) {
return this.canCatchFire(world, x + 1, y, z, WEST)
|| this.canCatchFire(world, x - 1, y, z, EAST)
|| this.canCatchFire(world, x, y - 1, z, UP)
|| this.canCatchFire(world, x, y + 1, z, DOWN)
|| this.canCatchFire(world, x, y, z - 1, SOUTH)
|| this.canCatchFire(world, x, y, z + 1, NORTH);
}
private int getChanceOfNeighborsEncouragingFire(World world, int x, int y, int z) {
if(!world.isAirBlock(x, y, z)) {
return 0;
} else {
int spread = 0;
spread = this.getChanceToEncourageFire(world, x + 1, y, z, spread, WEST);
spread = this.getChanceToEncourageFire(world, x - 1, y, z, spread, EAST);
spread = this.getChanceToEncourageFire(world, x, y - 1, z, spread, UP);
spread = this.getChanceToEncourageFire(world, x, y + 1, z, spread, DOWN);
spread = this.getChanceToEncourageFire(world, x, y, z - 1, spread, SOUTH);
spread = this.getChanceToEncourageFire(world, x, y, z + 1, spread, NORTH);
return spread;
}
}
@Override
public boolean canCatchFire(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return world.getBlock(x, y, z).isFlammable(world, x, y, z, face);
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
entity.setFire(10);
if(entity instanceof EntityLivingBase) ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(HbmPotion.radiation.id, 5 * 20, 9));
}
private IIcon field_149850_M;
public Balefire()
{
super();
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_) {
field_149850_M = p_149651_1_.registerIcon(this.getTextureName());
}
@SideOnly(Side.CLIENT)
public IIcon getFireIcon(int p_149840_1_)
{
return field_149850_M;
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int p_149691_2_)
{
return field_149850_M;
}
public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
{
if (p_149674_1_.getGameRules().getGameRuleBooleanValue("doFireTick"))
{
boolean flag = p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).isFireSource(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, UP);
if (!this.canPlaceBlockAt(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
{
p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
}
/*if (!flag && p_149674_1_.isRaining() && (p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_ - 1, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_ + 1, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_ - 1) || p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_ + 1)))
{
p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
}
else*/
{
int l = 0;
/*int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
if (l < 15)
{
p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l + p_149674_5_.nextInt(3) / 2, 4);
}*/
p_149674_1_.scheduleBlockUpdate(p_149674_2_, p_149674_3_, p_149674_4_, this, this.tickRate(p_149674_1_) + p_149674_5_.nextInt(10));
if (!flag && !this.canNeighborBurn(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
{
if (!World.doesBlockHaveSolidTopSurface(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_)/* || l > 3*/)
{
p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
}
}
/*else if (!flag && !this.canCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, UP) && l == 15 && p_149674_5_.nextInt(4) == 0)
{
//p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
}*/
else
{
//boolean flag1 = p_149674_1_.isBlockHighHumidity(p_149674_2_, p_149674_3_, p_149674_4_);
byte b0 = 0;
/*if (flag1)
{
b0 = -50;
}*/
this.tryCatchFire(p_149674_1_, p_149674_2_ + 1, p_149674_3_, p_149674_4_, 300 + b0, p_149674_5_, l, WEST );
this.tryCatchFire(p_149674_1_, p_149674_2_ - 1, p_149674_3_, p_149674_4_, 300 + b0, p_149674_5_, l, EAST );
this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, 250 + b0, p_149674_5_, l, UP );
this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_, 250 + b0, p_149674_5_, l, DOWN );
this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ - 1, 300 + b0, p_149674_5_, l, SOUTH);
this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ + 1, 300 + b0, p_149674_5_, l, NORTH);
for (int i1 = p_149674_2_ - 1; i1 <= p_149674_2_ + 1; ++i1)
{
for (int j1 = p_149674_4_ - 1; j1 <= p_149674_4_ + 1; ++j1)
{
for (int k1 = p_149674_3_ - 1; k1 <= p_149674_3_ + 4; ++k1)
{
if (i1 != p_149674_2_ || k1 != p_149674_3_ || j1 != p_149674_4_)
{
int l1 = 100;
if (k1 > p_149674_3_ + 1)
{
l1 += (k1 - (p_149674_3_ + 1)) * 100;
}
int i2 = this.getChanceOfNeighborsEncouragingFire(p_149674_1_, i1, k1, j1);
if (i2 > 0)
{
int j2 = (i2 + 40 + p_149674_1_.difficultySetting.getDifficultyId() * 7) / (l + 30);
/*if (flag1)
{
j2 /= 2;
}*/
if (j2 > 0 && p_149674_5_.nextInt(l1) <= j2)
{
int k2 = l + p_149674_5_.nextInt(5) / 4;
if (k2 > 15)
{
k2 = 15;
}
p_149674_1_.setBlock(i1, k1, j1, this, k2, 3);
}
}
}
}
}
}
}
}
}
}
private void tryCatchFire(World p_149841_1_, int p_149841_2_, int p_149841_3_, int p_149841_4_, int p_149841_5_, Random p_149841_6_, int p_149841_7_, ForgeDirection face)
{
int j1 = p_149841_1_.getBlock(p_149841_2_, p_149841_3_, p_149841_4_).getFlammability(p_149841_1_, p_149841_2_, p_149841_3_, p_149841_4_, face);
if (p_149841_6_.nextInt(p_149841_5_) < j1)
{
boolean flag = p_149841_1_.getBlock(p_149841_2_, p_149841_3_, p_149841_4_) == Blocks.tnt;
p_149841_1_.setBlock(p_149841_2_, p_149841_3_, p_149841_4_, this, 15, 3);
if (flag)
{
Blocks.tnt.onBlockDestroyedByPlayer(p_149841_1_, p_149841_2_, p_149841_3_, p_149841_4_, 1);
}
}
}
private boolean canNeighborBurn(World p_149847_1_, int p_149847_2_, int p_149847_3_, int p_149847_4_)
{
return this.canCatchFire(p_149847_1_, p_149847_2_ + 1, p_149847_3_, p_149847_4_, WEST ) ||
this.canCatchFire(p_149847_1_, p_149847_2_ - 1, p_149847_3_, p_149847_4_, EAST ) ||
this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_ - 1, p_149847_4_, UP ) ||
this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_ + 1, p_149847_4_, DOWN ) ||
this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ - 1, SOUTH) ||
this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ + 1, NORTH);
}
private int getChanceOfNeighborsEncouragingFire(World p_149845_1_, int p_149845_2_, int p_149845_3_, int p_149845_4_)
{
byte b0 = 0;
if (!p_149845_1_.isAirBlock(p_149845_2_, p_149845_3_, p_149845_4_))
{
return 0;
}
else
{
int l = b0;
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_ + 1, p_149845_3_, p_149845_4_, l, WEST );
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_ - 1, p_149845_3_, p_149845_4_, l, EAST );
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_ - 1, p_149845_4_, l, UP );
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_ + 1, p_149845_4_, l, DOWN );
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_, p_149845_4_ - 1, l, SOUTH);
l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_, p_149845_4_ + 1, l, NORTH);
return l;
}
}
public boolean canCatchFire(IBlockAccess world, int x, int y, int z, ForgeDirection face)
{
return world.getBlock(x, y, z).isFlammable(world, x, y, z, face);
}
@Override
public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_)
{
p_149670_5_.setFire(10);
if(p_149670_5_ instanceof EntityLivingBase)
((EntityLivingBase)p_149670_5_).addPotionEffect(new PotionEffect(HbmPotion.radiation.id, 5 * 20, 9));
}
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return Color.HSBtoRGB(0F, 0F, 1F - meta / 30F);
}
@Override
public int getRenderType() {
return 1;
}
}

View File

@ -1,90 +0,0 @@
package com.hbm.blocks.bomb;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class BlockCloudResidue extends Block {
public BlockCloudResidue(Material p_i45386_1_) {
super(p_i45386_1_);
}
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;
}
public MapColor getMapColor(int p_149728_1_)
{
return MapColor.redColor;
}
@Override
public int getRenderType(){
return ModBlocks.taint.getRenderType();
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return p_149650_2_.nextInt(25) == 0 ? ModItems.powder_cloud : null;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@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 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);
}
}

View File

@ -98,7 +98,7 @@ public class BlockCrashedBomb extends BlockContainer implements IBomb {
if(!world.isRemote) {
world.setBlockToAir(x, y, z);
EntityBalefire bf = new EntityBalefire(world).mute();
EntityBalefire bf = new EntityBalefire(world);
bf.posX = x;
bf.posY = y;
bf.posZ = z;

View File

@ -81,8 +81,9 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
}
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> volcanoRadExplosion = Arrays.asList(new ExAttrib[] {ExAttrib.NODROP, ExAttrib.LAVA_R, ExAttrib.NOSOUND, ExAttrib.ALLMOD, ExAttrib.NOHURT});
public int volcanoTimer;
@ -118,15 +119,28 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
if(this.shouldGrow()) {
worldObj.setBlock(xCoord, yCoord + 1, zCoord, this.getBlockType(), this.getBlockMetadata(), 3);
worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.volcanic_lava_block);
worldObj.setBlock(xCoord, yCoord, zCoord, getLava());
return;
} else if(this.isExtinguishing()) {
worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.volcanic_lava_block);
worldObj.setBlock(xCoord, yCoord, zCoord, getLava());
return;
}
}
}
}
public boolean isRadioacitve() {
return this.getBlockType() == ModBlocks.volcano_rad_core;
}
protected Block getLava() {
if(isRadioacitve()) return ModBlocks.rad_lava_block;
return ModBlocks.volcanic_lava_block;
}
protected List<ExAttrib> getExpAttrb() {
return this.isRadioacitve() ? this.volcanoRadExplosion : this.volcanoExplosion;
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
@ -184,21 +198,12 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
}
}
/* TODO */
private boolean doesPyroclastic() {
return false;
}
private double getPyroclasticRange() {
return 0D;
}
/** Causes two magma explosions, one from bedrock to the core and one from the core to 15 blocks above. */
private void blastMagmaChannel() {
ExplosionNT explosion = new ExplosionNT(worldObj, null, xCoord + 0.5, yCoord + worldObj.rand.nextInt(15) + 1.5, zCoord + 0.5, 7);
explosion.addAllAttrib(volcanoExplosion).explode();
explosion.addAllAttrib(getExpAttrb()).explode();
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(volcanoExplosion).explode();
explosion2.addAllAttrib(getExpAttrb()).explode();
}
/** Causes two magma explosions at a random position around the core, one at normal and one at half range. */
@ -207,7 +212,7 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
for(int i = 0; i < 2; i++) {
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);
explosion.addAllAttrib(volcanoExplosion).explode();
explosion.addAllAttrib(getExpAttrb()).explode();
}
}
@ -224,7 +229,7 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
if(!b.isAir(worldObj, x, y, z) && b.getExplosionResistance(null) < Blocks.obsidian.getExplosionResistance(null)) {
//turn into lava if solid block, otherwise just break
worldObj.setBlock(x, y, z, b.isNormalCube() ? ModBlocks.volcanic_lava_block : Blocks.air);
worldObj.setBlock(x, y, z, b.isNormalCube() ? this.getLava() : Blocks.air);
}
}
}
@ -236,8 +241,8 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
int rY = yCoord + worldObj.rand.nextInt(11);
int rZ = zCoord - 10 + worldObj.rand.nextInt(21);
if(worldObj.getBlock(rX, rY, rZ) == Blocks.air && worldObj.getBlock(rX, rY - 1, rZ) == ModBlocks.volcanic_lava_block)
worldObj.setBlock(rX, rY, rZ, ModBlocks.volcanic_lava_block);
if(worldObj.getBlock(rX, rY, rZ) == Blocks.air && worldObj.getBlock(rX, rY - 1, rZ) == this.getLava())
worldObj.setBlock(rX, rY, rZ, this.getLava());
}
/** Creates a 3x3x3 lava sphere around the core. */
@ -248,7 +253,7 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
for(int k = -1; k <= 1; k++) {
if(i != 0 || j != 0 || k != 0) {
worldObj.setBlock(xCoord + i, yCoord + j, zCoord + k, ModBlocks.volcanic_lava_block);
worldObj.setBlock(xCoord + i, yCoord + j, zCoord + k, this.getLava());
}
}
}
@ -264,7 +269,11 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
frag.motionY = 1D + worldObj.rand.nextDouble();
frag.motionX = worldObj.rand.nextGaussian() * 0.2D;
frag.motionZ = worldObj.rand.nextGaussian() * 0.2D;
frag.setVolcano(true);
if(this.isRadioacitve()) {
frag.setRadVolcano(true);
} else {
frag.setVolcano(true);
}
worldObj.spawnEntityInWorld(frag);
}
}

View File

@ -26,8 +26,14 @@ public class Landmine extends BlockContainer implements IBomb {
public static boolean safeMode = false;
public Landmine(Material p_i45386_1_) {
super(p_i45386_1_);
public double range;
public double height;
public Landmine(Material mat, double range, double height) {
super(mat);
this.range = range;
this.height = height;
}
@Override
@ -56,7 +62,7 @@ public class Landmine extends BlockContainer implements IBomb {
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) {
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
float f = 0.0625F;
if(this == ModBlocks.mine_ap)
this.setBlockBounds(6 * f, 0.0F, 6 * f, 10 * f, 2 * f, 10 * f);
@ -70,15 +76,7 @@ public class Landmine extends BlockContainer implements IBomb {
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
float f = 0.0625F;
if(this == ModBlocks.mine_ap)
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_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);
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);
}
@ -92,14 +90,7 @@ public class Landmine extends BlockContainer implements IBomb {
explode(world, x, y, z);
}
boolean flag = false;
if(!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) && !BlockFence.func_149825_a(world.getBlock(x, y - 1, z))) {
flag = true;
}
if(flag) {
if(!safeMode) {
explode(world, x, y, z);
} else {
@ -157,18 +148,14 @@ public class Landmine extends BlockContainer implements IBomb {
if(this == ModBlocks.mine_ap) {
world.newExplosion(null, x + 0.5, y + 0.5, z + 0.5, 2.5F, false, false);
}
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);
world.newExplosion(null, x + 0.5, y + 2, z + 0.5, 15F, false, false);
}
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);
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);
}
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);
}
}

View File

@ -1,131 +1,97 @@
package com.hbm.blocks.bomb;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.BlockDummyable;
import com.hbm.interfaces.IBomb;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.bomb.TileEntityLaunchPad;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class LaunchPad extends BlockContainer implements IBomb {
public class LaunchPad extends BlockDummyable implements IBomb {
public static boolean keepInventory = false;
private final static Random field_149933_a = new Random();
public LaunchPad(Material p_i45386_1_) {
super(p_i45386_1_);
public LaunchPad(Material mat) {
super(mat);
this.bounding.add(AxisAlignedBB.getBoundingBox(-1.5D, 0D, -1.5D, -0.5D, 1D, -0.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(0.5D, 0D, -1.5D, 1.5D, 1D, -0.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(-1.5D, 0D, 0.5D, -0.5D, 1D, 1.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(0.5D, 0D, 0.5D, 1.5D, 1D, 1.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(-0.5D, 0.5D, -1.5D, 0.5D, 1D, 1.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(-1.5D, 0.5D, -0.5D, 1.5D, 1D, 0.5D));
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityLaunchPad();
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityLaunchPad();
if(meta >= 6) return new TileEntityProxyCombo().inventory().power().fluid();
return null;
}
@Override
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) {
if(!keepInventory) {
TileEntityLaunchPad tileentityfurnace = (TileEntityLaunchPad) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if(tileentityfurnace != null) {
for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
if(itemstack != null) {
float f = LaunchPad.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f1 = LaunchPad.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f2 = LaunchPad.field_149933_a.nextFloat() * 0.8F + 0.1F;
while(itemstack.stackSize > 0) {
int j1 = LaunchPad.field_149933_a.nextInt(21) + 10;
if(j1 > itemstack.stackSize) {
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
if(itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (float) LaunchPad.field_149933_a.nextGaussian() * f3;
entityitem.motionY = (float) LaunchPad.field_149933_a.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) LaunchPad.field_149933_a.nextGaussian() * f3;
p_149749_1_.spawnEntityInWorld(entityitem);
}
}
}
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
}
}
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote) {
return true;
} else if(!player.isSneaking()) {
TileEntityLaunchPad entity = (TileEntityLaunchPad) world.getTileEntity(x, y, z);
if(entity != null) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
}
return true;
} else {
return false;
}
return this.standardOpenBehavior(world, x, y, z, player, 0);
}
@Override
public void onNeighborBlockChange(World p_149695_1_, int x, int y, int z, Block p_149695_5_) {
if(p_149695_1_.isBlockIndirectlyGettingPowered(x, y, z) && !p_149695_1_.isRemote) {
this.explode(p_149695_1_, x, y, z);
}
public int[] getDimensions() {
return new int[] {0, 0, 1, 1, 1, 1};
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) {
return Item.getItemFromBlock(ModBlocks.launch_pad);
public int getOffset() {
return 1;
}
@Override
public BombReturnCode explode(World world, int x, int y, int z) {
TileEntityLaunchPad entity = (TileEntityLaunchPad) world.getTileEntity(x, y, z);
return entity.launchFromDesignator();
if(!world.isRemote) {
int[] corePos = findCore(world, x, y, z);
if(corePos != null){
TileEntity core = world.getTileEntity(corePos[0], corePos[1], corePos[2]);
if(core instanceof TileEntityLaunchPad){
TileEntityLaunchPad entity = (TileEntityLaunchPad)core;
return entity.launchFromDesignator();
}
}
}
return BombReturnCode.UNDEFINED;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block blockIn){
if(!world.isRemote){
int[] corePos = findCore(world, x, y, z);
if(corePos != null){
TileEntity core = world.getTileEntity(corePos[0], corePos[1], corePos[2]);
if(core instanceof TileEntityLaunchPad){
TileEntityLaunchPad launchpad = (TileEntityLaunchPad)core;
launchpad.updateRedstonePower(x, y, z);
}
}
}
super.onNeighborBlockChange( world, x, y, z, blockIn);
}
@Override
public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
super.fillSpace(world, x, y, z, dir, o);
x += dir.offsetX * o;
z += dir.offsetZ * o;
this.makeExtra(world, x + 1, y, z + 1);
this.makeExtra(world, x + 1, y, z - 1);
this.makeExtra(world, x - 1, y, z + 1);
this.makeExtra(world, x - 1, y, z - 1);
}
}

View File

@ -0,0 +1,98 @@
package com.hbm.blocks.bomb;
import com.hbm.blocks.BlockDummyable;
import com.hbm.interfaces.IBomb;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.bomb.TileEntityLaunchPadLarge;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class LaunchPadLarge extends BlockDummyable implements IBomb {
public LaunchPadLarge(Material mat) {
super(mat);
this.bounding.add(AxisAlignedBB.getBoundingBox(-4.5D, 0D, -4.5D, 4.5D, 1D, -0.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(-4.5D, 0D, 0.5D, 4.5D, 1D, 4.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(-4.5D, 0.875D, -0.5D, 4.5D, 1D, 0.5D));
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityLaunchPadLarge();
if(meta >= 6) return new TileEntityProxyCombo().inventory().power().fluid();
return new TileEntityProxyCombo().inventory();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
return this.standardOpenBehavior(world, x, y, z, player, 0);
}
@Override
public int[] getDimensions() {
return new int[] {0, 0, 4, 4, 4, 4};
}
@Override
public int getOffset() {
return 4;
}
@Override
public BombReturnCode explode(World world, int x, int y, int z) {
if(!world.isRemote) {
int[] corePos = findCore(world, x, y, z);
if(corePos != null){
TileEntity core = world.getTileEntity(corePos[0], corePos[1], corePos[2]);
if(core instanceof TileEntityLaunchPadLarge){
TileEntityLaunchPadLarge entity = (TileEntityLaunchPadLarge)core;
return entity.launchFromDesignator();
}
}
}
return BombReturnCode.UNDEFINED;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block blockIn){
if(!world.isRemote){
int[] corePos = findCore(world, x, y, z);
if(corePos != null){
TileEntity core = world.getTileEntity(corePos[0], corePos[1], corePos[2]);
if(core instanceof TileEntityLaunchPadLarge){
TileEntityLaunchPadLarge launchpad = (TileEntityLaunchPadLarge)core;
launchpad.updateRedstonePower(x, y, z);
}
}
}
super.onNeighborBlockChange( world, x, y, z, blockIn);
}
@Override
public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
super.fillSpace(world, x, y, z, dir, o);
x += dir.offsetX * o;
z += dir.offsetZ * o;
this.makeExtra(world, x + 4, y, z + 2);
this.makeExtra(world, x + 4, y, z - 2);
this.makeExtra(world, x - 4, y, z + 2);
this.makeExtra(world, x - 4, y, z - 2);
this.makeExtra(world, x + 2, y, z + 4);
this.makeExtra(world, x - 2, y, z + 4);
this.makeExtra(world, x + 2, y, z - 4);
this.makeExtra(world, x - 2, y, z - 4);
}
}

View File

@ -0,0 +1,89 @@
package com.hbm.blocks.bomb;
import java.util.Random;
import com.hbm.blocks.BlockDummyable;
import com.hbm.interfaces.IBomb;
import com.hbm.tileentity.bomb.TileEntityLaunchPadRusted;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class LaunchPadRusted extends BlockDummyable implements IBomb {
public LaunchPadRusted(Material mat) {
super(mat);
this.bounding.add(AxisAlignedBB.getBoundingBox(-1.5D, 0D, -1.5D, -0.5D, 1D, -0.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(0.5D, 0D, -1.5D, 1.5D, 1D, -0.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(-1.5D, 0D, 0.5D, -0.5D, 1D, 1.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(0.5D, 0D, 0.5D, 1.5D, 1D, 1.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(-0.5D, 0.5D, -1.5D, 0.5D, 1D, 1.5D));
this.bounding.add(AxisAlignedBB.getBoundingBox(-1.5D, 0.5D, -0.5D, 1.5D, 1D, 0.5D));
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityLaunchPadRusted();
return null;
}
@Override
public Item getItemDropped(int i, Random rand, int j) {
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
return this.standardOpenBehavior(world, x, y, z, player, 0);
}
@Override
public int[] getDimensions() {
return new int[] {0, 0, 1, 1, 1, 1};
}
@Override
public int getOffset() {
return 1;
}
@Override
public BombReturnCode explode(World world, int x, int y, int z) {
if(!world.isRemote) {
int[] corePos = findCore(world, x, y, z);
if(corePos != null){
TileEntity core = world.getTileEntity(corePos[0], corePos[1], corePos[2]);
if(core instanceof TileEntityLaunchPadRusted){
TileEntityLaunchPadRusted entity = (TileEntityLaunchPadRusted)core;
return entity.launch();
}
}
}
return BombReturnCode.UNDEFINED;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block blockIn){
if(!world.isRemote){
int[] corePos = findCore(world, x, y, z);
if(corePos != null){
TileEntity core = world.getTileEntity(corePos[0], corePos[1], corePos[2]);
if(core instanceof TileEntityLaunchPadRusted){
TileEntityLaunchPadRusted launchpad = (TileEntityLaunchPadRusted)core;
launchpad.updateRedstonePower(x, y, z);
}
}
}
super.onNeighborBlockChange( world, x, y, z, blockIn);
}
}

View File

@ -1,137 +0,0 @@
package com.hbm.blocks.bomb;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.interfaces.IBomb;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.bomb.TileEntityNukeN45;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class NukeN45 extends BlockContainer implements IBomb {
private final Random field_149933_a = new Random();
private static boolean keepInventory = false;
public NukeN45(Material p_i45386_1_) {
super(p_i45386_1_);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityNukeN45();
}
@Override
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) {
if(!keepInventory) {
ISidedInventory tileentityfurnace = (ISidedInventory) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if(tileentityfurnace != null) {
for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
if(itemstack != null) {
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
while(itemstack.stackSize > 0) {
int j1 = this.field_149933_a.nextInt(21) + 10;
if(j1 > itemstack.stackSize) {
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
if(itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (float) this.field_149933_a.nextGaussian() * f3;
entityitem.motionY = (float) this.field_149933_a.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) this.field_149933_a.nextGaussian() * f3;
p_149749_1_.spawnEntityInWorld(entityitem);
}
}
}
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
}
}
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote) {
return true;
} else if(!player.isSneaking()) {
TileEntityNukeN45 entity = (TileEntityNukeN45) world.getTileEntity(x, y, z);
if(entity != null) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
}
return true;
} else {
return false;
}
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return Item.getItemFromBlock(ModBlocks.nuke_n45);
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public BombReturnCode explode(World world, int x, int y, int z) {
if(!world.isRemote) {
TileEntityNukeN45 entity = (TileEntityNukeN45) world.getTileEntity(x, y, z);
if(entity.getType() == 100) {
entity.primed = true;
return BombReturnCode.TRIGGERED;
} else if(!entity.primed && entity.getType() > 0) {
int t = entity.getType();
entity.clearSlots();
entity.explode(world, x, y, z, t);
return BombReturnCode.DETONATED;
}
return BombReturnCode.ERROR_MISSING_COMPONENT;
}
return BombReturnCode.UNDEFINED;
}
}

View File

@ -0,0 +1,81 @@
package com.hbm.blocks.fluid;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import com.hbm.util.ContaminationUtil;
import com.hbm.util.ContaminationUtil.ContaminationType;
import com.hbm.util.ContaminationUtil.HazardType;
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.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
public class RadBlock extends VolcanicBlock {
@SideOnly(Side.CLIENT) public static IIcon stillIconRad;
@SideOnly(Side.CLIENT) public static IIcon flowingIconRad;
public RadBlock(Fluid fluid, Material material) {
super(fluid, material);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
stillIconRad = register.registerIcon(RefStrings.MODID + ":rad_lava_still");
flowingIconRad = register.registerIcon(RefStrings.MODID + ":rad_lava_flowing");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return (side == 0 || side == 1) ? stillIconRad : flowingIconRad;
}
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
if(entity instanceof EntityLivingBase) ContaminationUtil.contaminate((EntityLivingBase) entity, HazardType.RADIATION, ContaminationType.CREATIVE, 5F);
}
@Override
public void onSolidify(World world, int x, int y, int z, int lavaCount, int basaltCount, Random rand) {
int r = rand.nextInt(400);
Block above = world.getBlock(x, y + 10, z);
boolean canMakeGem = lavaCount + basaltCount == 6 && lavaCount < 3 && (above == ModBlocks.sellafield_slaked || above == ModBlocks.rad_lava_block);
int meta = 5 + rand.nextInt(3);
if(r < 2) world.setBlock(x, y, z, ModBlocks.ore_sellafield_diamond, meta, 3);
else if(r == 2) world.setBlock(x, y, z, ModBlocks.ore_sellafield_emerald, meta, 3);
else if(r < 20 && canMakeGem) world.setBlock(x, y, z, ModBlocks.ore_sellafield_radgem, meta, 3);
else world.setBlock(x, y, z, ModBlocks.sellafield_slaked, meta, 3);
}
@Override
public Block getBasaltForCheck() {
return ModBlocks.sellafield_slaked;
}
@Override
public Block getReaction(World world, int x, int y, int z) {
Block b = world.getBlock(x, y, z);
if(b.getMaterial() == Material.water) return Blocks.stone;
if(b == Blocks.log || b == Blocks.log2) return ModBlocks.waste_log;
if(b == Blocks.planks) return ModBlocks.waste_planks;
if(b == Blocks.leaves || b == Blocks.leaves2) return Blocks.fire;
if(b == Blocks.diamond_ore) return ModBlocks.ore_sellafield_radgem;
if(b == ModBlocks.ore_uranium || b == ModBlocks.ore_gneiss_uranium) return world.rand.nextInt(5) == 0 ? ModBlocks.ore_sellafield_schrabidium : ModBlocks.ore_sellafield_uranium_scorched;
return null;
}
}

View File

@ -0,0 +1,31 @@
package com.hbm.blocks.fluid;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
public class RadFluid extends Fluid {
public RadFluid() {
super("rad_lava_fluid");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return getStillIcon();
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getStillIcon() {
return RadBlock.stillIconRad;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getFlowingIcon() {
return RadBlock.flowingIconRad;
}
}

View File

@ -51,26 +51,18 @@ public class VolcanicBlock extends BlockFluidClassic {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Block b = getReaction(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if(b != null)
world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, b);
if(b != null) world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, b, b == ModBlocks.ore_basalt ? 3 : 0, 3);
}
}
public Block getReaction(World world, int x, int y, int z) {
Block b = world.getBlock(x, y, z);
if(b.getMaterial() == Material.water) {
return Blocks.stone;
}
if(b == Blocks.log || b == Blocks.log2) {
return ModBlocks.waste_log;
}
if(b == Blocks.planks) {
return ModBlocks.waste_planks;
}
if(b == Blocks.leaves || b == Blocks.leaves2) {
return Blocks.fire;
}
if(b.getMaterial() == Material.water) return Blocks.stone;
if(b == Blocks.log || b == Blocks.log2) return ModBlocks.waste_log;
if(b == Blocks.planks) return ModBlocks.waste_planks;
if(b == Blocks.leaves || b == Blocks.leaves2) return Blocks.fire;
if(b == Blocks.diamond_ore) return ModBlocks.ore_basalt;
return null;
}
@ -87,30 +79,33 @@ public class VolcanicBlock extends BlockFluidClassic {
if(b == this)
lavaCount++;
if(b == ModBlocks.basalt) {
if(b == getBasaltForCheck()) {
basaltCount++;
}
}
if(!world.isRemote && ((!this.isSourceBlock(world, x, y, z) && lavaCount < 2) || (rand.nextInt(5) == 0) && lavaCount < 5) && world.getBlock(x, y - 1, z) != this) {
int r = rand.nextInt(200);
Block above = world.getBlock(x, y + 10, z);
boolean canMakeGem = lavaCount + basaltCount == 6 && lavaCount < 3 && (above == ModBlocks.basalt || above == ModBlocks.volcanic_lava_block);
if(r < 2)
world.setBlock(x, y, z, ModBlocks.basalt_sulfur);
else if(r == 2)
world.setBlock(x, y, z, ModBlocks.basalt_asbestos);
else if(r == 3)
world.setBlock(x, y, z, ModBlocks.basalt_fluorite);
else if(r < 14 && canMakeGem)
world.setBlock(x, y, z, ModBlocks.basalt_gem);
else
world.setBlock(x, y, z, ModBlocks.basalt);
this.onSolidify(world, x, y, z, lavaCount, basaltCount, rand);
}
}
public Block getBasaltForCheck() {
return ModBlocks.basalt;
}
public void onSolidify(World world, int x, int y, int z, int lavaCount, int basaltCount, Random rand) {
int r = rand.nextInt(200);
Block above = world.getBlock(x, y + 10, z);
boolean canMakeGem = lavaCount + basaltCount == 6 && lavaCount < 3 && (above == ModBlocks.basalt || above == ModBlocks.volcanic_lava_block);
if(r < 2) world.setBlock(x, y, z, ModBlocks.ore_basalt, 0, 3);
else if(r == 2) world.setBlock(x, y, z, ModBlocks.ore_basalt, 1, 3);
else if(r == 3) world.setBlock(x, y, z, ModBlocks.ore_basalt, 2, 3);
else if(r == 4) world.setBlock(x, y, z, ModBlocks.ore_basalt, 4, 3);
else if(r < 15 && canMakeGem) world.setBlock(x, y, z, ModBlocks.ore_basalt, 3, 3);
else world.setBlock(x, y, z, ModBlocks.basalt);
}
@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {

View File

@ -40,7 +40,7 @@ public class BlockGasClorine extends BlockGasBase {
EntityLivingBase entityLiving = (EntityLivingBase) entity;
if(ArmorRegistry.hasAllProtection(entityLiving, 3, HazardClass.GAS_CHLORINE)) {
if(ArmorRegistry.hasAllProtection(entityLiving, 3, HazardClass.GAS_LUNG)) {
ArmorUtil.damageGasMaskFilter(entityLiving, 1);
} else {

View File

@ -12,6 +12,7 @@ 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.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
@ -38,11 +39,31 @@ public class BlockAmmoCrate extends Block {
public IIcon getIcon(int side, int metadata) {
return side == 0 ? this.iconBottom : (side == 1 ? this.iconTop : this.blockIcon);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
if(player.getHeldItem() != null && player.getHeldItem().getItem().equals(ModItems.crowbar)) {
if(!world.isRemote) {
dropContents(world, x, y, z);
world.setBlockToAir(x, y, z);
world.playSoundEffect(x, y, z, "hbm:block.crateBreak", 0.5F, 1.0F);
}
return true;
}
return false;
}
Random rand = new Random();
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
public void dropContents(World world, int x, int y, int z) {
ArrayList<ItemStack> items = getContents(world, x, y, z);
for(ItemStack item : items) {
this.dropBlockAsItem(world, x, y, z, item);
}
}
public ArrayList<ItemStack> getContents(World world, int x, int y, int z) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();

View File

@ -6,20 +6,26 @@ import java.util.Random;
import com.hbm.blocks.IBlockMultiPass;
import com.hbm.blocks.ILookOverlay;
import com.hbm.inventory.FluidContainerRegistry;
import com.hbm.inventory.FluidStack;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemDrillbit.EnumDrillType;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.render.block.RenderBlockMultipass;
import com.hbm.util.EnumUtil;
import com.hbm.util.I18nUtil;
import api.hbm.fluid.IFillableItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -57,6 +63,45 @@ public class BlockBedrockOreTE extends BlockContainer implements ILookOverlay, I
super.onBlockPlacedBy(world, x, y, z, entity, stack);
world.markBlockForUpdate(x, y, z);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float fx, float fy, float fz) {
ItemStack stack = player.getHeldItem();
if(stack == null) return false;
if(!player.capabilities.isCreativeMode) return false;
if(world.isRemote) return true;
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityBedrockOre) {
TileEntityBedrockOre ore = (TileEntityBedrockOre) te;
if(stack.getItem() == ModItems.drillbit) {
EnumDrillType type = EnumUtil.grabEnumSafely(EnumDrillType.class, stack.getItemDamage());
ore.tier = type.tier;
} else if(FluidContainerRegistry.getFluidType(stack) != Fluids.NONE) {
FluidType type = FluidContainerRegistry.getFluidType(stack);
int amount = FluidContainerRegistry.getFluidContent(stack, type);
ore.acidRequirement = new FluidStack(type, amount);
} else if(stack.getItem() instanceof IFillableItem) {
IFillableItem item = (IFillableItem) stack.getItem();
FluidType type = item.getFirstFluidType(stack);
if(type != null) {
ore.acidRequirement = new FluidStack(type, item.getFill(stack));
}
} else {
ore.resource = stack.copy();
ore.shape = world.rand.nextInt(10);
}
ore.markDirty();
}
world.markBlockForUpdate(x, y, z);
return true;
}
@Override
public int getRenderType(){
@ -219,6 +264,12 @@ public class BlockBedrockOreTE extends BlockContainer implements ILookOverlay, I
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
this.readFromNBT(pkt.func_148857_g());
if(color == 0) {
this.color = MainRegistry.proxy.getStackColor(resource, true);
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}

View File

@ -191,8 +191,9 @@ 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),
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),
MICROWAVE( "Microwave", "Microwave", "OC Compatibility", "they call me the food heater", true, ScrapType.BRIDGE_BIOS),
PEEP( "Peep", "LePeeperSauvage", "Coilgun, Leadburster and Congo Lake models, BDCL QC", "Fluffy ears can't hide in ash, nor snow.", true, ScrapType.CPU_CLOCK);
MICROWAVE( "Microwave", "Microwave", "OC Compatibility", "they call me the food heater", 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),
MELLOW( "MELLOWARPEGGIATION", "Mellow", "Industrial lighting, animation tools", "Make something cool now, ask for permission later.", true, ScrapType.CARD_PROCESSOR);
public String name; //the title of the tooltip
public String label; //the name engraved in the socket

View File

@ -2,7 +2,7 @@ package com.hbm.blocks.generic;
import com.hbm.blocks.BlockBase;
import api.hbm.energy.IEnergyConnectorBlock;
import api.hbm.energymk2.IEnergyConnectorBlock;
import net.minecraft.block.material.Material;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;

View File

@ -11,9 +11,7 @@ import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
public class BlockCanCrate extends Block {
@ -21,79 +19,77 @@ public class BlockCanCrate extends Block {
public BlockCanCrate(Material p_i45394_1_) {
super(p_i45394_1_);
}
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override
public int getRenderType(){
public int getRenderType() {
return renderID;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
if(world.isRemote)
{
player.addChatMessage(new ChatComponentText("The one crate you are allowed to smash!"));
if(player.getHeldItem() != null && player.getHeldItem().getItem().equals(ModItems.crowbar)) {
if(!world.isRemote) {
dropContents(world, x, y, z);
world.setBlockToAir(x, y, z);
world.playSoundEffect(x, y, z, "hbm:block.crateBreak", 0.5F, 1.0F);
}
return true;
}
return true;
}
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
int count = quantityDropped(metadata, fortune, world.rand);
for(int i = 0; i < count; i++) {
Item item = getItemDropped(metadata, world.rand, fortune);
if(item != null)
ret.add(new ItemStack(item, 1, damageDropped(metadata, world.rand, item)));
}
return ret;
}
//pain
public int damageDropped(int meta, Random rand, Item item) {
if(item != ModItems.canned_conserve)
return damageDropped(meta);
else
return Math.abs(rand.nextInt() % EnumFoodType.values().length);
}
@Override
public Item getItemDropped(int i, Random rand, int j) {
List<Item> items = new ArrayList();
for(int a = 0; a < EnumFoodType.values().length; a++)
items.add(ModItems.canned_conserve);
items.add(ModItems.can_smart);
items.add(ModItems.can_creature);
items.add(ModItems.can_redbomb);
items.add(ModItems.can_mrsugar);
items.add(ModItems.can_overcharge);
items.add(ModItems.can_luna);
items.add(ModItems.can_breen);
items.add(ModItems.can_bepis);
items.add(ModItems.pudding);
return items.get(rand.nextInt(items.size()));
}
@Override
public int quantityDropped(Random rand) {
return 5 + rand.nextInt(4);
}
return false;
}
Random rand = new Random();
public void dropContents(World world, int x, int y, int z) {
ArrayList<ItemStack> items = getContents(world, x, y, z);
for(ItemStack item : items) {
this.dropBlockAsItem(world, x, y, z, item);
}
}
public ArrayList<ItemStack> getContents(World world, int x, int y, int z) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
int count = getContentAmount(world.rand);
for(int i = 0; i < count; i++) {
ret.add(getRandomItem(world.rand));
}
return ret;
}
public ItemStack getRandomItem(Random rand) {
List<ItemStack> items = new ArrayList();
for(int a = 0; a < EnumFoodType.values().length; a++)
items.add(new ItemStack(ModItems.canned_conserve, 1, a));
items.add(new ItemStack(ModItems.can_smart));
items.add(new ItemStack(ModItems.can_creature));
items.add(new ItemStack(ModItems.can_redbomb));
items.add(new ItemStack(ModItems.can_mrsugar));
items.add(new ItemStack(ModItems.can_overcharge));
items.add(new ItemStack(ModItems.can_luna));
items.add(new ItemStack(ModItems.can_breen));
items.add(new ItemStack(ModItems.can_bepis));
items.add(new ItemStack(ModItems.pudding));
return items.get(rand.nextInt(items.size()));
}
public int getContentAmount(Random rand) {
return 5 + rand.nextInt(4);
}
}

View File

@ -1,45 +1,69 @@
package com.hbm.blocks.generic;
import java.util.Locale;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.BlockPillar;
import com.hbm.blocks.BlockEnumMulti;
import com.hbm.items.ModItems;
import com.hbm.util.EnumUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
public class BlockCap extends BlockPillar {
public class BlockCap extends BlockEnumMulti {
protected IIcon[] iconsTop;
public BlockCap(Material mat, String tex) {
super(mat, tex);
public BlockCap() {
super(Material.iron, EnumCapBlock.class, true, true);
}
@Override
public Item getItemDropped(int i, Random rand, int j) {
if(this == ModBlocks.block_cap_nuka)
return ModItems.cap_nuka;
if(this == ModBlocks.block_cap_quantum)
return ModItems.cap_quantum;
if(this == ModBlocks.block_cap_sparkle)
return ModItems.cap_sparkle;
if(this == ModBlocks.block_cap_rad)
return ModItems.cap_rad;
if(this == ModBlocks.block_cap_korl)
return ModItems.cap_korl;
if(this == ModBlocks.block_cap_fritz)
return ModItems.cap_fritz;
if(this == ModBlocks.block_cap_sunset)
return ModItems.cap_sunset;
if(this == ModBlocks.block_cap_star)
return ModItems.cap_star;
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
Enum[] enums = theEnum.getEnumConstants();
this.icons = new IIcon[enums.length];
this.iconsTop = new IIcon[enums.length];
for(int i = 0; i < icons.length; i++) {
Enum num = enums[i];
this.icons[i] = reg.registerIcon(this.getTextureMultiName(num));
this.iconsTop[i] = reg.registerIcon(this.getTextureMultiName(num) + "_top");
}
}
@Override public String getTextureMultiName(Enum num) { return this.getTextureName() + "_" + num.name().toLowerCase(Locale.US); }
@Override public String getUnlocalizedMultiName(Enum num) { return super.getUnlocalizedName() + "_" + num.name().toLowerCase(Locale.US); }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return side == 0 || side == 1 ? this.iconsTop[meta % this.iconsTop.length] : this.icons[meta % this.icons.length];
}
@Override
public Item getItemDropped(int meta, Random rand, int j) {
EnumCapBlock cap = EnumUtil.grabEnumSafely(EnumCapBlock.class, meta);
if(cap == EnumCapBlock.NUKA) return ModItems.cap_nuka;
if(cap == EnumCapBlock.QUANTUM) return ModItems.cap_quantum;
if(cap == EnumCapBlock.SPARKLE) return ModItems.cap_sparkle;
if(cap == EnumCapBlock.RAD) return ModItems.cap_rad;
if(cap == EnumCapBlock.KORL) return ModItems.cap_korl;
if(cap == EnumCapBlock.FRITZ) return ModItems.cap_fritz;
return null;
}
@Override
public int quantityDropped(Random rand) {
return 128;
}
}
@Override public int quantityDropped(Random rand) { return 128; }
public static enum EnumCapBlock {
NUKA, QUANTUM, SPARKLE, RAD, KORL, FRITZ
}
}

View File

@ -62,7 +62,6 @@ public class BlockCluster extends Block implements IDrillInteraction, ITooltipPr
if(this == ModBlocks.cluster_titanium) return ModItems.crystal_titanium;
if(this == ModBlocks.cluster_aluminium) return ModItems.crystal_aluminium;
if(this == ModBlocks.cluster_copper) return ModItems.crystal_copper;
if(this == ModBlocks.basalt_gem) return ModItems.gem_volcanic;
return null;
}

View File

@ -14,7 +14,6 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
public class BlockCrate extends BlockFalling {
@ -29,25 +28,17 @@ public class BlockCrate extends BlockFalling {
super(p_i45394_1_);
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
if(player.getHeldItem() != null && player.getHeldItem().getItem().equals(ModItems.crowbar)) {
dropItems(world, x, y, z);
world.setBlockToAir(x, y, z);
world.playSoundEffect(x, y, z, "hbm:block.crateBreak", 0.5F, 1.0F);
return true;
} else {
if(world.isRemote) {
player.addChatMessage(new ChatComponentText("I'll need a crate opening device to get the loot, smashing the whole thing won't work..."));
if(!world.isRemote) {
dropItems(world, x, y, z);
world.setBlockToAir(x, y, z);
world.playSoundEffect(x, y, z, "hbm:block.crateBreak", 0.5F, 1.0F);
}
return true;
}
return true;
return false;
}
public void setDrops() {
@ -133,9 +124,8 @@ public class BlockCrate extends BlockFalling {
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_nuke_furnace_off), 7);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_coal_off), 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_selenium), 7);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_rtg_grey), 4);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.red_pylon), 9);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_battery), 8);
@ -143,7 +133,6 @@ public class BlockCrate extends BlockFalling {
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_electric_furnace_off), 8);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_assembler), 10);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_fluidtank), 7);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_drill), 4);
BlockCrate.addToListWithWeight(metalList, ModItems.centrifuge_element, 6);
BlockCrate.addToListWithWeight(metalList, ModItems.motor, 8);
BlockCrate.addToListWithWeight(metalList, ModItems.coil_tungsten, 7);
@ -151,7 +140,6 @@ public class BlockCrate extends BlockFalling {
BlockCrate.addToListWithWeight(metalList, ModItems.coil_copper, 10);
BlockCrate.addToListWithWeight(metalList, ModItems.tank_steel, 9);
BlockCrate.addToListWithWeight(metalList, ModItems.blade_titanium, 3);
BlockCrate.addToListWithWeight(metalList, ModItems.bolt_compound, 2);
BlockCrate.addToListWithWeight(metalList, ModItems.piston_selenium, 6);
// Red Crate

View File

@ -0,0 +1,76 @@
package com.hbm.blocks.generic;
import com.hbm.blocks.BlockMulti;
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.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class BlockDecoCRT extends BlockMulti {
protected String[] variants = new String[] {"crt_clean", "crt_broken", "crt_blinking", "crt_bsod"};
@SideOnly(Side.CLIENT) protected IIcon[] icons;
public BlockDecoCRT(Material mat) {
super(mat);
}
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override
public int getRenderType(){
return renderID;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
super.registerBlockIcons(reg);
this.icons = new IIcon[variants.length];
for(int i = 0; i < variants.length; i++) {
this.icons[i] = reg.registerIcon(RefStrings.MODID + ":" + variants[i]);
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return this.icons[damageDropped(meta)];
}
@Override
public int damageDropped(int meta) {
return (Math.abs(meta) % 16) / 4;
}
@Override
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 meta = stack.getItemDamage();
world.setBlockMetadataWithNotify(x, y, z, meta * 4 + i, 2);
}
@Override
public int getSubCount() {
return 4;
}
}

View File

@ -58,9 +58,9 @@ public class BlockDecoContainer extends BlockDecoModel implements ITileEntityPro
} else {
TileEntity entity = world.getTileEntity(x, y, z);
if(entity instanceof TileEntityLockableBase) { //annoying accommodations for the filing cabinet, but whatever, could potentially be useful
if(player.getHeldItem() != null && (player.getHeldItem().getItem() instanceof ItemLock || player.getHeldItem().getItem() == ModItems.key_kit))
if(player.getHeldItem() != null && (player.getHeldItem().getItem() instanceof ItemLock || player.getHeldItem().getItem() == ModItems.key_kit)) {
return false;
else if(!player.isSneaking() && ((TileEntityLockableBase) entity).canAccess(player)) {
} else if(!player.isSneaking() && ((TileEntityLockableBase) entity).canAccess(player)) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
return true;
}
@ -99,13 +99,13 @@ public class BlockDecoContainer extends BlockDecoModel implements ITileEntityPro
if(itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
float f3 = 0.05F;
entityitem.motionX = (float) rand.nextGaussian() * f3;
entityitem.motionY = (float) rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
float f3 = 0.05F;
entityitem.motionX = (float) rand.nextGaussian() * f3;
entityitem.motionY = (float) rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}

View File

@ -0,0 +1,93 @@
package com.hbm.blocks.generic;
import com.hbm.blocks.BlockMulti;
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.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockDecoToaster extends BlockMulti {
protected String[] variants = new String[] {"toaster_iron", "toaster_steel", "toaster_wood"};
@SideOnly(Side.CLIENT) protected IIcon[] icons;
public BlockDecoToaster(Material mat) {
super(mat);
}
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override
public int getRenderType(){
return renderID;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
super.registerBlockIcons(reg);
this.icons = new IIcon[variants.length];
for(int i = 0; i < variants.length; i++) {
this.icons[i] = reg.registerIcon(RefStrings.MODID + ":" + variants[i]);
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return this.icons[damageDropped(meta)];
}
@Override
public int damageDropped(int meta) {
return (Math.abs(meta) % 12) / 4;
}
@Override
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 meta = stack.getItemDamage();
world.setBlockMetadataWithNotify(x, y, z, meta * 4 + i, 2);
}
@Override
public int getSubCount() {
return 3;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if(meta % 2 == 0)
this.setBlockBounds(0.25F, 0.0F, 0.375F, 0.75F, 0.325F, 0.625F);
else
this.setBlockBounds(0.375F, 0.0F, 0.25F, 0.625F, 0.325F, 0.75F);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int 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);
}
}

View File

@ -1,43 +0,0 @@
package com.hbm.blocks.generic;
import java.util.Random;
import com.hbm.blocks.BlockEnumMulti;
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.world.World;
public class BlockDeepCobble extends BlockEnumMulti {
public static enum EnumDeepCobbleTypes {
NORMAL,
BURNING,
STEAMING
}
public BlockDeepCobble() {
super(Material.rock, EnumDeepCobbleTypes.class, true, true);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
super.randomDisplayTick(world, x, y, z, rand);
int meta = world.getBlockMetadata(x, y, z);
Block b = world.getBlock(x, y + 1, z);
if(!b.isNormalCube()) {
if(meta == EnumDeepCobbleTypes.BURNING.ordinal()) {
world.spawnParticle("flame", x + rand.nextDouble(), y + 1.0625, z + rand.nextDouble(), 0.0, 0.0, 0.0);
}
if(meta == EnumDeepCobbleTypes.STEAMING.ordinal()) {
world.spawnParticle("cloud", x + 0.25 + rand.nextDouble() * 0.5, y + 1.0625, z + 0.25 + rand.nextDouble() * 0.5, 0.0, 0.05, 0.0);
}
}
}
}

View File

@ -3,6 +3,7 @@ package com.hbm.blocks.generic;
import java.util.List;
import com.hbm.blocks.BlockDummyable;
import com.hbm.interfaces.IBomb;
import com.hbm.items.special.ItemDoorSkin;
import com.hbm.tileentity.DoorDecl;
import com.hbm.tileentity.TileEntityDoorGeneric;
@ -20,7 +21,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockDoorGeneric extends BlockDummyable {
public class BlockDoorGeneric extends BlockDummyable implements IBomb {
public DoorDecl type;
@ -43,7 +44,23 @@ public class BlockDoorGeneric extends BlockDummyable {
@Override
public int getOffset(){
return 0;
return type.getBlockOffset();
}
@Override
public BombReturnCode explode(World world, int x, int y, int z) {
int[] pos1 = findCore(world, x, y, z);
if(pos1 == null) return BombReturnCode.ERROR_INCOMPATIBLE;
TileEntityDoorGeneric door = (TileEntityDoorGeneric) world.getTileEntity(pos1[0], pos1[1], pos1[2]);
if(door != null) {
DoorDecl decl = door.getDoorType();
if(!decl.remoteControllable()) return BombReturnCode.ERROR_INCOMPATIBLE;
if(door.tryToggle(null)) {
return BombReturnCode.TRIGGERED;
}
}
return BombReturnCode.ERROR_INCOMPATIBLE;
}
@Override
@ -80,8 +97,8 @@ public class BlockDoorGeneric extends BlockDummyable {
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));
if(box.minY == y && box.maxY == y)
return;
if(box.minY == y && box.maxY == y) return;
if(box.minX == box.maxX && box.minY == box.maxY && box.minZ == box.maxZ) return;
if(box != null && box.intersectsWith(entityBox)) {
collidingBoxes.add(box);
@ -92,6 +109,18 @@ public class BlockDoorGeneric extends BlockDummyable {
//super.addCollisionBoxesToList(worldIn, x, y, z, entityBox, collidingBoxes, entityIn);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
AxisAlignedBB aabb = this.getBoundingBox(world, x, y, z);
if(aabb.minX == aabb.maxX && aabb.minY == aabb.maxY && aabb.minZ == aabb.maxZ) return null;
return aabb;
}
@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
return hasExtra(world.getBlockMetadata(x, y, z)); //if it's open
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block blockIn){
@ -136,5 +165,4 @@ public class BlockDoorGeneric extends BlockDummyable {
}
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
}
}

View File

@ -41,13 +41,19 @@ public class BlockFallout extends Block {
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
Block block = world.getBlock(x, y - 1, z);
return block != Blocks.ice && block != Blocks.packed_ice ? (block.isLeaves(world, x, y - 1, z) ? true : (block == this && (world.getBlockMetadata(x, y - 1, z) & 7) == 7 ? true : block.isOpaqueCube() && block.getMaterial().blocksMovement())) : false;
if (block == Blocks.ice || block == Blocks.packed_ice) return false;
if (block.isLeaves(world, x, y - 1, z) && !block.isAir(world, x, y - 1, z)) return true;
if (block == this && (world.getBlockMetadata(x, y - 1, z) & 7) == 7) return true;
return block.isOpaqueCube() && block.getMaterial().blocksMovement();
}
@Override
public void onEntityWalking(World world, int x, int y, int z, Entity entity) {
if(!world.isRemote && entity instanceof EntityLivingBase) {
if(entity instanceof EntityPlayer && ((EntityPlayer)entity).capabilities.isCreativeMode) return;
PotionEffect effect = new PotionEffect(HbmPotion.radiation.id, 10 * 60 * 20, 0);
effect.setCurativeItems(new ArrayList());
((EntityLivingBase) entity).addPotionEffect(effect);

View File

@ -1,6 +1,9 @@
package com.hbm.blocks.generic;
import java.util.Random;
import com.hbm.blocks.IBlockMultiPass;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import com.hbm.render.block.RenderBlockMultipass;
@ -11,6 +14,7 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockFissure extends Block implements IBlockMultiPass {
@ -21,6 +25,7 @@ public class BlockFissure extends Block implements IBlockMultiPass {
this.setBlockTextureName("bedrock");
this.setBlockUnbreakable();
this.setResistance(1_000_000);
this.setTickRandomly(true);
}
@Override
@ -41,6 +46,16 @@ public class BlockFissure extends Block implements IBlockMultiPass {
return this.overlay;
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
if(world.getBlock(x, y + 1, z).isReplaceable(world, x, y + 1, z)) world.setBlock(x, y + 1, z, ModBlocks.volcanic_lava_block);
}
@Override
public boolean shouldRenderItemMulti() {
return true;
}
@Override
public int getPasses() {
return 2;

View File

@ -1,21 +1,36 @@
package com.hbm.blocks.generic;
import java.util.List;
import java.util.Random;
import com.hbm.blocks.IBlockMulti;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
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.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class BlockGlyphid extends Block {
public IIcon[] icons = new IIcon[2];
public class BlockGlyphid extends Block implements IBlockMulti {
public IIcon[] iconsStandard = new IIcon[2];
public IIcon[] iconsInfested = new IIcon[2];
public BlockGlyphid(Material mat) {
super(mat);
this.setCreativeTab(MainRegistry.blockTab);
}
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
return null;
}
@Override
@ -24,20 +39,39 @@ public class BlockGlyphid extends Block {
long l = (long) (x * 3129871) ^ (long)y * 116129781L ^ (long)z;
l = l * l * 42317861L + l * 11L;
int i = (int)(l >> 16 & 3L);
return icons[(int)(Math.abs(i) % this.icons.length)];
IIcon[] icons = this.getIconArray(world.getBlockMetadata(x, y, z));
return icons[(int)(Math.abs(i) % icons.length)];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return icons[meta % this.icons.length];
IIcon[] icons = this.getIconArray(meta);
return icons[meta % icons.length];
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
icons[0] = reg.registerIcon(RefStrings.MODID + ":glyphid_base");
icons[1] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_alt");
iconsStandard[0] = reg.registerIcon(RefStrings.MODID + ":glyphid_base");
iconsStandard[1] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_alt");
iconsInfested[0] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_infested");
iconsInfested[1] = reg.registerIcon(RefStrings.MODID + ":glyphid_base_infested_alt");
}
protected IIcon[] getIconArray(int meta) {
if(meta == 1) return this.iconsInfested;
return this.iconsStandard;
}
@Override
public int getSubCount() {
return 2;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for(int i = 0; i < getSubCount(); ++i) list.add(new ItemStack(item, 1, i));
}
}

View File

@ -1,33 +1,48 @@
package com.hbm.blocks.generic;
import java.util.List;
import java.util.Random;
import java.util.*;
import java.util.function.Function;
import com.hbm.blocks.IBlockMulti;
import com.hbm.config.MobConfig;
import com.hbm.entity.mob.EntityGlyphid;
import com.hbm.entity.mob.EntityGlyphidBehemoth;
import com.hbm.entity.mob.EntityGlyphidBlaster;
import com.hbm.entity.mob.EntityGlyphidBombardier;
import com.hbm.entity.mob.EntityGlyphidBrawler;
import com.hbm.entity.mob.EntityGlyphidBrenda;
import com.hbm.entity.mob.EntityGlyphidNuclear;
import com.hbm.entity.mob.EntityGlyphidScout;
import com.hbm.entity.mob.glyphid.EntityGlyphid;
import com.hbm.entity.mob.glyphid.EntityGlyphidBehemoth;
import com.hbm.entity.mob.glyphid.EntityGlyphidBlaster;
import com.hbm.entity.mob.glyphid.EntityGlyphidBombardier;
import com.hbm.entity.mob.glyphid.EntityGlyphidBrawler;
import com.hbm.entity.mob.glyphid.EntityGlyphidBrenda;
import com.hbm.entity.mob.glyphid.EntityGlyphidDigger;
import com.hbm.entity.mob.glyphid.EntityGlyphidNuclear;
import com.hbm.entity.mob.glyphid.EntityGlyphidScout;
import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.util.Tuple.Pair;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
public class BlockGlyphidSpawner extends BlockContainer {
public class BlockGlyphidSpawner extends BlockContainer implements IBlockMulti {
public IIcon[] icons = new IIcon[2];
public BlockGlyphidSpawner(Material p_i45386_1_) {
super(p_i45386_1_);
public BlockGlyphidSpawner(Material mat) {
super(mat);
this.setCreativeTab(MainRegistry.blockTab);
}
@Override
@ -35,6 +50,44 @@ public class BlockGlyphidSpawner extends BlockContainer {
return ModItems.egg_glyphid;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return icons[meta % icons.length];
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
icons[0] = reg.registerIcon(RefStrings.MODID + ":glyphid_eggs_alt");
icons[1] = reg.registerIcon(RefStrings.MODID + ":glyphid_eggs_infested");
}
@Override
public int getSubCount() {
return 2;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for(int i = 0; i < getSubCount(); ++i) list.add(new ItemStack(item, 1, i));
}
private static final ArrayList<Pair<Function<World, EntityGlyphid>, int[]>> spawnMap = new ArrayList<>();
static {
// big thanks to martin for the suggestion of using functions
spawnMap.add(new Pair<>(EntityGlyphid::new, MobConfig.glyphidChance));
spawnMap.add(new Pair<>(EntityGlyphidBombardier::new, MobConfig.bombardierChance));
spawnMap.add(new Pair<>(EntityGlyphidBrawler::new, MobConfig.brawlerChance));
spawnMap.add(new Pair<>(EntityGlyphidDigger::new, MobConfig.diggerChance));
spawnMap.add(new Pair<>(EntityGlyphidBlaster::new, MobConfig.blasterChance));
spawnMap.add(new Pair<>(EntityGlyphidBehemoth::new, MobConfig.behemothChance));
spawnMap.add(new Pair<>(EntityGlyphidBrenda::new, MobConfig.brendaChance));
spawnMap.add(new Pair<>(EntityGlyphidNuclear::new, MobConfig.johnsonChance));
}
@Override
public int quantityDropped(int meta, int fortune, Random rand) {
return 1 + rand.nextInt(3) + fortune;
@ -46,47 +99,94 @@ public class BlockGlyphidSpawner extends BlockContainer {
}
public static class TileEntityGlpyhidSpawner extends TileEntity {
boolean initialSpawn = true;
@Override
public void updateEntity() {
if(!worldObj.isRemote && worldObj.getTotalWorldTime() % 60 == 0 && this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL) {
int count = 0;
for(Object e : worldObj.loadedEntityList) {
if(e instanceof EntityGlyphid) {
count++;
if(count >= MobConfig.spawnMax) return;
}
}
float soot = PollutionHandler.getPollution(worldObj, xCoord, yCoord, zCoord, PollutionType.SOOT);
List<EntityGlyphid> list = worldObj.getEntitiesWithinAABB(EntityGlyphid.class, AxisAlignedBB.getBoundingBox(xCoord - 6, yCoord + 1, zCoord - 6, xCoord + 7, yCoord + 9, zCoord + 7));
if(list.size() < 3) {
EntityGlyphid glyphid = createGlyphid(soot);
glyphid.setLocationAndAngles(xCoord + 0.5, yCoord + 1, zCoord + 0.5, worldObj.rand.nextFloat() * 360.0F, 0.0F);
this.worldObj.spawnEntityInWorld(glyphid);
}
if(worldObj.rand.nextInt(20) == 0 && soot >= MobConfig.scoutThreshold) {
EntityGlyphidScout scout = new EntityGlyphidScout(worldObj);
scout.setLocationAndAngles(xCoord + 0.5, yCoord + 1, zCoord + 0.5, worldObj.rand.nextFloat() * 360.0F, 0.0F);
this.worldObj.spawnEntityInWorld(scout);
if(!worldObj.isRemote && this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL) {
if(initialSpawn || worldObj.getTotalWorldTime() % MobConfig.swarmCooldown == 0) {
initialSpawn = false;
int count = 0;
for(Object e : worldObj.loadedEntityList) {
if(e instanceof EntityGlyphid) {
count++;
if(count >= MobConfig.spawnMax) return;
}
}
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);
if(list.size() <= 3) {
ArrayList<EntityGlyphid> currentSwarm = createSwarm(soot, this.getBlockMetadata());
for(EntityGlyphid glyphid : currentSwarm) {
trySpawnEntity(glyphid);
}
if(!initialSpawn && worldObj.rand.nextInt(MobConfig.scoutSwarmSpawnChance + 1) == 0 && soot >= MobConfig.scoutThreshold) {
EntityGlyphidScout scout = new EntityGlyphidScout(worldObj);
if(this.getBlockMetadata() == 1) scout.getDataWatcher().updateObject(EntityGlyphid.DW_SUBTYPE, (byte) EntityGlyphid.TYPE_INFECTED);
trySpawnEntity(scout);
}
}
}
}
}
public EntityGlyphid createGlyphid(float soot) {
Random rand = new Random();
if(soot < MobConfig.tier2Threshold) return rand.nextInt(5) == 0 ? new EntityGlyphidBombardier(worldObj) : new EntityGlyphid(worldObj);
if(soot < MobConfig.tier3Threshold) return rand.nextInt(5) == 0 ? new EntityGlyphidBombardier(worldObj) : new EntityGlyphidBrawler(worldObj);
if(soot < MobConfig.tier4Threshold) return rand.nextInt(5) == 0 ? new EntityGlyphidBlaster(worldObj) : new EntityGlyphidBehemoth(worldObj);
if(soot < MobConfig.tier5Threshold) return rand.nextInt(5) == 0 ? new EntityGlyphidBlaster(worldObj) : new EntityGlyphidBrenda(worldObj);
public void trySpawnEntity(EntityGlyphid glyphid) {
double offsetX = glyphid.getRNG().nextGaussian() * 3;
double offsetZ = glyphid.getRNG().nextGaussian() * 3;
return rand.nextInt(3) == 0 ? new EntityGlyphidBlaster(worldObj) : new EntityGlyphidNuclear(worldObj);
for(int i = 0; i < 7; i++) {
glyphid.setLocationAndAngles(xCoord + 0.5 + offsetX, yCoord - 2 + i, zCoord + 0.5 + offsetZ, worldObj.rand.nextFloat() * 360.0F, 0.0F);
if(glyphid.getCanSpawnHere()) {
worldObj.spawnEntityInWorld(glyphid);
return;
}
}
}
public ArrayList<EntityGlyphid> createSwarm(float soot, int meta) {
Random rand = new Random();
ArrayList<EntityGlyphid> currentSpawns = new ArrayList<>();
int swarmAmount = (int) Math.min(MobConfig.baseSwarmSize * Math.max(MobConfig.swarmScalingMult * (soot / MobConfig.sootStep), 1), 10);
int cap = 100;
while(currentSpawns.size() <= swarmAmount && cap >= 0) {
// (dys)functional programing
for(Pair<Function<World, EntityGlyphid>, int[]> glyphid : spawnMap) {
int[] chance = glyphid.getValue();
int adjustedChance = (int) (chance[0] + (chance[1] - chance[1] / Math.max(((soot + 1) / 3), 1)));
if(soot >= chance[2] && rand.nextInt(100) <= adjustedChance) {
EntityGlyphid entity = glyphid.getKey().apply(worldObj);
if(meta == 1) entity.getDataWatcher().updateObject(EntityGlyphid.DW_SUBTYPE, (byte) EntityGlyphid.TYPE_INFECTED);
currentSpawns.add(entity);
}
}
cap--;
}
return currentSpawns;
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("initialSpawn", initialSpawn);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.initialSpawn = nbt.getBoolean("initialSpawn");
}
}
}

View File

@ -0,0 +1,219 @@
package com.hbm.blocks.generic;
import java.util.List;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
import com.hbm.blocks.generic.BlockPedestal.TileEntityPedestal;
import com.hbm.itempool.ItemPool;
import com.hbm.itempool.ItemPoolsRedRoom;
import com.hbm.items.ModItems;
import com.hbm.items.tool.ItemModDoor;
import com.hbm.main.MainRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockStone;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockKeyhole extends BlockStone {
protected IIcon iconTop;
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
this.iconTop = iconRegister.registerIcon("stone");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return side == 0 || side == 1 ? this.iconTop : this.blockIcon;
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
return new ItemStack(Blocks.stone);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(player.getHeldItem() != null) {
boolean cracked = player.getHeldItem().getItem() == ModItems.key_red_cracked;
if((player.getHeldItem().getItem() == ModItems.key_red || cracked) && side != 0 && side != 1) {
if(cracked) player.getHeldItem().stackSize--;
if(world.isRemote) return true;
ForgeDirection dir = ForgeDirection.getOrientation(side);
generateRoom(world, x - dir.offsetX * 4, y - 2, z - dir.offsetZ * 4);
int b = 0;
if(side == 2) b = 1;
if(side == 5) b = 2;
if(side == 3) b = 3;
if(side == 4) b = 0;
ItemModDoor.placeDoorBlock(world, x, y - 1, z, b, ModBlocks.door_red);
world.playSoundAtEntity(player, "hbm:block.lockOpen", 1.0F, 1.0F);
player.triggerAchievement(MainRegistry.achRedRoom);
return true;
}
}
return false;
}
protected static void generateRoom(World world, int x, int y, int z) {
int size = 9;
int height = 5;
int width = size / 2;
//Outer Edges, top and bottom
for(int i = -width; i <= width; i++) {
world.setBlock(x + i, y, z + width, ModBlocks.brick_red, 6, 3);
world.setBlock(x + i, y, z - width, ModBlocks.brick_red, 6, 3);
world.setBlock(x + width, y, z + i, ModBlocks.brick_red, 6, 3);
world.setBlock(x - width, y, z + i, ModBlocks.brick_red, 6, 3);
world.setBlock(x + i, y + height - 1, z + width, ModBlocks.brick_red, 6, 3);
world.setBlock(x + i, y + height - 1, z - width, ModBlocks.brick_red, 6, 3);
world.setBlock(x + width, y + height - 1, z + i, ModBlocks.brick_red, 6, 3);
world.setBlock(x - width, y + height - 1, z + i, ModBlocks.brick_red, 6, 3);
}
for(int i = 1; i <= height - 2; i++) {
//Outer edges, sides
world.setBlock(x + width, y + i, z + width, ModBlocks.brick_red, 6, 3);
world.setBlock(x + width, y + i, z - width, ModBlocks.brick_red, 6, 3);
world.setBlock(x - width, y + i, z + width, ModBlocks.brick_red, 6, 3);
world.setBlock(x - width, y + i, z - width, ModBlocks.brick_red, 6, 3);
//Walls
for(int j = -width + 1; j <= width - 1; j++) {
world.setBlock(x + width, y + i, z + j, ModBlocks.brick_red, 4, 3);
world.setBlock(x - width, y + i, z + j, ModBlocks.brick_red, 5, 3);
world.setBlock(x + j, y + i, z + width, ModBlocks.brick_red, 2, 3);
world.setBlock(x + j, y + i, z - width, ModBlocks.brick_red, 3, 3);
}
}
for(int i = -width + 1; i <= width - 1; i++) {
for(int j = -width + 1; j <= width - 1; j++) {
//Floor and ceiling
world.setBlock(x + i, y, z + j, ModBlocks.brick_red, 1, 3);
world.setBlock(x + i, y + height - 1, z + j, ModBlocks.brick_red, 0, 3);
for(int k = 1; k <= height - 2; k++) {
world.setBlock(x + i, y + k, z + j, Blocks.air);
}
}
}
//Torches
int torchDist = width - 1;
int torchOff = torchDist - 1;
world.setBlock(x + torchDist, y + 2, z + torchOff, Blocks.torch);
world.setBlock(x + torchDist, y + 2, z - torchOff, Blocks.torch);
world.setBlock(x - torchDist, y + 2, z + torchOff, Blocks.torch);
world.setBlock(x - torchDist, y + 2, z - torchOff, Blocks.torch);
world.setBlock(x + torchOff, y + 2, z + torchDist, Blocks.torch);
world.setBlock(x - torchOff, y + 2, z + torchDist, Blocks.torch);
world.setBlock(x + torchOff, y + 2, z - torchDist, Blocks.torch);
world.setBlock(x - torchOff, y + 2, z - torchDist, Blocks.torch);
//Cobwebs
if(world.rand.nextInt(4) == 0) {
for(int i = -width + 1; i <= width - 1; i++) {
for(int j = -width + 1; j <= width - 1; j++) {
if(world.rand.nextBoolean()) world.setBlock(x + i, y + height - 2, z + j, Blocks.web);
}
}
}
//Pillars
if(world.rand.nextInt(4) == 0) {
for(int i = 1; i <= height - 2; i++) {
world.setBlock(x + width - 2, y + i, z + width - 2, ModBlocks.concrete_colored, 14, 3);
world.setBlock(x + width - 2, y + i, z - width + 2, ModBlocks.concrete_colored, 14, 3);
world.setBlock(x - width + 2, y + i, z + width - 2, ModBlocks.concrete_colored, 14, 3);
world.setBlock(x - width + 2, y + i, z - width + 2, ModBlocks.concrete_colored, 14, 3);
}
}
//Fire
if(world.rand.nextInt(4) == 0) {
world.setBlock(x + width - 1, y, z + width - 1, Blocks.netherrack);
world.setBlock(x + width - 1, y, z - width + 1, Blocks.netherrack);
world.setBlock(x - width + 1, y, z + width - 1, Blocks.netherrack);
world.setBlock(x - width + 1, y, z - width + 1, Blocks.netherrack);
world.setBlock(x + width - 1, y + 1, z + width - 1, Blocks.fire);
world.setBlock(x + width - 1, y + 1, z - width + 1, Blocks.fire);
world.setBlock(x - width + 1, y + 1, z + width - 1, Blocks.fire);
world.setBlock(x - width + 1, y + 1, z - width + 1, Blocks.fire);
}
//Circle
if(world.rand.nextInt(4) == 0) {
for(int i = -1; i <= 1; i++) {
for(int j = -1; j <= 1; j++) {
if(i != 0 || j != 0) world.setBlock(x + i, y, z + j, ModBlocks.concrete_colored, 14, 3);
}
}
}
//Lava
if(world.rand.nextInt(4) == 0) {
world.setBlock(x + width - 2, y, z + width - 1, Blocks.lava);
world.setBlock(x + width - 3, y, z + width - 1, Blocks.lava);
world.setBlock(x - width + 2, y, z + width - 1, Blocks.lava);
world.setBlock(x - width + 3, y, z + width - 1, Blocks.lava);
world.setBlock(x + width - 2, y, z - width + 1, Blocks.lava);
world.setBlock(x + width - 3, y, z - width + 1, Blocks.lava);
world.setBlock(x - width + 2, y, z - width + 1, Blocks.lava);
world.setBlock(x - width + 3, y, z - width + 1, Blocks.lava);
world.setBlock(x + width - 1, y, z + width - 2, Blocks.lava);
world.setBlock(x + width - 1, y, z + width - 3, Blocks.lava);
world.setBlock(x + width - 1, y, z - width + 2, Blocks.lava);
world.setBlock(x + width - 1, y, z - width + 3, Blocks.lava);
world.setBlock(x - width + 1, y, z + width - 2, Blocks.lava);
world.setBlock(x - width + 1, y, z + width - 3, Blocks.lava);
world.setBlock(x - width + 1, y, z - width + 2, Blocks.lava);
world.setBlock(x - width + 1, y, z - width + 3, Blocks.lava);
}
int rand = world.rand.nextInt(20);
if(rand == 0) {
world.setBlock(x, y + 1, z, ModBlocks.deco_loot);
TileEntityLoot loot = (TileEntityLoot) world.getTileEntity(x, y + 1, z);
loot.addItem(new ItemStack(ModItems.trenchmaster_helmet), 0, 0, 0);
loot.addItem(new ItemStack(ModItems.trenchmaster_plate), 0, 0, 0);
loot.addItem(new ItemStack(ModItems.trenchmaster_legs), 0, 0, 0);
loot.addItem(new ItemStack(ModItems.trenchmaster_boots), 0, 0, 0);
} else {
spawnPedestalItem(world, x, y + 1, z);
}
//Clear dropped items
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x + 0.5, y, z + 0.5, x + 0.5, y + height, z + 0.5).expand(size / 2D, 0, size / 2D));
for(EntityItem item : items) item.setDead();
}
public static void spawnPedestalItem(World world, int x, int y, int z) {
world.setBlock(x, y, z, ModBlocks.pedestal);
TileEntityPedestal pedestal = (TileEntityPedestal) world.getTileEntity(x, y, z);
WeightedRandomChestContent content = (WeightedRandomChestContent) WeightedRandom.getRandomItem(world.rand, ItemPool.getPool(ItemPoolsRedRoom.POOL_RED_PEDESTAL));
pedestal.item = content.theItemId.copy();
}
}

View File

@ -101,6 +101,8 @@ public class BlockLayering extends Block {
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
if(this == ModBlocks.leaves_layer) return true;
if(this == ModBlocks.oil_spill) return true;
if(this == ModBlocks.foam_layer) return true;
int meta = world.getBlockMetadata(x, y, z);
return meta >= 7 ? false : blockMaterial.isReplaceable();
}

View File

@ -48,19 +48,6 @@ public class BlockLoot extends BlockContainer {
return null;
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
/*TileEntityLoot loot = (TileEntityLoot) world.getTileEntity(x, y, z);
if(loot != null && loot.items.isEmpty()) {
loot.addItem(new ItemStack(ModItems.gun_lever_action), 0, 0, 0);
}*/
//LootGenerator.lootCapStash(world, x, y, z);
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {

View File

@ -1,159 +0,0 @@
package com.hbm.blocks.generic;
import java.util.Random;
import com.hbm.tileentity.machine.TileEntityStructureMarker;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class BlockMarker extends BlockContainer {
public BlockMarker(Material p_i45386_1_) {
super(p_i45386_1_);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityStructureMarker();
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) {
return null;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType() {
return 2;
}
private boolean func_150107_m(World p_150107_1_, int p_150107_2_, int p_150107_3_, int p_150107_4_) {
if(World.doesBlockHaveSolidTopSurface(p_150107_1_, p_150107_2_, p_150107_3_, p_150107_4_)) {
return true;
} else {
Block block = p_150107_1_.getBlock(p_150107_2_, p_150107_3_, p_150107_4_);
return block.canPlaceTorchOnTop(p_150107_1_, p_150107_2_, p_150107_3_, p_150107_4_);
}
}
@Override
public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) {
return func_150107_m(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_);
}
@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, 6, 2);
}
if(i == 1) {
world.setBlockMetadataWithNotify(x, y, z, 7, 2);
}
if(i == 2) {
world.setBlockMetadataWithNotify(x, y, z, 8, 2);
}
if(i == 3) {
world.setBlockMetadataWithNotify(x, y, z, 9, 2);
}
}
@Override
public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) {
super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);
if(p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_) == 0) {
this.onBlockAdded(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
}
}
@Override
public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) {
this.func_150108_b(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_);
}
protected boolean func_150108_b(World p_150108_1_, int p_150108_2_, int p_150108_3_, int p_150108_4_, Block p_150108_5_) {
if(this.func_150109_e(p_150108_1_, p_150108_2_, p_150108_3_, p_150108_4_)) {
boolean flag = false;
if(!this.func_150107_m(p_150108_1_, p_150108_2_, p_150108_3_ - 1, p_150108_4_)) {
flag = true;
}
if(flag) {
this.dropBlockAsItem(p_150108_1_, p_150108_2_, p_150108_3_, p_150108_4_, p_150108_1_.getBlockMetadata(p_150108_2_, p_150108_3_, p_150108_4_), 0);
p_150108_1_.setBlockToAir(p_150108_2_, p_150108_3_, p_150108_4_);
return true;
} else {
return false;
}
} else {
return true;
}
}
protected boolean func_150109_e(World p_150109_1_, int p_150109_2_, int p_150109_3_, int p_150109_4_) {
if(!this.canPlaceBlockAt(p_150109_1_, p_150109_2_, p_150109_3_, p_150109_4_)) {
if(p_150109_1_.getBlock(p_150109_2_, p_150109_3_, p_150109_4_) == this) {
this.dropBlockAsItem(p_150109_1_, p_150109_2_, p_150109_3_, p_150109_4_, p_150109_1_.getBlockMetadata(p_150109_2_, p_150109_3_, p_150109_4_), 0);
p_150109_1_.setBlockToAir(p_150109_2_, p_150109_3_, p_150109_4_);
}
return false;
} else {
return true;
}
}
@Override
public MovingObjectPosition collisionRayTrace(World p_149731_1_, int p_149731_2_, int p_149731_3_, int p_149731_4_, Vec3 p_149731_5_, Vec3 p_149731_6_) {
float f = 0.15F;
f = 0.1F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
return super.collisionRayTrace(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_, p_149731_5_, p_149731_6_);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote) {
int i = ((TileEntityStructureMarker) world.getTileEntity(x, y, z)).type + 1;
if(i > 2) i -= 3;
if(i == 0) player.addChatMessage(new ChatComponentText("[Structure Marker] Set template: Nuclear Reactor"));
if(i == 1) player.addChatMessage(new ChatComponentText("[Structure Marker] Set template: Watz Power Plant"));
if(i == 2) player.addChatMessage(new ChatComponentText("[Structure Marker] Set template: Fusionary Watz Plant"));
return true;
} else if(!player.isSneaking()) {
if(world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileEntityStructureMarker) {
((TileEntityStructureMarker) world.getTileEntity(x, y, z)).type++;
}
return true;
} else {
return false;
}
}
}

View File

@ -0,0 +1,13 @@
package com.hbm.blocks.generic;
import com.hbm.blocks.BlockEnumMulti;
import com.hbm.blocks.BlockEnums;
import net.minecraft.block.material.Material;
public class BlockMeteorOre extends BlockEnumMulti {
public BlockMeteorOre() {
super(Material.rock, BlockEnums.EnumMeteorType.class, true, true);
}
}

View File

@ -0,0 +1,33 @@
package com.hbm.blocks.generic;
import java.util.ArrayList;
import com.hbm.itempool.ItemPool;
import com.hbm.itempool.ItemPoolsSingle;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.world.World;
public class BlockMeteoriteTreasure extends Block {
public BlockMeteoriteTreasure(Material mat) {
super(mat);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
int count = 1 + world.rand.nextInt(3);
WeightedRandomChestContent[] pool = ItemPool.getPool(ItemPoolsSingle.POOL_METEORITE_TREASURE);
for(int i = 0; i < count; i++) {
ret.add(ItemPool.getStack(pool, world.rand));
}
return ret;
}
}

View File

@ -319,6 +319,8 @@ public class BlockModDoor extends Block {
return ModItems.door_metal;
else if (this == ModBlocks.door_office)
return ModItems.door_office;
else if (this == ModBlocks.door_red)
return ModItems.door_red;
else
return ModItems.door_bunker;
}
@ -379,6 +381,8 @@ public class BlockModDoor extends Block {
return ModItems.door_metal;
else if (this == ModBlocks.door_office)
return ModItems.door_office;
else if (this == ModBlocks.door_red)
return ModItems.door_red;
else
return ModItems.door_bunker;
}

View File

@ -1,9 +1,9 @@
package com.hbm.blocks.generic;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
import com.hbm.blocks.ModBlocks;
import com.hbm.config.GeneralConfig;
import com.hbm.world.feature.HugeMush;
@ -47,17 +47,19 @@ public class BlockMush extends Block implements IGrowable, IPlantable {
}
}
private static final Set<Block> canGrowOn = Sets.newHashSet(new Block[] {
ModBlocks.waste_earth,
ModBlocks.waste_mycelium,
ModBlocks.waste_trinitite,
ModBlocks.waste_trinitite_red,
ModBlocks.block_waste,
ModBlocks.block_waste_painted,
ModBlocks.block_waste_vitrified
});
private static final Set<Block> canGrowOn = new HashSet();
public boolean canMushGrowHere(World world, int x, int y, int z) {
if(canGrowOn.isEmpty()) {
canGrowOn.add(ModBlocks.waste_earth);
canGrowOn.add(ModBlocks.waste_mycelium);
canGrowOn.add(ModBlocks.waste_trinitite);
canGrowOn.add(ModBlocks.waste_trinitite_red);
canGrowOn.add(ModBlocks.block_waste);
canGrowOn.add(ModBlocks.block_waste_painted);
canGrowOn.add(ModBlocks.block_waste_vitrified);
}
Block block = world.getBlock(x, y - 1, z);
return canGrowOn.contains(block);
}
@ -75,7 +77,7 @@ public class BlockMush extends Block implements IGrowable, IPlantable {
*/
@Override
public boolean func_149851_a(World world, int x, int y, int z, boolean b) {
return this.canMushGrowHere(world, x, y, z);
return canBlockStay(world, x, y, z);
}
/**

View File

@ -5,6 +5,7 @@ import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.radiation.ChunkRadiationManager;
import com.hbm.interfaces.Spaghetti;
import com.hbm.items.ItemEnums.EnumChunkType;
import com.hbm.items.ModItems;
import com.hbm.potion.HbmPotion;
import cpw.mods.fml.relauncher.Side;
@ -43,13 +44,13 @@ public class BlockOre extends Block {
@Spaghetti("*throws up*")
@Override
public Item getItemDropped(int i, Random rand, int j) {
if(this == ModBlocks.ore_fluorite || this == ModBlocks.basalt_fluorite) {
if(this == ModBlocks.ore_fluorite) {
return ModItems.fluorite;
}
if(this == ModBlocks.ore_niter) {
return ModItems.niter;
}
if(this == ModBlocks.ore_sulfur || this == ModBlocks.ore_nether_sulfur || this == ModBlocks.ore_meteor_sulfur || this == ModBlocks.basalt_sulfur) {
if(this == ModBlocks.ore_sulfur || this == ModBlocks.ore_nether_sulfur) {
return ModItems.sulfur;
}
if(this == ModBlocks.waste_trinitite || this == ModBlocks.waste_trinitite_red) {
@ -76,121 +77,10 @@ public class BlockOre extends Block {
if(this == ModBlocks.block_meteor_broken) {
return ModItems.fragment_meteorite;
}
if(this == ModBlocks.block_meteor_treasure) {
switch(rand.nextInt(36)) {
case 0:
return ModItems.coil_advanced_alloy;
case 1:
return ModItems.plate_advanced_alloy;
case 2:
return ModItems.powder_desh_mix;
case 3:
return ModItems.ingot_desh;
case 4:
return ModItems.battery_advanced;
case 5:
return ModItems.battery_lithium_cell;
case 6:
return ModItems.battery_advanced_cell;
case 7:
return ModItems.nugget_schrabidium;
case 8:
return ModItems.ingot_plutonium;
case 9:
return ModItems.ingot_thorium_fuel;
case 10:
return ModItems.ingot_u233;
case 11:
return ModItems.turbine_tungsten;
case 12:
return ModItems.ingot_dura_steel;
case 13:
return ModItems.ingot_polymer;
case 14:
return ModItems.ingot_tungsten;
case 15:
return ModItems.ingot_combine_steel;
case 16:
return ModItems.ingot_lanthanium;
case 17:
return ModItems.ingot_actinium;
case 18:
return Item.getItemFromBlock(ModBlocks.block_meteor);
case 19:
return Item.getItemFromBlock(ModBlocks.fusion_heater);
case 20:
return ModItems.circuit_red_copper;
case 21:
return Item.getItemFromBlock(ModBlocks.watz_element);
case 22:
return Item.getItemFromBlock(ModBlocks.ore_rare);
case 23:
return Item.getItemFromBlock(ModBlocks.fusion_conductor);
case 24:
return Item.getItemFromBlock(ModBlocks.reactor_computer);
case 25:
return Item.getItemFromBlock(ModBlocks.machine_diesel);
case 26:
return Item.getItemFromBlock(ModBlocks.machine_rtg_grey);
case 27:
return ModItems.pellet_rtg;
case 28:
return ModItems.pellet_rtg_weak;
case 29:
return ModItems.rtg_unit;
case 30:
return ModItems.gun_spark_ammo;
case 31: case 32:
return ModItems.ammo_nuke;
case 33:
return ModItems.gun_defabricator_ammo;
case 34:
return ModItems.gun_osipr_ammo2;
case 35:
return ModItems.glitch;
}
}
if(this == ModBlocks.ore_rare || this == ModBlocks.ore_gneiss_rare) {
switch(rand.nextInt(6)) {
case 0:
return ModItems.fragment_boron;
case 1:
return ModItems.fragment_cerium;
case 2:
return ModItems.fragment_cobalt;
case 3:
return ModItems.fragment_lanthanium;
case 4:
return ModItems.fragment_neodymium;
case 5:
return ModItems.fragment_niobium;
}
return ModItems.chunk_ore;
}
if(this == ModBlocks.deco_aluminium) {
return ModItems.ingot_aluminium;
}
if(this == ModBlocks.deco_beryllium) {
return ModItems.ingot_beryllium;
}
if(this == ModBlocks.deco_lead) {
return ModItems.ingot_lead;
}
if(this == ModBlocks.deco_red_copper) {
return ModItems.ingot_red_copper;
}
if(this == ModBlocks.deco_steel) {
return ModItems.ingot_steel;
}
if(this == ModBlocks.deco_titanium) {
return ModItems.ingot_titanium;
}
if(this == ModBlocks.deco_tungsten) {
return ModItems.ingot_tungsten;
}
if(this == ModBlocks.deco_asbestos) {
return ModItems.ingot_asbestos;
}
if(this == ModBlocks.ore_asbestos || this == ModBlocks.ore_gneiss_asbestos || this == ModBlocks.basalt_asbestos) {
if(this == ModBlocks.ore_asbestos || this == ModBlocks.ore_gneiss_asbestos) {
return ModItems.ingot_asbestos;
}
if(this == ModBlocks.ore_lignite) {
@ -205,24 +95,24 @@ public class BlockOre extends Block {
if(this == ModBlocks.ore_cobalt || this == ModBlocks.ore_nether_cobalt) {
return ModItems.fragment_cobalt;
}
if(this == ModBlocks.block_meteor_molten) {
return null;
}
return Item.getItemFromBlock(this);
}
@Override
public int quantityDropped(Random rand) {
if(this == ModBlocks.ore_fluorite || this == ModBlocks.basalt_fluorite) {
if(this == ModBlocks.ore_fluorite) {
return 2 + rand.nextInt(3);
}
if(this == ModBlocks.ore_niter) {
return 2 + rand.nextInt(3);
}
if(this == ModBlocks.ore_sulfur || this == ModBlocks.ore_nether_sulfur || this == ModBlocks.ore_meteor_sulfur || this == ModBlocks.basalt_sulfur) {
if(this == ModBlocks.ore_sulfur || this == ModBlocks.ore_nether_sulfur) {
return 2 + rand.nextInt(3);
}
if(this == ModBlocks.ore_rare || this == ModBlocks.ore_gneiss_rare) {
return 4 + rand.nextInt(8);
}
if(this == ModBlocks.block_meteor_broken) {
return 1 + rand.nextInt(3);
}
@ -263,7 +153,8 @@ public class BlockOre extends Block {
}
@Override
public int damageDropped(int p_149692_1_) {
public int damageDropped(int meta) {
if(this == ModBlocks.ore_rare || this == ModBlocks.ore_gneiss_rare) return EnumChunkType.RARE.ordinal();
return this == ModBlocks.waste_planks ? 1 : 0;
}
@ -345,8 +236,7 @@ public class BlockOre extends Block {
public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int i) {
if(this == ModBlocks.block_meteor_molten) {
if(!world.isRemote)
world.setBlock(x, y, z, Blocks.lava);
if(!world.isRemote) world.setBlock(x, y, z, Blocks.lava);
}
}
}

View File

@ -0,0 +1,79 @@
package com.hbm.blocks.generic;
import java.util.Locale;
import java.util.Random;
import com.hbm.blocks.BlockEnumMulti;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockOreBasalt extends BlockEnumMulti {
public BlockOreBasalt() {
super(Material.rock, EnumBasaltOreType.class, true, true);
}
public static enum EnumBasaltOreType {
SULFUR,
FLUORITE,
ASBESTOS,
GEM,
MOLYSITE
}
public String getTextureMultiName(Enum num) {
return this.getTextureName() + "_" + num.name().toLowerCase(Locale.US);
}
public String getUnlocalizedMultiName(Enum num) {
return super.getUnlocalizedName() + "_" + num.name().toLowerCase(Locale.US);
}
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
if(meta == EnumBasaltOreType.SULFUR.ordinal()) return ModItems.sulfur;
if(meta == EnumBasaltOreType.FLUORITE.ordinal()) return ModItems.fluorite;
if(meta == EnumBasaltOreType.ASBESTOS.ordinal()) return ModItems.ingot_asbestos;
if(meta == EnumBasaltOreType.GEM.ordinal()) return ModItems.gem_volcanic;
if(meta == EnumBasaltOreType.MOLYSITE.ordinal()) return ModItems.powder_molysite;
return super.getItemDropped(meta, rand, fortune);
}
@Override
public int damageDropped(int meta) {
return 0;
}
@Override
public void onEntityWalking(World world, int x, int y, int z, Entity entity) {
int meta = world.getBlockMetadata(x, y, z);
if(meta == EnumBasaltOreType.ASBESTOS.ordinal() && world.getBlock(x, y + 1, z) == Blocks.air) {
if(world.rand.nextInt(10) == 0) world.setBlock(x, y + 1, z, ModBlocks.gas_asbestos);
for(int i = 0; i < 5; i++) world.spawnParticle("townaura", x + world.rand.nextFloat(), y + 1.1, z + world.rand.nextFloat(), 0.0D, 0.0D, 0.0D);
}
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
int meta = world.getBlockMetadata(x, y, z);
if(meta == EnumBasaltOreType.ASBESTOS.ordinal()) for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if(world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) == Blocks.air) {
world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ModBlocks.gas_asbestos);
}
}
}
@Override
public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int fortune) {
if(meta == EnumBasaltOreType.ASBESTOS.ordinal()) world.setBlock(x, y, z, ModBlocks.gas_asbestos);
super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, fortune);
}
}

View File

@ -57,8 +57,7 @@ public class BlockOutgas extends BlockOre {
if(this == ModBlocks.ore_asbestos || this == ModBlocks.ore_gneiss_asbestos ||
this == ModBlocks.block_asbestos || this == ModBlocks.deco_asbestos ||
this == ModBlocks.brick_asbestos || this == ModBlocks.tile_lab ||
this == ModBlocks.tile_lab_cracked || this == ModBlocks.tile_lab_broken ||
this == ModBlocks.basalt_asbestos) {
this == ModBlocks.tile_lab_cracked || this == ModBlocks.tile_lab_broken) {
return ModBlocks.gas_asbestos;
}

View File

@ -0,0 +1,148 @@
package com.hbm.blocks.generic;
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.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockPedestal extends BlockContainer {
protected IIcon iconSide;
public BlockPedestal() {
super(Material.rock);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityPedestal();
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
this.iconSide = iconRegister.registerIcon(RefStrings.MODID + ":pedestal_side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return side == 0 || side == 1 ? this.blockIcon : this.iconSide;
}
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override
public int getRenderType() {
return renderID;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
return true;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote) return true;
if(player.isSneaking()) return false;
TileEntityPedestal pedestal = (TileEntityPedestal) world.getTileEntity(x, y, z);
if(pedestal.item == null && player.getHeldItem() != null) {
pedestal.item = player.getHeldItem().copy();
player.inventory.mainInventory[player.inventory.currentItem] = null;
pedestal.markDirty();
world.markBlockForUpdate(x, y, z);
return true;
} else if(pedestal.item != null && player.getHeldItem() == null) {
player.inventory.mainInventory[player.inventory.currentItem] = pedestal.item.copy();
pedestal.item = null;
pedestal.markDirty();
world.markBlockForUpdate(x, y, z);
return true;
}
return false;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(!world.isRemote) {
TileEntityPedestal entity = (TileEntityPedestal) world.getTileEntity(x, y, z);
if(entity != null && entity.item != null) {
EntityItem item = new EntityItem(world, x + 0.5, y, z + 0.5, entity.item.copy());
world.spawnEntityInWorld(item);
}
}
super.breakBlock(world, x, y, z, block, meta);
}
public static class TileEntityPedestal extends TileEntity {
public ItemStack item;
@Override
public boolean canUpdate() {
return false;
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
this.writeToNBT(nbt);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
this.readFromNBT(pkt.func_148857_g());
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.item = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("item"));
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
if(this.item != null) {
NBTTagCompound stack = new NBTTagCompound();
this.item.writeToNBT(stack);
nbt.setTag("item", stack);
}
}
}
}

View File

@ -0,0 +1,52 @@
package com.hbm.blocks.generic;
import java.util.Random;
import com.hbm.lib.RefStrings;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockRedBrick extends Block {
protected IIcon iconFront;
protected IIcon iconTop;
public BlockRedBrick(Material material) {
super(material);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + ":brick_red");
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":brick_red_top");
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":brick_base");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return side == meta ? (side == 0 || side == 1 ? this.iconTop : this.iconFront) : this.blockIcon;
}
@Override
public Item getItemDropped(int i, Random rand, int j) {
return null;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
int l = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, l, 2);
}
}

View File

@ -8,11 +8,14 @@ import com.hbm.handler.radiation.ChunkRadiationManager;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.potion.HbmPotion;
import com.hbm.render.icon.RGBMutatorInterpolatedComponentRemap;
import com.hbm.render.icon.TextureAtlasSpriteMutatable;
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.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@ -20,12 +23,17 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockSellafield extends BlockHazard {
//Sellafite blocks should probably be entirely metadata, but removing them now might mess with shit
//...Ah, fuck it! Noone cares anyway.
@SideOnly(Side.CLIENT)
protected IIcon[][] icons;
public static final int SELLAFITE_LEVELS = 6;
public static final int TEXTURE_VARIANTS = 4;
public BlockSellafield(Material mat) {
super(mat);
this.setCreativeTab(MainRegistry.blockTab);
@ -56,10 +64,6 @@ public class BlockSellafield extends BlockHazard {
}
@Override public void onBlockAdded(World world, int x, int y, int z) { }
@SideOnly(Side.CLIENT)
protected IIcon[] icons;
@Override
public int damageDropped(int meta) {
@ -69,24 +73,62 @@ public class BlockSellafield extends BlockHazard {
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tabs, List list) {
for(byte i = 0; i < 6; i++) {
for(byte i = 0; i < SELLAFITE_LEVELS; i++) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
super.registerBlockIcons(iconRegister);
icons = new IIcon[6];
public void registerBlockIcons(IIconRegister reg) {
super.registerBlockIcons(reg);
icons = new IIcon[SELLAFITE_LEVELS][TEXTURE_VARIANTS];
String[] names = new String[] {
RefStrings.MODID + ":sellafield_slaked",
RefStrings.MODID + ":sellafield_slaked_1",
RefStrings.MODID + ":sellafield_slaked_2",
RefStrings.MODID + ":sellafield_slaked_3"
};
for(byte i = 0; i < 6; i++)
icons[i] = iconRegister.registerIcon(RefStrings.MODID + ":sellafield_" + i);
if(reg instanceof TextureMap) {
TextureMap map = (TextureMap) reg;
int[][] colors = new int[][] {
{0x4C7939, 0x41463F},
{0x418223, 0x3E443B},
{0x338C0E, 0x3B5431},
{0x1C9E00, 0x394733},
{0x02B200, 0x37492F},
{0x00D300, 0x324C26}
};
for(int level = 0; level < SELLAFITE_LEVELS; level++) {
int[] tint = colors[level];
for(int subtype = 0; subtype < TEXTURE_VARIANTS; subtype++) {
String texName = names[subtype];
String placeholderName = texName + "-" + level + "-" + subtype;
TextureAtlasSpriteMutatable mutableIcon = new TextureAtlasSpriteMutatable(placeholderName, new RGBMutatorInterpolatedComponentRemap(0x858384, 0x434343, tint[0], tint[1])).setBlockAtlas();
map.setTextureEntry(placeholderName, mutableIcon);
icons[level][subtype] = mutableIcon;
}
}
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
long l = (long) (x * 3129871) ^ (long)y * 116129781L ^ (long)z;
l = l * l * 42317861L + l * 11L;
int i = (int)(l >> 16 & 3L);
int meta = world.getBlockMetadata(x, y, z);
return icons[(int)(Math.abs(meta) % SELLAFITE_LEVELS)][(int)(Math.abs(i) % TEXTURE_VARIANTS)];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return this.icons[meta % this.icons.length];
return this.icons[(int) Math.abs(meta) % this.icons.length][0];
}
}

View File

@ -0,0 +1,108 @@
package com.hbm.blocks.generic;
import java.util.Random;
import com.hbm.blocks.IBlockMultiPass;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import com.hbm.render.block.RenderBlockMultipass;
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.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
public class BlockSellafieldOre extends BlockSellafieldSlaked implements IBlockMultiPass {
public BlockSellafieldOre(Material mat) {
super(mat);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
this.blockIcon = reg.registerIcon(this.getTextureName());
super.registerBlockIcons(reg);
}
@Override
public int getRenderType() {
return IBlockMultiPass.getRenderType();
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
if(RenderBlockMultipass.currentPass == 1) return this.blockIcon;
return super.getIcon(world, x, y, z, side);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
if(RenderBlockMultipass.currentPass == 1) return this.blockIcon;
return icons[0];
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
if(RenderBlockMultipass.currentPass == 1) return 0xffffff;
return super.colorMultiplier(world, x, y, z);
}
@Override
public int getPasses() {
return 2;
}
@Override
public boolean shouldRenderItemMulti() {
return true;
}
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
if(this == ModBlocks.ore_sellafield_diamond) return Items.diamond;
if(this == ModBlocks.ore_sellafield_emerald) return Items.emerald;
if(this == ModBlocks.ore_sellafield_radgem) return ModItems.gem_rad;
return Item.getItemFromBlock(this);
}
@Override
public int quantityDropped(Random rand) {
return 1;
}
@Override
public int quantityDroppedWithBonus(int fortune, Random rand) {
if(fortune > 0 && Item.getItemFromBlock(this) != this.getItemDropped(0, rand, fortune)) {
int j = rand.nextInt(fortune + 2) - 1;
if(j < 0) j = 0;
return this.quantityDropped(rand) * (j + 1);
} else {
return this.quantityDropped(rand);
}
}
private Random rand = new Random();
@Override
public int getExpDrop(IBlockAccess world, int meta, int fortune) {
if(this.getItemDropped(meta, rand, fortune) != Item.getItemFromBlock(this)) {
int j1 = 0;
if(this == ModBlocks.ore_sellafield_diamond) j1 = MathHelper.getRandomIntegerInRange(rand, 3, 7);
if(this == ModBlocks.ore_sellafield_emerald) j1 = MathHelper.getRandomIntegerInRange(rand, 3, 7);
if(this == ModBlocks.ore_sellafield_radgem) j1 = MathHelper.getRandomIntegerInRange(rand, 3, 7);
return j1;
}
return 0;
}
}

View File

@ -0,0 +1,53 @@
package com.hbm.blocks.generic;
import java.awt.Color;
import com.hbm.lib.RefStrings;
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.util.IIcon;
import net.minecraft.world.IBlockAccess;
public class BlockSellafieldSlaked extends Block {
public IIcon[] icons;
public BlockSellafieldSlaked(Material mat) {
super(mat);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
long l = (long) (x * 3129871) ^ (long)y * 116129781L ^ (long)z;
l = l * l * 42317861L + l * 11L;
int i = (int)(l >> 16 & 3L);
return icons[(int)(Math.abs(i) % icons.length)];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return icons[0];
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
icons = new IIcon[4];
icons[0] = reg.registerIcon(RefStrings.MODID + ":sellafield_slaked");
icons[1] = reg.registerIcon(RefStrings.MODID + ":sellafield_slaked_1");
icons[2] = reg.registerIcon(RefStrings.MODID + ":sellafield_slaked_2");
icons[3] = reg.registerIcon(RefStrings.MODID + ":sellafield_slaked_3");
}
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return Color.HSBtoRGB(0F, 0F, 1F - meta / 15F);
}
}

View File

@ -3,8 +3,9 @@ package com.hbm.blocks.generic;
import java.util.List;
import java.util.Random;
import com.hbm.inventory.gui.GUIScreenSnowglobe;
import com.hbm.main.MainRegistry;
import com.hbm.wiaj.WorldInAJar;
import com.hbm.tileentity.IGUIProvider;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
@ -12,11 +13,12 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -24,11 +26,13 @@ import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockSnowglobe extends BlockContainer {
public class BlockSnowglobe extends BlockContainer implements IGUIProvider {
public BlockSnowglobe() {
super(Material.glass);
@ -56,13 +60,8 @@ public class BlockSnowglobe extends BlockContainer {
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
TileEntitySnowglobe entity = (TileEntitySnowglobe) world.getTileEntity(x, y, z);
if(entity != null) {
return new ItemStack(this, 1, entity.type.ordinal());
}
if(entity != null) return new ItemStack(this, 1, entity.type.ordinal());
return super.getPickBlock(target, world, x, y, z, player);
}
@ -98,9 +97,7 @@ public class BlockSnowglobe extends BlockContainer {
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for(int i = 1; i < SnowglobeType.values().length; i++)
list.add(new ItemStack(item, 1, i));
for(int i = 1; i < SnowglobeType.values().length; i++) list.add(new ItemStack(item, 1, i));
}
@Override
@ -112,6 +109,18 @@ public class BlockSnowglobe extends BlockContainer {
bobble.type = SnowglobeType.values()[Math.abs(stack.getItemDamage()) % SnowglobeType.values().length];
bobble.markDirty();
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
float f = 0.0625F;
this.setBlockBounds(4F * f, 0.0F, 4F * f, 1.0F - 4F * f, 0.3125F, 1.0F - 4F * f);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int 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);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
@ -153,23 +162,30 @@ public class BlockSnowglobe extends BlockContainer {
}
public static enum SnowglobeType {
NONE("NONE", new WorldInAJar(1, 1, 1)),
TEST("Test", getTestJar());
NONE( "NONE", null),
RIVETCITY( "Rivet City", "Welcome to Rivet City. Please wait while the bridge extends."),
TENPENNYTOWER( "Tenpenny Tower", "Tenpenny Tower is the brainchild of Allistair Tenpenny, a British refugee who came to the Capital Wasteland seeking his fortune."),
LUCKY38( "Lucky 38", "My guess? Leads to a big cashout at some casino - and if the \"38\" on it is any indication... well... Lucky 38 it is."),
SIERRAMADRE( "Sierra Madre", "It's the moment you've been waiting for, the reason we're all here - the Gala Event, the Grand Opening of the Sierra Madre Casino."),
PRYDWEN( "The Prydwen", "People of the Commonwealth. Do not interfere. Our intentions are peaceful. We are the Brotherhood of Steel.");
public String label;
public WorldInAJar scene;
public String inscription;
private SnowglobeType(String label, WorldInAJar scene) {
private SnowglobeType(String label, String inscription) {
this.label = label;
this.scene = scene;
this.inscription = inscription;
}
}
private static WorldInAJar getTestJar() {
WorldInAJar world = new WorldInAJar(3, 3, 3);
for(int x = 0; x < 3; x++) for(int z = 0; z < 3; z++) world.setBlock(x, 0, z, Blocks.brick_block, 0);
world.setBlock(1, 1, 1, Blocks.gold_block, 0);
world.setBlock(1, 2, 1, Blocks.gold_block, 0);
return world;
@Override
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
@Override
@SideOnly(Side.CLIENT)
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUIScreenSnowglobe((TileEntitySnowglobe) world.getTileEntity(x, y, z));
}
}

View File

@ -13,7 +13,6 @@ import com.hbm.inventory.RecipesCommon.AStack;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.RecipesCommon.MetaBlock;
import com.hbm.inventory.RecipesCommon.OreDictStack;
import com.hbm.items.ModItems;
import com.hbm.util.I18nUtil;
import com.hbm.util.InventoryUtil;
import com.hbm.util.Tuple.Pair;
@ -151,7 +150,7 @@ public class BlockToolConversion extends BlockMulti implements IToolable, ILookO
public static HashMap<Pair<ToolType, MetaBlock>, Pair<AStack[], MetaBlock>> conversions = new HashMap();
public static void registerRecipes() {
conversions.put(new Pair(ToolType.BOLT, new MetaBlock(ModBlocks.watz_end, 0)), new Pair(new AStack[] {new ComparableStack(ModItems.bolt_dura_steel, 4)}, new MetaBlock(ModBlocks.watz_end, 1)));
conversions.put(new Pair(ToolType.BOLT, new MetaBlock(ModBlocks.watz_end, 0)), new Pair(new AStack[] {new OreDictStack(OreDictManager.DURA.bolt(), 4)}, new MetaBlock(ModBlocks.watz_end, 1)));
conversions.put(new Pair(ToolType.TORCH, new MetaBlock(ModBlocks.fusion_conductor, 0)), new Pair(new AStack[] {new OreDictStack(OreDictManager.STEEL.plateCast())}, new MetaBlock(ModBlocks.fusion_conductor, 1)));
}

View File

@ -3,7 +3,6 @@ package com.hbm.blocks.generic;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.tileentity.deco.TileEntityBomber;
import com.hbm.tileentity.deco.TileEntityDecoBlock;
import cpw.mods.fml.client.registry.RenderingRegistry;
@ -28,17 +27,11 @@ public class DecoBlock extends BlockContainer {
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
if(this == ModBlocks.bomber)
return new TileEntityBomber();
if(this == ModBlocks.steel_scaffold || this == ModBlocks.steel_beam)
return null;
if(this == ModBlocks.steel_scaffold || this == ModBlocks.steel_beam) return null;
return new TileEntityDecoBlock();
}
public static int renderIDBeam = RenderingRegistry.getNextAvailableRenderId();
public static int renderIDBeam = RenderingRegistry.getNextAvailableRenderId();
@Override
public int getRenderType(){
@ -59,158 +52,136 @@ public class DecoBlock extends BlockContainer {
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
if(this == ModBlocks.bomber)
return null;
return Item.getItemFromBlock(this);
}
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return Item.getItemFromBlock(this);
}
@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)
{
if(i == 0) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(i == 1)
{
if(i == 1) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
if(i == 2)
{
if(i == 2) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(i == 3)
{
if(i == 3) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) {
int te = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_);
float f = 0.0625F;
if(this == ModBlocks.steel_wall)
{
switch(te)
{
float f = 0.0625F;
if(this == ModBlocks.steel_wall) {
switch(te) {
case 4:
this.setBlockBounds(14*f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
this.setBlockBounds(14 * f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
case 2:
this.setBlockBounds(0.0F, 0.0F, 14*f, 1.0F, 1.0F, 1.0F);
break;
this.setBlockBounds(0.0F, 0.0F, 14 * f, 1.0F, 1.0F, 1.0F);
break;
case 5:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 2*f, 1.0F, 1.0F);
break;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 2 * f, 1.0F, 1.0F);
break;
case 3:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 2*f);
break;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 2 * f);
break;
}
}
if(this == ModBlocks.steel_corner)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
if(this == ModBlocks.steel_roof)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1*f, 1.0F);
}
if(this == ModBlocks.steel_beam)
{
this.setBlockBounds(7*f, 0.0F, 7*f, 9*f, 1.0F, 9*f);
}
if(this == ModBlocks.steel_scaffold)
{
this.setBlockBounds(0.0F, 0.0F, 2*f, 1.0F, 1.0F, 14*f);
switch(te)
{
}
if(this == ModBlocks.steel_corner) {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
if(this == ModBlocks.steel_roof) {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1 * f, 1.0F);
}
if(this == ModBlocks.steel_beam) {
this.setBlockBounds(7 * f, 0.0F, 7 * f, 9 * f, 1.0F, 9 * f);
}
if(this == ModBlocks.steel_scaffold) {
this.setBlockBounds(0.0F, 0.0F, 2 * f, 1.0F, 1.0F, 14 * f);
switch(te) {
case 4:
this.setBlockBounds(2*f, 0.0F, 0.0F, 14*f, 1.0F, 1.0F);
break;
this.setBlockBounds(2 * f, 0.0F, 0.0F, 14 * f, 1.0F, 1.0F);
break;
case 2:
this.setBlockBounds(0.0F, 0.0F, 2*f, 1.0F, 1.0F, 14*f);
break;
this.setBlockBounds(0.0F, 0.0F, 2 * f, 1.0F, 1.0F, 14 * f);
break;
case 5:
this.setBlockBounds(2*f, 0.0F, 0.0F, 14*f, 1.0F, 1.0F);
break;
this.setBlockBounds(2 * f, 0.0F, 0.0F, 14 * f, 1.0F, 1.0F);
break;
case 3:
this.setBlockBounds(0.0F, 0.0F, 2*f, 1.0F, 1.0F, 14*f);
break;
this.setBlockBounds(0.0F, 0.0F, 2 * f, 1.0F, 1.0F, 14 * f);
break;
}
}
//this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
// this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
int te = world.getBlockMetadata(x, y, z);
float f = 0.0625F;
if(this == ModBlocks.steel_wall)
{
switch(te)
{
float f = 0.0625F;
if(this == ModBlocks.steel_wall) {
switch(te) {
case 4:
this.setBlockBounds(14*f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
this.setBlockBounds(14 * f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
case 2:
this.setBlockBounds(0.0F, 0.0F, 14*f, 1.0F, 1.0F, 1.0F);
break;
this.setBlockBounds(0.0F, 0.0F, 14 * f, 1.0F, 1.0F, 1.0F);
break;
case 5:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 2*f, 1.0F, 1.0F);
break;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 2 * f, 1.0F, 1.0F);
break;
case 3:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 2*f);
break;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 2 * f);
break;
}
}
if(this == ModBlocks.steel_corner)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
if(this == ModBlocks.steel_roof)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1*f, 1.0F);
}
if(this == ModBlocks.steel_beam)
{
this.setBlockBounds(7*f, 0.0F, 7*f, 9*f, 1.0F, 9*f);
}
if(this == ModBlocks.steel_scaffold)
{
this.setBlockBounds(0.0F, 0.0F, 2*f, 1.0F, 1.0F, 14*f);
switch(te)
{
}
if(this == ModBlocks.steel_corner) {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
if(this == ModBlocks.steel_roof) {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1 * f, 1.0F);
}
if(this == ModBlocks.steel_beam) {
this.setBlockBounds(7 * f, 0.0F, 7 * f, 9 * f, 1.0F, 9 * f);
}
if(this == ModBlocks.steel_scaffold) {
this.setBlockBounds(0.0F, 0.0F, 2 * f, 1.0F, 1.0F, 14 * f);
switch(te) {
case 4:
this.setBlockBounds(2*f, 0.0F, 0.0F, 14*f, 1.0F, 1.0F);
break;
this.setBlockBounds(2 * f, 0.0F, 0.0F, 14 * f, 1.0F, 1.0F);
break;
case 2:
this.setBlockBounds(0.0F, 0.0F, 2*f, 1.0F, 1.0F, 14*f);
break;
this.setBlockBounds(0.0F, 0.0F, 2 * f, 1.0F, 1.0F, 14 * f);
break;
case 5:
this.setBlockBounds(2*f, 0.0F, 0.0F, 14*f, 1.0F, 1.0F);
break;
this.setBlockBounds(2 * f, 0.0F, 0.0F, 14 * f, 1.0F, 1.0F);
break;
case 3:
this.setBlockBounds(0.0F, 0.0F, 2*f, 1.0F, 1.0F, 14*f);
break;
this.setBlockBounds(0.0F, 0.0F, 2 * f, 1.0F, 1.0F, 14 * f);
break;
}
}
}
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
}
}

View File

@ -120,87 +120,11 @@ public class Guide extends Block implements ILookOverlay {
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote && !player.isSneaking()) {
for(int i = 0; i < 10; i++) {
MainRegistry.proxy.openLink(/*"https://ntm.fandom.com/wiki/HBM%27s_Nuclear_Tech_Wiki"*/ "https://www.youtube.com/watch?v=dQw4w9WgXcQ");
MainRegistry.proxy.openLink("https://gist.githubusercontent.com/HbmMods/ce11ffd908e98d4159f89011aca5c0b1/raw/5cbb1afdca06648319ee4293516f3c5f7cc448ca/go%2520fuck%2520yourself");
}
MainRegistry.proxy.openLink("https://nucleartech.wiki/wiki/Main_Page");
return true;
}
return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
/*if(!player.isSneaking())
{
ItemStack book1 = new ItemStack(Items.written_book);
book1.stackTagCompound = new NBTTagCompound();
book1.stackTagCompound.setString("author", "HbMinecraft");
book1.stackTagCompound.setString("title", "Hbm's Nuclear Tech Mod Part 1: Resources");
NBTTagList pages1 = new NBTTagList();
for(String s : Library.book1) {
pages1.appendTag(new NBTTagString(s));
}
book1.stackTagCompound.setTag("pages", pages1);
player.inventory.addItemStackToInventory(book1);
ItemStack book2 = new ItemStack(Items.written_book);
book2.stackTagCompound = new NBTTagCompound();
book2.stackTagCompound.setString("author", "HbMinecraft");
book2.stackTagCompound.setString("title", "Hbm's Nuclear Tech Mod Part 2: Machines");
NBTTagList pages2 = new NBTTagList();
for(String s : Library.book2) {
pages2.appendTag(new NBTTagString(s));
}
book2.stackTagCompound.setTag("pages", pages2);
player.inventory.addItemStackToInventory(book2);
ItemStack book3 = new ItemStack(Items.written_book);
book3.stackTagCompound = new NBTTagCompound();
book3.stackTagCompound.setString("author", "HbMinecraft");
book3.stackTagCompound.setString("title", "Hbm's Nuclear Tech Mod Part 3: Bombs");
NBTTagList pages3 = new NBTTagList();
for(String s : Library.book3) {
pages3.appendTag(new NBTTagString(s));
}
book3.stackTagCompound.setTag("pages", pages3);
player.inventory.addItemStackToInventory(book3);
ItemStack book4 = new ItemStack(Items.written_book);
book4.stackTagCompound = new NBTTagCompound();
book4.stackTagCompound.setString("author", "HbMinecraft");
book4.stackTagCompound.setString("title", "Hbm's Nuclear Tech Mod Part 4: Missiles");
NBTTagList pages4 = new NBTTagList();
for(String s : Library.book4) {
pages4.appendTag(new NBTTagString(s));
}
book4.stackTagCompound.setTag("pages", pages4);
player.inventory.addItemStackToInventory(book4);
ItemStack book5 = new ItemStack(Items.written_book);
book5.stackTagCompound = new NBTTagCompound();
book5.stackTagCompound.setString("author", "HbMinecraft");
book5.stackTagCompound.setString("title", "Hbm's Nuclear Tech Mod Part 5: Misc");
NBTTagList pages5 = new NBTTagList();
for(String s : Library.book5) {
pages5.appendTag(new NBTTagString(s));
}
book5.stackTagCompound.setTag("pages", pages5);
player.inventory.addItemStackToInventory(book5);
return true;
} else {
return false;
}*/
}
@Override

View File

@ -3,7 +3,7 @@ package com.hbm.blocks.generic;
import com.hbm.items.armor.ArmorFSB;
import com.hbm.items.armor.ArmorFSBPowered;
import api.hbm.energy.IBatteryItem;
import api.hbm.energymk2.IBatteryItem;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

View File

@ -77,27 +77,13 @@ public class ReinforcedLamp extends Block {
return new ItemStack(getOff());
}
private Block getOff() {
if(this == ModBlocks.reinforced_lamp_on)
return ModBlocks.reinforced_lamp_off;
if(this == ModBlocks.lamp_tritium_green_on)
return ModBlocks.lamp_tritium_green_off;
if(this == ModBlocks.lamp_tritium_blue_on)
return ModBlocks.lamp_tritium_blue_off;
protected Block getOff() {
if(this == ModBlocks.reinforced_lamp_on) return ModBlocks.reinforced_lamp_off;
return this;
}
private Block getOn() {
if(this == ModBlocks.reinforced_lamp_off)
return ModBlocks.reinforced_lamp_on;
if(this == ModBlocks.lamp_tritium_green_off)
return ModBlocks.lamp_tritium_green_on;
if(this == ModBlocks.lamp_tritium_blue_off)
return ModBlocks.lamp_tritium_blue_on;
protected Block getOn() {
if(this == ModBlocks.reinforced_lamp_off) return ModBlocks.reinforced_lamp_on;
return this;
}
}

View File

@ -0,0 +1,117 @@
package com.hbm.blocks.generic;
import java.util.Random;
import com.hbm.blocks.ISpotlight;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.Spotlight;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TritiumLamp extends Block implements ISpotlight {
private final boolean isOn;
public TritiumLamp(Material mat, boolean isOn) {
super(mat);
this.isOn = isOn;
if(isOn) {
this.setLightLevel(1.0F);
}
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
if(!world.isRemote) {
if(this.isOn && !world.isBlockIndirectlyGettingPowered(x, y, z)) {
world.scheduleBlockUpdate(x, y, z, this, 4);
} else if(!this.isOn && world.isBlockIndirectlyGettingPowered(x, y, z)) {
world.setBlock(x, y, z, getOn(), 0, 2);
}
updateBeam(world, x, y, z);
}
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block b) {
if(!world.isRemote) {
if(this.isOn && !world.isBlockIndirectlyGettingPowered(x, y, z)) {
world.scheduleBlockUpdate(x, y, z, this, 4);
} else if(!this.isOn && world.isBlockIndirectlyGettingPowered(x, y, z)) {
world.setBlock(x, y, z, getOn(), 0, 2);
}
updateBeam(world, x, y, z);
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random p_149674_5_) {
if(!world.isRemote && this.isOn && !world.isBlockIndirectlyGettingPowered(x, y, z)) {
world.setBlock(x, y, z, getOff(), 0, 2);
}
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
super.breakBlock(world, x, y, z, block, metadata);
if(world.isRemote) return;
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) Spotlight.unpropagateBeam(world, x, y, z, dir);
}
private void updateBeam(World world, int x, int y, int z) {
if(!isOn) return;
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) Spotlight.propagateBeam(world, x, y, z, dir, getBeamLength());
}
@Override
public Item getItemDropped(int i, Random r, int j) {
return Item.getItemFromBlock(getOff());
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem(World world, int x, int y, int z) {
return Item.getItemFromBlock(getOff());
}
@Override
protected ItemStack createStackedBlock(int e) {
return new ItemStack(getOff());
}
protected Block getOff() {
if(this == ModBlocks.lamp_tritium_green_on) return ModBlocks.lamp_tritium_green_off;
if(this == ModBlocks.lamp_tritium_blue_on) return ModBlocks.lamp_tritium_blue_off;
return this;
}
protected Block getOn() {
if(this == ModBlocks.lamp_tritium_green_off) return ModBlocks.lamp_tritium_green_on;
if(this == ModBlocks.lamp_tritium_blue_off) return ModBlocks.lamp_tritium_blue_on;
return this;
}
@Override
public int getBeamLength() {
return 8;
}
}

View File

@ -129,29 +129,31 @@ public class WasteEarth extends Block {
if(this == ModBlocks.burning_earth) {
for(int i = -1; i < 2; i++) {
for(int j = -1; j < 2; j++) {
for(int k = -1; k < 2; k++) {
if(!world.blockExists(x + i, y + j, z + k)) continue;
Block b0 = world.getBlock(x + i, y + j, z + k);
Block b1 = world.getBlock(x + i, y + j + 1, z + k);
if(!b1.isOpaqueCube() &&
((b0 == Blocks.grass || b0 == Blocks.mycelium || b0 == ModBlocks.waste_earth ||
b0 == ModBlocks.frozen_grass || b0 == ModBlocks.waste_mycelium)
&& !world.canLightningStrikeAt(x, y, z))) {
world.setBlock(x + i, y + j, z + k, ModBlocks.burning_earth);
}
if((b0 instanceof BlockLeaves || b0 instanceof BlockBush)) {
world.setBlockToAir(x + i, y + j, z + k);
}
if(b0 == ModBlocks.frozen_dirt) {
world.setBlock(x + i, y + j, z + k, Blocks.dirt);
}
if(b1.isFlammable(world, x, y, z, ForgeDirection.UP) && !(b1 instanceof BlockLeaves || b1 instanceof BlockBush) && world.getBlock(x, y + 1, z) == Blocks.air) {
world.setBlock(x, y + 1, z, Blocks.fire);
if(rand.nextInt(5) == 0) {
for(int i = -1; i < 2; i++) {
for(int j = -1; j < 2; j++) {
for(int k = -1; k < 2; k++) {
if(!world.blockExists(x + i, y + j, z + k)) continue;
Block b0 = world.getBlock(x + i, y + j, z + k);
Block b1 = world.getBlock(x + i, y + j + 1, z + k);
if(!b1.isOpaqueCube() &&
((b0 == Blocks.grass || b0 == Blocks.mycelium || b0 == ModBlocks.waste_earth ||
b0 == ModBlocks.frozen_grass || b0 == ModBlocks.waste_mycelium)
&& !world.canLightningStrikeAt(x, y, z))) {
world.setBlock(x + i, y + j, z + k, ModBlocks.burning_earth);
}
if((b0 instanceof BlockLeaves || b0 instanceof BlockBush)) {
world.setBlockToAir(x + i, y + j, z + k);
}
if(b0 == ModBlocks.frozen_dirt) {
world.setBlock(x + i, y + j, z + k, Blocks.dirt);
}
if(b1.isFlammable(world, x, y, z, ForgeDirection.UP) && !(b1 instanceof BlockLeaves || b1 instanceof BlockBush) && world.getBlock(x, y + 1, z) == Blocks.air) {
world.setBlock(x, y + 1, z, Blocks.fire);
}
}
}
}

View File

@ -1,108 +0,0 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.MultiblockHandler;
import com.hbm.interfaces.IMultiblock;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityAMSBase;
import com.hbm.tileentity.machine.TileEntityDummy;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockAMSBase extends BlockContainer implements IMultiblock {
public BlockAMSBase(Material p_i45386_1_) {
super(p_i45386_1_);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityAMSBase();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote)
{
return true;
} else if(!player.isSneaking())
{
TileEntityAMSBase entity = (TileEntityAMSBase) world.getTileEntity(x, y, z);
if(entity != null)
{
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
}
return true;
} else {
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) {
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.AMSBaseDimension)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.AMSBaseDimension, ModBlocks.dummy_block_ams_base);
DummyBlockAMSBase.safeBreak = true;
world.setBlock(x + 1, y, z, ModBlocks.dummy_port_ams_base);
TileEntity te = world.getTileEntity(x + 1, y, z);
if(te instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
world.setBlock(x, y, z - 1, ModBlocks.dummy_port_ams_base);
TileEntity te2 = world.getTileEntity(x, y, z - 1);
if(te instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te2;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
world.setBlock(x - 1, y, z, ModBlocks.dummy_port_ams_base);
TileEntity te3 = world.getTileEntity(x - 1, y, z);
if(te3 instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te3;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
world.setBlock(x, y, z + 1, ModBlocks.dummy_port_ams_base);
TileEntity te4 = world.getTileEntity(x, y , z + 1);
if(te4 instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te4;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
DummyBlockAMSBase.safeBreak = false;
} else
world.func_147480_a(x, y, z, true);
}
}

View File

@ -1,116 +0,0 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.MultiblockHandler;
import com.hbm.interfaces.IMultiblock;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityAMSEmitter;
import com.hbm.tileentity.machine.TileEntityDummy;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockAMSEmitter extends BlockContainer implements IMultiblock {
public BlockAMSEmitter(Material p_i45386_1_) {
super(p_i45386_1_);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityAMSEmitter();
}
@Override
public int getRenderType(){
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote)
{
return true;
} else if(!player.isSneaking())
{
TileEntityAMSEmitter entity = (TileEntityAMSEmitter) world.getTileEntity(x, y, z);
if(entity != null)
{
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
}
return true;
} else {
return false;
}
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.AMSEmitterDimension)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.AMSEmitterDimension, ModBlocks.dummy_block_ams_emitter);
DummyBlockAMSEmitter.safeBreak = true;
world.setBlock(x, y + 5, z, ModBlocks.dummy_port_ams_emitter);
TileEntity te = world.getTileEntity(x, y + 5, z);
if(te instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
world.setBlock(x, y + 5, z - 1, ModBlocks.dummy_port_ams_emitter);
TileEntity te2 = world.getTileEntity(x, y + 5, z - 1);
if(te instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te2;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
world.setBlock(x + 1, y + 5, z, ModBlocks.dummy_port_ams_emitter);
TileEntity te3 = world.getTileEntity(x + 1, y + 5, z);
if(te3 instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te3;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
world.setBlock(x - 1, y + 5, z, ModBlocks.dummy_port_ams_emitter);
TileEntity te4 = world.getTileEntity(x - 1, y + 5, z);
if(te4 instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te4;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
world.setBlock(x, y + 5, z + 1, ModBlocks.dummy_port_ams_emitter);
TileEntity te5 = world.getTileEntity(x, y + 5, z + 1);
if(te5 instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te5;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
DummyBlockAMSEmitter.safeBreak = false;
} else
world.func_147480_a(x, y, z, true);
}
}

View File

@ -1,186 +0,0 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.MultiblockHandler;
import com.hbm.interfaces.IMultiblock;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityAMSLimiter;
import com.hbm.tileentity.machine.TileEntityDummy;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class BlockAMSLimiter extends BlockContainer implements IMultiblock {
public BlockAMSLimiter(Material p_i45386_1_) {
super(p_i45386_1_);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityAMSLimiter();
}
@Override
public int getRenderType(){
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote)
{
return true;
} else if(!player.isSneaking())
{
TileEntityAMSLimiter entity = (TileEntityAMSLimiter) world.getTileEntity(x, y, z);
if(entity != null)
{
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
}
return true;
} else {
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(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.AMSLimiterDimensionEast)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.AMSLimiterDimensionEast, ModBlocks.dummy_block_ams_limiter);
//
DummyBlockAMSLimiter.safeBreak = true;
world.setBlock(x + 2, y, z, ModBlocks.dummy_port_ams_limiter);
TileEntity te = world.getTileEntity(x + 2, y, z);
if(te instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
world.setBlock(x - 2, y, z, ModBlocks.dummy_port_ams_limiter);
TileEntity te2 = world.getTileEntity(x - 2, y, z);
if(te2 instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te2;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
DummyBlockAMSLimiter.safeBreak = false;
//
} else
world.func_147480_a(x, y, z, true);
}
if (i == 1) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.AMSLimiterDimensionSouth)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.AMSLimiterDimensionSouth, ModBlocks.dummy_block_ams_limiter);
//
DummyBlockAMSLimiter.safeBreak = true;
world.setBlock(x, y, z + 2, ModBlocks.dummy_port_ams_limiter);
TileEntity te = world.getTileEntity(x, y, z + 2);
if(te instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
world.setBlock(x, y, z - 2, ModBlocks.dummy_port_ams_limiter);
TileEntity te2 = world.getTileEntity(x, y, z - 2);
if(te2 instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te2;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
DummyBlockAMSLimiter.safeBreak = false;
//
} else
world.func_147480_a(x, y, z, true);
}
if (i == 2) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.AMSLimiterDimensionWest)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.AMSLimiterDimensionWest, ModBlocks.dummy_block_ams_limiter);
//
DummyBlockAMSLimiter.safeBreak = true;
world.setBlock(x + 2, y, z, ModBlocks.dummy_port_ams_limiter);
TileEntity te = world.getTileEntity(x + 2, y, z);
if(te instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
world.setBlock(x - 2, y, z, ModBlocks.dummy_port_ams_limiter);
TileEntity te2 = world.getTileEntity(x - 2, y, z);
if(te2 instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te2;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
DummyBlockAMSLimiter.safeBreak = false;
//
} else
world.func_147480_a(x, y, z, true);
}
if (i == 3) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.AMSLimiterDimensionNorth)) {
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.AMSLimiterDimensionNorth, ModBlocks.dummy_block_ams_limiter);
//
DummyBlockAMSLimiter.safeBreak = true;
world.setBlock(x, y, z + 2, ModBlocks.dummy_port_ams_limiter);
TileEntity te = world.getTileEntity(x, y, z + 2);
if(te instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
world.setBlock(x, y, z - 2, ModBlocks.dummy_port_ams_limiter);
TileEntity te2 = world.getTileEntity(x, y, z - 2);
if(te2 instanceof TileEntityDummy) {
TileEntityDummy dummy = (TileEntityDummy)te2;
dummy.targetX = x;
dummy.targetY = y;
dummy.targetZ = z;
}
DummyBlockAMSLimiter.safeBreak = false;
//
} else
world.func_147480_a(x, y, z, true);
}
}
}

View File

@ -0,0 +1,9 @@
package com.hbm.blocks.machine;
import net.minecraft.block.material.Material;
public class BlockCMFlux extends BlockPillar{
public BlockCMFlux(Material mat, String top) {
super(mat, top);
}
}

View File

@ -0,0 +1,9 @@
package com.hbm.blocks.machine;
import net.minecraft.block.material.Material;
public class BlockCMHeat extends BlockPillar{
public BlockCMHeat(Material mat, String top) {
super(mat, top);
}
}

View File

@ -8,5 +8,4 @@ public class BlockHadronPlating extends Block {
public BlockHadronPlating(Material mat) {
super(mat);
}
}

View File

@ -0,0 +1,222 @@
package com.hbm.blocks.machine;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import com.hbm.render.block.ct.CT;
import com.hbm.render.block.ct.CTStitchReceiver;
import com.hbm.render.block.ct.IBlockCT;
import com.hbm.tileentity.machine.TileEntityICFController;
import api.hbm.energymk2.IEnergyReceiverMK2;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockICF extends BlockContainer implements IBlockCT {
@SideOnly(Side.CLIENT) protected IIcon iconPort;
public BlockICF(Material mat) {
super(mat);
}
@Override
public int getRenderType() {
return CT.renderID;
}
@Override
public Item getItemDropped(int i, Random rand, int j) {
return null;
}
@SideOnly(Side.CLIENT) public CTStitchReceiver rec;
@SideOnly(Side.CLIENT) public CTStitchReceiver recPort;
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
super.registerBlockIcons(reg);
this.iconPort = reg.registerIcon(RefStrings.MODID + ":icf_block_port");
this.rec = IBlockCT.primeReceiver(reg, this.blockIcon.getIconName(), this.blockIcon);
this.recPort = IBlockCT.primeReceiver(reg, this.iconPort.getIconName(), this.iconPort);
}
@Override
public IIcon[] getFragments(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if(meta == 1) return recPort.fragCache;
return rec.fragCache;
}
@Override
public boolean canConnect(IBlockAccess world, int x, int y, int z, Block block) {
return block == ModBlocks.icf_block || block == ModBlocks.icf_controller;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityBlockICF();
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityBlockICF) {
TileEntityBlockICF icf = (TileEntityBlockICF) tile;
world.removeTileEntity(x, y, z);
if(icf.block != null) {
world.setBlock(x, y, z, icf.block, icf.meta, 3);
TileEntity controller = world.getTileEntity(icf.coreX, icf.coreY, icf.coreZ);
if(controller instanceof TileEntityICFController) {
((TileEntityICFController) controller).assembled = false;
}
}
} else {
world.removeTileEntity(x, y, z);
}
super.breakBlock(world, x, y, z, block, meta);
}
public static class TileEntityBlockICF extends TileEntity implements IEnergyReceiverMK2 {
public Block block;
public int meta;
public int coreX;
public int coreY;
public int coreZ;
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
if(worldObj.getTotalWorldTime() % 20 == 0 && block != null) {
TileEntityICFController controller = getCore();
if(controller != null) {
if(!controller.assembled) {
this.getBlockType().breakBlock(worldObj, xCoord, yCoord, zCoord, this.getBlockType(), this.getBlockMetadata());
}
} else if(worldObj.getChunkProvider().chunkExists(coreX >> 4, coreZ >> 4)) {
this.getBlockType().breakBlock(worldObj, xCoord, yCoord, zCoord, this.getBlockType(), this.getBlockMetadata());
}
}
}
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
block = Block.getBlockById(nbt.getInteger("block"));
if(block != Blocks.air) {
meta = nbt.getInteger("meta");
coreX = nbt.getInteger("cX");
coreY = nbt.getInteger("cY");
coreZ = nbt.getInteger("cZ");
} else {
block = null;
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
if(block != null) {
nbt.setInteger("block", Block.getIdFromBlock(block));
nbt.setInteger("meta", meta);
nbt.setInteger("cX", coreX);
nbt.setInteger("cY", coreY);
nbt.setInteger("cZ", coreZ);
}
}
@Override
public void markDirty() {
if(this.worldObj != null) {
this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this);
}
}
public TileEntityICFController cachedCore;
protected TileEntityICFController getCore() {
if(cachedCore != null && !cachedCore.isInvalid()) return cachedCore;
if(worldObj.getChunkProvider().chunkExists(coreX >> 4, coreZ >> 4)) {
TileEntity tile = worldObj.getTileEntity(coreX, coreY, coreZ);
if(tile instanceof TileEntityICFController) {
TileEntityICFController controller = (TileEntityICFController) tile;
cachedCore = controller;
return controller;
}
}
return null;
}
@Override public long getPower() {
if(this.getBlockMetadata() != 1) return 0;
if(block == null) return 0;
TileEntityICFController controller = this.getCore();
if(controller != null) return controller.getPower();
return 0;
}
@Override public void setPower(long power) {
if(this.getBlockMetadata() != 1) return;
if(block == null) return;
TileEntityICFController controller = this.getCore();
if(controller != null) controller.setPower(power);
}
@Override public long getMaxPower() {
if(this.getBlockMetadata() != 1) return 0;
if(block == null) return 0;
TileEntityICFController controller = this.getCore();
if(controller != null) return controller.getMaxPower();
return 0;
}
public boolean isLoaded = true;
@Override
public boolean isLoaded() {
return isLoaded;
}
@Override
public void onChunkUnload() {
super.onChunkUnload();
this.isLoaded = false;
}
@Override
public boolean canConnect(ForgeDirection dir) {
if(this.getBlockMetadata() != 1) return false;
return dir != ForgeDirection.UNKNOWN;
}
}
}

View File

@ -0,0 +1,56 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.BlockEnumMulti;
import com.hbm.lib.RefStrings;
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 BlockICFLaserComponent extends BlockEnumMulti {
protected IIcon[] iconsTop;
public BlockICFLaserComponent() {
super(Material.iron, EnumICFPart.class, true, true);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
Enum[] enums = theEnum.getEnumConstants();
this.icons = new IIcon[enums.length];
this.iconsTop = new IIcon[enums.length];
this.icons[0] = this.iconsTop[0] = reg.registerIcon(RefStrings.MODID + ":icf_casing");
this.icons[1] = this.iconsTop[1] = reg.registerIcon(RefStrings.MODID + ":icf_port");
this.icons[2] = this.iconsTop[2] = reg.registerIcon(RefStrings.MODID + ":icf_cell");
this.icons[3] = this.iconsTop[3] = reg.registerIcon(RefStrings.MODID + ":icf_emitter");
this.icons[4] = reg.registerIcon(RefStrings.MODID + ":icf_capacitor_side");
this.icons[5] = reg.registerIcon(RefStrings.MODID + ":icf_turbocharger");
this.iconsTop[4] = this.iconsTop[5] = reg.registerIcon(RefStrings.MODID + ":icf_capacitor_top");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return side == 0 || side == 1 ? this.iconsTop[meta % this.iconsTop.length] : this.icons[meta % this.icons.length];
}
@Override
public int getSubCount() {
return EnumICFPart.values().length;
}
public static enum EnumICFPart {
CASING,
PORT,
CELL,
EMITTER,
CAPACITOR,
TURBO
}
}

View File

@ -1,83 +0,0 @@
package com.hbm.blocks.machine;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockObserver extends Block {
private boolean isActive;
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconBack;
public BlockObserver(Material mat, boolean isActive) {
super(mat);
this.isActive = isActive;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.iconBack = iconRegister.registerIcon(RefStrings.MODID + (this.isActive ? ":observer_back_on" : ":observer_back_off"));
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + ":observer_front");
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":observer_side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
ForgeDirection dir = ForgeDirection.getOrientation(metadata);
ForgeDirection opp = dir.getOpposite();
return side == dir.ordinal() ? iconFront : side == opp.ordinal() ? iconBack : blockIcon;
}
@Override
public Item getItemDropped(int meta, Random rand, int luck) {
return Item.getItemFromBlock(ModBlocks.observer_off);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
int l = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, l, 2);
if(this.isActive)
world.scheduleBlockUpdate(x, y, z, this, 2);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
if(!this.isActive) {
}
}
@Override
public boolean canProvidePower() {
return this.isActive;
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) {
return this.isActive ? 15 : 0;
}
}

View File

@ -316,5 +316,18 @@ public class BlockPWR extends BlockContainer implements IBlockCT {
return false;
}
public boolean isLoaded = true;
@Override
public boolean isLoaded() {
return isLoaded;
}
@Override
public void onChunkUnload() {
super.onChunkUnload();
this.isLoaded = false;
}
}
}

View File

@ -1,23 +1,15 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.lib.RefStrings;
import api.hbm.fluid.IFluidConnectorBlock;
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.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockPillar extends Block implements IFluidConnectorBlock {
public class BlockPillar extends Block {
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@ -37,18 +29,13 @@ public class BlockPillar extends Block implements IFluidConnectorBlock {
textureAlt = bottom;
}
public Block setBlockTextureName(String name) {
if(textureTop.isEmpty())
textureTop = name;
if(textureAlt.isEmpty())
textureAlt = name;
this.textureName = name;
return this;
}
public Block setBlockTextureName(String name) {
if(textureTop.isEmpty()) textureTop = name;
if(textureAlt.isEmpty()) textureAlt = name;
this.textureName = name;
return this;
}
@Override
@SideOnly(Side.CLIENT)
@ -62,37 +49,6 @@ public class BlockPillar extends Block implements IFluidConnectorBlock {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
if(this == ModBlocks.reactor_element && metadata == 1)
return side == 1 ? this.iconTop : (side == 0 ? this.iconTop : this.iconAlt);
return side == 1 ? this.iconTop : (side == 0 ? this.iconTop : this.blockIcon);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(this != ModBlocks.reactor_element)
return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
if(player.isSneaking())
{
if(world.getBlockMetadata(x, y, z) == 0) {
world.setBlockMetadataWithNotify(x, y, z, 1, 3);
} else {
world.setBlockMetadataWithNotify(x, y, z, 0, 3);
}
return true;
}
return false;
}
@Override
public boolean canConnect(FluidType type, IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
if(this != ModBlocks.reactor_conductor) return false;
return type == Fluids.WATER || type == Fluids.COOLANT || type == Fluids.STEAM || type == Fluids.HOTSTEAM || type == Fluids.SUPERHOTSTEAM || type == Fluids.ULTRAHOTSTEAM;
}
}

View File

@ -1,63 +0,0 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
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.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class BlockRotatable extends Block {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
public BlockRotatable(Material p_i45394_1_) {
super(p_i45394_1_);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
if(this == ModBlocks.reactor_ejector) {
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + ":reactor_ejector");
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":brick_concrete");
}
if(this == ModBlocks.reactor_inserter) {
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + ":reactor_inserter");
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":brick_concrete");
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon);
}
@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, 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);
}
}
}

View File

@ -1,105 +0,0 @@
package com.hbm.blocks.machine;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.interfaces.IDummy;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityAMSBase;
import com.hbm.tileentity.machine.TileEntityDummy;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class DummyBlockAMSBase extends BlockContainer implements IDummy {
public static boolean safeBreak = false;
public DummyBlockAMSBase(Material p_i45386_1_) {
super(p_i45386_1_);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityDummy();
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int i)
{
if(!safeBreak) {
TileEntity te = world.getTileEntity(x, y, z);
if(te != null && te instanceof TileEntityDummy) {
int a = ((TileEntityDummy)te).targetX;
int b = ((TileEntityDummy)te).targetY;
int c = ((TileEntityDummy)te).targetZ;
//world.getBlock(a, b, c).breakBlock(world, a, b, c, block, i);
if(!world.isRemote)
world.func_147480_a(a, b, c, true);
}
}
world.removeTileEntity(x, y, z);
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return null;
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem(World world, int x, int y, int z)
{
return Item.getItemFromBlock(ModBlocks.ams_base);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote)
{
return true;
} else if(!player.isSneaking())
{
TileEntity te = world.getTileEntity(x, y, z);
if(te != null && te instanceof TileEntityDummy) {
int a = ((TileEntityDummy)te).targetX;
int b = ((TileEntityDummy)te).targetY;
int c = ((TileEntityDummy)te).targetZ;
TileEntityAMSBase entity = (TileEntityAMSBase) world.getTileEntity(a, b, c);
if(entity != null)
{
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, a, b, c);
}
}
return true;
} else {
return false;
}
}
}

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