First Working Worldgen of Meteorites

This commit is contained in:
Sebastian Hartte
2020-07-07 18:55:56 +02:00
parent f8ee4bb1f2
commit 2944873431
10 changed files with 81 additions and 51 deletions
@@ -21,6 +21,12 @@ package appeng.worldgen.meteorite;
import java.util.ArrayList;
import java.util.List;
import alexiil.mc.lib.attributes.AttributeList;
import alexiil.mc.lib.attributes.AttributeProvider;
import alexiil.mc.lib.attributes.AttributeUtil;
import alexiil.mc.lib.attributes.item.ItemAttributes;
import appeng.tile.storage.SkyChestBlockEntity;
import appeng.util.inv.AdaptorFixedInv;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@@ -203,8 +209,12 @@ public final class MeteoritePlacer {
if (AEConfig.instance().isFeatureEnabled(AEFeature.SPAWN_PRESSES_IN_METEORITES)) {
this.putter.put(world, pos, this.skyChestDefinition.block().getDefaultState());
final BlockEntity te = world.getBlockEntity(pos); // FIXME: this is also probably a band-aid for another issue
final InventoryAdaptor ap = InventoryAdaptor.getAdaptor(te, Direction.UP);
final SkyChestBlockEntity te = (SkyChestBlockEntity) world.getBlockEntity(pos);
InventoryAdaptor ap = null;
if (te != null) {
ap = new AdaptorFixedInv(te.getInternalInventory());
}
if (ap != null && !ap.containsItems()) // FIXME: band-aid for meteorites being generated multiple times
{
// TODO: loot tables would be better
@@ -23,18 +23,9 @@ public class MeteoriteStructure extends StructureFeature<DefaultFeatureConfig> {
@Override
public boolean shouldStartAt(ChunkGenerator generator, BiomeSource biomeSource, long seed, ChunkRandom randIn, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos2, DefaultFeatureConfig featureConfig) {
int i = chunkX >> 4;
int j = chunkZ >> 4;
randIn.setSeed((long) (i ^ j << 4) ^ seed);
randIn.nextInt();
return randIn.nextBoolean();
}
@Override
public String getName() {
return ID.toString();
}
@Override
public StructureStartFactory<DefaultFeatureConfig> getStructureStartFactory() {
return MeteoriteStructureStart::new;
@@ -71,7 +71,7 @@ public final class PlacedMeteoriteSettings {
}
public CompoundTag write(CompoundTag tag) {
tag.putLong(Constants.TAG_POS, pos.toLong());
tag.putLong(Constants.TAG_POS, pos.asLong());
tag.putFloat(Constants.TAG_RADIUS, meteoriteRadius);
tag.putByte(Constants.TAG_CRATER, (byte) craterType.ordinal());