Merge remote-tracking branch 'upstream/master' into Optimization

# Conflicts:
#	src/main/java/api/hbm/energymk2/IEnergyReceiverMK2.java
#	src/main/java/com/hbm/items/weapon/ItemAmmoArty.java
#	src/main/java/com/hbm/items/weapon/sedna/factory/ConfettiUtil.java
#	src/main/java/com/hbm/tileentity/machine/TileEntityMachineRotaryFurnace.java
This commit is contained in:
BallOfEnergy 2025-03-07 22:06:13 -06:00
commit 52b781ea9f
426 changed files with 26032 additions and 10573 deletions

View File

@ -12,6 +12,7 @@
* NTM Reloaded: https://github.com/TheOriginalGolem/Hbm-s-Nuclear-Tech-GIT/releases * NTM Reloaded: https://github.com/TheOriginalGolem/Hbm-s-Nuclear-Tech-GIT/releases
* NTM Extended Edition (Alcater): https://github.com/Alcatergit/Hbm-s-Nuclear-Tech-GIT/releases * NTM Extended Edition (Alcater): https://github.com/Alcatergit/Hbm-s-Nuclear-Tech-GIT/releases
* NTM WarFactory: https://github.com/MisterNorwood/Hbm-s-Nuclear-Tech-GIT/releases
For 1.18, try Martin's remake: https://codeberg.org/MartinTheDragon/Nuclear-Tech-Mod-Remake/releases For 1.18, try Martin's remake: https://codeberg.org/MartinTheDragon/Nuclear-Tech-Mod-Remake/releases

View File

@ -1,12 +1,29 @@
## Added
* `/ntmserver`
* Functions like `/ntmclient` but for common settings
* Can toggle `DAMAGE_COMPATIBILITY_MODE`, off by default, enables a more compatible (but slightly jankier) version of the bullet damage code
* `MINE_<xxx>_DAMAGE` can be used to adjust landmine damage
* `TAINT_TRAILS` now replaces the hardcore taint config option, making taint blocks more potent and the potion effect trail taint blocks
## Changed ## Changed
* Particle detectors now print an error for when the recipe could not be completed * Fat mines now use the standardized mini nuke code
* Removed "no ore dict data" line from tooltips with extended view enabled * Fat mines now have a base damage of exactly 100, being identical to demolition mini nukes
* Added a client config called `GUN_ANIMATION_SPEED` which allows the speed of gun animations to be changed * Fat mines now gib affected entities
* Mostly for debugging, since it only applies to the bus animation system, things like smoke trails and muzzle flashes are unaffected * IV bags now use `setHealth` operations instead of dealing damage, preventing health duplication by just avoiding the damage
* The settings tool can now copy and paste the "paint" from paintable cables and fluid ducts
* Changed the way taint works
* Instead of neon purple vines, taint is bow a greyish sludge
* Taint now actively replaces blocks instead of growing along them
* Taint is still limited in spread, however taint spread is lower underground, taint decays three times faster in intensity if the block is not exposed to air, making taint spread more along the surface
* Taint has a 25% chance of splashing down when replacing a block with no supports, causing structures to collapse and taint to spread faster
* Similar to soil sand, entities will sink in taint and get slowed down
* The sludge consumeth
* `enableGuns` config option now applies to SEDNA system guns, simply canceling all gun-related keybinds
* Cinnabar dust, if registered by another mod, can now be acidized into cinnabar using hydrogen peroxide
* Copper wires, like AA and gold, can now be welded into dense wires
## Fixed ## Fixed
* Fixed items being annihilated when shift clicking them into the particle source * Fixed animation error on the MAS-36
* Fixed packet optimization not allowing packets to be sent when the day night cycle is halted * Fixed drone docks, requester and provider crates not dropping their contents when broken
* Fixed particle detectors not always using power when they should * Fixed all missing texture errors that appear in the startup log
* Fixed rotary furnace voiding low pressure steam when dealing with input numbers not divisible by 100 * Potentially fixed a crash with mekanism during the recipe change phase
* Fixed state leak causing smoke from the right akimbo weapon to glow when the first one is fired

View File

@ -1,6 +1,6 @@
mod_version=1.0.27 mod_version=1.0.27
# Empty build number makes a release type # Empty build number makes a release type
mod_build_number=5230 mod_build_number=5257
credits=HbMinecraft,\ credits=HbMinecraft,\
\ rodolphito (explosion algorithms),\ \ rodolphito (explosion algorithms),\
@ -12,6 +12,7 @@ credits=HbMinecraft,\
\ MellowArpeggiation (new animation system, turbine sounds, sound fixes, industrial lights, better particle diodes),\ \ MellowArpeggiation (new animation system, turbine sounds, sound fixes, industrial lights, better particle diodes),\
\ Pheo (textures, various machines, models, weapons),\ \ Pheo (textures, various machines, models, weapons),\
\ Vær (gas centrifuges, better worldgen, ZIRNOX, CP-1 parts, starter guide, new cyclotron, weapon animations),\ \ Vær (gas centrifuges, better worldgen, ZIRNOX, CP-1 parts, starter guide, new cyclotron, weapon animations),\
\ UFFR (RTG pellets, guns, casings, euphemium capacitor, nucleartech.wiki),\
\ LePeep (coilgun model, BDCL QC),\ \ LePeep (coilgun model, BDCL QC),\
\ Adam29 (liquid petroleum, ethanol, electric furnace),\ \ Adam29 (liquid petroleum, ethanol, electric furnace),\
\ Pvndols (thorium fuel recipe, gas turbine),\ \ Pvndols (thorium fuel recipe, gas turbine),\
@ -33,7 +34,6 @@ credits=HbMinecraft,\
\ Maksymisio (polish localization)\ \ Maksymisio (polish localization)\
\ el3ctro4ndre (italian localization),\ \ el3ctro4ndre (italian localization),\
\ Pu-238 (Tom impact effects),\ \ Pu-238 (Tom impact effects),\
\ UFFR (RTG pellets, guns, casings, euphemium capacitor),\
\ Frooz (gun models),\ \ Frooz (gun models),\
\ VT-6/24 (models, textures),\ \ VT-6/24 (models, textures),\
\ Nos (models),\ \ Nos (models),\

View File

@ -2,6 +2,8 @@ package api.hbm.energymk2;
import com.hbm.handler.threading.PacketThreading; import com.hbm.handler.threading.PacketThreading;
import com.hbm.packet.toclient.AuxParticlePacketNT; import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.uninos.IGenProvider;
import com.hbm.uninos.networkproviders.PowerNetProvider;
import com.hbm.util.Compat; import com.hbm.util.Compat;
import api.hbm.energymk2.Nodespace.PowerNode; import api.hbm.energymk2.Nodespace.PowerNode;
@ -12,7 +14,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
/** If it sends energy, use this */ /** If it sends energy, use this */
public interface IEnergyProviderMK2 extends IEnergyHandlerMK2 { public interface IEnergyProviderMK2 extends IEnergyHandlerMK2, IGenProvider<PowerNetProvider> {
/** Uses up available power, default implementation has no sanity checking, make sure that the requested power is lequal to the current power */ /** Uses up available power, default implementation has no sanity checking, make sure that the requested power is lequal to the current power */
public default void usePower(long power) { public default void usePower(long power) {

View File

@ -3,6 +3,8 @@ package api.hbm.energymk2;
import com.hbm.handler.threading.PacketThreading; import com.hbm.handler.threading.PacketThreading;
import com.hbm.interfaces.NotableComments; import com.hbm.interfaces.NotableComments;
import com.hbm.packet.toclient.AuxParticlePacketNT; import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.uninos.IGenReceiver;
import com.hbm.uninos.networkproviders.PowerNetProvider;
import com.hbm.util.Compat; import com.hbm.util.Compat;
import api.hbm.energymk2.Nodespace.PowerNode; import api.hbm.energymk2.Nodespace.PowerNode;
@ -14,7 +16,7 @@ import net.minecraftforge.common.util.ForgeDirection;
/** If it receives energy, use this */ /** If it receives energy, use this */
@NotableComments @NotableComments
public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 { public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2, IGenReceiver<PowerNetProvider> {
public default long transferPower(long power) { public default long transferPower(long power) {
if(power + this.getPower() <= this.getMaxPower()) { if(power + this.getPower() <= this.getMaxPower()) {
@ -76,31 +78,6 @@ public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 {
} }
} }
/**
* Project MKUltra was an illegal human experiments program designed and undertaken by the U.S. Central Intelligence Agency (CIA)
* to develop procedures and identify drugs that could be used during interrogations to weaken people and force confessions through
* brainwashing and psychological torture. It began in 1953 and was halted in 1973. MKUltra used numerous methods to manipulate
* its subjects' mental states and brain functions, such as the covert administration of high doses of psychoactive drugs (especially LSD)
* and other chemicals without the subjects' consent, electroshocks, hypnosis, sensory deprivation, isolation, verbal and sexual
* abuse, and other forms of torture.
* MKUltra was preceded by Project Artichoke. It was organized through the CIA's Office of Scientific Intelligence and coordinated
* with the United States Army Biological Warfare Laboratories. The program engaged in illegal activities, including the
* use of U.S. and Canadian citizens as unwitting test subjects. MKUltra's scope was broad, with activities carried
* out under the guise of research at more than 80 institutions aside from the military, including colleges and universities,
* hospitals, prisons, and pharmaceutical companies. The CIA operated using front organizations, although some top officials at these
* institutions were aware of the CIA's involvement.
* MKUltra was revealed to the public in 1975 by the Church Committee of the United States Congress and Gerald Ford's United States
* President's Commission on CIA activities within the United States (the Rockefeller Commission). Investigative efforts were hampered
* by CIA Director Richard Helms's order that all MKUltra files be destroyed in 1973; the Church Committee and Rockefeller Commission
* investigations relied on the sworn testimony of direct participants and on the small number of documents that survived Helms's order.
* In 1977, a Freedom of Information Act request uncovered a cache of 20,000 documents relating to MKUltra, which led to Senate hearings.
* Some surviving information about MKUltra was declassified in 2001.
* */
public default ConnectionPriority getPriority() {
return ConnectionPriority.NORMAL;
}
/** More is better-er */
public enum ConnectionPriority { public enum ConnectionPriority {
LOWEST, LOWEST,
LOW, LOW,

View File

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

View File

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

View File

@ -0,0 +1,17 @@
package api.hbm.fluid;
import com.hbm.uninos.NodeNet;
public class FluidNet extends NodeNet { // yeah i don't feel like it, gonna do that shit tomorrow or sth
public long tracker = 0L;
protected static int timeout = 3_000;
@Override public void resetTrackers() { this.tracker = 0; }
@Override
public void update() {
}
}

View File

@ -0,0 +1,11 @@
package api.hbm.fluidmk2;
import com.hbm.uninos.NodeNet;
public class FluidNetMK2 extends NodeNet {
@Override
public void update() {
}
}

View File

@ -0,0 +1,19 @@
package api.hbm.fluidmk2;
import com.hbm.uninos.GenNode;
import com.hbm.uninos.INetworkProvider;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
public class FluidNode extends GenNode<FluidNetMK2> {
public FluidNode(INetworkProvider<FluidNetMK2> provider, BlockPos... positions) {
super(provider, positions);
}
@Override
public FluidNode setConnections(DirPos... connections) {
super.setConnections(connections);
return this;
}
}

View File

@ -0,0 +1,12 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
public interface IFluidConnectorBlockMK2 {
/** dir is the face that is connected to, the direction going outwards from the block */
public boolean canConnect(FluidType type, IBlockAccess world, int x, int y, int z, ForgeDirection dir);
}

View File

@ -0,0 +1,17 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
import net.minecraftforge.common.util.ForgeDirection;
public interface IFluidConnectorMK2 {
/**
* Whether the given side can be connected to
* @param dir
* @return
*/
public default boolean canConnect(FluidType type, ForgeDirection dir) {
return dir != ForgeDirection.UNKNOWN;
}
}

View File

@ -0,0 +1,23 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.lib.Library;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import net.minecraft.tileentity.TileEntity;
public interface IFluidPipeMK2 {
public default FluidNode createNode(FluidType type) {
TileEntity tile = (TileEntity) this;
return new FluidNode(type.getNetworkProvider(), new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord)).setConnections(
new DirPos(tile.xCoord + 1, tile.yCoord, tile.zCoord, Library.POS_X),
new DirPos(tile.xCoord - 1, tile.yCoord, tile.zCoord, Library.NEG_X),
new DirPos(tile.xCoord, tile.yCoord + 1, tile.zCoord, Library.POS_Y),
new DirPos(tile.xCoord, tile.yCoord - 1, tile.zCoord, Library.NEG_Y),
new DirPos(tile.xCoord, tile.yCoord, tile.zCoord + 1, Library.POS_Z),
new DirPos(tile.xCoord, tile.yCoord, tile.zCoord - 1, Library.NEG_Z)
);
}
}

View File

@ -0,0 +1,11 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.uninos.IGenProvider;
import com.hbm.uninos.networkproviders.FluidNetProvider;
public interface IFluidProviderMK2 extends IGenProvider<FluidNetProvider> {
public void useUpFluid(FluidType type, int pressure, long amount);
public long getProviderSpeed(FluidType type, int pressure);
}

View File

@ -0,0 +1,12 @@
package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.uninos.IGenReceiver;
import com.hbm.uninos.networkproviders.FluidNetProvider;
public interface IFluidReceiverMK2 extends IGenReceiver<FluidNetProvider> {
/** Sends fluid of the desired type and pressure to the receiver, returns the remainder */
public long transferFluid(FluidType type, int pressure, long amount);
public long getReceiverSpeed(FluidType type, int pressure);
}

View File

@ -0,0 +1,16 @@
/**
*
*/
/**
* @author hbm
*
*/
package api.hbm.fluidmk2;
/*
It's rather shrimple: the shiny new energy system using universal nodespace, but hit with a hammer until it works with fluids.
Has a few extra bits and pieces for handling, but the concept is basically the same.
Sounds good?
*/

View File

@ -0,0 +1,13 @@
package api.hbm.recipe;
public interface IRecipeRegisterListener {
/**
* Called during SerializableRecipe.initialize(), after the defaults are loaded but before the template is written.
* Due to the way the recipes are handled, calling it once is not enough, it has to be called once for every SerializableRecipe
* instance handled, therefore the load operation passes the type name of the recipe, so that the listeners know what type of recipe
* to register at that point. Note that the actual SerializableRecipe instance is irrelevant, since recipes are static anyway,
* and direct tampering with SerializableRecipes is not recommended.
*/
public void onRecipeLoad(String recipeClassName);
}

View File

@ -0,0 +1,17 @@
package api.hbm.recipe;
/*
Quick guide on how to make robust and safe recipe integration:
* Implement IRecipeRegisterListener, the resulting class will handle all recipes, and the onRecipeLoad method is called every time the SerializableRecipe system updates
* Register your IRecipeRegisterListener using CompatExternal.registerRecipeRegisterListener, this has to happen before the SerializableRecipe initializes, doing this during PreInit should be safe
* In your IRecipeRegisterListener, check the supplied recipe type string (which will be the class name of the SerializableRecipe currently being registered) and register your custom recipes accordingly using CompatRecipeRegistry
Explanation:
* Order of operations is important for the recipes to work, if recipes are loaded outside the scope of SerializableRecipe.initialize, they will not work correctly
* If recipes are registered before the init, they are deleted, if they are registered after the init, they will not be part of the config template file, and get deleted when running /ntmreload
* Machines change all the time, so the recipe classes should not be considered API, since the compat would break immediately if a machine is changed or removed
* CompatRecipeRegistry promises to never change its method signatures, and have solid sanity checking when recipes are registered, allowing it to make the bst of whatever data is thrown at it
* Using this dedicated registry class means that even if a machine is changed or removed, the recipes will continue to work to the best of its abilities
*/

View File

@ -5,12 +5,15 @@ import com.hbm.handler.ThreeInts;
import com.hbm.interfaces.ICopiable; import com.hbm.interfaces.ICopiable;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IPersistentNBT; import com.hbm.tileentity.IPersistentNBT;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
@ -32,7 +35,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
public abstract class BlockDummyable extends BlockContainer implements ICustomBlockHighlight, ICopiable { public abstract class BlockDummyable extends BlockContainer implements ICustomBlockHighlight, ICopiable, INBTTransformable {
public BlockDummyable(Material mat) { public BlockDummyable(Material mat) {
super(mat); super(mat);
@ -116,7 +119,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return findCoreRec(world, x, y, z); return findCoreRec(world, x, y, z);
} }
List<ThreeInts> positions = new ArrayList(); List<ThreeInts> positions = new ArrayList<>();
public int[] findCoreRec(World world, int x, int y, int z) { public int[] findCoreRec(World world, int x, int y, int z) {
@ -216,11 +219,6 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
super.onBlockPlacedBy(world, x, y, z, player, itemStack); super.onBlockPlacedBy(world, x, y, z, player, itemStack);
} }
/*@Override
public void onBlockAdded(World world, int x, int y, int z) {
lastBlockSet = new BlockPos(x, y, z);
}*/
/** /**
* A bit more advanced than the dir modifier, but it is important that the resulting direction meta is in the core range. * A bit more advanced than the dir modifier, but it is important that the resulting direction meta is in the core range.
* Using the "extra" metas is technically possible but requires a bit of tinkering, e.g. preventing a recursive loop * Using the "extra" metas is technically possible but requires a bit of tinkering, e.g. preventing a recursive loop
@ -267,9 +265,9 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return; return;
// world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3); // world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3);
this.safeRem = true; safeRem = true;
world.setBlock(x, y, z, this, meta + extra, 3); world.setBlock(x, y, z, this, meta + extra, 3);
this.safeRem = false; safeRem = false;
} }
public void removeExtra(World world, int x, int y, int z) { public void removeExtra(World world, int x, int y, int z) {
@ -283,9 +281,9 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return; return;
// world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3); // world.setBlockMetadataWithNotify(x, y, z, meta + extra, 3);
this.safeRem = true; safeRem = true;
world.setBlock(x, y, z, this, meta - extra, 3); world.setBlock(x, y, z, this, meta - extra, 3);
this.safeRem = false; safeRem = false;
} }
// checks if the dummy metadata is within the extra range // checks if the dummy metadata is within the extra range
@ -423,8 +421,9 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return !bounding.isEmpty(); return !bounding.isEmpty();
} }
public List<AxisAlignedBB> bounding = new ArrayList(); public List<AxisAlignedBB> bounding = new ArrayList<>();
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override @Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB entityBounding, List list, Entity entity) { public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB entityBounding, List list, Entity entity) {
@ -443,7 +442,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
z = pos[2]; z = pos[2];
for(AxisAlignedBB aabb :this.bounding) { for(AxisAlignedBB aabb :this.bounding) {
AxisAlignedBB boxlet = getAABBRotationOffset(aabb, x + 0.5, y, z + 0.5, ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) - this.offset).getRotation(ForgeDirection.UP)); AxisAlignedBB boxlet = getAABBRotationOffset(aabb, x + 0.5, y, z + 0.5, ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) - offset).getRotation(ForgeDirection.UP));
if(entityBounding.intersectsWith(boxlet)) { if(entityBounding.intersectsWith(boxlet)) {
list.add(boxlet); list.add(boxlet);
@ -504,7 +503,7 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
ICustomBlockHighlight.setup(); ICustomBlockHighlight.setup();
for(AxisAlignedBB aabb : this.bounding) event.context.drawOutlinedBoundingBox(getAABBRotationOffset(aabb.expand(exp, exp, exp), 0, 0, 0, ForgeDirection.getOrientation(meta - offset).getRotation(ForgeDirection.UP)).getOffsetBoundingBox(x - dX + 0.5, y - dY, z - dZ + 0.5), -1); for(AxisAlignedBB aabb : this.bounding) RenderGlobal.drawOutlinedBoundingBox(getAABBRotationOffset(aabb.expand(exp, exp, exp), 0, 0, 0, ForgeDirection.getOrientation(meta - offset).getRotation(ForgeDirection.UP)).getOffsetBoundingBox(x - dX + 0.5, y - dY, z - dZ + 0.5), -1);
ICustomBlockHighlight.cleanup(); ICustomBlockHighlight.cleanup();
} }
@ -534,4 +533,27 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
return ((ICopiable) tile).infoForDisplay(world, x, y, z); return ((ICopiable) tile).infoForDisplay(world, x, y, z);
return null; return null;
} }
}
@Override
public int transformMeta(int meta, int coordBaseMode) {
boolean isOffset = meta >= 12; // squishing causes issues
boolean isExtra = !isOffset && meta >= extra;
if(isOffset) {
meta -= offset;
} else if(isExtra) {
meta -= extra;
}
meta = INBTTransformable.transformMetaDeco(meta, coordBaseMode);
if(isOffset) {
meta += offset;
} else if(isExtra) {
meta += extra;
}
return meta;
}
}

View File

@ -11,4 +11,27 @@ public interface IBlockSideRotation {
public static int getRenderType() { public static int getRenderType() {
return renderID; return renderID;
} }
// 0 1 3 2 becomes 0 2 3 1
// I want to smoke that swedish kush because it clearly makes you fucking stupid
public static int topToBottom(int topRotation) {
switch(topRotation) {
case 1: return 2;
case 2: return 1;
default: return topRotation;
}
}
public static boolean isOpposite(int from, int to) {
switch(from) {
case 0: return to == 1;
case 1: return to == 0;
case 2: return to == 3;
case 3: return to == 2;
case 4: return to == 5;
case 5: return to == 4;
default: return false;
}
}
} }

View File

@ -35,6 +35,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling; import net.minecraft.block.BlockFalling;
import net.minecraft.block.material.*; import net.minecraft.block.material.*;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -603,6 +604,7 @@ public class ModBlocks {
public static Block spikes; public static Block spikes;
public static Block charger; public static Block charger;
public static Block refueler;
public static Block tesla; public static Block tesla;
@ -1227,6 +1229,11 @@ public class ModBlocks {
public static Block pink_double_slab; public static Block pink_double_slab;
public static Block pink_stairs; public static Block pink_stairs;
// NBT Structure wand blocks
public static Block wand_air;
public static Block wand_loot;
public static Block wand_jigsaw;
public static Material materialGas = new MaterialGas(); public static Material materialGas = new MaterialGas();
private static void initializeBlock() { private static void initializeBlock() {
@ -1835,7 +1842,7 @@ public class ModBlocks {
pa_quadrupole = new BlockPAQuadrupole().setStepSound(Block.soundTypeMetal).setBlockName("pa_quadrupole").setHardness(5.0F).setResistance(10.0F); pa_quadrupole = new BlockPAQuadrupole().setStepSound(Block.soundTypeMetal).setBlockName("pa_quadrupole").setHardness(5.0F).setResistance(10.0F);
pa_dipole = new BlockPADipole().setStepSound(Block.soundTypeMetal).setBlockName("pa_dipole").setHardness(5.0F).setResistance(10.0F); pa_dipole = new BlockPADipole().setStepSound(Block.soundTypeMetal).setBlockName("pa_dipole").setHardness(5.0F).setResistance(10.0F);
pa_detector = new BlockPADetector().setStepSound(Block.soundTypeMetal).setBlockName("pa_detector").setHardness(5.0F).setResistance(10.0F); pa_detector = new BlockPADetector().setStepSound(Block.soundTypeMetal).setBlockName("pa_detector").setHardness(5.0F).setResistance(10.0F);
machine_electric_furnace_off = new MachineElectricFurnace(false).setBlockName("machine_electric_furnace_off").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); machine_electric_furnace_off = new MachineElectricFurnace(false).setBlockName("machine_electric_furnace_off").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
machine_electric_furnace_on = new MachineElectricFurnace(true).setBlockName("machine_electric_furnace_on").setHardness(5.0F).setLightLevel(1.0F).setResistance(10.0F); machine_electric_furnace_on = new MachineElectricFurnace(true).setBlockName("machine_electric_furnace_on").setHardness(5.0F).setLightLevel(1.0F).setResistance(10.0F);
machine_arc_furnace_off = new MachineArcFurnace(false).setBlockName("machine_arc_furnace_off").setHardness(5.0F).setResistance(10.0F); machine_arc_furnace_off = new MachineArcFurnace(false).setBlockName("machine_arc_furnace_off").setHardness(5.0F).setResistance(10.0F);
@ -2068,6 +2075,7 @@ public class ModBlocks {
spikes = new Spikes(Material.iron).setBlockName("spikes").setHardness(2.5F).setResistance(5.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":spikes"); spikes = new Spikes(Material.iron).setBlockName("spikes").setHardness(2.5F).setResistance(5.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":spikes");
charger = new Charger(Material.iron).setBlockName("charger").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":block_steel"); charger = new Charger(Material.iron).setBlockName("charger").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
refueler = new BlockRefueler(Material.iron).setBlockName("refueler").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
tesla = new MachineTesla(Material.iron).setBlockName("tesla").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":tesla"); tesla = new MachineTesla(Material.iron).setBlockName("tesla").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":tesla");
@ -2169,7 +2177,7 @@ public class ModBlocks {
mass_storage = new BlockMassStorage().setBlockName("mass_storage").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); mass_storage = new BlockMassStorage().setBlockName("mass_storage").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
boxcar = new DecoBlock(Material.iron).setBlockName("boxcar").setStepSound(Block.soundTypeMetal).setHardness(10.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":boxcar"); boxcar = new DecoBlock(Material.iron).setBlockName("boxcar").setStepSound(Block.soundTypeMetal).setHardness(10.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":boxcar");
boat = new DecoBlock(Material.iron).setBlockName("boat").setStepSound(Block.soundTypeMetal).setHardness(10.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":boat"); boat = new DecoBlock(Material.iron).setBlockName("boat").setStepSound(Block.soundTypeMetal).setHardness(10.0F).setResistance(10.0F).setCreativeTab(MainRegistry.blockTab).setBlockTextureName(RefStrings.MODID + ":asphalt");
machine_well = new MachineOilWell().setBlockName("machine_well").setHardness(5.0F).setResistance(20.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_well"); machine_well = new MachineOilWell().setBlockName("machine_well").setHardness(5.0F).setResistance(20.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_well");
machine_pumpjack = new MachinePumpjack().setBlockName("machine_pumpjack").setHardness(5.0F).setResistance(20.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_pumpjack"); machine_pumpjack = new MachinePumpjack().setBlockName("machine_pumpjack").setHardness(5.0F).setResistance(20.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_pumpjack");
@ -2271,7 +2279,7 @@ public class ModBlocks {
crystal_virus = new CrystalVirus(Material.iron).setBlockName("crystal_virus").setHardness(15.0F).setResistance(Float.POSITIVE_INFINITY).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":crystal_virus"); crystal_virus = new CrystalVirus(Material.iron).setBlockName("crystal_virus").setHardness(15.0F).setResistance(Float.POSITIVE_INFINITY).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":crystal_virus");
crystal_hardened = new BlockGeneric(Material.iron).setBlockName("crystal_hardened").setHardness(15.0F).setResistance(Float.POSITIVE_INFINITY).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":crystal_hardened"); crystal_hardened = new BlockGeneric(Material.iron).setBlockName("crystal_hardened").setHardness(15.0F).setResistance(Float.POSITIVE_INFINITY).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":crystal_hardened");
crystal_pulsar = new CrystalPulsar(Material.iron).setBlockName("crystal_pulsar").setHardness(15.0F).setResistance(Float.POSITIVE_INFINITY).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":crystal_pulsar"); crystal_pulsar = new CrystalPulsar(Material.iron).setBlockName("crystal_pulsar").setHardness(15.0F).setResistance(Float.POSITIVE_INFINITY).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":crystal_pulsar");
taint = new BlockTaint(Material.iron).setBlockName("taint").setHardness(15.0F).setResistance(10.0F).setCreativeTab(null); taint = new BlockTaint(Material.iron).setBlockName("taint").setHardness(15.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":taint");
vent_chlorine = new BlockVent(Material.iron).setBlockName("vent_chlorine").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":vent_chlorine"); vent_chlorine = new BlockVent(Material.iron).setBlockName("vent_chlorine").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":vent_chlorine");
vent_cloud = new BlockVent(Material.iron).setBlockName("vent_cloud").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":vent_cloud"); vent_cloud = new BlockVent(Material.iron).setBlockName("vent_cloud").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":vent_cloud");
@ -2352,6 +2360,10 @@ public class ModBlocks {
pink_slab = new BlockPinkSlab(false, Material.wood).setBlockName("pink_slab").setStepSound(Block.soundTypeWood).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pink_planks"); pink_slab = new BlockPinkSlab(false, Material.wood).setBlockName("pink_slab").setStepSound(Block.soundTypeWood).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pink_planks");
pink_double_slab = new BlockPinkSlab(true, Material.wood).setBlockName("pink_double_slab").setStepSound(Block.soundTypeWood).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pink_planks"); pink_double_slab = new BlockPinkSlab(true, Material.wood).setBlockName("pink_double_slab").setStepSound(Block.soundTypeWood).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pink_planks");
pink_stairs = new BlockGenericStairs(pink_planks, 0).setBlockName("pink_stairs").setStepSound(Block.soundTypeWood).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pink_planks"); pink_stairs = new BlockGenericStairs(pink_planks, 0).setBlockName("pink_stairs").setStepSound(Block.soundTypeWood).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":pink_planks");
wand_air = new BlockWand(Blocks.air).setBlockName("wand_air").setBlockTextureName(RefStrings.MODID + ":wand_air");
wand_loot = new BlockWandLoot().setBlockName("wand_loot").setBlockTextureName(RefStrings.MODID + ":wand_loot");
wand_jigsaw = new BlockWandJigsaw().setBlockName("wand_jigsaw").setBlockTextureName(RefStrings.MODID + ":wand_jigsaw");
} }
private static void registerBlock() { private static void registerBlock() {
@ -2709,6 +2721,7 @@ public class ModBlocks {
//Charger //Charger
GameRegistry.registerBlock(charger, charger.getUnlocalizedName()); GameRegistry.registerBlock(charger, charger.getUnlocalizedName());
GameRegistry.registerBlock(refueler, refueler.getUnlocalizedName());
//GameRegistry.registerBlock(floodlight, floodlight.getUnlocalizedName()); //GameRegistry.registerBlock(floodlight, floodlight.getUnlocalizedName());
//Decoration Blocks //Decoration Blocks
@ -3463,7 +3476,7 @@ public class ModBlocks {
GameRegistry.registerBlock(crystal_virus, crystal_virus.getUnlocalizedName()); GameRegistry.registerBlock(crystal_virus, crystal_virus.getUnlocalizedName());
GameRegistry.registerBlock(crystal_hardened, crystal_hardened.getUnlocalizedName()); GameRegistry.registerBlock(crystal_hardened, crystal_hardened.getUnlocalizedName());
GameRegistry.registerBlock(crystal_pulsar, crystal_pulsar.getUnlocalizedName()); GameRegistry.registerBlock(crystal_pulsar, crystal_pulsar.getUnlocalizedName());
GameRegistry.registerBlock(taint, ItemTaintBlock.class, taint.getUnlocalizedName()); register(taint);
GameRegistry.registerBlock(cheater_virus, cheater_virus.getUnlocalizedName()); GameRegistry.registerBlock(cheater_virus, cheater_virus.getUnlocalizedName());
GameRegistry.registerBlock(cheater_virus_seed, cheater_virus_seed.getUnlocalizedName()); GameRegistry.registerBlock(cheater_virus_seed, cheater_virus_seed.getUnlocalizedName());
GameRegistry.registerBlock(ntm_dirt, ntm_dirt.getUnlocalizedName()); GameRegistry.registerBlock(ntm_dirt, ntm_dirt.getUnlocalizedName());
@ -3472,6 +3485,10 @@ public class ModBlocks {
GameRegistry.registerBlock(pink_slab, pink_slab.getUnlocalizedName()); GameRegistry.registerBlock(pink_slab, pink_slab.getUnlocalizedName());
GameRegistry.registerBlock(pink_double_slab, pink_double_slab.getUnlocalizedName()); GameRegistry.registerBlock(pink_double_slab, pink_double_slab.getUnlocalizedName());
GameRegistry.registerBlock(pink_stairs, pink_stairs.getUnlocalizedName()); GameRegistry.registerBlock(pink_stairs, pink_stairs.getUnlocalizedName());
register(wand_air);
register(wand_loot);
register(wand_jigsaw);
} }
private static void register(Block b) { private static void register(Block b) {

View File

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

View File

@ -3,8 +3,8 @@ package com.hbm.blocks.bomb;
import java.util.Random; import java.util.Random;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.config.ServerConfig;
import com.hbm.explosion.ExplosionLarge; import com.hbm.explosion.ExplosionLarge;
import com.hbm.explosion.ExplosionNukeSmall;
import com.hbm.explosion.vanillant.ExplosionVNT; import com.hbm.explosion.vanillant.ExplosionVNT;
import com.hbm.explosion.vanillant.standard.BlockAllocatorStandard; import com.hbm.explosion.vanillant.standard.BlockAllocatorStandard;
import com.hbm.explosion.vanillant.standard.BlockProcessorStandard; import com.hbm.explosion.vanillant.standard.BlockProcessorStandard;
@ -13,8 +13,13 @@ import com.hbm.explosion.vanillant.standard.ExplosionEffectWeapon;
import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard; import com.hbm.explosion.vanillant.standard.PlayerProcessorStandard;
import com.hbm.interfaces.IBomb; import com.hbm.interfaces.IBomb;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.weapon.sedna.factory.XFactoryCatapult;
import com.hbm.main.MainRegistry;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.tileentity.bomb.TileEntityLandmine; import com.hbm.tileentity.bomb.TileEntityLandmine;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockFence; import net.minecraft.block.BlockFence;
@ -23,6 +28,7 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
@ -138,7 +144,7 @@ public class Landmine extends BlockContainer implements IBomb {
if(this == ModBlocks.mine_ap) { if(this == ModBlocks.mine_ap) {
ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 3F); ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 3F);
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(0.5, 10F).setupPiercing(5F, 0.2F)); vnt.setEntityProcessor(new EntityProcessorCrossSmooth(0.5, ServerConfig.MINE_AP_DAMAGE.get()).setupPiercing(5F, 0.2F));
vnt.setPlayerProcessor(new PlayerProcessorStandard()); vnt.setPlayerProcessor(new PlayerProcessorStandard());
vnt.setSFX(new ExplosionEffectWeapon(5, 1F, 0.5F)); vnt.setSFX(new ExplosionEffectWeapon(5, 1F, 0.5F));
vnt.explode(); vnt.explode();
@ -146,13 +152,13 @@ public class Landmine extends BlockContainer implements IBomb {
ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 4F); ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 4F);
vnt.setBlockAllocator(new BlockAllocatorStandard()); vnt.setBlockAllocator(new BlockAllocatorStandard());
vnt.setBlockProcessor(new BlockProcessorStandard()); vnt.setBlockProcessor(new BlockProcessorStandard());
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, 35).setupPiercing(15F, 0.2F)); vnt.setEntityProcessor(new EntityProcessorCrossSmooth(1, ServerConfig.MINE_HE_DAMAGE.get()).setupPiercing(15F, 0.2F));
vnt.setPlayerProcessor(new PlayerProcessorStandard()); vnt.setPlayerProcessor(new PlayerProcessorStandard());
vnt.setSFX(new ExplosionEffectWeapon(15, 3.5F, 1.25F)); vnt.setSFX(new ExplosionEffectWeapon(15, 3.5F, 1.25F));
vnt.explode(); vnt.explode();
} else if(this == ModBlocks.mine_shrap) { } else if(this == ModBlocks.mine_shrap) {
ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 3F); ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 3F);
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(0.5, 7.5F)); vnt.setEntityProcessor(new EntityProcessorCrossSmooth(0.5, ServerConfig.MINE_SHRAP_DAMAGE.get()));
vnt.setPlayerProcessor(new PlayerProcessorStandard()); vnt.setPlayerProcessor(new PlayerProcessorStandard());
vnt.setSFX(new ExplosionEffectWeapon(5, 1F, 0.5F)); vnt.setSFX(new ExplosionEffectWeapon(5, 1F, 0.5F));
vnt.explode(); vnt.explode();
@ -160,7 +166,20 @@ public class Landmine extends BlockContainer implements IBomb {
ExplosionLarge.spawnShrapnelShower(world, x + 0.5, y + 0.5, z + 0.5, 0, 1D, 0, 45, 0.2D); ExplosionLarge.spawnShrapnelShower(world, x + 0.5, y + 0.5, z + 0.5, 0, 1D, 0, 45, 0.2D);
ExplosionLarge.spawnShrapnels(world, x + 0.5, y + 0.5, z + 0.5, 5); ExplosionLarge.spawnShrapnels(world, x + 0.5, y + 0.5, z + 0.5, 5);
} else if(this == ModBlocks.mine_fat) { } else if(this == ModBlocks.mine_fat) {
ExplosionNukeSmall.explode(world, x + 0.5, y + 0.5, z + 0.5, ExplosionNukeSmall.PARAMS_MEDIUM);
ExplosionVNT vnt = new ExplosionVNT(world, x + 0.5, y + 0.5, z + 0.5, 10);
vnt.setBlockAllocator(new BlockAllocatorStandard(64));
vnt.setBlockProcessor(new BlockProcessorStandard());
vnt.setEntityProcessor(new EntityProcessorCrossSmooth(2, ServerConfig.MINE_NUKE_DAMAGE.get()).withRangeMod(1.5F));
vnt.setPlayerProcessor(new PlayerProcessorStandard());
vnt.explode();
XFactoryCatapult.incrementRad(world, x, y, z, 1.5F);
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "muke");
data.setBoolean("balefire", MainRegistry.polaroidID == 11 || world.rand.nextInt(100) == 0);
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, x + 0.5, y + 0.5, z + 0.5), new TargetPoint(world.provider.dimensionId, x + 0.5, y + 0.5, z + 0.5, 250));
} }
} }

View File

@ -4,6 +4,9 @@ import com.hbm.inventory.gui.GUIScreenBobble;
import com.hbm.items.special.ItemPlasticScrap.ScrapType; import com.hbm.items.special.ItemPlasticScrap.ScrapType;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IGUIProvider;
import com.hbm.world.gen.INBTTileEntityTransformable;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -31,7 +34,7 @@ import net.minecraft.world.World;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
public class BlockBobble extends BlockContainer implements IGUIProvider { public class BlockBobble extends BlockContainer implements IGUIProvider, INBTTransformable {
public BlockBobble() { public BlockBobble() {
super(Material.iron); super(Material.iron);
@ -136,12 +139,17 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
} }
@Override
public int transformMeta(int meta, int coordBaseMode) {
return (meta + coordBaseMode * 4) % 16;
}
@Override @Override
public TileEntity createNewTileEntity(World world, int meta) { public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityBobble(); return new TileEntityBobble();
} }
public static class TileEntityBobble extends TileEntity { public static class TileEntityBobble extends TileEntity implements INBTTileEntityTransformable {
public BobbleType type = BobbleType.NONE; public BobbleType type = BobbleType.NONE;
@ -173,6 +181,11 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setByte("type", (byte) type.ordinal()); nbt.setByte("type", (byte) type.ordinal());
} }
@Override
public void transformTE(World world, int coordBaseMode) {
type = BobbleType.values()[world.rand.nextInt(BobbleType.values().length - 1) + 1];
}
} }
public static enum BobbleType { public static enum BobbleType {
@ -200,7 +213,7 @@ public class BlockBobble extends BlockContainer implements IGUIProvider {
CIRNO( "Cirno", "Cirno", "the only multi layered skin i had", "No brain. Head empty.", true, ScrapType.BOARD_BLANK), CIRNO( "Cirno", "Cirno", "the only multi layered skin i had", "No brain. Head empty.", true, ScrapType.BOARD_BLANK),
MICROWAVE( "Microwave", "Microwave", "OC Compatibility and massive RBMK/packet optimizations", "they call me the food heater$john optimization", true, ScrapType.BOARD_CONVERTER), MICROWAVE( "Microwave", "Microwave", "OC Compatibility and massive RBMK/packet optimizations", "they call me the food heater$john optimization", true, ScrapType.BOARD_CONVERTER),
PEEP( "Peep", "LePeeperSauvage", "Coilgun, Leadburster and Congo Lake models, BDCL QC", "Fluffy ears can't hide in ash, nor snow.", true, ScrapType.CARD_BOARD), PEEP( "Peep", "LePeeperSauvage", "Coilgun, Leadburster and Congo Lake models, BDCL QC", "Fluffy ears can't hide in ash, nor snow.", true, ScrapType.CARD_BOARD),
MELLOW( "MELLOWARPEGGIATION", "Mellow", "Industrial lighting, animation tools", "Make something cool now, ask for permission later.", true, ScrapType.CARD_PROCESSOR); MELLOW( "MELLOWARPEGGIATION", "Mellow", "NBT Structures, industrial lighting, animation tools", "Make something cool now, ask for permission later.", true, ScrapType.CARD_PROCESSOR);
public String name; //the title of the tooltip public String name; //the title of the tooltip
public String label; //the name engraved in the socket public String label; //the name engraved in the socket

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@ public class BlockMultiSlab extends BlockSlab implements IStepTickReceiver {
} }
} }
this.setBlockTextureName(RefStrings.MODID + ":concrete_smooth"); this.setBlockTextureName(RefStrings.MODID + ":concrete");
} }
@Override @Override

View File

@ -1,8 +1,11 @@
package com.hbm.blocks.generic; package com.hbm.blocks.generic;
import java.util.List;
import com.hbm.inventory.recipes.PedestalRecipes; import com.hbm.inventory.recipes.PedestalRecipes;
import com.hbm.inventory.recipes.PedestalRecipes.PedestalRecipe; import com.hbm.inventory.recipes.PedestalRecipes.PedestalRecipe;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.particle.helper.ExplosionSmallCreator; import com.hbm.particle.helper.ExplosionSmallCreator;
import com.hbm.util.Compat; import com.hbm.util.Compat;
@ -21,6 +24,7 @@ import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -169,6 +173,9 @@ public class BlockPedestal extends BlockContainer {
world.markBlockForUpdate(x, y, z); world.markBlockForUpdate(x, y, z);
ExplosionSmallCreator.composeEffect(world, x + 0.5, y + 1.5, z + 0.5, 10, 2.5F, 1F); ExplosionSmallCreator.composeEffect(world, x + 0.5, y + 1.5, z + 0.5, 10, 2.5F, 1F);
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x + 0.5, y, z + 0.5, x + 0.5, y, z + 0.5).expand(50, 50, 50));
for(EntityPlayer player : players) player.addStat(MainRegistry.statLegendary, 1);
return; return;
} }
} }

View File

@ -4,6 +4,7 @@ import java.util.List;
import com.hbm.blocks.ITooltipProvider; import com.hbm.blocks.ITooltipProvider;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -16,7 +17,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockPipe extends Block implements ITooltipProvider { public class BlockPipe extends Block implements ITooltipProvider, INBTTransformable {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon sideIcon; private IIcon sideIcon;
@ -24,7 +25,7 @@ public class BlockPipe extends Block implements ITooltipProvider {
public IIcon frameIcon; public IIcon frameIcon;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon meshIcon; public IIcon meshIcon;
private String sideString; private String sideString;
public int rType = 0; //because registering either new renderer classes or making new block classes is a pain in the ass public int rType = 0; //because registering either new renderer classes or making new block classes is a pain in the ass
@ -33,7 +34,7 @@ public class BlockPipe extends Block implements ITooltipProvider {
this.sideString = tex; this.sideString = tex;
this.rType = rType; this.rType = rType;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) { public void registerBlockIcons(IIconRegister iconRegister) {
@ -42,7 +43,7 @@ public class BlockPipe extends Block implements ITooltipProvider {
this.frameIcon = iconRegister.registerIcon(RefStrings.MODID + ":pipe_frame"); this.frameIcon = iconRegister.registerIcon(RefStrings.MODID + ":pipe_frame");
this.meshIcon = iconRegister.registerIcon(RefStrings.MODID + ":pipe_mesh"); this.meshIcon = iconRegister.registerIcon(RefStrings.MODID + ":pipe_mesh");
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) { public IIcon getIcon(int side, int metadata) {
@ -92,4 +93,10 @@ public class BlockPipe extends Block implements ITooltipProvider {
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) { public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
list.add("Purely decorative"); list.add("Purely decorative");
} }
}
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTTransformable.transformMetaPillar(meta, coordBaseMode);
}
}

View File

@ -0,0 +1,51 @@
package com.hbm.blocks.generic;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockWand extends Block {
public final Block exportAs;
public BlockWand(Block exportAs) {
super(Material.glass);
this.exportAs = exportAs;
setBlockBounds(1F/16F, 1F/16F, 1F/16F, 15F/16F, 15F/16F, 15F/16F);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
return null;
}
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override
public int getRenderType() {
return renderID;
}
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
Block block = world.getBlock(x, y, z);
return block != this;
}
}

View File

@ -0,0 +1,387 @@
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.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.I18nUtil;
import com.hbm.world.gen.INBTTransformable;
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.inventory.Container;
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.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
public class BlockWandJigsaw extends BlockContainer implements IBlockSideRotation, INBTTransformable, IGUIProvider, ILookOverlay {
private IIcon iconTop;
private IIcon iconSide;
private IIcon iconBack;
public BlockWandJigsaw() {
super(Material.iron);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityWandJigsaw();
}
@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_jigsaw");
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":wand_jigsaw_top");
this.iconSide = iconRegister.registerIcon(RefStrings.MODID + ":wand_jigsaw_side");
this.iconBack = iconRegister.registerIcon(RefStrings.MODID + ":wand_jigsaw_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 INBTTransformable.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 TileEntityWandJigsaw)) return false;
TileEntityWandJigsaw jigsaw = (TileEntityWandJigsaw) te;
if(!player.isSneaking()) {
Block block = getBlock(world, player.getHeldItem());
if(block == ModBlocks.wand_air) block = Blocks.air;
if(block != null && block != ModBlocks.wand_jigsaw && block != ModBlocks.wand_loot) {
jigsaw.replaceBlock = block;
jigsaw.replaceMeta = player.getHeldItem().getItemDamage();
return true;
}
if(world.isRemote) FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z);
return true;
}
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) {
return new GuiWandJigsaw((TileEntityWandJigsaw) 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 TileEntityWandJigsaw)) return;
TileEntityWandJigsaw jigsaw = (TileEntityWandJigsaw) te;
List<String> text = new ArrayList<String>();
text.add(EnumChatFormatting.GRAY + "Target pool: " + EnumChatFormatting.RESET + jigsaw.pool);
text.add(EnumChatFormatting.GRAY + "Name: " + EnumChatFormatting.RESET + jigsaw.name);
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 + "Selection/Placement priority: " + EnumChatFormatting.RESET + jigsaw.selectionPriority + "/" + jigsaw.placementPriority);
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 TileEntityWandJigsaw extends TileEntityLoadedBase implements IControlReceiver {
private int selectionPriority = 0; // higher priority = this jigsaw block is selected first for generation
private int placementPriority = 0; // higher priority = children of this jigsaw block are checked for jigsaw blocks of their own and selected first
private String pool = "default";
private String name = "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
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
networkPackNT(15);
}
}
@Override
public void serialize(ByteBuf buf) {
buf.writeInt(selectionPriority);
buf.writeInt(placementPriority);
BufferUtil.writeString(buf, pool);
BufferUtil.writeString(buf, name);
BufferUtil.writeString(buf, target);
buf.writeInt(Block.getIdFromBlock(replaceBlock));
buf.writeInt(replaceMeta);
buf.writeBoolean(isRollable);
}
@Override
public void deserialize(ByteBuf buf) {
selectionPriority = buf.readInt();
placementPriority = buf.readInt();
pool = BufferUtil.readString(buf);
name = BufferUtil.readString(buf);
target = BufferUtil.readString(buf);
replaceBlock = Block.getBlockById(buf.readInt());
replaceMeta = buf.readInt();
isRollable = buf.readBoolean();
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("direction", this.getBlockMetadata());
nbt.setInteger("selection", selectionPriority);
nbt.setInteger("placement", placementPriority);
nbt.setString("pool", pool);
nbt.setString("name", name);
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) {
super.readFromNBT(nbt);
selectionPriority = nbt.getInteger("selection");
placementPriority = nbt.getInteger("placement");
pool = nbt.getString("pool");
name = nbt.getString("name");
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 static class GuiWandJigsaw extends GuiScreen {
private final TileEntityWandJigsaw jigsaw;
private GuiTextField textPool;
private GuiTextField textName;
private GuiTextField textTarget;
private GuiTextField textSelectionPriority;
private GuiTextField textPlacementPriority;
private GuiButton jointToggle;
public GuiWandJigsaw(TileEntityWandJigsaw 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);
textName = new GuiTextField(fontRendererObj, this.width / 2 - 150, 100, 140, 20);
textName.setText(jigsaw.name);
textTarget = new GuiTextField(fontRendererObj, this.width / 2 + 10, 100, 140, 20);
textTarget.setText(jigsaw.target);
textSelectionPriority = new GuiTextField(fontRendererObj, this.width / 2 - 150, 150, 90, 20);
textSelectionPriority.setText("" + jigsaw.selectionPriority);
textPlacementPriority = new GuiTextField(fontRendererObj, this.width / 2 - 40, 150, 90, 20);
textPlacementPriority.setText("" + jigsaw.placementPriority);
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, "Name:", this.width / 2 - 150, 87, 0xA0A0A0);
textName.drawTextBox();
drawString(fontRendererObj, "Target name:", this.width / 2 + 10, 87, 0xA0A0A0);
textTarget.drawTextBox();
drawString(fontRendererObj, "Selection priority:", this.width / 2 - 150, 137, 0xA0A0A0);
textSelectionPriority.drawTextBox();
drawString(fontRendererObj, "Placement priority:", this.width / 2 - 40, 137, 0xA0A0A0);
textPlacementPriority.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("name", textName.getText());
data.setString("target", textTarget.getText());
try { data.setInteger("selection", Integer.parseInt(textSelectionPriority.getText())); } catch(Exception ex) {}
try { data.setInteger("placement", Integer.parseInt(textPlacementPriority.getText())); } catch(Exception ex) {}
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);
textName.textboxKeyTyped(typedChar, keyCode);
textTarget.textboxKeyTyped(typedChar, keyCode);
textSelectionPriority.textboxKeyTyped(typedChar, keyCode);
textPlacementPriority.textboxKeyTyped(typedChar, keyCode);
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
textPool.mouseClicked(mouseX, mouseY, mouseButton);
textName.mouseClicked(mouseX, mouseY, mouseButton);
textTarget.mouseClicked(mouseX, mouseY, mouseButton);
textSelectionPriority.mouseClicked(mouseX, mouseY, mouseButton);
textPlacementPriority.mouseClicked(mouseX, mouseY, mouseButton);
if(jointToggle.mousePressed(mc, mouseX, mouseY)) {
System.out.println("displayString: " + jointToggle.displayString);
jointToggle.displayString = jointToggle.displayString == "Rollable" ? "Aligned" : "Rollable";
}
}
}
}

View File

@ -0,0 +1,338 @@
package com.hbm.blocks.generic;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
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.itempool.ItemPool;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.TileEntityLoadedBase;
import com.hbm.util.BufferUtil;
import com.hbm.util.I18nUtil;
import com.hbm.util.LootGenerator;
import com.hbm.world.gen.INBTTileEntityTransformable;
import com.mojang.authlib.GameProfile;
import api.hbm.block.IToolable;
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.ITileEntityProvider;
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.inventory.IInventory;
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.util.WeightedRandomChestContent;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory;
public class BlockWandLoot extends BlockContainer implements ILookOverlay, IToolable, ITooltipProvider, IBlockSideRotation {
@SideOnly(Side.CLIENT) protected IIcon iconTop;
public BlockWandLoot() {
super(Material.iron);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":wand_loot");
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":wand_loot_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);
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandLoot)) return;
((TileEntityWandLoot) te).placedRotation = player.rotationYaw;
}
@Override
public void printHook(Pre event, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityWandLoot)) return;
TileEntityWandLoot loot = (TileEntityWandLoot) te;
List<String> text = new ArrayList<String>();
text.add("Will replace with: " + loot.replaceBlock.getUnlocalizedName());
text.add(" meta: " + loot.replaceMeta);
text.add("Loot pool: " + loot.poolName);
if(loot.replaceBlock != ModBlocks.deco_loot) {
text.add("Minimum items: " + loot.minItems);
text.add("Maximum items: " + loot.maxItems);
}
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
list.add("Define loot crates/piles in .nbt structures");
list.add(EnumChatFormatting.GOLD + "Use screwdriver to increase/decrease minimum loot");
list.add(EnumChatFormatting.GOLD + "Use hand drill to increase/decrease maximum loot");
list.add(EnumChatFormatting.GOLD + "Use defuser to cycle loot types");
list.add(EnumChatFormatting.GOLD + "Use container block to set the block that spawns with loot inside");
}
@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 TileEntityWandLoot)) return false;
TileEntityWandLoot loot = (TileEntityWandLoot) te;
if(!player.isSneaking()) {
Block block = getLootableBlock(world, player.getHeldItem());
if(block != null) {
loot.replaceBlock = block;
loot.replaceMeta = player.getHeldItem().getItemDamage();
List<String> poolNames = loot.getPoolNames(block == ModBlocks.deco_loot);
if(!poolNames.contains(loot.poolName)) {
loot.poolName = poolNames.get(0);
}
return true;
}
}
return false;
}
private Block getLootableBlock(World world, ItemStack stack) {
if(stack == null) return null;
if(stack.getItem() instanceof ItemBlock) {
Block block = ((ItemBlock) stack.getItem()).field_150939_a;
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;
}
@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 TileEntityWandLoot)) return false;
TileEntityWandLoot loot = (TileEntityWandLoot) te;
switch(tool) {
case SCREWDRIVER:
if(player.isSneaking()) {
loot.minItems--;
if(loot.minItems < 0) loot.minItems = 0;
} else {
loot.minItems++;
loot.maxItems = Math.max(loot.minItems, loot.maxItems);
}
return true;
case HAND_DRILL:
if(player.isSneaking()) {
loot.maxItems--;
if(loot.maxItems < 0) loot.maxItems = 0;
loot.minItems = Math.min(loot.minItems, loot.maxItems);
} else {
loot.maxItems++;
}
return true;
case DEFUSER:
List<String> poolNames = loot.getPoolNames(loot.replaceBlock == ModBlocks.deco_loot);
int index = poolNames.indexOf(loot.poolName);
index += player.isSneaking() ? -1 : 1;
index = MathHelper.clamp_int(index, 0, poolNames.size() - 1);
loot.poolName = poolNames.get(index);
return true;
default: return false;
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityWandLoot();
}
public static class TileEntityWandLoot extends TileEntityLoadedBase implements INBTTileEntityTransformable {
private boolean triggerReplace;
private Block replaceBlock = ModBlocks.deco_loot;
private int replaceMeta;
private String poolName = LootGenerator.LOOT_BOOKLET;
private int minItems;
private int maxItems = 1;
private float placedRotation;
private static final GameProfile FAKE_PROFILE = new GameProfile(UUID.fromString("839eb18c-50bc-400c-8291-9383f09763e7"), "[NTM]");
private static FakePlayer fakePlayer;
@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() {
WeightedRandomChestContent[] pool = ItemPool.getPool(poolName);
worldObj.setBlock(xCoord, yCoord, zCoord, replaceBlock, replaceMeta, 2);
TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord);
if(te instanceof IInventory) {
int count = minItems;
if(maxItems - minItems > 0) count += worldObj.rand.nextInt(maxItems - minItems);
WeightedRandomChestContent.generateChestContents(worldObj.rand, pool, (IInventory) te, count);
} else if(te instanceof BlockLoot.TileEntityLoot) {
LootGenerator.applyLoot(worldObj, xCoord, yCoord, zCoord, poolName);
}
// Shouldn't happen but let's guard anyway, if it fails we just don't rotate the chest block correctly
if(!(worldObj instanceof WorldServer)) return;
if(fakePlayer == null || fakePlayer.worldObj != worldObj) {
fakePlayer = FakePlayerFactory.get((WorldServer)worldObj, FAKE_PROFILE);
}
fakePlayer.rotationYaw = fakePlayer.rotationYawHead = placedRotation;
ItemStack fakeStack = new ItemStack(replaceBlock, 1, replaceMeta);
replaceBlock.onBlockPlacedBy(worldObj, xCoord, yCoord, zCoord, fakePlayer, fakeStack);
}
private List<String> getPoolNames(boolean loot) {
if(loot) return Arrays.asList(LootGenerator.getLootNames());
List<String> names = new ArrayList<>();
names.addAll(ItemPool.pools.keySet());
return names;
}
@Override
public void transformTE(World world, int coordBaseMode) {
triggerReplace = !StructureConfig.debugStructures;
placedRotation = MathHelper.wrapAngleTo180_float(placedRotation + coordBaseMode * 90);
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
Block writeBlock = replaceBlock == null ? ModBlocks.deco_loot : replaceBlock;
nbt.setString("block", GameRegistry.findUniqueIdentifierFor(writeBlock).toString());
nbt.setInteger("meta", replaceMeta);
nbt.setInteger("min", minItems);
nbt.setInteger("max", maxItems);
nbt.setString("pool", poolName);
nbt.setFloat("rot", placedRotation);
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
replaceBlock = Block.getBlockFromName(nbt.getString("block"));
replaceMeta = nbt.getInteger("meta");
minItems = nbt.getInteger("min");
maxItems = nbt.getInteger("max");
poolName = nbt.getString("pool");
placedRotation = nbt.getFloat("rot");
if(replaceBlock == null) replaceBlock = ModBlocks.deco_loot;
}
@Override
public void serialize(ByteBuf buf) {
buf.writeInt(Block.getIdFromBlock(replaceBlock));
buf.writeInt(replaceMeta);
buf.writeInt(minItems);
buf.writeInt(maxItems);
BufferUtil.writeString(buf, poolName);
}
@Override
public void deserialize(ByteBuf buf) {
replaceBlock = Block.getBlockById(buf.readInt());
replaceMeta = buf.readInt();
minItems = buf.readInt();
maxItems = buf.readInt();
poolName = BufferUtil.readString(buf);
}
}
}

View File

@ -6,6 +6,7 @@ import java.util.Random;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.tileentity.deco.TileEntityDecoBlock; import com.hbm.tileentity.deco.TileEntityDecoBlock;
import com.hbm.world.gen.INBTTransformable;
import api.hbm.block.IToolable; import api.hbm.block.IToolable;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
@ -24,8 +25,8 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
public class DecoBlock extends BlockContainer implements IToolable { public class DecoBlock extends BlockContainer implements IToolable, INBTTransformable {
Random rand = new Random(); Random rand = new Random();
public DecoBlock(Material p_i45386_1_) { public DecoBlock(Material p_i45386_1_) {
@ -36,7 +37,7 @@ public class DecoBlock extends BlockContainer implements IToolable {
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
if(tool != ToolType.SCREWDRIVER) return false; if(tool != ToolType.SCREWDRIVER) return false;
if(this != ModBlocks.steel_wall && this != ModBlocks.steel_corner) return false; if(this != ModBlocks.steel_wall && this != ModBlocks.steel_corner) return false;
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
if(!player.isSneaking()) { if(!player.isSneaking()) {
@ -50,7 +51,7 @@ public class DecoBlock extends BlockContainer implements IToolable {
else if(meta == 2) world.setBlockMetadataWithNotify(x, y, z, 4, 3); else if(meta == 2) world.setBlockMetadataWithNotify(x, y, z, 4, 3);
else if(meta == 5) world.setBlockMetadataWithNotify(x, y, z, 2, 3); else if(meta == 5) world.setBlockMetadataWithNotify(x, y, z, 2, 3);
} }
return true; return true;
} }
@ -65,7 +66,7 @@ public class DecoBlock extends BlockContainer implements IToolable {
public static int renderIDBeam = RenderingRegistry.getNextAvailableRenderId(); public static int renderIDBeam = RenderingRegistry.getNextAvailableRenderId();
public static int renderIDWall = RenderingRegistry.getNextAvailableRenderId(); public static int renderIDWall = RenderingRegistry.getNextAvailableRenderId();
public static int renderIDCorner = RenderingRegistry.getNextAvailableRenderId(); public static int renderIDCorner = RenderingRegistry.getNextAvailableRenderId();
@Override @Override
public int getRenderType(){ public int getRenderType(){
if(this == ModBlocks.steel_wall) return renderIDWall; if(this == ModBlocks.steel_wall) return renderIDWall;
@ -73,32 +74,32 @@ public class DecoBlock extends BlockContainer implements IToolable {
if(this == ModBlocks.steel_beam) return renderIDBeam; if(this == ModBlocks.steel_beam) return renderIDBeam;
return -1; return -1;
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return Item.getItemFromBlock(this); return Item.getItemFromBlock(this);
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) { 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 == 0) world.setBlockMetadataWithNotify(x, y, z, 3, 2);
if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 4, 2); if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 4, 2);
if(i == 2) world.setBlockMetadataWithNotify(x, y, z, 2, 2); if(i == 2) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
if(i == 3) world.setBlockMetadataWithNotify(x, y, z, 5, 2); if(i == 3) world.setBlockMetadataWithNotify(x, y, z, 5, 2);
} }
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
int te = world.getBlockMetadata(x, y, z); int te = world.getBlockMetadata(x, y, z);
@ -141,14 +142,14 @@ public class DecoBlock extends BlockContainer implements IToolable {
this.setBlockBoundsBasedOnState(world, x, y, z); this.setBlockBoundsBasedOnState(world, x, y, z);
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ); return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
} }
@Override @Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity collider) { public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity collider) {
if(this == ModBlocks.steel_corner) { if(this == ModBlocks.steel_corner) {
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);
List<AxisAlignedBB> bbs = new ArrayList(); List<AxisAlignedBB> bbs = new ArrayList();
switch(meta) { switch(meta) {
case 2: case 2:
bbs.add(AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0D, z + 0.875D, x + 1D, y + 1D, z + 1D)); bbs.add(AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0D, z + 0.875D, x + 1D, y + 1D, z + 1D));
@ -171,7 +172,7 @@ public class DecoBlock extends BlockContainer implements IToolable {
bbs.add(AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0D, z + 0D, x + 1D, y + 1D, z + 0.125D)); bbs.add(AxisAlignedBB.getBoundingBox(x + 0.25D, y + 0D, z + 0D, x + 1D, y + 1D, z + 0.125D));
break; break;
} }
for(AxisAlignedBB bb : bbs) { for(AxisAlignedBB bb : bbs) {
if(aabb.intersectsWith(bb)) { if(aabb.intersectsWith(bb)) {
list.add(bb); list.add(bb);
@ -181,4 +182,9 @@ public class DecoBlock extends BlockContainer implements IToolable {
super.addCollisionBoxesToList(world, x, y, z, aabb, list, collider); super.addCollisionBoxesToList(world, x, y, z, aabb, list, collider);
} }
} }
}
@Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
}
}

View File

@ -1,6 +1,7 @@
package com.hbm.blocks.generic; package com.hbm.blocks.generic;
import com.hbm.tileentity.deco.TileEntityDecoPoleSatelliteReceiver; import com.hbm.tileentity.deco.TileEntityDecoPoleSatelliteReceiver;
import com.hbm.world.gen.INBTTransformable;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -10,7 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
public class DecoPoleSatelliteReceiver extends BlockContainer { public class DecoPoleSatelliteReceiver extends BlockContainer implements INBTTransformable {
public DecoPoleSatelliteReceiver(Material p_i45386_1_) { public DecoPoleSatelliteReceiver(Material p_i45386_1_) {
super(p_i45386_1_); super(p_i45386_1_);
@ -20,26 +21,26 @@ public class DecoPoleSatelliteReceiver extends BlockContainer {
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityDecoPoleSatelliteReceiver(); return new TileEntityDecoPoleSatelliteReceiver();
} }
@Override @Override
public int getRenderType(){ public int getRenderType(){
return -1; return -1;
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) { 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) if(i == 0)
{ {
world.setBlockMetadataWithNotify(x, y, z, 2, 2); world.setBlockMetadataWithNotify(x, y, z, 2, 2);
@ -58,4 +59,9 @@ public class DecoPoleSatelliteReceiver extends BlockContainer {
} }
} }
} @Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
}
}

View File

@ -1,5 +1,7 @@
package com.hbm.blocks.generic; package com.hbm.blocks.generic;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -9,7 +11,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
public class DecoTapeRecorder extends BlockContainer { public class DecoTapeRecorder extends BlockContainer implements INBTTransformable {
public DecoTapeRecorder(Material p_i45386_1_) { public DecoTapeRecorder(Material p_i45386_1_) {
super(p_i45386_1_); super(p_i45386_1_);
@ -19,28 +21,28 @@ public class DecoTapeRecorder extends BlockContainer {
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return null; return null;
} }
public static int renderID = RenderingRegistry.getNextAvailableRenderId(); public static int renderID = RenderingRegistry.getNextAvailableRenderId();
@Override @Override
public int getRenderType(){ public int getRenderType(){
return renderID; return renderID;
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube() {
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock() {
return false; return false;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) { 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) if(i == 0)
{ {
world.setBlockMetadataWithNotify(x, y, z, 2, 2); world.setBlockMetadataWithNotify(x, y, z, 2, 2);
@ -59,4 +61,9 @@ public class DecoTapeRecorder extends BlockContainer {
} }
} }
} @Override
public int transformMeta(int meta, int coordBaseMode) {
return INBTTransformable.transformMetaDeco(meta, coordBaseMode);
}
}

View File

@ -4,11 +4,11 @@ import java.util.Random;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.bomb.BlockDetonatable; import com.hbm.blocks.bomb.BlockDetonatable;
import com.hbm.blocks.bomb.BlockTaint;
import com.hbm.blocks.machine.BlockFluidBarrel; import com.hbm.blocks.machine.BlockFluidBarrel;
import com.hbm.entity.item.EntityTNTPrimedBase; import com.hbm.entity.item.EntityTNTPrimedBase;
import com.hbm.explosion.ExplosionThermo; import com.hbm.explosion.ExplosionThermo;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@ -68,7 +68,8 @@ public class RedBarrel extends BlockDetonatable {
int a = rand.nextInt(9) - 4 + ix; int a = rand.nextInt(9) - 4 + ix;
int b = rand.nextInt(9) - 4 + iy; int b = rand.nextInt(9) - 4 + iy;
int c = rand.nextInt(9) - 4 + iz; int c = rand.nextInt(9) - 4 + iz;
if(world.getBlock(a, b, c).isReplaceable(world, a, b, c) && BlockTaint.hasPosNeightbour(world, a, b, c)) { Block block = world.getBlock(a, b, c);
if(block.isNormalCube() && !block.isAir(world, a, b, c)) {
world.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3) + 4, 2); world.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3) + 4, 2);
} }
} }

View File

@ -0,0 +1,101 @@
package com.hbm.blocks.machine;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.items.machine.IItemFluidIdentifier;
import com.hbm.tileentity.machine.TileEntityRefueler;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockRefueler extends BlockContainer {
public BlockRefueler(Material mat) {
super(mat);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityRefueler();
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(!world.isRemote && !player.isSneaking()) {
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IItemFluidIdentifier) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileEntityRefueler))
return false;
TileEntityRefueler refueler = (TileEntityRefueler) te;
FluidType type = ((IItemFluidIdentifier) player.getHeldItem().getItem()).getType(world, x, y, z, player.getHeldItem());
refueler.tank.setTankType(type);
refueler.markDirty();
player.addChatComponentMessage(new ChatComponentText("Changed type to ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW)).appendSibling(new ChatComponentTranslation(type.getConditionalName())).appendSibling(new ChatComponentText("!")));
return true;
}
return false;
} else {
return true;
}
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if(i == 0) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
if(i == 1) world.setBlockMetadataWithNotify(x, y, z, 5, 2);
if(i == 2) world.setBlockMetadataWithNotify(x, y, z, 3, 2);
if(i == 3) world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
@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(0F, 0F, 12 * f, 1F, 1F, 1F); break;
case 3: this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 4 * f); break;
case 4: this.setBlockBounds(12 * f, 0F, 0F, 1F, 1F, 1F); break;
case 5: this.setBlockBounds(0F, 0F, 0F, 4 * f, 1F, 1F); break;
default: this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 1F); break;
}
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
this.setBlockBoundsBasedOnState(world, x, y, z);
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY, z + this.maxZ);
}
}

View File

@ -7,6 +7,7 @@ import java.util.Random;
import com.hbm.blocks.BlockEnums.LightType; import com.hbm.blocks.BlockEnums.LightType;
import com.hbm.blocks.ISpotlight; import com.hbm.blocks.ISpotlight;
import com.hbm.main.ResourceManager; import com.hbm.main.ResourceManager;
import com.hbm.world.gen.INBTTransformable;
import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -14,6 +15,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab; import net.minecraft.block.BlockSlab;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
@ -22,7 +24,7 @@ import net.minecraft.world.World;
import net.minecraftforge.client.model.obj.WavefrontObject; import net.minecraftforge.client.model.obj.WavefrontObject;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class Spotlight extends Block implements ISpotlight { public class Spotlight extends Block implements ISpotlight, INBTTransformable {
// I'd be extending the ReinforcedLamp class if it wasn't for the inverted behaviour of these specific lights // I'd be extending the ReinforcedLamp class if it wasn't for the inverted behaviour of these specific lights
// I want these blocks to be eminently useful, so removing the need for redstone by default is desired, // I want these blocks to be eminently useful, so removing the need for redstone by default is desired,
@ -38,7 +40,7 @@ public class Spotlight extends Block implements ISpotlight {
this.beamLength = beamLength; this.beamLength = beamLength;
this.type = type; this.type = type;
this.isOn = isOn; this.isOn = isOn;
this.setHardness(1F); this.setHardness(1F);
if(isOn) setLightLevel(1.0F); if(isOn) setLightLevel(1.0F);
@ -123,6 +125,8 @@ public class Spotlight extends Block implements ISpotlight {
} }
private boolean updatePower(World world, int x, int y, int z) { private boolean updatePower(World world, int x, int y, int z) {
if(isBroken(world.getBlockMetadata(x, y, z))) return false;
boolean isPowered = world.isBlockIndirectlyGettingPowered(x, y, z); boolean isPowered = world.isBlockIndirectlyGettingPowered(x, y, z);
if(isOn && isPowered) { if(isOn && isPowered) {
world.scheduleBlockUpdate(x, y, z, this, 4); world.scheduleBlockUpdate(x, y, z, this, 4);
@ -148,7 +152,7 @@ public class Spotlight extends Block implements ISpotlight {
@Override @Override
public void updateTick(World world, int x, int y, int z, Random p_149674_5_) { public void updateTick(World world, int x, int y, int z, Random p_149674_5_) {
if (world.isRemote) return; if (world.isRemote) return;
if (isOn && world.isBlockIndirectlyGettingPowered(x, y, z)) { if (isOn && world.isBlockIndirectlyGettingPowered(x, y, z)) {
world.setBlock(x, y, z, getOff(), world.getBlockMetadata(x, y, z), 2); world.setBlock(x, y, z, getOff(), world.getBlockMetadata(x, y, z), 2);
} }
@ -159,6 +163,7 @@ public class Spotlight extends Block implements ISpotlight {
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlock) { public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlock) {
if(world.isRemote) return; if(world.isRemote) return;
if(neighborBlock instanceof SpotlightBeam) return; if(neighborBlock instanceof SpotlightBeam) return;
if(neighborBlock == Blocks.air) return;
ForgeDirection dir = getDirection(world, x, y, z); ForgeDirection dir = getDirection(world, x, y, z);
@ -172,13 +177,13 @@ public class Spotlight extends Block implements ISpotlight {
updateBeam(world, x, y, z); updateBeam(world, x, y, z);
} }
@Override @Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side) { public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side) {
if(!super.canPlaceBlockOnSide(world, x, y, z, side)) return false; if(!super.canPlaceBlockOnSide(world, x, y, z, side)) return false;
ForgeDirection dir = ForgeDirection.getOrientation(side); ForgeDirection dir = ForgeDirection.getOrientation(side);
return canPlace(world, x, y, z, dir); return canPlace(world, x, y, z, dir);
} }
@ -215,6 +220,10 @@ public class Spotlight extends Block implements ISpotlight {
return ForgeDirection.getOrientation(metadata >> 1); return ForgeDirection.getOrientation(metadata >> 1);
} }
public boolean isBroken(int metadata) {
return (metadata & 1) == 1;
}
@Override @Override
public Item getItemDropped(int i, Random r, int j) { public Item getItemDropped(int i, Random r, int j) {
return Item.getItemFromBlock(getOn()); return Item.getItemFromBlock(getOn());
@ -292,20 +301,20 @@ public class Spotlight extends Block implements ISpotlight {
backPropagate(world, x, y, z, dir); backPropagate(world, x, y, z, dir);
} }
protected Block getOff() { protected Block getOff() {
if(this == ModBlocks.spotlight_incandescent) return ModBlocks.spotlight_incandescent_off; if(this == ModBlocks.spotlight_incandescent) return ModBlocks.spotlight_incandescent_off;
if(this == ModBlocks.spotlight_fluoro) return ModBlocks.spotlight_fluoro_off; if(this == ModBlocks.spotlight_fluoro) return ModBlocks.spotlight_fluoro_off;
if(this == ModBlocks.spotlight_halogen) return ModBlocks.spotlight_halogen_off; if(this == ModBlocks.spotlight_halogen) return ModBlocks.spotlight_halogen_off;
return this; return this;
} }
protected Block getOn() { protected Block getOn() {
if(this == ModBlocks.spotlight_incandescent_off) return ModBlocks.spotlight_incandescent; if(this == ModBlocks.spotlight_incandescent_off) return ModBlocks.spotlight_incandescent;
if(this == ModBlocks.spotlight_fluoro_off) return ModBlocks.spotlight_fluoro; if(this == ModBlocks.spotlight_fluoro_off) return ModBlocks.spotlight_fluoro;
if(this == ModBlocks.spotlight_halogen_off) return ModBlocks.spotlight_halogen; if(this == ModBlocks.spotlight_halogen_off) return ModBlocks.spotlight_halogen;
return this; return this;
} }
@ -313,4 +322,19 @@ public class Spotlight extends Block implements ISpotlight {
public int getBeamLength() { public int getBeamLength() {
return this.beamLength; return this.beamLength;
} }
}
@Override
public int transformMeta(int meta, int coordBaseMode) {
// +1 to set as broken, won't turn on until broken and replaced
return (INBTTransformable.transformMetaDeco(meta >> 1, coordBaseMode) << 1) + 1;
}
@Override
public Block transformBlock(Block block) {
if(block == ModBlocks.spotlight_incandescent) return ModBlocks.spotlight_incandescent_off;
if(block == ModBlocks.spotlight_fluoro) return ModBlocks.spotlight_fluoro_off;
if(block == ModBlocks.spotlight_halogen) return ModBlocks.spotlight_halogen_off;
return block;
}
}

View File

@ -58,31 +58,31 @@ public abstract class RBMKBase extends BlockDummyable implements IToolable, ILoo
public int getOffset() { public int getOffset() {
return 0; return 0;
} }
public boolean openInv(World world, int x, int y, int z, EntityPlayer player) { public boolean openInv(World world, int x, int y, int z, EntityPlayer player) {
if(world.isRemote) { if(world.isRemote) {
return true; return true;
} }
int[] pos = this.findCore(world, x, y, z); int[] pos = this.findCore(world, x, y, z);
if(pos == null) if(pos == null)
return false; return false;
TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]); TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]);
if(!(te instanceof TileEntityRBMKBase)) if(!(te instanceof TileEntityRBMKBase))
return false; return false;
TileEntityRBMKBase rbmk = (TileEntityRBMKBase) te; TileEntityRBMKBase rbmk = (TileEntityRBMKBase) te;
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemRBMKLid) { if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemRBMKLid) {
if(!rbmk.hasLid()) if(!rbmk.hasLid())
return false; return false;
} }
if(!player.isSneaking()) { if(!player.isSneaking()) {
FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, pos[0], pos[1], pos[2]); FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, pos[0], pos[1], pos[2]);
return true; return true;
@ -93,27 +93,27 @@ public abstract class RBMKBase extends BlockDummyable implements IToolable, ILoo
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
float height = 0.0F; float height = 0.0F;
int[] pos = this.findCore(world, x, y, z); int[] pos = this.findCore(world, x, y, z);
if(pos != null) { if(pos != null) {
TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]); TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]);
if(te instanceof TileEntityRBMKBase) { if(te instanceof TileEntityRBMKBase) {
TileEntityRBMKBase rbmk = (TileEntityRBMKBase) te; TileEntityRBMKBase rbmk = (TileEntityRBMKBase) te;
if(rbmk.hasLid()) { if(rbmk.hasLid()) {
height += 0.25F; height += 0.25F;
} }
} }
} }
return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY + height, z + this.maxZ); return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY + height, z + this.maxZ);
} }
/* /*
* NORTH: no cover * NORTH: no cover
* EAST: concrete cover * EAST: concrete cover
@ -130,21 +130,21 @@ public abstract class RBMKBase extends BlockDummyable implements IToolable, ILoo
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(world), this, dir); MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(world), this, dir);
this.makeExtra(world, x, y + RBMKDials.getColumnHeight(world), z); this.makeExtra(world, x, y + RBMKDials.getColumnHeight(world), z);
} }
@Override @Override
protected ForgeDirection getDirModified(ForgeDirection dir) { protected ForgeDirection getDirModified(ForgeDirection dir) {
return DIR_NO_LID; return DIR_NO_LID;
} }
public int[] getDimensions(World world) { public int[] getDimensions(World world) {
return new int[] {RBMKDials.getColumnHeight(world), 0, 0, 0, 0, 0}; return new int[] {RBMKDials.getColumnHeight(world), 0, 0, 0, 0, 0};
} }
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block b, int i) { public void breakBlock(World world, int x, int y, int z, Block b, int i) {
if(!world.isRemote && dropLids) { if(!world.isRemote && dropLids) {
if(i == DIR_NORMAL_LID.ordinal() + offset) { if(i == DIR_NORMAL_LID.ordinal() + offset) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5 + RBMKDials.getColumnHeight(world), z + 0.5, new ItemStack(ModItems.rbmk_lid))); world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5 + RBMKDials.getColumnHeight(world), z + 0.5, new ItemStack(ModItems.rbmk_lid)));
} }
@ -152,32 +152,32 @@ public abstract class RBMKBase extends BlockDummyable implements IToolable, ILoo
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5 + RBMKDials.getColumnHeight(world), z + 0.5, new ItemStack(ModItems.rbmk_lid_glass))); world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5 + RBMKDials.getColumnHeight(world), z + 0.5, new ItemStack(ModItems.rbmk_lid_glass)));
} }
} }
super.breakBlock(world, x, y, z, b, i); super.breakBlock(world, x, y, z, b, i);
} }
@Override @Override
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
if(tool != ToolType.SCREWDRIVER) if(tool != ToolType.SCREWDRIVER)
return false; return false;
int[] pos = this.findCore(world, x, y, z); int[] pos = this.findCore(world, x, y, z);
if(pos != null) { if(pos != null) {
TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]); TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]);
if(te instanceof TileEntityRBMKBase) { if(te instanceof TileEntityRBMKBase) {
TileEntityRBMKBase rbmk = (TileEntityRBMKBase) te; TileEntityRBMKBase rbmk = (TileEntityRBMKBase) te;
int i = rbmk.getBlockMetadata(); int i = rbmk.getBlockMetadata();
if(rbmk.hasLid() && rbmk.isLidRemovable()) { if(rbmk.hasLid() && rbmk.isLidRemovable()) {
RBMKNeutronNode node = (RBMKNeutronNode) NeutronNodeWorld.getNode(new BlockPos(te)); RBMKNeutronNode node = (RBMKNeutronNode) NeutronNodeWorld.getNode(world, new BlockPos(te));
if (node != null) if(node != null)
node.removeLid(); node.removeLid();
if(!world.isRemote) { if(!world.isRemote) {
if(i == DIR_NORMAL_LID.ordinal() + offset) { if(i == DIR_NORMAL_LID.ordinal() + offset) {
world.spawnEntityInWorld(new EntityItem(world, pos[0] + 0.5, pos[1] + 0.5 + RBMKDials.getColumnHeight(world), pos[2] + 0.5, new ItemStack(ModItems.rbmk_lid))); world.spawnEntityInWorld(new EntityItem(world, pos[0] + 0.5, pos[1] + 0.5 + RBMKDials.getColumnHeight(world), pos[2] + 0.5, new ItemStack(ModItems.rbmk_lid)));
@ -185,15 +185,15 @@ public abstract class RBMKBase extends BlockDummyable implements IToolable, ILoo
if(i == DIR_GLASS_LID.ordinal() + offset) { if(i == DIR_GLASS_LID.ordinal() + offset) {
world.spawnEntityInWorld(new EntityItem(world, pos[0] + 0.5, pos[1] + 0.5 + RBMKDials.getColumnHeight(world), pos[2] + 0.5, new ItemStack(ModItems.rbmk_lid_glass))); world.spawnEntityInWorld(new EntityItem(world, pos[0] + 0.5, pos[1] + 0.5 + RBMKDials.getColumnHeight(world), pos[2] + 0.5, new ItemStack(ModItems.rbmk_lid_glass)));
} }
world.setBlockMetadataWithNotify(pos[0], pos[1], pos[2], DIR_NO_LID.ordinal() + this.offset, 3); world.setBlockMetadataWithNotify(pos[0], pos[1], pos[2], DIR_NO_LID.ordinal() + offset, 3);
} }
return true; return true;
} }
} }
} }
return false; return false;
} }

View File

@ -2,6 +2,7 @@ package com.hbm.blocks.network;
import api.hbm.block.IToolable; import api.hbm.block.IToolable;
import com.hbm.blocks.IBlockMultiPass; import com.hbm.blocks.IBlockMultiPass;
import com.hbm.interfaces.ICopiable;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.render.block.RenderBlockMultipass; import com.hbm.render.block.RenderBlockMultipass;
import com.hbm.tileentity.network.TileEntityCableBaseNT; import com.hbm.tileentity.network.TileEntityCableBaseNT;
@ -124,7 +125,7 @@ public class BlockCablePaintable extends BlockContainer implements IToolable, IB
return IBlockMultiPass.getRenderType(); return IBlockMultiPass.getRenderType();
} }
public static class TileEntityCablePaintable extends TileEntityCableBaseNT { public static class TileEntityCablePaintable extends TileEntityCableBaseNT implements ICopiable {
private Block block; private Block block;
private int meta; private int meta;
@ -168,5 +169,23 @@ public class BlockCablePaintable extends BlockContainer implements IToolable, IB
if(block != null) nbt.setInteger("block", Block.getIdFromBlock(block)); if(block != null) nbt.setInteger("block", Block.getIdFromBlock(block));
nbt.setInteger("meta", meta); nbt.setInteger("meta", meta);
} }
@Override
public NBTTagCompound getSettings(World world, int x, int y, int z) {
NBTTagCompound nbt = new NBTTagCompound();
if(block != null) {
nbt.setInteger("paintblock", Block.getIdFromBlock(block));
nbt.setInteger("paintmeta", meta);
}
return nbt;
}
@Override
public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) {
if(nbt.hasKey("paintblock")) {
this.block = Block.getBlockById(nbt.getInteger("paintblock"));
this.meta = nbt.getInteger("paintmeta");
}
}
} }
} }

View File

@ -9,16 +9,21 @@ import com.hbm.tileentity.network.TileEntityDroneRequester;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.List; import java.util.List;
import java.util.Random;
public class DroneDock extends BlockContainer implements ITooltipProvider { public class DroneDock extends BlockContainer implements ITooltipProvider {
@ -69,4 +74,53 @@ public class DroneDock extends BlockContainer implements ITooltipProvider {
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) { public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
this.addStandardInfo(stack, player, list, ext); this.addStandardInfo(stack, player, list, ext);
} }
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if(this == ModBlocks.drone_dock) this.dropContents(world, x, y, z, block, meta, 0, 9);
if(this == ModBlocks.drone_crate_provider) this.dropContents(world, x, y, z, block, meta, 0, 9);
if(this == ModBlocks.drone_crate_requester) this.dropContents(world, x, y, z, block, meta, 9, 18);
super.breakBlock(world, x, y, z, block, meta);
}
private final Random rand = new Random();
public void dropContents(World world, int x, int y, int z, Block block, int meta, int start, int end) {
ISidedInventory sidedInventory = (ISidedInventory) world.getTileEntity(x, y, z);
if(sidedInventory != null) {
for(int i1 = start; i1 < end; ++i1) {
ItemStack stack = sidedInventory.getStackInSlot(i1);
if(stack != 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(stack.stackSize > 0) {
int j1 = this.rand.nextInt(21) + 10;
if(j1 > stack.stackSize) {
j1 = stack.stackSize;
}
stack.stackSize -= j1;
EntityItem entity = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(stack.getItem(), j1, stack.getItemDamage()));
if(stack.hasTagCompound()) {
entity.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
}
float f3 = 0.05F;
entity.motionX = (float) this.rand.nextGaussian() * f3;
entity.motionY = (float) this.rand.nextGaussian() * f3 + 0.2F;
entity.motionZ = (float) this.rand.nextGaussian() * f3;
world.spawnEntityInWorld(entity);
}
}
}
world.func_147453_f(x, y, z, block);
}
}
} }

View File

@ -3,6 +3,7 @@ package com.hbm.blocks.network;
import api.hbm.block.IToolable; import api.hbm.block.IToolable;
import com.hbm.blocks.IBlockMultiPass; import com.hbm.blocks.IBlockMultiPass;
import com.hbm.blocks.ILookOverlay; import com.hbm.blocks.ILookOverlay;
import com.hbm.interfaces.ICopiable;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.render.block.RenderBlockMultipass; import com.hbm.render.block.RenderBlockMultipass;
import com.hbm.tileentity.network.TileEntityPipeBaseNT; import com.hbm.tileentity.network.TileEntityPipeBaseNT;
@ -163,7 +164,7 @@ public class FluidDuctPaintable extends FluidDuctBase implements IToolable, IBlo
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text); ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
} }
public static class TileEntityPipePaintable extends TileEntityPipeBaseNT { public static class TileEntityPipePaintable extends TileEntityPipeBaseNT implements ICopiable {
private Block block; private Block block;
private int meta; private int meta;
@ -195,5 +196,23 @@ public class FluidDuctPaintable extends FluidDuctBase implements IToolable, IBlo
if(block != null) nbt.setInteger("block", Block.getIdFromBlock(block)); if(block != null) nbt.setInteger("block", Block.getIdFromBlock(block));
nbt.setInteger("meta", meta); nbt.setInteger("meta", meta);
} }
@Override
public NBTTagCompound getSettings(World world, int x, int y, int z) {
NBTTagCompound nbt = new NBTTagCompound();
if(block != null) {
nbt.setInteger("paintblock", Block.getIdFromBlock(block));
nbt.setInteger("paintmeta", meta);
}
return nbt;
}
@Override
public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) {
if(nbt.hasKey("paintblock")) {
this.block = Block.getBlockById(nbt.getInteger("paintblock"));
this.meta = nbt.getInteger("paintmeta");
}
}
} }
} }

View File

@ -1,24 +1,18 @@
package com.hbm.commands; package com.hbm.commands;
import java.util.Collections; import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import com.hbm.config.ClientConfig; import com.hbm.config.ClientConfig;
import com.hbm.config.ClientConfig.ConfigWrapper; import com.hbm.config.RunningConfig.ConfigWrapper;
import cpw.mods.fml.relauncher.FMLLaunchHandler; import cpw.mods.fml.relauncher.FMLLaunchHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender; import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.client.ClientCommandHandler;
public class CommandReloadClient extends CommandBase { public class CommandReloadClient extends CommandReloadConfig {
public static void register() { public static void register() {
if(FMLLaunchHandler.side() != Side.CLIENT) return; if(FMLLaunchHandler.side() != Side.CLIENT) return;
@ -34,95 +28,26 @@ public class CommandReloadClient extends CommandBase {
public String getCommandUsage(ICommandSender sender) { public String getCommandUsage(ICommandSender sender) {
return "/ntmclient help"; return "/ntmclient help";
} }
@Override @Override public void help(ICommandSender sender, String[] args) {
public boolean canCommandSenderUseCommand(ICommandSender sender) { if(args.length >= 2) {
return sender instanceof EntityPlayer; String command = args[1];
} if("help".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Shows usage for /ntmclient subcommands."));
if("list".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Shows all client variable names and values."));
@Override if("reload".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Reads client variables from the config file."));
public void processCommand(ICommandSender sender, String[] args) { if("get".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Shows value for the specified variable name."));
if("set".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Sets a variable's value and saves it to the config file."));
if(args.length < 1) throw new CommandException(getCommandUsage(sender)); } else {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmclient " + EnumChatFormatting.GOLD + "help " + EnumChatFormatting.RED + "<command>"));
String operator = args[0]; sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmclient " + EnumChatFormatting.GOLD + "list"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmclient " + EnumChatFormatting.GOLD + "reload"));
if("help".equals(operator)) { sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmclient " + EnumChatFormatting.GOLD + "get " + EnumChatFormatting.RED + "<name>"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmclient " + EnumChatFormatting.GOLD + "set " + EnumChatFormatting.RED + "<name> <value>"));
if(args.length >= 2) { }
String command = args[1];
if("help".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Shows usage for /ntmclient subcommands."));
if("list".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Shows all client variable names and values."));
if("reload".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Reads client variables from the config file."));
if("get".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Shows value for the specified variable name."));
if("set".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Sets a variable's value and saves it to the config file."));
} else {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmclient " + EnumChatFormatting.GOLD + "help " + EnumChatFormatting.RED + "<command>"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmclient " + EnumChatFormatting.GOLD + "list"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmclient " + EnumChatFormatting.GOLD + "reload"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmclient " + EnumChatFormatting.GOLD + "get " + EnumChatFormatting.RED + "<name>"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmclient " + EnumChatFormatting.GOLD + "set " + EnumChatFormatting.RED + "<name> <value>"));
}
return;
}
if("list".equals(operator)) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "CLIENT VARIABLES:"));
for(Entry<String, ConfigWrapper> line : ClientConfig.configMap.entrySet()) {
sender.addChatMessage(new ChatComponentText(" " + EnumChatFormatting.GOLD + line.getKey() + ": " + EnumChatFormatting.YELLOW + line.getValue().value));
}
return;
}
if("reload".equals(operator)) {
ClientConfig.reload();
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Variables loaded from config file."));
return;
}
if(args.length < 2) throw new CommandException(getCommandUsage(sender));
String key = args[1];
if("get".equals(operator)) {
ConfigWrapper wrapper = ClientConfig.configMap.get(key);
if(wrapper == null) throw new CommandException("Key does not exist.");
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + key + ": " + EnumChatFormatting.YELLOW + wrapper.value));
return;
}
if(args.length < 3) throw new CommandException(getCommandUsage(sender));
String value = args[2];
if("set".equals(operator)) {
ConfigWrapper wrapper = ClientConfig.configMap.get(key);
if(wrapper == null) throw new CommandException("Key does not exist.");
try {
wrapper.update(value);
ClientConfig.refresh();
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Value updated."));
} catch(Exception ex) {
throw new CommandException("Error parsing type for " + wrapper.value.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());
}
return;
}
throw new CommandException(getCommandUsage(sender));
}
@SuppressWarnings("rawtypes")
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] args) {
if(!(sender instanceof EntityPlayer)) return Collections.emptyList();
if(args.length < 1) return Collections.emptyList();
if(args.length == 1) return getListOfStringsMatchingLastWord(args, "list", "reload", "get", "set");
String operator = args[0];
if(args.length == 2 && ("get".equals(operator) || "set".equals(operator))) {
return getListOfStringsFromIterableMatchingLastWord(args, ClientConfig.configMap.keySet().stream().map(String::valueOf).collect(Collectors.toList()));
}
return Collections.emptyList();
} }
@Override public HashMap<String, ConfigWrapper> getConfigMap() { return ClientConfig.configMap; }
@Override public void refresh() { ClientConfig.refresh(); }
@Override public void reload() { ClientConfig.reload(); }
@Override public String getTitle() { return "CLIENT VARIABLES:"; }
} }

View File

@ -0,0 +1,102 @@
package com.hbm.commands;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import com.hbm.config.RunningConfig.ConfigWrapper;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
public abstract class CommandReloadConfig extends CommandBase {
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender) {
return sender instanceof EntityPlayer;
}
public abstract void help(ICommandSender sender, String[] args);
public abstract HashMap<String, ConfigWrapper> getConfigMap();
public abstract void refresh();
public abstract void reload();
public abstract String getTitle();
@Override
public void processCommand(ICommandSender sender, String[] args) {
if(args.length < 1) throw new CommandException(getCommandUsage(sender));
String operator = args[0];
if("help".equals(operator)) {
help(sender, args);
return;
}
if("list".equals(operator)) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + getTitle()));
for(Entry<String, ConfigWrapper> line : getConfigMap().entrySet()) {
sender.addChatMessage(new ChatComponentText(" " + EnumChatFormatting.GOLD + line.getKey() + ": " + EnumChatFormatting.YELLOW + line.getValue().value));
}
return;
}
if("reload".equals(operator)) {
reload();
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Variables loaded from config file."));
return;
}
if(args.length < 2) throw new CommandException(getCommandUsage(sender));
String key = args[1];
if("get".equals(operator)) {
ConfigWrapper wrapper = getConfigMap().get(key);
if(wrapper == null) throw new CommandException("Key does not exist.");
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + key + ": " + EnumChatFormatting.YELLOW + wrapper.value));
return;
}
if(args.length < 3) throw new CommandException(getCommandUsage(sender));
String value = args[2];
if("set".equals(operator)) {
ConfigWrapper wrapper = getConfigMap().get(key);
if(wrapper == null) throw new CommandException("Key does not exist.");
try {
wrapper.update(value);
refresh();
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Value updated."));
} catch(Exception ex) {
throw new CommandException("Error parsing type for " + wrapper.value.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());
}
return;
}
throw new CommandException(getCommandUsage(sender));
}
@SuppressWarnings("rawtypes")
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] args) {
if(!(sender instanceof EntityPlayer)) return Collections.emptyList();
if(args.length < 1) return Collections.emptyList();
if(args.length == 1) return getListOfStringsMatchingLastWord(args, "list", "reload", "get", "set");
String operator = args[0];
if(args.length == 2 && ("get".equals(operator) || "set".equals(operator))) {
return getListOfStringsFromIterableMatchingLastWord(args, getConfigMap().keySet().stream().map(String::valueOf).collect(Collectors.toList()));
}
return Collections.emptyList();
}
}

View File

@ -26,10 +26,10 @@ public class CommandReloadRecipes extends CommandBase {
@Override @Override
public void processCommand(ICommandSender sender, String[] args) { public void processCommand(ICommandSender sender, String[] args) {
try { try {
Fluids.reloadFluids();
SerializableRecipe.initialize(); SerializableRecipe.initialize();
ItemPoolConfigJSON.initialize(); ItemPoolConfigJSON.initialize();
DamageResistanceHandler.init(); DamageResistanceHandler.init();
Fluids.reloadFluids();
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Reload complete :)")); sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Reload complete :)"));
} catch(Exception ex) { } catch(Exception ex) {

View File

@ -0,0 +1,45 @@
package com.hbm.commands;
import java.util.HashMap;
import com.hbm.config.RunningConfig.ConfigWrapper;
import com.hbm.config.ServerConfig;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
public class CommandReloadServer extends CommandReloadConfig {
@Override
public String getCommandName() {
return "ntmserver";
}
@Override
public String getCommandUsage(ICommandSender sender) {
return "/ntmserver help";
}
@Override public void help(ICommandSender sender, String[] args) {
if(args.length >= 2) {
String command = args[1];
if("help".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Shows usage for /ntmserver subcommands."));
if("list".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Shows all server variable names and values."));
if("reload".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Reads server variables from the config file."));
if("get".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Shows value for the specified variable name."));
if("set".equals(command)) sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Sets a variable's value and saves it to the config file."));
} else {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmserver " + EnumChatFormatting.GOLD + "help " + EnumChatFormatting.RED + "<command>"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmserver " + EnumChatFormatting.GOLD + "list"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmserver " + EnumChatFormatting.GOLD + "reload"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmserver " + EnumChatFormatting.GOLD + "get " + EnumChatFormatting.RED + "<name>"));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "/ntmserver " + EnumChatFormatting.GOLD + "set " + EnumChatFormatting.RED + "<name> <value>"));
}
}
@Override public HashMap<String, ConfigWrapper> getConfigMap() { return ServerConfig.configMap; }
@Override public void refresh() { ServerConfig.refresh(); }
@Override public void reload() { ServerConfig.reload(); }
@Override public String getTitle() { return "SERVER VARIABLES:"; }
}

View File

@ -1,24 +1,13 @@
package com.hbm.config; package com.hbm.config;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.main.MainRegistry;
import com.hbm.util.Compat; import com.hbm.util.Compat;
import java.io.File; import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
// https://youtube.com/shorts/XTHZWqZt_AI // https://youtube.com/shorts/XTHZWqZt_AI
public class ClientConfig { public class ClientConfig extends RunningConfig {
public static final Gson gson = new Gson(); public static final Gson gson = new Gson();
public static HashMap<String, ConfigWrapper> configMap = new HashMap(); public static HashMap<String, ConfigWrapper> configMap = new HashMap();
@ -65,112 +54,28 @@ public class ClientConfig {
/** Initializes defaults, then reads the config file if it exists, then writes the config file. */ /** Initializes defaults, then reads the config file if it exists, then writes the config file. */
public static void initConfig() { public static void initConfig() {
initDefaults(); initDefaults();
File folder = MainRegistry.configHbmDir; File config = getConfig("hbmClient.json");
File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmClient.json");
if(config.exists()) readConfig(config); if(config.exists()) readConfig(config);
refresh(); refresh();
} }
/** Writes over the config file using the running config. */ /** Writes over the config file using the running config. */
public static void refresh() { public static void refresh() {
File folder = MainRegistry.configHbmDir; File config = getConfig("hbmClient.json");
File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmClient.json");
writeConfig(config); writeConfig(config);
} }
/** Writes over the running config using the config file. */ /** Writes over the running config using the config file. */
public static void reload() { public static void reload() {
File folder = MainRegistry.configHbmDir; File config = getConfig("hbmClient.json");
File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmClient.json");
if(config.exists()) readConfig(config); if(config.exists()) readConfig(config);
} }
private static void readConfig(File config) { private static void readConfig(File config) {
RunningConfig.readConfig(config, configMap);
try {
JsonObject json = gson.fromJson(new FileReader(config), JsonObject.class);
for(Entry<String, ConfigWrapper> line : configMap.entrySet()) {
if(json.has(line.getKey())) {
JsonElement value = json.get(line.getKey());
try {
//world's shittiest dynamic type parser
if(configMap.containsKey(line.getKey())) {
if(line.getValue().value instanceof String) configMap.get(line.getKey()).set(value.getAsString());
if(line.getValue().value instanceof Float) configMap.get(line.getKey()).set(value.getAsFloat());
if(line.getValue().value instanceof Double) configMap.get(line.getKey()).set(value.getAsDouble());
if(line.getValue().value instanceof Integer) configMap.get(line.getKey()).set(value.getAsInt());
if(line.getValue().value instanceof Boolean) configMap.get(line.getKey()).set(value.getAsBoolean());
}
//gson doesn't give me the option to read the raw value of a JsonPrimitive so we have to this shit effectively twice
//once to make sure that the parsed data matches with what's determined by the default,
//and a second time in the ConfigWrapper to add ease of reading the data without needing manual casts
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
} catch(Exception ex) {
ex.printStackTrace();
}
} }
private static void writeConfig(File config) { private static void writeConfig(File config) {
RunningConfig.writeConfig(config, configMap, "This file can be edited ingame using the /ntmclient command.");
try {
JsonWriter writer = new JsonWriter(new FileWriter(config));
writer.setIndent(" ");
writer.beginObject();
writer.name("info").value("This file can be edited ingame using the /ntmclient command.");
List<String> keys = new ArrayList();
keys.addAll(configMap.keySet());
Collections.sort(keys); //readability is cool
for(String key : keys) {
ConfigWrapper wrapper = configMap.get(key);
Object value = wrapper.value;
//this sucks and i am too stupid to come up with something better
if(value instanceof String) writer.name(key).value((String) value);
if(value instanceof Float) writer.name(key).value((Float) value);
if(value instanceof Double) writer.name(key).value((Double) value);
if(value instanceof Integer) writer.name(key).value((Integer) value);
if(value instanceof Boolean) writer.name(key).value((Boolean) value);
}
writer.endObject();
writer.close();
} catch(IOException e) {
e.printStackTrace();
}
}
public static class ConfigWrapper<T> {
public T value;
public ConfigWrapper(T o) {
this.value = o;
}
public T get() { return value; }
public void set(T value) { this.value = value; }
public void update(String param) {
Object stupidBufferObject = null; // wahh wahh can't cast Float to T wahh wahh shut the fuck up
if(value instanceof String) stupidBufferObject = param;
if(value instanceof Float) stupidBufferObject = Float.parseFloat(param);
if(value instanceof Double) stupidBufferObject = Double.parseDouble(param);
if(value instanceof Integer) stupidBufferObject = Integer.parseInt(param);
if(value instanceof Boolean) stupidBufferObject = Boolean.parseBoolean(param);
if(stupidBufferObject != null) this.value = (T) stupidBufferObject;
}
} }
} }

View File

@ -23,13 +23,11 @@ public class GeneralConfig {
public static boolean enableVaults = true; public static boolean enableVaults = true;
public static boolean enableCataclysm = false; public static boolean enableCataclysm = false;
public static boolean enableExtendedLogging = false; public static boolean enableExtendedLogging = false;
public static boolean enableHardcoreTaint = false;
public static boolean enableGuns = true; public static boolean enableGuns = true;
public static boolean enableVirus = true; public static boolean enableVirus = true;
public static boolean enableCrosshairs = true; public static boolean enableCrosshairs = true;
public static boolean enableReflectorCompat = false; public static boolean enableReflectorCompat = false;
public static boolean enableRenderDistCheck = true; public static boolean enableRenderDistCheck = true;
public static boolean enableReEval = true;
public static boolean enableSilentCompStackErrors = true; public static boolean enableSilentCompStackErrors = true;
public static boolean enableSkyboxes = true; public static boolean enableSkyboxes = true;
public static boolean enableImpactWorldProvider = true; public static boolean enableImpactWorldProvider = true;
@ -42,7 +40,6 @@ public class GeneralConfig {
public static boolean enableSoundExtension = true; public static boolean enableSoundExtension = true;
public static boolean enableMekanismChanges = true; public static boolean enableMekanismChanges = true;
public static int normalSoundChannels = 200; public static int normalSoundChannels = 200;
public static int hintPos = 0;
public static boolean enableExpensiveMode = false; public static boolean enableExpensiveMode = false;
@ -100,15 +97,12 @@ public class GeneralConfig {
enableVaults = config.get(CATEGORY_GENERAL, "1.15_enableVaultSpawn", true, "Allows locked safes to spawn").getBoolean(true); enableVaults = config.get(CATEGORY_GENERAL, "1.15_enableVaultSpawn", true, "Allows locked safes to spawn").getBoolean(true);
enableCataclysm = config.get(CATEGORY_GENERAL, "1.17_enableCataclysm", false, "Causes satellites to fall whenever a mob dies").getBoolean(false); enableCataclysm = config.get(CATEGORY_GENERAL, "1.17_enableCataclysm", false, "Causes satellites to fall whenever a mob dies").getBoolean(false);
enableExtendedLogging = config.get(CATEGORY_GENERAL, "1.18_enableExtendedLogging", false, "Logs uses of the detonator, nuclear explosions, missile launches, grenades, etc.").getBoolean(false); enableExtendedLogging = config.get(CATEGORY_GENERAL, "1.18_enableExtendedLogging", false, "Logs uses of the detonator, nuclear explosions, missile launches, grenades, etc.").getBoolean(false);
enableHardcoreTaint = config.get(CATEGORY_GENERAL, "1.19_enableHardcoreTaint", false, "Allows tainted mobs to spread taint").getBoolean(false);
enableGuns = config.get(CATEGORY_GENERAL, "1.20_enableGuns", true, "Prevents new system guns to be fired").getBoolean(true); enableGuns = config.get(CATEGORY_GENERAL, "1.20_enableGuns", true, "Prevents new system guns to be fired").getBoolean(true);
enableVirus = config.get(CATEGORY_GENERAL, "1.21_enableVirus", false, "Allows virus blocks to spread").getBoolean(false); enableVirus = config.get(CATEGORY_GENERAL, "1.21_enableVirus", false, "Allows virus blocks to spread").getBoolean(false);
enableCrosshairs = config.get(CATEGORY_GENERAL, "1.22_enableCrosshairs", true, "Shows custom crosshairs when an NTM gun is being held").getBoolean(true); enableCrosshairs = config.get(CATEGORY_GENERAL, "1.22_enableCrosshairs", true, "Shows custom crosshairs when an NTM gun is being held").getBoolean(true);
enableReflectorCompat = config.get(CATEGORY_GENERAL, "1.24_enableReflectorCompat", false, "Enable old reflector oredict name (\"plateDenseLead\") instead of new \"plateTungCar\"").getBoolean(false); enableReflectorCompat = config.get(CATEGORY_GENERAL, "1.24_enableReflectorCompat", false, "Enable old reflector oredict name (\"plateDenseLead\") instead of new \"plateTungCar\"").getBoolean(false);
enableRenderDistCheck = config.get(CATEGORY_GENERAL, "1.25_enableRenderDistCheck", true, "Check invalid render distances (over 16, without OptiFine) and fix it").getBoolean(true); enableRenderDistCheck = config.get(CATEGORY_GENERAL, "1.25_enableRenderDistCheck", true, "Check invalid render distances (over 16, without OptiFine) and fix it").getBoolean(true);
enableReEval = config.get(CATEGORY_GENERAL, "1.27_enableReEval", true, "Allows re-evaluating power networks on link remove instead of destroying and recreating").getBoolean(true);
enableSilentCompStackErrors = config.get(CATEGORY_GENERAL, "1.28_enableSilentCompStackErrors", false, "Enabling this will disable log spam created by unregistered items in ComparableStack instances.").getBoolean(false); enableSilentCompStackErrors = config.get(CATEGORY_GENERAL, "1.28_enableSilentCompStackErrors", false, "Enabling this will disable log spam created by unregistered items in ComparableStack instances.").getBoolean(false);
hintPos = CommonConfig.createConfigInt(config, CATEGORY_GENERAL, "1.29_hudOverlayPosition", "0: Top left\n1: Top right\n2: Center right\n3: Center Left", 0);
enableSkyboxes = config.get(CATEGORY_GENERAL, "1.31_enableSkyboxes", true, "If enabled, will try to use NTM's custom skyboxes.").getBoolean(true); enableSkyboxes = config.get(CATEGORY_GENERAL, "1.31_enableSkyboxes", true, "If enabled, will try to use NTM's custom skyboxes.").getBoolean(true);
enableImpactWorldProvider = config.get(CATEGORY_GENERAL, "1.32_enableImpactWorldProvider", true, "If enabled, registers custom world provider which modifies lighting and sky colors for post impact effects.").getBoolean(true); enableImpactWorldProvider = config.get(CATEGORY_GENERAL, "1.32_enableImpactWorldProvider", true, "If enabled, registers custom world provider which modifies lighting and sky colors for post impact effects.").getBoolean(true);
enableStatReRegistering = config.get(CATEGORY_GENERAL, "1.33_enableStatReRegistering", true, "If enabled, will re-register item crafting/breaking/usage stats in order to fix a forge bug where modded items just won't show up.").getBoolean(true); enableStatReRegistering = config.get(CATEGORY_GENERAL, "1.33_enableStatReRegistering", true, "If enabled, will re-register item crafting/breaking/usage stats in order to fix a forge bug where modded items just won't show up.").getBoolean(true);

View File

@ -0,0 +1,116 @@
package com.hbm.config;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter;
import com.hbm.main.MainRegistry;
public class RunningConfig {
public static final Gson gson = new Gson();
public static File getConfig(String name) {
File folder = MainRegistry.configHbmDir;
return new File(folder.getAbsolutePath() + File.separatorChar + name);
}
public static void readConfig(File config, HashMap<String, ConfigWrapper> configMap) {
try {
JsonObject json = gson.fromJson(new FileReader(config), JsonObject.class);
for(Entry<String, ConfigWrapper> line : configMap.entrySet()) {
if(json.has(line.getKey())) {
JsonElement value = json.get(line.getKey());
try {
//world's shittiest dynamic type parser
if(configMap.containsKey(line.getKey())) {
if(line.getValue().value instanceof String) configMap.get(line.getKey()).set(value.getAsString());
if(line.getValue().value instanceof Float) configMap.get(line.getKey()).set(value.getAsFloat());
if(line.getValue().value instanceof Double) configMap.get(line.getKey()).set(value.getAsDouble());
if(line.getValue().value instanceof Integer) configMap.get(line.getKey()).set(value.getAsInt());
if(line.getValue().value instanceof Boolean) configMap.get(line.getKey()).set(value.getAsBoolean());
}
//gson doesn't give me the option to read the raw value of a JsonPrimitive so we have to this shit effectively twice
//once to make sure that the parsed data matches with what's determined by the default,
//and a second time in the ConfigWrapper to add ease of reading the data without needing manual casts
} catch(Exception ex) {
ex.printStackTrace();
}
}
}
} catch(Exception ex) {
ex.printStackTrace();
}
}
public static void writeConfig(File config, HashMap<String, ConfigWrapper> configMap, String info) {
try {
JsonWriter writer = new JsonWriter(new FileWriter(config));
writer.setIndent(" ");
writer.beginObject();
writer.name("info").value(info);
List<String> keys = new ArrayList();
keys.addAll(configMap.keySet());
Collections.sort(keys); //readability is cool
for(String key : keys) {
ConfigWrapper wrapper = configMap.get(key);
Object value = wrapper.value;
//this sucks and i am too stupid to come up with something better
if(value instanceof String) writer.name(key).value((String) value);
if(value instanceof Float) writer.name(key).value((Float) value);
if(value instanceof Double) writer.name(key).value((Double) value);
if(value instanceof Integer) writer.name(key).value((Integer) value);
if(value instanceof Boolean) writer.name(key).value((Boolean) value);
}
writer.endObject();
writer.close();
} catch(IOException e) {
e.printStackTrace();
}
}
public static class ConfigWrapper<T> {
public T value;
public ConfigWrapper(T o) {
this.value = o;
}
public T get() { return value; }
public void set(T value) { this.value = value; }
public void update(String param) {
Object stupidBufferObject = null; // wahh wahh can't cast Float to T wahh wahh shut the fuck up
if(value instanceof String) stupidBufferObject = param;
if(value instanceof Float) stupidBufferObject = Float.parseFloat(param);
if(value instanceof Double) stupidBufferObject = Double.parseDouble(param);
if(value instanceof Integer) stupidBufferObject = Integer.parseInt(param);
if(value instanceof Boolean) stupidBufferObject = Boolean.parseBoolean(param);
if(stupidBufferObject != null) this.value = (T) stupidBufferObject;
}
}
}

View File

@ -0,0 +1,56 @@
package com.hbm.config;
import java.io.File;
import java.util.HashMap;
import com.google.gson.Gson;
public class ServerConfig extends RunningConfig {
public static final Gson gson = new Gson();
public static HashMap<String, ConfigWrapper> configMap = new HashMap();
public static ConfigWrapper<Boolean> DAMAGE_COMPATIBILITY_MODE = new ConfigWrapper(false);
public static ConfigWrapper<Float> MINE_AP_DAMAGE = new ConfigWrapper(10F);
public static ConfigWrapper<Float> MINE_HE_DAMAGE = new ConfigWrapper(35F);
public static ConfigWrapper<Float> MINE_SHRAP_DAMAGE = new ConfigWrapper(7.5F);
public static ConfigWrapper<Float> MINE_NUKE_DAMAGE = new ConfigWrapper(100F);
public static ConfigWrapper<Boolean> TAINT_TRAILS = new ConfigWrapper(false);
private static void initDefaults() {
configMap.put("DAMAGE_COMPATIBILITY_MODE", DAMAGE_COMPATIBILITY_MODE);
configMap.put("MINE_AP_DAMAGE", MINE_AP_DAMAGE);
configMap.put("MINE_HE_DAMAGE", MINE_HE_DAMAGE);
configMap.put("MINE_SHRAP_DAMAGE", MINE_SHRAP_DAMAGE);
configMap.put("MINE_NUKE_DAMAGE", MINE_NUKE_DAMAGE);
configMap.put("TAINT_TRAILS", TAINT_TRAILS);
}
/** Initializes defaults, then reads the config file if it exists, then writes the config file. */
public static void initConfig() {
initDefaults();
File config = getConfig("hbmServer.json");
if(config.exists()) readConfig(config);
refresh();
}
/** Writes over the config file using the running config. */
public static void refresh() {
File config = getConfig("hbmServer.json");
writeConfig(config);
}
/** Writes over the running config using the config file. */
public static void reload() {
File config = getConfig("hbmServer.json");
if(config.exists()) readConfig(config);
}
private static void readConfig(File config) {
RunningConfig.readConfig(config, configMap);
}
private static void writeConfig(File config) {
RunningConfig.writeConfig(config, configMap, "This file can be edited ingame using the /ntmserver command.");
}
}

View File

@ -7,36 +7,40 @@ import com.hbm.main.MainRegistry;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
public class StructureConfig { public class StructureConfig {
public static int enableStructures = 2; public static int enableStructures = 2;
public static int structureMinChunks = 8; public static int structureMinChunks = 8;
public static int structureMaxChunks = 24; public static int structureMaxChunks = 24;
public static double lootAmountFactor = 1D; public static double lootAmountFactor = 1D;
public static boolean debugStructures = false;
public static void loadFromConfig(Configuration config) { public static void loadFromConfig(Configuration config) {
final String CATEGORY_STRUCTURES = CommonConfig.CATEGORY_STRUCTURES; final String CATEGORY_STRUCTURES = CommonConfig.CATEGORY_STRUCTURES;
String unparsedStructureFlag = CommonConfig.createConfigString(config, CATEGORY_STRUCTURES, "5.00_enableStructures", "Flag for whether modern NTM structures will spawn. Valid values are true|false|flag - flag will respect the \"Generate Structures\" world flag.", "flag"); String unparsedStructureFlag = CommonConfig.createConfigString(config, CATEGORY_STRUCTURES, "5.00_enableStructures", "Flag for whether modern NTM structures will spawn. Valid values are true|false|flag - flag will respect the \"Generate Structures\" world flag.", "flag");
enableStructures = CommonConfig.parseStructureFlag(unparsedStructureFlag); enableStructures = CommonConfig.parseStructureFlag(unparsedStructureFlag);
structureMinChunks = CommonConfig.createConfigInt(config, CATEGORY_STRUCTURES, "5.01_structureMinChunks", "Minimum non-zero distance between structures in chunks (Settings lower than 8 may be problematic).", 8); structureMinChunks = CommonConfig.createConfigInt(config, CATEGORY_STRUCTURES, "5.01_structureMinChunks", "Minimum non-zero distance between structures in chunks (Settings lower than 8 may be problematic).", 8);
structureMaxChunks = CommonConfig.createConfigInt(config, CATEGORY_STRUCTURES, "5.02_structureMaxChunks", "Maximum non-zero distance between structures in chunks.", 24); structureMaxChunks = CommonConfig.createConfigInt(config, CATEGORY_STRUCTURES, "5.02_structureMaxChunks", "Maximum non-zero distance between structures in chunks.", 24);
lootAmountFactor = CommonConfig.createConfigDouble(config, CATEGORY_STRUCTURES, "5.03_lootAmountFactor", "General factor for loot spawns. Applies to spawned IInventories, not loot blocks.", 1D); lootAmountFactor = CommonConfig.createConfigDouble(config, CATEGORY_STRUCTURES, "5.03_lootAmountFactor", "General factor for loot spawns. Applies to spawned IInventories, not loot blocks.", 1D);
debugStructures = CommonConfig.createConfigBool(config, CATEGORY_STRUCTURES, "5.04_debugStructures", "If enabled, special structure blocks like jigsaw blocks will not be transformed after generating", false);
structureMinChunks = CommonConfig.setDef(structureMinChunks, 8); structureMinChunks = CommonConfig.setDef(structureMinChunks, 8);
structureMaxChunks = CommonConfig.setDef(structureMaxChunks, 24); structureMaxChunks = CommonConfig.setDef(structureMaxChunks, 24);
if(structureMinChunks > structureMaxChunks) { if(structureMinChunks > structureMaxChunks) {
MainRegistry.logger.error("Fatal error config: Minimum value has been set higher than the maximum value!"); MainRegistry.logger.error("Fatal error config: Minimum value has been set higher than the maximum value!");
MainRegistry.logger.error(String.format(Locale.US, "Errored values will default back to %1$d and %2$d respectively, PLEASE REVIEW CONFIGURATION DESCRIPTION BEFORE MEDDLING WITH VALUES!", 8, 24)); MainRegistry.logger.error(String.format(Locale.US, "Errored values will default back to %1$d and %2$d respectively, PLEASE REVIEW CONFIGURATION DESCRIPTION BEFORE MEDDLING WITH VALUES!", 8, 24));
structureMinChunks = 8; structureMinChunks = 8;
structureMaxChunks = 24; structureMaxChunks = 24;
} }
} }
} }

View File

@ -7,7 +7,7 @@ public class WorldConfig {
public static boolean overworldOre = true; public static boolean overworldOre = true;
public static boolean netherOre = true; public static boolean netherOre = true;
public static boolean endOre = true; public static boolean endOre = true;
public static int uraniumSpawn = 6; public static int uraniumSpawn = 6;
public static int thoriumSpawn = 7; public static int thoriumSpawn = 7;
public static int titaniumSpawn = 8; public static int titaniumSpawn = 8;
@ -74,10 +74,16 @@ public class WorldConfig {
public static int endTikiteSpawn = 8; public static int endTikiteSpawn = 8;
public static boolean enableHematite = true;
public static boolean enableMalachite = true;
public static boolean enableBauxite = true;
public static boolean enableSulfurCave = true;
public static boolean enableAsbestosCave = true;
public static int radioStructure = 500; public static int radioStructure = 500;
public static int antennaStructure = 250; public static int antennaStructure = 250;
public static int atomStructure = 500; public static int atomStructure = 500;
public static int vertibirdStructure = 500;
public static int dungeonStructure = 64; public static int dungeonStructure = 64;
public static int relayStructure = 500; public static int relayStructure = 500;
public static int satelliteStructure = 500; public static int satelliteStructure = 500;
@ -88,7 +94,6 @@ public class WorldConfig {
public static int geyserWater = 3000; public static int geyserWater = 3000;
public static int geyserChlorine = 3000; public static int geyserChlorine = 3000;
public static int geyserVapor = 500; public static int geyserVapor = 500;
public static int meteorStructure = 15000;
public static int capsuleStructure = 100; public static int capsuleStructure = 100;
public static int arcticStructure = 500; public static int arcticStructure = 500;
public static int jungleStructure = 2000; public static int jungleStructure = 2000;
@ -115,15 +120,15 @@ public class WorldConfig {
public static float craterBiomeInnerRad = 25F; public static float craterBiomeInnerRad = 25F;
public static float craterBiomeOuterRad = 0.5F; public static float craterBiomeOuterRad = 0.5F;
public static float craterBiomeWaterMult = 5F; public static float craterBiomeWaterMult = 5F;
public static void loadFromConfig(Configuration config) { public static void loadFromConfig(Configuration config) {
final String CATEGORY_OREGEN = CommonConfig.CATEGORY_ORES; final String CATEGORY_OREGEN = CommonConfig.CATEGORY_ORES;
overworldOre = CommonConfig.createConfigBool(config, CATEGORY_OREGEN, "2.D00_overworldOres", "General switch for whether overworld ores should be generated. Does not include special structures like oil.", true); overworldOre = CommonConfig.createConfigBool(config, CATEGORY_OREGEN, "2.D00_overworldOres", "General switch for whether overworld ores should be generated. Does not include special structures like oil.", true);
netherOre = CommonConfig.createConfigBool(config, CATEGORY_OREGEN, "2.D01_netherOres", "General switch for whether nether ores should be generated.", true); netherOre = CommonConfig.createConfigBool(config, CATEGORY_OREGEN, "2.D01_netherOres", "General switch for whether nether ores should be generated.", true);
endOre = CommonConfig.createConfigBool(config, CATEGORY_OREGEN, "2.D02_endOres", "General switch for whether end ores should be generated. Does not include special structures like trixite crystals.", true); endOre = CommonConfig.createConfigBool(config, CATEGORY_OREGEN, "2.D02_endOres", "General switch for whether end ores should be generated. Does not include special structures like trixite crystals.", true);
uraniumSpawn = CommonConfig.createConfigInt(config, CATEGORY_OREGEN, "2.00_uraniumSpawnrate", "Amount of uranium ore veins per chunk", 7); uraniumSpawn = CommonConfig.createConfigInt(config, CATEGORY_OREGEN, "2.00_uraniumSpawnrate", "Amount of uranium ore veins per chunk", 7);
titaniumSpawn = CommonConfig.createConfigInt(config, CATEGORY_OREGEN, "2.01_titaniumSpawnrate", "Amount of titanium ore veins per chunk", 8); titaniumSpawn = CommonConfig.createConfigInt(config, CATEGORY_OREGEN, "2.01_titaniumSpawnrate", "Amount of titanium ore veins per chunk", 8);
sulfurSpawn = CommonConfig.createConfigInt(config, CATEGORY_OREGEN, "2.02_sulfurSpawnrate", "Amount of sulfur ore veins per chunk", 5); sulfurSpawn = CommonConfig.createConfigInt(config, CATEGORY_OREGEN, "2.02_sulfurSpawnrate", "Amount of sulfur ore veins per chunk", 5);
@ -191,11 +196,17 @@ public class WorldConfig {
endTikiteSpawn = CommonConfig.createConfigInt(config, CATEGORY_OREGEN, "2.E00_tikiteSpawnrate", "Amount of end trixite per chunk", 8); endTikiteSpawn = CommonConfig.createConfigInt(config, CATEGORY_OREGEN, "2.E00_tikiteSpawnrate", "Amount of end trixite per chunk", 8);
enableHematite = CommonConfig.createConfigBool(config, CATEGORY_OREGEN, "2.L00_enableHematite", "Toggles hematite deposits", true);
enableMalachite = CommonConfig.createConfigBool(config, CATEGORY_OREGEN, "2.L01_enableMalachite", "Toggles malachite deposits", true);
enableBauxite = CommonConfig.createConfigBool(config, CATEGORY_OREGEN, "2.L02_enableBauxite", "Toggles bauxite deposits", true);
enableSulfurCave = CommonConfig.createConfigBool(config, CATEGORY_OREGEN, "2.C00_enableSulfurCave", "Toggles sulfur caves", true);
enableAsbestosCave = CommonConfig.createConfigBool(config, CATEGORY_OREGEN, "2.C01_enableAsbestosCave", "Toggles asbestos caves", true);
final String CATEGORY_DUNGEON = CommonConfig.CATEGORY_DUNGEONS; final String CATEGORY_DUNGEON = CommonConfig.CATEGORY_DUNGEONS;
radioStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.00_radioSpawn", "Spawn radio station on every nTH chunk", 500); radioStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.00_radioSpawn", "Spawn radio station on every nTH chunk", 500);
antennaStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.01_antennaSpawn", "Spawn antenna on every nTH chunk", 250); antennaStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.01_antennaSpawn", "Spawn antenna on every nTH chunk", 250);
atomStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.02_atomSpawn", "Spawn power plant on every nTH chunk", 500); atomStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.02_atomSpawn", "Spawn power plant on every nTH chunk", 500);
vertibirdStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.03_vertibirdSpawn", "Spawn vertibird on every nTH chunk", 500);
dungeonStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.04_dungeonSpawn", "Spawn library dungeon on every nTH chunk", 64); dungeonStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.04_dungeonSpawn", "Spawn library dungeon on every nTH chunk", 64);
relayStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.05_relaySpawn", "Spawn relay on every nTH chunk", 500); relayStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.05_relaySpawn", "Spawn relay on every nTH chunk", 500);
satelliteStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.06_satelliteSpawn", "Spawn satellite dish on every nTH chunk", 500); satelliteStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.06_satelliteSpawn", "Spawn satellite dish on every nTH chunk", 500);
@ -210,7 +221,6 @@ public class WorldConfig {
geyserWater = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.17_geyserWaterSpawn", "Spawn water geyser on every nTH chunk", 3000); geyserWater = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.17_geyserWaterSpawn", "Spawn water geyser on every nTH chunk", 3000);
geyserChlorine = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.18_geyserChlorineSpawn", "Spawn poison geyser on every nTH chunk", 3000); geyserChlorine = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.18_geyserChlorineSpawn", "Spawn poison geyser on every nTH chunk", 3000);
geyserVapor = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.19_geyserVaporSpawn", "Spawn vapor geyser on every nTH chunk", 500); geyserVapor = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.19_geyserVaporSpawn", "Spawn vapor geyser on every nTH chunk", 500);
meteorStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.20_meteorSpawn", "Spawn meteor dungeon on every nTH chunk", 15000);
capsuleStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.21_capsuleSpawn", "Spawn landing capsule on every nTH chunk", 100); capsuleStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.21_capsuleSpawn", "Spawn landing capsule on every nTH chunk", 100);
arcticStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.22_arcticVaultSpawn", "Spawn arctic code vault on every nTH chunk", 500); arcticStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.22_arcticVaultSpawn", "Spawn arctic code vault on every nTH chunk", 500);
jungleStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.23_jungleDungeonSpawn", "Spawn jungle dungeon on every nTH chunk", 2000); jungleStructure = CommonConfig.createConfigInt(config, CATEGORY_DUNGEON, "4.23_jungleDungeonSpawn", "Spawn jungle dungeon on every nTH chunk", 2000);
@ -238,7 +248,6 @@ public class WorldConfig {
radioStructure = CommonConfig.setDefZero(radioStructure, 1000); radioStructure = CommonConfig.setDefZero(radioStructure, 1000);
antennaStructure = CommonConfig.setDefZero(antennaStructure, 1000); antennaStructure = CommonConfig.setDefZero(antennaStructure, 1000);
atomStructure = CommonConfig.setDefZero(atomStructure, 1000); atomStructure = CommonConfig.setDefZero(atomStructure, 1000);
vertibirdStructure = CommonConfig.setDefZero(vertibirdStructure, 1000);
dungeonStructure = CommonConfig.setDefZero(dungeonStructure, 1000); dungeonStructure = CommonConfig.setDefZero(dungeonStructure, 1000);
relayStructure = CommonConfig.setDefZero(relayStructure, 1000); relayStructure = CommonConfig.setDefZero(relayStructure, 1000);
satelliteStructure = CommonConfig.setDefZero(satelliteStructure, 1000); satelliteStructure = CommonConfig.setDefZero(satelliteStructure, 1000);
@ -253,11 +262,10 @@ public class WorldConfig {
minefreq = CommonConfig.setDefZero(minefreq, 1000); minefreq = CommonConfig.setDefZero(minefreq, 1000);
radfreq = CommonConfig.setDefZero(radfreq, 1000); radfreq = CommonConfig.setDefZero(radfreq, 1000);
vaultfreq = CommonConfig.setDefZero(vaultfreq, 1000); vaultfreq = CommonConfig.setDefZero(vaultfreq, 1000);
meteorStructure = CommonConfig.setDefZero(meteorStructure, 15000);
jungleStructure = CommonConfig.setDefZero(jungleStructure, 1000); jungleStructure = CommonConfig.setDefZero(jungleStructure, 1000);
capsuleStructure = CommonConfig.setDefZero(capsuleStructure, 100); capsuleStructure = CommonConfig.setDefZero(capsuleStructure, 100);
arcticStructure = CommonConfig.setDefZero(arcticStructure, 500); arcticStructure = CommonConfig.setDefZero(arcticStructure, 500);
meteorStrikeChance = CommonConfig.setDef(meteorStrikeChance, 1000); meteorStrikeChance = CommonConfig.setDef(meteorStrikeChance, 1000);
meteorShowerChance = CommonConfig.setDef(meteorShowerChance, 1000); meteorShowerChance = CommonConfig.setDef(meteorShowerChance, 1000);
} }

View File

@ -163,10 +163,7 @@ public class ToolRecipes {
CraftingManager.addRecipeAuto(new ItemStack(ModItems.boltgun), new Object[] { "DPS", " RD", " D ", 'D', DURA.ingot(), 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'R', RUBBER.ingot(), 'S', STEEL.shell() }); CraftingManager.addRecipeAuto(new ItemStack(ModItems.boltgun), new Object[] { "DPS", " RD", " D ", 'D', DURA.ingot(), 'P', DictFrame.fromOne(ModItems.part_generic, EnumPartType.PISTON_PNEUMATIC), 'R', RUBBER.ingot(), 'S', STEEL.shell() });
//Bobmazon //Bobmazon
CraftingManager.addShapelessAuto(new ItemStack(ModItems.bobmazon_materials), new Object[] { Items.book, Items.gold_nugget, Items.string }); CraftingManager.addShapelessAuto(new ItemStack(ModItems.bobmazon), new Object[] { Items.book, Items.gold_nugget, Items.string, KEY_BLUE });
CraftingManager.addShapelessAuto(new ItemStack(ModItems.bobmazon_machines), new Object[] { Items.book, Items.gold_nugget, KEY_RED });
CraftingManager.addShapelessAuto(new ItemStack(ModItems.bobmazon_weapons), new Object[] { Items.book, Items.gold_nugget, KEY_GRAY });
CraftingManager.addShapelessAuto(new ItemStack(ModItems.bobmazon_tools), new Object[] { Items.book, Items.gold_nugget, KEY_GREEN });
//Carts //Carts
CraftingManager.addRecipeAuto(ItemModMinecart.createCartItem(EnumCartBase.WOOD, EnumMinecart.EMPTY), new Object[] { "P P", "WPW", 'P',KEY_SLAB, 'W', KEY_PLANKS }); CraftingManager.addRecipeAuto(ItemModMinecart.createCartItem(EnumCartBase.WOOD, EnumMinecart.EMPTY), new Object[] { "P P", "WPW", 'P',KEY_SLAB, 'W', KEY_PLANKS });

View File

@ -6,50 +6,52 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.special.ItemBookLore;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.World; import net.minecraft.world.World;
public class MKUCraftingHandler implements IRecipe { public class MKUCraftingHandler implements IRecipe {
public static ItemStack[] MKURecipe; public static ItemStack[] MKURecipe;
private static long lastSeed; private static long lastSeed;
@Override @Override
public boolean matches(InventoryCrafting inventory, World world) { public boolean matches(InventoryCrafting inventory, World world) {
if(world == null) if(world == null)
return false; return false;
if(MKURecipe == null || world.getSeed() != lastSeed) if(MKURecipe == null || world.getSeed() != lastSeed)
generateRecipe(world); generateRecipe(world);
for(int i = 0; i < 9; i++) { for(int i = 0; i < 9; i++) {
ItemStack stack = inventory.getStackInRowAndColumn(i % 3, i / 3); ItemStack stack = inventory.getStackInRowAndColumn(i % 3, i / 3);
ItemStack recipe = MKURecipe[i]; ItemStack recipe = MKURecipe[i];
if(stack == null && recipe == null) if(stack == null && recipe == null)
continue; continue;
if(stack != null && recipe != null && stack.getItem() == recipe.getItem() && stack.getItemDamage() == recipe.getItemDamage()) if(stack != null && recipe != null && stack.getItem() == recipe.getItem() && stack.getItemDamage() == recipe.getItemDamage())
continue; continue;
return false; return false;
} }
return true; return true;
} }
public static void generateRecipe(World world) { public static void generateRecipe(World world) {
Random rand = new Random(world.getSeed()); Random rand = new Random(world.getSeed());
if(lastSeed == world.getSeed() && MKURecipe != null) if(lastSeed == world.getSeed() && MKURecipe != null)
return; return;
lastSeed = world.getSeed(); lastSeed = world.getSeed();
List<ItemStack> list = Arrays.asList(new ItemStack[] { List<ItemStack> list = Arrays.asList(new ItemStack[] {
new ItemStack(ModItems.powder_iodine), new ItemStack(ModItems.powder_iodine),
new ItemStack(ModItems.powder_fire), new ItemStack(ModItems.powder_fire),
@ -61,12 +63,54 @@ public class MKUCraftingHandler implements IRecipe {
null, null,
null null
}); });
Collections.shuffle(list, rand); Collections.shuffle(list, rand);
MKURecipe = list.toArray(new ItemStack[9]); MKURecipe = list.toArray(new ItemStack[9]);
} }
public static Item getMKUItem(World world) {
switch(world.rand.nextInt(6)) {
case 0: return ModItems.powder_iodine;
case 1: return ModItems.powder_fire;
case 2: return ModItems.dust;
case 3: return ModItems.ingot_mercury;
case 4: return ModItems.morning_glory;
case 5: return ModItems.syringe_metal_empty;
default: return ModItems.flame_pony;
}
}
public static ItemStack generateBook(World world, Item mkuItem) {
MKUCraftingHandler.generateRecipe(world);
ItemStack[] recipe = MKUCraftingHandler.MKURecipe;
if(recipe == null) return new ItemStack(ModItems.flame_pony);
String key = null;
int pages = 1;
if(mkuItem == ModItems.powder_iodine) { key = "book_iodine"; pages = 3; }
if(mkuItem == ModItems.powder_fire) { key = "book_phosphorous"; pages = 2; }
if(mkuItem == ModItems.dust) { key = "book_dust"; pages = 3; }
if(mkuItem == ModItems.ingot_mercury) { key = "book_mercury"; pages = 2; }
if(mkuItem == ModItems.morning_glory) { key = "book_flower"; pages = 2; }
if(mkuItem == ModItems.syringe_metal_empty) { key = "book_syringe"; pages = 2; }
if(key == null) return new ItemStack(ModItems.flame_pony);
int s = 1;
for(int i = 0; i < 9; i++) {
if(recipe[i] != null && recipe[i].getItem() == mkuItem) {
s = i + 1; break;
}
}
ItemStack book = ItemBookLore.createBook(key, pages, 0x271E44, 0xFBFFF4);
ItemBookLore.addArgs(book, pages - 1, String.valueOf(s));
return book;
}
@Override @Override
public int getRecipeSize() { public int getRecipeSize() {
return 6; return 6;
@ -81,4 +125,4 @@ public class MKUCraftingHandler implements IRecipe {
public ItemStack getRecipeOutput() { public ItemStack getRecipeOutput() {
return new ItemStack(ModItems.syringe_mkunicorn); return new ItemStack(ModItems.syringe_mkunicorn);
} }
} }

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.bomb.BlockTaint;
import com.hbm.entity.effect.EntityNukeTorex; import com.hbm.entity.effect.EntityNukeTorex;
import com.hbm.entity.logic.EntityBalefire; import com.hbm.entity.logic.EntityBalefire;
import com.hbm.entity.logic.EntityNukeExplosionMK5; import com.hbm.entity.logic.EntityNukeExplosionMK5;
@ -22,6 +21,7 @@ import com.hbm.items.weapon.ItemCustomMissilePart.WarheadType;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import api.hbm.entity.IRadarDetectableNT; import api.hbm.entity.IRadarDetectableNT;
import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -211,7 +211,8 @@ public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLo
int a = rand.nextInt(r) + (int) posX - (r / 2 - 1); int a = rand.nextInt(r) + (int) posX - (r / 2 - 1);
int b = rand.nextInt(r) + (int) posY - (r / 2 - 1); int b = rand.nextInt(r) + (int) posY - (r / 2 - 1);
int c = rand.nextInt(r) + (int) posZ - (r / 2 - 1); int c = rand.nextInt(r) + (int) posZ - (r / 2 - 1);
if(worldObj.getBlock(a, b, c).isReplaceable(worldObj, a, b, c) && BlockTaint.hasPosNeightbour(worldObj, a, b, c)) { Block block = worldObj.getBlock(a, b, c);
if(block.isNormalCube() && !block.isAir(worldObj, a, b, c)) {
worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3) + 4, 2); worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3) + 4, 2);
} }
} }

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.bomb.BlockTaint;
import com.hbm.config.BombConfig; import com.hbm.config.BombConfig;
import com.hbm.entity.effect.EntityBlackHole; import com.hbm.entity.effect.EntityBlackHole;
import com.hbm.entity.effect.EntityCloudFleija; import com.hbm.entity.effect.EntityCloudFleija;
@ -128,7 +127,10 @@ public abstract class EntityMissileTier0 extends EntityMissileBaseNT {
int a = rand.nextInt(11) + (int) this.posX - 5; int a = rand.nextInt(11) + (int) this.posX - 5;
int b = rand.nextInt(11) + (int) this.posY - 5; int b = rand.nextInt(11) + (int) this.posY - 5;
int c = rand.nextInt(11) + (int) this.posZ - 5; int c = rand.nextInt(11) + (int) this.posZ - 5;
if(worldObj.getBlock(a, b, c).isReplaceable(worldObj, a, b, c) && BlockTaint.hasPosNeightbour(worldObj, a, b, c)) worldObj.setBlock(a, b, c, ModBlocks.taint); Block block = worldObj.getBlock(a, b, c);
if(block.isNormalCube() && !block.isAir(worldObj, a, b, c)) {
worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3) + 4, 2);
}
} }
} }
@Override public ItemStack getDebrisRareDrop() { return new ItemStack(ModItems.powder_spark_mix, 1); } @Override public ItemStack getDebrisRareDrop() { return new ItemStack(ModItems.powder_spark_mix, 1); }

View File

@ -1,7 +1,7 @@
package com.hbm.entity.mob; package com.hbm.entity.mob;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.config.GeneralConfig; import com.hbm.config.ServerConfig;
import api.hbm.entity.IRadiationImmune; import api.hbm.entity.IRadiationImmune;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -55,9 +55,9 @@ public class EntityCreeperTainted extends EntityCreeper implements IRadiationImm
int a = rand.nextInt(15) + (int) posX - 7; int a = rand.nextInt(15) + (int) posX - 7;
int b = rand.nextInt(15) + (int) posY - 7; int b = rand.nextInt(15) + (int) posY - 7;
int c = rand.nextInt(15) + (int) posZ - 7; int c = rand.nextInt(15) + (int) posZ - 7;
Block block = worldObj.getBlock(a, b, c);
if(worldObj.getBlock(a, b, c).isReplaceable(worldObj, a, b, c) && hasPosNeightbour(worldObj, a, b, c)) { if(block.isNormalCube() && !block.isAir(worldObj, a, b, c)) {
if(!GeneralConfig.enableHardcoreTaint) { if(!ServerConfig.TAINT_TRAILS.get()) {
worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3) + 5, 2); worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3) + 5, 2);
} else { } else {
worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3), 2); worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3), 2);
@ -71,9 +71,9 @@ public class EntityCreeperTainted extends EntityCreeper implements IRadiationImm
int a = rand.nextInt(7) + (int) posX - 3; int a = rand.nextInt(7) + (int) posX - 3;
int b = rand.nextInt(7) + (int) posY - 3; int b = rand.nextInt(7) + (int) posY - 3;
int c = rand.nextInt(7) + (int) posZ - 3; int c = rand.nextInt(7) + (int) posZ - 3;
Block block = worldObj.getBlock(a, b, c);
if(worldObj.getBlock(a, b, c).isReplaceable(worldObj, a, b, c) && hasPosNeightbour(worldObj, a, b, c)) { if(block.isNormalCube() && !block.isAir(worldObj, a, b, c)) {
if(!GeneralConfig.enableHardcoreTaint) { if(!ServerConfig.TAINT_TRAILS.get()) {
worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(6) + 10, 2); worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(6) + 10, 2);
} else { } else {
worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3) + 4, 2); worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3) + 4, 2);

View File

@ -12,7 +12,7 @@ import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ExplosionNukeSmall { @Deprecated public class ExplosionNukeSmall {
public static void explode(World world, double posX, double posY, double posZ, MukeParams params) { public static void explode(World world, double posX, double posY, double posZ, MukeParams params) {

View File

@ -4,6 +4,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockConcreteColoredExt.EnumConcreteType;
import com.hbm.blocks.generic.BlockNTMFlower.EnumFlowerType;
import com.hbm.blocks.generic.BlockPlushie.PlushieType;
import com.hbm.blocks.generic.BlockSnowglobe.SnowglobeType;
import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.gui.GUIScreenBobmazon.Offer; import com.hbm.inventory.gui.GUIScreenBobmazon.Offer;
import com.hbm.inventory.gui.GUIScreenBobmazon.Requirement; import com.hbm.inventory.gui.GUIScreenBobmazon.Requirement;
@ -14,124 +18,38 @@ import com.hbm.items.special.ItemKitCustom;
import com.hbm.items.special.ItemKitNBT; import com.hbm.items.special.ItemKitNBT;
import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmo; import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmo;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class BobmazonOfferFactory { public class BobmazonOfferFactory {
public static List<Offer> materials = new ArrayList(); public static List<Offer> standard = new ArrayList();
public static List<Offer> machines = new ArrayList();
public static List<Offer> weapons = new ArrayList();
public static List<Offer> tools = new ArrayList();
public static List<Offer> special = new ArrayList(); public static List<Offer> special = new ArrayList();
public static void init() { public static void init() {
materials.clear(); standard.clear();
machines.clear();
weapons.clear();
tools.clear();
special.clear(); special.clear();
int inflation = 5; //gear
materials.add(new Offer(new ItemStack(ModItems.ingot_uranium), Requirement.NUCLEAR, 6 * inflation)); standard.add(new Offer(new ItemStack(Blocks.torch, 64), Requirement.NONE, 2));
materials.add(new Offer(new ItemStack(ModItems.ingot_u233), Requirement.NUCLEAR, 20 * inflation)); standard.add(new Offer(new ItemStack(ModItems.definitelyfood, 16), Requirement.NONE, 4));
materials.add(new Offer(new ItemStack(ModItems.ingot_u238), Requirement.NUCLEAR, 15 * inflation)); standard.add(new Offer(new ItemStack(ModItems.nitra, 4), Requirement.CHEMICS, 16));
materials.add(new Offer(new ItemStack(ModItems.ingot_th232), Requirement.NUCLEAR, 4 * inflation)); standard.add(new Offer(new ItemStack(ModItems.gun_kit_1, 1), Requirement.ASSEMBLY, 16));
materials.add(new Offer(new ItemStack(ModItems.ingot_plutonium), Requirement.NUCLEAR, 25 * inflation)); standard.add(new Offer(new ItemStack(ModItems.geiger_counter, 1), Requirement.NONE, 16));
materials.add(new Offer(new ItemStack(ModItems.ingot_titanium), Requirement.STEEL, 2 * inflation)); standard.add(new Offer(new ItemStack(ModItems.matchstick, 16), Requirement.STEEL, 2));
materials.add(new Offer(new ItemStack(ModItems.ingot_copper), Requirement.STEEL, 2 * inflation)); //plants
materials.add(new Offer(new ItemStack(ModItems.ingot_red_copper), Requirement.STEEL, 4 * inflation)); standard.add(new Offer(new ItemStack(Blocks.sapling, 1, 3), Requirement.STEEL, 12, 9));
materials.add(new Offer(new ItemStack(ModItems.ingot_tungsten), Requirement.STEEL, 3 * inflation)); standard.add(new Offer(new ItemStack(ModBlocks.plant_flower, 1, EnumFlowerType.FOXGLOVE.ordinal()), Requirement.STEEL, 16, 5));
materials.add(new Offer(new ItemStack(ModItems.ingot_aluminium), Requirement.STEEL, 2 * inflation)); standard.add(new Offer(new ItemStack(ModBlocks.plant_flower, 1, EnumFlowerType.TOBACCO.ordinal()), Requirement.STEEL, 16, 9));
materials.add(new Offer(new ItemStack(ModItems.ingot_steel), Requirement.STEEL, 4 * inflation)); standard.add(new Offer(new ItemStack(ModBlocks.plant_flower, 1, EnumFlowerType.NIGHTSHADE.ordinal()), Requirement.STEEL, 16, 3));
materials.add(new Offer(new ItemStack(ModItems.ingot_lead), Requirement.STEEL, 2 * inflation)); standard.add(new Offer(new ItemStack(ModBlocks.plant_flower, 1, EnumFlowerType.WEED.ordinal()), Requirement.STEEL, 4, 10));
materials.add(new Offer(new ItemStack(ModItems.ingot_polymer), Requirement.OIL, 8 * inflation)); standard.add(new Offer(new ItemStack(ModBlocks.plant_flower, 1, EnumFlowerType.CD0.ordinal()), Requirement.NUCLEAR, 64, 8));
materials.add(new Offer(new ItemStack(ModItems.ingot_uranium_fuel), Requirement.NUCLEAR, 18 * inflation)); //deco
materials.add(new Offer(new ItemStack(ModItems.ingot_thorium_fuel), Requirement.NUCLEAR, 16 * inflation)); for(EnumConcreteType conc : EnumConcreteType.values()) standard.add(new Offer(new ItemStack(ModBlocks.concrete_colored_ext, 16, conc.ordinal()), Requirement.CHEMICS, 4));
materials.add(new Offer(new ItemStack(ModItems.ingot_desh), Requirement.OIL, 16 * inflation)); for(SnowglobeType globe : SnowglobeType.values()) standard.add(new Offer(new ItemStack(ModBlocks.snowglobe, 1, globe.ordinal()), Requirement.CHEMICS, 128));
materials.add(new Offer(new ItemStack(ModItems.ingot_saturnite), Requirement.STEEL, 8 * inflation)); for(int i = 1; i < PlushieType.values().length; i++) standard.add(new Offer(new ItemStack(ModBlocks.plushie, 1, i), Requirement.OIL, 16, i < 3 ? 10 : 0));
materials.add(new Offer(new ItemStack(ModItems.lithium), Requirement.CHEMICS, 6 * inflation));
materials.add(new Offer(new ItemStack(ModItems.solid_fuel), Requirement.OIL, 4 * inflation));
materials.add(new Offer(new ItemStack(ModItems.lignite), Requirement.STEEL, 2 * inflation));
materials.add(new Offer(new ItemStack(ModItems.canister_full, 1, Fluids.OIL.getID()), Requirement.OIL, 4 * inflation));
materials.add(new Offer(new ItemStack(ModItems.canister_full, 1, Fluids.DIESEL.getID()), Requirement.OIL, 16 * inflation));
materials.add(new Offer(new ItemStack(ModItems.canister_full, 1, Fluids.PETROIL.getID()), Requirement.OIL, 12 * inflation));
materials.add(new Offer(new ItemStack(ModItems.canister_full, 1, Fluids.GASOLINE.getID()), Requirement.OIL, 20 * inflation));
materials.add(new Offer(new ItemStack(ModItems.canister_full, 1, Fluids.KEROSENE.getID()), Requirement.OIL, 20 * inflation));
materials.add(new Offer(new ItemStack(ModItems.canister_full, 1, Fluids.NITAN.getID()), Requirement.OIL, 100 * inflation));
materials.add(new Offer(new ItemStack(ModItems.gas_full, 1, Fluids.PETROLEUM.getID()), Requirement.OIL, 8 * inflation));
materials.add(new Offer(new ItemStack(ModItems.motor), Requirement.ASSEMBLY, 12 * inflation));
materials.add(new Offer(new ItemStack(ModItems.rtg_unit), Requirement.NUCLEAR, 25 * inflation));
materials.add(new Offer(new ItemStack(ModItems.pellet_gas), Requirement.CHEMICS, 4 * inflation));
materials.add(new Offer(new ItemStack(ModItems.magnetron), Requirement.ASSEMBLY, 10 * inflation));
materials.add(new Offer(new ItemStack(ModItems.pellet_rtg), Requirement.NUCLEAR, 27 * inflation));
materials.add(new Offer(new ItemStack(ModItems.piston_selenium), Requirement.ASSEMBLY, 12 * inflation));
materials.add(new Offer(ItemBattery.getFullBattery(ModItems.battery_advanced), Requirement.ASSEMBLY, 15 * inflation));
materials.add(new Offer(ItemBattery.getFullBattery(ModItems.battery_lithium), Requirement.CHEMICS, 30 * inflation));
materials.add(new Offer(new ItemStack(ModItems.arc_electrode), Requirement.ASSEMBLY, 15 * inflation));
materials.add(new Offer(new ItemStack(ModItems.fuse), Requirement.ASSEMBLY, 5 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.concrete_smooth, 16), Requirement.CHEMICS, 32 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.brick_compound, 8), Requirement.CHEMICS, 48 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.barbed_wire, 16), Requirement.ASSEMBLY, 12 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_siren), Requirement.ASSEMBLY, 12 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.vault_door), Requirement.CHEMICS, 250 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.blast_door), Requirement.CHEMICS, 120 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_epress), Requirement.OIL, 60 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_difurnace_off), Requirement.STEEL, 26 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_gascent), Requirement.OIL, 100 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_diesel), Requirement.CHEMICS, 65 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_geo), Requirement.CHEMICS, 30 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_battery), Requirement.ASSEMBLY, 30 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_lithium_battery), Requirement.CHEMICS, 60 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_assembler), Requirement.ASSEMBLY, 30 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_chemplant), Requirement.CHEMICS, 50 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_shredder), Requirement.ASSEMBLY, 45 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_well), Requirement.OIL, 40 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.machine_refinery), Requirement.OIL, 80 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.absorber), Requirement.CHEMICS, 10 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.absorber_green), Requirement.OIL, 25 * inflation));
machines.add(new Offer(new ItemStack(ModBlocks.decon), Requirement.CHEMICS, 15 * inflation));
weapons.add(new Offer(new ItemStack(ModItems.loot_10), Requirement.OIL, 50 * inflation));
weapons.add(new Offer(new ItemStack(ModItems.loot_15), Requirement.OIL, 65 * inflation));
weapons.add(new Offer(new ItemStack(ModItems.loot_misc), Requirement.NUCLEAR, 65 * inflation));
weapons.add(new Offer(new ItemStack(ModBlocks.launch_pad), Requirement.OIL, 95 * inflation));
weapons.add(new Offer(new ItemStack(ModBlocks.machine_radar), Requirement.OIL, 90 * inflation));
weapons.add(new Offer(new ItemStack(ModItems.designator), Requirement.CHEMICS, 35 * inflation));
weapons.add(new Offer(new ItemStack(ModItems.designator_range), Requirement.CHEMICS, 50 * inflation));
weapons.add(new Offer(new ItemStack(ModItems.sat_chip), Requirement.CHEMICS, 35 * inflation));
weapons.add(new Offer(new ItemStack(ModItems.turret_chip), Requirement.CHEMICS, 80 * inflation));
weapons.add(new Offer(new ItemStack(ModBlocks.mine_ap, 4), Requirement.ASSEMBLY, 25 * inflation));
weapons.add(new Offer(new ItemStack(ModBlocks.emp_bomb), Requirement.CHEMICS, 90 * inflation));
weapons.add(new Offer(new ItemStack(ModBlocks.det_cord, 16), Requirement.ASSEMBLY, 50 * inflation));
weapons.add(new Offer(new ItemStack(ModBlocks.det_charge), Requirement.CHEMICS, 25 * inflation));
weapons.add(new Offer(new ItemStack(ModItems.detonator), Requirement.ASSEMBLY, 15 * inflation));
weapons.add(new Offer(new ItemStack(ModItems.detonator_laser), Requirement.CHEMICS, 60 * inflation));
weapons.add(new Offer(new ItemStack(ModItems.defuser), Requirement.OIL, 5 * inflation));
tools.add(new Offer(new ItemStack(ModBlocks.crate_can, 1), Requirement.STEEL, 20 * inflation));
tools.add(new Offer(new ItemStack(ModBlocks.machine_keyforge), Requirement.STEEL, 10 * inflation));
tools.add(new Offer(new ItemStack(ModBlocks.machine_satlinker), Requirement.CHEMICS, 50 * inflation));
tools.add(new Offer(new ItemStack(ModItems.oil_detector), Requirement.CHEMICS, 45 * inflation));
tools.add(new Offer(new ItemStack(ModItems.geiger_counter), Requirement.CHEMICS, 10 * inflation));
tools.add(new Offer(new ItemStack(ModItems.key), Requirement.STEEL, 2 * inflation));
tools.add(new Offer(new ItemStack(ModItems.padlock), Requirement.STEEL, 5 * inflation));
tools.add(new Offer(new ItemStack(ModItems.padlock_reinforced), Requirement.OIL, 15 * inflation));
tools.add(new Offer(new ItemStack(ModItems.syringe_antidote, 6), Requirement.STEEL, 10 * inflation));
tools.add(new Offer(new ItemStack(ModItems.syringe_metal_stimpak, 4), Requirement.STEEL, 10 * inflation));
tools.add(new Offer(new ItemStack(ModItems.syringe_metal_medx, 4), Requirement.STEEL, 10 * inflation));
tools.add(new Offer(new ItemStack(ModItems.radaway, 6), Requirement.ASSEMBLY, 30 * inflation));
tools.add(new Offer(new ItemStack(ModItems.radaway_strong, 3), Requirement.ASSEMBLY, 35 * inflation));
tools.add(new Offer(new ItemStack(ModItems.radx, 4), Requirement.ASSEMBLY, 20 * inflation));
tools.add(new Offer(new ItemStack(ModItems.pill_iodine, 6), Requirement.ASSEMBLY, 20 * inflation));
tools.add(new Offer(new ItemStack(ModItems.gas_mask_filter, 1), Requirement.ASSEMBLY, 5 * inflation));
tools.add(new Offer(new ItemStack(ModItems.gun_kit_1, 4), Requirement.OIL, 20 * inflation));
tools.add(new Offer(new ItemStack(ModItems.gun_kit_2, 2), Requirement.OIL, 45 * inflation));
tools.add(new Offer(new ItemStack(ModItems.hazmat_kit), Requirement.ASSEMBLY, 40 * inflation));
tools.add(new Offer(new ItemStack(ModItems.hazmat_red_kit), Requirement.CHEMICS, 100 * inflation));
tools.add(new Offer(new ItemStack(ModItems.hazmat_grey_kit), Requirement.OIL, 160 * inflation));
special.add(new Offer(new ItemStack(Items.iron_ingot, 64), Requirement.STEEL, 1)); special.add(new Offer(new ItemStack(Items.iron_ingot, 64), Requirement.STEEL, 1));
special.add(new Offer(new ItemStack(ModItems.ingot_steel, 64), Requirement.STEEL, 1)); special.add(new Offer(new ItemStack(ModItems.ingot_steel, 64), Requirement.STEEL, 1));
@ -160,8 +78,8 @@ public class BobmazonOfferFactory {
special.add(new Offer(new ItemStack(ModItems.grenade_kit), Requirement.STEEL, 5)); special.add(new Offer(new ItemStack(ModItems.grenade_kit), Requirement.STEEL, 5));
special.add(new Offer(new ItemStack(ModItems.jetpack_vector), Requirement.STEEL, 2)); special.add(new Offer(new ItemStack(ModItems.jetpack_vector), Requirement.STEEL, 2));
special.add(new Offer(new ItemStack(ModItems.jetpack_tank), Requirement.STEEL, 2)); special.add(new Offer(new ItemStack(ModItems.jetpack_tank), Requirement.STEEL, 2));
special.add(new Offer(new ItemStack(ModItems.gun_kit_1, 10), Requirement.STEEL, 1)); special.add(new Offer(new ItemStack(ModItems.gun_kit_1, 1), Requirement.STEEL, 1));
special.add(new Offer(new ItemStack(ModItems.gun_kit_2, 5), Requirement.STEEL, 3)); special.add(new Offer(new ItemStack(ModItems.gun_kit_2, 1), Requirement.STEEL, 3));
special.add(new Offer(new ItemStack(ModBlocks.struct_launcher_core, 1), Requirement.STEEL, 3)); special.add(new Offer(new ItemStack(ModBlocks.struct_launcher_core, 1), Requirement.STEEL, 3));
special.add(new Offer(new ItemStack(ModBlocks.struct_launcher_core_large, 1), Requirement.STEEL, 3)); special.add(new Offer(new ItemStack(ModBlocks.struct_launcher_core_large, 1), Requirement.STEEL, 3));
special.add(new Offer(new ItemStack(ModBlocks.struct_launcher, 40), Requirement.STEEL, 7)); special.add(new Offer(new ItemStack(ModBlocks.struct_launcher, 40), Requirement.STEEL, 7));
@ -242,17 +160,13 @@ public class BobmazonOfferFactory {
new ItemStack(ModItems.ammo_standard, 64, EnumAmmo.CAPACITOR_OVERCHARGE.ordinal()), new ItemStack(ModItems.ammo_standard, 64, EnumAmmo.CAPACITOR_OVERCHARGE.ordinal()),
new ItemStack(ModItems.ammo_standard, 64, EnumAmmo.CAPACITOR_OVERCHARGE.ordinal()), new ItemStack(ModItems.ammo_standard, 64, EnumAmmo.CAPACITOR_OVERCHARGE.ordinal()),
new ItemStack(ModItems.ammo_standard, 64, EnumAmmo.CAPACITOR_OVERCHARGE.ordinal()) new ItemStack(ModItems.ammo_standard, 64, EnumAmmo.CAPACITOR_OVERCHARGE.ordinal())
).setStackDisplayName("Frenchman's Reward"), Requirement.HIDDEN, 32)); ).setStackDisplayName("Frenchie's Reward"), Requirement.HIDDEN, 32));
} }
public static List<Offer> getOffers(ItemStack stack) { public static List<Offer> getOffers(ItemStack stack) {
if(stack != null) { if(stack != null) {
if(stack.getItem() == ModItems.bobmazon) return standard;
if(stack.getItem() == ModItems.bobmazon_materials) return materials;
if(stack.getItem() == ModItems.bobmazon_machines) return machines;
if(stack.getItem() == ModItems.bobmazon_weapons) return weapons;
if(stack.getItem() == ModItems.bobmazon_tools) return tools;
if(stack.getItem() == ModItems.bobmazon_hidden) return special; if(stack.getItem() == ModItems.bobmazon_hidden) return special;
} }

View File

@ -94,7 +94,7 @@ public class CasingEjector implements Cloneable {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void spawnCasing(TextureManager textureManager, SpentCasing config, World world, double x, double y, double z, float pitch, float yaw, boolean crouched) { public void spawnCasing(TextureManager textureManager, SpentCasing config, World world, double x, double y, double z, float pitch, float yaw, boolean crouched) {
Vec3 rotatedMotionVec = rotateVector(getMotion(), pitch + (float) rand.nextGaussian() * getPitchFactor(), yaw + (float) rand.nextGaussian() * getPitchFactor(), getPitchFactor(), getPitchFactor()); Vec3 rotatedMotionVec = rotateVector(getMotion(), pitch + (float) rand.nextGaussian() * getPitchFactor(), yaw + (float) rand.nextGaussian() * getPitchFactor(), getPitchFactor(), getPitchFactor());
ParticleSpentCasing casing = new ParticleSpentCasing(textureManager, world, x, y, z, rotatedMotionVec.xCoord, rotatedMotionVec.yCoord, rotatedMotionVec.zCoord, (float) (getPitchFactor() * rand.nextGaussian()), (float) (getYawFactor() * rand.nextGaussian()), config, false, 0, 0, 0); ParticleSpentCasing casing = new ParticleSpentCasing(textureManager, world, x, y, z, rotatedMotionVec.xCoord, rotatedMotionVec.yCoord, rotatedMotionVec.zCoord, (float) (world.rand.nextGaussian() * 5F), (float) (world.rand.nextGaussian() * 10F), config, false, 0, 0, 0);
offsetCasing(casing, getOffset(), pitch, yaw, crouched); offsetCasing(casing, getOffset(), pitch, yaw, crouched);

View File

@ -13,7 +13,7 @@ public class GunCannonFactory {
protected static SpentCasing CASINNG240MM; protected static SpentCasing CASINNG240MM;
static { static {
CASINNG240MM = new SpentCasing(CasingType.BOTTLENECK).setScale(7.5F).setBounceMotion(0.02F, 0.05F).setColor(SpentCasing.COLOR_CASE_BRASS).setupSmoke(1F, 0.5D, 60, 20); CASINNG240MM = new SpentCasing(CasingType.BOTTLENECK).setScale(7.5F).setBounceMotion(0.5F, 0.5F).setColor(SpentCasing.COLOR_CASE_BRASS).setupSmoke(1F, 0.5D, 60, 20);
} }
public static BulletConfiguration getShellConfig() { public static BulletConfiguration getShellConfig() {

View File

@ -8,7 +8,7 @@ public class GunDGKFactory {
public static final SpentCasing CASINGDGK; public static final SpentCasing CASINGDGK;
static { static {
CASINGDGK = new SpentCasing(CasingType.STRAIGHT).setScale(1.5F).setBounceMotion(0.05F, 0.02F).setColor(SpentCasing.COLOR_CASE_BRASS).register("DGK").setupSmoke(0.02F, 0.5D, 60, 20).setMaxAge(60); //3 instead of 12 seconds CASINGDGK = new SpentCasing(CasingType.STRAIGHT).setScale(1.5F).setBounceMotion(1F, 0.5F).setColor(SpentCasing.COLOR_CASE_BRASS).register("DGK").setupSmoke(0.02F, 0.5D, 60, 20).setMaxAge(60); //3 instead of 12 seconds
} }
/*public static BulletConfiguration getDGKConfig() { /*public static BulletConfiguration getDGKConfig() {

View File

@ -3,8 +3,13 @@ package com.hbm.handler.nei;
import java.awt.Rectangle; import java.awt.Rectangle;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.gui.GUICrystallizer; import com.hbm.inventory.gui.GUICrystallizer;
import com.hbm.inventory.recipes.CrystallizerRecipes; import com.hbm.inventory.recipes.CrystallizerRecipes;
import com.hbm.inventory.recipes.CrystallizerRecipes.CrystallizerRecipe;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
public class CrystallizerRecipeHandler extends NEIUniversalHandler { public class CrystallizerRecipeHandler extends NEIUniversalHandler {
@ -24,4 +29,19 @@ public class CrystallizerRecipeHandler extends NEIUniversalHandler {
guiGui.add(GUICrystallizer.class); guiGui.add(GUICrystallizer.class);
RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui); RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui);
} }
@Override
public void drawExtras(int recipe) {
RecipeSet rec = (RecipeSet) this.arecipes.get(recipe);
CrystallizerRecipe cRecipe = CrystallizerRecipes.getOutput(rec.input[1].item, Fluids.fromID(rec.input[0].item.getItemDamage()));
if(cRecipe != null && cRecipe.productivity > 0) {
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String momentum = "Effectiveness: +" + Math.min((int) (cRecipe.productivity * 100), 99) + "% per level";
int side = 8;
fontRenderer.drawString(momentum, side, 52, 0x404040);
}
}
} }

View File

@ -1,164 +0,0 @@
package com.hbm.handler.nei;
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
import java.awt.Rectangle;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.imc.ICompatNHNEI;
import com.hbm.inventory.gui.GUIHadron;
import com.hbm.inventory.recipes.HadronRecipes;
import com.hbm.inventory.recipes.HadronRecipes.HadronRecipe;
import com.hbm.lib.RefStrings;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
public class HadronRecipeHandler extends TemplateRecipeHandler implements ICompatNHNEI {
@Override
public ItemStack[] getMachinesForRecipe() {
return new ItemStack[]{
new ItemStack(ModBlocks.hadron_core)};
}
@Override
public String getRecipeID() {
return "hadron";
}
public LinkedList<RecipeTransferRect> transferRectsRec = new LinkedList<RecipeTransferRect>();
public LinkedList<RecipeTransferRect> transferRectsGui = new LinkedList<RecipeTransferRect>();
public LinkedList<Class<? extends GuiContainer>> guiRec = new LinkedList<Class<? extends GuiContainer>>();
public LinkedList<Class<? extends GuiContainer>> guiGui = new LinkedList<Class<? extends GuiContainer>>();
public class RecipeSet extends TemplateRecipeHandler.CachedRecipe {
PositionedStack input1;
PositionedStack input2;
PositionedStack output1;
PositionedStack output2;
int momentum;
boolean analysisOnly;
public RecipeSet(HadronRecipe recipe) {
this.input1 = new PositionedStack(recipe.in1.toStack(), 12, 24);
this.input2 = new PositionedStack(recipe.in2.toStack(), 30, 24);
this.output1 = new PositionedStack(recipe.out1, 84, 24);
this.output2 = new PositionedStack(recipe.out2, 102, 24);
this.momentum = recipe.momentum;
this.analysisOnly = recipe.analysisOnly;
}
@Override
public List<PositionedStack> getIngredients() {
return Arrays.asList(new PositionedStack[] { input1, input2 });
}
@Override
public List<PositionedStack> getOtherStacks() {
return Arrays.asList(new PositionedStack[] { output1, output2 });
}
@Override
public PositionedStack getResult() {
return output1;
}
}
@Override
public String getRecipeName() {
return "Particle Accelerator";
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if(outputId.equals("hadron") && getClass() == HadronRecipeHandler.class) {
List<HadronRecipe> recipes = HadronRecipes.getRecipes();
for(HadronRecipe recipe : recipes) {
this.arecipes.add(new RecipeSet(recipe));
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
List<HadronRecipe> recipes = HadronRecipes.getRecipes();
for(HadronRecipe recipe : recipes) {
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.out1, result) || NEIServerUtils.areStacksSameTypeCrafting(recipe.out2, result)) {
this.arecipes.add(new RecipeSet(recipe));
}
}
}
@Override
public void loadUsageRecipes(String inputId, Object... ingredients) {
if(inputId.equals("hadron") && getClass() == HadronRecipeHandler.class) {
loadCraftingRecipes("hadron", new Object[0]);
} else {
super.loadUsageRecipes(inputId, ingredients);
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
List<HadronRecipe> recipes = HadronRecipes.getRecipes();
for(HadronRecipe recipe : recipes) {
if(NEIServerUtils.areStacksSameTypeCrafting(recipe.in1.toStack(), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(recipe.in2.toStack(), ingredient)) {
this.arecipes.add(new RecipeSet(recipe));
}
}
}
@Override
public void loadTransferRects() {
transferRectsGui = new LinkedList<RecipeTransferRect>();
guiGui = new LinkedList<Class<? extends GuiContainer>>();
transferRects.add(new RecipeTransferRect(new Rectangle(58 - 5, 34 - 11, 24, 18), "hadron"));
transferRectsGui.add(new RecipeTransferRect(new Rectangle(72 - 5, 28 - 11, 30, 30), "hadron"));
guiGui.add(GUIHadron.class);
RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects);
RecipeTransferRectHandler.registerRectsToGuis(guiGui, transferRectsGui);
}
@Override
public void drawExtras(int recipe) {
RecipeSet rec = (RecipeSet) this.arecipes.get(recipe);
if(rec.analysisOnly)
drawTexturedModalRect(128, 23, 0, 86, 18, 18);
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
String mom = String.format(Locale.US, "%,d", rec.momentum);
fontRenderer.drawString(mom, -fontRenderer.getStringWidth(mom) / 2 + 30, 42, 0x404040);
}
@Override
public String getGuiTexture() {
return RefStrings.MODID + ":textures/gui/nei/gui_nei_hadron.png";
}
}

View File

@ -106,8 +106,8 @@ public abstract class NEIUniversalHandler extends TemplateRecipeHandler implemen
@Override @Override
public List<PositionedStack> getOtherStacks() { public List<PositionedStack> getOtherStacks() {
List<PositionedStack> other = new ArrayList(); List<PositionedStack> other = new ArrayList();
for(PositionedStack pos : output) { for(int i = 1; i < output.length; i++) {
other.add(pos); other.add(output[i]);
} }
other.add(machinePositioned); other.add(machinePositioned);
return getCycledIngredients(cycleticks / 20, other); return getCycledIngredients(cycleticks / 20, other);

View File

@ -0,0 +1,178 @@
package com.hbm.handler.nei;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.imc.ICompatNHNEI;
import com.hbm.itempool.ItemPool;
import com.hbm.itempool.ItemPoolsSatellite;
import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings;
import com.hbm.saveddata.satellites.SatelliteMiner;
import com.hbm.util.ItemStackUtil;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.WeightedRandomChestContent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect;
public class SatelliteHandler extends TemplateRecipeHandler implements ICompatNHNEI {
@Override
public ItemStack[] getMachinesForRecipe() {
return new ItemStack[] {
new ItemStack(ModBlocks.sat_dock)
};
}
@Override
public String getRecipeID() {
return "ntmSatellite";
}
@Override
public String getRecipeName() {
return "Satellite";
}
@Override
public String getGuiTexture() {
return RefStrings.MODID + ":textures/gui/nei/gui_nei_anvil.png";
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if(outputId.equals("ntmSatellite")) {
for(Item satelliteItem : new Item[]{ModItems.sat_miner, ModItems.sat_lunar_miner}) {
String poolName = SatelliteMiner.getCargoForItem(satelliteItem);
if(poolName == null) {
continue;
}
this.addRecipeToList(satelliteItem, ItemPool.getPool(poolName));
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for(Item satelliteItem : new Item[]{ModItems.sat_miner, ModItems.sat_lunar_miner}) {
String poolName = SatelliteMiner.getCargoForItem(satelliteItem);
if(poolName == null) {
continue;
}
WeightedRandomChestContent[] pool = ItemPool.getPool(poolName);
for(WeightedRandomChestContent poolEntry : pool) {
if(NEIServerUtils.areStacksSameTypeCrafting(poolEntry.theItemId, result)) {
this.addRecipeToList(satelliteItem, pool);
break;
}
}
}
}
@Override
public void loadUsageRecipes(String inputId, Object... ingredients) {
if(inputId.equals("ntmSatellite")) {
loadCraftingRecipes("ntmSatellite");
} else {
super.loadUsageRecipes(inputId, ingredients);
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
if(ingredient.getItem() == ModItems.sat_miner) {
this.addRecipeToList(ModItems.sat_miner, ItemPool.getPool(ItemPoolsSatellite.POOL_SAT_MINER));
} else if(ingredient.getItem() == ModItems.sat_lunar_miner) {
this.addRecipeToList(ModItems.sat_lunar_miner, ItemPool.getPool(ItemPoolsSatellite.POOL_SAT_LUNAR));
}
}
private void addRecipeToList(Item poolItem, WeightedRandomChestContent[] poolEntries) {
List<ItemStack> outs = new ArrayList<>();
int weight = Arrays.stream(poolEntries).mapToInt(poolEntry -> poolEntry.itemWeight).sum();
for(WeightedRandomChestContent poolEntry : poolEntries) {
ItemStack stack = poolEntry.theItemId.copy();
float chance = 100F * poolEntry.itemWeight / weight;
ItemStackUtil.addTooltipToStack(stack, EnumChatFormatting.RED + "" + ((int)(chance * 10F) / 10F) + "%");
outs.add(stack);
}
this.arecipes.add(new RecipeSet(new ItemStack(poolItem), outs));
}
@Override
public void drawBackground(int recipe) {
super.drawBackground(recipe);
drawTexturedModalRect(11, 23, 113, 105, 18, 18); //in
drawTexturedModalRect(47, 5, 5, 87, 108, 54); //out
drawTexturedModalRect(29, 14, 131, 96, 18, 36); //operation
}
public class RecipeSet extends TemplateRecipeHandler.CachedRecipe {
List<PositionedStack> input = new ArrayList<>();
List<PositionedStack> output = new ArrayList<>();
PositionedStack satelliteDock;
public RecipeSet(Object in, List<ItemStack> out) {
//not the prettiest of solutions but certainly the most pleasant to work with
int inLine = 1;
int outLine = 1;
int inOX = 0;
int inOY = 0;
int outOX = 0;
int outOY = 0;
int anvX = 0;
int anvY = 31;
outLine = 6;
inOX = 12;
inOY = 24;
outOX = 48;
outOY = 6;
anvX = 30;
this.input.add(new PositionedStack(in, inOX, inOY));
int overflowCount = out.size() / 18;
for(int i = 0; i < Math.min(out.size(), 18); i++) {
ItemStack[] stacks = new ItemStack[overflowCount + 1];
for(int j = 0; j < overflowCount + 1 && j * 18 + i < out.size(); j++) {
stacks[j] = out.get(j * 18 + i);
}
this.output.add(new PositionedStack(stacks, outOX + 18 * (i % outLine), outOY + 18 * (i / outLine)));
}
this.satelliteDock = new PositionedStack(new ItemStack(ModBlocks.sat_dock), anvX, anvY);
}
@Override
public List<PositionedStack> getIngredients() {
return getCycledIngredients(cycleticks / 20, input);
}
@Override
public PositionedStack getResult() {
return output.get(0);
}
@Override
public List<PositionedStack> getOtherStacks() {
ArrayList<PositionedStack> stacks = new ArrayList<>(output);
stacks.add(satelliteDock);
return getCycledIngredients(cycleticks / 20, stacks);
}
}
}

View File

@ -1,13 +1,10 @@
package com.hbm.handler.neutron; package com.hbm.handler.neutron;
import com.hbm.tileentity.machine.rbmk.RBMKDials; import com.hbm.tileentity.machine.rbmk.RBMKDials;
import com.hbm.util.fauxpointtwelve.BlockPos;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
@ -21,20 +18,16 @@ public class NeutronHandler {
if(event.phase != TickEvent.Phase.START) if(event.phase != TickEvent.Phase.START)
return; return;
// Freshen the node cache every `cacheTime` ticks to prevent huge RAM usage from idle nodes.
int cacheTime = 20;
boolean cacheClear = ticks >= cacheTime;
if(cacheClear) ticks = 0;
ticks++;
// Remove `StreamWorld` objects if they have no streams. // Remove `StreamWorld` objects if they have no streams.
{ // aflghdkljghlkbhfjkghgilurbhlkfjghkffdjgn NeutronNodeWorld.removeEmptyWorlds();
List<World> toRemove = new ArrayList<>();
NeutronNodeWorld.streamWorlds.forEach((world, streamWorld) -> {
if (streamWorld.streams.isEmpty())
toRemove.add(world);
});
for (World world : toRemove) { for(Map.Entry<World, NeutronNodeWorld.StreamWorld> world : NeutronNodeWorld.streamWorlds.entrySet()) {
NeutronNodeWorld.streamWorlds.remove(world);
}
}
for (Map.Entry<World, NeutronNodeWorld.StreamWorld> world : NeutronNodeWorld.streamWorlds.entrySet()) {
// Gamerule caching because this apparently is kinda slow? // Gamerule caching because this apparently is kinda slow?
// meh, good enough // meh, good enough
@ -48,33 +41,10 @@ public class NeutronHandler {
RBMKNeutronHandler.columnHeight = RBMKDials.getColumnHeight(world.getKey()) + 1; RBMKNeutronHandler.columnHeight = RBMKDials.getColumnHeight(world.getKey()) + 1;
RBMKNeutronHandler.fluxRange = RBMKDials.getFluxRange(world.getKey()); RBMKNeutronHandler.fluxRange = RBMKDials.getFluxRange(world.getKey());
for (NeutronStream stream : world.getValue().streams) { world.getValue().runStreamInteractions(world.getKey());
stream.runStreamInteraction(world.getKey());
}
world.getValue().removeAllStreams(); world.getValue().removeAllStreams();
if(cacheClear) world.getValue().cleanNodes();
} }
// Freshen the node cache every `cacheTime` ticks to prevent huge RAM usage from idle nodes.
int cacheTime = 20;
if (ticks >= cacheTime) {
ticks = 0;
List<BlockPos> toRemove = new ArrayList<>();
for (NeutronNode cachedNode : NeutronNodeWorld.nodeCache.values()) {
if (cachedNode.type == NeutronStream.NeutronType.RBMK) {
RBMKNeutronHandler.RBMKNeutronNode node = (RBMKNeutronHandler.RBMKNeutronNode) cachedNode;
toRemove.addAll(node.checkNode());
}
/* TODO: actually do this and uncache pile nodes
if (cachedNode.type == NeutronStream.NeutronType.PILE) {
PileNeutronNode node = (PileNeutronNode) cachedNode;
toRemove.addAll(node.checkNode());
}
*/
}
toRemove.forEach(NeutronNodeWorld::removeNode);
}
ticks++;
} }
} }

View File

@ -8,55 +8,97 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
public class NeutronNodeWorld { public class NeutronNodeWorld {
// HashMap of all neutron nodes and their positions.
protected static HashMap<BlockPos, NeutronNode> nodeCache = new HashMap<>();
public static void addNode(NeutronNode node) {
nodeCache.put(node.pos, node);
}
public static void removeNode(BlockPos position) {
nodeCache.remove(position);
}
public static NeutronNode getNode(BlockPos position) {
return nodeCache.get(position);
}
public static void removeAllNodes() {
nodeCache.clear();
}
// List of all stream worlds. // List of all stream worlds.
public static HashMap<World, StreamWorld> streamWorlds = new HashMap<>(); public static HashMap<World, StreamWorld> streamWorlds = new HashMap<>();
public static class StreamWorld { public static NeutronNode getNode(World world, BlockPos pos) {
StreamWorld streamWorld = streamWorlds.get(world);
return streamWorld != null ? streamWorld.nodeCache.get(pos) : null;
}
List<NeutronStream> streams; public static void removeNode(World world, BlockPos pos) {
StreamWorld streamWorld = streamWorlds.get(world);
if(streamWorld == null) return;
streamWorld.removeNode(pos);
}
public StreamWorld() { public static StreamWorld getOrAddWorld(World world) {
streams = new ArrayList<>(); StreamWorld streamWorld = streamWorlds.get(world);
} if(streamWorld == null) {
streamWorld = new StreamWorld();
public void addStream(NeutronStream stream) { streamWorlds.put(world, streamWorld);
this.streams.add(stream);
}
public void removeAllStreams() {
this.streams.clear();
}
public void removeAllStreamsOfType(NeutronStream.NeutronType type) {
List<NeutronStream> toRemove = new ArrayList<>();
for (NeutronStream stream : streams) {
if (stream.type == type)
toRemove.add(stream);
}
toRemove.forEach((stream) -> streams.remove(stream));
} }
return streamWorld;
} }
public static void removeAllWorlds() { public static void removeAllWorlds() {
streamWorlds.clear(); streamWorlds.clear();
} }
public static void removeEmptyWorlds() {
streamWorlds.values().removeIf((streamWorld) -> {
return streamWorld.streams.isEmpty();
});
}
public static class StreamWorld {
private List<NeutronStream> streams;
private HashMap<BlockPos, NeutronNode> nodeCache = new HashMap<>();
public StreamWorld() {
streams = new ArrayList<>();
}
public void runStreamInteractions(World world) {
for(NeutronStream stream : streams) {
stream.runStreamInteraction(world, this);
}
}
public void addStream(NeutronStream stream) {
streams.add(stream);
}
public void removeAllStreams() {
streams.clear();
}
public void cleanNodes() {
List<BlockPos> toRemove = new ArrayList<>();
for(NeutronNode cachedNode : nodeCache.values()) {
if(cachedNode.type == NeutronStream.NeutronType.RBMK) {
RBMKNeutronHandler.RBMKNeutronNode node = (RBMKNeutronHandler.RBMKNeutronNode) cachedNode;
toRemove.addAll(node.checkNode(this));
}
/* TODO: actually do this and uncache pile nodes
if(cachedNode.type == NeutronStream.NeutronType.PILE) {
PileNeutronNode node = (PileNeutronNode) cachedNode;
toRemove.addAll(node.checkNode());
}
*/
}
for(BlockPos pos : toRemove) {
nodeCache.remove(pos);
}
}
public NeutronNode getNode(BlockPos pos) {
return nodeCache.get(pos);
}
public void addNode(NeutronNode node) {
nodeCache.put(node.pos, node);
}
public void removeNode(BlockPos pos) {
nodeCache.remove(pos);
}
public void removeAllStreamsOfType(NeutronStream.NeutronType type) {
streams.removeIf(stream -> stream.type == type);
}
}
} }

View File

@ -1,9 +1,9 @@
package com.hbm.handler.neutron; package com.hbm.handler.neutron;
import com.hbm.handler.neutron.NeutronNodeWorld.StreamWorld;
import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.BlockPos;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.hbm.handler.neutron.NeutronNodeWorld.StreamWorld;
import java.util.Iterator; import java.util.Iterator;
@ -43,13 +43,8 @@ public abstract class NeutronStream {
this.fluxQuantity = flux; this.fluxQuantity = flux;
this.fluxRatio = ratio; this.fluxRatio = ratio;
this.type = type; this.type = type;
World worldObj = origin.tile.getWorldObj();
if (NeutronNodeWorld.streamWorlds.get(worldObj) == null) { NeutronNodeWorld.getOrAddWorld(origin.tile.getWorldObj()).addStream(this);
StreamWorld world = new StreamWorld();
world.addStream(this);
NeutronNodeWorld.streamWorlds.put(worldObj, world);
} else
NeutronNodeWorld.streamWorlds.get(worldObj).addStream(this);
} }
protected BlockPos posInstance; protected BlockPos posInstance;
@ -78,5 +73,5 @@ public abstract class NeutronStream {
}; };
} }
public abstract void runStreamInteraction(World worldObj); public abstract void runStreamInteraction(World worldObj, StreamWorld streamWorld);
} }

View File

@ -2,6 +2,7 @@ package com.hbm.handler.neutron;
import api.hbm.block.IPileNeutronReceiver; import api.hbm.block.IPileNeutronReceiver;
import com.hbm.blocks.ModBlocks; import com.hbm.blocks.ModBlocks;
import com.hbm.handler.neutron.NeutronNodeWorld.StreamWorld;
import com.hbm.tileentity.machine.pile.TileEntityPileBase; import com.hbm.tileentity.machine.pile.TileEntityPileBase;
import com.hbm.util.ContaminationUtil; import com.hbm.util.ContaminationUtil;
import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.BlockPos;
@ -26,11 +27,10 @@ public class PileNeutronHandler {
} }
public static PileNeutronNode makeNode(TileEntityPileBase tile) { public static PileNeutronNode makeNode(StreamWorld streamWorld, TileEntityPileBase tile) {
BlockPos pos = new BlockPos(tile); BlockPos pos = new BlockPos(tile);
if (NeutronNodeWorld.nodeCache.containsKey(pos)) PileNeutronNode node = (PileNeutronNode) streamWorld.getNode(pos);
return (PileNeutronNode) NeutronNodeWorld.getNode(pos); return node != null ? node : new PileNeutronNode(tile);
return new PileNeutronNode(tile);
} }
private static TileEntity blockPosToTE(World worldObj, BlockPos pos) { private static TileEntity blockPosToTE(World worldObj, BlockPos pos) {
@ -43,35 +43,38 @@ public class PileNeutronHandler {
super(origin, vector, flux, 0D, NeutronType.PILE); super(origin, vector, flux, 0D, NeutronType.PILE);
} }
@SuppressWarnings("unchecked")
@Override @Override
public void runStreamInteraction(World worldObj) { public void runStreamInteraction(World worldObj, StreamWorld streamWorld) {
TileEntityPileBase originTE = (TileEntityPileBase) origin.tile; TileEntityPileBase originTE = (TileEntityPileBase) origin.tile;
BlockPos pos = new BlockPos(originTE); BlockPos pos = new BlockPos(originTE);
for(float i = 1; i <= range; i += 0.5F) { for(float i = 1; i <= range; i += 0.5F) {
BlockPos node = new BlockPos( BlockPos nodePos = new BlockPos(
(int)Math.floor(pos.getX() + 0.5 + vector.xCoord * i), (int)Math.floor(pos.getX() + 0.5 + vector.xCoord * i),
(int)Math.floor(pos.getY() + 0.5 + vector.yCoord * i), (int)Math.floor(pos.getY() + 0.5 + vector.yCoord * i),
(int)Math.floor(pos.getZ() + 0.5 + vector.zCoord * i) (int)Math.floor(pos.getZ() + 0.5 + vector.zCoord * i)
); );
if(node.equals(pos)) if(nodePos.equals(pos))
continue; // don't interact with itself! continue; // don't interact with itself!
pos.mutate(node.getX(), node.getY(), node.getZ()); pos.mutate(nodePos.getX(), nodePos.getY(), nodePos.getZ());
TileEntity tile; TileEntity tile;
if (NeutronNodeWorld.nodeCache.containsKey(node)) NeutronNode node = streamWorld.getNode(nodePos);
tile = NeutronNodeWorld.nodeCache.get(node).tile; if(node != null && node instanceof PileNeutronNode) {
else { tile = node.tile;
tile = blockPosToTE(worldObj, node); } else {
if (tile == null) tile = blockPosToTE(worldObj, nodePos);
return; // Doesn't exist! if(tile == null) return;
if (tile instanceof TileEntityPileBase)
NeutronNodeWorld.addNode(new PileNeutronNode((TileEntityPileBase) tile)); if(tile instanceof TileEntityPileBase) {
streamWorld.addNode(new PileNeutronNode((TileEntityPileBase) tile));
}
} }
Block block = tile.getBlockType(); Block block = tile.getBlockType();
@ -79,17 +82,17 @@ public class PileNeutronHandler {
if(!(tile instanceof TileEntityPileBase)) { if(!(tile instanceof TileEntityPileBase)) {
// Return when a boron block is hit // Return when a boron block is hit
if (block == ModBlocks.block_boron) if(block == ModBlocks.block_boron)
return; return;
else if (block == ModBlocks.concrete || else if(block == ModBlocks.concrete ||
block == ModBlocks.concrete_smooth || block == ModBlocks.concrete_smooth ||
block == ModBlocks.concrete_asbestos || block == ModBlocks.concrete_asbestos ||
block == ModBlocks.concrete_colored || block == ModBlocks.concrete_colored ||
block == ModBlocks.brick_concrete) block == ModBlocks.brick_concrete)
fluxQuantity *= 0.25; fluxQuantity *= 0.25;
if (block == ModBlocks.block_graphite_rod && (meta & 8) == 0) if(block == ModBlocks.block_graphite_rod && (meta & 8) == 0)
return; return;
} }
@ -102,9 +105,9 @@ public class PileNeutronHandler {
return; return;
} }
int x = (int) (node.getX() + 0.5); int x = (int) (nodePos.getX() + 0.5);
int y = (int) (node.getY() + 0.5); int y = (int) (nodePos.getY() + 0.5);
int z = (int) (node.getZ() + 0.5); int z = (int) (nodePos.getZ() + 0.5);
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x, y, z, x, y, z)); List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(x, y, z, x, y, z));
if(entities != null) if(entities != null)

View File

@ -1,6 +1,7 @@
package com.hbm.handler.neutron; package com.hbm.handler.neutron;
import com.hbm.blocks.machine.rbmk.RBMKBase; import com.hbm.blocks.machine.rbmk.RBMKBase;
import com.hbm.handler.neutron.NeutronNodeWorld.StreamWorld;
import com.hbm.handler.radiation.ChunkRadiationManager; import com.hbm.handler.radiation.ChunkRadiationManager;
import com.hbm.tileentity.machine.rbmk.*; import com.hbm.tileentity.machine.rbmk.*;
import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.BlockPos;
@ -37,11 +38,10 @@ public class RBMKNeutronHandler {
return worldObj.getTileEntity(pos.getX(), pos.getY(), pos.getZ()); return worldObj.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
} }
public static RBMKNeutronNode makeNode(TileEntityRBMKBase tile) { public static RBMKNeutronNode makeNode(StreamWorld streamWorld, TileEntityRBMKBase tile) {
BlockPos pos = new BlockPos(tile); BlockPos pos = new BlockPos(tile);
if (NeutronNodeWorld.nodeCache.containsKey(pos)) RBMKNeutronNode node = (RBMKNeutronNode) streamWorld.getNode(pos);
return (RBMKNeutronNode) NeutronNodeWorld.getNode(pos); return node != null ? node : new RBMKNeutronNode(tile, tile.getRBMKType(), tile.hasLid());
return new RBMKNeutronNode(tile, tile.getRBMKType(), tile.hasLid());
} }
public static class RBMKNeutronNode extends NeutronNode { public static class RBMKNeutronNode extends NeutronNode {
@ -79,16 +79,16 @@ public class RBMKNeutronHandler {
@Override @Override
public BlockPos next() { public BlockPos next() {
if (Math.pow(x, 2) + Math.pow(z, 2) <= fluxRange * fluxRange) { if(Math.pow(x, 2) + Math.pow(z, 2) <= fluxRange * fluxRange) {
z++; z++;
if (z > fluxRange) { if(z > fluxRange) {
z = -fluxRange; z = -fluxRange;
x++; x++;
} }
return posInstance.mutate(tile.xCoord + x, tile.yCoord, tile.zCoord + z); return posInstance.mutate(tile.xCoord + x, tile.yCoord, tile.zCoord + z);
} else { } else {
z++; z++;
if (z > fluxRange) { if(z > fluxRange) {
z = -fluxRange; z = -fluxRange;
x++; x++;
} }
@ -98,7 +98,7 @@ public class RBMKNeutronHandler {
}; };
} }
public List<BlockPos> checkNode() { public List<BlockPos> checkNode(StreamWorld streamWorld) {
List<BlockPos> list = new ArrayList<>(); List<BlockPos> list = new ArrayList<>();
BlockPos pos = new BlockPos(this.tile); BlockPos pos = new BlockPos(this.tile);
@ -107,18 +107,18 @@ public class RBMKNeutronHandler {
// Simulate streams coming out of the RBMK rod. // Simulate streams coming out of the RBMK rod.
ForgeDirection[] fluxDirs = TileEntityRBMKRod.fluxDirs; ForgeDirection[] fluxDirs = TileEntityRBMKRod.fluxDirs;
for (int i = 0; i < fluxDirs.length; i++) { for(int i = 0; i < fluxDirs.length; i++) {
streams[i] = (new RBMKNeutronStream(this, Vec3.createVectorHelper(fluxDirs[i].offsetX, 0, fluxDirs[i].offsetZ))); streams[i] = (new RBMKNeutronStream(this, Vec3.createVectorHelper(fluxDirs[i].offsetX, 0, fluxDirs[i].offsetZ)));
} }
// Check if the rod should uncache nodes. // Check if the rod should uncache nodes.
if (tile instanceof TileEntityRBMKRod && !(tile instanceof TileEntityRBMKRodReaSim)) { if(tile instanceof TileEntityRBMKRod && !(tile instanceof TileEntityRBMKRodReaSim)) {
TileEntityRBMKRod rod = (TileEntityRBMKRod) tile; TileEntityRBMKRod rod = (TileEntityRBMKRod) tile;
if (!rod.hasRod || rod.lastFluxQuantity == 0) { if(!rod.hasRod || rod.lastFluxQuantity == 0) {
for (RBMKNeutronStream stream : streams) { for(RBMKNeutronStream stream : streams) {
for(RBMKNeutronNode node : stream.getNodes(false)) for(NeutronNode node : stream.getNodes(streamWorld, false))
if (node != null) if(node != null)
list.add(new BlockPos(node.tile)); list.add(new BlockPos(node.tile));
} }
@ -130,11 +130,11 @@ public class RBMKNeutronHandler {
Iterator<BlockPos> reaSimNodes = getReaSimNodes(); Iterator<BlockPos> reaSimNodes = getReaSimNodes();
// Check if the ReaSim rod should be culled from the cache due to no rod or no flux. // Check if the ReaSim rod should be culled from the cache due to no rod or no flux.
if (tile instanceof TileEntityRBMKRodReaSim) { // fuckkkkkkk if(tile instanceof TileEntityRBMKRodReaSim) { // fuckkkkkkk
TileEntityRBMKRodReaSim rod = (TileEntityRBMKRodReaSim) tile; TileEntityRBMKRodReaSim rod = (TileEntityRBMKRodReaSim) tile;
if (!rod.hasRod || rod.lastFluxQuantity == 0) { if(!rod.hasRod || rod.lastFluxQuantity == 0) {
reaSimNodes.forEachRemaining((a) -> { reaSimNodes.forEachRemaining((a) -> {
if (a != null) if(a != null)
list.add(a.clone()); // ae The RAM usage will be really high here but hopefully the GC can take care of it :pray: list.add(a.clone()); // ae The RAM usage will be really high here but hopefully the GC can take care of it :pray:
}); });
return list; return list;
@ -155,32 +155,32 @@ public class RBMKNeutronHandler {
if(nodePos == null) if(nodePos == null)
continue; continue;
NeutronNode node = NeutronNodeWorld.nodeCache.get(nodePos); NeutronNode node = streamWorld.getNode(nodePos);
if (node != null && node.tile instanceof TileEntityRBMKRod) { if(node != null && node.tile instanceof TileEntityRBMKRod) {
TileEntityRBMKRod rod = (TileEntityRBMKRod) node.tile; TileEntityRBMKRod rod = (TileEntityRBMKRod) node.tile;
if (rod.hasRod && rod.lastFluxQuantity > 0) { if(rod.hasRod && rod.lastFluxQuantity > 0) {
hasRod = true; hasRod = true;
break; break;
} }
} }
} }
if (!hasRod) { if(!hasRod) {
list.add(pos); list.add(pos);
return list; return list;
} }
} }
// Check if non-rod nodes should be uncached due to no rod in range. // Check if non-rod nodes should be uncached due to no rod in range.
for (RBMKNeutronStream stream : streams) { for(RBMKNeutronStream stream : streams) {
RBMKNeutronNode[] nodes = stream.getNodes(false); NeutronNode[] nodes = stream.getNodes(streamWorld, false);
for (RBMKNeutronNode node : nodes) { for(NeutronNode node : nodes) {
if (!(node == null) && node.tile instanceof TileEntityRBMKRod) if(!(node == null) && node.tile instanceof TileEntityRBMKRod)
return list; return list;
} }
} }
@ -209,28 +209,28 @@ public class RBMKNeutronHandler {
// Does NOT include the origin node // Does NOT include the origin node
// USES THE CACHE!!! // USES THE CACHE!!!
public RBMKNeutronNode[] getNodes(boolean addNode) { public NeutronNode[] getNodes(StreamWorld streamWorld, boolean addNode) {
RBMKNeutronNode[] positions = new RBMKNeutronNode[fluxRange]; NeutronNode[] positions = new RBMKNeutronNode[fluxRange];
BlockPos pos = new BlockPos(origin.tile); BlockPos pos = new BlockPos(origin.tile);
World world = origin.tile.getWorldObj();
for (int i = 1; i <= fluxRange; i++) { for(int i = 1; i <= fluxRange; i++) {
int x = (int) Math.floor(0.5 + vector.xCoord * i); int x = (int) Math.floor(0.5 + vector.xCoord * i);
int z = (int) Math.floor(0.5 + vector.zCoord * i); int z = (int) Math.floor(0.5 + vector.zCoord * i);
pos.mutate(origin.tile.xCoord + x, origin.tile.yCoord, origin.tile.zCoord + z); pos.mutate(origin.tile.xCoord + x, origin.tile.yCoord, origin.tile.zCoord + z);
if (NeutronNodeWorld.nodeCache.containsKey(pos)) NeutronNode node = streamWorld.getNode(pos);
positions[i - 1] = (RBMKNeutronNode) NeutronNodeWorld.getNode(pos); if(node != null && node instanceof RBMKNeutronNode) {
positions[i - 1] = node;
else if (this.origin.tile.getBlockType() instanceof RBMKBase) { } else if(this.origin.tile.getBlockType() instanceof RBMKBase) {
TileEntity te = blockPosToTE(this.origin.tile.getWorldObj(), pos); TileEntity te = blockPosToTE(world, pos);
if (te instanceof TileEntityRBMKBase) { if(te instanceof TileEntityRBMKBase) {
TileEntityRBMKBase rbmkBase = (TileEntityRBMKBase) te; TileEntityRBMKBase rbmkBase = (TileEntityRBMKBase) te;
RBMKNeutronNode node = makeNode(rbmkBase); node = makeNode(streamWorld, rbmkBase);
positions[i - 1] = node; positions[i - 1] = node;
if (addNode) if(addNode) streamWorld.addNode(node);
NeutronNodeWorld.addNode(node);
} }
} }
} }
@ -238,23 +238,24 @@ public class RBMKNeutronHandler {
} }
// The... small one? whatever it's still pretty big, runs the interaction for the stream. // The... small one? whatever it's still pretty big, runs the interaction for the stream.
public void runStreamInteraction(World worldObj) { public void runStreamInteraction(World worldObj, StreamWorld streamWorld) {
// do nothing if there's nothing to do lmao // do nothing if there's nothing to do lmao
if (fluxQuantity == 0D) if(fluxQuantity == 0D)
return; return;
BlockPos pos = new BlockPos(origin.tile); BlockPos pos = new BlockPos(origin.tile);
TileEntityRBMKBase originTE; TileEntityRBMKBase originTE;
if (NeutronNodeWorld.nodeCache.containsKey(pos)) NeutronNode node = streamWorld.getNode(pos);
originTE = (TileEntityRBMKBase) NeutronNodeWorld.nodeCache.get(pos).tile; if(node != null) {
else { originTE = (TileEntityRBMKBase) node.tile;
} else {
originTE = (TileEntityRBMKBase) blockPosToTE(worldObj, pos); originTE = (TileEntityRBMKBase) blockPosToTE(worldObj, pos);
if (originTE == null) if(originTE == null) return; // Doesn't exist anymore!
return; // Doesn't exist anymore!
NeutronNodeWorld.addNode(new RBMKNeutronNode(originTE, originTE.getRBMKType(), originTE.hasLid())); streamWorld.addNode(new RBMKNeutronNode(originTE, originTE.getRBMKType(), originTE.hasLid()));
} }
int moderatedCount = 0; int moderatedCount = 0;
@ -263,23 +264,22 @@ public class RBMKNeutronHandler {
while(iterator.hasNext()) { while(iterator.hasNext()) {
BlockPos nodePos = iterator.next(); BlockPos targetPos = iterator.next();
if (fluxQuantity == 0D) // Whoops, used it all up! if(fluxQuantity == 0D) // Whoops, used it all up!
return; return;
RBMKNeutronNode node; NeutronNode targetNode = streamWorld.getNode(targetPos);
if(targetNode == null) {
if (!NeutronNodeWorld.nodeCache.containsKey(nodePos)) { TileEntity te = blockPosToTE(worldObj, targetPos); // ok, maybe it didn't get added to the list somehow??
TileEntity te = blockPosToTE(worldObj, nodePos); // ok, maybe it didn't get added to the list somehow?? if(te instanceof TileEntityRBMKBase) {
if (te instanceof TileEntityRBMKBase) { targetNode = makeNode(streamWorld, (TileEntityRBMKBase) te);
node = makeNode((TileEntityRBMKBase) te); streamWorld.addNode(targetNode); // whoops!
NeutronNodeWorld.addNode(node); // whoops!
} else { } else {
int hits = getHits(nodePos); // Get the amount of hits on blocks. int hits = getHits(targetPos); // Get the amount of hits on blocks.
if (hits == columnHeight) // If stream is fully blocked. if(hits == columnHeight) // If stream is fully blocked.
return; return;
else if (hits > 0) { // If stream is partially blocked. else if(hits > 0) { // If stream is partially blocked.
irradiateFromFlux(pos, hits); irradiateFromFlux(pos, hits);
fluxQuantity *= 1 - ((double) hits / columnHeight); // Inverse to get partial blocking by blocks. fluxQuantity *= 1 - ((double) hits / columnHeight); // Inverse to get partial blocking by blocks.
continue; continue;
@ -290,81 +290,79 @@ public class RBMKNeutronHandler {
} }
} }
node = (RBMKNeutronNode) NeutronNodeWorld.nodeCache.get(nodePos); RBMKType type = (RBMKType) targetNode.data.get("type");
RBMKType type = (RBMKType) node.data.get("type"); if(type == RBMKType.OTHER || type == null) // pass right on by!
if (type == RBMKType.OTHER) // pass right on by!
continue; continue;
// we established earlier during `getNodes()` that they should all be RBMKBase TEs // we established earlier during `getNodes()` that they should all be RBMKBase TEs
// no issue with casting here! // no issue with casting here!
TileEntityRBMKBase nodeTE = (TileEntityRBMKBase) node.tile; TileEntityRBMKBase nodeTE = (TileEntityRBMKBase) targetNode.tile;
if (!(boolean) node.data.get("hasLid")) if(!(boolean) targetNode.data.get("hasLid"))
ChunkRadiationManager.proxy.incrementRad(worldObj, nodePos.getX(), nodePos.getY(), nodePos.getZ(), (float) (this.fluxQuantity * 0.05F)); ChunkRadiationManager.proxy.incrementRad(worldObj, targetPos.getX(), targetPos.getY(), targetPos.getZ(), (float) (this.fluxQuantity * 0.05F));
if (type == RBMKType.MODERATOR || nodeTE.isModerated()) { if(type == RBMKType.MODERATOR || nodeTE.isModerated()) {
moderatedCount++; moderatedCount++;
moderateStream(); moderateStream();
} }
if (nodeTE instanceof IRBMKFluxReceiver) { if(nodeTE instanceof IRBMKFluxReceiver) {
IRBMKFluxReceiver column = (IRBMKFluxReceiver) nodeTE; IRBMKFluxReceiver column = (IRBMKFluxReceiver) nodeTE;
if (type == RBMKType.ROD) { if(type == RBMKType.ROD) {
TileEntityRBMKRod rod = (TileEntityRBMKRod) column; TileEntityRBMKRod rod = (TileEntityRBMKRod) column;
if (rod.hasRod) { if(rod.hasRod) {
rod.receiveFlux(this); rod.receiveFlux(this);
return; return;
} }
} else if (type == RBMKType.OUTGASSER) { } else if(type == RBMKType.OUTGASSER) {
TileEntityRBMKOutgasser outgasser = ((TileEntityRBMKOutgasser) column); TileEntityRBMKOutgasser outgasser = ((TileEntityRBMKOutgasser) column);
if (outgasser.canProcess()) { if(outgasser.canProcess()) {
column.receiveFlux(this); column.receiveFlux(this);
return; return;
} }
} }
} else if (type == RBMKType.CONTROL_ROD) { } else if(type == RBMKType.CONTROL_ROD) {
TileEntityRBMKControl rod = (TileEntityRBMKControl) nodeTE; TileEntityRBMKControl rod = (TileEntityRBMKControl) nodeTE;
if (rod.level > 0.0D) { if(rod.level > 0.0D) {
this.fluxQuantity *= rod.getMult(); this.fluxQuantity *= rod.getMult();
continue; continue;
} }
return; return;
} else if (type == RBMKType.REFLECTOR) { } else if(type == RBMKType.REFLECTOR) {
if (((TileEntityRBMKBase) this.origin.tile).isModerated()) if(((TileEntityRBMKBase) this.origin.tile).isModerated())
moderatedCount++; moderatedCount++;
if (this.fluxRatio > 0 && moderatedCount > 0) if(this.fluxRatio > 0 && moderatedCount > 0)
for (int i = 0; i < moderatedCount; i++) for(int i = 0; i < moderatedCount; i++)
moderateStream(); moderateStream();
if (reflectorEfficiency != 1.0D) { if(reflectorEfficiency != 1.0D) {
this.fluxQuantity *= reflectorEfficiency; this.fluxQuantity *= reflectorEfficiency;
continue; continue;
} }
((TileEntityRBMKRod) originTE).receiveFlux(this); ((TileEntityRBMKRod) originTE).receiveFlux(this);
return; return;
} else if (type == RBMKType.ABSORBER) { } else if(type == RBMKType.ABSORBER) {
if (absorberEfficiency == 1) if(absorberEfficiency == 1)
return; return;
this.fluxQuantity *= absorberEfficiency; this.fluxQuantity *= absorberEfficiency;
} }
} }
RBMKNeutronNode[] nodes = getNodes(true); NeutronNode[] nodes = getNodes(streamWorld, true);
RBMKNeutronNode lastNode = nodes[(nodes.length - 1)]; NeutronNode lastNode = nodes[(nodes.length - 1)];
if(lastNode == null) { // This implies that there was *no* last node, meaning either way it was never caught. if(lastNode == null) { // This implies that there was *no* last node, meaning either way it was never caught.
// There is really no good way to figure out where exactly it should irradiate, so just irradiate at the origin tile. // There is really no good way to figure out where exactly it should irradiate, so just irradiate at the origin tile.
@ -374,9 +372,9 @@ public class RBMKNeutronHandler {
RBMKType lastNodeType = (RBMKType) lastNode.data.get("type"); RBMKType lastNodeType = (RBMKType) lastNode.data.get("type");
if (lastNodeType == RBMKType.CONTROL_ROD) { if(lastNodeType == RBMKType.CONTROL_ROD) {
TileEntityRBMKControl rod = (TileEntityRBMKControl) lastNode.tile; TileEntityRBMKControl rod = (TileEntityRBMKControl) lastNode.tile;
if (rod.getMult() > 0.0D) { if(rod.getMult() > 0.0D) {
this.fluxQuantity *= rod.getMult(); this.fluxQuantity *= rod.getMult();
BlockPos posAfter = new BlockPos(lastNode.tile.xCoord + this.vector.xCoord, lastNode.tile.yCoord, lastNode.tile.zCoord + this.vector.zCoord); BlockPos posAfter = new BlockPos(lastNode.tile.xCoord + this.vector.xCoord, lastNode.tile.yCoord, lastNode.tile.zCoord + this.vector.zCoord);
@ -404,7 +402,7 @@ public class RBMKNeutronHandler {
// I FUCKING HATE THIS // I FUCKING HATE THIS
// total count of bugs fixed attributed to this function: 14 // total count of bugs fixed attributed to this function: 14
Block block = origin.tile.getWorldObj().getBlock(pos.getX(), pos.getY() + h, pos.getZ()); Block block = origin.tile.getWorldObj().getBlock(pos.getX(), pos.getY() + h, pos.getZ());
if (block.isOpaqueCube()) if(block.isOpaqueCube())
hits += 1; hits += 1;
} }

View File

@ -13,8 +13,10 @@ import com.hbm.inventory.fluid.trait.*;
import com.hbm.inventory.fluid.trait.FluidTraitSimple.*; import com.hbm.inventory.fluid.trait.FluidTraitSimple.*;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.render.util.EnumSymbol; import com.hbm.render.util.EnumSymbol;
import com.hbm.uninos.INetworkProvider;
import com.hbm.util.I18nUtil; import com.hbm.util.I18nUtil;
import api.hbm.fluidmk2.FluidNetMK2;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -252,4 +254,8 @@ public class FluidType {
public String name() { public String name() {
return this.stringId; return this.stringId;
} }
public INetworkProvider<FluidNetMK2> getNetworkProvider() {
return null; //TBI
}
} }

View File

@ -7,6 +7,7 @@ import org.lwjgl.opengl.GL11;
import com.hbm.interfaces.NotableComments; import com.hbm.interfaces.NotableComments;
import com.hbm.inventory.container.ContainerAutocrafter; import com.hbm.inventory.container.ContainerAutocrafter;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.machine.TileEntityMachineAutocrafter; import com.hbm.tileentity.machine.TileEntityMachineAutocrafter;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -41,16 +42,7 @@ public class GUIAutocrafter extends GuiInfoContainer {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i); Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i);
if(this.isMouseOverSlot(slot, x, y) && diFurnace.matcher.modes[i] != null) { if(this.isMouseOverSlot(slot, x, y) && diFurnace.matcher.modes[i] != null) {
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", ModulePatternMatcher.getLabel(diFurnace.matcher.modes[i]) }), x, y - 30);
String label = EnumChatFormatting.YELLOW + "";
switch(diFurnace.matcher.modes[i]) {
case "exact": label += "Item and meta match"; break;
case "wildcard": label += "Item matches"; break;
default: label += "Ore dict key matches: " + diFurnace.matcher.modes[i]; break;
}
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30);
} }
} }

View File

@ -7,6 +7,7 @@ import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerCounterTorch; import com.hbm.inventory.container.ContainerCounterTorch;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.packet.PacketDispatcher; import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toserver.NBTControlPacket; import com.hbm.packet.toserver.NBTControlPacket;
import com.hbm.tileentity.network.TileEntityRadioTorchCounter; import com.hbm.tileentity.network.TileEntityRadioTorchCounter;
@ -72,16 +73,7 @@ public class GUICounterTorch extends GuiInfoContainer {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i); Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i);
if(this.isMouseOverSlot(slot, x, y) && counter.matcher.modes[i] != null) { if(this.isMouseOverSlot(slot, x, y) && counter.matcher.modes[i] != null) {
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", ModulePatternMatcher.getLabel(counter.matcher.modes[i]) }), x, y - 30);
String label = EnumChatFormatting.YELLOW + "";
switch(counter.matcher.modes[i]) {
case "exact": label += "Item and meta match"; break;
case "wildcard": label += "Item matches"; break;
default: label += "Ore dict key matches: " + counter.matcher.modes[i]; break;
}
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30);
} }
} }
} }

View File

@ -6,6 +6,7 @@ import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerCraneExtractor; import com.hbm.inventory.container.ContainerCraneExtractor;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.packet.PacketDispatcher; import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toserver.NBTControlPacket; import com.hbm.packet.toserver.NBTControlPacket;
import com.hbm.tileentity.network.TileEntityCraneExtractor; import com.hbm.tileentity.network.TileEntityCraneExtractor;
@ -41,16 +42,7 @@ public class GUICraneExtractor extends GuiInfoContainer {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i); Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i);
if(this.isMouseOverSlot(slot, x, y) && ejector.matcher.modes[i] != null) { if(this.isMouseOverSlot(slot, x, y) && ejector.matcher.modes[i] != null) {
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", ModulePatternMatcher.getLabel(ejector.matcher.modes[i]) }), x, y - 30);
String label = EnumChatFormatting.YELLOW + "";
switch(ejector.matcher.modes[i]) {
case "exact": label += "Item and meta match"; break;
case "wildcard": label += "Item matches"; break;
default: label += "Ore dict key matches: " + ejector.matcher.modes[i]; break;
}
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30);
} }
} }
} }

View File

@ -6,6 +6,7 @@ import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerCraneGrabber; import com.hbm.inventory.container.ContainerCraneGrabber;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.packet.PacketDispatcher; import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toserver.NBTControlPacket; import com.hbm.packet.toserver.NBTControlPacket;
import com.hbm.tileentity.network.TileEntityCraneGrabber; import com.hbm.tileentity.network.TileEntityCraneGrabber;
@ -41,16 +42,7 @@ public class GUICraneGrabber extends GuiInfoContainer {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i); Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i);
if(this.isMouseOverSlot(slot, x, y) && grabber.matcher.modes[i] != null) { if(this.isMouseOverSlot(slot, x, y) && grabber.matcher.modes[i] != null) {
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", ModulePatternMatcher.getLabel(grabber.matcher.modes[i]) }), x, y - 30);
String label = EnumChatFormatting.YELLOW + "";
switch(grabber.matcher.modes[i]) {
case "exact": label += "Item and meta match"; break;
case "wildcard": label += "Item matches"; break;
default: label += "Ore dict key matches: " + grabber.matcher.modes[i]; break;
}
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30);
} }
} }
} }

View File

@ -83,16 +83,7 @@ public class GUICraneRouter extends GuiInfoContainer {
int index = i % 5; int index = i % 5;
if(this.isMouseOverSlot(slot, x, y) && matcher.modes[index] != null) { if(this.isMouseOverSlot(slot, x, y) && matcher.modes[index] != null) {
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", ModulePatternMatcher.getLabel(matcher.modes[index])}), x, y - 30);
String label = EnumChatFormatting.YELLOW + "";
switch(matcher.modes[index]) {
case "exact": label += "Item and meta match"; break;
case "wildcard": label += "Item matches"; break;
default: label += "Ore dict key matches: " + matcher.modes[index]; break;
}
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label}), x, y - 30);
} }
} }
} }

View File

@ -6,6 +6,7 @@ import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerDroneRequester; import com.hbm.inventory.container.ContainerDroneRequester;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.network.TileEntityDroneRequester; import com.hbm.tileentity.network.TileEntityDroneRequester;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -37,16 +38,7 @@ public class GUIDroneRequester extends GuiInfoContainer {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i); Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i);
if(this.isMouseOverSlot(slot, x, y) && diFurnace.matcher.modes[i] != null) { if(this.isMouseOverSlot(slot, x, y) && diFurnace.matcher.modes[i] != null) {
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", ModulePatternMatcher.getLabel(diFurnace.matcher.modes[i]) }), x, y - 30);
String label = EnumChatFormatting.YELLOW + "";
switch(diFurnace.matcher.modes[i]) {
case "exact": label += "Item and meta match"; break;
case "wildcard": label += "Item matches"; break;
default: label += "Ore dict key matches: " + diFurnace.matcher.modes[i]; break;
}
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30);
} }
} }
} }

View File

@ -10,6 +10,7 @@ import com.hbm.inventory.SlotPattern;
import com.hbm.inventory.container.ContainerMachineCustom; import com.hbm.inventory.container.ContainerMachineCustom;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.machine.TileEntityCustomMachine; import com.hbm.tileentity.machine.TileEntityCustomMachine;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -44,16 +45,7 @@ public class GUIMachineCustom extends GuiInfoContainer {
int tileIndex = slot.getSlotIndex(); int tileIndex = slot.getSlotIndex();
if(this.isMouseOverSlot(slot, x, y) && slot instanceof SlotPattern && custom.matcher.modes[tileIndex - 10] != null) { if(this.isMouseOverSlot(slot, x, y) && slot instanceof SlotPattern && custom.matcher.modes[tileIndex - 10] != null) {
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", ModulePatternMatcher.getLabel(custom.matcher.modes[tileIndex - 10]) }), x, y - 30);
String label = EnumChatFormatting.YELLOW + "";
switch(custom.matcher.modes[tileIndex - 10]) {
case "exact": label += "Item and meta match"; break;
case "wildcard": label += "Item matches"; break;
default: label += "Ore dict key matches: " + custom.matcher.modes[tileIndex - 10]; break;
}
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30);
} }
} }
} }

View File

@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.lib.RefStrings; import com.hbm.lib.RefStrings;
@ -21,89 +22,88 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement; import net.minecraft.stats.Achievement;
import net.minecraft.stats.AchievementList;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
public class GUIScreenBobmazon extends GuiScreen { public class GUIScreenBobmazon extends GuiScreen {
protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_bobmazon.png");
protected int xSize = 176;
protected int ySize = 229;
protected int guiLeft;
protected int guiTop;
int currentPage = 0;
List<Offer> offers = new ArrayList<Offer>();
List<FolderButton> buttons = new ArrayList<FolderButton>();
private final EntityPlayer player;
public GUIScreenBobmazon(EntityPlayer player, List<Offer> offers) {
this.player = player;
this.offers = offers; protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_bobmazon.png");
} protected int xSize = 176 + 41;
protected int ySize = 229;
int getPageCount() { protected int guiLeft;
return (int)Math.ceil((offers.size() - 1) / 3); protected int guiTop;
} int currentPage = 0;
List<Offer> offers = new ArrayList<Offer>();
public void updateScreen() { List<FolderButton> buttons = new ArrayList<FolderButton>();
if(currentPage < 0) private final EntityPlayer player;
currentPage = 0;
if(currentPage > getPageCount())
currentPage = getPageCount();
if(this.player.getHeldItem() != null && this.player.getHeldItem().getItem() == ModItems.bobmazon_hidden && player.getDisplayName().equals("SolsticeUnlimitd"))
this.mc.thePlayer.closeScreen();
}
public void drawScreen(int mouseX, int mouseY, float f)
{
this.drawDefaultBackground();
this.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
GL11.glDisable(GL11.GL_LIGHTING);
this.drawGuiContainerForegroundLayer(mouseX, mouseY);
GL11.glEnable(GL11.GL_LIGHTING);
}
public void initGui()
{
super.initGui();
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
updateButtons(); public GUIScreenBobmazon(EntityPlayer player, List<Offer> offers) {
}
protected void updateButtons() {
if(!buttons.isEmpty())
buttons.clear();
for(int i = currentPage * 3; i < Math.min(currentPage * 3 + 3, offers.size()); i++) {
buttons.add(new FolderButton(guiLeft + 34, guiTop + 35 + (54 * (int)Math.floor(i)) - currentPage * 3 * 54, offers.get(i)));
}
if(currentPage != 0) this.player = player;
buttons.add(new FolderButton(guiLeft + 25 - 18, guiTop + 26 + (27 * 3), 1, "Previous"));
if(currentPage != getPageCount()) this.offers = offers;
buttons.add(new FolderButton(guiLeft + 25 + (27 * 4) + 18, guiTop + 26 + (27 * 3), 2, "Next")); }
}
int getPageCount() {
return (int) Math.ceil((offers.size() - 1) / 3);
}
public void updateScreen() {
if(currentPage < 0)
currentPage = 0;
if(currentPage > getPageCount())
currentPage = getPageCount();
if(this.player.getHeldItem() != null && this.player.getHeldItem().getItem() == ModItems.bobmazon_hidden && player.getDisplayName().equals("SolsticeUnlimitd"))
this.mc.thePlayer.closeScreen();
}
public void drawScreen(int mouseX, int mouseY, float f) {
this.drawDefaultBackground();
this.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
GL11.glDisable(GL11.GL_LIGHTING);
this.drawGuiContainerForegroundLayer(mouseX, mouseY);
GL11.glEnable(GL11.GL_LIGHTING);
}
public void initGui() {
super.initGui();
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
updateButtons();
}
protected void updateButtons() {
if(!buttons.isEmpty())
buttons.clear();
for(int i = currentPage * 3; i < Math.min(currentPage * 3 + 3, offers.size()); i++) {
buttons.add(new FolderButton(guiLeft + 34, guiTop + 35 + (54 * (int) Math.floor(i)) - currentPage * 3 * 54, offers.get(i)));
}
if(currentPage != 0)
buttons.add(new FolderButton(guiLeft + 25 - 18, guiTop + 26 + (27 * 3), 1, "Previous"));
if(currentPage != getPageCount())
buttons.add(new FolderButton(guiLeft + 25 + (27 * 4) + 18 + 41, guiTop + 26 + (27 * 3), 2, "Next"));
}
protected void mouseClicked(int i, int j, int k) {
try {
for(FolderButton b : buttons)
if(b.isMouseOnButton(i, j))
b.executeAction();
} catch(Exception ex) {
updateButtons();
}
}
protected void mouseClicked(int i, int j, int k) {
try {
for(FolderButton b : buttons)
if(b.isMouseOnButton(i, j))
b.executeAction();
} catch (Exception ex) {
updateButtons();
}
}
protected void drawGuiContainerForegroundLayer(int i, int j) { protected void drawGuiContainerForegroundLayer(int i, int j) {
this.fontRendererObj.drawString(I18n.format((currentPage + 1) + "/" + (getPageCount() + 1)), this.fontRendererObj.drawString(I18n.format((currentPage + 1) + "/" + (getPageCount() + 1)),
guiLeft + this.xSize / 2 - this.fontRendererObj.getStringWidth(I18n.format((currentPage + 1) + "/" + (getPageCount() + 1))) / 2, guiTop + 205, 4210752); guiLeft + this.xSize / 2 - this.fontRendererObj.getStringWidth(I18n.format((currentPage + 1) + "/" + (getPageCount() + 1))) / 2, guiTop + 205, 4210752);
for(FolderButton b : buttons) for(FolderButton b : buttons)
if(b.isMouseOnButton(i, j)) if(b.isMouseOnButton(i, j))
b.drawString(i, j); b.drawString(i, j);
@ -118,73 +118,73 @@ public class GUIScreenBobmazon extends GuiScreen {
b.drawButton(b.isMouseOnButton(i, j)); b.drawButton(b.isMouseOnButton(i, j));
for(FolderButton b : buttons) for(FolderButton b : buttons)
b.drawIcon(b.isMouseOnButton(i, j)); b.drawIcon(b.isMouseOnButton(i, j));
for(int d = currentPage * 3; d < Math.min(currentPage * 3 + 3, offers.size()); d++) { for(int d = currentPage * 3; d < Math.min(currentPage * 3 + 3, offers.size()); d++) {
offers.get(d).drawRequirement(this, guiLeft + 34, guiTop + 53 + (54 * (int)Math.floor(d)) - currentPage * 3 * 54); offers.get(d).drawRequirement(this, guiLeft + 34, guiTop + 53 + (54 * (int) Math.floor(d)) - currentPage * 3 * 54);
} }
} }
protected void keyTyped(char p_73869_1_, int p_73869_2_) protected void keyTyped(char p_73869_1_, int p_73869_2_) {
{ if(p_73869_2_ == 1 || p_73869_2_ == this.mc.gameSettings.keyBindInventory.getKeyCode()) {
if (p_73869_2_ == 1 || p_73869_2_ == this.mc.gameSettings.keyBindInventory.getKeyCode()) this.mc.thePlayer.closeScreen();
{ }
this.mc.thePlayer.closeScreen();
} }
}
class FolderButton { class FolderButton {
int xPos; int xPos;
int yPos; int yPos;
//0: regular, 1: prev, 2: next // 0: regular, 1: prev, 2: next
int type; int type;
String info; String info;
Offer offer; Offer offer;
public FolderButton(int x, int y, int t, String i) { public FolderButton(int x, int y, int t, String i) {
xPos = x; xPos = x;
yPos = y; yPos = y;
type = t; type = t;
info = i; info = i;
} }
public FolderButton(int x, int y, Offer offer) { public FolderButton(int x, int y, Offer offer) {
xPos = x; xPos = x;
yPos = y; yPos = y;
type = 0; type = 0;
this.offer = offer; this.offer = offer;
} }
public void updateButton(int mouseX, int mouseY) { public void updateButton(int mouseX, int mouseY) {
} }
public boolean isMouseOnButton(int mouseX, int mouseY) { public boolean isMouseOnButton(int mouseX, int mouseY) {
return xPos <= mouseX && xPos + 18 > mouseX && yPos < mouseY && yPos + 18 >= mouseY; return xPos <= mouseX && xPos + 18 > mouseX && yPos < mouseY && yPos + 18 >= mouseY;
} }
public void drawButton(boolean b) { public void drawButton(boolean b) {
Minecraft.getMinecraft().getTextureManager().bindTexture(texture); Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(xPos, yPos, b ? 176 + 18 : 176, type == 1 ? 18 : (type == 2 ? 36 : 0), 18, 18); drawTexturedModalRect(xPos, yPos, b ? 176 + 41 + 18 : 176 + 41, type == 1 ? 18 : (type == 2 ? 36 : 0), 18, 18);
} }
public void drawIcon(boolean b) { public void drawIcon(boolean b) {
try { try {
GL11.glDisable(GL11.GL_LIGHTING); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
if(offer != null) { if(offer != null) {
RenderHelper.enableGUIStandardItemLighting();
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), offer.offer, xPos + 1, yPos + 1); itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), offer.offer, xPos + 1, yPos + 1);
} }
GL11.glEnable(GL11.GL_LIGHTING); } catch(Exception x) {
} catch(Exception x) { } }
} }
public void drawString(int x, int y) { public void drawString(int x, int y) {
if(info == null || info.isEmpty()) if(info == null || info.isEmpty())
return; return;
func_146283_a(Arrays.asList(new String[] { info }), x, y); func_146283_a(Arrays.asList(new String[] { info }), x, y);
} }
public void executeAction() { public void executeAction() {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
if(type == 0) { if(type == 0) {
@ -200,21 +200,21 @@ public class GUIScreenBobmazon extends GuiScreen {
} }
} }
} }
@Override @Override
public boolean doesGuiPauseGame() { public boolean doesGuiPauseGame() {
return false; return false;
} }
public static class Offer { public static class Offer {
public ItemStack offer; public ItemStack offer;
public Requirement requirement; public Requirement requirement;
public int cost; public int cost;
public int rating; public int rating;
public String comment; public String comment;
public String author; public String author;
public Offer(ItemStack offer, Requirement requirement, int cost, int rating, String comment, String author) { public Offer(ItemStack offer, Requirement requirement, int cost, int rating, String comment, String author) {
this.offer = offer; this.offer = offer;
this.requirement = requirement; this.requirement = requirement;
@ -223,82 +223,81 @@ public class GUIScreenBobmazon extends GuiScreen {
this.comment = comment; this.comment = comment;
this.author = author; this.author = author;
} }
public Offer(ItemStack offer, Requirement requirement, int cost) { public Offer(ItemStack offer, Requirement requirement, int cost) {
this.offer = offer; this(offer, requirement, cost, 0);
this.requirement = requirement;
this.cost = cost;
this.rating = 0;
this.comment = "No Ratings";
this.author = "";
} }
public Offer(ItemStack offer, Requirement requirement, int cost, int rating) {
this(offer, requirement, cost, rating, "No Ratings", "");
}
public void drawRequirement(GUIScreenBobmazon gui, int x, int y) { public void drawRequirement(GUIScreenBobmazon gui, int x, int y) {
try { try {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderHelper.enableGUIStandardItemLighting(); RenderHelper.enableGUIStandardItemLighting();
GL11.glColor3f(1F, 1F, 1F); GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture); Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
gui.drawTexturedModalRect(x + 19, y - 4, 176, 62, 39, 8); gui.drawTexturedModalRect(x + 19, y - 4, 176 + 41, 62, 39, 8);
gui.drawTexturedModalRect(x + 19, y - 4, 176, 54, rating, 8); gui.drawTexturedModalRect(x + 19, y - 4, 176 + 41, 54, rating, 8);
String count = ""; String count = "";
if(offer.stackSize > 1) if(offer.stackSize > 1)
count = " x" + offer.stackSize; count = " x" + offer.stackSize;
GL11.glPushMatrix(); GL11.glPushMatrix();
float scale = 0.5F;
float scale = 0.65F;
GL11.glScalef(scale, scale, scale); GL11.glScalef(scale, scale, scale);
gui.fontRendererObj.drawString(I18n.format(offer.getDisplayName()) + count, (int)((x + 20) / scale), (int)((y - 12) / scale), 4210752); gui.fontRendererObj.drawString(I18n.format(offer.getDisplayName()) + count, (int) ((x + 20) / scale), (int) ((y - 12) / scale), 4210752);
GL11.glPopMatrix(); GL11.glPopMatrix();
String price = cost + " Cap"; String price = cost + " Cap";
if(cost != 1) if(cost != 1)
price += "s"; price += "s";
gui.fontRendererObj.drawString(price, x + 62, y - 3, 4210752); gui.fontRendererObj.drawString(price, x + 62, y - 3, 4210752);
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glScalef(0.5F, 0.5F, 0.5F); GL11.glScalef(0.5F, 0.5F, 0.5F);
if(!author.isEmpty()) if(!author.isEmpty())
gui.fontRendererObj.drawString("- " + author, (x + 20) * 2, (y + 18) * 2, 0x222222); gui.fontRendererObj.drawString("- " + author, (x + 20) * 2, (y + 18) * 2, 0x222222);
gui.fontRendererObj.drawString(comment, (x + 20) * 2, (y + 8) * 2, 0x222222); gui.fontRendererObj.drawString(comment, (x + 20) * 2, (y + 8) * 2, 0x222222);
GL11.glPopMatrix(); GL11.glPopMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
if(offer != null) { if(offer != null) {
GL11.glEnable(GL11.GL_LIGHTING);
gui.itemRender.renderItemAndEffectIntoGUI(gui.fontRendererObj, gui.mc.getTextureManager(), requirement.achievement.theItemStack, x + 1, y + 1); gui.itemRender.renderItemAndEffectIntoGUI(gui.fontRendererObj, gui.mc.getTextureManager(), requirement.achievement.theItemStack, x + 1, y + 1);
} }
GL11.glEnable(GL11.GL_LIGHTING);
} catch(Exception ex) {
} catch(Exception ex) { } }
} }
} }
public enum Requirement { public enum Requirement {
NONE(AchievementList.openInventory),
STEEL(MainRegistry.achBlastFurnace), STEEL(MainRegistry.achBlastFurnace),
ASSEMBLY(MainRegistry.achAssembly), ASSEMBLY(MainRegistry.achAssembly),
CHEMICS(MainRegistry.achChemplant), CHEMICS(MainRegistry.achChemplant),
OIL(MainRegistry.achDesh), OIL(MainRegistry.achDesh),
NUCLEAR(MainRegistry.achTechnetium), NUCLEAR(MainRegistry.achTechnetium),
HIDDEN(MainRegistry.bobHidden); HIDDEN(MainRegistry.bobHidden);
private Requirement(Achievement achievement) { private Requirement(Achievement achievement) {
this.achievement = achievement; this.achievement = achievement;
} }
public boolean fullfills(EntityPlayerMP player) { public boolean fullfills(EntityPlayerMP player) {
return player.func_147099_x().hasAchievementUnlocked(achievement); return player.func_147099_x().hasAchievementUnlocked(achievement);
} }
public Achievement achievement; public Achievement achievement;
} }

View File

@ -46,6 +46,8 @@ public class ArcWelderRecipes extends SerializableRecipe {
new OreDictStack(ANY_BISMOIDBRONZE.plateCast(), 2), new OreDictStack(CMB.plateWelded(), 1), new ComparableStack(ModItems.ingot_cft))); new OreDictStack(ANY_BISMOIDBRONZE.plateCast(), 2), new OreDictStack(CMB.plateWelded(), 1), new ComparableStack(ModItems.ingot_cft)));
//Dense Wires //Dense Wires
recipes.add(new ArcWelderRecipe(new ItemStack(ModItems.wire_dense, 1, Mats.MAT_COPPER.id), 100, 10_000L,
new OreDictStack(CU.wireFine(), 8)));
recipes.add(new ArcWelderRecipe(new ItemStack(ModItems.wire_dense, 1, Mats.MAT_ALLOY.id), 100, 10_000L, recipes.add(new ArcWelderRecipe(new ItemStack(ModItems.wire_dense, 1, Mats.MAT_ALLOY.id), 100, 10_000L,
new OreDictStack(ALLOY.wireFine(), 8))); new OreDictStack(ALLOY.wireFine(), 8)));
recipes.add(new ArcWelderRecipe(new ItemStack(ModItems.wire_dense, 1, Mats.MAT_GOLD.id), 100, 10_000L, recipes.add(new ArcWelderRecipe(new ItemStack(ModItems.wire_dense, 1, Mats.MAT_GOLD.id), 100, 10_000L,

View File

@ -79,7 +79,7 @@ public class AssemblerRecipes extends SerializableRecipe {
makeRecipe(new ComparableStack(ModItems.rtg_unit, 1), new AStack[] {new ComparableStack(ModItems.thermo_element, 2), new OreDictStack(CU.plateCast(), 1), new OreDictStack(PB.ingot(), 2), new OreDictStack(STEEL.plate(), 2), new ComparableStack(ModItems.circuit, 1, EnumCircuitType.CAPACITOR.ordinal()), },100); makeRecipe(new ComparableStack(ModItems.rtg_unit, 1), new AStack[] {new ComparableStack(ModItems.thermo_element, 2), new OreDictStack(CU.plateCast(), 1), new OreDictStack(PB.ingot(), 2), new OreDictStack(STEEL.plate(), 2), new ComparableStack(ModItems.circuit, 1, EnumCircuitType.CAPACITOR.ordinal()), },100);
makeRecipe(new ComparableStack(ModItems.levitation_unit, 1), new AStack[] {new ComparableStack(ModItems.coil_copper, 4), new ComparableStack(ModItems.coil_tungsten, 2), new OreDictStack(TI.plate(), 6), new ComparableStack(ModItems.nugget_schrabidium, 2), },100); makeRecipe(new ComparableStack(ModItems.levitation_unit, 1), new AStack[] {new ComparableStack(ModItems.coil_copper, 4), new ComparableStack(ModItems.coil_tungsten, 2), new OreDictStack(TI.plate(), 6), new ComparableStack(ModItems.nugget_schrabidium, 2), },100);
makeRecipe(new ComparableStack(ModItems.drill_titanium, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 2), new OreDictStack(DURA.ingot(), 2), new OreDictStack(DURA.bolt(), 4), new OreDictStack(TI.plate(), 6), },100); makeRecipe(new ComparableStack(ModItems.drill_titanium, 1), new AStack[] {new OreDictStack(STEEL.ingot(), 2), new OreDictStack(DURA.ingot(), 2), new OreDictStack(DURA.bolt(), 4), new OreDictStack(TI.plate(), 6), },100);
makeRecipe(new ComparableStack(ModItems.entanglement_kit, 1), new AStack[] {new OreDictStack(STEEL.plate(), 8), new OreDictStack(DURA.ingot(), 4), new OreDictStack(CU.plate(), 24), new ComparableStack(ModBlocks.hadron_coil_gold, 4), new OreDictStack(Fluids.XENON.getDict(1_000))},200); makeRecipe(new ComparableStack(ModItems.entanglement_kit, 1), new AStack[] {new OreDictStack(STEEL.plate(), 8), new OreDictStack(DURA.ingot(), 4), new OreDictStack(CU.plate(), 24), new OreDictStack(GOLD.wireDense(), 16), new OreDictStack(Fluids.XENON.getDict(1_000))},200);
makeRecipe(new ComparableStack(ModItems.dysfunctional_reactor, 1), new AStack[] {new OreDictStack(STEEL.plate(), 15), new OreDictStack(PB.ingot(), 5), new ComparableStack(ModItems.rod_quad_empty, 10), new OreDictStack("dyeBrown", 3), },200); makeRecipe(new ComparableStack(ModItems.dysfunctional_reactor, 1), new AStack[] {new OreDictStack(STEEL.plate(), 15), new OreDictStack(PB.ingot(), 5), new ComparableStack(ModItems.rod_quad_empty, 10), new OreDictStack("dyeBrown", 3), },200);
makeRecipe(new ComparableStack(ModItems.missile_assembly, 1), new AStack[] {new OreDictStack(STEEL.shell(), 2), new OreDictStack(AL.shell(), 2), new OreDictStack(TI.plate(), 8), new OreDictStack(ANY_PLASTIC.ingot(), 8), new ComparableStack(ModItems.rocket_fuel, 8), new ComparableStack(ModItems.circuit, 1, EnumCircuitType.BASIC), }, 200); makeRecipe(new ComparableStack(ModItems.missile_assembly, 1), new AStack[] {new OreDictStack(STEEL.shell(), 2), new OreDictStack(AL.shell(), 2), new OreDictStack(TI.plate(), 8), new OreDictStack(ANY_PLASTIC.ingot(), 8), new ComparableStack(ModItems.rocket_fuel, 8), new ComparableStack(ModItems.circuit, 1, EnumCircuitType.BASIC), }, 200);
makeRecipe(new ComparableStack(ModItems.warhead_generic_small, 1), new AStack[] {new OreDictStack(TI.plate(), 5), new OreDictStack(STEEL.plate(), 3), new ComparableStack(ModItems.ball_dynamite, 2), new ComparableStack(ModItems.circuit, 1, EnumCircuitType.CHIP) },100); makeRecipe(new ComparableStack(ModItems.warhead_generic_small, 1), new AStack[] {new OreDictStack(TI.plate(), 5), new OreDictStack(STEEL.plate(), 3), new ComparableStack(ModItems.ball_dynamite, 2), new ComparableStack(ModItems.circuit, 1, EnumCircuitType.CHIP) },100);
@ -552,8 +552,7 @@ public class AssemblerRecipes extends SerializableRecipe {
makeRecipe(new ComparableStack(ModBlocks.machine_cyclotron, 1), new AStack[] { makeRecipe(new ComparableStack(ModBlocks.machine_cyclotron, 1), new AStack[] {
new ComparableStack(ModBlocks.machine_lithium_battery, 3), new ComparableStack(ModBlocks.machine_lithium_battery, 3),
new ComparableStack(ModBlocks.hadron_coil_neodymium, 8), new OreDictStack(ND.wireDense(), 32),
new OreDictStack(ALLOY.wireDense(), 16),
!exp ? new OreDictStack(STEEL.ingot(), 16) : new OreDictStack(STEEL.heavyComp(), 3), !exp ? new OreDictStack(STEEL.ingot(), 16) : new OreDictStack(STEEL.heavyComp(), 3),
new OreDictStack(STEEL.plate528(), 32), new OreDictStack(STEEL.plate528(), 32),
new OreDictStack(AL.plate528(), 32), new OreDictStack(AL.plate528(), 32),
@ -1149,16 +1148,6 @@ public class AssemblerRecipes extends SerializableRecipe {
new ComparableStack(ModItems.circuit, 10, EnumCircuitType.CAPACITOR_BOARD), new ComparableStack(ModItems.circuit, 10, EnumCircuitType.CAPACITOR_BOARD),
}, 300); }, 300);
makeRecipe(new ComparableStack(ModBlocks.hadron_core, 1), new AStack[] {
new ComparableStack(ModBlocks.hadron_coil_alloy, 24),
new OreDictStack(STEEL.ingot(), 8),
new OreDictStack(ANY_PLASTIC.ingot(), 16),
new OreDictStack(ANY_RESISTANTALLOY.ingot(), 8),
new ComparableStack(ModItems.circuit, 16, EnumCircuitType.BISMOID),
new ComparableStack(ModItems.circuit, 192, EnumCircuitType.CAPACITOR_BOARD),
new ComparableStack(ModItems.crt_display, 1),
}, 300);
makeRecipe(new ComparableStack(ModBlocks.struct_launcher_core, 1), new AStack[] { makeRecipe(new ComparableStack(ModBlocks.struct_launcher_core, 1), new AStack[] {
new ComparableStack(ModBlocks.machine_battery, 3), new ComparableStack(ModBlocks.machine_battery, 3),
new ComparableStack(ModBlocks.steel_scaffold, 10), new ComparableStack(ModBlocks.steel_scaffold, 10),

View File

@ -77,7 +77,7 @@ public class BlastFurnaceRecipes extends SerializableRecipe {
hiddenRecipes.add(new ComparableStack(ModItems.meteorite_sword_alloyed)); hiddenRecipes.add(new ComparableStack(ModItems.meteorite_sword_alloyed));
} }
private static void addRecipe(Object in1, Object in2, ItemStack out) { public static void addRecipe(Object in1, Object in2, ItemStack out) {
if(in1 instanceof Item) in1 = new ComparableStack((Item) in1); if(in1 instanceof Item) in1 = new ComparableStack((Item) in1);
if(in1 instanceof Block) in1 = new ComparableStack((Block) in1); if(in1 instanceof Block) in1 = new ComparableStack((Block) in1);

View File

@ -19,7 +19,7 @@ import net.minecraft.item.ItemStack;
public class BreederRecipes extends SerializableRecipe { public class BreederRecipes extends SerializableRecipe {
private static HashMap<ComparableStack, BreederRecipe> recipes = new HashMap(); public static HashMap<ComparableStack, BreederRecipe> recipes = new HashMap();
@Override @Override
public void registerDefaults() { public void registerDefaults() {

View File

@ -43,7 +43,7 @@ import net.minecraftforge.oredict.OreDictionary;
public class CentrifugeRecipes extends SerializableRecipe { public class CentrifugeRecipes extends SerializableRecipe {
private static HashMap<AStack, ItemStack[]> recipes = new HashMap(); public static HashMap<AStack, ItemStack[]> recipes = new HashMap();
@Override @Override
public void registerDefaults() { public void registerDefaults() {

View File

@ -38,7 +38,7 @@ public class ChemplantRecipes extends SerializableRecipe {
@Override @Override
public void registerDefaults() { public void registerDefaults() {
//6-30, formerly oil cracking, coal liquefaction and solidifciation //6-30, formerly oil cracking, coal liquefaction and solidification
registerOtherOil(); registerOtherOil();
recipes.add(new ChemRecipe(36, "COOLANT", 50) recipes.add(new ChemRecipe(36, "COOLANT", 50)

View File

@ -25,7 +25,7 @@ import net.minecraft.item.ItemStack;
public class CokerRecipes extends SerializableRecipe { public class CokerRecipes extends SerializableRecipe {
private static HashMap<FluidType, Triplet<Integer, ItemStack, FluidStack>> recipes = new HashMap(); public static HashMap<FluidType, Triplet<Integer, ItemStack, FluidStack>> recipes = new HashMap();
@Override @Override
public void registerDefaults() { public void registerDefaults() {
@ -68,7 +68,7 @@ public class CokerRecipes extends SerializableRecipe {
registerRecipe(VITRIOL, 4000, new ItemStack(ModItems.powder_iron), new FluidStack(SULFURIC_ACID, 500)); registerRecipe(VITRIOL, 4000, new ItemStack(ModItems.powder_iron), new FluidStack(SULFURIC_ACID, 500));
} }
private static void registerAuto(FluidType fluid, FluidType type) { public static void registerAuto(FluidType fluid, FluidType type) {
registerSFAuto(fluid, 820_000L, DictFrame.fromOne(ModItems.coke, EnumCokeType.PETROLEUM), type); //3200 burntime * 1.25 burntime bonus * 200 TU/t + 20000TU per operation registerSFAuto(fluid, 820_000L, DictFrame.fromOne(ModItems.coke, EnumCokeType.PETROLEUM), type); //3200 burntime * 1.25 burntime bonus * 200 TU/t + 20000TU per operation
} }
private static void registerSFAuto(FluidType fluid, long tuPerSF, ItemStack fuel, FluidType type) { private static void registerSFAuto(FluidType fluid, long tuPerSF, ItemStack fuel, FluidType type) {

View File

@ -34,7 +34,7 @@ import net.minecraft.item.ItemStack;
public class CombinationRecipes extends SerializableRecipe { public class CombinationRecipes extends SerializableRecipe {
private static HashMap<Object, Pair<ItemStack, FluidStack>> recipes = new HashMap(); public static HashMap<Object, Pair<ItemStack, FluidStack>> recipes = new HashMap();
@Override @Override
public void registerDefaults() { public void registerDefaults() {

View File

@ -36,7 +36,7 @@ public class CrackingRecipes extends SerializableRecipe {
public static final int xyl_crack_aroma = 80; public static final int xyl_crack_aroma = 80;
public static final int xyl_crack_petro = 20; public static final int xyl_crack_petro = 20;
private static Map<FluidType, Pair<FluidStack, FluidStack>> cracking = new HashMap(); public static Map<FluidType, Pair<FluidStack, FluidStack>> cracking = new HashMap();
@Override @Override
public void registerDefaults() { public void registerDefaults() {

View File

@ -61,57 +61,56 @@ public class CrystallizerRecipes extends SerializableRecipe {
final int mixingTime = 20; final int mixingTime = 20;
FluidStack sulfur = new FluidStack(Fluids.SULFURIC_ACID, 500); FluidStack sulfur = new FluidStack(Fluids.SULFURIC_ACID, 500);
registerRecipe(COAL.ore(), new CrystallizerRecipe(ModItems.crystal_coal, baseTime)); registerRecipe(COAL.ore(), new CrystallizerRecipe(ModItems.crystal_coal, baseTime).prod(0.05F));
registerRecipe(IRON.ore(), new CrystallizerRecipe(ModItems.crystal_iron, baseTime)); registerRecipe(IRON.ore(), new CrystallizerRecipe(ModItems.crystal_iron, baseTime).prod(0.05F));
registerRecipe(GOLD.ore(), new CrystallizerRecipe(ModItems.crystal_gold, baseTime)); registerRecipe(GOLD.ore(), new CrystallizerRecipe(ModItems.crystal_gold, baseTime).prod(0.05F));
registerRecipe(REDSTONE.ore(), new CrystallizerRecipe(ModItems.crystal_redstone, baseTime)); registerRecipe(REDSTONE.ore(), new CrystallizerRecipe(ModItems.crystal_redstone, baseTime).prod(0.05F));
registerRecipe(LAPIS.ore(), new CrystallizerRecipe(ModItems.crystal_lapis, baseTime)); registerRecipe(LAPIS.ore(), new CrystallizerRecipe(ModItems.crystal_lapis, baseTime).prod(0.05F));
registerRecipe(DIAMOND.ore(), new CrystallizerRecipe(ModItems.crystal_diamond, baseTime)); registerRecipe(DIAMOND.ore(), new CrystallizerRecipe(ModItems.crystal_diamond, baseTime).prod(0.05F));
registerRecipe(U.ore(), new CrystallizerRecipe(ModItems.crystal_uranium, baseTime), sulfur); registerRecipe(U.ore(), new CrystallizerRecipe(ModItems.crystal_uranium, baseTime).prod(0.05F), sulfur);
for(String ore : OreDictManager.TH232.all(MaterialShapes.ONLY_ORE)) registerRecipe(ore, new CrystallizerRecipe(ModItems.crystal_thorium, baseTime), sulfur); for(String ore : OreDictManager.TH232.all(MaterialShapes.ONLY_ORE)) registerRecipe(ore, new CrystallizerRecipe(ModItems.crystal_thorium, baseTime).prod(0.05F), sulfur);
registerRecipe(PU.ore(), new CrystallizerRecipe(ModItems.crystal_plutonium, baseTime), sulfur); registerRecipe(PU.ore(), new CrystallizerRecipe(ModItems.crystal_plutonium, baseTime).prod(0.05F), sulfur);
registerRecipe(TI.ore(), new CrystallizerRecipe(ModItems.crystal_titanium, baseTime), sulfur); registerRecipe(TI.ore(), new CrystallizerRecipe(ModItems.crystal_titanium, baseTime).prod(0.05F), sulfur);
registerRecipe(S.ore(), new CrystallizerRecipe(ModItems.crystal_sulfur, baseTime)); registerRecipe(S.ore(), new CrystallizerRecipe(ModItems.crystal_sulfur, baseTime).prod(0.05F));
registerRecipe(KNO.ore(), new CrystallizerRecipe(ModItems.crystal_niter, baseTime)); registerRecipe(KNO.ore(), new CrystallizerRecipe(ModItems.crystal_niter, baseTime).prod(0.05F));
registerRecipe(CU.ore(), new CrystallizerRecipe(ModItems.crystal_copper, baseTime)); registerRecipe(CU.ore(), new CrystallizerRecipe(ModItems.crystal_copper, baseTime).prod(0.05F));
registerRecipe(W.ore(), new CrystallizerRecipe(ModItems.crystal_tungsten, baseTime), sulfur); registerRecipe(W.ore(), new CrystallizerRecipe(ModItems.crystal_tungsten, baseTime).prod(0.05F), sulfur);
registerRecipe(AL.ore(), new CrystallizerRecipe(ModItems.crystal_aluminium, baseTime)); registerRecipe(AL.ore(), new CrystallizerRecipe(ModItems.crystal_aluminium, baseTime).prod(0.05F));
registerRecipe(F.ore(), new CrystallizerRecipe(ModItems.crystal_fluorite, baseTime)); registerRecipe(F.ore(), new CrystallizerRecipe(ModItems.crystal_fluorite, baseTime).prod(0.05F));
registerRecipe(BE.ore(), new CrystallizerRecipe(ModItems.crystal_beryllium, baseTime)); registerRecipe(BE.ore(), new CrystallizerRecipe(ModItems.crystal_beryllium, baseTime).prod(0.05F));
registerRecipe(PB.ore(), new CrystallizerRecipe(ModItems.crystal_lead, baseTime)); registerRecipe(PB.ore(), new CrystallizerRecipe(ModItems.crystal_lead, baseTime).prod(0.05F));
registerRecipe(SA326.ore(), new CrystallizerRecipe(ModItems.crystal_schrabidium, baseTime), sulfur); registerRecipe(SA326.ore(), new CrystallizerRecipe(ModItems.crystal_schrabidium, baseTime).prod(0.05F), sulfur);
registerRecipe(LI.ore(), new CrystallizerRecipe(ModItems.crystal_lithium, baseTime), sulfur); registerRecipe(LI.ore(), new CrystallizerRecipe(ModItems.crystal_lithium, baseTime).prod(0.05F), sulfur);
//registerRecipe(STAR.ore(), new CrystallizerRecipe(ModItems.crystal_starmetal, baseTime), sulfur); registerRecipe(CO.ore(), new CrystallizerRecipe(ModItems.crystal_cobalt, baseTime).prod(0.05F), sulfur);
registerRecipe(CO.ore(), new CrystallizerRecipe(ModItems.crystal_cobalt, baseTime), sulfur);
registerRecipe(new ComparableStack(ModItems.powder_calcium), new CrystallizerRecipe(new ItemStack(ModItems.powder_cement, 8), utilityTime), new FluidStack(Fluids.REDMUD, 75)); registerRecipe(new ComparableStack(ModItems.powder_calcium), new CrystallizerRecipe(new ItemStack(ModItems.powder_cement, 8), utilityTime).prod(0.1F), new FluidStack(Fluids.REDMUD, 75));
registerRecipe(MALACHITE.ingot(), new CrystallizerRecipe(ItemScraps.create(new MaterialStack(Mats.MAT_COPPER, MaterialShapes.INGOT.q(1))), 300), new FluidStack(Fluids.SULFURIC_ACID, 250)); registerRecipe(MALACHITE.ingot(), new CrystallizerRecipe(ItemScraps.create(new MaterialStack(Mats.MAT_COPPER, MaterialShapes.INGOT.q(1))), 300).prod(0.1F), new FluidStack(Fluids.SULFURIC_ACID, 250));
registerRecipe("oreRareEarth", new CrystallizerRecipe(ModItems.crystal_rare, baseTime), sulfur); registerRecipe("oreRareEarth", new CrystallizerRecipe(ModItems.crystal_rare, baseTime).prod(0.05F), sulfur);
registerRecipe("oreCinnabar", new CrystallizerRecipe(ModItems.crystal_cinnebar, baseTime)); registerRecipe("oreCinnabar", new CrystallizerRecipe(ModItems.crystal_cinnebar, baseTime).prod(0.05F));
registerRecipe(new ComparableStack(ModBlocks.ore_nether_fire), new CrystallizerRecipe(ModItems.crystal_phosphorus, baseTime)); registerRecipe(new ComparableStack(ModBlocks.ore_nether_fire), new CrystallizerRecipe(ModItems.crystal_phosphorus, baseTime).prod(0.05F));
registerRecipe(new ComparableStack(ModBlocks.ore_tikite), new CrystallizerRecipe(ModItems.crystal_trixite, baseTime), sulfur); registerRecipe(new ComparableStack(ModBlocks.ore_tikite), new CrystallizerRecipe(ModItems.crystal_trixite, baseTime).prod(0.05F), sulfur);
registerRecipe(new ComparableStack(ModBlocks.gravel_diamond), new CrystallizerRecipe(ModItems.crystal_diamond, baseTime)); registerRecipe(new ComparableStack(ModBlocks.gravel_diamond), new CrystallizerRecipe(ModItems.crystal_diamond, baseTime).prod(0.05F));
registerRecipe(SRN.ingot(), new CrystallizerRecipe(ModItems.crystal_schraranium, baseTime)); registerRecipe(SRN.ingot(), new CrystallizerRecipe(ModItems.crystal_schraranium, baseTime).prod(0.05F));
registerRecipe(KEY_SAND, new CrystallizerRecipe(ModItems.ingot_fiberglass, utilityTime)); registerRecipe(KEY_SAND, new CrystallizerRecipe(ModItems.ingot_fiberglass, utilityTime).prod(0.15F));
registerRecipe(SI.ingot(), new CrystallizerRecipe(new ItemStack(Items.quartz, 2), utilityTime), new FluidStack(Fluids.OXYGEN, 250)); registerRecipe(SI.ingot(), new CrystallizerRecipe(new ItemStack(Items.quartz, 2), utilityTime).prod(0.1F), new FluidStack(Fluids.OXYGEN, 250));
registerRecipe(REDSTONE.block(), new CrystallizerRecipe(ModItems.ingot_mercury, baseTime)); registerRecipe(REDSTONE.block(), new CrystallizerRecipe(ModItems.ingot_mercury, baseTime).prod(0.25F));
registerRecipe(CINNABAR.crystal(), new CrystallizerRecipe(new ItemStack(ModItems.ingot_mercury, 3), baseTime)); registerRecipe(CINNABAR.crystal(), new CrystallizerRecipe(new ItemStack(ModItems.ingot_mercury, 3), baseTime).prod(0.25F));
registerRecipe(BORAX.dust(), new CrystallizerRecipe(new ItemStack(ModItems.powder_boron_tiny, 3), baseTime), sulfur); registerRecipe(BORAX.dust(), new CrystallizerRecipe(new ItemStack(ModItems.powder_boron_tiny, 3), baseTime).prod(0.25F), sulfur);
registerRecipe(COAL.block(), new CrystallizerRecipe(ModBlocks.block_graphite, baseTime)); registerRecipe(COAL.block(), new CrystallizerRecipe(ModBlocks.block_graphite, baseTime));
registerRecipe(new ComparableStack(Blocks.cobblestone), new CrystallizerRecipe(ModBlocks.reinforced_stone, utilityTime)); registerRecipe(new ComparableStack(Blocks.cobblestone), new CrystallizerRecipe(ModBlocks.reinforced_stone, utilityTime));
registerRecipe(new ComparableStack(ModBlocks.gravel_obsidian), new CrystallizerRecipe(ModBlocks.brick_obsidian, utilityTime)); registerRecipe(new ComparableStack(ModBlocks.gravel_obsidian), new CrystallizerRecipe(ModBlocks.brick_obsidian, utilityTime));
registerRecipe(new ComparableStack(Items.rotten_flesh), new CrystallizerRecipe(Items.leather, utilityTime)); registerRecipe(new ComparableStack(Items.rotten_flesh), new CrystallizerRecipe(Items.leather, utilityTime).prod(0.25F));
registerRecipe(new ComparableStack(ModItems.coal_infernal), new CrystallizerRecipe(ModItems.solid_fuel, utilityTime)); registerRecipe(new ComparableStack(ModItems.coal_infernal), new CrystallizerRecipe(ModItems.solid_fuel, utilityTime));
registerRecipe(new ComparableStack(ModBlocks.stone_gneiss), new CrystallizerRecipe(ModItems.powder_lithium, utilityTime)); registerRecipe(new ComparableStack(ModBlocks.stone_gneiss), new CrystallizerRecipe(ModItems.powder_lithium, utilityTime).prod(0.25F));
registerRecipe(new ComparableStack(Items.dye, 1, 15), new CrystallizerRecipe(new ItemStack(Items.slime_ball, 4), mixingTime), new FluidStack(Fluids.SULFURIC_ACID, 250)); registerRecipe(new ComparableStack(Items.dye, 1, 15), new CrystallizerRecipe(new ItemStack(Items.slime_ball, 4), mixingTime), new FluidStack(Fluids.SULFURIC_ACID, 250));
registerRecipe(new ComparableStack(Items.bone), new CrystallizerRecipe(new ItemStack(Items.slime_ball, 16), mixingTime), new FluidStack(Fluids.SULFURIC_ACID, 1_000)); registerRecipe(new ComparableStack(Items.bone), new CrystallizerRecipe(new ItemStack(Items.slime_ball, 16), mixingTime), new FluidStack(Fluids.SULFURIC_ACID, 1_000));
registerRecipe(new ComparableStack(DictFrame.fromOne(ModItems.plant_item, EnumPlantType.MUSTARDWILLOW)), new CrystallizerRecipe(new ItemStack(ModItems.powder_cadmium), 100).setReq(10), new FluidStack(Fluids.RADIOSOLVENT, 250)); registerRecipe(new ComparableStack(DictFrame.fromOne(ModItems.plant_item, EnumPlantType.MUSTARDWILLOW)), new CrystallizerRecipe(new ItemStack(ModItems.powder_cadmium), 100).setReq(10), new FluidStack(Fluids.RADIOSOLVENT, 250));
registerRecipe(new ComparableStack(ModItems.scrap_oil), new CrystallizerRecipe(new ItemStack(ModItems.nugget_arsenic), 100).setReq(16), new FluidStack(Fluids.RADIOSOLVENT, 100)); registerRecipe(new ComparableStack(ModItems.scrap_oil), new CrystallizerRecipe(new ItemStack(ModItems.nugget_arsenic), 100).prod(0.3F).setReq(16), new FluidStack(Fluids.RADIOSOLVENT, 100));
registerRecipe(new ComparableStack(DictFrame.fromOne(ModItems.powder_ash, EnumAshType.FULLERENE)), new CrystallizerRecipe(new ItemStack(ModItems.ingot_cft), baseTime).setReq(4), new FluidStack(Fluids.XYLENE, 1_000)); registerRecipe(new ComparableStack(DictFrame.fromOne(ModItems.powder_ash, EnumAshType.FULLERENE)), new CrystallizerRecipe(new ItemStack(ModItems.ingot_cft), baseTime).prod(0.1F).setReq(4), new FluidStack(Fluids.XYLENE, 1_000));
registerRecipe(DIAMOND.dust(), new CrystallizerRecipe(Items.diamond, utilityTime)); registerRecipe(DIAMOND.dust(), new CrystallizerRecipe(Items.diamond, utilityTime));
registerRecipe(EMERALD.dust(), new CrystallizerRecipe(Items.emerald, utilityTime)); registerRecipe(EMERALD.dust(), new CrystallizerRecipe(Items.emerald, utilityTime));
@ -120,8 +119,8 @@ public class CrystallizerRecipes extends SerializableRecipe {
registerRecipe(new ComparableStack(ModItems.powder_desh_ready), new CrystallizerRecipe(ModItems.ingot_desh, baseTime)); registerRecipe(new ComparableStack(ModItems.powder_desh_ready), new CrystallizerRecipe(ModItems.ingot_desh, baseTime));
registerRecipe(new ComparableStack(ModItems.powder_meteorite), new CrystallizerRecipe(ModItems.fragment_meteorite, utilityTime)); registerRecipe(new ComparableStack(ModItems.powder_meteorite), new CrystallizerRecipe(ModItems.fragment_meteorite, utilityTime));
registerRecipe(CD.dust(), new CrystallizerRecipe(ModItems.ingot_rubber, utilityTime), new FluidStack(Fluids.FISHOIL, 250)); registerRecipe(CD.dust(), new CrystallizerRecipe(ModItems.ingot_rubber, utilityTime), new FluidStack(Fluids.FISHOIL, 250));
registerRecipe(LATEX.ingot(), new CrystallizerRecipe(ModItems.ingot_rubber, mixingTime), new FluidStack(Fluids.SOURGAS, 25)); registerRecipe(LATEX.ingot(), new CrystallizerRecipe(ModItems.ingot_rubber, mixingTime).prod(0.15F), new FluidStack(Fluids.SOURGAS, 25));
registerRecipe(new ComparableStack(ModItems.powder_sawdust), new CrystallizerRecipe(ModItems.cordite, mixingTime), new FluidStack(Fluids.NITROGLYCERIN, 250)); registerRecipe(new ComparableStack(ModItems.powder_sawdust), new CrystallizerRecipe(ModItems.cordite, mixingTime).prod(0.25F), new FluidStack(Fluids.NITROGLYCERIN, 250));
registerRecipe(new ComparableStack(ModItems.meteorite_sword_treated), new CrystallizerRecipe(ModItems.meteorite_sword_etched, baseTime)); registerRecipe(new ComparableStack(ModItems.meteorite_sword_treated), new CrystallizerRecipe(ModItems.meteorite_sword_etched, baseTime));
registerRecipe(new ComparableStack(ModItems.powder_impure_osmiridium), new CrystallizerRecipe(ModItems.crystal_osmiridium, baseTime), new FluidStack(Fluids.SCHRABIDIC, 1_000)); registerRecipe(new ComparableStack(ModItems.powder_impure_osmiridium), new CrystallizerRecipe(ModItems.crystal_osmiridium, baseTime), new FluidStack(Fluids.SCHRABIDIC, 1_000));
@ -202,14 +201,14 @@ public class CrystallizerRecipes extends SerializableRecipe {
registerRecipe(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type)), new CrystallizerRecipe(ItemBedrockOreNew.make(BedrockOreGrade.BASE, type), bedrock).setReq(64), new FluidStack(Fluids.NITRIC_ACID, 1000)); registerRecipe(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type)), new CrystallizerRecipe(ItemBedrockOreNew.make(BedrockOreGrade.BASE, type), bedrock).setReq(64), new FluidStack(Fluids.NITRIC_ACID, 1000));
} }
FluidStack[] dyes = new FluidStack[] {new FluidStack(Fluids.WOODOIL, 100), new FluidStack(Fluids.FISHOIL, 100)}; FluidStack[] dyes = new FluidStack[] {new FluidStack(Fluids.WOODOIL, 100), new FluidStack(Fluids.FISHOIL, 100), new FluidStack(Fluids.LIGHTOIL, 100)};
for(FluidStack dye : dyes) { for(FluidStack dye : dyes) {
registerRecipe(COAL.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.BLACK, 4), mixingTime), dye); registerRecipe(COAL.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.BLACK, 4), mixingTime).prod(0.15F), dye);
registerRecipe(TI.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.WHITE, 4), mixingTime), dye); registerRecipe(TI.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.WHITE, 4), mixingTime).prod(0.15F), dye);
registerRecipe(IRON.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.RED, 4), mixingTime), dye); registerRecipe(IRON.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.RED, 4), mixingTime).prod(0.15F), dye);
registerRecipe(W.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.YELLOW, 4), mixingTime), dye); registerRecipe(W.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.YELLOW, 4), mixingTime).prod(0.15F), dye);
registerRecipe(CU.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.GREEN, 4), mixingTime), dye); registerRecipe(CU.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.GREEN, 4), mixingTime).prod(0.15F), dye);
registerRecipe(CO.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.BLUE, 4), mixingTime), dye); registerRecipe(CO.dust(), new CrystallizerRecipe(DictFrame.fromOne(ModItems.chemical_dye, EnumChemDye.BLUE, 4), mixingTime).prod(0.15F), dye);
} }
registerRecipe(new ComparableStack(DictFrame.fromOne(ModItems.oil_tar, EnumTarType.CRUDE)), new CrystallizerRecipe(DictFrame.fromOne(ModItems.oil_tar, EnumTarType.WAX), 20), new FluidStack(Fluids.CHLORINE, 250)); registerRecipe(new ComparableStack(DictFrame.fromOne(ModItems.oil_tar, EnumTarType.CRUDE)), new CrystallizerRecipe(DictFrame.fromOne(ModItems.oil_tar, EnumTarType.WAX), 20), new FluidStack(Fluids.CHLORINE, 250));
@ -236,6 +235,12 @@ public class CrystallizerRecipes extends SerializableRecipe {
registerRecipe(P_WHITE.dust(), new CrystallizerRecipe(new ItemStack(ModItems.ingot_phosphorus), utilityTime), new FluidStack(Fluids.AROMATICS, 50)); registerRecipe(P_WHITE.dust(), new CrystallizerRecipe(new ItemStack(ModItems.ingot_phosphorus), utilityTime), new FluidStack(Fluids.AROMATICS, 50));
} }
/// COMPAT CINNABAR DUST ///
List<ItemStack> dustCinnabar = OreDictionary.getOres(CINNABAR.dust());
if(dustCinnabar != null && !dustCinnabar.isEmpty()) {
registerRecipe(CINNABAR.dust(), new CrystallizerRecipe(new ItemStack(ModItems.cinnebar), utilityTime), new FluidStack(Fluids.PEROXIDE, 50));
}
if(!IMCCrystallizer.buffer.isEmpty()) { if(!IMCCrystallizer.buffer.isEmpty()) {
recipes.putAll(IMCCrystallizer.buffer); recipes.putAll(IMCCrystallizer.buffer);
MainRegistry.logger.info("Fetched " + IMCCrystallizer.buffer.size() + " IMC crystallizer recipes!"); MainRegistry.logger.info("Fetched " + IMCCrystallizer.buffer.size() + " IMC crystallizer recipes!");
@ -327,6 +332,7 @@ public class CrystallizerRecipes extends SerializableRecipe {
public int acidAmount; public int acidAmount;
public int itemAmount = 1; public int itemAmount = 1;
public int duration; public int duration;
public float productivity = 0F;
public ItemStack output; public ItemStack output;
public CrystallizerRecipe(Block output, int duration) { this(new ItemStack(output), duration); } public CrystallizerRecipe(Block output, int duration) { this(new ItemStack(output), duration); }
@ -342,6 +348,11 @@ public class CrystallizerRecipes extends SerializableRecipe {
this.duration = duration; this.duration = duration;
this.acidAmount = 500; this.acidAmount = 500;
} }
public CrystallizerRecipe prod(float productivity) {
this.productivity = productivity;
return this;
}
} }
@Override @Override
@ -371,6 +382,7 @@ public class CrystallizerRecipes extends SerializableRecipe {
} else if(input instanceof OreDictStack) { } else if(input instanceof OreDictStack) {
recipes.put(new Pair(((OreDictStack) input).name, fluid.type), cRecipe); recipes.put(new Pair(((OreDictStack) input).name, fluid.type), cRecipe);
} }
if(obj.has("productivity")) cRecipe.prod(obj.get("productivity").getAsFloat());
} }
@Override @Override
@ -389,6 +401,7 @@ public class CrystallizerRecipes extends SerializableRecipe {
this.writeAStack(input, writer); this.writeAStack(input, writer);
writer.name("output"); writer.name("output");
this.writeItemStack(cRecipe.output, writer); this.writeItemStack(cRecipe.output, writer);
writer.name("productivity").value(cRecipe.productivity);
} }
@Override @Override

View File

@ -19,7 +19,7 @@ import net.minecraft.item.ItemStack;
public class FractionRecipes extends SerializableRecipe { public class FractionRecipes extends SerializableRecipe {
private static Map<FluidType, Pair<FluidStack, FluidStack>> fractions = new HashMap(); public static Map<FluidType, Pair<FluidStack, FluidStack>> fractions = new HashMap();
@Override @Override
public void registerDefaults() { public void registerDefaults() {
@ -40,8 +40,8 @@ public class FractionRecipes extends SerializableRecipe {
fractions.put(Fluids.OIL_COKER, new Pair(new FluidStack(Fluids.CRACKOIL, 30), new FluidStack(Fluids.HEATINGOIL, 70))); fractions.put(Fluids.OIL_COKER, new Pair(new FluidStack(Fluids.CRACKOIL, 30), new FluidStack(Fluids.HEATINGOIL, 70)));
fractions.put(Fluids.NAPHTHA_COKER, new Pair(new FluidStack(Fluids.NAPHTHA_CRACK, 75), new FluidStack(Fluids.LIGHTOIL_CRACK, 25))); fractions.put(Fluids.NAPHTHA_COKER, new Pair(new FluidStack(Fluids.NAPHTHA_CRACK, 75), new FluidStack(Fluids.LIGHTOIL_CRACK, 25)));
fractions.put(Fluids.GAS_COKER, new Pair(new FluidStack(Fluids.AROMATICS, 25), new FluidStack(Fluids.CARBONDIOXIDE, 75))); fractions.put(Fluids.GAS_COKER, new Pair(new FluidStack(Fluids.AROMATICS, 25), new FluidStack(Fluids.CARBONDIOXIDE, 75)));
fractions.put(Fluids.CHLOROCALCITE_MIX, new Pair(new FluidStack(Fluids.CHLOROCALCITE_CLEANED, 50), new FluidStack(Fluids.COLLOID, 50))); fractions.put(Fluids.CHLOROCALCITE_MIX, new Pair(new FluidStack(Fluids.CHLOROCALCITE_CLEANED, 50), new FluidStack(Fluids.COLLOID, 50)));
fractions.put(Fluids.BAUXITE_SOLUTION, new Pair(new FluidStack(Fluids.REDMUD, 50), new FluidStack(Fluids.SODIUM_ALUMINATE, 50))); fractions.put(Fluids.BAUXITE_SOLUTION, new Pair(new FluidStack(Fluids.REDMUD, 50), new FluidStack(Fluids.SODIUM_ALUMINATE, 50)));
} }
public static Pair<FluidStack, FluidStack> getFractions(FluidType oil) { public static Pair<FluidStack, FluidStack> getFractions(FluidType oil) {

View File

@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.recipes.loader.SerializableRecipe; import com.hbm.inventory.recipes.loader.SerializableRecipe;
@ -15,7 +14,7 @@ import com.hbm.tileentity.machine.TileEntityHadron.EnumHadronState;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class HadronRecipes extends SerializableRecipe { @Deprecated public class HadronRecipes extends SerializableRecipe {
/* /*
* Since we're dealing with like 10 or so recipes, using a HashMap (or to combine two keys, a HashMap *in* a HashMap) * Since we're dealing with like 10 or so recipes, using a HashMap (or to combine two keys, a HashMap *in* a HashMap)
@ -183,45 +182,10 @@ public class HadronRecipes extends SerializableRecipe {
} }
@Override @Override
public void readRecipe(JsonElement recipe) { public void readRecipe(JsonElement recipe) { }
JsonObject obj = (JsonObject) recipe;
int momentum = obj.get("momentum").getAsInt();
boolean lineMode = obj.get("lineMode").getAsBoolean();
ItemStack[] in = this.readItemStackArray(obj.get("inputs").getAsJsonArray());
ItemStack[] out = this.readItemStackArray(obj.get("outputs").getAsJsonArray());
this.recipes.add(new HadronRecipe(
in[0],
in[1],
momentum,
out[0],
out[1],
lineMode
));
}
@Override @Override
public void writeRecipe(Object recipe, JsonWriter writer) throws IOException { public void writeRecipe(Object recipe, JsonWriter writer) throws IOException { }
HadronRecipe rec = (HadronRecipe) recipe;
writer.name("momentum").value(rec.momentum);
writer.name("lineMode").value(rec.analysisOnly);
writer.name("inputs").beginArray();
this.writeItemStack(rec.in1.toStack(), writer);
this.writeItemStack(rec.in2.toStack(), writer);
writer.endArray();
writer.name("outputs").beginArray();
this.writeItemStack(rec.out1, writer);
this.writeItemStack(rec.out2, writer);
writer.endArray();
}
@Override
public String getComment() {
return "Rules: Both in- and output stacks cannot be null. Stacksizes are set to 1 for all stacks.";
}
@Override @Override
public void deleteRecipes() { public void deleteRecipes() {

View File

@ -18,7 +18,7 @@ import net.minecraft.item.ItemStack;
public class HydrotreatingRecipes extends SerializableRecipe { public class HydrotreatingRecipes extends SerializableRecipe {
private static HashMap<FluidType, Triplet<FluidStack, FluidStack, FluidStack>> recipes = new HashMap(); public static HashMap<FluidType, Triplet<FluidStack, FluidStack, FluidStack>> recipes = new HashMap();
@Override @Override
public void registerDefaults() { public void registerDefaults() {

View File

@ -27,7 +27,7 @@ import net.minecraftforge.oredict.OreDictionary;
public class LiquefactionRecipes extends SerializableRecipe { public class LiquefactionRecipes extends SerializableRecipe {
private static HashMap<Object, FluidStack> recipes = new HashMap(); public static HashMap<Object, FluidStack> recipes = new HashMap();
@Override @Override
public void registerDefaults() { public void registerDefaults() {

View File

@ -56,18 +56,6 @@ public class MagicRecipes {
new ComparableStack(ModItems.powder_dineutronium), new ComparableStack(ModItems.powder_dineutronium),
new ComparableStack(ModItems.blades_desh), new ComparableStack(ModItems.blades_desh),
new ComparableStack(ModItems.diamond_gavel))); new ComparableStack(ModItems.diamond_gavel)));
recipes.add(new MagicRecipe(new ItemStack(ModBlocks.hadron_coil_mese),
new ComparableStack(ModBlocks.hadron_coil_chlorophyte),
new ComparableStack(ModItems.powder_dineutronium),
new ComparableStack(ModItems.plate_desh),
new OreDictStack(GOLD.dust())));
recipes.add(new MagicRecipe(new ItemStack(ModBlocks.hadron_coil_mese),
new ComparableStack(ModBlocks.hadron_coil_chlorophyte),
new OreDictStack(DNT.wireDense()),
new OreDictStack(W.wireDense()),
new OreDictStack(GOLD.wireDense())));
} }
public static List<MagicRecipe> getRecipes() { public static List<MagicRecipe> getRecipes() {

View File

@ -147,7 +147,7 @@ public class PedestalRecipes extends SerializableRecipe {
} }
public static enum PedestalExtraCondition { public static enum PedestalExtraCondition {
NONE, FULL_MOON, NEW_MOON, SUN NONE, FULL_MOON, NEW_MOON, SUN, GOOD_KARMA, BAD_KARMA
} }
public static class PedestalRecipe { public static class PedestalRecipe {

View File

@ -118,9 +118,13 @@ public class PyroOvenRecipes extends SerializableRecipe {
recipes.add(new PyroOvenRecipe(60) recipes.add(new PyroOvenRecipe(60)
.in(new FluidStack(GAS_COKER, 4_000)) .in(new FluidStack(GAS_COKER, 4_000))
.out(new FluidStack(Fluids.REFORMGAS, 100))); .out(new FluidStack(Fluids.REFORMGAS, 100)));
//hydrogen and carbon from natgas
recipes.add(new PyroOvenRecipe(60)
.in(new FluidStack(Fluids.GAS, 12_000))
.out(new FluidStack(Fluids.HYDROGEN, 8_000)).out(new ItemStack(ModItems.ingot_graphite, 1)));
} }
private static void registerSFAuto(FluidType fluid) { public static void registerSFAuto(FluidType fluid) {
registerSFAuto(fluid, 1_440_000L, ModItems.solid_fuel); //3200 burntime * 1.5 burntime bonus * 300 TU/t registerSFAuto(fluid, 1_440_000L, ModItems.solid_fuel); //3200 burntime * 1.5 burntime bonus * 300 TU/t
} }
private static void registerSFAuto(FluidType fluid, long tuPerSF, Item fuel) { private static void registerSFAuto(FluidType fluid, long tuPerSF, Item fuel) {

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