Remove libstructure
Migrate to 1.16.2 final
This commit is contained in:
@@ -196,8 +196,8 @@ public final class AppEngClient extends AppEngBase {
|
||||
// WorldData
|
||||
// each time the integrated server starts&stops
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(WorldData::onServerStarting);
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(server -> WorldData.instance().onServerStopping());
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register(server -> WorldData.instance().onServerStoppped());
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(server -> WorldData.onServerStopping(server));
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register(WorldData::onServerStoppped);
|
||||
|
||||
this.bindings = new EnumMap<>(ActionKey.class);
|
||||
for (ActionKey key : ActionKey.values()) {
|
||||
|
||||
@@ -4,56 +4,24 @@ import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.earthcomputer.libstructure.LibStructure;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BannerBlockEntity;
|
||||
import net.minecraft.block.entity.BeaconBlockEntity;
|
||||
import net.minecraft.block.entity.BrewingStandBlockEntity;
|
||||
import net.minecraft.block.entity.ChestBlockEntity;
|
||||
import net.minecraft.block.entity.CommandBlockBlockEntity;
|
||||
import net.minecraft.block.entity.ComparatorBlockEntity;
|
||||
import net.minecraft.block.entity.DaylightDetectorBlockEntity;
|
||||
import net.minecraft.block.entity.DispenserBlockEntity;
|
||||
import net.minecraft.block.entity.DropperBlockEntity;
|
||||
import net.minecraft.block.entity.EnchantingTableBlockEntity;
|
||||
import net.minecraft.block.entity.EndPortalBlockEntity;
|
||||
import net.minecraft.block.entity.EnderChestBlockEntity;
|
||||
import net.minecraft.block.entity.FurnaceBlockEntity;
|
||||
import net.minecraft.block.entity.HopperBlockEntity;
|
||||
import net.minecraft.block.entity.MobSpawnerBlockEntity;
|
||||
import net.minecraft.block.entity.PistonBlockEntity;
|
||||
import net.minecraft.block.entity.ShulkerBoxBlockEntity;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.block.entity.*;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.chunk.StructureConfig;
|
||||
import net.minecraft.world.gen.decorator.Decorator;
|
||||
import net.minecraft.world.gen.decorator.NopeDecoratorConfig;
|
||||
import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.api.features.IRegistryContainer;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.features.IWorldGen;
|
||||
@@ -72,39 +40,7 @@ import appeng.bootstrap.components.ITileEntityRegistrationComponent;
|
||||
import appeng.client.render.effects.ParticleTypes;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.CellWorkbenchContainer;
|
||||
import appeng.container.implementations.ChestContainer;
|
||||
import appeng.container.implementations.CondenserContainer;
|
||||
import appeng.container.implementations.CraftAmountContainer;
|
||||
import appeng.container.implementations.CraftConfirmContainer;
|
||||
import appeng.container.implementations.CraftingCPUContainer;
|
||||
import appeng.container.implementations.CraftingStatusContainer;
|
||||
import appeng.container.implementations.CraftingTermContainer;
|
||||
import appeng.container.implementations.DriveContainer;
|
||||
import appeng.container.implementations.FormationPlaneContainer;
|
||||
import appeng.container.implementations.GrinderContainer;
|
||||
import appeng.container.implementations.IOPortContainer;
|
||||
import appeng.container.implementations.InscriberContainer;
|
||||
import appeng.container.implementations.InterfaceContainer;
|
||||
import appeng.container.implementations.InterfaceTerminalContainer;
|
||||
import appeng.container.implementations.LevelEmitterContainer;
|
||||
import appeng.container.implementations.MEMonitorableContainer;
|
||||
import appeng.container.implementations.MEPortableCellContainer;
|
||||
import appeng.container.implementations.MolecularAssemblerContainer;
|
||||
import appeng.container.implementations.NetworkStatusContainer;
|
||||
import appeng.container.implementations.NetworkToolContainer;
|
||||
import appeng.container.implementations.PatternTermContainer;
|
||||
import appeng.container.implementations.PriorityContainer;
|
||||
import appeng.container.implementations.QNBContainer;
|
||||
import appeng.container.implementations.QuartzKnifeContainer;
|
||||
import appeng.container.implementations.SecurityStationContainer;
|
||||
import appeng.container.implementations.SkyChestContainer;
|
||||
import appeng.container.implementations.SpatialIOPortContainer;
|
||||
import appeng.container.implementations.StorageBusContainer;
|
||||
import appeng.container.implementations.UpgradeableContainer;
|
||||
import appeng.container.implementations.VibrationChamberContainer;
|
||||
import appeng.container.implementations.WirelessContainer;
|
||||
import appeng.container.implementations.WirelessTermContainer;
|
||||
import appeng.container.implementations.*;
|
||||
import appeng.core.features.registries.P2PTunnelRegistry;
|
||||
import appeng.core.features.registries.cell.BasicCellHandler;
|
||||
import appeng.core.features.registries.cell.BasicItemCellGuiHandler;
|
||||
@@ -115,41 +51,18 @@ import appeng.core.stats.AeStats;
|
||||
import appeng.core.sync.BasePacket;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.network.TargetPoint;
|
||||
import appeng.fluids.container.FluidFormationPlaneContainer;
|
||||
import appeng.fluids.container.FluidIOContainer;
|
||||
import appeng.fluids.container.FluidInterfaceContainer;
|
||||
import appeng.fluids.container.FluidLevelEmitterContainer;
|
||||
import appeng.fluids.container.FluidStorageBusContainer;
|
||||
import appeng.fluids.container.FluidTerminalContainer;
|
||||
import appeng.fluids.container.*;
|
||||
import appeng.fluids.registries.BasicFluidCellGuiHandler;
|
||||
import appeng.hooks.ToolItemHook;
|
||||
import appeng.items.parts.FacadeItem;
|
||||
import appeng.items.tools.NetworkToolItem;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import appeng.me.cache.EnergyGridCache;
|
||||
import appeng.me.cache.GridStorageCache;
|
||||
import appeng.me.cache.P2PCache;
|
||||
import appeng.me.cache.PathGridCache;
|
||||
import appeng.me.cache.SecurityCache;
|
||||
import appeng.me.cache.SpatialPylonCache;
|
||||
import appeng.me.cache.TickManagerCache;
|
||||
import appeng.me.cache.*;
|
||||
import appeng.mixins.CriteriaRegisterMixin;
|
||||
import appeng.recipes.game.DisassembleRecipe;
|
||||
import appeng.recipes.game.FacadeRecipe;
|
||||
import appeng.recipes.handlers.GrinderRecipe;
|
||||
import appeng.recipes.handlers.GrinderRecipeSerializer;
|
||||
import appeng.recipes.handlers.InscriberRecipe;
|
||||
import appeng.recipes.handlers.InscriberRecipeSerializer;
|
||||
import appeng.recipes.handlers.QuartzKnifeRecipeSerializer;
|
||||
import appeng.recipes.handlers.*;
|
||||
import appeng.server.AECommand;
|
||||
import appeng.spatial.SpatialStorageBiome;
|
||||
import appeng.spatial.SpatialStorageChunkGenerator;
|
||||
import appeng.spatial.SpatialStorageDimensionIds;
|
||||
import appeng.tile.AEBaseBlockEntity;
|
||||
import appeng.worldgen.BiomeModifier;
|
||||
import appeng.worldgen.ChargedQuartzOreConfig;
|
||||
import appeng.worldgen.ChargedQuartzOreFeature;
|
||||
import appeng.worldgen.meteorite.MeteoriteStructure;
|
||||
|
||||
public abstract class AppEngBase implements AppEng {
|
||||
|
||||
@@ -172,8 +85,6 @@ public abstract class AppEngBase implements AppEng {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
AEConfig.load(FabricLoader.getInstance().getConfigDirectory());
|
||||
|
||||
CreativeTab.init();
|
||||
FacadeCreativeTab.init();// This call has a side-effect (adding it to the creative screen)
|
||||
|
||||
@@ -182,15 +93,12 @@ public abstract class AppEngBase implements AppEng {
|
||||
|
||||
ToolItemHook.install();
|
||||
|
||||
Api.INSTANCE = new Api();
|
||||
registerBlockEntities();
|
||||
|
||||
registerScreenHandlerTypes();
|
||||
registerParticleTypes();
|
||||
registerRecipeSerializers();
|
||||
registerWorldGen();
|
||||
registerServerCommands();
|
||||
registerDimension();
|
||||
|
||||
setupInternalRegistries();
|
||||
|
||||
@@ -549,61 +457,6 @@ public abstract class AppEngBase implements AppEng {
|
||||
return type;
|
||||
}
|
||||
|
||||
private void registerWorldGen() {
|
||||
LibStructure.registerStructure(MeteoriteStructure.ID, MeteoriteStructure.INSTANCE,
|
||||
GenerationStep.Feature.TOP_LAYER_MODIFICATION, new StructureConfig(32, 8, 124895654),
|
||||
new MeteoriteStructure(DefaultFeatureConfig.CODEC).configure(DefaultFeatureConfig.INSTANCE));
|
||||
Registry.register(Registry.FEATURE, AppEng.makeId("charged_quartz_ore"), ChargedQuartzOreFeature.INSTANCE);
|
||||
|
||||
// add to all standard biomes
|
||||
// TODO: Wrong...
|
||||
BuiltinRegistries.BIOME.forEach(b -> {
|
||||
addMeteoriteWorldGen(b);
|
||||
addQuartzWorldGen(b);
|
||||
});
|
||||
}
|
||||
|
||||
private static void addMeteoriteWorldGen(Biome b) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (b.getCategory() == Biome.Category.THEEND || b.getCategory() == Biome.Category.NETHER) {
|
||||
return;
|
||||
}
|
||||
|
||||
BiomeModifier modifier = new BiomeModifier(b);
|
||||
modifier.addStructureFeature(MeteoriteStructure.INSTANCE.configure(FeatureConfig.DEFAULT));
|
||||
}
|
||||
|
||||
private static void addQuartzWorldGen(Biome b) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.CERTUS_QUARTZ_WORLD_GEN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BiomeModifier modifier = new BiomeModifier(b);
|
||||
|
||||
BlockState quartzOre = Api.instance().definitions().blocks().quartzOre().block().getDefaultState();
|
||||
modifier.addFeature(GenerationStep.Feature.UNDERGROUND_ORES,
|
||||
Feature.ORE
|
||||
.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, quartzOre,
|
||||
AEConfig.instance().getQuartzOresPerCluster()))
|
||||
.decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(12, 12, 72))).spreadHorizontally()
|
||||
.repeat(AEConfig.instance().getQuartzOresClusterAmount()));
|
||||
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CHARGED_CERTUS_ORE)) {
|
||||
|
||||
BlockState chargedQuartzOre = Api.instance().definitions().blocks().quartzOreCharged().block()
|
||||
.getDefaultState();
|
||||
modifier.addFeature(GenerationStep.Feature.UNDERGROUND_DECORATION,
|
||||
ChargedQuartzOreFeature.INSTANCE
|
||||
.configure(new ChargedQuartzOreConfig(quartzOre, chargedQuartzOre,
|
||||
AEConfig.instance().getSpawnChargedChance()))
|
||||
.decorate(Decorator.NOPE.configure(NopeDecoratorConfig.INSTANCE)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void registerServerCommands() {
|
||||
// The server commands need to know what the current minecraft server is.
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
|
||||
@@ -611,11 +464,4 @@ public abstract class AppEngBase implements AppEng {
|
||||
});
|
||||
}
|
||||
|
||||
private void registerDimension() {
|
||||
BuiltinRegistries.add(BuiltinRegistries.BIOME, SpatialStorageDimensionIds.BIOME_KEY.getValue(),
|
||||
SpatialStorageBiome.INSTANCE);
|
||||
Registry.register(Registry.CHUNK_GENERATOR, SpatialStorageDimensionIds.CHUNK_GENERATOR_ID,
|
||||
SpatialStorageChunkGenerator.CODEC);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
package appeng.core;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.decorator.Decorator;
|
||||
import net.minecraft.world.gen.decorator.NopeDecoratorConfig;
|
||||
import net.minecraft.world.gen.decorator.RangeDecoratorConfig;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.OreFeatureConfig;
|
||||
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.mixins.feature.ConfiguredFeaturesAccessor;
|
||||
import appeng.mixins.structure.ConfiguredStructureFeaturesAccessor;
|
||||
import appeng.mixins.structure.StructureFeatureAccessor;
|
||||
import appeng.spatial.SpatialStorageChunkGenerator;
|
||||
import appeng.spatial.SpatialStorageDimensionIds;
|
||||
import appeng.worldgen.BiomeModifier;
|
||||
import appeng.worldgen.ChargedQuartzOreConfig;
|
||||
import appeng.worldgen.ChargedQuartzOreFeature;
|
||||
import appeng.worldgen.meteorite.MeteoriteStructure;
|
||||
|
||||
/**
|
||||
* Hooks into the very early bootstrapping phase to register things before the
|
||||
* first dynamic registry manager is created.
|
||||
*/
|
||||
public final class AppEngBootstrap {
|
||||
|
||||
private static boolean initialized;
|
||||
|
||||
private AppEngBootstrap() {
|
||||
}
|
||||
|
||||
public synchronized static void initialize() {
|
||||
Preconditions.checkState(!initialized, "Already initialized!");
|
||||
initialized = true;
|
||||
|
||||
AEConfig.load(FabricLoader.getInstance().getConfigDirectory());
|
||||
Api.INSTANCE = new Api();
|
||||
|
||||
registerStructures();
|
||||
|
||||
ConfiguredFeature<?, ?> quartzOreFeature = registerQuartzOreFeature();
|
||||
ConfiguredFeature<?, ?> chargedQuartzOreFeature = registerChargedQuartzOreFeature();
|
||||
|
||||
// add to all standard biomes
|
||||
// TODO: This means we'll not add these things to newly created biomes
|
||||
BuiltinRegistries.BIOME.forEach(b -> {
|
||||
addMeteoriteWorldGen(b);
|
||||
addQuartzWorldGen(b, quartzOreFeature, chargedQuartzOreFeature);
|
||||
});
|
||||
|
||||
registerDimension();
|
||||
}
|
||||
|
||||
private static void registerStructures() {
|
||||
// Registering into the registry alone is INSUFFICIENT!
|
||||
// There's a bidirectional map in the Structure class itself primarily for the
|
||||
// purposes of NBT serialization
|
||||
StructureFeatureAccessor.register(MeteoriteStructure.ID.toString(), MeteoriteStructure.INSTANCE,
|
||||
GenerationStep.Feature.TOP_LAYER_MODIFICATION);
|
||||
|
||||
ConfiguredStructureFeaturesAccessor.register(MeteoriteStructure.ID.toString(),
|
||||
MeteoriteStructure.CONFIGURED_INSTANCE);
|
||||
}
|
||||
|
||||
private static void addMeteoriteWorldGen(Biome b) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.METEORITE_WORLD_GEN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (b.getCategory() == Biome.Category.THEEND || b.getCategory() == Biome.Category.NETHER) {
|
||||
return;
|
||||
}
|
||||
|
||||
BiomeModifier modifier = new BiomeModifier(b);
|
||||
modifier.addStructureFeature(MeteoriteStructure.CONFIGURED_INSTANCE);
|
||||
}
|
||||
|
||||
private static void addQuartzWorldGen(Biome b, ConfiguredFeature<?, ?> quartzOre,
|
||||
ConfiguredFeature<?, ?> chargedQuartz) {
|
||||
if (!AEConfig.instance().isFeatureEnabled(AEFeature.CERTUS_QUARTZ_WORLD_GEN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BiomeModifier modifier = new BiomeModifier(b);
|
||||
|
||||
modifier.addFeature(GenerationStep.Feature.UNDERGROUND_ORES, quartzOre);
|
||||
|
||||
if (AEConfig.instance().isFeatureEnabled(AEFeature.CHARGED_CERTUS_ORE)) {
|
||||
modifier.addFeature(GenerationStep.Feature.UNDERGROUND_DECORATION, chargedQuartz);
|
||||
}
|
||||
}
|
||||
|
||||
private static ConfiguredFeature<?, ?> registerQuartzOreFeature() {
|
||||
// Tell Minecraft about our configured quartz ore feature
|
||||
BlockState quartzOreState = Api.instance().definitions().blocks().quartzOre().block().getDefaultState();
|
||||
return ConfiguredFeaturesAccessor.register(AppEng.makeId("quartz_ore").toString(),
|
||||
Feature.ORE
|
||||
.configure(new OreFeatureConfig(OreFeatureConfig.Rules.BASE_STONE_OVERWORLD, quartzOreState,
|
||||
AEConfig.instance().getQuartzOresPerCluster()))
|
||||
.decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(12, 12, 72))).spreadHorizontally()
|
||||
.repeat(AEConfig.instance().getQuartzOresClusterAmount()));
|
||||
}
|
||||
|
||||
private static ConfiguredFeature<?, ?> registerChargedQuartzOreFeature() {
|
||||
// Tell Minecraft about our configured charged quartz ore feature
|
||||
Registry.register(Registry.FEATURE, AppEng.makeId("charged_quartz_ore"), ChargedQuartzOreFeature.INSTANCE);
|
||||
|
||||
BlockState quartzOreState = Api.instance().definitions().blocks().quartzOre().block().getDefaultState();
|
||||
BlockState chargedQuartzOreState = Api.instance().definitions().blocks().quartzOreCharged().block()
|
||||
.getDefaultState();
|
||||
return ConfiguredFeaturesAccessor.register(AppEng.makeId("charged_quartz_ore").toString(),
|
||||
ChargedQuartzOreFeature.INSTANCE
|
||||
.configure(new ChargedQuartzOreConfig(quartzOreState, chargedQuartzOreState,
|
||||
AEConfig.instance().getSpawnChargedChance()))
|
||||
.decorate(Decorator.NOPE.configure(NopeDecoratorConfig.INSTANCE)));
|
||||
}
|
||||
|
||||
private static void registerDimension() {
|
||||
Registry.register(Registry.CHUNK_GENERATOR, SpatialStorageDimensionIds.CHUNK_GENERATOR_ID,
|
||||
SpatialStorageChunkGenerator.CODEC);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.bootstrap.FeatureFactory;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.entity.ChargedQuartzEntity;
|
||||
import appeng.entity.SingularityEntity;
|
||||
import appeng.items.materials.MaterialItem;
|
||||
@@ -191,12 +190,6 @@ public final class ApiMaterials implements IMaterials {
|
||||
IItemDefinition def = registry.item(mat.getId(), props -> new MaterialItem(props, mat))
|
||||
.features(mat.getFeature().toArray(new AEFeature[0])).build();
|
||||
|
||||
boolean enabled = true;
|
||||
|
||||
for (final AEFeature f : mat.getFeature()) {
|
||||
enabled = enabled && AEConfig.instance().isFeatureEnabled(f);
|
||||
}
|
||||
|
||||
mat.setItemInstance(def.item());
|
||||
mat.markReady();
|
||||
return def;
|
||||
|
||||
@@ -26,10 +26,6 @@ import javax.annotation.Nonnull;
|
||||
* @since rv3 30.05.2015
|
||||
*/
|
||||
public interface IWorldData {
|
||||
void onServerStopping();
|
||||
|
||||
void onServerStoppped();
|
||||
|
||||
@Nonnull
|
||||
IWorldGridStorageData storageData();
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class WorldData implements IWorldData {
|
||||
* Is null while no MinecraftServer exists.
|
||||
*/
|
||||
@Nullable
|
||||
private static IWorldData instance;
|
||||
private static WorldData instance;
|
||||
|
||||
@Nullable
|
||||
private static MinecraftServer server;
|
||||
@@ -113,16 +113,17 @@ public final class WorldData implements IWorldData {
|
||||
WorldData.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServerStopping() {
|
||||
compassData.service().kill();
|
||||
public static void onServerStopping(MinecraftServer server) {
|
||||
if (WorldData.server == server && instance != null) {
|
||||
instance.compassData.service().kill();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServerStoppped() {
|
||||
Preconditions.checkNotNull(server);
|
||||
instance = null;
|
||||
WorldData.server = null;
|
||||
public static void onServerStoppped(MinecraftServer server) {
|
||||
if (WorldData.server == server) {
|
||||
instance = null;
|
||||
WorldData.server = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package appeng.mixins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.GenerationSettings;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
@Mixin(Biome.class)
|
||||
public interface BiomeAccessor {
|
||||
|
||||
@Accessor
|
||||
Map<Integer, List<StructureFeature<?>>> getField_26634();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package appeng.mixins;
|
||||
|
||||
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.CallbackInfo;
|
||||
|
||||
import net.minecraft.Bootstrap;
|
||||
|
||||
import appeng.core.AppEngBootstrap;
|
||||
|
||||
@Mixin(Bootstrap.class)
|
||||
public class BootstrapMixin {
|
||||
|
||||
@Inject(method = "initialize", at = @At(value = "INVOKE", target = "Lnet/minecraft/Bootstrap;setOutputStreams()V", shift = At.Shift.AFTER), require = 1, allow = 1)
|
||||
private static void afterInitialize(CallbackInfo ci) {
|
||||
AppEngBootstrap.initialize();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package appeng.mixins;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.server.WorldGenerationProgressListener;
|
||||
import net.minecraft.server.world.ThreadedAnvilChunkStorage;
|
||||
|
||||
@Mixin(ThreadedAnvilChunkStorage.class)
|
||||
public interface ThreadedAnvilChunkStorageAccessor {
|
||||
|
||||
@Accessor
|
||||
WorldGenerationProgressListener getWorldGenerationProgressListener();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package appeng.mixins.feature;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeatures;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
|
||||
@Mixin(ConfiguredFeatures.class)
|
||||
public interface ConfiguredFeaturesAccessor {
|
||||
|
||||
@Invoker("register")
|
||||
static <FC extends FeatureConfig> ConfiguredFeature<FC, ?> register(String id,
|
||||
ConfiguredFeature<FC, ?> configuredFeature) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.mixins.spatial;
|
||||
|
||||
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.CallbackInfo;
|
||||
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
|
||||
import appeng.spatial.SpatialStorageBiome;
|
||||
import appeng.spatial.SpatialStorageDimensionIds;
|
||||
|
||||
/**
|
||||
* This only needs to be here because the server-side will create a dynamic
|
||||
* registry manager long before our mod is initialized.
|
||||
*/
|
||||
@Mixin(Biomes.class)
|
||||
public class BiomesMixin {
|
||||
|
||||
@Inject(method = "<clinit>", at = @At("TAIL"))
|
||||
private static void registerBiomes(CallbackInfo ci) {
|
||||
BuiltinRegistries.add(BuiltinRegistries.BIOME, SpatialStorageDimensionIds.BIOME_KEY.getValue(),
|
||||
SpatialStorageBiome.INSTANCE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package appeng.mixins.structure;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
/**
|
||||
* Allows access to the copy of _all_ structures that is maintained within each
|
||||
* instance of {@link Biome}, in order to add our new structure to it. Note that
|
||||
* this does not mean the structure will start _generating_ in this biome, it
|
||||
* will only continue to generate if an adjacent biome has started the structure
|
||||
* and it extends into this one.
|
||||
*/
|
||||
@Mixin(Biome.class)
|
||||
public interface BiomeAccessor {
|
||||
|
||||
@Accessor
|
||||
Map<Integer, List<StructureFeature<?>>> getField_26634();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package appeng.mixins.structure;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeatures;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
@Mixin(ConfiguredStructureFeatures.class)
|
||||
public interface ConfiguredStructureFeaturesAccessor {
|
||||
|
||||
@Invoker("register")
|
||||
static <FC extends FeatureConfig, F extends StructureFeature<FC>> ConfiguredStructureFeature<FC, F> register(
|
||||
String id, ConfiguredStructureFeature<FC, F> configuredStructureFeature) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
}
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
package appeng.mixins;
|
||||
package appeng.mixins.structure;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
@@ -10,6 +10,9 @@ import net.minecraft.world.biome.GenerationSettings;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
|
||||
|
||||
/**
|
||||
* Allows the settings in a Biome's generation settings to be modified.
|
||||
*/
|
||||
@Mixin(GenerationSettings.class)
|
||||
public interface GenerationSettingsAccessor {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.mixins.structure;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
@Mixin(StructureFeature.class)
|
||||
public interface StructureFeatureAccessor {
|
||||
|
||||
@Invoker("register")
|
||||
static <F extends StructureFeature<?>> F register(String id, F structureFeature, GenerationStep.Feature step) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package appeng.mixins.structure;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
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;
|
||||
|
||||
import net.minecraft.world.gen.chunk.StructureConfig;
|
||||
import net.minecraft.world.gen.chunk.StructuresConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
import appeng.worldgen.meteorite.MeteoriteStructure;
|
||||
|
||||
/**
|
||||
* This Mixin will add the structure placement configuration for the meteorite
|
||||
* structure to the static final immutable map that contains them. There is
|
||||
* currently no Fabric API for this, and registering them during the registry
|
||||
* event is already too late.
|
||||
* <p>
|
||||
* If this is not done, Meteorites spawn every chunk, since that is the default
|
||||
* for missing entries.
|
||||
*/
|
||||
@Mixin(StructuresConfig.class)
|
||||
public class StructuresConfigMixin {
|
||||
|
||||
@Shadow
|
||||
@Mutable
|
||||
private static ImmutableMap<StructureFeature<?>, StructureConfig> DEFAULT_STRUCTURES;
|
||||
|
||||
@Inject(method = "<clinit>", at = @At("TAIL"))
|
||||
private static void addMeteoriteConfig(CallbackInfo ci) {
|
||||
DEFAULT_STRUCTURES = ImmutableMap.<StructureFeature<?>, StructureConfig>builder().putAll(DEFAULT_STRUCTURES)
|
||||
.put(MeteoriteStructure.INSTANCE, MeteoriteStructure.PLACEMENT_CONFIG).build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,8 +32,8 @@ public final class AppEngServer extends AppEngBase {
|
||||
this.tickHandler = new TickHandler();
|
||||
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(this::onServerStarting);
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(s -> onServerStopping());
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register(s -> onServerStopped());
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(WorldData::onServerStopping);
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register(WorldData::onServerStoppped);
|
||||
}
|
||||
|
||||
private void onServerStarting(MinecraftServer server) {
|
||||
@@ -43,14 +43,6 @@ public final class AppEngServer extends AppEngBase {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
private void onServerStopping() {
|
||||
WorldData.instance().onServerStopping();
|
||||
}
|
||||
|
||||
private void onServerStopped() {
|
||||
WorldData.instance().onServerStoppped();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<? extends PlayerEntity> getPlayers() {
|
||||
return PlayerStream.all(server);
|
||||
|
||||
@@ -13,8 +13,8 @@ import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
import appeng.mixins.BiomeAccessor;
|
||||
import appeng.mixins.GenerationSettingsAccessor;
|
||||
import appeng.mixins.structure.BiomeAccessor;
|
||||
import appeng.mixins.structure.GenerationSettingsAccessor;
|
||||
|
||||
public final class BiomeModifier {
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.gen.ChunkRandom;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.StructureConfig;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
|
||||
@@ -15,11 +17,19 @@ import appeng.core.AppEng;
|
||||
|
||||
public class MeteoriteStructure extends StructureFeature<DefaultFeatureConfig> {
|
||||
|
||||
/**
|
||||
* Configures how this structure will be placed throughout the world.
|
||||
*/
|
||||
public static final StructureConfig PLACEMENT_CONFIG = new StructureConfig(32, 8, 124895654);
|
||||
|
||||
public static final Identifier ID = AppEng.makeId("meteorite");
|
||||
|
||||
public static final StructureFeature<DefaultFeatureConfig> INSTANCE = new MeteoriteStructure(
|
||||
DefaultFeatureConfig.CODEC);
|
||||
|
||||
public static final ConfiguredStructureFeature<DefaultFeatureConfig, ? extends StructureFeature<DefaultFeatureConfig>> CONFIGURED_INSTANCE = INSTANCE
|
||||
.configure(DefaultFeatureConfig.INSTANCE);
|
||||
|
||||
public MeteoriteStructure(Codec<DefaultFeatureConfig> configCodec) {
|
||||
super(configCodec);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user