Skip to content

Commit

Permalink
Pandora's Box 2.2.6 Forge - Bug eradication & nearing completion of r…
Browse files Browse the repository at this point in the history
…uined portal
  • Loading branch information
Alexandra-Myers committed Mar 30, 2024
1 parent b1353b6 commit fca4c20
Show file tree
Hide file tree
Showing 19 changed files with 275 additions and 293 deletions.
3 changes: 0 additions & 3 deletions src/main/java/ivorius/pandorasbox/PandorasBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import ivorius.pandorasbox.client.rendering.effects.PBEffectRendererExplosion;
import ivorius.pandorasbox.client.rendering.effects.PBEffectRenderingRegistry;
import ivorius.pandorasbox.effects.PBEffectExplode;
import ivorius.pandorasbox.effects.PBEffects;
import ivorius.pandorasbox.events.PBEventHandler;
import ivorius.pandorasbox.init.Registry;
import ivorius.pandorasbox.utils.ArrayListExtensions;
Expand Down Expand Up @@ -55,8 +54,6 @@ public class PandorasBox {
public static ArrayListExtensions<Block> saplings;
public static ArrayListExtensions<Block> pots;
public static PBConfig CONFIG;

public static PBEventHandler fmlEventHandler;
public PandorasBox() {
// Register the setup method for modloading
initConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,28 @@
/**
* Created by lukas on 30.03.14.
*/
public class PBECConvertToNether implements PBEffectCreator
{
public class PBECConvertToNether implements PBEffectCreator {
public DValue range;
public DValue chanceToDiscardNetherrack;
public String biome;

public PBECConvertToNether(DValue range, String biome)
{
public PBECConvertToNether(DValue range, DValue chanceToDiscardNetherrack, String biome) {
this.range = range;
this.chanceToDiscardNetherrack = chanceToDiscardNetherrack;
this.biome = biome;
}

@Override
public PBEffect constructEffect(World world, double x, double y, double z, Random random)
{
public PBEffect constructEffect(World world, double x, double y, double z, Random random) {
double range = this.range.getValue(random);
int time = MathHelper.floor((random.nextDouble() * 7.0 + 3.0) * range);
double discardChance = chanceToDiscardNetherrack.getValue(random);

return new PBEffectGenConvertToNether(time, range, PandorasBoxHelper.getRandomUnifiedSeed(random), biome);
return new PBEffectGenConvertToNether(time, range, discardChance, PandorasBoxHelper.getRandomUnifiedSeed(random), biome);
}

@Override
public float chanceForMoreEffects(World world, double x, double y, double z, Random random)
{
public float chanceForMoreEffects(World world, double x, double y, double z, Random random) {
return 0.1f;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import ivorius.pandorasbox.random.DValue;
import ivorius.pandorasbox.weighted.WeightedBlock;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;

Expand All @@ -37,7 +38,7 @@ public PBEffect constructEffect(World world, double x, double y, double z, Rando
double range = this.range.getValue(random);
int time = MathHelper.floor((random.nextDouble() * 7.0 + 3.0) * range);

Block platformBlock = PandorasBoxHelper.getRandomBlock(random, platformBlocks);
Block platformBlock = platformBlocks.isEmpty() ? Blocks.AIR : PandorasBoxHelper.getRandomBlock(random, platformBlocks);

return new PBEffectGenPool(time, range, PandorasBoxHelper.getRandomUnifiedSeed(random), block, platformBlock);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,41 @@
import net.minecraft.util.Direction;
import net.minecraft.world.World;

import java.util.Collection;
import java.util.Arrays;
import java.util.Random;

/**
* Created by lukas on 30.03.14.
*/
public class PBECRuinedPortal implements PBEffectCreator {
public IValue rangeX;
public IValue rangeH;
public IValue rangeY;
public IValue rangeZ;
public IValue rangeStartY;

public Block block;
public final Collection<ArrayListExtensions<WeightedBlock>> bricks;
public final WeightedBlock[][] bricks;
public final ArrayListExtensions<RandomizedItemStack> loot;
public final Direction.Axis axis;

public PBECRuinedPortal(IValue rangeX, IValue rangeY, IValue rangeZ, IValue rangeStartY, Collection<ArrayListExtensions<WeightedBlock>> brickSet, ArrayListExtensions<RandomizedItemStack> loot, Direction.Axis axis) {
this.rangeX = rangeX;
public PBECRuinedPortal(IValue rangeH, IValue rangeY, IValue rangeStartY, WeightedBlock[][] brickSet, ArrayListExtensions<RandomizedItemStack> loot) {
this.rangeH = rangeH;
this.rangeY = rangeY;
this.rangeZ = rangeZ;
this.rangeStartY = rangeStartY;
this.bricks = brickSet;
this.loot = loot;
this.axis = axis;
}

@Override
public PBEffect constructEffect(World world, double x, double y, double z, Random random) {
int rangeX = this.rangeX.getValue(random);
int rangeH = this.rangeH.getValue(random);
int rangeY = this.rangeY.getValue(random);
int rangeStartY = this.rangeStartY.getValue(random);
int rangeZ = this.rangeZ.getValue(random);
rangeY += rangeStartY;
int time = 6 * (rangeX * rangeY * rangeZ) + 50;
int time = rangeH * rangeH * rangeY;

ArrayListExtensions<WeightedBlock> bricks = WeightedSelector.selectWeightless(random, this.bricks, this.bricks.size());
WeightedBlock[] bricks = WeightedSelector.selectWeightless(random, Arrays.asList(this.bricks), this.bricks.length);
Direction.Axis axis = random.nextBoolean() ? Direction.Axis.X : Direction.Axis.Z;

return new PBEffectGenRuinedPortal(time, rangeX, rangeZ, rangeY, rangeStartY, PandorasBoxHelper.getRandomUnifiedSeed(random), bricks, loot, axis);
return new PBEffectGenRuinedPortal(time, rangeH, rangeY, rangeStartY, PandorasBoxHelper.getRandomUnifiedSeed(random), bricks, loot, axis);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,47 @@
*/
public class PBEffectGenConvertToNether extends PBEffectGenerate {
private String biome;
private double discardNetherrackChance;
private int timesFeatureAMade = 0;
private int timesFeatureBMade = 0;
public PBEffectGenConvertToNether() {}

public PBEffectGenConvertToNether(int time, double range, int unifiedSeed, String biome) {
public PBEffectGenConvertToNether(int time, double range, double discardChance, int unifiedSeed, String biome) {
super(time, range, 2, unifiedSeed);
this.discardNetherrackChance = discardChance;
this.biome = biome;
}

@Override
public void generateOnBlock(World world, PandorasBoxEntity entity, Vec3d effectCenter, Random random, int pass, BlockPos pos, double range) {
if(world instanceof ServerWorld) {
if (world instanceof ServerWorld) {
ServerWorld serverWorld = (ServerWorld) world;
float newRatio = getRatioDone(entity.getEffectTicksExisted() + 1);
switch (biome) {
case "wastes": {
createWastes(serverWorld, entity, random, pass, pos);
createWastes(serverWorld, entity, random, pass, newRatio, pos);
break;
}
case "soul_sand_valley": {
createSoul(serverWorld, entity, random, pass, pos);
createSoul(serverWorld, entity, random, pass, newRatio, pos);
break;
}
case "crimson": {
createCrimson(serverWorld, entity, random, pass, pos);
createCrimson(serverWorld, entity, random, pass, newRatio, pos);
break;
}
case "warped": {
createWarped(serverWorld, entity, random, pass, pos);
createWarped(serverWorld, entity, random, pass, newRatio, pos);
break;
}
case "deltas": {
createDeltas(serverWorld, entity, random, pass, pos);
createDeltas(serverWorld, entity, random, pass, newRatio, pos);
break;
}
}
}
}
public void createWastes(ServerWorld world, PandorasBoxEntity entity, Random random, int pass, BlockPos pos) {
public void createWastes(ServerWorld world, PandorasBoxEntity entity, Random random, int pass, float newRatio, BlockPos pos) {
BlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
ArrayListExtensions<Block> blocks = new ArrayListExtensions<>();
Expand All @@ -79,7 +82,9 @@ public void createWastes(ServerWorld world, PandorasBoxEntity entity, Random ran
misc.addAll(PandorasBox.terracotta);

if (pass == 0) {
if (isBlockAnyOf(block, Blocks.COBBLESTONE, Blocks.ICE, Blocks.WATER, Blocks.OBSIDIAN)) {
if (random.nextDouble() < (discardNetherrackChance / 100) * Math.pow(1 + (discardNetherrackChance * 2), newRatio * 100)) {
return;
} else if (isBlockAnyOf(block, Blocks.COBBLESTONE, Blocks.ICE, Blocks.WATER, Blocks.OBSIDIAN)) {
Optional<Integer> integer = blockState.getOptionalValue(FlowingFluidBlock.LEVEL);
BlockState blockState2 = Blocks.LAVA.defaultBlockState();
if(integer.isPresent()) {
Expand Down Expand Up @@ -140,7 +145,7 @@ public void createWastes(ServerWorld world, PandorasBoxEntity entity, Random ran
if(success) timesFeatureAMade++;
}
}
if(random.nextDouble() < Math.pow(0.3, Math.floor(timesFeatureBMade / 4.0))) {
if (random.nextDouble() < Math.pow(0.3, Math.floor(timesFeatureBMade / 4.0))) {
BlockPos posBelow = pos.below();
BlockState blockBelowState = world.getBlockState(posBelow);

Expand All @@ -150,7 +155,7 @@ public void createWastes(ServerWorld world, PandorasBoxEntity entity, Random ran
}
}
}
public void createSoul(ServerWorld world, PandorasBoxEntity entity, Random random, int pass, BlockPos pos) {
public void createSoul(ServerWorld world, PandorasBoxEntity entity, Random random, int pass, float newRatio, BlockPos pos) {
BlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
ArrayListExtensions<Block> blocks = new ArrayListExtensions<>();
Expand All @@ -161,6 +166,7 @@ public void createSoul(ServerWorld world, PandorasBoxEntity entity, Random rando
misc.addAll(PandorasBox.terracotta);

if (pass == 0) {
if (random.nextDouble() < (discardNetherrackChance / 100) * Math.pow(1 + (discardNetherrackChance * 2), newRatio * 100)) return;
if (isBlockAnyOf(block, Blocks.COBBLESTONE, Blocks.ICE, Blocks.WATER, Blocks.OBSIDIAN)) {
Optional<Integer> integer = blockState.getOptionalValue(FlowingFluidBlock.LEVEL);
BlockState blockState2 = Blocks.LAVA.defaultBlockState();
Expand Down Expand Up @@ -215,7 +221,7 @@ public void createSoul(ServerWorld world, PandorasBoxEntity entity, Random rando
}
}
}
public void createCrimson(ServerWorld world, PandorasBoxEntity entity, Random random, int pass, BlockPos pos) {
public void createCrimson(ServerWorld world, PandorasBoxEntity entity, Random random, int pass, float newRatio, BlockPos pos) {
BlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
ArrayListExtensions<Block> blocks = new ArrayListExtensions<>();
Expand All @@ -229,7 +235,9 @@ public void createCrimson(ServerWorld world, PandorasBoxEntity entity, Random ra
blocks.removeAll(Blocks.CRIMSON_STEM, Blocks.STRIPPED_CRIMSON_STEM, Blocks.WARPED_STEM, Blocks.STRIPPED_WARPED_STEM);

if (pass == 0) {
if (isBlockAnyOf(block, Blocks.COBBLESTONE, Blocks.ICE, Blocks.WATER, Blocks.OBSIDIAN)) {
if (random.nextDouble() < (discardNetherrackChance / 100) * Math.pow(1 + (discardNetherrackChance * 2), newRatio * 100)) {
return;
} else if (isBlockAnyOf(block, Blocks.COBBLESTONE, Blocks.ICE, Blocks.WATER, Blocks.OBSIDIAN)) {
Optional<Integer> integer = blockState.getOptionalValue(FlowingFluidBlock.LEVEL);
BlockState blockState2 = Blocks.LAVA.defaultBlockState();
if(integer.isPresent()) {
Expand Down Expand Up @@ -307,7 +315,7 @@ public void createCrimson(ServerWorld world, PandorasBoxEntity entity, Random ra
}
}
}
public void createWarped(ServerWorld world, PandorasBoxEntity entity, Random random, int pass, BlockPos pos) {
public void createWarped(ServerWorld world, PandorasBoxEntity entity, Random random, int pass, float newRatio, BlockPos pos) {
BlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
ArrayListExtensions<Block> blocks = new ArrayListExtensions<>();
Expand All @@ -321,7 +329,9 @@ public void createWarped(ServerWorld world, PandorasBoxEntity entity, Random ran
blocks.removeAll(Blocks.CRIMSON_STEM, Blocks.STRIPPED_CRIMSON_STEM, Blocks.WARPED_STEM, Blocks.STRIPPED_WARPED_STEM);

if (pass == 0) {
if (isBlockAnyOf(block, Blocks.COBBLESTONE, Blocks.ICE, Blocks.WATER, Blocks.OBSIDIAN)) {
if (random.nextDouble() < (discardNetherrackChance / 100) * Math.pow(1 + (discardNetherrackChance * 2), newRatio * 100)) {
return;
} else if (isBlockAnyOf(block, Blocks.COBBLESTONE, Blocks.ICE, Blocks.WATER, Blocks.OBSIDIAN)) {
Optional<Integer> integer = blockState.getOptionalValue(FlowingFluidBlock.LEVEL);
BlockState blockState2 = Blocks.LAVA.defaultBlockState();
if(integer.isPresent()) {
Expand Down Expand Up @@ -392,7 +402,7 @@ public void createWarped(ServerWorld world, PandorasBoxEntity entity, Random ran
}
}
}
public void createDeltas(ServerWorld world, PandorasBoxEntity entity, Random random, int pass, BlockPos pos) {
public void createDeltas(ServerWorld world, PandorasBoxEntity entity, Random random, int pass, float newRatio, BlockPos pos) {
BlockState blockState = world.getBlockState(pos);
Block block = blockState.getBlock();
ArrayListExtensions<Block> blocks = new ArrayListExtensions<>();
Expand All @@ -403,7 +413,9 @@ public void createDeltas(ServerWorld world, PandorasBoxEntity entity, Random ran
misc.addAll(PandorasBox.terracotta);

if (pass == 0) {
if (isBlockAnyOf(block, Blocks.COBBLESTONE, Blocks.ICE, Blocks.WATER, Blocks.OBSIDIAN)) {
if (random.nextDouble() < (discardNetherrackChance / 100) * Math.pow(1 + (discardNetherrackChance * 2), newRatio * 100)) {
return;
} else if (isBlockAnyOf(block, Blocks.COBBLESTONE, Blocks.ICE, Blocks.WATER, Blocks.OBSIDIAN)) {
Optional<Integer> integer = blockState.getOptionalValue(FlowingFluidBlock.LEVEL);
BlockState blockState2 = Blocks.LAVA.defaultBlockState();
if(integer.isPresent()) {
Expand Down Expand Up @@ -479,6 +491,7 @@ private void createGlowstoneBlobs(ServerWorld world, BlockPos pos, Random random
public void readFromNBT(CompoundNBT compound) {
super.readFromNBT(compound);
biome = compound.getString("biome");
discardNetherrackChance = compound.getDouble("discardNetherrackChance");
timesFeatureAMade = compound.getInt("featureACount");
timesFeatureBMade = compound.getInt("featureBCount");
}
Expand All @@ -489,6 +502,7 @@ public void writeToNBT(CompoundNBT compound) {
if (biome != null) {
compound.putString("biome", biome);
}
compound.putDouble("discardNetherrackChance", discardNetherrackChance);
compound.putInt("featureACount", timesFeatureAMade);
compound.putInt("featureBCount", timesFeatureBMade);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public PBEffectGenPool(int time, double range, int unifiedSeed, Block block, Blo
public void generateOnBlock(World world, PandorasBoxEntity entity, Vec3d effectCenter, Random random, int pass, BlockPos pos, double range) {
if (!world.isClientSide && !world.getBlockState(pos).isAir()) {
boolean setPlatform = false;
if (platformBlock != null) {
if (platformBlock != null && !platformBlock.defaultBlockState().isAir()) {
List<LivingEntity> livingEntities = world.getEntitiesOfClass(LivingEntity.class, BlockPositions.expandToAABB(pos, 2.5, 2.5, 2.5));

if (!livingEntities.isEmpty())
Expand Down
Loading

0 comments on commit fca4c20

Please sign in to comment.