Compare commits

..

No commits in common. "master" and "1.0.27_X5356" have entirely different histories.

1410 changed files with 49563 additions and 157098 deletions

View File

@ -7,46 +7,27 @@
# Yes this is a mostly untouched Github actions template
name: Java CI with Gradle
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin' # Temurin because it's default :P
# Calculate days since 10/10/10
- name: Calculate days since 10/10/10
id: calculate_days
run: |
start_date="2010-10-10"
current_date=$(date +%Y-%m-%d)
days_since=$(( ($(date -d "$current_date" +%s) - $(date -d "$start_date" +%s)) / 86400 ))
echo "days=$days_since" >> $GITHUB_OUTPUT
# Update version files with proper sed syntax
- name: Update version files
run: |
days=${{ steps.calculate_days.outputs.days }}
# Use proper sed syntax for Linux runners
sed -i "s/public static final String VERSION = \".*\";/public static final String VERSION = \"1.0.27 BETA ($days)\";/" src/main/java/com/hbm/lib/RefStrings.java
sed -i "s/mod_build_number=.*/mod_build_number=$days/" gradle.properties
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
- name: Setup Gradle
@ -60,3 +41,5 @@ jobs:
with:
# A file, directory or wildcard pattern that describes what to upload
path: ./build/libs

View File

@ -2,7 +2,7 @@
[NTM on Modrinth](https://modrinth.com/mod/ntm)
[NTM on CurseForge](https://www.curseforge.com/minecraft/mc-mods/hbms-nuclear-tech-mod)
[NTM on CurseForge](https://minecraft.curseforge.com/projects/hbms-nuclear-tech-mod?gameCategorySlug=mc-mods&projectID=235439)
[Official NTM Wiki](https://nucleartech.wiki/wiki/Main_Page)
@ -10,9 +10,9 @@
**This is for 1.7.10!** For 1.12, check out these projects:
* NTM Community Edition (WarFactory): https://github.com/MisterNorwood/Hbm-s-Nuclear-Tech-CE
* NTM Extended Edition (Alcater): https://github.com/Alcatergit/Hbm-s-Nuclear-Tech-GIT/releases
* NTM Reloaded: https://github.com/TheOriginalGolem/Hbm-s-Nuclear-Tech-GIT/releases
* NTM Extended Edition (Alcater): https://github.com/Alcatergit/Hbm-s-Nuclear-Tech-GIT/releases
* NTM Community Edition (WarFactory): https://codeberg.org/MrNorwood/Hbm-s-Nuclear-Tech-CE
For 1.18, try Martin's remake: https://codeberg.org/MartinTheDragon/Nuclear-Tech-Mod-Remake/releases
@ -25,7 +25,7 @@ Simply navigate to "Releases" on the right side of the page, download links for
Tired of waiting until the next version comes out? Here is a tutorial on how to compile the very newest version yourself:
Please note that these installation instructions are assuming you're running Microsoft Windows operating system. Linux users should know what to do by looking at the same guide.
1. Make sure you have JDK8 installed. If not, download it from [adoptium.net](https://adoptium.net/temurin/releases?version=8)
1. Make sure you have JDK8 installed. If not, download it from [adoptium.net](https://adoptium.net/?variant=openjdk8&jvmVariant=hotspot)
2. If you don't have git installed, download&install it from [here](https://git-scm.com/downloads).
3. Open up "Git Bash":
* Press Windows Button, type "Git Bash" and press ENTER

View File

@ -6,7 +6,6 @@ import java.nio.file.StandardCopyOption
buildscript {
repositories {
maven { url = 'https://maven.ntmr.dev/proxy/' }
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://plugins.gradle.org/m2' }
mavenCentral()
@ -68,10 +67,6 @@ eclipse.classpath.file.whenMerged { cp ->
}
repositories {
maven {
name = 'Blerg'
url = 'https://maven.ntmr.dev/proxy/'
}
maven {
name = 'ModMaven'
url = 'https://modmaven.dev'
@ -84,18 +79,6 @@ repositories {
// name = "CurseForge"
// url = "https://minecraft.curseforge.com/api/maven/"
//}
maven {
name = "Jitpack"
url = "https://jitpack.io"
}
maven {
name = "CurseMaven"
url = "https://cursemaven.com"
}
maven {
name = "OpenComputers"
url = "https://maven.cil.li/"
}
}
dependencies {
@ -111,8 +94,6 @@ dependencies {
compileOnly "inventorytweaks:InventoryTweaks:1.59-dev:deobf"
implementation "li.cil.oc:OpenComputers:MC1.7.10-1.5.+:api"
compileOnly "com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta.56-GTNH:dev"
}
processResources {

106
changelog
View File

@ -1,27 +1,81 @@
## Changed
* Updated russian localization
* Rad absorbers now use metadata, existing blocks will be converted automatically
* Fissure bombs that go off in crater biomes now create fissures with metadata 1 which creates radioactive volcanic lava
* If a crater biome is created on top of an existing fissure, it will keep producing normal volcanic lava
* Simplified the battery socket's client packets, reducing CPU load
* Muzzle flashes on guns now work in third person mode, including on other players and on NPCs, making it more apparent when you're being fired at
* This includes non-standard special effects like the .44 gap flash and the .35-800 ejector plume
* Removed the old unused satelite deco blocks, freeing up 6 block IDs
* Crucibles that smelt metal with no template set will no place the metal in the recipe stack instead of the waste stack, this should make it easier to get a recipe to work in the many, many cases where people add the template after smelting the material
* Battery sockets and the FENSU now support the copy tool
* Removed unused displaylist support from the model loader
* DLs have been long phased out in favor of VBOs anyway
* Rebranded canned horse slime
* Now with extra bone marrow
* Updated the deuterium tower's model
* Increased the energy requirement for welding osmiridium
## Added
* Two new anti-material rifle variants
* .50 BMG demolisher rounds are finally usable
* Added a special ammo type exclusive to one of the variants
* Starmetal .50 BMG now returns
* Overall better armor piercing stats than DU
* Not compatible with the M2, only usable in amat rifles
* Reworked chemical plant
* No longer needs template items for everything, comes with a convenient recipe selector GUI
* Three item and three fluids for in and outputs
* Slots are locked to the ingredients they accept, allowing for better performance and shift click support
* Item IO now works like most other machines instead of using chutes
* If the center block right above the chemplant is not air, it will render with a frame, making chemplant stacking actually nice to look at
* Now has a more convenient 3x3 footprint
* Features 12 access ports, more than enough for full coverage of the entire machine's IO
* Has an optional slot for template items separate from the recipe selector (i.e. secret recipes) (doesn't work yet since we don't have secret recipe :P)
* Ports are now standardized, no longer are fluids connected to ports that look like copper contacts
* Can't use upgrades just yet
# Fixed
* Potentially fixed yet another issue regarding crates
* Fixed battery socket `fillpercent` RoR function always assuming a max power of 1
* Fixed issue where multiblock ports would generate many OpenComputers component entries
* Fixed RBMK automatic control rods having incorrect settings when using the copy tool
* Fixed battery sockets producing junk debug data in the logs
* Fixed an issue where the charging station would crash when trying to charge certain items
* Fixed the DFC's core component not dropping its contents when mined
* Fixed audio problems with guns
## Changed
* Added Ukrainian localization
* The RBMK console's grid can now be rotated using a screwdriver
* Tool abilities have changed
* Right-clicking while holding ALT now opens a configuration window
* The configuration window allows creation of tool presets
* Area and block abilities can now be toggled independently from each other. For example, the vein miner ability can be combined with silk touch
* Clicking on the same ability allows switching between levels
* Updated textures for the armor and gun modification tables
* Ported the fire extinguisher to the SEDNA gun system, eliminating the final remaining ItemGunBase gun
* Water extinguishers can now wash away foam blocks
* Obliterated Fabsol's vodka
* Tier 4 heart piece is now called "heart of darkness"
* Thermal sights now render dead mobs in black
* Guns now have unique scope overlays instead of reusing the .44 scope for everything
* The new chemplant has slightly altered recipes
* Very basic mixing recipes (e.g. coolant) have been removed, it's now required to use the mixer
* Water to hydrogen peroxide is now 1,000 : 1,000 (instead of 1,000 : 800)
* Sulfuric acid's peroxide requirement has been adjusted accordingly
* Nitric acid has an alternate recipe using air and water, however it takes 4x as long and has a base consumption of 2kHE/t
* Desh now only takes 5 seconds to produce instead of 15
* Laminate now only takes 50mB of either fluid per recipe and processes much quicker
* Ducrete now uses U238 in the form of ferrouranium, decreasing U238 needed, and no longer requires gravel at all
* All recipes for nuclear fuel production now have a higher base consumption
* Base consumption in general has been tweaked for many later-game recipes. Many recipes however still use the old 100HE/t rate
* Cordite now uses sawdust instead of wood planks and sugar
* Kevlar is now made from aromatics, nitric acid and chlorine (or phosgene in 528 mode)
* Electrolysis using the chemplant has been removed. Hydrogen can be made using water and coal (or coke), and oxygen can be distilled from intake air
* Solid nuclear waste can also be vitrified now
* Thorium salt reprocessing now only has a 50% chance to produce a U233 nugget and a 25% chance to produce nuclear waste, making it less absurdly powerful and easier to deal with the waste
* Glyphid meat processing is now less autistic
* Making rusty steel now only takes 2 seconds per recipe
* Perfluoromethyl can now also be made in the chemical plant (technically, the process isn't just simple mixing after all)
* Recipe changes are still subject to balancing
* Removed niter to nitric acid liquefaction recipe
* Updated N2 model
* Glow in the dark paint not included (yet)
* Wooden scaffolds now have a slightly smaller hitbox and are climbable
* Hanging chains and vines can now be climbed by holding space
* Hopefully fixed the strand caster being weird for good
* Removed angry metal drop from meteorites (use the assembler recipe)
* The automatic buzzsaw can now handle crops
* The automatic buzzsaw will no longer clip through walls when extending
* The automatic buzzsaw can be turned off using a screwdriver
* Template folders now support page turning via scrolling
* Named crates will now show their names in the GUI as well as as a tooltip
* Vanilla anvils no longer increase experience costs when renaming an item
* Fans now have diminishing force, old behavior can be restored with the hand drill
## Fixed
* Conveyor ejectors should now correctly place items onto the back of splitters instead of on the output belts
* Fixed strand caster fluid gauges going out of bounds
* Fixed arc welder and soldering station not changing buffer size based on upgrade, preventing use of higher overdrive tiers
* Fixed non-standard template folder recipes not using the correct icon
* Fixed jetpack flight time not resetting when equipped like armor, causing kicks on servers that don't have flying cheats allowed
* Fixed missing energy damage category localization
* Fixed server crash caused by tool abilities
* Fixed chunkloading entities not releasing their loading tickets properly
* Potentially fixed a dupe issue related to tool abilities
* Fixed certain sky features not being as bright as they should be
* Fixed detailed hitboxes behaving weird
* Fixed issue where empty crates would retain irrelevant NBT data, rendering them unstackable with freshly crafted crates

View File

@ -1,15 +1,15 @@
mod_version=1.0.27
# Empty build number makes a release type
mod_build_number=5572
mod_build_number=5356
credits=HbMinecraft,\
\ rodolphito (explosion algorithms),\
\ grangerave (explosion algorithms),\
\ Hoboy (textures, models),\
\ Drillgon200 (effects, models),\
\ Drillgon200 (effects, models, porting),\
\ MartinTheDragon (calculator, chunk-based fallout, bendable cranes, pipe improvements, PWR sounds),\
\ Alcater (GUI textures),\
\ MellowArpeggiation (new animation system, turbine sounds, sound fixes, industrial lights, conveyor wand, NBT structures, MSU displays),\
\ Alcater (GUI textures, porting),\
\ MellowArpeggiation (new animation system, turbine sounds, sound fixes, industrial lights, conveyor wand, NBT structures),\
\ Pheo (textures, various machines, models, weapons),\
\ Vær (gas centrifuges, better worldgen, ZIRNOX, CP-1 parts, starter guide, new cyclotron, weapon animations),\
\ UFFR (RTG pellets, guns, casings, euphemium capacitor, nucleartech.wiki),\
@ -22,7 +22,6 @@ credits=HbMinecraft,\
\ Doctor17 (russian localization)),\
\ Pashtet (russian localization),\
\ 7H40 (russian localization),\
\ RayzerHan (russian localization),\
\ Bismarck (chinese localization),\
\ Creeper-banner (chinese localization),\
\ 5467864 (chinese localization),\
@ -35,10 +34,8 @@ credits=HbMinecraft,\
\ Herobrine 457985 (chinese localization),\
\ xxwinhere (chinese localization),\
\ Nycticoraxnightheron (chinese localization),\
\ NarekoMichigami810 (chinese localization),\
\ Maksymisio (polish localization)\
\ el3ctro4ndre (italian localization),\
\ Goaty1208 (italian localization),\
\ Pu-238 (Tom impact effects),\
\ Frooz (gun models),\
\ VT-6/24 (models, textures),\
@ -58,22 +55,18 @@ credits=HbMinecraft,\
\ Silly541 (config for safe ME drives),\
\ Voxelstice (OpenComputers integration, turbine spinup),\
\ BallOfEnergy1 (OpenComputers integration, RBMK and packet optimization, crate backpacks),\
\ PewPewCricket (OpenComputers integration),\
\ kelllllen (OpenComputers integration),\
\ sdddddf80 (recipe configs, chinese localization, custom machine holograms),\
\ Abel1502 (abilities GUI, optimization, crate upgrade recipes, strand caster improvements, varous tweaks),\
\ Darek505 (armor rendering compatibility fix),\
\ ranch21 (improved HUD gauges),\
\ SuperCraftAlex (tooltips)\
\ Ice-Arrow (research reactor tweaks),\
\ 245tt (anvil GUI improvements),\
\ KoblizekXD (doors),\
\ FOlkvangrField (custom machine parts),\
\ RosaTryp (centrifuge config),\
\ Toshayo (satellite loot system, project settings, gradle curse task, OpenComputers integration, fluid counter valve),\
\ Toshayo (satellite loot system, project settings, gradle curse task, OpenComputers integration),\
\ Dash (PA particle serialization fix),\
\ archiecarrot123 (armor rendering compatibility fix),\
\ mikkerlo (mining laser & builder's jetpack improvements),\
\ icomet (refactoring),\
\ martemen (project settings),\
\ OvermindDL1 (project settings),\

View File

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

View File

@ -1,6 +1,5 @@
package api.hbm.block;
@Deprecated
public interface IMiningDrill {
/**

View File

@ -11,8 +11,8 @@ public interface IBatteryItem {
public void dischargeBattery(ItemStack stack, long i);
public long getCharge(ItemStack stack);
public long getMaxCharge(ItemStack stack);
public long getChargeRate(ItemStack stack);
public long getDischargeRate(ItemStack stack);
public long getChargeRate();
public long getDischargeRate();
/** Returns a string for the NBT tag name of the long storing power */
public default String getChargeTagName() {

View File

@ -2,6 +2,7 @@ package api.hbm.energymk2;
import com.hbm.handler.threading.PacketThreading;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.util.Compat;
import api.hbm.energymk2.Nodespace.PowerNode;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
@ -24,7 +25,7 @@ public interface IEnergyProviderMK2 extends IEnergyHandlerMK2 {
public default void tryProvide(World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = TileAccessCache.getTileOrCache(world, x, y, z);
TileEntity te = Compat.getTileStandard(world, x, y, z);
boolean red = false;
if(te instanceof IEnergyConductorMK2) {
@ -42,7 +43,7 @@ public interface IEnergyProviderMK2 extends IEnergyHandlerMK2 {
if(te instanceof IEnergyReceiverMK2 && te != this) {
IEnergyReceiverMK2 rec = (IEnergyReceiverMK2) te;
if(rec.canConnect(dir.getOpposite()) && rec.allowDirectProvision()) {
if(rec.canConnect(dir.getOpposite())) {
long provides = Math.min(this.getPower(), this.getProviderSpeed());
long receives = Math.min(rec.getMaxPower() - rec.getPower(), rec.getReceiverSpeed());
long toTransfer = Math.min(provides, receives);

View File

@ -3,6 +3,7 @@ package api.hbm.energymk2;
import com.hbm.handler.threading.PacketThreading;
import com.hbm.interfaces.NotableComments;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.util.Compat;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energymk2.Nodespace.PowerNode;
@ -30,15 +31,12 @@ public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 {
public default long getReceiverSpeed() {
return this.getMaxPower();
}
/** Whether a provider can provide power by touching the block (i.e. via proxies), bypassing the need for a network entirely */
public default boolean allowDirectProvision() { return true; }
public default void trySubscribe(World world, DirPos pos) { trySubscribe(world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); }
public default void trySubscribe(World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = TileAccessCache.getTileOrCache(world, x, y, z);
TileEntity te = Compat.getTileStandard(world, x, y, z);
boolean red = false;
if(te instanceof IEnergyConductorMK2) {

View File

@ -16,7 +16,6 @@ import net.minecraft.world.World;
*
* @author hbm
*/
@NotableComments
public class Nodespace {
public static final PowerNetProvider THE_POWER_PROVIDER = new PowerNetProvider();

View File

@ -78,7 +78,7 @@ public class PowerNetMK2 extends NodeNet<IEnergyReceiverMK2, IEnergyProviderMK2,
for(Pair<IEnergyReceiverMK2, Long> entry : list) {
double weight = (double) entry.getValue() / (double) (priorityDemand);
long toSend = (long) Math.min(Math.max(toTransfer * weight, 0D), entry.getValue());
long toSend = (long) Math.max(toTransfer * weight, 0D);
energyUsed += (toSend - entry.getKey().transferPower(toSend)); //leftovers are subtracted from the intended amount to use up
}

View File

@ -5,6 +5,7 @@ import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.uninos.GenNode;
import com.hbm.uninos.UniNodespace;
import com.hbm.util.Compat;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
@ -27,7 +28,7 @@ public interface IFluidReceiverMK2 extends IFluidUserMK2 {
public default void trySubscribe(FluidType type, World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = TileAccessCache.getTileOrCache(world, x, y, z);
TileEntity te = Compat.getTileStandard(world, x, y, z);
boolean red = false;
if(te instanceof IFluidConnectorMK2) {

View File

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

View File

@ -6,6 +6,7 @@ import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.uninos.GenNode;
import com.hbm.uninos.UniNodespace;
import com.hbm.util.Compat;
import com.hbm.util.fauxpointtwelve.DirPos;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
@ -29,7 +30,7 @@ public interface IFluidStandardSenderMK2 extends IFluidProviderMK2 {
public default void tryProvide(FluidType type, int pressure, World world, int x, int y, int z, ForgeDirection dir) {
TileEntity te = TileAccessCache.getTileOrCache(world, x, y, z);
TileEntity te = Compat.getTileStandard(world, x, y, z);
boolean red = false;
if(te instanceof IFluidConnectorMK2) {

View File

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

View File

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

View File

@ -5,7 +5,7 @@ import com.hbm.handler.ThreeInts;
import com.hbm.interfaces.ICopiable;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IPersistentNBT;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
@ -37,7 +37,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public abstract class BlockDummyable extends BlockContainer implements ICustomBlockHighlight, ICopiable, INBTBlockTransformable {
public abstract class BlockDummyable extends BlockContainer implements ICustomBlockHighlight, ICopiable, INBTTransformable {
public BlockDummyable(Material mat) {
super(mat);
@ -77,20 +77,27 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
super.onNeighborBlockChange(world, x, y, z, block);
if(safeRem)
if(world.isRemote || safeRem)
return;
destroyIfOrphan(world, x, y, z);
int metadata = world.getBlockMetadata(x, y, z);
// if it's an extra, remove the extra-ness
if(metadata >= extra)
metadata -= extra;
ForgeDirection dir = ForgeDirection.getOrientation(metadata).getOpposite();
Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if(b != this) {
world.setBlockToAir(x, y, z);
}
}
public void updateTick(World world, int x, int y, int z, Random rand) {
super.updateTick(world, x, y, z, rand);
destroyIfOrphan(world, x, y, z);
}
private void destroyIfOrphan(World world, int x, int y, int z) {
if(world.isRemote)
return;
@ -103,32 +110,10 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
ForgeDirection dir = ForgeDirection.getOrientation(metadata).getOpposite();
Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
// An extra precaution against multiblocks on chunk borders being erroneously deleted.
// Technically, this might be used to persist ghost dummy blocks by manipulating
// loaded chunks and block destruction, but this gives no benefit to the player,
// cannot be done accidentally, and is definitely preferable to multiblocks
// just vanishing when their chunks are unloaded in an unlucky way.
if(b != this && world.checkChunksExist(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1)) {
if (isLegacyMonoblock(world, x, y, z)) {
fixLegacyMonoblock(world, x, y, z);
} else {
world.setBlockToAir(x, y, z);
}
if(b != this) {
world.setBlockToAir(x, y, z);
}
}
// Override this when turning a single block into a pseudo-multiblock.
// If this returns true, instead of being deleted as an orphan, the block
// will be promoted to a core of a dummyable, however without any dummies.
// This is only called if the block is presumed an orphan, so you don't
// need to check that here.
protected boolean isLegacyMonoblock(World world, int x, int y, int z) {
return false;
}
protected void fixLegacyMonoblock(World world, int x, int y, int z) {
// Promote to a lone core block with the same effective rotation as before the change
world.setBlockMetadataWithNotify(x, y, z, offset + world.getBlockMetadata(x, y, z), 3);
}
public int[] findCore(World world, int x, int y, int z) {
@ -565,7 +550,6 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
@Override
public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) {
int[] pos = findCore(world, x, y, z);
if(pos == null) return;
TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]);
if (tile instanceof ICopiable)
((ICopiable) tile).pasteSettings(nbt, index, world, player, pos[0], pos[1], pos[2]);
@ -591,7 +575,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
meta -= extra;
}
meta = INBTBlockTransformable.transformMetaDeco(meta, coordBaseMode);
meta = INBTTransformable.transformMetaDeco(meta, coordBaseMode);
if(isOffset) {
meta += offset;

View File

@ -80,5 +80,4 @@ public class BlockEnums {
FLUORESCENT,
HALOGEN
}
}

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,6 @@ package com.hbm.blocks.bomb;
import com.hbm.blocks.ModBlocks;
import com.hbm.entity.item.EntityTNTPrimedBase;
import com.hbm.explosion.ExplosionNukeSmall;
import com.hbm.world.biome.BiomeGenCraterBase;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
@ -17,8 +16,6 @@ public class BlockFissureBomb extends BlockTNTBase {
int range = 5;
boolean crater = world.getBiomeGenForCoords((int) Math.floor(x), (int) Math.floor(z)) instanceof BiomeGenCraterBase;
for(int i = -range; i <= range; i++) {
for(int j = -range; j <= range; j++) {
for(int k = -range; k <= range; k++) {
@ -30,7 +27,7 @@ public class BlockFissureBomb extends BlockTNTBase {
Block block = world.getBlock(a, b, c);
if(block == ModBlocks.ore_bedrock) {
world.setBlock(a, b, c, ModBlocks.ore_volcano, crater ? 1 : 0, 3);
world.setBlock(a, b, c, ModBlocks.ore_volcano);
} else if(block == ModBlocks.ore_bedrock_oil) {
world.setBlock(a, b, c, Blocks.bedrock);
}

View File

@ -151,7 +151,7 @@ public class BlockVolcano extends BlockContainer implements ITooltipProvider, IB
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("timer", this.volcanoTimer);
nbt.setInteger("tier", this.volcanoTimer);
}
private boolean shouldGrow() {

View File

@ -3,17 +3,16 @@ package com.hbm.blocks.bomb;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.config.BombConfig;
import com.hbm.entity.effect.EntityCloudFleija;
import com.hbm.entity.effect.EntityCloudFleijaRainbow;
import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.entity.grenade.EntityGrenadeZOMG;
import com.hbm.entity.logic.EntityBalefire;
import com.hbm.entity.logic.EntityNukeExplosionMK3;
import com.hbm.entity.logic.EntityNukeExplosionMK5;
import com.hbm.entity.projectile.EntityFallingNuke;
import com.hbm.explosion.ExplosionChaos;
import com.hbm.explosion.ExplosionLarge;
import com.hbm.interfaces.IBomb;
import com.hbm.interfaces.NotableComments;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.bomb.TileEntityNukeCustom;
@ -31,10 +30,10 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
// this entire class sucks ass
@NotableComments
public class NukeCustom extends BlockContainer implements IBomb {
public TileEntityNukeCustom tetn = new TileEntityNukeCustom();
private static boolean keepInventory = false;
private final static Random field_149933_a = new Random();
@ -135,7 +134,6 @@ public class NukeCustom extends BlockContainer implements IBomb {
public static final int maxAmat = 350;
public static final int maxSchrab = 250;
// genuinely some of the worst fucking code i've ever written
public static void explodeCustom(World worldObj, double xCoord, double yCoord, double zCoord, float tnt, float nuke, float hydro, float amat, float dirty, float schrab, float euph) {
dirty = Math.min(dirty, 100);
@ -143,23 +141,8 @@ public class NukeCustom extends BlockContainer implements IBomb {
/// EUPHEMIUM ///
if(euph > 0) {
EntityNukeExplosionMK3 ex = new EntityNukeExplosionMK3(worldObj);
ex.posX = xCoord;
ex.posY = yCoord;
ex.posZ = zCoord;
ex.destructionRange = 150;
ex.speed = BombConfig.blastSpeed;
ex.coefficient = 1.0F;
ex.waste = false;
worldObj.spawnEntityInWorld(ex);
worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.explode", 100000.0F, 1.0F);
EntityCloudFleijaRainbow cloud = new EntityCloudFleijaRainbow(worldObj, 50);
cloud.posX = xCoord;
cloud.posY = yCoord;
cloud.posZ = zCoord;
worldObj.spawnEntityInWorld(cloud);
EntityGrenadeZOMG zomg = new EntityGrenadeZOMG(worldObj, xCoord, yCoord, zCoord);
ExplosionChaos.zomgMeSinPi(worldObj, xCoord, yCoord, zCoord, 1000, null, zomg);
// SCHRABIDIUM ///
} else if(schrab > 0) {

View File

@ -59,15 +59,8 @@ public class CoriumFinite extends GenericFiniteFluid {
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
// COFH core apparently replaces the water block class with an incompatible type which breaks
// the finite fluid implementation. can't recreate the issue, but according to the provided log
// it seems like this shitty band aid might work
try {
super.updateTick(world, x, y, z, rand);
} catch(ClassCastException ex) {
if(!world.isRemote) world.setBlockToAir(x, y, z);
}
super.updateTick(world, x, y, z, rand);
if(!world.isRemote && rand.nextInt(10) == 0 && world.getBlock(x, y - 1, z) != this) {

View File

@ -2,79 +2,38 @@ package com.hbm.blocks.generic;
import java.util.Random;
import com.hbm.blocks.BlockEnumMulti;
import com.hbm.blocks.IBlockMulti;
import com.hbm.handler.radiation.ChunkRadiationManager;
import com.hbm.lib.RefStrings;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockAbsorber extends BlockEnumMulti implements IBlockMulti {
public class BlockAbsorber extends Block {
// Enum for tiers they are in order of meta data, 0, 1, 2, 3 for Base, Red, Green, Pink
public static enum EnumAbsorberTier {
float absorb = 0;
BASE(2.5F, "absorber"), RED(10F, "absorber_red"), GREEN(100F, "absorber_green"), PINK(10000F, "absorber_pink");
public final float absorbAmount;
public final String textureName;
private EnumAbsorberTier(float absorb, String texture) {
this.absorbAmount = absorb;
this.textureName = texture;
}
}
public BlockAbsorber(Material mat) {
super(mat, EnumAbsorberTier.class, true, true);
public BlockAbsorber(Material mat, float ab) {
super(mat);
this.setTickRandomly(true);
this.setBlockName("rad_absorber");
absorb = ab;
}
public EnumAbsorberTier getTier(int meta) {
return EnumAbsorberTier.values()[rectify(meta)];
}
@Override
public String getUnlocalizedName(ItemStack stack) {
EnumAbsorberTier tier = getTier(stack.getItemDamage());
String tierName = net.minecraft.util.StatCollector.translateToLocal("tile.rad_absorber." + tier.name().toLowerCase());
return tierName;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(net.minecraft.client.renderer.texture.IIconRegister reg) {
icons = new IIcon[EnumAbsorberTier.values().length];
for(int i = 0; i < icons.length; i++) {
icons[i] = reg.registerIcon(RefStrings.MODID + ":" + EnumAbsorberTier.values()[i].textureName);
}
}
// All that rad math shit that was on there already, did not touch this
// -Wolf
@Override
public int tickRate(World world) {
return 10;
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
EnumAbsorberTier tier = getTier(world.getBlockMetadata(x, y, z));
ChunkRadiationManager.proxy.decrementRad(world, x, y, z, tier.absorbAmount);
world.scheduleBlockUpdate(x, y, z, this, tickRate(world));
ChunkRadiationManager.proxy.decrementRad(world, x, y, z, absorb);
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
world.scheduleBlockUpdate(x, y, z, this, tickRate(world));
world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world));
}
}

View File

@ -4,8 +4,8 @@ import com.hbm.inventory.gui.GUIScreenBobble;
import com.hbm.items.special.ItemPlasticScrap.ScrapType;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.world.gen.nbt.INBTTileEntityTransformable;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTileEntityTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
@ -34,7 +34,7 @@ import net.minecraft.world.World;
import java.util.List;
import java.util.Random;
public class BlockBobble extends BlockContainer implements IGUIProvider, INBTBlockTransformable {
public class BlockBobble extends BlockContainer implements IGUIProvider, INBTTransformable {
public BlockBobble() {
super(Material.iron);

View File

@ -7,7 +7,6 @@ import static net.minecraftforge.common.util.ForgeDirection.WEST;
import com.hbm.lib.RefStrings;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -21,23 +20,23 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockChain extends Block implements INBTBlockTransformable {
public class BlockChain extends Block {
@SideOnly(Side.CLIENT)
private IIcon iconEnd;
public BlockChain(Material mat) {
super(mat);
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
public int getRenderType() {
@ -48,7 +47,7 @@ public class BlockChain extends Block implements INBTBlockTransformable {
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
@ -61,14 +60,14 @@ public class BlockChain extends Block implements INBTBlockTransformable {
if(world.isSideSolid(x, y - 1, z, ForgeDirection.UP, false) || (world.getBlock(x, y - 1, z) == this && world.getBlockMetadata(x, y, z) == world.getBlockMetadata(x, y - 1, z)))
return this.blockIcon;
return this.iconEnd;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return null;
}
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
func_149797_b(world.getBlockMetadata(x, y, z));
@ -77,11 +76,11 @@ public class BlockChain extends Block implements INBTBlockTransformable {
}
public void func_149797_b(int meta) {
float f = 0.125F;
if(meta == 0) {
this.minX = 3 * f;
this.minY = 0;
this.minZ = 3 * f;
@ -110,24 +109,24 @@ public class BlockChain extends Block implements INBTBlockTransformable {
this.setBlockBounds(0.0F, 0.0F, 3 * f, f, 1.0F, 5 * f);
}
}
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
this.setBlockBoundsBasedOnState(world, x, y, z);
return super.getSelectedBoundingBoxFromPool(world, x, y, z);
}
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
if(world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN) || world.getBlock(x, y + 1, z) == this)
return true;
return world.isSideSolid(x - 1, y, z, EAST ) ||
world.isSideSolid(x + 1, y, z, WEST ) ||
world.isSideSolid(x, y, z - 1, SOUTH) ||
world.isSideSolid(x, y, z + 1, NORTH);
}
public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int meta)
{
int j1 = meta;
@ -143,12 +142,12 @@ public class BlockChain extends Block implements INBTBlockTransformable {
if(side == 5 && world.isSideSolid(x - 1, y, z, EAST))
j1 = 5;
if(j1 == 0) {
if(world.getBlock(x, y + 1, z) == this)
return world.getBlockMetadata(x, y + 1, z);
if(world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN))
return 0;
}
@ -156,30 +155,30 @@ public class BlockChain extends Block implements INBTBlockTransformable {
if(j1 == 0) {
if(world.isSideSolid(x, y, z + 1, NORTH))
j1 = 2;
if(world.isSideSolid(x, y, z - 1, SOUTH))
j1 = 3;
if(world.isSideSolid(x + 1, y, z, WEST))
j1 = 4;
if(world.isSideSolid(x - 1, y, z, EAST))
j1 = 5;
}
return j1;
}
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
int l = world.getBlockMetadata(x, y, z);
boolean flag = false;
if(world.getBlock(x, y + 1, z) == this && world.getBlockMetadata(x, y, z) == world.getBlockMetadata(x, y + 1, z)) {
super.onNeighborBlockChange(world, x, y, z, block);
return;
}
if(world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN) && world.getBlockMetadata(x, y, z) == 0) {
super.onNeighborBlockChange(world, x, y, z, block);
return;
@ -202,12 +201,4 @@ public class BlockChain extends Block implements INBTBlockTransformable {
super.onNeighborBlockChange(world, x, y, z, block);
}
@Override
public int transformMeta(int meta, int coordBaseMode) {
if (coordBaseMode == 0) return meta;
if (meta == 0) return meta;
if (meta == 1) return meta;
return INBTBlockTransformable.transformMetaDeco(meta, coordBaseMode);
}
}

View File

@ -1,15 +1,26 @@
package com.hbm.blocks.generic;
import java.util.List;
import java.util.Random;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import com.hbm.util.i18n.I18nUtil;
import api.hbm.block.IDrillInteraction;
import api.hbm.block.IMiningDrill;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
public class BlockCluster extends Block {
public class BlockCluster extends Block implements IDrillInteraction, ITooltipProvider {
public BlockCluster(Material mat) {
super(mat);
@ -17,7 +28,32 @@ public class BlockCluster extends Block {
@Override
public Item getItemDropped(int i, Random rand, int j) {
return getDrop();
return null;
}
@Override
public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int meta) {
if(player instanceof FakePlayer || player == null) {
return;
}
if(!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops") && !world.restoringBlockSnapshots) {
Item drop = getDrop();
if(drop == null)
return;
float f = 0.7F;
double mX = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double mY = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double mZ = (double) (world.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(world, (double) x + mX, (double) y + mY, (double) z + mZ, new ItemStack(drop));
entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem);
}
}
private Item getDrop() {
@ -29,4 +65,24 @@ public class BlockCluster extends Block {
return null;
}
@Override
public boolean canBreak(World world, int x, int y, int z, int meta, IMiningDrill drill) {
return drill.getDrillRating() > 70 || world.rand.nextFloat() < 0.05;
}
@Override
public ItemStack extractResource(World world, int x, int y, int z, int meta, IMiningDrill drill) {
return drill.getDrillRating() <= 70 ? new ItemStack(getDrop()) : null;
}
@Override
public float getRelativeHardness(World world, int x, int y, int z, int meta, IMiningDrill drill) {
return this.getBlockHardness(world, x, y, z);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
list.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey("trait.tile.cluster"));
}
}

View File

@ -0,0 +1,78 @@
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.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockCoalBurning extends BlockOutgas {
public BlockCoalBurning(Material mat) {
super(mat, false, 1, false);
this.setTickRandomly(true);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
super.randomDisplayTick(world, x, y, z, rand);
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if(dir == ForgeDirection.DOWN)
continue;
if(world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ).getMaterial() == Material.air) {
double ix = x + 0.5F + dir.offsetX + rand.nextDouble() - 0.5D;
double iy = y + 0.5F + dir.offsetY + rand.nextDouble() - 0.5D;
double iz = z + 0.5F + dir.offsetZ + rand.nextDouble() - 0.5D;
if(dir.offsetX != 0)
ix = x + 0.5F + dir.offsetX * 0.5 + rand.nextDouble() * 0.125 * dir.offsetX;
if(dir.offsetY != 0)
iy = y + 0.5F + dir.offsetY * 0.5 + rand.nextDouble() * 0.125 * dir.offsetY;
if(dir.offsetZ != 0)
iz = z + 0.5F + dir.offsetZ * 0.5 + rand.nextDouble() * 0.125 * dir.offsetZ;
world.spawnParticle("flame", ix, iy, iz, 0.0, 0.0, 0.0);
world.spawnParticle("smoke", ix, iy, iz, 0.0, 0.0, 0.0);
world.spawnParticle("smoke", ix, iy, iz, 0.0, 0.1, 0.0);
}
}
}
@Override
public Item getItemDropped(int i, Random rand, int j) {
return null;
}
public void breakBlock(World world, int x, int y, int z, Block block, int i) {
super.breakBlock(world, x, y, z, block, i);
world.setBlock(x, y, z, Blocks.fire);
for(int ix = -2; ix <= 2; ix++) {
for(int iy = -2; iy <= 2; iy++) {
for(int iz = -2; iz <= 2; iz++) {
if(Math.abs(ix + iy + iz) < 5 && world.getBlock(x + ix, y + iy, z + iz) == Blocks.air) {
world.setBlock(x + ix, y + iy, z + iz, this.getGas());
}
}
}
}
}
@Override
public void onEntityWalking(World world, int x, int y, int z, Entity entity) {
entity.setFire(3);
}
}

View File

@ -0,0 +1,33 @@
package com.hbm.blocks.generic;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.world.World;
public class BlockCoalOil extends Block {
public BlockCoalOil(Material mat) {
super(mat);
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
world.setBlock(x, y, z, ModBlocks.ore_coal_oil_burning);
}
@Override
public Item getItemDropped(int i, Random rand, int j) {
return Items.coal;
}
@Override
public int quantityDropped(Random rand) {
return 2 + rand.nextInt(2);
}
}

View File

@ -5,10 +5,8 @@ import java.util.List;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.interfaces.Spaghetti;
import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmoSecret;
import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemBatteryPack.EnumBatteryPack;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.material.Material;
@ -18,7 +16,6 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@Spaghetti("this is implemented in the most braindead fucking way imaginable") // TODO: rework this unholy abomination using configurable loot pools
public class BlockCrate extends BlockFalling {
List<ItemStack> crateList;
@ -72,16 +69,22 @@ public class BlockCrate extends BlockFalling {
// Lead Crate
BlockCrate.addToListWithWeight(leadList, ModItems.ingot_uranium, 10);
// BlockCrate.addToListWithWeight(leadList, ModItems.ingot_u235, 5);
BlockCrate.addToListWithWeight(leadList, ModItems.ingot_u238, 8);
BlockCrate.addToListWithWeight(leadList, ModItems.ingot_plutonium, 7);
// BlockCrate.addToListWithWeight(leadList, ModItems.ingot_pu238, 5);
// BlockCrate.addToListWithWeight(leadList, ModItems.ingot_pu239, 4);
BlockCrate.addToListWithWeight(leadList, ModItems.ingot_pu240, 6);
BlockCrate.addToListWithWeight(leadList, ModItems.ingot_neptunium, 7);
BlockCrate.addToListWithWeight(leadList, ModItems.ingot_uranium_fuel, 8);
BlockCrate.addToListWithWeight(leadList, ModItems.ingot_plutonium_fuel, 7);
BlockCrate.addToListWithWeight(leadList, ModItems.ingot_mox_fuel, 6);
BlockCrate.addToListWithWeight(leadList, ModItems.nugget_uranium, 10);
// BlockCrate.addToListWithWeight(leadList, ModItems.nugget_u235, 5);
BlockCrate.addToListWithWeight(leadList, ModItems.nugget_u238, 8);
BlockCrate.addToListWithWeight(leadList, ModItems.nugget_plutonium, 7);
// BlockCrate.addToListWithWeight(leadList, ModItems.nugget_pu238, 5);
// BlockCrate.addToListWithWeight(leadList, ModItems.nugget_pu239, 4);
BlockCrate.addToListWithWeight(leadList, ModItems.nugget_pu240, 6);
BlockCrate.addToListWithWeight(leadList, ModItems.nugget_neptunium, 7);
BlockCrate.addToListWithWeight(leadList, ModItems.nugget_uranium_fuel, 8);
@ -93,6 +96,7 @@ public class BlockCrate extends BlockFalling {
BlockCrate.addToListWithWeight(leadList, ModItems.cell_puf6, 8);
BlockCrate.addToListWithWeight(leadList, ModItems.pellet_rtg, 6);
BlockCrate.addToListWithWeight(leadList, ModItems.pellet_rtg_weak, 7);
BlockCrate.addToListWithWeight(leadList, ModItems.tritium_deuterium_cake, 5);
BlockCrate.addToListWithWeight(leadList, ModItems.powder_yellowcake, 10);
// Metal Crate
@ -103,15 +107,17 @@ public class BlockCrate extends BlockFalling {
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_diesel), 8);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_rtg_grey), 4);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.red_pylon), 9);
BlockCrate.addToListWithWeight(metalList, new ItemStack(ModItems.battery_pack, 1, EnumBatteryPack.BATTERY_LEAD.ordinal()), 10);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_battery), 8);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_lithium_battery), 5);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_electric_furnace_off), 8);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_assembly_machine), 10);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_assembler), 10);
BlockCrate.addToListWithWeight(metalList, Item.getItemFromBlock(ModBlocks.machine_fluidtank), 7);
BlockCrate.addToListWithWeight(metalList, ModItems.centrifuge_element, 6);
BlockCrate.addToListWithWeight(metalList, ModItems.motor, 8);
BlockCrate.addToListWithWeight(metalList, ModItems.coil_tungsten, 7);
BlockCrate.addToListWithWeight(metalList, ModItems.photo_panel, 3);
BlockCrate.addToListWithWeight(metalList, ModItems.coil_copper, 10);
BlockCrate.addToListWithWeight(metalList, ModItems.tank_steel, 9);
BlockCrate.addToListWithWeight(metalList, ModItems.blade_titanium, 3);
BlockCrate.addToListWithWeight(metalList, ModItems.piston_selenium, 6);

View File

@ -2,7 +2,7 @@ package com.hbm.blocks.generic;
import com.hbm.blocks.BlockMulti;
import com.hbm.lib.RefStrings;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
@ -15,7 +15,7 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class BlockDecoCRT extends BlockMulti implements INBTBlockTransformable {
public class BlockDecoCRT extends BlockMulti implements INBTTransformable {
protected String[] variants = new String[] {"crt_clean", "crt_broken", "crt_blinking", "crt_bsod"};
@SideOnly(Side.CLIENT) protected IIcon[] icons;
@ -77,7 +77,7 @@ public class BlockDecoCRT extends BlockMulti implements INBTBlockTransformable {
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTBlockTransformable.transformMetaDecoModel(meta, coordBaseMode);
return INBTTransformable.transformMetaDecoModel(meta, coordBaseMode);
}
}

View File

@ -1,7 +1,7 @@
package com.hbm.blocks.generic;
import com.hbm.blocks.BlockEnumMulti;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.block.material.Material;
@ -12,7 +12,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockDecoModel extends BlockEnumMulti implements INBTBlockTransformable {
public class BlockDecoModel extends BlockEnumMulti implements INBTTransformable {
public BlockDecoModel(Material mat, Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) {
super(mat, theEnum, multiName, multiTexture);

View File

@ -2,7 +2,7 @@ package com.hbm.blocks.generic;
import com.hbm.blocks.BlockMulti;
import com.hbm.lib.RefStrings;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
@ -17,7 +17,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockDecoToaster extends BlockMulti implements INBTBlockTransformable {
public class BlockDecoToaster extends BlockMulti implements INBTTransformable {
protected String[] variants = new String[] {"toaster_iron", "toaster_steel", "toaster_wood"};
@SideOnly(Side.CLIENT) protected IIcon[] icons;
@ -94,7 +94,7 @@ public class BlockDecoToaster extends BlockMulti implements INBTBlockTransformab
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTBlockTransformable.transformMetaDecoModel(meta, coordBaseMode);
return INBTTransformable.transformMetaDecoModel(meta, coordBaseMode);
}
}

View File

@ -17,8 +17,6 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@ -94,7 +92,7 @@ public class BlockDoorGeneric extends BlockDummyable implements IBomb {
@Override
public void addCollisionBoxesToList(World worldIn, int x, int y, int z, AxisAlignedBB entityBox, List collidingBoxes, Entity entityIn) {
AxisAlignedBB box = getBoundingBox(worldIn, x, y, z, true);
AxisAlignedBB box = getBoundingBox(worldIn, x, y ,z);
box = AxisAlignedBB.getBoundingBox(
Math.min(box.minX, box.maxX), Math.min(box.minY, box.maxY), Math.min(box.minZ, box.maxZ),
Math.max(box.minX, box.maxX), Math.max(box.minY, box.maxY), Math.max(box.minZ, box.maxZ));
@ -113,27 +111,11 @@ public class BlockDoorGeneric extends BlockDummyable implements IBomb {
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
AxisAlignedBB aabb = this.getBoundingBox(world, x, y, z, true);
AxisAlignedBB aabb = this.getBoundingBox(world, x, y, z);
if(aabb.minX == aabb.maxX && aabb.minY == aabb.maxY && aabb.minZ == aabb.maxZ) return null;
return aabb;
}
// Enables clicking through the open door
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) {
AxisAlignedBB box = getBoundingBox(world, x, y, z, false);
box = AxisAlignedBB.getBoundingBox(
Math.min(box.minX, box.maxX), Math.min(box.minY, box.maxY), Math.min(box.minZ, box.maxZ),
Math.max(box.minX, box.maxX), Math.max(box.minY, box.maxY), Math.max(box.minZ, box.maxZ)
);
MovingObjectPosition intercept = box.calculateIntercept(startVec, endVec);
if(intercept != null) {
return new MovingObjectPosition(x, y, z, intercept.sideHit, intercept.hitVec);
}
return null;
}
@Override //should fix AI pathfinding
public boolean getBlocksMovement(IBlockAccess world, int x, int y, int z) { //btw the method name is the exact opposite of that it's doing, check net.minecraft.pathfinding.PathNavigate#512
return hasExtra(world.getBlockMetadata(x, y, z)); //if it's open
@ -158,11 +140,11 @@ public class BlockDoorGeneric extends BlockDummyable implements IBomb {
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
return getBoundingBox(world, x, y, z, false);
return getBoundingBox(world, x, y, z);
//return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1);
}
public AxisAlignedBB getBoundingBox(World world, int x, int y, int z, boolean forCollision) {
public AxisAlignedBB getBoundingBox(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
TileEntity te = world.getTileEntity(x, y, z);
int[] core = this.findCore(world, x, y, z);
@ -173,7 +155,7 @@ public class BlockDoorGeneric extends BlockDummyable implements IBomb {
TileEntity te2 = world.getTileEntity(core[0], core[1], core[2]);
ForgeDirection dir = ForgeDirection.getOrientation(te2.getBlockMetadata() - BlockDummyable.offset);
BlockPos pos = new BlockPos(x - core[0], y - core[1], z - core[2]).rotate(Rotation.getBlockRotation(dir).add(Rotation.COUNTERCLOCKWISE_90));
AxisAlignedBB box = type.getBlockBound(pos.getX(), pos.getY(), pos.getZ(), open, forCollision);
AxisAlignedBB box = type.getBlockBound(pos.getX(), pos.getY(), pos.getZ(), open);
switch(te2.getBlockMetadata() - offset){
case 2: return AxisAlignedBB.getBoundingBox(x + 1 - box.minX, y + box.minY, z + 1 - box.minZ, x + 1 - box.maxX, y + box.maxY, z + 1 - box.maxZ);

View File

@ -55,8 +55,7 @@ public class BlockFissure extends BlockContainer implements IBlockMultiPass {
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
boolean crater = world.getBlockMetadata(x, y, z) != 0;
if(world.getBlock(x, y + 1, z).isReplaceable(world, x, y + 1, z)) world.setBlock(x, y + 1, z, crater ? ModBlocks.rad_lava_block : ModBlocks.volcanic_lava_block);
if(world.getBlock(x, y + 1, z).isReplaceable(world, x, y + 1, z)) world.setBlock(x, y + 1, z, ModBlocks.volcanic_lava_block);
}
@Override

View File

@ -4,7 +4,7 @@ import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.ModItems;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -21,7 +21,7 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockModDoor extends Block implements INBTBlockTransformable {
public class BlockModDoor extends Block implements INBTTransformable {
@SideOnly(Side.CLIENT)
private IIcon[] field_150017_a;
@SideOnly(Side.CLIENT)
@ -400,6 +400,6 @@ public class BlockModDoor extends Block implements INBTBlockTransformable {
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTBlockTransformable.transformMetaDoor(meta, coordBaseMode);
return INBTTransformable.transformMetaDoor(meta, coordBaseMode);
}
}

View File

@ -1,79 +0,0 @@
package com.hbm.blocks.generic;
import java.util.Locale;
import java.util.Random;
import com.hbm.blocks.BlockEnumMulti;
import com.hbm.lib.RefStrings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.world.World;
public class BlockNTMSand extends BlockEnumMulti {
public BlockNTMSand(Material mat) {
super(mat, EnumSandType.class, true, true);
}
@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 b) {
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);
}
}
private void fall(World world, int x, int y, int z) {
if(BlockFalling.func_149831_e(world, x, y - 1, z) && y >= 0) {
byte b0 = 32;
if(!BlockFalling.fallInstantly && world.checkChunksExist(x - b0, y - b0, z - b0, x + b0, y + b0, z + b0)) {
if(!world.isRemote) {
EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, this, world.getBlockMetadata(x, y, z));
world.spawnEntityInWorld(entityfallingblock);
}
} else {
world.setBlockToAir(x, y, z);
while(BlockFalling.func_149831_e(world, x, y - 1, z) && y > 0) {
--y;
}
if(y > 0) {
world.setBlock(x, y, z, this);
}
}
}
}
@Override
public int tickRate(World p_149738_1_) {
return 2;
}
@Override
public String getTextureMultiName(Enum num) {
return RefStrings.MODID + ":sand_" + num.name().toLowerCase(Locale.US);
}
@Override
public String getUnlocalizedMultiName(Enum num) {
return "tile.sand_" + num.name().toLowerCase(Locale.US);
}
public static enum EnumSandType {
BORON, LEAD, URANIUM, POLONIUM, QUARTZ
}
}

View File

@ -1,60 +0,0 @@
package com.hbm.blocks.generic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTrapDoor;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockNTMTrapdoor extends BlockTrapDoor {
public BlockNTMTrapdoor(Material material) {
super(material);
}
@Override
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity) {
int meta = world.getBlockMetadata(x, y, z);
// isOpen
if (!func_150118_d(meta))
return false;
Block blockBelow = world.getBlock(x, y - 1, z);
return blockBelow != null && blockBelow.isLadder(world, x, y - 1, z, entity);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
// Make the hitbox in-line with ladders, if relevant
if (isLadder(world, x, y, z, null)) {
int meta = world.getBlockMetadata(x, y, z);
float thickness = 0.125F;
if ((meta & 3) == 0)
return AxisAlignedBB.getBoundingBox(x, y, z + 1F - thickness, x + 1F, y + 1F, z + 1F);
if ((meta & 3) == 1)
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1F, y + 1F, z + thickness);
if ((meta & 3) == 2)
return AxisAlignedBB.getBoundingBox(x + 1F - thickness, y, z, x + 1F, y + 1F, z + 1F);
if ((meta & 3) == 3)
return AxisAlignedBB.getBoundingBox(x, y, z, x + thickness, y + 1F, z + 1F);
}
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
// The original code prevented manual operation of Material.iron trapdoors. This bypasses that behavior
int meta = world.getBlockMetadata(x, y, z);
world.setBlockMetadataWithNotify(x, y, z, meta ^ 4, 2);
world.playAuxSFXAtEntity(player, 1003, x, y, z, 0);
return true;
}
}

View File

@ -50,7 +50,7 @@ public class BlockOutgas extends BlockOre {
if(this == ModBlocks.ancient_scrap)
return ModBlocks.gas_radon_tomb;
if(this == ModBlocks.ore_nether_coal) {
if(this == ModBlocks.ore_coal_oil_burning || this == ModBlocks.ore_nether_coal) {
return ModBlocks.gas_monoxide;
}

View File

@ -4,7 +4,7 @@ import java.util.List;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.lib.RefStrings;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
@ -17,7 +17,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class BlockPipe extends Block implements ITooltipProvider, INBTBlockTransformable {
public class BlockPipe extends Block implements ITooltipProvider, INBTTransformable {
@SideOnly(Side.CLIENT)
private IIcon sideIcon;
@ -96,7 +96,7 @@ public class BlockPipe extends Block implements ITooltipProvider, INBTBlockTrans
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTBlockTransformable.transformMetaPillar(meta, coordBaseMode);
return INBTTransformable.transformMetaPillar(meta, coordBaseMode);
}
}

View File

@ -10,33 +10,49 @@ import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
@Deprecated
public class BlockPlasma extends Block {
public BlockPlasma(Material p_i45394_1_) {
super(p_i45394_1_);
this.setTickRandomly(true);
this.setTickRandomly(true);
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand)
{
if (world.getGameRules().getGameRuleBooleanValue("doFireTick"))
world.setBlock(x, y, z, Blocks.air);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
return null;
}
@Override
public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_)
{
p_149670_5_.setFire(10);
p_149670_5_.setInWeb();
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
if(world.getGameRules().getGameRuleBooleanValue("doFireTick"))
world.setBlock(x, y, z, Blocks.air);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) {
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return null;
}
@Override
public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) {
p_149670_5_.setFire(10);
p_149670_5_.setInWeb();
}
@Override public boolean isOpaqueCube() { return false; }
@Override public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { return null; }
@Override public boolean renderAsNormalBlock() { return false; }
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
}

View File

@ -5,8 +5,8 @@ import java.util.Random;
import com.hbm.blocks.IBlockMulti;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.world.gen.nbt.INBTTileEntityTransformable;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTileEntityTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -29,7 +29,7 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
public class BlockPlushie extends BlockContainer implements IBlockMulti, ITooltipProvider, INBTBlockTransformable {
public class BlockPlushie extends BlockContainer implements IBlockMulti, ITooltipProvider, INBTTransformable {
public BlockPlushie() {
super(Material.cloth);
@ -96,16 +96,12 @@ public class BlockPlushie extends BlockContainer implements IBlockMulti, IToolti
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
TileEntityPlushie plushie = (TileEntityPlushie) world.getTileEntity(x, y, z);
if(world.isRemote) {
TileEntityPlushie plushie = (TileEntityPlushie) world.getTileEntity(x, y, z);
plushie.squishTimer = 11;
return true;
} else {
if(plushie.type == PlushieType.HUNDUN) {
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "hbm:block.hunduns_magnificent_howl", 100F, 1F);
} else {
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "hbm:block.squeakyToy", 0.25F, 1F);
}
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "hbm:block.squeakyToy", 0.25F, 1F);
return true;
}
}
@ -159,8 +155,7 @@ public class BlockPlushie extends BlockContainer implements IBlockMulti, IToolti
NONE( "NONE", null),
YOMI( "Yomi", "Hi! Can I be your rabbit friend?"),
NUMBERNINE( "Number Nine", "None of y'all deserve coal."),
HUNDUN( "Hundun", "混沌"),
DERG( "Dragon", "Squeeze him.");
POOH( "Winnie the Pooh", "Beloved children's character with no malicious intent.");
public String label;
public String inscription;

View File

@ -1,497 +0,0 @@
package com.hbm.blocks.generic;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import com.hbm.blocks.ModBlocks;
import com.hbm.config.ClientConfig;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.items.ModItems;
import com.hbm.items.tool.ItemRebarPlacer;
import com.hbm.lib.Library;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.main.ServerProxy;
import com.hbm.render.block.ISBRHUniversal;
import com.hbm.render.util.RenderBlocksNT;
import com.hbm.tileentity.IBufPacketReceiver;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.tileentity.network.TileEntityPipeBaseNT;
import com.hbm.uninos.GenNode;
import com.hbm.uninos.INetworkProvider;
import com.hbm.uninos.UniNodespace;
import com.hbm.uninos.networkproviders.RebarNetwork;
import com.hbm.uninos.networkproviders.RebarNetworkProvider;
import com.hbm.util.BobMathUtil;
import com.hbm.util.Compat;
import com.hbm.util.InventoryUtil;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.fluidmk2.IFluidReceiverMK2;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockRebar extends BlockContainer implements ISBRHUniversal {
@SideOnly(Side.CLIENT) protected IIcon concrete;
public BlockRebar() {
super(Material.iron);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
super.registerBlockIcons(reg);
this.concrete = reg.registerIcon(RefStrings.MODID + ":concrete_liquid");
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityRebar();
}
@Override public int getRenderType() { return renderID; }
@Override public boolean isOpaqueCube() { return false; }
@Override public boolean renderAsNormalBlock() { return false; }
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
return true;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
TileEntity tile = world.getTileEntity(x, y, z);
if(!(tile instanceof TileEntityRebar)) return;
TileEntityRebar rebar = (TileEntityRebar) tile;
rebar.hasConnection = false;
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity neighbor = Compat.getTileStandard(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if(neighbor instanceof TileEntityPipeBaseNT) {
rebar.hasConnection = true;
return;
}
}
}
public static class TileEntityRebar extends TileEntityLoadedBase implements IFluidReceiverMK2, IBufPacketReceiver {
public Block concrete;
public int concreteMeta;
public int progress;
public int prevProgress;
protected RebarNode node;
public boolean hasConnection = false;
public TileEntityRebar setup(Block b, int m) {
this.concrete = b;
this.concreteMeta = m;
return this;
}
@Override
public void updateEntity() {
long time = worldObj.getTotalWorldTime();
if(!worldObj.isRemote) {
if(prevProgress != progress) {
worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this);
prevProgress = progress;
}
if(this.progress >= 1_000) {
if(concrete != null && ItemRebarPlacer.isValidConk(Item.getItemFromBlock(concrete), concreteMeta)) {
worldObj.setBlock(xCoord, yCoord, zCoord, concrete, concreteMeta, 3);
} else {
worldObj.setBlock(xCoord, yCoord, zCoord, ModBlocks.concrete_rebar);
}
return;
}
if(time % 60 == 0) {
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
this.trySubscribe(Fluids.CONCRETE, worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
}
}
if(this.node == null || this.node.expired) {
this.node = (RebarNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, RebarNetworkProvider.THE_PROVIDER);
if(this.node == null || this.node.expired) {
this.node = this.createNode();
UniNodespace.createNode(worldObj, this.node);
}
}
this.networkPackNT(100);
}
}
@Override
public void invalidate() {
super.invalidate();
if(!worldObj.isRemote) {
if(this.node != null) {
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, RebarNetworkProvider.THE_PROVIDER);
}
}
}
@Override public void serialize(ByteBuf buf) { buf.writeInt(progress); }
@Override public void deserialize(ByteBuf buf) { this.progress = buf.readInt(); }
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.progress = nbt.getInteger("progress");
this.hasConnection = nbt.getBoolean("hasConnection");
if(nbt.hasKey("block")) {
this.concrete = Block.getBlockById(nbt.getInteger("block"));
this.concreteMeta = nbt.getInteger("meta");
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("progress", this.progress);
nbt.setBoolean("hasConnection", this.hasConnection);
if(this.concrete != null) {
nbt.setInteger("block", Block.getIdFromBlock(this.concrete));
nbt.setInteger("meta", this.concreteMeta);
}
}
public RebarNode createNode() {
TileEntity tile = (TileEntity) this;
return new RebarNode(RebarNetworkProvider.THE_PROVIDER, new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord)).setConnections(
new DirPos(tile.xCoord + 1, tile.yCoord, tile.zCoord, Library.POS_X),
new DirPos(tile.xCoord - 1, tile.yCoord, tile.zCoord, Library.NEG_X),
new DirPos(tile.xCoord, tile.yCoord + 1, tile.zCoord, Library.POS_Y),
new DirPos(tile.xCoord, tile.yCoord - 1, tile.zCoord, Library.NEG_Y),
new DirPos(tile.xCoord, tile.yCoord, tile.zCoord + 1, Library.POS_Z),
new DirPos(tile.xCoord, tile.yCoord, tile.zCoord - 1, Library.NEG_Z)
);
}
@Override
public FluidTank[] getAllTanks() {
FluidTank tank = new FluidTank(Fluids.CONCRETE, 1_000);
tank.setFill(progress);
return new FluidTank[] {tank};
}
@Override
public long transferFluid(FluidType type, int pressure, long amount) {
if(type != Fluids.CONCRETE) return amount;
if(this.node == null || this.node.expired || !this.node.hasValidNet()) return amount;
List<TileEntityRebar> lowestLinks = new ArrayList();
int lowestY = 256;
int progress = 0;
int capacity = 0;
for(Object o : this.node.net.links) {
RebarNode node = (RebarNode) o;
int y = node.positions[0].getY(); //rebar can only have one pos, there's no multiblock rebar
if(y < lowestY) {
lowestY = y;
progress = 0;
capacity = 0;
lowestLinks.clear();
}
if(y == lowestY) {
TileEntity tile = worldObj.getTileEntity(node.positions[0].getX(), y, node.positions[0].getZ());
if(!(tile instanceof TileEntityRebar)) continue;
TileEntityRebar rebar = (TileEntityRebar) tile;
progress += rebar.progress;
capacity += 1_000;
lowestLinks.add(rebar);
}
}
if(capacity > 0 && !lowestLinks.isEmpty()) {
int maxSpeed = 50;
int maxAccept = (int) BobMathUtil.min(capacity - progress, amount, maxSpeed * lowestLinks.size());
int target = Math.min((progress + maxAccept) / lowestLinks.size(), 1_000);
for(TileEntityRebar rebar : lowestLinks) {
if(rebar.progress >= target) continue;
int delta = target - rebar.progress;
if(delta > amount) continue;
rebar.progress += delta;
amount -= delta;
}
}
return amount;
}
@Override
public long getDemand(FluidType type, int pressure) {
return 10_000;
}
}
public static class RebarNode extends GenNode<RebarNetwork> {
public RebarNode(INetworkProvider<RebarNetwork> provider, BlockPos... positions) {
super(provider, positions);
}
@Override
public RebarNode setConnections(DirPos... connections) {
super.setConnections(connections);
return this;
}
}
@Override
public void renderInventoryBlock(Block block, int meta, int modelId, Object renderBlocks) {
GL11.glPushMatrix();
RenderBlocks renderer = (RenderBlocks) renderBlocks;
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
double o = 0.25D;
renderer.setRenderBounds(0.4375D - o, 0D, 0.4375D - o, 0.5625D - o, 1D, 0.5625D - o); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0.4375D - o, 0D, 0.4375D + o, 0.5625D - o, 1D, 0.5625D + o); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0.4375D + o, 0D, 0.4375D - o, 0.5625D + o, 1D, 0.5625D - o); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0.4375D + o, 0D, 0.4375D + o, 0.5625D + o, 1D, 0.5625D + o); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0D, 0.4375D - o, 0.4375D - o, 1D, 0.5625D - o, 0.5625D - o); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0D, 0.4375D - o, 0.4375D + o, 1D, 0.5625D - o, 0.5625D + o); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0D, 0.4375D + o, 0.4375D - o, 1D, 0.5625D + o, 0.5625D - o); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0D, 0.4375D + o, 0.4375D + o, 1D, 0.5625D + o, 0.5625D + o); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0.4375D - o, 0.4375D - o, 0D, 0.5625D - o, 0.5625D - o, 1D); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0.4375D - o, 0.4375D + o, 0D, 0.5625D - o, 0.5625D + o, 1D); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0.4375D + o, 0.4375D - o, 0D, 0.5625D + o, 0.5625D - o, 1D); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
renderer.setRenderBounds(0.4375D + o, 0.4375D + o, 0D, 0.5625D + o, 0.5625D + o, 1D); RenderBlocksNT.renderStandardInventoryBlock(block, meta, renderer);
GL11.glPopMatrix();
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, Object renderBlocks) {
RenderBlocksNT renderer = RenderBlocksNT.INSTANCE.setWorld(world);
Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
tessellator.setColorOpaque_F(1, 1, 1);
double o = 0.25D;
double min = -0.001;
double max = 1.001;
if(ClientConfig.RENDER_REBAR_SIMPLE.get()) {
renderer.setRenderBounds(0.4375D, min, 0.4375D, 0.5625D, max, 0.5625D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(min, 0.4375D, 0.4375D, max, 0.5625D, 0.5625D); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.4375D, 0.4375D, min, 0.5625D, 0.5625D, max); renderer.renderStandardBlock(block, x, y, z);
} else {
renderer.setRenderBounds(0.4375D - o, min, 0.4375D - o, 0.5625D - o, max, 0.5625D - o); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.4375D - o, min, 0.4375D + o, 0.5625D - o, max, 0.5625D + o); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.4375D + o, min, 0.4375D - o, 0.5625D + o, max, 0.5625D - o); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.4375D + o, min, 0.4375D + o, 0.5625D + o, max, 0.5625D + o); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(min, 0.4375D - o, 0.4375D - o, max, 0.5625D - o, 0.5625D - o); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(min, 0.4375D - o, 0.4375D + o, max, 0.5625D - o, 0.5625D + o); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(min, 0.4375D + o, 0.4375D - o, max, 0.5625D + o, 0.5625D - o); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(min, 0.4375D + o, 0.4375D + o, max, 0.5625D + o, 0.5625D + o); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.4375D - o, 0.4375D - o, min, 0.5625D - o, 0.5625D - o, max); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.4375D - o, 0.4375D + o, min, 0.5625D - o, 0.5625D + o, max); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.4375D + o, 0.4375D - o, min, 0.5625D + o, 0.5625D - o, max); renderer.renderStandardBlock(block, x, y, z);
renderer.setRenderBounds(0.4375D + o, 0.4375D + o, min, 0.5625D + o, 0.5625D + o, max); renderer.renderStandardBlock(block, x, y, z);
}
/*TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityRebar) {
TileEntityRebar rebar = (TileEntityRebar) tile;
if(rebar.progress > 0) {
double height = rebar.progress / 1000D;
renderer.setOverrideBlockTexture(concrete);
renderer.setRenderBounds(0, 0, 0, 1, height, 1); renderer.renderStandardBlock(block, x, y, z);
renderer.clearOverrideBlockTexture();
}
}*/
return true;
}
// from ModEventHandlerClient.onRenderWorldLastEvent
@SideOnly(Side.CLIENT)
public static void renderRebar(List tiles, float interp) {
List<TileEntityRebar> rebars = new ArrayList();
for(Object o : tiles) {
if(!(o instanceof TileEntityRebar)) continue;
TileEntityRebar rebar = (TileEntityRebar) o;
if(rebar.progress > 0) rebars.add(rebar);
if(rebars.size() >= ClientConfig.RENDER_REBAR_LIMIT.get()) break;
}
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
World world = mc.theWorld;
double dx = player.prevPosX + (player.posX - player.prevPosX) * interp;
double dy = player.prevPosY + (player.posY - player.prevPosY) * interp;
double dz = player.prevPosZ + (player.posZ - player.prevPosZ) * interp;
if(!rebars.isEmpty()) {
GL11.glPushMatrix();
GL11.glShadeModel(GL11.GL_SMOOTH);
//RenderHelper.enableStandardItemLighting();
EntityRenderer entityRenderer = mc.entityRenderer;
entityRenderer.enableLightmap(interp);
RenderBlocksNT renderer = RenderBlocksNT.INSTANCE.setWorld(world);
renderer.setOverrideBlockTexture(((BlockRebar) ModBlocks.rebar).concrete);
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
for(TileEntityRebar rebar : rebars) {
tess.setTranslation(-dx, -dy, -dz);
tess.setColorRGBA_F(1F, 1F, 1F, 1F);
renderer.setRenderBounds(0, 0, 0, 1, rebar.progress / 1000D, 1);
renderer.renderStandardBlock(ModBlocks.rebar, rebar.xCoord, rebar.yCoord, rebar.zCoord);
}
tess.draw();
tess.setTranslation(0, 0, 0);
renderer.clearOverrideBlockTexture();
entityRenderer.disableLightmap(interp);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glPopMatrix();
}
if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.rebar_placer && player.getHeldItem().hasTagCompound() &&
player.getHeldItem().stackTagCompound.hasKey("pos") && mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectType.BLOCK) {
int[] pos = player.getHeldItem().stackTagCompound.getIntArray("pos");
MovingObjectPosition mop = mc.objectMouseOver;
ForgeDirection dir = ForgeDirection.getOrientation(mop.sideHit);
int iX = mop.blockX + dir.offsetX;
int iY = mop.blockY + dir.offsetY;
int iZ = mop.blockZ + dir.offsetZ;
double minX = Math.min(pos[0], iX) + 0.125;
double maxX = Math.max(pos[0], iX) + 0.875;
double minY = Math.min(pos[1], iY) + 0.125;
double maxY = Math.max(pos[1], iY) + 0.875;
double minZ = Math.min(pos[2], iZ) + 0.125;
double maxZ = Math.max(pos[2], iZ) + 0.875;
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor3f(1F, 1F, 1F);
Tessellator tess = Tessellator.instance;
tess.setTranslation(-dx, -dy, -dz);
tess.startDrawing(GL11.GL_LINES);
tess.setBrightness(240);
tess.setColorRGBA_F(1F, 1F, 1F, 1F);
// top
tess.addVertex(minX, maxY, minZ);
tess.addVertex(minX, maxY, maxZ);
tess.addVertex(minX, maxY, maxZ);
tess.addVertex(maxX, maxY, maxZ);
tess.addVertex(maxX, maxY, maxZ);
tess.addVertex(maxX, maxY, minZ);
tess.addVertex(maxX, maxY, minZ);
tess.addVertex(minX, maxY, minZ);
// bottom
tess.addVertex(minX, minY, minZ);
tess.addVertex(minX, minY, maxZ);
tess.addVertex(minX, minY, maxZ);
tess.addVertex(maxX, minY, maxZ);
tess.addVertex(maxX, minY, maxZ);
tess.addVertex(maxX, minY, minZ);
tess.addVertex(maxX, minY, minZ);
tess.addVertex(minX, minY, minZ);
// sides
tess.addVertex(minX, minY, minZ);
tess.addVertex(minX, maxY, minZ);
tess.addVertex(maxX, minY, minZ);
tess.addVertex(maxX, maxY, minZ);
tess.addVertex(maxX, minY, maxZ);
tess.addVertex(maxX, maxY, maxZ);
tess.addVertex(minX, minY, maxZ);
tess.addVertex(minX, maxY, maxZ);
tess.draw();
tess.setTranslation(0, 0, 0);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
int rebarLeft = InventoryUtil.countAStackMatches(player, new ComparableStack(ModBlocks.rebar), true);
int rebarRequired = (Math.max(pos[0], iX) - Math.min(pos[0], iX) + 1) * (Math.max(pos[1], iY) - Math.min(pos[1], iY) + 1) * (Math.max(pos[2], iZ) - Math.min(pos[2], iZ) + 1);
MainRegistry.proxy.displayTooltip((rebarRequired > rebarLeft ? EnumChatFormatting.RED : EnumChatFormatting.GREEN) + (rebarLeft + " / " + rebarRequired), 1_000, ServerProxy.ID_CABLE);
}
}
}

View File

@ -11,7 +11,6 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
@ -67,7 +66,7 @@ public class BlockReeds extends Block {
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
return Items.stick;
return null;
}
@Override

View File

@ -152,7 +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 OreDictStack(OreDictManager.DURA.bolt(), 4)}, new MetaBlock(ModBlocks.watz_end, 1)));
conversions.put(new Pair(ToolType.TORCH, new MetaBlock(ModBlocks.fusion_component, 0)), new Pair(new AStack[] {new OreDictStack(OreDictManager.STEEL.plateCast())}, new MetaBlock(ModBlocks.fusion_component, 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)));
conversions.put(new Pair(ToolType.TORCH, new MetaBlock(ModBlocks.icf_component, 1)), new Pair(new AStack[] {new OreDictStack(OreDictManager.ANY_BISMOIDBRONZE.plateCast())}, new MetaBlock(ModBlocks.icf_component, 2)));
conversions.put(new Pair(ToolType.BOLT, new MetaBlock(ModBlocks.icf_component, 3)), new Pair(new AStack[] {new OreDictStack(OreDictManager.STEEL.plateCast()), new OreDictStack(OreDictManager.DURA.bolt(), 4)}, new MetaBlock(ModBlocks.icf_component, 4)));
}

View File

@ -18,7 +18,7 @@ import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.BufferUtil;
import com.hbm.util.i18n.I18nUtil;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.common.registry.GameRegistry;
@ -37,6 +37,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -46,7 +47,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
public class BlockWandJigsaw extends BlockContainer implements IBlockSideRotation, INBTBlockTransformable, IGUIProvider, ILookOverlay {
public class BlockWandJigsaw extends BlockContainer implements IBlockSideRotation, INBTTransformable, IGUIProvider, ILookOverlay {
private IIcon iconTop;
private IIcon iconSide;
@ -122,7 +123,7 @@ public class BlockWandJigsaw extends BlockContainer implements IBlockSideRotatio
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTBlockTransformable.transformMetaDeco(meta, coordBaseMode);
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
}
@Override
@ -134,10 +135,10 @@ public class BlockWandJigsaw extends BlockContainer implements IBlockSideRotatio
TileEntityWandJigsaw jigsaw = (TileEntityWandJigsaw) te;
if(!player.isSneaking()) {
Block block = ModBlocks.getBlockFromStack(player.getHeldItem());
Block block = getBlock(world, player.getHeldItem());
if(block == ModBlocks.wand_air) block = Blocks.air;
if(block != null && !ModBlocks.isStructureBlock(block, false)) {
if(block != null && block != ModBlocks.wand_jigsaw && block != ModBlocks.wand_loot) {
jigsaw.replaceBlock = block;
jigsaw.replaceMeta = player.getHeldItem().getItemDamage();
@ -154,6 +155,13 @@ public class BlockWandJigsaw extends BlockContainer implements IBlockSideRotatio
return false;
}
private Block getBlock(World world, ItemStack stack) {
if(stack == null) return null;
if(!(stack.getItem() instanceof ItemBlock)) return null;
return ((ItemBlock) stack.getItem()).field_150939_a;
}
@Override
@SideOnly(Side.CLIENT)
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {

View File

@ -1,345 +0,0 @@
package com.hbm.blocks.generic;
import api.hbm.block.IToolable;
import com.hbm.blocks.IBlockSideRotation;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks;
import com.hbm.config.StructureConfig;
import com.hbm.interfaces.IBomb;
import com.hbm.interfaces.ICopiable;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.BufferUtil;
import com.hbm.util.i18n.I18nUtil;
import com.hbm.world.gen.nbt.INBTTileEntityTransformable;
import com.hbm.world.gen.util.LogicBlockActions;
import com.hbm.world.gen.util.LogicBlockConditions;
import com.hbm.world.gen.util.LogicBlockInteractions;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
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.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.List;
public class BlockWandLogic extends BlockContainer implements ILookOverlay, IToolable, ITooltipProvider, IBlockSideRotation, IBomb {
@SideOnly(Side.CLIENT) protected IIcon iconTop;
public BlockWandLogic() {
super(Material.iron);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":wand_logic");
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":wand_logic_top");
}
@Override
public IIcon getIcon(int side, int meta) {
return (side <= 1) ? iconTop : blockIcon;
}
@Override
public int getRotationFromSide(IBlockAccess world, int x, int y, int z, int side) {
if(side == 0) return IBlockSideRotation.topToBottom(world.getBlockMetadata(x, y, z));
if(side == 1) return world.getBlockMetadata(x, y, z);
return 0;
}
@Override
public int getRenderType() {
return IBlockSideRotation.getRenderType();
}
@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, 3, 2);
if (i == 1) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
if (i == 2) world.setBlockMetadataWithNotify(x, y, z, 0, 2);
if (i == 3) world.setBlockMetadataWithNotify(x, y, z, 1, 2);
ForgeDirection dir = ForgeDirection.UNKNOWN;
switch(i){
case 0: dir = ForgeDirection.SOUTH;break;
case 1: dir = ForgeDirection.WEST; break;
case 2: dir = ForgeDirection.NORTH;break;
case 3: dir = ForgeDirection.EAST; break;
}
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileEntityWandLogic)
((TileEntityWandLogic)te).placedRotation = dir.ordinal();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float fX, float fY, float fZ) {
ItemStack stack = player.getHeldItem();
if (stack != null && stack.getItem() instanceof ItemBlock && !player.isSneaking()) {
ItemBlock ib = (ItemBlock) stack.getItem();
Block block = ib.field_150939_a;
if (block.renderAsNormalBlock() && block != this) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityWandLogic){
TileEntityWandLogic logic = (TileEntityWandLogic) tile;
logic.disguise = block;
logic.disguiseMeta = stack.getItemDamage() & 15;
return true;
}
}
}
return super.onBlockActivated(world, x, y, z, player, side, fX, fY, fZ);
}
@Override
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandLogic)) return false;
TileEntityWandLogic logic = (TileEntityWandLogic) te;
switch(tool) {
case SCREWDRIVER:
List<String> actionNames = LogicBlockActions.getActionNames();
int indexA = actionNames.indexOf(logic.actionID);
indexA += player.isSneaking() ? -1 : 1;
indexA = MathHelper.clamp_int(indexA, 0, actionNames.size() - 1);
logic.actionID = actionNames.get(indexA);
return true;
case DEFUSER:
List<String> conditionNames = LogicBlockConditions.getConditionNames();
int indexC = conditionNames.indexOf(logic.conditionID);
indexC += player.isSneaking() ? -1 : 1;
indexC = MathHelper.clamp_int(indexC, 0, conditionNames.size() - 1);
logic.conditionID = conditionNames.get(indexC);
return true;
case HAND_DRILL:
List<String> interactionNames = LogicBlockInteractions.getInteractionNames();
int indexI = interactionNames.indexOf(logic.interactionID);
indexI += player.isSneaking() ? -1 : 1;
indexI = MathHelper.clamp_int(indexI, 0, interactionNames.size() - 1);
logic.interactionID = interactionNames.get(indexI);
return true;
default: return false;
}
}
@Override
public void printHook(RenderGameOverlayEvent.Pre event, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandLogic)) return;
TileEntityWandLogic logic = (TileEntityWandLogic) te;
List<String> text = new ArrayList<>();
text.add("Action: " + logic.actionID);
text.add("Condition: " + logic.conditionID);
text.add("Interaction: " + (logic.interactionID != null ? logic.interactionID : "None"));
String block;
if(logic.disguise != null && logic.disguise != Blocks.air)
block = I18nUtil.resolveKey(logic.disguise.getUnlocalizedName() + ".name");
else
block = "None";
text.add("Disguise Block: " + block);
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
list.add(EnumChatFormatting.GOLD + "Use screwdriver to cycle forwards through the action list, shift click to go back");
list.add(EnumChatFormatting.GOLD + "Use defuser to cycle forwards through the condition list, shift click to go back");
list.add(EnumChatFormatting.GOLD + "Use hand drill to cycle forwards through the interaction list, shift click to go back");
list.add(EnumChatFormatting.YELLOW + "Use a detonator to transform");
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityWandLogic();
}
@Override
public BombReturnCode explode(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandLogic)) return null;
((TileEntityWandLogic) te).triggerReplace = true;
return BombReturnCode.TRIGGERED;
}
public static class TileEntityWandLogic extends TileEntityLoadedBase implements INBTTileEntityTransformable, ICopiable {
private boolean triggerReplace;
public int placedRotation;
Block disguise;
int disguiseMeta = -1;
public String actionID = "FODDER_WAVE";
public String conditionID = "PLAYER_CUBE_5";
public String interactionID;
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
if(triggerReplace) {
// On the first tick of this TE, replace with intended block and fill with loot
replace();
} else {
networkPackNT(15);
}
}
}
private void replace() {
if (!(worldObj.getBlock(xCoord, yCoord, zCoord) instanceof BlockWandLogic)) {
MainRegistry.logger.warn("Somehow the block at: " + xCoord + ", " + yCoord + ", " + zCoord + " isn't a logic block but we're doing a TE update as if it is, cancelling!");
return;
}
worldObj.setBlock(xCoord,yCoord,zCoord, ModBlocks.logic_block);
TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord);
if(te == null || te instanceof BlockWandLoot.TileEntityWandLoot) {
MainRegistry.logger.warn("TE for logic block set incorrectly at: " + xCoord + ", " + yCoord + ", " + zCoord + ". If you're using some sort of world generation mod, report it to the author!");
te = ModBlocks.wand_logic.createTileEntity(worldObj, 0);
worldObj.setTileEntity(xCoord, yCoord, zCoord, te);
}
if(te instanceof LogicBlock.TileEntityLogicBlock){
LogicBlock.TileEntityLogicBlock logic = (LogicBlock.TileEntityLogicBlock) te;
logic.actionID = actionID;
logic.conditionID = conditionID;
logic.interactionID = interactionID;
logic.direction = ForgeDirection.getOrientation(placedRotation);
logic.disguise = disguise;
logic.disguiseMeta = disguiseMeta;
}
}
@Override
public void transformTE(World world, int coordBaseMode) {
triggerReplace = !StructureConfig.debugStructures;
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setString("actionID", actionID);
nbt.setString("conditionID", conditionID);
if(interactionID != null)
nbt.setString("interactionID", interactionID);
nbt.setInteger("rotation", placedRotation);
if(disguise != null){
nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString());
nbt.setInteger("disguiseMeta", disguiseMeta);
}
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
actionID = nbt.getString("actionID");
conditionID = nbt.getString("conditionID");
if(nbt.hasKey("interactionID"))
interactionID = nbt.getString("interactionID");
placedRotation = nbt.getInteger("rotation");
if(nbt.hasKey("disguise")){
disguise = Block.getBlockFromName(nbt.getString("disguise"));
disguiseMeta = nbt.getInteger("disguiseMeta");
}
}
@Override
public void serialize(ByteBuf buf) {
buf.writeInt(placedRotation);
BufferUtil.writeString(buf, actionID);
BufferUtil.writeString(buf, conditionID);
BufferUtil.writeString(buf, interactionID);
buf.writeInt(Block.getIdFromBlock(disguise));
buf.writeInt(disguiseMeta);
}
@Override
public void deserialize(ByteBuf buf) {
placedRotation = buf.readInt();
actionID = BufferUtil.readString(buf);
conditionID = BufferUtil.readString(buf);
interactionID = BufferUtil.readString(buf);
disguise = Block.getBlockById(buf.readInt());
disguiseMeta = buf.readInt();
}
@Override
public NBTTagCompound getSettings(World world, int x, int y, int z) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("actionID", actionID);
nbt.setString("conditionID", conditionID);
if(interactionID != null)
nbt.setString("interactionID", interactionID);
if(disguise != null){
nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString());
nbt.setInteger("disguiseMeta", disguiseMeta);
}
return nbt;
}
@Override
public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) {
actionID = nbt.getString("actionID");
conditionID = nbt.getString("conditionID");
interactionID = nbt.getString("interactionID");
if(nbt.hasKey("disguise")){
disguise = Block.getBlockFromName(nbt.getString("disguise"));
disguiseMeta = nbt.getInteger("disguiseMeta");
}
}
}
}

View File

@ -17,7 +17,7 @@ import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.BufferUtil;
import com.hbm.util.LootGenerator;
import com.hbm.util.i18n.I18nUtil;
import com.hbm.world.gen.nbt.INBTTileEntityTransformable;
import com.hbm.world.gen.INBTTileEntityTransformable;
import com.mojang.authlib.GameProfile;
import api.hbm.block.IToolable;
@ -33,6 +33,7 @@ import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -81,7 +82,7 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
@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;
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if(i == 0) world.setBlockMetadataWithNotify(x, y, z, 3, 2);
if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
@ -152,14 +153,17 @@ public class BlockWandLoot extends BlockContainer implements ILookOverlay, ITool
}
private Block getLootableBlock(World world, ItemStack stack) {
Block block = ModBlocks.getBlockFromStack(stack);
if(block == null) return null;
if(stack == null) return null;
if(block == ModBlocks.deco_loot) return block;
if(stack.getItem() instanceof ItemBlock) {
Block block = ((ItemBlock) stack.getItem()).field_150939_a;
if(block instanceof ITileEntityProvider) {
TileEntity te = ((ITileEntityProvider) block).createNewTileEntity(world, 12);
if(te instanceof IInventory) return block;
if(block == ModBlocks.deco_loot) return block;
if(block instanceof ITileEntityProvider) {
TileEntity te = ((ITileEntityProvider) block).createNewTileEntity(world, 12);
if(te instanceof IInventory) return block;
}
}
return null;

View File

@ -1,573 +0,0 @@
package com.hbm.blocks.generic;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.lwjgl.input.Keyboard;
import com.hbm.blocks.IBlockMulti;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ModBlocks;
import com.hbm.config.StructureConfig;
import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.gui.element.GuiFileList;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toserver.NBTControlPacket;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.BufferUtil;
import com.hbm.util.Tuple.Pair;
import com.hbm.util.i18n.I18nUtil;
import com.hbm.world.gen.nbt.NBTStructure;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.event.ClickEvent;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
public class BlockWandStructure extends BlockContainer implements IBlockMulti, IGUIProvider, ILookOverlay {
private IIcon saveIcon;
private IIcon loadIcon;
public BlockWandStructure() {
super(Material.iron);
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityWandStructure();
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
saveIcon = iconRegister.registerIcon(RefStrings.MODID + ":wand_structure_save");
loadIcon = iconRegister.registerIcon(RefStrings.MODID + ":wand_structure_load");
}
@Override
public IIcon getIcon(int side, int meta) {
if(meta == 1) return loadIcon;
return saveIcon;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandStructure)) return false;
TileEntityWandStructure structure = (TileEntityWandStructure) te;
if(!player.isSneaking()) {
Block block = ModBlocks.getBlockFromStack(player.getHeldItem());
if(block != null && !ModBlocks.isStructureBlock(block, true)) {
Pair<Block, Integer> bm = new Pair<Block, Integer>(block, player.getHeldItem().getItemDamage());
if(structure.blacklist.contains(bm)) {
structure.blacklist.remove(bm);
} else {
structure.blacklist.add(bm);
}
return true;
}
if(world.isRemote) FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
return true;
}
return false;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) {
list.add(new ItemStack(itemIn, 1, 0));
list.add(new ItemStack(itemIn, 1, 1));
}
@Override
public int getSubCount() {
return 2;
}
@Override
public String getUnlocalizedName(ItemStack stack) {
int meta = stack.getItemDamage();
if(meta == 1) return getUnlocalizedName() + ".load";
return getUnlocalizedName() + ".save";
}
@Override
public int damageDropped(int meta) {
return meta;
}
@Override
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
@Override
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
TileEntityWandStructure structure = (TileEntityWandStructure) world.getTileEntity(x, y, z);
if(meta == 1) return new GuiStructureLoad(structure);
return new GuiStructureSave(structure);
}
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
if(world.getBlockMetadata(x, y, z) != 0) return;
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandStructure)) return;
TileEntityWandStructure structure = (TileEntityWandStructure) te;
List<String> text = new ArrayList<String>();
text.add(EnumChatFormatting.GRAY + "Name: " + EnumChatFormatting.RESET + structure.name);
text.add(EnumChatFormatting.GRAY + "Blacklist:");
for (Pair<Block, Integer> bm : structure.blacklist) {
text.add(EnumChatFormatting.RED + "- " + bm.getKey().getUnlocalizedName() + " : " + bm.getValue());
}
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".save.name"), 0xffff00, 0x404000, text);
}
public static class TileEntityWandStructure extends TileEntityLoadedBase implements IControlReceiver {
public String name = "";
public int sizeX = 1;
public int sizeY = 1;
public int sizeZ = 1;
public Set<Pair<Block, Integer>> blacklist = new HashSet<>();
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
networkPackNT(256);
}
}
public void saveStructure(EntityPlayer player) {
if(name.isEmpty()) {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not save: invalid name"));
return;
}
if(sizeX <= 0 || sizeY <= 0 || sizeZ <= 0) {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not save: invalid dimensions"));
return;
}
Pair<Block, Integer> air = new Pair<Block, Integer>(Blocks.air, 0);
blacklist.add(air);
File file = NBTStructure.quickSaveArea(name + ".nbt", worldObj, xCoord, yCoord + 1, zCoord, xCoord + sizeX - 1, yCoord + sizeY, zCoord + sizeZ - 1, blacklist);
blacklist.remove(air);
if(file == null) {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Failed to save structure"));
return;
}
ChatComponentText fileText = new ChatComponentText(file.getName());
fileText.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file.getParentFile().getAbsolutePath()));
fileText.getChatStyle().setUnderlined(true);
player.addChatMessage(new ChatComponentText("Saved structure as ").appendSibling(fileText));
}
public void loadStructure(EntityPlayer player) {
if(name.isEmpty()) {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not load: no filename specified"));
return;
}
File structureDirectory = new File(Minecraft.getMinecraft().mcDataDir, "structures");
structureDirectory.mkdir();
File structureFile = new File(structureDirectory, name + ".nbt");
boolean previousDebug = StructureConfig.debugStructures;
StructureConfig.debugStructures = true;
try {
NBTStructure structure = new NBTStructure(structureFile);
sizeX = structure.getSizeX();
sizeY = structure.getSizeY();
sizeZ = structure.getSizeZ();
structure.build(worldObj, xCoord, yCoord + 1, zCoord, 0, false, true);
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 3);
player.addChatMessage(new ChatComponentText("Structure loaded"));
} catch (FileNotFoundException ex) {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not load: file not found"));
} finally {
StructureConfig.debugStructures = previousDebug;
}
}
@Override
public void serialize(ByteBuf buf) {
BufferUtil.writeString(buf, name);
buf.writeInt(sizeX);
buf.writeInt(sizeY);
buf.writeInt(sizeZ);
buf.writeInt(blacklist.size());
for(Pair<Block, Integer> bm : blacklist) {
buf.writeInt(Block.getIdFromBlock(bm.getKey()));
buf.writeInt(bm.getValue());
}
}
@Override
public void deserialize(ByteBuf buf) {
name = BufferUtil.readString(buf);
sizeX = buf.readInt();
sizeY = buf.readInt();
sizeZ = buf.readInt();
int count = buf.readInt();
blacklist = new HashSet<>();
for(int i = 0; i < count; i++) {
Block block = Block.getBlockById(buf.readInt());
int meta = buf.readInt();
blacklist.add(new Pair<Block, Integer>(block, meta));
}
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
name = nbt.getString("name");
sizeX = nbt.getInteger("sizeX");
sizeY = nbt.getInteger("sizeY");
sizeZ = nbt.getInteger("sizeZ");
int[] blocks = nbt.getIntArray("blocks");
int[] metas = nbt.getIntArray("metas");
blacklist = new HashSet<>();
for (int i = 0; i < blocks.length; i++) {
blacklist.add(new Pair<Block, Integer>(Block.getBlockById(blocks[i]), metas[i]));
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setString("name", name);
nbt.setInteger("sizeX", sizeX);
nbt.setInteger("sizeY", sizeY);
nbt.setInteger("sizeZ", sizeZ);
nbt.setIntArray("blocks", blacklist.stream().mapToInt(b -> Block.getIdFromBlock(b.getKey())).toArray());
nbt.setIntArray("metas", blacklist.stream().mapToInt(b -> b.getValue()).toArray());
}
@Override
public boolean hasPermission(EntityPlayer player) {
return true;
}
public void receiveControl(NBTTagCompound data) {}
@Override
public void receiveControl(EntityPlayer player, NBTTagCompound nbt) {
readFromNBT(nbt);
markDirty();
if(nbt.getBoolean("save")) {
saveStructure(player);
}
if(nbt.getBoolean("load")) {
loadStructure(player);
}
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
return INFINITE_EXTENT_AABB;
}
@Override
@SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() {
return 65536.0D;
}
}
@SideOnly(Side.CLIENT)
public static class GuiStructureSave extends GuiScreen {
private final TileEntityWandStructure tile;
private GuiTextField textName;
private GuiTextField textSizeX;
private GuiTextField textSizeY;
private GuiTextField textSizeZ;
private GuiButton performAction;
private boolean saveOnClose = false;
public GuiStructureSave(TileEntityWandStructure tile) {
this.tile = tile;
}
@Override
public void initGui() {
Keyboard.enableRepeatEvents(true);
textName = new GuiTextField(fontRendererObj, width / 2 - 150, 50, 300, 20);
textName.setText(tile.name);
textSizeX = new GuiTextField(fontRendererObj, width / 2 - 150, 100, 50, 20);
textSizeX.setText("" + tile.sizeX);
textSizeY = new GuiTextField(fontRendererObj, width / 2 - 100, 100, 50, 20);
textSizeY.setText("" + tile.sizeY);
textSizeZ = new GuiTextField(fontRendererObj, width / 2 - 50, 100, 50, 20);
textSizeZ.setText("" + tile.sizeZ);
performAction = new GuiButton(0, width / 2 - 150, 150, 300, 20, "SAVE");
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
drawDefaultBackground();
textName.drawTextBox();
textSizeX.drawTextBox();
textSizeY.drawTextBox();
textSizeZ.drawTextBox();
performAction.drawButton(mc, mouseX, mouseY);
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
NBTTagCompound data = new NBTTagCompound();
tile.writeToNBT(data);
data.setString("name", textName.getText());
try { data.setInteger("sizeX", Integer.parseInt(textSizeX.getText())); } catch (Exception ex) {}
try { data.setInteger("sizeY", Integer.parseInt(textSizeY.getText())); } catch (Exception ex) {}
try { data.setInteger("sizeZ", Integer.parseInt(textSizeZ.getText())); } catch (Exception ex) {}
if(saveOnClose) data.setBoolean("save", true);
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, tile.xCoord, tile.yCoord, tile.zCoord));
}
@Override
protected void keyTyped(char typedChar, int keyCode) {
super.keyTyped(typedChar, keyCode);
textName.textboxKeyTyped(typedChar, keyCode);
textSizeX.textboxKeyTyped(typedChar, keyCode);
textSizeY.textboxKeyTyped(typedChar, keyCode);
textSizeZ.textboxKeyTyped(typedChar, keyCode);
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
textName.mouseClicked(mouseX, mouseY, mouseButton);
textSizeX.mouseClicked(mouseX, mouseY, mouseButton);
textSizeY.mouseClicked(mouseX, mouseY, mouseButton);
textSizeZ.mouseClicked(mouseX, mouseY, mouseButton);
if(performAction.mousePressed(mc, mouseX, mouseY)) {
saveOnClose = true;
mc.displayGuiScreen(null);
mc.setIngameFocus();
}
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
}
@SideOnly(Side.CLIENT)
public static class GuiStructureLoad extends GuiScreen {
private final TileEntityWandStructure tile;
private GuiTextField textName;
private GuiFileList fileList;
private GuiButton performAction;
private boolean loadOnClose = false;
private static File structureDirectory = new File(Minecraft.getMinecraft().mcDataDir, "structures");
private static String nameFilter = "";
private static final FileFilter structureFilter = new FileFilter() {
public boolean accept(File file) {
if(!file.isFile() || !file.getName().endsWith(".nbt")) return false;
return nameFilter.isEmpty() || file.getName().contains(nameFilter);
}
};
public GuiStructureLoad(TileEntityWandStructure tile) {
this.tile = tile;
}
@Override
public void initGui() {
Keyboard.enableRepeatEvents(true);
textName = new GuiTextField(fontRendererObj, width / 2 - 150, 50, 300, 20);
textName.setText(tile.name);
nameFilter = tile.name;
structureDirectory.mkdir();
fileList = new GuiFileList(mc, structureDirectory.listFiles(structureFilter), this::selectFile, nameFilter, width, height, 70, height - 90, 16);
performAction = new GuiButton(0, width / 2 - 150, height - 70, 300, 20, "LOAD");
}
public void selectFile(File file) {
String fileName = file.getName();
textName.setText(fileName.substring(0, fileName.length() - 4));
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
fileList.drawScreen(mouseX, mouseY, partialTicks);
textName.drawTextBox();
performAction.drawButton(mc, mouseX, mouseY);
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
NBTTagCompound data = new NBTTagCompound();
tile.writeToNBT(data);
data.setString("name", textName.getText());
if(loadOnClose) data.setBoolean("load", true);
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, tile.xCoord, tile.yCoord, tile.zCoord));
}
@Override
protected void keyTyped(char typedChar, int keyCode) {
super.keyTyped(typedChar, keyCode);
textName.textboxKeyTyped(typedChar, keyCode);
if(!nameFilter.equals(textName.getText())) {
nameFilter = textName.getText();
fileList = new GuiFileList(mc, structureDirectory.listFiles(structureFilter), this::selectFile, nameFilter, width, height, 70, height - 90, 16);
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
textName.mouseClicked(mouseX, mouseY, mouseButton);
fileList.func_148179_a(mouseX, mouseY, mouseButton);
fileList.select(textName.getText());
if(performAction.mousePressed(mc, mouseX, mouseY)) {
loadOnClose = true;
mc.displayGuiScreen(null);
mc.setIngameFocus();
}
}
@Override
protected void mouseMovedOrUp(int mouseX, int mouseY, int state) {
super.mouseMovedOrUp(mouseX, mouseY, state);
fileList.func_148181_b(mouseX, mouseY, state);
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
}
}

View File

@ -1,430 +0,0 @@
package com.hbm.blocks.generic;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Keyboard;
import com.hbm.blocks.IBlockSideRotation;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ModBlocks;
import com.hbm.interfaces.IControlReceiver;
import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toserver.NBTControlPacket;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.BufferUtil;
import com.hbm.util.i18n.I18nUtil;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.nbt.NBTStructure;
import com.hbm.world.gen.nbt.NBTStructure.JigsawConnection;
import com.hbm.world.gen.nbt.SpawnCondition;
import com.hbm.world.gen.nbt.JigsawPiece;
import com.hbm.world.gen.nbt.JigsawPool;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import net.minecraftforge.common.util.ForgeDirection;
/**
* You're familiar with Billy Mitchell, World Video Game Champion? He could probably do it.
* So I gotta find a way to harness his power. And I think I've found a way.
*
* THAT'S RIGHT, WE'RE GONNA CHEAT.
*
* NBTStructures have the inherent flaws of the vanilla structure system: Structures are composed
* before terrain gen even kicks in, placement order of components are arbitrary and certain
* connected parts will fall apart due to unexpected variance in the terrain. Not good.
* The solution: Simply delay generation of parts using a tile entity that checks if the chunks
* in front of it are loaded, and then places a random part from the chosen pool. When this happens,
* the player is usually still far far away so they'll be none the wiser. Chunk load checks help
* prevent forced chunk loading and all the lag that comes with that.
*
* The system is named after tandem shaped charges: Make a hole with the first charge, then deliver
* the actual payload.
*
* @author hbm, Mellow
*/
public class BlockWandTandem extends BlockContainer implements IBlockSideRotation, INBTBlockTransformable, IGUIProvider, ILookOverlay {
private IIcon iconTop;
private IIcon iconSide;
private IIcon iconBack;
public BlockWandTandem() {
super(Material.iron);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityWandTandem();
}
@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
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":wand_tandem");
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":wand_tandem_top");
this.iconSide = iconRegister.registerIcon(RefStrings.MODID + ":wand_tandem_side");
this.iconBack = iconRegister.registerIcon(RefStrings.MODID + ":wand_tandem_back");
}
@Override
public IIcon getIcon(int side, int meta) {
if(side == meta) return blockIcon;
if(IBlockSideRotation.isOpposite(side, meta)) return iconBack;
if(side <= 1) return iconTop;
if(side > 3 && meta <= 1) return iconTop;
return iconSide;
}
@Override
public int getRotationFromSide(IBlockAccess world, int x, int y, int z, int side) {
if(side == 0) return IBlockSideRotation.topToBottom(getRotationFromSide(world, x, y, z, 1));
int meta = world.getBlockMetadata(x, y, z);
if(side == meta || IBlockSideRotation.isOpposite(side, meta)) return 0;
// downwards facing has no changes, upwards flips anything not handled already
if(meta == 0) return 0;
if(meta == 1) return 3;
// top (and bottom) is rotated fairly normally
if(side == 1) {
switch(meta) {
case 2: return 3;
case 3: return 0;
case 4: return 1;
case 5: return 2;
}
}
// you know what I aint explaining further, it's a fucking mess here
if(meta == 2) return side == 4 ? 2 : 1;
if(meta == 3) return side == 4 ? 1 : 2;
if(meta == 4) return side == 2 ? 1 : 2;
if(meta == 5) return side == 2 ? 2 : 1;
return 0;
}
@Override
public int getRenderType() {
return IBlockSideRotation.getRenderType();
}
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTBlockTransformable.transformMetaDeco(meta, coordBaseMode);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandTandem)) return false;
TileEntityWandTandem jigsaw = (TileEntityWandTandem) te;
if(player.getHeldItem() != null && player.getHeldItem().getItem() == Items.paper) {
TileEntityWandTandem.copyMode = true;
if(!player.getHeldItem().hasTagCompound()) {
player.getHeldItem().stackTagCompound = new NBTTagCompound();
jigsaw.writeToNBT(player.getHeldItem().stackTagCompound);
} else {
jigsaw.readFromNBT(player.getHeldItem().stackTagCompound);
jigsaw.markDirty();
}
TileEntityWandTandem.copyMode = false;
return true;
}
if(!player.isSneaking()) {
Block block = ModBlocks.getBlockFromStack(player.getHeldItem());
if(block == ModBlocks.wand_air) block = Blocks.air;
if(block != null && !ModBlocks.isStructureBlock(block, false)) {
jigsaw.replaceBlock = block;
jigsaw.replaceMeta = player.getHeldItem().getItemDamage();
jigsaw.markDirty();
return true;
}
if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.wand_s) return false;
if(world.isRemote) FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
return true;
}
return false;
}
@Override
@SideOnly(Side.CLIENT)
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GuiWandTandem((TileEntityWandTandem) world.getTileEntity(x, y, z));
}
@Override
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandTandem)) return;
TileEntityWandTandem jigsaw = (TileEntityWandTandem) te;
List<String> text = new ArrayList<String>();
text.add(EnumChatFormatting.GRAY + "Target pool: " + EnumChatFormatting.RESET + jigsaw.pool);
text.add(EnumChatFormatting.GRAY + "Target name: " + EnumChatFormatting.RESET + jigsaw.target);
text.add(EnumChatFormatting.GRAY + "Turns into: " + EnumChatFormatting.RESET + GameRegistry.findUniqueIdentifierFor(jigsaw.replaceBlock).toString());
text.add(EnumChatFormatting.GRAY + " with meta: " + EnumChatFormatting.RESET + jigsaw.replaceMeta);
text.add(EnumChatFormatting.GRAY + "Joint type: " + EnumChatFormatting.RESET + (jigsaw.isRollable ? "Rollable" : "Aligned"));
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
public static class TileEntityWandTandem extends TileEntityLoadedBase implements IControlReceiver {
public static boolean copyMode = false;
private String pool = "default";
private String target = "default";
private Block replaceBlock = Blocks.air;
private int replaceMeta = 0;
private boolean isRollable = true; // sets joint type, rollable joints can be placed in any orientation for vertical jigsaw connections
private boolean isArmed = false;
private SpawnCondition structure;
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
tryGenerate();
networkPackNT(15);
}
}
private void tryGenerate() {
if(!this.isArmed || target == null || target.isEmpty() || pool == null || pool.isEmpty()) return;
JigsawPool pool = structure.getPool(this.pool);
if(pool == null) return;
JigsawPiece nextPiece = pool.get(worldObj.rand);
if(nextPiece == null) return;
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata());
List<JigsawConnection> connectionPool = nextPiece.structure.getConnectionPool(dir, target);
if(connectionPool == null) return;
JigsawConnection toConnection = connectionPool.get(worldObj.rand.nextInt(connectionPool.size()));
int nextCoordBase = directionOffsetToCoordBase(dir.getOpposite(), toConnection.dir);
BlockPos pos = new BlockPos(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
// offset the starting point to the connecting point
int ox = nextPiece.structure.rotateX(toConnection.pos.x, toConnection.pos.z, nextCoordBase);
int oy = toConnection.pos.y;
int oz = nextPiece.structure.rotateZ(toConnection.pos.x, toConnection.pos.z, nextCoordBase);
nextPiece.structure.build(worldObj, nextPiece, pos.getX() - ox, pos.getY() - oy, pos.getZ() - oz, nextCoordBase, structure.name);
worldObj.setBlock(xCoord, yCoord, zCoord, replaceBlock, replaceMeta, 2);
}
private int directionOffsetToCoordBase(ForgeDirection from, ForgeDirection to) {
for(int i = 0; i < 4; i++) {
if(from == to) return i % 4;
from = from.getRotation(ForgeDirection.DOWN);
}
return 0;
}
@Override
public void serialize(ByteBuf buf) {
BufferUtil.writeString(buf, pool);
BufferUtil.writeString(buf, target);
buf.writeInt(Block.getIdFromBlock(replaceBlock));
buf.writeInt(replaceMeta);
buf.writeBoolean(isRollable);
}
@Override
public void deserialize(ByteBuf buf) {
pool = BufferUtil.readString(buf);
target = BufferUtil.readString(buf);
replaceBlock = Block.getBlockById(buf.readInt());
replaceMeta = buf.readInt();
isRollable = buf.readBoolean();
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
if(!copyMode) {
super.writeToNBT(nbt);
nbt.setInteger("direction", this.getBlockMetadata());
if(isArmed) {
nbt.setBoolean("isArmed", isArmed);
nbt.setString("structure", structure.name);
}
}
nbt.setString("pool", pool);
nbt.setString("target", target);
nbt.setString("block", GameRegistry.findUniqueIdentifierFor(replaceBlock).toString());
nbt.setInteger("meta", replaceMeta);
nbt.setBoolean("roll", isRollable);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
if(!copyMode) {
super.readFromNBT(nbt);
isArmed = nbt.getBoolean("isArmed");
structure = NBTStructure.getStructure(nbt.getString("structure"));
}
pool = nbt.getString("pool");
target = nbt.getString("target");
replaceBlock = Block.getBlockFromName(nbt.getString("block"));
replaceMeta = nbt.getInteger("meta");
isRollable = nbt.getBoolean("roll");
}
@Override
public boolean hasPermission(EntityPlayer player) {
return true;
}
@Override
public void receiveControl(NBTTagCompound nbt) {
readFromNBT(nbt);
markDirty();
}
public void arm(SpawnCondition structure) {
isArmed = true;
this.structure = structure;
}
}
public static class GuiWandTandem extends GuiScreen {
private final TileEntityWandTandem jigsaw;
private GuiTextField textPool;
private GuiTextField textTarget;
private GuiButton jointToggle;
public GuiWandTandem(TileEntityWandTandem jigsaw) {
this.jigsaw = jigsaw;
}
@Override
public void initGui() {
Keyboard.enableRepeatEvents(true);
textPool = new GuiTextField(fontRendererObj, this.width / 2 - 150, 50, 300, 20);
textPool.setText(jigsaw.pool);
textTarget = new GuiTextField(fontRendererObj, this.width / 2 + 10, 100, 140, 20);
textTarget.setText(jigsaw.target);
jointToggle = new GuiButton(0, this.width / 2 + 60, 150, 90, 20, jigsaw.isRollable ? "Rollable" : "Aligned");
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
drawDefaultBackground();
drawString(fontRendererObj, "Target pool:", this.width / 2 - 150, 37, 0xA0A0A0);
textPool.drawTextBox();
drawString(fontRendererObj, "Target name:", this.width / 2 + 10, 87, 0xA0A0A0);
textTarget.drawTextBox();
drawString(fontRendererObj, "Joint type:", this.width / 2 + 60, 137, 0xA0A0A0);
jointToggle.drawButton(mc, mouseX, mouseY);
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
public void onGuiClosed() {
Keyboard.enableRepeatEvents(false);
NBTTagCompound data = new NBTTagCompound();
jigsaw.writeToNBT(data);
data.setString("pool", textPool.getText());
data.setString("target", textTarget.getText());
data.setBoolean("roll", jointToggle.displayString == "Rollable");
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, jigsaw.xCoord, jigsaw.yCoord, jigsaw.zCoord));
}
@Override
protected void keyTyped(char typedChar, int keyCode) {
super.keyTyped(typedChar, keyCode);
textPool.textboxKeyTyped(typedChar, keyCode);
textTarget.textboxKeyTyped(typedChar, keyCode);
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
textPool.mouseClicked(mouseX, mouseY, mouseButton);
textTarget.mouseClicked(mouseX, mouseY, mouseButton);
if(jointToggle.mousePressed(mc, mouseX, mouseY)) {
jointToggle.displayString = jointToggle.displayString == "Rollable" ? "Aligned" : "Rollable";
}
}
@Override public boolean doesGuiPauseGame() { return false; }
}
}

View File

@ -6,7 +6,7 @@ import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.tileentity.deco.TileEntityDecoBlock;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTransformable;
import api.hbm.block.IToolable;
import cpw.mods.fml.client.registry.RenderingRegistry;
@ -25,7 +25,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class DecoBlock extends BlockContainer implements IToolable, INBTBlockTransformable {
public class DecoBlock extends BlockContainer implements IToolable, INBTTransformable {
Random rand = new Random();
@ -185,6 +185,6 @@ public class DecoBlock extends BlockContainer implements IToolable, INBTBlockTra
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTBlockTransformable.transformMetaDeco(meta, coordBaseMode);
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
}
}

View File

@ -1,7 +1,7 @@
package com.hbm.blocks.generic;
import com.hbm.tileentity.deco.TileEntityDecoPoleSatelliteReceiver;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTransformable;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -11,7 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class DecoPoleSatelliteReceiver extends BlockContainer implements INBTBlockTransformable {
public class DecoPoleSatelliteReceiver extends BlockContainer implements INBTTransformable {
public DecoPoleSatelliteReceiver(Material p_i45386_1_) {
super(p_i45386_1_);
@ -61,7 +61,7 @@ public class DecoPoleSatelliteReceiver extends BlockContainer implements INBTBlo
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTBlockTransformable.transformMetaDeco(meta, coordBaseMode);
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
}
}

View File

@ -1,6 +1,6 @@
package com.hbm.blocks.generic;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.block.BlockContainer;
@ -11,7 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class DecoTapeRecorder extends BlockContainer implements INBTBlockTransformable {
public class DecoTapeRecorder extends BlockContainer implements INBTTransformable {
public DecoTapeRecorder(Material p_i45386_1_) {
super(p_i45386_1_);
@ -63,7 +63,7 @@ public class DecoTapeRecorder extends BlockContainer implements INBTBlockTransfo
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTBlockTransformable.transformMetaDeco(meta, coordBaseMode);
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
}
}

View File

@ -81,7 +81,6 @@ public class DungeonSpawner extends BlockContainer {
public static Function<TileEntityDungeonSpawner, Boolean> CON_ABERRATOR = (tile) -> {
World world = tile.getWorldObj();
if(world.difficultySetting.ordinal() == 0) return false;
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.zCoord;
@ -123,11 +122,7 @@ public class DungeonSpawner extends BlockContainer {
TileEntity te = world.getTileEntity(x, y + 18, z);
if(te instanceof TileEntitySkeletonHolder) {
TileEntitySkeletonHolder skeleton = (TileEntitySkeletonHolder) te;
if(world.rand.nextInt(5) == 0) {
skeleton.item = new ItemStack(ModItems.item_secret, 1, EnumSecretType.ABERRATOR.ordinal());
} else {
skeleton.item = new ItemStack(ModItems.clay_tablet, 1, 1);
}
skeleton.item = new ItemStack(ModItems.item_secret, 1, EnumSecretType.ABERRATOR.ordinal());
skeleton.markDirty();
world.markBlockForUpdate(x, y + 18, z);
}

View File

@ -1,162 +0,0 @@
package com.hbm.blocks.generic;
import com.hbm.world.gen.util.LogicBlockActions;
import com.hbm.world.gen.util.LogicBlockConditions;
import com.hbm.world.gen.util.LogicBlockInteractions;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.function.Consumer;
import java.util.function.Function;
public class LogicBlock extends BlockContainer {
public LogicBlock() {
super(Material.rock);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new LogicBlock.TileEntityLogicBlock();
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof LogicBlock.TileEntityLogicBlock){
LogicBlock.TileEntityLogicBlock logicBlock = (LogicBlock.TileEntityLogicBlock) tile;
if(logicBlock.disguise != null){
return logicBlock.disguise.getIcon(side, logicBlock.disguiseMeta);
}
}
return super.getIcon(world, x, y, z, side);
}
@Override
public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, float subY, float subZ) {
TileEntity te = worldIn.getTileEntity(x, y, z);
if(te instanceof LogicBlock.TileEntityLogicBlock && ((LogicBlock.TileEntityLogicBlock) te).interaction != null) {
((LogicBlock.TileEntityLogicBlock) te).interaction.accept(new Object[]{worldIn, te, x, y, z, player, side, subX, subY, subZ});
return true;
}
return super.onBlockActivated(worldIn, x, y, z, player, side, subX, subY, subZ);
}
public static class TileEntityLogicBlock extends TileEntity {
//phase is incremented per condition check, timer counts since last condition check by default
public int phase = 0;
public int timer = 0;
public Block disguise;
public int disguiseMeta;
/**Actions always get called before conditions, use the phase and timer variables in order to control behavior via conditions*/
public String conditionID = "PLAYER_CUBE_5";
public String actionID = "FODDER_WAVE";
/**Interactions are called on right click, and passes on the parameters of the right click to consumer*/
public String interactionID;
public Function<LogicBlock.TileEntityLogicBlock, Boolean> condition;
public Consumer<LogicBlock.TileEntityLogicBlock> action;
/**Consists of world instance, TileEntity instance, three ints for coordinates, one int for block side, and player instance, in that order **/
public Consumer<Object[]> interaction;
public EntityPlayer player;
public ForgeDirection direction = ForgeDirection.UNKNOWN;
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
if(action == null){
action = LogicBlockActions.actions.get(actionID);
}
if(condition == null){
condition = LogicBlockConditions.conditions.get(conditionID);
}
if(interaction == null && interactionID != null){
interaction = LogicBlockInteractions.interactions.get(interactionID);
}
if(action == null || condition == null){
worldObj.setBlock(xCoord,yCoord,zCoord, Blocks.air);
return;
}
action.accept(this);
if(condition.apply(this)) {
phase++;
timer = 0;
} else {
timer++;
}
}
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("phase", phase);
nbt.setString("actionID", actionID);
nbt.setString("conditionID", conditionID);
if(interactionID != null)
nbt.setString("interactionID", interactionID);
nbt.setInteger("direction", direction.ordinal());
if(disguise != null){
nbt.setInteger("disguiseMeta", disguiseMeta);
nbt.setString("disguise", GameRegistry.findUniqueIdentifierFor(disguise).toString());
}
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.phase = nbt.getInteger("phase");
this.actionID = nbt.getString("actionID");
this.conditionID = nbt.getString("conditionID");
if(nbt.hasKey("interactionID")) this.interactionID = nbt.getString("interactionID");
this.direction = ForgeDirection.getOrientation(nbt.getInteger("direction"));
if(nbt.hasKey("disguise")){
disguiseMeta = nbt.getInteger("disguiseMeta");
disguise = Block.getBlockFromName(nbt.getString("disguise"));
}
}
@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());
}
}
}

View File

@ -79,7 +79,7 @@ public class TritiumLamp extends Block implements ISpotlight {
private void updateBeam(World world, int x, int y, int z) {
if(!isOn) return;
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) Spotlight.propagateBeam(world, x, y, z, dir, getBeamLength(), getMeta());
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) Spotlight.propagateBeam(world, x, y, z, dir, getBeamLength());
}
@Override
@ -98,12 +98,6 @@ public class TritiumLamp extends Block implements ISpotlight {
return new ItemStack(getOff());
}
protected int getMeta() {
if(this == ModBlocks.lamp_tritium_green_off || this == ModBlocks.lamp_tritium_green_on) return Spotlight.META_GREEN;
if(this == ModBlocks.lamp_tritium_blue_off || this == ModBlocks.lamp_tritium_blue_on) return Spotlight.META_BLUE;
return Spotlight.META_YELLOW;
}
protected Block getOff() {
if(this == ModBlocks.lamp_tritium_green_on) return ModBlocks.lamp_tritium_green_off;
if(this == ModBlocks.lamp_tritium_blue_on) return ModBlocks.lamp_tritium_blue_off;

View File

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

View File

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

View File

@ -1,13 +0,0 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.generic.BlockToolConversion;
import net.minecraft.block.material.Material;
public class BlockFusionComponent extends BlockToolConversion {
public BlockFusionComponent() {
super(Material.iron);
this.addVariant(".bscco_welded", ".blanket", ".motor");
}
}

View File

@ -1,16 +0,0 @@
package com.hbm.blocks.machine;
import com.hbm.tileentity.machine.TileEntityFusionTorusStruct;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockFusionTorusStruct extends BlockContainer {
public BlockFusionTorusStruct(Material mat) { super(mat); }
@Override public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityFusionTorusStruct(); }
@Override public boolean isOpaqueCube() { return false; }
}

View File

@ -0,0 +1,25 @@
package com.hbm.blocks.machine;
import com.hbm.tileentity.machine.TileEntityITERStruct;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockITERStruct extends BlockContainer {
public BlockITERStruct(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityITERStruct();
}
@Override
public boolean isOpaqueCube() {
return false;
}
}

View File

@ -1,7 +1,7 @@
package com.hbm.blocks.machine;
import com.hbm.main.MainRegistry;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.Block;
@ -17,7 +17,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public abstract class BlockMachineBase extends BlockContainer implements INBTBlockTransformable {
public abstract class BlockMachineBase extends BlockContainer implements INBTTransformable {
int guiID = -1;
protected boolean rotatable = false;
@ -115,6 +115,6 @@ public abstract class BlockMachineBase extends BlockContainer implements INBTBlo
@Override
public int transformMeta(int meta, int coordBaseMode) {
if(!rotatable) return meta;
return INBTBlockTransformable.transformMetaDeco(meta, coordBaseMode);
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
}
}

View File

@ -33,7 +33,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
@ -41,8 +40,7 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
@SideOnly(Side.CLIENT) private IIcon[] iconTop;
@SideOnly(Side.CLIENT) private IIcon[] iconSide;
@SideOnly(Side.CLIENT) private IIcon[] iconFront;
public BlockMassStorage() {
super(Material.iron);
}
@ -52,23 +50,15 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
public void registerBlockIcons(IIconRegister iconRegister) {
this.iconTop = new IIcon[4];
this.iconSide = new IIcon[4];
this.iconFront = 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");
this.iconFront[0] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_front_iron");
this.iconTop[1] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top_desh");
this.iconSide[1] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side_desh");
this.iconFront[1] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_front_desh");
this.iconTop[2] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top");
this.iconSide[2] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side");
this.iconFront[2] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_front");
this.iconTop[3] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top_wood");
this.iconSide[3] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side_wood");
this.iconFront[3] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_front_wood");
}
@Override
@ -84,24 +74,20 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
int meta = this.rectify(metadata);
int dir = (metadata / getSubCount()) + 2;
if(side == 0 || side == 1) return iconTop[meta];
if(side == dir) return iconFront[meta];
return iconSide[meta];
return side == 1 ? this.iconTop[meta] : (side == 0 ? this.iconTop[meta] : this.iconSide[meta]);
}
@Override
public int damageDropped(int meta) {
return rectify(meta);
return meta;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityMassStorage(getCapacity(meta));
}
public int getCapacity(int meta) {
meta = rectify(meta);
return meta == 3 ? 100 : meta == 0 ? 10_000 : meta == 1 ? 100_000 : meta == 2 ? 1_000_000 : 0;
}
@ -122,129 +108,121 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
return false;
}
}
private static boolean dropInv = true;
@Override
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) {
ItemStack drop = new ItemStack(this, 1, rectify(world.getBlockMetadata(x, y, z)));
ItemStack drop = new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
ISidedInventory inv = (ISidedInventory)world.getTileEntity(x, y, z);
NBTTagCompound nbt = new NBTTagCompound();
if(inv != null) {
for(int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(stack == null)
continue;
NBTTagCompound slot = new NBTTagCompound();
stack.writeToNBT(slot);
nbt.setTag("slot" + i, slot);
}
}
if(inv instanceof TileEntityLockableBase) {
TileEntityLockableBase lockable = (TileEntityLockableBase) inv;
if(lockable.isLocked()) {
nbt.setInteger("lock", lockable.getPins());
nbt.setDouble("lockMod", lockable.getMod());
}
}
if(inv instanceof TileEntityMassStorage && nbt.func_150296_c().size() > 0) {
TileEntityMassStorage storage = (TileEntityMassStorage) inv;
nbt.setInteger("stack", storage.getStockpile());
}
if(!nbt.hasNoTags()) {
drop.stackTagCompound = nbt;
}
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop));
}
dropInv = false;
boolean flag = world.setBlockToAir(x, y, z);
dropInv = true;
return flag;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
ISidedInventory inv = (ISidedInventory)world.getTileEntity(x, y, z);
if(inv != null && stack.hasTagCompound()) {
for(int i = 0; i < inv.getSizeInventory(); i++) {
inv.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("slot" + i)));
}
if(inv instanceof TileEntityMassStorage) {
TileEntityMassStorage storage = (TileEntityMassStorage) inv;
if(stack.stackTagCompound.hasKey("lock")) {
storage.setPins(stack.stackTagCompound.getInteger("lock"));
storage.setMod(stack.stackTagCompound.getDouble("lockMod"));
storage.lock();
}
storage.setStockpile(stack.stackTagCompound.getInteger("stack"));
}
}
super.onBlockPlacedBy(world, x, y, z, player, stack);
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
int meta = stack.getItemDamage();
if(i == 0) world.setBlockMetadataWithNotify(x, y, z, meta, 2);
if(i == 1) world.setBlockMetadataWithNotify(x, y, z, meta + 3 * getSubCount(), 2);
if(i == 2) world.setBlockMetadataWithNotify(x, y, z, meta + 1 * getSubCount(), 2);
if(i == 3) world.setBlockMetadataWithNotify(x, y, z, meta + 2 * getSubCount(), 2);
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(dropInv) {
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 == 1) continue; //do NOT drop the filter item
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;
@ -253,7 +231,7 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
}
}
}
world.func_147453_f(x, y, z, block);
}
}
@ -273,51 +251,51 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityMassStorage))
return;
TileEntityMassStorage storage = (TileEntityMassStorage) te;
List<String> text = new ArrayList();
String title = "Empty";
boolean full = storage.type != null;
if(full) {
title = storage.type.getDisplayName();
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);
int color = ((int) (0xFF - 0xFF * percent)) << 16 | ((int)(0xFF * percent) << 8);
text.add("&[" + color + "&]" + (charge / 100D) + "%");
}
ILookOverlay.printGeneric(event, title, full ? 0xffff00 : 0x00ffff, full ? 0x404000 : 0x004040, text);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
if(!stack.hasTagCompound()) return;
ItemStack type = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("slot1"));
if(type != null) {
list.add(EnumChatFormatting.GOLD + type.getDisplayName());
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;

View File

@ -0,0 +1,52 @@
package com.hbm.blocks.machine;
import com.hbm.tileentity.machine.TileEntityPlasmaStruct;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class BlockPlasmaStruct extends BlockContainer {
public BlockPlasmaStruct(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityPlasmaStruct();
}
public boolean isOpaqueCube() {
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, 2, 2);
}
if(i == 1)
{
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(i == 2)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(i == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
}
}

View File

@ -1,7 +1,6 @@
package com.hbm.blocks.machine;
import com.hbm.tileentity.machine.TileEntityCharger;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -13,8 +12,8 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class Charger extends BlockContainer implements INBTBlockTransformable {
public class Charger extends BlockContainer {
public Charger(Material mat) {
super(mat);
}
@ -23,17 +22,17 @@ public class Charger extends BlockContainer implements INBTBlockTransformable {
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityCharger();
}
@Override
public int getRenderType(){
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
@ -41,9 +40,9 @@ public class Charger extends BlockContainer implements INBTBlockTransformable {
@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);
}
@ -61,13 +60,13 @@ public class Charger extends BlockContainer implements INBTBlockTransformable {
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
float f = 0.0625F;
switch(world.getBlockMetadata(x, y, z)) {
case 2: this.setBlockBounds(5 * f, 0.25F, 12 * f, 11 * f, 0.75F, 1F); break;
case 3: this.setBlockBounds(5 * f, 0.25F, 0F, 11 * f, 0.75F, 4 * f); break;
case 4: this.setBlockBounds(12 * f, 0.25F, 5 * f, 1F, 0.75F, 11 * f); break;
case 5: this.setBlockBounds(0F, 0.25F, 5 * f, 4 * f, 0.75F, 11 * f); break;
default: this.setBlockBounds(5 * f, 0.25F, 5 * f, 11 * f, 0.75F, 11 * f); break;
case 2: this.setBlockBounds(5 * f, 0.25F, 12 * f, 11 * f, 0.75F, 1F); break;
case 3: this.setBlockBounds(5 * f, 0.25F, 0F, 11 * f, 0.75F, 4 * f); break;
case 4: this.setBlockBounds(12 * f, 0.25F, 5 * f, 1F, 0.75F, 11 * f); break;
case 5: this.setBlockBounds(0F, 0.25F, 5 * f, 4 * f, 0.75F, 11 * f); break;
default: this.setBlockBounds(5 * f, 0.25F, 5 * f, 11 * f, 0.75F, 11 * f); break;
}
}
@ -76,9 +75,4 @@ public class Charger extends BlockContainer implements INBTBlockTransformable {
this.setBlockBoundsBasedOnState(world, x, y, z);
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
}
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTBlockTransformable.transformMetaDeco(meta, coordBaseMode);
}
}

View File

@ -1,18 +1,12 @@
package com.hbm.blocks.machine;
import java.util.Random;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityCore;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@ -56,43 +50,5 @@ public class CoreCore extends BlockContainer {
return false;
}
}
private Random rand = new Random();
// shitty copy pasted crap for the 50th time because i hate this block
@Override
public void breakBlock(World world, int x, int y, int z, Block b, int m) {
TileEntityCore core = (TileEntityCore) world.getTileEntity(x, y, z);
if(core != null) {
for(int i1 = 0; i1 < core.getSizeInventory(); ++i1) {
ItemStack itemstack = core.getStackInSlot(i1);
if(itemstack != null) {
float f = this.rand.nextFloat() * 0.8F + 0.1F;
float f1 = this.rand.nextFloat() * 0.8F + 0.1F;
float f2 = this.rand.nextFloat() * 0.8F + 0.1F;
while(itemstack.stackSize > 0) {
int j1 = this.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) this.rand.nextGaussian() * f3;
entityitem.motionY = (float) this.rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) this.rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, b);
}
super.breakBlock(world, x, y, z, b, m);
}
}

View File

@ -4,10 +4,10 @@ import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.FloodlightBeam.TileEntityFloodlightBeam;
import com.hbm.util.Compat;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.world.gen.nbt.INBTBlockTransformable;
import api.hbm.block.IToolable;
import api.hbm.energymk2.IEnergyReceiverMK2;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
@ -28,7 +28,7 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class Floodlight extends BlockContainer implements IToolable, INBTBlockTransformable {
public class Floodlight extends BlockContainer implements IToolable, INBTTransformable {
public Floodlight(Material mat) {
super(mat);

View File

@ -4,17 +4,11 @@ import java.util.ArrayList;
import java.util.List;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.material.NTMMaterial;
import com.hbm.inventory.material.Mats.MaterialStack;
import com.hbm.items.machine.ItemScraps;
import com.hbm.lib.Library;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityFoundryChannel;
import com.hbm.uninos.GenNode;
import com.hbm.uninos.INetworkProvider;
import com.hbm.uninos.networkproviders.FoundryNetwork;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.block.ICrucibleAcceptor;
import cpw.mods.fml.client.registry.RenderingRegistry;
@ -47,7 +41,7 @@ public class FoundryChannel extends BlockContainer implements ICrucibleAcceptor
public FoundryChannel() {
super(Material.rock);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
@ -71,16 +65,16 @@ public class FoundryChannel extends BlockContainer implements ICrucibleAcceptor
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB entityBounding, List list, Entity entity) {
List<AxisAlignedBB> bbs = new ArrayList();
bbs.add(AxisAlignedBB.getBoundingBox(x + 0.3125D, y, z + 0.3125D, x + 0.6875D, y + 0.5D, z + 0.6875D));
if(canConnectTo(world, x, y, z, Library.POS_X)) bbs.add(AxisAlignedBB.getBoundingBox(x + 0.6875D, y, z + 0.3125D, x + 1D, y + 0.5D, z + 0.6875D));
if(canConnectTo(world, x, y, z, Library.NEG_X)) bbs.add(AxisAlignedBB.getBoundingBox(x, y, z + 0.3125D, x + 0.3125D, y + 0.5D, z + 0.6875D));
if(canConnectTo(world, x, y, z, Library.POS_Z)) bbs.add(AxisAlignedBB.getBoundingBox(x + 0.3125D, y, z + 0.6875D, x + 0.6875D, y + 0.5D, z + 1D));
if(canConnectTo(world, x, y, z, Library.NEG_Z)) bbs.add(AxisAlignedBB.getBoundingBox(x + 0.3125D, y, z, x + 0.6875D, y + 0.5D, z + 0.3125D));
for(AxisAlignedBB bb : bbs) {
if(entityBounding.intersectsWith(bb)) {
list.add(bb);
@ -126,23 +120,23 @@ public class FoundryChannel extends BlockContainer implements ICrucibleAcceptor
public boolean canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack 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 ((ICrucibleAcceptor) world.getTileEntity(x, y, z)).flow(world, x, y, z, side, stack);
}
public boolean canConnectTo(IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
if(dir == ForgeDirection.UP || dir == ForgeDirection.DOWN || dir == ForgeDirection.UNKNOWN)
return false;
Block b = world.getBlock(x + dir.offsetX, y, z + dir.offsetZ);
int meta = world.getBlockMetadata(x + dir.offsetX, y, z + dir.offsetZ);
if((b == ModBlocks.foundry_outlet || b == ModBlocks.foundry_slagtap) && meta == dir.ordinal())
return true;
return b == ModBlocks.foundry_channel || b == ModBlocks.foundry_mold;
}
@ -152,25 +146,25 @@ public class FoundryChannel extends BlockContainer implements ICrucibleAcceptor
public int getRenderType() {
return renderID;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote) {
return true;
}
TileEntityFoundryChannel cast = (TileEntityFoundryChannel) world.getTileEntity(x, y, z);
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTool && ((ItemTool) player.getHeldItem().getItem()).getToolClasses(player.getHeldItem()).contains("shovel")) {
if(cast.amount > 0) {
ItemStack scrap = ItemScraps.create(new MaterialStack(cast.type, cast.amount));
@ -182,18 +176,19 @@ public class FoundryChannel extends BlockContainer implements ICrucibleAcceptor
}
cast.amount = 0;
cast.type = null;
cast.propagateMaterial(null);
cast.markDirty();
world.markBlockForUpdate(x, y, z);
}
return true;
}
return false;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block b, int i) {
TileEntityFoundryChannel channel = (TileEntityFoundryChannel) world.getTileEntity(x, y, z);
if(channel.amount > 0) {
ItemStack scrap = ItemScraps.create(new MaterialStack(channel.type, channel.amount));
@ -201,24 +196,7 @@ public class FoundryChannel extends BlockContainer implements ICrucibleAcceptor
world.spawnEntityInWorld(item);
channel.amount = 0;
}
super.breakBlock(world, x, y, z, b, i);
}
public static class FoundryNode extends GenNode<FoundryNetwork> {
public NTMMaterial type;
public FoundryNode(INetworkProvider<FoundryNetwork> provider, BlockPos... positions) {
super(provider, positions);
}
@Override
public FoundryNode setConnections(DirPos... connections) {
super.setConnections(connections);
return this;
}
}
}

View File

@ -0,0 +1,34 @@
package com.hbm.blocks.machine;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityMachineAmgen;
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.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class MachineAmgen extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon iconTop;
public MachineAmgen(Material p_i45386_1_) {
super(p_i45386_1_);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityMachineAmgen();
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":block_deprecated");
}
}

View File

@ -1,55 +0,0 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.BlockDummyable;
import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityMachineAnnihilator;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineAnnihilator extends BlockDummyable {
public MachineAnnihilator() {
super(Material.iron);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachineAnnihilator();
if(meta >= 6) return new TileEntityProxyCombo().inventory().fluid();
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
return standardOpenBehavior(world, x, y, z, player, side);
}
@Override public int[] getDimensions() { return new int[] {2, 0, 4, 4, 1, 1}; }
@Override public int getOffset() { return 4; }
@Override
protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) {
return super.checkRequirement(world, x, y, z, dir, o) &&
MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * (o - 3), y, z + dir.offsetZ * (o - 3), new int[] {8, -2, 1, 1, 1, 1}, x, y, z, dir);
}
@Override
public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
super.fillSpace(world, x, y, z, dir, o);
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * (o - 3), y, z + dir.offsetZ * (o - 3), new int[] {8, -2, 1, 1, 1, 1}, this, dir);
x += dir.offsetX * o;
z += dir.offsetZ * o;
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
this.makeExtra(world, x + dir.offsetX * 3 + rot.offsetX, y, z + dir.offsetZ * 3 + rot.offsetZ);
this.makeExtra(world, x + dir.offsetX * 3 - rot.offsetX, y, z + dir.offsetZ * 3 - rot.offsetZ);
this.makeExtra(world, x + dir.offsetX * 4, y, z + dir.offsetZ * 4);
}
}

View File

@ -0,0 +1,288 @@
package com.hbm.blocks.machine;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityMachineArcFurnace;
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.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.util.MathHelper;
import net.minecraft.world.World;
public class MachineArcFurnace extends BlockContainer {
private final Random field_149933_a = new Random();
private final boolean isActive;
private static boolean keepInventory;
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBottom;
@SideOnly(Side.CLIENT)
private IIcon iconRods;
public MachineArcFurnace(boolean blockState) {
super(Material.iron);
isActive = blockState;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.iconFront = iconRegister.registerIcon(RefStrings.MODID + (this.isActive ? ":machine_arc_furnace_front_on" : ":machine_arc_furnace_front_off"));
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + (this.isActive ? ":machine_arc_furnace_top_on" : ":machine_arc_furnace_top"));
this.iconBottom = iconRegister.registerIcon(RefStrings.MODID + ":machine_arc_furnace_bottom");
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":machine_arc_furnace_side");
this.iconRods = iconRegister.registerIcon(RefStrings.MODID + ":machine_arc_furnace_top_rods");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
if(this == ModBlocks.machine_arc_furnace_off) {
if(side == 1 && metadata > 5) {
return iconRods;
}
}
if(metadata > 5)
metadata -= 4;
if(side == 0)
return this.iconBottom;
if(side == 1)
return this.iconTop;
return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon);
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return Item.getItemFromBlock(ModBlocks.machine_arc_furnace_off);
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
}
private void setDefaultDirection(World world, int x, int y, int z) {
if(!world.isRemote)
{
Block block1 = world.getBlock(x, y, z - 1);
Block block2 = world.getBlock(x, y, z + 1);
Block block3 = world.getBlock(x - 1, y, z);
Block block4 = world.getBlock(x + 1, y, z);
byte b0 = 3;
if(block1.func_149730_j() && !block2.func_149730_j())
{
b0 = 3;
}
if(block2.func_149730_j() && !block1.func_149730_j())
{
b0 = 2;
}
if(block3.func_149730_j() && !block4.func_149730_j())
{
b0 = 5;
}
if(block4.func_149730_j() && !block3.func_149730_j())
{
b0 = 4;
}
world.setBlockMetadataWithNotify(x, y, z, b0, 2);
}
}
@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);
}
if(itemStack.hasDisplayName())
{
((TileEntityMachineArcFurnace)world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
}
}
@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())
{
TileEntityMachineArcFurnace entity = (TileEntityMachineArcFurnace) world.getTileEntity(x, y, z);
if(entity != null)
{
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
}
return true;
} else {
return false;
}
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityMachineArcFurnace();
}
public static void updateBlockState(boolean isProcessing, World world, int x, int y, int z) {
int i = world.getBlockMetadata(x, y, z);
TileEntity entity = world.getTileEntity(x, y, z);
keepInventory = true;
if(isProcessing)
{
world.setBlock(x, y, z, ModBlocks.machine_arc_furnace_on);
}else{
world.setBlock(x, y, z, ModBlocks.machine_arc_furnace_off);
}
keepInventory = false;
world.setBlockMetadataWithNotify(x, y, z, i, 2);
if(entity != null) {
entity.validate();
world.setTileEntity(x, y, z, entity);
}
}
@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)
{
TileEntityMachineArcFurnace tileentityfurnace = (TileEntityMachineArcFurnace)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if (tileentityfurnace != null)
{
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
{
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
if (itemstack != null)
{
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0)
{
int j1 = this.field_149933_a.nextInt(21) + 10;
if (j1 > itemstack.stackSize)
{
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (float)this.field_149933_a.nextGaussian() * f3;
entityitem.motionY = (float)this.field_149933_a.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)this.field_149933_a.nextGaussian() * f3;
p_149749_1_.spawnEntityInWorld(entityitem);
}
}
}
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
}
}
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World p_149734_1_, int x, int y, int z, Random rand)
{
if (isActive)
{
int l = p_149734_1_.getBlockMetadata(x, y, z);
float f = x + 0.5F;
float f1 = y + 0.0F + rand.nextFloat() * 6.0F / 16.0F;
float f2 = z + 0.5F;
float f3 = 0.52F;
float f4 = rand.nextFloat() * 0.6F - 0.3F;
if (l == 4)
{
p_149734_1_.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
p_149734_1_.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
}
else if (l == 5)
{
p_149734_1_.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
p_149734_1_.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
}
else if (l == 2)
{
p_149734_1_.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
p_149734_1_.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
}
else if (l == 3)
{
p_149734_1_.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
p_149734_1_.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
}
}
}
@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.machine_arc_furnace_off);
}
}

View File

@ -11,7 +11,6 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@Deprecated
public class MachineAssembler extends BlockDummyable {
public MachineAssembler(Material p_i45386_1_) {

View File

@ -1,88 +0,0 @@
package com.hbm.blocks.machine;
import java.util.ArrayList;
import java.util.List;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.tileentity.TileEntityProxyDyn;
import com.hbm.tileentity.machine.TileEntityMachineAssemblyFactory;
import com.hbm.util.fauxpointtwelve.DirPos;
import com.hbm.util.i18n.I18nUtil;
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.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineAssemblyFactory extends BlockDummyable implements ITooltipProvider, ILookOverlay {
public MachineAssemblyFactory(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachineAssemblyFactory();
if(meta >= 6) return new TileEntityProxyDyn().inventory().power().fluid();
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
return this.standardOpenBehavior(world, x, y, z, player, 0);
}
@Override public int[] getDimensions() { return new int[] {2, 0, 2, 2, 2, 2}; }
@Override public int getOffset() { return 2; }
@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 * 2;
z -= dir.offsetZ * 2;
for(int i = -2; i <= 2; i++) for(int j = -2; j <= 2; j++) {
if(Math.abs(i) == 2 || Math.abs(j) == 2) this.makeExtra(world, x + i, y, z + j);
}
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
for(int i = -2; i <= 2; i++) {
this.makeExtra(world, x + dir.offsetX * i + rot.offsetX * 2, y + 2, z + dir.offsetZ * i + rot.offsetZ * 2);
this.makeExtra(world, x + dir.offsetX * i - rot.offsetX * 2, y + 2, z + dir.offsetZ * i - rot.offsetZ * 2);
}
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
this.addStandardInfo(stack, player, list, ext);
}
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null) return;
TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]);
if(!(te instanceof TileEntityMachineAssemblyFactory)) return;
TileEntityMachineAssemblyFactory assemfac = (TileEntityMachineAssemblyFactory) te;
DirPos[] cool = assemfac.getCoolPos();
for(DirPos dirPos : cool) if(dirPos.compare(x + dirPos.getDir().offsetX, y, z + dirPos.getDir().offsetZ)) {
List<String> text = new ArrayList();
text.add(EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + assemfac.water.getTankType().getLocalizedName());
text.add(EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + assemfac.lps.getTankType().getLocalizedName());
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
break;
}
}
}

View File

@ -1,45 +0,0 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.BlockDummyable;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityMachineAssemblyMachine;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineAssemblyMachine extends BlockDummyable {
public MachineAssemblyMachine(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachineAssemblyMachine();
if(meta >= 6) return new TileEntityProxyCombo().inventory().power().fluid();
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
return this.standardOpenBehavior(world, x, y, z, player, 0);
}
@Override public int[] getDimensions() { return new int[] {2, 0, 1, 1, 1, 1}; }
@Override public int getOffset() { return 1; }
@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;
for(int i = -1; i <= 1; i++) for(int j = -1; j <= 1; j++) {
if(i != 0 || j != 0) this.makeExtra(world, x + i, y, z + j);
}
}
}

View File

@ -10,7 +10,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@Deprecated
public class MachineAssemfac extends BlockDummyable {
public MachineAssemfac(Material mat) {

View File

@ -3,12 +3,6 @@ package com.hbm.blocks.machine;
import java.util.ArrayList;
import java.util.List;
import com.hbm.handler.CompatHandler;
import cpw.mods.fml.common.Optional;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import li.cil.oc.api.network.SimpleComponent;
import org.lwjgl.input.Keyboard;
import com.hbm.blocks.ILookOverlay;
@ -155,15 +149,13 @@ public class MachineCapacitor extends BlockContainer implements ILookOverlay, IP
player.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1);
player.addExhaustion(0.025F);
}
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public static class TileEntityCapacitor extends TileEntityLoadedBase implements IEnergyProviderMK2, IEnergyReceiverMK2, IPersistentNBT, IRORValueProvider, SimpleComponent, CompatHandler.OCComponent {
public static class TileEntityCapacitor extends TileEntityLoadedBase implements IEnergyProviderMK2, IEnergyReceiverMK2, IPersistentNBT, IRORValueProvider {
public long power;
protected long maxPower;
public long powerReceived;
public long powerSent;
public long lastPowerReceived;
public long lastPowerSent;
public TileEntityCapacitor() { }
@ -206,8 +198,6 @@ public class MachineCapacitor extends BlockContainer implements ILookOverlay, IP
networkPackNT(15);
this.lastPowerSent = powerSent;
this.lastPowerReceived = powerReceived;
this.powerSent = 0;
this.powerReceived = 0;
}
@ -325,69 +315,5 @@ public class MachineCapacitor extends BlockContainer implements ILookOverlay, IP
if((PREFIX_VALUE + "fillpercent").equals(name)) return "" + this.power * 100 / this.maxPower;
return null;
}
// opencomputer
@Override
@Optional.Method(modid = "OpenComputers")
public String getComponentName() {
return "capacitor";
}
@Callback(direct = true)
@Optional.Method(modid = "OpenComputers")
public Object[] getEnergy(Context context, Arguments args) {
return new Object[] {power};
}
@Callback(direct = true)
@Optional.Method(modid = "OpenComputers")
public Object[] getMaxEnergy(Context context, Arguments args) {
return new Object[] {maxPower};
}
@Callback(direct = true)
@Optional.Method(modid = "OpenComputers")
public Object[] getEnergySent(Context context, Arguments args) {
return new Object[] {lastPowerReceived};
}
@Callback(direct = true)
@Optional.Method(modid = "OpenComputers")
public Object[] getEnergyReceived(Context context, Arguments args) { return new Object[] {lastPowerSent}; }
@Callback(direct = true)
@Optional.Method(modid = "OpenComputers")
public Object[] getInfo(Context context, Arguments args) {
return new Object[] {power, maxPower, lastPowerReceived, lastPowerSent};
}
@Override
@Optional.Method(modid = "OpenComputers")
public String[] methods() {
return new String[] {
"getEnergy",
"getMaxEnergy",
"getEnergySent",
"getEnergyReceived",
"getInfo"
};
}
@Override
@Optional.Method(modid = "OpenComputers")
public Object[] invoke(String method, Context context, Arguments args) throws Exception {
switch(method) {
case ("getEnergy"):
return getEnergy(context, args);
case ("getMaxEnergy"):
return getMaxEnergy(context, args);
case ("getEnergySent"):
return getEnergySent(context, args);
case ("getEnergyReceived"):
return getEnergyReceived(context, args);
case ("getInfo"):
return getEnergyReceived(context, args);
}
throw new NoSuchMethodException();
}
}
}

View File

@ -10,7 +10,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@Deprecated
public class MachineChemfac extends BlockDummyable {
public MachineChemfac(Material mat) {

View File

@ -1,88 +0,0 @@
package com.hbm.blocks.machine;
import java.util.ArrayList;
import java.util.List;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.tileentity.TileEntityProxyDyn;
import com.hbm.tileentity.machine.TileEntityMachineChemicalFactory;
import com.hbm.util.fauxpointtwelve.DirPos;
import com.hbm.util.i18n.I18nUtil;
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.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineChemicalFactory extends BlockDummyable implements ITooltipProvider, ILookOverlay {
public MachineChemicalFactory(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachineChemicalFactory();
if(meta >= 6) return new TileEntityProxyDyn().inventory().power().fluid();
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
return this.standardOpenBehavior(world, x, y, z, player, 0);
}
@Override public int[] getDimensions() { return new int[] {2, 0, 2, 2, 2, 2}; }
@Override public int getOffset() { return 2; }
@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 * 2;
z -= dir.offsetZ * 2;
for(int i = -2; i <= 2; i++) for(int j = -2; j <= 2; j++) {
if(Math.abs(i) == 2 || Math.abs(j) == 2) this.makeExtra(world, x + i, y, z + j);
}
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
for(int i = -2; i <= 2; i++) {
this.makeExtra(world, x + dir.offsetX * i + rot.offsetX * 2, y + 2, z + dir.offsetZ * i + rot.offsetZ * 2);
this.makeExtra(world, x + dir.offsetX * i - rot.offsetX * 2, y + 2, z + dir.offsetZ * i - rot.offsetZ * 2);
}
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
this.addStandardInfo(stack, player, list, ext);
}
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null) return;
TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]);
if(!(te instanceof TileEntityMachineChemicalFactory)) return;
TileEntityMachineChemicalFactory chemfac = (TileEntityMachineChemicalFactory) te;
DirPos[] cool = chemfac.getCoolPos();
for(DirPos dirPos : cool) if(dirPos.compare(x + dirPos.getDir().offsetX, y, z + dirPos.getDir().offsetZ)) {
List<String> text = new ArrayList();
text.add(EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + chemfac.water.getTankType().getLocalizedName());
text.add(EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + chemfac.lps.getTankType().getLocalizedName());
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
break;
}
}
}

View File

@ -1,7 +1,6 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.BlockDummyable;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityMachineChemicalPlant;
import net.minecraft.block.material.Material;
@ -19,7 +18,6 @@ public class MachineChemicalPlant extends BlockDummyable {
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachineChemicalPlant();
if(meta >= 6) return new TileEntityProxyCombo().inventory().power().fluid();
return null;
}

View File

@ -5,7 +5,6 @@ import java.util.List;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ICustomBlockHighlight;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.inventory.material.Mats.MaterialStack;
import com.hbm.items.machine.ItemScraps;
import com.hbm.main.MainRegistry;
@ -28,7 +27,7 @@ import net.minecraft.world.World;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineCrucible extends BlockDummyable implements ICrucibleAcceptor, ITooltipProvider {
public class MachineCrucible extends BlockDummyable implements ICrucibleAcceptor {
public MachineCrucible() {
super(Material.rock);
@ -182,9 +181,4 @@ public class MachineCrucible extends BlockDummyable implements ICrucibleAcceptor
@Override public boolean canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { return false; }
@Override public MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, MaterialStack stack) { return null; }
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
this.addStandardInfo(stack, player, list, ext);
}
}

View File

@ -1,80 +1,129 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.BlockDummyable;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityMachineEPress;
import java.util.Random;
import api.hbm.block.IToolable;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityMachineEPress;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
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 MachineEPress extends BlockDummyable implements IToolable {
public class MachineEPress extends BlockContainer implements INBTTransformable {
public MachineEPress(Material mat) {
super(mat);
private final Random field_149933_a = new Random();
private static boolean keepInventory;
public MachineEPress(Material p_i45386_1_) {
super(p_i45386_1_);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachineEPress();
if(meta >= 6) return new TileEntityProxyCombo(true, false, false);
return null;
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityMachineEPress();
}
@Override
public int[] getDimensions() {
return new int[] {2, 0, 0, 0, 0, 0};
public int getRenderType() {
return -1;
}
@Override
public int getOffset() {
return 0;
public boolean isOpaqueCube() {
return false;
}
@Override
protected boolean isLegacyMonoblock(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
return te != null && te instanceof TileEntityMachineEPress;
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) {
if(!keepInventory) {
ISidedInventory tileentityfurnace = (ISidedInventory) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if(tileentityfurnace != null) {
for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
if(itemstack != null) {
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
while(itemstack.stackSize > 0) {
int j1 = this.field_149933_a.nextInt(21) + 10;
if(j1 > itemstack.stackSize) {
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
if(itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (float) this.field_149933_a.nextGaussian() * f3;
entityitem.motionY = (float) this.field_149933_a.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) this.field_149933_a.nextGaussian() * f3;
p_149749_1_.spawnEntityInWorld(entityitem);
}
}
}
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
}
}
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
super.onBlockPlacedBy(world, x, y, z, player, 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);
if(itemStack.hasDisplayName()) {
int[] pos = this.findCore(world, x, y, z);
if(pos != null) {
TileEntityMachineEPress entity = (TileEntityMachineEPress) world.getTileEntity(pos[0], pos[1], pos[2]);
if(entity != null) {
entity.setCustomName(itemStack.getDisplayName());
}
}
((TileEntityMachineEPress) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
}
}
@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);
if(world.isRemote) {
return true;
} else if(!player.isSneaking()) {
TileEntityMachineEPress entity = (TileEntityMachineEPress) world.getTileEntity(x, y, z);
if(entity != null) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
}
return true;
} else {
return false;
}
}
// Un-multiblickable with a hand drill for schenanigans
@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.HAND_DRILL)
return false;
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 12)
return false;
safeRem = true;
world.setBlockToAir(x, y, z);
safeRem = false;
return true;
public int transformMeta(int meta, int coordBaseMode) {
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
}
}

View File

@ -35,7 +35,7 @@ public class MachineElectrolyser extends BlockDummyable {
@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, -1);
return this.standardOpenBehavior(world, x, y, z, player, 0);
}
@Override

View File

@ -6,12 +6,13 @@ import java.util.List;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.IPersistentInfoProvider;
import com.hbm.tileentity.IPersistentNBT;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.storage.TileEntityMachineBattery;
import com.hbm.tileentity.machine.storage.TileEntityMachineFENSU;
import com.hbm.util.BobMathUtil;
import com.hbm.util.i18n.I18nUtil;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -29,21 +30,43 @@ public class MachineFENSU extends BlockDummyable implements ILookOverlay, IPersi
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachineFENSU();
if(meta >= 12)
return new TileEntityMachineFENSU();
return null;
}
@Override public int[] getDimensions() { return new int[] {4, 0, 1, 1, 2, 2}; }
@Override public int getOffset() { return 1; }
@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);
public int[] getDimensions() {
return new int[] {4, 0, 1, 1, 2, 2};
}
@Override
public int getOffset() {
return 1;
}
@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);
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())
{
int[] pos = this.findCore(world, x, y, z);
if(pos == null)
return false;
TileEntityMachineFENSU entity = (TileEntityMachineFENSU) world.getTileEntity(pos[0], pos[1], pos[2]);
if(entity != null)
{
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, pos[0], pos[1], pos[2]);
}
return true;
} else {
return false;
}
}
@Override

View File

@ -116,7 +116,7 @@ public class MachineFan extends BlockContainer implements IToolable, ITooltipPro
double coeff = push;
if(falloff) {
if(!falloff) {
double dist = e.getDistance(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
coeff *= 1.5 * (1 - dist / range / 2);
}

View File

@ -1,14 +1,21 @@
package com.hbm.blocks.machine;
import java.util.Random;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.material.Mats;
import com.hbm.items.ModItems;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityITER;
import com.hbm.tileentity.machine.TileEntityITERStruct;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
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;
@ -18,7 +25,6 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@Deprecated
public class MachineITER extends BlockDummyable {
public MachineITER() {
@ -37,6 +43,11 @@ public class MachineITER extends BlockDummyable {
return null;
}
@Override
public Item getItemDropped(int i, Random rand, int j) {
return null;
}
@Override
public int[] getDimensions() {
//because we'll implement our own gnarly behavior here
@ -227,5 +238,28 @@ public class MachineITER extends BlockDummyable {
public int getOffset() {
return 7;
}
public static boolean drop = true;
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int i) {
if(i >= 12 && drop) {
for(int l = 0; l < 4; l++) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.fusion_conductor, 64)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.plate_cast, 64, Mats.MAT_STEEL.id)));
}
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.fusion_conductor, 36)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.plate_cast, 36, Mats.MAT_STEEL.id)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.fusion_center, 64)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.fusion_motor, 4)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.reinforced_glass, 8)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.struct_iter_core, 1)));
}
super.breakBlock(world, x, y, z, block, i);
}
}

View File

@ -1,54 +0,0 @@
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.TileEntityMachinePUREX;
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;
import net.minecraftforge.common.util.ForgeDirection;
public class MachinePUREX extends BlockDummyable implements ITooltipProvider {
public MachinePUREX(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachinePUREX();
if(meta >= 6) return new TileEntityProxyCombo().inventory().power().fluid();
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
return this.standardOpenBehavior(world, x, y, z, player, 0);
}
@Override public int[] getDimensions() { return new int[] {4, 0, 2, 2, 2, 2}; }
@Override public int getOffset() { return 2; }
@Override
public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
super.fillSpace(world, x, y, z, dir, o);
x += dir.offsetX * o;
z += dir.offsetZ * o;
for(int i = -2; i <= 2; i++) for(int j = -2; j <= 2; j++) {
if(Math.abs(i) == 2 || Math.abs(j) == 2) this.makeExtra(world, x + i, y, z + j);
}
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
this.addStandardInfo(stack, player, list, ext);
}
}

View File

@ -4,7 +4,6 @@ import com.hbm.blocks.ITooltipProvider;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.BlockPWR.TileEntityBlockPWR;
import com.hbm.handler.threading.PacketThreading;
import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.packet.toclient.AuxParticlePacketNT;
@ -81,7 +80,6 @@ public class MachinePWRController extends BlockContainer implements ITooltipProv
if(!controller.assembled) {
assemble(world, x, y, z, player);
} else {
if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.pwr_printer) return false;
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
}

View File

@ -1,19 +1,26 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityMachinePlasmaHeater;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.Random;
public class MachinePlasmaHeater extends BlockDummyable {
public MachinePlasmaHeater() {
@ -32,6 +39,11 @@ public class MachinePlasmaHeater extends BlockDummyable {
return null;
}
@Override
public Item getItemDropped(int i, Random rand, int j) {
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(world.isRemote)
@ -121,4 +133,19 @@ public class MachinePlasmaHeater extends BlockDummyable {
public int getOffset() {
return 1;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int i) {
if(i >= 12) {
for(int l = 0; l < 2; l++)
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.fusion_heater, 64)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.fusion_heater, 7)));
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModBlocks.struct_plasma_core, 1)));
}
super.breakBlock(world, x, y, z, block, i);
}
}

View File

@ -1,20 +0,0 @@
package com.hbm.blocks.machine;
import com.hbm.tileentity.machine.TileEntityMachinePrecAss;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class MachinePrecAss extends MachineAssemblyMachine {
public MachinePrecAss(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachinePrecAss();
return super.createNewTileEntity(world, meta);
}
}

View File

@ -1,64 +1,105 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.BlockDummyable;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityMachinePress;
import java.util.Random;
import api.hbm.block.IToolable;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityMachinePress;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class MachinePress extends BlockDummyable implements IToolable {
public class MachinePress extends BlockContainer {
private final Random field_149933_a = new Random();
private static boolean keepInventory;
public MachinePress(Material mat) {
super(mat);
public MachinePress(Material p_i45386_1_) {
super(p_i45386_1_);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityMachinePress();
if(meta >= 6) return new TileEntityProxyCombo(true, false, false);
return null;
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityMachinePress();
}
@Override
public int[] getDimensions() {
return new int[] {2, 0, 0, 0, 0, 0};
public int getRenderType() {
return -1;
}
@Override
public int getOffset() {
return 0;
public boolean isOpaqueCube() {
return false;
}
@Override
protected boolean isLegacyMonoblock(World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
return te != null && te instanceof TileEntityMachinePress;
public boolean renderAsNormalBlock() {
return false;
}
@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) {
TileEntityMachinePress tileentityfurnace = (TileEntityMachinePress) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if(tileentityfurnace != null) {
for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
if(itemstack != null) {
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
while(itemstack.stackSize > 0) {
int j1 = this.field_149933_a.nextInt(21) + 10;
if(j1 > itemstack.stackSize) {
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
if(itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (float) this.field_149933_a.nextGaussian() * f3;
entityitem.motionY = (float) this.field_149933_a.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) this.field_149933_a.nextGaussian() * f3;
p_149749_1_.spawnEntityInWorld(entityitem);
}
}
}
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
}
}
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
return this.standardOpenBehavior(world, x, y, z, player, 0);
}
// Un-multiblickable with a hand drill for schenanigans
@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.HAND_DRILL)
if(world.isRemote) {
return true;
} else if(!player.isSneaking()) {
TileEntityMachinePress entity = (TileEntityMachinePress) world.getTileEntity(x, y, z);
if(entity != null) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
}
return true;
} else {
return false;
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 12)
return false;
safeRem = true;
world.setBlockToAir(x, y, z);
safeRem = false;
return true;
}
}
}

View File

@ -24,6 +24,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.EnumChatFormatting;
@ -86,11 +87,27 @@ public class MachineRefinery extends BlockDummyable implements IPersistentInfoPr
public int getOffset() {
return 1;
}
@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 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 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 void addInformation(ItemStack stack, NBTTagCompound persistentTag, EntityPlayer player, List list, boolean ext) {

View File

@ -1,22 +1,15 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ILookOverlay;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.TileEntityMachineRotaryFurnace;
import com.hbm.util.i18n.I18nUtil;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.List;
public class MachineRotaryFurnace extends BlockDummyable implements ILookOverlay {
public class MachineRotaryFurnace extends BlockDummyable {
public MachineRotaryFurnace(Material mat) {
super(mat);
@ -63,54 +56,4 @@ public class MachineRotaryFurnace extends BlockDummyable implements ILookOverla
//solid fuel
this.makeExtra(world, x + dir.offsetX + rot.offsetX, y, z + dir.offsetZ + rot.offsetZ);
}
@Override
public void printHook(RenderGameOverlayEvent.Pre event, World world, int x, int y, int z) {
int[] pos = this.findCore(world, x, y, z);
if(pos == null) return;
TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]);
if(!(te instanceof TileEntityMachineRotaryFurnace)) return;
TileEntityMachineRotaryFurnace furnace = (TileEntityMachineRotaryFurnace) te;
ForgeDirection dir = ForgeDirection.getOrientation(furnace.getBlockMetadata() - offset);
List<String> text = new ArrayList<>();
//steam
if(hitCheck(dir, pos[0], pos[1], pos[2], -1, -1, 0, x, y, z) || hitCheck(dir, pos[0], pos[1], pos[2], -1, -2, 0, x, y, z)) {
text.add(EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + furnace.tanks[1].getTankType().getLocalizedName());
text.add(EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + furnace.tanks[2].getTankType().getLocalizedName());
}
//fluids
if(hitCheck(dir, pos[0], pos[1], pos[2], 1, 2, 0, x, y, z) || hitCheck(dir, pos[0], pos[1], pos[2], -1, 2, 0, x, y, z)) {
text.add(EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + furnace.tanks[0].getTankType().getLocalizedName());
}
if(hitCheck(dir, pos[0], pos[1], pos[2], 1, 1, 0, x, y, z)) {
text.add(EnumChatFormatting.YELLOW + "-> " + EnumChatFormatting.RESET + "Fuel");
}
if(!text.isEmpty()) {
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
}
protected boolean hitCheck(ForgeDirection dir, int coreX, int coreY, int coreZ, int exDir, int exRot, int exY, int hitX, int hitY, int hitZ) {
ForgeDirection turn = dir.getRotation(ForgeDirection.DOWN);
int iX = coreX + dir.offsetX * exDir + turn.offsetX * exRot;
int iY = coreY + exY;
int iZ = coreZ + dir.offsetZ * exDir + turn.offsetZ * exRot;
return iX == hitX && iZ == hitZ && iY == hitY;
}
}

View File

@ -0,0 +1,133 @@
package com.hbm.blocks.machine;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityMachineSchrabidiumTransmutator;
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.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.IIcon;
import net.minecraft.world.World;
import java.util.Random;
public class MachineSchrabidiumTransmutator extends BlockContainer {
private final Random field_149933_a = new Random();
private static boolean keepInventory;
@SideOnly(Side.CLIENT)
//private IIcon iconFront;
private IIcon iconTop;
private IIcon iconBottom;
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + (":transmutator_top"));
this.iconBottom = iconRegister.registerIcon(RefStrings.MODID + (":transmutator_bottom"));
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":transmutator_side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return side == 1 ? this.iconTop : (side == 0 ? this.iconBottom : this.blockIcon);
}
public MachineSchrabidiumTransmutator(Material p_i45386_1_) {
super(p_i45386_1_);
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return Item.getItemFromBlock(ModBlocks.machine_schrabidium_transmutator);
}
@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())
{
TileEntityMachineSchrabidiumTransmutator entity = (TileEntityMachineSchrabidiumTransmutator) world.getTileEntity(x, y, z);
if(entity != null)
{
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
}
return true;
} else {
return false;
}
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityMachineSchrabidiumTransmutator();
}
@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)
{
TileEntityMachineSchrabidiumTransmutator tileentityfurnace = (TileEntityMachineSchrabidiumTransmutator)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if (tileentityfurnace != null)
{
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
{
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
if (itemstack != null)
{
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0)
{
int j1 = this.field_149933_a.nextInt(21) + 10;
if (j1 > itemstack.stackSize)
{
j1 = itemstack.stackSize;
}
itemstack.stackSize -= j1;
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (float)this.field_149933_a.nextGaussian() * f3;
entityitem.motionY = (float)this.field_149933_a.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)this.field_149933_a.nextGaussian() * f3;
p_149749_1_.spawnEntityInWorld(entityitem);
}
}
}
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
}
}
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
}

View File

@ -26,8 +26,12 @@ public class MachineSolarBoiler extends BlockDummyable implements ILookOverlay {
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntitySolarBoiler();
if(meta >= extra) return new TileEntityProxyCombo(false, false, true);
if(meta >= 12)
return new TileEntitySolarBoiler();
if(meta >= extra)
return new TileEntityProxyCombo(false, false, true);
return null;
}

View File

@ -2,31 +2,39 @@ package com.hbm.blocks.machine;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.TileEntityMachineTransformer;
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.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class MachineTransformer extends Block {
public class MachineTransformer extends BlockContainer {
long buffer;
int delay;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
public MachineTransformer(Material p_i45394_1_, long b, int d) {
super(p_i45394_1_);
buffer = b;
delay = d;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
if(this == ModBlocks.machine_transformer) {
if(this == ModBlocks.machine_transformer || this == ModBlocks.machine_transformer_20) {
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":machine_transformer_top_iron");
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":machine_transformer_iron");
}
if(this == ModBlocks.machine_transformer_dnt) {
if(this == ModBlocks.machine_transformer_dnt || this == ModBlocks.machine_transformer_dnt_20) {
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":machine_transformer_top");
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":machine_transformer");
}
@ -37,4 +45,9 @@ public class MachineTransformer extends Block {
public IIcon getIcon(int side, int metadata) {
return side == 1 ? this.iconTop : (side == 0 ? this.iconTop : this.blockIcon);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityMachineTransformer();
}
}

View File

@ -282,6 +282,8 @@ public class PistonInserter extends BlockContainerBase implements ITooltipProvid
if(this.slot != null) {
BufferUtil.writeNBT(buf, slot.stackTagCompound);
}
this.turnProgress = 2;
}
@Override

View File

@ -1,6 +1,7 @@
package com.hbm.blocks.machine;
import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemBattery;
import com.hbm.tileentity.machine.TileEntityRadiobox;
import net.minecraft.block.Block;
@ -46,17 +47,31 @@ public class Radiobox extends BlockContainer {
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);
if(i == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(i == 1)
{
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(i == 2)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(i == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
}
@Override
public 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()) {
} else if(!player.isSneaking())
{
TileEntityRadiobox box = (TileEntityRadiobox)world.getTileEntity(x, y, z);
if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.battery_spark && !box.infinite) {
@ -78,53 +93,78 @@ public class Radiobox extends BlockContainer {
return true;
} else {
//FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_radiobox, world, x, y, z);
//return true;
return false;
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) {
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
int te = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_);
float f = 0.0625F;
this.setBlockBounds(0.0F, 0.0F, 2 * f, 1.0F, 1.0F, 14 * f);
switch(te) {
float f = 0.0625F;
this.setBlockBounds(0.0F, 0.0F, 2*f, 1.0F, 1.0F, 14*f);
switch(te)
{
case 4:
case 8: this.setBlockBounds(11 * f, 1 * f, 4 * f, 16 * f, 15 * f, 12 * f); break;
case 8:
this.setBlockBounds(11*f, 1*f, 4*f, 16*f, 15*f, 12*f);
break;
case 2:
case 6: this.setBlockBounds(4 * f, 1 * f, 11 * f, 12 * f, 15 * f, 16 * f); break;
case 6:
this.setBlockBounds(4*f, 1*f, 11*f, 12*f, 15*f, 16*f);
break;
case 5:
case 9: this.setBlockBounds(0 * f, 1 * f, 4 * f, 5 * f, 15 * f, 12 * f); break;
case 9:
this.setBlockBounds(0*f, 1*f, 4*f, 5*f, 15*f, 12*f);
break;
case 3:
case 7: this.setBlockBounds(4 * f, 1 * f, 0 * f, 12 * f, 15 * f, 5 * f); break;
case 7:
this.setBlockBounds(4*f, 1*f, 0*f, 12*f, 15*f, 5*f);
break;
}
}
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
int te = world.getBlockMetadata(x, y, z);
float f = 0.0625F;
this.setBlockBounds(0.0F, 0.0F, 2 * f, 1.0F, 1.0F, 14 * f);
switch(te) {
float f = 0.0625F;
this.setBlockBounds(0.0F, 0.0F, 2*f, 1.0F, 1.0F, 14*f);
switch(te)
{
case 4:
case 8: this.setBlockBounds(11 * f, 1 * f, 4 * f, 16 * f, 15 * f, 12 * f); break;
case 8:
this.setBlockBounds(11*f, 1*f, 4*f, 16*f, 15*f, 12*f);
break;
case 2:
case 6: this.setBlockBounds(4 * f, 1 * f, 11 * f, 12 * f, 15 * f, 16 * f); break;
case 6:
this.setBlockBounds(4*f, 1*f, 11*f, 12*f, 15*f, 16*f);
break;
case 5:
case 9: this.setBlockBounds(0 * f, 1 * f, 4 * f, 5 * f, 15 * f, 12 * f); break;
case 9:
this.setBlockBounds(0*f, 1*f, 4*f, 5*f, 15*f, 12*f);
break;
case 3:
case 7: this.setBlockBounds(4 * f, 1 * f, 0 * f, 12 * f, 15 * f, 5 * f); break;
case 7:
this.setBlockBounds(4*f, 1*f, 0*f, 12*f, 15*f, 5*f);
break;
}
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
}
public void breakBlock(World world, int x, int y, int z, Block b, int m) {
public void breakBlock(World world, int x, int y, int z, Block b, int m) {
TileEntityRadiobox box = (TileEntityRadiobox)world.getTileEntity(x, y, z);
if(box.infinite) world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.battery_spark)));
super.breakBlock(world, x, y, z, b, m);
}
if(box.infinite) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, ItemBattery.getEmptyBattery(ModItems.battery_spark)));
}
super.breakBlock(world, x, y, z, b, m);
}
}

View File

@ -4,9 +4,9 @@ import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.world.World;
public class RailBooster extends RailGeneric {
public RailBooster(String tool, int harvestLevel) {
super(tool, harvestLevel);
public RailBooster() {
super();
this.setMaxSpeed(1.0F);
this.setFlexible(false);
}

View File

@ -17,20 +17,19 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class RailGeneric extends BlockRailBase implements ITooltipProvider {
@SideOnly(Side.CLIENT)
protected IIcon turnedIcon;
protected static final float baseSpeed = 0.4F;
protected float maxSpeed = 0.4F;
protected boolean slopable = true;
protected boolean flexible = true;
public RailGeneric(String tool, int harvestLevel) {
public RailGeneric() {
super(false);
setHarvestLevel(tool, harvestLevel);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
@ -41,16 +40,16 @@ public class RailGeneric extends BlockRailBase implements ITooltipProvider {
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister reg) {
super.registerBlockIcons(reg);
if(flexible)
this.turnedIcon = reg.registerIcon(this.getTextureName() + "_turned");
}
@Override
public float getRailMaxSpeed(World world, EntityMinecart cart, int y, int x, int z) {
return maxSpeed;
}
public RailGeneric setMaxSpeed(float speed) {
this.maxSpeed = speed;
return this;
@ -60,7 +59,7 @@ public class RailGeneric extends BlockRailBase implements ITooltipProvider {
public boolean isFlexibleRail(IBlockAccess world, int y, int x, int z) {
return !isPowered();
}
public RailGeneric setFlexible(boolean flexible) {
this.flexible = flexible;
return this;
@ -70,7 +69,7 @@ public class RailGeneric extends BlockRailBase implements ITooltipProvider {
public boolean canMakeSlopes(IBlockAccess world, int x, int y, int z) {
return true;
}
public RailGeneric setSlopable(boolean slopable) {
this.slopable = slopable;
return this;
@ -79,15 +78,15 @@ public class RailGeneric extends BlockRailBase implements ITooltipProvider {
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
float speed = this.maxSpeed / this.baseSpeed;
if(speed != 1F) {
list.add((speed > 1 ? EnumChatFormatting.BLUE : EnumChatFormatting.RED) + "Speed: " + ((int) (speed * 100)) + "%");
}
if(!flexible) {
list.add(EnumChatFormatting.RED + "Cannot be used for turns!");
}
if(!slopable) {
list.add(EnumChatFormatting.RED + "Cannot be used for slopes!");
}

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