forked from Anvilcraft/pccompat
fix: universal alectricity fully implemented
This commit is contained in:
parent
2a223e8c81
commit
9d3f087599
8
src/main/java/net/anvilcraft/pccompat/IModProxy.java
Normal file
8
src/main/java/net/anvilcraft/pccompat/IModProxy.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package net.anvilcraft.pccompat;
|
||||
|
||||
public interface IModProxy {
|
||||
public void registerPowerSystem();
|
||||
public void registerBlocks();
|
||||
public void registerTiles();
|
||||
public void registerRecipes();
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package net.anvilcraft.pccompat;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.anvilcraft.pccompat.blocks.BlockPowerConverterUniversalElectricity;
|
||||
import net.anvilcraft.pccompat.items.ItemBlockPowerConverterUniversalElectricity;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class PCCBlocks {
|
||||
public static Block powerConverterUniversalElectricity;
|
||||
|
||||
public static void register() {
|
||||
GameRegistry.registerBlock(
|
||||
powerConverterUniversalElectricity
|
||||
= new BlockPowerConverterUniversalElectricity(),
|
||||
ItemBlockPowerConverterUniversalElectricity.class,
|
||||
"power_converter_universal_electrictity"
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,39 +1,30 @@
|
|||
package net.anvilcraft.pccompat;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
|
||||
import covers1624.powerconverters.api.registry.PowerSystemRegistry;
|
||||
import covers1624.powerconverters.api.registry.PowerSystemRegistry.PowerSystem;
|
||||
import covers1624.powerconverters.init.PowerSystems;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.anvilcraft.pccompat.tiles.TileEntityUniversalElectricityConsumer;
|
||||
import net.anvilcraft.pccompat.tiles.TileEntityUniversalElectricityProducer;
|
||||
import net.anvilcraft.pccompat.mods.UniversalElectricityProxy;
|
||||
|
||||
@Mod(
|
||||
modid = "pccompat",
|
||||
name = "PC Compat",
|
||||
version = "0.1.0",
|
||||
dependencies = "required-after:PowerConverters3"
|
||||
dependencies = "required-after:PowerConverters3;after:basiccomponents"
|
||||
)
|
||||
public class PCCompat {
|
||||
public static PowerSystem universalElectricityPowerSystem;
|
||||
public static HashSet<IModProxy> mods = new HashSet<>();
|
||||
|
||||
@Mod.EventHandler
|
||||
public static void preInit(FMLPreInitializationEvent ev) {
|
||||
PowerSystemRegistry.registerPowerSystem(
|
||||
universalElectricityPowerSystem = new PowerSystem(
|
||||
"Universal Electricity",
|
||||
"UE",
|
||||
400,
|
||||
new String[] { "LV", "MV", "HV", "EV" },
|
||||
new int[] { 60, 120, 240, 480 },
|
||||
"W"
|
||||
)
|
||||
);
|
||||
|
||||
collectMods();
|
||||
try {
|
||||
// Fix IC2 scale "Ammount" due to mod outragous developer incompetence
|
||||
Field field = PowerSystem.class.getDeclaredField("scaleAmmount");
|
||||
field.setAccessible(true);
|
||||
field.setInt(PowerSystems.powerSystemIndustrialCraft, 4000);
|
||||
|
@ -41,13 +32,21 @@ public class PCCompat {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
GameRegistry.registerTileEntity(
|
||||
TileEntityUniversalElectricityConsumer.class, "universal_electricity_consumer"
|
||||
);
|
||||
GameRegistry.registerTileEntity(
|
||||
TileEntityUniversalElectricityProducer.class, "universal_electricity_producer"
|
||||
);
|
||||
for (IModProxy mp : mods) {
|
||||
mp.registerPowerSystem();
|
||||
mp.registerBlocks();
|
||||
mp.registerTiles();
|
||||
}
|
||||
}
|
||||
|
||||
PCCBlocks.register();
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent ev) {
|
||||
for (IModProxy mp : mods)
|
||||
mp.registerRecipes();
|
||||
}
|
||||
|
||||
private static void collectMods() {
|
||||
if (Loader.isModLoaded("basiccomponents"))
|
||||
mods.add(new UniversalElectricityProxy());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
package net.anvilcraft.pccompat.mods;
|
||||
|
||||
import basiccomponents.common.BasicComponents;
|
||||
import covers1624.powerconverters.api.registry.PowerSystemRegistry;
|
||||
import covers1624.powerconverters.api.registry.PowerSystemRegistry.PowerSystem;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.anvilcraft.pccompat.IModProxy;
|
||||
import net.anvilcraft.pccompat.blocks.BlockPowerConverterUniversalElectricity;
|
||||
import net.anvilcraft.pccompat.items.ItemBlockPowerConverterUniversalElectricity;
|
||||
import net.anvilcraft.pccompat.recipe.RecipeBuilder;
|
||||
import net.anvilcraft.pccompat.recipe.ShapedOreRecipeAdapter;
|
||||
import net.anvilcraft.pccompat.recipe.ShapelessOreRecipeAdapter;
|
||||
import net.anvilcraft.pccompat.tiles.TileEntityUniversalElectricityConsumer;
|
||||
import net.anvilcraft.pccompat.tiles.TileEntityUniversalElectricityProducer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class UniversalElectricityProxy implements IModProxy {
|
||||
public static PowerSystem powerSystem;
|
||||
public static Block blockPowerConverter;
|
||||
|
||||
@Override
|
||||
public void registerPowerSystem() {
|
||||
PowerSystemRegistry.registerPowerSystem(
|
||||
powerSystem = new PowerSystem(
|
||||
"Universal Electricity",
|
||||
"UE",
|
||||
400,
|
||||
new String[] { "LV", "MV", "HV", "EV" },
|
||||
new int[] { 60, 120, 240, 480 },
|
||||
"W"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlocks() {
|
||||
GameRegistry.registerBlock(
|
||||
blockPowerConverter = new BlockPowerConverterUniversalElectricity(),
|
||||
ItemBlockPowerConverterUniversalElectricity.class,
|
||||
"power_converter_universal_electrictity"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTiles() {
|
||||
GameRegistry.registerTileEntity(
|
||||
TileEntityUniversalElectricityConsumer.class, "universal_electricity_consumer"
|
||||
);
|
||||
GameRegistry.registerTileEntity(
|
||||
TileEntityUniversalElectricityProducer.class, "universal_electricity_producer"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {
|
||||
ItemStack batbox = new ItemStack(BasicComponents.blockMachine, 1, 4);
|
||||
|
||||
new RecipeBuilder(new ShapedOreRecipeAdapter())
|
||||
.pattern("G G", " ", "GBG")
|
||||
.ingredient('G', "ingotGold")
|
||||
.ingredient('B', batbox)
|
||||
.output(new ItemStack(blockPowerConverter, 1, 0))
|
||||
.register();
|
||||
|
||||
new RecipeBuilder(new ShapedOreRecipeAdapter())
|
||||
.pattern("G G", " B ", "G G")
|
||||
.ingredient('G', "ingotGold")
|
||||
.ingredient('B', batbox)
|
||||
.output(new ItemStack(blockPowerConverter, 1, 2))
|
||||
.register();
|
||||
|
||||
new RecipeBuilder(new ShapedOreRecipeAdapter())
|
||||
.pattern("GBG", " ", "G G")
|
||||
.ingredient('G', "ingotGold")
|
||||
.ingredient('B', batbox)
|
||||
.output(new ItemStack(blockPowerConverter, 1, 4))
|
||||
.register();
|
||||
|
||||
new RecipeBuilder(new ShapedOreRecipeAdapter())
|
||||
.pattern("GBG", "G G", "G G")
|
||||
.ingredient('G', "ingotGold")
|
||||
.ingredient('B', batbox)
|
||||
.output(new ItemStack(blockPowerConverter, 1, 6))
|
||||
.register();
|
||||
|
||||
for (int i = 0; i < 8; i += 2) {
|
||||
new RecipeBuilder(new ShapelessOreRecipeAdapter())
|
||||
.ingredient(
|
||||
new ItemStack(blockPowerConverter, 1, i)
|
||||
)
|
||||
.output(
|
||||
new ItemStack(blockPowerConverter, 1, i + 1)
|
||||
)
|
||||
.register();
|
||||
|
||||
new RecipeBuilder(new ShapelessOreRecipeAdapter())
|
||||
.ingredient(
|
||||
new ItemStack(blockPowerConverter, 1, i + 1)
|
||||
)
|
||||
.output(new ItemStack(blockPowerConverter, 1, i))
|
||||
.register();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package net.anvilcraft.pccompat.recipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
public interface IRecipeAdapter {
|
||||
public void setOutput(ItemStack item);
|
||||
|
||||
public void setPattern(String... pattern);
|
||||
|
||||
public void addIngredient(Object... ingredients);
|
||||
|
||||
public IRecipe create();
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package net.anvilcraft.pccompat.recipe;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RecipeBuilder {
|
||||
IRecipeAdapter adapter;
|
||||
|
||||
public RecipeBuilder(IRecipeAdapter adapter) {
|
||||
this.adapter = adapter;
|
||||
}
|
||||
|
||||
public RecipeBuilder output(ItemStack stack) {
|
||||
this.adapter.setOutput(stack);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecipeBuilder output(Item item) {
|
||||
this.adapter.setOutput(new ItemStack(item));
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecipeBuilder output(Block block) {
|
||||
this.adapter.setOutput(new ItemStack(block));
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecipeBuilder output(Block block, int count) {
|
||||
this.adapter.setOutput(new ItemStack(block, count));
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecipeBuilder output(Item item, int count) {
|
||||
this.adapter.setOutput(new ItemStack(item, count));
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecipeBuilder pattern(String... pat) {
|
||||
this.adapter.setPattern(pat);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RecipeBuilder ingredient(Object... i) {
|
||||
this.adapter.addIngredient(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void register() {
|
||||
GameRegistry.addRecipe(this.adapter.create());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package net.anvilcraft.pccompat.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
public class ShapedOreRecipeAdapter implements IRecipeAdapter {
|
||||
ItemStack output;
|
||||
String[] pattern;
|
||||
ArrayList<Object> ingredients = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void setOutput(ItemStack item) {
|
||||
this.output = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPattern(String... pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addIngredient(Object... ingredients) {
|
||||
this.ingredients.add(ingredients[0]);
|
||||
this.ingredients.add(ingredients[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipe create() {
|
||||
ArrayList<Object> args = new ArrayList<>();
|
||||
|
||||
for (String pat : this.pattern)
|
||||
args.add(pat);
|
||||
|
||||
for (Object ing : this.ingredients)
|
||||
args.add(ing);
|
||||
|
||||
return new ShapedOreRecipe(this.output, args.toArray());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package net.anvilcraft.pccompat.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
public class ShapelessOreRecipeAdapter implements IRecipeAdapter {
|
||||
ItemStack output;
|
||||
ArrayList<Object> ingredients = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void setOutput(ItemStack item) {
|
||||
this.output = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPattern(String... pattern) {
|
||||
throw new UnsupportedOperationException("Shapeless recipe has no pattern!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addIngredient(Object... ingredients) {
|
||||
this.ingredients.add(ingredients[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipe create() {
|
||||
return new ShapelessOreRecipe(this.output, this.ingredients.toArray());
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package net.anvilcraft.pccompat.tiles;
|
||||
|
||||
import covers1624.powerconverters.api.registry.PowerSystemRegistry.PowerSystem;
|
||||
import covers1624.powerconverters.tile.main.TileEntityEnergyConsumer;
|
||||
import net.anvilcraft.pccompat.PCCompat;
|
||||
import net.anvilcraft.pccompat.mods.UniversalElectricityProxy;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
|
@ -18,7 +17,7 @@ public class TileEntityUniversalElectricityConsumer
|
|||
|
||||
public TileEntityUniversalElectricityConsumer(int voltageNameIndex) {
|
||||
super(
|
||||
PCCompat.universalElectricityPowerSystem, voltageNameIndex, IConductor.class);
|
||||
UniversalElectricityProxy.powerSystem, voltageNameIndex, IConductor.class);
|
||||
}
|
||||
|
||||
// TODO: WTF
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package net.anvilcraft.pccompat.tiles;
|
||||
|
||||
import covers1624.powerconverters.tile.main.TileEntityEnergyProducer;
|
||||
import net.anvilcraft.pccompat.PCCompat;
|
||||
import net.anvilcraft.pccompat.mods.UniversalElectricityProxy;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import universalelectricity.core.block.IConductor;
|
||||
|
@ -14,7 +14,7 @@ public class TileEntityUniversalElectricityProducer
|
|||
extends TileEntityEnergyProducer<IConductor> implements IConnector, IVoltage {
|
||||
public TileEntityUniversalElectricityProducer(int voltageNameIndex) {
|
||||
super(
|
||||
PCCompat.universalElectricityPowerSystem, voltageNameIndex, IConductor.class
|
||||
UniversalElectricityProxy.powerSystem, voltageNameIndex, IConductor.class
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue