This commit is contained in:
LordMZTE 2023-06-16 22:17:05 +02:00
parent a30785fd4a
commit 33a3a6f3b3
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
153 changed files with 8546 additions and 103 deletions

130
.clang-format Normal file
View file

@ -0,0 +1,130 @@
---
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
JavaImportGroups: ["java"]
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: CaseInsensitive
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"]

5
.gitignore vendored
View file

@ -1,4 +1,9 @@
.classpath
.eclipse
.gradle
.idea
.project
.settings
bin
build
run

View file

@ -11,21 +11,21 @@ buildscript {
}
}
dependencies {
classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.0.+') {
classpath ("com.anatawa12.forge:ForgeGradle:1.2-1.0.+") {
changing = true
}
}
}
apply plugin: 'forge'
apply plugin: 'maven-publish'
apply plugin: "forge"
apply plugin: "maven-publish"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
version = "1.0"
group= "modgroup"
archivesBaseName = "modid"
group = "covers1624"
archivesBaseName = "powerconverters"
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
@ -34,33 +34,54 @@ minecraft {
repositories {
maven { url = "https://maven.tilera.xyz" }
maven {
url = "https://s3.tilera.xyz/cdn/minecraft/libs/"
metadataSources { artifact() }
}
maven {
name = "ic2"
url = "https://maven.ic2.player.to/"
metadataSources { artifact() }
}
maven {
name "central"
url "https://maven.thorfusion.com/artifactory/central/"
}
}
dependencies {
implementation "cofh:CoFHCore:[1.7.10]3.1.4-329:dev"
implementation "net.industrial-craft:industrialcraft-2:2.2.660-experimental:dev"
implementation "mods:Factorization:1.7.10-0.8.109:deobf"
implementation "mcp.mobius.waila:Waila:1.5.10_1.7.10:dev"
implementation "codechicken:CodeChickenLib:1.7.10-1.1.3.141:dev"
implementation "codechicken:NotEnoughItems:1.7.10-1.0.5.120:dev"
implementation "codechicken:CodeChickenCore:1.7.10-1.0.7.48:dev"
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
filesMatching('mcmod.info') {
expand 'version':project.version, 'mcversion':project.minecraft.version
filesMatching("mcmod.info") {
expand "version":project.version, "mcversion":project.minecraft.version
}
}
task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = 'deobf'
classifier = "deobf"
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
classifier = "sources"
}
publishing {
tasks.publish.dependsOn 'build'
tasks.publish.dependsOn "build"
publications {
mavenJava(MavenPublication) {
artifactId = project.archivesBaseName
@ -72,7 +93,7 @@ publishing {
}
repositories {
if (project.hasProperty('mvnURL')) {
if (project.hasProperty("mvnURL")) {
maven {
credentials {
username findProperty("mvnUsername")
@ -85,4 +106,4 @@ publishing {
mavenLocal()
}
}
}
}

90
gradlew.bat vendored
View file

@ -1,90 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View file

@ -0,0 +1,232 @@
package covers1624.powerconverters;
import java.util.Iterator;
import java.util.Set;
import covers1624.powerconverters.grid.GridTickHandler;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.handler.PCEventHandler;
import covers1624.powerconverters.handler.PCGUIHandler;
import covers1624.powerconverters.init.ModBlocks;
import covers1624.powerconverters.init.ModItems;
import covers1624.powerconverters.init.PowerSystems;
import covers1624.powerconverters.init.Recipes;
import covers1624.powerconverters.init.WorldGenerators;
import covers1624.powerconverters.net.EnergyBridgeSyncPacket;
import covers1624.powerconverters.net.PacketPipeline;
import covers1624.powerconverters.net.RecipeSyncPacket;
import covers1624.powerconverters.proxy.IPCProxy;
import covers1624.powerconverters.updatechecker.UpdateManager;
import covers1624.powerconverters.util.LogHelper;
import covers1624.powerconverters.util.RFHelper;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry.Type;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.item.Item;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fluids.FluidRegistry;
@Mod(
modid = "PowerConverters3",
name = "Power Converters 3",
version = "1.7.10-2.11",
dependencies
= "after:BuildCraft|Energy;after:factorization;after:IC2;after:Railcraft;after:ThermalExpansion",
guiFactory = "covers1624.powerconverters.gui.PCGuiFactory"
)
public class PowerConverters {
@SidedProxy(
clientSide = "covers1624.powerconverters.proxy.ProxyClient",
serverSide = "covers1624.powerconverters.proxy.ProxyServer"
)
public static IPCProxy proxy;
@Instance("Power Converters")
public static PowerConverters instance;
private static ConfigurationHandler configHandler;
public static int steamId = -1;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
checkClassLoader();
instance = this;
LogHelper.info("PowerConverters PreInitialization Started.");
LogHelper.trace("Checking For RF API...");
RFHelper.init();
LogHelper.trace("Initializing Configuration File");
configHandler = new ConfigurationHandler(event.getSuggestedConfigurationFile());
LogHelper.trace("Registering Update Manager");
UpdateManager updateManager = new UpdateManager();
FMLCommonHandler.instance().bus().register(updateManager);
LogHelper.trace("Registering Event Handlers.");
PCEventHandler eventHandler = new PCEventHandler();
MinecraftForge.EVENT_BUS.register(eventHandler);
FMLCommonHandler.instance().bus().register(eventHandler);
LogHelper.trace("Initializing PowerSystems");
PowerSystems.init();
LogHelper.trace("Initializing ChargeHandlers");
PowerSystems.initChargeHandlers();
LogHelper.info("PowerConverters PreInitialization Finished.");
}
@EventHandler
public void init(FMLInitializationEvent event) {
LogHelper.info("PowerConverters Core Initialization Started.");
LogHelper.trace("Initializing PacketPipeline");
PacketPipeline.INSTANCE.initalise();
PacketPipeline.INSTANCE.registerPacket(RecipeSyncPacket.class);
PacketPipeline.INSTANCE.registerPacket(EnergyBridgeSyncPacket.class);
MinecraftForge.EVENT_BUS.register(GridTickHandler.energy);
FMLCommonHandler.instance().bus().register(GridTickHandler.energy);
LogHelper.trace("Registering Gui Handler.");
NetworkRegistry.INSTANCE.registerGuiHandler(this, new PCGUIHandler());
LogHelper.trace("Registering Blocks.");
ModBlocks.init();
LogHelper.trace("Registering Items.");
ModItems.init();
LogHelper.trace("Registering World Generators.");
WorldGenerators.init();
LogHelper.trace("Registering Client Rendering.");
proxy.initRendering();
if (!ConfigurationHandler.useTechRebornRecipes
&& !ConfigurationHandler.useThermalExpansionRecipes) {
LogHelper.trace("Registering Default Recipes.");
Recipes.initDefaults();
}
Recipes.setDefaultRecipes(Recipes.getCurrentRecipes());
if (Loader.isModLoaded("Waila")) {
LogHelper.trace("Regestering Waila Module.");
FMLInterModComms.sendMessage(
"Waila",
"register",
"covers1624.powerconverters.waila.WailaModule.callBackRegister"
);
}
LogHelper.info("PowerConverters Core Initialization Finished.");
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
LogHelper.info("PowerConverters PostInitialization Started.");
LogHelper.trace(
"PostInitializing PacketPipeline. ALL PACKETS SHOULD BE REGISTERED BY NOW!"
);
PacketPipeline.INSTANCE.postInitialise();
if (FluidRegistry.isFluidRegistered("steam")) {
steamId = FluidRegistry.getFluidID("steam");
}
LogHelper.trace("PowerConverters PostInitialization Finished.");
}
@EventHandler
public void missingMapping(FMLMissingMappingsEvent event) {
Iterator i$ = event.getAll().iterator();
while (i$.hasNext()) {
FMLMissingMappingsEvent.MissingMapping mapping
= (FMLMissingMappingsEvent.MissingMapping) i$.next();
if (mapping.type == Type.BLOCK) {
if (mapping.name.equals("PowerConverters:tile.powerconverters.conduit")) {
LogHelper.warn("REMAPPING BLOCK: " + mapping.name);
mapping.remap(ModBlocks.conduitBlock);
}
if (mapping.name.equals("PowerConverters:tile.powerconverters.rf")) {
LogHelper.warn("REMAPPING BLOCK: " + mapping.name);
mapping.remap(ModBlocks.converterBlockRedstoneFlux);
}
if (mapping.name.equals("PowerConverters:tile.powerconverters.ic2")) {
LogHelper.warn("REMAPPING BLOCK: " + mapping.name);
mapping.remap(ModBlocks.converterBlockIndustrialCraft);
}
if (mapping.name.equals("PowerConverters:tile.powerconverters.fz")) {
LogHelper.warn("REMAPPING BLOCK: " + mapping.name);
mapping.remap(ModBlocks.converterBlockFactorization);
}
if (mapping.name.equals("PowerConverters:tile.powerconverters.steam")) {
LogHelper.warn("REMAPPING BLOCK: " + mapping.name);
mapping.remap(ModBlocks.converterBlockSteam);
}
if (mapping.name.equals("PowerConverters:tile.powerconverters.common")) {
LogHelper.warn("REMAPPING BLOCK: " + mapping.name);
mapping.remap(ModBlocks.converterBlockCommon);
}
}
if (mapping.type == Type.ITEM) {
if (mapping.name.equals("PowerConverters:debugItem")) {
LogHelper.warn("REMAPPING ITEM: " + mapping.name);
mapping.remap(ModItems.debugItem);
}
if (mapping.name.equals("PowerConverters:tile.powerconverters.conduit")) {
LogHelper.warn("REMAPPING ITEM: " + mapping.name);
mapping.remap(Item.getItemFromBlock(ModBlocks.conduitBlock));
}
if (mapping.name.equals("PowerConverters:tile.powerconverters.rf")) {
LogHelper.warn("REMAPPING ITEM: " + mapping.name);
mapping.remap(
Item.getItemFromBlock(ModBlocks.converterBlockRedstoneFlux)
);
}
if (mapping.name.equals("PowerConverters:tile.powerconverters.ic2")) {
LogHelper.warn("REMAPPING ITEM: " + mapping.name);
mapping.remap(
Item.getItemFromBlock(ModBlocks.converterBlockIndustrialCraft)
);
}
if (mapping.name.equals("PowerConverters:tile.powerconverters.fz")) {
LogHelper.warn("REMAPPING ITEM: " + mapping.name);
mapping.remap(
Item.getItemFromBlock(ModBlocks.converterBlockFactorization)
);
}
if (mapping.name.equals("PowerConverters:tile.powerconverters.steam")) {
LogHelper.warn("REMAPPING ITEM: " + mapping.name);
mapping.remap(Item.getItemFromBlock(ModBlocks.converterBlockSteam));
}
if (mapping.name.equals("PowerConverters:tile.powerconverters.common")) {
LogHelper.warn("REMAPPING ITEM: " + mapping.name);
mapping.remap(Item.getItemFromBlock(ModBlocks.converterBlockCommon));
}
}
}
}
private static void checkClassLoader() {
Set transformerExceptions = (Set) ReflectionHelper.getPrivateValue(
LaunchClassLoader.class,
Launch.classLoader,
new String[] { "transformerExceptions" }
);
if (!transformerExceptions.contains("covers1624.powerconverters.")) {
LogHelper.fatal(
"PowerConverters has detected that it has been removed from the transformerExceptions list, this could cause unknown issues. I Will provide no support for PowerConverters in this state."
);
}
}
}

View file

@ -0,0 +1,40 @@
package covers1624.powerconverters.api.bridge;
import covers1624.powerconverters.api.registry.PowerSystemRegistry;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class BridgeSideData {
public ForgeDirection side;
public PowerSystemRegistry.PowerSystem powerSystem;
public boolean isConsumer;
public boolean isProducer;
public boolean isConnected;
public int voltageNameIndex;
public double outputRate;
public void writeToNBT(NBTTagCompound tag) {
tag.setInteger("VoltageIndex", this.voltageNameIndex);
tag.setBoolean("IsConsumer", this.isConsumer);
tag.setBoolean("IsProducer", this.isProducer);
if (this.powerSystem != null) {
tag.setInteger("PowerSystem", this.powerSystem.getId());
}
tag.setBoolean("Connected", this.isConnected);
tag.setDouble("OutputRate", this.outputRate);
}
public void loadFromNBT(NBTTagCompound tag) {
this.voltageNameIndex = tag.getInteger("VoltageIndex");
this.isConsumer = tag.getBoolean("IsConsumer");
this.isProducer = tag.getBoolean("IsProducer");
if (tag.hasKey("PowerSystem")) {
this.powerSystem
= PowerSystemRegistry.getPowerSystemById(tag.getInteger("PowerSystem"));
}
this.isConnected = tag.getBoolean("Connected");
this.outputRate = tag.getDouble("OutputRate");
}
}

View file

@ -0,0 +1,18 @@
package covers1624.powerconverters.api.charge;
import covers1624.powerconverters.api.registry.PowerSystemRegistry;
import net.minecraft.item.ItemStack;
public interface IChargeHandler {
PowerSystemRegistry.PowerSystem getPowerSystem();
boolean canHandle(ItemStack var1);
double charge(ItemStack var1, double var2);
double discharge(ItemStack var1, double var2);
boolean isItemCharged(ItemStack var1);
String name();
}

View file

@ -0,0 +1,192 @@
package covers1624.powerconverters.api.registry;
import java.util.HashMap;
import covers1624.powerconverters.util.LogHelper;
import cpw.mods.fml.common.Loader;
public class PowerSystemRegistry {
private static HashMap powerSystems = new HashMap();
private static int nextPowerSystemId = 0;
public static PowerSystem createNewPowerSystem(
String name,
String abbreviation,
int scaleAmmount,
String[] voltageNames,
int[] voltageValues,
String unit
) {
return new PowerSystem(
name, abbreviation, scaleAmmount, voltageNames, voltageValues, unit
);
}
public static void registerPowerSystem(PowerSystem powerSystem) {
registerPowerSystem(powerSystem, nextPowerSystemId, true);
++nextPowerSystemId;
}
public static void
registerPowerSystem(PowerSystem powerSystem, int id, boolean force) {
if (powerSystems.get(id) == null) {
powerSystem.id = id;
powerSystems.put(id, powerSystem);
} else {
LogHelper.trace(
"PowerSystem allready Registered %s and %s is trying to be registered. It is recomended that you let the mod decide what to do here.",
((PowerSystem) powerSystems.get(id)).getName(),
powerSystem.getName()
);
if (force) {
LogHelper.warn(
"Mod %s is forcing that PowerSystem id %s equals %s THIS MAY BREAK ALL FUNCTIONALITY!",
Loader.instance().activeModContainer().getModId(),
String.valueOf(id),
powerSystem.getName()
);
powerSystems.remove(id);
powerSystem.id = id;
powerSystems.put(id, powerSystem);
}
}
}
public static void unregisterPowerSystem(int id) {
if (powerSystems.containsKey(id)) {
LogHelper.warn(
"Someone is trying to remove PowerSystem %s THIS MAY BREAK ALL FUNCTIONALITY!",
((PowerSystem) powerSystems.get(id)).getName()
);
powerSystems.remove(id);
}
}
public static PowerSystem getPowerSystemById(int id) {
return (PowerSystem) powerSystems.get(id);
}
public static class PowerSystem {
private String abbreviation;
private String name;
private int scaleAmmount;
private String[] voltageNames;
private int[] voltageValues;
private String unit;
private int id;
private boolean consumerDissabled;
private boolean producerDissabled;
public PowerSystem(
String name, String abbreviation, int scaleAmmount, String unit
) {
this(name, abbreviation, scaleAmmount, (String[]) null, (int[]) null, unit);
}
public PowerSystem(
String name,
String abbreviation,
int scaleAmmount,
String unit,
boolean consumerDissabled,
boolean producerDissabled
) {
this(
name,
abbreviation,
scaleAmmount,
(String[]) null,
(int[]) null,
unit,
consumerDissabled,
producerDissabled
);
}
public PowerSystem(
String name,
String abbreviation,
int scaleAmmount,
String[] voltageNames,
int[] voltageValues,
String unit
) {
this.consumerDissabled = false;
this.producerDissabled = false;
this.name = name;
this.abbreviation = abbreviation;
this.scaleAmmount = scaleAmmount;
this.voltageNames = voltageNames;
this.voltageValues = voltageValues;
this.unit = unit;
}
public PowerSystem(
String name,
String abbreviation,
int scaleAmmount,
String[] voltageNames,
int[] voltageValues,
String unit,
boolean consumerDissabled,
boolean producerDissabled
) {
this.consumerDissabled = false;
this.producerDissabled = false;
this.name = name;
this.abbreviation = abbreviation;
this.scaleAmmount = scaleAmmount;
this.voltageNames = voltageNames;
this.voltageValues = voltageValues;
this.unit = unit;
this.consumerDissabled = consumerDissabled;
this.producerDissabled = producerDissabled;
}
public String getName() {
return this.name;
}
public String getAbbreviation() {
return this.abbreviation;
}
public String[] getVoltageNames() {
return this.voltageNames;
}
public int[] getVoltageValues() {
return this.voltageValues;
}
public int getScaleAmmount() {
return this.scaleAmmount;
}
public String getUnit() {
return this.unit;
}
public int getId() {
return this.id;
}
public boolean consumerDissabled() {
return this.consumerDissabled;
}
public boolean producerDissabled() {
return this.producerDissabled;
}
public PowerSystem setProducerState(boolean state) {
this.producerDissabled = state;
return this;
}
public PowerSystem setConsumerState(boolean state) {
this.consumerDissabled = state;
return this;
}
}
}

View file

@ -0,0 +1,31 @@
package covers1624.powerconverters.api.registry;
import java.util.ArrayList;
import java.util.List;
import covers1624.powerconverters.api.charge.IChargeHandler;
import covers1624.powerconverters.util.LogHelper;
import cpw.mods.fml.common.Loader;
public class UniversalChargerRegistry {
private static List chargeHandlers = new ArrayList();
public static void registerChargeHandler(IChargeHandler chargeHandler) {
LogHelper.trace(
"Registering ChargeHandler for mod %s with the name of %s.",
Loader.instance().activeModContainer().getModId(),
chargeHandler.name()
);
if (chargeHandlers.contains(chargeHandler)) {
LogHelper.error(
"Failed to register ChargeHandler %s it is already registered."
);
} else {
chargeHandlers.add(chargeHandler);
}
}
public static List getChargeHandlers() {
return chargeHandlers;
}
}

View file

@ -0,0 +1,34 @@
package covers1624.powerconverters.asm;
import java.util.Map;
import covers1624.powerconverters.util.LogHelper;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import net.minecraft.launchwrapper.Launch;
@MCVersion("1.7.10")
public class ASMHandler implements IFMLLoadingPlugin {
public String[] getASMTransformerClass() {
return null;
}
public String getModContainerClass() {
return null;
}
public String getSetupClass() {
return null;
}
public void injectData(Map data) {}
public String getAccessTransformerClass() {
return null;
}
static {
LogHelper.info("Adding PowerConverters to Transformer Exclusions list.");
Launch.classLoader.addTransformerExclusion("covers1624.powerconverters.");
}
}

View file

@ -0,0 +1,48 @@
package covers1624.powerconverters.block;
import covers1624.powerconverters.gui.PCCreativeTab;
import covers1624.powerconverters.tile.main.TileEnergyConduit;
import covers1624.powerconverters.util.IUpdateTileWithCords;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockEnergyConduit extends BlockContainer {
public BlockEnergyConduit() {
super(Material.rock);
this.setBlockName("powerconverters.conduit");
this.setCreativeTab(PCCreativeTab.tab);
}
public boolean renderAsNormalBlock() {
return false;
}
public int getRenderType() {
return 22;
}
public boolean isOpaqueCube() {
return false;
}
public void onNeighborChange(
IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ
) {
TileEntity te = world instanceof World ? world.getTileEntity(x, y, z)
: world.getTileEntity(x, y, z);
if (te instanceof IUpdateTileWithCords) {
((IUpdateTileWithCords) te).onNeighboorChanged(tileX, tileY, tileZ);
}
}
public boolean hasTileEntity(int metadata) {
return true;
}
public TileEntity createNewTileEntity(World world, int par1) {
return new TileEnergyConduit();
}
}

View file

@ -0,0 +1,129 @@
package covers1624.powerconverters.block;
import java.util.Random;
import covers1624.powerconverters.PowerConverters;
import covers1624.powerconverters.item.DebugItem;
import covers1624.powerconverters.net.PacketPipeline;
import covers1624.powerconverters.tile.main.TileEntityBridgeComponent;
import covers1624.powerconverters.tile.main.TileEntityEnergyBridge;
import covers1624.powerconverters.util.INeighboorUpdateTile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockPowerConverter extends BlockContainer {
protected IIcon[] _icons;
protected boolean isGettingRedstone;
public BlockPowerConverter(int metaCount) {
super(Material.iron);
this.setHardness(1.0F);
this._icons = new IIcon[metaCount * 2];
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int offset = ((TileEntityBridgeComponent) world.getTileEntity(x, y, z))
.isSideConnectedClient(side)
? 1
: 0;
return this._icons[world.getBlockMetadata(x, y, z) * 2 + offset];
}
public IIcon getIcon(int side, int metadata) {
return this._icons[metadata * 2];
}
public TileEntity createNewTileEntity(World world, int par1) {
return null;
}
public int damageDropped(int par1) {
return par1;
}
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
this.checkRedstone(world, x, y, z);
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof INeighboorUpdateTile) {
((INeighboorUpdateTile) te).onNeighboorChanged();
world.markBlockForUpdate(x, y, z);
}
}
public boolean onBlockActivated(
World world,
int x,
int y,
int z,
EntityPlayer player,
int par6,
float par7,
float par8,
float par9
) {
try {
if (player.getHeldItem().getItem() instanceof DebugItem) {
return false;
}
} catch (Exception var12) {}
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntityBridgeComponent) {
TileEntityEnergyBridge bridge
= ((TileEntityBridgeComponent) te).getFirstBridge();
if (bridge != null) {
if (!world.isRemote) {
PacketPipeline.INSTANCE.sendTo(
bridge.getNetPacket(), (EntityPlayerMP) player
);
}
player.openGui(
PowerConverters.instance,
0,
world,
bridge.xCoord,
bridge.yCoord,
bridge.zCoord
);
}
}
return true;
}
public boolean
shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) {
return true;
}
public boolean getWeakChanges(IBlockAccess world, int x, int y, int z) {
return true;
}
public void updateTick(World world, int x, int y, int z, Random random) {
this.checkRedstone(world, x, y, z);
}
public boolean isGettingRedstone() {
return this.isGettingRedstone;
}
private void checkRedstone(World world, int x, int y, int z) {
if (world.isBlockIndirectlyGettingPowered(x, y, z)) {
this.isGettingRedstone = true;
} else {
this.isGettingRedstone = false;
}
}
}

View file

@ -0,0 +1,160 @@
package covers1624.powerconverters.block;
import covers1624.powerconverters.PowerConverters;
import covers1624.powerconverters.gui.PCCreativeTab;
import covers1624.powerconverters.item.DebugItem;
import covers1624.powerconverters.tile.main.TileEntityBridgeComponent;
import covers1624.powerconverters.tile.main.TileEntityCharger;
import covers1624.powerconverters.tile.main.TileEntityEnergyBridge;
import covers1624.powerconverters.util.INeighboorUpdateTile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockPowerConverterCommon extends BlockContainer {
private IIcon _iconBridge;
private IIcon _iconChargerOn;
private IIcon _iconChargerOff;
public BlockPowerConverterCommon() {
super(Material.iron);
this.setHardness(1.0F);
this.setBlockName("powerconverters.common");
this.setCreativeTab(PCCreativeTab.tab);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister ir) {
this._iconBridge
= ir.registerIcon("powerconverters:" + this.getUnlocalizedName() + ".bridge");
this._iconChargerOn = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".charger.on"
);
this._iconChargerOff = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".charger.off"
);
}
public IIcon getIcon(int side, int meta) {
if (meta == 0) {
return this._iconBridge;
} else {
return meta == 2 ? this._iconChargerOff : null;
}
}
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int meta = world.getBlockMetadata(x, y, z);
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityBridgeComponent) {
if (meta == 0) {
return this._iconBridge;
}
if (meta == 2) {
boolean isConnected
= ((TileEntityBridgeComponent) te).isSideConnectedClient(side);
if (isConnected) {
return this._iconChargerOn;
}
return this._iconChargerOff;
}
}
return this.getIcon(side, meta);
}
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof INeighboorUpdateTile) {
((INeighboorUpdateTile) te).onNeighboorChanged();
}
}
public TileEntity createNewTileEntity(World world, int md) {
if (md == 0) {
return new TileEntityEnergyBridge();
} else {
return md == 2 ? new TileEntityCharger() : null;
}
}
public boolean onBlockActivated(
World world,
int x,
int y,
int z,
EntityPlayer player,
int par6,
float par7,
float par8,
float par9
) {
try {
if (player.getHeldItem().getItem() instanceof DebugItem) {
return false;
}
} catch (Exception var12) {}
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntityCharger) {
player.openGui(PowerConverters.instance, 1, world, x, y, z);
return true;
} else {
if (te != null && te instanceof TileEntityBridgeComponent) {
TileEntityEnergyBridge bridge
= ((TileEntityBridgeComponent) te).getFirstBridge();
if (bridge != null) {
player.openGui(
PowerConverters.instance,
0,
world,
bridge.xCoord,
bridge.yCoord,
bridge.zCoord
);
}
} else if (te != null && te instanceof TileEntityEnergyBridge) {
player.openGui(PowerConverters.instance, 0, world, x, y, z);
}
return true;
}
}
public int damageDropped(int i) {
return i;
}
public AxisAlignedBB
getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 2) {
float shrinkAmount = 0.125F;
return AxisAlignedBB.getBoundingBox(
(double) x,
(double) y,
(double) z,
(double) (x + 1),
(double) ((float) (y + 1) - shrinkAmount),
(double) (z + 1)
);
} else {
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
}
public void
onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {}
}

View file

@ -0,0 +1,43 @@
package covers1624.powerconverters.block;
import covers1624.powerconverters.gui.PCCreativeTab;
import covers1624.powerconverters.tile.factorization.TileEntityPowerConverterFactorizationConsumer;
import covers1624.powerconverters.tile.factorization.TileEntityPowerConverterFactorizationProducer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockPowerConverterFactorization extends BlockPowerConverter {
public BlockPowerConverterFactorization() {
super(2);
this.setBlockName("powerconverters.fz");
this.setCreativeTab(PCCreativeTab.tab);
}
public TileEntity createTileEntity(World world, int metadata) {
if (metadata == 0) {
return new TileEntityPowerConverterFactorizationConsumer();
} else {
return metadata == 1 ? new TileEntityPowerConverterFactorizationProducer()
: null;
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister ir) {
super._icons[0] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".consumer.off"
);
super._icons[1] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".consumer.on"
);
super._icons[2] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".producer.off"
);
super._icons[3] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".producer.on"
);
}
}

View file

@ -0,0 +1,90 @@
package covers1624.powerconverters.block;
import covers1624.powerconverters.gui.PCCreativeTab;
import covers1624.powerconverters.tile.ic2.TileEntityIndustrialCraftConsumer;
import covers1624.powerconverters.tile.ic2.TileEntityIndustrialCraftProducer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockPowerConverterIndustrialCraft extends BlockPowerConverter {
public BlockPowerConverterIndustrialCraft() {
super(8);
this.setBlockName("powerconverters.ic2");
this.setCreativeTab(PCCreativeTab.tab);
}
public TileEntity createTileEntity(World world, int metadata) {
if (metadata == 0) {
return new TileEntityIndustrialCraftConsumer(0);
} else if (metadata == 1) {
return new TileEntityIndustrialCraftProducer(0);
} else if (metadata == 2) {
return new TileEntityIndustrialCraftConsumer(1);
} else if (metadata == 3) {
return new TileEntityIndustrialCraftProducer(1);
} else if (metadata == 4) {
return new TileEntityIndustrialCraftConsumer(2);
} else if (metadata == 5) {
return new TileEntityIndustrialCraftProducer(2);
} else if (metadata == 6) {
return new TileEntityIndustrialCraftConsumer(3);
} else {
return metadata == 7 ? new TileEntityIndustrialCraftProducer(3) : null;
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister ir) {
super._icons[0] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".lv.consumer.off"
);
super._icons[1] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".lv.consumer.on"
);
super._icons[2] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".lv.producer.off"
);
super._icons[3] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".lv.producer.on"
);
super._icons[4] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".mv.consumer.off"
);
super._icons[5] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".mv.consumer.on"
);
super._icons[6] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".mv.producer.off"
);
super._icons[7] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".mv.producer.on"
);
super._icons[8] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".hv.consumer.off"
);
super._icons[9] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".hv.consumer.on"
);
super._icons[10] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".hv.producer.off"
);
super._icons[11] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".hv.producer.on"
);
super._icons[12] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".ev.consumer.off"
);
super._icons[13] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".ev.consumer.on"
);
super._icons[14] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".ev.producer.off"
);
super._icons[15] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".ev.producer.on"
);
}
}

View file

@ -0,0 +1,38 @@
package covers1624.powerconverters.block;
import covers1624.powerconverters.gui.PCCreativeTab;
import covers1624.powerconverters.tile.redstoneflux.TileEntityRedstoneFluxConsumer;
import covers1624.powerconverters.tile.redstoneflux.TileEntityRedstoneFluxProducer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockPowerConverterRedstoneFlux extends BlockPowerConverter {
public BlockPowerConverterRedstoneFlux() {
super(2);
this.setBlockName("powerconverters.rf");
this.setCreativeTab(PCCreativeTab.tab);
}
public TileEntity createTileEntity(World world, int meta) {
if (meta == 0) {
return new TileEntityRedstoneFluxConsumer();
} else {
return meta == 1 ? new TileEntityRedstoneFluxProducer() : null;
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister ir) {
super._icons[0]
= ir.registerIcon("powerconverters:tile.powerconverters.rf.consumer.off");
super._icons[1]
= ir.registerIcon("powerconverters:tile.powerconverters.rf.consumer.on");
super._icons[2]
= ir.registerIcon("powerconverters:tile.powerconverters.rf.producer.off");
super._icons[3]
= ir.registerIcon("powerconverters:tile.powerconverters.rf.producer.on");
}
}

View file

@ -0,0 +1,42 @@
package covers1624.powerconverters.block;
import covers1624.powerconverters.gui.PCCreativeTab;
import covers1624.powerconverters.tile.steam.TileEntitySteamConsumer;
import covers1624.powerconverters.tile.steam.TileEntitySteamProducer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockPowerConverterSteam extends BlockPowerConverter {
public BlockPowerConverterSteam() {
super(2);
this.setBlockName("powerconverters.steam");
this.setCreativeTab(PCCreativeTab.tab);
}
public TileEntity createTileEntity(World world, int metadata) {
if (metadata == 0) {
return new TileEntitySteamConsumer();
} else {
return metadata == 1 ? new TileEntitySteamProducer() : null;
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister ir) {
super._icons[0] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".consumer.off"
);
super._icons[1] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".consumer.on"
);
super._icons[2] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".producer.off"
);
super._icons[3] = ir.registerIcon(
"powerconverters:" + this.getUnlocalizedName() + ".producer.on"
);
}
}

View file

@ -0,0 +1,56 @@
package covers1624.powerconverters.charge;
import covers1624.powerconverters.api.charge.IChargeHandler;
import covers1624.powerconverters.api.registry.PowerSystemRegistry;
import covers1624.powerconverters.init.PowerSystems;
import ic2.api.item.ElectricItem;
import ic2.api.item.IElectricItem;
import net.minecraft.item.ItemStack;
public class ChargeHandlerIndustrialCraft implements IChargeHandler {
public PowerSystemRegistry.PowerSystem getPowerSystem() {
return PowerSystems.powerSystemIndustrialCraft;
}
public boolean canHandle(ItemStack stack) {
return stack != null && stack.getItem() instanceof IElectricItem;
}
public double charge(ItemStack stack, double energyInput) {
double eu = energyInput
/ (double) PowerSystems.powerSystemIndustrialCraft.getScaleAmmount();
eu -= ElectricItem.manager.charge(
stack, eu, ((IElectricItem) stack.getItem()).getTier(stack), false, false
);
return eu * (double) PowerSystems.powerSystemIndustrialCraft.getScaleAmmount();
}
public double discharge(ItemStack stack, double energyRequest) {
double eu = energyRequest
/ (double) PowerSystems.powerSystemIndustrialCraft.getScaleAmmount();
eu = ElectricItem.manager.discharge(
stack,
eu,
((IElectricItem) stack.getItem()).getTier(stack),
false,
false,
false
);
return eu * (double) PowerSystems.powerSystemIndustrialCraft.getScaleAmmount();
}
public String name() {
return "Industrial Craft";
}
public boolean isItemCharged(ItemStack stack) {
if (this.canHandle(stack)) {
IElectricItem item = (IElectricItem) stack.getItem();
if (item.getMaxCharge(stack) == ElectricItem.manager.getCharge(stack)) {
return true;
}
}
return false;
}
}

View file

@ -0,0 +1,50 @@
package covers1624.powerconverters.charge;
import cofh.api.energy.IEnergyContainerItem;
import covers1624.powerconverters.api.charge.IChargeHandler;
import covers1624.powerconverters.api.registry.PowerSystemRegistry;
import covers1624.powerconverters.init.PowerSystems;
import net.minecraft.item.ItemStack;
public class ChargeHandlerRedstoneFlux implements IChargeHandler {
public PowerSystemRegistry.PowerSystem getPowerSystem() {
return PowerSystems.powerSystemRedstoneFlux;
}
public boolean canHandle(ItemStack stack) {
return stack != null && stack.getItem() instanceof IEnergyContainerItem;
}
public double charge(ItemStack stack, double energyInput) {
double RF = energyInput / (double) this.getPowerSystem().getScaleAmmount();
RF -= (double) ((IEnergyContainerItem) stack.getItem())
.receiveEnergy(stack, (int) RF, false);
return RF * (double) this.getPowerSystem().getScaleAmmount();
}
public double discharge(ItemStack stack, double energyRequest) {
IEnergyContainerItem cell = (IEnergyContainerItem) stack.getItem();
return (double
) (cell.extractEnergy(
stack,
(int) (energyRequest / (double) this.getPowerSystem().getScaleAmmount()),
false
)
* this.getPowerSystem().getScaleAmmount());
}
public String name() {
return "Redstone Flux";
}
public boolean isItemCharged(ItemStack stack) {
if (this.canHandle(stack)) {
IEnergyContainerItem item = (IEnergyContainerItem) stack.getItem();
if (item.getEnergyStored(stack) == item.getMaxEnergyStored(stack)) {
return true;
}
}
return false;
}
}

View file

@ -0,0 +1,293 @@
package covers1624.powerconverters.client.render;
import cpw.mods.fml.common.FMLLog;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipInputStream;
import javax.imageio.ImageIO;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.resources.IResource;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModelCustom;
import net.minecraftforge.client.model.ModelFormatException;
import org.lwjgl.opengl.GL11;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class CustomTechneModel extends ModelBase implements IModelCustom {
public static final List cubeTypes = Arrays.asList("d9e621f7-957f-4b77-b1ae-20dcd0da7751", "de81aa14-bd60-4228-8d8d-5238bcd3caaa");
private String fileName;
private Map zipContents = new HashMap();
private Map parts = new LinkedHashMap();
private String texture = null;
private Dimension textureDims = null;
private DynamicTexture dynamicTexture;
private boolean textureNameSet = false;
public CustomTechneModel(ResourceLocation resource) throws ModelFormatException {
this.fileName = resource.toString();
try {
IResource res = Minecraft.getMinecraft().getResourceManager().getResource(resource);
this.loadTechneModel(res.getInputStream());
} catch (IOException var3) {
throw new ModelFormatException("IO Exception reading model format", var3);
}
}
private void loadTechneModel(InputStream stream) throws ModelFormatException {
try {
ZipInputStream zipInput = new ZipInputStream(stream);
ZipEntry entry;
byte[] data;
while((entry = zipInput.getNextEntry()) != null) {
data = new byte[(int)entry.getSize()];
for(int i = 0; zipInput.available() > 0 && i < data.length; data[i++] = (byte)zipInput.read()) {
}
this.zipContents.put(entry.getName(), data);
}
data = (byte[])this.zipContents.get("model.xml");
if (data == null) {
throw new ModelFormatException("Model " + this.fileName + " contains no model.xml file");
}
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(new ByteArrayInputStream(data));
NodeList nodeListTechne = document.getElementsByTagName("Techne");
if (nodeListTechne.getLength() < 1) {
throw new ModelFormatException("Model " + this.fileName + " contains no Techne tag");
}
NodeList nodeListModel = document.getElementsByTagName("Model");
if (nodeListModel.getLength() < 1) {
throw new ModelFormatException("Model " + this.fileName + " contains no Model tag");
}
NamedNodeMap modelAttributes = nodeListModel.item(0).getAttributes();
if (modelAttributes == null) {
throw new ModelFormatException("Model " + this.fileName + " contains a Model tag with no attributes");
}
Node modelTexture = modelAttributes.getNamedItem("texture");
if (modelTexture != null) {
this.texture = modelTexture.getTextContent();
}
NodeList textureDim = document.getElementsByTagName("TextureSize");
if (textureDim.getLength() > 0) {
try {
String[] tmp = textureDim.item(0).getTextContent().split(",");
if (tmp.length == 2) {
this.textureDims = new Dimension(Integer.parseInt(tmp[0]), Integer.parseInt(tmp[1]));
}
} catch (NumberFormatException var32) {
throw new ModelFormatException("Model " + this.fileName + " contains a TextureSize tag with invalid data");
}
}
NodeList shapes = document.getElementsByTagName("Shape");
for(int i = 0; i < shapes.getLength(); ++i) {
Node shape = shapes.item(i);
NamedNodeMap shapeAttributes = shape.getAttributes();
if (shapeAttributes == null) {
throw new ModelFormatException("Shape #" + (i + 1) + " in " + this.fileName + " has no attributes");
}
Node name = shapeAttributes.getNamedItem("name");
String shapeName = null;
if (name != null) {
shapeName = name.getNodeValue();
}
if (shapeName == null) {
shapeName = "Shape #" + (i + 1);
}
String shapeType = null;
Node type = shapeAttributes.getNamedItem("type");
if (type != null) {
shapeType = type.getNodeValue();
}
if (shapeType != null && !cubeTypes.contains(shapeType)) {
FMLLog.warning("Model shape [" + shapeName + "] in " + this.fileName + " is not a cube, ignoring", new Object[0]);
} else {
try {
boolean mirrored = false;
String[] offset = new String[3];
String[] position = new String[3];
String[] rotation = new String[3];
String[] size = new String[3];
String[] textureOffset = new String[2];
NodeList shapeChildren = shape.getChildNodes();
for(int j = 0; j < shapeChildren.getLength(); ++j) {
Node shapeChild = shapeChildren.item(j);
String shapeChildName = shapeChild.getNodeName();
String shapeChildValue = shapeChild.getTextContent();
if (shapeChildValue != null) {
shapeChildValue = shapeChildValue.trim();
if (shapeChildName.equals("IsMirrored")) {
mirrored = !shapeChildValue.equals("False");
} else if (shapeChildName.equals("Offset")) {
offset = shapeChildValue.split(",");
} else if (shapeChildName.equals("Position")) {
position = shapeChildValue.split(",");
} else if (shapeChildName.equals("Rotation")) {
rotation = shapeChildValue.split(",");
} else if (shapeChildName.equals("Size")) {
size = shapeChildValue.split(",");
} else if (shapeChildName.equals("TextureOffset")) {
textureOffset = shapeChildValue.split(",");
}
}
}
ModelRenderer cube = new ModelRenderer(this, Integer.parseInt(textureOffset[0]), Integer.parseInt(textureOffset[1]));
cube.mirror = mirrored;
cube.addBox(Float.parseFloat(offset[0]), Float.parseFloat(offset[1]), Float.parseFloat(offset[2]), Integer.parseInt(size[0]), Integer.parseInt(size[1]), Integer.parseInt(size[2]));
cube.setRotationPoint(Float.parseFloat(position[0]), Float.parseFloat(position[1]) - 23.4F, Float.parseFloat(position[2]));
cube.rotateAngleX = (float)Math.toRadians((double)Float.parseFloat(rotation[0]));
cube.rotateAngleY = (float)Math.toRadians((double)Float.parseFloat(rotation[1]));
cube.rotateAngleZ = (float)Math.toRadians((double)Float.parseFloat(rotation[2]));
if (this.textureDims != null) {
cube.setTextureSize((int)this.textureDims.getWidth(), (int)this.textureDims.getHeight());
}
this.parts.put(shapeName, cube);
} catch (NumberFormatException var33) {
FMLLog.warning("Model shape [" + shapeName + "] in " + this.fileName + " contains malformed integers within its data, ignoring", new Object[0]);
var33.printStackTrace();
}
}
}
} catch (ZipException var34) {
throw new ModelFormatException("Model " + this.fileName + " is not a valid zip file");
} catch (IOException var35) {
throw new ModelFormatException("Model " + this.fileName + " could not be read", var35);
} catch (ParserConfigurationException var36) {
} catch (SAXException var37) {
throw new ModelFormatException("Model " + this.fileName + " contains invalid XML", var37);
}
}
public void bindTexture() {
if (this.texture != null) {
if (!this.textureNameSet) {
try {
byte[] textureEntry = (byte[])this.zipContents.get(this.texture);
if (textureEntry == null) {
throw new ModelFormatException("Model " + this.fileName + " has no such texture " + this.texture);
}
BufferedImage image = ImageIO.read(new ByteArrayInputStream(textureEntry));
this.dynamicTexture = new DynamicTexture(image);
ResourceLocation resourceLocation = new ResourceLocation("powerconverters:textures/models/dynamic/" + this.dynamicTexture.getGlTextureId());
Minecraft.getMinecraft().renderEngine.loadTexture(resourceLocation, this.dynamicTexture);
Minecraft.getMinecraft().renderEngine.bindTexture(resourceLocation);
this.textureNameSet = true;
} catch (ZipException var4) {
throw new ModelFormatException("Model " + this.fileName + " is not a valid zip file");
} catch (IOException var5) {
throw new ModelFormatException("Texture for model " + this.fileName + " could not be read", var5);
}
}
if (this.textureNameSet) {
GL11.glBindTexture(3553, this.dynamicTexture.getGlTextureId());
}
}
}
public String getType() {
return "tcn";
}
public void renderAll() {
Iterator i$ = this.parts.keySet().iterator();
while(i$.hasNext()) {
String name = (String)i$.next();
ModelRenderer part = (ModelRenderer)this.parts.get(name);
part.render(1.0F);
}
}
public void renderPart(String partName) {
ModelRenderer part = (ModelRenderer)this.parts.get(partName);
if (part != null) {
part.renderWithRotation(1.0F);
}
}
public void renderOnly(String... groupNames) {
Iterator it$ = this.parts.values().iterator();
while(it$.hasNext()) {
ModelRenderer part = (ModelRenderer)it$.next();
String[] arr$ = groupNames;
int len$ = groupNames.length;
for(int i$ = 0; i$ < len$; ++i$) {
String groupName = arr$[i$];
if (groupName.equalsIgnoreCase(part.boxName)) {
part.render(1.0F);
}
}
}
}
public void renderAllExcept(String... excludedGroupNames) {
Iterator it$ = this.parts.values().iterator();
while(it$.hasNext()) {
ModelRenderer part = (ModelRenderer)it$.next();
boolean skipPart = false;
String[] arr$ = excludedGroupNames;
int len$ = excludedGroupNames.length;
for(int i$ = 0; i$ < len$; ++i$) {
String excludedGroupName = arr$[i$];
if (excludedGroupName.equalsIgnoreCase(part.boxName)) {
skipPart = true;
}
}
if (!skipPart) {
part.render(1.0F);
}
}
}
}

View file

@ -0,0 +1,28 @@
package covers1624.powerconverters.client.render;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class TileUniversalConduitRender extends TileEntitySpecialRenderer {
private CustomTechneModel model;
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTicks) {
if (this.model == null) {
this.model = new CustomTechneModel(new ResourceLocation("powerconverters:textures/model/universalConduitModel.tcn"));
}
CustomTechneModel modelConduit = this.model;
this.bindTexture(new ResourceLocation("powerconverters:textures/model/universalConduitTextureDebug.png"));
GL11.glPushMatrix();
GL11.glEnable(32826);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float)x, (float)y + 1.0F, (float)z + 1.0F);
GL11.glScalef(0.06F, 0.06F, 0.06F);
GL11.glTranslatef(8.35F, -2.0F, -8.35F);
modelConduit.renderAll();
GL11.glDisable(32826);
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,40 @@
package covers1624.powerconverters.container;
import covers1624.powerconverters.net.PacketPipeline;
import covers1624.powerconverters.tile.main.TileEntityEnergyBridge;
import covers1624.powerconverters.util.InventoryUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
public class ContainerEnergyBridge extends Container {
private TileEntityEnergyBridge energyBridge;
private EntityPlayer player;
public ContainerEnergyBridge(
TileEntityEnergyBridge bridge, InventoryPlayer inventoryPlayer
) {
this.player = inventoryPlayer.player;
this.energyBridge = bridge;
InventoryUtils.bindPlayerInventory(this, inventoryPlayer, 8, 113);
}
public boolean canInteractWith(EntityPlayer var1) {
return true;
}
public void updateProgressBar(int var, int value) {}
public void detectAndSendChanges() {
super.detectAndSendChanges();
PacketPipeline.INSTANCE.sendTo(
this.energyBridge.getNetPacket(), (EntityPlayerMP) this.player
);
}
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
return null;
}
}

View file

@ -0,0 +1,103 @@
package covers1624.powerconverters.container;
import covers1624.powerconverters.slot.ChargerInputSlot;
import covers1624.powerconverters.slot.ChargerOutputSlot;
import covers1624.powerconverters.tile.main.TileEntityCharger;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerUniversalCharger extends Container {
private InventoryPlayer playerInventory;
private TileEntityCharger tileCharger;
public ContainerUniversalCharger(
InventoryPlayer playerInventory, TileEntityCharger charger
) {
this.playerInventory = playerInventory;
this.tileCharger = charger;
int slot = 0;
int i;
int j;
int x;
int y;
for (i = 0; i < 4; ++i) {
for (j = 0; j < 4; ++j) {
x = 8 + j * 18;
y = 18 + i * 18;
this.addSlotToContainer(new ChargerInputSlot(this.tileCharger, slot, x, y)
);
++slot;
}
}
for (i = 0; i < 4; ++i) {
for (j = 0; j < 4; ++j) {
x = 98 + j * 18;
y = 18 + i * 18;
this.addSlotToContainer(
new ChargerOutputSlot(this.tileCharger, slot, x, y)
);
++slot;
}
}
this.bindPlayerInventory(playerInventory);
}
public boolean canInteractWith(EntityPlayer p_75145_1_) {
return true;
}
public ItemStack transferStackInSlot(EntityPlayer player, int inventorySlot) {
ItemStack itemStack = null;
Slot slot = (Slot) super.inventorySlots.get(inventorySlot);
if (slot != null && slot.getHasStack()) {
ItemStack itemStack2 = slot.getStack();
itemStack = itemStack2.copy();
if (inventorySlot > 15
&& this.tileCharger.isItemValidForSlot(0, itemStack2)) {
if (!this.mergeItemStack(itemStack2, 0, 15, false)) {
return null;
}
slot.onSlotChange(itemStack2, itemStack);
} else if (slot instanceof ChargerOutputSlot && !this.mergeItemStack(itemStack2, 32, super.inventorySlots.size(), false)) {
return null;
}
if (itemStack2.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if (itemStack2.stackSize == itemStack.stackSize) {
return null;
}
slot.onPickupFromSlot(player, itemStack2);
}
return itemStack;
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
int slot = j + i * 9 + 9;
int x = 8 + j * 18;
int y = 104 + i * 18;
this.addSlotToContainer(new Slot(inventoryPlayer, slot, x, y));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 162));
}
}
}

View file

@ -0,0 +1,167 @@
package covers1624.powerconverters.grid;
import java.util.Iterator;
import java.util.LinkedHashSet;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
public class GridTickHandler implements IGridController {
public static final GridTickHandler energy = new GridTickHandler("Energy");
private LinkedHashSet<IGrid> tickingGridsToRegenerate = new LinkedHashSet<>();
private LinkedHashSet<IGrid> tickingGridsToAdd = new LinkedHashSet<>();
private LinkedHashSet<IGrid> tickingGrids = new LinkedHashSet<>();
private LinkedHashSet<IGrid> tickingGridsToRemove = new LinkedHashSet<>();
private LinkedHashSet<INode> conduit = new LinkedHashSet<>();
private LinkedHashSet<INode> conduitToAdd = new LinkedHashSet<>();
private LinkedHashSet<INode> conduitToUpd = new LinkedHashSet<>();
private final String label;
public GridTickHandler(String name) {
name.hashCode();
this.label = "GridTickHandler[" + name + "]";
}
public void addGrid(IGrid grid) {
this.tickingGridsToAdd.add(grid);
this.tickingGridsToRemove.remove(grid);
}
public void removeGrid(IGrid grid) {
this.tickingGridsToRemove.add(grid);
this.tickingGridsToAdd.remove(grid);
}
public void regenerateGrid(IGrid grid) {
this.tickingGridsToRegenerate.add(grid);
}
public boolean isGridTicking(IGrid grid) {
return this.tickingGrids.contains(grid);
}
public void addConduitForTick(INode node) {
this.conduitToAdd.add(node);
}
public void addConduitForUpdate(INode node) {
this.conduitToUpd.add(node);
}
@SubscribeEvent
public void tick(TickEvent.ServerTickEvent event) {
if (event.phase == Phase.START) {
this.tickStart();
} else {
this.tickEnd();
}
}
public void tickStart() {
Iterator iter;
if (!this.tickingGridsToRegenerate.isEmpty()) {
synchronized (this.tickingGridsToRegenerate) {
iter = this.tickingGridsToRegenerate.iterator();
while (iter.hasNext()) {
IGrid grid = (IGrid) iter.next();
grid.markSweep();
}
this.tickingGridsToRegenerate.clear();
}
}
if (!this.conduitToUpd.isEmpty()) {
synchronized (this.conduitToUpd) {
this.conduit.addAll(this.conduitToUpd);
this.conduitToUpd.clear();
}
}
if (!this.conduit.isEmpty()) {
INode cond = null;
try {
iter = this.conduit.iterator();
while (iter.hasNext()) {
cond = (INode) iter.next();
if (!cond.isNotValid()) {
cond.updateInternalTypes(this);
}
}
this.conduit.clear();
} catch (Throwable var7) {
throw new RuntimeException("Crashing on conduit " + cond, var7);
}
}
if (!this.tickingGrids.isEmpty()) {
Iterator i$ = this.tickingGrids.iterator();
while (i$.hasNext()) {
IGrid grid = (IGrid) i$.next();
grid.doGridPreUpdate();
}
}
}
public void tickEnd() {
if (!this.tickingGridsToRemove.isEmpty()) {
synchronized (this.tickingGridsToRemove) {
this.tickingGrids.removeAll(this.tickingGridsToRemove);
this.tickingGridsToRemove.clear();
}
}
if (!this.tickingGridsToAdd.isEmpty()) {
synchronized (this.tickingGridsToAdd) {
this.tickingGrids.addAll(this.tickingGridsToAdd);
this.tickingGridsToAdd.clear();
}
}
Iterator cond;
if (!this.tickingGrids.isEmpty()) {
cond = this.tickingGrids.iterator();
while (cond.hasNext()) {
IGrid grid = (IGrid) cond.next();
grid.doGridUpdate();
}
}
if (!this.conduitToAdd.isEmpty()) {
synchronized (this.conduitToAdd) {
this.conduit.addAll(this.conduitToAdd);
this.conduitToAdd.clear();
}
}
if (!this.conduit.isEmpty()) {
cond = null;
try {
Iterator iter = this.conduit.iterator();
while (iter.hasNext()) {
INode cond1 = (INode) iter.next();
if (!cond1.isNotValid()) {
cond1.firstTick(this);
}
}
this.conduit.clear();
} catch (Throwable var8) {
throw new RuntimeException("Crashing on conduit " + cond, var8);
}
}
}
public String toString() {
return this.label + "@" + this.hashCode();
}
}

View file

@ -0,0 +1,9 @@
package covers1624.powerconverters.grid;
public interface IGrid {
void doGridPreUpdate();
void doGridUpdate();
void markSweep();
}

View file

@ -0,0 +1,3 @@
package covers1624.powerconverters.grid;
public interface IGridController {}

View file

@ -0,0 +1,9 @@
package covers1624.powerconverters.grid;
public interface INode {
boolean isNotValid();
void firstTick(IGridController var1);
void updateInternalTypes(IGridController var1);
}

View file

@ -0,0 +1,159 @@
package covers1624.powerconverters.gui;
import covers1624.powerconverters.api.bridge.BridgeSideData;
import covers1624.powerconverters.container.ContainerEnergyBridge;
import covers1624.powerconverters.tile.main.TileEntityEnergyBridge;
import covers1624.powerconverters.util.GuiArea;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
public class GuiEnergyBridge extends GuiContainer {
private TileEntityEnergyBridge energyBridge;
private GuiArea[] guiAreas = new GuiArea[7];
public GuiEnergyBridge(ContainerEnergyBridge container, TileEntityEnergyBridge te) {
super(container);
super.ySize = 195;
this.energyBridge = te;
}
private void initGuiAreas() {
this.guiAreas[0] = new GuiArea(8, 17, 122, 47, ForgeDirection.UP);
this.guiAreas[1] = new GuiArea(8, 51, 122, 81, ForgeDirection.NORTH);
this.guiAreas[2] = new GuiArea(8, 85, 122, 115, ForgeDirection.EAST);
this.guiAreas[3] = new GuiArea(126, 17, 240, 47, ForgeDirection.DOWN);
this.guiAreas[4] = new GuiArea(126, 51, 240, 81, ForgeDirection.SOUTH);
this.guiAreas[5] = new GuiArea(126, 85, 240, 115, ForgeDirection.WEST);
this.guiAreas[6] = new GuiArea(44, 119, 204, 163, ForgeDirection.UNKNOWN);
}
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
this.drawOldGuiContainerForegroundLayer(mouseX, mouseY);
}
protected void
drawGuiContainerBackgroundLayer(float gameTicks, int mouseX, int mouseY) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(
new ResourceLocation("powerconverters:textures/gui/energyBridge.png")
);
int x = (super.width - super.xSize) / 2;
int y = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, super.xSize, super.ySize);
this.drawOldGuiContainerBackgroundLayer(gameTicks, mouseX, mouseY, x, y);
}
protected void mouseClicked(int mouseX, int mouseY, int clickedButton) {
super.mouseClicked(mouseX, mouseY, clickedButton);
}
private void drawSlotLighting(int mouseX, int mouseY, int x, int y) {
GL11.glPushMatrix();
GuiArea[] arr$ = this.guiAreas;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
GuiArea guiArea = arr$[i$];
if (guiArea.isMouseInArea(mouseX, mouseY, x, y)) {
GL11.glDisable(2896);
GL11.glDisable(2929);
GL11.glColorMask(true, true, true, false);
this.drawGradientRect(
guiArea.xTop + x,
guiArea.yTop + y,
guiArea.xBottom + x,
guiArea.yBottom + y,
-2130706433,
-2130706433
);
GL11.glColorMask(true, true, true, true);
GL11.glEnable(2896);
GL11.glEnable(2929);
}
}
GL11.glPopMatrix();
}
private String getOutputRateString(BridgeSideData data) {
if (!data.isConnected) {
return "NO LINK";
} else {
double rate = data.outputRate;
if (rate > 1000.0) {
double rateThousand = rate / 1000.0;
return String.format(
"%.1f %s%s", rateThousand, "k", data.powerSystem.getUnit()
);
} else {
return rate + " " + data.powerSystem.getUnit();
}
}
}
private void drawOldGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.fontRendererObj.drawString("Energy Bridge", 8, 6, 4210752);
if (this.energyBridge.isInputLimited()) {
super.fontRendererObj.drawString("INPUT LIMITED", 98, 6, -1);
} else {
super.fontRendererObj.drawString("OUTPUT LIMITED", 90, 6, -1);
}
for (int i = 0; i < 6; ++i) {
ForgeDirection dir = ForgeDirection.getOrientation(i);
super.fontRendererObj.drawString(dir.toString(), 10, 6 + 12 * (i + 1), -1);
BridgeSideData data = this.energyBridge.getDataForSide(dir);
if ((data.isConsumer || data.isProducer) && data.powerSystem != null) {
String name = data.powerSystem.getAbbreviation();
if (data.powerSystem.getVoltageNames() != null) {
name = name + " "
+ data.powerSystem.getVoltageNames()[data.voltageNameIndex];
}
super.fontRendererObj.drawString(name, 49, 6 + 12 * (i + 1), -1);
super.fontRendererObj.drawString(
data.isConsumer ? "IN" : "OUT", 92, 6 + 12 * (i + 1), -1
);
super.fontRendererObj.drawString(
this.getOutputRateString(data), 119, 6 + 12 * (i + 1), -1
);
} else {
super.fontRendererObj.drawString("<NONE>", 49, 6 + 12 * (i + 1), -1);
}
}
super.fontRendererObj.drawString("% CHG", 10, 90, -1);
GL11.glDisable(2896);
drawRect(46, 97, 46 + (int) this.energyBridge.getEnergyScaled(), 89, -16734721);
GL11.glEnable(2896);
super.fontRendererObj.drawString(
StatCollector.translateToLocal("container.inventory"),
8,
super.ySize - 96 + 2,
4210752
);
}
private void drawOldGuiContainerBackgroundLayer(
float gameTicks, int mouseX, int mouseY, int x, int y
) {
for (int i = 0; i < 6; ++i) {
ForgeDirection dir = ForgeDirection.getOrientation(i);
BridgeSideData data = this.energyBridge.getDataForSide(dir);
if ((data.isConsumer || data.isProducer) && data.powerSystem != null) {
if (!data.isConnected) {
this.drawTexturedModalRect(x + 7, y + 15 + 12 * i, 0, 208, 162, 12);
} else if (data.outputRate == 0.0) {
this.drawTexturedModalRect(x + 7, y + 15 + 12 * i, 0, 234, 162, 12);
} else {
this.drawTexturedModalRect(x + 7, y + 15 + 12 * i, 0, 195, 162, 12);
}
} else {
this.drawTexturedModalRect(x + 7, y + 15 + 12 * i, 0, 221, 162, 12);
}
}
}
}

View file

@ -0,0 +1,33 @@
package covers1624.powerconverters.gui;
import covers1624.powerconverters.container.ContainerUniversalCharger;
import covers1624.powerconverters.tile.main.TileEntityCharger;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiUniversalCharger extends GuiContainer {
public GuiUniversalCharger(
InventoryPlayer playerInventory, TileEntityCharger charger
) {
super(new ContainerUniversalCharger(playerInventory, charger));
super.ySize = 186;
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
super.fontRendererObj.drawString("Universal Charger", 40, 6, 4210752);
super.fontRendererObj.drawString("Inventory", 8, super.ySize - 96 + 2, 4210752);
}
protected void
drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(
new ResourceLocation("powerconverters:textures/gui/universalCharger.png")
);
int x = (super.width - super.xSize) / 2;
int y = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, super.xSize, super.ySize);
}
}

View file

@ -0,0 +1,24 @@
package covers1624.powerconverters.gui;
import covers1624.powerconverters.handler.ConfigurationHandler;
import cpw.mods.fml.client.config.GuiConfig;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
public class PCConfigGui extends GuiConfig {
public PCConfigGui(GuiScreen parent) {
super(
parent,
(new ConfigElement(
ConfigurationHandler.INSTANCE.configuration.getCategory("basic")
))
.getChildElements(),
"PowerConverters3",
false,
true,
GuiConfig.getAbridgedConfigPath(
ConfigurationHandler.INSTANCE.configuration.toString()
)
);
}
}

View file

@ -0,0 +1,26 @@
package covers1624.powerconverters.gui;
import covers1624.powerconverters.init.ModBlocks;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class PCCreativeTab extends CreativeTabs {
public static final PCCreativeTab tab = new PCCreativeTab();
public PCCreativeTab() {
super("Power Converters");
}
public ItemStack getIconItemStack() {
return new ItemStack(ModBlocks.converterBlockCommon, 1, 0);
}
public String getTranslatedTabLabel() {
return this.getTabLabel();
}
public Item getTabIconItem() {
return null;
}
}

View file

@ -0,0 +1,23 @@
package covers1624.powerconverters.gui;
import java.util.Set;
import cpw.mods.fml.client.IModGuiFactory;
import net.minecraft.client.Minecraft;
public class PCGuiFactory implements IModGuiFactory {
public void initialize(Minecraft minecraftInstance) {}
public Class mainConfigGuiClass() {
return PCConfigGui.class;
}
public Set runtimeGuiCategories() {
return null;
}
public IModGuiFactory.RuntimeOptionGuiHandler
getHandlerFor(IModGuiFactory.RuntimeOptionCategoryElement element) {
return null;
}
}

View file

@ -0,0 +1,136 @@
package covers1624.powerconverters.handler;
import java.io.File;
import net.minecraftforge.common.config.Configuration;
public class ConfigurationHandler {
public Configuration configuration;
public static ConfigurationHandler INSTANCE;
public static boolean logDebug;
public static int bridgeBufferSize;
public static boolean useThermalExpansionRecipes;
public static boolean useTechRebornRecipes;
public static boolean doFlatBedrock;
public static boolean doUpdateCheck;
public static boolean sendRecipesToClient;
public static boolean ignoreRecipesFromServer;
public static boolean dissableRFProducer;
public static boolean dissableRFConsumer;
public static boolean dissableIC2Producer;
public static boolean dissableIC2Consumer;
public static boolean dissableFactorizationProducer;
public static boolean dissableFactorizationConsumer;
public static boolean dissableSteamProducer;
public static boolean dissableSteamConsumer;
public static boolean dissableUniversalCharger;
public static boolean dissableUniversalUnCharger;
public ConfigurationHandler(File config) {
INSTANCE = this;
if (this.configuration == null) {
this.configuration = new Configuration(config);
}
this.loadConfiguration();
}
public void loadConfiguration() {
bridgeBufferSize
= this.configuration.get("basic", "BridgeBufferSize", 160000000).getInt();
logDebug = this.configuration
.get(
"basic",
"Log Debug Messages",
false,
"Set this to true to see all debug messages."
)
.getBoolean();
doFlatBedrock = this.configuration
.get(
"basic",
"Do Flat Bedrock",
false,
"Set this to false for normal Bedrock."
)
.getBoolean();
doUpdateCheck
= this.configuration
.get(
"basic",
"Do Update Check",
true,
"Set to false and PowerConverters will not check for an update"
)
.getBoolean();
sendRecipesToClient
= this.configuration
.get(
"basic",
"Send Recipes To Client",
true,
"Setting this to false will dissable recipe syncing with the server"
)
.getBoolean();
ignoreRecipesFromServer
= this.configuration
.get(
"basic",
"Ignore Server Recipes",
false,
"Setting this to true will dissable the client using the server recipes."
)
.getBoolean();
useThermalExpansionRecipes
= this.configuration
.get("Recipes", "Thermal Expansion", false, "Thermal Expansion Recipes")
.getBoolean();
useTechRebornRecipes
= this.configuration
.get("Recipes", "Tech Reborn", false, "Tech Reborn Recipes")
.getBoolean();
dissableRFProducer = this.configuration.getBoolean(
"Dissable RF Producer", "Devices", false, "Dissables the RF Producer"
);
dissableRFConsumer = this.configuration.getBoolean(
"Dissable RF Consumer", "Devices", false, "Dissables the RF Consumer"
);
dissableIC2Producer = this.configuration.getBoolean(
"Dissable IC2 Producers", "Devices", false, "Dissables the IC2 Producers"
);
dissableIC2Consumer = this.configuration.getBoolean(
"Dissable IC2 Consumers", "Devices", false, "Dissables the IC2 Consumers"
);
dissableFactorizationProducer = this.configuration.getBoolean(
"Dissable Factorization Producer",
"Devices",
false,
"Dissables the Factorization Producer"
);
dissableFactorizationConsumer = this.configuration.getBoolean(
"Dissable Factorization Consumer",
"Devices",
false,
"Dissables the Factorization Consumer"
);
dissableSteamProducer = this.configuration.getBoolean(
"Dissable Steam Producer", "Devices", false, "Dissables the Steam Producer"
);
dissableSteamConsumer = this.configuration.getBoolean(
"Dissable Steam Consumer", "Devices", false, "Dissables the Steam Consumer"
);
dissableUniversalCharger = this.configuration.getBoolean(
"Dissable Universal Charger",
"Devices",
false,
"Dissables the Universal Charger"
);
dissableUniversalUnCharger = this.configuration.getBoolean(
"Dissable Universal Un Charger",
"Devices",
false,
"Dissables the Universal Un Charger"
);
this.configuration.save();
}
}

View file

@ -0,0 +1,91 @@
package covers1624.powerconverters.handler;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import covers1624.powerconverters.PowerConverters;
import covers1624.powerconverters.init.Recipes;
import covers1624.powerconverters.net.PacketPipeline;
import covers1624.powerconverters.net.RecipeSyncPacket;
import covers1624.powerconverters.util.IRecipeHandler;
import covers1624.powerconverters.util.LogHelper;
import covers1624.powerconverters.util.RecipeRemover;
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidRegistry;
public class PCEventHandler {
public static int ticksInGame = 0;
@SubscribeEvent
public void onFluidRegisterEvent(FluidRegistry.FluidRegisterEvent event) {
LogHelper.info(event.fluidName);
if (event.fluidName.equals("Steam")) {
PowerConverters.steamId = event.fluidID;
} else if (event.fluidName.equals("steam") && PowerConverters.steamId == -1) {
PowerConverters.steamId = event.fluidID;
}
}
@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.modID.equalsIgnoreCase("PowerConverters3")) {
ConfigurationHandler.INSTANCE.loadConfiguration();
}
}
@SideOnly(Side.SERVER)
public void onClientJoin(PlayerEvent.PlayerLoggedInEvent event) {
if (!ConfigurationHandler.sendRecipesToClient) {
LogHelper.trace("Recipe Sending is turned off.");
} else {
NBTTagCompound tag = new NBTTagCompound();
List recipes = Recipes.getCurrentRecipes();
NBTTagList tagList = new NBTTagList();
Iterator i$ = recipes.iterator();
while (i$.hasNext()) {
IRecipe recipe = (IRecipe) i$.next();
NBTTagCompound tagCompound = IRecipeHandler.writeIRecipeToTag(recipe);
tagList.appendTag(tagCompound);
}
tag.setTag("Recipes", tagList);
RecipeSyncPacket syncPacket = new RecipeSyncPacket(tag);
PacketPipeline.INSTANCE.sendTo(syncPacket, (EntityPlayerMP) event.player);
}
}
@SideOnly(Side.CLIENT)
public void
onClientDisconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
List currentOutputs = new ArrayList();
Iterator i$ = Recipes.getCurrentRecipes().iterator();
IRecipe recipe;
while (i$.hasNext()) {
recipe = (IRecipe) i$.next();
ItemStack stack = recipe.getRecipeOutput();
currentOutputs.add(stack);
}
RecipeRemover.removeAnyRecipes(currentOutputs);
i$ = Recipes.getDefaultRecipes().iterator();
while (i$.hasNext()) {
recipe = (IRecipe) i$.next();
CraftingManager.getInstance().getRecipeList().add(recipe);
}
}
}

View file

@ -0,0 +1,45 @@
package covers1624.powerconverters.handler;
import covers1624.powerconverters.container.ContainerEnergyBridge;
import covers1624.powerconverters.container.ContainerUniversalCharger;
import covers1624.powerconverters.gui.GuiEnergyBridge;
import covers1624.powerconverters.gui.GuiUniversalCharger;
import covers1624.powerconverters.tile.main.TileEntityCharger;
import covers1624.powerconverters.tile.main.TileEntityEnergyBridge;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class PCGUIHandler implements IGuiHandler {
public Object
getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (ID == 1) {
return new ContainerUniversalCharger(
player.inventory, (TileEntityCharger) te
);
} else {
return te != null && te instanceof TileEntityEnergyBridge
? new ContainerEnergyBridge((TileEntityEnergyBridge) te, player.inventory)
: null;
}
}
public Object
getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (ID == 1) {
return new GuiUniversalCharger(player.inventory, (TileEntityCharger) te);
} else {
return te != null && te instanceof TileEntityEnergyBridge
? new GuiEnergyBridge(
new ContainerEnergyBridge(
(TileEntityEnergyBridge) te, player.inventory
),
(TileEntityEnergyBridge) te
)
: null;
}
}
}

View file

@ -0,0 +1,3 @@
package covers1624.powerconverters.handler;
public class PlayerHandler {}

View file

@ -0,0 +1,115 @@
package covers1624.powerconverters.init;
import covers1624.powerconverters.block.BlockEnergyConduit;
import covers1624.powerconverters.block.BlockPowerConverterCommon;
import covers1624.powerconverters.block.BlockPowerConverterFactorization;
import covers1624.powerconverters.block.BlockPowerConverterIndustrialCraft;
import covers1624.powerconverters.block.BlockPowerConverterRedstoneFlux;
import covers1624.powerconverters.block.BlockPowerConverterSteam;
import covers1624.powerconverters.item.ItemBlockPowerConverterCommon;
import covers1624.powerconverters.item.ItemBlockPowerConverterFactorization;
import covers1624.powerconverters.item.ItemBlockPowerConverterIndustrialCraft;
import covers1624.powerconverters.item.ItemBlockPowerConverterRedstoneFlux;
import covers1624.powerconverters.item.ItemBlockPowerConverterSteam;
import covers1624.powerconverters.tile.factorization.TileEntityPowerConverterFactorizationConsumer;
import covers1624.powerconverters.tile.factorization.TileEntityPowerConverterFactorizationProducer;
import covers1624.powerconverters.tile.ic2.TileEntityIndustrialCraftConsumer;
import covers1624.powerconverters.tile.ic2.TileEntityIndustrialCraftProducer;
import covers1624.powerconverters.tile.main.TileEnergyConduit;
import covers1624.powerconverters.tile.main.TileEntityCharger;
import covers1624.powerconverters.tile.main.TileEntityEnergyBridge;
import covers1624.powerconverters.tile.redstoneflux.TileEntityRedstoneFluxConsumer;
import covers1624.powerconverters.tile.redstoneflux.TileEntityRedstoneFluxProducer;
import covers1624.powerconverters.tile.steam.TileEntitySteamConsumer;
import covers1624.powerconverters.tile.steam.TileEntitySteamProducer;
import covers1624.powerconverters.util.RFHelper;
import covers1624.powerconverters.util.TextureUtils;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
public class ModBlocks {
public static Block conduitBlock;
public static Block converterBlockCommon;
public static Block converterBlockIndustrialCraft;
public static Block converterBlockSteam;
public static Block converterBlockFactorization;
public static Block converterBlockRedstoneFlux;
public static void init() {
conduitBlock = new BlockEnergyConduit();
registerBlock(conduitBlock, conduitBlock.getUnlocalizedName());
GameRegistry.registerTileEntity(TileEnergyConduit.class, "powerConverterConduit");
converterBlockCommon = new BlockPowerConverterCommon();
registerBlock(
converterBlockCommon,
ItemBlockPowerConverterCommon.class,
converterBlockCommon.getUnlocalizedName()
);
GameRegistry.registerTileEntity(TileEntityEnergyBridge.class, "EnergyBridge");
GameRegistry.registerTileEntity(TileEntityCharger.class, "UniversalCharger");
if (Loader.isModLoaded("ThermalExpansion") || Loader.isModLoaded("BuildCraft")
|| RFHelper.iEnergyHandlerExists) {
converterBlockRedstoneFlux = new BlockPowerConverterRedstoneFlux();
registerBlock(
converterBlockRedstoneFlux,
ItemBlockPowerConverterRedstoneFlux.class,
converterBlockRedstoneFlux.getUnlocalizedName()
);
GameRegistry.registerTileEntity(
TileEntityRedstoneFluxConsumer.class, "RFConsumer"
);
GameRegistry.registerTileEntity(
TileEntityRedstoneFluxProducer.class, "RFProducer"
);
}
if (Loader.isModLoaded("IC2")) {
converterBlockIndustrialCraft = new BlockPowerConverterIndustrialCraft();
registerBlock(
converterBlockIndustrialCraft,
ItemBlockPowerConverterIndustrialCraft.class,
converterBlockIndustrialCraft.getUnlocalizedName()
);
GameRegistry.registerTileEntity(
TileEntityIndustrialCraftConsumer.class, "IC2Consumer"
);
GameRegistry.registerTileEntity(
TileEntityIndustrialCraftProducer.class, "IC2Producer"
);
}
converterBlockSteam = new BlockPowerConverterSteam();
registerBlock(
converterBlockSteam,
ItemBlockPowerConverterSteam.class,
converterBlockSteam.getUnlocalizedName()
);
GameRegistry.registerTileEntity(TileEntitySteamConsumer.class, "SteamConsumer");
GameRegistry.registerTileEntity(TileEntitySteamProducer.class, "SteamProducer");
if (Loader.isModLoaded("factorization")) {
converterBlockFactorization = new BlockPowerConverterFactorization();
registerBlock(
converterBlockFactorization,
ItemBlockPowerConverterFactorization.class,
converterBlockFactorization.getUnlocalizedName()
);
GameRegistry.registerTileEntity(
TileEntityPowerConverterFactorizationConsumer.class, "FZConsumer"
);
GameRegistry.registerTileEntity(
TileEntityPowerConverterFactorizationProducer.class, "FZProducer"
);
}
}
private static void registerBlock(Block block, Class itemclass, String name) {
GameRegistry.registerBlock(
block, itemclass, TextureUtils.stripUnlocalizedName(name)
);
}
private static void registerBlock(Block block, String name) {
GameRegistry.registerBlock(block, TextureUtils.stripUnlocalizedName(name));
}
}

View file

@ -0,0 +1,14 @@
package covers1624.powerconverters.init;
import covers1624.powerconverters.item.DebugItem;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.Item;
public class ModItems {
public static Item debugItem;
public static void init() {
debugItem = new DebugItem();
GameRegistry.registerItem(debugItem, "debugItem");
}
}

View file

@ -0,0 +1,62 @@
package covers1624.powerconverters.init;
import covers1624.powerconverters.api.registry.PowerSystemRegistry;
import covers1624.powerconverters.api.registry.UniversalChargerRegistry;
import covers1624.powerconverters.charge.ChargeHandlerIndustrialCraft;
import covers1624.powerconverters.charge.ChargeHandlerRedstoneFlux;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.util.RFHelper;
public class PowerSystems {
public static PowerSystemRegistry.PowerSystem powerSystemIndustrialCraft;
public static PowerSystemRegistry.PowerSystem powerSystemSteam;
public static PowerSystemRegistry.PowerSystem powerSystemFactorization;
public static PowerSystemRegistry.PowerSystem powerSystemRedstoneFlux;
public static PowerSystemRegistry.PowerSystem powerSystemPneumaticCraft;
public static void init() {
powerSystemIndustrialCraft = new PowerSystemRegistry.PowerSystem(
"IndustrialCraft",
"IC2",
4000,
new String[] { "LV", "MV", "HV", "EV" },
new int[] { 32, 128, 512, 2048 },
"EU/t"
);
powerSystemSteam
= new PowerSystemRegistry.PowerSystem("Steam", "STEAM", 875, "mB/t");
powerSystemFactorization
= new PowerSystemRegistry.PowerSystem("Factorization", "FZ", 175, "CG/t");
powerSystemRedstoneFlux
= new PowerSystemRegistry.PowerSystem("RedstoneFlux", "RF", 1000, "RF/t");
powerSystemPneumaticCraft
= new PowerSystemRegistry.PowerSystem("PneumaticCraft", "PSI", 100, "PSI");
powerSystemIndustrialCraft
.setConsumerState(ConfigurationHandler.dissableIC2Consumer)
.setProducerState(ConfigurationHandler.dissableIC2Producer);
powerSystemSteam.setConsumerState(ConfigurationHandler.dissableSteamConsumer)
.setProducerState(ConfigurationHandler.dissableSteamProducer);
powerSystemFactorization
.setConsumerState(ConfigurationHandler.dissableFactorizationConsumer)
.setProducerState(ConfigurationHandler.dissableFactorizationProducer);
powerSystemRedstoneFlux.setConsumerState(ConfigurationHandler.dissableRFConsumer)
.setProducerState(ConfigurationHandler.dissableRFProducer);
PowerSystemRegistry.registerPowerSystem(powerSystemIndustrialCraft);
PowerSystemRegistry.registerPowerSystem(powerSystemSteam);
PowerSystemRegistry.registerPowerSystem(powerSystemFactorization);
PowerSystemRegistry.registerPowerSystem(powerSystemRedstoneFlux);
}
public static void initChargeHandlers() {
if (RFHelper.iEnergyContainerItemExists) {
UniversalChargerRegistry.registerChargeHandler(new ChargeHandlerRedstoneFlux()
);
}
if (Recipes.industrialCraftFound) {
UniversalChargerRegistry.registerChargeHandler(
new ChargeHandlerIndustrialCraft()
);
}
}
}

View file

@ -0,0 +1,422 @@
package covers1624.powerconverters.init;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import covers1624.powerconverters.util.FMLLogHelper;
import covers1624.powerconverters.util.LogHelper;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import org.apache.logging.log4j.Level;
public class Recipes {
private static List defaultRecipes = new ArrayList();
private static List curentRecipes = new ArrayList();
public static boolean buildcraftFound = Loader.isModLoaded("BuildCraft|Energy");
public static boolean industrialCraftFound = Loader.isModLoaded("IC2");
public static boolean thermalExpansionFound = Loader.isModLoaded("ThermalExpansion");
public static boolean factorizationFound = Loader.isModLoaded("factorization");
public static boolean railcraftFound = Loader.isModLoaded("Railcraft");
public static void initDefaults() {
Recipes.Defaults.mainRecipes();
Recipes.Defaults.redstoneFluxRecipes();
Recipes.Defaults.industrialCraft2Recipes();
Recipes.Defaults.railcraftRecipes();
Recipes.Defaults.factorizationRecipes();
}
public static List getCurrentRecipes() {
return curentRecipes;
}
public static List getDefaultRecipes() {
return defaultRecipes;
}
public static void setDefaultRecipes(List recipes) {
defaultRecipes = recipes;
}
private static void addRecipe(ItemStack output, Object... params) {
String s = "";
int i = 0;
int j = 0;
int k = 0;
if (params[i] instanceof String[]) {
String[] astring = (String[]) ((String[]) params[i++]);
for (int l = 0; l < astring.length; ++l) {
String s1 = astring[l];
++k;
j = s1.length();
s = s + s1;
}
} else {
while (params[i] instanceof String) {
String s2 = (String) params[i++];
++k;
j = s2.length();
s = s + s2;
}
}
HashMap hashmap;
for (hashmap = new HashMap(); i < params.length; i += 2) {
Character character = (Character) params[i];
ItemStack itemstack1 = null;
if (params[i + 1] instanceof Item) {
itemstack1 = new ItemStack((Item) params[i + 1]);
} else if (params[i + 1] instanceof Block) {
itemstack1 = new ItemStack((Block) params[i + 1], 1, 32767);
} else if (params[i + 1] instanceof ItemStack) {
itemstack1 = (ItemStack) params[i + 1];
}
hashmap.put(character, itemstack1);
}
ItemStack[] aitemstack = new ItemStack[j * k];
for (int i1 = 0; i1 < j * k; ++i1) {
char c0 = s.charAt(i1);
if (hashmap.containsKey(c0)) {
aitemstack[i1] = ((ItemStack) hashmap.get(c0)).copy();
} else {
aitemstack[i1] = null;
}
}
ShapedRecipes shapedrecipes = new ShapedRecipes(j, k, aitemstack, output);
curentRecipes.add(shapedrecipes);
CraftingManager.getInstance().getRecipeList().add(shapedrecipes);
}
private static void addShapelessRecipe(ItemStack output, Object... params) {
ArrayList arraylist = new ArrayList();
Object[] aobject = params;
int i = params.length;
for (int j = 0; j < i; ++j) {
Object object1 = aobject[j];
if (object1 instanceof ItemStack) {
arraylist.add(((ItemStack) object1).copy());
} else if (object1 instanceof Item) {
arraylist.add(new ItemStack((Item) object1));
} else {
if (!(object1 instanceof Block)) {
throw new RuntimeException("Invalid shapeless recipy!");
}
arraylist.add(new ItemStack((Block) object1));
}
}
curentRecipes.add(new ShapelessRecipes(output, arraylist));
CraftingManager.getInstance().getRecipeList().add(
new ShapelessRecipes(output, arraylist)
);
}
public static class Defaults {
public static void mainRecipes() {
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockCommon, 1, 0),
"GRG",
"LDL",
"GRG",
'G',
Items.gold_ingot,
'R',
Items.redstone,
'L',
Blocks.glass,
'D',
Items.diamond
);
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockCommon, 1, 2),
"GRG",
"ICI",
"GRG",
'G',
Items.gold_ingot,
'R',
Items.redstone,
'I',
Items.iron_ingot,
'C',
Blocks.chest
);
}
public static void redstoneFluxRecipes() {
Block blockDynamo = GameRegistry.findBlock("ThermalExpansion", "Dynamo");
Block engineBlock = GameRegistry.findBlock("BuildCraft|Core", "engineBlock");
Block engineBlock2
= GameRegistry.findBlock("BuildCraft|Energy", "engineBlock");
if (Recipes.thermalExpansionFound) {
LogHelper.trace("ThermalExpansion Found.");
if (blockDynamo != null) {
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockRedstoneFlux, 1, 0),
"G G",
" E ",
"G G",
'G',
Items.gold_ingot,
'E',
new ItemStack(blockDynamo, 1, 1)
);
} else {
LogHelper.error(
"A Error has occored while trying to lookup \"Dynamo\" in GameRegistry. This can be caused by an outdated version of PowerConverters or ThermalExpansion. Please Ensure you are using the Latest version of both before submitting a bug report.Due to this the recipes for RedstoneFlux Consumer / Producer will not use ThermalExpansion Components."
);
}
} else {
LogHelper.trace("ThermalExpansion Not Found.");
}
if (Recipes.buildcraftFound) {
LogHelper.trace("BuildCraft Found.");
if (engineBlock != null) {
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockRedstoneFlux, 1, 0),
"G G",
" E ",
"G G",
'G',
Items.gold_ingot,
'E',
new ItemStack(engineBlock, 1, 1)
);
} else if (engineBlock2 != null) {
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockRedstoneFlux, 1, 0),
"G G",
" E ",
"G G",
'G',
Items.gold_ingot,
'E',
new ItemStack(engineBlock2, 1, 1)
);
} else {
LogHelper.error(
"A Error has occored while trying to lookup \"engineBlock\" in GameRegistry. This can be caused by an outdated version of PowerConverters or BuildCraft. Please Ensure you are using the Latest version of both before submitting a bug report.Due to this the recipes for RedstoneFlux Consumer / Producer will not use BuildCraft Components."
);
}
} else {
LogHelper.trace("BuildCraft not Found.");
}
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockRedstoneFlux, 1, 1),
new ItemStack(ModBlocks.converterBlockRedstoneFlux, 1, 0)
);
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockRedstoneFlux, 1, 0),
new ItemStack(ModBlocks.converterBlockRedstoneFlux, 1, 1)
);
}
public static void industrialCraft2Recipes() {
if (Recipes.industrialCraftFound) {
try {
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 0),
"G G",
" T ",
"G G",
'G',
Items.gold_ingot,
'T',
Class.forName("ic2.core.Ic2Items")
.getField("lvTransformer")
.get((Object) null)
);
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 2),
"G G",
" T ",
"G G",
'G',
Items.gold_ingot,
'T',
Class.forName("ic2.core.Ic2Items")
.getField("mvTransformer")
.get((Object) null)
);
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 4),
"G G",
" T ",
"G G",
'G',
Items.gold_ingot,
'T',
Class.forName("ic2.core.Ic2Items")
.getField("hvTransformer")
.get((Object) null)
);
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 6),
"G G",
" T ",
"G G",
'G',
Items.gold_ingot,
'T',
Class.forName("ic2.core.Ic2Items")
.getField("mfsUnit")
.get((Object) null)
);
} catch (Exception var1) {
FMLLogHelper.logException(
Level.ERROR,
"Found IC2 But Failed To Load Recipes, Mabey They Changed Their Item / Block Names? This is not a fatal error only recipes wont be registered.",
var1
);
}
}
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 1),
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 0)
);
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 0),
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 1)
);
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 3),
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 2)
);
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 2),
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 3)
);
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 5),
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 4)
);
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 4),
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 5)
);
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 7),
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 6)
);
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 6),
new ItemStack(ModBlocks.converterBlockIndustrialCraft, 1, 7)
);
}
public static void railcraftRecipes() {
try {
if (Recipes.railcraftFound) {
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockSteam, 1, 0),
"G G",
" E ",
"G G",
'G',
Items.gold_ingot,
'E',
new ItemStack(
(Block
) ((Block) Class
.forName("mods.railcraft.common.blocks.RailcraftBlocks"
)
.getMethod("getBlockMachineBeta")
.invoke((Object) null)),
1,
8
)
);
}
if (Recipes.factorizationFound) {
Object fzRegistry = Class.forName("factorization.shared.Core")
.getField("registry")
.get((Object) null);
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockSteam, 1, 0),
"G G",
" E ",
"G G",
'G',
Items.gold_ingot,
'E',
Class.forName("factorization.common.Registry")
.getField("steamturbine_item")
.get(fzRegistry)
);
}
} catch (Exception var1) {
FMLLogHelper.logException(
Level.ERROR,
"Found Railcraft / Factorization But Failed To Load Recipes, Mabey They Changed Ther Item / Block Names? This is not a fatal error only recipes wont be registered.",
var1
);
}
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockSteam, 1, 1),
new ItemStack(ModBlocks.converterBlockSteam, 1, 0)
);
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockSteam, 1, 0),
new ItemStack(ModBlocks.converterBlockSteam, 1, 1)
);
}
public static void factorizationRecipes() {
try {
if (Recipes.factorizationFound) {
Object fzRegistry = Class.forName("factorization.shared.Core")
.getField("registry")
.get((Object) null);
Recipes.addRecipe(
new ItemStack(ModBlocks.converterBlockFactorization, 1, 0),
"I I",
" B ",
"I I",
'I',
Items.gold_ingot,
'B',
Class.forName("factorization.common.Registry")
.getField("solarboiler_item")
.get(fzRegistry)
);
}
} catch (Exception var1) {
FMLLogHelper.logException(
Level.ERROR,
"Found Factorization But Failed To Load Recipes, Mabey They Changed Their Item / Block Names? This is not a fatal error only recipes wont be registered.",
var1
);
}
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockFactorization, 1, 1),
new ItemStack(ModBlocks.converterBlockFactorization, 1, 0)
);
Recipes.addShapelessRecipe(
new ItemStack(ModBlocks.converterBlockFactorization, 1, 0),
new ItemStack(ModBlocks.converterBlockFactorization, 1, 1)
);
}
}
}

View file

@ -0,0 +1,13 @@
package covers1624.powerconverters.init;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.worldgen.FlatBedrockWorldGen;
import cpw.mods.fml.common.registry.GameRegistry;
public class WorldGenerators {
public static void init() {
if (ConfigurationHandler.doFlatBedrock) {
GameRegistry.registerWorldGenerator(new FlatBedrockWorldGen(), 1);
}
}
}

View file

@ -0,0 +1,92 @@
package covers1624.powerconverters.item;
import java.util.ArrayList;
import covers1624.powerconverters.tile.main.TileEntityBridgeComponent;
import covers1624.powerconverters.tile.main.TileEntityEnergyBridge;
import covers1624.powerconverters.util.IAdvancedLogTile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class DebugItem extends Item {
public DebugItem() {
this.setUnlocalizedName("pcdebugitem");
this.setMaxStackSize(1);
}
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister ir) {
super.itemIcon = ir.registerIcon("powerconverters:" + this.getUnlocalizedName());
}
public boolean onItemUse(
ItemStack stack,
EntityPlayer player,
World world,
int x,
int y,
int z,
int side,
float hitx,
float hity,
float hitz
) {
boolean success = false;
TileEntity te = world.getTileEntity(x, y, z);
TileEntityEnergyBridge teb = null;
if (world.isRemote) {
player.addChatMessage(new ChatComponentText("-Client-"));
return false;
} else {
player.addChatMessage(new ChatComponentText("-Server-"));
if (te instanceof TileEntityEnergyBridge
|| te instanceof TileEntityBridgeComponent) {
if (te instanceof TileEntityBridgeComponent) {
teb = ((TileEntityBridgeComponent) te).getFirstBridge();
} else {
teb = (TileEntityEnergyBridge) te;
}
double energyamount
= 100.0 * (teb.getEnergyStored() / teb.getEnergyStoredMax());
String energy = String.valueOf((int) energyamount);
player.addChatMessage(
new ChatComponentText("Energy Bridge Is " + energy + "% Full")
);
success = true;
}
if (te instanceof IAdvancedLogTile) {
ArrayList info = new ArrayList();
((IAdvancedLogTile) te)
.getTileInfo(
info,
ForgeDirection.VALID_DIRECTIONS[side],
player,
player.isSneaking()
);
for (int i = 0; i < info.size(); ++i) {
player.addChatMessage((IChatComponent) info.get(i));
}
success = true;
} else if (world.getBlock(x, y, z) != null) {
player.addChatMessage(
new ChatComponentText(String.valueOf(world.getBlockMetadata(x, y, z)))
);
}
return success;
}
}
}

View file

@ -0,0 +1,52 @@
package covers1624.powerconverters.item;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockPowerConverterCommon extends ItemBlock {
public ItemBlockPowerConverterCommon(Block block) {
super(block);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
public int getMetadata(int i) {
return i;
}
public String getUnlocalizedName(ItemStack itemstack) {
int md = itemstack.getItemDamage();
if (md == 0) {
return "powerconverters.common.bridge";
} else {
return md == 2 ? "powerconverters.common.charger" : "unknown";
}
}
public void
addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean par4) {
int md = itemstack.getItemDamage();
if (md == 0) {
list.add("Common Block in the Power Converter MultiBlock");
}
if (md == 2) {
list.add("A universal Charging Block (WIP)");
}
if (md != 0 && md != 2) {
list.add("ERROR in tool tips contact covers1624");
}
}
public void getSubItems(Item item, CreativeTabs creativeTab, List subTypes) {
subTypes.add(new ItemStack(item, 1, 0));
subTypes.add(new ItemStack(item, 1, 2));
}
}

View file

@ -0,0 +1,36 @@
package covers1624.powerconverters.item;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockPowerConverterFactorization extends ItemBlock {
public ItemBlockPowerConverterFactorization(Block block) {
super(block);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
public int getMetadata(int i) {
return i;
}
public String getUnlocalizedName(ItemStack itemstack) {
int md = itemstack.getItemDamage();
if (md == 0) {
return "powerconverters.fz.consumer";
} else {
return md == 1 ? "powerconverters.fz.producer" : "unknown";
}
}
public void getSubItems(Item item, CreativeTabs creativeTab, List subTypes) {
for (int i = 0; i <= 1; ++i) {
subTypes.add(new ItemStack(item, 1, i));
}
}
}

View file

@ -0,0 +1,73 @@
package covers1624.powerconverters.item;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockPowerConverterIndustrialCraft extends ItemBlock {
public ItemBlockPowerConverterIndustrialCraft(Block block) {
super(block);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
public int getMetadata(int i) {
return i;
}
public String getUnlocalizedName(ItemStack itemstack) {
int md = itemstack.getItemDamage();
if (md == 0) {
return "powerconverters.ic2.lv.consumer";
} else if (md == 1) {
return "powerconverters.ic2.lv.producer";
} else if (md == 2) {
return "powerconverters.ic2.mv.consumer";
} else if (md == 3) {
return "powerconverters.ic2.mv.producer";
} else if (md == 4) {
return "powerconverters.ic2.hv.consumer";
} else if (md == 5) {
return "powerconverters.ic2.hv.producer";
} else if (md == 6) {
return "powerconverters.ic2.ev.consumer";
} else {
return md == 7 ? "powerconverters.ic2.ev.producer" : "unknown";
}
}
public void
addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean par4) {
int md = itemstack.getItemDamage();
if (md == 0) {
list.add("IC2 LV Consumer, MAX Input: 32 EU/t (BatBox)");
} else if (md == 1) {
list.add("IC2 LV Producer, MAX Output: 32 EU/t (BatBox)");
} else if (md == 2) {
list.add("IC2 MV Consumer, MAX Input: 128 EU/t (CESU)");
} else if (md == 3) {
list.add("IC2 MV Producer, MAX Output: 128 EU/t (CESU)");
} else if (md == 4) {
list.add("IC2 HV Consumer, MAX Input: 512 EU/t (MFE)");
} else if (md == 5) {
list.add("IC2 HV Producer, MAX Output: 512 EU/t (MFE)");
} else if (md == 6) {
list.add("IC2 EV Consumer, MAX Input: 2048 EU/t (MFSU)");
} else if (md == 7) {
list.add("IC2 EV Producer, MAX Output: 2048 EU/t (MFSU)");
} else {
list.add("ERROR in tool tips contact covers1624");
}
}
public void getSubItems(Item item, CreativeTabs creativeTab, List subTypes) {
for (int i = 0; i <= 7; ++i) {
subTypes.add(new ItemStack(item, 1, i));
}
}
}

View file

@ -0,0 +1,49 @@
package covers1624.powerconverters.item;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockPowerConverterRedstoneFlux extends ItemBlock {
public ItemBlockPowerConverterRedstoneFlux(Block block) {
super(block);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
public int getMetadata(int i) {
return i;
}
public String getUnlocalizedName(ItemStack itemstack) {
int md = itemstack.getItemDamage();
if (md == 0) {
return "powerconverters.rf.consumer";
} else {
return md == 1 ? "powerconverters.rf.producer" : "unknown";
}
}
public void
addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean par4) {
int md = itemstack.getItemDamage();
if (md == 0) {
list.add("Consumes RedstoneFlux");
} else if (md == 1) {
list.add("Produces RedstoneFlux");
} else {
list.add("ERROR in tool tips contact covers1624");
}
}
public void getSubItems(Item item, CreativeTabs creativeTab, List subTypes) {
for (int i = 0; i <= 1; ++i) {
subTypes.add(new ItemStack(item, 1, i));
}
}
}

View file

@ -0,0 +1,36 @@
package covers1624.powerconverters.item;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class ItemBlockPowerConverterSteam extends ItemBlock {
public ItemBlockPowerConverterSteam(Block block) {
super(block);
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
public int getMetadata(int i) {
return i;
}
public String getUnlocalizedName(ItemStack itemstack) {
int md = itemstack.getItemDamage();
if (md == 0) {
return "powerconverters.steam.consumer";
} else {
return md == 1 ? "powerconverters.steam.producer" : "unknown";
}
}
public void getSubItems(Item item, CreativeTabs creativeTab, List subTypes) {
for (int i = 0; i <= 1; ++i) {
subTypes.add(new ItemStack(item, 1, i));
}
}
}

View file

@ -0,0 +1,268 @@
package covers1624.powerconverters.nei;
import java.util.ArrayList;
import java.util.List;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.PositionedStack;
import codechicken.nei.api.IOverlayHandler;
import codechicken.nei.api.IRecipeOverlayRenderer;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.ICraftingHandler;
import codechicken.nei.recipe.IUsageHandler;
import covers1624.powerconverters.util.LogHelper;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
public class InfoHandler implements IUsageHandler, ICraftingHandler {
public static FontRenderer fontRenderer;
public static int color;
ItemStack displayItem;
boolean precise = false;
String id;
String name;
String[] info;
public boolean checkedOrder = false;
int noLinesPerPage = 12;
public final String suffix = ".documentation";
public InfoHandler() {
this.displayItem = null;
}
public InfoHandler(ItemStack item) {
if (!StatCollector.canTranslate(item.getUnlocalizedName() + ".documentation")
&& !StatCollector.canTranslate(
item.getUnlocalizedName() + ".documentation"
+ ".0"
)) {
this.id = item.getItem().getUnlocalizedName();
this.name
= StatCollector.translateToLocal(item.getItem().getUnlocalizedName());
this.precise = false;
} else {
this.id = item.getUnlocalizedName();
this.name = StatCollector.translateToLocal(item.getUnlocalizedName());
this.precise = true;
}
if (StatCollector.canTranslate(this.id + ".documentation")) {
List list = this.splitString(
StatCollector.translateToLocal(this.id + ".documentation")
);
this.info = (String[]) ((String[]) list.toArray(new String[list.size()]));
} else {
ArrayList temp = new ArrayList();
for (int i = 0; StatCollector.canTranslate(
this.id + ".documentation"
+ "." + i
);
++i) {
String a = StatCollector.translateToLocal(
this.id + ".documentation"
+ "." + i
);
temp.addAll(this.splitString(a));
}
this.info = (String[]) ((String[]) temp.toArray(new String[temp.size()]));
}
this.displayItem = item.copy();
this.displayItem.stackSize = 1;
}
public void drawBackground(int arg0) {}
public void drawForeground(int recipe) {
List text = fontRenderer.listFormattedStringToWidth(
this.info[recipe], this.getWidth() - 8
);
for (int i = 0; i < text.size(); ++i) {
String toDraw = (String) text.get(i);
GuiDraw.drawString(
toDraw,
this.getWidth() / 2 - GuiDraw.getStringWidth(toDraw) / 2,
18 + i * 8,
color,
false
);
}
}
public List splitString(String input) {
ArrayList list = new ArrayList();
List page = fontRenderer.listFormattedStringToWidth(input, this.getWidth() - 8);
if (page.size() < this.noLinesPerPage) {
list.add(input);
} else {
String temp = "";
for (int i = 0; i < page.size(); ++i) {
temp = temp + (String) page.get(i) + " ";
if (i > 0 && i % this.noLinesPerPage == 0) {
String temp2 = temp.trim();
list.add(temp2);
temp = "";
}
}
temp = temp.trim();
if (!"".equals(temp)) {
list.add(temp);
}
}
return list;
}
public int getWidth() {
return 166;
}
public List getIngredientStacks(int arg0) {
return new ArrayList();
}
public List getOtherStacks(int arg0) {
return new ArrayList();
}
public IOverlayHandler getOverlayHandler(GuiContainer arg0, int arg1) {
return null;
}
public IRecipeOverlayRenderer getOverlayRenderer(GuiContainer gui, int arg1) {
return null;
}
public String getRecipeName() {
if (this.displayItem == null) {
return "Documentation";
} else {
String s = Item.itemRegistry.getNameForObject(this.displayItem.getItem());
String modid = s.split(":")[0];
if ("minecraft".equals(modid)) {
return "Minecraft";
} else {
ModContainer selectMod
= (ModContainer) Loader.instance().getIndexedModList().get(modid);
return selectMod == null ? modid
: (!selectMod.getMetadata().autogenerated
? selectMod.getMetadata().name
: selectMod.getName());
}
}
}
public PositionedStack getResultStack(int arg0) {
return new PositionedStack(this.displayItem, this.getWidth() / 2 - 9, 0, false);
}
public List
handleItemTooltip(GuiRecipe gui, ItemStack stack, List currenttip, int recipe) {
return currenttip;
}
public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) {
return currenttip;
}
public boolean hasOverlay(GuiContainer gui, Container container, int recipe) {
return false;
}
public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) {
return false;
}
public boolean mouseClicked(GuiRecipe gui, int button, int recipe) {
return false;
}
public int numRecipes() {
return this.displayItem != null && this.info != null ? this.info.length : 0;
}
public void onUpdate() {}
public int recipiesPerPage() {
return 1;
}
public boolean isValidItem(ItemStack item) {
boolean flag = false;
LogHelper.info(item.getUnlocalizedName() + ".documentation");
if (StatCollector.canTranslate(item.getUnlocalizedName() + ".documentation")) {
flag = true;
} else if (StatCollector.canTranslate(
item.getItem().getUnlocalizedName() + ".documentation"
)) {
flag = true;
} else if (StatCollector.canTranslate(
item.getUnlocalizedName() + ".documentation"
+ ".0"
)) {
flag = true;
} else if (StatCollector.canTranslate(
item.getItem().getUnlocalizedName() + ".documentation"
+ ".0"
)) {
flag = true;
}
return flag;
}
public IUsageHandler getUsageHandler(String inputId, Object... ingredients) {
if (!inputId.equals("item")) {
return this;
} else {
Object[] ingredientsArray = ingredients;
int ingredientsLength = ingredients.length;
for (int i = 0; i < ingredientsLength; ++i) {
Object ingredient = ingredientsArray[i];
if (ingredient instanceof ItemStack
&& this.isValidItem((ItemStack) ingredient)) {
return new InfoHandler((ItemStack) ingredient);
}
}
return this;
}
}
public ICraftingHandler getRecipeHandler(String outputId, Object... results) {
if (!outputId.equals("item")) {
return this;
} else {
Object[] ingredientsArray = results;
int ingredientsLength = results.length;
for (int i = 0; i < ingredientsLength; ++i) {
Object ingredient = ingredientsArray[i];
if (ingredient instanceof ItemStack
&& this.isValidItem((ItemStack) ingredient)) {
return new InfoHandler((ItemStack) ingredient);
}
}
return this;
}
}
static {
fontRenderer = Minecraft.getMinecraft().fontRenderer;
color = -12566464;
}
}

View file

@ -0,0 +1,75 @@
package covers1624.powerconverters.nei;
import java.util.Iterator;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.ICraftingHandler;
import codechicken.nei.recipe.ShapedRecipeHandler;
import codechicken.nei.recipe.ShapelessRecipeHandler;
import covers1624.powerconverters.init.Recipes;
import covers1624.powerconverters.util.LogHelper;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
public class NEIInfoHandlerConfig implements IConfigureNEI {
public void loadConfig() {
LogHelper.info("NEI Has called us to init.");
API.registerUsageHandler(new InfoHandler());
}
public String getName() {
return "PowerConverters: Nei Integration";
}
public String getVersion() {
return "1";
}
public static void addRecipesToNEI() {
Iterator i$ = GuiCraftingRecipe.craftinghandlers.iterator();
while (true) {
ICraftingHandler handler;
IRecipe recipe;
do {
if (!i$.hasNext()) {
return;
}
handler = (ICraftingHandler) i$.next();
if (handler.getClass().getName() == ShapedRecipeHandler.class.getName()) {
ShapedRecipeHandler shapedRecipeHandler = (ShapedRecipeHandler) handler;
i$ = Recipes.getCurrentRecipes().iterator();
while (i$.hasNext()) {
recipe = (IRecipe) i$.next();
if (recipe instanceof ShapedRecipes) {
shapedRecipeHandler.getClass();
ShapedRecipeHandler.CachedShapedRecipe shapedRecipe = shapedRecipeHandler.new CachedShapedRecipe(
(ShapedRecipes) recipe);
shapedRecipe.computeVisuals();
shapedRecipeHandler.arecipes.add(shapedRecipe);
}
}
}
} while (handler.getClass().getName() != ShapelessRecipeHandler.class.getName());
ShapelessRecipeHandler shapelessRecipeHandler = (ShapelessRecipeHandler) handler;
i$ = Recipes.getCurrentRecipes().iterator();
while (i$.hasNext()) {
recipe = (IRecipe) i$.next();
if (recipe instanceof ShapelessRecipes) {
ShapelessRecipes shapelessRecipe = (ShapelessRecipes) recipe;
shapelessRecipeHandler.getClass();
ShapelessRecipeHandler.CachedShapelessRecipe cachedShapelessRecipe = shapelessRecipeHandler.new CachedShapelessRecipe(
shapelessRecipe.recipeItems, shapelessRecipe.getRecipeOutput());
shapelessRecipeHandler.arecipes.add(cachedShapelessRecipe);
}
}
}
}
}

View file

@ -0,0 +1,15 @@
package covers1624.powerconverters.net;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.entity.player.EntityPlayer;
public abstract class AbstractPacket {
public abstract void encodeInto(ChannelHandlerContext var1, ByteBuf var2);
public abstract void decodeInto(ChannelHandlerContext var1, ByteBuf var2);
public abstract void handleClientSide(EntityPlayer var1);
public abstract void handleServerSide(EntityPlayer var1);
}

View file

@ -0,0 +1,64 @@
package covers1624.powerconverters.net;
import covers1624.powerconverters.PowerConverters;
import covers1624.powerconverters.api.bridge.BridgeSideData;
import covers1624.powerconverters.tile.main.TileEntityEnergyBridge;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class EnergyBridgeSyncPacket extends AbstractPacket {
private NBTTagCompound tagCompound;
public EnergyBridgeSyncPacket() {}
public EnergyBridgeSyncPacket(NBTTagCompound tag, int x, int y, int z) {
this.tagCompound = tag;
this.tagCompound.setInteger("X", x);
this.tagCompound.setInteger("Y", y);
this.tagCompound.setInteger("Z", z);
}
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
ByteBufUtils.writeTag(buffer, this.tagCompound);
}
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
this.tagCompound = ByteBufUtils.readTag(buffer);
}
public void handleClientSide(EntityPlayer player) {
int x = this.tagCompound.getInteger("X");
int y = this.tagCompound.getInteger("Y");
int z = this.tagCompound.getInteger("Z");
TileEntity tileEntity
= PowerConverters.proxy.getClientWorld().getTileEntity(x, y, z);
if (!(tileEntity instanceof TileEntityEnergyBridge)) {
throw new RuntimeException(
String.format("Tile @ %s, %s, %s, Does not match the server.", x, y, z)
);
} else {
TileEntityEnergyBridge energyBridge = (TileEntityEnergyBridge) tileEntity;
ForgeDirection[] arr$ = ForgeDirection.VALID_DIRECTIONS;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
ForgeDirection dir = arr$[i$];
NBTTagCompound tag
= this.tagCompound.getCompoundTag(String.valueOf(dir.ordinal()));
BridgeSideData data = new BridgeSideData();
data.loadFromNBT(tag);
energyBridge.setClientDataForSide(dir, data);
}
energyBridge.setIsInputLimited(this.tagCompound.getBoolean("InputLimited"));
energyBridge.setEnergyScaled(this.tagCompound.getDouble("Energy"));
}
}
public void handleServerSide(EntityPlayer player) {}
}

View file

@ -0,0 +1,174 @@
package covers1624.powerconverters.net;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.LinkedList;
import java.util.List;
import covers1624.powerconverters.PowerConverters;
import covers1624.powerconverters.util.LogHelper;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
import cpw.mods.fml.common.network.FMLOutboundHandler;
import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageCodec;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.INetHandler;
import net.minecraft.network.NetHandlerPlayServer;
// TODO: _____ ___ ____ ___ __ _______ _____
// TODO: |_ _/ _ \| _ \ / _ \ _ \ \ / /_ _| ___|
// TODO: | || | | | | | | | | (_) \ \ /\ / / | | | |_
// TODO: | || |_| | |_| | |_| |_ \ V V / | | | _|
// TODO: |_| \___/|____/ \___/(_) \_/\_/ |_| |_|
@Sharable
public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, AbstractPacket> {
private EnumMap channels;
private LinkedList packets = new LinkedList();
private boolean isPostInitialised = false;
public static final PacketPipeline INSTANCE = new PacketPipeline();
public boolean registerPacket(Class clazz) {
if (this.packets.size() > 256) {
LogHelper.fatal("Failed to register packet, The array is full.");
return false;
} else if (this.packets.contains(clazz)) {
LogHelper.fatal("Packet Allready Registered: " + clazz.toString());
return false;
} else if (this.isPostInitialised) {
LogHelper.fatal(
"Already started PostInit, You are doing it wrong, Add Packets any time before PostInit.");
return false;
} else {
this.packets.add(clazz);
return true;
}
}
protected void encode(ChannelHandlerContext ctx, AbstractPacket msg, List out)
throws Exception {
ByteBuf buffer = Unpooled.buffer();
Class clazz = msg.getClass();
if (!this.packets.contains(msg.getClass())) {
throw new NullPointerException(
"No Packet Registered for: " + msg.getClass().getCanonicalName());
} else {
byte discriminator = (byte) this.packets.indexOf(clazz);
buffer.writeByte(discriminator);
msg.encodeInto(ctx, buffer);
FMLProxyPacket proxyPacket = new FMLProxyPacket(
buffer.copy(),
(String) ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
out.add(proxyPacket);
}
}
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List out)
throws Exception {
ByteBuf payload = msg.payload();
byte discriminator = payload.readByte();
Class clazz = (Class) this.packets.get(discriminator);
if (clazz == null) {
throw new NullPointerException(
"No packet registered for discriminator: " + discriminator);
} else {
AbstractPacket pkt = (AbstractPacket) clazz.newInstance();
pkt.decodeInto(ctx, payload.slice());
switch (FMLCommonHandler.instance().getEffectiveSide()) {
case CLIENT:
EntityPlayer player = this.getClientPlayer();
pkt.handleClientSide(player);
break;
case SERVER:
INetHandler netHandler = (INetHandler) ctx.channel()
.attr(NetworkRegistry.NET_HANDLER)
.get();
player = ((NetHandlerPlayServer) netHandler).playerEntity;
pkt.handleServerSide(player);
}
}
}
public void initalise() {
this.channels = NetworkRegistry.INSTANCE.newChannel(
"Power Converters 3", new ChannelHandler[] { this });
}
public void postInitialise() {
if (!this.isPostInitialised) {
this.isPostInitialised = true;
Collections.sort(this.packets, new Comparator<Class<?>>() {
public int compare(Class clazz1, Class clazz2) {
int com = String.CASE_INSENSITIVE_ORDER.compare(
clazz1.getCanonicalName(), clazz2.getCanonicalName());
if (com == 0) {
com = clazz1.getCanonicalName().compareTo(clazz2.getCanonicalName());
}
return com;
}
});
}
}
@SideOnly(Side.CLIENT)
private EntityPlayer getClientPlayer() {
return PowerConverters.proxy.getClientPlayer();
}
public void sendToAll(AbstractPacket message) {
((FMLEmbeddedChannel) this.channels.get(Side.SERVER))
.attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(OutboundTarget.ALL);
((FMLEmbeddedChannel) this.channels.get(Side.SERVER)).writeAndFlush(message);
}
public void sendTo(AbstractPacket message, EntityPlayerMP player) {
((FMLEmbeddedChannel) this.channels.get(Side.SERVER))
.attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(OutboundTarget.PLAYER);
((FMLEmbeddedChannel) this.channels.get(Side.SERVER))
.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS)
.set(player);
((FMLEmbeddedChannel) this.channels.get(Side.SERVER)).writeAndFlush(message);
}
public void sendToAllAround(AbstractPacket message, NetworkRegistry.TargetPoint point) {
((FMLEmbeddedChannel) this.channels.get(Side.SERVER))
.attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(OutboundTarget.ALLAROUNDPOINT);
((FMLEmbeddedChannel) this.channels.get(Side.SERVER))
.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS)
.set(point);
((FMLEmbeddedChannel) this.channels.get(Side.SERVER)).writeAndFlush(message);
}
public void sendToDimension(AbstractPacket message, int dimensionId) {
((FMLEmbeddedChannel) this.channels.get(Side.SERVER))
.attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(OutboundTarget.DIMENSION);
((FMLEmbeddedChannel) this.channels.get(Side.SERVER))
.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS)
.set(dimensionId);
((FMLEmbeddedChannel) this.channels.get(Side.SERVER)).writeAndFlush(message);
}
public void sendToServer(AbstractPacket message) {
((FMLEmbeddedChannel) this.channels.get(Side.CLIENT))
.attr(FMLOutboundHandler.FML_MESSAGETARGET)
.set(OutboundTarget.TOSERVER);
((FMLEmbeddedChannel) this.channels.get(Side.CLIENT)).writeAndFlush(message);
}
}

View file

@ -0,0 +1,81 @@
package covers1624.powerconverters.net;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.init.Recipes;
import covers1624.powerconverters.nei.NEIInfoHandlerConfig;
import covers1624.powerconverters.util.IRecipeHandler;
import covers1624.powerconverters.util.LogHelper;
import covers1624.powerconverters.util.RecipeRemover;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class RecipeSyncPacket extends AbstractPacket {
private NBTTagCompound tagCompound;
public RecipeSyncPacket() {}
public RecipeSyncPacket(NBTTagCompound tag) {
this.tagCompound = tag;
}
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
ByteBufUtils.writeTag(buffer, this.tagCompound);
}
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
this.tagCompound = ByteBufUtils.readTag(buffer);
}
public void handleClientSide(EntityPlayer player) {
if (ConfigurationHandler.ignoreRecipesFromServer) {
LogHelper.trace("Ignoring recipe packet from server.");
} else {
NBTTagList tagList = this.tagCompound.getTagList("Recipes", 10);
List recipes = new ArrayList();
for (int i = 0; i < tagList.tagCount(); ++i) {
IRecipe recipe
= IRecipeHandler.readIRecipeFromTag(tagList.getCompoundTagAt(i));
if (recipe != null) {
recipes.add(recipe);
}
}
List currentOutputs = new ArrayList();
Iterator i$ = Recipes.getCurrentRecipes().iterator();
IRecipe recipe;
while (i$.hasNext()) {
recipe = (IRecipe) i$.next();
ItemStack stack = recipe.getRecipeOutput();
currentOutputs.add(stack);
}
RecipeRemover.removeAnyRecipes(currentOutputs);
i$ = recipes.iterator();
while (i$.hasNext()) {
recipe = (IRecipe) i$.next();
CraftingManager.getInstance().getRecipeList().add(recipe);
}
if (Loader.isModLoaded("NotEnoughItems")) {
NEIInfoHandlerConfig.addRecipesToNEI();
}
}
}
public void handleServerSide(EntityPlayer player) {}
}

View file

@ -0,0 +1,12 @@
package covers1624.powerconverters.proxy;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public interface IPCProxy {
void initRendering();
EntityPlayer getClientPlayer();
World getClientWorld();
}

View file

@ -0,0 +1,24 @@
package covers1624.powerconverters.proxy;
import covers1624.powerconverters.client.render.TileUniversalConduitRender;
import covers1624.powerconverters.tile.main.TileEnergyConduit;
import cpw.mods.fml.client.registry.ClientRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public class ProxyClient implements IPCProxy {
public void initRendering() {
ClientRegistry.bindTileEntitySpecialRenderer(
TileEnergyConduit.class, new TileUniversalConduitRender()
);
}
public EntityPlayer getClientPlayer() {
return Minecraft.getMinecraft().thePlayer;
}
public World getClientWorld() {
return Minecraft.getMinecraft().theWorld;
}
}

View file

@ -0,0 +1,16 @@
package covers1624.powerconverters.proxy;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public class ProxyServer implements IPCProxy {
public void initRendering() {}
public EntityPlayer getClientPlayer() {
return null;
}
public World getClientWorld() {
return null;
}
}

View file

@ -0,0 +1,11 @@
package covers1624.powerconverters.randomdebugshit;
// TODO: _____ ___ ____ ___ __ _______ _____
// TODO: |_ _/ _ \| _ \ / _ \ _ \ \ / /_ _| ___|
// TODO: | || | | | | | | | | (_) \ \ /\ / / | | | |_
// TODO: | || |_| | |_| | |_| |_ \ V V / | | | _|
// TODO: |_| \___/|____/ \___/(_) \_/\_/ |_| |_|
public class RandomDebugShit {
public static void init() {}
}

View file

@ -0,0 +1,23 @@
package covers1624.powerconverters.reference;
public class Reference {
public static final String MOD_ID = "PowerConverters3";
public static final String MOD_NAME = "Power Converters 3";
public static final String MOD_VERSION = "1.7.10-2.11";
public static final String MOD_PREFIX = "powerconverters:";
public static final String TEXTURE_FOLDER = "powerconverters:textures/";
public static final String GUI_FOLDER = "powerconverters:textures/gui/";
public static final String MODEL_FOLDER = "powerconverters:textures/model/";
public static final String TOOLTIP_ERROR = "ERROR in tool tips contact covers1624";
public static final String CLIENT_PROXY
= "covers1624.powerconverters.proxy.ProxyClient";
public static final String SERVER_PROXY
= "covers1624.powerconverters.proxy.ProxyServer";
public static final String GUI_FACTORY
= "covers1624.powerconverters.gui.PCGuiFactory";
public static final String BASIC_CATEGORY = "basic";
public static final String RECIPES_CATEGORY = "Recipes";
public static final String FEATURES_CATEGORY = "Features";
public static final String THROTTLES_CATEGORY = "Throttles";
public static final String DEVICES_CATEGORY = "Devices";
}

View file

@ -0,0 +1,30 @@
package covers1624.powerconverters.slot;
import java.util.Iterator;
import covers1624.powerconverters.api.charge.IChargeHandler;
import covers1624.powerconverters.api.registry.UniversalChargerRegistry;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ChargerInputSlot extends Slot {
public ChargerInputSlot(IInventory inventory, int slot, int xPos, int yPos) {
super(inventory, slot, xPos, yPos);
}
public boolean isItemValid(ItemStack stack) {
Iterator i$ = UniversalChargerRegistry.getChargeHandlers().iterator();
IChargeHandler handler;
do {
if (!i$.hasNext()) {
return false;
}
handler = (IChargeHandler) i$.next();
} while (!handler.canHandle(stack));
return true;
}
}

View file

@ -0,0 +1,15 @@
package covers1624.powerconverters.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ChargerOutputSlot extends Slot {
public ChargerOutputSlot(IInventory inventory, int slot, int xPos, int yPos) {
super(inventory, slot, xPos, yPos);
}
public boolean isItemValid(ItemStack p_75214_1_) {
return false;
}
}

View file

@ -0,0 +1,61 @@
package covers1624.powerconverters.tile.factorization;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.init.PowerSystems;
import covers1624.powerconverters.tile.main.TileEntityEnergyConsumer;
import factorization.api.Charge;
import factorization.api.Coord;
import factorization.api.IChargeConductor;
import net.minecraft.util.MathHelper;
public class TileEntityPowerConverterFactorizationConsumer
extends TileEntityEnergyConsumer implements IChargeConductor {
private Charge _charge = new Charge(this);
private double _chargeLastTick = 0.0;
private static final int _maxCG = 2000;
public TileEntityPowerConverterFactorizationConsumer() {
super(PowerSystems.powerSystemFactorization, 0, IChargeConductor.class);
}
public void updateEntity() {
super.updateEntity();
if (!super.worldObj.isRemote) {
if (!ConfigurationHandler.dissableFactorizationConsumer) {
if (this._charge.getValue() < 2000) {
this._charge.update();
}
if (this._charge.getValue() > 0) {
double used = (double) this._charge.tryTake(this._charge.getValue());
this._chargeLastTick = (double) MathHelper.floor_double(used);
this.storeEnergy(
(double) ((int
) (used
* (double
) PowerSystems.powerSystemFactorization.getScaleAmmount())),
false
);
} else {
this._chargeLastTick = 0.0;
}
}
}
}
public double getInputRate() {
return this._chargeLastTick;
}
public Charge getCharge() {
return this._charge;
}
public String getInfo() {
return null;
}
public Coord getCoord() {
return new Coord(this);
}
}

View file

@ -0,0 +1,59 @@
package covers1624.powerconverters.tile.factorization;
import java.util.Iterator;
import java.util.Map;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.init.PowerSystems;
import covers1624.powerconverters.tile.main.TileEntityEnergyProducer;
import factorization.api.Charge;
import factorization.api.Coord;
import factorization.api.IChargeConductor;
public class TileEntityPowerConverterFactorizationProducer
extends TileEntityEnergyProducer implements IChargeConductor {
private Charge _charge = new Charge(this);
private static final double _maxCG = 2000.0;
public TileEntityPowerConverterFactorizationProducer() {
super(PowerSystems.powerSystemFactorization, 0, IChargeConductor.class);
}
public double produceEnergy(double energy) {
if (ConfigurationHandler.dissableFactorizationProducer) {
return energy;
} else {
double CG = energy
/ (double) PowerSystems.powerSystemFactorization.getScaleAmmount();
Iterator i$ = this.getTiles().entrySet().iterator();
while (i$.hasNext()) {
Map.Entry output = (Map.Entry) i$.next();
IChargeConductor o = (IChargeConductor) output.getValue();
if (o != null && (double) o.getCharge().getValue() < 2000.0) {
double store
= Math.min(2000.0 - (double) o.getCharge().getValue(), CG);
o.getCharge().addValue((int) store);
CG -= store;
if (CG <= 0.0) {
break;
}
}
}
return CG * (double) PowerSystems.powerSystemFactorization.getScaleAmmount();
}
}
public Charge getCharge() {
return this._charge;
}
public String getInfo() {
return null;
}
public Coord getCoord() {
return new Coord(this);
}
}

View file

@ -0,0 +1,116 @@
package covers1624.powerconverters.tile.ic2;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.init.PowerSystems;
import covers1624.powerconverters.tile.main.TileEntityEnergyConsumer;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergyEmitter;
import ic2.api.energy.tile.IEnergySink;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityIndustrialCraftConsumer
extends TileEntityEnergyConsumer implements IEnergySink {
private boolean _isAddedToEnergyNet;
private boolean _didFirstAddToNet;
private double _euLastTick;
private long _lastTickInjected;
public TileEntityIndustrialCraftConsumer() {
this(0);
}
public TileEntityIndustrialCraftConsumer(int voltageIndex) {
super(
PowerSystems.powerSystemIndustrialCraft, voltageIndex, IEnergyEmitter.class
);
}
public void updateEntity() {
super.updateEntity();
if (!this._didFirstAddToNet && !super.worldObj.isRemote) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
this._didFirstAddToNet = true;
this._isAddedToEnergyNet = true;
}
if (super.worldObj.getWorldTime() - this._lastTickInjected > 2L) {
this._euLastTick = 0.0;
}
}
public void validate() {
super.validate();
if (!this._isAddedToEnergyNet) {
this._didFirstAddToNet = false;
}
}
public void invalidate() {
if (this._isAddedToEnergyNet) {
if (!super.worldObj.isRemote) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
}
this._isAddedToEnergyNet = false;
}
super.invalidate();
}
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
return !ConfigurationHandler.dissableIC2Consumer;
}
public double getDemandedEnergy() {
return this.getTotalEnergyDemand()
/ (double) PowerSystems.powerSystemIndustrialCraft.getScaleAmmount();
}
public double
injectEnergy(ForgeDirection directionFrom, double realAmount, double voltage) {
double amount = (double) ((int) Math.floor(realAmount));
if (amount > (double) this.getSinkTier()) {
Block block
= super.worldObj.getBlock(super.xCoord, super.yCoord, super.zCoord);
int meta = super.worldObj.getBlockMetadata(
super.xCoord, super.yCoord, super.zCoord
);
super.worldObj.setBlockToAir(super.xCoord, super.yCoord, super.zCoord);
block.dropBlockAsItem(
super.worldObj, super.xCoord, super.yCoord, super.zCoord, meta, 0
);
return amount;
} else {
double pcuNotStored = this.storeEnergy(
amount
* (double) PowerSystems.powerSystemIndustrialCraft.getScaleAmmount(),
false
);
double euNotStored = pcuNotStored
/ (double) PowerSystems.powerSystemIndustrialCraft.getScaleAmmount();
double euThisInjection = amount - euNotStored;
if (this._lastTickInjected == super.worldObj.getWorldTime()) {
this._euLastTick += euThisInjection;
} else {
this._euLastTick = euThisInjection;
this._lastTickInjected = super.worldObj.getWorldTime();
}
return euNotStored;
}
}
public int getSinkTier() {
return this.getVoltageIndex() == 3
? Integer.MAX_VALUE
: this.getPowerSystem().getVoltageValues()[this.getVoltageIndex()];
}
public double getInputRate() {
return this._euLastTick;
}
}

View file

@ -0,0 +1,94 @@
package covers1624.powerconverters.tile.ic2;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.init.PowerSystems;
import covers1624.powerconverters.tile.main.TileEntityEnergyProducer;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergySource;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityIndustrialCraftProducer
extends TileEntityEnergyProducer implements IEnergySource {
private boolean _isAddedToEnergyNet;
private boolean _didFirstAddToNet;
private double eu;
private int _packetCount;
public TileEntityIndustrialCraftProducer() {
this(0);
}
public TileEntityIndustrialCraftProducer(int voltageIndex) {
super(
PowerSystems.powerSystemIndustrialCraft, voltageIndex, IEnergyAcceptor.class
);
this._packetCount = 1;
}
public void updateEntity() {
if (!this._didFirstAddToNet && !super.worldObj.isRemote) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
this._didFirstAddToNet = true;
this._isAddedToEnergyNet = true;
}
super.updateEntity();
}
public void validate() {
super.validate();
if (!this._isAddedToEnergyNet) {
this._didFirstAddToNet = false;
}
}
public void invalidate() {
if (this._isAddedToEnergyNet) {
if (!super.worldObj.isRemote) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
}
this._isAddedToEnergyNet = false;
}
super.invalidate();
}
public double produceEnergy(double energy) {
if (ConfigurationHandler.dissableIC2Producer) {
return energy;
} else {
double eu = energy
/ (double) PowerSystems.powerSystemIndustrialCraft.getScaleAmmount();
double usedEu = Math.min(eu, this.getMaxEnergyOutput() - this.eu);
this.eu += usedEu;
return (eu - usedEu)
* (double) PowerSystems.powerSystemIndustrialCraft.getScaleAmmount();
}
}
public double getMaxEnergyOutput() {
return (double) this.getPowerSystem().getVoltageValues()[this.getVoltageIndex()];
}
public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) {
return true;
}
public double getOfferedEnergy() {
return Math.min(this.eu, this.getMaxEnergyOutput());
}
public void drawEnergy(double amount) {
this.eu -= (double) MathHelper.ceiling_double_int(amount);
}
public int getSourceTier() {
return this.getVoltageIndex();
}
}

View file

@ -0,0 +1,359 @@
package covers1624.powerconverters.tile.main;
import java.util.Iterator;
import cofh.api.energy.EnergyStorage;
import covers1624.powerconverters.grid.GridTickHandler;
import covers1624.powerconverters.grid.IGrid;
import covers1624.powerconverters.util.BlockPosition;
import covers1624.repack.cofh.lib.util.ArrayHashList;
import covers1624.repack.cofh.lib.util.LinkedHashList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class EnergyNetwork implements IGrid {
public static final int TRANSFER_RATE = 1000;
public static final int STORAGE = 6000;
static final GridTickHandler HANDLER;
private ArrayHashList nodeSet = new ArrayHashList();
LinkedHashList conduitSet;
private TileEnergyConduit master;
private int overflowSelector;
private boolean regenerating = false;
EnergyStorage storage = new EnergyStorage(480, 80);
public int distribution;
public int distributionSide;
protected EnergyNetwork() {
this.storage.setCapacity(6000);
this.storage.setMaxTransfer(1000);
}
public EnergyNetwork(TileEnergyConduit base) {
this.storage.setCapacity(6000);
this.storage.setMaxTransfer(1000);
this.conduitSet = new LinkedHashList();
this.regenerating = true;
this.addConduit(base);
this.regenerating = false;
}
public int getNodeShare(TileEnergyConduit conduit) {
int size = this.nodeSet.size();
if (size <= 1) {
return this.storage.getEnergyStored();
} else {
int amt = 0;
if (this.master == conduit) {
amt = this.storage.getEnergyStored() % size;
}
return amt + this.storage.getEnergyStored() / size;
}
}
public void addConduit(TileEnergyConduit conduit) {
if (this.conduitSet.add(conduit)) {
if (!this.conduitAdded(conduit)) {
return;
}
if (conduit.isNode) {
if (this.nodeSet.add(conduit)) {
this.nodeAdded(conduit);
}
} else if (!this.nodeSet.isEmpty()) {
int share = this.getNodeShare(conduit);
if (this.nodeSet.remove(conduit)) {
conduit.energyForGrid = this.storage.extractEnergy(share, false);
this.nodeRemoved(conduit);
}
}
}
}
public void removeConduit(TileEnergyConduit conduit) {
this.conduitSet.remove(conduit);
if (!this.nodeSet.isEmpty()) {
int share = this.getNodeShare(conduit);
if (this.nodeSet.remove(conduit)) {
conduit.energyForGrid = this.storage.extractEnergy(share, false);
this.nodeRemoved(conduit);
}
}
}
public void regenerate() {
this.regenerating = true;
HANDLER.regenerateGrid(this);
}
public boolean isRegenerating() {
return this.regenerating;
}
public void doGridPreUpdate() {
if (!this.regenerating) {
if (this.nodeSet.isEmpty()) {
HANDLER.removeGrid(this);
} else {
EnergyStorage tempStorage = this.storage;
if (tempStorage.getEnergyStored() < tempStorage.getMaxEnergyStored()) {
ForgeDirection[] directions = ForgeDirection.VALID_DIRECTIONS;
Iterator i$ = this.nodeSet.iterator();
while (i$.hasNext()) {
TileEnergyConduit conduit = (TileEnergyConduit) i$.next();
int i = 6;
while (i-- > 0) {
conduit.extract(directions[i], tempStorage);
}
}
}
}
}
}
public void doGridUpdate() {
if (!this.regenerating) {
if (this.nodeSet.isEmpty()) {
HANDLER.removeGrid(this);
} else {
EnergyStorage storage = this.storage;
if (storage.getEnergyStored() > 0) {
ForgeDirection[] directions = ForgeDirection.VALID_DIRECTIONS;
int size = this.nodeSet.size();
int toDistribute = storage.getEnergyStored() / size;
int sideDistribute = toDistribute / 6;
this.distribution = toDistribute;
this.distributionSide = sideDistribute;
int overflow = this.overflowSelector
= (this.overflowSelector + 1) % size;
TileEnergyConduit master
= (TileEnergyConduit) this.nodeSet.get(overflow);
if (sideDistribute > 0) {
Iterator i$ = this.nodeSet.iterator();
label70:
while (true) {
TileEnergyConduit cond;
do {
if (!i$.hasNext()) {
break label70;
}
cond = (TileEnergyConduit) i$.next();
} while (cond == master);
int e = 0;
for (int i = 6; i-- > 0;
e += cond.transfer(directions[i], sideDistribute)) {}
if (e > 0) {
storage.modifyEnergyStored(-e);
}
}
}
toDistribute += storage.getEnergyStored() % size;
sideDistribute = toDistribute / 6;
int e;
int i;
if (sideDistribute > 0) {
e = 0;
for (i = 6; i-- > 0;
e += master.transfer(directions[i], sideDistribute)) {}
if (e > 0) {
storage.modifyEnergyStored(-e);
}
} else if (toDistribute > 0) {
e = 0;
for (i = 6; i-- > 0 && e < toDistribute;
e += master.transfer(directions[i], toDistribute - e)) {}
if (e > 0) {
storage.modifyEnergyStored(-e);
}
}
}
}
}
}
public void markSweep() {
this.destroyGrid();
if (!this.conduitSet.isEmpty()) {
TileEnergyConduit main = (TileEnergyConduit) this.conduitSet.poke();
LinkedHashList oldSet = this.conduitSet;
this.nodeSet.clear();
this.conduitSet = new LinkedHashList(Math.min(oldSet.size() / 6, 5));
LinkedHashList toCheck = new LinkedHashList();
LinkedHashList checked = new LinkedHashList();
BlockPosition bp = new BlockPosition(0, 0, 0);
ForgeDirection[] dir = ForgeDirection.VALID_DIRECTIONS;
toCheck.add(main);
checked.add(main);
while (!toCheck.isEmpty()) {
main = (TileEnergyConduit) toCheck.shift();
this.addConduit(main);
World world = main.getWorldObj();
int i = 6;
while (i-- > 0) {
bp.x = main.xCoord;
bp.y = main.yCoord;
bp.z = main.zCoord;
bp.step(dir[i]);
if (world.blockExists(bp.x, bp.y, bp.z)) {
TileEntity te = bp.getTileEntity(world);
if (te instanceof TileEnergyConduit) {
TileEnergyConduit teConduit = (TileEnergyConduit) te;
if (main.canInterface(teConduit, dir[i ^ 1])
&& checked.add(teConduit)) {
toCheck.add(teConduit);
}
}
}
}
oldSet.remove(main);
}
if (!oldSet.isEmpty()) {
EnergyNetwork newGrid = new EnergyNetwork();
newGrid.conduitSet = oldSet;
newGrid.regenerating = true;
newGrid.markSweep();
}
if (this.nodeSet.isEmpty()) {
HANDLER.removeGrid(this);
} else {
HANDLER.addGrid(this);
}
this.rebalanceGrid();
this.regenerating = false;
}
}
public void destroyGrid() {
this.master = null;
this.regenerating = true;
Iterator i$ = this.nodeSet.iterator();
TileEnergyConduit currentConduit;
while (i$.hasNext()) {
currentConduit = (TileEnergyConduit) i$.next();
this.destroyNode(currentConduit);
}
i$ = this.conduitSet.iterator();
while (i$.hasNext()) {
currentConduit = (TileEnergyConduit) i$.next();
this.destroyConduit(currentConduit);
}
HANDLER.removeGrid(this);
}
public void destroyNode(TileEnergyConduit conduit) {
conduit.energyForGrid = this.getNodeShare(conduit);
conduit.grid = null;
}
public void destroyConduit(TileEnergyConduit conduit) {
conduit.grid = null;
}
public boolean canMergeGrid(EnergyNetwork otherGrid) {
return otherGrid != null;
}
public void mergeGrid(EnergyNetwork grid) {
if (grid != this) {
boolean r = this.regenerating || grid.regenerating;
grid.destroyGrid();
if (!this.regenerating & r) {
this.regenerate();
}
this.regenerating = true;
Iterator i$ = grid.conduitSet.iterator();
while (i$.hasNext()) {
TileEnergyConduit conduit = (TileEnergyConduit) i$.next();
this.addConduit(conduit);
}
this.regenerating = r;
grid.conduitSet.clear();
grid.nodeSet.clear();
}
}
public void nodeAdded(TileEnergyConduit conduit) {
if (this.master == null) {
this.master = conduit;
HANDLER.addGrid(this);
}
this.rebalanceGrid();
this.storage.modifyEnergyStored(conduit.energyForGrid);
}
public void nodeRemoved(TileEnergyConduit conduit) {
this.rebalanceGrid();
if (conduit == this.master) {
if (this.nodeSet.isEmpty()) {
this.master = null;
HANDLER.removeGrid(this);
} else {
this.master = (TileEnergyConduit) this.nodeSet.get(0);
}
}
}
public boolean conduitAdded(TileEnergyConduit conduit) {
if (conduit.grid != null) {
if (conduit.grid == this) {
return false;
}
this.conduitSet.remove(conduit);
if (!this.canMergeGrid(conduit.grid)) {
return false;
}
this.mergeGrid(conduit.grid);
} else {
conduit.setGrid(this);
}
return true;
}
public void rebalanceGrid() {
this.storage.setCapacity(this.nodeSet.size() * 6000);
}
public int getConduitCount() {
return this.conduitSet.size();
}
public int getNodeCount() {
return this.nodeSet.size();
}
static {
HANDLER = GridTickHandler.energy;
}
}

View file

@ -0,0 +1,306 @@
package covers1624.powerconverters.tile.main;
import java.util.List;
import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyConnection;
import cofh.api.energy.IEnergyHandler;
import cofh.api.energy.IEnergyProvider;
import cofh.api.energy.IEnergyReceiver;
import covers1624.powerconverters.grid.GridTickHandler;
import covers1624.powerconverters.grid.IGridController;
import covers1624.powerconverters.grid.INode;
import covers1624.powerconverters.util.BlockPosition;
import covers1624.powerconverters.util.IAdvancedLogTile;
import covers1624.powerconverters.util.IUpdateTileWithCords;
import covers1624.powerconverters.util.LogHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEnergyConduit extends TileEntity
implements INode, IEnergyHandler, IUpdateTileWithCords, IAdvancedLogTile {
private IEnergyReceiver[] receiverCache = null;
private IEnergyProvider[] providerCache = null;
private boolean readFromNBT = false;
private boolean deadCache = false;
boolean isNode = false;
int energyForGrid = 0;
EnergyNetwork grid;
public TileEnergyConduit() {
if (this.grid == null) {
this.validate();
}
}
public boolean isNotValid() {
return super.tileEntityInvalid;
}
public void validate() {
super.validate();
this.deadCache = true;
this.receiverCache = null;
this.providerCache = null;
if (super.worldObj != null && !super.worldObj.isRemote) {
GridTickHandler.energy.addConduitForTick(this);
}
}
public void invalidate() {
super.invalidate();
if (this.grid != null) {
this.grid.removeConduit(this);
this.grid.storage.modifyEnergyStored(-this.energyForGrid);
this.grid.regenerate();
this.deadCache = true;
this.grid = null;
}
}
private void addCache(TileEntity tile) {
if (tile != null) {
int x = tile.xCoord;
int y = tile.yCoord;
int z = tile.yCoord;
if (x < super.xCoord) {
this.addCache(tile, 5);
} else if (x > super.xCoord) {
this.addCache(tile, 4);
} else if (z < super.zCoord) {
this.addCache(tile, 3);
} else if (z > super.zCoord) {
this.addCache(tile, 2);
} else if (y < super.yCoord) {
this.addCache(tile, 1);
} else if (y > super.yCoord) {
this.addCache(tile, 0);
}
}
}
private void addCache(TileEntity tile, int side) {
if (this.receiverCache != null) {
this.receiverCache[side] = null;
}
if (this.providerCache != null) {
this.providerCache[side] = null;
}
if (!(tile instanceof TileEnergyConduit) && tile instanceof IEnergyConnection
&& ((IEnergyConnection) tile)
.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[side])) {
if (tile instanceof IEnergyReceiver) {
if (this.receiverCache == null) {
this.receiverCache = new IEnergyReceiver[6];
}
this.receiverCache[side] = (IEnergyReceiver) tile;
}
if (tile instanceof IEnergyProvider) {
if (this.providerCache == null) {
this.providerCache = new IEnergyProvider[6];
}
this.providerCache[side] = (IEnergyProvider) tile;
}
}
}
private void reCache() {
if (this.deadCache) {
ForgeDirection[] arr$ = ForgeDirection.VALID_DIRECTIONS;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
ForgeDirection dir = arr$[i$];
this.addCache(BlockPosition.getAdjacentTileEntity(this, dir));
}
this.deadCache = false;
this.updateInternalTypes(EnergyNetwork.HANDLER);
}
}
private void incorporateTiles() {
if (this.grid == null) {
boolean hasGrid = false;
ForgeDirection[] arr$ = ForgeDirection.VALID_DIRECTIONS;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
ForgeDirection dir = arr$[i$];
if (!this.readFromNBT && BlockPosition.blockExists(this, dir)) {
TileEnergyConduit pipe
= (TileEnergyConduit) BlockPosition
.getAdjacentTileEntity(this, dir, TileEnergyConduit.class);
if (pipe != null && pipe.grid != null
&& pipe.canInterface(this, dir)) {
if (hasGrid) {
pipe.grid.mergeGrid(this.grid);
} else {
pipe.grid.addConduit(this);
hasGrid = this.grid != null;
}
}
}
}
}
}
public void firstTick(IGridController grid) {
LogHelper.info("First Grid Tick");
if (super.worldObj != null && !super.worldObj.isRemote
&& grid == EnergyNetwork.HANDLER) {
if (this.grid == null) {
this.incorporateTiles();
this.setGrid(new EnergyNetwork(this));
}
this.readFromNBT = true;
this.reCache();
this.markDirty();
}
}
public void updateInternalTypes(IGridController grid) {
if (!this.deadCache && grid == EnergyNetwork.HANDLER) {
this.isNode = true;
if (this.grid != null) {
this.grid.addConduit(this);
}
}
}
public boolean canConnectEnergy(ForgeDirection from) {
return this.grid != null;
}
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
return this.grid != null ? this.grid.storage.receiveEnergy(maxReceive, simulate)
: 0;
}
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
return 0;
}
public int getEnergyStored(ForgeDirection from) {
return this.grid != null ? this.grid.storage.getEnergyStored() : 0;
}
public int getMaxEnergyStored(ForgeDirection from) {
if (this.grid != null) {
this.grid.storage.getMaxEnergyStored();
}
return 0;
}
public void extract(ForgeDirection forgeDirection, EnergyStorage tempStorage) {}
public int transfer(ForgeDirection forgeDirection, int energy) {
if (this.deadCache) {
return 0;
} else {
if (this.receiverCache != null) {
IEnergyReceiver handlerTile
= this.receiverCache[forgeDirection.ordinal()];
if (handlerTile != null) {
return handlerTile.receiveEnergy(forgeDirection, energy, false);
}
}
return 0;
}
}
public void setGrid(EnergyNetwork energyNetwork) {
this.grid = energyNetwork;
}
public boolean canInterface(TileEnergyConduit teConduit, ForgeDirection dir) {
if (this.receiverCache != null) {
if (this.receiverCache[dir.ordinal()] != null) {
return true;
}
} else if (this.providerCache != null && this.providerCache[dir.ordinal()] != null) {
return true;
}
return false;
}
public void onNeighboorChanged(int x, int y, int z) {
if (!(super.worldObj.isRemote | this.deadCache)) {
TileEntity tile = super.worldObj.getTileEntity(x, y, z);
if (x < super.xCoord) {
this.addCache(tile, 5);
} else if (x > super.xCoord) {
this.addCache(tile, 4);
} else if (z < super.zCoord) {
this.addCache(tile, 3);
} else if (z > super.zCoord) {
this.addCache(tile, 2);
} else if (y < super.yCoord) {
this.addCache(tile, 1);
} else if (y > super.yCoord) {
this.addCache(tile, 0);
}
}
}
public void
getTileInfo(List info, ForgeDirection side, EntityPlayer player, boolean debug) {
info.add(this.text("-Energy-"));
if (this.grid != null) {
if (debug && this.isNode) {
info.add(this.text("Throughput All: " + this.grid.distribution));
info.add(this.text("Throughput Side: " + this.grid.distributionSide));
}
if (!debug) {
float sat = 0.0F;
if (this.grid.getNodeCount() != 0) {
sat = (float
) (Math.ceil((double
) ((float) this.grid.storage.getEnergyStored()
/ (float) this.grid.storage.getMaxEnergyStored() * 1000.0F))
/ 10.0);
}
info.add(this.text("Saturation: " + sat));
}
} else if (!debug) {
info.add(this.text("Null Grid"));
}
if (debug) {
if (this.grid != null) {
info.add(this.text("Grid:" + this.grid));
info.add(this.text(
"Conduits: " + this.grid.getConduitCount()
+ ", Nodes: " + this.grid.getNodeCount()
));
info.add(this.text(
"Grid Max: " + this.grid.storage.getMaxEnergyStored()
+ ", Grid Cur: " + this.grid.storage.getEnergyStored()
));
} else {
info.add(this.text("Null Grid"));
}
info.add(this.text("Node: " + this.isNode + ", Energy: " + this.energyForGrid)
);
}
}
public IChatComponent text(String str) {
return new ChatComponentText(str);
}
}

View file

@ -0,0 +1,144 @@
package covers1624.powerconverters.tile.main;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import covers1624.powerconverters.api.registry.PowerSystemRegistry;
import covers1624.powerconverters.block.BlockPowerConverter;
import covers1624.powerconverters.util.BlockPosition;
import covers1624.powerconverters.util.IAdvancedLogTile;
import covers1624.powerconverters.util.INeighboorUpdateTile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityBridgeComponent
extends TileEntity implements INeighboorUpdateTile, IAdvancedLogTile {
private Map _adjacentBridges = new HashMap();
private Map _adjacentTiles = new HashMap();
private Class _adjacentClass;
protected PowerSystemRegistry.PowerSystem powerSystem;
protected int _voltageIndex;
protected String type;
private boolean _initialized;
protected TileEntityBridgeComponent(
PowerSystemRegistry.PowerSystem powersystem,
int voltageNameIndex,
Class adjacentClass
) {
this.powerSystem = powersystem;
this._voltageIndex = voltageNameIndex;
this._adjacentClass = adjacentClass;
}
public void updateEntity() {
super.updateEntity();
if (!this._initialized && !super.tileEntityInvalid) {
this.onNeighboorChanged();
this._initialized = true;
}
}
public void onNeighboorChanged() {
Map adjacentBridges = new HashMap();
Map adjacentTiles = new HashMap();
ForgeDirection[] arr$ = ForgeDirection.VALID_DIRECTIONS;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
ForgeDirection d = arr$[i$];
TileEntity te = BlockPosition.getAdjacentTileEntity(this, d);
if (te != null && te instanceof TileEntityEnergyBridge) {
adjacentBridges.put(d, (TileEntityEnergyBridge) te);
} else if (te != null && this._adjacentClass.isAssignableFrom(te.getClass())) {
adjacentTiles.put(d, te);
}
}
this._adjacentBridges = adjacentBridges;
this._adjacentTiles = adjacentTiles;
}
public PowerSystemRegistry.PowerSystem getPowerSystem() {
return this.powerSystem;
}
public boolean isConnected() {
return this._adjacentTiles.size() > 0;
}
public boolean isSideConnected(int side) {
return this._adjacentTiles.get(ForgeDirection.getOrientation(side)) != null;
}
public boolean isSideConnectedClient(int side) {
TileEntity te = BlockPosition.getAdjacentTileEntity(
this, ForgeDirection.getOrientation(side)
);
return te != null && this._adjacentClass.isAssignableFrom(te.getClass());
}
public int getVoltageIndex() {
return this._voltageIndex;
}
public TileEntityEnergyBridge getFirstBridge() {
return this._adjacentBridges.size() == 0
? null
: (TileEntityEnergyBridge) this._adjacentBridges.values().toArray()[0];
}
protected Map getBridges() {
return this._adjacentBridges;
}
protected Map getTiles() {
return this._adjacentTiles;
}
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
if (this._voltageIndex == 0) {
this._voltageIndex = tagCompound.getInteger("voltageIndex");
}
}
public void writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound);
tagCompound.setInteger("voltageIndex", this._voltageIndex);
}
public boolean isGettingRedstone() {
Block block = super.worldObj.getBlock(super.xCoord, super.yCoord, super.zCoord);
if (block instanceof BlockPowerConverter) {
BlockPowerConverter blockPowerConverter = (BlockPowerConverter) block;
return blockPowerConverter.isGettingRedstone();
} else {
return false;
}
}
@SideOnly(Side.CLIENT)
public void addWailaInfo(List info) {
info.add("Type: " + this.type);
info.add("PowerSystem: " + this.powerSystem.getName());
if (this.type.equals("Consumer")) {
info.add("Consumer Dissabled: " + this.powerSystem.consumerDissabled());
} else if (this.type.equals("Producer")) {
info.add("Producer Dissabled: " + this.powerSystem.producerDissabled());
}
}
public void
getTileInfo(List info, ForgeDirection side, EntityPlayer player, boolean debug) {
info.add(new ChatComponentText("Is getting Redstone: " + this.isGettingRedstone())
);
}
}

View file

@ -0,0 +1,282 @@
package covers1624.powerconverters.tile.main;
import java.util.Iterator;
import java.util.List;
import covers1624.powerconverters.api.charge.IChargeHandler;
import covers1624.powerconverters.api.registry.UniversalChargerRegistry;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.init.PowerSystems;
import covers1624.powerconverters.util.BlockPosition;
import covers1624.powerconverters.util.IAdvancedLogTile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityCharger
extends TileEntityEnergyProducer implements IAdvancedLogTile, ISidedInventory {
private TileEntity[] sideCache = new TileEntity[6];
private ItemStack[] slots = new ItemStack[32];
public TileEntityCharger() {
super(PowerSystems.powerSystemRedstoneFlux, 0, IInventory.class);
}
public void updateEntity() {
super.updateEntity();
this.searchForTiles();
this.validateSlots();
}
public double produceEnergy(double energy) {
if (energy == 0.0) {
return 0.0;
} else if (ConfigurationHandler.dissableUniversalCharger) {
return energy;
} else {
double energyRemaining = energy;
for (int i = 0; i < 16; ++i) {
ItemStack stack = this.slots[i];
if (stack != null) {
Iterator i$ = UniversalChargerRegistry.getChargeHandlers().iterator();
while (i$.hasNext()) {
IChargeHandler handler = (IChargeHandler) i$.next();
if (handler.canHandle(stack)) {
energyRemaining = handler.charge(stack, energyRemaining);
if (energyRemaining == 0.0) {
return 0.0;
}
}
}
}
}
energyRemaining = this.powerTiles(energyRemaining);
return energyRemaining;
}
}
private void searchForTiles() {
ForgeDirection[] arr$ = ForgeDirection.VALID_DIRECTIONS;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
ForgeDirection dir = arr$[i$];
TileEntity tileEntity = BlockPosition.getAdjacentTileEntity(this, dir);
if (tileEntity != null && tileEntity instanceof IInventory) {
this.sideCache[dir.ordinal()] = tileEntity;
}
if (tileEntity == null) {
this.sideCache[dir.ordinal()] = null;
}
}
}
private void validateSlots() {
label46:
for (int i = 0; i < 16; ++i) {
if (this.slots[i] != null) {
Iterator i$ = UniversalChargerRegistry.getChargeHandlers().iterator();
while (true) {
while (true) {
IChargeHandler handler;
do {
do {
if (!i$.hasNext()) {
continue label46;
}
handler = (IChargeHandler) i$.next();
} while (!handler.canHandle(this.slots[i]));
} while (!handler.isItemCharged(this.slots[i]));
for (int j = 16; j < 32; ++j) {
if (this.slots[j] == null) {
this.slots[j] = this.slots[i];
this.slots[i] = null;
break;
}
}
}
}
}
}
}
public double powerTiles(double energyRemaining) {
TileEntity[] arr$ = this.sideCache;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
TileEntity tileEntity = arr$[i$];
if (tileEntity != null) {
IInventory iInventory = (IInventory) tileEntity;
for (int i = 0; i < iInventory.getSizeInventory(); ++i) {
ItemStack itemStack = iInventory.getStackInSlot(i);
if (itemStack != null) {
Iterator it$
= UniversalChargerRegistry.getChargeHandlers().iterator();
while (it$.hasNext()) {
IChargeHandler handler = (IChargeHandler) it$.next();
if (handler.canHandle(itemStack)) {
energyRemaining
= handler.charge(itemStack, energyRemaining);
if (energyRemaining == 0.0) {
return 0.0;
}
}
}
}
}
}
}
return energyRemaining;
}
public void
getTileInfo(List info, ForgeDirection side, EntityPlayer player, boolean debug) {
info.add(this.text("-SideCache-"));
for (int i = 0; i < this.sideCache.length; ++i) {
String data = this.sideCache[i] != null
? this.sideCache[i].getClass().getName()
: "Null";
info.add(this.text(String.format(
"Side: %s, Data: %s", ForgeDirection.VALID_DIRECTIONS[i], data
)));
}
}
private ChatComponentText text(String string) {
return new ChatComponentText(string);
}
public void writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.slots.length; ++i) {
if (this.slots[i] != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setInteger("Slot", i);
this.slots[i].writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
tagCompound.setTag("Items", nbttaglist);
}
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
NBTTagList nbttaglist = tagCompound.getTagList("Items", 10);
this.slots = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound1.getInteger("Slot");
if (j >= 0 && j < this.slots.length) {
this.slots[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
}
}
}
public int getSizeInventory() {
return this.slots.length;
}
public ItemStack getStackInSlot(int slot) {
return this.slots[slot];
}
public ItemStack decrStackSize(int slot, int ammount) {
if (this.slots[slot] != null) {
ItemStack itemStack;
if (this.slots[slot].stackSize <= ammount) {
itemStack = this.slots[slot];
this.slots[slot] = null;
return itemStack;
} else {
itemStack = this.slots[slot].splitStack(ammount);
if (this.slots[slot].stackSize == 0) {
this.slots[slot] = null;
}
return itemStack;
}
} else {
return null;
}
}
public ItemStack getStackInSlotOnClosing(int slot) {
return this.slots[slot];
}
public void setInventorySlotContents(int slot, ItemStack stack) {
this.slots[slot] = stack;
if (stack != null && stack.stackSize > this.getInventoryStackLimit()) {
stack.stackSize = this.getInventoryStackLimit();
}
}
public String getInventoryName() {
return "Universal Charger";
}
public boolean hasCustomInventoryName() {
return true;
}
public int getInventoryStackLimit() {
return 64;
}
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
return true;
}
public void openInventory() {}
public void closeInventory() {}
public boolean isItemValidForSlot(int slot, ItemStack stack) {
if (slot < 16) {
Iterator i$ = UniversalChargerRegistry.getChargeHandlers().iterator();
while (i$.hasNext()) {
IChargeHandler chargeHandler = (IChargeHandler) i$.next();
if (chargeHandler.canHandle(stack)) {
return true;
}
}
}
return false;
}
public int[] getAccessibleSlotsFromSide(int side) {
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
}
public boolean canInsertItem(int slot, ItemStack stack, int side) {
return this.isItemValidForSlot(slot, stack);
}
public boolean canExtractItem(int slot, ItemStack stack, int side) {
return slot > 16;
}
}

View file

@ -0,0 +1,241 @@
package covers1624.powerconverters.tile.main;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import covers1624.powerconverters.api.bridge.BridgeSideData;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.net.EnergyBridgeSyncPacket;
import covers1624.powerconverters.util.BlockPosition;
import covers1624.powerconverters.util.INeighboorUpdateTile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityEnergyBridge extends TileEntity implements INeighboorUpdateTile {
private double _energyStored;
private double _energyStoredMax;
private double _energyScaledClient;
private double _energyStoredLast;
private boolean _isInputLimited;
private Map _producerTiles;
private Map clientSideData;
private Map _producerOutputRates;
private boolean _initialized;
public TileEntityEnergyBridge() {
this._energyStoredMax = (double) ConfigurationHandler.bridgeBufferSize;
this._producerTiles = new HashMap();
this.clientSideData = new HashMap();
this._producerOutputRates = new HashMap();
ForgeDirection[] arr$ = ForgeDirection.VALID_DIRECTIONS;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
ForgeDirection d = arr$[i$];
this.clientSideData.put(d, new BridgeSideData());
this._producerOutputRates.put(d, 0.0);
}
}
public double getEnergyStored() {
return this._energyStored;
}
public double getEnergyStoredMax() {
return this._energyStoredMax;
}
public double storeEnergy(double energy, boolean simulate) {
double toStore = Math.min(energy, this._energyStoredMax - this._energyStored);
if (simulate) {
return energy - toStore;
} else {
this._energyStored += toStore;
return energy - toStore;
}
}
public void updateEntity() {
super.updateEntity();
if (!this._initialized) {
this.onNeighboorChanged();
this._initialized = true;
}
if (!super.worldObj.isRemote) {
double energyRemaining = Math.min(this._energyStored, this._energyStoredMax);
double energyNotProduced = 0.0;
Iterator i$ = this._producerTiles.entrySet().iterator();
while (i$.hasNext()) {
Map.Entry prod = (Map.Entry) i$.next();
if (!((TileEntityEnergyProducer) prod.getValue()).isGettingRedstone()) {
if (energyRemaining > 0.0) {
energyNotProduced = ((TileEntityEnergyProducer) prod.getValue())
.produceEnergy(energyRemaining);
if (energyNotProduced > energyRemaining) {
energyNotProduced = energyRemaining;
}
this._producerOutputRates.put(
prod.getKey(),
(energyRemaining - energyNotProduced)
/ (double) ((TileEntityEnergyProducer) prod.getValue())
.getPowerSystem()
.getScaleAmmount()
);
energyRemaining = energyNotProduced;
} else {
((TileEntityEnergyProducer) prod.getValue()).produceEnergy(0.0);
this._producerOutputRates.put(prod.getKey(), 0.0);
}
}
}
this._energyStored = Math.max(0.0, energyRemaining);
if ((this._energyStored != this._energyStoredLast
|| this._energyStored != this._energyStoredMax)
&& !(this._energyStored > this._energyStoredLast)) {
this._isInputLimited = true;
} else {
this._isInputLimited = false;
}
this._energyStoredLast = this._energyStored;
}
}
public void onNeighboorChanged() {
Map producerTiles = new HashMap();
ForgeDirection[] arr$ = ForgeDirection.VALID_DIRECTIONS;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
ForgeDirection d = arr$[i$];
BlockPosition p = new BlockPosition(this);
p.orientation = d;
p.moveForwards(1);
TileEntity te = super.worldObj.getTileEntity(p.x, p.y, p.z);
if (te != null && te instanceof TileEntityEnergyProducer) {
producerTiles.put(d, (TileEntityEnergyProducer) te);
}
}
this._producerTiles = producerTiles;
}
public BridgeSideData getDataForSide(ForgeDirection dir) {
if (!super.worldObj.isRemote) {
BridgeSideData d = new BridgeSideData();
BlockPosition p = new BlockPosition(this);
p.orientation = dir;
p.moveForwards(1);
TileEntity te = super.worldObj.getTileEntity(p.x, p.y, p.z);
if (te != null && te instanceof TileEntityBridgeComponent) {
if (te instanceof TileEntityEnergyConsumer) {
d.isConsumer = true;
d.outputRate = ((TileEntityEnergyConsumer) te).getInputRate();
}
if (te instanceof TileEntityEnergyProducer) {
d.isProducer = true;
d.outputRate = (Double) this._producerOutputRates.get(dir);
}
TileEntityBridgeComponent c = (TileEntityBridgeComponent) te;
d.powerSystem = c.getPowerSystem();
d.isConnected = c.isConnected();
d.side = dir;
d.voltageNameIndex = c.getVoltageIndex();
}
return d;
} else {
return (BridgeSideData) this.clientSideData.get(dir);
}
}
public BridgeSideData[] getClientData() {
BridgeSideData[] data = new BridgeSideData[6];
ForgeDirection[] arr$ = ForgeDirection.VALID_DIRECTIONS;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
ForgeDirection dir = arr$[i$];
data[dir.ordinal()] = (BridgeSideData) this.clientSideData.get(dir);
}
return data;
}
public void setClientDataForSide(ForgeDirection dir, BridgeSideData data) {
if (this.clientSideData.containsKey(dir)) {
this.clientSideData.remove(dir);
}
this.clientSideData.put(dir, data);
}
public boolean isInputLimited() {
return this._isInputLimited;
}
@SideOnly(Side.CLIENT)
public void setIsInputLimited(boolean isInputLimited) {
this._isInputLimited = isInputLimited;
}
public double getEnergyScaled() {
return super.worldObj.isRemote
? this._energyScaledClient
: 120.0 * (this._energyStored / this._energyStoredMax);
}
public void setEnergyScaled(double scaled) {
this._energyScaledClient = scaled;
}
public void addWailaInfo(List info) {}
public void writeToNBT(NBTTagCompound par1nbtTagCompound) {
super.writeToNBT(par1nbtTagCompound);
par1nbtTagCompound.setDouble("energyStored", this._energyStored);
}
public void readFromNBT(NBTTagCompound par1nbtTagCompound) {
super.readFromNBT(par1nbtTagCompound);
this._energyStored = par1nbtTagCompound.getDouble("energyStored");
}
public EnergyBridgeSyncPacket getNetPacket() {
BridgeSideData[] bridgeSideData = new BridgeSideData[6];
ForgeDirection[] arr$ = ForgeDirection.VALID_DIRECTIONS;
int side = arr$.length;
for (int i$ = 0; i$ < side; ++i$) {
ForgeDirection dir = arr$[i$];
bridgeSideData[dir.ordinal()] = this.getDataForSide(dir);
}
NBTTagCompound tagCompound = new NBTTagCompound();
for (side = 0; side < 6; ++side) {
BridgeSideData data = bridgeSideData[side];
NBTTagCompound tag = new NBTTagCompound();
data.writeToNBT(tag);
tagCompound.setTag(String.valueOf(side), tag);
}
tagCompound.setBoolean("InputLimited", this.isInputLimited());
tagCompound.setDouble("Energy", this.getEnergyScaled());
EnergyBridgeSyncPacket syncPacket = new EnergyBridgeSyncPacket(
tagCompound, super.xCoord, super.yCoord, super.zCoord
);
return syncPacket;
}
}

View file

@ -0,0 +1,50 @@
package covers1624.powerconverters.tile.main;
import java.util.Iterator;
import java.util.Map;
import covers1624.powerconverters.api.registry.PowerSystemRegistry;
public abstract class TileEntityEnergyConsumer extends TileEntityBridgeComponent {
public TileEntityEnergyConsumer(
PowerSystemRegistry.PowerSystem powerSystem,
int voltageNameIndex,
Class adjacentClass
) {
super(powerSystem, voltageNameIndex, adjacentClass);
super.type = "Consumer";
}
protected double storeEnergy(double energy, boolean simulate) {
Iterator i$ = this.getBridges().entrySet().iterator();
do {
if (!i$.hasNext()) {
return energy;
}
Map.Entry bridge = (Map.Entry) i$.next();
if (!this.isGettingRedstone()) {
energy = ((TileEntityEnergyBridge) bridge.getValue())
.storeEnergy(energy, simulate);
}
} while (!(energy <= 0.0));
return 0.0;
}
protected double getTotalEnergyDemand() {
double demand = 0.0;
Map.Entry bridge;
for (Iterator i$ = this.getBridges().entrySet().iterator(); i$.hasNext();
demand += ((TileEntityEnergyBridge) bridge.getValue()).getEnergyStoredMax()
- ((TileEntityEnergyBridge) bridge.getValue()).getEnergyStored()) {
bridge = (Map.Entry) i$.next();
}
return demand;
}
public abstract double getInputRate();
}

View file

@ -0,0 +1,16 @@
package covers1624.powerconverters.tile.main;
import covers1624.powerconverters.api.registry.PowerSystemRegistry;
public abstract class TileEntityEnergyProducer extends TileEntityBridgeComponent {
public TileEntityEnergyProducer(
PowerSystemRegistry.PowerSystem powerSystem,
int voltageNameIndex,
Class adjacentClass
) {
super(powerSystem, voltageNameIndex, adjacentClass);
super.type = "Producer";
}
public abstract double produceEnergy(double var1);
}

View file

@ -0,0 +1,58 @@
package covers1624.powerconverters.tile.redstoneflux;
import cofh.api.energy.IEnergyReceiver;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.init.PowerSystems;
import covers1624.powerconverters.tile.main.TileEntityEnergyBridge;
import covers1624.powerconverters.tile.main.TileEntityEnergyConsumer;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityRedstoneFluxConsumer
extends TileEntityEnergyConsumer implements IEnergyReceiver {
private double lastReceivedRF;
public TileEntityRedstoneFluxConsumer() {
super(PowerSystems.powerSystemRedstoneFlux, 0, IEnergyReceiver.class);
}
public void updateEntity() {
super.updateEntity();
}
public double getInputRate() {
double last = this.lastReceivedRF;
this.lastReceivedRF = 0.0;
return last;
}
public boolean canConnectEnergy(ForgeDirection arg0) {
return !ConfigurationHandler.dissableRFConsumer;
}
public int getEnergyStored(ForgeDirection arg0) {
TileEntityEnergyBridge bridge = this.getFirstBridge();
return bridge == null ? 0
: (int
) (bridge.getEnergyStored()
/ (double) this.getPowerSystem().getScaleAmmount());
}
public int getMaxEnergyStored(ForgeDirection arg0) {
TileEntityEnergyBridge bridge = this.getFirstBridge();
return bridge == null ? 0
: (int
) (bridge.getEnergyStoredMax()
/ (double) this.getPowerSystem().getScaleAmmount());
}
public int receiveEnergy(ForgeDirection from, int receiveMax, boolean simulate) {
if (this.getFirstBridge() == null) {
return 0;
} else {
int actualRF = this.getPowerSystem().getScaleAmmount() * receiveMax;
int rfNotStored = (int
) ((double) actualRF - this.storeEnergy((double) actualRF, simulate));
return rfNotStored / this.getPowerSystem().getScaleAmmount();
}
}
}

View file

@ -0,0 +1,77 @@
package covers1624.powerconverters.tile.redstoneflux;
import java.util.Iterator;
import java.util.List;
import cofh.api.energy.IEnergyHandler;
import cofh.api.energy.IEnergyProvider;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.init.PowerSystems;
import covers1624.powerconverters.tile.main.TileEntityEnergyBridge;
import covers1624.powerconverters.tile.main.TileEntityEnergyProducer;
import covers1624.powerconverters.util.BlockPosition;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityRedstoneFluxProducer
extends TileEntityEnergyProducer implements IEnergyProvider {
public TileEntityRedstoneFluxProducer() {
super(PowerSystems.powerSystemRedstoneFlux, 0, IEnergyProvider.class);
}
public boolean canConnectEnergy(ForgeDirection arg0) {
return true;
}
public int extractEnergy(ForgeDirection arg0, int arg1, boolean arg2) {
return 0;
}
public int getEnergyStored(ForgeDirection arg0) {
TileEntityEnergyBridge bridge = this.getFirstBridge();
return bridge == null ? 0
: (int
) (bridge.getEnergyStored()
/ (double) this.getPowerSystem().getScaleAmmount());
}
public int getMaxEnergyStored(ForgeDirection arg0) {
TileEntityEnergyBridge bridge = this.getFirstBridge();
return bridge == null ? 0
: (int
) (bridge.getEnergyStoredMax()
/ (double) this.getPowerSystem().getScaleAmmount());
}
public double produceEnergy(double energy) {
if (ConfigurationHandler.dissableRFProducer) {
return energy;
} else {
double toUseRF = energy / (double) this.getPowerSystem().getScaleAmmount();
if (toUseRF > 0.0) {
List pos = (new BlockPosition(super.xCoord, super.yCoord, super.zCoord))
.getAdjacent(true);
Iterator i$ = pos.iterator();
while (i$.hasNext()) {
BlockPosition p = (BlockPosition) i$.next();
TileEntity te = super.worldObj.getTileEntity(p.x, p.y, p.z);
if (te instanceof IEnergyHandler
&& !(te instanceof TileEntityRedstoneFluxConsumer)
&& !(te instanceof TileEntityEnergyBridge)) {
IEnergyHandler handler = (IEnergyHandler) te;
double RF = (double) handler.receiveEnergy(
p.orientation.getOpposite(), (int) toUseRF, false
);
energy -= RF * (double) this.getPowerSystem().getScaleAmmount();
if (energy <= 0.0) {
break;
}
}
}
}
return energy;
}
}
}

View file

@ -0,0 +1,75 @@
package covers1624.powerconverters.tile.steam;
import covers1624.powerconverters.PowerConverters;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.init.PowerSystems;
import covers1624.powerconverters.tile.main.TileEntityEnergyConsumer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
public class TileEntitySteamConsumer
extends TileEntityEnergyConsumer implements IFluidHandler {
private FluidTank _steamTank = new FluidTank(10000);
private int _mBLastTick;
public TileEntitySteamConsumer() {
super(PowerSystems.powerSystemSteam, 0, IFluidHandler.class);
}
public void updateEntity() {
super.updateEntity();
if (this._steamTank != null && this._steamTank.getFluid() != null) {
int amount = this._steamTank.getFluid().amount;
double energy
= (double) (amount * PowerSystems.powerSystemSteam.getScaleAmmount());
energy = this.storeEnergy(energy, false);
int toDrain = amount
- (int) (energy / (double) PowerSystems.powerSystemSteam.getScaleAmmount()
);
this._steamTank.drain(toDrain, true);
this._mBLastTick = toDrain;
} else {
this._mBLastTick = 0;
}
}
public int getVoltageIndex() {
return 0;
}
public double getInputRate() {
return (double) this._mBLastTick;
}
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
return resource != null && resource.getFluidID() == PowerConverters.steamId
&& PowerConverters.steamId != -1
? this._steamTank.fill(resource, doFill)
: 0;
}
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return null;
}
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return null;
}
public boolean canFill(ForgeDirection from, Fluid fluid) {
return fluid != null && fluid.getID() == PowerConverters.steamId
&& !ConfigurationHandler.dissableSteamConsumer;
}
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return false;
}
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return new FluidTankInfo[] { this._steamTank.getInfo() };
}
}

View file

@ -0,0 +1,81 @@
package covers1624.powerconverters.tile.steam;
import covers1624.powerconverters.PowerConverters;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.init.PowerSystems;
import covers1624.powerconverters.tile.main.TileEntityEnergyProducer;
import covers1624.powerconverters.util.BlockPosition;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
public class TileEntitySteamProducer
extends TileEntityEnergyProducer implements IFluidHandler {
private FluidTank _tank = new FluidTank(10000);
public TileEntitySteamProducer() {
super(PowerSystems.powerSystemSteam, 0, IFluidHandler.class);
}
public double produceEnergy(double energy) {
if (PowerConverters.steamId != -1
&& !ConfigurationHandler.dissableSteamProducer) {
energy /= (double) PowerSystems.powerSystemSteam.getScaleAmmount();
for (int i = 0; i < 6; ++i) {
BlockPosition bp = new BlockPosition(this);
bp.orientation = ForgeDirection.getOrientation(i);
bp.moveForwards(1);
TileEntity te = super.worldObj.getTileEntity(bp.x, bp.y, bp.z);
if (te != null && te instanceof IFluidHandler) {
energy -= (double) ((IFluidHandler) te)
.fill(
bp.orientation.getOpposite(),
new FluidStack(
FluidRegistry.getFluid(PowerConverters.steamId),
(int) energy
),
true
);
}
if (energy <= 0.0) {
return 0.0;
}
}
return energy * (double) PowerSystems.powerSystemSteam.getScaleAmmount();
} else {
return energy;
}
}
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
return 0;
}
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
return null;
}
public boolean canFill(ForgeDirection from, Fluid fluid) {
return false;
}
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return null;
}
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return true;
}
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return new FluidTankInfo[] { this._tank.getInfo() };
}
}

View file

@ -0,0 +1,65 @@
package covers1624.powerconverters.updatechecker;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import covers1624.powerconverters.util.FMLLogHelper;
import covers1624.powerconverters.util.LogHelper;
import org.apache.logging.log4j.Level;
public class UpdateCheckThread extends Thread {
private String updateURL
= "https://raw.github.com/covers1624/PowerConverters/master/UpdateInfo.update";
private boolean checkComplete = false;
private boolean newVersionAvalable = false;
private float newVersion = 0.0F;
private float currentVersion = 0.0F;
public UpdateCheckThread() {
super("PowerConverters Update Thread");
}
public void run() {
try {
URL versionFile = new URL(this.updateURL);
BufferedReader reader
= new BufferedReader(new InputStreamReader(versionFile.openStream()));
String remoteString = reader.readLine();
String[] localSplit = "1.7.10-2.11".split("-");
String[] remoteSplit = remoteString.split("-");
if (this.compareVersions(localSplit[1], remoteSplit[1])) {
this.newVersionAvalable = true;
LogHelper.info("We Have An update");
} else {
LogHelper.info("We Have No Update");
}
this.checkComplete = true;
} catch (Exception var6) {
FMLLogHelper.logException(Level.INFO, "It Broke!", var6);
}
}
private boolean compareVersions(String local, String remote) {
if (Float.parseFloat(local) > Float.parseFloat(remote)) {
this.newVersion = Float.parseFloat(remote);
this.currentVersion = Float.parseFloat(local);
return true;
} else {
return false;
}
}
public float getNewVersion() {
return this.newVersion;
}
public boolean checkFinished() {
return this.checkComplete;
}
public boolean newVersion() {
return this.newVersionAvalable;
}
}

View file

@ -0,0 +1,51 @@
package covers1624.powerconverters.updatechecker;
import covers1624.powerconverters.handler.ConfigurationHandler;
import covers1624.powerconverters.util.LogHelper;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.IChatComponent.Serializer;
public class UpdateManager {
private int lastPoll = 400;
private boolean notificationDisplayed = false;
private UpdateCheckThread updateThread = new UpdateCheckThread();
private String location
= "http://minecraft.curseforge.com/mc-mods/225064-power-converters3";
private String message
= "Hey PowerConverters has an update, It may include some cool stuff";
public UpdateManager() {
if (!ConfigurationHandler.doUpdateCheck) {
LogHelper.info("Update Checker is turned off.");
} else {
this.updateThread.start();
}
}
@SubscribeEvent
public void tickStart(TickEvent.PlayerTickEvent event) {
if (this.notificationDisplayed && event.phase == Phase.START) {
if (this.lastPoll > 0) {
--this.lastPoll;
} else {
this.lastPoll = 400;
if (this.updateThread.checkFinished()) {
this.notificationDisplayed = true;
if (this.updateThread.newVersion()
&& FMLCommonHandler.instance().getSide() == Side.CLIENT) {
EntityPlayer player = event.player;
IChatComponent chatComponent = Serializer.func_150699_a("[{\"text\":\"" + this.message + "\",\"color\":\"aqua\"}," + "{\"text\":\" " + EnumChatFormatting.WHITE + "[" + EnumChatFormatting.GREEN + "Download" + EnumChatFormatting.WHITE + "]\"," + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":" + "{\"text\":\"Click this to download the latest version\",\"color\":\"yellow\"}}," + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + this.location + "\"}}]");
player.addChatMessage(chatComponent);
}
}
}
}
}
}

View file

@ -0,0 +1,245 @@
package covers1624.powerconverters.util;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockPosition {
public int x;
public int y;
public int z;
public ForgeDirection orientation;
public static final int[][] SIDE_COORD_MOD
= new int[][] { { 0, -1, 0 }, { 0, 1, 0 }, { 0, 0, -1 },
{ 0, 0, 1 }, { -1, 0, 0 }, { 1, 0, 0 } };
public BlockPosition(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
this.orientation = ForgeDirection.UNKNOWN;
}
public BlockPosition(int x, int y, int z, ForgeDirection corientation) {
this.x = x;
this.y = y;
this.z = z;
this.orientation = corientation;
}
public BlockPosition(BlockPosition p) {
this.x = p.x;
this.y = p.y;
this.z = p.z;
this.orientation = p.orientation;
}
public BlockPosition(NBTTagCompound nbttagcompound) {
this.x = nbttagcompound.getInteger("i");
this.y = nbttagcompound.getInteger("j");
this.z = nbttagcompound.getInteger("k");
this.orientation = ForgeDirection.UNKNOWN;
}
public BlockPosition(TileEntity tile) {
this.x = tile.xCoord;
this.y = tile.yCoord;
this.z = tile.zCoord;
this.orientation = ForgeDirection.UNKNOWN;
}
public BlockPosition copy() {
return new BlockPosition(this.x, this.y, this.z, this.orientation);
}
public BlockPosition step(int dir, int dist) {
int[] d = SIDE_COORD_MOD[dir];
this.x += d[0] * dist;
this.y += d[1] * dist;
this.z += d[2] * dist;
return this;
}
public BlockPosition step(ForgeDirection dir) {
this.x += dir.offsetX;
this.y += dir.offsetY;
this.z += dir.offsetZ;
return this;
}
public BlockPosition step(ForgeDirection dir, int dist) {
this.x += dir.offsetX * dist;
this.y += dir.offsetY * dist;
this.z += dir.offsetZ * dist;
return this;
}
public void moveRight(int step) {
switch (this.orientation) {
case SOUTH:
this.x -= step;
break;
case NORTH:
this.x += step;
break;
case EAST:
this.z += step;
break;
case WEST:
this.z -= step;
}
}
public void moveLeft(int step) {
this.moveRight(-step);
}
public void moveForwards(int step) {
switch (this.orientation) {
case SOUTH:
this.z += step;
break;
case NORTH:
this.z -= step;
break;
case EAST:
this.x += step;
break;
case WEST:
this.x -= step;
break;
case UP:
this.y += step;
break;
case DOWN:
this.y -= step;
}
}
public void moveBackwards(int step) {
this.moveForwards(-step);
}
public void moveUp(int step) {
switch (this.orientation) {
case SOUTH:
case NORTH:
case EAST:
case WEST:
this.y += step;
default:
}
}
public void moveDown(int step) {
this.moveUp(-step);
}
public void writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setDouble("i", (double) this.x);
nbttagcompound.setDouble("j", (double) this.y);
nbttagcompound.setDouble("k", (double) this.z);
}
public String toString() {
return this.orientation == null
? "{" + this.x + ", " + this.y + ", " + this.z + "}"
: "{" + this.x + ", " + this.y + ", " + this.z + ";"
+ this.orientation.toString() + "}";
}
public boolean equals(Object obj) {
if (!(obj instanceof BlockPosition)) {
return false;
} else {
BlockPosition bp = (BlockPosition) obj;
return bp.x == this.x && bp.y == this.y && bp.z == this.z
&& bp.orientation == this.orientation;
}
}
public int hashCode() {
return this.x & 4095 | this.y & '\uff00' | this.z & 16773120;
}
public BlockPosition min(BlockPosition p) {
return new BlockPosition(
p.x > this.x ? this.x : p.x,
p.y > this.y ? this.y : p.y,
p.z > this.z ? this.z : p.z
);
}
public BlockPosition max(BlockPosition p) {
return new BlockPosition(
p.x < this.x ? this.x : p.x,
p.y < this.y ? this.y : p.y,
p.z < this.z ? this.z : p.z
);
}
public List getAdjacent(boolean includeVertical) {
List a = new ArrayList();
a.add(new BlockPosition(this.x + 1, this.y, this.z, ForgeDirection.EAST));
a.add(new BlockPosition(this.x - 1, this.y, this.z, ForgeDirection.WEST));
a.add(new BlockPosition(this.x, this.y, this.z + 1, ForgeDirection.SOUTH));
a.add(new BlockPosition(this.x, this.y, this.z - 1, ForgeDirection.NORTH));
if (includeVertical) {
a.add(new BlockPosition(this.x, this.y + 1, this.z, ForgeDirection.UP));
a.add(new BlockPosition(this.x, this.y - 1, this.z, ForgeDirection.DOWN));
}
return a;
}
public TileEntity getTileEntity(World world) {
return world.getTileEntity(this.x, this.y, this.z);
}
public Block getBlock(World world) {
return world.getBlock(this.x, this.y, this.z);
}
public Object getTileEntity(World world, Class targetClass) {
TileEntity te = world.getTileEntity(this.x, this.y, this.z);
return targetClass.isInstance(te) ? te : null;
}
public static TileEntity getTileEntityRaw(World world, int x, int y, int z) {
return !world.blockExists(x, y, z)
? null
: world.getChunkFromBlockCoords(x, z).getTileEntityUnsafe(x & 15, y, z & 15);
}
public static Object
getTileEntityRaw(World world, int x, int y, int z, Class targetClass) {
TileEntity te = getTileEntityRaw(world, x, y, z);
return targetClass.isInstance(te) ? te : null;
}
public static boolean blockExists(TileEntity start, ForgeDirection dir) {
int x = start.xCoord + dir.offsetX;
int y = start.yCoord + dir.offsetY;
int z = start.zCoord + dir.offsetZ;
return start.getWorldObj().blockExists(x, y, z);
}
public static TileEntity
getAdjacentTileEntity(TileEntity start, ForgeDirection direction) {
BlockPosition p = new BlockPosition(start);
p.orientation = direction;
p.moveForwards(1);
return start.getWorldObj().getTileEntity(p.x, p.y, p.z);
}
public static Object
getAdjacentTileEntity(TileEntity start, ForgeDirection direction, Class targetClass) {
TileEntity te = getAdjacentTileEntity(start, direction);
return targetClass.isInstance(te) ? te : null;
}
}

View file

@ -0,0 +1,14 @@
package covers1624.powerconverters.util;
import cpw.mods.fml.relauncher.FMLRelaunchLog;
import org.apache.logging.log4j.Level;
public class FMLLogHelper {
public static void logException(Level level, String data, Throwable ex) {
FMLRelaunchLog.log.getLogger().log(level, data, ex);
}
public static void log(Level level, Object obj) {
FMLRelaunchLog.log.getLogger().log(level, String.valueOf(obj));
}
}

View file

@ -0,0 +1,47 @@
package covers1624.powerconverters.util;
import net.minecraftforge.common.util.ForgeDirection;
public class GuiArea {
public int xTop;
public int yTop;
public int xBottom;
public int yBottom;
public ForgeDirection direction;
public GuiArea(int xTop, int yTop, int xBottom, int yBottom, ForgeDirection dir) {
this.xTop = xTop;
this.yTop = yTop;
this.xBottom = xBottom;
this.yBottom = yBottom;
this.direction = dir;
}
public void scaleValues(
int xTopScale, int yTopScale, int xBottomScale, int yBottomScale, boolean type
) {
if (type) {
this.xTop += xTopScale;
this.yTop += yTopScale;
this.xBottom += xBottomScale;
this.yBottom += yBottomScale;
} else {
this.xTop -= xTopScale;
this.yTop -= yTopScale;
this.xBottom -= xBottomScale;
this.yBottom -= yBottomScale;
}
}
public boolean isMouseInArea(int mouseX, int mouseY) {
return this.xTop <= mouseX && this.xBottom >= mouseX && this.yTop <= mouseY
&& this.yBottom >= mouseY;
}
public boolean isMouseInArea(int mouseX, int mouseY, int xScale, int yScale) {
this.scaleValues(xScale, yScale, xScale, yScale, true);
boolean awnser = this.isMouseInArea(mouseX, mouseY);
this.scaleValues(xScale, yScale, xScale, yScale, false);
return awnser;
}
}

View file

@ -0,0 +1,28 @@
package covers1624.powerconverters.util;
import net.minecraftforge.common.util.ForgeDirection;
public class GuiUtils {
public static String dirToAbbreviation(ForgeDirection dir) {
return dirToAbbreviation(dir.ordinal());
}
public static String dirToAbbreviation(int dir) {
switch (dir) {
case 0:
return "D";
case 1:
return "U";
case 2:
return "N";
case 3:
return "S";
case 4:
return "W";
case 5:
return "E";
default:
return "NULL";
}
}
}

View file

@ -0,0 +1,10 @@
package covers1624.powerconverters.util;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.util.ForgeDirection;
public interface IAdvancedLogTile {
void getTileInfo(List var1, ForgeDirection var2, EntityPlayer var3, boolean var4);
}

View file

@ -0,0 +1,5 @@
package covers1624.powerconverters.util;
public interface INeighboorUpdateTile {
void onNeighboorChanged();
}

View file

@ -0,0 +1,100 @@
package covers1624.powerconverters.util;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class IRecipeHandler {
public static NBTTagCompound writeIRecipeToTag(IRecipe recipe) {
NBTTagCompound mainTag = new NBTTagCompound();
NBTTagCompound tag;
NBTTagList tagList;
int i;
NBTTagCompound nbtTagCompound;
if (recipe instanceof ShapedRecipes) {
ShapedRecipes shapedRecipes = (ShapedRecipes) recipe;
tag = new NBTTagCompound();
shapedRecipes.getRecipeOutput().writeToNBT(tag);
mainTag.setTag("Output", tag);
tagList = new NBTTagList();
for (i = 0; i < shapedRecipes.recipeItems.length; ++i) {
if (shapedRecipes.recipeItems[i] != null) {
nbtTagCompound = new NBTTagCompound();
nbtTagCompound.setInteger("Slot", i);
shapedRecipes.recipeItems[i].writeToNBT(nbtTagCompound);
tagList.appendTag(nbtTagCompound);
}
}
mainTag.setTag("Input", tagList);
mainTag.setInteger("Height", shapedRecipes.recipeHeight);
mainTag.setInteger("Width", shapedRecipes.recipeWidth);
mainTag.setString("Type", "Shaped");
return mainTag;
} else if (!(recipe instanceof ShapelessRecipes)) {
return null;
} else {
ShapelessRecipes shapelessRecipes = (ShapelessRecipes) recipe;
tag = new NBTTagCompound();
shapelessRecipes.getRecipeOutput().writeToNBT(tag);
mainTag.setTag("Output", tag);
tagList = new NBTTagList();
for (i = 0; i < shapelessRecipes.recipeItems.size(); ++i) {
nbtTagCompound = new NBTTagCompound();
ItemStack stack = (ItemStack) shapelessRecipes.recipeItems.get(i);
stack.writeToNBT(nbtTagCompound);
tagList.appendTag(nbtTagCompound);
}
mainTag.setTag("Input", tagList);
mainTag.setString("Type", "Shapeless");
return mainTag;
}
}
public static IRecipe readIRecipeFromTag(NBTTagCompound tagCompound) {
String type = tagCompound.getString("Type");
ItemStack output;
if (type.equals("Shaped")) {
output = ItemStack.loadItemStackFromNBT((NBTTagCompound
) tagCompound.getTag("Output"));
int height = tagCompound.getInteger("Height");
int width = tagCompound.getInteger("Width");
ItemStack[] recipeItems = new ItemStack[9];
NBTTagList tagList = tagCompound.getTagList("Input", 10);
for (int i = 0; i < tagList.tagCount(); ++i) {
NBTTagCompound nbtTagCompound = tagList.getCompoundTagAt(i);
int slot = nbtTagCompound.getInteger("Slot");
recipeItems[slot] = ItemStack.loadItemStackFromNBT(nbtTagCompound);
}
ShapedRecipes shapedRecipe
= new ShapedRecipes(width, height, recipeItems, output);
return shapedRecipe;
} else if (!type.equals("Shapeless")) {
return null;
} else {
output = ItemStack.loadItemStackFromNBT((NBTTagCompound
) tagCompound.getTag("Output"));
ArrayList recipeItems = new ArrayList();
NBTTagList tagList = tagCompound.getTagList("Input", 10);
for (int i = 0; i < tagList.tagCount(); ++i) {
ItemStack itemStack
= ItemStack.loadItemStackFromNBT(tagList.getCompoundTagAt(i));
recipeItems.add(itemStack);
}
ShapelessRecipes shapelessRecipe = new ShapelessRecipes(output, recipeItems);
return shapelessRecipe;
}
}
}

View file

@ -0,0 +1,5 @@
package covers1624.powerconverters.util;
public interface IUpdateTileWithCords {
void onNeighboorChanged(int var1, int var2, int var3);
}

View file

@ -0,0 +1,161 @@
package covers1624.powerconverters.util;
import covers1624.powerconverters.slot.ChargerOutputSlot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class InventoryUtils {
public static void bindPlayerInventory(
Container container, InventoryPlayer inventoryPlayer, int xStart, int yStart
) {
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
int slot = j + i * 9 + 9;
int x = xStart + j * 18;
int y = yStart + i * 18;
addSlotToContainer(container, new Slot(inventoryPlayer, slot, x, y));
}
}
for (i = 0; i < 9; ++i) {
addSlotToContainer(
container, new Slot(inventoryPlayer, i, xStart + i * 18, yStart + 58)
);
}
}
public static Slot addSlotToContainer(Container container, Slot slot) {
slot.slotNumber = container.inventorySlots.size();
container.inventorySlots.add(slot);
container.inventoryItemStacks.add((Object) null);
return slot;
}
public static ItemStack
transferStackInSlot(Container container, EntityPlayer player, int slotIndex) {
ItemStack originalStack = null;
Slot slot = (Slot) container.inventorySlots.get(slotIndex);
int numSlots = container.inventorySlots.size();
if (slot != null && slot.getHasStack()) {
ItemStack stackInSlot = slot.getStack();
originalStack = stackInSlot.copy();
if (slotIndex < numSlots - 36
|| !tryShiftItem(container, stackInSlot, numSlots)) {
if (slotIndex >= numSlots - 36 && slotIndex < numSlots - 9) {
if (!shiftItemStack(container, stackInSlot, numSlots - 9, numSlots)) {
return null;
}
} else if (slotIndex >= numSlots - 9 && slotIndex < numSlots) {
if (!shiftItemStack(
container, stackInSlot, numSlots - 36, numSlots - 9
)) {
return null;
}
} else if (!shiftItemStack(
container, stackInSlot, numSlots - 36, numSlots
)) {
return null;
}
}
slot.onSlotChange(stackInSlot, originalStack);
if (stackInSlot.stackSize <= 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if (stackInSlot.stackSize == originalStack.stackSize) {
return null;
}
slot.onPickupFromSlot(player, stackInSlot);
}
return originalStack;
}
public static boolean
tryShiftItem(Container container, ItemStack stackToShift, int numSlots) {
for (int machineIndex = 0; machineIndex < numSlots - 36; ++machineIndex) {
Slot slot = (Slot) container.inventorySlots.get(machineIndex);
if (!(slot instanceof ChargerOutputSlot) && slot.isItemValid(stackToShift)
&& shiftItemStack(
container, stackToShift, machineIndex, machineIndex + 1
)) {
return true;
}
}
return false;
}
public static boolean
shiftItemStack(Container container, ItemStack stackToShift, int start, int end) {
boolean changed = false;
int slotIndex;
Slot slot;
ItemStack stackInSlot;
if (stackToShift.isStackable()) {
for (slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end;
++slotIndex) {
slot = (Slot) container.inventorySlots.get(slotIndex);
stackInSlot = slot.getStack();
if (stackInSlot != null && canStacksMerge(stackInSlot, stackToShift)) {
int max = stackInSlot.stackSize + stackToShift.stackSize;
max = Math.min(
stackToShift.getMaxStackSize(), slot.getSlotStackLimit()
);
if (max <= max) {
stackToShift.stackSize = 0;
stackInSlot.stackSize = max;
slot.onSlotChanged();
changed = true;
} else if (stackInSlot.stackSize < max) {
stackToShift.stackSize -= max - stackInSlot.stackSize;
stackInSlot.stackSize = max;
slot.onSlotChanged();
changed = true;
}
}
}
}
if (stackToShift.stackSize > 0) {
for (slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end;
++slotIndex) {
slot = (Slot) container.inventorySlots.get(slotIndex);
stackInSlot = slot.getStack();
if (stackInSlot == null) {
int max = Math.min(
stackToShift.getMaxStackSize(), slot.getSlotStackLimit()
);
stackInSlot = stackToShift.copy();
stackInSlot.stackSize = Math.min(stackToShift.stackSize, max);
stackToShift.stackSize -= stackInSlot.stackSize;
slot.putStack(stackInSlot);
slot.onSlotChanged();
changed = true;
}
}
}
return changed;
}
public static boolean canStacksMerge(ItemStack stack1, ItemStack stack2) {
if (stack1 != null && stack2 != null) {
if (!stack1.isItemEqual(stack2)) {
return false;
} else {
return ItemStack.areItemStackTagsEqual(stack1, stack2);
}
} else {
return false;
}
}
}

View file

@ -0,0 +1,95 @@
package covers1624.powerconverters.util;
import covers1624.powerconverters.handler.ConfigurationHandler;
import cpw.mods.fml.common.FMLLog;
import org.apache.logging.log4j.Level;
public class LogHelper {
public static void log(Level logLevel, Object object) {
FMLLog.log("PowerConverters", logLevel, String.valueOf(object), new Object[0]);
}
public static void all(Object object) {
log(Level.ALL, object);
}
public static void debug(Object object) {
log(Level.DEBUG, object);
}
public static void error(Object object) {
log(Level.ERROR, object);
}
public static void fatal(Object object) {
log(Level.FATAL, object);
}
public static void info(Object object) {
log(Level.INFO, object);
}
public static void off(Object object) {
log(Level.OFF, object);
}
public static void trace(Object object) {
if (ConfigurationHandler.logDebug) {
info(object);
} else {
log(Level.TRACE, object);
}
}
public static void warn(Object object) {
log(Level.WARN, object);
}
public static void all(String object, Object... format) {
log(Level.ALL, String.format(object, format));
}
public static void debug(String object, Object... format) {
log(Level.DEBUG, String.format(object, format));
}
public static void error(String object, Object... format) {
log(Level.ERROR, String.format(object, format));
}
public static void fatal(String object, Object... format) {
log(Level.FATAL, String.format(object, format));
}
public static void info(String object, Object... format) {
log(Level.INFO, String.format(object, format));
}
public static void off(String object, Object... format) {
log(Level.OFF, String.format(object, format));
}
public static void trace(String object, Object... format) {
if (ConfigurationHandler.logDebug) {
log(Level.INFO, String.format(object, format));
} else {
log(Level.TRACE, String.format(object, format));
}
}
public static void warn(String object, Object... format) {
log(Level.WARN, String.format(object, format));
}
public static void bigFatal(String format, Object... data) {
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
fatal("****************************************");
fatal("* " + format, data);
for (int i = 2; i < 8 && i < trace.length; ++i) {
fatal("* at %s%s", trace[i].toString(), i == 7 ? "..." : "");
}
fatal("****************************************");
}
}

View file

@ -0,0 +1,25 @@
package covers1624.powerconverters.util;
public class RFHelper {
public static boolean iEnergyHandlerExists = false;
public static boolean iEnergyContainerItemExists = false;
public static void init() {
try {
Class.forName("cofh.api.energy.IEnergyHandler");
iEnergyHandlerExists = true;
LogHelper.trace("IEnergyHandler Exists!");
} catch (ClassNotFoundException var2) {
LogHelper.trace("Failed To Find IEnergy Handler, Not Enableing RF Support.");
}
try {
Class.forName("cofh.api.energy.IEnergyContainerItem");
iEnergyContainerItemExists = true;
} catch (ClassNotFoundException var1) {
LogHelper.trace(
"Failed to find IEnergyContainerItem, Not registering Chargehandler for RF."
);
}
}
}

View file

@ -0,0 +1,56 @@
package covers1624.powerconverters.util;
import java.util.Iterator;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
public class RecipeRemover {
public static void removeAnyRecipes(List removeList) {
Iterator i$ = removeList.iterator();
while (i$.hasNext()) {
ItemStack stack = (ItemStack) i$.next();
removeAnyRecipe(stack);
}
}
public static void removeShapedRecipes(List removelist) {
Iterator i$ = removelist.iterator();
while (i$.hasNext()) {
ItemStack stack = (ItemStack) i$.next();
removeShapedRecipe(stack);
}
}
public static void removeAnyRecipe(ItemStack resultItem) {
List recipes = CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < recipes.size(); ++i) {
IRecipe tmpRecipe = (IRecipe) recipes.get(i);
ItemStack recipeResult = tmpRecipe.getRecipeOutput();
if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) {
recipes.remove(i--);
}
}
}
public static void removeShapedRecipe(ItemStack resultItem) {
List recipes = CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < recipes.size(); ++i) {
IRecipe tmpRecipe = (IRecipe) recipes.get(i);
if (tmpRecipe instanceof ShapedRecipes) {
ShapedRecipes recipe = (ShapedRecipes) tmpRecipe;
ItemStack recipeResult = recipe.getRecipeOutput();
if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) {
recipes.remove(i++);
}
}
}
}
}

View file

@ -0,0 +1,3 @@
package covers1624.powerconverters.util;
public class TODO {}

View file

@ -0,0 +1,14 @@
package covers1624.powerconverters.util;
public class TextureUtils {
public static String stripUnlocalizedName(String unlocalizedName) {
if (unlocalizedName.contains("item.")) {
return unlocalizedName.replaceFirst("item.", "");
} else if (unlocalizedName.contains("tile.")) {
return unlocalizedName.replaceFirst("tile.", "");
} else {
LogHelper.fatal("Unable to strip UnlocalizedName %s", unlocalizedName);
return null;
}
}
}

View file

@ -0,0 +1,58 @@
package covers1624.powerconverters.waila;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class WailaBridgeProvider implements IWailaDataProvider {
public ItemStack
getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
public List getWailaHead(
ItemStack itemStack,
List currenttip,
IWailaDataAccessor accessor,
IWailaConfigHandler config
) {
return currenttip;
}
public List getWailaBody(
ItemStack itemStack,
List currenttip,
IWailaDataAccessor accessor,
IWailaConfigHandler config
) {
return currenttip;
}
public List getWailaTail(
ItemStack itemStack,
List currenttip,
IWailaDataAccessor accessor,
IWailaConfigHandler config
) {
return currenttip;
}
public NBTTagCompound getNBTData(
EntityPlayerMP player,
TileEntity te,
NBTTagCompound tag,
World world,
int x,
int y,
int z
) {
return tag;
}
}

View file

@ -0,0 +1,62 @@
package covers1624.powerconverters.waila;
import java.util.List;
import covers1624.powerconverters.tile.main.TileEntityBridgeComponent;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class WailaComponentProvider implements IWailaDataProvider {
public ItemStack
getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
public List getWailaHead(
ItemStack itemStack,
List currenttip,
IWailaDataAccessor accessor,
IWailaConfigHandler config
) {
return currenttip;
}
public List getWailaBody(
ItemStack itemStack,
List currenttip,
IWailaDataAccessor accessor,
IWailaConfigHandler config
) {
TileEntityBridgeComponent bridgeComponent
= (TileEntityBridgeComponent) accessor.getTileEntity();
bridgeComponent.addWailaInfo(currenttip);
return currenttip;
}
public List getWailaTail(
ItemStack itemStack,
List currenttip,
IWailaDataAccessor accessor,
IWailaConfigHandler config
) {
return currenttip;
}
public NBTTagCompound getNBTData(
EntityPlayerMP player,
TileEntity te,
NBTTagCompound tag,
World world,
int x,
int y,
int z
) {
return tag;
}
}

View file

@ -0,0 +1,16 @@
package covers1624.powerconverters.waila;
import covers1624.powerconverters.tile.main.TileEntityBridgeComponent;
import covers1624.powerconverters.tile.main.TileEntityEnergyBridge;
import mcp.mobius.waila.api.IWailaRegistrar;
public class WailaModule {
public static void callBackRegister(IWailaRegistrar registrar) {
registrar.registerBodyProvider(
new WailaComponentProvider(), TileEntityBridgeComponent.class
);
registrar.registerBodyProvider(
new WailaBridgeProvider(), TileEntityEnergyBridge.class
);
}
}

View file

@ -0,0 +1,82 @@
package covers1624.powerconverters.worldgen;
import java.util.Random;
import cpw.mods.fml.common.IWorldGenerator;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
public class FlatBedrockWorldGen implements IWorldGenerator {
private static Block netherrack;
private static Block stone;
private static Block bedrock;
public void generate(
Random random,
int chunkX,
int chunkZ,
World world,
IChunkProvider chunkGenerator,
IChunkProvider chunkProvider
) {
BiomeGenBase b = world.getBiomeGenForCoords(chunkX, chunkZ);
boolean isNether = b.biomeName.toLowerCase().equals("hell");
for (int blockX = 0; blockX < 16; ++blockX) {
for (int blockZ = 0; blockZ < 16; ++blockZ) {
int blockY;
if (isNether) {
for (blockY = 126; blockY > 121; --blockY) {
if (world.getBlock(
chunkX * 16 + blockX, blockY, chunkZ * 16 + blockZ
)
== bedrock) {
world.setBlock(
chunkX * 16 + blockX,
blockY,
chunkZ * 16 + blockZ,
netherrack,
0,
2
);
}
}
}
for (blockY = 5; blockY > 0; --blockY) {
if (world.getBlock(chunkX * 16 + blockX, blockY, chunkZ * 16 + blockZ)
== bedrock) {
if (isNether) {
world.setBlock(
chunkX * 16 + blockX,
blockY,
chunkZ * 16 + blockZ,
netherrack,
0,
2
);
} else {
world.setBlock(
chunkX * 16 + blockX,
blockY,
chunkZ * 16 + blockZ,
stone,
0,
2
);
}
}
}
}
}
}
static {
netherrack = Blocks.netherrack;
stone = Blocks.stone;
bedrock = Blocks.bedrock;
}
}

View file

@ -0,0 +1,527 @@
package covers1624.repack.cofh.lib.util;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.Arrays;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import com.google.common.base.Objects;
public class ArrayHashList
extends AbstractCollection implements List, Cloneable, Serializable {
private static final long serialVersionUID = 3230581060536180693L;
private transient Object[] elementData;
protected transient int size;
protected transient int mask;
protected transient Entry[] hashTable;
protected transient int modCount;
private static final int MAX_ARRAY_SIZE = 2147483639;
protected static int hash(Object n) {
int h = n == null ? 0 : n.hashCode();
h ^= h >>> 20 ^ h >>> 12;
return h ^ h >>> 7 ^ h >>> 4;
}
private static int roundUpToPowerOf2(int number) {
return number >= 1073741824
? 1073741824
: (number > 2 ? Integer.highestOneBit(number - 1 << 1) : 2);
}
public ArrayHashList() {
this.elementData = new Object[10];
this.hashTable = new Entry[8];
this.mask = 7;
}
public ArrayHashList(int size) {
this.elementData = new Object[size];
size = roundUpToPowerOf2(size) >> 1;
this.hashTable = new Entry[size];
this.mask = size - 1;
}
public ArrayHashList(Collection col) {
int size = col.size();
this.elementData = new Object[size];
size = roundUpToPowerOf2(size) >> 1;
this.hashTable = new Entry[size];
this.mask = size - 1;
this.addAll(col);
}
public int size() {
return this.size;
}
protected void add(Object obj, int hash) {
this.ensureCapacityInternal(this.size + 1);
this.elementData[this.size++] = obj;
this.insert(new Entry(obj, hash));
this.rehashIfNecessary();
}
public boolean add(Object obj) {
int hash = hash(obj);
if (this.seek(obj, hash) != null) {
return false;
} else {
this.add(obj, hash);
return true;
}
}
public Object set(int index, Object obj) {
this.checkElementIndex(index);
int hash = hash(obj);
if (this.seek(obj, hash) != null) {
throw new IllegalArgumentException("Duplicate entries not allowed");
} else {
++this.modCount;
Entry e = this.seek(this.elementData[index], hash(this.elementData[index]));
this.delete(e);
this.elementData[index] = obj;
this.insert(new Entry(obj, hash));
return e.key;
}
}
public void add(int index, Object obj) {
this.checkPositionIndex(index);
int hash = hash(obj);
if (this.seek(obj, hash) != null) {
throw new IllegalArgumentException("Duplicate entries not allowed");
} else if (index == this.size) {
this.add(obj, hash);
} else {
this.ensureCapacityInternal(++this.size);
System.arraycopy(
this.elementData,
index,
this.elementData,
index + 1,
this.size - index - 1
);
this.elementData[index] = obj;
this.insert(new Entry(obj, hash));
this.rehashIfNecessary();
}
}
public boolean addAll(int index, Collection c) {
if (c.size() == 0) {
return false;
} else {
Iterator i$ = c.iterator();
while (i$.hasNext()) {
Object e = i$.next();
this.add(index++, e);
}
return true;
}
}
public Object get(int index) {
this.checkElementIndex(index);
return this.index(index);
}
public int indexOf(Object obj) {
Entry e = this.seek(obj, hash(obj));
if (e == null) {
return -1;
} else {
Object o = e.key;
Object[] data = this.elementData;
int i = this.size;
while (i-- > 0 && data[i] != o) {}
return i;
}
}
public int lastIndexOf(Object o) {
return this.indexOf(o);
}
public boolean contains(Object obj) {
return this.seek(obj, hash(obj)) != null;
}
public Object remove(int index) {
this.checkElementIndex(index);
Object oldValue = this.index(index);
this.delete(this.seek(oldValue, hash(oldValue)));
this.fastRemove(index);
return oldValue;
}
public boolean remove(Object obj) {
Entry e = this.seek(obj, hash(obj));
if (e == null) {
return false;
} else {
Object o = e.key;
Object[] data = this.elementData;
int i = this.size;
while (i-- > 0) {
if (data[i] == o) {
this.fastRemove(i);
break;
}
}
this.delete(e);
return true;
}
}
private void fastRemove(int index) {
++this.modCount;
int numMoved = this.size - index - 1;
if (numMoved > 0) {
System.arraycopy(
this.elementData, index + 1, this.elementData, index, numMoved
);
}
this.elementData[--this.size] = null;
}
public void clear() {
++this.modCount;
int i;
for (i = 0; i < this.size; ++i) {
this.elementData[i] = null;
}
for (i = this.hashTable.length; i-- > 0; this.hashTable[i] = null) {}
this.size = 0;
}
public void trimToSize() {
++this.modCount;
if (this.size < this.elementData.length) {
this.elementData = Arrays.copyOf(this.elementData, this.size);
}
}
public void ensureCapacity(int minCapacity) {
if (minCapacity > 0) {
this.ensureCapacityInternal(minCapacity);
}
}
private void ensureCapacityInternal(int minCapacity) {
++this.modCount;
if (minCapacity - this.elementData.length > 0) {
this.grow(minCapacity);
}
}
private void grow(int minCapacity) {
int oldCapacity = this.elementData.length;
int newCapacity = oldCapacity + (oldCapacity >> 1);
if (newCapacity - minCapacity < 0) {
newCapacity = minCapacity;
}
if (newCapacity - 2147483639 > 0) {
newCapacity = hugeCapacity(minCapacity);
}
this.elementData = Arrays.copyOf(this.elementData, newCapacity);
}
private static int hugeCapacity(int minCapacity) {
if (minCapacity < 0) {
throw new OutOfMemoryError();
} else {
return minCapacity > 2147483639 ? Integer.MAX_VALUE : 2147483639;
}
}
private void writeObject(ObjectOutputStream s) throws IOException {
int expectedModCount = this.modCount;
s.defaultWriteObject();
s.writeInt(this.size);
for (int i = 0; i < this.size; ++i) {
s.writeObject(this.elementData[i]);
}
if (this.modCount != expectedModCount) {
throw new ConcurrentModificationException();
}
}
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException {
this.elementData = new Object[10];
this.hashTable = new Entry[8];
this.mask = 7;
s.defaultReadObject();
int size = s.readInt();
if (size > 0) {
this.ensureCapacityInternal(size);
for (int i = 0; i < size; ++i) {
this.add(s.readObject());
}
}
}
Object index(int index) {
return this.elementData[index];
}
protected Entry seek(Object obj, int hash) {
for (Entry entry = this.hashTable[hash & this.mask]; entry != null;
entry = entry.nextInBucket) {
if (hash == entry.hash && Objects.equal(obj, entry.key)) {
return entry;
}
}
return null;
}
protected void insert(Entry entry) {
int bucket = entry.hash & this.mask;
entry.nextInBucket = this.hashTable[bucket];
this.hashTable[bucket] = entry;
}
protected void delete(Entry entry) {
synchronized (this.hashTable) {
int bucket = entry.hash & this.mask;
Entry prev = null;
Entry cur = this.hashTable[bucket];
if (cur == entry) {
this.hashTable[bucket] = cur.nextInBucket;
} else {
while (cur != entry) {
prev = cur;
cur = cur.nextInBucket;
}
prev.nextInBucket = entry.nextInBucket;
}
}
}
protected void rehashIfNecessary() {
Entry[] old = this.hashTable;
if (this.size > old.length * 2 && old.length < 1073741824) {
synchronized (this.hashTable) {
int newTableSize = old.length * 2;
int newMask = newTableSize - 1;
Entry[] newTable = this.hashTable = new Entry[newTableSize];
this.mask = newMask;
int bucket = old.length;
Entry nextEntry;
while (bucket-- > 0) {
for (Entry entry = old[bucket]; entry != null; entry = nextEntry) {
nextEntry = entry.nextInBucket;
int keyBucket = entry.hash & newMask;
entry.nextInBucket = newTable[keyBucket];
newTable[keyBucket] = entry;
}
}
}
}
}
public ArrayHashList clone() {
return new ArrayHashList(this);
}
public List subList(int fromIndex, int toIndex) {
throw new UnsupportedOperationException();
}
public Iterator iterator() {
return new Itr();
}
public ListIterator listIterator() {
return this.listIterator(0);
}
public ListIterator listIterator(int index) {
return new ListItr(index);
}
protected boolean isElementIndex(int index) {
return index >= 0 && index < this.size;
}
protected boolean isPositionIndex(int index) {
return index >= 0 && index <= this.size;
}
protected String outOfBoundsMsg(int index) {
return "Index: " + index + ", Size: " + this.size;
}
protected void checkElementIndex(int index) {
if (!this.isElementIndex(index)) {
throw new IndexOutOfBoundsException(this.outOfBoundsMsg(index));
}
}
protected void checkPositionIndex(int index) {
if (!this.isPositionIndex(index)) {
throw new IndexOutOfBoundsException(this.outOfBoundsMsg(index));
}
}
private class ListItr extends Itr implements ListIterator {
ListItr(int index) {
super(null);
super.cursor = index;
}
public boolean hasPrevious() {
return super.cursor != 0;
}
public int nextIndex() {
return super.cursor;
}
public int previousIndex() {
return super.cursor - 1;
}
public Object previous() {
this.checkForComodification();
int i = super.cursor - 1;
if (i < 0) {
throw new NoSuchElementException();
} else {
Object[] elementData = ArrayHashList.this.elementData;
if (i >= elementData.length) {
throw new ConcurrentModificationException();
} else {
super.cursor = i;
return elementData[super.lastRet = i];
}
}
}
public void set(Object e) {
if (super.lastRet < 0) {
throw new IllegalStateException();
} else {
this.checkForComodification();
try {
ArrayHashList.this.set(super.lastRet, e);
} catch (IndexOutOfBoundsException var3) {
throw new ConcurrentModificationException();
}
}
}
public void add(Object e) {
this.checkForComodification();
try {
int i = super.cursor;
ArrayHashList.this.add(i, e);
super.cursor = i + 1;
super.lastRet = -1;
super.expectedModCount = ArrayHashList.this.modCount;
} catch (IndexOutOfBoundsException var3) {
throw new ConcurrentModificationException();
}
}
}
private class Itr implements Iterator {
int cursor;
int lastRet;
int expectedModCount;
private Itr() {
this.lastRet = -1;
this.expectedModCount = ArrayHashList.this.modCount;
}
public boolean hasNext() {
return this.cursor != ArrayHashList.this.size;
}
public Object next() {
this.checkForComodification();
int i = this.cursor;
if (i >= ArrayHashList.this.size) {
throw new NoSuchElementException();
} else {
Object[] elementData = ArrayHashList.this.elementData;
if (i >= elementData.length) {
throw new ConcurrentModificationException();
} else {
this.cursor = i + 1;
return elementData[this.lastRet = i];
}
}
}
public void remove() {
if (this.lastRet < 0) {
throw new IllegalStateException();
} else {
this.checkForComodification();
try {
ArrayHashList.this.remove(this.lastRet);
this.cursor = this.lastRet;
this.lastRet = -1;
this.expectedModCount = ArrayHashList.this.modCount;
} catch (IndexOutOfBoundsException var2) {
throw new ConcurrentModificationException();
}
}
}
final void checkForComodification() {
if (ArrayHashList.this.modCount != this.expectedModCount) {
throw new ConcurrentModificationException();
}
}
// $FF: synthetic method
Itr(Object x1) {
this();
}
}
protected static final class Entry {
protected final Object key;
protected final int hash;
protected Entry nextInBucket;
protected Entry(Object key, int keyHash) {
this.key = key;
this.hash = keyHash;
}
}
}

View file

@ -0,0 +1,471 @@
package covers1624.repack.cofh.lib.util;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import com.google.common.base.Objects;
public class LinkedHashList extends AbstractCollection implements Cloneable {
protected transient Entry head;
protected transient Entry tail;
protected transient int size;
protected transient int mask;
protected transient Entry[] hashTable;
protected transient int modCount;
protected static int roundUpToPowerOf2(int number) {
return number >= 1073741824
? 1073741824
: (number > 2 ? Integer.highestOneBit(number - 1 << 1) : 2);
}
public LinkedHashList() {
this.hashTable = new Entry[8];
this.mask = 7;
}
public LinkedHashList(int size) {
size = roundUpToPowerOf2(size);
this.hashTable = new Entry[size];
this.mask = size - 1;
}
public LinkedHashList(Collection col) {
int size = roundUpToPowerOf2(col.size());
this.hashTable = new Entry[size];
this.mask = size - 1;
this.addAll(col);
}
protected int hash(Object n) {
int h = n == null ? 0 : n.hashCode();
h ^= h >>> 20 ^ h >>> 12;
return h ^ h >>> 7 ^ h >>> 4;
}
public int size() {
return this.size;
}
public boolean add(Object e) {
return this.push(e);
}
public Object get(int index) {
this.checkElementIndex(index);
return this.index(index).key;
}
public boolean push(Object obj) {
int hash = this.hash(obj);
if (this.seek(obj, hash) != null) {
return false;
} else {
++this.modCount;
Entry e;
this.insert(e = new Entry(obj, hash));
this.rehashIfNecessary();
e.prev = this.tail;
e.next = null;
if (this.tail != null) {
this.tail.next = e;
} else {
this.head = e;
}
this.tail = e;
return true;
}
}
public Object pop() {
Entry e = this.tail;
if (e != null) {
++this.modCount;
this.delete(e);
this.tail = e.prev;
e.prev = null;
if (this.tail != null) {
this.tail.next = null;
} else {
this.head = null;
}
return e.key;
} else {
return null;
}
}
public Object peek() {
return this.tail != null ? this.tail.key : null;
}
public Object poke() {
return this.head != null ? this.head.key : null;
}
public boolean unshift(Object obj) {
int hash = this.hash(obj);
if (this.seek(obj, hash) != null) {
return false;
} else {
++this.modCount;
Entry e;
this.insert(e = new Entry(obj, hash));
this.rehashIfNecessary();
e.next = this.head;
e.prev = null;
if (this.head != null) {
this.head.prev = e;
} else {
this.tail = e;
}
this.head = e;
return true;
}
}
public Object shift() {
Entry e = this.head;
if (e != null) {
++this.modCount;
this.delete(e);
this.head = e.next;
e.next = null;
if (this.head != null) {
this.head.prev = null;
} else {
this.tail = null;
}
return e.key;
} else {
return null;
}
}
public boolean contains(Object obj) {
return this.seek(obj, this.hash(obj)) != null;
}
public boolean remove(Object obj) {
Entry e = this.seek(obj, this.hash(obj));
if (e == null) {
return false;
} else {
this.unlink(e);
return true;
}
}
protected Entry index(int index) {
Entry x;
int i;
if (index < this.size >> 1) {
x = this.head;
for (i = index; i-- > 0; x = x.next) {}
} else {
x = this.tail;
for (i = this.size - 1; i-- > index; x = x.prev) {}
}
return x;
}
protected Entry seek(Object obj, int hash) {
for (Entry entry = this.hashTable[hash & this.mask]; entry != null;
entry = entry.nextInBucket) {
if (hash == entry.hash && Objects.equal(obj, entry.key)) {
return entry;
}
}
return null;
}
protected void insert(Entry entry) {
int bucket = entry.hash & this.mask;
entry.nextInBucket = this.hashTable[bucket];
this.hashTable[bucket] = entry;
++this.size;
}
protected boolean linkBefore(Object obj, Entry succ) {
int hash = this.hash(obj);
if (this.seek(obj, hash) != null) {
return false;
} else {
Entry pred = succ.prev;
Entry newNode = new Entry(obj, hash);
++this.modCount;
this.insert(newNode);
this.rehashIfNecessary();
newNode.next = succ;
newNode.prev = pred;
succ.prev = newNode;
if (pred == null) {
this.head = newNode;
} else {
pred.next = newNode;
}
return true;
}
}
protected void delete(Entry entry) {
synchronized (this.hashTable) {
int bucket = entry.hash & this.mask;
Entry prev = null;
Entry cur = this.hashTable[bucket];
if (cur == entry) {
this.hashTable[bucket] = cur.nextInBucket;
} else {
while (cur != entry) {
prev = cur;
cur = cur.nextInBucket;
}
prev.nextInBucket = entry.nextInBucket;
}
}
--this.size;
}
protected Object unlink(Entry x) {
Object element = x.key;
Entry next = x.next;
Entry prev = x.prev;
if (prev == null) {
this.head = next;
} else {
prev.next = next;
x.prev = null;
}
if (next == null) {
this.tail = prev;
} else {
next.prev = prev;
x.next = null;
}
this.delete(x);
++this.modCount;
return element;
}
protected void rehashIfNecessary() {
Entry[] old = this.hashTable;
if (this.size > old.length * 2 && old.length < 1073741824) {
synchronized (this.hashTable) {
int newTableSize = old.length * 2;
int newMask = newTableSize - 1;
Entry[] newTable = new Entry[newTableSize];
this.mask = newMask;
int bucket = old.length;
Entry nextEntry;
while (bucket-- > 0) {
for (Entry entry = old[bucket]; entry != null; entry = nextEntry) {
nextEntry = entry.nextInBucket;
int keyBucket = entry.hash & newMask;
entry.nextInBucket = newTable[keyBucket];
newTable[keyBucket] = entry;
}
}
this.hashTable = newTable;
}
}
}
public LinkedHashList clone() {
return new LinkedHashList(this);
}
public Iterator iterator() {
return this.listIterator();
}
public ListIterator listIterator() {
return this.listIterator(0);
}
public ListIterator listIterator(int index) {
this.checkPositionIndex(index);
return new ListItr(index);
}
public Iterator descendingIterator() {
return new DescendingIterator();
}
protected boolean isElementIndex(int index) {
return index >= 0 && index < this.size;
}
protected boolean isPositionIndex(int index) {
return index >= 0 && index <= this.size;
}
protected String outOfBoundsMsg(int index) {
return "Index: " + index + ", Size: " + this.size;
}
protected void checkElementIndex(int index) {
if (!this.isElementIndex(index)) {
throw new IndexOutOfBoundsException(this.outOfBoundsMsg(index));
}
}
protected void checkPositionIndex(int index) {
if (!this.isPositionIndex(index)) {
throw new IndexOutOfBoundsException(this.outOfBoundsMsg(index));
}
}
protected class DescendingIterator implements Iterator {
protected final ListItr itr
= LinkedHashList.this.new ListItr(LinkedHashList.this.size());
public boolean hasNext() {
return this.itr.hasPrevious();
}
public Object next() {
return this.itr.previous();
}
public void remove() {
this.itr.remove();
}
}
protected class ListItr implements ListIterator {
protected Entry lastReturned = null;
protected Entry next;
protected int nextIndex;
protected int expectedModCount;
protected ListItr(int index) {
this.expectedModCount = LinkedHashList.this.modCount;
this.next = index == LinkedHashList.this.size
? null
: LinkedHashList.this.index(index);
this.nextIndex = index;
}
public boolean hasNext() {
return this.nextIndex < LinkedHashList.this.size;
}
public Object next() {
this.checkForComodification();
if (!this.hasNext()) {
throw new NoSuchElementException();
} else {
this.lastReturned = this.next;
this.next = this.next.next;
++this.nextIndex;
return this.lastReturned.key;
}
}
public boolean hasPrevious() {
return this.nextIndex > 0;
}
public Object previous() {
this.checkForComodification();
if (!this.hasPrevious()) {
throw new NoSuchElementException();
} else {
this.lastReturned = this.next
= this.next == null ? LinkedHashList.this.tail : this.next.prev;
--this.nextIndex;
return this.lastReturned.key;
}
}
public int nextIndex() {
return this.nextIndex;
}
public int previousIndex() {
return this.nextIndex - 1;
}
public void remove() {
this.checkForComodification();
if (this.lastReturned == null) {
throw new IllegalStateException();
} else {
Entry lastNext = this.lastReturned.next;
LinkedHashList.this.unlink(this.lastReturned);
if (this.next == this.lastReturned) {
this.next = lastNext;
} else {
--this.nextIndex;
}
this.lastReturned = null;
++this.expectedModCount;
}
}
public void set(Object e) {
this.checkForComodification();
if (this.lastReturned == null) {
throw new IllegalStateException();
} else {
LinkedHashList.this.linkBefore(e, this.lastReturned);
LinkedHashList.this.unlink(this.lastReturned);
this.lastReturned
= this.next == null ? LinkedHashList.this.tail : this.next.prev;
this.expectedModCount += 2;
}
}
public void add(Object e) {
this.checkForComodification();
this.lastReturned = null;
if (this.next == null) {
LinkedHashList.this.push(e);
} else {
LinkedHashList.this.linkBefore(e, this.next);
}
++this.nextIndex;
++this.expectedModCount;
}
protected final void checkForComodification() {
if (LinkedHashList.this.modCount != this.expectedModCount) {
throw new ConcurrentModificationException();
}
}
}
protected static final class Entry {
protected Entry next;
protected Entry prev;
protected final Object key;
protected final int hash;
protected Entry nextInBucket;
protected Entry(Object key, int keyHash) {
this.key = key;
this.hash = keyHash;
}
}
}

View file

@ -0,0 +1,51 @@
#Common Blocks
powerconverters.common.bridge.name=Energy Bridge
powerconverters.common.charger.name=Universal Charger
#Bc Blocks Dead. Kept for no reason at all
#powerconverters.bc.consumer.name=BC Consumer
#powerconverters.bc.producer.name=BC Producer
#IC2
powerconverters.ic2.lv.consumer.name=IC2 LV Consumer
powerconverters.ic2.lv.producer.name=IC2 LV Producer
powerconverters.ic2.mv.consumer.name=IC2 MV Consumer
powerconverters.ic2.mv.producer.name=IC2 MV Producer
powerconverters.ic2.hv.consumer.name=IC2 HV Consumer
powerconverters.ic2.hv.producer.name=IC2 HV Producer
powerconverters.ic2.ev.consumer.name=IC2 EV Consumer
powerconverters.ic2.ev.producer.name=IC2 EV Producer
#RF
powerconverters.rf.consumer.name=RF Consumer
powerconverters.rf.producer.name=RF Producer
#Steam
powerconverters.steam.consumer.name=Steam Consumer
powerconverters.steam.producer.name=Steam Producer
#Factorization
powerconverters.fz.consumer.name=Factorization Consumer
powerconverters.fz.producer.name=Factorization Producer
#Items
item.pcdebugitem.name=Power Converters Debug Probe
#Documentation, see powercrystals.powerconverters.nei.InfoHandler,
item.pcdebugitem.documentation=This item will tell you the current percent energy stored in a EnergyBridge multi block, simply right click on any Consumer or Producer or the Energy Bridge. It will also show you advanced information about the status of a Energy Conduit Network.
powerconverters.common.bridge.documentation=This is the Common Block for PowerConverters, When you place a consumer next to this block the Consumer will deposit the energy received into the energy bridge, When a Producer is placed next to this block it will produce energy from the energy stored in the Bridge.
powerconverters.common.charger.documentation=This block when placed next to a EnergyBridge will charge any items that work of IC2 power or RF power, The items can be placed in the Charger itself or in any chest next to it. Please note: if you have any server tps issues with this please submit a bug report it is NOT intended.
powerconverters.steam.consumer.documentation=This block when placed next to a EnergyBridge will accept Steam and convert it into energy that will be stored in the EnergyBridge.
powerconverters.steam.producer.documentation=This block when placed next to a EnergyBridge will Provide Steam to adjacent blocks and pipes using the energy stored in the EnergyBridge.
powerconverters.rf.consumer.documentation=This block when placed next to a EnergyBridge will accept Redstone Flux Energy (RF) at a infinite rate and convert it into energy that will be stored in the EnergyBridge.
powerconverters.rf.producer.documentation=This block when placed next to a EnergyBridge will Provide Redstone Flux Energy (RF) at a infinate rate to adjacent blocks and conduits that support RF using the energy stored in the EnergyBridge.
powerconverters.fz.consumer.documentation=This block when placed next to a EnergyBridge will accept Factorization GC and convert it into energy that will be stored in the EnergyBridge.
powerconverters.fz.producer.documentation=This block when placed next to a EnergyBridge will Provice Factorization GC to adjacent blocks and Lead Cables using the energy stored in the EnergyBridge.
powerconverters.ic2.lv.consumer.documentation=This block when placed next to a EnergyBridge will accept EU at a MAX of 32 EU/t (BatBox) and convert it into energy that will be stored in the EnergyBridge.
powerconverters.ic2.lv.producer.documentation=This block when placed next to a EnergyBridge will provide EU at a MAX of 32 EU/t (BatBox) to adjacent blocks and cables using the energy stored in the EnergyBridge.
powerconverters.ic2.mv.consumer.documentation=This block when placed next to a EnergyBridge will accept EU at a MAX of 128 EU/t (CESU) and convert it into energy that will be stored in the EnergyBridge.
powerconverters.ic2.mv.producer.documentation=This block when placed next to a EnergyBridge will provide EU at a MAX of 128 EU/t (CESU) to adjacent blocks and cables using the energy stored in the EnergyBridge.
powerconverters.ic2.hv.consumer.documentation=This block when placed next to a EnergyBridge will accept EU at a MAX of 512 EU/t (MFE) and convert it into energy that will be stored in the EnergyBridge.
powerconverters.ic2.hv.producer.documentation=This block when placed next to a EnergyBridge will provide EU at a MAX of 512 EU/t (MFE) to adjacent blocks and cables using the energy stored in the EnergyBridge.
powerconverters.ic2.ev.consumer.documentation=This block when placed next to a EnergyBridge will accept EU at a MAX of 2048 EU/t (MFSU) and convert it into energy that will be stored in the EnergyBridge.
powerconverters.ic2.ev.producer.documentation=This block when placed next to a EnergyBridge will provide EU at a MAX of 2048 EU/t (MFSU) to adjacent blocks and cables using the energy stored in the EnergyBridge.

Binary file not shown.

After

Width:  |  Height:  |  Size: 844 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 B

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