[Forge, Fabric] Update to latest 1.15.2

Some bits of the Fabric 1.15.2 update were moved into common code.

This is NOT ready yet, tree features still need to be updated. Mappings
are comitted, just waiting for them to come out.
This commit is contained in:
Octavia Togami 2020-01-31 14:03:10 -08:00
parent 68d48148d3
commit 0324196b5d
No known key found for this signature in database
GPG Key ID: CC364524D1983C99
14 changed files with 126 additions and 84 deletions

View File

@ -50,7 +50,7 @@
implementation("net.ltgt.apt-idea:net.ltgt.apt-idea.gradle.plugin:0.21")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7")
implementation("gradle.plugin.org.spongepowered:spongegradle:0.9.0")
implementation("net.minecraftforge.gradle:ForgeGradle:3.0.143")
implementation("net.minecraftforge.gradle:ForgeGradle:3.0.159")
implementation("net.fabricmc:fabric-loom:$loomVersion")
implementation("net.fabricmc:sponge-mixin:$mixinVersion")
implementation("gradle.plugin.com.mendhak.gradlecrowdin:plugin:0.1.0")

View File

@ -3,5 +3,5 @@ version=7.1.1-SNAPSHOT
org.gradle.jvmargs=-Xmx1G
loom.version=0.2.6-20191213.183106-50
loom.version=0.2.6-20200124.104118-60
mixin.version=0.8+build.17

View File

@ -0,0 +1,51 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.internal.util;
import net.royawesome.jlibnoise.MathHelper;
public class BiomeMath {
// From BiomeArray / BiomeContainer
public static final int HORIZONTAL_SECTION_COUNT = (int) Math.round(Math.log(16.0D) / Math.log(2.0D)) - 2;
public static final int VERTICAL_SECTION_COUNT = (int)Math.round(Math.log(256.0D) / Math.log(2.0D)) - 2;
public static final int HORIZONTAL_BIT_MASK = (1 << HORIZONTAL_SECTION_COUNT) - 1;
public static final int VERTICAL_BIT_MASK = (1 << VERTICAL_SECTION_COUNT) - 1;
private BiomeMath() {
}
/**
* Compute the index into the MC biome array.
*
* @param x the block x coordinate
* @param y the block y coordinate
* @param z the block z coordinate
* @return the index into the standard MC biome array
*/
public static int computeBiomeIndex(int x, int y, int z) {
int l = x & HORIZONTAL_BIT_MASK;
int m = MathHelper.clamp(y, 0, VERTICAL_BIT_MASK);
int n = z & HORIZONTAL_BIT_MASK;
return m << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT
| n << HORIZONTAL_SECTION_COUNT
| l;
}
}

View File

@ -7,8 +7,8 @@
apply(plugin = "fabric-loom")
val minecraftVersion = "1.15.2"
val yarnMappings = "1.15.2+build.7"
val loaderVersion = "0.7.6+build.179"
val yarnMappings = "1.15.2+build.8:v2"
val loaderVersion = "0.7.6+build.180"
configurations.all {
resolutionStrategy {

View File

@ -33,6 +33,7 @@
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.util.BiomeMath;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
@ -259,7 +260,7 @@ public boolean setBiome(BlockVector2 position, BiomeType biome) {
}
MutableBiomeArray biomeArray = MutableBiomeArray.inject(chunk.getBiomeArray());
// Temporary, while biome setting is 2D only
for (int i = 0; i < BiomeArray.VERTICAL_BIT_MASK; i++) {
for (int i = 0; i < BiomeMath.VERTICAL_BIT_MASK; i++) {
biomeArray.setBiome(position.getX(), i, position.getZ(), FabricAdapter.adapt(biome));
}
chunk.setShouldSave(true);

View File

@ -20,7 +20,7 @@
package com.sk89q.worldedit.fabric.mixin;
import com.sk89q.worldedit.fabric.MutableBiomeArray;
import net.minecraft.util.math.MathHelper;
import com.sk89q.worldedit.internal.util.BiomeMath;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeArray;
import org.spongepowered.asm.mixin.Mixin;
@ -28,20 +28,12 @@
@Mixin(BiomeArray.class)
public abstract class MixinBiomeArray implements MutableBiomeArray {
// From BiomeArray
private static final int HORIZONTAL_SECTION_COUNT = (int) Math.round(Math.log(16.0D) / Math.log(2.0D)) - 2;
@Shadow
private Biome[] data;
@Override
public void setBiome(int x, int y, int z, Biome biome) {
int l = x & BiomeArray.HORIZONTAL_BIT_MASK;
int m = MathHelper.clamp(y, 0, BiomeArray.VERTICAL_BIT_MASK);
int n = z & BiomeArray.HORIZONTAL_BIT_MASK;
this.data[
m << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT
| n << HORIZONTAL_SECTION_COUNT
| l] = biome;
this.data[BiomeMath.computeBiomeIndex(x, y, z)] = biome;
}
}

View File

@ -11,9 +11,9 @@
applyPlatformAndCoreConfiguration()
applyShadowConfiguration()
val minecraftVersion = "1.14.4"
val mappingsMinecraftVersion = "1.14.3"
val forgeVersion = "28.1.0"
val minecraftVersion = "1.15.2"
val mappingsMinecraftVersion = "1.15.1"
val forgeVersion = "31.0.14"
configurations.all {
resolutionStrategy {
@ -31,7 +31,7 @@
configure<UserDevExtension> {
mappings(mapOf(
"channel" to "snapshot",
"version" to "20190913-$mappingsMinecraftVersion"
"version" to "20200131-$mappingsMinecraftVersion"
))
accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg"))

View File

@ -167,7 +167,7 @@ private String fixItemType(String key, int srcVer) {
}
private static String fixName(String key, int srcVer, TypeReference type) {
return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, new StringNBT(key)), srcVer, DATA_VERSION)
return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, StringNBT.valueOf(key)), srcVer, DATA_VERSION)
.asString().orElse(key);
}
@ -639,17 +639,17 @@ public CompoundNBT convert(CompoundNBT cmp) {
if (!cmp.contains("HandDropChances", 10)) {
nbttaglist2 = new ListNBT();
nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(0)));
nbttaglist2.add(new FloatNBT(0.0F));
nbttaglist2.add(FloatNBT.valueOf(nbttaglist1.getFloat(0)));
nbttaglist2.add(FloatNBT.valueOf(0.0F));
cmp.put("HandDropChances", nbttaglist2);
}
if (!cmp.contains("ArmorDropChances", 10)) {
nbttaglist2 = new ListNBT();
nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(1)));
nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(2)));
nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(3)));
nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(4)));
nbttaglist2.add(FloatNBT.valueOf(nbttaglist1.getFloat(1)));
nbttaglist2.add(FloatNBT.valueOf(nbttaglist1.getFloat(2)));
nbttaglist2.add(FloatNBT.valueOf(nbttaglist1.getFloat(3)));
nbttaglist2.add(FloatNBT.valueOf(nbttaglist1.getFloat(4)));
cmp.put("ArmorDropChances", nbttaglist2);
}
@ -1874,7 +1874,7 @@ public CompoundNBT convert(CompoundNBT cmp) {
object = new StringTextComponent("");
}
nbttaglist.set(i, new StringNBT(ITextComponent.Serializer.toJson((ITextComponent) object)));
nbttaglist.set(i, StringNBT.valueOf(ITextComponent.Serializer.toJson((ITextComponent) object)));
}
nbttagcompound1.put("pages", nbttaglist);

View File

@ -66,7 +66,7 @@ public BaseEntity getState() {
public Location getLocation() {
net.minecraft.entity.Entity entity = entityRef.get();
if (entity != null) {
Vector3 position = Vector3.at(entity.posX, entity.posY, entity.posZ);
Vector3 position = Vector3.at(entity.getPosX(), entity.getPosY(), entity.getPosZ());
float yaw = entity.rotationYaw;
float pitch = entity.rotationPitch;

View File

@ -95,7 +95,7 @@ public BaseEntity getState() {
@Override
public Location getLocation() {
Vector3 position = Vector3.at(this.player.posX, this.player.posY, this.player.posZ);
Vector3 position = Vector3.at(this.player.getPosX(), this.player.getPosY(), this.player.getPosZ());
return new Location(
ForgeWorldEdit.inst.getWorld(this.player.world),
position,

View File

@ -33,6 +33,7 @@
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.util.BiomeMath;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
@ -66,29 +67,24 @@
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeContainer;
import net.minecraft.world.biome.DefaultBiomeFeatures;
import net.minecraft.world.chunk.AbstractChunkProvider;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.chunk.listener.IChunkStatusListener;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.feature.BigBrownMushroomFeature;
import net.minecraft.world.gen.feature.BigMushroomFeatureConfig;
import net.minecraft.world.gen.feature.BigRedMushroomFeature;
import net.minecraft.world.gen.feature.BigTreeFeature;
import net.minecraft.world.gen.feature.BirchTreeFeature;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.DarkOakTreeFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraft.world.gen.feature.JungleTreeFeature;
import net.minecraft.world.gen.feature.MegaJungleFeature;
import net.minecraft.world.gen.feature.MegaPineTree;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import net.minecraft.world.gen.feature.PointyTaigaTreeFeature;
import net.minecraft.world.gen.feature.SavannaTreeFeature;
import net.minecraft.world.gen.feature.ShrubFeature;
import net.minecraft.world.gen.feature.SwampTreeFeature;
import net.minecraft.world.gen.feature.TallTaigaTreeFeature;
import net.minecraft.world.gen.feature.TreeFeature;
import net.minecraft.world.server.ServerChunkProvider;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.SaveHandler;
@ -253,7 +249,7 @@ public boolean clearContainerBlockContents(BlockVector3 position) {
@Override
public BiomeType getBiome(BlockVector2 position) {
checkNotNull(position);
return ForgeAdapter.adapt(getWorld().getBiomeBody(new BlockPos(position.getBlockX(), 0, position.getBlockZ())));
return ForgeAdapter.adapt(getWorld().getBiome(new BlockPos(position.getBlockX(), 0, position.getBlockZ())));
}
@Override
@ -262,10 +258,15 @@ public boolean setBiome(BlockVector2 position, BiomeType biome) {
checkNotNull(biome);
IChunk chunk = getWorld().getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4, ChunkStatus.FULL, false);
if (chunk == null) {
BiomeContainer container = chunk == null ? null : chunk.getBiomes();
if (chunk == null || container == null) {
return false;
}
chunk.getBiomes()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = ForgeAdapter.adapt(biome);
// Temporary, while biome setting is 2D only
for (int i = 0; i < BiomeMath.VERTICAL_BIT_MASK; i++) {
int idx = BiomeMath.computeBiomeIndex(position.getX(), i, position.getZ());
container.biomes[idx] = ForgeAdapter.adapt(biome);
}
chunk.setModified(true);
return true;
}
@ -293,8 +294,10 @@ public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
ActionResultType used = stack.onItemUse(itemUseContext);
if (used != ActionResultType.SUCCESS) {
// try activating the block
if (getWorld().getBlockState(blockPos).onBlockActivated(world, fakePlayer, Hand.MAIN_HAND, rayTraceResult)) {
used = ActionResultType.SUCCESS;
ActionResultType resultType = getWorld().getBlockState(blockPos)
.onBlockActivated(world, fakePlayer, Hand.MAIN_HAND, rayTraceResult);
if (resultType.isSuccessOrConsume()) {
used = resultType;
} else {
used = stack.getItem().onItemRightClick(world, fakePlayer, Hand.MAIN_HAND).getType();
}
@ -366,45 +369,39 @@ public boolean regenerate(Region region, EditSession editSession) {
}
@Nullable
private static Feature<? extends IFeatureConfig> createTreeFeatureGenerator(TreeType type) {
private static ConfiguredFeature<?, ?> createTreeFeatureGenerator(TreeType type) {
switch (type) {
case TREE: return new TreeFeature(NoFeatureConfig::deserialize, true);
case BIG_TREE: return new BigTreeFeature(NoFeatureConfig::deserialize, true);
case REDWOOD: return new PointyTaigaTreeFeature(NoFeatureConfig::deserialize);
case TALL_REDWOOD: return new TallTaigaTreeFeature(NoFeatureConfig::deserialize, true);
case BIRCH: return new BirchTreeFeature(NoFeatureConfig::deserialize, true, false);
case JUNGLE: return new MegaJungleFeature(NoFeatureConfig::deserialize, true, 10, 20, JUNGLE_LOG, JUNGLE_LEAF);
case SMALL_JUNGLE: return new JungleTreeFeature(NoFeatureConfig::deserialize, true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, false);
case SHORT_JUNGLE: return new JungleTreeFeature(NoFeatureConfig::deserialize, true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, true);
case JUNGLE_BUSH: return new ShrubFeature(NoFeatureConfig::deserialize, JUNGLE_LOG, JUNGLE_SHRUB);
case SWAMP: return new SwampTreeFeature(NoFeatureConfig::deserialize);
case ACACIA: return new SavannaTreeFeature(NoFeatureConfig::deserialize, true);
case DARK_OAK: return new DarkOakTreeFeature(NoFeatureConfig::deserialize, true);
case MEGA_REDWOOD: return new MegaPineTree(NoFeatureConfig::deserialize, true, random.nextBoolean());
case TALL_BIRCH: return new BirchTreeFeature(NoFeatureConfig::deserialize, true, true);
case RED_MUSHROOM: return new BigRedMushroomFeature(BigMushroomFeatureConfig::deserialize);
case BROWN_MUSHROOM: return new BigBrownMushroomFeature(BigMushroomFeatureConfig::deserialize);
case RANDOM: return createTreeFeatureGenerator(TreeType.values()[ThreadLocalRandom.current().nextInt(TreeType.values().length)]);
// TODO: Fix these after 2020201-1.15.1 mappings are out
// case TREE: return Feature.NORMAL_TREE.withConfiguration(DefaultBiomeFeatures.);
// case BIG_TREE: return new BigTreeFeature(NoFeatureConfig::deserialize, true);
// case REDWOOD: return new PointyTaigaTreeFeature(NoFeatureConfig::deserialize);
// case TALL_REDWOOD: return new TallTaigaTreeFeature(NoFeatureConfig::deserialize, true);
// case BIRCH: return new BirchTreeFeature(NoFeatureConfig::deserialize, true, false);
// case JUNGLE: return new MegaJungleFeature(NoFeatureConfig::deserialize, true, 10, 20, JUNGLE_LOG, JUNGLE_LEAF);
// case SMALL_JUNGLE: return new JungleTreeFeature(NoFeatureConfig::deserialize, true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, false);
// case SHORT_JUNGLE: return new JungleTreeFeature(NoFeatureConfig::deserialize, true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, true);
// case JUNGLE_BUSH: return new ShrubFeature(NoFeatureConfig::deserialize, JUNGLE_LOG, JUNGLE_SHRUB);
// case SWAMP: return new SwampTreeFeature(NoFeatureConfig::deserialize);
// case ACACIA: return new SavannaTreeFeature(NoFeatureConfig::deserialize, true);
// case DARK_OAK: return new DarkOakTreeFeature(NoFeatureConfig::deserialize, true);
// case MEGA_REDWOOD: return new MegaPineTree(NoFeatureConfig::deserialize, true, random.nextBoolean());
// case TALL_BIRCH: return new BirchTreeFeature(NoFeatureConfig::deserialize, true, true);
// case RED_MUSHROOM: return new BigRedMushroomFeature(BigMushroomFeatureConfig::deserialize);
// case BROWN_MUSHROOM: return new BigBrownMushroomFeature(BigMushroomFeatureConfig::deserialize);
// case RANDOM: return createTreeFeatureGenerator(TreeType.values()[ThreadLocalRandom.current().nextInt(TreeType.values().length)]);
default:
return null;
}
}
private IFeatureConfig createFeatureConfig(TreeType type) {
if (type == TreeType.RED_MUSHROOM || type == TreeType.BROWN_MUSHROOM) {
return new BigMushroomFeatureConfig(true);
} else {
return new NoFeatureConfig();
}
}
@Override
public boolean generateTree(TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
@SuppressWarnings("unchecked")
Feature<IFeatureConfig> generator = (Feature<IFeatureConfig>) createTreeFeatureGenerator(type);
ConfiguredFeature<?, ?> generator = createTreeFeatureGenerator(type);
ChunkGenerator<?> chunkGenerator = ((ServerChunkProvider) getWorld().getChunkProvider())
.getChunkGenerator();
return generator != null
&& generator.place(getWorld(), getWorld().getChunkProvider().getChunkGenerator(), random,
ForgeAdapter.toBlockPos(position), createFeatureConfig(type));
&& generator.place(getWorld(), chunkGenerator, random,
ForgeAdapter.toBlockPos(position));
}
@Override
@ -421,7 +418,7 @@ public void fixAfterFastMode(Iterable<BlockVector2> chunks) {
public void fixLighting(Iterable<BlockVector2> chunks) {
World world = getWorld();
for (BlockVector2 chunk : chunks) {
world.getChunkProvider().getLightManager().func_215571_a(new ChunkPos(chunk.getBlockX(), chunk.getBlockZ()), true);
world.getChunkProvider().getLightManager().retainData(new ChunkPos(chunk.getBlockX(), chunk.getBlockZ()), true);
}
}

View File

@ -117,19 +117,19 @@ public static ListNBT toNative(ListTag tag) {
}
public static LongNBT toNative(LongTag tag) {
return new LongNBT(tag.getValue());
return LongNBT.valueOf(tag.getValue());
}
public static StringNBT toNative(StringTag tag) {
return new StringNBT(tag.getValue());
return StringNBT.valueOf(tag.getValue());
}
public static IntNBT toNative(IntTag tag) {
return new IntNBT(tag.getValue());
return IntNBT.valueOf(tag.getValue());
}
public static ByteNBT toNative(ByteTag tag) {
return new ByteNBT(tag.getValue());
return ByteNBT.valueOf(tag.getValue());
}
public static ByteArrayNBT toNative(ByteArrayTag tag) {
@ -146,15 +146,15 @@ public static CompoundNBT toNative(CompoundTag tag) {
}
public static FloatNBT toNative(FloatTag tag) {
return new FloatNBT(tag.getValue());
return FloatNBT.valueOf(tag.getValue());
}
public static ShortNBT toNative(ShortTag tag) {
return new ShortNBT(tag.getValue());
return ShortNBT.valueOf(tag.getValue());
}
public static DoubleNBT toNative(DoubleTag tag) {
return new DoubleNBT(tag.getValue());
return DoubleNBT.valueOf(tag.getValue());
}
public static Tag fromNative(INBT other) {

View File

@ -49,9 +49,9 @@ private static void updateForSet(CompoundNBT tag, BlockVector3 position) {
checkNotNull(tag);
checkNotNull(position);
tag.put("x", new IntNBT(position.getBlockX()));
tag.put("y", new IntNBT(position.getBlockY()));
tag.put("z", new IntNBT(position.getBlockZ()));
tag.put("x", IntNBT.valueOf(position.getBlockX()));
tag.put("y", IntNBT.valueOf(position.getBlockY()));
tag.put("z", IntNBT.valueOf(position.getBlockZ()));
}
/**

View File

@ -1,2 +1,3 @@
public net.minecraft.server.MinecraftServer field_211151_aa # serverTime
public net.minecraft.entity.player.ServerPlayerEntity field_71148_cg # language
public net.minecraft.world.biome.BiomeContainer field_227054_f_ # biomes