mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
ebdd05ccde
6
.gitignore
vendored
6
.gitignore
vendored
@ -20,3 +20,9 @@ build
|
||||
|
||||
# other
|
||||
run
|
||||
|
||||
# CurseForge configuration
|
||||
/curseforge.properties
|
||||
|
||||
# Changelog backup
|
||||
/changelog.bak
|
||||
|
||||
38
CONTRIBUTING.md
Normal file
38
CONTRIBUTING.md
Normal file
@ -0,0 +1,38 @@
|
||||
# NTM Contribution Guidelines, Version 1
|
||||
|
||||
## Keep it concise
|
||||
|
||||
The best PRs are the ones that are small and to the point. The entire PR should focus on the thing you're trying to do, whether it's a fix or a feature PR. If your PR adds the Super Weldtronic 9000, there's no reason to include changes and tweaks to other things that have nothing to do with the Super Weldtronic 9000. If you think those changes are still necessary, open a new PR.
|
||||
|
||||
## Keep it clean
|
||||
|
||||
While admittedly my own code isn't the cleanest on earth, please try to keep terrible practices at a minimum. Also avoid things like unused variables and imports, mixed indentation styles or changes that have a high likelihood of breaking things.
|
||||
|
||||
Things you should also avoid include:
|
||||
* new libraries (unless your PR absolutely needs it like for special mod compat)
|
||||
* duplicate util functions (just use what we have, man)
|
||||
* unused or half finished util functions (for obvious reasons)
|
||||
* half finished or obviously broken features (à la "bob will fix it, i'm sure of it", please don't do that)
|
||||
|
||||
## Test your code
|
||||
|
||||
This should go without saying, but please don't PR code that was never actually tested or has obvious compiler errors in it.
|
||||
|
||||
## Communication
|
||||
|
||||
If you're planning on adding some new thing or doing a grand change, it's best to ask whether that's a good idea before spending 50 hours on a project that won't end up getting merged, due to issues that could have been entirely avoidable with communication.
|
||||
|
||||
## No guarantees
|
||||
|
||||
This ties together with the previous point - there's no guarantees that your PR gets merged no matter how hard or long you've worked on it. However, if you follow these guidelines, there's a good chance that your PR will be accepted.
|
||||
|
||||
## I want to help but don't know where to start
|
||||
|
||||
If you want to help the project, consider getting involved with the [wiki](ntm.fandom.com) first. Writing an article is the easiest and quickest way of helping, and requires no programming knowledge. If you do know Java and want to help, consider these places first:
|
||||
|
||||
* Localization, i.e. translations in different language are always accepted.
|
||||
* `IConfigurableMachine`, an interface that allows machines to be added to the `hbmMachines.json` config, is still not used by many machines.
|
||||
* F1 Presentations, also known as "Stare" or "Jar Presentations", is a neat system of creating a short movie explaining functionality. All the relevant code can be found in `com.hbm.wiaj`.
|
||||
* Some guns still use the old "bow-style" systems and not `ItemGunBase`.
|
||||
* Many guns don't have any animations whatsoever, just adding a minor recoil would already improve them by a lot.
|
||||
* Adding tooltips to more machines, explaining some of the basics.
|
||||
15
README.md
15
README.md
@ -91,5 +91,20 @@ If you want to make some changes to the mod, follow this guide:
|
||||
* Click **Add Standard VM**; in the JRE home, navigate to the directory where the JDK is installed, then click finish and select it.
|
||||
10. Code!
|
||||
|
||||
## 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.
|
||||
|
||||
### Skybox chainloader
|
||||
NTM adds a few small things to the skybox using a custom skybox renderer. Minecraft can only have a single skybox renderer loaded, so setting the skybox to the NTM custom one would break compatibility with other mods' skyboxes. To mend this, NTM employs a **chainloader**. This chainloader will detect if a different skybox is loaded, save a reference to that skybox and then use NTM's skybox, which when used will also make sure to run the previous modded skybox renderer. In the event that NTM's skybox were to cause trouble, it can be disabled with the config option `1.31_enableSkyboxes`.
|
||||
|
||||
### Custom world provider
|
||||
A world provider is a piece of code that minecraft can load to determine certain aspects of how the world should be handled, like light levels, sky color, day/night cycle, etc. In order for the Tom impact effects to work, NTM employs such a world provider, although this is known to cause issues with Hardcore Darkness. The world provider can be disabled with the config option `1.32_enableImpactWorldProvider`.
|
||||
|
||||
### Stat re-registering
|
||||
An often overlooked aspect of Minecraft is its stats, the game keeps track of how many of an item were crafted, placed, broken, etc. By default, Minecraft can only handle vanilla items, modded items would not show up in the stats window. Forge does little to fix this, and since NTM has to keep track of certain things (such as the use of an acidizer for spawning Mask Man) it will run its own code which re-registers all stats for all modded items. In the event that re-registering causes issues, or another mod already does this better already, this behavior can be disabled with the config option `1.33_enableStatReRegistering`.
|
||||
|
||||
### Keybind overlap
|
||||
An often annoying aspect of modded Minecraft is its keybinds. Even though multiple binds can be assigned the same key, all but one will show up as "conflicting" and only the non-conflicting one will work. Which one this is is usually arbitrary, and there is no reason to have such limitation. Often times keybinds are only applicable in certain scenarios, and a commonly found degree of overlap is within reason. Therefore, NTM will run its own key handling code which allows conflicting keybinds to work. If there should be any issues with this behavior, it can be disabled with the config option `1.34_enableKeybindOverlap`.
|
||||
|
||||
# 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.
|
||||
|
||||
51
build.gradle
51
build.gradle
@ -1,3 +1,9 @@
|
||||
import org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.StandardCopyOption
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url = 'https://maven.minecraftforge.net/' }
|
||||
@ -10,6 +16,14 @@ buildscript {
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
apply plugin: 'curseforge'
|
||||
|
||||
|
||||
if(Files.exists(Paths.get("curseforge.properties"))) {
|
||||
// Load CurseForge configuration
|
||||
ext.cfprops = parseConfig(file("curseforge.properties"))
|
||||
}
|
||||
|
||||
def version_name = version = mod_version
|
||||
if(!mod_build_number.isEmpty()) {
|
||||
version_name = mod_version + "_X" + mod_build_number
|
||||
@ -42,7 +56,7 @@ eclipse.classpath.file.whenMerged { cp ->
|
||||
}
|
||||
|
||||
// Create file reference factory
|
||||
def fileref = new org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory()
|
||||
def fileref = new FileReferenceFactory()
|
||||
|
||||
// Find all codechicken development jars
|
||||
cp.entries.findAll { entry -> entry.path.contains("codechicken") && entry.path.endsWith("-dev.jar") }.forEach { entry ->
|
||||
@ -114,3 +128,38 @@ task version {
|
||||
println project.version
|
||||
}
|
||||
}
|
||||
|
||||
if(Files.exists(Paths.get("curseforge.properties"))) {
|
||||
curse {
|
||||
apiKey = cfprops.api_key
|
||||
projectId = cfprops.project_id
|
||||
releaseType = "release"
|
||||
|
||||
displayName = "Hbm's Nuclear Tech Mod " + version_name.replace("_", "") + " for Minecraft 1.7.10"
|
||||
|
||||
gameVersions.addAll([
|
||||
"Forge",
|
||||
"Java 8",
|
||||
"Client", "Server"
|
||||
])
|
||||
|
||||
if (Files.exists(Paths.get("changelog"))) {
|
||||
changelog = String.join("\r\n", Files.readAllLines(Paths.get("changelog")))
|
||||
|
||||
// Perform a backup of the changelog and create a new file for next changes
|
||||
doLast {
|
||||
Files.move(Paths.get("changelog"), Paths.get("changelog.bak"), StandardCopyOption.REPLACE_EXISTING)
|
||||
Files.createFile(Paths.get("changelog"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Properties file parsing helper
|
||||
static def parseConfig(File config) {
|
||||
config.withReader {
|
||||
def prop = new Properties()
|
||||
prop.load(it)
|
||||
return (new ConfigSlurper().parse(prop))
|
||||
}
|
||||
}
|
||||
|
||||
54
changelog
Normal file
54
changelog
Normal file
@ -0,0 +1,54 @@
|
||||
## 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
|
||||
|
||||
## 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
|
||||
|
||||
## 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
|
||||
5
curseforge.properties.example
Normal file
5
curseforge.properties.example
Normal file
@ -0,0 +1,5 @@
|
||||
# CurseForge API token (obtainable from https://legacy.curseforge.com/account/api-tokens)
|
||||
api_key=
|
||||
|
||||
# CurseForge project ID
|
||||
project_id=
|
||||
@ -1,14 +1,19 @@
|
||||
mod_version=1.0.27
|
||||
# Empty build number makes a release type
|
||||
mod_build_number=4585
|
||||
mod_build_number=4809
|
||||
|
||||
credits=HbMinecraft, rodolphito (explosion algorithms), grangerave (explosion algorithms),\
|
||||
\ Hoboy (textures, models), Doctor17 (russian localization), Drillgon200 (effects, models, porting),\
|
||||
\ UFFR (RTGs, guns, casings), 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), haru315 (spiral point algorithm),\
|
||||
\ Sten89 (models), Pixelguru26 (textures), TheBlueHat (textures), Alcater (GUI textures, porting), impbk2002 (project settings),\
|
||||
\ OvermindDL1 (project settings), TehTemmie (reacher radiation function), Toshayo (satellite loot system, project settings), 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), sdddddf80 (recipe configs), SuperCraftAlex (tooltips)
|
||||
\ 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)
|
||||
|
||||
10
src/main/java/api/hbm/block/IBlowable.java
Normal file
10
src/main/java/api/hbm/block/IBlowable.java
Normal file
@ -0,0 +1,10 @@
|
||||
package api.hbm.block;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IBlowable { //sloppy toppy
|
||||
|
||||
/** Called server-side when a fan blows on an IBlowable in range every tick. */
|
||||
public void applyFan(World world, int x, int y, int z, ForgeDirection dir, int dist);
|
||||
}
|
||||
10
src/main/java/api/hbm/block/IInsertable.java
Normal file
10
src/main/java/api/hbm/block/IInsertable.java
Normal file
@ -0,0 +1,10 @@
|
||||
package api.hbm.block;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IInsertable { //uwu
|
||||
|
||||
public boolean insertItem(World world, int x, int y, int z, ForgeDirection dir, ItemStack stack);
|
||||
}
|
||||
@ -75,7 +75,7 @@ public interface IEnergyConnector extends ILoadedTile {
|
||||
red = true;
|
||||
}
|
||||
|
||||
if(particleDebug) {//
|
||||
if(particleDebug) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "network");
|
||||
data.setString("mode", "power");
|
||||
|
||||
@ -28,15 +28,17 @@ public interface IEnergyUser extends IEnergyConnector {
|
||||
@Override
|
||||
public default long transferPower(long power) {
|
||||
|
||||
this.setPower(this.getPower() + power);
|
||||
|
||||
if(this.getPower() > this.getMaxPower()) {
|
||||
if(this.getPower() + power > this.getMaxPower()) {
|
||||
|
||||
long overshoot = this.getPower() - 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;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -32,4 +33,5 @@ public interface IPowerNet {
|
||||
public List<IEnergyConnector> getSubscribers();
|
||||
|
||||
public long transferPower(long power);
|
||||
public BigInteger getTotalTransfer();
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package api.hbm.energy;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -20,6 +21,9 @@ public class PowerNet implements IPowerNet {
|
||||
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) {
|
||||
@ -119,6 +123,11 @@ public class PowerNet implements IPowerNet {
|
||||
public boolean isValid() {
|
||||
return this.valid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getTotalTransfer() {
|
||||
return this.totalTransfer;
|
||||
}
|
||||
|
||||
public long lastCleanup = System.currentTimeMillis();
|
||||
|
||||
@ -129,7 +138,9 @@ public class PowerNet implements IPowerNet {
|
||||
cleanup(this.subscribers);
|
||||
lastCleanup = System.currentTimeMillis();
|
||||
}*/
|
||||
|
||||
|
||||
trackingInstances = new ArrayList();
|
||||
trackingInstances.add(this);
|
||||
return fairTransfer(this.subscribers, power);
|
||||
}
|
||||
|
||||
@ -142,6 +153,8 @@ public class PowerNet implements IPowerNet {
|
||||
|
||||
public static long fairTransfer(List<IEnergyConnector> subscribers, long power) {
|
||||
|
||||
if(power <= 0) return 0;
|
||||
|
||||
if(subscribers.isEmpty())
|
||||
return power;
|
||||
|
||||
@ -149,6 +162,8 @@ public class PowerNet implements IPowerNet {
|
||||
|
||||
ConnectionPriority[] priorities = new ConnectionPriority[] {ConnectionPriority.HIGH, ConnectionPriority.NORMAL, ConnectionPriority.LOW};
|
||||
|
||||
long totalTransfer = 0;
|
||||
|
||||
for(ConnectionPriority p : priorities) {
|
||||
|
||||
List<IEnergyConnector> subList = new ArrayList();
|
||||
@ -183,9 +198,23 @@ public class PowerNet implements IPowerNet {
|
||||
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;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package api.hbm.entity;
|
||||
|
||||
@Deprecated //Use IRadarDetectableNT instead, old interface will still work though
|
||||
public interface IRadarDetectable {
|
||||
|
||||
public static enum RadarTargetType {
|
||||
@ -15,7 +16,7 @@ public interface IRadarDetectable {
|
||||
MISSILE_20("Size 20 Custom Missile"), //size 20 custom missiles
|
||||
MISSILE_AB("Anti-Ballistic Missile"), //anti ballistic missile
|
||||
PLAYER("Player"), //airborne players
|
||||
ARTILLERY("Artillery Shell"); //airborne players
|
||||
ARTILLERY("Artillery Shell"); //artillery shells
|
||||
|
||||
public String name;
|
||||
|
||||
|
||||
45
src/main/java/api/hbm/entity/IRadarDetectableNT.java
Normal file
45
src/main/java/api/hbm/entity/IRadarDetectableNT.java
Normal file
@ -0,0 +1,45 @@
|
||||
package api.hbm.entity;
|
||||
|
||||
public interface IRadarDetectableNT {
|
||||
|
||||
public static final int TIER0 = 0;
|
||||
public static final int TIER1 = 1;
|
||||
public static final int TIER2 = 2;
|
||||
public static final int TIER3 = 3;
|
||||
public static final int TIER4 = 4;
|
||||
public static final int TIER10 = 5;
|
||||
public static final int TIER10_15 = 6;
|
||||
public static final int TIER15 = 7;
|
||||
public static final int TIER15_20 = 8;
|
||||
public static final int TIER20 = 9;
|
||||
public static final int TIER_AB = 10;
|
||||
public static final int PLAYER = 11;
|
||||
public static final int ARTY = 12;
|
||||
/** Reserved type that shows a unique purple blip. Used for when nothing else applies. */
|
||||
public static final int SPECIAL = 13;
|
||||
|
||||
/** Name use for radar display, uses I18n for lookup */
|
||||
public String getUnlocalizedName();
|
||||
/** The type of dot to show on the radar as well as the redstone level in tier mode */
|
||||
public int getBlipLevel();
|
||||
/** Whether the object can be seen by this type of radar */
|
||||
public boolean canBeSeenBy(Object radar);
|
||||
/** Whether the object is currently visible, as well as whether the radar's setting allow for picking this up */
|
||||
public boolean paramsApplicable(RadarScanParams params);
|
||||
/** Whether this radar entry should be counted for the redstone output */
|
||||
public boolean suppliesRedstone(RadarScanParams params);
|
||||
|
||||
public static class RadarScanParams {
|
||||
public boolean scanMissiles = true;
|
||||
public boolean scanShells = true;
|
||||
public boolean scanPlayers = true;
|
||||
public boolean smartMode = true;
|
||||
|
||||
public RadarScanParams(boolean m, boolean s, boolean p, boolean smart) {
|
||||
this.scanMissiles = m;
|
||||
this.scanShells = s;
|
||||
this.scanPlayers = p;
|
||||
this.smartMode = smart;
|
||||
}
|
||||
}
|
||||
}
|
||||
66
src/main/java/api/hbm/entity/RadarEntry.java
Normal file
66
src/main/java/api/hbm/entity/RadarEntry.java
Normal file
@ -0,0 +1,66 @@
|
||||
package api.hbm.entity;
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class RadarEntry {
|
||||
|
||||
/** Name use for radar display, uses I18n for lookup */
|
||||
public String unlocalizedName;
|
||||
/** The type of dot to show on the radar as well as the redstone level in tier mode */
|
||||
public int blipLevel;
|
||||
public int posX;
|
||||
public int posY;
|
||||
public int posZ;
|
||||
public int dim;
|
||||
public int entityID;
|
||||
/** Whether this radar entry should be counted for the redstone output */
|
||||
public boolean redstone;
|
||||
|
||||
public RadarEntry() { } //blank ctor for packets
|
||||
|
||||
public RadarEntry(String name, int level, int x, int y, int z, int dim, int entityID, boolean redstone) {
|
||||
this.unlocalizedName = name;
|
||||
this.blipLevel = level;
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
this.posZ = z;
|
||||
this.dim = dim;
|
||||
this.entityID = entityID;
|
||||
this.redstone = redstone;
|
||||
}
|
||||
|
||||
public RadarEntry(IRadarDetectableNT detectable, Entity entity, boolean redstone) {
|
||||
this(detectable.getUnlocalizedName(), detectable.getBlipLevel(), (int) Math.floor(entity.posX), (int) Math.floor(entity.posY), (int) Math.floor(entity.posZ), entity.dimension, entity.getEntityId(), redstone);
|
||||
}
|
||||
|
||||
public RadarEntry(IRadarDetectable detectable, Entity entity) {
|
||||
this(detectable.getTargetType().name, detectable.getTargetType().ordinal(), (int) Math.floor(entity.posX), (int) Math.floor(entity.posY), (int) Math.floor(entity.posZ), entity.dimension, entity.getEntityId(), entity.motionY < 0);
|
||||
}
|
||||
|
||||
public RadarEntry(EntityPlayer player) {
|
||||
this(player.getDisplayName(), IRadarDetectableNT.PLAYER, (int) Math.floor(player.posX), (int) Math.floor(player.posY), (int) Math.floor(player.posZ), player.dimension, player.getEntityId(), true);
|
||||
}
|
||||
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.unlocalizedName = ByteBufUtils.readUTF8String(buf);
|
||||
this.blipLevel = buf.readShort();
|
||||
this.posX = buf.readInt();
|
||||
this.posY = buf.readInt();
|
||||
this.posZ = buf.readInt();
|
||||
this.dim = buf.readShort();
|
||||
this.entityID = buf.readInt();
|
||||
}
|
||||
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeUTF8String(buf, this.unlocalizedName);
|
||||
buf.writeShort(this.blipLevel);
|
||||
buf.writeInt(this.posX);
|
||||
buf.writeInt(this.posY);
|
||||
buf.writeInt(this.posZ);
|
||||
buf.writeShort(this.dim);
|
||||
buf.writeInt(this.entityID);
|
||||
}
|
||||
}
|
||||
@ -9,11 +9,11 @@ public interface IFluidConductor extends IFluidConnector {
|
||||
public void setPipeNet(FluidType type, IPipeNet network);
|
||||
|
||||
@Override
|
||||
public default long transferFluid(FluidType type, long amount) {
|
||||
public default long transferFluid(FluidType type, int pressure, long amount) {
|
||||
|
||||
if(this.getPipeNet(type) == null)
|
||||
return amount;
|
||||
|
||||
return this.getPipeNet(type).transferFluid(amount);
|
||||
return this.getPipeNet(type).transferFluid(amount, pressure);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ public interface IFluidConnector {
|
||||
* @param power
|
||||
* @return
|
||||
*/
|
||||
public long transferFluid(FluidType type, long fluid);
|
||||
public long transferFluid(FluidType type, int pressure, long fluid);
|
||||
|
||||
/**
|
||||
* Whether the given side can be connected to
|
||||
@ -33,7 +33,7 @@ public interface IFluidConnector {
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public long getDemand(FluidType type);
|
||||
public long getDemand(FluidType type, int pressure);
|
||||
|
||||
/**
|
||||
* Basic implementation of subscribing to a nearby power grid
|
||||
|
||||
@ -14,10 +14,10 @@ import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
public interface IFluidStandardReceiver extends IFluidUser {
|
||||
|
||||
@Override
|
||||
public default long transferFluid(FluidType type, long amount) {
|
||||
public default long transferFluid(FluidType type, int pressure, long amount) {
|
||||
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
tank.setFill(tank.getFill() + (int) amount);
|
||||
|
||||
if(tank.getFill() > tank.getMaxFill()) {
|
||||
@ -36,10 +36,10 @@ public interface IFluidStandardReceiver extends IFluidUser {
|
||||
public FluidTank[] getReceivingTanks();
|
||||
|
||||
@Override
|
||||
public default long getDemand(FluidType type) {
|
||||
public default long getDemand(FluidType type, int pressure) {
|
||||
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
return tank.getMaxFill() - tank.getFill();
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,10 +16,10 @@ public interface IFluidStandardSender extends IFluidUser {
|
||||
public FluidTank[] getSendingTanks();
|
||||
|
||||
@Override
|
||||
public default long getTotalFluidForSend(FluidType type) {
|
||||
public default long getTotalFluidForSend(FluidType type, int pressure) {
|
||||
|
||||
for(FluidTank tank : getSendingTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
return tank.getFill();
|
||||
}
|
||||
}
|
||||
@ -28,10 +28,10 @@ public interface IFluidStandardSender extends IFluidUser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public default void removeFluidForTransfer(FluidType type, long amount) {
|
||||
public default void removeFluidForTransfer(FluidType type, int pressure, long amount) {
|
||||
|
||||
for(FluidTank tank : getSendingTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
tank.setFill(tank.getFill() - (int) amount);
|
||||
return;
|
||||
}
|
||||
@ -39,12 +39,12 @@ public interface IFluidStandardSender extends IFluidUser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long transferFluid(FluidType type, long fluid) {
|
||||
public default long transferFluid(FluidType type, int pressure, long fluid) {
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long getDemand(FluidType type) {
|
||||
public default long getDemand(FluidType type, int pressure) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,10 +23,10 @@ public interface IFluidStandardTransceiver extends IFluidUser {
|
||||
public FluidTank[] getReceivingTanks();
|
||||
|
||||
@Override
|
||||
public default long getTotalFluidForSend(FluidType type) {
|
||||
public default long getTotalFluidForSend(FluidType type, int pressure) {
|
||||
|
||||
for(FluidTank tank : getSendingTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
return tank.getFill();
|
||||
}
|
||||
}
|
||||
@ -35,10 +35,10 @@ public interface IFluidStandardTransceiver extends IFluidUser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public default void removeFluidForTransfer(FluidType type, long amount) {
|
||||
public default void removeFluidForTransfer(FluidType type, int pressure, long amount) {
|
||||
|
||||
for(FluidTank tank : getSendingTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
tank.setFill(tank.getFill() - (int) amount);
|
||||
return;
|
||||
}
|
||||
@ -46,10 +46,10 @@ public interface IFluidStandardTransceiver extends IFluidUser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long getDemand(FluidType type) {
|
||||
public default long getDemand(FluidType type, int pressure) {
|
||||
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
return tank.getMaxFill() - tank.getFill();
|
||||
}
|
||||
}
|
||||
@ -58,10 +58,10 @@ public interface IFluidStandardTransceiver extends IFluidUser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public default long transferFluid(FluidType type, long amount) {
|
||||
public default long transferFluid(FluidType type, int pressure, long amount) {
|
||||
|
||||
for(FluidTank tank : getReceivingTanks()) {
|
||||
if(tank.getTankType() == type) {
|
||||
if(tank.getTankType() == type && tank.getPressure() == pressure) {
|
||||
tank.setFill(tank.getFill() + (int) amount);
|
||||
|
||||
if(tank.getFill() > tank.getMaxFill()) {
|
||||
|
||||
@ -13,7 +13,11 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IFluidUser extends IFluidConnector {
|
||||
|
||||
public default void sendFluid(FluidType type, World world, int x, int y, int z, ForgeDirection dir) {
|
||||
public default void sendFluid(FluidTank tank, World world, int x, int y, int z, ForgeDirection dir) {
|
||||
sendFluid(tank.getTankType(), tank.getPressure(), world, x, y, z, dir);
|
||||
}
|
||||
|
||||
public default void sendFluid(FluidType type, int pressure, World world, int x, int y, int z, ForgeDirection dir) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
boolean wasSubscribed = false;
|
||||
@ -32,9 +36,12 @@ public interface IFluidUser extends IFluidConnector {
|
||||
IFluidConnector con = (IFluidConnector) te;
|
||||
|
||||
if(con.canConnect(type, dir.getOpposite())) {
|
||||
long toSend = this.getTotalFluidForSend(type);
|
||||
long transfer = toSend - con.transferFluid(type, toSend);
|
||||
this.removeFluidForTransfer(type, transfer);
|
||||
long toSend = this.getTotalFluidForSend(type, pressure);
|
||||
|
||||
if(toSend > 0) {
|
||||
long transfer = toSend - con.transferFluid(type, pressure, toSend);
|
||||
this.removeFluidForTransfer(type, pressure, transfer);
|
||||
}
|
||||
red = true;
|
||||
}
|
||||
}
|
||||
@ -77,15 +84,21 @@ public interface IFluidUser extends IFluidConnector {
|
||||
return null;
|
||||
}
|
||||
|
||||
public default void sendFluidToAll(FluidType type, TileEntity te) {
|
||||
/** Use more common conPos method instead */
|
||||
@Deprecated public default void sendFluidToAll(FluidTank tank, TileEntity te) {
|
||||
sendFluidToAll(tank.getTankType(), tank.getPressure(), te);
|
||||
}
|
||||
|
||||
/** Use more common conPos method instead */
|
||||
@Deprecated public default void sendFluidToAll(FluidType type, int pressure, TileEntity te) {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
sendFluid(type, te.getWorldObj(), te.xCoord + dir.offsetX, te.yCoord + dir.offsetY, te.zCoord + dir.offsetZ, dir);
|
||||
sendFluid(type, pressure, te.getWorldObj(), te.xCoord + dir.offsetX, te.yCoord + dir.offsetY, te.zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
}
|
||||
|
||||
public default long getTotalFluidForSend(FluidType type) { return 0; }
|
||||
public default void removeFluidForTransfer(FluidType type, long amount) { }
|
||||
public default long getTotalFluidForSend(FluidType type, int pressure) { return 0; }
|
||||
public default void removeFluidForTransfer(FluidType type, int pressure, long amount) { }
|
||||
|
||||
public default void subscribeToAllAround(FluidType type, TileEntity te) {
|
||||
subscribeToAllAround(type, te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
|
||||
|
||||
@ -24,7 +24,7 @@ public interface IPipeNet {
|
||||
|
||||
public boolean isValid();
|
||||
|
||||
public long transferFluid(long fill);
|
||||
public long transferFluid(long fill, int pressure);
|
||||
public FluidType getType();
|
||||
public BigInteger getTotalTransfer();
|
||||
}
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
package api.hbm.fluid;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
|
||||
@ -18,6 +21,7 @@ public class PipeNet implements IPipeNet {
|
||||
|
||||
public static List<PipeNet> trackingInstances = null;
|
||||
protected BigInteger totalTransfer = BigInteger.ZERO;
|
||||
public List<String> debug = new ArrayList();
|
||||
|
||||
public PipeNet(FluidType type) {
|
||||
this.type = type;
|
||||
@ -85,7 +89,7 @@ public class PipeNet implements IPipeNet {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferFluid(long fill) {
|
||||
public long transferFluid(long fill, int pressure) {
|
||||
|
||||
this.subscribers.removeIf(x ->
|
||||
x == null || !(x instanceof TileEntity) || ((TileEntity)x).isInvalid()
|
||||
@ -97,16 +101,18 @@ public class PipeNet implements IPipeNet {
|
||||
trackingInstances = new ArrayList();
|
||||
trackingInstances.add(this);
|
||||
List<IFluidConnector> subList = new ArrayList(subscribers);
|
||||
return fairTransfer(subList, type, fill);
|
||||
return fairTransfer(subList, type, pressure, fill);
|
||||
}
|
||||
|
||||
public static long fairTransfer(List<IFluidConnector> subList, FluidType type, long fill) {
|
||||
public static long fairTransfer(List<IFluidConnector> subList, FluidType type, int pressure, long fill) {
|
||||
|
||||
if(fill <= 0) return 0;
|
||||
|
||||
List<Long> weight = new ArrayList();
|
||||
long totalReq = 0;
|
||||
|
||||
for(IFluidConnector con : subList) {
|
||||
long req = con.getDemand(type);
|
||||
long req = con.getDemand(type, pressure);
|
||||
weight.add(req);
|
||||
totalReq += req;
|
||||
}
|
||||
@ -123,7 +129,24 @@ public class PipeNet implements IPipeNet {
|
||||
|
||||
long given = (long) Math.floor(fraction * fill);
|
||||
|
||||
totalGiven += (given - con.transferFluid(type, given));
|
||||
if(given > 0) {
|
||||
|
||||
totalGiven += (given - con.transferFluid(type, pressure, given));
|
||||
|
||||
if(con instanceof TileEntity) {
|
||||
TileEntity tile = (TileEntity) con;
|
||||
tile.getWorldObj().markTileEntityChunkModified(tile.xCoord, tile.yCoord, tile.zCoord, tile);
|
||||
}
|
||||
|
||||
if(trackingInstances != null) {
|
||||
for(int j = 0; j < trackingInstances.size(); j++) {
|
||||
PipeNet net = trackingInstances.get(j);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss:SSS");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
log(net, sdf.format(new Date(System.currentTimeMillis())) + " Sending " + given + "mB to " + conToString(con));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(trackingInstances != null) {
|
||||
@ -162,4 +185,22 @@ public class PipeNet implements IPipeNet {
|
||||
public BigInteger getTotalTransfer() {
|
||||
return this.totalTransfer;
|
||||
}
|
||||
|
||||
public static void log(PipeNet net, String msg) {
|
||||
net.debug.add(msg);
|
||||
|
||||
while(net.debug.size() > 50) {
|
||||
net.debug.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static String conToString(IFluidConnector con) {
|
||||
|
||||
if(con instanceof TileEntity) {
|
||||
TileEntity tile = (TileEntity) con;
|
||||
return tile.getClass().getSimpleName() + " @ " + tile.xCoord + "/" + tile.yCoord + "/" + tile.zCoord;
|
||||
}
|
||||
|
||||
return "" + con;
|
||||
}
|
||||
}
|
||||
|
||||
@ -490,12 +490,10 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
|
||||
|
||||
int[] pos = this.findCore(world, x, y, z);
|
||||
if(pos == null) return;
|
||||
TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
if(tile == null) return;
|
||||
|
||||
x = tile.xCoord;
|
||||
y = tile.yCoord;
|
||||
z = tile.zCoord;
|
||||
x = pos[0];
|
||||
y = pos[1];
|
||||
z = pos[2];
|
||||
|
||||
EntityPlayer player = event.player;
|
||||
float interp = event.partialTicks;
|
||||
@ -503,9 +501,11 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
|
||||
double dY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) interp;
|
||||
double dZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)interp;
|
||||
float exp = 0.002F;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
ICustomBlockHighlight.setup();
|
||||
for(AxisAlignedBB aabb : this.bounding) event.context.drawOutlinedBoundingBox(getAABBRotationOffset(aabb.expand(exp, exp, exp), 0, 0, 0, ForgeDirection.getOrientation(tile.getBlockMetadata() - offset).getRotation(ForgeDirection.UP)).getOffsetBoundingBox(x - dX + 0.5, y - dY, z - dZ + 0.5), -1);
|
||||
for(AxisAlignedBB aabb : this.bounding) event.context.drawOutlinedBoundingBox(getAABBRotationOffset(aabb.expand(exp, exp, exp), 0, 0, 0, ForgeDirection.getOrientation(meta - offset).getRotation(ForgeDirection.UP)).getOffsetBoundingBox(x - dX + 0.5, y - dY, z - dZ + 0.5), -1);
|
||||
ICustomBlockHighlight.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.hbm.blocks;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.hbm.util.EnumUtil;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -34,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());
|
||||
this.icons[i] = reg.registerIcon(this.getTextureName() + "." + num.name().toLowerCase(Locale.US));
|
||||
}
|
||||
} else {
|
||||
this.blockIcon = reg.registerIcon(this.getTextureName());
|
||||
@ -45,7 +47,7 @@ public class BlockEnumMulti extends BlockMulti {
|
||||
|
||||
if(this.multiName) {
|
||||
Enum num = EnumUtil.grabEnumSafely(this.theEnum, stack.getItemDamage());
|
||||
return super.getUnlocalizedName() + "." + num.name().toLowerCase();
|
||||
return super.getUnlocalizedName() + "." + num.name().toLowerCase(Locale.US);
|
||||
}
|
||||
|
||||
return this.getUnlocalizedName();
|
||||
|
||||
@ -7,13 +7,40 @@ public class BlockEnums {
|
||||
ASBESTOS,
|
||||
HEMATITE,
|
||||
MALACHITE,
|
||||
LIMESTONE
|
||||
LIMESTONE,
|
||||
BAUXITE
|
||||
}
|
||||
|
||||
public static enum EnumBiomeType {
|
||||
DESERT,
|
||||
WOODLAND
|
||||
}
|
||||
|
||||
public static enum EnumStalagmiteType {
|
||||
SULFUR,
|
||||
ASBESTOS
|
||||
}
|
||||
|
||||
public static enum EnumCMMaterials {
|
||||
STEEL,
|
||||
ALLOY,
|
||||
DESH,
|
||||
TCALLOY
|
||||
}
|
||||
|
||||
public static enum EnumCMEngines {
|
||||
STANDARD,
|
||||
DESH,
|
||||
BISMUTH
|
||||
}
|
||||
|
||||
public static enum EnumCMCircuit {
|
||||
ALUMINIUM,
|
||||
COPPER,
|
||||
RED_COPPER,
|
||||
GOLD,
|
||||
SCHRABIDIUM
|
||||
}
|
||||
|
||||
/** DECO / STRUCTURE ENUMS */
|
||||
//i apologize in advance
|
||||
|
||||
96
src/main/java/com/hbm/blocks/BlockFallingNT.java
Normal file
96
src/main/java/com/hbm/blocks/BlockFallingNT.java
Normal file
@ -0,0 +1,96 @@
|
||||
package com.hbm.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.entity.item.EntityFallingBlockNT;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockFallingNT extends Block {
|
||||
|
||||
public static boolean fallInstantly;
|
||||
|
||||
public BlockFallingNT() {
|
||||
super(Material.sand);
|
||||
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||
}
|
||||
|
||||
public BlockFallingNT(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random rand) {
|
||||
if(!world.isRemote) {
|
||||
this.fall(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fall(World world, int x, int y, int z) {
|
||||
|
||||
if(canFallThrough(world, x, y - 1, z) && y >= 0) {
|
||||
byte range = 32;
|
||||
|
||||
if(!fallInstantly && world.checkChunksExist(x - range, y - range, z - range, x + range, y + range, z + range)) {
|
||||
if(!world.isRemote) {
|
||||
EntityFallingBlockNT entityfallingblock = new EntityFallingBlockNT(world, x + 0.5D, y + 0.5D, z + 0.5D, this, world.getBlockMetadata(x, y, z));
|
||||
this.modifyFallingBlock(entityfallingblock);
|
||||
world.spawnEntityInWorld(entityfallingblock);
|
||||
}
|
||||
} else {
|
||||
world.setBlockToAir(x, y, z);
|
||||
|
||||
while(canFallThrough(world, x, y - 1, z) && y > 0) {
|
||||
--y;
|
||||
}
|
||||
|
||||
if(y > 0) {
|
||||
world.setBlock(x, y, z, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void modifyFallingBlock(EntityFallingBlockNT falling) { }
|
||||
|
||||
@Override
|
||||
public int tickRate(World world) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public static boolean canFallThrough(World world, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if(block.isAir(world, x, y, z)) {
|
||||
return true;
|
||||
} else if(block == Blocks.fire) {
|
||||
return true;
|
||||
} else {
|
||||
Material material = block.getMaterial();
|
||||
return material == Material.water ? true : material == Material.lava;
|
||||
}
|
||||
}
|
||||
|
||||
public void onLand(World world, int x, int y, int z, int meta) { }
|
||||
|
||||
@SideOnly(Side.CLIENT) public boolean shouldOverrideRenderer() { return false; }
|
||||
@SideOnly(Side.CLIENT) public void overrideRenderer(EntityFallingBlockNT falling, RenderBlocks renderBlocks, Tessellator tessellator) { }
|
||||
}
|
||||
41
src/main/java/com/hbm/blocks/BlockRemap.java
Normal file
41
src/main/java/com/hbm/blocks/BlockRemap.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.hbm.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
|
||||
public class BlockRemap extends Block implements ILookOverlay {
|
||||
|
||||
public Block remapBlock;
|
||||
public int remapMeta;
|
||||
|
||||
protected BlockRemap(Block block, int meta) {
|
||||
super(Material.tnt);
|
||||
this.remapBlock = block;
|
||||
this.remapMeta = meta;
|
||||
this.setTickRandomly(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block setBlockName(String name) {
|
||||
super.setBlockName(name);
|
||||
this.setBlockTextureName(RefStrings.MODID + ":" + name);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random rand) {
|
||||
world.setBlock(x, y, z, this.remapBlock, this.remapMeta, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
ILookOverlay.printGeneric(event, "Compatibility block, will convert on update tick.", 0xffff00, 0x404000, new ArrayList());
|
||||
}
|
||||
}
|
||||
10
src/main/java/com/hbm/blocks/IAnalyzable.java
Normal file
10
src/main/java/com/hbm/blocks/IAnalyzable.java
Normal file
@ -0,0 +1,10 @@
|
||||
package com.hbm.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IAnalyzable {
|
||||
|
||||
public List<String> getDebugInfo(World world, int x, int y, int z);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -2,18 +2,168 @@ package com.hbm.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ModSoundType extends Block.SoundType {
|
||||
protected final String placeSound;
|
||||
protected final String breakSound;
|
||||
protected final String stepSound;
|
||||
|
||||
public ModSoundType(String name, float volume, float pitch) {
|
||||
super(name, volume, pitch);
|
||||
protected ModSoundType(String placeSound, String breakSound, String stepSound, float volume, float pitch) {
|
||||
super("", volume, pitch);
|
||||
this.placeSound = placeSound;
|
||||
this.breakSound = breakSound;
|
||||
this.stepSound = stepSound;
|
||||
}
|
||||
|
||||
public ModEnvelopedSoundType enveloped() {
|
||||
return new ModEnvelopedSoundType(placeSound, breakSound, stepSound, volume, frequency);
|
||||
}
|
||||
|
||||
public ModEnvelopedSoundType enveloped(Random random) {
|
||||
return new ModEnvelopedSoundType(placeSound, breakSound, stepSound, volume, frequency, random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String func_150496_b() {
|
||||
return placeSound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBreakSound() {
|
||||
return "hbm:" + super.getBreakSound();
|
||||
return breakSound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStepResourcePath() {
|
||||
return "hbm:" + super.getStepResourcePath();
|
||||
return stepSound;
|
||||
}
|
||||
|
||||
// creates a sound type with vanilla-like sound strings name-spaced to the mod
|
||||
public static ModSoundType mod(String soundName, float volume, float pitch) {
|
||||
return new ModSoundType(modDig(soundName), modDig(soundName), modStep(soundName), volume, pitch);
|
||||
}
|
||||
|
||||
// these permutations allow creating a sound type with one of the three sounds being custom
|
||||
// and the other ones defaulting to vanilla-like sound strings name-spaced to the mod
|
||||
|
||||
public static ModSoundType customPlace(String soundName, String placeSound, float volume, float pitch) {
|
||||
return new ModSoundType(placeSound, modDig(soundName), modStep(soundName), volume, pitch);
|
||||
}
|
||||
|
||||
public static ModSoundType customBreak(String soundName, String breakSound, float volume, float pitch) {
|
||||
return new ModSoundType(modDig(soundName), breakSound, modStep(soundName), volume, pitch);
|
||||
}
|
||||
|
||||
public static ModSoundType customStep(String soundName, String stepSound, float volume, float pitch) {
|
||||
return new ModSoundType(modDig(soundName), modDig(soundName), stepSound, volume, pitch);
|
||||
}
|
||||
|
||||
public static ModSoundType customDig(String soundName, String digSound, float volume, float pitch) {
|
||||
return new ModSoundType(digSound, digSound, modStep(soundName), volume, pitch);
|
||||
}
|
||||
|
||||
// these permutations copy sounds from an existing sound type and modify one of the sounds,
|
||||
// but with a manual path for the custom sound
|
||||
|
||||
public static ModSoundType customPlace(Block.SoundType from, String placeSound, float volume, float pitch) {
|
||||
return new ModSoundType(placeSound, from.getBreakSound(), from.getStepResourcePath(), volume, pitch);
|
||||
}
|
||||
|
||||
public static ModSoundType customBreak(Block.SoundType from, String breakSound, float volume, float pitch) {
|
||||
return new ModSoundType(from.func_150496_b(), breakSound, from.getStepResourcePath(), volume, pitch);
|
||||
}
|
||||
|
||||
public static ModSoundType customStep(Block.SoundType from, String stepSound, float volume, float pitch) {
|
||||
return new ModSoundType(from.func_150496_b(), from.getBreakSound(), stepSound, volume, pitch);
|
||||
}
|
||||
|
||||
public static ModSoundType customDig(Block.SoundType from, String dig, float volume, float pitch) {
|
||||
return new ModSoundType(dig, dig, from.getStepResourcePath(), volume, pitch);
|
||||
}
|
||||
|
||||
// customizes all sounds
|
||||
public static ModSoundType placeBreakStep(String placeSound, String breakSound, String stepSound, float volume, float pitch) {
|
||||
return new ModSoundType(placeSound, breakSound, stepSound, volume, pitch);
|
||||
}
|
||||
|
||||
private static String modDig(String soundName) {
|
||||
return "hbm:dig." + soundName;
|
||||
}
|
||||
|
||||
private static String modStep(String soundName) {
|
||||
return "hbm:step." + soundName;
|
||||
}
|
||||
|
||||
public static class ModEnvelopedSoundType extends ModSoundType {
|
||||
private final Random random;
|
||||
|
||||
ModEnvelopedSoundType(String placeSound, String breakSound, String stepSound, float volume, float pitch, Random random) {
|
||||
super(placeSound, breakSound, stepSound, volume, pitch);
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
ModEnvelopedSoundType(String placeSound, String breakSound, String stepSound, float volume, float pitch) {
|
||||
this(placeSound, breakSound, stepSound, volume, pitch, new Random());
|
||||
}
|
||||
|
||||
// a bit of a hack, but most of the time, playSound is called with the sound path queried first, and then volume and pitch
|
||||
private SubType probableSubType = SubType.PLACE;
|
||||
|
||||
@Override
|
||||
public String func_150496_b() {
|
||||
probableSubType = SubType.PLACE;
|
||||
return super.func_150496_b();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBreakSound() {
|
||||
probableSubType = SubType.BREAK;
|
||||
return super.getBreakSound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStepResourcePath() {
|
||||
probableSubType = SubType.STEP;
|
||||
return super.getStepResourcePath();
|
||||
}
|
||||
|
||||
private Envelope volumeEnvelope = null;
|
||||
private Envelope pitchEnvelope = null;
|
||||
|
||||
public ModEnvelopedSoundType volumeFunction(Envelope volumeEnvelope) {
|
||||
this.volumeEnvelope = volumeEnvelope;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModEnvelopedSoundType pitchFunction(Envelope pitchEnvelope) {
|
||||
this.pitchEnvelope = pitchEnvelope;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVolume() {
|
||||
if (volumeEnvelope == null)
|
||||
return super.getVolume();
|
||||
else
|
||||
return volumeEnvelope.compute(super.getVolume(), random, probableSubType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPitch() {
|
||||
if (pitchEnvelope == null)
|
||||
return super.getPitch();
|
||||
else
|
||||
return pitchEnvelope.compute(super.getPitch(), random, probableSubType);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Envelope {
|
||||
float compute(float in, Random rand, SubType type);
|
||||
}
|
||||
}
|
||||
|
||||
public enum SubType {
|
||||
PLACE, BREAK, STEP
|
||||
}
|
||||
}
|
||||
|
||||
13
src/main/java/com/hbm/blocks/ModSoundTypes.java
Normal file
13
src/main/java/com/hbm/blocks/ModSoundTypes.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.hbm.blocks;
|
||||
|
||||
import com.hbm.main.MainRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class ModSoundTypes {
|
||||
|
||||
public static final ModSoundType grate = ModSoundType.customStep(Block.soundTypeStone, "hbm:step.metalBlock", 0.5F, 1.0F);
|
||||
public static final ModSoundType pipe = ModSoundType.customDig(Block.soundTypeMetal, "hbm:block.pipePlaced", 0.85F, 0.85F).enveloped(MainRegistry.instance.rand).pitchFunction((in, rand, type) -> {
|
||||
if(type == ModSoundType.SubType.BREAK) in -= 0.15F;
|
||||
return in + rand.nextFloat() * 0.2F;
|
||||
});
|
||||
}
|
||||
@ -16,11 +16,13 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class BlockTNTBase extends BlockFlammable implements IToolable {
|
||||
|
||||
@ -44,6 +46,8 @@ public abstract class BlockTNTBase extends BlockFlammable implements IToolable {
|
||||
if(world.isBlockIndirectlyGettingPowered(x, y, z)) {
|
||||
this.onBlockDestroyedByPlayer(world, x, y, z, 1);
|
||||
world.setBlockToAir(x, y, z);
|
||||
} else {
|
||||
checkAndIgnite(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +56,19 @@ public abstract class BlockTNTBase extends BlockFlammable implements IToolable {
|
||||
if(world.isBlockIndirectlyGettingPowered(x, y, z)) {
|
||||
this.onBlockDestroyedByPlayer(world, x, y, z, 1);
|
||||
world.setBlockToAir(x, y, z);
|
||||
} else {
|
||||
checkAndIgnite(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkAndIgnite(World world, int x, int y, int z) {
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if(world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) == Blocks.fire) {
|
||||
this.onBlockDestroyedByPlayer(world, x, y, z, 1);
|
||||
world.setBlockToAir(x, y, z);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,8 +145,8 @@ public abstract class BlockTNTBase extends BlockFlammable implements IToolable {
|
||||
|
||||
if(tool == ToolType.DEFUSER) {
|
||||
if(!world.isRemote) {
|
||||
world.func_147480_a(x, y, z, true);
|
||||
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
|
||||
world.func_147480_a(x, y, z, false);
|
||||
this.dropBlockAsItem(world, x, y, z, 0, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ public class CompactLauncher extends BlockContainer implements IMultiblock, IBom
|
||||
TileEntityCompactLauncher entity = (TileEntityCompactLauncher) world.getTileEntity(x, y, z);
|
||||
|
||||
if(entity.canLaunch()) {
|
||||
entity.launch();
|
||||
entity.launchFromDesignator();
|
||||
return BombReturnCode.LAUNCHED;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ package com.hbm.blocks.bomb;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.BombConfig;
|
||||
import com.hbm.entity.effect.EntityNukeCloudSmall;
|
||||
import com.hbm.entity.effect.EntityNukeTorex;
|
||||
import com.hbm.entity.logic.EntityNukeExplosionMK5;
|
||||
import com.hbm.explosion.ExplosionLarge;
|
||||
import com.hbm.explosion.ExplosionNT;
|
||||
@ -78,12 +78,7 @@ public class ExplosiveCharge extends Block implements IBomb, IDetConnectible {
|
||||
}
|
||||
if(this == ModBlocks.det_nuke) {
|
||||
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.missileRadius, x + 0.5, y + 0.5, z + 0.5));
|
||||
|
||||
EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, BombConfig.missileRadius * 0.005F);
|
||||
entity2.posX = x;
|
||||
entity2.posY = y;
|
||||
entity2.posZ = z;
|
||||
world.spawnEntityInWorld(entity2);
|
||||
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.missileRadius);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,38 +2,27 @@ package com.hbm.blocks.bomb;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.GeneralConfig;
|
||||
import com.hbm.entity.missile.*;
|
||||
import com.hbm.interfaces.IBomb;
|
||||
import com.hbm.interfaces.Spaghetti;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.bomb.TileEntityLaunchPad;
|
||||
|
||||
import api.hbm.item.IDesignatorItem;
|
||||
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.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
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.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class LaunchPad extends BlockContainer implements IBomb {
|
||||
|
||||
public TileEntityLaunchPad tetn = new TileEntityLaunchPad();
|
||||
public static boolean keepInventory = false;
|
||||
private final static Random field_149933_a = new Random();
|
||||
|
||||
@ -46,11 +35,6 @@ public class LaunchPad extends BlockContainer implements IBomb {
|
||||
return new TileEntityLaunchPad();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
|
||||
return Item.getItemFromBlock(ModBlocks.launch_pad);
|
||||
}
|
||||
|
||||
@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) {
|
||||
@ -132,186 +116,16 @@ public class LaunchPad extends BlockContainer implements IBomb {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
|
||||
if(i == 0) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||
}
|
||||
if(i == 1) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
}
|
||||
if(i == 2) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
||||
}
|
||||
if(i == 3) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @Override public void setBlockBoundsBasedOnState(IBlockAccess
|
||||
* p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) { float f
|
||||
* = 0.0625F; this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); }
|
||||
*
|
||||
* @Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World
|
||||
* world, int x, int y, int z) { float f = 0.0625F;
|
||||
* this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 8*f, 1.0F); return
|
||||
* AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ,
|
||||
* x + this.maxX, y + this.maxY, z + this.maxZ); }
|
||||
*/
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Spaghetti("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA *takes breath* AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
|
||||
@Override
|
||||
public BombReturnCode explode(World world, int x, int y, int z) {
|
||||
|
||||
TileEntityLaunchPad entity = (TileEntityLaunchPad) world.getTileEntity(x, y, z);
|
||||
|
||||
if(entity.slots[0] == null || world.isRemote)
|
||||
return BombReturnCode.ERROR_MISSING_COMPONENT;
|
||||
|
||||
if(entity.slots[1] != null && entity.slots[1].getItem() instanceof IDesignatorItem && entity.power >= 75000) {
|
||||
|
||||
if(!((IDesignatorItem)entity.slots[1].getItem()).isReady(world, entity.slots[1], x, y, z))
|
||||
return BombReturnCode.ERROR_MISSING_COMPONENT;
|
||||
|
||||
int xCoord = entity.slots[1].stackTagCompound.getInteger("xCoord");
|
||||
int zCoord = entity.slots[1].stackTagCompound.getInteger("zCoord");
|
||||
|
||||
if(xCoord == entity.xCoord && zCoord == entity.zCoord) {
|
||||
xCoord += 1;
|
||||
}
|
||||
|
||||
Entity missile = null;
|
||||
|
||||
if(entity.slots[0].getItem() == ModItems.missile_generic) {
|
||||
missile = new EntityMissileGeneric(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_incendiary) {
|
||||
missile = new EntityMissileIncendiary(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_cluster) {
|
||||
missile = new EntityMissileCluster(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_buster) {
|
||||
missile = new EntityMissileBunkerBuster(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_strong) {
|
||||
missile = new EntityMissileStrong(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_incendiary_strong) {
|
||||
missile = new EntityMissileIncendiaryStrong(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_cluster_strong) {
|
||||
missile = new EntityMissileClusterStrong(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_buster_strong) {
|
||||
missile = new EntityMissileBusterStrong(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_burst) {
|
||||
missile = new EntityMissileBurst(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_inferno) {
|
||||
missile = new EntityMissileInferno(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_rain) {
|
||||
missile = new EntityMissileRain(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_drill) {
|
||||
missile = new EntityMissileDrill(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_nuclear) {
|
||||
missile = new EntityMissileNuclear(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_endo) {
|
||||
missile = new EntityMissileEndo(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_exo) {
|
||||
missile = new EntityMissileExo(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_nuclear_cluster) {
|
||||
missile = new EntityMissileMirv(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_doomsday) {
|
||||
missile = new EntityMissileDoomsday(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_taint) {
|
||||
missile = new EntityMissileTaint(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_micro) {
|
||||
missile = new EntityMissileMicro(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_bhole) {
|
||||
missile = new EntityMissileBHole(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_schrabidium) {
|
||||
missile = new EntityMissileSchrabidium(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_emp) {
|
||||
missile = new EntityMissileEMP(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_emp_strong) {
|
||||
missile = new EntityMissileEMPStrong(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_volcano) {
|
||||
missile = new EntityMissileVolcano(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
if(entity.slots[0].getItem() == ModItems.missile_shuttle) {
|
||||
missile = new EntityMissileShuttle(world, x + 0.5F, y + 2F, z + 0.5F, xCoord, zCoord);
|
||||
}
|
||||
|
||||
if(missile != null) {
|
||||
world.spawnEntityInWorld(missile);
|
||||
world.playSoundEffect(x, y, z, "hbm:weapon.missileTakeOff", 2.0F, 1.0F);
|
||||
entity.power -= 75000;
|
||||
entity.slots[0] = null;
|
||||
|
||||
if(GeneralConfig.enableExtendedLogging)
|
||||
MainRegistry.logger.log(Level.INFO, "[MISSILE] Tried to launch missile at " + x + " / " + y + " / " + z + " to " + xCoord + " / " + zCoord + "!");
|
||||
return BombReturnCode.LAUNCHED;
|
||||
}
|
||||
}
|
||||
|
||||
if(entity.slots[0] != null && entity.slots[0].getItem() == ModItems.missile_carrier && entity.power >= 75000) {
|
||||
EntityCarrier missile = new EntityCarrier(world);
|
||||
missile.posX = x + 0.5F;
|
||||
missile.posY = y + 1F;
|
||||
missile.posZ = z + 0.5F;
|
||||
|
||||
if(entity.slots[1] != null)
|
||||
missile.setPayload(entity.slots[1]);
|
||||
|
||||
world.spawnEntityInWorld(missile);
|
||||
entity.power -= 75000;
|
||||
|
||||
entity.slots[0] = null;
|
||||
entity.slots[1] = null;
|
||||
world.playSoundEffect(x, y, z, "hbm:entity.rocketTakeoff", 100.0F, 1.0F);
|
||||
return BombReturnCode.LAUNCHED;
|
||||
}
|
||||
|
||||
if(entity.slots[0] != null && entity.slots[0].getItem() == ModItems.missile_anti_ballistic && entity.power >= 75000) {
|
||||
EntityMissileAntiBallistic missile = new EntityMissileAntiBallistic(world);
|
||||
missile.posX = x + 0.5F;
|
||||
missile.posY = y + 0.5F;
|
||||
missile.posZ = z + 0.5F;
|
||||
|
||||
world.spawnEntityInWorld(missile);
|
||||
entity.power -= 75000;
|
||||
|
||||
entity.slots[0] = null;
|
||||
world.playSoundEffect(x, y, z, "hbm:weapon.missileTakeOff", 2.0F, 1.0F);
|
||||
return BombReturnCode.LAUNCHED;
|
||||
}
|
||||
|
||||
return BombReturnCode.ERROR_MISSING_COMPONENT;
|
||||
return entity.launchFromDesignator();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ public class LaunchTable extends BlockContainer implements IMultiblock, IBomb {
|
||||
TileEntityLaunchTable entity = (TileEntityLaunchTable) world.getTileEntity(x, y, z);
|
||||
|
||||
if(entity.canLaunch()) {
|
||||
entity.launch();
|
||||
entity.launchFromDesignator();
|
||||
return BombReturnCode.LAUNCHED;
|
||||
}
|
||||
|
||||
|
||||
@ -4,11 +4,12 @@ import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.BombConfig;
|
||||
import com.hbm.entity.effect.EntityNukeCloudSmall;
|
||||
import com.hbm.entity.effect.EntityNukeTorex;
|
||||
import com.hbm.entity.logic.EntityNukeExplosionMK5;
|
||||
import com.hbm.interfaces.IBomb;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.bomb.TileEntityNukeBoy;
|
||||
import com.hbm.util.TrackerUtil;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import net.minecraft.block.Block;
|
||||
@ -124,7 +125,13 @@ public class NukeBoy extends BlockContainer implements IBomb {
|
||||
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||
|
||||
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.boyRadius, x + 0.5, y + 0.5, z + 0.5));
|
||||
world.spawnEntityInWorld(EntityNukeCloudSmall.statFac(world, x, y, z, BombConfig.boyRadius));
|
||||
//world.spawnEntityInWorld(EntityNukeCloudSmall.statFac(world, x, y, z, BombConfig.boyRadius));
|
||||
|
||||
EntityNukeTorex torex = new EntityNukeTorex(world);
|
||||
torex.setPositionAndRotation(x + 0.5, y + 1, z + 0.5, 0, 0);
|
||||
torex.getDataWatcher().updateObject(10, 1.5F);
|
||||
world.spawnEntityInWorld(torex);
|
||||
TrackerUtil.setTrackingRange(world, torex, 1000);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.entity.effect.EntityCloudFleija;
|
||||
import com.hbm.entity.effect.EntityNukeCloudSmall;
|
||||
import com.hbm.entity.effect.EntityNukeTorex;
|
||||
import com.hbm.entity.grenade.EntityGrenadeZOMG;
|
||||
import com.hbm.entity.logic.EntityBalefire;
|
||||
import com.hbm.entity.logic.EntityNukeExplosionMK3;
|
||||
@ -169,7 +169,7 @@ public class NukeCustom extends BlockContainer implements IBomb {
|
||||
bf.setPosition(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
|
||||
bf.destructionRange = (int) amat;
|
||||
worldObj.spawnEntityInWorld(bf);
|
||||
worldObj.spawnEntityInWorld(EntityNukeCloudSmall.statFacBale(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, amat * 1.5F, 1000));
|
||||
EntityNukeTorex.statFacBale(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, amat);
|
||||
|
||||
/// HYDROGEN ///
|
||||
} else if(hydro > 0) {
|
||||
@ -179,7 +179,7 @@ public class NukeCustom extends BlockContainer implements IBomb {
|
||||
dirty *= 0.25F;
|
||||
|
||||
worldObj.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(worldObj, (int)hydro, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5).moreFallout((int)dirty));
|
||||
worldObj.spawnEntityInWorld(EntityNukeCloudSmall.statFac(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, hydro));
|
||||
EntityNukeTorex.statFac(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, hydro);
|
||||
|
||||
/// NUCLEAR ///
|
||||
} else if(nuke > 0) {
|
||||
@ -188,7 +188,7 @@ public class NukeCustom extends BlockContainer implements IBomb {
|
||||
nuke = Math.min(nuke, maxNuke);
|
||||
|
||||
worldObj.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(worldObj, (int)nuke, xCoord + 0.5, yCoord + 5, zCoord + 0.5).moreFallout((int)dirty));
|
||||
worldObj.spawnEntityInWorld(EntityNukeCloudSmall.statFac(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, nuke));
|
||||
EntityNukeTorex.statFac(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, nuke);
|
||||
|
||||
/// NON-NUCLEAR ///
|
||||
} else if(tnt >= 75) {
|
||||
@ -196,7 +196,7 @@ public class NukeCustom extends BlockContainer implements IBomb {
|
||||
tnt = Math.min(tnt, maxTnt);
|
||||
|
||||
worldObj.spawnEntityInWorld(EntityNukeExplosionMK5.statFacNoRad(worldObj, (int)tnt, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5));
|
||||
worldObj.spawnEntityInWorld(EntityNukeCloudSmall.statFac(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, tnt));
|
||||
EntityNukeTorex.statFac(worldObj, xCoord + 0.5, yCoord + 5, zCoord + 0.5, tnt);
|
||||
} else if(tnt > 0) {
|
||||
|
||||
ExplosionLarge.explode(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, tnt, true, true, true);
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.BombConfig;
|
||||
import com.hbm.entity.effect.EntityNukeCloudSmall;
|
||||
import com.hbm.entity.effect.EntityNukeTorex;
|
||||
import com.hbm.entity.logic.EntityNukeExplosionMK5;
|
||||
import com.hbm.interfaces.IBomb;
|
||||
import com.hbm.main.MainRegistry;
|
||||
@ -130,13 +130,8 @@ public class NukeGadget extends BlockContainer implements IBomb {
|
||||
tetn.clearSlots();
|
||||
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||
|
||||
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.gadgetRadius, x + 0.5, y + 0.5, z + 0.5));
|
||||
|
||||
EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, BombConfig.gadgetRadius * 0.005F);
|
||||
entity2.posX = x;
|
||||
entity2.posY = y;
|
||||
entity2.posZ = z;
|
||||
world.spawnEntityInWorld(entity2);
|
||||
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.gadgetRadius, x + 0.5, y + 0.5, z + 0.5));
|
||||
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.gadgetRadius);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.BombConfig;
|
||||
import com.hbm.entity.effect.EntityNukeCloudSmall;
|
||||
import com.hbm.entity.effect.EntityNukeTorex;
|
||||
import com.hbm.entity.logic.EntityNukeExplosionMK5;
|
||||
import com.hbm.interfaces.IBomb;
|
||||
import com.hbm.main.MainRegistry;
|
||||
@ -124,12 +124,7 @@ public class NukeMan extends BlockContainer implements IBomb {
|
||||
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||
|
||||
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.manRadius, x + 0.5, y + 0.5, z + 0.5));
|
||||
|
||||
EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, BombConfig.manRadius * 0.005F);
|
||||
entity2.posX = x;
|
||||
entity2.posY = y;
|
||||
entity2.posZ = z;
|
||||
world.spawnEntityInWorld(entity2);
|
||||
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.manRadius);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.BombConfig;
|
||||
import com.hbm.entity.effect.EntityNukeCloudSmall;
|
||||
import com.hbm.entity.effect.EntityNukeTorex;
|
||||
import com.hbm.entity.logic.EntityNukeExplosionMK5;
|
||||
import com.hbm.interfaces.IBomb;
|
||||
import com.hbm.main.MainRegistry;
|
||||
@ -131,12 +131,7 @@ public class NukeMike extends BlockContainer implements IBomb {
|
||||
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||
|
||||
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, BombConfig.mikeRadius, x + 0.5, y + 0.5, z + 0.5));
|
||||
|
||||
EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, r * 0.005F);
|
||||
entity2.posX = x;
|
||||
entity2.posY = y;
|
||||
entity2.posZ = z;
|
||||
world.spawnEntityInWorld(entity2);
|
||||
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, BombConfig.mikeRadius);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.BombConfig;
|
||||
import com.hbm.entity.effect.EntityNukeCloudSmall;
|
||||
import com.hbm.entity.effect.EntityNukeTorex;
|
||||
import com.hbm.entity.logic.EntityNukeExplosionMK5;
|
||||
import com.hbm.interfaces.IBomb;
|
||||
import com.hbm.main.MainRegistry;
|
||||
@ -120,12 +120,7 @@ public class NukeN2 extends BlockContainer implements IBomb {
|
||||
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||
|
||||
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFacNoRad(world, r, x + 0.5, y + 0.5, z + 0.5));
|
||||
|
||||
EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, r * 0.005F);
|
||||
entity2.posX = x;
|
||||
entity2.posY = y;
|
||||
entity2.posZ = z;
|
||||
world.spawnEntityInWorld(entity2);
|
||||
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, r);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -4,7 +4,7 @@ import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.config.BombConfig;
|
||||
import com.hbm.entity.effect.EntityNukeCloudSmall;
|
||||
import com.hbm.entity.effect.EntityNukeTorex;
|
||||
import com.hbm.entity.logic.EntityNukeExplosionMK5;
|
||||
import com.hbm.interfaces.IBomb;
|
||||
import com.hbm.main.MainRegistry;
|
||||
@ -127,18 +127,9 @@ public class NukeTsar extends BlockContainer implements IBomb {
|
||||
public boolean igniteTestBomb(World world, int x, int y, int z, int r) {
|
||||
if(!world.isRemote) {
|
||||
tetn.clearSlots();
|
||||
// world.spawnParticle("hugeexplosion", x, y, z, 0, 0, 0);
|
||||
world.playSoundEffect(x, y, z, "random.explode", 1.0f, world.rand.nextFloat() * 0.1F + 0.9F);
|
||||
|
||||
world.spawnEntityInWorld(EntityNukeExplosionMK5.statFac(world, r, x + 0.5, y + 0.5, z + 0.5));
|
||||
|
||||
EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(world, 1000, r * 0.005F);
|
||||
entity2.posX = x;
|
||||
entity2.posY = y;
|
||||
entity2.posZ = z;
|
||||
world.spawnEntityInWorld(entity2);
|
||||
|
||||
// ExplosionNukeAdvanced.mush(world, x, y, z);
|
||||
EntityNukeTorex.statFac(world, x + 0.5, y + 0.5, z + 0.5, r);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -62,7 +62,7 @@ public class CoriumBlock extends BlockFluidClassic {
|
||||
return true;
|
||||
Random rand = new Random();
|
||||
|
||||
return b.getMaterial().isLiquid() || rand.nextInt((int) res) == 0;
|
||||
return b.getMaterial().isLiquid() || rand.nextInt((int) (res * res)) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
84
src/main/java/com/hbm/blocks/fluid/CoriumFinite.java
Normal file
84
src/main/java/com/hbm/blocks/fluid/CoriumFinite.java
Normal file
@ -0,0 +1,84 @@
|
||||
package com.hbm.blocks.fluid;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.lib.ModDamageSource;
|
||||
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.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class CoriumFinite extends GenericFiniteFluid {
|
||||
|
||||
public CoriumFinite(Fluid fluid, Material material) {
|
||||
super(fluid, material, "corium_still", "corium_flowing");
|
||||
setQuantaPerBlock(5);
|
||||
this.tickRate = 30;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
|
||||
Block b = world.getBlock(x, y, z);
|
||||
float res = (float) (Math.sqrt(b.getExplosionResistance(null)) * 3);
|
||||
|
||||
if(res < 1)
|
||||
return true;
|
||||
Random rand = new Random();
|
||||
|
||||
return b.getMaterial().isLiquid() || rand.nextInt((int) res) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displaceIfPossible(World world, int x, int y, int z) {
|
||||
|
||||
if(world.getBlock(x, y, z).getMaterial().isLiquid()) {
|
||||
return false;
|
||||
}
|
||||
return canDisplace(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
||||
entity.setInWeb();
|
||||
entity.setFire(3);
|
||||
entity.attackEntityFrom(ModDamageSource.radiation, 2F);
|
||||
|
||||
if(entity instanceof EntityLivingBase)
|
||||
ContaminationUtil.contaminate((EntityLivingBase)entity, HazardType.RADIATION, ContaminationType.CREATIVE, 1F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random rand) {
|
||||
|
||||
super.updateTick(world, x, y, z, rand);
|
||||
|
||||
if(!world.isRemote && rand.nextInt(10) == 0 && world.getBlock(x, y - 1, z) != this) {
|
||||
|
||||
if(rand.nextInt(3) == 0)
|
||||
world.setBlock(x, y, z, ModBlocks.block_corium);
|
||||
else
|
||||
world.setBlock(x, y, z, ModBlocks.block_corium_cobble);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.items.ModItems;
|
||||
|
||||
import api.hbm.block.IDrillInteraction;
|
||||
import api.hbm.block.IMiningDrill;
|
||||
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;
|
||||
|
||||
public class BlockBedrockOre extends Block implements IDrillInteraction {
|
||||
|
||||
public BlockBedrockOre() {
|
||||
super(Material.rock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreak(World world, int x, int y, int z, int meta, IMiningDrill drill) {
|
||||
return drill.getDrillRating() > 70;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack extractResource(World world, int x, int y, int z, int meta, IMiningDrill drill) {
|
||||
|
||||
if(drill.getDrillRating() > 70)
|
||||
return null;
|
||||
|
||||
Item drop = this.getDrop();
|
||||
|
||||
if(drop == null)
|
||||
return null;
|
||||
|
||||
return world.rand.nextInt(50) == 0 ? new ItemStack(drop) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRelativeHardness(World world, int x, int y, int z, int meta, IMiningDrill drill) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
private Item getDrop() {
|
||||
|
||||
if(this == ModBlocks.ore_bedrock_coltan)
|
||||
return ModItems.fragment_coltan;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -145,7 +145,7 @@ public class BlockBedrockOreTE extends BlockContainer implements ILookOverlay, I
|
||||
text.add("Tier: " + ore.tier);
|
||||
|
||||
if(ore.acidRequirement != null) {
|
||||
text.add("Requires: " + ore.acidRequirement.fill + "mB " + I18nUtil.resolveKey(ore.acidRequirement.type.getUnlocalizedName()));
|
||||
text.add("Requires: " + ore.acidRequirement.fill + "mB " + ore.acidRequirement.type.getLocalizedName());
|
||||
}
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
|
||||
55
src/main/java/com/hbm/blocks/generic/BlockBiomeStone.java
Normal file
55
src/main/java/com/hbm/blocks/generic/BlockBiomeStone.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.hbm.blocks.BlockEnumMulti;
|
||||
import com.hbm.blocks.BlockEnums.EnumBiomeType;
|
||||
|
||||
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;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockBiomeStone extends BlockEnumMulti {
|
||||
|
||||
public BlockBiomeStone() {
|
||||
super(Material.rock, EnumBiomeType.class, true, true);
|
||||
}
|
||||
|
||||
protected IIcon[] iconsTop;
|
||||
protected IIcon[] iconsLayer;
|
||||
|
||||
@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.iconsLayer = new IIcon[enums.length];
|
||||
|
||||
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.iconsTop[i] = reg.registerIcon(this.getTextureName() + "_top." + num.name().toLowerCase(Locale.US));
|
||||
this.iconsLayer[i] = reg.registerIcon(this.getTextureName() + "_layer." + num.name().toLowerCase(Locale.US));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(side == 0) return this.iconsTop[meta % this.icons.length];
|
||||
if(side == 1) return this.iconsTop[meta % this.icons.length];
|
||||
|
||||
if(world.getBlock(x, y + 1, z) == this && world.getBlockMetadata(x, y + 1, z) == meta) {
|
||||
return this.getIcon(side, meta);
|
||||
} else {
|
||||
return this.iconsLayer[meta % this.icons.length];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,9 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.inventory.gui.GUIScreenBobble;
|
||||
import com.hbm.items.special.ItemPlasticScrap.ScrapType;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -33,6 +29,9 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockBobble extends BlockContainer implements IGUIProvider {
|
||||
|
||||
public BlockBobble() {
|
||||
@ -171,27 +170,29 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
|
||||
|
||||
public static enum BobbleType {
|
||||
|
||||
NONE( "null", "null", null, null, false, ScrapType.BOARD_BLANK),
|
||||
STRENGTH( "Strength", "Strength", null, "It's essential to give your arguments impact.", false, ScrapType.BRIDGE_BIOS),
|
||||
PERCEPTION( "Perception", "Perception", null, "Only through observation will you perceive weakness.", false, ScrapType.BRIDGE_NORTH),
|
||||
ENDURANCE( "Endurance", "Endurance", null, "Always be ready to take one for the team.", false, ScrapType.BRIDGE_SOUTH),
|
||||
CHARISMA( "Charisma", "Charisma", null, "Nothing says pizzaz like a winning smile.", false, ScrapType.BRIDGE_IO),
|
||||
INTELLIGENCE( "Intelligence", "Intelligence", null, "It takes the smartest individuals to realize$there's always more to learn.", false, ScrapType.BRIDGE_BUS),
|
||||
AGILITY( "Agility", "Agility", null, "Never be afraid to dodge the sensitive issues.", false, ScrapType.BRIDGE_CHIPSET),
|
||||
LUCK( "Luck", "Luck", null, "There's only one way to give 110%.", false, ScrapType.BRIDGE_CMOS),
|
||||
BOB( "Robert \"The Bobcat\" Katzinsky", "HbMinecraft", "Hbm's Nuclear Tech Mod", "I know where you live, " + System.getProperty("user.name"), false, ScrapType.CPU_SOCKET),
|
||||
FRIZZLE( "Frooz", "Frooz", "Weapon models", "BLOOD IS FUEL", true, ScrapType.CPU_CLOCK),
|
||||
PU238( "Pu-238", "Pu-238", "Improved Tom impact mechanics", null, false, ScrapType.CPU_REGISTER),
|
||||
VT( "VT-6/24", "VT-6/24", "Balefire warhead model and general texturework", "You cannot unfuck a horse.", true, ScrapType.CPU_EXT),
|
||||
DOC( "The Doctor", "Doctor17PH", "Russian localization, lunar miner", "Perhaps the moon rocks were too expensive", true, ScrapType.CPU_CACHE),
|
||||
BLUEHAT( "The Blue Hat", "The Blue Hat", "Textures", "payday 2's deagle freeaim champ of the year 2022", true, ScrapType.MEM_16K_A),
|
||||
PHEO( "Pheo", "Pheonix", "Deuterium machines, tantalium textures, Reliant Rocket", "RUN TO THE BEDROOM, ON THE SUITCASE ON THE LEFT,$YOU'LL FIND MY FAVORITE AXE", true, ScrapType.MEM_16K_B),
|
||||
ADAM29( "Adam29", "Adam29", "Ethanol, liquid petroleum gas", "You know, nukes are really quite beatiful.$It's like watching a star be born for a split second.", true, ScrapType.MEM_16K_C),
|
||||
UFFR( "UFFR", "UFFR", "All sorts of things from his PR", "fried shrimp", false, ScrapType.MEM_SOCKET),
|
||||
VAER( "vaer", "vaer", "ZIRNOX", "taken de family out to the weekend cigarette festival", true, ScrapType.MEM_16K_D),
|
||||
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);
|
||||
NONE( "null", "null", null, null, false, ScrapType.BOARD_BLANK),
|
||||
STRENGTH( "Strength", "Strength", null, "It's essential to give your arguments impact.", false, ScrapType.BRIDGE_BIOS),
|
||||
PERCEPTION( "Perception", "Perception", null, "Only through observation will you perceive weakness.", false, ScrapType.BRIDGE_NORTH),
|
||||
ENDURANCE( "Endurance", "Endurance", null, "Always be ready to take one for the team.", false, ScrapType.BRIDGE_SOUTH),
|
||||
CHARISMA( "Charisma", "Charisma", null, "Nothing says pizzaz like a winning smile.", false, ScrapType.BRIDGE_IO),
|
||||
INTELLIGENCE( "Intelligence", "Intelligence", null, "It takes the smartest individuals to realize$there's always more to learn.", false, ScrapType.BRIDGE_BUS),
|
||||
AGILITY( "Agility", "Agility", null, "Never be afraid to dodge the sensitive issues.", false, ScrapType.BRIDGE_CHIPSET),
|
||||
LUCK( "Luck", "Luck", null, "There's only one way to give 110%.", false, ScrapType.BRIDGE_CMOS),
|
||||
BOB( "Robert \"The Bobcat\" Katzinsky", "HbMinecraft", "Hbm's Nuclear Tech Mod", "I know where you live, " + System.getProperty("user.name"), false, ScrapType.CPU_SOCKET),
|
||||
FRIZZLE( "Frooz", "Frooz", "Weapon models", "BLOOD IS FUEL", true, ScrapType.CPU_CLOCK),
|
||||
PU238( "Pu-238", "Pu-238", "Improved Tom impact mechanics", null, false, ScrapType.CPU_REGISTER),
|
||||
VT( "VT-6/24", "VT-6/24", "Balefire warhead model and general texturework", "You cannot unfuck a horse.", true, ScrapType.CPU_EXT),
|
||||
DOC( "The Doctor", "Doctor17PH", "Russian localization, lunar miner", "Perhaps the moon rocks were too expensive", true, ScrapType.CPU_CACHE),
|
||||
BLUEHAT( "The Blue Hat", "The Blue Hat", "Textures", "payday 2's deagle freeaim champ of the year 2022", true, ScrapType.MEM_16K_A),
|
||||
PHEO( "Pheo", "Pheonix", "Deuterium machines, tantalium textures, Reliant Rocket", "RUN TO THE BEDROOM, ON THE SUITCASE ON THE LEFT,$YOU'LL FIND MY FAVORITE AXE", true, ScrapType.MEM_16K_B),
|
||||
ADAM29( "Adam29", "Adam29", "Ethanol, liquid petroleum gas", "You know, nukes are really quite beatiful.$It's like watching a star be born for a split second.", true, ScrapType.MEM_16K_C),
|
||||
UFFR( "UFFR", "UFFR", "All sorts of things from his PR", "fried shrimp", false, ScrapType.MEM_SOCKET),
|
||||
VAER( "vaer", "vaer", "ZIRNOX", "taken de family out to the weekend cigarette festival", true, ScrapType.MEM_16K_D),
|
||||
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);
|
||||
|
||||
public String name; //the title of the tooltip
|
||||
public String label; //the name engraved in the socket
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import com.hbm.blocks.BlockEnumMulti;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockConcreteColoredExt extends BlockEnumMulti {
|
||||
|
||||
public BlockConcreteColoredExt(Material mat) {
|
||||
super(mat, EnumConcreteType.class, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
|
||||
if(meta == EnumConcreteType.MACHINE_STRIPE.ordinal() && (side == 0 || side == 1)) {
|
||||
return super.getIcon(side, EnumConcreteType.MACHINE.ordinal());
|
||||
}
|
||||
|
||||
return super.getIcon(side, meta);
|
||||
}
|
||||
|
||||
public enum EnumConcreteType {
|
||||
MACHINE,
|
||||
MACHINE_STRIPE,
|
||||
INDIGO,
|
||||
PURPLE,
|
||||
PINK,
|
||||
HAZARD
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.hbm.blocks.generic;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.items.special.ItemDoorSkin;
|
||||
import com.hbm.tileentity.DoorDecl;
|
||||
import com.hbm.tileentity.TileEntityDoorGeneric;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
@ -54,12 +55,14 @@ public class BlockDoorGeneric extends BlockDummyable {
|
||||
TileEntityDoorGeneric door = (TileEntityDoorGeneric) world.getTileEntity(pos1[0], pos1[1], pos1[2]);
|
||||
|
||||
if(door != null) {
|
||||
return door.tryToggle(playerIn);
|
||||
if(playerIn.getHeldItem() != null && playerIn.getHeldItem().getItem() instanceof ItemDoorSkin) {
|
||||
return door.setSkinIndex((byte) playerIn.getHeldItem().getItemDamage());
|
||||
} else {
|
||||
return door.tryToggle(playerIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!playerIn.isSneaking())
|
||||
return true;
|
||||
return false;
|
||||
return !playerIn.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
278
src/main/java/com/hbm/blocks/generic/BlockDynamicSlag.java
Normal file
278
src/main/java/com/hbm/blocks/generic/BlockDynamicSlag.java
Normal file
@ -0,0 +1,278 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.material.MaterialShapes;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
import com.hbm.inventory.material.Mats.MaterialStack;
|
||||
import com.hbm.inventory.material.NTMMaterial;
|
||||
import com.hbm.items.machine.ItemScraps;
|
||||
import com.hbm.render.icon.RGBMutatorInterpolatedComponentRemap;
|
||||
import com.hbm.render.icon.TextureAtlasSpriteMutatable;
|
||||
import com.hbm.util.Compat;
|
||||
|
||||
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.client.renderer.texture.TextureMap;
|
||||
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.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockDynamicSlag extends BlockContainer {
|
||||
|
||||
private HashMap<NTMMaterial, IIcon> iconMap = new HashMap();
|
||||
|
||||
public BlockDynamicSlag() {
|
||||
super(Material.iron);
|
||||
this.useNeighborBrightness = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntitySlag();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
super.registerBlockIcons(reg);
|
||||
|
||||
if(reg instanceof TextureMap) {
|
||||
TextureMap map = (TextureMap) reg;
|
||||
|
||||
for(NTMMaterial mat : Mats.orderedList) {
|
||||
if(mat.solidColorLight != mat.solidColorDark) {
|
||||
String placeholderName = this.getTextureName() + "-" + mat.names[0];
|
||||
TextureAtlasSpriteMutatable mutableIcon = new TextureAtlasSpriteMutatable(placeholderName, new RGBMutatorInterpolatedComponentRemap(0xFFFFFF, 0x505050, mat.solidColorLight, mat.solidColorDark)).setBlockAtlas();
|
||||
map.setTextureEntry(placeholderName, mutableIcon);
|
||||
iconMap.put(mat, mutableIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
|
||||
TileEntitySlag tile = (TileEntitySlag) world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile != null && tile.mat != null) {
|
||||
IIcon override = iconMap.get(tile.mat);
|
||||
if(override != null) {
|
||||
return override;
|
||||
}
|
||||
}
|
||||
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
|
||||
|
||||
TileEntitySlag tile = (TileEntitySlag) world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile != null && tile.mat != null) {
|
||||
if(!iconMap.containsKey(tile.mat)) {
|
||||
return tile.mat.moltenColor;
|
||||
}
|
||||
}
|
||||
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntitySlag tile = (TileEntitySlag) world.getTileEntity(x, y, z);
|
||||
if(tile != null) {
|
||||
this.setBlockBounds(0F, 0F, 0F, 1F, (float) tile.amount / (float) TileEntitySlag.maxAmount, 1F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
TileEntitySlag tile = (TileEntitySlag) world.getTileEntity(x, y, z);
|
||||
if(tile != null) {
|
||||
this.setBlockBounds(0F, 0F, 0F, 1F, (float) tile.amount / (float) TileEntitySlag.maxAmount, 1F);
|
||||
}
|
||||
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random rand) {
|
||||
|
||||
TileEntity s = Compat.getTileStandard(world, x, y, z);
|
||||
TileEntity b = Compat.getTileStandard(world, x, y - 1, z);
|
||||
|
||||
/* Error here, delete the block */
|
||||
if(s == null || !(s instanceof TileEntitySlag)) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntitySlag self = (TileEntitySlag) s;
|
||||
|
||||
/* Flow down */
|
||||
if(world.getBlock(x, y - 1, z).isReplaceable(world, x, y - 1, z)) {
|
||||
world.setBlock(x, y - 1, z, ModBlocks.slag);
|
||||
TileEntitySlag tile = (TileEntitySlag) Compat.getTileStandard(world, x, y - 1, z);
|
||||
tile.mat = self.mat;
|
||||
tile.amount = self.amount;
|
||||
world.markBlockForUpdate(x, y - 1, z);
|
||||
world.setBlockToAir(x, y, z);
|
||||
return;
|
||||
} else if(b instanceof TileEntitySlag) {
|
||||
|
||||
TileEntitySlag below = (TileEntitySlag) b;
|
||||
|
||||
if(below.mat == self.mat && below.amount < TileEntitySlag.maxAmount) {
|
||||
int transfer = Math.min(TileEntitySlag.maxAmount - below.amount, self.amount);
|
||||
below.amount += transfer;
|
||||
self.amount -= transfer;
|
||||
|
||||
if(self.amount <= 0){
|
||||
world.setBlockToAir(x, y, z);
|
||||
} else {
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(x, y - 1, z);
|
||||
world.scheduleBlockUpdate(x, y - 1, z, ModBlocks.slag, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Flow sideways, no neighbors */
|
||||
ForgeDirection[] sides = new ForgeDirection[] { ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST };
|
||||
int count = 0;
|
||||
for(ForgeDirection dir : sides) {
|
||||
int iX = x + dir.offsetX;
|
||||
int iZ = z + dir.offsetZ;
|
||||
|
||||
if(world.getBlock(iX, y, iZ).isReplaceable(world, iX, y, iZ)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if(self.amount >= self.maxAmount / 5 && count > 0) {
|
||||
int toSpread = Math.max(self.amount / (count * 2), 1);
|
||||
|
||||
for(ForgeDirection dir : sides) {
|
||||
int iX = x + dir.offsetX;
|
||||
int iZ = z + dir.offsetZ;
|
||||
|
||||
if(world.getBlock(iX, y, iZ).isReplaceable(world, iX, y, iZ)) {
|
||||
world.setBlock(iX, y, iZ, ModBlocks.slag);
|
||||
TileEntitySlag tile = (TileEntitySlag) Compat.getTileStandard(world, iX, y, iZ);
|
||||
world.markBlockForUpdate(iX, y, iZ);
|
||||
world.scheduleBlockUpdate(iX, y, iZ, ModBlocks.slag, 1);
|
||||
tile.mat = self.mat;
|
||||
tile.amount = toSpread;
|
||||
self.amount -= toSpread;
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
|
||||
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
harvesters.set(player);
|
||||
this.dropBlockAsItem(world, x, y, z, meta, 0);
|
||||
harvesters.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
|
||||
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
|
||||
player.addExhaustion(0.025F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
|
||||
TileEntitySlag tile = (TileEntitySlag) world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile != null && tile.mat != null && tile.amount > 0) {
|
||||
ret.add(ItemScraps.create(new MaterialStack(tile.mat, tile.amount)));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
|
||||
|
||||
TileEntitySlag tile = (TileEntitySlag) world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile != null) {
|
||||
return ItemScraps.create(new MaterialStack(tile.mat, tile.amount));
|
||||
}
|
||||
|
||||
return super.getPickBlock(target, world, x, y, z, player);
|
||||
}
|
||||
|
||||
public static class TileEntitySlag extends TileEntity {
|
||||
|
||||
public NTMMaterial mat;
|
||||
public int amount;
|
||||
public static int maxAmount = MaterialShapes.BLOCK.q(16);
|
||||
|
||||
@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.mat = Mats.matById.get(nbt.getInteger("mat"));
|
||||
this.amount = nbt.getInteger("amount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
if(this.mat != null) nbt.setInteger("mat", this.mat.id);
|
||||
nbt.setInteger("amount", this.amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
43
src/main/java/com/hbm/blocks/generic/BlockGlyphid.java
Normal file
43
src/main/java/com/hbm/blocks/generic/BlockGlyphid.java
Normal file
@ -0,0 +1,43 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
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 BlockGlyphid extends Block {
|
||||
|
||||
public IIcon[] icons = new IIcon[2];
|
||||
|
||||
public BlockGlyphid(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) % this.icons.length)];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return icons[meta % this.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");
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
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.handler.pollution.PollutionHandler;
|
||||
import com.hbm.handler.pollution.PollutionHandler.PollutionType;
|
||||
import com.hbm.items.ModItems;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockGlyphidSpawner extends BlockContainer {
|
||||
|
||||
public BlockGlyphidSpawner(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int meta, Random rand, int fortune) {
|
||||
return ModItems.egg_glyphid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(int meta, int fortune, Random rand) {
|
||||
return 1 + rand.nextInt(3) + fortune;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityGlpyhidSpawner();
|
||||
}
|
||||
|
||||
public static class TileEntityGlpyhidSpawner extends TileEntity {
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return rand.nextInt(3) == 0 ? new EntityGlyphidBlaster(worldObj) : new EntityGlyphidNuclear(worldObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -138,6 +138,7 @@ public class BlockHazard extends Block implements ITooltipProvider {
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
|
||||
// who wrote this???
|
||||
rad = HazardSystem.getHazardLevelFromStack(new ItemStack(this), HazardRegistry.RADIATION) * 0.1F;
|
||||
|
||||
if(this.rad > 0)
|
||||
|
||||
31
src/main/java/com/hbm/blocks/generic/BlockLantern.java
Normal file
31
src/main/java/com/hbm/blocks/generic/BlockLantern.java
Normal file
@ -0,0 +1,31 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.tileentity.deco.TileEntityLantern;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockLantern extends BlockDummyable {
|
||||
|
||||
public BlockLantern() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
if(meta >= 12) return new TileEntityLantern();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getDimensions() {
|
||||
return new int[] {4, 0, 0, 0, 0, 0};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.extprop.HbmPlayerProps;
|
||||
import com.hbm.tileentity.IRepairable;
|
||||
import com.hbm.tileentity.deco.TileEntityLanternBehemoth;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
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;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
|
||||
public class BlockLanternBehemoth extends BlockDummyable implements IToolable, ILookOverlay {
|
||||
|
||||
public BlockLanternBehemoth() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
if(meta >= 12) return new TileEntityLanternBehemoth();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int i, Random rand, int j) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getDimensions() {
|
||||
return new int[] {4, 0, 0, 0, 0, 0};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
|
||||
if(tool != ToolType.TORCH) return false;
|
||||
boolean didRepair = IRepairable.tryRepairMultiblock(world, x, y, z, this, player);
|
||||
|
||||
if(didRepair) {
|
||||
HbmPlayerProps data = HbmPlayerProps.getData(player);
|
||||
data.reputation++;
|
||||
}
|
||||
|
||||
return didRepair;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
IRepairable.addGenericOverlay(event, world, x, y, z, this);
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.hbm.blocks.generic;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.machine.ZirnoxDestroyed;
|
||||
import com.hbm.blocks.machine.rbmk.RBMKDebris;
|
||||
|
||||
@ -99,6 +100,7 @@ public class BlockLayering extends Block {
|
||||
}
|
||||
|
||||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
|
||||
if(this == ModBlocks.leaves_layer) return true;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
return meta >= 7 ? false : blockMaterial.isReplaceable();
|
||||
}
|
||||
|
||||
@ -22,19 +22,23 @@ public class BlockNTMGlass extends BlockBreakable {
|
||||
this.doesDrop = doesDrop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random rand) {
|
||||
return doesDrop ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass() {
|
||||
return renderLayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canSilkHarvest() {
|
||||
return true;
|
||||
}
|
||||
|
||||
52
src/main/java/com/hbm/blocks/generic/BlockNTMGlassPane.java
Normal file
52
src/main/java/com/hbm/blocks/generic/BlockNTMGlassPane.java
Normal file
@ -0,0 +1,52 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPane;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockNTMGlassPane extends BlockPane
|
||||
{
|
||||
int renderLayer;
|
||||
boolean doesDrop = false;
|
||||
|
||||
//NOTE when you have eclipse make the constructor for you it *WILL BE 'protected'* so make sure to make this public like below.
|
||||
/*public BlockNTMGlassPane(String flatFaceTextureName, String rimTextureName,
|
||||
Material mat, boolean bool) {
|
||||
super(flatFaceTextureName, rimTextureName, mat, bool);
|
||||
// TODO Auto-generated constructor stub
|
||||
this.setLightOpacity(1);
|
||||
this.opaque = true;
|
||||
}*/
|
||||
|
||||
public BlockNTMGlassPane(int layer, String name, String rimTextureName, Material material, boolean doesDrop) {
|
||||
super(name, rimTextureName, material, false);
|
||||
this.renderLayer = layer;
|
||||
this.doesDrop = doesDrop;
|
||||
this.opaque = true;
|
||||
this.setLightOpacity(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPaneConnectTo(IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
|
||||
Block b = world.getBlock(x, y, z);
|
||||
return super.canPaneConnectTo(world, x, y, z, dir) || b instanceof BlockNTMGlass;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderBlockPass() {
|
||||
return renderLayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random rand) {
|
||||
return doesDrop ? 1 : 0;
|
||||
}
|
||||
|
||||
}
|
||||
@ -29,6 +29,8 @@ public class BlockSellafield extends BlockHazard {
|
||||
public BlockSellafield(Material mat) {
|
||||
super(mat);
|
||||
this.setCreativeTab(MainRegistry.blockTab);
|
||||
this.needsRandomTick = true;
|
||||
this.rad = 0.5F;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,19 +43,20 @@ public class BlockSellafield extends BlockHazard {
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, int x, int y, int z, Random rand) {
|
||||
|
||||
ChunkRadiationManager.proxy.incrementRad(world, x, y, z, this.rad);
|
||||
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(rand.nextInt(meta == 0 ? 30 * 60 : 15 * 60) == 0) {
|
||||
ChunkRadiationManager.proxy.incrementRad(world, x, y, z, this.rad * (meta + 1));
|
||||
|
||||
if(rand.nextInt(meta == 0 ? 25 : 15) == 0) {
|
||||
if(meta > 0)
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta - 1, 2);
|
||||
else
|
||||
world.setBlock(x, y, z, ModBlocks.sellafield_slaked);
|
||||
}
|
||||
|
||||
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
|
||||
}
|
||||
|
||||
@Override public void onBlockAdded(World world, int x, int y, int z) { }
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected IIcon[] icons;
|
||||
@ -86,6 +89,4 @@ public class BlockSellafield extends BlockHazard {
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return this.icons[meta % this.icons.length];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
32
src/main/java/com/hbm/blocks/generic/BlockSlag.java
Normal file
32
src/main/java/com/hbm/blocks/generic/BlockSlag.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
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 BlockSlag extends BlockBeaconable {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconAlt;
|
||||
|
||||
public BlockSlag(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
super.registerBlockIcons(iconRegister);
|
||||
this.iconAlt = iconRegister.registerIcon(this.getTextureName() + "_broken");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
if(metadata == 1) return this.iconAlt;
|
||||
|
||||
return this.blockIcon;
|
||||
}
|
||||
}
|
||||
@ -1,21 +1,19 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.IBlockMulti;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.tool.ItemLock;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityLockableBase;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityCrateBase;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityCrateDesh;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityCrateIron;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityCrateSteel;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityCrateTungsten;
|
||||
import com.hbm.tileentity.machine.storage.TileEntitySafe;
|
||||
import com.hbm.tileentity.machine.storage.*;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -27,6 +25,8 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -39,7 +39,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockStorageCrate extends BlockContainer implements IBlockMulti {
|
||||
public class BlockStorageCrate extends BlockContainer implements IBlockMulti, ITooltipProvider {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconTop;
|
||||
@ -75,6 +75,9 @@ public class BlockStorageCrate extends BlockContainer implements IBlockMulti {
|
||||
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top");
|
||||
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side");
|
||||
}
|
||||
if(this == ModBlocks.crate_template) {
|
||||
this.iconTop = this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":crate_template");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,6 +96,7 @@ public class BlockStorageCrate extends BlockContainer implements IBlockMulti {
|
||||
if(this == ModBlocks.crate_steel) return new TileEntityCrateSteel();
|
||||
if(this == ModBlocks.crate_desh) return new TileEntityCrateDesh();
|
||||
if(this == ModBlocks.crate_tungsten) return new TileEntityCrateTungsten();
|
||||
if(this == ModBlocks.crate_template) return new TileEntityCrateTemplate();
|
||||
if(this == ModBlocks.safe) return new TileEntitySafe();
|
||||
return null;
|
||||
}
|
||||
@ -140,6 +144,7 @@ public class BlockStorageCrate extends BlockContainer implements IBlockMulti {
|
||||
|
||||
if(abyte.length > 6000) {
|
||||
player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.RED + "Warning: Container NBT exceeds 6kB, contents will be ejected!"));
|
||||
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(this)));
|
||||
return world.setBlockToAir(x, y, z);
|
||||
}
|
||||
|
||||
@ -270,4 +275,45 @@ public class BlockStorageCrate extends BlockContainer implements IBlockMulti {
|
||||
public int getSubCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
|
||||
return Container.calcRedstoneFromInventory((IInventory) world.getTileEntity(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||
if(stack.hasTagCompound()) {
|
||||
|
||||
List<String> contents = new ArrayList();
|
||||
int amount = 0;
|
||||
|
||||
for(int i = 0; i < 100; i++) { //whatever the biggest container is, i can't be bothered to check
|
||||
ItemStack content = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("slot" + i));
|
||||
|
||||
if(content != null) {
|
||||
amount++;
|
||||
|
||||
if(contents.size() < 10) {
|
||||
contents.add(EnumChatFormatting.AQUA + " - " + content.getDisplayName() + (content.stackSize > 1 ? (" x" + content.stackSize) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!contents.isEmpty()) {
|
||||
list.add(EnumChatFormatting.AQUA + "Contains:");
|
||||
list.addAll(contents);
|
||||
amount -= contents.size();
|
||||
|
||||
if(amount > 0) {
|
||||
list.add(EnumChatFormatting.AQUA + "...and " + amount + " more.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.BlockEnumMulti;
|
||||
@ -87,8 +88,8 @@ public class BlockTallPlant extends BlockEnumMulti implements IPlantable, IGrowa
|
||||
|
||||
for(int i = 0; i < icons.length; i++) {
|
||||
Enum num = enums[i];
|
||||
this.icons[i] = reg.registerIcon(this.getTextureName() + "." + num.name().toLowerCase() + ".upper");
|
||||
this.bottomIcons[i] = reg.registerIcon(this.getTextureName() + "." + num.name().toLowerCase() + ".lower");
|
||||
this.icons[i] = reg.registerIcon(this.getTextureName() + "." + num.name().toLowerCase(Locale.US) + ".upper");
|
||||
this.bottomIcons[i] = reg.registerIcon(this.getTextureName() + "." + num.name().toLowerCase(Locale.US) + ".lower");
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,7 +305,7 @@ public class BlockTallPlant extends BlockEnumMulti implements IPlantable, IGrowa
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ArrayList<ItemStack> ret = super.getDrops(world, x, y, z, metadata, fortune);
|
||||
|
||||
if(rectify(world.getBlockMetadata(x, y, z)) == EnumTallFlower.CD4.ordinal()) {
|
||||
if(metadata == EnumTallFlower.CD4.ordinal() + 8) {
|
||||
ret.add(DictFrame.fromOne(ModItems.plant_item, com.hbm.items.ItemEnums.EnumPlantType.MUSTARDWILLOW, 3 + world.rand.nextInt(4)));
|
||||
}
|
||||
|
||||
|
||||
@ -8,9 +8,11 @@ import java.util.Map.Entry;
|
||||
import com.hbm.blocks.BlockMulti;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.OreDictManager;
|
||||
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;
|
||||
@ -150,6 +152,7 @@ public class BlockToolConversion extends BlockMulti implements IToolable, ILookO
|
||||
|
||||
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.TORCH, new MetaBlock(ModBlocks.fusion_conductor, 0)), new Pair(new AStack[] {new OreDictStack(OreDictManager.STEEL.plateCast())}, new MetaBlock(ModBlocks.fusion_conductor, 1)));
|
||||
}
|
||||
|
||||
public static HashMap<Object[], Object> bufferedRecipes = new HashMap();
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
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 BlockToolConversionPillar extends BlockToolConversion {
|
||||
|
||||
public IIcon[] topIcons;
|
||||
public IIcon topIcon;
|
||||
|
||||
public BlockToolConversionPillar(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
|
||||
this.blockIcon = iconRegister.registerIcon(this.getTextureName() + "_side");
|
||||
this.topIcon = iconRegister.registerIcon(this.getTextureName() + "_top");
|
||||
|
||||
if(names != null) {
|
||||
icons = new IIcon[names.length];
|
||||
topIcons = new IIcon[names.length];
|
||||
|
||||
for(int i = 0; i < names.length; i++) {
|
||||
icons[i] = iconRegister.registerIcon(getTextureName() + "_side" + names[i]);
|
||||
topIcons[i] = iconRegister.registerIcon(getTextureName() + "_top" + names[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
|
||||
metadata -= 1;
|
||||
|
||||
if(metadata == -1 || icons == null || metadata >= icons.length) {
|
||||
return side == 0 || side == 1 ? topIcon : blockIcon;
|
||||
}
|
||||
|
||||
return side == 0 || side == 1 ? topIcons[metadata] : icons[metadata];
|
||||
}
|
||||
}
|
||||
30
src/main/java/com/hbm/blocks/machine/BlockCM.java
Normal file
30
src/main/java/com/hbm/blocks/machine/BlockCM.java
Normal file
@ -0,0 +1,30 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.hbm.blocks.BlockEnumMulti;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockCM extends BlockEnumMulti {
|
||||
|
||||
public BlockCM(Material mat, Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) {
|
||||
super(mat, theEnum, multiName, multiTexture);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
Enum[] enums = theEnum.getEnumConstants();
|
||||
this.icons = new IIcon[enums.length];
|
||||
|
||||
for(int i = 0; i < icons.length; i++) {
|
||||
Enum num = enums[i];
|
||||
this.icons[i] = reg.registerIcon(this.getTextureName() + "_" + num.name().toLowerCase(Locale.US));
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/main/java/com/hbm/blocks/machine/BlockCMAnchor.java
Normal file
46
src/main/java/com/hbm/blocks/machine/BlockCMAnchor.java
Normal file
@ -0,0 +1,46 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
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 BlockCMAnchor extends Block {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconFront;
|
||||
|
||||
public BlockCMAnchor() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + ":cmt_terminal_front");
|
||||
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":cmt_terminal_side");
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
31
src/main/java/com/hbm/blocks/machine/BlockCMGlass.java
Normal file
31
src/main/java/com/hbm/blocks/machine/BlockCMGlass.java
Normal file
@ -0,0 +1,31 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
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.IBlockAccess;
|
||||
|
||||
public class BlockCMGlass extends BlockCM {
|
||||
|
||||
public BlockCMGlass(Material mat, Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) {
|
||||
super(mat, theEnum, multiName, multiTexture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
return block == this ? false : super.shouldSideBeRendered(world, x, y, z, side);
|
||||
}
|
||||
}
|
||||
32
src/main/java/com/hbm/blocks/machine/BlockCMPort.java
Normal file
32
src/main/java/com/hbm/blocks/machine/BlockCMPort.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCMPort extends BlockCM implements ITileEntityProvider {
|
||||
|
||||
public BlockCMPort(Material mat, Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) {
|
||||
super(mat, theEnum, multiName, multiTexture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityProxyCombo().inventory().power().fluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block b, int m) {
|
||||
super.breakBlock(world, x, y, z, b, m);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
}
|
||||
206
src/main/java/com/hbm/blocks/machine/BlockCustomMachine.java
Normal file
206
src/main/java/com/hbm/blocks/machine/BlockCustomMachine.java
Normal file
@ -0,0 +1,206 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.config.CustomMachineConfigJSON;
|
||||
import com.hbm.config.CustomMachineConfigJSON.MachineConfiguration;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityCustomMachine;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
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.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCustomMachine extends BlockContainer {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconFront;
|
||||
|
||||
public BlockCustomMachine() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityCustomMachine();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + ":cm_terminal_front");
|
||||
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":cm_terminal_side");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
if(metadata >= 100) return side == 3 ? this.iconFront : this.blockIcon;
|
||||
return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : 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(world.isRemote) {
|
||||
return true;
|
||||
} else if(!player.isSneaking()) {
|
||||
|
||||
TileEntityCustomMachine tile = (TileEntityCustomMachine) world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile != null) {
|
||||
|
||||
if(tile.checkStructure()) {
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
} else if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.wand_s) {
|
||||
tile.buildStructure();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
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);
|
||||
|
||||
TileEntityCustomMachine tile = (TileEntityCustomMachine) world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile != null) {
|
||||
int id = stack.getItemDamage() - 100;
|
||||
|
||||
if(id >= 0 && id < CustomMachineConfigJSON.customMachines.size()) {
|
||||
|
||||
MachineConfiguration config = CustomMachineConfigJSON.niceList.get(id);
|
||||
|
||||
if(config != null) {
|
||||
tile.machineType = config.unlocalizedName;
|
||||
tile.init();
|
||||
tile.markChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
|
||||
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
harvesters.set(player);
|
||||
this.dropBlockAsItem(world, x, y, z, meta, 0);
|
||||
harvesters.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
|
||||
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
|
||||
player.addExhaustion(0.025F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
Item item = getItemDropped(metadata, world.rand, fortune);
|
||||
if(item != null) {
|
||||
|
||||
TileEntityCustomMachine tile = (TileEntityCustomMachine) world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile != null) {
|
||||
ItemStack stack = new ItemStack(item, 1, CustomMachineConfigJSON.niceList.indexOf(tile.config) + 100);
|
||||
ret.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { //using the deprecated one to make NEI happy
|
||||
|
||||
TileEntityCustomMachine tile = (TileEntityCustomMachine) world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile != null && tile.machineType != null && !tile.machineType.isEmpty()) {
|
||||
ItemStack stack = new ItemStack(this, 1, CustomMachineConfigJSON.niceList.indexOf(tile.config) + 100);
|
||||
return stack;
|
||||
}
|
||||
|
||||
return super.getPickBlock(target, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
|
||||
ISidedInventory sided = (ISidedInventory) world.getTileEntity(x, y, z);
|
||||
Random rand = world.rand;
|
||||
|
||||
if(sided != null) {
|
||||
for(int i1 = 0; i1 < sided.getSizeInventory(); ++i1) {
|
||||
|
||||
if(i1 >= 10 && i1 <= 15)
|
||||
continue; // do NOT drop the filters
|
||||
|
||||
ItemStack itemstack = sided.getStackInSlot(i1);
|
||||
|
||||
if(itemstack != null) {
|
||||
float f = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = rand.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while(itemstack.stackSize > 0) {
|
||||
int j1 = rand.nextInt(21) + 10;
|
||||
|
||||
if(j1 > itemstack.stackSize) {
|
||||
j1 = itemstack.stackSize;
|
||||
}
|
||||
|
||||
itemstack.stackSize -= j1;
|
||||
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + 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) rand.nextGaussian() * f3;
|
||||
entityitem.motionY = (float) rand.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motionZ = (float) rand.nextGaussian() * f3;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
world.func_147453_f(x, y, z, block);
|
||||
}
|
||||
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
}
|
||||
@ -7,12 +7,13 @@ import java.util.Random;
|
||||
import com.hbm.blocks.IPersistentInfoProvider;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityBarrel;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
@ -28,6 +29,9 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@ -72,7 +76,19 @@ public class BlockFluidBarrel extends BlockContainer implements ITooltipProvider
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
return true;
|
||||
|
||||
} else {
|
||||
} else if(player.isSneaking()){
|
||||
TileEntityBarrel mileEntity = (TileEntityBarrel) world.getTileEntity(x, y, z);
|
||||
|
||||
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IItemFluidIdentifier) {
|
||||
FluidType type = ((IItemFluidIdentifier) player.getHeldItem().getItem()).getType(world, x, y, z, player.getHeldItem());
|
||||
|
||||
mileEntity.tank.setTankType(type);
|
||||
mileEntity.markDirty();
|
||||
player.addChatComponentMessage(new ChatComponentText("Changed type to ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)).appendSibling(new ChatComponentTranslation(type.getConditionalName())).appendSibling(new ChatComponentText("!")));
|
||||
}
|
||||
return true;
|
||||
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -164,11 +180,28 @@ public class BlockFluidBarrel extends BlockContainer implements ITooltipProvider
|
||||
player.addExhaustion(0.025F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(!(te instanceof TileEntityBarrel))
|
||||
return 0;
|
||||
|
||||
TileEntityBarrel barrel = (TileEntityBarrel) te;
|
||||
return barrel.getComparatorPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||
FluidTank tank = new FluidTank(Fluids.NONE, 0, 0);
|
||||
FluidTank tank = new FluidTank(Fluids.NONE, 0);
|
||||
tank.readFromNBT(persistentTag, "tank");
|
||||
list.add(EnumChatFormatting.YELLOW + "" + tank.getFill() + "/" + tank.getMaxFill() + "mB " + I18nUtil.resolveKey(tank.getTankType().getUnlocalizedName()));
|
||||
list.add(EnumChatFormatting.YELLOW + "" + tank.getFill() + "/" + tank.getMaxFill() + "mB " + tank.getTankType().getLocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
22
src/main/java/com/hbm/blocks/machine/BlockGenericPWR.java
Normal file
22
src/main/java/com/hbm/blocks/machine/BlockGenericPWR.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.blocks.generic.BlockGeneric;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BlockGenericPWR extends BlockGeneric implements ITooltipProvider {
|
||||
|
||||
public BlockGenericPWR(Material material) {
|
||||
super(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||
this.addStandardInfo(stack, player, list, ext);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.render.block.ct.CT;
|
||||
@ -47,12 +48,12 @@ public class BlockHadronCoil extends Block implements IBlockCT, ITooltipProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(IBlockAccess world, int x, int y, int z, IBlockCT block) {
|
||||
public boolean canConnect(IBlockAccess world, int x, int y, int z, Block block) {
|
||||
return block instanceof BlockHadronCoil;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) {
|
||||
list.add(I18nUtil.resolveKey("info.coil") + ": " + String.format("%,d", factor));
|
||||
list.add(I18nUtil.resolveKey("info.coil") + ": " + String.format(Locale.US, "%,d", factor));
|
||||
}
|
||||
}
|
||||
|
||||
67
src/main/java/com/hbm/blocks/machine/BlockHadronCooler.java
Normal file
67
src/main/java/com/hbm/blocks/machine/BlockHadronCooler.java
Normal file
@ -0,0 +1,67 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.hbm.blocks.BlockMulti;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
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.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class BlockHadronCooler extends BlockMulti implements ITooltipProvider {
|
||||
|
||||
private IIcon[] icons = new IIcon[getSubCount()];
|
||||
|
||||
public BlockHadronCooler(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
icons[0] = reg.registerIcon(RefStrings.MODID + ":hadron_cooler");
|
||||
icons[1] = reg.registerIcon(RefStrings.MODID + ":hadron_cooler_mk2");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return icons[this.rectify(metadata)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSubCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
int meta = this.rectify(stack.getItemDamage());
|
||||
|
||||
if(meta == 1) return this.getUnlocalizedName() + "_mk2";
|
||||
|
||||
return this.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
|
||||
for(String s : I18nUtil.resolveKeyArray(this.getUnlocalizedName(stack) + ".desc")) list.add(EnumChatFormatting.YELLOW + s);
|
||||
} else {
|
||||
list.add(EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.ITALIC +"Hold <" +
|
||||
EnumChatFormatting.YELLOW + "" + EnumChatFormatting.ITALIC + "LSHIFT" +
|
||||
EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.ITALIC + "> to display more info");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.IBlockMulti;
|
||||
@ -47,8 +48,8 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
this.iconTop = new IIcon[3];
|
||||
this.iconSide = new IIcon[3];
|
||||
this.iconTop = new IIcon[4];
|
||||
this.iconSide = new IIcon[4];
|
||||
|
||||
this.iconTop[0] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top_iron");
|
||||
this.iconSide[0] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side_iron");
|
||||
@ -56,14 +57,17 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
|
||||
this.iconSide[1] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side_desh");
|
||||
this.iconTop[2] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top");
|
||||
this.iconSide[2] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side");
|
||||
this.iconTop[3] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top_wood");
|
||||
this.iconSide[3] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side_wood");
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
list.add(new ItemStack(item, 1, 3));
|
||||
list.add(new ItemStack(item, 1, 0));
|
||||
list.add(new ItemStack(item, 1, 1));
|
||||
list.add(new ItemStack(item, 1, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,7 +88,7 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
|
||||
}
|
||||
|
||||
public int getCapacity(int meta) {
|
||||
return meta == 0 ? 10_000 : meta == 1 ? 100_000 : meta == 2 ? 1_000_000 : 0;
|
||||
return meta == 3 ? 100 : meta == 0 ? 10_000 : meta == 1 ? 100_000 : meta == 2 ? 1_000_000 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -242,7 +246,7 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
|
||||
|
||||
@Override
|
||||
public int getSubCount() {
|
||||
return 3;
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -262,7 +266,7 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
|
||||
if(full) {
|
||||
|
||||
title = storage.type.getDisplayName();
|
||||
text.add(String.format("%,d", storage.getStockpile()) + " / " + String.format("%,d", storage.getCapacity()));
|
||||
text.add(String.format(Locale.US, "%,d", storage.getStockpile()) + " / " + String.format(Locale.US, "%,d", storage.getCapacity()));
|
||||
|
||||
double percent = (double) storage.getStockpile() / (double) storage.getCapacity();
|
||||
int charge = (int) Math.floor(percent * 10_000D);
|
||||
@ -283,7 +287,17 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
|
||||
|
||||
if(type != null) {
|
||||
list.add(EnumChatFormatting.GOLD + type.getDisplayName());
|
||||
list.add(String.format("%,d", stack.stackTagCompound.getInteger("stack")) + " / " + String.format("%,d", getCapacity(stack.getItemDamage())));
|
||||
list.add(String.format(Locale.US, "%,d", stack.stackTagCompound.getInteger("stack")) + " / " + String.format(Locale.US, "%,d", getCapacity(stack.getItemDamage())));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
|
||||
return ((TileEntityMassStorage) world.getTileEntity(x, y, z)).redstone;
|
||||
}
|
||||
}
|
||||
|
||||
320
src/main/java/com/hbm/blocks/machine/BlockPWR.java
Normal file
320
src/main/java/com/hbm/blocks/machine/BlockPWR.java
Normal file
@ -0,0 +1,320 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
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.TileEntityPWRController;
|
||||
|
||||
import api.hbm.fluid.IFluidConnector;
|
||||
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.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
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.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockPWR extends BlockContainer implements IBlockCT {
|
||||
|
||||
@SideOnly(Side.CLIENT) protected IIcon iconPort;
|
||||
|
||||
public BlockPWR(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 + ":pwr_casing_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.pwr_block || block == ModBlocks.pwr_controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityBlockPWR();
|
||||
}
|
||||
|
||||
@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 TileEntityBlockPWR) {
|
||||
TileEntityBlockPWR pwr = (TileEntityBlockPWR) tile;
|
||||
world.removeTileEntity(x, y, z);
|
||||
if(pwr.block != null) {
|
||||
world.setBlock(x, y, z, pwr.block);
|
||||
TileEntity controller = world.getTileEntity(pwr.coreX, pwr.coreY, pwr.coreZ);
|
||||
|
||||
if(controller instanceof TileEntityPWRController) {
|
||||
((TileEntityPWRController) controller).assembled = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
|
||||
public static class TileEntityBlockPWR extends TileEntity implements IFluidConnector, ISidedInventory {
|
||||
|
||||
public Block block;
|
||||
public int coreX;
|
||||
public int coreY;
|
||||
public int coreZ;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(worldObj.getTotalWorldTime() % 20 == 0 && block != null) {
|
||||
|
||||
TileEntityPWRController 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) {
|
||||
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("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 TileEntityPWRController cachedCore;
|
||||
|
||||
protected TileEntityPWRController 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 TileEntityPWRController) {
|
||||
TileEntityPWRController controller = (TileEntityPWRController) tile;
|
||||
cachedCore = controller;
|
||||
return controller;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferFluid(FluidType type, int pressure, long fluid) {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return fluid;
|
||||
if(block == null) return fluid;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.transferFluid(type, pressure, fluid);
|
||||
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDemand(FluidType type, int pressure) {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return 0;
|
||||
if(block == null) return 0;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.getDemand(type, pressure);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(FluidType type, ForgeDirection dir) {
|
||||
return this.getBlockMetadata() == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return 0;
|
||||
if(block == null) return 0;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.getSizeInventory();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return null;
|
||||
if(block == null) return null;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.getStackInSlot(slot);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return null;
|
||||
if(block == null) return null;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.decrStackSize(slot, amount);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return null;
|
||||
if(block == null) return null;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.getStackInSlotOnClosing(slot);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return;
|
||||
if(block == null) return;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) controller.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return 0;
|
||||
if(block == null) return 0;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.getInventoryStackLimit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override public boolean isUseableByPlayer(EntityPlayer player) { return false; }
|
||||
@Override public void openInventory() { }
|
||||
@Override public void closeInventory() { }
|
||||
@Override public String getInventoryName() { return ""; }
|
||||
@Override public boolean hasCustomInventoryName() { return false; }
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return false;
|
||||
if(block == null) return false;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.isItemValidForSlot(slot, stack);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return new int[0];
|
||||
if(block == null) return new int[0];
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.getAccessibleSlotsFromSide(side);
|
||||
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side) {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return false;
|
||||
if(block == null) return false;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.canInsertItem(slot, stack, side);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side) {
|
||||
|
||||
if(this.getBlockMetadata() != 1) return false;
|
||||
if(block == null) return false;
|
||||
TileEntityPWRController controller = this.getCore();
|
||||
if(controller != null) return controller.canExtractItem(slot, stack, side);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
src/main/java/com/hbm/blocks/machine/BlockPillarPWR.java
Normal file
21
src/main/java/com/hbm/blocks/machine/BlockPillarPWR.java
Normal file
@ -0,0 +1,21 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BlockPillarPWR extends BlockPillar implements ITooltipProvider {
|
||||
|
||||
public BlockPillarPWR(Material mat, String top) {
|
||||
super(mat, top);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||
this.addStandardInfo(stack, player, list, ext);
|
||||
}
|
||||
}
|
||||
@ -77,7 +77,7 @@ public class DeuteriumTower extends BlockDummyable implements ILookOverlay {
|
||||
text.add((tower.power < tower.getMaxPower() / 20 ? EnumChatFormatting.RED : EnumChatFormatting.GREEN) + "Power: " + BobMathUtil.getShortNumber(tower.power) + "HE");
|
||||
|
||||
for(int i = 0; i < tower.tanks.length; i++)
|
||||
text.add((i < 1 ? (EnumChatFormatting.GREEN + "-> ") : (EnumChatFormatting.RED + "<- ")) + EnumChatFormatting.RESET + I18nUtil.resolveKey("hbmfluid." + tower.tanks[i].getTankType().getName().toLowerCase()) + ": " + tower.tanks[i].getFill() + "/" + tower.tanks[i].getMaxFill() + "mB");
|
||||
text.add((i < 1 ? (EnumChatFormatting.GREEN + "-> ") : (EnumChatFormatting.RED + "<- ")) + EnumChatFormatting.RESET + tower.tanks[i].getTankType().getLocalizedName() + ": " + tower.tanks[i].getFill() + "/" + tower.tanks[i].getMaxFill() + "mB");
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.machine.TileEntityFWatzCore;
|
||||
|
||||
import api.hbm.energy.IEnergyConnectorBlock;
|
||||
import api.hbm.fluid.IFluidConnectorBlock;
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -26,7 +27,7 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class FWatzHatch extends Block implements IFluidConnectorBlock {
|
||||
public class FWatzHatch extends Block implements IEnergyConnectorBlock, IFluidConnectorBlock {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconFront;
|
||||
@ -158,4 +159,9 @@ public class FWatzHatch extends Block implements IFluidConnectorBlock {
|
||||
public boolean canConnect(FluidType type, IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
|
||||
return type == Fluids.AMAT || type == Fluids.ASCHRAB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ public class FoundryChannel extends BlockContainer implements ICrucibleAcceptor
|
||||
if(b == ModBlocks.foundry_outlet && meta == dir.ordinal())
|
||||
return true;
|
||||
|
||||
return b == ModBlocks.foundry_channel || b == ModBlocks.foundry_mold;
|
||||
return b == ModBlocks.foundry_channel || b == ModBlocks.foundry_mold || b == ModBlocks.foundry_slagtap;
|
||||
}
|
||||
|
||||
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@ -167,12 +167,12 @@ public class FoundryOutlet extends BlockContainer implements ICrucibleAcceptor,
|
||||
|
||||
@Override
|
||||
public boolean canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) {
|
||||
return ((TileEntityFoundryOutlet) world.getTileEntity(x, y, z)).canAcceptPartialFlow(world, x, y, z, side, stack);
|
||||
return ((ICrucibleAcceptor) world.getTileEntity(x, y, z)).canAcceptPartialFlow(world, x, y, z, side, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) {
|
||||
return ((TileEntityFoundryOutlet) world.getTileEntity(x, y, z)).flow(world, x, y, z, side, stack);
|
||||
return ((ICrucibleAcceptor) world.getTileEntity(x, y, z)).flow(world, x, y, z, side, stack);
|
||||
}
|
||||
|
||||
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
35
src/main/java/com/hbm/blocks/machine/FoundrySlagtap.java
Normal file
35
src/main/java/com/hbm/blocks/machine/FoundrySlagtap.java
Normal file
@ -0,0 +1,35 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.TileEntityFoundrySlagtap;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
|
||||
public class FoundrySlagtap extends FoundryOutlet {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
super.registerBlockIcons(iconRegister);
|
||||
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":foundry_slagtap_top");
|
||||
this.iconSide = iconRegister.registerIcon(RefStrings.MODID + ":foundry_slagtap_side");
|
||||
this.iconBottom = iconRegister.registerIcon(RefStrings.MODID + ":foundry_slagtap_bottom");
|
||||
this.iconInner = iconRegister.registerIcon(RefStrings.MODID + ":foundry_slagtap_inner");
|
||||
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + ":foundry_slagtap_front");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityFoundrySlagtap();
|
||||
}
|
||||
|
||||
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { return false; }
|
||||
@Override public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { return false; }
|
||||
@Override public void printHook(Pre event, World world, int x, int y, int z) { }
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.tileentity.conductor.TileEntityGasDuctSolid;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GasDuctSolid extends BlockContainer {
|
||||
|
||||
public GasDuctSolid(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TileEntityGasDuctSolid();
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
@ -75,7 +76,7 @@ public class HeaterElectric extends BlockDummyable implements ILookOverlay, IToo
|
||||
TileEntityHeaterElectric heater = (TileEntityHeaterElectric) te;
|
||||
|
||||
List<String> text = new ArrayList();
|
||||
text.add(String.format("%,d", heater.heatEnergy) + " TU");
|
||||
text.add(String.format(Locale.US, "%,d", heater.heatEnergy) + " TU");
|
||||
text.add(EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + heater.getConsumption() + " HE/t");
|
||||
text.add(EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + heater.getHeatGen() + " TU/t");
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ public class HeaterFirebox extends BlockDummyable implements ITooltipProvider {
|
||||
/*if(lastCore.getX() == lastBlockSet.getX() && lastCore.getY() + 1 == lastBlockSet.getY() && lastCore.getZ() == lastBlockSet.getZ())
|
||||
return new TileEntityProxyCombo().inventory().heatSource();*/
|
||||
|
||||
return new TileEntityProxyCombo(true, false, false);
|
||||
return new TileEntityProxyCombo().inventory().fluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -2,6 +2,7 @@ package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
@ -63,7 +64,7 @@ public class HeaterHeatex extends BlockDummyable implements ILookOverlay, IToolt
|
||||
TileEntityHeaterHeatex heater = (TileEntityHeaterHeatex) te;
|
||||
|
||||
List<String> text = new ArrayList();
|
||||
text.add(String.format("%,d", heater.heatEnergy) + " TU");
|
||||
text.add(String.format(Locale.US, "%,d", heater.heatEnergy) + " TU");
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
@ -97,7 +98,7 @@ public class HeaterOilburner extends BlockDummyable implements ILookOverlay, ITo
|
||||
FluidType type = heater.tank.getTankType();
|
||||
if(type.hasTrait(FT_Flammable.class)) {
|
||||
int heat = (int)(type.getTrait(FT_Flammable.class).getHeatEnergy() * heater.setting / 1000);
|
||||
text.add(EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + String.format("%,d", heat) + " TU/t");
|
||||
text.add(EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + String.format(Locale.US, "%,d", heat) + " TU/t");
|
||||
}
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
|
||||
@ -23,7 +23,7 @@ public class HeaterOven extends BlockDummyable implements ITooltipProvider {
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
|
||||
if(meta >= 12) return new TileEntityHeaterOven();
|
||||
return new TileEntityProxyCombo(true, false, false);
|
||||
return new TileEntityProxyCombo().inventory().fluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
38
src/main/java/com/hbm/blocks/machine/MachineArcWelder.java
Normal file
38
src/main/java/com/hbm/blocks/machine/MachineArcWelder.java
Normal file
@ -0,0 +1,38 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineArcWelder;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MachineArcWelder extends BlockDummyable {
|
||||
|
||||
public MachineArcWelder(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
if(meta >= 12) return new TileEntityMachineArcWelder();
|
||||
return new TileEntityProxyCombo().inventory().power().fluid();
|
||||
}
|
||||
|
||||
@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[] {1, 0, 1, 0, 1, 1};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
47
src/main/java/com/hbm/blocks/machine/MachineAshpit.java
Normal file
47
src/main/java/com/hbm/blocks/machine/MachineAshpit.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.TileEntityAshpit;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MachineAshpit extends BlockDummyable implements ITooltipProvider {
|
||||
|
||||
public MachineAshpit() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
if(meta >= 12) return new TileEntityAshpit();
|
||||
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, 1, 1, 1, 1};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||
this.addStandardInfo(stack, player, list, ext);
|
||||
}
|
||||
}
|
||||
@ -1,296 +1,55 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.handler.MultiblockHandler;
|
||||
import com.hbm.interfaces.IMultiblock;
|
||||
import com.hbm.tileentity.machine.TileEntityDummy;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineAssembler;
|
||||
|
||||
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.item.EntityItem;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class MachineAssembler extends BlockContainer implements IMultiblock {
|
||||
public class MachineAssembler extends BlockDummyable {
|
||||
|
||||
public MachineAssembler(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TileEntityMachineAssembler();
|
||||
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
if(meta >= 12) return new TileEntityMachineAssembler();
|
||||
if(meta >= 6) return new TileEntityProxyCombo().power();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
|
||||
return Item.getItemFromBlock(ModBlocks.machine_assembler);
|
||||
public int[] getDimensions() {
|
||||
return new int[] {1, 0, 2, 1, 2, 1};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
|
||||
if (i == 0) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.assemblerDimensionEast)) {
|
||||
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.assemblerDimensionEast, ModBlocks.dummy_block_assembler);
|
||||
|
||||
//
|
||||
DummyBlockAssembler.safeBreak = true;
|
||||
world.setBlock(x - 1, y, z, ModBlocks.dummy_port_assembler);
|
||||
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 - 1, y, z + 1, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te2 = world.getTileEntity(x - 1, y, z + 1);
|
||||
if(te2 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te2;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x + 2, y, z, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te3 = world.getTileEntity(x + 2, y, z);
|
||||
if(te3 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te3;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x + 2, y, z + 1, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te4 = world.getTileEntity(x + 2, y, z + 1);
|
||||
if(te4 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te4;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
DummyBlockAssembler.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.assemblerDimensionSouth)) {
|
||||
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.assemblerDimensionSouth, ModBlocks.dummy_block_assembler);
|
||||
|
||||
//
|
||||
DummyBlockAssembler.safeBreak = true;
|
||||
world.setBlock(x, y, z - 1, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te = world.getTileEntity(x, y, z - 1);
|
||||
if(te instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x - 1, y, z - 1, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te2 = world.getTileEntity(x - 1, y, z - 1);
|
||||
if(te2 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te2;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x, y, z + 2, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te3 = world.getTileEntity(x, y, z + 2);
|
||||
if(te3 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te3;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x - 1, y, z + 2, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te4 = world.getTileEntity(x - 1, y, z + 2);
|
||||
if(te4 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te4;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
DummyBlockAssembler.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.assemblerDimensionWest)) {
|
||||
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.assemblerDimensionWest, ModBlocks.dummy_block_assembler);
|
||||
|
||||
//
|
||||
DummyBlockAssembler.safeBreak = true;
|
||||
world.setBlock(x + 1, y, z, ModBlocks.dummy_port_assembler);
|
||||
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 + 1, y, z - 1, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te2 = world.getTileEntity(x + 1, y, z - 1);
|
||||
if(te2 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te2;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x - 2, y, z, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te3 = world.getTileEntity(x - 2, y, z);
|
||||
if(te3 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te3;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x - 2, y, z - 1, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te4 = world.getTileEntity(x - 2, y, z - 1);
|
||||
if(te4 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te4;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
DummyBlockAssembler.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.assemblerDimensionNorth)) {
|
||||
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.assemblerDimensionNorth, ModBlocks.dummy_block_assembler);
|
||||
|
||||
//
|
||||
DummyBlockAssembler.safeBreak = true;
|
||||
world.setBlock(x, y, z + 1, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te = world.getTileEntity(x, y, z + 1);
|
||||
if(te instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x + 1, y, z + 1, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te2 = world.getTileEntity(x + 1, y, z + 1);
|
||||
if(te2 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te2;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x, y, z - 2, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te3 = world.getTileEntity(x, y, z - 2);
|
||||
if(te3 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te3;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x + 1, y, z - 2, ModBlocks.dummy_port_assembler);
|
||||
TileEntity te4 = world.getTileEntity(x + 1, y, z - 2);
|
||||
if(te4 instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te4;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
DummyBlockAssembler.safeBreak = false;
|
||||
//
|
||||
|
||||
} else
|
||||
world.func_147480_a(x, y, z, true);
|
||||
}
|
||||
public int getOffset() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
private final Random field_149933_a = new Random();
|
||||
private static boolean keepInventory;
|
||||
|
||||
@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_);
|
||||
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);
|
||||
}
|
||||
|
||||
if (tileentityfurnace != null)
|
||||
{
|
||||
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
|
||||
{
|
||||
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
|
||||
@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;
|
||||
z -= dir.offsetZ;
|
||||
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
|
||||
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_);
|
||||
}
|
||||
this.makeExtra(world, x + rot.offsetX * 2, y, z + rot.offsetZ * 2);
|
||||
this.makeExtra(world, x - rot.offsetX * 1, y, z - rot.offsetZ * 1);
|
||||
this.makeExtra(world, x + rot.offsetX * 2 - dir.offsetX, y, z + rot.offsetZ * 2 - dir.offsetZ);
|
||||
this.makeExtra(world, x - rot.offsetX * 1 - dir.offsetX, y, z - rot.offsetZ * 1 - dir.offsetZ);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,16 +4,25 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineAutosaw;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
|
||||
public class MachineAutosaw extends BlockContainer implements ILookOverlay {
|
||||
public class MachineAutosaw extends BlockContainer implements ILookOverlay, ITooltipProvider {
|
||||
|
||||
public MachineAutosaw() {
|
||||
super(Material.iron);
|
||||
@ -38,6 +47,30 @@ public class MachineAutosaw extends BlockContainer implements ILookOverlay {
|
||||
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 && !player.isSneaking()) {
|
||||
|
||||
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IItemFluidIdentifier) {
|
||||
|
||||
TileEntityMachineAutosaw saw = (TileEntityMachineAutosaw) world.getTileEntity(x, y, z);
|
||||
|
||||
FluidType type = ((IItemFluidIdentifier) player.getHeldItem().getItem()).getType(world, x, y, z, player.getHeldItem());
|
||||
if(saw.acceptedFuels.contains(type)) {
|
||||
saw.tank.setTankType(type);
|
||||
saw.markDirty();
|
||||
player.addChatComponentMessage(new ChatComponentText("Changed type to ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)).appendSibling(new ChatComponentTranslation(type.getConditionalName())).appendSibling(new ChatComponentText("!")));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
@ -50,8 +83,13 @@ public class MachineAutosaw extends BlockContainer implements ILookOverlay {
|
||||
TileEntityMachineAutosaw saw = (TileEntityMachineAutosaw) te;
|
||||
|
||||
List<String> text = new ArrayList();
|
||||
text.add(I18nUtil.resolveKey("hbmfluid." + saw.tank.getTankType().getName().toLowerCase()) + ": " + saw.tank.getFill() + "/" + saw.tank.getMaxFill() + "mB");
|
||||
text.add(saw.tank.getTankType().getLocalizedName() + ": " + saw.tank.getFill() + "/" + saw.tank.getMaxFill() + "mB");
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||
this.addStandardInfo(stack, player, list, ext);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,13 +6,14 @@ import java.util.List;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.IPersistentInfoProvider;
|
||||
import com.hbm.handler.MultiblockHandlerXR;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.items.machine.IItemFluidIdentifier;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.storage.TileEntityMachineBAT9000;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import net.minecraft.block.material.Material;
|
||||
@ -20,6 +21,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@ -88,7 +92,26 @@ public class MachineBigAssTank9000 extends BlockDummyable implements IPersistent
|
||||
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, pos[0], pos[1], pos[2]); //we can do this because nobody is stopping me from doing this
|
||||
return true;
|
||||
} else {
|
||||
} else if(player.isSneaking()){
|
||||
int[] pos = this.findCore(world, x, y, z);
|
||||
|
||||
if(pos == null)
|
||||
return false;
|
||||
|
||||
TileEntityMachineBAT9000 trialEntity = (TileEntityMachineBAT9000) world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
|
||||
if(trialEntity != null) {
|
||||
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IItemFluidIdentifier) {
|
||||
FluidType type = ((IItemFluidIdentifier) player.getHeldItem().getItem()).getType(world, pos[0], pos[1], pos[2], player.getHeldItem());
|
||||
|
||||
trialEntity.tank.setTankType(type);
|
||||
trialEntity.markDirty();
|
||||
player.addChatComponentMessage(new ChatComponentText("Changed type to ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)).appendSibling(new ChatComponentTranslation(type.getConditionalName())).appendSibling(new ChatComponentText("!")));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -98,10 +121,27 @@ public class MachineBigAssTank9000 extends BlockDummyable implements IPersistent
|
||||
return IPersistentNBT.getDrops(world, x, y, z, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(!(te instanceof TileEntityMachineBAT9000))
|
||||
return 0;
|
||||
|
||||
TileEntityMachineBAT9000 tank = (TileEntityMachineBAT9000) te;
|
||||
return tank.getComparatorPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||
FluidTank tank = new FluidTank(Fluids.NONE, 0, 0);
|
||||
FluidTank tank = new FluidTank(Fluids.NONE, 0);
|
||||
tank.readFromNBT(persistentTag, "tank");
|
||||
list.add(EnumChatFormatting.YELLOW + "" + tank.getFill() + "/" + tank.getMaxFill() + "mB " + I18nUtil.resolveKey(tank.getTankType().getUnlocalizedName()));
|
||||
list.add(EnumChatFormatting.YELLOW + "" + tank.getFill() + "/" + tank.getMaxFill() + "mB " + tank.getTankType().getLocalizedName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,30 +147,10 @@ public class MachineBoiler extends BlockContainer {
|
||||
|
||||
@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)
|
||||
{
|
||||
if(world.isRemote) {
|
||||
return true;
|
||||
} else if(!player.isSneaking())
|
||||
{
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(te instanceof TileEntityMachineBoiler) {
|
||||
|
||||
TileEntityMachineBoiler entity = (TileEntityMachineBoiler) te;
|
||||
if(entity != null)
|
||||
{
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
if(te instanceof TileEntityMachineBoilerElectric) {
|
||||
|
||||
TileEntityMachineBoilerElectric entity = (TileEntityMachineBoilerElectric) te;
|
||||
if(entity != null)
|
||||
{
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
}
|
||||
}
|
||||
} else if(!player.isSneaking()) {
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
272
src/main/java/com/hbm/blocks/machine/MachineCapacitor.java
Normal file
272
src/main/java/com/hbm/blocks/machine/MachineCapacitor.java
Normal file
@ -0,0 +1,272 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.blocks.IPersistentInfoProvider;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import api.hbm.energy.IEnergyUser;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class MachineCapacitor extends BlockContainer implements ILookOverlay, IPersistentInfoProvider, ITooltipProvider {
|
||||
|
||||
@SideOnly(Side.CLIENT) public IIcon iconTop;
|
||||
@SideOnly(Side.CLIENT) public IIcon iconSide;
|
||||
@SideOnly(Side.CLIENT) public IIcon iconBottom;
|
||||
@SideOnly(Side.CLIENT) public IIcon iconInnerTop;
|
||||
@SideOnly(Side.CLIENT) public IIcon iconInnerSide;
|
||||
|
||||
protected long power;
|
||||
String name;
|
||||
|
||||
public MachineCapacitor(Material mat, long power, String name) {
|
||||
super(mat);
|
||||
this.power = power;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
super.registerBlockIcons(iconRegister);
|
||||
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":capacitor_" + name + "_top");
|
||||
this.iconSide = iconRegister.registerIcon(RefStrings.MODID + ":capacitor_" + name + "_side");
|
||||
this.iconBottom = iconRegister.registerIcon(RefStrings.MODID + ":capacitor_" + name + "_bottom");
|
||||
this.iconInnerTop = iconRegister.registerIcon(RefStrings.MODID + ":capacitor_" + name + "_inner_top");
|
||||
this.iconInnerSide = iconRegister.registerIcon(RefStrings.MODID + ":capacitor_" + name + "_inner_side");
|
||||
}
|
||||
|
||||
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
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float fX, float fY, float fZ, int meta) {
|
||||
return side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityCapacitor(this.power);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if(!(te instanceof TileEntityCapacitor))
|
||||
return;
|
||||
|
||||
TileEntityCapacitor battery = (TileEntityCapacitor) te;
|
||||
List<String> text = new ArrayList();
|
||||
text.add(BobMathUtil.getShortNumber(battery.getPower()) + " / " + BobMathUtil.getShortNumber(battery.getMaxPower()) + "HE");
|
||||
|
||||
double percent = (double) battery.getPower() / (double) battery.getMaxPower();
|
||||
int charge = (int) Math.floor(percent * 10_000D);
|
||||
int color = ((int) (0xFF - 0xFF * percent)) << 16 | ((int)(0xFF * percent) << 8);
|
||||
text.add("&[" + color + "&]" + (charge / 100D) + "%");
|
||||
text.add(EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + "+" + BobMathUtil.getShortNumber(battery.powerReceived) + "HE/t");
|
||||
text.add(EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + "-" + BobMathUtil.getShortNumber(battery.powerSent) + "HE/t");
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {
|
||||
list.add(EnumChatFormatting.YELLOW + "" + BobMathUtil.getShortNumber(persistentTag.getLong("power")) + "/" + BobMathUtil.getShortNumber(persistentTag.getLong("maxPower")) + "HE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
|
||||
for(String s : I18nUtil.resolveKeyArray("tile.capacitor.desc")) list.add(EnumChatFormatting.YELLOW + s);
|
||||
} else {
|
||||
list.add(EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.ITALIC +"Hold <" +
|
||||
EnumChatFormatting.YELLOW + "" + EnumChatFormatting.ITALIC + "LSHIFT" +
|
||||
EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.ITALIC + "> to display more info");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
return IPersistentNBT.getDrops(world, x, y, z, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||
IPersistentNBT.restoreData(world, x, y, z, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
|
||||
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
harvesters.set(player);
|
||||
this.dropBlockAsItem(world, x, y, z, meta, 0);
|
||||
harvesters.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
|
||||
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
|
||||
player.addExhaustion(0.025F);
|
||||
}
|
||||
|
||||
public static class TileEntityCapacitor extends TileEntityLoadedBase implements IEnergyUser, INBTPacketReceiver, IPersistentNBT {
|
||||
|
||||
public long power;
|
||||
protected long maxPower;
|
||||
public long prevPower;
|
||||
public long powerReceived;
|
||||
public long powerSent;
|
||||
|
||||
public TileEntityCapacitor() { }
|
||||
|
||||
public TileEntityCapacitor(long maxPower) {
|
||||
this.maxPower = maxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
long gain = power - prevPower;
|
||||
|
||||
ForgeDirection opp = ForgeDirection.getOrientation(this.getBlockMetadata());
|
||||
ForgeDirection dir = opp.getOpposite();
|
||||
|
||||
BlockPos pos = new BlockPos(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
|
||||
boolean didStep = false;
|
||||
ForgeDirection last = null;
|
||||
|
||||
while(worldObj.getBlock(pos.getX(), pos.getY(), pos.getZ()) == ModBlocks.capacitor_bus) {
|
||||
ForgeDirection current = ForgeDirection.getOrientation(worldObj.getBlockMetadata(pos.getX(), pos.getY(), pos.getZ()));
|
||||
if(!didStep) last = current;
|
||||
didStep = true;
|
||||
|
||||
if(last != current) {
|
||||
pos = null;
|
||||
break;
|
||||
}
|
||||
|
||||
pos = pos.offset(current);
|
||||
}
|
||||
|
||||
long preSend = power;
|
||||
if(pos != null && last != null) {
|
||||
this.tryUnsubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ());
|
||||
this.sendPower(worldObj, pos.getX(), pos.getY(), pos.getZ(), last);
|
||||
}
|
||||
long sent = preSend - power;
|
||||
|
||||
this.trySubscribe(worldObj, xCoord + opp.offsetX, yCoord+ opp.offsetY, zCoord + opp.offsetZ, opp);
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setLong("power", power);
|
||||
data.setLong("maxPower", maxPower);
|
||||
data.setLong("rec", gain);
|
||||
data.setLong("sent", sent);
|
||||
INBTPacketReceiver.networkPack(this, data, 15);
|
||||
|
||||
this.prevPower = power;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
this.power = nbt.getLong("power");
|
||||
this.maxPower = nbt.getLong("maxPower");
|
||||
this.powerReceived = nbt.getLong("rec");
|
||||
this.powerSent = nbt.getLong("sent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
return maxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionPriority getPriority() {
|
||||
return ConnectionPriority.LOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long power) {
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection dir) {
|
||||
return dir == ForgeDirection.getOrientation(this.getBlockMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setLong("power", power);
|
||||
data.setLong("maxPower", maxPower);
|
||||
nbt.setTag(NBT_PERSISTENT_KEY, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound data = nbt.getCompoundTag(NBT_PERSISTENT_KEY);
|
||||
this.power = data.getLong("power");
|
||||
this.maxPower = data.getLong("maxPower");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.power = nbt.getLong("power");
|
||||
this.maxPower = nbt.getLong("maxPower");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setLong("power", power);
|
||||
nbt.setLong("maxPower", maxPower);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.lib.RefStrings;
|
||||
|
||||
import api.hbm.energy.IEnergyConnectorBlock;
|
||||
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.entity.player.EntityPlayer;
|
||||
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 MachineCapacitorBus extends Block implements IEnergyConnectorBlock, ITooltipProvider {
|
||||
|
||||
@SideOnly(Side.CLIENT) private IIcon topIcon;
|
||||
|
||||
public MachineCapacitorBus(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister p_149651_1_) {
|
||||
this.blockIcon = p_149651_1_.registerIcon(RefStrings.MODID + ":capacitor_bus_side");
|
||||
this.topIcon = p_149651_1_.registerIcon(RefStrings.MODID + ":capacitor_bus_out");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return side == meta ? topIcon : blockIcon;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
ForgeDirection busDir = ForgeDirection.getOrientation(meta);
|
||||
return dir == busDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||
this.addStandardInfo(stack, player, list, ext);
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@ public class MachineCatalyticCracker extends BlockDummyable implements ILookOver
|
||||
FluidType type = ((IItemFluidIdentifier) player.getHeldItem().getItem()).getType(world, pos[0], pos[1], pos[2], player.getHeldItem());
|
||||
cracker.tanks[0].setTankType(type);
|
||||
cracker.markDirty();
|
||||
player.addChatComponentMessage(new ChatComponentText("Changed type to ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)).appendSibling(new ChatComponentTranslation("hbmfluid." + type.getName().toLowerCase())).appendSibling(new ChatComponentText("!")));
|
||||
player.addChatComponentMessage(new ChatComponentText("Changed type to ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)).appendSibling(new ChatComponentTranslation(type.getConditionalName())).appendSibling(new ChatComponentText("!")));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -129,7 +129,7 @@ public class MachineCatalyticCracker extends BlockDummyable implements ILookOver
|
||||
List<String> text = new ArrayList();
|
||||
|
||||
for(int i = 0; i < cracker.tanks.length; i++)
|
||||
text.add((i < 2 ? (EnumChatFormatting.GREEN + "-> ") : (EnumChatFormatting.RED + "<- ")) + EnumChatFormatting.RESET + I18nUtil.resolveKey("hbmfluid." + cracker.tanks[i].getTankType().getName().toLowerCase()) + ": " + cracker.tanks[i].getFill() + "/" + cracker.tanks[i].getMaxFill() + "mB");
|
||||
text.add((i < 2 ? (EnumChatFormatting.GREEN + "-> ") : (EnumChatFormatting.RED + "<- ")) + EnumChatFormatting.RESET + cracker.tanks[i].getTankType().getLocalizedName() + ": " + cracker.tanks[i].getFill() + "/" + cracker.tanks[i].getMaxFill() + "mB");
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user