forked from Anvilcraft/pccompat
parent
6643d0c02f
commit
07a5234e88
|
@ -46,6 +46,7 @@ dependencies {
|
|||
implementation "universalelectricity:universalelectricity:5.2.2:deobf"
|
||||
implementation "universalelectricity:basiccomponents:2.0.1:deobf"
|
||||
implementation "appeng:appliedenergistics2:rv3-beta-21:dev"
|
||||
implementation "com.hbm:HBM-NTM:1.0.27_X4627:deobf"
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
|
|
@ -10,6 +10,7 @@ import cpw.mods.fml.common.Mod;
|
|||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.anvilcraft.pccompat.mods.AppliedEnergisticsProxy;
|
||||
import net.anvilcraft.pccompat.mods.HBMProxy;
|
||||
import net.anvilcraft.pccompat.mods.UniversalElectricityProxy;
|
||||
|
||||
@Mod(
|
||||
|
@ -51,5 +52,7 @@ public class PCCompat {
|
|||
mods.add(new UniversalElectricityProxy());
|
||||
if (Loader.isModLoaded("appliedenergistics2"))
|
||||
mods.add(new AppliedEnergisticsProxy());
|
||||
if (Loader.isModLoaded("hbm"))
|
||||
mods.add(new HBMProxy());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package net.anvilcraft.pccompat.blocks;
|
||||
|
||||
import covers1624.powerconverters.block.BlockPowerConverter;
|
||||
import covers1624.powerconverters.gui.PCCreativeTab;
|
||||
import net.anvilcraft.pccompat.tiles.TileEntityHBMConsumer;
|
||||
import net.anvilcraft.pccompat.tiles.TileEntityHBMProducer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockPowerConverterHBM extends BlockPowerConverter {
|
||||
|
||||
public BlockPowerConverterHBM() {
|
||||
super(2);
|
||||
this.setCreativeTab(PCCreativeTab.tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return meta == 0 ? new TileEntityHBMProducer() : new TileEntityHBMConsumer();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package net.anvilcraft.pccompat.items;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
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 ItemBlockPowerConverterHBM extends ItemBlock {
|
||||
|
||||
public ItemBlockPowerConverterHBM(Block block) {
|
||||
super(block);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
int meta = stack.getItemDamage();
|
||||
|
||||
return "pccompat:power_converter_hbm_" + meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public void getSubItems(Item alec1, CreativeTabs alec2, List list) {
|
||||
IntStream.range(0, 2)
|
||||
.mapToObj((i) -> new ItemStack(this, 1, i))
|
||||
.forEach(list::add);
|
||||
}
|
||||
|
||||
}
|
77
src/main/java/net/anvilcraft/pccompat/mods/HBMProxy.java
Normal file
77
src/main/java/net/anvilcraft/pccompat/mods/HBMProxy.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package net.anvilcraft.pccompat.mods;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
|
||||
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.BlockPowerConverterHBM;
|
||||
import net.anvilcraft.pccompat.items.ItemBlockPowerConverterHBM;
|
||||
import net.anvilcraft.pccompat.recipe.RecipeBuilder;
|
||||
import net.anvilcraft.pccompat.recipe.ShapedOreRecipeAdapter;
|
||||
import net.anvilcraft.pccompat.recipe.ShapelessOreRecipeAdapter;
|
||||
import net.anvilcraft.pccompat.tiles.TileEntityHBMConsumer;
|
||||
import net.anvilcraft.pccompat.tiles.TileEntityHBMProducer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class HBMProxy implements IModProxy {
|
||||
|
||||
public static PowerSystem powerSystem;
|
||||
public static Block blockPowerConverter;
|
||||
|
||||
@Override
|
||||
public void registerPowerSystem() {
|
||||
PowerSystemRegistry.registerPowerSystem(
|
||||
powerSystem = new PowerSystem(
|
||||
"HBM",
|
||||
"HBM",
|
||||
4000,
|
||||
"HE"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlocks() {
|
||||
GameRegistry.registerBlock(blockPowerConverter = new BlockPowerConverterHBM(), ItemBlockPowerConverterHBM.class, "power_converter_hbm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTiles() {
|
||||
GameRegistry.registerTileEntity(TileEntityHBMConsumer.class, "hbm_consumer");
|
||||
GameRegistry.registerTileEntity(TileEntityHBMProducer.class, "hbm_producer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {
|
||||
|
||||
ItemStack cable = new ItemStack(ModBlocks.red_cable);
|
||||
|
||||
new RecipeBuilder(new ShapedOreRecipeAdapter())
|
||||
.pattern("G G", " C ", "G G")
|
||||
.ingredient('G', "ingotGold")
|
||||
.ingredient('C', cable)
|
||||
.output(new ItemStack(blockPowerConverter, 1 ,0))
|
||||
.register();
|
||||
|
||||
|
||||
new RecipeBuilder(new ShapelessOreRecipeAdapter())
|
||||
.ingredient(
|
||||
new ItemStack(blockPowerConverter, 1, 0)
|
||||
)
|
||||
.output(
|
||||
new ItemStack(blockPowerConverter, 1, 1)
|
||||
)
|
||||
.register();
|
||||
|
||||
new RecipeBuilder(new ShapelessOreRecipeAdapter())
|
||||
.ingredient(
|
||||
new ItemStack(blockPowerConverter, 1, 1)
|
||||
)
|
||||
.output(new ItemStack(blockPowerConverter, 1, 0))
|
||||
.register();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package net.anvilcraft.pccompat.tiles;
|
||||
|
||||
import api.hbm.energy.IEnergyConnector;
|
||||
import covers1624.powerconverters.tile.main.TileEntityEnergyConsumer;
|
||||
import net.anvilcraft.pccompat.mods.HBMProxy;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityHBMConsumer extends TileEntityEnergyConsumer<IEnergyConnector> implements IEnergyConnector {
|
||||
|
||||
private boolean isLoaded = true;
|
||||
private boolean recursionBrake = false;
|
||||
private boolean transferLastTick = false;
|
||||
private double lastTransfer = 0.0;
|
||||
|
||||
public TileEntityHBMConsumer() {
|
||||
super(HBMProxy.powerSystem, 0, IEnergyConnector.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
|
||||
if (this.transferLastTick) {
|
||||
this.transferLastTick = false;
|
||||
} else {
|
||||
this.lastTransfer = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getInputRate() {
|
||||
return lastTransfer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
return (long) (this.getTotalEnergyDemand() / this.getPowerSystem().getScaleAmmount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return this.isLoaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
this.isLoaded = false;
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long transferPower(long power) {
|
||||
if (recursionBrake) return power;
|
||||
|
||||
this.recursionBrake = true;
|
||||
|
||||
long toInsert = power * this.getPowerSystem().getScaleAmmount();
|
||||
double leftover = this.storeEnergy(toInsert, false);
|
||||
long ret = MathHelper.floor_double_long(leftover / this.getPowerSystem().getScaleAmmount());
|
||||
|
||||
this.lastTransfer = power - ret;
|
||||
|
||||
this.recursionBrake = false;
|
||||
this.transferLastTick = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package net.anvilcraft.pccompat.tiles;
|
||||
|
||||
import api.hbm.energy.IEnergyConnector;
|
||||
import api.hbm.energy.IEnergyGenerator;
|
||||
import covers1624.powerconverters.tile.main.TileEntityEnergyProducer;
|
||||
import net.anvilcraft.pccompat.mods.HBMProxy;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityHBMProducer extends TileEntityEnergyProducer<IEnergyConnector> implements IEnergyGenerator {
|
||||
|
||||
private boolean isLoaded = true;
|
||||
private boolean recursionBrake = false;
|
||||
private long subBuffer = 0;
|
||||
|
||||
public TileEntityHBMProducer() {
|
||||
super(HBMProxy.powerSystem, 0, IEnergyConnector.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double produceEnergy(double energy) {
|
||||
|
||||
if (this.recursionBrake) return energy;
|
||||
|
||||
this.recursionBrake = true;
|
||||
|
||||
long toProduce = MathHelper.floor_double_long(energy / this.getPowerSystem().getScaleAmmount());
|
||||
this.subBuffer = toProduce;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
this.sendPower(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
|
||||
this.recursionBrake = false;
|
||||
|
||||
long tmp = this.subBuffer;
|
||||
this.subBuffer = 0;
|
||||
|
||||
return tmp * this.getPowerSystem().getScaleAmmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long power) {
|
||||
this.subBuffer = power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return this.subBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxPower() {
|
||||
return this.subBuffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return this.isLoaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
this.isLoaded = false;
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
}
|
|
@ -9,3 +9,6 @@ pccompat:power_converter_ue_7.name=UE 480V Producer
|
|||
|
||||
pccompat:power_converter_ae_0.name=AE Producer
|
||||
pccompat:power_converter_ae_1.name=AE Consumer
|
||||
|
||||
pccompat:power_converter_hbm_0.name=HBM Producer
|
||||
pccompat:power_converter_hbm_1.name=HBM Consumer
|
||||
|
|
Loading…
Reference in a new issue