Improved laser tree farm accessibility
Players are tempted to place the farming block below soil while it should be level with it. To address that, the machine will be 'jammed' with some particles when misplaced.
This commit is contained in:
parent
e92839ab02
commit
6938e1030d
2 changed files with 48 additions and 5 deletions
|
@ -139,11 +139,30 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
return;
|
||||
}
|
||||
} else if (currentState == STATE_SCAN) {
|
||||
int energyCost = TREE_FARM_ENERGY_PER_SURFACE * (1 + 2 * radiusX) * (1 + 2 * radiusZ);
|
||||
final int energyCost = TREE_FARM_ENERGY_PER_SURFACE * (1 + 2 * radiusX) * (1 + 2 * radiusZ);
|
||||
if (delayTicks == 1) {
|
||||
if (WarpDriveConfig.LOGGING_COLLECTION) {
|
||||
WarpDrive.logger.debug("Scan pre-tick");
|
||||
}
|
||||
|
||||
// validate environment: clearance above
|
||||
final Block blockAbove = worldObj.getBlock(xCoord, yCoord + 1, zCoord);
|
||||
if ( !isLog(blockAbove)
|
||||
&& !isLeaf(blockAbove)
|
||||
&& !blockAbove.isAir(worldObj, xCoord, yCoord + 1, zCoord) ) {
|
||||
PacketHandler.sendSpawnParticlePacket(worldObj, "jammed", (byte) 5, new Vector3(this).translate(0.5F),
|
||||
new Vector3(0.0D, 0.0D, 0.0D),
|
||||
1.0F, 1.0F, 1.0F,
|
||||
1.0F, 1.0F, 1.0F,
|
||||
32);
|
||||
|
||||
currentState = STATE_WARMUP; // going back to warmup state to show the animation when it'll be back online
|
||||
delayTicks = 0;
|
||||
delayTargetTicks = TREE_FARM_LOW_POWER_DELAY_TICKS;
|
||||
updateMetadata(BlockLaserTreeFarm.ICON_SCANNING_LOW_POWER);
|
||||
return;
|
||||
}
|
||||
|
||||
// check power level
|
||||
enoughPower = consumeEnergyFromLaserMediums(energyCost, true);
|
||||
if (!enoughPower) {
|
||||
|
@ -254,7 +273,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
}
|
||||
|
||||
// consume power
|
||||
int energyCost = TREE_FARM_ENERGY_PER_WET_SPOT;
|
||||
final int energyCost = TREE_FARM_ENERGY_PER_WET_SPOT;
|
||||
enoughPower = consumeEnergyFromLaserMediums(energyCost, false);
|
||||
if (!enoughPower) {
|
||||
delayTargetTicks = TREE_FARM_LOW_POWER_DELAY_TICKS;
|
||||
|
@ -415,8 +434,8 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
|
|||
}
|
||||
|
||||
// consume power
|
||||
double energyCost = TREE_FARM_ENERGY_PER_SAPLING;
|
||||
enoughPower = consumeEnergyFromLaserMediums((int) Math.round(energyCost), false);
|
||||
final int energyCost = TREE_FARM_ENERGY_PER_SAPLING;
|
||||
enoughPower = consumeEnergyFromLaserMediums(energyCost, false);
|
||||
if (!enoughPower) {
|
||||
delayTargetTicks = TREE_FARM_LOW_POWER_DELAY_TICKS;
|
||||
updateMetadata(BlockLaserTreeFarm.ICON_PLANTING_LOW_POWER);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cr0s.warpdrive.network;
|
||||
|
||||
import cr0s.warpdrive.Commons;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
import cr0s.warpdrive.data.Vector3;
|
||||
|
@ -14,6 +15,7 @@ import net.minecraft.client.particle.EntityExplodeFX;
|
|||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.particle.EntityFireworkSparkFX;
|
||||
import net.minecraft.client.particle.EntityFlameFX;
|
||||
import net.minecraft.client.particle.EntityHeartFX;
|
||||
import net.minecraft.client.particle.EntitySnowShovelFX;
|
||||
import net.minecraft.client.particle.EntitySpellParticleFX;
|
||||
import net.minecraft.init.Items;
|
||||
|
@ -25,6 +27,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
|||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class MessageSpawnParticle implements IMessage, IMessageHandler<MessageSpawnParticle, IMessage> {
|
||||
|
||||
|
@ -115,7 +118,7 @@ public class MessageSpawnParticle implements IMessage, IMessageHandler<MessageSp
|
|||
// adjust color as needed
|
||||
EntityFX effect;
|
||||
double noiseLevel = direction.getMagnitude() * 0.35D;
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
for (int index = 0; index < quantity; index++) {
|
||||
Vector3 directionRandomized = new Vector3(
|
||||
direction.x + noiseLevel * (world.rand.nextFloat() - world.rand.nextFloat()),
|
||||
direction.y + noiseLevel * (world.rand.nextFloat() - world.rand.nextFloat()),
|
||||
|
@ -153,6 +156,27 @@ public class MessageSpawnParticle implements IMessage, IMessageHandler<MessageSp
|
|||
case "cloud":
|
||||
effect = new EntityCloudFX(world, origin.x, origin.y, origin.z, directionRandomized.x, directionRandomized.y, directionRandomized.z);
|
||||
break;
|
||||
|
||||
case "jammed":// jammed machine particle reusing vanilla angryVillager particle
|
||||
// as of MC1.7.10, direction vector is ignored by upstream
|
||||
final ForgeDirection directionFacing = Commons.getHorizontalDirectionFromEntity(Minecraft.getMinecraft().thePlayer);
|
||||
if (directionFacing.offsetX != 0) {
|
||||
effect = new EntityHeartFX(world,
|
||||
origin.x + 0.51D * directionFacing.offsetX,
|
||||
origin.y - 0.50D + world.rand.nextDouble(),
|
||||
origin.z - 0.50D + world.rand.nextDouble(),
|
||||
directionRandomized.x, directionRandomized.y, directionRandomized.z,
|
||||
0.5F + world.rand.nextFloat() * 1.5F);
|
||||
} else {
|
||||
effect = new EntityHeartFX(world,
|
||||
origin.x - 0.50D + world.rand.nextDouble(),
|
||||
origin.y - 0.50D + world.rand.nextDouble(),
|
||||
origin.z + 0.51D * directionFacing.offsetZ,
|
||||
directionRandomized.x, directionRandomized.y, directionRandomized.z,
|
||||
0.5F + world.rand.nextFloat() * 1.5F);
|
||||
}
|
||||
effect.setParticleTextureIndex(81);
|
||||
break;
|
||||
}
|
||||
if (baseRed >= 0.0F && baseGreen >= 0.0F && baseBlue >= 0.0F) {
|
||||
effect.setRBGColorF(baseRed, baseGreen, baseBlue);
|
||||
|
|
Loading…
Reference in a new issue