fix #2948, add better precision controls to lists

This commit is contained in:
Adrian 2015-08-08 09:01:40 +02:00
parent 99d226940e
commit 924b7276b0
7 changed files with 33 additions and 12 deletions

View file

@ -8,4 +8,5 @@ Improvements:
Bugs fixed:
* [#2948] Precise damage checking not working (asie)
* Hovering over slot causing incorrect item lighting (asie)

View file

@ -15,7 +15,7 @@ import net.minecraftforge.oredict.OreDictionary;
public final class ColorUtils {
private static final int[] WOOL_TO_RGB = new int[] {
0xFFFFFF, 0xD87F33, 0xB24CD8, 0x6699D8,
0xFAFAFA, 0xD87F33, 0xB24CD8, 0x6699D8,
0xE5E533, 0x7FCC19, 0xF27FA5, 0x4C4C4C,
0x999999, 0x4C7F99, 0x7F3FB2, 0x334CB2,
0x664C33, 0x667F33, 0x993333, 0x191919

View file

@ -69,8 +69,11 @@ public final class ListHandlerNew {
}
} else {
for (ItemStack s : stacks) {
if (s != null && StackHelper.isMatchingItem(s, target, precise || target.getItem().getHasSubtypes(), precise)) {
return true;
if (s != null && StackHelper.isMatchingItem(s, target, true, precise)) {
// If precise, re-check damage
if (!precise || s.getItemDamage() == target.getItemDamage()) {
return true;
}
}
}
}

View file

@ -30,7 +30,11 @@ public class ListMatchHandlerArmor extends ListMatchHandler {
int armorTypeIDSource = getArmorTypeID(stack);
if (armorTypeIDSource > 0) {
int armorTypeIDTarget = getArmorTypeID(target);
return (armorTypeIDSource & armorTypeIDTarget) != 0;
if (precise) {
return armorTypeIDSource == armorTypeIDTarget;
} else {
return (armorTypeIDSource & armorTypeIDTarget) != 0;
}
}
}
return false;

View file

@ -1,9 +1,7 @@
package buildcraft.core.list;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import buildcraft.api.lists.ListMatchHandler;
@ -15,6 +13,11 @@ public class ListMatchHandlerTools extends ListMatchHandler {
Set<String> toolClassesSource = stack.getItem().getToolClasses(stack);
Set<String> toolClassesTarget = target.getItem().getToolClasses(stack);
if (toolClassesSource.size() > 0 && toolClassesTarget.size() > 0) {
if (precise) {
if (toolClassesSource.size() != toolClassesTarget.size()) {
return false;
}
}
for (String s : toolClassesSource) {
if (!toolClassesTarget.contains(s)) {
return false;

View file

@ -226,12 +226,15 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
watts);
internalPower[i] -= watts;
dbgEnergyOutput[j] += watts;
powerAverage[j].push((int) Math.ceil(watts));
powerAverage[i].push((int) Math.ceil(watts));
} else {
int iWatts = (int) watts;
if (ep instanceof IEnergyHandler) {
IEnergyHandler handler = (IEnergyHandler) ep;
if (handler.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite())) {
watts = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(),
iWatts = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(),
iWatts, false);
}
internalPower[i] -= iWatts;
@ -239,16 +242,16 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
} else if (ep instanceof IEnergyReceiver) {
IEnergyReceiver handler = (IEnergyReceiver) ep;
if (handler.canConnectEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite())) {
watts = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(),
iWatts = handler.receiveEnergy(ForgeDirection.VALID_DIRECTIONS[j].getOpposite(),
iWatts, false);
}
internalPower[i] -= iWatts;
dbgEnergyOutput[j] += iWatts;
}
}
powerAverage[j].push((int) Math.ceil(watts));
powerAverage[i].push((int) Math.ceil(watts));
powerAverage[j].push(iWatts);
powerAverage[i].push(iWatts);
}
}
}
}
@ -263,7 +266,7 @@ public class PipeTransportPower extends PipeTransport implements IDebuggable {
}
}
overload += highestPower > ((float) maxPower) * 0.95F ? 1 : -1;
overload += highestPower > (maxPower * 0.95F) ? 1 : -1;
if (overload < 0) {
overload = 0;
}

View file

@ -29,6 +29,7 @@ import buildcraft.transport.PipeIconProvider;
import buildcraft.transport.PipeRenderState;
import buildcraft.transport.TileGenericPipe;
import buildcraft.transport.TransportProxy;
import buildcraft.transport.pipes.PipeStructureCobblestone;
public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
@ -52,6 +53,12 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler {
if (renderPass == 1) {
fakeBlock.setColor(ColorUtils.getRGBColor(glassColor));
} else if (glassColor >= 0 && tile.getPipe() instanceof PipeStructureCobblestone) {
if (glassColor == 0) {
fakeBlock.setColor(0xDFDFDF);
} else {
fakeBlock.setColor(ColorUtils.getRGBColor(glassColor));
}
}
// render the unconnected pipe faces of the center block (if any)