Compiles again.

This commit is contained in:
Sebastian Hartte
2020-07-27 23:50:28 +02:00
parent 56ecda5173
commit 84e6aaa122
136 changed files with 1004 additions and 1108 deletions
@@ -0,0 +1,26 @@
package appeng.mixins;
import appeng.spatial.SpatialDimensionManager;
import net.minecraft.server.IDynamicRegistries;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.DimensionType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.OptionalLong;
@Mixin(DimensionType.class)
public class DimensionTypeMixin {
@Inject(method = "func_236027_a_", at = @At("TAIL"))
private static void addRegistryDefaults(IDynamicRegistries.Impl registryTracker, CallbackInfoReturnable<?> cir) {
registryTracker.func_239774_a_(SpatialDimensionManager.STORAGE_DIMENSION_TYPE,
new DimensionType(OptionalLong.of(12000), false, false, false, false, false, false, true, false,
false, 256, BlockTags.INFINIBURN_OVERWORLD.getName(), 1.0f));
}
}
@@ -0,0 +1,102 @@
package appeng.mixins;
import appeng.hooks.DynamicDimensions;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import net.minecraft.server.IDynamicRegistries;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.Dimension;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraft.world.border.IBorderListener;
import net.minecraft.world.border.WorldBorder;
import net.minecraft.world.chunk.listener.IChunkStatusListener;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.DerivedWorldInfo;
import net.minecraft.world.storage.IServerConfiguration;
import net.minecraft.world.storage.IServerWorldInfo;
import net.minecraft.world.storage.SaveFormat;
import net.minecraft.world.storage.ServerWorldInfo;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Map;
import java.util.concurrent.Executor;
@Mixin(MinecraftServer.class)
public class MinecraftServerMixin implements DynamicDimensions {
@Shadow()
private IDynamicRegistries.Impl field_240767_f_;
@Shadow
private Map<RegistryKey<World>, ServerWorld> worlds;
@Shadow
private IServerConfiguration field_240768_i_;
@Shadow
private Executor backgroundExecutor;
@Shadow
private SaveFormat.LevelSave anvilConverterForAnvilFile;
public ServerWorld addWorld(RegistryKey<World> worldId, RegistryKey<DimensionType> dimensionTypeId,
ChunkGenerator chunkGenerator) {
Preconditions.checkArgument(!worlds.containsKey(worldId), "World with id %s already exists.",
worldId.func_240901_a_());
// Each worlds must have a corresponding dimension options, otherwise they will
// not be re-created on load
DimensionGeneratorSettings generatorOptions = this.field_240768_i_.func_230418_z_();
Preconditions.checkArgument(!generatorOptions.func_236224_e_().containsKey(worldId.func_240901_a_()),
"Dimension config with id %s already exists.", worldId.func_240901_a_());
DimensionType dimensionType = field_240767_f_.func_230520_a_().func_230516_a_(dimensionTypeId);
Preconditions.checkArgument(dimensionType != null, "dimensionTypeId %s is not registered", dimensionTypeId);
// Create dimension options with the given world-id and chunk generator
Dimension dimensionOptions = new Dimension(
() -> field_240767_f_.func_230520_a_().func_230516_a_(dimensionTypeId), chunkGenerator);
IServerWorldInfo serverWorldProperties = this.field_240768_i_.func_230407_G_();
// This sucks a little, but during startup, the server will use the same
// listener for every world,
// but it is ultimately only stored in the chunk storage. So we retrieve it from
// the overworld to
// mirror the original code as much as possible
ServerWorld overworld = worlds.get(ServerWorld.field_234918_g_);
Preconditions.checkState(overworld != null, "Overworld does not exist!");
IChunkStatusListener worldGenerationProgressListener = ((ThreadedAnvilChunkStorageAccessor) overworld
.getChunkProvider().chunkManager).getWorldGenerationProgressListener();
// Inherit seed + WorldBorder from overworld
long seed = overworld.getSeed();
WorldBorder worldBorder = overworld.getWorldBorder();
MinecraftServer self = (MinecraftServer) (Object) this;
DerivedWorldInfo unmodifiableLevelProperties = new DerivedWorldInfo(this.field_240768_i_,
serverWorldProperties);
ServerWorld world = new ServerWorld(self, this.backgroundExecutor, this.anvilConverterForAnvilFile, unmodifiableLevelProperties,
worldId, dimensionTypeId, dimensionType, worldGenerationProgressListener, chunkGenerator, false, seed,
ImmutableList.of(), false);
worldBorder.addListener(new IBorderListener.Impl(world.getWorldBorder()));
this.worlds.put(worldId, world);
// Adding it here will cause the world to be re-created on server restart
RegistryKey<Dimension> dimOptKey = RegistryKey.func_240903_a_(Registry.DIMENSION_KEY, worldId.func_240901_a_());
generatorOptions.func_236224_e_().register(dimOptKey, dimensionOptions);
generatorOptions.func_236224_e_().func_239662_d_(dimOptKey); // Otherwise it wont be saved
// Ensure the save properties are saved, or the world will potentially be lost
// on restart
this.anvilConverterForAnvilFile.func_237288_a_(this.field_240767_f_, this.field_240768_i_, self.getPlayerList().getHostPlayerData());
return world;
}
}
@@ -0,0 +1,25 @@
package appeng.mixins;
import appeng.spatial.SpatialDimensionManager;
import net.minecraft.client.world.DimensionRenderInfo;
import net.minecraft.util.RegistryKey;
import net.minecraft.world.DimensionType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Optional;
@Mixin(DimensionRenderInfo.class)
public class SkyPropertiesMixin {
@Inject(method = "func_239215_a_", at = @At("HEAD"), cancellable = true, remap = false)
private static void byDimensionType(Optional<RegistryKey<DimensionType>> optional,
CallbackInfoReturnable<DimensionRenderInfo> ci) {
if (optional.orElse(null) == SpatialDimensionManager.STORAGE_DIMENSION_TYPE) {
ci.setReturnValue(SpatialDimensionManager.STORAGE_SKY);
}
}
}
@@ -0,0 +1,29 @@
package appeng.mixins;
import appeng.client.render.SpatialSkyRender;
import appeng.spatial.SpatialDimensionManager;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.WorldRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(WorldRenderer.class)
public class SkyRenderMixin {
@Shadow(aliases = {"mc"})
private Minecraft client;
@SuppressWarnings("ConstantConditions")
@Inject(method = "renderSky", at = @At("HEAD"), cancellable = true)
public void renderSky(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
if (client.world.func_234922_V_() == SpatialDimensionManager.STORAGE_DIMENSION_TYPE) {
SpatialSkyRender.getInstance().render(matrices);
ci.cancel();
}
}
}
@@ -0,0 +1,14 @@
package appeng.mixins;
import net.minecraft.world.chunk.listener.IChunkStatusListener;
import net.minecraft.world.server.ChunkManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ChunkManager.class)
public interface ThreadedAnvilChunkStorageAccessor {
@Accessor("field_219266_t")
IChunkStatusListener getWorldGenerationProgressListener();
}
@@ -0,0 +1,20 @@
package appeng.mixins;
import net.minecraft.block.TNTBlock;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import javax.annotation.Nullable;
@Mixin(TNTBlock.class)
public interface TntAccessor {
@Invoker
static void callPrimeTnt(World world, BlockPos pos, @Nullable LivingEntity igniter) {
throw new AssertionError("Mixin dummy");
}
}