Fixed force field thickness calculation
Fixed force field shape not always updating Added double sided projector bonus Improved creative players support
This commit is contained in:
parent
c7f0d94d53
commit
5608bc76e2
9 changed files with 142 additions and 91 deletions
|
@ -21,6 +21,7 @@ import java.util.Collection;
|
|||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -313,19 +314,32 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
|
|||
|
||||
public Object getFirstUpgradeOfType(final Class clazz, final Object defaultValue) {
|
||||
for (Object object : installedUpgrades.keySet()) {
|
||||
if (clazz.isInstance(object)) {
|
||||
if (clazz != null && clazz.isInstance(object)) {
|
||||
return object;
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public Map<Object, Integer> getUpgradesOfType(final Class clazz) {
|
||||
if (clazz == null) {
|
||||
return installedUpgrades;
|
||||
}
|
||||
Map<Object, Integer> mapResult = new HashMap<>(installedUpgrades.size());
|
||||
for (Entry<Object, Integer> entry : installedUpgrades.entrySet()) {
|
||||
if (clazz.isInstance(entry.getKey())) {
|
||||
mapResult.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
return mapResult;
|
||||
}
|
||||
|
||||
public int getUpgradeCount(final Object upgrade) {
|
||||
Integer value = installedUpgrades.get(upgrade);
|
||||
return value == null ? 0 : value;
|
||||
}
|
||||
|
||||
protected int getUpgradeMaxCount(final Object upgrade) {
|
||||
public int getUpgradeMaxCount(final Object upgrade) {
|
||||
Integer value = maxUpgrades.get(upgrade);
|
||||
return value == null ? 0 : value;
|
||||
}
|
||||
|
|
|
@ -172,16 +172,16 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
|||
|
||||
} else if (itemStackHeld.getItem() instanceof ItemForceFieldShape) {// no sneaking and shape in hand => mounting a shape
|
||||
if (side == (metadata & 7) || (((TileEntityForceFieldProjector) tileEntity).isDoubleSided && ForgeDirection.OPPOSITES[side] == (metadata & 7))) {
|
||||
// validate quantity
|
||||
if (itemStackHeld.stackSize < (tileEntityForceFieldProjector.isDoubleSided ? 2 : 1)) {
|
||||
// not enough shape items
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted(
|
||||
tileEntityForceFieldProjector.isDoubleSided ?
|
||||
"warpdrive.forcefield.shape.result.notEnoughShapes.double" : "warpdrive.forcefield.shape.result.notEnoughShapes.single"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!entityPlayer.capabilities.isCreativeMode) {
|
||||
// validate quantity
|
||||
if (itemStackHeld.stackSize < (tileEntityForceFieldProjector.isDoubleSided ? 2 : 1)) {
|
||||
// not enough shape items
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted(
|
||||
tileEntityForceFieldProjector.isDoubleSided ?
|
||||
"warpdrive.forcefield.shape.result.notEnoughShapes.double" : "warpdrive.forcefield.shape.result.notEnoughShapes.single"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// update player inventory
|
||||
itemStackHeld.stackSize -= tileEntityForceFieldProjector.isDoubleSided ? 2 : 1;
|
||||
|
||||
|
@ -207,20 +207,26 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
|
|||
|
||||
} else if (itemStackHeld.getItem() instanceof ItemForceFieldUpgrade) {// no sneaking and an upgrade in hand => mounting an upgrade
|
||||
// validate type
|
||||
if (!tileEntityForceFieldProjector.canUpgrade(enumForceFieldUpgrade)) {
|
||||
if (tileEntityForceFieldProjector.getUpgradeMaxCount(enumForceFieldUpgrade) <= 0) {
|
||||
// invalid upgrade type
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.invalidUpgrade"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// validate quantity
|
||||
if (itemStackHeld.stackSize < 1) {
|
||||
// not enough upgrade items
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.notEnoughUpgrades"));
|
||||
if (!tileEntityForceFieldProjector.canUpgrade(enumForceFieldUpgrade)) {
|
||||
// too many upgrades
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.tooManyUpgrades",
|
||||
tileEntityForceFieldProjector.getUpgradeMaxCount(enumForceFieldUpgrade)));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!entityPlayer.capabilities.isCreativeMode) {
|
||||
// validate quantity
|
||||
if (itemStackHeld.stackSize < 1) {
|
||||
// not enough upgrade items
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.notEnoughUpgrades"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// update player inventory
|
||||
itemStackHeld.stackSize -= 1;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
|||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
for (EnumForceFieldUpgrade enumForceFieldUpgrade : EnumForceFieldUpgrade.values()) {
|
||||
if (enumForceFieldUpgrade.allowOnRelay) {
|
||||
if (enumForceFieldUpgrade.maxCountOnRelay > 0) {
|
||||
icons[enumForceFieldUpgrade.ordinal()] = iconRegister.registerIcon("warpdrive:forcefield/relay" + "_" + enumForceFieldUpgrade.unlocalizedName);
|
||||
} else {
|
||||
icons[enumForceFieldUpgrade.ordinal()] = iconRegister.registerIcon("warpdrive:forcefield/relay" + "_" + EnumForceFieldUpgrade.NONE.unlocalizedName);
|
||||
|
@ -110,20 +110,20 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
|
|||
|
||||
} else if (itemStackHeld.getItem() instanceof ItemForceFieldUpgrade) {
|
||||
// validate type
|
||||
if (!EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage()).allowOnRelay) {
|
||||
if (EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage()).maxCountOnRelay <= 0) {
|
||||
// invalid upgrade type
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.invalidUpgrade"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// validate quantity
|
||||
if (itemStackHeld.stackSize < 1) {
|
||||
// not enough upgrade items
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.notEnoughUpgrades"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!entityPlayer.capabilities.isCreativeMode) {
|
||||
// validate quantity
|
||||
if (itemStackHeld.stackSize < 1) {
|
||||
// not enough upgrade items
|
||||
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.forcefield.upgrade.result.notEnoughUpgrades"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// update player inventory
|
||||
itemStackHeld.stackSize -= 1;
|
||||
|
||||
|
|
|
@ -76,8 +76,8 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
});
|
||||
|
||||
for (EnumForceFieldUpgrade enumForceFieldUpgrade : EnumForceFieldUpgrade.values()) {
|
||||
if (enumForceFieldUpgrade.allowOnProjector) {
|
||||
setUpgradeMaxCount(enumForceFieldUpgrade, 1);
|
||||
if (enumForceFieldUpgrade.maxCountOnProjector > 0) {
|
||||
setUpgradeMaxCount(enumForceFieldUpgrade, enumForceFieldUpgrade.maxCountOnProjector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -580,14 +580,17 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
|
|||
// reset field in case of major changes
|
||||
if (legacy_forceFieldSetup != null) {
|
||||
int energyRequired = cache_forceFieldSetup.startupEnergyCost - legacy_forceFieldSetup.startupEnergyCost;
|
||||
if ( legacy_forceFieldSetup.getCamouflageBlock() != cache_forceFieldSetup.getCamouflageBlock()
|
||||
|| legacy_forceFieldSetup.getCamouflageMetadata() != cache_forceFieldSetup.getCamouflageMetadata()
|
||||
if (legacy_forceFieldSetup.getCamouflageBlock() != cache_forceFieldSetup.getCamouflageBlock()
|
||||
|| legacy_forceFieldSetup.getCamouflageMetadata() != cache_forceFieldSetup.getCamouflageMetadata()
|
||||
|| legacy_forceFieldSetup.beamFrequency != cache_forceFieldSetup.beamFrequency
|
||||
|| legacy_forceFieldSetup.isInverted != cache_forceFieldSetup.isInverted
|
||||
|| legacy_forceFieldSetup.shapeProvider != cache_forceFieldSetup.shapeProvider
|
||||
|| legacy_forceFieldSetup.thickness != cache_forceFieldSetup.thickness
|
||||
|| !consumeEnergy(energyRequired, false)) {
|
||||
destroyForceField(true);
|
||||
|
||||
} else if (legacy_forceFieldSetup.isInverted != cache_forceFieldSetup.isInverted
|
||||
|| legacy_forceFieldSetup.shapeProvider != cache_forceFieldSetup.shapeProvider
|
||||
|| legacy_forceFieldSetup.thickness != cache_forceFieldSetup.thickness) {
|
||||
destroyForceField(true);
|
||||
isDirty.set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package cr0s.warpdrive.block.forcefield;
|
|||
import cr0s.warpdrive.api.IForceFieldUpgrade;
|
||||
import cr0s.warpdrive.api.IForceFieldUpgradeEffector;
|
||||
import cr0s.warpdrive.data.EnumForceFieldUpgrade;
|
||||
import cr0s.warpdrive.data.ForceFieldSetup;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
|
@ -86,6 +87,6 @@ public class TileEntityForceFieldRelay extends TileEntityAbstractForceField impl
|
|||
|
||||
@Override
|
||||
public float getUpgradeValue() {
|
||||
return isEnabled ? getUpgrade().getUpgradeValue() * tier / 2.0F : 0.0F;
|
||||
return isEnabled ? getUpgrade().getUpgradeValue() * (1.0F + (tier - 1) * ForceFieldSetup.FORCEFIELD_UPGRADE_BOOST_PER_RELAY_TIER) : 0.0F;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,16 +40,16 @@ public enum EnumForceFieldShape implements IForceFieldShape {
|
|||
public Map<VectorI, Boolean> getVertexes(ForceFieldSetup forceFieldSetup) {
|
||||
VectorI vScale = forceFieldSetup.vMax.clone().translateBack(forceFieldSetup.vMin);
|
||||
Map<VectorI, Boolean> mapVertexes = new HashMap<>(vScale.x * vScale.y * vScale.z);
|
||||
int radius;
|
||||
int thickness;
|
||||
int radiusInterior2;
|
||||
int radiusPerimeter2;
|
||||
float radius;
|
||||
float halfThickness = forceFieldSetup.thickness / 2.0F;
|
||||
float radiusInterior2;
|
||||
float radiusPerimeter2;
|
||||
VectorI vCenter;
|
||||
switch(this) {
|
||||
case SPHERE:
|
||||
radius = forceFieldSetup.vMax.y;
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
radiusInterior2 = (radius - halfThickness) * (radius - halfThickness);
|
||||
radiusPerimeter2 = (radius + halfThickness) * (radius + halfThickness);
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
int y2 = (y - vCenter.y) * (y - vCenter.y);
|
||||
|
@ -66,9 +66,9 @@ public enum EnumForceFieldShape implements IForceFieldShape {
|
|||
break;
|
||||
|
||||
case CYLINDER_H:
|
||||
radius = Math.round((forceFieldSetup.vMax.y + forceFieldSetup.vMax.z) / 2);
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
radius = (forceFieldSetup.vMax.y + forceFieldSetup.vMax.z) / 2.0F;
|
||||
radiusInterior2 = (radius - halfThickness) * (radius - halfThickness);
|
||||
radiusPerimeter2 = (radius + halfThickness) * (radius + halfThickness);
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
int y2 = (y - vCenter.y) * (y - vCenter.y);
|
||||
|
@ -85,9 +85,9 @@ public enum EnumForceFieldShape implements IForceFieldShape {
|
|||
break;
|
||||
|
||||
case CYLINDER_V:
|
||||
radius = Math.round((forceFieldSetup.vMax.x + forceFieldSetup.vMax.y) / 2);
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
radius = (forceFieldSetup.vMax.x + forceFieldSetup.vMax.y) / 2.0F;
|
||||
radiusInterior2 = (radius - halfThickness) * (radius - halfThickness);
|
||||
radiusPerimeter2 = (radius + halfThickness) * (radius + halfThickness);
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
int x2 = (x - vCenter.x) * (x - vCenter.x);
|
||||
|
@ -104,9 +104,9 @@ public enum EnumForceFieldShape implements IForceFieldShape {
|
|||
break;
|
||||
|
||||
case TUBE:
|
||||
radius = Math.round((forceFieldSetup.vMax.x + forceFieldSetup.vMax.z) / 2);
|
||||
radiusInterior2 = Math.round((radius - forceFieldSetup.thickness) * (radius - forceFieldSetup.thickness));
|
||||
radiusPerimeter2 = Math.round((radius + forceFieldSetup.thickness) * (radius + forceFieldSetup.thickness));
|
||||
radius =(forceFieldSetup.vMax.x + forceFieldSetup.vMax.z) / 2.0F;
|
||||
radiusInterior2 = (radius - halfThickness) * (radius - halfThickness);
|
||||
radiusPerimeter2 = (radius + halfThickness) * (radius + halfThickness);
|
||||
vCenter = new VectorI(0, 0, 0);
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
int x2 = (x - vCenter.x) * (x - vCenter.x);
|
||||
|
@ -123,16 +123,15 @@ public enum EnumForceFieldShape implements IForceFieldShape {
|
|||
break;
|
||||
|
||||
case CUBE:
|
||||
thickness = Math.round(forceFieldSetup.thickness);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
boolean yFace = Math.abs(y - forceFieldSetup.vMin.y) <= thickness
|
||||
|| Math.abs(y - forceFieldSetup.vMax.y) <= thickness;
|
||||
boolean yFace = Math.abs(y - forceFieldSetup.vMin.y) <= halfThickness
|
||||
|| Math.abs(y - forceFieldSetup.vMax.y) <= halfThickness;
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
boolean xFace = Math.abs(x - forceFieldSetup.vMin.x) <= thickness
|
||||
|| Math.abs(x - forceFieldSetup.vMax.x) <= thickness;
|
||||
boolean xFace = Math.abs(x - forceFieldSetup.vMin.x) <= halfThickness
|
||||
|| Math.abs(x - forceFieldSetup.vMax.x) <= halfThickness;
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
boolean zFace = Math.abs(z - forceFieldSetup.vMin.z) <= thickness
|
||||
|| Math.abs(z - forceFieldSetup.vMax.z) <= thickness;
|
||||
boolean zFace = Math.abs(z - forceFieldSetup.vMin.z) <= halfThickness
|
||||
|| Math.abs(z - forceFieldSetup.vMax.z) <= halfThickness;
|
||||
mapVertexes.put(new VectorI(x, y, z), xFace || yFace || zFace);
|
||||
}
|
||||
}
|
||||
|
@ -140,10 +139,9 @@ public enum EnumForceFieldShape implements IForceFieldShape {
|
|||
break;
|
||||
|
||||
case PLANE:
|
||||
thickness = Math.round(forceFieldSetup.thickness);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
boolean yFace = Math.abs(y - forceFieldSetup.vMin.y) <= thickness
|
||||
|| Math.abs(y - forceFieldSetup.vMax.y) <= thickness;
|
||||
boolean yFace = Math.abs(y - forceFieldSetup.vMin.y) <= halfThickness
|
||||
|| Math.abs(y - forceFieldSetup.vMax.y) <= halfThickness;
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
mapVertexes.put(new VectorI(x, y, z), yFace);
|
||||
|
@ -153,15 +151,14 @@ public enum EnumForceFieldShape implements IForceFieldShape {
|
|||
break;
|
||||
|
||||
case TUNNEL:
|
||||
thickness = Math.round(forceFieldSetup.thickness);
|
||||
for (int y = forceFieldSetup.vMin.y; y <= forceFieldSetup.vMax.y; y++) {
|
||||
for (int x = forceFieldSetup.vMin.x; x <= forceFieldSetup.vMax.x; x++) {
|
||||
boolean xFace = Math.abs(x - forceFieldSetup.vMin.x) <= thickness
|
||||
|| Math.abs(x - forceFieldSetup.vMax.x) <= thickness;
|
||||
boolean xFace = Math.abs(x - forceFieldSetup.vMin.x) <= halfThickness
|
||||
|| Math.abs(x - forceFieldSetup.vMax.x) <= halfThickness;
|
||||
for (int z = forceFieldSetup.vMin.z; z <= forceFieldSetup.vMax.z; z++) {
|
||||
boolean isPerimeter = xFace
|
||||
|| Math.abs(z - forceFieldSetup.vMin.z) <= thickness
|
||||
|| Math.abs(z - forceFieldSetup.vMax.z) <= thickness;
|
||||
|| Math.abs(z - forceFieldSetup.vMin.z) <= halfThickness
|
||||
|| Math.abs(z - forceFieldSetup.vMax.z) <= halfThickness;
|
||||
mapVertexes.put(new VectorI(x, y, z), isPerimeter);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,27 +14,27 @@ import java.util.HashMap;
|
|||
public enum EnumForceFieldUpgrade implements IForceFieldUpgrade, IForceFieldUpgradeEffector {
|
||||
// Upgrade - Compatibility - ----- Value ----- -- Scan speed -- -- Place speed -- ------- Energy costs ------- comment
|
||||
// name projector relay incr. cap minimum maximum minimum maximum startup scan place entity
|
||||
NONE ("none" , false, false, 0.0F, 0.0F, 0.000F, 0.000F, 0.000F, 0.000F, 0.0F, 0.000F, 0.000F, 0.0F, ""),
|
||||
BREAKING ("breaking" , false, true , 1.0F, 25.0F, 0.400F, 0.500F, 0.010F, 0.100F, 70.0F, 0.020F, 1.000F, 0.0F, "value is hardness level"),
|
||||
CAMOUFLAGE ("camouflage" , false, true , 1.0F, 3.0F, 0.600F, 0.850F, 0.700F, 0.950F, 100.0F, 0.100F, 0.300F, 0.0F, "value is boolean"),
|
||||
COOLING ("cooling" , true , true , 30.0F, 300.0F, 0.000F, 0.000F, 0.900F, 0.900F, 15.0F, 0.020F, 0.500F, 10.0F, "value is heat units"),
|
||||
FUSION ("fusion" , true , true , 1.0F, 1.0F, 0.000F, 0.000F, 0.000F, 0.000F, 100.0F, 0.050F, 0.050F, 0.0F, "value is boolean"),
|
||||
HEATING ("heating" , true , true , 100.0F, 10000.0F, 0.000F, 0.000F, 0.900F, 0.900F, 15.0F, 0.100F, 1.000F, 5.0F, "value is heat units"),
|
||||
INVERSION ("inversion" , true , false, 1.0F, 1.0F, 0.250F, 0.250F, 0.000F, 0.000F, 150.0F, 0.050F, 0.050F, 1.0F, "value is boolean"),
|
||||
PUMPING ("pumping" , false, true , 1000.0F, 50000.0F, 0.800F, 1.000F, 0.400F, 1.000F, 80.0F, 0.010F, 0.500F, 0.0F, "value is viscosity"),
|
||||
RANGE ("range" , true , true , 8.0F, 56.0F, 1.100F, 0.800F, 1.100F, 0.800F, 1.0F, 0.100F, 0.250F, 4.0F, "value is bonus blocks"),
|
||||
ROTATION ("rotation" , true , false, 1.0F, 1.0F, 0.000F, 0.000F, 0.000F, 0.000F, 10.0F, 0.000F, 0.000F, 0.0F, "value is boolean"),
|
||||
SHOCK ("shock" , true , true , 1.0F, 10.0F, 0.800F, 0.800F, 0.800F, 0.800F, 30.0F, 0.100F, 2.000F, 30.0F, "value is damage points"),
|
||||
SILENCER ("silencer" , true , false, 1.0F, 1.0F, 0.000F, 0.000F, 0.000F, 0.000F, 0.0F, 0.010F, 0.020F, 0.0F, "value is boolean"),
|
||||
SPEED ("speed" , true , true , 1.0F, 20.0F, 1.250F, 6.000F, 1.200F, 5.000F, 20.0F, 0.100F, 1.000F, 5.0F, "value is not used (just a counter)"),
|
||||
STABILIZATION("stabilization", false, true , 1.0F, 6.0F, 0.450F, 0.550F, 0.050F, 0.150F, 40.0F, 0.100F, 1.000F, 0.0F, "value is boolean"),
|
||||
THICKNESS ("thickness" , true , true , 0.2F, 1.0F, 0.800F, 1.600F, 0.000F, 0.000F, 10.0F, 0.100F, 1.000F, 1.0F, "value is bonus ratio"),
|
||||
TRANSLATION ("translation" , true , false, 1.0F, 1.0F, 0.000F, 0.000F, 0.000F, 0.000F, 10.0F, 0.000F, 0.000F, 0.0F, "value is boolean"),
|
||||
NONE ("none" , 0, 0, 0.0F, 0.0F, 0.000F, 0.000F, 0.000F, 0.000F, 0.0F, 0.000F, 0.000F, 0.0F, ""),
|
||||
BREAKING ("breaking" , 0, 1, 1.0F, 25.0F, 0.400F, 0.500F, 0.010F, 0.100F, 70.0F, 0.020F, 1.000F, 0.0F, "value is hardness level"),
|
||||
CAMOUFLAGE ("camouflage" , 0, 1, 1.0F, 3.0F, 0.600F, 0.850F, 0.700F, 0.950F, 100.0F, 0.100F, 0.300F, 0.0F, "value is boolean"),
|
||||
COOLING ("cooling" , 3, 1, 30.0F, 300.0F, 0.000F, 0.000F, 0.900F, 0.900F, 15.0F, 0.020F, 0.500F, 10.0F, "value is heat units"),
|
||||
FUSION ("fusion" , 1, 1, 1.0F, 1.0F, 0.000F, 0.000F, 0.000F, 0.000F, 100.0F, 0.050F, 0.050F, 0.0F, "value is boolean"),
|
||||
HEATING ("heating" , 3, 1, 100.0F, 10000.0F, 0.000F, 0.000F, 0.900F, 0.900F, 15.0F, 0.100F, 1.000F, 5.0F, "value is heat units"),
|
||||
INVERSION ("inversion" , 1, 0, 1.0F, 1.0F, 0.250F, 0.250F, 0.000F, 0.000F, 150.0F, 0.050F, 0.050F, 1.0F, "value is boolean"),
|
||||
PUMPING ("pumping" , 0, 1, 1000.0F, 50000.0F, 0.800F, 1.000F, 0.400F, 1.000F, 80.0F, 0.010F, 0.500F, 0.0F, "value is viscosity"),
|
||||
RANGE ("range" , 4, 1, 8.0F, 56.0F, 1.100F, 0.800F, 1.100F, 0.800F, 1.0F, 0.100F, 0.250F, 4.0F, "value is bonus blocks"),
|
||||
ROTATION ("rotation" , 1, 0, 1.0F, 1.0F, 0.000F, 0.000F, 0.000F, 0.000F, 10.0F, 0.000F, 0.000F, 0.0F, "value is boolean"),
|
||||
SHOCK ("shock" , 3, 1, 1.0F, 10.0F, 0.800F, 0.800F, 0.800F, 0.800F, 30.0F, 0.100F, 2.000F, 30.0F, "value is damage points"),
|
||||
SILENCER ("silencer" , 1, 0, 1.0F, 1.0F, 0.000F, 0.000F, 0.000F, 0.000F, 0.0F, 0.010F, 0.020F, 0.0F, "value is boolean"),
|
||||
SPEED ("speed" , 4, 1, 1.0F, 20.0F, 1.250F, 6.000F, 1.200F, 5.000F, 20.0F, 0.100F, 1.000F, 5.0F, "value is not used (just a counter)"),
|
||||
STABILIZATION("stabilization", 0, 1, 1.0F, 6.0F, 0.450F, 0.550F, 0.050F, 0.150F, 40.0F, 0.100F, 1.000F, 0.0F, "value is boolean"),
|
||||
THICKNESS ("thickness" , 5, 1, 0.2F, 1.0F, 0.800F, 1.600F, 0.000F, 0.000F, 10.0F, 0.100F, 1.000F, 1.0F, "value is bonus ratio"),
|
||||
TRANSLATION ("translation" , 1, 0, 1.0F, 1.0F, 0.000F, 0.000F, 0.000F, 0.000F, 10.0F, 0.000F, 0.000F, 0.0F, "value is boolean"),
|
||||
;
|
||||
|
||||
public final String unlocalizedName;
|
||||
public final boolean allowOnProjector;
|
||||
public final boolean allowOnRelay;
|
||||
public final int maxCountOnProjector;
|
||||
public final int maxCountOnRelay;
|
||||
private final float upgradeValue;
|
||||
private final float upgradeValueMax;
|
||||
private final float scanSpeedOffset;
|
||||
|
@ -57,14 +57,14 @@ public enum EnumForceFieldUpgrade implements IForceFieldUpgrade, IForceFieldUpgr
|
|||
}
|
||||
}
|
||||
|
||||
EnumForceFieldUpgrade(final String unlocalizedName, final boolean allowOnProjector, final boolean allowOnRelay,
|
||||
EnumForceFieldUpgrade(final String unlocalizedName, final int allowOnProjector, final int maxCountOnRelay,
|
||||
final float upgradeValue, final float upgradeValueMax,
|
||||
final float scanSpeedMinimum, final float scanSpeedMaximum, final float placeSpeedMinimum, final float placeSpeedMaximum,
|
||||
final float startupEnergyCost, final float scanEnergyCost, final float placeEnergyCost, final float entityEffectEnergyCost,
|
||||
final String comment) {
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.allowOnProjector = allowOnProjector;
|
||||
this.allowOnRelay = allowOnRelay;
|
||||
this.maxCountOnProjector = allowOnProjector;
|
||||
this.maxCountOnRelay = maxCountOnRelay;
|
||||
|
||||
this.upgradeValue = upgradeValue;
|
||||
this.upgradeValueMax = upgradeValueMax;
|
||||
|
|
|
@ -14,13 +14,21 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
public class ForceFieldSetup extends GlobalPosition {
|
||||
private static final float FORCEFIELD_BASE_SCAN_SPEED_BLOCKS_PER_SECOND = 500;
|
||||
private static final float FORCEFIELD_BASE_PLACE_SPEED_BLOCKS_PER_SECOND = 100;
|
||||
private static final float FORCEFIELD_MAX_SCAN_SPEED_BLOCKS_PER_SECOND = 50000;
|
||||
private static final float FORCEFIELD_MAX_PLACE_SPEED_BLOCKS_PER_SECOND = 20000;
|
||||
private static final float FORCEFIELD_UPGRADE_BOOST_PER_PROJECTOR_TIER = 0.50F;
|
||||
public static final float FORCEFIELD_UPGRADE_BOOST_PER_RELAY_TIER = 0.25F;
|
||||
|
||||
public final int beamFrequency;
|
||||
public final byte tier;
|
||||
|
@ -133,7 +141,21 @@ public class ForceFieldSetup extends GlobalPosition {
|
|||
vTranslation = new VectorI(projector);
|
||||
// TODO vMin = projector.vMin;
|
||||
// TODO vMax = projector.vMax;
|
||||
// TODO upgrades ?
|
||||
for (Entry<Object, Integer> entry : projector.getUpgradesOfType(null).entrySet()) {
|
||||
if (entry.getKey() instanceof IForceFieldUpgrade) {
|
||||
IForceFieldUpgradeEffector upgradeEffector = ((IForceFieldUpgrade)entry.getKey()).getUpgradeEffector();
|
||||
if (upgradeEffector != null) {
|
||||
Float currentValue = upgradeValues.get(upgradeEffector);
|
||||
if (currentValue == null) {
|
||||
currentValue = 0.0F;
|
||||
}
|
||||
float addedValue = ((IForceFieldUpgrade)entry.getKey()).getUpgradeValue() * entry.getValue();
|
||||
addedValue *= 1 + (tier - 1) * FORCEFIELD_UPGRADE_BOOST_PER_PROJECTOR_TIER;
|
||||
upgradeValues.put(upgradeEffector, currentValue + addedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if ((((TileEntityForceFieldProjector) tileEntity).isEnabled)
|
||||
&& (((TileEntityForceFieldProjector) tileEntity).isCalculated())
|
||||
|
@ -167,12 +189,20 @@ public class ForceFieldSetup extends GlobalPosition {
|
|||
}
|
||||
|
||||
// set default coefficients, depending on projector
|
||||
scanSpeed = FORCEFIELD_BASE_SCAN_SPEED_BLOCKS_PER_SECOND;
|
||||
placeSpeed = FORCEFIELD_BASE_PLACE_SPEED_BLOCKS_PER_SECOND;
|
||||
scanSpeed = FORCEFIELD_BASE_SCAN_SPEED_BLOCKS_PER_SECOND * (isDoubleSided ? 2.1F : 1.0F);
|
||||
placeSpeed = FORCEFIELD_BASE_PLACE_SPEED_BLOCKS_PER_SECOND * (isDoubleSided ? 2.1F : 1.0F);
|
||||
float startupEnergyCost = 60.0F + 20.0F * tier;
|
||||
float scanEnergyCost = 1.0F + 1.0F * tier;
|
||||
float placeEnergyCost = 3.0F + 3.0F * tier;
|
||||
float entityEnergyCost = 2.0F;
|
||||
if (isDoubleSided) {
|
||||
scanSpeed *= 2.1F;
|
||||
placeSpeed *= 2.1F;
|
||||
startupEnergyCost += 20.0F * tier;
|
||||
scanEnergyCost *= 0.9F;
|
||||
placeEnergyCost *= 0.9F;
|
||||
entityEnergyCost *= 0.9F;
|
||||
}
|
||||
|
||||
// apply scaling
|
||||
float speedRatio;
|
||||
|
|
|
@ -101,10 +101,10 @@ public class ItemForceFieldUpgrade extends Item {
|
|||
WarpDrive.addTooltip(list, "\n");
|
||||
|
||||
EnumForceFieldUpgrade enumForceFieldUpgrade = EnumForceFieldUpgrade.get(itemStack.getItemDamage());
|
||||
if (enumForceFieldUpgrade.allowOnProjector) {
|
||||
if (enumForceFieldUpgrade.maxCountOnProjector > 0) {
|
||||
WarpDrive.addTooltip(list, StatCollector.translateToLocalFormatted("item.warpdrive.forcefield.upgrade.tooltip.usage.projector"));
|
||||
}
|
||||
if (enumForceFieldUpgrade.allowOnRelay) {
|
||||
if (enumForceFieldUpgrade.maxCountOnRelay > 0) {
|
||||
WarpDrive.addTooltip(list, StatCollector.translateToLocalFormatted("item.warpdrive.forcefield.upgrade.tooltip.usage.relay"));
|
||||
}
|
||||
WarpDrive.addTooltip(list, StatCollector.translateToLocalFormatted("item.warpdrive.forcefield.upgrade.tooltip.usage.dismount"));
|
||||
|
|
Loading…
Add table
Reference in a new issue