Attempted to improve the crucible's logic.

This commit is contained in:
WayofTime 2016-02-18 09:03:18 -05:00
parent 29a8117771
commit d947f23696
2 changed files with 54 additions and 26 deletions

View file

@ -1,5 +1,5 @@
# #
#Tue Feb 09 07:17:21 EST 2016 #Thu Feb 18 08:35:51 EST 2016
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.brace_position_for_block=next_line org.eclipse.jdt.core.formatter.brace_position_for_block=next_line
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
@ -288,10 +288,10 @@ org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
eclipse.preferences.version=1
org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert eclipse.preferences.version=1
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.formatter.blank_lines_after_package=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.tile; package WayofTime.bloodmagic.tile;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -26,7 +27,7 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
public HashMap<EnumDemonWillType, Double> willMap = new HashMap<EnumDemonWillType, Double>(); public HashMap<EnumDemonWillType, Double> willMap = new HashMap<EnumDemonWillType, Double>();
public final int maxWill = 100; public final int maxWill = 100;
public final double maxTransferPerTick = 1; public final double maxTransferPerTick = 1;
public final double thresholdFill = 0.01; public final double thresholdFill = 0.0;
public final double gemDrainRate = 10; public final double gemDrainRate = 10;
public int internalCounter = 0; public int internalCounter = 0;
@ -120,6 +121,7 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
double maxWeight = 0; double maxWeight = 0;
List<IDemonWillConduit> tileList = new ArrayList<IDemonWillConduit>(); List<IDemonWillConduit> tileList = new ArrayList<IDemonWillConduit>();
Collections.shuffle(tileList);
Iterator<BlockPos> iterator = conduitList.iterator(); Iterator<BlockPos> iterator = conduitList.iterator();
while (iterator.hasNext()) while (iterator.hasNext())
@ -140,38 +142,64 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
{ {
for (EnumDemonWillType type : EnumDemonWillType.values()) for (EnumDemonWillType type : EnumDemonWillType.values())
{ {
List<IDemonWillConduit> copyTileList = new ArrayList<IDemonWillConduit>();
copyTileList.addAll(tileList);
double currentAmount = this.getCurrentWill(type); double currentAmount = this.getCurrentWill(type);
if (currentAmount <= 0) if (currentAmount <= 0)
{ {
continue; continue;
} }
for (IDemonWillConduit conduit : tileList) double transfered = 0;
double newMaxWeight = 0;
double transferTotalLastRound = 0;
int pass = 0;
final int maxPasses = 2;
while (pass < maxPasses && transfered < maxTransferPerTick && maxWeight > 0)
{ {
if (!conduit.canFill(type)) pass++;
newMaxWeight = 0;
Iterator<IDemonWillConduit> conduitIterator = copyTileList.iterator();
while (conduitIterator.hasNext())
{ {
continue; IDemonWillConduit conduit = conduitIterator.next();
if (!conduit.canFill(type))
{
conduitIterator.remove();
continue;
}
newMaxWeight += conduit.getWeight();
double transfer = Math.min(currentAmount, conduit.getWeight() * (maxTransferPerTick - transferTotalLastRound) / maxWeight);
if (transfer <= 0)
{
conduitIterator.remove();
continue;
}
double conduitAmount = conduit.getCurrentWill(type);
if (currentAmount - conduitAmount <= thresholdFill) // Will only fill if this conduit's amount is greater than the conduit it is filling.
{
conduitIterator.remove();
continue;
}
transfer = conduit.fillDemonWill(type, transfer, false);
if (transfer > 0)
{
conduit.fillDemonWill(type, transfer, true);
currentAmount -= transfer;
transfered += transfer;
}
} }
double transfer = Math.min(currentAmount, conduit.getWeight() * maxTransferPerTick / maxWeight); maxWeight = newMaxWeight;
if (transfer <= 0) transferTotalLastRound = transfered;
{
break;
}
double conduitAmount = conduit.getCurrentWill(type);
if (currentAmount - conduitAmount <= thresholdFill) // Will only fill if this conduit's amount is greater than the conduit it is filling.
{
continue;
}
transfer = conduit.fillDemonWill(type, transfer, false);
if (transfer > 0)
{
conduit.fillDemonWill(type, transfer, true);
currentAmount -= transfer;
}
} }
if (currentAmount <= 0) if (currentAmount <= 0)