Skip to content

Commit

Permalink
- fix: Corrected the calculation of output energy of the kinetic motor.
Browse files Browse the repository at this point in the history
- fix: Fixed AbstractMethodError of the monitor blocks.
  • Loading branch information
defeatedcrow committed Mar 1, 2018
1 parent 353ad7a commit c5245c6
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 71 deletions.
58 changes: 4 additions & 54 deletions java/defeatedcrow/hac/machine/block/TileKineticMotor.java
Expand Up @@ -13,8 +13,6 @@
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.fml.common.Optional.Method;

Expand All @@ -24,51 +22,17 @@
public class TileKineticMotor extends TileTorqueBase implements ITorqueProvider, cofh.api.energy.IEnergyReceiver {

public int cashedRF = 0;
public int cashedFU = 0;

public int getMaxCashRF() {
return (int) (128 * EnergyConvertRate.rateVsRF);
}

public int getMaxCashFU() {
int cur = cashedRF * (int) (EnergyConvertRate.rateVsRF);
cur /= EnergyConvertRate.rateVsFU;
return (int) ((128 - cur) * EnergyConvertRate.rateVsFU);
}

@Override
public void updateTile() {
super.updateTile();
if (!worldObj.isRemote) {
// 方向ごとのFUTileを能動的に見に行く
for (EnumFacing face : EnumFacing.VALUES) {
if (face == this.getBaseSide()) {
continue;
}
TileEntity tile = worldObj.getTileEntity(getPos().offset(face));
if (tile == null) {
continue;
}

if (cashedFU < getMaxCashFU()) {
if (tile.hasCapability(CapabilityEnergy.ENERGY, face.getOpposite())) {
IEnergyStorage stFU = tile.getCapability(CapabilityEnergy.ENERGY, face.getOpposite());
if (stFU != null && stFU.canExtract()) {
int ext2 = getMaxCashFU();
int ret = stFU.extractEnergy(ext2, true);
ret = Math.min(ret, ext2 - cashedFU);
if (ret > 0) {
stFU.extractEnergy(ret, false);
cashedFU += ret;
}
}
}
}
}

// provider
this.currentTorque += cashedRF * EnergyConvertRate.rateVsRF;
this.currentTorque += cashedFU * EnergyConvertRate.rateVsFU;
this.currentTorque += cashedRF / EnergyConvertRate.rateVsRF;
if (currentTorque > this.maxTorque()) {
this.currentTorque = maxTorque();
}
Expand All @@ -80,22 +44,12 @@ public void updateTile() {

// DCLogger.debugLog("*** Kinetic Motor ***");
// DCLogger.debugLog("send: " + send);
// RFが優先で減る
float lim1 = send * EnergyConvertRate.rateVsRF;
lim1 = Math.min(cashedRF, lim1);
float add1 = lim1 / EnergyConvertRate.rateVsRF;
this.cashedRF -= lim1;
send -= add1;
// DCLogger.debugLog("RF use: " + lim1);

// RFが優先で減る
float lim2 = send * EnergyConvertRate.rateVsFU;
lim2 = Math.min(cashedFU, lim2);
this.cashedFU -= lim2;
// DCLogger.debugLog("FU use: " + lim2);

if (this.cashedRF < 0) {
this.cashedRF = 0;
}
}

}

@Override
Expand Down Expand Up @@ -156,30 +110,26 @@ public boolean isOutputSide(EnumFacing side) {
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
this.cashedRF = tag.getInteger("dcs.Ecash");
this.cashedFU = tag.getInteger("dcs.Fcash");
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setInteger("dcs.Ecash", this.cashedRF);
tag.setInteger("dcs.Fcash", this.cashedFU);
return tag;
}

@Override
public NBTTagCompound getNBT(NBTTagCompound tag) {
super.getNBT(tag);
tag.setInteger("dcs.Ecash", this.cashedRF);
tag.setInteger("dcs.Fcash", this.cashedFU);
return tag;
}

@Override
public void setNBT(NBTTagCompound tag) {
super.setNBT(tag);
this.cashedRF = tag.getInteger("dcs.Ecash");
this.cashedFU = tag.getInteger("dcs.Fcash");
}

@Override
Expand Down
6 changes: 4 additions & 2 deletions java/defeatedcrow/hac/machine/block/TileMonitorBase.java
Expand Up @@ -15,7 +15,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public abstract class TileMonitorBase extends DCTileEntity implements ITagGetter {
public class TileMonitorBase extends DCTileEntity implements ITagGetter {

// pair
protected BlockPos pairPos = null;
Expand Down Expand Up @@ -103,7 +103,9 @@ public void updateTile() {
}
}

protected abstract boolean updateAmount();
protected boolean updateAmount() {
return false;
}

// NBT

Expand Down
2 changes: 1 addition & 1 deletion java/defeatedcrow/hac/machine/block/TileMonitorRF.java
Expand Up @@ -12,7 +12,7 @@ public String unit() {
}

@Override
@Method(modid = "redstoneflux")
@Method(modid = "cofhcore")
protected boolean updateAmount() {
TileEntity target = worldObj.getTileEntity(getPairPos());
if (target != null && RFDeviceHelper.isRFHandler(target)) {
Expand Down
16 changes: 8 additions & 8 deletions java/defeatedcrow/hac/machine/recipes/MachineCrusherRecipe.java
Expand Up @@ -107,7 +107,7 @@ static void load() {
new ItemStack(MainInit.oreDust, 1, 9), 0.25F, new ItemStack(MainInit.oreDust, 1, 10), 0.05F, null, ti,
"oreMagnetite");

if (OreDictionary.doesOreNameExist("dustCobalt")) {
if (!OreDictionary.getOres("dustCobalt").isEmpty()) {
ItemStack cob = OreDictionary.getOres("dustCobalt").get(0);
RecipeAPI.registerCrushers.addRecipe(new ItemStack(MainInit.oreDust, 3, 2),
new ItemStack(MainInit.oreDust, 1, 5), 0.25F, cob, 0.05F, null, ti, "oreNickel");
Expand All @@ -125,7 +125,7 @@ static void load() {
new ItemStack(MainInit.oreDust, 1, 4), 0.25F, null, 0F, new FluidStack(MachineInit.sulfuricAcid, 50),
ti, "oreSilver");

if (OreDictionary.doesOreNameExist("gemRuby")) {
if (!OreDictionary.getOres("gemRuby").isEmpty()) {
ItemStack gem = OreDictionary.getOres("gemRuby").get(0);
RecipeAPI.registerCrushers.addRecipe(new ItemStack(MainInit.oreDust, 3, 11),
new ItemStack(Items.CLAY_BALL, 1, 0), 0.25F, gem, 0.03F, null, ti, "oreAluminum");
Expand Down Expand Up @@ -165,7 +165,7 @@ static void load() {
new ItemStack(MainInit.oreDust, 1, 10), 0.1F, new ItemStack(MainInit.gems, 1, 11), 0.03F, null, ti,
"oreTin");

if (OreDictionary.doesOreNameExist("gemAmethyst")) {
if (!OreDictionary.getOres("gemAmethyst").isEmpty()) {
ItemStack gem = OreDictionary.getOres("gemAmethyst").get(0);
RecipeAPI.registerCrushers.addRecipe(new ItemStack(MainInit.gems, 3, 11),
new ItemStack(MainInit.gems, 1, 21), 0.03F, gem, 0.03F, null, ti, "oreSchorl");
Expand All @@ -178,7 +178,7 @@ static void load() {
RecipeAPI.registerCrushers.addRecipe(new ItemStack(MainInit.gems, 3, 12), new ItemStack(MainInit.oreDust, 1, 2),
0.25F, new ItemStack(MainInit.gems, 1, 13), 0.1F, null, ti, "oreSerpentine");

if (OreDictionary.doesOreNameExist("dustManganese")) {
if (!OreDictionary.getOres("dustManganese").isEmpty()) {
ItemStack gem = OreDictionary.getOres("dustManganese").get(0);
RecipeAPI.registerCrushers.addRecipe(new ItemStack(MainInit.gems, 3, 14),
new ItemStack(MainInit.gems, 1, 20), 0.1F, gem, 0.03F, null, ti, "oreGarnet");
Expand All @@ -200,15 +200,15 @@ static void load() {
new ItemStack(MainInit.miscDust, 1, 6), 0.5F, new ItemStack(Items.DYE, 1, 15), 0.5F, null, ti,
"oreApatite");

if (OreDictionary.doesOreNameExist("oreLead")) {
if (!OreDictionary.getOres("oreLead").isEmpty()) {
RecipeAPI.registerCrushers.addRecipe(new ItemStack(MainInit.oreDust, 3, 13),
new ItemStack(MainInit.oreDust, 1, 1), 0.25F, new ItemStack(MainInit.oreDust, 1, 3), 0.1F, null, ti,
"oreLead");
}

if (OreDictionary.doesOreNameExist("oreOsmium")) {
if (!OreDictionary.getOres("oreOsmium").isEmpty()) {
ItemStack os = OreDictionary.getOres("dustOsmium").get(0);
if (OreDictionary.doesOreNameExist("dustIridium")) {
if (!OreDictionary.getOres("dustIridium").isEmpty()) {
ItemStack gem = OreDictionary.getOres("dustIridium").get(0);
RecipeAPI.registerCrushers.addRecipe(new ItemStack(os.getItem(), 3, os.getItemDamage()), gem, 0.1F,
null, 0F, null, ti, "oreOsmium");
Expand Down Expand Up @@ -300,7 +300,7 @@ static void load() {
RecipeAPI.registerCrushers.addRecipe(new ItemStack(Items.DYE, 1, EnumDyeColor.GREEN.getDyeDamage()), ti,
"gemMalachite");

if (OreDictionary.doesOreNameExist("dustLithium")) {
if (!OreDictionary.getOres("dustLithium").isEmpty()) {
ItemStack dust = OreDictionary.getOres("dustLithium").get(0);
RecipeAPI.registerCrushers.addRecipe(dust, ti, "gemKunzite");
}
Expand Down
2 changes: 1 addition & 1 deletion java/defeatedcrow/hac/main/ClimateMain.java
Expand Up @@ -38,7 +38,7 @@ public class ClimateMain {
public static final String MOD_NAME = "HeatAndClimateMod";
public static final int MOD_MEJOR = 2;
public static final int MOD_MINOR = 2;
public static final int MOD_BUILD = 2;
public static final int MOD_BUILD = 3;
public static final String MOD_DEPENDENCIES = "required-after:dcs_lib@[2.2.0,)";

@SidedProxy(clientSide = "defeatedcrow.hac.main.client.ClientMainProxy", serverSide = "defeatedcrow.hac.main.CommonMainProxy")
Expand Down
5 changes: 1 addition & 4 deletions java/defeatedcrow/hac/main/config/MainCoreConfig.java
Expand Up @@ -49,9 +49,6 @@ public void load(Configuration cfg) {
Property vsEU = cfg.get("plugin setting", "Conversion rate vs EU", rateVsEU,
"Set the amount of conversion rate as EU/torque.");

Property vsFU = cfg.get("plugin setting", "Conversion rate vs FU", rateVsFU,
"Set the amount of conversion rate as FU/torque.");

Property noSteel = cfg.get("item setting", "Enable Steel Recipe", steel,
"Enable the climate recipe for smelting the steel block.");

Expand All @@ -70,7 +67,7 @@ public void load(Configuration cfg) {

rateVsRF = vsRF.getDouble();
rateVsEU = vsEU.getDouble();
rateVsFU = vsFU.getDouble();
rateVsFU = vsRF.getDouble();

steel = noSteel.getBoolean();
lead = noLead.getBoolean();
Expand Down
2 changes: 1 addition & 1 deletion resources/mcmod.info
Expand Up @@ -14,7 +14,7 @@
"name":"HeatAndClimateMod",
"url":"http://defeatedcrow.jp/modwiki/HeatAndClimate",
"updateUrl":"",
"version":"1.12.1_2.2.2",
"version":"1.12.1_2.2.3",
"requiredMods":[
"Minecraft Forge1.10.2-12.18.3.2316+", "HeatAndClimateLib-1.10.2_2.2.0+"
]
Expand Down

0 comments on commit c5245c6

Please sign in to comment.