Compiles again.
This commit is contained in:
@@ -45,6 +45,7 @@ import appeng.api.util.WorldCoord;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
public class CachedPlane {
|
||||
private final int x_size;
|
||||
@@ -59,13 +60,13 @@ public class CachedPlane {
|
||||
private final Column[][] myColumns;
|
||||
private final List<TileEntity> tiles = new ArrayList<>();
|
||||
private final List<NextTickListEntry<Block>> ticks = new ArrayList<>();
|
||||
private final World world;
|
||||
private final ServerWorld world;
|
||||
private final IMovableRegistry reg = Api.instance().registries().movable();
|
||||
private final List<WorldCoord> updates = new ArrayList<>();
|
||||
private int verticalBits;
|
||||
private final BlockState matrixBlockState;
|
||||
|
||||
public CachedPlane(final World w, final int minX, final int minY, final int minZ, final int maxX, final int maxY,
|
||||
public CachedPlane(final ServerWorld w, final int minX, final int minY, final int minZ, final int maxX, final int maxY,
|
||||
final int maxZ) {
|
||||
|
||||
Block matrixFrameBlock = Api.instance().definitions().blocks().matrixFrame().maybeBlock().orElse(null);
|
||||
@@ -159,7 +160,7 @@ public class CachedPlane {
|
||||
if (tePOS.getX() >= minX && tePOS.getX() <= maxX && tePOS.getY() >= minY && tePOS.getY() <= maxY
|
||||
&& tePOS.getZ() >= minZ && tePOS.getZ() <= maxZ) {
|
||||
this.ticks.add(new NextTickListEntry<>(tePOS, entry.getTarget(),
|
||||
entry.scheduledTime - gameTime, entry.priority));
|
||||
entry.field_235017_b_ - gameTime, entry.priority));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,7 +264,7 @@ public class CachedPlane {
|
||||
|
||||
private void addTick(final int x, final int y, final int z, final NextTickListEntry<Block> entry) {
|
||||
BlockPos where = new BlockPos(x + this.x_offset, y + this.y_offset, z + this.z_offset);
|
||||
this.world.getPendingBlockTicks().scheduleTick(where, entry.getTarget(), (int) entry.scheduledTime,
|
||||
this.world.getPendingBlockTicks().scheduleTick(where, entry.getTarget(), (int) entry.field_235017_b_,
|
||||
entry.priority);
|
||||
}
|
||||
|
||||
@@ -315,12 +316,10 @@ public class CachedPlane {
|
||||
|
||||
final Chunk c = this.myChunks[x][z];
|
||||
|
||||
for (int y = 1; y < 255; y += 32) {
|
||||
WorldData.instance().compassData().service().updateArea(this.getWorld(), c.getPos(), y);
|
||||
}
|
||||
WorldData.instance().compassData().service().updateArea(this.getWorld(), c);
|
||||
|
||||
// FIXME this was sending chunks to players...
|
||||
SChunkDataPacket cdp = new SChunkDataPacket(c, verticalBits);
|
||||
SChunkDataPacket cdp = new SChunkDataPacket(c, verticalBits, false);
|
||||
((ServerChunkProvider) world.getChunkProvider()).chunkManager.getTrackingPlayers(c.getPos(), false)
|
||||
.forEach(spe -> spe.connection.sendPacket(cdp));
|
||||
|
||||
@@ -336,7 +335,7 @@ public class CachedPlane {
|
||||
return this.updates;
|
||||
}
|
||||
|
||||
World getWorld() {
|
||||
ServerWorld getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,70 +1,70 @@
|
||||
package appeng.spatial;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
|
||||
/**
|
||||
* Helps with encoding and decoding the extra data we attach to the spatial
|
||||
* {@link net.minecraft.world.dimension.DimensionType} as "extra data". Keep in
|
||||
* mind this data will also be sent to the client unless
|
||||
* {@link net.minecraftforge.common.ModDimension#write(PacketBuffer, boolean)}
|
||||
* is overridden.
|
||||
* Helps with encoding and decoding the extra data we attach to each created
|
||||
* storage dimension world as persistent state.
|
||||
*/
|
||||
public final class SpatialDimensionExtraData {
|
||||
public final class SpatialDimensionExtraData extends WorldSavedData {
|
||||
|
||||
/**
|
||||
* ID of this data when it is attached to a world.
|
||||
*/
|
||||
public static final String ID = "ae2_spatial_info";
|
||||
|
||||
// Used to allow forward compatibility
|
||||
private static final int CURRENT_FORMAT = 1;
|
||||
|
||||
private static final String TAG_FORMAT = "format";
|
||||
|
||||
private static final String TAG_SIZE = "size";
|
||||
|
||||
/**
|
||||
* The storage size of this dimension. This is dicateted by the pylon structure
|
||||
* size used to perform the first transfer into this dimension. Once it's set,
|
||||
* it cannot be changed anymore.
|
||||
*/
|
||||
private final BlockPos size;
|
||||
private BlockPos size = BlockPos.ZERO;
|
||||
|
||||
public SpatialDimensionExtraData(BlockPos size) {
|
||||
this.size = size;
|
||||
public SpatialDimensionExtraData() {
|
||||
super(ID);
|
||||
}
|
||||
|
||||
public PacketBuffer write() {
|
||||
PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
|
||||
buf.writeByte(CURRENT_FORMAT);
|
||||
buf.writeBlockPos(size);
|
||||
buf.capacity(buf.writerIndex()); // This cuts the backing buffer to the required size
|
||||
return buf;
|
||||
public SpatialDimensionExtraData(BlockPos size) {
|
||||
super(ID);
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public BlockPos getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SpatialDimensionExtraData read(@Nullable PacketBuffer buf) {
|
||||
if (buf == null) {
|
||||
return null;
|
||||
public void setSize(BlockPos size) {
|
||||
this.size = size;
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT tag) {
|
||||
int version = tag.getInt(TAG_FORMAT);
|
||||
if (version != CURRENT_FORMAT) {
|
||||
// Currently no new format has been defined, as such anything but the current
|
||||
// version is invalid
|
||||
throw new IllegalStateException("Invalid AE2 spatial info version: " + version);
|
||||
}
|
||||
|
||||
try {
|
||||
buf.readerIndex(0);
|
||||
byte version = buf.readByte();
|
||||
if (version != CURRENT_FORMAT) {
|
||||
// Currently no new format has been defined, as such anything but the current
|
||||
// version is invalid
|
||||
return null;
|
||||
}
|
||||
size = NBTUtil.readBlockPos(tag.getCompound(TAG_SIZE));
|
||||
}
|
||||
|
||||
BlockPos size = buf.readBlockPos();
|
||||
return new SpatialDimensionExtraData(size);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
AELog.warn(e, "Failed to read spatial storage dimension data.");
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
tag.putInt(TAG_FORMAT, CURRENT_FORMAT);
|
||||
tag.put(TAG_SIZE, NBTUtil.writeBlockPos(size));
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,14 +23,19 @@ import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.hooks.DynamicDimensions;
|
||||
import net.minecraft.client.world.DimensionRenderInfo;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
@@ -40,6 +45,35 @@ import appeng.core.localization.GuiText;
|
||||
|
||||
public final class SpatialDimensionManager implements ISpatialDimension {
|
||||
|
||||
// A region file is 512x512 blocks (32x32 chunks),
|
||||
// to avoid creating the 4 regions around 0,0,0,
|
||||
// we move the origin to the middle of region 0,0
|
||||
public static final BlockPos REGION_CENTER = new BlockPos(512 / 2, 64, 512 / 2);
|
||||
|
||||
public static final RegistryKey<DimensionType> STORAGE_DIMENSION_TYPE = RegistryKey.func_240903_a_(Registry.DIMENSION_TYPE_KEY,
|
||||
AppEng.makeId("storage_cell"));
|
||||
|
||||
// See the fabric version of this to get any idea what its doing
|
||||
public static final DimensionRenderInfo STORAGE_SKY = new DimensionRenderInfo(Float.NaN /* disables clouds */, false,
|
||||
DimensionRenderInfo.FogType.NONE /* we use a custom render mixin */, true, false) {
|
||||
|
||||
@Override
|
||||
public Vector3d func_230494_a_(Vector3d p_230494_1_, float p_230494_2_) {
|
||||
return Vector3d.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_230493_a_(int p_230493_1_, int p_230493_2_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public float[] func_230492_a_(float p_230492_1_, float p_230492_2_) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
public static final ISpatialDimension INSTANCE = new SpatialDimensionManager();
|
||||
|
||||
private static final String DIM_ID_PREFIX = "spatial_";
|
||||
@@ -48,18 +82,27 @@ public final class SpatialDimensionManager implements ISpatialDimension {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerWorld getWorld(DimensionType cellDim) {
|
||||
return DimensionManager.getWorld(getServer(), cellDim, true, true);
|
||||
public ServerWorld getWorld(RegistryKey<World> cellDim) {
|
||||
MinecraftServer server = getServer();
|
||||
return server.getWorld(cellDim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DimensionType createNewCellDimension(BlockPos size) {
|
||||
public RegistryKey<World> createNewCellDimension(BlockPos size) {
|
||||
ResourceLocation dimKey = findFreeDimensionId();
|
||||
AELog.info("Allocating storage cell dimension '%s'", dimKey);
|
||||
|
||||
PacketBuffer extraData = new SpatialDimensionExtraData(size).write();
|
||||
DynamicDimensions dynamicDimensions = (DynamicDimensions) getServer();
|
||||
|
||||
return DimensionManager.registerDimension(dimKey, StorageCellModDimension.INSTANCE, extraData, true);
|
||||
RegistryKey<World> worldId = RegistryKey.func_240903_a_(Registry.WORLD_KEY, dimKey);
|
||||
|
||||
ServerWorld world = dynamicDimensions.addWorld(worldId, STORAGE_DIMENSION_TYPE, StorageChunkGenerator.INSTANCE);
|
||||
|
||||
SpatialDimensionExtraData spatialExtraData = world.getSavedData()
|
||||
.getOrCreate(SpatialDimensionExtraData::new, SpatialDimensionExtraData.ID);
|
||||
spatialExtraData.setSize(size);
|
||||
|
||||
return worldId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,8 +111,8 @@ public final class SpatialDimensionManager implements ISpatialDimension {
|
||||
*/
|
||||
private ResourceLocation findFreeDimensionId() {
|
||||
int maxId = 0;
|
||||
for (DimensionType dimensionType : DimensionType.getAll()) {
|
||||
ResourceLocation regName = dimensionType.getRegistryName();
|
||||
for (RegistryKey<World> worldId : getServer().func_240770_D_()) {
|
||||
ResourceLocation regName = worldId.func_240901_a_();
|
||||
if (regName == null || !AppEng.MOD_ID.equals(regName.getNamespace())) {
|
||||
continue;
|
||||
}
|
||||
@@ -89,46 +132,56 @@ public final class SpatialDimensionManager implements ISpatialDimension {
|
||||
|
||||
++maxId;
|
||||
|
||||
return new ResourceLocation(AppEng.MOD_ID, DIM_ID_PREFIX + maxId);
|
||||
return AppEng.makeId(DIM_ID_PREFIX + maxId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCellDimension(DimensionType cellDim) {
|
||||
AELog.info("Unregistering storage cell dimension %s", cellDim.getRegistryName());
|
||||
public void deleteCellDimension(RegistryKey<World> worldId) {
|
||||
AELog.info("Unregistering storage cell dimension %s", worldId.func_240901_a_());
|
||||
MinecraftServer server = getServer();
|
||||
ServerWorld world = DimensionManager.getWorld(server, cellDim, false, false);
|
||||
if (world != null) {
|
||||
DimensionManager.unloadWorld(world);
|
||||
}
|
||||
DimensionManager.unloadWorlds(server, true);
|
||||
DimensionManager.unregisterDimension(cellDim.getId());
|
||||
// FIXME FABRIC ServerWorld world = DimensionManager.getWorld(server, worldId, false, false);
|
||||
// FIXME FABRIC if (world != null) {
|
||||
// FIXME FABRIC DimensionManager.unloadWorld(world);
|
||||
// FIXME FABRIC }
|
||||
// FIXME FABRIC DimensionManager.unloadWorlds(server, true);
|
||||
// FIXME FABRIC DimensionManager.unregisterDimension(worldId.getId());
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellDimension(DimensionType cellDim) {
|
||||
// Check if the cell dimension type is even registered
|
||||
if (cellDim.getRegistryName() == null || !cellDim.getRegistryName().equals(DimensionType.getKey(cellDim))) {
|
||||
public boolean isCellDimension(RegistryKey<World> worldId) {
|
||||
ResourceLocation id = worldId.func_240901_a_();
|
||||
if (!id.getNamespace().equals(AppEng.MOD_ID)) {
|
||||
return false; // World belongs to a different mod
|
||||
}
|
||||
if (!id.getPath().startsWith(DIM_ID_PREFIX)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return cellDim.getModType() instanceof StorageCellModDimension;
|
||||
// Check that the world has the right dimension type
|
||||
ServerWorld world = getServer().getWorld(worldId);
|
||||
if (world == null) {
|
||||
return false; // Non-existent world
|
||||
}
|
||||
|
||||
return world.func_234922_V_().equals(STORAGE_DIMENSION_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellDimensionOrigin(DimensionType cellDim) {
|
||||
return StorageCellDimension.REGION_CENTER;
|
||||
public BlockPos getCellDimensionOrigin(RegistryKey<World> worldId) {
|
||||
return REGION_CENTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellDimensionSize(DimensionType cellDim) {
|
||||
SpatialDimensionExtraData extraData = getExtraData(cellDim);
|
||||
public BlockPos getCellDimensionSize(RegistryKey<World> worldId) {
|
||||
SpatialDimensionExtraData extraData = getExtraData(worldId);
|
||||
return extraData != null ? extraData.getSize() : BlockPos.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCellDimensionTooltip(DimensionType cellDim, List<ITextComponent> lines) {
|
||||
public void addCellDimensionTooltip(RegistryKey<World> worldId, List<ITextComponent> lines) {
|
||||
// Check if the cell dimension type is even registered
|
||||
ResourceLocation registryName = cellDim.getRegistryName();
|
||||
ResourceLocation registryName = worldId.func_240901_a_();
|
||||
if (registryName == null || !AppEng.MOD_ID.equals(registryName.getNamespace())) {
|
||||
return;
|
||||
}
|
||||
@@ -138,8 +191,8 @@ public final class SpatialDimensionManager implements ISpatialDimension {
|
||||
}
|
||||
|
||||
// Add the actual stored size
|
||||
BlockPos size = SpatialDimensionManager.INSTANCE.getCellDimensionSize(cellDim);
|
||||
lines.add(GuiText.StoredSize.textComponent(size.getX(), size.getY(), size.getZ()));
|
||||
BlockPos size = SpatialDimensionManager.INSTANCE.getCellDimensionSize(worldId);
|
||||
lines.add(GuiText.StoredSize.text(size.getX(), size.getY(), size.getZ()));
|
||||
|
||||
// Add a serial number to allows players to keep different cells apart
|
||||
int dimId;
|
||||
@@ -152,15 +205,17 @@ public final class SpatialDimensionManager implements ISpatialDimension {
|
||||
|
||||
// Try to make this a little more flavorful.
|
||||
String serialNumber = String.format(Locale.ROOT, "SP-%04d", dimId);
|
||||
lines.add(GuiText.SerialNumber.textComponent(serialNumber));
|
||||
lines.add(GuiText.SerialNumber.text(serialNumber));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private SpatialDimensionExtraData getExtraData(DimensionType cellDim) {
|
||||
if (!(cellDim.getModType() instanceof StorageCellModDimension)) {
|
||||
private SpatialDimensionExtraData getExtraData(RegistryKey<World> worldId) {
|
||||
ServerWorld world = getWorld(worldId);
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
return SpatialDimensionExtraData.read(cellDim.getData());
|
||||
|
||||
return world.getSavedData().get(SpatialDimensionExtraData::new, SpatialDimensionExtraData.ID);
|
||||
}
|
||||
|
||||
private static MinecraftServer getServer() {
|
||||
|
||||
@@ -18,14 +18,9 @@
|
||||
|
||||
package appeng.spatial;
|
||||
|
||||
import net.minecraft.util.SharedSeedRandom;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.gen.GenerationSettings;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.biome.BiomeAmbience;
|
||||
import net.minecraft.world.gen.surfacebuilders.ConfiguredSurfaceBuilder;
|
||||
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -34,15 +29,14 @@ public class StorageCellBiome extends Biome {
|
||||
|
||||
public static final StorageCellBiome INSTANCE = new StorageCellBiome();
|
||||
|
||||
static {
|
||||
INSTANCE.setRegistryName("appliedenergistics2:storage");
|
||||
}
|
||||
|
||||
public StorageCellBiome() {
|
||||
super(new Biome.Builder().surfaceBuilder(SurfaceBuilder.NOPE, SurfaceBuilder.STONE_STONE_GRAVEL_CONFIG)
|
||||
super(new Biome.Builder()
|
||||
.surfaceBuilder(new ConfiguredSurfaceBuilder<>(SurfaceBuilder.NOPE, SurfaceBuilder.STONE_STONE_GRAVEL_CONFIG))
|
||||
.precipitation(RainType.NONE).category(Category.NONE).depth(0).scale(1)
|
||||
// Copied from the vanilla void biome
|
||||
.temperature(0.5F).downfall(0.5F).waterColor(4159204).waterFogColor(329011).parent(null));
|
||||
.temperature(0.5F).downfall(0.5F)
|
||||
.func_235097_a_(new BiomeAmbience.Builder().func_235246_b_(4159204).func_235248_c_(329011).func_235239_a_(0).func_235238_a_())
|
||||
.parent(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,24 +45,4 @@ public class StorageCellBiome extends Biome {
|
||||
return 0x111111;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesWaterFreeze(IWorldReader worldIn, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesWaterFreeze(IWorldReader worldIn, BlockPos water, boolean mustBeAtEdge) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSnowGenerate(IWorldReader worldIn, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(GenerationStage.Decoration stage, ChunkGenerator<? extends GenerationSettings> chunkGenerator,
|
||||
IWorld worldIn, long seed, SharedSeedRandom random, BlockPos pos) {
|
||||
// Nothing should ever generate here...
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.spatial;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.Dimension;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.IRenderHandler;
|
||||
|
||||
import appeng.client.render.SpatialSkyRender;
|
||||
|
||||
public class StorageCellDimension extends Dimension {
|
||||
|
||||
// A region file is 512x512 blocks (32x32 chunks),
|
||||
// to avoid creating the 4 regions around 0,0,0,
|
||||
// we move the origin to the middle of region 0,0
|
||||
public static final BlockPos REGION_CENTER = new BlockPos(512 / 2, 64, 512 / 2);
|
||||
|
||||
public StorageCellDimension(World world, DimensionType dimensionType) {
|
||||
// FIXME: check light value
|
||||
super(world, dimensionType, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator createChunkGenerator() {
|
||||
return new StorageChunkGenerator(this.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float calculateCelestialAngle(final long par1, final float par3) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSurfaceWorld() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public float[] calcSunriseSunsetColors(final float celestialAngle, final float partialTicks) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3d getFogColor(final float par1, final float par2) {
|
||||
return new Vector3d(0.07, 0.07, 0.07);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRespawnHere() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public boolean isSkyColored() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesXZShowFog(final int par1, final int par2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRenderHandler getSkyRenderer() {
|
||||
return SpatialSkyRender.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDaytime() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getSpawnCoordinate() {
|
||||
return REGION_CENTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHighHumidity(final BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDoLightning(final Chunk chunk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDoRainSnowIce(Chunk chunk) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockPos findSpawn(ChunkPos chunkPosIn, boolean checkValid) {
|
||||
return getSpawnCoordinate();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockPos findSpawn(int posX, int posZ, boolean checkValid) {
|
||||
return getSpawnCoordinate();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.spatial;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import net.minecraft.world.Dimension;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ModDimension;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class StorageCellModDimension extends ModDimension {
|
||||
|
||||
public static final StorageCellModDimension INSTANCE = new StorageCellModDimension();
|
||||
|
||||
static {
|
||||
INSTANCE.setRegistryName(AppEng.MOD_ID, "storage_cell");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiFunction<World, DimensionType, ? extends Dimension> getFactory() {
|
||||
return StorageCellDimension::new;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,38 +18,63 @@
|
||||
|
||||
package appeng.spatial;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.Blockreader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeManager;
|
||||
import net.minecraft.world.biome.provider.BiomeProvider;
|
||||
import net.minecraft.world.biome.provider.SingleBiomeProvider;
|
||||
import net.minecraft.world.biome.provider.SingleBiomeProviderSettings;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
import net.minecraft.world.gen.ChunkGenerator;
|
||||
import net.minecraft.world.gen.GenerationSettings;
|
||||
import net.minecraft.world.gen.GenerationStage;
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraft.world.gen.WorldGenRegion;
|
||||
|
||||
import appeng.core.Api;
|
||||
import net.minecraft.world.gen.feature.structure.StructureManager;
|
||||
import net.minecraft.world.gen.settings.DimensionStructuresSettings;
|
||||
|
||||
public class StorageChunkGenerator extends ChunkGenerator<GenerationSettings> {
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
public class StorageChunkGenerator extends ChunkGenerator {
|
||||
|
||||
private final Blockreader columnSample;
|
||||
|
||||
public static final StorageChunkGenerator INSTANCE = new StorageChunkGenerator();
|
||||
|
||||
public static final Codec<StorageChunkGenerator> CODEC = RecordCodecBuilder
|
||||
.create((instance) -> instance.stable(INSTANCE));
|
||||
|
||||
private final BlockState defaultBlockState;
|
||||
|
||||
public StorageChunkGenerator(final World world) {
|
||||
super(world, createBiomeProvider(), createSettings());
|
||||
private StorageChunkGenerator() {
|
||||
super(createBiomeProvider(), createSettings());
|
||||
this.defaultBlockState = Api.instance().definitions().blocks().matrixFrame().block().getDefaultState();
|
||||
|
||||
// Vertical sample is mostly used for Feature generation, for those purposes
|
||||
// we're all filled with matrix blocks
|
||||
BlockState[] columnSample = new BlockState[256];
|
||||
Arrays.fill(columnSample, this.defaultBlockState);
|
||||
this.columnSample = new Blockreader(columnSample);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Codec<? extends ChunkGenerator> func_230347_a_() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
private static BiomeProvider createBiomeProvider() {
|
||||
SingleBiomeProviderSettings biomeSettings = new SingleBiomeProviderSettings(null);
|
||||
biomeSettings.setBiome(StorageCellBiome.INSTANCE);
|
||||
return new SingleBiomeProvider(biomeSettings);
|
||||
return new SingleBiomeProvider(StorageCellBiome.INSTANCE);
|
||||
}
|
||||
|
||||
private static GenerationSettings createSettings() {
|
||||
return new GenerationSettings();
|
||||
private static DimensionStructuresSettings createSettings() {
|
||||
return new DimensionStructuresSettings(Optional.empty(), Collections.emptyMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,22 +100,34 @@ public class StorageChunkGenerator extends ChunkGenerator<GenerationSettings> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroundHeight() {
|
||||
public int func_230356_f_() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeBase(IWorld worldIn, IChunk chunkIn) {
|
||||
public ChunkGenerator func_230349_a_(long p_230349_1_) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(int p_222529_1_, int p_222529_2_, Heightmap.Type heightmapType) {
|
||||
public void func_230352_b_(IWorld world, StructureManager accessor, IChunk chunk) {
|
||||
}
|
||||
|
||||
public IBlockReader func_230348_a_(int x, int z) {
|
||||
return columnSample;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int func_222529_a(int p_222529_1_, int p_222529_2_, Heightmap.Type heightmapType) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(WorldGenRegion region) {
|
||||
// Do not decorate chunks at all
|
||||
public void func_230351_a_(WorldGenRegion region, StructureManager accessor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_230350_a_(long seed, BiomeManager access, IChunk chunk, GenerationStage.Carving carver) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -97,11 +97,11 @@ public class StorageHelper {
|
||||
newWorld.getChunkProvider().getChunk(MathHelper.floor(link.x) >> 4, MathHelper.floor(link.z) >> 4,
|
||||
ChunkStatus.FULL, true);
|
||||
|
||||
if (entity instanceof ServerPlayerEntity && link.dim.getDimension() instanceof StorageCellDimension) {
|
||||
if (entity instanceof ServerPlayerEntity && link.dim.func_234922_V_() == SpatialDimensionManager.STORAGE_DIMENSION_TYPE) {
|
||||
AppEng.instance().getAdvancementTriggers().getSpatialExplorer().trigger((ServerPlayerEntity) entity);
|
||||
}
|
||||
|
||||
entity.changeDimension(link.dim.getDimension().getType(), new METeleporter(link));
|
||||
entity.changeDimension(link.dim, new METeleporter(link));
|
||||
|
||||
if (!passengersOnOtherSide.isEmpty()) {
|
||||
for (Entity passanger : passengersOnOtherSide) {
|
||||
@@ -136,7 +136,7 @@ public class StorageHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void swapRegions(final World srcWorld, final int srcX, final int srcY, final int srcZ, final World dstWorld,
|
||||
public void swapRegions(final ServerWorld srcWorld, final int srcX, final int srcY, final int srcZ, final ServerWorld dstWorld,
|
||||
final int dstX, final int dstY, final int dstZ, final int scaleX, final int scaleY, final int scaleZ) {
|
||||
Api.instance().definitions().blocks().matrixFrame().maybeBlock()
|
||||
.ifPresent(matrixFrameBlock -> this.transverseEdges(dstX - 1, dstY - 1, dstZ - 1, dstX + scaleX + 1,
|
||||
@@ -222,12 +222,12 @@ public class StorageHelper {
|
||||
}
|
||||
|
||||
private static class TelDestination {
|
||||
private final World dim;
|
||||
private final ServerWorld dim;
|
||||
private final double x;
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
TelDestination(final World dimension, final AxisAlignedBB srcBox, final double x, final double y,
|
||||
TelDestination(final ServerWorld dimension, final AxisAlignedBB srcBox, final double x, final double y,
|
||||
final double z, final int tileX, final int tileY, final int tileZ) {
|
||||
this.dim = dimension;
|
||||
this.x = Math.min(srcBox.maxX - 0.5, Math.max(srcBox.minX + 0.5, x + tileX));
|
||||
|
||||
Reference in New Issue
Block a user