replace explosions with overheating mechanic, close #2077
This commit is contained in:
parent
19ba9f3515
commit
20031e79e9
6 changed files with 76 additions and 34 deletions
|
@ -232,20 +232,31 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
|||
public void randomDisplayTick(World world, int i, int j, int k, Random random) {
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
|
||||
if (tile instanceof TileEngine && !((TileEngine) tile).isBurning()) {
|
||||
if (!(tile instanceof TileEngine)) {
|
||||
return;
|
||||
}
|
||||
|
||||
float f = i + 0.5F;
|
||||
float f1 = j + 0.0F + (random.nextFloat() * 6F) / 16F;
|
||||
float f2 = k + 0.5F;
|
||||
float f3 = 0.52F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
if (((TileEngine) tile).getEnergyStage() == TileEngine.EnergyStage.OVERHEAT) {
|
||||
for (int f = 0; f < 16; f++) {
|
||||
world.spawnParticle("smoke", i + 0.4F + (random.nextFloat() * 0.2F),
|
||||
j + (random.nextFloat() * 0.5F),
|
||||
k + 0.4F + (random.nextFloat() * 0.2F),
|
||||
random.nextFloat() * 0.04F - 0.02F,
|
||||
random.nextFloat() * 0.05F + 0.02F,
|
||||
random.nextFloat() * 0.04F - 0.02F);
|
||||
}
|
||||
} else if (((TileEngine) tile).isBurning()) {
|
||||
float f = i + 0.5F;
|
||||
float f1 = j + 0.0F + (random.nextFloat() * 6F) / 16F;
|
||||
float f2 = k + 0.5F;
|
||||
float f3 = 0.52F;
|
||||
float f4 = random.nextFloat() * 0.6F - 0.3F;
|
||||
|
||||
world.spawnParticle("reddust", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("reddust", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
|
|
|
@ -11,6 +11,7 @@ package buildcraft.energy;
|
|||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -18,6 +19,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import cofh.api.energy.IEnergyHandler;
|
||||
import buildcraft.api.power.IEngine;
|
||||
import buildcraft.api.tiles.IHeatable;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
|
@ -55,6 +57,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
public static final ResourceLocation TRUNK_GREEN_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_green.png");
|
||||
public static final ResourceLocation TRUNK_YELLOW_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_yellow.png");
|
||||
public static final ResourceLocation TRUNK_RED_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_red.png");
|
||||
public static final ResourceLocation TRUNK_OVERHEAT_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_overheat.png");
|
||||
|
||||
public enum EnergyStage {
|
||||
BLUE, GREEN, YELLOW, RED, OVERHEAT;
|
||||
|
@ -103,12 +106,28 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
return TRUNK_YELLOW_TEXTURE;
|
||||
case RED:
|
||||
return TRUNK_RED_TEXTURE;
|
||||
case OVERHEAT:
|
||||
return TRUNK_OVERHEAT_TEXTURE;
|
||||
default:
|
||||
return TRUNK_RED_TEXTURE;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBlockActivated(EntityPlayer player, ForgeDirection side) {
|
||||
if (!player.worldObj.isRemote && player.getCurrentEquippedItem() != null &&
|
||||
player.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
|
||||
IToolWrench wrench = (IToolWrench) player.getCurrentEquippedItem().getItem();
|
||||
if (wrench.canWrench(player, xCoord, yCoord, zCoord)) {
|
||||
if (getEnergyStage() == EnergyStage.OVERHEAT) {
|
||||
energyStage = computeEnergyStage();
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
checkOrientation = true;
|
||||
|
||||
wrench.wrenchUsed(player, xCoord, yCoord, zCoord);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -141,6 +160,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
|
||||
if (energyStage != newStage) {
|
||||
energyStage = newStage;
|
||||
if (energyStage == EnergyStage.OVERHEAT) {
|
||||
overheat();
|
||||
}
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
@ -148,6 +170,10 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
return energyStage;
|
||||
}
|
||||
|
||||
public void overheat() {
|
||||
this.isPumping = false;
|
||||
}
|
||||
|
||||
public void updateHeat() {
|
||||
heat = (float) ((MAX_HEAT - MIN_HEAT) * getEnergyLevel()) + MIN_HEAT;
|
||||
}
|
||||
|
@ -206,6 +232,12 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
|
||||
updateHeat();
|
||||
getEnergyStage();
|
||||
|
||||
if (getEnergyStage() == EnergyStage.OVERHEAT) {
|
||||
this.energy = Math.max(this.energy - 50, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
engineUpdate();
|
||||
|
||||
TileEntity tile = getTile(orientation);
|
||||
|
@ -437,13 +469,12 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
public abstract boolean isBurning();
|
||||
|
||||
public void addEnergy(int addition) {
|
||||
energy += addition;
|
||||
|
||||
if (getEnergyStage() == EnergyStage.OVERHEAT) {
|
||||
worldObj.createExplosion(null, xCoord, yCoord, zCoord, explosionRange(), true);
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
return;
|
||||
}
|
||||
|
||||
energy += addition;
|
||||
|
||||
if (energy > getMaxEnergy()) {
|
||||
energy = getMaxEnergy();
|
||||
}
|
||||
|
@ -493,8 +524,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPipeConnecti
|
|||
|
||||
public abstract int maxEnergyExtracted();
|
||||
|
||||
public abstract float explosionRange();
|
||||
|
||||
public int getEnergyStored() {
|
||||
return energy;
|
||||
}
|
||||
|
|
|
@ -127,9 +127,4 @@ public class TileEngineCreative extends TileEngine {
|
|||
public int calculateCurrentOutput() {
|
||||
return powerMode.maxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float explosionRange() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,10 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(EntityPlayer player, ForgeDirection side) {
|
||||
if (super.onBlockActivated(player, side)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ItemStack current = player.getCurrentEquippedItem();
|
||||
if (current != null) {
|
||||
if (current.getItem() instanceof IItemPipe) {
|
||||
|
@ -91,11 +95,6 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float explosionRange() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPistonSpeed() {
|
||||
if (!worldObj.isRemote) {
|
||||
|
@ -133,6 +132,10 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
|
|||
|
||||
@Override
|
||||
public boolean isBurning() {
|
||||
if (getEnergyStage() == EnergyStage.OVERHEAT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FluidStack fuel = tankFuel.getFluid();
|
||||
return fuel != null && fuel.amount > 0 && penaltyCooling == 0 && isRedstonePowered;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,9 @@ public class TileEngineStone extends TileEngineWithInventory {
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(EntityPlayer player, ForgeDirection side) {
|
||||
if (super.onBlockActivated(player, side)) {
|
||||
return true;
|
||||
}
|
||||
if (!worldObj.isRemote) {
|
||||
player.openGui(BuildCraftEnergy.instance, GuiIds.ENGINE_STONE, worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
@ -58,13 +61,14 @@ public class TileEngineStone extends TileEngineWithInventory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public float explosionRange() {
|
||||
return 2;
|
||||
public boolean isBurning() {
|
||||
return burnTime > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBurning() {
|
||||
return burnTime > 0;
|
||||
public void overheat() {
|
||||
super.overheat();
|
||||
burnTime = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,8 +29,8 @@ public class TileEngineWood extends TileEngine {
|
|||
}
|
||||
|
||||
@Override
|
||||
public float explosionRange() {
|
||||
return 1;
|
||||
public ResourceLocation getTrunkTexture(EnergyStage stage) {
|
||||
return super.getTrunkTexture(stage == EnergyStage.RED && progress < 0.5 ? EnergyStage.YELLOW : stage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,9 +46,9 @@ public class TileEngineWood extends TileEngine {
|
|||
@Override
|
||||
protected EnergyStage computeEnergyStage() {
|
||||
double energyLevel = getEnergyLevel();
|
||||
if (energyLevel < 0.25f) {
|
||||
if (energyLevel < 0.33f) {
|
||||
return EnergyStage.BLUE;
|
||||
} else if (energyLevel < 0.5f) {
|
||||
} else if (energyLevel < 0.66f) {
|
||||
return EnergyStage.GREEN;
|
||||
} else if (energyLevel < 0.75f) {
|
||||
return EnergyStage.YELLOW;
|
||||
|
|
Loading…
Reference in a new issue