Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -1,9 +1,13 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.inversion.InversionPillarHandler;
|
||||
import WayofTime.bloodmagic.tile.base.TileTicking;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
@ -19,18 +23,13 @@ import net.minecraftforge.common.animation.TimeValues.VariableValue;
|
|||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.inversion.InversionPillarHandler;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.tile.base.TileTicking;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class TileInversionPillar extends TileTicking
|
||||
{
|
||||
public class TileInversionPillar extends TileTicking {
|
||||
public static final double maxWillForChunk = 1000;
|
||||
public static double willPerOperation = 0.5;
|
||||
public static double inversionPerOperation = 4;
|
||||
public static double addedInversionPerFailedCheck = 1;
|
||||
|
@ -41,9 +40,7 @@ public class TileInversionPillar extends TileTicking
|
|||
public static double willPushRate = 1;
|
||||
public static double inversionCostPerWillSpread = 4;
|
||||
public static double minimumWillForChunkWhenSpreading = 100;
|
||||
|
||||
private final IAnimationStateMachine asm;
|
||||
private float animationOffsetValue = 0;
|
||||
private final VariableValue animationOffset = new VariableValue(0);
|
||||
private final VariableValue cycleLength = new VariableValue(4);
|
||||
|
||||
|
@ -58,45 +55,37 @@ public class TileInversionPillar extends TileTicking
|
|||
public int counter = 0;
|
||||
|
||||
public boolean isRegistered = false;
|
||||
private float animationOffsetValue = 0;
|
||||
|
||||
public static final double maxWillForChunk = 1000;
|
||||
|
||||
public TileInversionPillar()
|
||||
{
|
||||
public TileInversionPillar() {
|
||||
this(EnumDemonWillType.DEFAULT);
|
||||
}
|
||||
|
||||
public TileInversionPillar(EnumDemonWillType type)
|
||||
{
|
||||
public TileInversionPillar(EnumDemonWillType type) {
|
||||
this.type = type;
|
||||
asm = BloodMagic.proxy.load(new ResourceLocation(BloodMagic.MODID.toLowerCase(), "asms/block/inversion_pillar.json"), ImmutableMap.<String, ITimeValue>of("offset", animationOffset, "cycle_length", cycleLength));
|
||||
animationOffsetValue = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if (animationOffsetValue < 0)
|
||||
{
|
||||
public void onUpdate() {
|
||||
if (animationOffsetValue < 0) {
|
||||
animationOffsetValue = getWorld().getTotalWorldTime() * getWorld().rand.nextFloat();
|
||||
animationOffset.setValue(animationOffsetValue);
|
||||
}
|
||||
|
||||
if (getWorld().isRemote)
|
||||
{
|
||||
if (getWorld().isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isRegistered)
|
||||
{
|
||||
if (!isRegistered) {
|
||||
isRegistered = InversionPillarHandler.addPillarToMap(getWorld(), getType(), getPos());
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
double currentWill = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type);
|
||||
if (counter % 1 == 0)
|
||||
{
|
||||
if (counter % 1 == 0) {
|
||||
List<BlockPos> pillarList = getNearbyPillarsExcludingThis();
|
||||
// if (type == EnumDemonWillType.VENGEFUL)
|
||||
// {
|
||||
|
@ -105,33 +94,27 @@ public class TileInversionPillar extends TileTicking
|
|||
generateWillForNearbyPillars(currentWill, pillarList);
|
||||
generateInversionForNearbyPillars(currentWill, pillarList);
|
||||
int pollute = polluteNearbyBlocks(currentWill);
|
||||
if (pollute == 1)
|
||||
{
|
||||
if (pollute == 1) {
|
||||
currentInversion += addedInversionPerFailedCheck;
|
||||
consecutiveFailedChecks++;
|
||||
} else if (pollute == 3)
|
||||
{
|
||||
} else if (pollute == 3) {
|
||||
currentInversion += addedInversionPerFailedCheck;
|
||||
consecutiveFailedAirChecks++;
|
||||
} else if (pollute == 0)
|
||||
{
|
||||
} else if (pollute == 0) {
|
||||
//We successfully found a block to replace!
|
||||
consecutiveFailedChecks = 0;
|
||||
consecutiveFailedAirChecks = 0;
|
||||
}
|
||||
|
||||
if (consecutiveFailedAirChecks > 100)
|
||||
{
|
||||
if (consecutiveFailedAirChecks > 100) {
|
||||
createObstructionsInAir();
|
||||
}
|
||||
|
||||
if (currentInversion >= inversionToSpreadWill)
|
||||
{
|
||||
if (currentInversion >= inversionToSpreadWill) {
|
||||
spreadWillToSurroundingChunks();
|
||||
}
|
||||
|
||||
if (consecutiveFailedChecks > 5 * currentInfectionRadius && currentInversion >= inversionToIncreaseRadius)
|
||||
{
|
||||
if (consecutiveFailedChecks > 5 * currentInfectionRadius && currentInversion >= inversionToIncreaseRadius) {
|
||||
currentInfectionRadius++;
|
||||
consecutiveFailedChecks = 0;
|
||||
currentInversion -= inversionToIncreaseRadius;
|
||||
|
@ -144,13 +127,11 @@ public class TileInversionPillar extends TileTicking
|
|||
System.out.println("Increasing radius due to being in the air!");
|
||||
}
|
||||
|
||||
if (currentInfectionRadius >= 8 && currentInversion >= inversionToAddPillar)
|
||||
{
|
||||
if (currentInfectionRadius >= 8 && currentInversion >= inversionToAddPillar) {
|
||||
//TODO: Improve algorithm
|
||||
List<BlockPos> allConnectedPos = InversionPillarHandler.getAllConnectedPillars(getWorld(), type, pos);
|
||||
BlockPos candidatePos = findCandidatePositionForPillar(getWorld(), type, pos, allConnectedPos, 5, 10);
|
||||
if (!candidatePos.equals(BlockPos.ORIGIN))
|
||||
{
|
||||
if (!candidatePos.equals(BlockPos.ORIGIN)) {
|
||||
currentInversion = 0;
|
||||
IBlockState pillarState = RegistrarBloodMagicBlocks.INVERSION_PILLAR.getStateFromMeta(type.ordinal());
|
||||
IBlockState bottomState = RegistrarBloodMagicBlocks.INVERSION_PILLAR_END.getStateFromMeta(type.ordinal() * 2);
|
||||
|
@ -168,10 +149,8 @@ public class TileInversionPillar extends TileTicking
|
|||
// return 0;
|
||||
// }
|
||||
|
||||
public void createObstructionsInAir()
|
||||
{
|
||||
if (currentInversion > 1000)
|
||||
{
|
||||
public void createObstructionsInAir() {
|
||||
if (currentInversion > 1000) {
|
||||
Vec3d vec = new Vec3d(getWorld().rand.nextDouble() * 2 - 1, getWorld().rand.nextDouble() * 2 - 1, getWorld().rand.nextDouble() * 2 - 1).normalize().scale(2 * currentInfectionRadius);
|
||||
|
||||
BlockPos centralPos = pos.add(vec.x, vec.y, vec.z);
|
||||
|
@ -181,72 +160,18 @@ public class TileInversionPillar extends TileTicking
|
|||
}
|
||||
}
|
||||
|
||||
public static BlockPos findCandidatePositionForPillar(World world, EnumDemonWillType type, BlockPos pos, List<BlockPos> posList, double tooCloseDistance, double wantedAverageDistance)
|
||||
{
|
||||
int maxIterations = 100;
|
||||
int heightCheckRange = 3;
|
||||
|
||||
for (int i = 0; i < maxIterations; i++)
|
||||
{
|
||||
Collections.shuffle(posList);
|
||||
BlockPos pillarPos = posList.get(0);
|
||||
|
||||
Vec3d vec = new Vec3d(world.rand.nextDouble() * 2 - 1, world.rand.nextDouble() * 2 - 1, world.rand.nextDouble() * 2 - 1).normalize().scale(wantedAverageDistance);
|
||||
|
||||
BlockPos centralPos = pillarPos.add(vec.x, vec.y, vec.z);
|
||||
BlockPos testPos = null;
|
||||
candidateTest: for (int h = 0; h <= heightCheckRange; h++)
|
||||
{
|
||||
for (int sig = -1; sig <= 1; sig += (h > 0 ? 2 : 3))
|
||||
{
|
||||
BlockPos candidatePos = centralPos.add(0, sig * h, 0);
|
||||
if (world.isAirBlock(candidatePos) && world.isAirBlock(candidatePos.up()) && world.isAirBlock(candidatePos.down()) && !world.isAirBlock(candidatePos.down(2)))
|
||||
{
|
||||
testPos = candidatePos;
|
||||
break candidateTest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (testPos != null)
|
||||
{
|
||||
boolean isValid = true;
|
||||
for (BlockPos pillarTestPos : posList)
|
||||
{
|
||||
if (pillarTestPos.distanceSq(testPos) <= tooCloseDistance * tooCloseDistance)
|
||||
{
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
return testPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return BlockPos.ORIGIN;
|
||||
}
|
||||
|
||||
public void spreadWillToSurroundingChunks()
|
||||
{
|
||||
public void spreadWillToSurroundingChunks() {
|
||||
double currentAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type);
|
||||
if (currentAmount <= minimumWillForChunkWhenSpreading)
|
||||
{
|
||||
if (currentAmount <= minimumWillForChunkWhenSpreading) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (EnumFacing side : EnumFacing.HORIZONTALS)
|
||||
{
|
||||
for (EnumFacing side : EnumFacing.HORIZONTALS) {
|
||||
BlockPos offsetPos = pos.offset(side, 16);
|
||||
double sideAmount = WorldDemonWillHandler.getCurrentWill(getWorld(), offsetPos, type);
|
||||
if (currentAmount > sideAmount)
|
||||
{
|
||||
if (currentAmount > sideAmount) {
|
||||
double drainAmount = Math.min((currentAmount - sideAmount) / 2, willPushRate);
|
||||
if (drainAmount < willPushRate / 2)
|
||||
{
|
||||
if (drainAmount < willPushRate / 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -258,26 +183,21 @@ public class TileInversionPillar extends TileTicking
|
|||
}
|
||||
}
|
||||
|
||||
public void removePillarFromMap()
|
||||
{
|
||||
if (!getWorld().isRemote)
|
||||
{
|
||||
public void removePillarFromMap() {
|
||||
if (!getWorld().isRemote) {
|
||||
InversionPillarHandler.removePillarFromMap(getWorld(), type, pos);
|
||||
}
|
||||
}
|
||||
|
||||
public List<BlockPos> getNearbyPillarsExcludingThis()
|
||||
{
|
||||
public List<BlockPos> getNearbyPillarsExcludingThis() {
|
||||
return InversionPillarHandler.getNearbyPillars(getWorld(), type, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(NBTTagCompound tag)
|
||||
{
|
||||
public void deserialize(NBTTagCompound tag) {
|
||||
super.deserialize(tag);
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
|
||||
type = EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
|
@ -291,8 +211,7 @@ public class TileInversionPillar extends TileTicking
|
|||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serialize(NBTTagCompound tag)
|
||||
{
|
||||
public NBTTagCompound serialize(NBTTagCompound tag) {
|
||||
super.serialize(tag);
|
||||
|
||||
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
||||
|
@ -304,31 +223,26 @@ public class TileInversionPillar extends TileTicking
|
|||
return tag;
|
||||
}
|
||||
|
||||
public void generateWillForNearbyPillars(double currentWillInChunk, List<BlockPos> offsetPositions)
|
||||
{
|
||||
public void generateWillForNearbyPillars(double currentWillInChunk, List<BlockPos> offsetPositions) {
|
||||
double totalGeneratedWill = 0;
|
||||
double willFactor = currentWillInChunk / 1000;
|
||||
|
||||
for (BlockPos offsetPos : offsetPositions)
|
||||
{
|
||||
for (BlockPos offsetPos : offsetPositions) {
|
||||
double distanceSquared = offsetPos.distanceSq(pos);
|
||||
|
||||
totalGeneratedWill += willFactor * 343 / (343 + Math.pow(distanceSquared, 3 / 2));
|
||||
}
|
||||
|
||||
if (totalGeneratedWill > 0)
|
||||
{
|
||||
if (totalGeneratedWill > 0) {
|
||||
WorldDemonWillHandler.fillWillToMaximum(getWorld(), pos, type, totalGeneratedWill, maxWillForChunk, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateInversionForNearbyPillars(double currentWillInChunk, List<BlockPos> offsetPositions)
|
||||
{
|
||||
public void generateInversionForNearbyPillars(double currentWillInChunk, List<BlockPos> offsetPositions) {
|
||||
double willFactor = currentWillInChunk / 400;
|
||||
double totalGeneratedInversion = willFactor;
|
||||
|
||||
for (BlockPos offsetPos : offsetPositions)
|
||||
{
|
||||
for (BlockPos offsetPos : offsetPositions) {
|
||||
double distanceSquared = offsetPos.distanceSq(pos);
|
||||
|
||||
totalGeneratedInversion += 3125 / (3125 + Math.pow(distanceSquared, 5 / 2));
|
||||
|
@ -338,30 +252,25 @@ public class TileInversionPillar extends TileTicking
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param currentWillInChunk
|
||||
* @return 0 if the block is successfully placed, 1 if the block is not
|
||||
* placed due to the selected place being invalid, 2 if the block is
|
||||
* not placed due to there not being enough Will or Inversion, 3 if
|
||||
* the block is not placed due to the selected block being air.
|
||||
* placed due to the selected place being invalid, 2 if the block is
|
||||
* not placed due to there not being enough Will or Inversion, 3 if
|
||||
* the block is not placed due to the selected block being air.
|
||||
*/
|
||||
public int polluteNearbyBlocks(double currentWillInChunk)
|
||||
{
|
||||
public int polluteNearbyBlocks(double currentWillInChunk) {
|
||||
// System.out.println("Hai! :D Current Inversion: " + currentInversion + ", Current Will: " + currentWillInChunk);
|
||||
if (currentWillInChunk < operationThreshold || currentInversion < inversionPerOperation)
|
||||
{
|
||||
if (currentWillInChunk < operationThreshold || currentInversion < inversionPerOperation) {
|
||||
return 2; //Not enough Will or Inversion available
|
||||
}
|
||||
|
||||
for (int i = 0; i < currentInfectionRadius; i++)
|
||||
{
|
||||
for (int i = 0; i < currentInfectionRadius; i++) {
|
||||
double xOff = (getWorld().rand.nextBoolean() ? 1 : -1) * (getWorld().rand.nextGaussian() + 1) * (currentInfectionRadius);
|
||||
double yOff = (getWorld().rand.nextBoolean() ? 1 : -1) * (getWorld().rand.nextGaussian() + 1) * (currentInfectionRadius);
|
||||
double zOff = (getWorld().rand.nextBoolean() ? 1 : -1) * (getWorld().rand.nextGaussian() + 1) * (currentInfectionRadius);
|
||||
double r2 = xOff * xOff + yOff * yOff + zOff * zOff;
|
||||
int maxInfectionRadius2 = (9 * currentInfectionRadius * currentInfectionRadius);
|
||||
if (r2 > maxInfectionRadius2)
|
||||
{
|
||||
if (r2 > maxInfectionRadius2) {
|
||||
double factor = Math.sqrt(maxInfectionRadius2 / r2);
|
||||
xOff *= factor;
|
||||
yOff *= factor;
|
||||
|
@ -369,20 +278,16 @@ public class TileInversionPillar extends TileTicking
|
|||
}
|
||||
|
||||
BlockPos offsetPos = pos.add(xOff + 0.5, yOff + 0.5, zOff + 0.5);
|
||||
if (offsetPos.equals(pos))
|
||||
{
|
||||
if (offsetPos.equals(pos)) {
|
||||
return 1; //Invalid block (itself!)
|
||||
}
|
||||
|
||||
IBlockState state = getWorld().getBlockState(offsetPos);
|
||||
if (!state.getBlock().isAir(state, getWorld(), offsetPos))
|
||||
{
|
||||
if (!state.getBlock().isAir(state, getWorld(), offsetPos)) {
|
||||
//Consume Will and set this block
|
||||
Block block = state.getBlock();
|
||||
if (block == Blocks.DIRT || block == Blocks.STONE || block == Blocks.GRASS)
|
||||
{
|
||||
if (getWorld().setBlockState(offsetPos, RegistrarBloodMagicBlocks.DEMON_EXTRAS.getStateFromMeta(0)))
|
||||
{
|
||||
if (block == Blocks.DIRT || block == Blocks.STONE || block == Blocks.GRASS) {
|
||||
if (getWorld().setBlockState(offsetPos, RegistrarBloodMagicBlocks.DEMON_EXTRAS.getStateFromMeta(0))) {
|
||||
WorldDemonWillHandler.drainWill(getWorld(), pos, type, willPerOperation, true);
|
||||
currentInversion -= inversionPerOperation;
|
||||
|
||||
|
@ -397,40 +302,150 @@ public class TileInversionPillar extends TileTicking
|
|||
return 3; //The block was air
|
||||
}
|
||||
|
||||
public void handleEvents(float time, Iterable<Event> pastEvents)
|
||||
{
|
||||
for (Event event : pastEvents)
|
||||
{
|
||||
public void handleEvents(float time, Iterable<Event> pastEvents) {
|
||||
for (Event event : pastEvents) {
|
||||
System.out.println("Event: " + event.event() + " " + event.offset() + " " + getPos() + " " + time);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFastRenderer()
|
||||
{
|
||||
public boolean hasFastRenderer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing side)
|
||||
{
|
||||
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
|
||||
{
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing side) {
|
||||
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY) {
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing side)
|
||||
{
|
||||
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
|
||||
{
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing side) {
|
||||
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY) {
|
||||
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
|
||||
}
|
||||
return super.getCapability(capability, side);
|
||||
}
|
||||
|
||||
public IAnimationStateMachine getAsm() {
|
||||
return asm;
|
||||
}
|
||||
|
||||
public float getAnimationOffsetValue() {
|
||||
return animationOffsetValue;
|
||||
}
|
||||
|
||||
public void setAnimationOffsetValue(float animationOffsetValue) {
|
||||
this.animationOffsetValue = animationOffsetValue;
|
||||
}
|
||||
|
||||
public VariableValue getAnimationOffset() {
|
||||
return animationOffset;
|
||||
}
|
||||
|
||||
public VariableValue getCycleLength() {
|
||||
return cycleLength;
|
||||
}
|
||||
|
||||
public EnumDemonWillType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(EnumDemonWillType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public double getCurrentInversion() {
|
||||
return currentInversion;
|
||||
}
|
||||
|
||||
public void setCurrentInversion(double currentInversion) {
|
||||
this.currentInversion = currentInversion;
|
||||
}
|
||||
|
||||
public int getConsecutiveFailedChecks() {
|
||||
return consecutiveFailedChecks;
|
||||
}
|
||||
|
||||
public void setConsecutiveFailedChecks(int consecutiveFailedChecks) {
|
||||
this.consecutiveFailedChecks = consecutiveFailedChecks;
|
||||
}
|
||||
|
||||
public int getConsecutiveFailedAirChecks() {
|
||||
return consecutiveFailedAirChecks;
|
||||
}
|
||||
|
||||
public void setConsecutiveFailedAirChecks(int consecutiveFailedAirChecks) {
|
||||
this.consecutiveFailedAirChecks = consecutiveFailedAirChecks;
|
||||
}
|
||||
|
||||
public int getCurrentInfectionRadius() {
|
||||
return currentInfectionRadius;
|
||||
}
|
||||
|
||||
public void setCurrentInfectionRadius(int currentInfectionRadius) {
|
||||
this.currentInfectionRadius = currentInfectionRadius;
|
||||
}
|
||||
|
||||
public int getCounter() {
|
||||
return counter;
|
||||
}
|
||||
|
||||
public void setCounter(int counter) {
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
public boolean isRegistered() {
|
||||
return isRegistered;
|
||||
}
|
||||
|
||||
public void setRegistered(boolean registered) {
|
||||
isRegistered = registered;
|
||||
}
|
||||
|
||||
public static BlockPos findCandidatePositionForPillar(World world, EnumDemonWillType type, BlockPos pos, List<BlockPos> posList, double tooCloseDistance, double wantedAverageDistance) {
|
||||
int maxIterations = 100;
|
||||
int heightCheckRange = 3;
|
||||
|
||||
for (int i = 0; i < maxIterations; i++) {
|
||||
Collections.shuffle(posList);
|
||||
BlockPos pillarPos = posList.get(0);
|
||||
|
||||
Vec3d vec = new Vec3d(world.rand.nextDouble() * 2 - 1, world.rand.nextDouble() * 2 - 1, world.rand.nextDouble() * 2 - 1).normalize().scale(wantedAverageDistance);
|
||||
|
||||
BlockPos centralPos = pillarPos.add(vec.x, vec.y, vec.z);
|
||||
BlockPos testPos = null;
|
||||
candidateTest:
|
||||
for (int h = 0; h <= heightCheckRange; h++) {
|
||||
for (int sig = -1; sig <= 1; sig += (h > 0 ? 2 : 3)) {
|
||||
BlockPos candidatePos = centralPos.add(0, sig * h, 0);
|
||||
if (world.isAirBlock(candidatePos) && world.isAirBlock(candidatePos.up()) && world.isAirBlock(candidatePos.down()) && !world.isAirBlock(candidatePos.down(2))) {
|
||||
testPos = candidatePos;
|
||||
break candidateTest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (testPos != null) {
|
||||
boolean isValid = true;
|
||||
for (BlockPos pillarTestPos : posList) {
|
||||
if (pillarTestPos.distanceSq(testPos) <= tooCloseDistance * tooCloseDistance) {
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
return testPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return BlockPos.ORIGIN;
|
||||
}
|
||||
|
||||
public static double getWillPerOperation() {
|
||||
return willPerOperation;
|
||||
}
|
||||
|
@ -511,82 +526,6 @@ public class TileInversionPillar extends TileTicking
|
|||
TileInversionPillar.minimumWillForChunkWhenSpreading = minimumWillForChunkWhenSpreading;
|
||||
}
|
||||
|
||||
public IAnimationStateMachine getAsm() {
|
||||
return asm;
|
||||
}
|
||||
|
||||
public float getAnimationOffsetValue() {
|
||||
return animationOffsetValue;
|
||||
}
|
||||
|
||||
public void setAnimationOffsetValue(float animationOffsetValue) {
|
||||
this.animationOffsetValue = animationOffsetValue;
|
||||
}
|
||||
|
||||
public VariableValue getAnimationOffset() {
|
||||
return animationOffset;
|
||||
}
|
||||
|
||||
public VariableValue getCycleLength() {
|
||||
return cycleLength;
|
||||
}
|
||||
|
||||
public EnumDemonWillType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(EnumDemonWillType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public double getCurrentInversion() {
|
||||
return currentInversion;
|
||||
}
|
||||
|
||||
public void setCurrentInversion(double currentInversion) {
|
||||
this.currentInversion = currentInversion;
|
||||
}
|
||||
|
||||
public int getConsecutiveFailedChecks() {
|
||||
return consecutiveFailedChecks;
|
||||
}
|
||||
|
||||
public void setConsecutiveFailedChecks(int consecutiveFailedChecks) {
|
||||
this.consecutiveFailedChecks = consecutiveFailedChecks;
|
||||
}
|
||||
|
||||
public int getConsecutiveFailedAirChecks() {
|
||||
return consecutiveFailedAirChecks;
|
||||
}
|
||||
|
||||
public void setConsecutiveFailedAirChecks(int consecutiveFailedAirChecks) {
|
||||
this.consecutiveFailedAirChecks = consecutiveFailedAirChecks;
|
||||
}
|
||||
|
||||
public int getCurrentInfectionRadius() {
|
||||
return currentInfectionRadius;
|
||||
}
|
||||
|
||||
public void setCurrentInfectionRadius(int currentInfectionRadius) {
|
||||
this.currentInfectionRadius = currentInfectionRadius;
|
||||
}
|
||||
|
||||
public int getCounter() {
|
||||
return counter;
|
||||
}
|
||||
|
||||
public void setCounter(int counter) {
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
public boolean isRegistered() {
|
||||
return isRegistered;
|
||||
}
|
||||
|
||||
public void setRegistered(boolean registered) {
|
||||
isRegistered = registered;
|
||||
}
|
||||
|
||||
public static double getMaxWillForChunk() {
|
||||
return maxWillForChunk;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue