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:
LemADEC 2017-11-10 01:19:08 +01:00
parent e92839ab02
commit 6938e1030d
2 changed files with 48 additions and 5 deletions

View file

@ -139,11 +139,30 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
return; return;
} }
} else if (currentState == STATE_SCAN) { } 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 (delayTicks == 1) {
if (WarpDriveConfig.LOGGING_COLLECTION) { if (WarpDriveConfig.LOGGING_COLLECTION) {
WarpDrive.logger.debug("Scan pre-tick"); 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 // check power level
enoughPower = consumeEnergyFromLaserMediums(energyCost, true); enoughPower = consumeEnergyFromLaserMediums(energyCost, true);
if (!enoughPower) { if (!enoughPower) {
@ -254,7 +273,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
} }
// consume power // consume power
int energyCost = TREE_FARM_ENERGY_PER_WET_SPOT; final int energyCost = TREE_FARM_ENERGY_PER_WET_SPOT;
enoughPower = consumeEnergyFromLaserMediums(energyCost, false); enoughPower = consumeEnergyFromLaserMediums(energyCost, false);
if (!enoughPower) { if (!enoughPower) {
delayTargetTicks = TREE_FARM_LOW_POWER_DELAY_TICKS; delayTargetTicks = TREE_FARM_LOW_POWER_DELAY_TICKS;
@ -415,8 +434,8 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
} }
// consume power // consume power
double energyCost = TREE_FARM_ENERGY_PER_SAPLING; final int energyCost = TREE_FARM_ENERGY_PER_SAPLING;
enoughPower = consumeEnergyFromLaserMediums((int) Math.round(energyCost), false); enoughPower = consumeEnergyFromLaserMediums(energyCost, false);
if (!enoughPower) { if (!enoughPower) {
delayTargetTicks = TREE_FARM_LOW_POWER_DELAY_TICKS; delayTargetTicks = TREE_FARM_LOW_POWER_DELAY_TICKS;
updateMetadata(BlockLaserTreeFarm.ICON_PLANTING_LOW_POWER); updateMetadata(BlockLaserTreeFarm.ICON_PLANTING_LOW_POWER);

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.network; package cr0s.warpdrive.network;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig; import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Vector3; 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.EntityFX;
import net.minecraft.client.particle.EntityFireworkSparkFX; import net.minecraft.client.particle.EntityFireworkSparkFX;
import net.minecraft.client.particle.EntityFlameFX; import net.minecraft.client.particle.EntityFlameFX;
import net.minecraft.client.particle.EntityHeartFX;
import net.minecraft.client.particle.EntitySnowShovelFX; import net.minecraft.client.particle.EntitySnowShovelFX;
import net.minecraft.client.particle.EntitySpellParticleFX; import net.minecraft.client.particle.EntitySpellParticleFX;
import net.minecraft.init.Items; 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.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
public class MessageSpawnParticle implements IMessage, IMessageHandler<MessageSpawnParticle, IMessage> { public class MessageSpawnParticle implements IMessage, IMessageHandler<MessageSpawnParticle, IMessage> {
@ -115,7 +118,7 @@ public class MessageSpawnParticle implements IMessage, IMessageHandler<MessageSp
// adjust color as needed // adjust color as needed
EntityFX effect; EntityFX effect;
double noiseLevel = direction.getMagnitude() * 0.35D; double noiseLevel = direction.getMagnitude() * 0.35D;
for (int i = 0; i < quantity; i++) { for (int index = 0; index < quantity; index++) {
Vector3 directionRandomized = new Vector3( Vector3 directionRandomized = new Vector3(
direction.x + noiseLevel * (world.rand.nextFloat() - world.rand.nextFloat()), direction.x + noiseLevel * (world.rand.nextFloat() - world.rand.nextFloat()),
direction.y + 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": case "cloud":
effect = new EntityCloudFX(world, origin.x, origin.y, origin.z, directionRandomized.x, directionRandomized.y, directionRandomized.z); effect = new EntityCloudFX(world, origin.x, origin.y, origin.z, directionRandomized.x, directionRandomized.y, directionRandomized.z);
break; 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) { if (baseRed >= 0.0F && baseGreen >= 0.0F && baseBlue >= 0.0F) {
effect.setRBGColorF(baseRed, baseGreen, baseBlue); effect.setRBGColorF(baseRed, baseGreen, baseBlue);