Some random fixes, 959 errors

This commit is contained in:
modmuss50 2019-02-21 18:11:55 +00:00
parent 0975b4353b
commit f6a79ce579
37 changed files with 131 additions and 186 deletions

View file

@ -26,6 +26,7 @@ package techreborn.world;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Sets;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraftforge.event.world.ChunkDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@ -44,15 +45,15 @@ import java.util.Set;
*/
public class TechRebornRetroGen {
private static final String RETROGEN_TAG = "techrebonr:retogen";
private static final Set<ChunkCoord> completedChunks = Sets.newHashSet();
private final Deque<ChunkCoord> chunksToRetroGen = new ArrayDeque<>(64);
private static final Set<ChunkPos> completedChunks = Sets.newHashSet();
private final Deque<ChunkPos> chunksToRetroGen = new ArrayDeque<>(64);
private boolean isChunkEligibleForRetroGen(ChunkDataEvent.Load event) {
return TechReborn.worldGen.config.retroGenOres && event.getWorld().provider.getDimension() == 0
&& event.getData().getString(RETROGEN_TAG).isEmpty();
}
public void markChunk(ChunkCoord coord) {
public void markChunk(ChunkPos coord) {
completedChunks.add(coord);
}
@ -64,7 +65,7 @@ public class TechRebornRetroGen {
public void onWorldTick(TickEvent.WorldTickEvent event) {
if (isTickEligibleForRetroGen(event)) {
if (!chunksToRetroGen.isEmpty()) {
final ChunkCoord coord = chunksToRetroGen.pollFirst();
final ChunkPos coord = chunksToRetroGen.pollFirst();
TechReborn.LOGGER.info("Regenerating ore in " + coord + '.');
final World world = event.world;
if (world.getChunkProvider().getLoadedChunk(coord.getX(), coord.getZ()) != null) {
@ -83,7 +84,7 @@ public class TechRebornRetroGen {
@SubscribeEvent
public void onChunkLoad(ChunkDataEvent.Load event) {
if (isChunkEligibleForRetroGen(event)) {
final ChunkCoord coord = ChunkCoord.of(event);
final ChunkPos coord = ChunkPos.of(event);
TechReborn.LOGGER.info("Queueing retro ore gen for " + coord + '.');
chunksToRetroGen.addLast(coord);
}
@ -91,7 +92,7 @@ public class TechRebornRetroGen {
@SubscribeEvent
public void onChunkSave(ChunkDataEvent.Save event) {
final ChunkCoord coord = ChunkCoord.of(event);
final ChunkPos coord = ChunkPos.of(event);
if (completedChunks.contains(coord)) {
event.getData().setString(RETROGEN_TAG, "X");
completedChunks.remove(coord);

View file

@ -29,47 +29,50 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent;
import net.minecraft.world.gen.structure.StructureVillagePieces;
import net.minecraft.world.gen.feature.structure.StructurePiece;
import net.minecraft.world.gen.feature.structure.VillagePieces;
import techreborn.init.TRContent;
import techreborn.world.RubberTreeGenerator;
import java.util.List;
import java.util.Random;
public class VillageComponentRubberPlantaion extends StructureVillagePieces.Field1 {
public class VillageComponentRubberPlantaion extends VillagePieces.Field1 {
public static StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) {
StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 13, 4, 9, facing);
return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(pieces, structureboundingbox) == null ? new VillageComponentRubberPlantaion(startPiece, p5, random, structureboundingbox, facing) : null;
public static VillagePieces.Village buildComponent(VillagePieces.PieceWeight villagePiece, VillagePieces.Start startPiece, List<StructurePiece> pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) {
MutableBoundingBox structureboundingbox = MutableBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, 13, 4, 9, facing);
return canVillageGoDeeper(structureboundingbox) && StructurePiece.findIntersecting(pieces, structureboundingbox) == null ? new VillageComponentRubberPlantaion(startPiece, p5, random, structureboundingbox, facing) : null;
}
public VillageComponentRubberPlantaion() {
}
public VillageComponentRubberPlantaion(StructureVillagePieces.Start start, int type, Random rand, StructureBoundingBox structureBoundingBox, EnumFacing facing) {
public VillageComponentRubberPlantaion(VillagePieces.Start start, int type, Random rand, MutableBoundingBox structureBoundingBox, EnumFacing facing) {
super(start, type, rand, structureBoundingBox, facing);
}
@Override
protected void fillWithBlocks(World worldIn, StructureBoundingBox boundingboxIn, int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, IBlockState boundaryBlockState, IBlockState insideBlockState, boolean existingOnly) {
protected void fillWithBlocks(IWorld worldIn, MutableBoundingBox boundingboxIn, int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, IBlockState boundaryBlockState, IBlockState insideBlockState, boolean existingOnly) {
//Replaces farmland with dirt, its not great but it works.
if (boundaryBlockState.getBlock() == Blocks.FARMLAND) {
boundaryBlockState = Blocks.GRASS.getDefaultState();
insideBlockState = Blocks.GRASS.getDefaultState();
}
//Replaces the water and logs with stone bricks
if (boundaryBlockState.getBlock() == Blocks.WATER || boundaryBlockState.getBlock() == Blocks.LOG) {
boundaryBlockState = Blocks.STONEBRICK.getDefaultState();
insideBlockState = Blocks.STONEBRICK.getDefaultState();
if (boundaryBlockState.getBlock() == Blocks.WATER || boundaryBlockState.getBlock() == Blocks.OAK_LOG) {
boundaryBlockState = Blocks.STONE_BRICKS.getDefaultState();
insideBlockState = Blocks.STONE_BRICKS.getDefaultState();
}
super.fillWithBlocks(worldIn, boundingboxIn, xMin, yMin, zMin, xMax, yMax, zMax, boundaryBlockState, insideBlockState, existingOnly);
}
@Override
protected void setBlockState(World worldIn, IBlockState blockstateIn, int x, int y, int z, StructureBoundingBox boundingboxIn) {
protected void setBlockState(IWorld worldIn, IBlockState blockstateIn, int x, int y, int z, MutableBoundingBox boundingboxIn) {
if (isCrop(blockstateIn)) {
blockstateIn = TRContent.RUBBER_SAPLING.getDefaultState();
}
@ -77,8 +80,8 @@ public class VillageComponentRubberPlantaion extends StructureVillagePieces.Fiel
}
@Override
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
super.addComponentParts(worldIn, randomIn, structureBoundingBoxIn);
public boolean addComponentParts(IWorld worldIn, Random randomIn, MutableBoundingBox structureBoundingBoxIn, ChunkPos chunkPos) {
super.addComponentParts(worldIn, randomIn, structureBoundingBoxIn, chunkPos);
for (int i = 1; i < 7; i++) {
growRandom(i, 1, structureBoundingBoxIn, randomIn, worldIn);
growRandom(i, 2, structureBoundingBoxIn, randomIn, worldIn);
@ -93,7 +96,7 @@ public class VillageComponentRubberPlantaion extends StructureVillagePieces.Fiel
return true;
}
private void growRandom(int coloum, int row, StructureBoundingBox structureBoundingBox, Random random, World world) {
private void growRandom(int coloum, int row, MutableBoundingBox structureBoundingBox, Random random, World world) {
if (random.nextInt(10) == 0) {
setBlockState(world, Blocks.AIR.getDefaultState(), row, 1, coloum, structureBoundingBox);
BlockPos pos = new BlockPos(this.getXWithOffset(row, coloum), this.getYWithOffset(1), this.getZWithOffset(row, coloum));

View file

@ -25,6 +25,8 @@
package techreborn.world.village;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.gen.feature.structure.StructurePiece;
import net.minecraft.world.gen.feature.structure.VillagePieces;
import net.minecraft.world.gen.structure.StructureComponent;
import net.minecraft.world.gen.structure.StructureVillagePieces;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
@ -35,8 +37,8 @@ import java.util.Random;
public class VillagePlantaionHandler implements VillagerRegistry.IVillageCreationHandler {
@Override
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) {
return new StructureVillagePieces.PieceWeight(VillageComponentRubberPlantaion.class, 5, 1);
public VillagePieces.PieceWeight getVillagePieceWeight(Random random, int i) {
return new StructurePiece.PieceWeight(VillageComponentRubberPlantaion.class, 5, 1);
}
@Override
@ -44,8 +46,9 @@ public class VillagePlantaionHandler implements VillagerRegistry.IVillageCreatio
return VillageComponentRubberPlantaion.class;
}
@Override
public StructureVillagePieces.Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) {
public VillagePieces.Village buildComponent(VillagePieces.PieceWeight villagePiece, VillagePieces.Start startPiece, List<StructurePiece> pieces, Random random, int p1, int p2, int p3, EnumFacing facing, int p5) {
return VillageComponentRubberPlantaion.buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, facing, p5);
}
}