mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-15 04:41:37 +08:00
[Forge] Update to 1.16.2
haha bad mapping system go func_318237_brrrrrrrr
This commit is contained in:
parent
d2239ef7de
commit
5cf6750f8c
@ -12,12 +12,12 @@
|
||||
applyPlatformAndCoreConfiguration()
|
||||
applyShadowConfiguration()
|
||||
|
||||
val minecraftVersion = "1.16.1"
|
||||
val minecraftVersion = "1.16.2"
|
||||
val nextMajorMinecraftVersion: String = minecraftVersion.split('.').let { (useless, major) ->
|
||||
"$useless.${major.toInt() + 1}"
|
||||
}
|
||||
val mappingsMinecraftVersion = "1.16"
|
||||
val forgeVersion = "32.0.92"
|
||||
val forgeVersion = "33.0.3"
|
||||
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
|
@ -51,11 +51,14 @@
|
||||
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.world.biome.Biome;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
@ -72,11 +75,19 @@ public static World adapt(net.minecraft.world.World world) {
|
||||
}
|
||||
|
||||
public static Biome adapt(BiomeType biomeType) {
|
||||
return ForgeRegistries.BIOMES.getValue(new ResourceLocation(biomeType.getId()));
|
||||
return ServerLifecycleHooks.getCurrentServer()
|
||||
.func_244267_aX()
|
||||
.func_243612_b(Registry.field_239720_u_)
|
||||
.getOrDefault(new ResourceLocation(biomeType.getId()));
|
||||
}
|
||||
|
||||
public static BiomeType adapt(Biome biome) {
|
||||
return BiomeTypes.get(biome.getRegistryName().toString());
|
||||
ResourceLocation id = ServerLifecycleHooks.getCurrentServer()
|
||||
.func_244267_aX()
|
||||
.func_243612_b(Registry.field_239720_u_)
|
||||
.getKey(biome);
|
||||
Objects.requireNonNull(id, "biome is not registered");
|
||||
return BiomeTypes.get(id.toString());
|
||||
}
|
||||
|
||||
public static Vector3 adapt(Vector3d vector) {
|
||||
@ -162,7 +173,7 @@ public static Map<Property<?>, Object> adaptProperties(BlockType block, Map<net.
|
||||
return props;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private static net.minecraft.block.BlockState applyProperties(StateContainer<Block, net.minecraft.block.BlockState> stateContainer, net.minecraft.block.BlockState newState, Map<Property<?>, Object> states) {
|
||||
for (Map.Entry<Property<?>, Object> state : states.entrySet()) {
|
||||
net.minecraft.state.Property property = stateContainer.getProperty(state.getKey().getName());
|
||||
|
@ -24,7 +24,8 @@
|
||||
import com.sk89q.worldedit.world.biome.BiomeData;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
/**
|
||||
* Provides access to biome data in Forge.
|
||||
@ -33,13 +34,13 @@ class ForgeBiomeRegistry implements BiomeRegistry {
|
||||
|
||||
@Override
|
||||
public Component getRichName(BiomeType biomeType) {
|
||||
return TranslatableComponent.of(ForgeAdapter.adapt(biomeType).getTranslationKey());
|
||||
return TranslatableComponent.of(Util.makeTranslationKey("biome", new ResourceLocation(biomeType.getId())));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public BiomeData getData(BiomeType biome) {
|
||||
return new ForgeBiomeData(ForgeAdapter.adapt(biome));
|
||||
return new ForgeBiomeData(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,21 +48,21 @@ public BiomeData getData(BiomeType biome) {
|
||||
*/
|
||||
@Deprecated
|
||||
private static class ForgeBiomeData implements BiomeData {
|
||||
private final Biome biome;
|
||||
private final BiomeType biome;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param biome the base biome
|
||||
*/
|
||||
private ForgeBiomeData(Biome biome) {
|
||||
private ForgeBiomeData(BiomeType biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public String getName() {
|
||||
return biome.getDisplayName().getString();
|
||||
return biome.getId();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.mojang.serialization.Codec;
|
||||
@ -73,24 +75,25 @@
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.concurrent.ThreadTaskExecutor;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.DynamicRegistries;
|
||||
import net.minecraft.util.registry.WorldSettingsImport;
|
||||
import net.minecraft.world.Dimension;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeContainer;
|
||||
import net.minecraft.world.biome.ColumnFuzzedBiomeMagnifier;
|
||||
import net.minecraft.world.biome.DefaultBiomeFeatures;
|
||||
import net.minecraft.world.biome.IBiomeMagnifier;
|
||||
import net.minecraft.world.chunk.AbstractChunkProvider;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.HugeFungusConfig;
|
||||
import net.minecraft.world.gen.feature.NoFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.Features;
|
||||
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
|
||||
import net.minecraft.world.server.ServerChunkProvider;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
@ -108,13 +111,13 @@
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -127,6 +130,13 @@ public class ForgeWorld extends AbstractWorld {
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
private static ResourceLocation getDimensionRegistryKey(World world) {
|
||||
return Objects.requireNonNull(world.getServer(), "server cannot be null")
|
||||
.func_244267_aX()
|
||||
.func_230520_a_()
|
||||
.getKey(world.func_230315_m_());
|
||||
}
|
||||
|
||||
private final WeakReference<World> worldRef;
|
||||
private final ForgeWorldNativeAccess nativeAccess;
|
||||
|
||||
@ -163,7 +173,7 @@ public String getName() {
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return getName() + "_" + getWorld().func_234922_V_().func_240901_a_();
|
||||
return getName() + "_" + getDimensionRegistryKey(getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -320,16 +330,25 @@ private void doRegen(Region region, Extent extent, RegenOptions options) throws
|
||||
(ServerWorldInfo) originalWorld.getServer().func_240793_aU_();
|
||||
DimensionGeneratorSettings originalOpts = levelProperties.field_237343_c_;
|
||||
|
||||
WorldSettingsImport<INBT> nbtRegOps = WorldSettingsImport.func_244335_a(
|
||||
NBTDynamicOps.INSTANCE,
|
||||
originalWorld.getServer().getDataPackRegistries().func_240970_h_(),
|
||||
(DynamicRegistries.Impl) originalWorld.getServer().func_244267_aX()
|
||||
);
|
||||
Codec<DimensionGeneratorSettings> dimCodec = DimensionGeneratorSettings.field_236201_a_;
|
||||
DimensionGeneratorSettings newOpts = dimCodec
|
||||
.encodeStart(NBTDynamicOps.INSTANCE, originalOpts)
|
||||
.encodeStart(nbtRegOps, originalOpts)
|
||||
.flatMap(tag ->
|
||||
dimCodec.parse(
|
||||
recursivelySetSeed(new Dynamic<>(NBTDynamicOps.INSTANCE, tag), seed, new HashSet<>())
|
||||
recursivelySetSeed(new Dynamic<>(nbtRegOps, tag), seed, new HashSet<>())
|
||||
)
|
||||
)
|
||||
.result()
|
||||
.orElseThrow(() -> new IllegalStateException("Unable to map GeneratorOptions"));
|
||||
.get().map(
|
||||
l -> l,
|
||||
error -> {
|
||||
throw new IllegalStateException("Unable to map GeneratorOptions: " + error.message());
|
||||
}
|
||||
);
|
||||
|
||||
levelProperties.field_237343_c_ = newOpts;
|
||||
RegistryKey<World> worldRegKey = originalWorld.func_234923_W_();
|
||||
@ -340,7 +359,6 @@ private void doRegen(Region region, Extent extent, RegenOptions options) throws
|
||||
originalWorld.getServer(), Util.getServerExecutor(), session,
|
||||
((IServerWorldInfo) originalWorld.getWorldInfo()),
|
||||
worldRegKey,
|
||||
originalWorld.func_234922_V_(),
|
||||
originalWorld.func_230315_m_(),
|
||||
new WorldEditGenListener(),
|
||||
dimGenOpts.func_236064_c_(),
|
||||
@ -439,25 +457,25 @@ private List<CompletableFuture<IChunk>> submitChunkLoadTasks(Region region, Serv
|
||||
@Nullable
|
||||
private static ConfiguredFeature<?, ?> createTreeFeatureGenerator(TreeType type) {
|
||||
switch (type) {
|
||||
case TREE: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.OAK_TREE_CONFIG);
|
||||
case BIG_TREE: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.FANCY_TREE_CONFIG);
|
||||
case REDWOOD: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.SPRUCE_TREE_CONFIG);
|
||||
case TALL_REDWOOD: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.MEGA_SPRUCE_TREE_CONFIG);
|
||||
case MEGA_REDWOOD: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.MEGA_PINE_TREE_CONFIG);
|
||||
case BIRCH: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.BIRCH_TREE_CONFIG);
|
||||
case JUNGLE: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.MEGA_JUNGLE_TREE_CONFIG);
|
||||
case SMALL_JUNGLE: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.JUNGLE_TREE_CONFIG);
|
||||
case SHORT_JUNGLE: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.JUNGLE_SAPLING_TREE_CONFIG);
|
||||
case JUNGLE_BUSH: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.JUNGLE_GROUND_BUSH_CONFIG);
|
||||
case SWAMP: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.SWAMP_TREE_CONFIG);
|
||||
case ACACIA: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.ACACIA_TREE_CONFIG);
|
||||
case DARK_OAK: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.DARK_OAK_TREE_CONFIG);
|
||||
case TALL_BIRCH: return Feature.field_236291_c_.withConfiguration(DefaultBiomeFeatures.field_230130_i_);
|
||||
case RED_MUSHROOM: return Feature.HUGE_RED_MUSHROOM.withConfiguration(DefaultBiomeFeatures.BIG_RED_MUSHROOM);
|
||||
case BROWN_MUSHROOM: return Feature.HUGE_BROWN_MUSHROOM.withConfiguration(DefaultBiomeFeatures.BIG_BROWN_MUSHROOM);
|
||||
case WARPED_FUNGUS: return Feature.field_236281_L_.withConfiguration(HugeFungusConfig.field_236299_b_);
|
||||
case CRIMSON_FUNGUS: return Feature.field_236281_L_.withConfiguration(HugeFungusConfig.field_236301_d_);
|
||||
case CHORUS_PLANT: return Feature.CHORUS_PLANT.withConfiguration(NoFeatureConfig.field_236559_b_);
|
||||
case TREE: return Features.field_243862_bH;
|
||||
case BIG_TREE: return Features.field_243869_bO;
|
||||
case REDWOOD: return Features.field_243866_bL;
|
||||
case TALL_REDWOOD: return Features.field_243872_bR;
|
||||
case MEGA_REDWOOD: return Features.field_243873_bS;
|
||||
case BIRCH: return Features.field_243864_bJ;
|
||||
case JUNGLE: return Features.field_243871_bQ;
|
||||
case SMALL_JUNGLE: return Features.field_243868_bN;
|
||||
case SHORT_JUNGLE: return Features.field_243870_bP;
|
||||
case JUNGLE_BUSH: return Features.field_243876_bV;
|
||||
case SWAMP: return Features.field_243875_bU;
|
||||
case ACACIA: return Features.field_243865_bK;
|
||||
case DARK_OAK: return Features.field_243863_bI;
|
||||
case TALL_BIRCH: return Features.field_243940_cw;
|
||||
case RED_MUSHROOM: return Features.field_243860_bF;
|
||||
case BROWN_MUSHROOM: return Features.field_243861_bG;
|
||||
case WARPED_FUNGUS: return Features.field_243858_bD;
|
||||
case CRIMSON_FUNGUS: return Features.field_243856_bB;
|
||||
case CHORUS_PLANT: return Features.field_243944_d;
|
||||
case RANDOM: return createTreeFeatureGenerator(TreeType.values()[ThreadLocalRandom.current().nextInt(TreeType.values().length)]);
|
||||
default:
|
||||
return null;
|
||||
@ -469,9 +487,8 @@ public boolean generateTree(TreeType type, EditSession editSession, BlockVector3
|
||||
ConfiguredFeature<?, ?> generator = createTreeFeatureGenerator(type);
|
||||
ServerWorld world = (ServerWorld) getWorld();
|
||||
ServerChunkProvider chunkManager = world.getChunkProvider();
|
||||
return generator != null && generator.func_236265_a_(
|
||||
world, world.func_241112_a_(), chunkManager.getChunkGenerator(), random,
|
||||
ForgeAdapter.toBlockPos(position)
|
||||
return generator != null && generator.func_242765_a(
|
||||
world, chunkManager.getChunkGenerator(), random, ForgeAdapter.toBlockPos(position)
|
||||
);
|
||||
}
|
||||
|
||||
@ -617,11 +634,19 @@ public boolean equals(Object o) {
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
final World world = getWorld();
|
||||
if (!(world instanceof ServerWorld)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return ((ServerWorld) world).getEntities().filter(e -> region.contains(ForgeAdapter.adapt(e.func_233580_cy_())))
|
||||
.map(ForgeEntity::new).collect(Collectors.toList());
|
||||
AxisAlignedBB box = new AxisAlignedBB(
|
||||
ForgeAdapter.toBlockPos(region.getMinimumPoint()),
|
||||
ForgeAdapter.toBlockPos(region.getMaximumPoint())
|
||||
);
|
||||
List<net.minecraft.entity.Entity> nmsEntities = world.getEntitiesWithinAABB(
|
||||
(EntityType<net.minecraft.entity.Entity>) null,
|
||||
box,
|
||||
e -> region.contains(ForgeAdapter.adapt(e.func_233580_cy_()))
|
||||
);
|
||||
return ImmutableList.copyOf(Lists.transform(
|
||||
nmsEntities,
|
||||
ForgeEntity::new
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -630,7 +655,10 @@ public List<? extends Entity> getEntities() {
|
||||
if (!(world instanceof ServerWorld)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return ((ServerWorld) world).getEntities().map(ForgeEntity::new).collect(Collectors.toList());
|
||||
return ImmutableList.copyOf(Iterables.transform(
|
||||
((ServerWorld) world).func_241136_z_(),
|
||||
ForgeEntity::new
|
||||
));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -39,10 +39,12 @@
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.CommandEvent;
|
||||
@ -67,7 +69,6 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Files;
|
||||
@ -147,7 +148,7 @@ private void setupPlatform() {
|
||||
// }
|
||||
}
|
||||
|
||||
private void setupRegistries() {
|
||||
private void setupRegistries(MinecraftServer server) {
|
||||
// Blocks
|
||||
for (ResourceLocation name : ForgeRegistries.BLOCKS.getKeys()) {
|
||||
if (BlockType.REGISTRY.get(name.toString()) == null) {
|
||||
@ -168,7 +169,7 @@ private void setupRegistries() {
|
||||
}
|
||||
}
|
||||
// Biomes
|
||||
for (ResourceLocation name : ForgeRegistries.BIOMES.getKeys()) {
|
||||
for (ResourceLocation name : server.func_244267_aX().func_243612_b(Registry.field_239720_u_).keySet()) {
|
||||
if (BiomeType.REGISTRY.get(name.toString()) == null) {
|
||||
BiomeType.REGISTRY.register(name.toString(), new BiomeType(name.toString()));
|
||||
}
|
||||
@ -204,7 +205,7 @@ public void serverStopping(FMLServerStoppingEvent event) {
|
||||
@SubscribeEvent
|
||||
public void serverStarted(FMLServerStartedEvent event) {
|
||||
setupPlatform();
|
||||
setupRegistries();
|
||||
setupRegistries(event.getServer());
|
||||
|
||||
config = new ForgeConfiguration(this);
|
||||
config.load();
|
||||
|
Loading…
Reference in New Issue
Block a user