Compare commits

...

2 commits

Author SHA1 Message Date
bceb2f1ad6
fix: TE init packets are processed correctly 2024-08-21 15:01:28 +02:00
c61ee30c7f
feat: add ported IC2 code 2024-08-20 19:46:59 +02:00
1829 changed files with 117171 additions and 4 deletions

129
.clang-format Normal file
View file

@ -0,0 +1,129 @@
---
AccessModifierOffset: 0
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: None
AlignConsecutiveAssignments: None
AlignConsecutiveMacros: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: DontAlign
AlignOperands: DontAlign
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros: []
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: After
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakAfterJavaFieldAnnotations: true
#BreakArrays: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: true
ColumnLimit: 90
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false # wtf
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros: ["BOOST_FOREACH"]
IfMacros: []
IncludeBlocks: Regroup
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: true
IndentPPDirectives: BeforeHash
#IndentRequiresClause: false
IndentWidth: 4
IndentWrappedFunctionNames: false
#InsertBraces: false
InsertTrailingCommas: Wrapped
JavaScriptQuotes: Double
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: OuterScope
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PackConstructorInitializers: NextLine
PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Left
ReflowComments: true
#RemoveSemicolon: true
#RequiresClausePosition: OwnLine
#RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Always
SortIncludes: false
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: After
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: false
SpaceBeforeInheritanceColon: false
SpaceBeforeParens: ControlStatementsExceptControlMacros
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInLineCommentPrefix:
Minimum: 0
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++20
StatementAttributeLikeMacros: []
StatementMacros: []
TabWidth: 4
TypenameMacros: []
UseCRLF: false # wtf
UseTab: Never
WhitespaceSensitiveMacros: ["BOOST_PP_STRINGSIZE"]

4
.gitignore vendored
View file

@ -2,3 +2,7 @@
.idea
build
run
bin
.settings
.classpath
.project

View file

@ -23,9 +23,9 @@ apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
version = "1.0"
group= "modgroup"
archivesBaseName = "modid"
version = "2.2.827-experimental"
group = "net.industrial-craft"
archivesBaseName = "industrialcraft-2"
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
@ -33,11 +33,29 @@ minecraft {
}
repositories {
maven {
url = "https://s3.tilera.xyz/cdn/minecraft/libs/"
metadataSources { artifact() }
}
maven { url = "https://maven.tilera.xyz" }
maven {
name "central"
url "https://nexus.covers1624.net/repository/maven-hosted/"
}
}
dependencies {
implementation "org.ejml:EJML-core:0.26"
implementation "buildcraft:buildcraft:7.1.25:dev"
implementation "codechicken:NotEnoughItems:1.7.10-1.0.5.120:dev"
implementation "codechicken:CodeChickenCore:1.7.10-1.0.7.48:dev"
implementation "codechicken:CodeChickenLib:1.7.10-1.1.3.141:dev"
}
jar {
manifest {
attributes "FMLAT": "IC2_at.cfg"
}
}
processResources {
@ -85,4 +103,4 @@ publishing {
mavenLocal()
}
}
}
}

View file

@ -0,0 +1,90 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api;
import java.util.EnumSet;
import net.minecraft.world.World;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.Set;
public enum Direction {
XN,
XP,
YN,
YP,
ZN,
ZP;
public final int xOffset;
public final int yOffset;
public final int zOffset;
public static final Direction[] directions;
public static final Set<Direction> noDirections;
public static final Set<Direction> allDirections;
private Direction() {
final int side = this.ordinal() / 2;
final int sign = this.getSign();
this.xOffset = ((side == 0) ? sign : 0);
this.yOffset = ((side == 1) ? sign : 0);
this.zOffset = ((side == 2) ? sign : 0);
}
public static Direction fromSideValue(final int side) {
return Direction.directions[(side + 2) % 6];
}
public static Direction fromForgeDirection(final ForgeDirection dir) {
if (dir == ForgeDirection.UNKNOWN) {
return null;
}
return fromSideValue(dir.ordinal());
}
public TileEntity applyToTileEntity(final TileEntity te) {
return this.applyTo(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
}
public TileEntity applyTo(final World world, final int x, final int y, final int z) {
final int[] array;
final int[] coords = array = new int[] { x, y, z };
final int n = this.ordinal() / 2;
array[n] += this.getSign();
if (world != null && world.blockExists(coords[0], coords[1], coords[2])) {
try {
return world.getTileEntity(coords[0], coords[1], coords[2]);
} catch (final Exception e) {
throw new RuntimeException(
"error getting TileEntity at dim " + world.provider.dimensionId + " "
+ coords[0] + "/" + coords[1] + "/" + coords[2]
);
}
}
return null;
}
public Direction getInverse() {
return Direction.directions[this.ordinal() ^ 0x1];
}
public int toSideValue() {
return (this.ordinal() + 4) % 6;
}
private int getSign() {
return this.ordinal() % 2 * 2 - 1;
}
public ForgeDirection toForgeDirection() {
return ForgeDirection.getOrientation(this.toSideValue());
}
static {
directions = values();
noDirections = EnumSet.noneOf(Direction.class);
allDirections = EnumSet.allOf(Direction.class);
}
}

View file

@ -0,0 +1,53 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.crops;
public class BaseSeed {
public final CropCard crop;
@Deprecated
public int id;
public int size;
public int statGrowth;
public int statGain;
public int statResistance;
public int stackSize;
public BaseSeed(
final CropCard crop,
final int size,
final int statGrowth,
final int statGain,
final int statResistance,
final int stackSize
) {
this.crop = crop;
this.id = Crops.instance.getIdFor(crop);
this.size = size;
this.statGrowth = statGrowth;
this.statGain = statGain;
this.statResistance = statResistance;
this.stackSize = stackSize;
}
@Deprecated
public BaseSeed(
final int id,
final int size,
final int statGrowth,
final int statGain,
final int statResistance,
final int stackSize
) {
this(getCropFromId(id), size, statGrowth, statGain, statResistance, stackSize);
}
private static CropCard getCropFromId(final int id) {
final CropCard[] crops = Crops.instance.getCropList();
if (id < 0 || id >= crops.length) {
return null;
}
return crops[id];
}
}

View file

@ -0,0 +1,195 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.crops;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.Loader;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.client.renderer.texture.IIconRegister;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.IIcon;
public abstract class CropCard {
@SideOnly(Side.CLIENT)
protected IIcon[] textures;
private final String modId;
public CropCard() {
this.modId = getModId();
}
public abstract String name();
public String owner() {
return this.modId;
}
public String displayName() {
return this.name();
}
public String discoveredBy() {
return "unknown";
}
public String desc(final int i) {
final String[] att = this.attributes();
if (att == null || att.length == 0) {
return "";
}
if (i == 0) {
String s = att[0];
if (att.length >= 2) {
s = s + ", " + att[1];
if (att.length >= 3) {
s += ",";
}
}
return s;
}
if (att.length < 3) {
return "";
}
String s = att[2];
if (att.length >= 4) {
s = s + ", " + att[3];
}
return s;
}
public int getrootslength(final ICropTile crop) {
return 1;
}
public abstract int tier();
public abstract int stat(final int p0);
public abstract String[] attributes();
public abstract int maxSize();
@SideOnly(Side.CLIENT)
public void registerSprites(final IIconRegister iconRegister) {
this.textures = new IIcon[this.maxSize()];
for (int i = 1; i <= this.textures.length; ++i) {
this.textures[i - 1] = iconRegister.registerIcon(
"ic2:crop/blockCrop." + this.name() + "." + i
);
}
}
@SideOnly(Side.CLIENT)
public IIcon getSprite(final ICropTile crop) {
if (crop.getSize() <= 0 || crop.getSize() > this.textures.length) {
return null;
}
return this.textures[crop.getSize() - 1];
}
public int growthDuration(final ICropTile crop) {
return this.tier() * 200;
}
public abstract boolean canGrow(final ICropTile p0);
public int weightInfluences(
final ICropTile crop, final float humidity, final float nutrients, final float air
) {
return (int) (humidity + nutrients + air);
}
public boolean canCross(final ICropTile crop) {
return crop.getSize() >= 3;
}
public boolean rightclick(final ICropTile crop, final EntityPlayer player) {
return crop.harvest(true);
}
public abstract int getOptimalHavestSize(final ICropTile p0);
public abstract boolean canBeHarvested(final ICropTile p0);
public float dropGainChance() {
return (float) Math.pow(0.95, this.tier());
}
public abstract ItemStack getGain(final ICropTile p0);
public byte getSizeAfterHarvest(final ICropTile crop) {
return 1;
}
public boolean leftclick(final ICropTile crop, final EntityPlayer player) {
return crop.pick(true);
}
public float dropSeedChance(final ICropTile crop) {
if (crop.getSize() == 1) {
return 0.0f;
}
float base = 0.5f;
if (crop.getSize() == 2) {
base /= 2.0f;
}
for (int i = 0; i < this.tier(); ++i) {
base *= (float) 0.8;
}
return base;
}
public ItemStack getSeeds(final ICropTile crop) {
return crop.generateSeeds(
crop.getCrop(),
crop.getGrowth(),
crop.getGain(),
crop.getResistance(),
crop.getScanLevel()
);
}
public void onNeighbourChange(final ICropTile crop) {}
public int emitRedstone(final ICropTile crop) {
return 0;
}
public void onBlockDestroyed(final ICropTile crop) {}
public int getEmittedLight(final ICropTile crop) {
return 0;
}
public boolean onEntityCollision(final ICropTile crop, final Entity entity) {
return entity instanceof EntityLivingBase
&& ((EntityLivingBase) entity).isSprinting();
}
public void tick(final ICropTile crop) {}
public boolean isWeed(final ICropTile crop) {
return crop.getSize() >= 2
&& (crop.getCrop() == Crops.weed || crop.getGrowth() >= 24);
}
@Deprecated
public final int getId() {
return Crops.instance.getIdFor(this);
}
private static String getModId() {
final ModContainer modContainer = Loader.instance().activeModContainer();
if (modContainer != null) {
return modContainer.getModId();
}
assert false;
return "unknown";
}
}

View file

@ -0,0 +1,68 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.crops;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import java.util.Collection;
import net.minecraft.item.ItemStack;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
public abstract class Crops {
public static Crops instance;
public static CropCard weed;
public abstract void
addBiomenutrientsBonus(final BiomeDictionary.Type p0, final int p1);
public abstract void
addBiomehumidityBonus(final BiomeDictionary.Type p0, final int p1);
public abstract int getHumidityBiomeBonus(final BiomeGenBase p0);
public abstract int getNutrientBiomeBonus(final BiomeGenBase p0);
public abstract CropCard getCropCard(final String p0, final String p1);
public abstract CropCard getCropCard(final ItemStack p0);
public abstract Collection<CropCard> getCrops();
@Deprecated
public abstract CropCard[] getCropList();
public abstract short registerCrop(final CropCard p0);
public abstract boolean registerCrop(final CropCard p0, final int p1);
@Deprecated
public abstract boolean registerBaseSeed(
final ItemStack p0,
final int p1,
final int p2,
final int p3,
final int p4,
final int p5
);
public abstract boolean registerBaseSeed(
final ItemStack p0,
final CropCard p1,
final int p2,
final int p3,
final int p4,
final int p5
);
public abstract BaseSeed getBaseSeed(final ItemStack p0);
@SideOnly(Side.CLIENT)
public abstract void startSpriteRegistration(final IIconRegister p0);
@Deprecated
public abstract int getIdFor(final CropCard p0);
}

View file

@ -0,0 +1,92 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.crops;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraft.nbt.NBTTagCompound;
public interface ICropTile {
CropCard getCrop();
void setCrop(final CropCard p0);
@Deprecated
short getID();
@Deprecated
void setID(final short p0);
byte getSize();
void setSize(final byte p0);
byte getGrowth();
void setGrowth(final byte p0);
byte getGain();
void setGain(final byte p0);
byte getResistance();
void setResistance(final byte p0);
byte getScanLevel();
void setScanLevel(final byte p0);
NBTTagCompound getCustomData();
int getNutrientStorage();
void setNutrientStorage(final int p0);
int getHydrationStorage();
void setHydrationStorage(final int p0);
int getWeedExStorage();
void setWeedExStorage(final int p0);
byte getHumidity();
byte getNutrients();
byte getAirQuality();
World getWorld();
ChunkCoordinates getLocation();
int getLightLevel();
boolean pick(final boolean p0);
boolean harvest(final boolean p0);
ItemStack[] harvest_automated(final boolean p0);
void reset();
void updateState();
boolean isBlockBelow(final Block p0);
boolean isBlockBelow(final String p0);
ItemStack generateSeeds(
final CropCard p0, final byte p1, final byte p2, final byte p3, final byte p4
);
@Deprecated
ItemStack generateSeeds(
final short p0, final byte p1, final byte p2, final byte p3, final byte p4
);
}

View file

@ -0,0 +1,9 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy;
public final class EnergyNet {
public static IEnergyNet instance;
}

View file

@ -0,0 +1,27 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public interface IEnergyNet {
TileEntity getTileEntity(final World p0, final int p1, final int p2, final int p3);
TileEntity getNeighbor(final TileEntity p0, final ForgeDirection p1);
@Deprecated
double getTotalEnergyEmitted(final TileEntity p0);
@Deprecated
double getTotalEnergySunken(final TileEntity p0);
NodeStats getNodeStats(final TileEntity p0);
double getPowerFromTier(final int p0);
int getTierFromPower(final double p0);
}

View file

@ -0,0 +1,31 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy;
public class NodeStats {
protected double energyIn;
protected double energyOut;
protected double voltage;
public NodeStats(
final double energyIn, final double energyOut, final double voltage
) {
this.energyIn = energyIn;
this.energyOut = energyOut;
this.voltage = voltage;
}
public double getEnergyIn() {
return this.energyIn;
}
public double getEnergyOut() {
return this.energyOut;
}
public double getVoltage() {
return this.voltage;
}
}

View file

@ -0,0 +1,21 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.event;
import net.minecraft.tileentity.TileEntity;
import ic2.api.energy.tile.IEnergyTile;
import net.minecraftforge.event.world.WorldEvent;
public class EnergyTileEvent extends WorldEvent {
public final IEnergyTile energyTile;
public EnergyTileEvent(final IEnergyTile energyTile1) {
super(((TileEntity) energyTile1).getWorldObj());
if (this.world == null) {
throw new NullPointerException("world is null");
}
this.energyTile = energyTile1;
}
}

View file

@ -0,0 +1,13 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.event;
import ic2.api.energy.tile.IEnergyTile;
public class EnergyTileLoadEvent extends EnergyTileEvent {
public EnergyTileLoadEvent(final IEnergyTile energyTile1) {
super(energyTile1);
}
}

View file

@ -0,0 +1,13 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.event;
import ic2.api.energy.tile.IEnergyTile;
public class EnergyTileUnloadEvent extends EnergyTileEvent {
public EnergyTileUnloadEvent(final IEnergyTile energyTile1) {
super(energyTile1);
}
}

View file

@ -0,0 +1,180 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.prefab;
import net.minecraftforge.common.util.ForgeDirection;
import ic2.api.item.ElectricItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import cpw.mods.fml.common.eventhandler.Event;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.energy.event.EnergyTileLoadEvent;
import net.minecraftforge.common.MinecraftForge;
import ic2.api.info.Info;
import cpw.mods.fml.common.FMLCommonHandler;
import ic2.api.energy.tile.IEnergySink;
import net.minecraft.tileentity.TileEntity;
public class BasicSink extends TileEntity implements IEnergySink {
public final TileEntity parent;
protected int capacity;
protected int tier;
protected double energyStored;
protected boolean addedToEnet;
public BasicSink(final TileEntity parent1, final int capacity1, final int tier1) {
this.parent = parent1;
this.capacity = capacity1;
this.tier = tier1;
}
public void updateEntity() {
if (!this.addedToEnet) {
this.onLoaded();
}
}
public void onLoaded() {
if (!this.addedToEnet
&& !FMLCommonHandler.instance().getEffectiveSide().isClient()
&& Info.isIc2Available()) {
this.worldObj = this.parent.getWorldObj();
this.xCoord = this.parent.xCoord;
this.yCoord = this.parent.yCoord;
this.zCoord = this.parent.zCoord;
MinecraftForge.EVENT_BUS.post((Event) new EnergyTileLoadEvent(this));
this.addedToEnet = true;
}
}
public void invalidate() {
super.invalidate();
this.onChunkUnload();
}
public void onChunkUnload() {
if (this.addedToEnet && Info.isIc2Available()) {
MinecraftForge.EVENT_BUS.post((Event) new EnergyTileUnloadEvent(this));
this.addedToEnet = false;
}
}
public void readFromNBT(final NBTTagCompound tag) {
super.readFromNBT(tag);
final NBTTagCompound data = tag.getCompoundTag("IC2BasicSink");
this.energyStored = data.getDouble("energy");
}
public void writeToNBT(final NBTTagCompound tag) {
try {
super.writeToNBT(tag);
} catch (final RuntimeException ex) {}
final NBTTagCompound data = new NBTTagCompound();
data.setDouble("energy", this.energyStored);
tag.setTag("IC2BasicSink", (NBTBase) data);
}
public int getCapacity() {
return this.capacity;
}
public void setCapacity(final int capacity1) {
this.capacity = capacity1;
}
public int getTier() {
return this.tier;
}
public void setTier(final int tier1) {
this.tier = tier1;
}
public double getEnergyStored() {
return this.energyStored;
}
public void setEnergyStored(final double amount) {
this.energyStored = amount;
}
public boolean canUseEnergy(final double amount) {
return this.energyStored >= amount;
}
public boolean useEnergy(final double amount) {
if (this.canUseEnergy(amount)
&& !FMLCommonHandler.instance().getEffectiveSide().isClient()) {
this.energyStored -= amount;
return true;
}
return false;
}
public boolean discharge(final ItemStack stack, final int limit) {
if (stack == null || !Info.isIc2Available()) {
return false;
}
double amount = this.capacity - this.energyStored;
if (amount <= 0.0) {
return false;
}
if (limit > 0 && limit < amount) {
amount = limit;
}
amount = ElectricItem.manager.discharge(
stack, amount, this.tier, limit > 0, true, false
);
this.energyStored += amount;
return amount > 0.0;
}
@Deprecated
public void onUpdateEntity() {
this.updateEntity();
}
@Deprecated
public void onInvalidate() {
this.invalidate();
}
@Deprecated
public void onOnChunkUnload() {
this.onChunkUnload();
}
@Deprecated
public void onReadFromNbt(final NBTTagCompound tag) {
this.readFromNBT(tag);
}
@Deprecated
public void onWriteToNbt(final NBTTagCompound tag) {
this.writeToNBT(tag);
}
public boolean
acceptsEnergyFrom(final TileEntity emitter, final ForgeDirection direction) {
return true;
}
public double getDemandedEnergy() {
return Math.max(0.0, this.capacity - this.energyStored);
}
public double injectEnergy(
final ForgeDirection directionFrom, final double amount, final double voltage
) {
this.energyStored += amount;
return 0.0;
}
public int getSinkTier() {
return this.tier;
}
}

View file

@ -0,0 +1,186 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.prefab;
import net.minecraftforge.common.util.ForgeDirection;
import ic2.api.item.ElectricItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import cpw.mods.fml.common.eventhandler.Event;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.energy.event.EnergyTileLoadEvent;
import net.minecraftforge.common.MinecraftForge;
import ic2.api.info.Info;
import cpw.mods.fml.common.FMLCommonHandler;
import ic2.api.energy.EnergyNet;
import ic2.api.energy.tile.IEnergySource;
import net.minecraft.tileentity.TileEntity;
public class BasicSource extends TileEntity implements IEnergySource {
public final TileEntity parent;
protected double capacity;
protected int tier;
protected double power;
protected double energyStored;
protected boolean addedToEnet;
public BasicSource(
final TileEntity parent1, final double capacity1, final int tier1
) {
final double power = EnergyNet.instance.getPowerFromTier(tier1);
this.parent = parent1;
this.capacity = ((capacity1 < power) ? power : capacity1);
this.tier = tier1;
this.power = power;
}
public void updateEntity() {
if (!this.addedToEnet) {
this.onLoaded();
}
}
public void onLoaded() {
if (!this.addedToEnet
&& !FMLCommonHandler.instance().getEffectiveSide().isClient()
&& Info.isIc2Available()) {
this.worldObj = this.parent.getWorldObj();
this.xCoord = this.parent.xCoord;
this.yCoord = this.parent.yCoord;
this.zCoord = this.parent.zCoord;
MinecraftForge.EVENT_BUS.post((Event) new EnergyTileLoadEvent(this));
this.addedToEnet = true;
}
}
public void invalidate() {
super.invalidate();
this.onChunkUnload();
}
public void onChunkUnload() {
if (this.addedToEnet && Info.isIc2Available()) {
MinecraftForge.EVENT_BUS.post((Event) new EnergyTileUnloadEvent(this));
this.addedToEnet = false;
}
}
public void readFromNBT(final NBTTagCompound tag) {
super.readFromNBT(tag);
final NBTTagCompound data = tag.getCompoundTag("IC2BasicSource");
this.energyStored = data.getDouble("energy");
}
public void writeToNBT(final NBTTagCompound tag) {
try {
super.writeToNBT(tag);
} catch (final RuntimeException ex) {}
final NBTTagCompound data = new NBTTagCompound();
data.setDouble("energy", this.energyStored);
tag.setTag("IC2BasicSource", (NBTBase) data);
}
public double getCapacity() {
return this.capacity;
}
public void setCapacity(double capacity1) {
if (capacity1 < this.power) {
capacity1 = this.power;
}
this.capacity = capacity1;
}
public int getTier() {
return this.tier;
}
public void setTier(final int tier1) {
final double power = EnergyNet.instance.getPowerFromTier(tier1);
if (this.capacity < power) {
this.capacity = power;
}
this.tier = tier1;
this.power = power;
}
public double getEnergyStored() {
return this.energyStored;
}
public void setEnergyStored(final double amount) {
this.energyStored = amount;
}
public double getFreeCapacity() {
return this.capacity - this.energyStored;
}
public double addEnergy(double amount) {
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
return 0.0;
}
if (amount > this.capacity - this.energyStored) {
amount = this.capacity - this.energyStored;
}
this.energyStored += amount;
return amount;
}
public boolean charge(final ItemStack stack) {
if (stack == null || !Info.isIc2Available()) {
return false;
}
final double amount = ElectricItem.manager.charge(
stack, this.energyStored, this.tier, false, false
);
this.energyStored -= amount;
return amount > 0.0;
}
@Deprecated
public void onUpdateEntity() {
this.updateEntity();
}
@Deprecated
public void onInvalidate() {
this.invalidate();
}
@Deprecated
public void onOnChunkUnload() {
this.onChunkUnload();
}
@Deprecated
public void onReadFromNbt(final NBTTagCompound tag) {
this.readFromNBT(tag);
}
@Deprecated
public void onWriteToNbt(final NBTTagCompound tag) {
this.writeToNBT(tag);
}
public boolean
emitsEnergyTo(final TileEntity receiver, final ForgeDirection direction) {
return true;
}
public double getOfferedEnergy() {
return Math.min(this.energyStored, this.power);
}
public void drawEnergy(final double amount) {
this.energyStored -= amount;
}
public int getSourceTier() {
return this.tier;
}
}

View file

@ -0,0 +1,12 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.tile;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.tileentity.TileEntity;
public interface IEnergyAcceptor extends IEnergyTile {
boolean acceptsEnergyFrom(final TileEntity p0, final ForgeDirection p1);
}

View file

@ -0,0 +1,19 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.tile;
public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter {
double getConductionLoss();
double getInsulationEnergyAbsorption();
double getInsulationBreakdownEnergy();
double getConductorBreakdownEnergy();
void removeInsulation();
void removeConductor();
}

View file

@ -0,0 +1,12 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.tile;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.tileentity.TileEntity;
public interface IEnergyEmitter extends IEnergyTile {
boolean emitsEnergyTo(final TileEntity p0, final ForgeDirection p1);
}

View file

@ -0,0 +1,15 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.tile;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergySink extends IEnergyAcceptor {
double getDemandedEnergy();
int getSinkTier();
double injectEnergy(final ForgeDirection p0, final double p1, final double p2);
}

View file

@ -0,0 +1,13 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.tile;
public interface IEnergySource extends IEnergyEmitter {
double getOfferedEnergy();
void drawEnergy(final double p0);
int getSourceTier();
}

View file

@ -0,0 +1,7 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.tile;
public interface IEnergyTile {}

View file

@ -0,0 +1,13 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.tile;
import net.minecraftforge.common.util.ForgeDirection;
public interface IHeatSource {
int maxrequestHeatTick(final ForgeDirection p0);
int requestHeat(final ForgeDirection p0, final int p1);
}

View file

@ -0,0 +1,13 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.tile;
import net.minecraftforge.common.util.ForgeDirection;
public interface IKineticSource {
int maxrequestkineticenergyTick(final ForgeDirection p0);
int requestkineticenergy(final ForgeDirection p0, final int p1);
}

View file

@ -0,0 +1,12 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.energy.tile;
import net.minecraft.tileentity.TileEntity;
import java.util.List;
public interface IMetaDelegate extends IEnergyTile {
List<TileEntity> getSubTiles();
}

View file

@ -0,0 +1,45 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.event;
import net.minecraft.world.World;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.Entity;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.event.world.WorldEvent;
@Cancelable
public class ExplosionEvent extends WorldEvent {
public final Entity entity;
public double x;
public double y;
public double z;
public double power;
public final EntityLivingBase igniter;
public final int radiationRange;
public final double rangeLimit;
public ExplosionEvent(
final World world,
final Entity entity,
final double x,
final double y,
final double z,
final double power,
final EntityLivingBase igniter,
final int radiationRange,
final double rangeLimit
) {
super(world);
this.entity = entity;
this.x = x;
this.y = y;
this.z = z;
this.power = power;
this.igniter = igniter;
this.radiationRange = radiationRange;
this.rangeLimit = rangeLimit;
}
}

View file

@ -0,0 +1,179 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.event;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.Entity;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.event.world.WorldEvent;
@Cancelable
public class LaserEvent extends WorldEvent {
public final Entity lasershot;
public EntityLivingBase owner;
public float range;
public float power;
public int blockBreaks;
public boolean explosive;
public boolean smelt;
public LaserEvent(
final World world1,
final Entity lasershot1,
final EntityLivingBase owner1,
final float range1,
final float power1,
final int blockBreaks1,
final boolean explosive1,
final boolean smelt1
) {
super(world1);
this.lasershot = lasershot1;
this.owner = owner1;
this.range = range1;
this.power = power1;
this.blockBreaks = blockBreaks1;
this.explosive = explosive1;
this.smelt = smelt1;
}
public static class LaserShootEvent extends LaserEvent {
ItemStack laseritem;
public LaserShootEvent(
final World world1,
final Entity lasershot1,
final EntityLivingBase owner1,
final float range1,
final float power1,
final int blockBreaks1,
final boolean explosive1,
final boolean smelt1,
final ItemStack laseritem1
) {
super(
world1,
lasershot1,
owner1,
range1,
power1,
blockBreaks1,
explosive1,
smelt1
);
this.laseritem = laseritem1;
}
}
public static class LaserExplodesEvent extends LaserEvent {
public float explosionpower;
public float explosiondroprate;
public float explosionentitydamage;
public LaserExplodesEvent(
final World world1,
final Entity lasershot1,
final EntityLivingBase owner1,
final float range1,
final float power1,
final int blockBreaks1,
final boolean explosive1,
final boolean smelt1,
final float explosionpower1,
final float explosiondroprate1,
final float explosionentitydamage1
) {
super(
world1,
lasershot1,
owner1,
range1,
power1,
blockBreaks1,
explosive1,
smelt1
);
this.explosionpower = explosionpower1;
this.explosiondroprate = explosiondroprate1;
this.explosionentitydamage = explosionentitydamage1;
}
}
public static class LaserHitsBlockEvent extends LaserEvent {
public int x;
public int y;
public int z;
public int side;
public boolean removeBlock;
public boolean dropBlock;
public float dropChance;
public LaserHitsBlockEvent(
final World world1,
final Entity lasershot1,
final EntityLivingBase owner1,
final float range1,
final float power1,
final int blockBreaks1,
final boolean explosive1,
final boolean smelt1,
final int x1,
final int y1,
final int z1,
final int side1,
final float dropChance1,
final boolean removeBlock1,
final boolean dropBlock1
) {
super(
world1,
lasershot1,
owner1,
range1,
power1,
blockBreaks1,
explosive1,
smelt1
);
this.x = x1;
this.y = y1;
this.z = z1;
this.side = side1;
this.removeBlock = removeBlock1;
this.dropBlock = dropBlock1;
this.dropChance = dropChance1;
}
}
public static class LaserHitsEntityEvent extends LaserEvent {
public Entity hitentity;
public LaserHitsEntityEvent(
final World world1,
final Entity lasershot1,
final EntityLivingBase owner1,
final float range1,
final float power1,
final int blockBreaks1,
final boolean explosive1,
final boolean smelt1,
final Entity hitentity1
) {
super(
world1,
lasershot1,
owner1,
range1,
power1,
blockBreaks1,
explosive1,
smelt1
);
this.hitentity = hitentity1;
}
}
}

View file

@ -0,0 +1,36 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.event;
import net.minecraft.world.World;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.event.world.WorldEvent;
@Cancelable
public class PaintEvent extends WorldEvent {
public final int x;
public final int y;
public final int z;
public final int side;
public final int color;
public boolean painted;
public PaintEvent(
final World world1,
final int x1,
final int y1,
final int z1,
final int side1,
final int color1
) {
super(world1);
this.painted = false;
this.x = x1;
this.y = y1;
this.z = z1;
this.side = side1;
this.color = color1;
}
}

View file

@ -0,0 +1,43 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.event;
import net.minecraft.world.World;
import net.minecraft.block.Block;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraftforge.event.world.WorldEvent;
@Cancelable
public class RetextureEvent extends WorldEvent {
public final int x;
public final int y;
public final int z;
public final int side;
public final Block referencedBlock;
public final int referencedMeta;
public final int referencedSide;
public boolean applied;
public RetextureEvent(
final World world1,
final int x1,
final int y1,
final int z1,
final int side1,
final Block referencedBlock,
final int referencedMeta1,
final int referencedSide1
) {
super(world1);
this.applied = false;
this.x = x1;
this.y = y1;
this.z = z1;
this.side = side1;
this.referencedBlock = referencedBlock;
this.referencedMeta = referencedMeta1;
this.referencedSide = referencedSide1;
}
}

View file

@ -0,0 +1,11 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.info;
import net.minecraft.item.ItemStack;
public interface IEnergyValueProvider {
double getEnergyValue(final ItemStack p0);
}

View file

@ -0,0 +1,11 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.info;
import net.minecraft.item.ItemStack;
public interface IFuelValueProvider {
int getFuelValue(final ItemStack p0, final boolean p1);
}

View file

@ -0,0 +1,36 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.info;
import cpw.mods.fml.common.LoaderState;
import cpw.mods.fml.common.Loader;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
public class Info {
public static IEnergyValueProvider itemEnergy;
public static IFuelValueProvider itemFuel;
public static Object ic2ModInstance;
public static DamageSource DMG_ELECTRIC;
public static DamageSource DMG_NUKE_EXPLOSION;
public static DamageSource DMG_RADIATION;
public static Potion POTION_RADIATION;
private static Boolean ic2Available;
public static boolean isIc2Available() {
if (Info.ic2Available != null) {
return Info.ic2Available;
}
final boolean loaded = Loader.isModLoaded("IC2");
if (Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) {
Info.ic2Available = loaded;
}
return loaded;
}
static {
Info.ic2Available = null;
}
}

View file

@ -0,0 +1,33 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import java.util.ArrayList;
import java.util.Iterator;
import net.minecraft.item.ItemStack;
import java.util.List;
public final class ElectricItem {
public static IElectricItemManager manager;
public static IElectricItemManager rawManager;
private static final List<IBackupElectricItemManager> backupManagers;
public static void registerBackupManager(final IBackupElectricItemManager manager) {
ElectricItem.backupManagers.add(manager);
}
public static IBackupElectricItemManager getBackupManager(final ItemStack stack) {
for (final IBackupElectricItemManager manager : ElectricItem.backupManagers) {
if (manager.handles(stack)) {
return manager;
}
}
return null;
}
static {
backupManagers = new ArrayList<IBackupElectricItemManager>();
}
}

View file

@ -0,0 +1,11 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import net.minecraft.item.ItemStack;
public interface IBackupElectricItemManager extends IElectricItemManager {
boolean handles(final ItemStack p0);
}

View file

@ -0,0 +1,9 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
public interface IBlockCuttingBlade {
int gethardness();
}

View file

@ -0,0 +1,11 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import net.minecraft.item.ItemStack;
public interface IBoxable {
boolean canBeStoredInToolbox(final ItemStack p0);
}

View file

@ -0,0 +1,36 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import net.minecraft.item.ItemStack;
public final class IC2Items {
private static Class<?> Ic2Items;
public static ItemStack getItem(final String name) {
try {
if (IC2Items.Ic2Items == null) {
IC2Items.Ic2Items = Class.forName(getPackage() + ".core.Ic2Items");
}
final Object ret = IC2Items.Ic2Items.getField(name).get(null);
if (ret instanceof ItemStack) {
return (ItemStack) ret;
}
return null;
} catch (final Exception e) {
System.out.println("IC2 API: Call getItem failed for " + name);
return null;
}
}
private static String getPackage() {
final Package pkg = IC2Items.class.getPackage();
if (pkg != null) {
final String packageName = pkg.getName();
return packageName.substring(0, packageName.length() - ".api.item".length());
}
return "ic2";
}
}

View file

@ -0,0 +1,19 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
public interface ICustomDamageItem {
int getCustomDamage(final ItemStack p0);
int getMaxCustomDamage(final ItemStack p0);
void setCustomDamage(final ItemStack p0, final int p1);
boolean
applyCustomDamage(final ItemStack p0, final int p1, final EntityLivingBase p2);
}

View file

@ -0,0 +1,11 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
public interface IDebuggable {
boolean isDebuggable();
String getDebugText();
}

View file

@ -0,0 +1,22 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public interface IElectricItem {
boolean canProvideEnergy(final ItemStack p0);
Item getChargedItem(final ItemStack p0);
Item getEmptyItem(final ItemStack p0);
double getMaxCharge(final ItemStack p0);
int getTier(final ItemStack p0);
double getTransferLimit(final ItemStack p0);
}

View file

@ -0,0 +1,37 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
public interface IElectricItemManager {
double charge(
final ItemStack p0,
final double p1,
final int p2,
final boolean p3,
final boolean p4
);
double discharge(
final ItemStack p0,
final double p1,
final int p2,
final boolean p3,
final boolean p4,
final boolean p5
);
double getCharge(final ItemStack p0);
boolean canUse(final ItemStack p0, final double p1);
boolean use(final ItemStack p0, final double p1, final EntityLivingBase p2);
void chargeFromArmor(final ItemStack p0, final EntityLivingBase p1);
String getToolTip(final ItemStack p0);
}

View file

@ -0,0 +1,12 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import java.util.List;
import net.minecraft.item.ItemStack;
public interface IItemHudInfo {
List<String> getHudInfo(final ItemStack p0);
}

View file

@ -0,0 +1,27 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import net.minecraft.util.ResourceLocation;
import net.minecraft.item.ItemStack;
public interface IKineticRotor {
int getDiameter(final ItemStack p0);
ResourceLocation getRotorRenderTexture(final ItemStack p0);
float getEfficiency(final ItemStack p0);
int getMinWindStrength(final ItemStack p0);
int getMaxWindStrength(final ItemStack p0);
boolean isAcceptedType(final ItemStack p0, final GearboxType p1);
public enum GearboxType {
WATER,
WIND;
}
}

View file

@ -0,0 +1,31 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.ResourceLocation;
import net.minecraft.item.ItemStack;
public interface ILatheItem {
int getWidth(final ItemStack p0);
int[] getCurrentState(final ItemStack p0);
void setState(final ItemStack p0, final int p1, final int p2);
ItemStack getOutputItem(final ItemStack p0, final int p1);
float getOutputChance(final ItemStack p0, final int p1);
@SideOnly(Side.CLIENT)
ResourceLocation getTexture(final ItemStack p0);
int getHardness(final ItemStack p0);
public interface ILatheTool extends ICustomDamageItem {
int getHardness(final ItemStack p0);
}
}

View file

@ -0,0 +1,12 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public interface IMetalArmor {
boolean isMetalArmor(final ItemStack p0, final EntityPlayer p1);
}

View file

@ -0,0 +1,11 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import net.minecraft.item.ItemStack;
public interface ISpecialElectricItem extends IElectricItem {
IElectricItemManager getManager(final ItemStack p0);
}

View file

@ -0,0 +1,15 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import net.minecraft.world.World;
public interface ITerraformingBP {
int getConsume();
int getRange();
boolean terraform(final World p0, final int p1, final int p2, final int p3);
}

View file

@ -0,0 +1,51 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.item;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemWrapper {
private static final Multimap<Item, IBoxable> boxableItems;
private static final Multimap<Item, IMetalArmor> metalArmorItems;
public static void registerBoxable(final Item item, final IBoxable boxable) {
ItemWrapper.boxableItems.put(item, boxable);
}
public static boolean canBeStoredInToolbox(final ItemStack stack) {
final Item item = stack.getItem();
for (final IBoxable boxable : ItemWrapper.boxableItems.get(item)) {
if (boxable.canBeStoredInToolbox(stack)) {
return true;
}
}
return item instanceof IBoxable && ((IBoxable) item).canBeStoredInToolbox(stack);
}
public static void registerMetalArmor(final Item item, final IMetalArmor armor) {
ItemWrapper.metalArmorItems.put(item, armor);
}
public static boolean isMetalArmor(final ItemStack stack, final EntityPlayer player) {
final Item item = stack.getItem();
for (final IMetalArmor metalArmor : ItemWrapper.metalArmorItems.get(item)) {
if (metalArmor.isMetalArmor(stack, player)) {
return true;
}
}
return item instanceof IMetalArmor
&& ((IMetalArmor) item).isMetalArmor(stack, player);
}
static {
boxableItems = ArrayListMultimap.create();
metalArmorItems = ArrayListMultimap.create();
}
}

View file

@ -0,0 +1,11 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.network;
import net.minecraft.entity.player.EntityPlayer;
public interface INetworkClientTileEntityEventListener {
void onNetworkEvent(final EntityPlayer p0, final int p1);
}

View file

@ -0,0 +1,11 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.network;
import java.util.List;
public interface INetworkDataProvider {
List<String> getNetworkedFields();
}

View file

@ -0,0 +1,12 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.network;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public interface INetworkItemEventListener {
void onNetworkEvent(final ItemStack p0, final EntityPlayer p1, final int p2);
}

View file

@ -0,0 +1,9 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.network;
public interface INetworkTileEntityEventListener {
void onNetworkEvent(final int p0);
}

View file

@ -0,0 +1,9 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.network;
public interface INetworkUpdateListener {
void onNetworkUpdate(final String p0);
}

View file

@ -0,0 +1,163 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.network;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import java.lang.reflect.Method;
public final class NetworkHelper {
private static Object instance;
private static Method NetworkManager_updateTileEntityField;
private static Method NetworkManager_initiateTileEntityEvent;
private static Method NetworkManager_initiateItemEvent;
private static Method NetworkManager_initiateClientTileEntityEvent;
private static Method NetworkManager_initiateClientItemEvent;
public static void updateTileEntityField(final TileEntity te, final String field) {
try {
if (NetworkHelper.NetworkManager_updateTileEntityField == null) {
NetworkHelper.NetworkManager_updateTileEntityField
= Class.forName(getPackage() + ".core.network.NetworkManager")
.getMethod(
"updateTileEntityField", TileEntity.class, String.class
);
}
if (NetworkHelper.instance == null) {
NetworkHelper.instance = getInstance();
}
NetworkHelper.NetworkManager_updateTileEntityField.invoke(
NetworkHelper.instance, te, field
);
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
public static void initiateTileEntityEvent(
final TileEntity te, final int event, final boolean limitRange
) {
try {
if (NetworkHelper.NetworkManager_initiateTileEntityEvent == null) {
NetworkHelper.NetworkManager_initiateTileEntityEvent
= Class.forName(getPackage() + ".core.network.NetworkManager")
.getMethod(
"initiateTileEntityEvent",
TileEntity.class,
Integer.TYPE,
Boolean.TYPE
);
}
if (NetworkHelper.instance == null) {
NetworkHelper.instance = getInstance();
}
NetworkHelper.NetworkManager_initiateTileEntityEvent.invoke(
NetworkHelper.instance, te, event, limitRange
);
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
public static void initiateItemEvent(
final EntityPlayer player,
final ItemStack itemStack,
final int event,
final boolean limitRange
) {
try {
if (NetworkHelper.NetworkManager_initiateItemEvent == null) {
NetworkHelper.NetworkManager_initiateItemEvent
= Class.forName(getPackage() + ".core.network.NetworkManager")
.getMethod(
"initiateItemEvent",
EntityPlayer.class,
ItemStack.class,
Integer.TYPE,
Boolean.TYPE
);
}
if (NetworkHelper.instance == null) {
NetworkHelper.instance = getInstance();
}
NetworkHelper.NetworkManager_initiateItemEvent.invoke(
NetworkHelper.instance, player, itemStack, event, limitRange
);
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
public static void
initiateClientTileEntityEvent(final TileEntity te, final int event) {
try {
if (NetworkHelper.NetworkManager_initiateClientTileEntityEvent == null) {
NetworkHelper.NetworkManager_initiateClientTileEntityEvent
= Class.forName(getPackage() + ".core.network.NetworkManager")
.getMethod(
"initiateClientTileEntityEvent",
TileEntity.class,
Integer.TYPE
);
}
if (NetworkHelper.instance == null) {
NetworkHelper.instance = getInstance();
}
NetworkHelper.NetworkManager_initiateClientTileEntityEvent.invoke(
NetworkHelper.instance, te, event
);
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
public static void
initiateClientItemEvent(final ItemStack itemStack, final int event) {
try {
if (NetworkHelper.NetworkManager_initiateClientItemEvent == null) {
NetworkHelper.NetworkManager_initiateClientItemEvent
= Class.forName(getPackage() + ".core.network.NetworkManager")
.getMethod(
"initiateClientItemEvent", ItemStack.class, Integer.TYPE
);
}
if (NetworkHelper.instance == null) {
NetworkHelper.instance = getInstance();
}
NetworkHelper.NetworkManager_initiateClientItemEvent.invoke(
NetworkHelper.instance, itemStack, event
);
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
private static String getPackage() {
final Package pkg = NetworkHelper.class.getPackage();
if (pkg != null) {
final String packageName = pkg.getName();
return packageName.substring(
0, packageName.length() - ".api.network".length()
);
}
return "ic2";
}
private static Object getInstance() {
try {
return Class.forName(getPackage() + ".core.util.SideGateway")
.getMethod("get", (Class<?>[]) new Class[0])
.invoke(
Class.forName(getPackage() + ".core.IC2")
.getDeclaredField("network")
.get(null),
new Object[0]
);
} catch (final Throwable e) {
throw new RuntimeException(e);
}
}
}

View file

@ -0,0 +1,51 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.reactor;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.util.ChunkCoordinates;
public interface IReactor {
ChunkCoordinates getPosition();
World getWorld();
int getHeat();
void setHeat(final int p0);
int addHeat(final int p0);
int getMaxHeat();
void setMaxHeat(final int p0);
void addEmitHeat(final int p0);
float getHeatEffectModifier();
void setHeatEffectModifier(final float p0);
float getReactorEnergyOutput();
double getReactorEUEnergyOutput();
float addOutput(final float p0);
ItemStack getItemAt(final int p0, final int p1);
void setItemAt(final int p0, final int p1, final ItemStack p2);
void explode();
int getTickRate();
boolean produceEnergy();
void setRedstoneSignal(final boolean p0);
boolean isFluidCooled();
}

View file

@ -0,0 +1,11 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.reactor;
public interface IReactorChamber {
IReactor getReactor();
void setRedstoneSignal(final boolean p0);
}

View file

@ -0,0 +1,41 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.reactor;
import net.minecraft.item.ItemStack;
public interface IReactorComponent {
void processChamber(
final IReactor p0,
final ItemStack p1,
final int p2,
final int p3,
final boolean p4
);
boolean acceptUraniumPulse(
final IReactor p0,
final ItemStack p1,
final ItemStack p2,
final int p3,
final int p4,
final int p5,
final int p6,
final boolean p7
);
boolean
canStoreHeat(final IReactor p0, final ItemStack p1, final int p2, final int p3);
int getMaxHeat(final IReactor p0, final ItemStack p1, final int p2, final int p3);
int getCurrentHeat(final IReactor p0, final ItemStack p1, final int p2, final int p3);
int alterHeat(
final IReactor p0, final ItemStack p1, final int p2, final int p3, final int p4
);
float influenceExplosion(final IReactor p0, final ItemStack p1);
}

View file

@ -0,0 +1,32 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.Map;
import net.minecraft.item.ItemStack;
public interface ICannerBottleRecipeManager {
void addRecipe(final IRecipeInput p0, final IRecipeInput p1, final ItemStack p2);
RecipeOutput getOutputFor(
final ItemStack p0, final ItemStack p1, final boolean p2, final boolean p3
);
Map<Input, RecipeOutput> getRecipes();
public static class Input {
public final IRecipeInput container;
public final IRecipeInput fill;
public Input(final IRecipeInput container1, final IRecipeInput fill1) {
this.container = container1;
this.fill = fill1;
}
public boolean matches(final ItemStack container1, final ItemStack fill1) {
return this.container.matches(container1) && this.fill.matches(fill1);
}
}
}

View file

@ -0,0 +1,34 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public interface ICannerEnrichRecipeManager {
void addRecipe(final FluidStack p0, final IRecipeInput p1, final FluidStack p2);
RecipeOutput getOutputFor(
final FluidStack p0, final ItemStack p1, final boolean p2, final boolean p3
);
Map<Input, FluidStack> getRecipes();
public static class Input {
public final FluidStack fluid;
public final IRecipeInput additive;
public Input(final FluidStack fluid1, final IRecipeInput additive1) {
this.fluid = fluid1;
this.additive = additive1;
}
public boolean matches(final FluidStack fluid1, final ItemStack additive1) {
return (this.fluid == null || this.fluid.isFluidEqual(fluid1))
&& this.additive.matches(additive1);
}
}
}

View file

@ -0,0 +1,13 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import net.minecraft.item.ItemStack;
public interface ICraftingRecipeManager {
void addRecipe(final ItemStack p0, final Object... p1);
void addShapelessRecipe(final ItemStack p0, final Object... p1);
}

View file

@ -0,0 +1,26 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.Map;
import net.minecraftforge.fluids.Fluid;
public interface IFluidHeatManager extends ILiquidAcceptManager {
void addFluid(final String p0, final int p1, final int p2);
BurnProperty getBurnProperty(final Fluid p0);
Map<String, BurnProperty> getBurnProperties();
public static class BurnProperty {
public final int amount;
public final int heat;
public BurnProperty(final int amount1, final int heat1) {
this.amount = amount1;
this.heat = heat1;
}
}
}

View file

@ -0,0 +1,14 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.Set;
import net.minecraftforge.fluids.Fluid;
public interface ILiquidAcceptManager {
boolean acceptsFluid(final Fluid p0);
Set<Fluid> getAcceptedFluids();
}

View file

@ -0,0 +1,28 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.Map;
import net.minecraftforge.fluids.Fluid;
public interface ILiquidHeatExchangerManager extends ILiquidAcceptManager {
void addFluid(final String p0, final String p1, final int p2);
HeatExchangeProperty getHeatExchangeProperty(final Fluid p0);
Map<String, HeatExchangeProperty> getHeatExchangeProperties();
ILiquidAcceptManager getSingleDirectionLiquidManager();
public static class HeatExchangeProperty {
public final Fluid outputFluid;
public final int huPerMB;
public HeatExchangeProperty(final Fluid outputFluid, final int huPerMB) {
this.outputFluid = outputFluid;
this.huPerMB = huPerMB;
}
}
}

View file

@ -0,0 +1,18 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.List;
import net.minecraft.item.ItemStack;
public interface IListRecipeManager extends Iterable<IRecipeInput> {
void add(final IRecipeInput p0);
boolean contains(final ItemStack p0);
boolean isEmpty();
List<IRecipeInput> getInputs();
}

View file

@ -0,0 +1,17 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public interface IMachineRecipeManager {
void addRecipe(final IRecipeInput p0, final NBTTagCompound p1, final ItemStack... p2);
RecipeOutput getOutputFor(final ItemStack p0, final boolean p1);
Map<IRecipeInput, RecipeOutput> getRecipes();
}

View file

@ -0,0 +1,17 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public interface IMachineRecipeManagerExt extends IMachineRecipeManager {
boolean addRecipe(
final IRecipeInput p0,
final NBTTagCompound p1,
final boolean p2,
final ItemStack... p3
);
}

View file

@ -0,0 +1,14 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.List;
import net.minecraft.item.ItemStack;
public interface IPatternStorage {
boolean addPattern(final ItemStack p0);
List<ItemStack> getPatterns();
}

View file

@ -0,0 +1,16 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.List;
import net.minecraft.item.ItemStack;
public interface IRecipeInput {
boolean matches(final ItemStack p0);
int getAmount();
List<ItemStack> getInputs();
}

View file

@ -0,0 +1,16 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.Map;
import net.minecraft.item.ItemStack;
public interface IScrapboxManager {
void addDrop(final ItemStack p0, final float p1);
ItemStack getDrop(final ItemStack p0, final boolean p1);
Map<ItemStack, Float> getDrops();
}

View file

@ -0,0 +1,26 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.Map;
import net.minecraftforge.fluids.Fluid;
public interface ISemiFluidFuelManager extends ILiquidAcceptManager {
void addFluid(final String p0, final int p1, final double p2);
BurnProperty getBurnProperty(final Fluid p0);
Map<String, BurnProperty> getBurnProperties();
public static class BurnProperty {
public final int amount;
public final double power;
public BurnProperty(final int amount1, final double power1) {
this.amount = amount1;
this.power = power1;
}
}
}

View file

@ -0,0 +1,54 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.ArrayList;
import java.util.List;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
public class RecipeInputFluidContainer implements IRecipeInput {
public final Fluid fluid;
public final int amount;
public RecipeInputFluidContainer(final Fluid fluid) {
this(fluid, 1000);
}
public RecipeInputFluidContainer(final Fluid fluid, final int amount) {
this.fluid = fluid;
this.amount = amount;
}
@Override
public boolean matches(final ItemStack subject) {
final FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject);
return fs != null && fs.getFluid() == this.fluid;
}
@Override
public int getAmount() {
return this.amount;
}
@Override
public List<ItemStack> getInputs() {
final List<ItemStack> ret = new ArrayList<ItemStack>();
for (final FluidContainerRegistry.FluidContainerData data :
FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (data.fluid.getFluid() == this.fluid) {
ret.add(data.filledContainer);
}
}
return ret;
}
@Override
public String toString() {
return "RInputFluidContainer<" + this.amount + "x" + this.fluid.getName() + ">";
}
}

View file

@ -0,0 +1,50 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.Arrays;
import java.util.List;
import net.minecraft.item.ItemStack;
public class RecipeInputItemStack implements IRecipeInput {
public final ItemStack input;
public final int amount;
public RecipeInputItemStack(final ItemStack aInput) {
this(aInput, aInput.stackSize);
}
public RecipeInputItemStack(final ItemStack aInput, final int aAmount) {
if (aInput.getItem() == null) {
throw new IllegalArgumentException("Invalid item stack specfied");
}
this.input = aInput.copy();
this.amount = aAmount;
}
@Override
public boolean matches(final ItemStack subject) {
return subject.getItem() == this.input.getItem()
&& (subject.getItemDamage() == this.input.getItemDamage()
|| this.input.getItemDamage() == 32767);
}
@Override
public int getAmount() {
return this.amount;
}
@Override
public List<ItemStack> getInputs() {
return Arrays.asList(this.input);
}
@Override
public String toString() {
final ItemStack stack = this.input.copy();
this.input.stackSize = this.amount;
return "RInputItemStack<" + stack + ">";
}
}

View file

@ -0,0 +1,103 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
public class RecipeInputOreDict implements IRecipeInput {
public final String input;
public final int amount;
public final Integer meta;
private List<ItemStack> ores;
public RecipeInputOreDict(final String input1) {
this(input1, 1);
}
public RecipeInputOreDict(final String input1, final int amount1) {
this(input1, amount1, null);
}
public RecipeInputOreDict(
final String input1, final int amount1, final Integer meta
) {
this.input = input1;
this.amount = amount1;
this.meta = meta;
}
@Override
public boolean matches(final ItemStack subject) {
final List<ItemStack> inputs = this.getOres();
final boolean useOreStackMeta = this.meta == null;
final Item subjectItem = subject.getItem();
final int subjectMeta = subject.getItemDamage();
for (final ItemStack oreStack : inputs) {
final Item oreItem = oreStack.getItem();
if (oreItem == null) {
continue;
}
final int metaRequired
= useOreStackMeta ? oreStack.getItemDamage() : this.meta;
if (subjectItem == oreItem
&& (subjectMeta == metaRequired || metaRequired == 32767)) {
return true;
}
}
return false;
}
@Override
public int getAmount() {
return this.amount;
}
@Override
public List<ItemStack> getInputs() {
final List<ItemStack> ores = this.getOres();
boolean hasInvalidEntries = false;
for (final ItemStack stack : ores) {
if (stack.getItem() == null) {
hasInvalidEntries = true;
break;
}
}
if (!hasInvalidEntries) {
return ores;
}
final List<ItemStack> ret = new ArrayList<ItemStack>(ores.size());
for (final ItemStack stack2 : ores) {
if (stack2.getItem() != null) {
ret.add(stack2);
}
}
return Collections.unmodifiableList((List<? extends ItemStack>) ret);
}
@Override
public String toString() {
if (this.meta == null) {
return "RInputOreDict<" + this.amount + "x" + this.input + ">";
}
return "RInputOreDict<" + this.amount + "x" + this.input + "@" + this.meta + ">";
}
private List<ItemStack> getOres() {
if (this.ores != null) {
return this.ores;
}
final List<ItemStack> ret = OreDictionary.getOres(this.input);
if (ret != OreDictionary.EMPTY_LIST) {
this.ores = ret;
}
return ret;
}
}

View file

@ -0,0 +1,54 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
import java.util.Iterator;
import java.util.Arrays;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.item.ItemStack;
import java.util.List;
public final class RecipeOutput {
public final List<ItemStack> items;
public final NBTTagCompound metadata;
public RecipeOutput(final NBTTagCompound metadata1, final List<ItemStack> items1) {
assert !items1.contains(null);
this.metadata = metadata1;
this.items = items1;
}
public RecipeOutput(final NBTTagCompound metadata1, final ItemStack... items1) {
this(metadata1, Arrays.asList(items1));
}
@Override
public boolean equals(final Object obj) {
if (obj instanceof RecipeOutput) {
final RecipeOutput ro = (RecipeOutput) obj;
if (this.items.size() == ro.items.size()
&& ((this.metadata == null && ro.metadata == null)
|| (this.metadata != null && ro.metadata != null
&& this.metadata.equals((Object) ro.metadata)))) {
final Iterator<ItemStack> itA = this.items.iterator();
final Iterator<ItemStack> itB = ro.items.iterator();
while (itA.hasNext() && itB.hasNext()) {
final ItemStack stackA = itA.next();
final ItemStack stackB = itB.next();
if (ItemStack.areItemStacksEqual(stackA, stackB)) {
return false;
}
}
return true;
}
}
return false;
}
@Override
public String toString() {
return "ROutput<" + this.items + "," + this.metadata + ">";
}
}

View file

@ -0,0 +1,30 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.recipe;
public class Recipes {
public static IMachineRecipeManager macerator;
public static IMachineRecipeManager extractor;
public static IMachineRecipeManager compressor;
public static IMachineRecipeManager centrifuge;
public static IMachineRecipeManager blockcutter;
public static IMachineRecipeManager blastfurance;
public static IMachineRecipeManager recycler;
public static IMachineRecipeManager metalformerExtruding;
public static IMachineRecipeManager metalformerCutting;
public static IMachineRecipeManager metalformerRolling;
public static IMachineRecipeManager oreWashing;
public static ICannerBottleRecipeManager cannerBottle;
public static ICannerEnrichRecipeManager cannerEnrich;
public static IMachineRecipeManager matterAmplifier;
public static IScrapboxManager scrapboxDrops;
public static IListRecipeManager recyclerBlacklist;
public static IListRecipeManager recyclerWhitelist;
public static ICraftingRecipeManager advRecipes;
public static ISemiFluidFuelManager semiFluidGenerator;
public static IFluidHeatManager FluidHeatGenerator;
public static ILiquidHeatExchangerManager liquidCooldownManager;
public static ILiquidHeatExchangerManager liquidHeatupManager;
}

View file

@ -0,0 +1,29 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.tile;
import java.util.HashSet;
import net.minecraft.block.Block;
import java.util.Set;
public final class ExplosionWhitelist {
private static Set<Block> whitelist;
public static void addWhitelistedBlock(final Block block) {
ExplosionWhitelist.whitelist.add(block);
}
public static void removeWhitelistedBlock(final Block block) {
ExplosionWhitelist.whitelist.remove(block);
}
public static boolean isBlockWhitelisted(final Block block) {
return ExplosionWhitelist.whitelist.contains(block);
}
static {
ExplosionWhitelist.whitelist = new HashSet<Block>();
}
}

View file

@ -0,0 +1,23 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.tile;
import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyStorage {
int getStored();
void setStored(final int p0);
int addEnergy(final int p0);
int getCapacity();
int getOutput();
double getOutputEnergyUnitsPerTick();
boolean isTeleporterCompatible(final ForgeDirection p0);
}

View file

@ -0,0 +1,22 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.tile;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.EntityPlayer;
public interface IWrenchable {
boolean wrenchCanSetFacing(final EntityPlayer p0, final int p1);
short getFacing();
void setFacing(final short p0);
boolean wrenchCanRemove(final EntityPlayer p0);
float getWrenchDropRate();
ItemStack getWrenchDrop(final EntityPlayer p0);
}

View file

@ -0,0 +1,25 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.util;
import net.minecraft.entity.player.EntityPlayer;
public interface IKeyboard {
boolean isAltKeyDown(final EntityPlayer p0);
boolean isBoostKeyDown(final EntityPlayer p0);
boolean isForwardKeyDown(final EntityPlayer p0);
boolean isJumpKeyDown(final EntityPlayer p0);
boolean isModeSwitchKeyDown(final EntityPlayer p0);
boolean isSideinventoryKeyDown(final EntityPlayer p0);
boolean isHudModeKeyDown(final EntityPlayer p0);
boolean isSneakKeyDown(final EntityPlayer p0);
}

View file

@ -0,0 +1,9 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.api.util;
public class Keys {
public static IKeyboard instance;
}

View file

@ -0,0 +1,176 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.bcIntegration;
import java.util.List;
import ic2.core.block.machine.tileentity.TileEntityBlastFurnace;
import ic2.core.block.machine.tileentity.TileEntityCentrifuge;
import ic2.core.block.machine.tileentity.TileEntityInduction;
import ic2.core.block.machine.tileentity.TileEntityMatter;
import ic2.core.block.wiring.TileEntityCableDetector;
import ic2.core.block.generator.tileentity.TileEntitySemifluidGenerator;
import ic2.core.block.heatgenerator.tileentity.TileEntityFluidHeatGenerator;
import ic2.core.block.heatgenerator.tileentity.TileEntitySolidHeatGenerator;
import ic2.core.block.generator.tileentity.TileEntityGeoGenerator;
import ic2.core.block.machine.tileentity.TileEntityLathe;
import ic2.core.block.wiring.TileEntityElectricBlock;
import ic2.core.block.generator.tileentity.TileEntityBaseGenerator;
import ic2.core.block.machine.tileentity.TileEntityStandardMachine;
import java.util.ArrayList;
import buildcraft.api.statements.ITriggerExternal;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.statements.ITriggerInternal;
import java.util.Collection;
import buildcraft.api.statements.IStatementContainer;
import cpw.mods.fml.common.event.FMLInterModComms;
import net.minecraft.block.Block;
import ic2.core.Ic2Items;
import buildcraft.api.statements.StatementManager;
import ic2.bcIntegration.core.TriggerType;
import ic2.bcIntegration.core.TriggerHeat;
import ic2.bcIntegration.core.TriggerScrap;
import ic2.bcIntegration.core.TriggerFuel;
import ic2.bcIntegration.core.TriggerEnergyFlow;
import ic2.bcIntegration.core.TriggerWork;
import ic2.bcIntegration.core.TriggerCapacitor;
import buildcraft.api.statements.ITriggerProvider;
public class SubModule implements ITriggerProvider {
public static TriggerCapacitor triggerCapacitorEmpty;
public static TriggerCapacitor triggerCapacitorHasEnergy;
public static TriggerCapacitor triggerCapacitorHasRoom;
public static TriggerCapacitor triggerCapacitorFull;
public static TriggerCapacitor triggerChargeEmpty;
public static TriggerCapacitor triggerChargePartial;
public static TriggerCapacitor triggerChargeFull;
public static TriggerCapacitor triggerDischargeEmpty;
public static TriggerCapacitor triggerDischargePartial;
public static TriggerCapacitor triggerDischargeFull;
public static TriggerWork triggerWorking;
public static TriggerWork triggerNotWorking;
public static TriggerEnergyFlow triggerEnergyFlowing;
public static TriggerEnergyFlow triggerEnergyNotFlowing;
public static TriggerFuel triggerHasFuel;
public static TriggerFuel triggerNoFuel;
public static TriggerScrap triggerHasScrap;
public static TriggerScrap triggerNoScrap;
public static TriggerHeat triggerFullHeat;
public static TriggerHeat triggerNoFullHeat;
public static boolean init() {
SubModule.triggerCapacitorEmpty
= new TriggerCapacitor(TriggerType.CapacitorEmpty);
SubModule.triggerCapacitorHasEnergy
= new TriggerCapacitor(TriggerType.CapacitorHasEnergy);
SubModule.triggerCapacitorHasRoom
= new TriggerCapacitor(TriggerType.CapacitorHasRoom);
SubModule.triggerCapacitorFull = new TriggerCapacitor(TriggerType.CapacitorFull);
SubModule.triggerChargeEmpty = new TriggerCapacitor(TriggerType.ChargeEmpty);
SubModule.triggerChargePartial = new TriggerCapacitor(TriggerType.ChargePartial);
SubModule.triggerChargeFull = new TriggerCapacitor(TriggerType.ChargeFull);
SubModule.triggerDischargeEmpty
= new TriggerCapacitor(TriggerType.DischargeEmpty);
SubModule.triggerDischargePartial
= new TriggerCapacitor(TriggerType.DischargePartial);
SubModule.triggerDischargeFull = new TriggerCapacitor(TriggerType.DischargeFull);
SubModule.triggerWorking = new TriggerWork(TriggerType.Working);
SubModule.triggerNotWorking = new TriggerWork(TriggerType.NotWorking);
SubModule.triggerEnergyFlowing = new TriggerEnergyFlow(TriggerType.EnergyFlowing);
SubModule.triggerEnergyNotFlowing
= new TriggerEnergyFlow(TriggerType.EnergyNotFlowing);
SubModule.triggerHasFuel = new TriggerFuel(TriggerType.HasFuel);
SubModule.triggerNoFuel = new TriggerFuel(TriggerType.NoFuel);
SubModule.triggerHasScrap = new TriggerScrap(TriggerType.HasScrap);
SubModule.triggerNoScrap = new TriggerScrap(TriggerType.NoScrap);
SubModule.triggerFullHeat = new TriggerHeat(TriggerType.FullHeat);
SubModule.triggerNoFullHeat = new TriggerHeat(TriggerType.NoFullHeat);
StatementManager.registerTriggerProvider((ITriggerProvider) new SubModule());
FMLInterModComms.sendMessage(
"BuildCraft|Transport",
"add-facade",
Block.getIdFromBlock(Block.getBlockFromItem(Ic2Items.bronzeBlock.getItem()))
+ "@" + Ic2Items.bronzeBlock.getItemDamage()
);
FMLInterModComms.sendMessage(
"BuildCraft|Transport",
"add-facade",
Block.getIdFromBlock(Block.getBlockFromItem(Ic2Items.copperBlock.getItem()))
+ "@" + Ic2Items.copperBlock.getItemDamage()
);
FMLInterModComms.sendMessage(
"BuildCraft|Transport",
"add-facade",
Block.getIdFromBlock(Block.getBlockFromItem(Ic2Items.tinBlock.getItem()))
+ "@" + Ic2Items.tinBlock.getItemDamage()
);
FMLInterModComms.sendMessage(
"BuildCraft|Transport",
"add-facade",
Block.getIdFromBlock(Block.getBlockFromItem(Ic2Items.uraniumBlock.getItem()))
+ "@" + Ic2Items.uraniumBlock.getItemDamage()
);
return true;
}
public Collection<ITriggerInternal>
getInternalTriggers(final IStatementContainer container) {
return null;
}
public Collection<ITriggerExternal>
getExternalTriggers(final ForgeDirection side, final TileEntity tile) {
final List<ITriggerExternal> temp = new ArrayList<ITriggerExternal>();
if (tile instanceof TileEntityStandardMachine
|| tile instanceof TileEntityBaseGenerator
|| tile instanceof TileEntityElectricBlock
|| tile instanceof TileEntityLathe) {
temp.add((ITriggerExternal) SubModule.triggerCapacitorEmpty);
temp.add((ITriggerExternal) SubModule.triggerCapacitorHasEnergy);
temp.add((ITriggerExternal) SubModule.triggerCapacitorHasRoom);
temp.add((ITriggerExternal) SubModule.triggerCapacitorFull);
}
if (tile instanceof TileEntityBaseGenerator
|| tile instanceof TileEntityElectricBlock) {
temp.add((ITriggerExternal) SubModule.triggerChargeEmpty);
temp.add((ITriggerExternal) SubModule.triggerChargePartial);
temp.add((ITriggerExternal) SubModule.triggerChargeFull);
}
if (tile instanceof TileEntityStandardMachine
|| tile instanceof TileEntityElectricBlock) {
temp.add((ITriggerExternal) SubModule.triggerDischargeEmpty);
temp.add((ITriggerExternal) SubModule.triggerDischargePartial);
temp.add((ITriggerExternal) SubModule.triggerDischargeFull);
}
if (tile instanceof TileEntityStandardMachine
|| tile instanceof TileEntityBaseGenerator
|| tile instanceof TileEntityLathe) {
temp.add((ITriggerExternal) SubModule.triggerWorking);
temp.add((ITriggerExternal) SubModule.triggerNotWorking);
}
if (tile instanceof TileEntityBaseGenerator
|| tile instanceof TileEntityGeoGenerator
|| tile instanceof TileEntitySolidHeatGenerator
|| tile instanceof TileEntityFluidHeatGenerator
|| tile instanceof TileEntitySemifluidGenerator) {
temp.add((ITriggerExternal) SubModule.triggerHasFuel);
temp.add((ITriggerExternal) SubModule.triggerNoFuel);
}
if (tile instanceof TileEntityCableDetector) {
temp.add((ITriggerExternal) SubModule.triggerEnergyFlowing);
temp.add((ITriggerExternal) SubModule.triggerEnergyNotFlowing);
}
if (tile instanceof TileEntityMatter) {
temp.add((ITriggerExternal) SubModule.triggerHasScrap);
temp.add((ITriggerExternal) SubModule.triggerNoScrap);
}
if (tile instanceof TileEntityInduction || tile instanceof TileEntityCentrifuge
|| tile instanceof TileEntityBlastFurnace) {
temp.add((ITriggerExternal) SubModule.triggerFullHeat);
temp.add((ITriggerExternal) SubModule.triggerNoFullHeat);
}
return temp;
}
}

View file

@ -0,0 +1,70 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.bcIntegration.core;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.IStatementContainer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.tileentity.TileEntity;
import ic2.core.IC2;
import net.minecraft.client.renderer.texture.IIconRegister;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.StatementManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.IIcon;
import buildcraft.api.statements.ITriggerExternal;
public abstract class Trigger implements ITriggerExternal {
protected final TriggerType type;
@SideOnly(Side.CLIENT)
protected IIcon icon;
public Trigger(final TriggerType type) {
this.type = type;
StatementManager.registerStatement((IStatement) this);
}
public String getUniqueTag() {
return "IC2_" + this.type.name();
}
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return this.icon;
}
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister) {
this.icon = iconRegister.registerIcon(
IC2.textureDomain + ":bcTrigger/" + this.type.name()
);
}
public abstract String getDescription();
public abstract boolean isTriggerActive(
final TileEntity p0,
final ForgeDirection p1,
final IStatementContainer p2,
final IStatementParameter[] p3
);
public int maxParameters() {
return 0;
}
public int minParameters() {
return 0;
}
public IStatementParameter createParameter(final int index) {
return null;
}
public IStatement rotateLeft() {
return (IStatement) this;
}
}

View file

@ -0,0 +1,220 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.bcIntegration.core;
import net.minecraft.item.Item;
import ic2.api.item.ElectricItem;
import net.minecraft.item.ItemStack;
import ic2.core.block.machine.tileentity.TileEntityLathe;
import ic2.core.block.wiring.TileEntityElectricBlock;
import ic2.core.block.generator.tileentity.TileEntityBaseGenerator;
import ic2.core.block.machine.tileentity.TileEntityStandardMachine;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.IStatementContainer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.tileentity.TileEntity;
public class TriggerCapacitor extends Trigger {
public TriggerCapacitor(final TriggerType type) {
super(type);
}
@Override
public String getDescription() {
switch (this.type) {
case CapacitorEmpty: {
return "Capacitor Empty";
}
case CapacitorHasEnergy: {
return "Capacitor Has Energy";
}
case CapacitorHasRoom: {
return "Space For Energy";
}
case CapacitorFull: {
return "Capacitor Full";
}
case ChargeEmpty: {
return "Charging Empty Item";
}
case ChargePartial: {
return "Charging Partially Charged Item";
}
case ChargeFull: {
return "Charging Fully Charged Item";
}
case DischargeEmpty: {
return "Discharging Empty Item";
}
case DischargePartial: {
return "Discharging Partially Charged Item";
}
case DischargeFull: {
return "Discharging Fully Charged Item";
}
default: {
return "";
}
}
}
@Override
public boolean isTriggerActive(
final TileEntity target,
final ForgeDirection side,
final IStatementContainer source,
final IStatementParameter[] parameters
) {
if (target == null) {
return false;
}
if (target instanceof TileEntityStandardMachine) {
final TileEntityStandardMachine te = (TileEntityStandardMachine) target;
final boolean hasEnergy = te.energy >= te.defaultEnergyConsume;
final boolean hasRoom = te.energy <= te.maxEnergy - te.defaultEnergyConsume;
final ItemStack item = te.dischargeSlot.get();
switch (this.type) {
case CapacitorEmpty: {
return !hasEnergy;
}
case CapacitorHasEnergy: {
return hasEnergy;
}
case CapacitorHasRoom: {
return hasRoom;
}
case CapacitorFull: {
return !hasRoom;
}
case DischargeEmpty: {
return item != null && !this.canDischarge(item);
}
case DischargePartial: {
return item != null && this.canDischarge(item)
&& this.canCharge(item);
}
case DischargeFull: {
return item != null && !this.canCharge(item);
}
default: {
return false;
}
}
} else if (target instanceof TileEntityBaseGenerator) {
final TileEntityBaseGenerator te2 = (TileEntityBaseGenerator) target;
final boolean hasEnergy = te2.storage > 0.0;
final boolean hasRoom = te2.storage < te2.maxStorage;
final ItemStack item = te2.chargeSlot.get();
switch (this.type) {
case CapacitorEmpty: {
return !hasEnergy;
}
case CapacitorHasEnergy: {
return hasEnergy;
}
case CapacitorHasRoom: {
return hasRoom;
}
case CapacitorFull: {
return !hasRoom;
}
case ChargeEmpty: {
return item != null && !this.canDischarge(item);
}
case ChargePartial: {
return item != null && this.canDischarge(item)
&& this.canCharge(item);
}
case ChargeFull: {
return item != null && !this.canCharge(item);
}
default: {
return false;
}
}
} else if (target instanceof TileEntityElectricBlock) {
final TileEntityElectricBlock te3 = (TileEntityElectricBlock) target;
final boolean hasEnergy = te3.energy >= te3.output;
final boolean hasRoom = te3.energy < te3.maxStorage;
final ItemStack chargeItem = te3.chargeSlot.get();
final ItemStack dischargeItem = te3.dischargeSlot.get();
switch (this.type) {
case CapacitorEmpty: {
return !hasEnergy;
}
case CapacitorHasEnergy: {
return hasEnergy;
}
case CapacitorHasRoom: {
return hasRoom;
}
case CapacitorFull: {
return !hasRoom;
}
case ChargeEmpty: {
return chargeItem != null && !this.canDischarge(chargeItem);
}
case ChargePartial: {
return chargeItem != null && this.canDischarge(chargeItem)
&& this.canCharge(chargeItem);
}
case ChargeFull: {
return chargeItem != null && !this.canCharge(chargeItem);
}
case DischargeEmpty: {
return dischargeItem != null && !this.canDischarge(dischargeItem);
}
case DischargePartial: {
return dischargeItem != null && this.canDischarge(dischargeItem)
&& this.canCharge(dischargeItem);
}
case DischargeFull: {
return dischargeItem != null && !this.canCharge(dischargeItem);
}
default: {
return false;
}
}
} else {
if (!(target instanceof TileEntityLathe)) {
return false;
}
final TileEntityLathe te4 = (TileEntityLathe) target;
final boolean hasEnergy = te4.kUBuffer > 0;
final boolean hasRoom = te4.kUBuffer < 10000;
switch (this.type) {
case CapacitorEmpty: {
return !hasEnergy;
}
case CapacitorHasEnergy: {
return hasEnergy;
}
case CapacitorHasRoom: {
return hasRoom;
}
case CapacitorFull: {
return !hasRoom;
}
default: {
return false;
}
}
}
}
private boolean canDischarge(final ItemStack itemStack) {
final Item item = itemStack.getItem();
return item != null && ElectricItem.manager.getCharge(itemStack) > 0.0;
}
private boolean canCharge(final ItemStack itemStack) {
final Item item = itemStack.getItem();
return item != null
&& ElectricItem.manager.charge(
itemStack, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, true
)
> 0.0;
}
}

View file

@ -0,0 +1,48 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.bcIntegration.core;
import ic2.core.block.wiring.TileEntityCableDetector;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.IStatementContainer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.tileentity.TileEntity;
public class TriggerEnergyFlow extends Trigger {
public TriggerEnergyFlow(final TriggerType type) {
super(type);
}
@Override
public String getDescription() {
switch (this.type) {
case EnergyFlowing: {
return "Energy flowing";
}
case EnergyNotFlowing: {
return "Energy not flowing";
}
default: {
return "";
}
}
}
@Override
public boolean isTriggerActive(
final TileEntity target,
final ForgeDirection side,
final IStatementContainer source,
final IStatementParameter[] parameters
) {
if (target instanceof TileEntityCableDetector) {
final TileEntityCableDetector te = (TileEntityCableDetector) target;
final boolean active = te.getActive();
return (this.type == TriggerType.EnergyFlowing && active)
|| (this.type == TriggerType.EnergyNotFlowing && !active);
}
return false;
}
}

View file

@ -0,0 +1,74 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.bcIntegration.core;
import ic2.core.block.generator.tileentity.TileEntitySemifluidGenerator;
import ic2.core.block.heatgenerator.tileentity.TileEntityFluidHeatGenerator;
import ic2.core.block.heatgenerator.tileentity.TileEntitySolidHeatGenerator;
import ic2.core.block.generator.tileentity.TileEntityGeoGenerator;
import ic2.core.block.generator.tileentity.TileEntityBaseGenerator;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.IStatementContainer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.tileentity.TileEntity;
public class TriggerFuel extends Trigger {
public TriggerFuel(final TriggerType type) {
super(type);
}
@Override
public String getDescription() {
switch (this.type) {
case HasFuel: {
return "Has Fuel";
}
case NoFuel: {
return "No Fuel";
}
default: {
return "";
}
}
}
@Override
public boolean isTriggerActive(
final TileEntity target,
final ForgeDirection side,
final IStatementContainer source,
final IStatementParameter[] parameters
) {
if (target instanceof TileEntityBaseGenerator) {
final TileEntityBaseGenerator te = (TileEntityBaseGenerator) target;
return (this.type == TriggerType.HasFuel && te.fuel > 0)
|| (this.type == TriggerType.NoFuel && te.fuel <= 0);
}
if (target instanceof TileEntityGeoGenerator) {
final TileEntityGeoGenerator te2 = (TileEntityGeoGenerator) target;
return (this.type == TriggerType.HasFuel && te2.getTankAmount() > 0)
|| (this.type == TriggerType.NoFuel && te2.getTankAmount() <= 0);
}
if (target instanceof TileEntitySolidHeatGenerator) {
final TileEntitySolidHeatGenerator te3
= (TileEntitySolidHeatGenerator) target;
return (this.type == TriggerType.HasFuel && te3.fuel > 0)
|| (this.type == TriggerType.NoFuel && te3.fuel <= 0);
}
if (target instanceof TileEntityFluidHeatGenerator) {
final TileEntityFluidHeatGenerator te4
= (TileEntityFluidHeatGenerator) target;
return (this.type == TriggerType.HasFuel && te4.getTankAmount() > 0)
|| (this.type == TriggerType.NoFuel && te4.getTankAmount() <= 0);
}
if (target instanceof TileEntitySemifluidGenerator) {
final TileEntitySemifluidGenerator te5
= (TileEntitySemifluidGenerator) target;
return (this.type == TriggerType.HasFuel && te5.getTankAmount() > 0)
|| (this.type == TriggerType.NoFuel && te5.getTankAmount() <= 0);
}
return false;
}
}

View file

@ -0,0 +1,63 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.bcIntegration.core;
import ic2.core.block.machine.tileentity.TileEntityCentrifuge;
import ic2.core.block.machine.tileentity.TileEntityBlastFurnace;
import ic2.core.block.machine.tileentity.TileEntityInduction;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.IStatementContainer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.tileentity.TileEntity;
public class TriggerHeat extends Trigger {
public TriggerHeat(final TriggerType type) {
super(type);
}
@Override
public String getDescription() {
switch (this.type) {
case FullHeat: {
return "Fully Heated Up";
}
case NoFullHeat: {
return "Not Fully Heated Up";
}
default: {
return "";
}
}
}
@Override
public boolean isTriggerActive(
final TileEntity target,
final ForgeDirection side,
final IStatementContainer source,
final IStatementParameter[] parameters
) {
if (target instanceof TileEntityInduction) {
final TileEntityInduction te = (TileEntityInduction) target;
return (this.type == TriggerType.FullHeat
&& te.heat >= TileEntityInduction.maxHeat)
|| (this.type == TriggerType.NoFullHeat
&& te.heat < TileEntityInduction.maxHeat);
}
if (target instanceof TileEntityBlastFurnace) {
final TileEntityBlastFurnace te2 = (TileEntityBlastFurnace) target;
return (this.type == TriggerType.FullHeat
&& te2.heat >= TileEntityBlastFurnace.maxHeat)
|| (this.type == TriggerType.NoFullHeat
&& te2.heat < TileEntityBlastFurnace.maxHeat);
}
if (target instanceof TileEntityCentrifuge) {
final TileEntityCentrifuge te3 = (TileEntityCentrifuge) target;
return (this.type == TriggerType.FullHeat && te3.workheat >= te3.heat)
|| (this.type == TriggerType.NoFullHeat && te3.workheat < te3.heat);
}
return false;
}
}

View file

@ -0,0 +1,48 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.bcIntegration.core;
import ic2.core.block.machine.tileentity.TileEntityMatter;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.IStatementContainer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.tileentity.TileEntity;
public class TriggerScrap extends Trigger {
public TriggerScrap(final TriggerType type) {
super(type);
}
@Override
public String getDescription() {
switch (this.type) {
case HasScrap: {
return "Has Amplifier";
}
case NoScrap: {
return "No Amplifier";
}
default: {
return "";
}
}
}
@Override
public boolean isTriggerActive(
final TileEntity target,
final ForgeDirection side,
final IStatementContainer source,
final IStatementParameter[] parameters
) {
if (target instanceof TileEntityMatter) {
final TileEntityMatter te = (TileEntityMatter) target;
final boolean available = te.amplificationIsAvailable();
return (this.type == TriggerType.HasScrap && available)
|| (this.type == TriggerType.NoScrap && !available);
}
return false;
}
}

View file

@ -0,0 +1,28 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.bcIntegration.core;
public enum TriggerType {
CapacitorEmpty,
CapacitorHasEnergy,
CapacitorHasRoom,
CapacitorFull,
ChargeEmpty,
ChargePartial,
ChargeFull,
DischargeEmpty,
DischargePartial,
DischargeFull,
Working,
NotWorking,
EnergyFlowing,
EnergyNotFlowing,
HasFuel,
NoFuel,
HasScrap,
NoScrap,
FullHeat,
NoFullHeat;
}

View file

@ -0,0 +1,78 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.bcIntegration.core;
import ic2.core.block.machine.tileentity.TileEntityLathe;
import ic2.core.block.machine.tileentity.TileEntityStandardMachine;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.IStatementContainer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
public class TriggerWork extends Trigger {
public TriggerWork(final TriggerType type) {
super(type);
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(final IIconRegister iconRegister) {
switch (this.type) {
case Working: {
this.icon = iconRegister.registerIcon(
"buildcraft:triggers/trigger_machine_active"
);
break;
}
case NotWorking: {
this.icon = iconRegister.registerIcon(
"buildcraft:triggers/trigger_machine_inactive"
);
break;
}
default: {
}
}
}
@Override
public String getDescription() {
switch (this.type) {
case Working: {
return "Machine On";
}
case NotWorking: {
return "Machine Off";
}
default: {
return "";
}
}
}
@Override
public boolean isTriggerActive(
final TileEntity target,
final ForgeDirection side,
final IStatementContainer source,
final IStatementParameter[] parameters
) {
if (target instanceof TileEntityStandardMachine) {
final TileEntityStandardMachine te = (TileEntityStandardMachine) target;
final boolean active = te.getActive();
return (this.type == TriggerType.Working && active)
|| (this.type == TriggerType.NotWorking && !active);
}
if (target instanceof TileEntityLathe) {
final boolean active2 = ((TileEntityLathe) target).canWork(true);
return (this.type == TriggerType.Working && active2)
|| (this.type == TriggerType.NotWorking && !active2);
}
return false;
}
}

View file

@ -0,0 +1,20 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.core;
import net.minecraft.item.ItemStack;
import ic2.api.recipe.ICraftingRecipeManager;
public class AdvCraftingRecipeManager implements ICraftingRecipeManager {
@Override
public void addRecipe(final ItemStack output, final Object... input) {
AdvRecipe.addAndRegister(output, input);
}
@Override
public void addShapelessRecipe(final ItemStack output, final Object... input) {
AdvShapelessRecipe.addAndRegister(output, input);
}
}

View file

@ -0,0 +1,511 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.core;
import ic2.core.util.Util;
import net.minecraftforge.fluids.IFluidContainerItem;
import ic2.api.item.ElectricItem;
import java.lang.reflect.Array;
import net.minecraftforge.oredict.OreDictionary;
import ic2.core.util.StackUtil;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry;
import java.util.Collection;
import ic2.core.util.ConfigUtil;
import net.minecraft.inventory.IInventory;
import net.minecraft.world.World;
import net.minecraft.inventory.InventoryCrafting;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import ic2.core.util.LogCategory;
import org.apache.commons.lang3.StringUtils;
import net.minecraft.item.Item;
import net.minecraft.block.Block;
import ic2.api.recipe.IRecipeInput;
import java.util.ArrayList;
import java.util.HashMap;
import ic2.core.init.MainConfig;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
public class AdvRecipe implements IRecipe {
private static final boolean debug;
public final ItemStack output;
public final Object[] input;
public final Object[] inputMirrored;
public final int[] masks;
public final int[] masksMirrored;
public final int inputWidth;
public final int inputHeight;
public final boolean hidden;
public static void addAndRegister(final ItemStack result, final Object... args) {
try {
CraftingManager.getInstance().getRecipeList().add(new AdvRecipe(result, args)
);
} catch (final RuntimeException e) {
if (!MainConfig.ignoreInvalidRecipes) {
throw e;
}
}
}
public AdvRecipe(final ItemStack result, final Object... args) {
if (result == null) {
displayError("null result", null, null, false);
}
final Map<Character, Object> charMapping = new HashMap<Character, Object>();
final List<String> inputArrangement = new ArrayList<String>();
Character lastChar = null;
boolean isHidden = false;
for (Object arg : args) {
if (arg instanceof String) {
if (lastChar == null) {
if (!charMapping.isEmpty()) {
displayError(
"oredict name without preceding char",
"Name: " + arg,
result,
false
);
}
final String str = (String) arg;
if (str.isEmpty() || str.length() > 3) {
displayError(
"none or too many crafting columns",
"Input: " + str + "\nSize: " + str.length(),
result,
false
);
}
inputArrangement.add(str);
} else {
charMapping.put(lastChar, arg);
lastChar = null;
}
} else if (arg instanceof Character) {
if (lastChar != null) {
displayError(
"two consecutive char definitions",
"Input: " + arg + "\nprev. Input: " + lastChar,
result,
false
);
}
lastChar = (Character) arg;
} else if (arg instanceof IRecipeInput || arg instanceof ItemStack
|| arg instanceof Block || arg instanceof Item
|| arg.getClass().isArray() || arg instanceof Iterable) {
if (lastChar == null) {
displayError(
"item without preceding char",
"Input: " + arg + "\nType: "
+ ((arg == null) ? "null" : arg.getClass().getName()),
result,
false
);
}
if (arg instanceof Block) {
arg = new ItemStack((Block) arg, 1);
} else if (arg instanceof Item) {
arg = new ItemStack((Item) arg, 1);
}
expand(arg);
charMapping.put(lastChar, arg);
lastChar = null;
} else if (arg instanceof Boolean) {
isHidden = (boolean) arg;
} else {
displayError(
"unknown type",
"Input: " + arg + "\nType: " + arg.getClass().getName(),
result,
false
);
}
}
this.hidden = isHidden;
this.inputHeight = inputArrangement.size();
if (lastChar != null) {
displayError(
"one or more unused mapping chars", "Letter: " + lastChar, result, false
);
}
if (this.inputHeight == 0 || this.inputHeight > 3) {
displayError(
"none or too many crafting rows",
"Size: " + inputArrangement.size(),
result,
false
);
}
if (charMapping.size() == 0) {
displayError("no mapping chars", null, result, false);
}
this.inputWidth = inputArrangement.get(0).length();
if (AdvRecipe.debug) {
if (StringUtils.containsOnly(
(CharSequence) inputArrangement.get(0), new char[] { ' ' }
)) {
IC2.log.warn(
LogCategory.Recipe,
"Leading empty row in shaped recipe for %s, from %s.",
result,
getCaller()
);
}
if (StringUtils.containsOnly(
(CharSequence) inputArrangement.get(this.inputHeight - 1),
new char[] { ' ' }
)) {
IC2.log.warn(
LogCategory.Recipe,
"Trailing empty row in shaped recipe for %s, from %s.",
result,
getCaller()
);
}
for (int pass = 0; pass < 2; ++pass) {
boolean found = true;
for (int y = 0; y < this.inputHeight; ++y) {
final String str2 = inputArrangement.get(y);
if ((pass == 0 && str2.charAt(0) != ' ')
|| (pass == 1 && str2.charAt(this.inputWidth - 1) != ' ')) {
found = false;
break;
}
}
if (found) {
if (pass == 0) {
IC2.log.warn(
LogCategory.Recipe,
"Leading empty column in shaped recipe for %s, from %s.",
result,
getCaller()
);
} else {
IC2.log.warn(
LogCategory.Recipe,
"Trailing empty column in shaped recipe for %s, from %s.",
result,
getCaller()
);
}
}
}
}
final int xMasks = -this.inputWidth + 4;
final int yMasks = -this.inputHeight + 4;
int mask = 0;
final List<Object> inputs = new ArrayList<Object>();
for (int y2 = 0; y2 < 3; ++y2) {
String str3 = null;
if (y2 < this.inputHeight) {
str3 = inputArrangement.get(y2);
if (str3.length() != this.inputWidth) {
displayError(
"no fixed width",
"Expected: " + this.inputWidth + "\nGot: " + str3.length(),
result,
false
);
}
}
for (int x = 0; x < 3; ++x) {
mask <<= 1;
if (x < this.inputWidth && str3 != null) {
final char c = str3.charAt(x);
if (c != ' ') {
if (!charMapping.containsKey(c)) {
displayError(
"missing char mapping", "Letter: " + c, result, false
);
}
inputs.add(charMapping.get(c));
mask |= 0x1;
}
}
}
}
this.input = inputs.toArray();
boolean mirror = false;
if (this.inputWidth != 1) {
for (final String s : inputArrangement) {
if (s.charAt(0) != s.charAt(this.inputWidth - 1)) {
mirror = true;
break;
}
}
}
if (!mirror) {
this.inputMirrored = null;
} else {
final Object[] tmp = new Object[9];
int i = 0;
int j = 0;
while (i < 9) {
if ((mask & 1 << 8 - i) != 0x0) {
tmp[i] = this.input[j];
++j;
}
++i;
}
Object old = tmp[0];
tmp[0] = tmp[2];
tmp[2] = old;
old = tmp[3];
tmp[3] = tmp[5];
tmp[5] = old;
old = tmp[6];
tmp[6] = tmp[8];
tmp[8] = old;
this.inputMirrored = new Object[this.input.length];
int k = 0;
int l = 0;
while (k < 9) {
if (tmp[k] != null) {
this.inputMirrored[l] = tmp[k];
++l;
}
++k;
}
}
this.masks = new int[xMasks * yMasks];
if (!mirror) {
this.masksMirrored = null;
} else {
this.masksMirrored = new int[this.masks.length];
}
for (int y3 = 0; y3 < yMasks; ++y3) {
final int yMask = mask >>> y3 * 3;
for (int x2 = 0; x2 < xMasks; ++x2) {
final int xyMask = yMask >>> x2;
this.masks[x2 + y3 * xMasks] = xyMask;
if (mirror) {
this.masksMirrored[x2 + y3 * xMasks]
= ((xyMask << 2 & 0x124) | (xyMask & 0x92) | (xyMask >>> 2 & 0x49)
);
}
}
}
this.output = result;
}
public boolean matches(final InventoryCrafting inventorycrafting, final World world) {
return this.getCraftingResult(inventorycrafting) != null;
}
public ItemStack getCraftingResult(final InventoryCrafting inventorycrafting) {
final int size = inventorycrafting.getSizeInventory();
int mask = 0;
for (int i = 0; i < size; ++i) {
mask <<= 1;
if (inventorycrafting.getStackInSlot(i) != null) {
mask |= 0x1;
}
}
if (size == 4) {
mask = ((mask & 0xC) << 5 | (mask & 0x3) << 4);
}
if (checkMask(mask, this.masks)) {
final ItemStack ret
= this.checkItems((IInventory) inventorycrafting, this.input);
if (ret != null) {
return ret;
}
}
if (this.masksMirrored != null && checkMask(mask, this.masksMirrored)) {
final ItemStack ret
= this.checkItems((IInventory) inventorycrafting, this.inputMirrored);
if (ret != null) {
return ret;
}
}
return null;
}
public int getRecipeSize() {
return this.input.length;
}
public ItemStack getRecipeOutput() {
return this.output;
}
public static boolean recipeContains(final Object[] inputs, final ItemStack item) {
for (final Object input : inputs) {
if (input != null) {
final List<ItemStack> realInputs = expand(input);
for (final ItemStack realInput : realInputs) {
if (item.isItemEqual(realInput)) {
return true;
}
}
}
}
return false;
}
public static boolean
canShow(final Object[] input, final ItemStack output, final boolean hidden) {
return !hidden || !ConfigUtil.getBool(MainConfig.get(), "misc/hideSecretRecipes");
}
public boolean canShow() {
return canShow(this.input, this.output, this.hidden);
}
public static List<ItemStack> expand(final Object o) {
final List<ItemStack> ret = new ArrayList<ItemStack>();
if (o instanceof IRecipeInput) {
ret.addAll(((IRecipeInput) o).getInputs());
} else if (o instanceof String) {
final String s = (String) o;
if (s.startsWith("liquid$")) {
final String name = s.substring(7);
for (final FluidContainerRegistry.FluidContainerData data :
FluidContainerRegistry.getRegisteredFluidContainerData()) {
final String fluidName
= FluidRegistry.getFluidName(data.fluid);
if (fluidName != null) {
if (StackUtil.check(data.filledContainer)) {
if (name.equals(fluidName)) {
ret.add(data.filledContainer);
}
}
}
}
} else {
for (final ItemStack stack : OreDictionary.getOres((String) o)) {
if (StackUtil.check(stack)) {
ret.add(stack);
}
}
}
} else if (o instanceof ItemStack) {
if (StackUtil.check((ItemStack) o)) {
ret.add((ItemStack) o);
}
} else if (o.getClass().isArray()) {
assert Array.getLength(o) != 0;
for (int i = 0; i < Array.getLength(o); ++i) {
ret.addAll(expand(Array.get(o, i)));
}
} else {
if (!(o instanceof Iterable)) {
displayError(
"unknown type",
"Input: " + o + "\nType: " + o.getClass().getName(),
null,
false
);
return null;
}
assert ((Iterable) o).iterator().hasNext();
for (final Object o2 : (Iterable) o) {
ret.addAll(expand(o2));
}
}
return ret;
}
public static List<ItemStack>[] expandArray(final Object[] array) {
final List<ItemStack>[] ret = new List[array.length];
for (int i = 0; i < array.length; ++i) {
if (array[i] == null) {
ret[i] = null;
} else {
ret[i] = expand(array[i]);
}
}
return ret;
}
public static void displayError(
final String cause,
final String tech,
final ItemStack result,
final boolean shapeless
) {
final String msg
= "An invalid crafting recipe was attempted to be added. This could happen "
+ "due to a bug in IndustrialCraft 2 or an addon.\n\n(Technical "
+ "information: Adv" + (shapeless ? "Shapeless" : "") + "Recipe, " + cause
+ ")\n" + ((result != null) ? ("Output: " + result + "\n") : "")
+ ((tech != null) ? (tech + "\n") : "") + "Source: " + getCaller();
if (MainConfig.ignoreInvalidRecipes) {
IC2.log.warn(LogCategory.Recipe, msg);
throw new RuntimeException(msg);
}
IC2.platform.displayError(msg, new Object[0]);
}
private static String getCaller() {
String ret = "unknown";
for (final StackTraceElement st : Thread.currentThread().getStackTrace()) {
final String className = st.getClassName();
final int pkgSeparator = className.lastIndexOf(46);
final String pkg
= (pkgSeparator == -1) ? "" : className.substring(0, pkgSeparator);
if (!pkg.equals("ic2.core") && !pkg.startsWith("ic2.api")
&& !pkg.startsWith("java.")) {
ret = className + "." + st.getMethodName() + "(" + st.getFileName() + ":"
+ st.getLineNumber() + ")";
break;
}
}
return ret;
}
private static boolean checkMask(final int mask, final int[] request) {
for (final int cmpMask : request) {
if (mask == cmpMask) {
return true;
}
}
return false;
}
private ItemStack checkItems(final IInventory inventory, final Object[] request) {
final int size = inventory.getSizeInventory();
double outputCharge = 0.0;
int i = 0;
int j = 0;
while (i < size) {
final ItemStack offer = inventory.getStackInSlot(i);
if (offer != null) {
final List<ItemStack> requestedItemStacks = expand(request[j]);
boolean found = false;
for (final ItemStack requestedItemStack : requestedItemStacks) {
if (offer.isItemEqual(requestedItemStack)
|| (requestedItemStack.getItemDamage() == 32767
&& offer.getItem() == requestedItemStack.getItem())) {
outputCharge += ElectricItem.manager.getCharge(offer);
found = true;
break;
}
}
if (!found) {
return null;
}
++j;
}
++i;
}
final ItemStack ret = this.output.copy();
final Item item = ret.getItem();
ElectricItem.manager.charge(ret, outputCharge, Integer.MAX_VALUE, true, false);
if (item instanceof IFluidContainerItem) {
StackUtil.getOrCreateNbtData(ret);
}
return ret;
}
static {
debug = Util.hasAssertions();
}
}

View file

@ -0,0 +1,141 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.core;
import java.util.Iterator;
import java.util.List;
import ic2.core.util.StackUtil;
import net.minecraftforge.fluids.IFluidContainerItem;
import ic2.api.item.ElectricItem;
import java.util.Vector;
import net.minecraft.world.World;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.block.Block;
import ic2.api.recipe.IRecipeInput;
import ic2.core.util.Util;
import ic2.core.init.MainConfig;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
public class AdvShapelessRecipe implements IRecipe {
public ItemStack output;
public Object[] input;
public boolean hidden;
public static void addAndRegister(final ItemStack result, final Object... args) {
try {
CraftingManager.getInstance().getRecipeList().add(
new AdvShapelessRecipe(result, args)
);
} catch (final RuntimeException e) {
if (!MainConfig.ignoreInvalidRecipes) {
throw e;
}
}
}
public AdvShapelessRecipe(ItemStack result, final Object... args) {
if (result == null) {
AdvRecipe.displayError("null result", null, null, true);
} else {
result = result.copy();
}
this.input = new Object[args.length - Util.countInArray(args, Boolean.class)];
int inputIndex = 0;
for (Object o : args) {
if (o instanceof String) {
this.input[inputIndex++] = o;
} else if (o instanceof IRecipeInput || o instanceof ItemStack
|| o instanceof Block || o instanceof Item
|| o.getClass().isArray() || o instanceof Iterable) {
if (o instanceof Block) {
o = new ItemStack((Block) o, 1, 32767);
} else if (o instanceof Item) {
o = new ItemStack((Item) o, 1, 32767);
}
AdvRecipe.expand(o);
this.input[inputIndex++] = o;
} else if (o instanceof Boolean) {
this.hidden = (boolean) o;
} else {
AdvRecipe.displayError(
"unknown type",
"O: " + o + "\nT: " + o.getClass().getName(),
result,
true
);
}
}
if (inputIndex != this.input.length) {
AdvRecipe.displayError(
"length calculation error",
"I: " + inputIndex + "\nL: " + this.input.length,
result,
true
);
}
this.output = result;
}
public boolean matches(final InventoryCrafting inventorycrafting, final World world) {
return this.getCraftingResult(inventorycrafting) != null;
}
public ItemStack getCraftingResult(final InventoryCrafting inventorycrafting) {
final int offerSize = inventorycrafting.getSizeInventory();
if (offerSize < this.input.length) {
return null;
}
final List<Object> unmatched = new Vector<Object>();
for (final Object o : this.input) {
unmatched.add(o);
}
double outputCharge = 0.0;
Label_0225:
for (int i = 0; i < offerSize; ++i) {
final ItemStack offer = inventorycrafting.getStackInSlot(i);
if (offer != null) {
for (int j = 0; j < unmatched.size(); ++j) {
final List<ItemStack> requestedItemStacks
= AdvRecipe.expand(unmatched.get(j));
for (final ItemStack requestedItemStack : requestedItemStacks) {
if (offer.isItemEqual(requestedItemStack)
|| (requestedItemStack.getItemDamage() == 0x7fff
&& offer.getItem() == requestedItemStack.getItem())) {
outputCharge += ElectricItem.manager.getCharge(offer);
unmatched.remove(j);
continue Label_0225;
}
}
}
return null;
}
}
if (!unmatched.isEmpty()) {
return null;
}
final ItemStack ret = this.output.copy();
final Item item = ret.getItem();
ElectricItem.manager.charge(ret, outputCharge, Integer.MAX_VALUE, true, false);
if (item instanceof IFluidContainerItem) {
StackUtil.getOrCreateNbtData(ret);
}
return ret;
}
public int getRecipeSize() {
return this.input.length;
}
public ItemStack getRecipeOutput() {
return this.output;
}
public boolean canShow() {
return AdvRecipe.canShow(this.input, this.output, this.hidden);
}
}

View file

@ -0,0 +1,56 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.core;
import java.util.Iterator;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import ic2.api.recipe.IRecipeInput;
import java.util.List;
import ic2.api.recipe.IListRecipeManager;
public class BasicListRecipeManager implements IListRecipeManager {
private final List<IRecipeInput> list;
public BasicListRecipeManager() {
this.list = new ArrayList<IRecipeInput>();
}
@Override
public void add(final IRecipeInput input) {
if (input == null) {
throw new NullPointerException("Input must not be null.");
}
this.list.add(input);
}
@Override
public boolean contains(final ItemStack stack) {
if (stack == null) {
return false;
}
for (final IRecipeInput input : this.list) {
if (input.matches(stack)) {
return true;
}
}
return false;
}
@Override
public boolean isEmpty() {
return this.list.isEmpty();
}
@Override
public List<IRecipeInput> getInputs() {
return this.list;
}
@Override
public Iterator<IRecipeInput> iterator() {
return this.list.iterator();
}
}

View file

@ -0,0 +1,344 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.core;
import ic2.core.init.MainConfig;
import java.util.Collection;
import ic2.api.recipe.RecipeInputItemStack;
import ic2.core.util.LogCategory;
import net.minecraftforge.common.MinecraftForge;
import java.util.ListIterator;
import ic2.core.util.StackUtil;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import ic2.api.recipe.RecipeInputOreDict;
import net.minecraftforge.oredict.OreDictionary;
import java.util.Iterator;
import java.util.AbstractSet;
import java.util.Set;
import java.util.AbstractMap;
import java.util.Arrays;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.HashMap;
import java.util.List;
import ic2.core.util.Tuple;
import net.minecraft.item.Item;
import ic2.api.recipe.RecipeOutput;
import ic2.api.recipe.IRecipeInput;
import java.util.Map;
import ic2.api.recipe.IMachineRecipeManagerExt;
public class BasicMachineRecipeManager implements IMachineRecipeManagerExt {
private final Map<IRecipeInput, RecipeOutput> recipes;
private final Map<Item, Map<Integer, Tuple.T2<IRecipeInput, RecipeOutput>>>
recipeCache;
private final List<Tuple.T2<IRecipeInput, RecipeOutput>> uncacheableRecipes;
private boolean oreRegisterEventSubscribed;
public BasicMachineRecipeManager() {
this.recipes = new HashMap<IRecipeInput, RecipeOutput>();
this.recipeCache = new IdentityHashMap<
Item,
Map<Integer, Tuple.T2<IRecipeInput, RecipeOutput>>>();
this.uncacheableRecipes = new ArrayList<Tuple.T2<IRecipeInput, RecipeOutput>>();
}
@Override
public void addRecipe(
final IRecipeInput input,
final NBTTagCompound metadata,
final ItemStack... outputs
) {
if (!this.addRecipe(input, metadata, false, outputs)) {
this.displayError(
"ambiguous recipe: [" + input.getInputs() + " -> "
+ Arrays.asList(outputs) + "]"
);
}
}
@Override
public boolean addRecipe(
final IRecipeInput input,
final NBTTagCompound metadata,
final boolean overwrite,
final ItemStack... outputs
) {
return this.addRecipe(input, new RecipeOutput(metadata, outputs), overwrite);
}
@Override
public RecipeOutput getOutputFor(final ItemStack input, final boolean adjustInput) {
if (input == null) {
return null;
}
final Tuple.T2<IRecipeInput, RecipeOutput> data = this.getRecipe(input);
if (data == null) {
return null;
}
if (input.stackSize >= data.a.getAmount()
&& (!input.getItem().hasContainerItem(input)
|| input.stackSize == data.a.getAmount())) {
if (adjustInput) {
if (input.getItem().hasContainerItem(input)) {
final ItemStack container = input.getItem().getContainerItem(input);
input.func_150996_a(container.getItem());
input.stackSize = container.stackSize;
input.setItemDamage(container.getItemDamage());
input.stackTagCompound = container.stackTagCompound;
} else {
input.stackSize -= data.a.getAmount();
}
}
return data.b;
}
return null;
}
@Override
public Map<IRecipeInput, RecipeOutput> getRecipes() {
return new AbstractMap<IRecipeInput, RecipeOutput>() {
@Override
public Set<Map.Entry<IRecipeInput, RecipeOutput>> entrySet() {
return new AbstractSet<Map.Entry<IRecipeInput, RecipeOutput>>() {
@Override
public Iterator<Map.Entry<IRecipeInput, RecipeOutput>> iterator() {
return new Iterator<Map.Entry<IRecipeInput, RecipeOutput>>() {
private final Iterator<Map.Entry<IRecipeInput, RecipeOutput>>
recipeIt
= BasicMachineRecipeManager.this.recipes.entrySet()
.iterator();
private IRecipeInput lastInput;
@Override
public boolean hasNext() {
return this.recipeIt.hasNext();
}
@Override
public Map.Entry<IRecipeInput, RecipeOutput> next() {
final Map.Entry<IRecipeInput, RecipeOutput> ret
= this.recipeIt.next();
this.lastInput = ret.getKey();
return ret;
}
@Override
public void remove() {
this.recipeIt.remove();
BasicMachineRecipeManager.this.removeCachedRecipes(
this.lastInput
);
}
};
}
@Override
public int size() {
return BasicMachineRecipeManager.this.recipes.size();
}
};
}
@Override
public RecipeOutput put(final IRecipeInput key, final RecipeOutput value) {
BasicMachineRecipeManager.this.addRecipe(key, value, true);
return null;
}
};
}
@SubscribeEvent
public void onOreRegister(final OreDictionary.OreRegisterEvent event) {
final List<Tuple.T2<IRecipeInput, RecipeOutput>> datas
= new ArrayList<Tuple.T2<IRecipeInput, RecipeOutput>>();
for (final Map.Entry<IRecipeInput, RecipeOutput> data : this.recipes.entrySet()) {
if (data.getKey().getClass() != RecipeInputOreDict.class) {
continue;
}
final RecipeInputOreDict recipe = (RecipeInputOreDict) data.getKey();
if (!recipe.input.equals(event.Name)) {
continue;
}
datas.add(
new Tuple.T2<IRecipeInput, RecipeOutput>(data.getKey(), data.getValue())
);
}
for (final Tuple.T2<IRecipeInput, RecipeOutput> data2 : datas) {
this.addToCache(event.Ore, data2);
}
}
private Tuple.T2<IRecipeInput, RecipeOutput> getRecipe(final ItemStack input) {
final Map<Integer, Tuple.T2<IRecipeInput, RecipeOutput>> metaMap
= this.recipeCache.get(input.getItem());
if (metaMap != null) {
Tuple.T2<IRecipeInput, RecipeOutput> data = metaMap.get(32767);
if (data != null) {
return data;
}
final int meta = input.getItemDamage();
data = metaMap.get(meta);
if (data != null) {
return data;
}
}
for (final Tuple.T2<IRecipeInput, RecipeOutput> data2 : this.uncacheableRecipes) {
if (data2.a.matches(input)) {
return data2;
}
}
return null;
}
private boolean addRecipe(
final IRecipeInput input, final RecipeOutput output, final boolean overwrite
) {
if (input == null) {
this.displayError("The recipe input is null");
return false;
}
final ListIterator<ItemStack> it = output.items.listIterator();
while (it.hasNext()) {
final ItemStack stack = it.next();
if (stack == null) {
this.displayError("An output ItemStack is null.");
return false;
}
if (!StackUtil.check(stack)) {
this.displayError(
"The output ItemStack " + StackUtil.toStringSafe(stack)
+ " is invalid."
);
return false;
}
if (input.matches(stack)
&& (output.metadata == null
|| !output.metadata.hasKey("ignoreSameInputOutput"))) {
this.displayError(
"The output ItemStack " + stack.toString()
+ " is the same as the recipe input " + input + "."
);
return false;
}
it.set(stack.copy());
}
for (final ItemStack is : input.getInputs()) {
Tuple.T2<IRecipeInput, RecipeOutput> data = this.getRecipe(is);
if (data != null) {
if (!overwrite) {
return false;
}
do {
this.recipes.remove(data.a);
this.removeCachedRecipes(data.a);
data = this.getRecipe(is);
} while (data != null);
}
}
this.recipes.put(input, output);
this.addToCache(input, output);
return true;
}
private void addToCache(final IRecipeInput input, final RecipeOutput output) {
final Tuple.T2<IRecipeInput, RecipeOutput> data
= new Tuple.T2<IRecipeInput, RecipeOutput>(input, output);
final List<ItemStack> stacks = this.getStacksFromRecipe(input);
if (stacks != null) {
for (final ItemStack stack : stacks) {
this.addToCache(stack, data);
}
if (input.getClass() == RecipeInputOreDict.class
&& !this.oreRegisterEventSubscribed) {
MinecraftForge.EVENT_BUS.register((Object) this);
this.oreRegisterEventSubscribed = true;
}
} else {
this.uncacheableRecipes.add(data);
}
}
private void
addToCache(final ItemStack stack, final Tuple.T2<IRecipeInput, RecipeOutput> data) {
final Item item = stack.getItem();
Map<Integer, Tuple.T2<IRecipeInput, RecipeOutput>> metaMap
= this.recipeCache.get(item);
if (metaMap == null) {
metaMap = new HashMap<Integer, Tuple.T2<IRecipeInput, RecipeOutput>>();
this.recipeCache.put(item, metaMap);
}
final int meta = stack.getItemDamage();
metaMap.put(meta, data);
}
private void removeCachedRecipes(final IRecipeInput input) {
final List<ItemStack> stacks = this.getStacksFromRecipe(input);
if (stacks != null) {
for (final ItemStack stack : stacks) {
final Item item = stack.getItem();
final int meta = stack.getItemDamage();
final Map<Integer, Tuple.T2<IRecipeInput, RecipeOutput>> map
= this.recipeCache.get(item);
if (map == null) {
IC2.log.warn(
LogCategory.Recipe,
"Inconsistent recipe cache, the entry for the item " + item + "("
+ stack + ") is missing."
);
} else {
map.remove(meta);
if (!map.isEmpty()) {
continue;
}
this.recipeCache.remove(item);
}
}
} else {
final Iterator<Tuple.T2<IRecipeInput, RecipeOutput>> it
= this.uncacheableRecipes.iterator();
while (it.hasNext()) {
final Tuple.T2<IRecipeInput, RecipeOutput> data = it.next();
if (data.a == input) {
it.remove();
}
}
}
}
private List<ItemStack> getStacksFromRecipe(final IRecipeInput recipe) {
if (recipe.getClass() == RecipeInputItemStack.class) {
return recipe.getInputs();
}
if (recipe.getClass() != RecipeInputOreDict.class) {
return null;
}
final Integer meta = ((RecipeInputOreDict) recipe).meta;
if (meta == null) {
return recipe.getInputs();
}
final List<ItemStack> ret = new ArrayList<ItemStack>(recipe.getInputs());
final ListIterator<ItemStack> it = ret.listIterator();
while (it.hasNext()) {
ItemStack stack = it.next();
if (stack.getItemDamage() != meta) {
stack = stack.copy();
stack.setItemDamage((int) meta);
it.set(stack);
}
}
return ret;
}
private void displayError(final String msg) {
if (MainConfig.ignoreInvalidRecipes) {
IC2.log.warn(LogCategory.Recipe, msg);
return;
}
throw new RuntimeException(msg);
}
}

View file

@ -0,0 +1,212 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.core;
import ic2.core.util.StackUtil;
import ic2.core.util.ReflectionUtil;
import net.minecraft.inventory.ICrafting;
import java.util.ArrayList;
import java.util.List;
import ic2.core.block.comp.TileEntityComponent;
import java.util.Map;
import ic2.core.block.TileEntityBlock;
import ic2.core.network.NetworkManager;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import ic2.core.slot.SlotInvSlot;
import ic2.core.slot.SlotHologramSlot;
import ic2.core.slot.SlotInvSlotReadOnly;
import java.util.ListIterator;
import java.util.Iterator;
import net.minecraft.item.ItemStack;
import net.minecraft.inventory.Slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
public abstract class ContainerBase<T extends IInventory> extends Container {
protected static final int windowBorder = 8;
protected static final int slotSize = 16;
protected static final int slotDistance = 2;
protected static final int slotSeparator = 4;
protected static final int hotbarYOffset = -24;
protected static final int inventoryYOffset = -82;
public final T base;
public ContainerBase(final T base1) {
this.base = base1;
}
protected void addPlayerInventorySlots(final EntityPlayer player, final int height) {
this.addPlayerInventorySlots(player, 178, height);
}
protected void addPlayerInventorySlots(
final EntityPlayer player, final int width, final int height
) {
final int xStart = (width - 162) / 2;
for (int row = 0; row < 3; ++row) {
for (int col = 0; col < 9; ++col) {
this.addSlotToContainer(new Slot(
(IInventory) player.inventory,
col + row * 9 + 9,
xStart + col * 18,
height - 82 + row * 18
));
}
}
for (int col2 = 0; col2 < 9; ++col2) {
this.addSlotToContainer(new Slot(
(IInventory) player.inventory, col2, xStart + col2 * 18, height - 24
));
}
}
@SuppressWarnings("unchecked")
public final ItemStack
transferStackInSlot(final EntityPlayer player, final int sourceSlotIndex) {
final Slot sourceSlot = (Slot) this.inventorySlots.get(sourceSlotIndex);
if (sourceSlot != null && sourceSlot.getHasStack()) {
final ItemStack sourceItemStack = sourceSlot.getStack();
final int oldSourceItemStackSize = sourceItemStack.stackSize;
if (sourceSlot.inventory == player.inventory) {
for (int run = 0; run < 4 && sourceItemStack.stackSize > 0; ++run) {
for (final Slot targetSlot : (ArrayList<Slot>) this.inventorySlots) {
if (targetSlot.inventory != player.inventory
&& isValidTargetSlot(
targetSlot, sourceItemStack, run % 2 == 1, run < 2
)) {
this.transfer(sourceItemStack, targetSlot);
if (sourceItemStack.stackSize == 0) {
break;
}
continue;
}
}
}
} else {
for (int run = 0; run < 2 && sourceItemStack.stackSize > 0; ++run) {
final ListIterator<Slot> it
= this.inventorySlots.listIterator(this.inventorySlots.size());
while (it.hasPrevious()) {
final Slot targetSlot = it.previous();
if (targetSlot.inventory == player.inventory
&& isValidTargetSlot(
targetSlot, sourceItemStack, run == 1, false
)) {
this.transfer(sourceItemStack, targetSlot);
if (sourceItemStack.stackSize == 0) {
break;
}
continue;
}
}
}
}
if (sourceItemStack.stackSize != oldSourceItemStackSize) {
if (sourceItemStack.stackSize == 0) {
sourceSlot.putStack((ItemStack) null);
} else {
sourceSlot.onPickupFromSlot(player, sourceItemStack);
}
if (IC2.platform.isSimulating()) {
this.detectAndSendChanges();
}
}
}
return null;
}
private static final boolean isValidTargetSlot(
final Slot slot,
final ItemStack stack,
final boolean allowEmpty,
final boolean requireInputOnly
) {
return !(slot instanceof SlotInvSlotReadOnly)
&& !(slot instanceof SlotHologramSlot) && slot.isItemValid(stack)
&& (allowEmpty || slot.getHasStack())
&& (!requireInputOnly
|| (slot instanceof SlotInvSlot && ((SlotInvSlot) slot).invSlot.canInput()
));
}
public boolean canInteractWith(final EntityPlayer entityplayer) {
return this.base.isUseableByPlayer(entityplayer);
}
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (this.base instanceof TileEntity) {
for (final String name : this.getNetworkedFields()) {
for (final Object crafter : this.crafters) {
if (crafter instanceof EntityPlayerMP) {
IC2.network.get().updateTileEntityFieldTo(
(TileEntity) this.base, name, (EntityPlayerMP) crafter
);
}
}
}
if (this.base instanceof TileEntityBlock) {
for (final Map.Entry<String, TileEntityComponent> entry :
((TileEntityBlock) this.base).getNamedComponents()) {
for (final Object crafter : this.crafters) {
if (crafter instanceof EntityPlayerMP) {
entry.getValue().onContainerUpdate(
entry.getKey(), (EntityPlayerMP) crafter
);
}
}
}
}
}
}
public List<String> getNetworkedFields() {
return new ArrayList<String>();
}
public List<ICrafting> getCrafters() {
return this.crafters;
}
public void setField(final String fieldName, final Object value) {
ReflectionUtil.setValueRecursive(this, fieldName, value);
IC2.network.get().sendContainerField(this, fieldName);
}
public void onContainerEvent(final String event) {}
private void transfer(final ItemStack stack, final Slot dst) {
final int amount = this.getTransferAmount(stack, dst);
if (amount <= 0) {
return;
}
final ItemStack dstStack = dst.getStack();
if (dstStack == null) {
dst.putStack(StackUtil.copyWithSize(stack, amount));
} else {
final ItemStack itemStack = dstStack;
itemStack.stackSize += amount;
}
stack.stackSize -= amount;
dst.onSlotChanged();
}
private int getTransferAmount(final ItemStack stack, final Slot dst) {
int amount
= Math.min(dst.inventory.getInventoryStackLimit(), dst.getSlotStackLimit());
amount = Math.min(amount, stack.isStackable() ? stack.getMaxStackSize() : 1);
final ItemStack dstStack = dst.getStack();
if (dstStack != null && !StackUtil.isStackEqualStrict(stack, dstStack)) {
return 0;
}
if (dstStack != null) {
amount -= dstStack.stackSize;
}
amount = Math.min(amount, stack.stackSize);
return amount;
}
}

View file

@ -0,0 +1,22 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.core;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
public abstract class ContainerFullInv<T extends IInventory> extends ContainerBase<T> {
public ContainerFullInv(final EntityPlayer player, final T base, final int height) {
super(base);
this.addPlayerInventorySlots(player, height);
}
public ContainerFullInv(
final EntityPlayer player, final T base, final int width, final int height
) {
super(base);
this.addPlayerInventorySlots(player, width, height);
}
}

View file

@ -0,0 +1,52 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.core;
import net.minecraft.item.Item;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.creativetab.CreativeTabs;
public class CreativeTabIC2 extends CreativeTabs {
private static ItemStack laser;
private static ItemStack a;
private static ItemStack b;
private static ItemStack z;
private int ticker;
public CreativeTabIC2() {
super("IC2");
}
public ItemStack getIconItemStack() {
if (CreativeTabIC2.laser == null) {
CreativeTabIC2.laser = Ic2Items.miningLaser.copy();
}
if (IC2.seasonal) {
if (CreativeTabIC2.a == null) {
CreativeTabIC2.a = new ItemStack(Items.skull, 1, 2);
}
if (CreativeTabIC2.b == null) {
CreativeTabIC2.b = new ItemStack(Items.skull, 1, 0);
}
if (CreativeTabIC2.z == null) {
CreativeTabIC2.z = Ic2Items.nanoBodyarmor.copy();
}
if (++this.ticker >= 5000) {
this.ticker = 0;
}
return (this.ticker < 2500)
? CreativeTabIC2.laser
: ((this.ticker < 3000)
? CreativeTabIC2.a
: ((this.ticker < 4500) ? CreativeTabIC2.b : CreativeTabIC2.z));
}
return CreativeTabIC2.laser;
}
public Item getTabIconItem() {
return null;
}
}

View file

@ -0,0 +1,655 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.core;
import net.minecraft.world.IBlockAccess;
import net.minecraft.init.Blocks;
import ic2.api.tile.ExplosionWhitelist;
import net.minecraft.block.Block;
import java.util.Iterator;
import ic2.core.util.StackUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import ic2.core.util.ItemStackWrapper;
import java.util.Map;
import java.util.HashMap;
import ic2.core.network.NetworkManager;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.Potion;
import ic2.core.item.armor.ItemArmorHazmat;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import java.util.Collections;
import java.util.Comparator;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.util.AxisAlignedBB;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.common.MinecraftForge;
import ic2.api.event.ExplosionEvent;
import ic2.core.util.Util;
import java.util.ArrayList;
import net.minecraft.entity.Entity;
import net.minecraft.world.ChunkCache;
import java.util.List;
import net.minecraft.util.DamageSource;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.world.World;
import java.util.Random;
import net.minecraft.world.Explosion;
public class ExplosionIC2 extends Explosion {
private final Random ExplosionRNG;
private final World worldObj;
private final int mapHeight;
private final float power;
private final float explosionDropRate;
private final Type type;
private final int radiationRange;
private final EntityLivingBase igniter;
private final double maxDistance;
private final int areaSize;
private final int areaX;
private final int areaZ;
private final DamageSource damageSource;
private final List<EntityDamage> entitiesInRange;
private final long[][] destroyedBlockPositions;
private ChunkCache chunkCache;
private static final double dropPowerLimit = 8.0;
private static final double damageAtDropPowerLimit = 32.0;
private static final double accelerationAtDropPowerLimit = 0.7;
private static final double motionLimit = 60.0;
private static final int secondaryRayCount = 5;
private static final int bitSetElementSize = 2;
public ExplosionIC2(
final World world,
final Entity entity,
final double x,
final double y,
final double z,
final float power1,
final float drop
) {
this(world, entity, x, y, z, power1, drop, Type.Normal);
}
public ExplosionIC2(
final World world,
final Entity entity,
final double x,
final double y,
final double z,
final float power1,
final float drop,
final Type type1
) {
this(world, entity, x, y, z, power1, drop, type1, null, 0);
}
public ExplosionIC2(
final World world,
final Entity entity,
final double x,
final double y,
final double z,
final float power1,
final float drop,
final Type type1,
final EntityLivingBase igniter1,
final int radiationRange1
) {
super(world, entity, x, y, z, power1);
this.ExplosionRNG = new Random();
this.entitiesInRange = new ArrayList<EntityDamage>();
this.worldObj = world;
this.mapHeight = IC2.getWorldHeight(world);
this.exploder = entity;
this.power = power1;
this.explosionDropRate = drop;
this.explosionX = x;
this.explosionY = y;
this.explosionZ = z;
this.type = type1;
this.igniter = igniter1;
this.radiationRange = radiationRange1;
this.maxDistance = this.power / 0.4;
final int maxDistanceInt = (int) Math.ceil(this.maxDistance);
this.areaSize = maxDistanceInt * 2;
this.areaX = Util.roundToNegInf(this.explosionX) - maxDistanceInt;
this.areaZ = Util.roundToNegInf(this.explosionZ) - maxDistanceInt;
if (this.isNuclear()) {
this.damageSource = IC2DamageSource.getNukeSource(this);
} else {
this.damageSource = DamageSource.setExplosionSource((Explosion) this);
}
this.destroyedBlockPositions = new long[this.mapHeight][];
}
@SuppressWarnings("unchecked")
public void doExplosion() {
if (this.power <= 0.0f) {
return;
}
final ExplosionEvent event = new ExplosionEvent(
this.worldObj,
this.exploder,
this.explosionX,
this.explosionY,
this.explosionZ,
this.power,
this.igniter,
this.radiationRange,
this.maxDistance
);
if (MinecraftForge.EVENT_BUS.post((Event) event)) {
return;
}
this.chunkCache = new ChunkCache(
this.worldObj,
(int) this.explosionX - this.areaSize / 2,
(int) this.explosionY - this.areaSize / 2,
(int) this.explosionZ - this.areaSize / 2,
(int) this.explosionX + this.areaSize / 2,
(int) this.explosionY + this.areaSize / 2,
(int) this.explosionZ + this.areaSize / 2,
0
);
final List<Entity> entities = this.worldObj.getEntitiesWithinAABBExcludingEntity(
(Entity) null,
AxisAlignedBB.getBoundingBox(
this.explosionX - this.maxDistance,
this.explosionY - this.maxDistance,
this.explosionZ - this.maxDistance,
this.explosionX + this.maxDistance,
this.explosionY + this.maxDistance,
this.explosionZ + this.maxDistance
)
);
for (final Entity entity : entities) {
if (entity instanceof EntityLivingBase || entity instanceof EntityItem) {
final int distance = (int) (Util.square(entity.posX - this.explosionX)
+ Util.square(entity.posY - this.explosionY)
+ Util.square(entity.posZ - this.explosionZ));
final double health = getEntityHealth(entity);
this.entitiesInRange.add(new EntityDamage(entity, distance, health));
}
}
final boolean entitiesAreInRange = !this.entitiesInRange.isEmpty();
if (entitiesAreInRange) {
Collections.sort(this.entitiesInRange, new Comparator<EntityDamage>() {
@Override
public int compare(final EntityDamage a, final EntityDamage b) {
return a.distance - b.distance;
}
});
}
for (int steps
= (int) Math.ceil(3.141592653589793 / Math.atan(1.0 / this.maxDistance)),
phi_n = 0;
phi_n < 2 * steps;
++phi_n) {
for (int theta_n = 0; theta_n < steps; ++theta_n) {
final double phi = 6.283185307179586 / steps * phi_n;
final double theta = 3.141592653589793 / steps * theta_n;
this.shootRay(
this.explosionX,
this.explosionY,
this.explosionZ,
phi,
theta,
this.power,
entitiesAreInRange && phi_n % 8 == 0 && theta_n % 8 == 0
);
}
}
for (final EntityDamage entry : this.entitiesInRange) {
final Entity entity2 = entry.entity;
entity2.attackEntityFrom(this.damageSource, (float) entry.damage);
if (entity2 instanceof EntityPlayer) {
final EntityPlayer entityPlayer = (EntityPlayer) entity2;
if (this.isNuclear() && this.igniter != null
&& entityPlayer == this.igniter && entityPlayer.getHealth() <= 0.0f) {
IC2.achievements.issueAchievement(entityPlayer, "dieFromOwnNuke");
}
}
final double motionSq = Util.square(entry.motionX)
+ Util.square(entity2.motionY) + Util.square(entity2.motionZ);
final double reduction
= (motionSq > 3600.0) ? Math.sqrt(3600.0 / motionSq) : 1.0;
final Entity entity4 = entity2;
entity4.motionX += entry.motionX * reduction;
final Entity entity5 = entity2;
entity5.motionY += entry.motionY * reduction;
final Entity entity6 = entity2;
entity6.motionZ += entry.motionZ * reduction;
}
if (this.isNuclear() && this.radiationRange >= 1) {
for (final EntityLiving entity3 :
(List<EntityLiving>) this.worldObj.getEntitiesWithinAABB(
EntityLiving.class,
AxisAlignedBB.getBoundingBox(
this.explosionX - this.radiationRange,
this.explosionY - this.radiationRange,
this.explosionZ - this.radiationRange,
this.explosionX + this.radiationRange,
this.explosionY + this.radiationRange,
this.explosionZ + this.radiationRange
)
)) {
if (ItemArmorHazmat.hasCompleteHazmat((EntityLivingBase) entity3)) {
continue;
}
final double distance2 = entity3.getDistance(
this.explosionX, this.explosionY, this.explosionZ
);
final int hungerLength
= (int) (120.0 * (this.radiationRange - distance2));
final int poisonLength
= (int) (80.0 * (this.radiationRange / 3 - distance2));
if (hungerLength >= 0) {
entity3.addPotionEffect(
new PotionEffect(Potion.hunger.id, hungerLength, 0)
);
}
if (poisonLength < 0) {
continue;
}
IC2Potion.radiation.applyTo((EntityLivingBase) entity3, poisonLength, 0);
}
}
IC2.network.get().initiateExplosionEffect(
this.worldObj, this.explosionX, this.explosionY, this.explosionZ
);
final Random rng = this.worldObj.rand;
final boolean doDrops
= this.worldObj.getGameRules().getGameRuleBooleanValue("doTileDrops");
final Map<XZposition, Map<ItemStackWrapper, DropData>> blocksToDrop
= new HashMap<XZposition, Map<ItemStackWrapper, DropData>>();
this.worldObj.playSoundEffect(
this.explosionX,
this.explosionY,
this.explosionZ,
"random.explode",
4.0f,
(1.0f + (rng.nextFloat() - rng.nextFloat()) * 0.2f) * 0.7f
);
for (int y = 0; y < this.destroyedBlockPositions.length; ++y) {
final long[] bitSet = this.destroyedBlockPositions[y];
if (bitSet != null) {
int index = -2;
while ((index = nextSetIndex(index + 2, bitSet, 2)) != -1) {
final int realIndex = index / 2;
int z = realIndex / this.areaSize;
int x = realIndex - z * this.areaSize;
x += this.areaX;
z += this.areaZ;
final Block block = this.chunkCache.getBlock(x, y, z);
if (this.power < 20.0f) {
final double effectX = x + rng.nextFloat();
final double effectY = y + rng.nextFloat();
final double effectZ = z + rng.nextFloat();
double d3 = effectX - this.explosionX;
double d4 = effectY - this.explosionY;
double d5 = effectZ - this.explosionZ;
final double effectDistance
= MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
d3 /= effectDistance;
d4 /= effectDistance;
d5 /= effectDistance;
double d6 = 0.5 / (effectDistance / this.power + 0.1);
d6 *= rng.nextFloat() * rng.nextFloat() + 0.3f;
d3 *= d6;
d4 *= d6;
d5 *= d6;
this.worldObj.spawnParticle(
"explode",
(effectX + this.explosionX) / 2.0,
(effectY + this.explosionY) / 2.0,
(effectZ + this.explosionZ) / 2.0,
d3,
d4,
d5
);
this.worldObj.spawnParticle(
"smoke", effectX, effectY, effectZ, d3, d4, d5
);
}
if (doDrops && getAtIndex(index, bitSet, 2) == 1) {
final int meta = this.chunkCache.getBlockMetadata(x, y, z);
for (final ItemStack itemStack :
block.getDrops(this.worldObj, x, y, z, meta, 0)) {
if (rng.nextFloat() <= this.explosionDropRate) {
final XZposition xZposition
= new XZposition(x / 2, z / 2);
if (!blocksToDrop.containsKey(xZposition)) {
blocksToDrop.put(
xZposition,
new HashMap<ItemStackWrapper, DropData>()
);
}
final Map<ItemStackWrapper, DropData> map
= blocksToDrop.get(xZposition);
final ItemStackWrapper isw
= new ItemStackWrapper(itemStack);
if (!map.containsKey(isw)) {
map.put(isw, new DropData(itemStack.stackSize, y));
} else {
map.put(
isw, map.get(isw).add(itemStack.stackSize, y)
);
}
}
}
}
this.worldObj.setBlockToAir(x, y, z);
block.onBlockDestroyedByExplosion(
this.worldObj, x, y, z, (Explosion) this
);
}
}
}
for (final Map.Entry<XZposition, Map<ItemStackWrapper, DropData>> entry2 :
blocksToDrop.entrySet()) {
final XZposition xZposition2 = entry2.getKey();
for (final Map.Entry<ItemStackWrapper, DropData> entry3 :
entry2.getValue().entrySet()) {
final ItemStackWrapper isw2 = entry3.getKey();
int stackSize;
for (int count = entry3.getValue().n; count > 0; count -= stackSize) {
stackSize = Math.min(count, 64);
final EntityItem entityitem = new EntityItem(
this.worldObj,
(xZposition2.x + this.worldObj.rand.nextFloat()) * 2.0,
entry3.getValue().maxY + 0.5,
(xZposition2.z + this.worldObj.rand.nextFloat()) * 2.0,
StackUtil.copyWithSize(isw2.stack, stackSize)
);
entityitem.delayBeforeCanPickup = 10;
this.worldObj.spawnEntityInWorld((Entity) entityitem);
}
}
}
}
public void destroy(final int x, final int y, final int z, final boolean noDrop) {
this.destroyUnchecked(x, y, z, noDrop);
}
private void
destroyUnchecked(final int x, final int y, final int z, final boolean noDrop) {
int index = (z - this.areaZ) * this.areaSize + (x - this.areaX);
index *= 2;
long[] array = this.destroyedBlockPositions[y];
if (array == null) {
array = makeArray(Util.square(this.areaSize), 2);
this.destroyedBlockPositions[y] = array;
}
if (noDrop) {
setAtIndex(index, array, 3);
} else {
setAtIndex(index, array, 1);
}
}
private void shootRay(
double x,
double y,
double z,
final double phi,
final double theta,
double power1,
final boolean killEntities
) {
final double deltaX = Math.sin(theta) * Math.cos(phi);
final double deltaY = Math.cos(theta);
final double deltaZ = Math.sin(theta) * Math.sin(phi);
int step = 0;
while (true) {
final int blockY = Util.roundToNegInf(y);
if (blockY < 0) {
break;
}
if (blockY >= this.mapHeight) {
break;
}
final int blockX = Util.roundToNegInf(x);
final int blockZ = Util.roundToNegInf(z);
final Block block = this.chunkCache.getBlock(blockX, blockY, blockZ);
double absorption = this.getAbsorption(block, blockX, blockY, blockZ);
if (absorption > 1000.0 && !ExplosionWhitelist.isBlockWhitelisted(block)) {
absorption = 0.5;
} else {
if (absorption > power1) {
break;
}
if (block == Blocks.stone
|| (block != Blocks.air
&& !block.isAir(
(IBlockAccess) this.worldObj, blockX, blockY, blockZ
))) {
this.destroyUnchecked(blockX, blockY, blockZ, power1 > 8.0);
}
}
if (killEntities && (step + 4) % 8 == 0 && !this.entitiesInRange.isEmpty()
&& power1 >= 0.25) {
this.damageEntities(x, y, z, step, power1);
}
if (absorption > 10.0) {
for (int i = 0; i < 5; ++i) {
this.shootRay(
x,
y,
z,
this.ExplosionRNG.nextDouble() * 2.0 * 3.141592653589793,
this.ExplosionRNG.nextDouble() * 3.141592653589793,
absorption * 0.4,
false
);
}
}
power1 -= absorption;
x += deltaX;
y += deltaY;
z += deltaZ;
++step;
}
}
private double
getAbsorption(final Block block, final int x, final int y, final int z) {
double ret = 0.5;
if (block == Blocks.air || block.isAir((IBlockAccess) this.worldObj, x, y, z)) {
return ret;
}
if ((block == Blocks.water || block == Blocks.flowing_water)
&& this.type != Type.Normal) {
++ret;
} else {
final double extra = (block.getExplosionResistance(
this.exploder,
this.worldObj,
x,
y,
z,
this.explosionX,
this.explosionY,
this.explosionZ
)
+ 4.0f)
* 0.3;
if (this.type != Type.Heat) {
ret += extra;
} else {
ret += extra * 6.0;
}
}
return ret;
}
private void damageEntities(
final double x, final double y, final double z, final int step, final double power
) {
int index;
if (step != 4) {
final int distanceMin = Util.square(step - 5);
int indexStart = 0;
int indexEnd = this.entitiesInRange.size() - 1;
do {
index = (indexStart + indexEnd) / 2;
final int distance = this.entitiesInRange.get(index).distance;
if (distance < distanceMin) {
indexStart = index + 1;
} else if (distance > distanceMin) {
indexEnd = index - 1;
} else {
indexEnd = index;
}
} while (indexStart < indexEnd);
} else {
index = 0;
}
final int distanceMax = Util.square(step + 5);
for (int i = index; i < this.entitiesInRange.size(); ++i) {
final EntityDamage entry = this.entitiesInRange.get(i);
if (entry.distance >= distanceMax) {
break;
}
final Entity entity = entry.entity;
if (Util.square(entity.posX - x) + Util.square(entity.posY - y)
+ Util.square(entity.posZ - z)
<= 25.0) {
final double damage = 4.0 * power;
final EntityDamage entityDamage = entry;
entityDamage.damage += damage;
final EntityDamage entityDamage2 = entry;
entityDamage2.health -= damage;
final double dx = entity.posX - this.explosionX;
final double dy = entity.posY - this.explosionY;
final double dz = entity.posZ - this.explosionZ;
final double distance2 = Math.sqrt(dx * dx + dy * dy + dz * dz);
final EntityDamage entityDamage3 = entry;
entityDamage3.motionX += dx / distance2 * 0.0875 * power;
final EntityDamage entityDamage4 = entry;
entityDamage4.motionY += dy / distance2 * 0.0875 * power;
final EntityDamage entityDamage5 = entry;
entityDamage5.motionZ += dz / distance2 * 0.0875 * power;
if (entry.health <= 0.0) {
entity.attackEntityFrom(this.damageSource, (float) entry.damage);
if (!entity.isEntityAlive()) {
this.entitiesInRange.remove(i);
--i;
}
}
}
}
}
public EntityLivingBase getExplosivePlacedBy() {
return this.igniter;
}
private boolean isNuclear() {
return this.type == Type.Nuclear;
}
private static double getEntityHealth(final Entity entity) {
if (entity instanceof EntityItem) {
return 5.0;
}
return Double.POSITIVE_INFINITY;
}
private static long[] makeArray(final int size, final int step) {
return new long[(size * step + 8 - step) / 8];
}
private static int nextSetIndex(final int start, final long[] array, final int step) {
int offset = start % 8;
for (int i = start / 8; i < array.length; ++i) {
final long aval = array[i];
for (int j = offset; j < 8; j += step) {
final int val = (int) (aval >> j & (long) ((1 << step) - 1));
if (val != 0) {
return i * 8 + j;
}
}
offset = 0;
}
return -1;
}
private static int getAtIndex(final int index, final long[] array, final int step) {
return (int) (array[index / 8] >>> index % 8 & (long) ((1 << step) - 1));
}
private static void setAtIndex(final int index, final long[] array, final int value) {
final int n = index / 8;
array[n] |= value << index % 8;
}
private static class XZposition {
int x;
int z;
XZposition(final int x1, final int z1) {
this.x = x1;
this.z = z1;
}
@Override
public boolean equals(final Object obj) {
if (obj instanceof XZposition) {
final XZposition xZposition = (XZposition) obj;
return xZposition.x == this.x && xZposition.z == this.z;
}
return false;
}
@Override
public int hashCode() {
return this.x * 31 ^ this.z;
}
}
private static class DropData {
int n;
int maxY;
DropData(final int n1, final int y) {
this.n = n1;
this.maxY = y;
}
public DropData add(final int n1, final int y) {
this.n += n1;
if (y > this.maxY) {
this.maxY = y;
}
return this;
}
}
public enum Type {
Normal,
Heat,
Nuclear;
}
private static class EntityDamage {
final Entity entity;
final int distance;
double health;
double damage;
double motionX;
double motionY;
double motionZ;
EntityDamage(final Entity entity, final int distance, final double health) {
this.entity = entity;
this.distance = distance;
this.health = health;
}
}
}

View file

@ -0,0 +1,62 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.core;
import java.util.Iterator;
import net.minecraftforge.fluids.FluidRegistry;
import java.util.HashSet;
import java.util.Set;
import net.minecraftforge.fluids.Fluid;
import java.util.HashMap;
import java.util.Map;
import ic2.api.recipe.IFluidHeatManager;
public class FluidHeatManager implements IFluidHeatManager {
private final Map<String, BurnProperty> burnProperties;
public FluidHeatManager() {
this.burnProperties = new HashMap<String, BurnProperty>();
}
@Override
public void addFluid(final String fluidName, final int amount, final int heat) {
if (this.burnProperties.containsKey(fluidName)) {
throw new RuntimeException(
"The fluid " + fluidName + " does already have a burn property assigned."
);
}
this.burnProperties.put(fluidName, new BurnProperty(amount, heat));
}
@Override
public BurnProperty getBurnProperty(final Fluid fluid) {
if (fluid == null) {
return null;
}
return this.burnProperties.get(fluid.getName());
}
@Override
public boolean acceptsFluid(final Fluid fluid) {
return this.burnProperties.containsKey(fluid.getName());
}
@Override
public Set<Fluid> getAcceptedFluids() {
final Set<Fluid> ret = new HashSet<Fluid>();
for (final String fluidName : this.burnProperties.keySet()) {
final Fluid fluid = FluidRegistry.getFluid(fluidName);
if (fluid != null) {
ret.add(fluid);
}
}
return ret;
}
@Override
public Map<String, BurnProperty> getBurnProperties() {
return this.burnProperties;
}
}

View file

@ -0,0 +1,82 @@
//
// Decompiled by Procyon v0.6.0
//
package ic2.core;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import ic2.core.util.GuiTooltipHelper;
import ic2.core.upgrade.IUpgradableBlock;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.client.gui.inventory.GuiContainer;
public abstract class GuiIC2 extends GuiContainer {
public ContainerBase<? extends IInventory> container;
protected int xoffset;
protected int yoffset;
public GuiIC2(final ContainerBase<? extends IInventory> container) {
this(container, 176, 166);
}
public GuiIC2(final ContainerBase<? extends IInventory> container, final int ySize) {
this(container, 176, ySize);
}
public GuiIC2(
final ContainerBase<? extends IInventory> container,
final int xSize,
final int ySize
) {
super((Container) container);
this.container = container;
this.ySize = ySize;
this.xSize = xSize;
}
protected void drawGuiContainerForegroundLayer(final int par1, final int par2) {
this.fontRendererObj.drawString(
this.getName(),
(this.xSize - this.fontRendererObj.getStringWidth(this.getName())) / 2,
6,
4210752
);
if (this.container.base instanceof IUpgradableBlock) {
GuiTooltipHelper.drawUpgradeslotTooltip(
par1 - this.guiLeft,
par2 - this.guiTop,
0,
0,
12,
12,
(IUpgradableBlock) this.container.base,
25,
0
);
}
}
protected void
drawGuiContainerBackgroundLayer(final float f, final int x, final int y) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
this.mc.getTextureManager().bindTexture(this.getResourceLocation());
this.xoffset = (this.width - this.xSize) / 2;
this.yoffset = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(
this.xoffset, this.yoffset, 0, 0, this.xSize, this.ySize
);
if (this.container.base instanceof IUpgradableBlock) {
this.mc.getTextureManager().bindTexture(
new ResourceLocation(IC2.textureDomain, "textures/gui/infobutton.png")
);
this.drawTexturedModalRect(this.xoffset + 3, this.yoffset + 3, 0, 0, 10, 10);
this.mc.getTextureManager().bindTexture(this.getResourceLocation());
}
}
public abstract String getName();
public abstract ResourceLocation getResourceLocation();
}

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