Set default minimum power to 50% and set four blocks to 100%

This commit is contained in:
Timmeey86
2018-12-07 19:37:51 +01:00
parent e726d16094
commit 787706b1f7
4 changed files with 24 additions and 6 deletions

View File

@ -71,13 +71,13 @@ public class DefenseBlocks extends BlockList implements ContentList{
}};
mendProjector = new MendProjector("mend-projector"){{
consumes.powerDirect(0.2f);
consumes.powerDirect(0.2f, 1.0f);
size = 2;
consumes.item(Items.phasefabric).optional(true);
}};
overdriveProjector = new OverdriveProjector("overdrive-projector"){{
consumes.powerDirect(0.35f);
consumes.powerDirect(0.35f, 1.0f);
size = 2;
consumes.item(Items.phasefabric).optional(true);
}};

View File

@ -35,7 +35,7 @@ public class DistributionBlocks extends BlockList implements ContentList{
phaseConveyor = new ItemBridge("phase-conveyor"){{
range = 12;
hasPower = true;
consumes.powerDirect(0.03f);
consumes.powerDirect(0.03f, 1.0f);
}};
sorter = new Sorter("sorter");

View File

@ -67,7 +67,7 @@ public class LiquidBlocks extends BlockList implements ContentList{
phaseConduit = new LiquidBridge("phase-conduit"){{
range = 12;
hasPower = true;
consumes.powerDirect(0.03f);
consumes.powerDirect(0.03f, 1.0f);
}};
}
}

View File

@ -37,12 +37,12 @@ public class Consumers{
}
/**
* Creates a consumer which directly uses power without buffering it. The module will work while at least 60% of power is supplied.
* Creates a consumer which directly uses power without buffering it. The module will work while at least 50% of power is supplied.
* @param powerPerTick The amount of power which is required each tick for 100% efficiency.
* @return the created consumer object.
*/
public ConsumePower powerDirect(float powerPerTick){
return powerDirect(powerPerTick, 0.6f);
return powerDirect(powerPerTick, 0.5f);
}
/**
@ -122,6 +122,15 @@ public class Consumers{
return map.containsKey(type);
}
public boolean hasSubtypeOf(Class<? extends Consume> type){
for(Consume consume : all()){
if(type.isAssignableFrom(consume.getClass())){
return true;
}
}
return false;
}
public <T extends Consume> T get(Class<T> type){
if(!map.containsKey(type)){
throw new IllegalArgumentException("Block does not contain consumer of type '" + type + "'!");
@ -129,6 +138,15 @@ public class Consumers{
return (T) map.get(type);
}
public <T extends Consume> T getSubtypeOf(Class<T> type){
for(Consume consume : all()){
if(type.isAssignableFrom(consume.getClass())){
return (T)consume;
}
}
throw new IllegalArgumentException("Block does not contain consumer of type '" + type + "' or any of its subtypes!");
}
public Iterable<Consume> all(){
return map.values();
}