mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-03-01 13:36:46 +08:00
[Fabric] Update to 1.15
This commit is contained in:
parent
9ede68deb5
commit
b633775c9b
@ -3,5 +3,5 @@ version=7.1.0-SNAPSHOT
|
||||
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
loom.version=0.2.5-20190906.190953-30
|
||||
mixin.version=0.7.11.38
|
||||
loom.version=0.2.6-20191118.221541-46
|
||||
mixin.version=0.8.11
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
apply(plugin = "fabric-loom")
|
||||
|
||||
val minecraftVersion = "1.14.4"
|
||||
val yarnMappings = "1.14.4+build.12"
|
||||
val loaderVersion = "0.6.2+build.166"
|
||||
val minecraftVersion = "1.15"
|
||||
val yarnMappings = "1.15+build.1"
|
||||
val loaderVersion = "0.7.2+build.174"
|
||||
|
||||
configurations.all {
|
||||
resolutionStrategy {
|
||||
@ -25,10 +25,10 @@
|
||||
"modCompile"("net.fabricmc:fabric-loader:$loaderVersion")
|
||||
|
||||
listOf(
|
||||
"net.fabricmc.fabric-api:fabric-api-base:0.1.0+2983bc0442",
|
||||
"net.fabricmc.fabric-api:fabric-events-interaction-v0:0.1.1+591e97ae42",
|
||||
"net.fabricmc.fabric-api:fabric-events-lifecycle-v0:0.1.1+591e97ae42",
|
||||
"net.fabricmc.fabric-api:fabric-networking-v0:0.1.3+591e97ae42"
|
||||
"net.fabricmc.fabric-api:fabric-api-base:0.1.2+28f8190f42",
|
||||
"net.fabricmc.fabric-api:fabric-events-interaction-v0:0.2.6+12515ed975",
|
||||
"net.fabricmc.fabric-api:fabric-events-lifecycle-v0:0.1.2+b7f9825de8",
|
||||
"net.fabricmc.fabric-api:fabric-networking-v0:0.1.7+12515ed975"
|
||||
).forEach {
|
||||
"include"(it)
|
||||
"modImplementation"(it)
|
||||
|
@ -45,7 +45,7 @@
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.state.StateFactory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.StringIdentifiable;
|
||||
@ -154,8 +154,8 @@ public static Map<Property<?>, Object> adaptProperties(BlockType block, Map<net.
|
||||
return props;
|
||||
}
|
||||
|
||||
private static net.minecraft.block.BlockState applyProperties(StateFactory<Block, net.minecraft.block.BlockState> stateContainer,
|
||||
net.minecraft.block.BlockState newState, Map<Property<?>, Object> states) {
|
||||
private static net.minecraft.block.BlockState applyProperties(StateManager<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 property = stateContainer.getProperty(state.getKey().getName());
|
||||
Comparable value = (Comparable) state.getValue();
|
||||
@ -165,7 +165,7 @@ private static net.minecraft.block.BlockState applyProperties(StateFactory<Block
|
||||
value = adapt(dir);
|
||||
} else if (property instanceof net.minecraft.state.property.EnumProperty) {
|
||||
String enumName = (String) value;
|
||||
value = ((net.minecraft.state.property.EnumProperty<?>) property).getValue((String) value).orElseGet(() -> {
|
||||
value = ((net.minecraft.state.property.EnumProperty<?>) property).parse((String) value).orElseGet(() -> {
|
||||
throw new IllegalStateException("Enum property " + property.getName() + " does not contain " + enumName);
|
||||
});
|
||||
}
|
||||
@ -179,7 +179,7 @@ public static net.minecraft.block.BlockState adapt(BlockState blockState) {
|
||||
Block mcBlock = adapt(blockState.getBlockType());
|
||||
net.minecraft.block.BlockState newState = mcBlock.getDefaultState();
|
||||
Map<Property<?>, Object> states = blockState.getStates();
|
||||
return applyProperties(mcBlock.getStateFactory(), newState, states);
|
||||
return applyProperties(mcBlock.getStateManager(), newState, states);
|
||||
}
|
||||
|
||||
public static BlockState adapt(net.minecraft.block.BlockState blockState) {
|
||||
|
@ -130,7 +130,7 @@ private String fixBlockState(String blockState, int srcVer) {
|
||||
private String nbtToState(net.minecraft.nbt.CompoundTag tagCompound) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(tagCompound.getString("Name"));
|
||||
if (tagCompound.containsKey("Properties", 10)) {
|
||||
if (tagCompound.contains("Properties", 10)) {
|
||||
sb.append('[');
|
||||
net.minecraft.nbt.CompoundTag props = tagCompound.getCompound("Properties");
|
||||
sb.append(props.getKeys().stream().map(k -> k + "=" + props.getString(k).replace("\"", "")).collect(Collectors.joining(",")));
|
||||
@ -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 StringTag(key)), srcVer, DATA_VERSION)
|
||||
return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, StringTag.of(key)), srcVer, DATA_VERSION)
|
||||
.asString().orElse(key);
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ public static net.minecraft.nbt.CompoundTag convert(LegacyType type, net.minecra
|
||||
}
|
||||
|
||||
public static net.minecraft.nbt.CompoundTag convert(TypeReference type, net.minecraft.nbt.CompoundTag cmp) {
|
||||
int i = cmp.containsKey("DataVersion", 99) ? cmp.getInt("DataVersion") : -1;
|
||||
int i = cmp.contains("DataVersion", 99) ? cmp.getInt("DataVersion") : -1;
|
||||
return convert(type, cmp, i);
|
||||
}
|
||||
|
||||
@ -586,17 +586,17 @@ private static void convertCompound(LegacyType type, net.minecraft.nbt.CompoundT
|
||||
}
|
||||
|
||||
private static void convertItem(net.minecraft.nbt.CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) {
|
||||
if (nbttagcompound.containsKey(key, 10)) {
|
||||
if (nbttagcompound.contains(key, 10)) {
|
||||
convertCompound(LegacyType.ITEM_INSTANCE, nbttagcompound, key, sourceVer, targetVer);
|
||||
}
|
||||
}
|
||||
|
||||
private static void convertItems(net.minecraft.nbt.CompoundTag nbttagcompound, String key, int sourceVer, int targetVer) {
|
||||
if (nbttagcompound.containsKey(key, 9)) {
|
||||
if (nbttagcompound.contains(key, 9)) {
|
||||
ListTag nbttaglist = nbttagcompound.getList(key, 10);
|
||||
|
||||
for (int j = 0; j < nbttaglist.size(); ++j) {
|
||||
nbttaglist.add(j, convert(LegacyType.ITEM_INSTANCE, nbttaglist.getCompoundTag(j), sourceVer, targetVer));
|
||||
nbttaglist.add(j, convert(LegacyType.ITEM_INSTANCE, nbttaglist.getCompound(j), sourceVer, targetVer));
|
||||
}
|
||||
}
|
||||
|
||||
@ -616,14 +616,14 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
ListTag nbttaglist = cmp.getList("Equipment", 10);
|
||||
ListTag nbttaglist1;
|
||||
|
||||
if (!nbttaglist.isEmpty() && !cmp.containsKey("HandItems", 10)) {
|
||||
if (!nbttaglist.isEmpty() && !cmp.contains("HandItems", 10)) {
|
||||
nbttaglist1 = new ListTag();
|
||||
nbttaglist1.add(nbttaglist.get(0));
|
||||
nbttaglist1.add(new net.minecraft.nbt.CompoundTag());
|
||||
cmp.put("HandItems", nbttaglist1);
|
||||
}
|
||||
|
||||
if (nbttaglist.size() > 1 && !cmp.containsKey("ArmorItem", 10)) {
|
||||
if (nbttaglist.size() > 1 && !cmp.contains("ArmorItem", 10)) {
|
||||
nbttaglist1 = new ListTag();
|
||||
nbttaglist1.add(nbttaglist.get(1));
|
||||
nbttaglist1.add(nbttaglist.get(2));
|
||||
@ -633,23 +633,23 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
}
|
||||
|
||||
cmp.remove("Equipment");
|
||||
if (cmp.containsKey("DropChances", 9)) {
|
||||
if (cmp.contains("DropChances", 9)) {
|
||||
nbttaglist1 = cmp.getList("DropChances", 5);
|
||||
ListTag nbttaglist2;
|
||||
|
||||
if (!cmp.containsKey("HandDropChances", 10)) {
|
||||
if (!cmp.contains("HandDropChances", 10)) {
|
||||
nbttaglist2 = new ListTag();
|
||||
nbttaglist2.add(new FloatTag(nbttaglist1.getFloat(0)));
|
||||
nbttaglist2.add(new FloatTag(0.0F));
|
||||
nbttaglist2.add(FloatTag.of(nbttaglist1.getFloat(0)));
|
||||
nbttaglist2.add(FloatTag.of(0.0F));
|
||||
cmp.put("HandDropChances", nbttaglist2);
|
||||
}
|
||||
|
||||
if (!cmp.containsKey("ArmorDropChances", 10)) {
|
||||
if (!cmp.contains("ArmorDropChances", 10)) {
|
||||
nbttaglist2 = new ListTag();
|
||||
nbttaglist2.add(new FloatTag(nbttaglist1.getFloat(1)));
|
||||
nbttaglist2.add(new FloatTag(nbttaglist1.getFloat(2)));
|
||||
nbttaglist2.add(new FloatTag(nbttaglist1.getFloat(3)));
|
||||
nbttaglist2.add(new FloatTag(nbttaglist1.getFloat(4)));
|
||||
nbttaglist2.add(FloatTag.of(nbttaglist1.getFloat(1)));
|
||||
nbttaglist2.add(FloatTag.of(nbttaglist1.getFloat(2)));
|
||||
nbttaglist2.add(FloatTag.of(nbttaglist1.getFloat(3)));
|
||||
nbttaglist2.add(FloatTag.of(nbttaglist1.getFloat(4)));
|
||||
cmp.put("ArmorDropChances", nbttaglist2);
|
||||
}
|
||||
|
||||
@ -679,12 +679,12 @@ private static String convertEntityId(int i, String s) {
|
||||
|
||||
@Override
|
||||
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
|
||||
if (!cmp.containsKey("tag", 10)) {
|
||||
if (!cmp.contains("tag", 10)) {
|
||||
return cmp;
|
||||
} else {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag");
|
||||
|
||||
if (nbttagcompound1.containsKey("BlockEntityTag", 10)) {
|
||||
if (nbttagcompound1.contains("BlockEntityTag", 10)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
|
||||
String s = cmp.getString("id");
|
||||
String s1 = convertEntityId(sourceVer, s);
|
||||
@ -695,7 +695,7 @@ public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp,
|
||||
// DataInspectorBlockEntity.a.warn("Unable to resolve BlockEntity for ItemInstance: {}", s);
|
||||
flag = false;
|
||||
} else {
|
||||
flag = !nbttagcompound2.containsKey("id");
|
||||
flag = !nbttagcompound2.contains("id");
|
||||
nbttagcompound2.putString("id", s1);
|
||||
}
|
||||
|
||||
@ -812,7 +812,7 @@ private static class DataInspectorEntity implements DataInspector {
|
||||
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag");
|
||||
|
||||
if (nbttagcompound1.containsKey("EntityTag", 10)) {
|
||||
if (nbttagcompound1.contains("EntityTag", 10)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
|
||||
String s = cmp.getString("id");
|
||||
String s1;
|
||||
@ -833,7 +833,7 @@ public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp,
|
||||
DataInspectorEntity.a.warn("Unable to resolve Entity for ItemInstance: {}", s);
|
||||
flag = false;
|
||||
} else {
|
||||
flag = !nbttagcompound2.containsKey("id", 8);
|
||||
flag = !nbttagcompound2.contains("id", 8);
|
||||
nbttagcompound2.putString("id", s1);
|
||||
}
|
||||
|
||||
@ -913,7 +913,7 @@ public int getDataVersion() {
|
||||
}
|
||||
|
||||
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
|
||||
if (cmp.containsKey("id", 99)) {
|
||||
if (cmp.contains("id", 99)) {
|
||||
short short0 = cmp.getShort("id");
|
||||
|
||||
if (short0 > 0 && short0 < materials.length && materials[short0] != null) {
|
||||
@ -1269,18 +1269,18 @@ public int getDataVersion() {
|
||||
}
|
||||
|
||||
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
|
||||
if ("minecraft:banner".equals(cmp.getString("id")) && cmp.containsKey("tag", 10)) {
|
||||
if ("minecraft:banner".equals(cmp.getString("id")) && cmp.contains("tag", 10)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag");
|
||||
|
||||
if (nbttagcompound1.containsKey("BlockEntityTag", 10)) {
|
||||
if (nbttagcompound1.contains("BlockEntityTag", 10)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
|
||||
|
||||
if (nbttagcompound2.containsKey("Base", 99)) {
|
||||
if (nbttagcompound2.contains("Base", 99)) {
|
||||
cmp.putShort("Damage", (short) (nbttagcompound2.getShort("Base") & 15));
|
||||
if (nbttagcompound1.containsKey("display", 10)) {
|
||||
if (nbttagcompound1.contains("display", 10)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound3 = nbttagcompound1.getCompound("display");
|
||||
|
||||
if (nbttagcompound3.containsKey("Lore", 9)) {
|
||||
if (nbttagcompound3.contains("Lore", 9)) {
|
||||
ListTag nbttaglist = nbttagcompound3.getList("Lore", 8);
|
||||
|
||||
if (nbttaglist.size() == 1 && "(+NBT)".equals(nbttaglist.getString(0))) {
|
||||
@ -1320,7 +1320,7 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag");
|
||||
short short0 = cmp.getShort("Damage");
|
||||
|
||||
if (!nbttagcompound1.containsKey("Potion", 8)) {
|
||||
if (!nbttagcompound1.contains("Potion", 8)) {
|
||||
String s = DataConverterPotionId.potions[short0 & 127];
|
||||
|
||||
nbttagcompound1.putString("Potion", s == null ? "minecraft:water" : s);
|
||||
@ -1486,7 +1486,7 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
|
||||
short short0 = cmp.getShort("Damage");
|
||||
|
||||
if (!nbttagcompound2.containsKey("id", 8)) {
|
||||
if (!nbttagcompound2.contains("id", 8)) {
|
||||
String s = DataConverterSpawnEgg.eggs[short0 & 255];
|
||||
|
||||
if (s != null) {
|
||||
@ -1615,7 +1615,7 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
if (!"MobSpawner".equals(cmp.getString("id"))) {
|
||||
return cmp;
|
||||
} else {
|
||||
if (cmp.containsKey("EntityId", 8)) {
|
||||
if (cmp.contains("EntityId", 8)) {
|
||||
String s = cmp.getString("EntityId");
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("SpawnData");
|
||||
|
||||
@ -1624,13 +1624,13 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
cmp.remove("EntityId");
|
||||
}
|
||||
|
||||
if (cmp.containsKey("SpawnPotentials", 9)) {
|
||||
if (cmp.contains("SpawnPotentials", 9)) {
|
||||
ListTag nbttaglist = cmp.getList("SpawnPotentials", 10);
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttaglist.getCompoundTag(i);
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttaglist.getCompound(i);
|
||||
|
||||
if (nbttagcompound2.containsKey("Type", 8)) {
|
||||
if (nbttagcompound2.contains("Type", 8)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound3 = nbttagcompound2.getCompound("Properties");
|
||||
|
||||
nbttagcompound3.putString("id", nbttagcompound2.getString("Type"));
|
||||
@ -1655,7 +1655,7 @@ public int getDataVersion() {
|
||||
}
|
||||
|
||||
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
|
||||
if (cmp.containsKey("UUID", 8)) {
|
||||
if (cmp.contains("UUID", 8)) {
|
||||
cmp.putUuid("UUID", UUID.fromString(cmp.getString("UUID")));
|
||||
}
|
||||
|
||||
@ -1677,11 +1677,11 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
if (DataConverterHealth.a.contains(cmp.getString("id"))) {
|
||||
float f;
|
||||
|
||||
if (cmp.containsKey("HealF", 99)) {
|
||||
if (cmp.contains("HealF", 99)) {
|
||||
f = cmp.getFloat("HealF");
|
||||
cmp.remove("HealF");
|
||||
} else {
|
||||
if (!cmp.containsKey("Health", 99)) {
|
||||
if (!cmp.contains("Health", 99)) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
@ -1704,7 +1704,7 @@ public int getDataVersion() {
|
||||
}
|
||||
|
||||
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
|
||||
if ("EntityHorse".equals(cmp.getString("id")) && !cmp.containsKey("SaddleItem", 10) && cmp.getBoolean("Saddle")) {
|
||||
if ("EntityHorse".equals(cmp.getString("id")) && !cmp.contains("SaddleItem", 10) && cmp.getBoolean("Saddle")) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = new net.minecraft.nbt.CompoundTag();
|
||||
|
||||
nbttagcompound1.putString("id", "minecraft:saddle");
|
||||
@ -1731,16 +1731,16 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
boolean flag = "Painting".equals(s);
|
||||
boolean flag1 = "ItemFrame".equals(s);
|
||||
|
||||
if ((flag || flag1) && !cmp.containsKey("Facing", 99)) {
|
||||
if ((flag || flag1) && !cmp.contains("Facing", 99)) {
|
||||
Direction enumdirection;
|
||||
|
||||
if (cmp.containsKey("Direction", 99)) {
|
||||
if (cmp.contains("Direction", 99)) {
|
||||
enumdirection = Direction.fromHorizontal(cmp.getByte("Direction"));
|
||||
cmp.putInt("TileX", cmp.getInt("TileX") + enumdirection.getOffsetX());
|
||||
cmp.putInt("TileY", cmp.getInt("TileY") + enumdirection.getOffsetY());
|
||||
cmp.putInt("TileZ", cmp.getInt("TileZ") + enumdirection.getOffsetZ());
|
||||
cmp.remove("Direction");
|
||||
if (flag1 && cmp.containsKey("ItemRotation", 99)) {
|
||||
if (flag1 && cmp.contains("ItemRotation", 99)) {
|
||||
cmp.putByte("ItemRotation", (byte) (cmp.getByte("ItemRotation") * 2));
|
||||
}
|
||||
} else {
|
||||
@ -1766,14 +1766,14 @@ public int getDataVersion() {
|
||||
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
|
||||
ListTag nbttaglist;
|
||||
|
||||
if (cmp.containsKey("HandDropChances", 9)) {
|
||||
if (cmp.contains("HandDropChances", 9)) {
|
||||
nbttaglist = cmp.getList("HandDropChances", 5);
|
||||
if (nbttaglist.size() == 2 && nbttaglist.getFloat(0) == 0.0F && nbttaglist.getFloat(1) == 0.0F) {
|
||||
cmp.remove("HandDropChances");
|
||||
}
|
||||
}
|
||||
|
||||
if (cmp.containsKey("ArmorDropChances", 9)) {
|
||||
if (cmp.contains("ArmorDropChances", 9)) {
|
||||
nbttaglist = cmp.getList("ArmorDropChances", 5);
|
||||
if (nbttaglist.size() == 4 && nbttaglist.getFloat(0) == 0.0F && nbttaglist.getFloat(1) == 0.0F && nbttaglist.getFloat(2) == 0.0F && nbttaglist.getFloat(3) == 0.0F) {
|
||||
cmp.remove("ArmorDropChances");
|
||||
@ -1793,7 +1793,7 @@ public int getDataVersion() {
|
||||
}
|
||||
|
||||
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
|
||||
while (cmp.containsKey("Riding", 10)) {
|
||||
while (cmp.contains("Riding", 10)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = this.b(cmp);
|
||||
|
||||
this.convert(cmp, nbttagcompound1);
|
||||
@ -1830,7 +1830,7 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
if ("minecraft:written_book".equals(cmp.getString("id"))) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag");
|
||||
|
||||
if (nbttagcompound1.containsKey("pages", 9)) {
|
||||
if (nbttagcompound1.contains("pages", 9)) {
|
||||
ListTag nbttaglist = nbttagcompound1.getList("pages", 8);
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||
@ -1874,7 +1874,7 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
object = new LiteralText("");
|
||||
}
|
||||
|
||||
nbttaglist.set(i, new StringTag(Text.Serializer.toJson((Text) object)));
|
||||
nbttaglist.set(i, StringTag.of(Text.Serializer.toJson((Text) object)));
|
||||
}
|
||||
|
||||
nbttagcompound1.put("pages", nbttaglist);
|
||||
@ -1896,7 +1896,7 @@ public int getDataVersion() {
|
||||
}
|
||||
|
||||
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
|
||||
if (cmp.containsKey("id", 8) && DataConverterCookedFish.a.equals(new Identifier(cmp.getString("id")))) {
|
||||
if (cmp.contains("id", 8) && DataConverterCookedFish.a.equals(new Identifier(cmp.getString("id")))) {
|
||||
cmp.putString("id", "minecraft:cooked_fish");
|
||||
}
|
||||
|
||||
@ -1916,10 +1916,10 @@ public int getDataVersion() {
|
||||
|
||||
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
|
||||
if ("Zombie".equals(cmp.getString("id")) && cmp.getBoolean("IsVillager")) {
|
||||
if (!cmp.containsKey("ZombieType", 99)) {
|
||||
if (!cmp.contains("ZombieType", 99)) {
|
||||
int i = -1;
|
||||
|
||||
if (cmp.containsKey("VillagerProfession", 99)) {
|
||||
if (cmp.contains("VillagerProfession", 99)) {
|
||||
try {
|
||||
i = this.convert(cmp.getInt("VillagerProfession"));
|
||||
} catch (RuntimeException runtimeexception) {
|
||||
@ -2244,11 +2244,11 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals(s)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag");
|
||||
|
||||
if (!nbttagcompound1.containsKey("Potion", 8)) {
|
||||
if (!nbttagcompound1.contains("Potion", 8)) {
|
||||
nbttagcompound1.putString("Potion", "minecraft:water");
|
||||
}
|
||||
|
||||
if (!cmp.containsKey("tag", 10)) {
|
||||
if (!cmp.contains("tag", 10)) {
|
||||
cmp.put("tag", nbttagcompound1);
|
||||
}
|
||||
}
|
||||
@ -2266,7 +2266,7 @@ public int getDataVersion() {
|
||||
}
|
||||
|
||||
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
|
||||
if ("minecraft:shulker".equals(cmp.getString("id")) && !cmp.containsKey("Color", 99)) {
|
||||
if ("minecraft:shulker".equals(cmp.getString("id")) && !cmp.contains("Color", 99)) {
|
||||
cmp.putByte("Color", (byte) 10);
|
||||
}
|
||||
|
||||
@ -2285,10 +2285,10 @@ public int getDataVersion() {
|
||||
}
|
||||
|
||||
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
|
||||
if ("minecraft:shulker_box".equals(cmp.getString("id")) && cmp.containsKey("tag", 10)) {
|
||||
if ("minecraft:shulker_box".equals(cmp.getString("id")) && cmp.contains("tag", 10)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("tag");
|
||||
|
||||
if (nbttagcompound1.containsKey("BlockEntityTag", 10)) {
|
||||
if (nbttagcompound1.contains("BlockEntityTag", 10)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
|
||||
|
||||
if (nbttagcompound2.getList("Items", 10).isEmpty()) {
|
||||
@ -2340,7 +2340,7 @@ public int getDataVersion() {
|
||||
}
|
||||
|
||||
public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp) {
|
||||
if (cmp.containsKey("lang", 8)) {
|
||||
if (cmp.contains("lang", 8)) {
|
||||
cmp.putString("lang", cmp.getString("lang").toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
@ -2386,7 +2386,7 @@ public net.minecraft.nbt.CompoundTag convert(net.minecraft.nbt.CompoundTag cmp)
|
||||
ListTag nbttaglist1 = nbttagcompound1.getList("Sections", 10);
|
||||
|
||||
for (int k = 0; k < nbttaglist1.size(); ++k) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttaglist1.getCompoundTag(k);
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttaglist1.getCompound(k);
|
||||
byte b0 = nbttagcompound2.getByte("Y");
|
||||
byte[] abyte = nbttagcompound2.getByteArray("Blocks");
|
||||
|
||||
@ -2528,10 +2528,10 @@ private void convert(net.minecraft.nbt.CompoundTag nbttagcompound, String s) {
|
||||
private static class DataInspectorPlayerVehicle implements DataInspector {
|
||||
@Override
|
||||
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
|
||||
if (cmp.containsKey("RootVehicle", 10)) {
|
||||
if (cmp.contains("RootVehicle", 10)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("RootVehicle");
|
||||
|
||||
if (nbttagcompound1.containsKey("Entity", 10)) {
|
||||
if (nbttagcompound1.contains("Entity", 10)) {
|
||||
convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer);
|
||||
}
|
||||
}
|
||||
@ -2543,7 +2543,7 @@ public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp,
|
||||
private static class DataInspectorLevelPlayer implements DataInspector {
|
||||
@Override
|
||||
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
|
||||
if (cmp.containsKey("Player", 10)) {
|
||||
if (cmp.contains("Player", 10)) {
|
||||
convertCompound(LegacyType.PLAYER, cmp, "Player", sourceVer, targetVer);
|
||||
}
|
||||
|
||||
@ -2558,23 +2558,23 @@ public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp,
|
||||
int j;
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1;
|
||||
|
||||
if (cmp.containsKey("entities", 9)) {
|
||||
if (cmp.contains("entities", 9)) {
|
||||
nbttaglist = cmp.getList("entities", 10);
|
||||
|
||||
for (j = 0; j < nbttaglist.size(); ++j) {
|
||||
nbttagcompound1 = (net.minecraft.nbt.CompoundTag) nbttaglist.get(j);
|
||||
if (nbttagcompound1.containsKey("nbt", 10)) {
|
||||
if (nbttagcompound1.contains("nbt", 10)) {
|
||||
convertCompound(LegacyType.ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmp.containsKey("blocks", 9)) {
|
||||
if (cmp.contains("blocks", 9)) {
|
||||
nbttaglist = cmp.getList("blocks", 10);
|
||||
|
||||
for (j = 0; j < nbttaglist.size(); ++j) {
|
||||
nbttagcompound1 = (net.minecraft.nbt.CompoundTag) nbttaglist.get(j);
|
||||
if (nbttagcompound1.containsKey("nbt", 10)) {
|
||||
if (nbttagcompound1.contains("nbt", 10)) {
|
||||
convertCompound(LegacyType.BLOCK_ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer);
|
||||
}
|
||||
}
|
||||
@ -2587,12 +2587,12 @@ public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp,
|
||||
private static class DataInspectorChunks implements DataInspector {
|
||||
@Override
|
||||
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
|
||||
if (cmp.containsKey("Level", 10)) {
|
||||
if (cmp.contains("Level", 10)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("Level");
|
||||
ListTag nbttaglist;
|
||||
int j;
|
||||
|
||||
if (nbttagcompound1.containsKey("Entities", 9)) {
|
||||
if (nbttagcompound1.contains("Entities", 9)) {
|
||||
nbttaglist = nbttagcompound1.getList("Entities", 10);
|
||||
|
||||
for (j = 0; j < nbttaglist.size(); ++j) {
|
||||
@ -2600,7 +2600,7 @@ public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp,
|
||||
}
|
||||
}
|
||||
|
||||
if (nbttagcompound1.containsKey("TileEntities", 9)) {
|
||||
if (nbttagcompound1.contains("TileEntities", 9)) {
|
||||
nbttaglist = nbttagcompound1.getList("TileEntities", 10);
|
||||
|
||||
for (j = 0; j < nbttaglist.size(); ++j) {
|
||||
@ -2616,11 +2616,11 @@ public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp,
|
||||
private static class DataInspectorEntityPassengers implements DataInspector {
|
||||
@Override
|
||||
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
|
||||
if (cmp.containsKey("Passengers", 9)) {
|
||||
if (cmp.contains("Passengers", 9)) {
|
||||
ListTag nbttaglist = cmp.getList("Passengers", 10);
|
||||
|
||||
for (int j = 0; j < nbttaglist.size(); ++j) {
|
||||
nbttaglist.set(j, convert(LegacyType.ENTITY, nbttaglist.getCompoundTag(j), sourceVer, targetVer));
|
||||
nbttaglist.set(j, convert(LegacyType.ENTITY, nbttaglist.getCompound(j), sourceVer, targetVer));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2633,11 +2633,11 @@ private static class DataInspectorPlayer implements DataInspector {
|
||||
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
|
||||
convertItems(cmp, "Inventory", sourceVer, targetVer);
|
||||
convertItems(cmp, "EnderItems", sourceVer, targetVer);
|
||||
if (cmp.containsKey("ShoulderEntityLeft", 10)) {
|
||||
if (cmp.contains("ShoulderEntityLeft", 10)) {
|
||||
convertCompound(LegacyType.ENTITY, cmp, "ShoulderEntityLeft", sourceVer, targetVer);
|
||||
}
|
||||
|
||||
if (cmp.containsKey("ShoulderEntityRight", 10)) {
|
||||
if (cmp.contains("ShoulderEntityRight", 10)) {
|
||||
convertCompound(LegacyType.ENTITY, cmp, "ShoulderEntityRight", sourceVer, targetVer);
|
||||
}
|
||||
|
||||
@ -2650,14 +2650,14 @@ private static class DataInspectorVillagers implements DataInspector {
|
||||
|
||||
@Override
|
||||
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
|
||||
if (entityVillager.equals(new Identifier(cmp.getString("id"))) && cmp.containsKey("Offers", 10)) {
|
||||
if (entityVillager.equals(new Identifier(cmp.getString("id"))) && cmp.contains("Offers", 10)) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = cmp.getCompound("Offers");
|
||||
|
||||
if (nbttagcompound1.containsKey("Recipes", 9)) {
|
||||
if (nbttagcompound1.contains("Recipes", 9)) {
|
||||
ListTag nbttaglist = nbttagcompound1.getList("Recipes", 10);
|
||||
|
||||
for (int j = 0; j < nbttaglist.size(); ++j) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttaglist.getCompoundTag(j);
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound2 = nbttaglist.getCompound(j);
|
||||
|
||||
convertItem(nbttagcompound2, "buy", sourceVer, targetVer);
|
||||
convertItem(nbttagcompound2, "buyB", sourceVer, targetVer);
|
||||
@ -2694,11 +2694,11 @@ private static class DataInspectorMobSpawnerMobs implements DataInspector {
|
||||
@Override
|
||||
public net.minecraft.nbt.CompoundTag inspect(net.minecraft.nbt.CompoundTag cmp, int sourceVer, int targetVer) {
|
||||
if (tileEntityMobSpawner.equals(new Identifier(cmp.getString("id")))) {
|
||||
if (cmp.containsKey("SpawnPotentials", 9)) {
|
||||
if (cmp.contains("SpawnPotentials", 9)) {
|
||||
ListTag nbttaglist = cmp.getList("SpawnPotentials", 10);
|
||||
|
||||
for (int j = 0; j < nbttaglist.size(); ++j) {
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = nbttaglist.getCompoundTag(j);
|
||||
net.minecraft.nbt.CompoundTag nbttagcompound1 = nbttaglist.getCompound(j);
|
||||
|
||||
convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public BaseEntity getState() {
|
||||
public Location getLocation() {
|
||||
net.minecraft.entity.Entity entity = entityRef.get();
|
||||
if (entity != null) {
|
||||
Vector3 position = Vector3.at(entity.x, entity.y, entity.z);
|
||||
Vector3 position = Vector3.at(entity.getX(), entity.getY(), entity.getZ());
|
||||
float yaw = entity.yaw;
|
||||
float pitch = entity.pitch;
|
||||
|
||||
|
@ -94,7 +94,7 @@ public BaseEntity getState() {
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
Vector3 position = Vector3.at(this.player.x, this.player.y, this.player.z);
|
||||
Vector3 position = Vector3.at(this.player.getX(), this.player.getY(), this.player.getZ());
|
||||
return new Location(
|
||||
FabricWorldEdit.inst.getWorld(this.player.world),
|
||||
position,
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.fabric;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
@ -52,8 +50,6 @@
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
@ -71,30 +67,19 @@
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSaveHandler;
|
||||
import net.minecraft.world.biome.DefaultBiomeFeatures;
|
||||
import net.minecraft.world.biome.source.BiomeArray;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkManager;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
import net.minecraft.world.gen.feature.BirchTreeFeature;
|
||||
import net.minecraft.world.gen.feature.DarkOakTreeFeature;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.BranchedTreeFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
import net.minecraft.world.gen.feature.HugeBrownMushroomFeature;
|
||||
import net.minecraft.world.gen.feature.HugeRedMushroomFeature;
|
||||
import net.minecraft.world.gen.feature.JungleGroundBushFeature;
|
||||
import net.minecraft.world.gen.feature.JungleTreeFeature;
|
||||
import net.minecraft.world.gen.feature.LargeOakTreeFeature;
|
||||
import net.minecraft.world.gen.feature.MegaJungleTreeFeature;
|
||||
import net.minecraft.world.gen.feature.MegaPineTreeFeature;
|
||||
import net.minecraft.world.gen.feature.OakTreeFeature;
|
||||
import net.minecraft.world.gen.feature.PineTreeFeature;
|
||||
import net.minecraft.world.gen.feature.PlantedFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.SavannaTreeFeature;
|
||||
import net.minecraft.world.gen.feature.SpruceTreeFeature;
|
||||
import net.minecraft.world.gen.feature.SwampTreeFeature;
|
||||
import net.minecraft.world.level.LevelProperties;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.file.Path;
|
||||
@ -108,7 +93,7 @@
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* An adapter to Minecraft worlds for WorldEdit.
|
||||
@ -118,10 +103,6 @@ public class FabricWorld extends AbstractWorld {
|
||||
private static final Random random = new Random();
|
||||
private static final int UPDATE = 1, NOTIFY = 2;
|
||||
|
||||
private static final net.minecraft.block.BlockState JUNGLE_LOG = Blocks.JUNGLE_LOG.getDefaultState();
|
||||
private static final net.minecraft.block.BlockState JUNGLE_LEAF = Blocks.JUNGLE_LEAVES.getDefaultState().with(LeavesBlock.PERSISTENT, Boolean.TRUE);
|
||||
private static final net.minecraft.block.BlockState JUNGLE_SHRUB = Blocks.OAK_LEAVES.getDefaultState().with(LeavesBlock.PERSISTENT, Boolean.TRUE);
|
||||
|
||||
private final WeakReference<World> worldRef;
|
||||
|
||||
/**
|
||||
@ -213,8 +194,7 @@ public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B
|
||||
BlockEntity tileEntity = getWorld().getWorldChunk(pos).getBlockEntity(pos);
|
||||
if (tileEntity != null) {
|
||||
tileEntity.fromTag(nativeTag);
|
||||
tileEntity.setPos(pos);
|
||||
tileEntity.setWorld(world);
|
||||
tileEntity.setWorld(world, pos);
|
||||
successful = true; // update if TE changed as well
|
||||
}
|
||||
}
|
||||
@ -222,8 +202,8 @@ public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B
|
||||
}
|
||||
|
||||
if (successful && notifyAndLight) {
|
||||
world.getChunkManager().getLightingProvider().enqueueLightUpdate(pos);
|
||||
world.scheduleBlockRender(pos, old, newState);
|
||||
world.getChunkManager().getLightingProvider().checkBlock(pos);
|
||||
world.checkBlockRerender(pos, old, newState);
|
||||
world.updateListeners(pos, old, newState, UPDATE | NOTIFY);
|
||||
world.updateNeighbors(pos, newState.getBlock());
|
||||
if (old.hasComparatorOutput()) {
|
||||
@ -275,7 +255,12 @@ public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
if (chunk == null) {
|
||||
return false;
|
||||
}
|
||||
chunk.getBiomeArray()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = FabricAdapter.adapt(biome);
|
||||
MutableBiomeArray biomeArray = MutableBiomeArray.inject(chunk.getBiomeArray());
|
||||
// Temporary, while biome setting is 2D only
|
||||
for (int i = 0; i < BiomeArray.VERTICAL_BIT_MASK; i++) {
|
||||
biomeArray.setBiome(position.getX(), i, position.getZ(), FabricAdapter.adapt(biome));
|
||||
}
|
||||
chunk.setShouldSave(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -302,11 +287,10 @@ public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
|
||||
ActionResult used = stack.useOnBlock(itemUseContext);
|
||||
if (used != ActionResult.SUCCESS) {
|
||||
// try activating the block
|
||||
if (getWorld().getBlockState(blockPos).activate(world, fakePlayer, Hand.MAIN_HAND, rayTraceResult)) {
|
||||
used = ActionResult.SUCCESS;
|
||||
} else {
|
||||
used = stack.getItem().use(world, fakePlayer, Hand.MAIN_HAND).getResult();
|
||||
}
|
||||
used = getWorld().getBlockState(blockPos).onUse(world, fakePlayer, Hand.MAIN_HAND, rayTraceResult);
|
||||
}
|
||||
if (used != ActionResult.SUCCESS) {
|
||||
used = stack.use(world, fakePlayer, Hand.MAIN_HAND).getResult();
|
||||
}
|
||||
return used == ActionResult.SUCCESS;
|
||||
}
|
||||
@ -372,45 +356,40 @@ public boolean regenerate(Region region, EditSession editSession) {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Feature<? extends FeatureConfig> createTreeFeatureGenerator(TreeType type) {
|
||||
private static ConfiguredFeature<?, ?> createTreeFeatureGenerator(TreeType type) {
|
||||
switch (type) {
|
||||
case TREE: return new OakTreeFeature(DefaultFeatureConfig::deserialize, true);
|
||||
case BIG_TREE: return new LargeOakTreeFeature(DefaultFeatureConfig::deserialize, true);
|
||||
case REDWOOD: return new PineTreeFeature(DefaultFeatureConfig::deserialize);
|
||||
case TALL_REDWOOD: return new SpruceTreeFeature(DefaultFeatureConfig::deserialize, true);
|
||||
case BIRCH: return new BirchTreeFeature(DefaultFeatureConfig::deserialize, true, false);
|
||||
case JUNGLE: return new MegaJungleTreeFeature(DefaultFeatureConfig::deserialize, true, 10, 20, JUNGLE_LOG, JUNGLE_LEAF);
|
||||
case SMALL_JUNGLE: return new JungleTreeFeature(DefaultFeatureConfig::deserialize, true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, false);
|
||||
case SHORT_JUNGLE: return new JungleTreeFeature(DefaultFeatureConfig::deserialize, true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, true);
|
||||
case JUNGLE_BUSH: return new JungleGroundBushFeature(DefaultFeatureConfig::deserialize, JUNGLE_LOG, JUNGLE_SHRUB);
|
||||
case SWAMP: return new SwampTreeFeature(DefaultFeatureConfig::deserialize);
|
||||
case ACACIA: return new SavannaTreeFeature(DefaultFeatureConfig::deserialize, true);
|
||||
case DARK_OAK: return new DarkOakTreeFeature(DefaultFeatureConfig::deserialize, true);
|
||||
case MEGA_REDWOOD: return new MegaPineTreeFeature(DefaultFeatureConfig::deserialize, true, random.nextBoolean());
|
||||
case TALL_BIRCH: return new BirchTreeFeature(DefaultFeatureConfig::deserialize, true, true);
|
||||
case RED_MUSHROOM: return new HugeRedMushroomFeature(PlantedFeatureConfig::deserialize);
|
||||
case BROWN_MUSHROOM: return new HugeBrownMushroomFeature(PlantedFeatureConfig::deserialize);
|
||||
// Based off of the SaplingGenerator class, as well as uses of DefaultBiomeFeatures fields
|
||||
case TREE: return Feature.NORMAL_TREE.configure(DefaultBiomeFeatures.OAK_TREE_CONFIG);
|
||||
case BIG_TREE: return Feature.FANCY_TREE.configure(DefaultBiomeFeatures.FANCY_TREE_CONFIG);
|
||||
case REDWOOD: return Feature.NORMAL_TREE.configure(DefaultBiomeFeatures.SPRUCE_TREE_CONFIG);
|
||||
case TALL_REDWOOD: return Feature.MEGA_SPRUCE_TREE.configure(DefaultBiomeFeatures.MEGA_SPRUCE_TREE_CONFIG);
|
||||
case MEGA_REDWOOD: return Feature.MEGA_SPRUCE_TREE.configure(DefaultBiomeFeatures.MEGA_PINE_TREE_CONFIG);
|
||||
case BIRCH: return Feature.NORMAL_TREE.configure(DefaultBiomeFeatures.BIRCH_TREE_CONFIG);
|
||||
case JUNGLE: return Feature.MEGA_JUNGLE_TREE.configure(DefaultBiomeFeatures.MEGA_JUNGLE_TREE_CONFIG);
|
||||
case SMALL_JUNGLE: return Feature.NORMAL_TREE.configure(DefaultBiomeFeatures.JUNGLE_TREE_CONFIG);
|
||||
case SHORT_JUNGLE: return new OakTreeFeature(BranchedTreeFeatureConfig::deserialize2)
|
||||
.configure(DefaultBiomeFeatures.JUNGLE_SAPLING_TREE_CONFIG);
|
||||
case JUNGLE_BUSH: return Feature.JUNGLE_GROUND_BUSH.configure(DefaultBiomeFeatures.JUNGLE_GROUND_BUSH_CONFIG);
|
||||
case SWAMP: return Feature.NORMAL_TREE.configure(DefaultBiomeFeatures.SWAMP_TREE_CONFIG);
|
||||
case ACACIA: return Feature.ACACIA_TREE.configure(DefaultBiomeFeatures.ACACIA_TREE_CONFIG);
|
||||
case DARK_OAK: return Feature.DARK_OAK_TREE.configure(DefaultBiomeFeatures.DARK_OAK_TREE_CONFIG);
|
||||
case TALL_BIRCH: return Feature.NORMAL_TREE.configure(DefaultBiomeFeatures.LARGE_BIRCH_TREE_CONFIG);
|
||||
case RED_MUSHROOM: return Feature.HUGE_RED_MUSHROOM.configure(DefaultBiomeFeatures.HUGE_RED_MUSHROOM_CONFIG);
|
||||
case BROWN_MUSHROOM: return Feature.HUGE_BROWN_MUSHROOM.configure(DefaultBiomeFeatures.HUGE_BROWN_MUSHROOM_CONFIG);
|
||||
case RANDOM: return createTreeFeatureGenerator(TreeType.values()[ThreadLocalRandom.current().nextInt(TreeType.values().length)]);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private FeatureConfig createFeatureConfig(TreeType type) {
|
||||
if (type == TreeType.RED_MUSHROOM || type == TreeType.BROWN_MUSHROOM) {
|
||||
return new PlantedFeatureConfig(true);
|
||||
} else {
|
||||
return new DefaultFeatureConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
|
||||
@SuppressWarnings("unchecked")
|
||||
Feature<FeatureConfig> generator = (Feature<FeatureConfig>) createTreeFeatureGenerator(type);
|
||||
return generator != null
|
||||
&& generator.generate(getWorld(), getWorld().getChunkManager().getChunkGenerator(), random,
|
||||
FabricAdapter.toBlockPos(position), createFeatureConfig(type));
|
||||
public boolean generateTree(TreeType type, EditSession editSession, BlockVector3 position) {
|
||||
ConfiguredFeature<?, ?> generator = createTreeFeatureGenerator(type);
|
||||
ServerChunkManager chunkManager = (ServerChunkManager) getWorld().getChunkManager();
|
||||
return generator != null && generator.generate(
|
||||
getWorld(), chunkManager.getChunkGenerator(), random,
|
||||
FabricAdapter.toBlockPos(position)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -427,7 +406,9 @@ public void fixAfterFastMode(Iterable<BlockVector2> chunks) {
|
||||
public void fixLighting(Iterable<BlockVector2> chunks) {
|
||||
World world = getWorld();
|
||||
for (BlockVector2 chunk : chunks) {
|
||||
world.getChunkManager().getLightingProvider().suppressLight(new ChunkPos(chunk.getBlockX(), chunk.getBlockZ()), true);
|
||||
world.getChunkManager().getLightingProvider().setLightEnabled(
|
||||
new ChunkPos(chunk.getBlockX(), chunk.getBlockZ()), true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
@ -51,6 +52,7 @@
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
@ -241,19 +243,20 @@ private ActionResult onRightClickBlock(PlayerEntity playerEntity, World world, H
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
private ActionResult onRightClickAir(PlayerEntity playerEntity, World world, Hand hand) {
|
||||
private TypedActionResult<ItemStack> onRightClickAir(PlayerEntity playerEntity, World world, Hand hand) {
|
||||
ItemStack stackInHand = playerEntity.getStackInHand(hand);
|
||||
if (shouldSkip() || hand == Hand.OFF_HAND || world.isClient) {
|
||||
return ActionResult.PASS;
|
||||
return TypedActionResult.pass(stackInHand);
|
||||
}
|
||||
|
||||
WorldEdit we = WorldEdit.getInstance();
|
||||
FabricPlayer player = adaptPlayer((ServerPlayerEntity) playerEntity);
|
||||
|
||||
if (we.handleRightClick(player)) {
|
||||
return ActionResult.SUCCESS;
|
||||
return TypedActionResult.success(stackInHand);
|
||||
}
|
||||
|
||||
return ActionResult.PASS;
|
||||
return TypedActionResult.pass(stackInHand);
|
||||
}
|
||||
|
||||
// TODO Pass empty left click to server
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.sk89q.worldedit.fabric;
|
||||
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeArray;
|
||||
|
||||
/**
|
||||
* Interface over a {@link BiomeArray} as a mutable object.
|
||||
*/
|
||||
public interface MutableBiomeArray {
|
||||
|
||||
/**
|
||||
* Hook into the given biome array, to allow edits on it.
|
||||
* @param biomeArray the biome array to edit
|
||||
* @return the mutable interface to the biome array
|
||||
*/
|
||||
static MutableBiomeArray inject(BiomeArray biomeArray) {
|
||||
// It's Mixin'd
|
||||
return (MutableBiomeArray) biomeArray;
|
||||
}
|
||||
|
||||
void setBiome(int x, int y, int z, Biome biome);
|
||||
|
||||
}
|
@ -104,19 +104,19 @@ public static net.minecraft.nbt.ListTag toNative(ListTag tag) {
|
||||
}
|
||||
|
||||
public static net.minecraft.nbt.LongTag toNative(LongTag tag) {
|
||||
return new net.minecraft.nbt.LongTag(tag.getValue());
|
||||
return net.minecraft.nbt.LongTag.of(tag.getValue());
|
||||
}
|
||||
|
||||
public static net.minecraft.nbt.StringTag toNative(StringTag tag) {
|
||||
return new net.minecraft.nbt.StringTag(tag.getValue());
|
||||
return net.minecraft.nbt.StringTag.of(tag.getValue());
|
||||
}
|
||||
|
||||
public static net.minecraft.nbt.IntTag toNative(IntTag tag) {
|
||||
return new net.minecraft.nbt.IntTag(tag.getValue());
|
||||
return net.minecraft.nbt.IntTag.of(tag.getValue());
|
||||
}
|
||||
|
||||
public static net.minecraft.nbt.ByteTag toNative(ByteTag tag) {
|
||||
return new net.minecraft.nbt.ByteTag(tag.getValue());
|
||||
return net.minecraft.nbt.ByteTag.of(tag.getValue());
|
||||
}
|
||||
|
||||
public static net.minecraft.nbt.ByteArrayTag toNative(ByteArrayTag tag) {
|
||||
@ -133,15 +133,15 @@ public static net.minecraft.nbt.CompoundTag toNative(CompoundTag tag) {
|
||||
}
|
||||
|
||||
public static net.minecraft.nbt.FloatTag toNative(FloatTag tag) {
|
||||
return new net.minecraft.nbt.FloatTag(tag.getValue());
|
||||
return net.minecraft.nbt.FloatTag.of(tag.getValue());
|
||||
}
|
||||
|
||||
public static net.minecraft.nbt.ShortTag toNative(ShortTag tag) {
|
||||
return new net.minecraft.nbt.ShortTag(tag.getValue());
|
||||
return net.minecraft.nbt.ShortTag.of(tag.getValue());
|
||||
}
|
||||
|
||||
public static net.minecraft.nbt.DoubleTag toNative(DoubleTag tag) {
|
||||
return new net.minecraft.nbt.DoubleTag(tag.getValue());
|
||||
return net.minecraft.nbt.DoubleTag.of(tag.getValue());
|
||||
}
|
||||
|
||||
public static Tag fromNative(net.minecraft.nbt.Tag other) {
|
||||
@ -232,7 +232,7 @@ public static CompoundTag fromNative(net.minecraft.nbt.CompoundTag other) {
|
||||
Set<String> tags = other.getKeys();
|
||||
Map<String, Tag> map = new HashMap<>();
|
||||
for (String tagName : tags) {
|
||||
map.put(tagName, fromNative(other.getTag(tagName)));
|
||||
map.put(tagName, fromNative(other.get(tagName)));
|
||||
}
|
||||
return new CompoundTag(map);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public List<T> getValues() {
|
||||
|
||||
@Override
|
||||
public T getValueFor(String string) throws IllegalArgumentException {
|
||||
Optional<T> val = property.getValue(string);
|
||||
Optional<T> val = property.parse(string);
|
||||
checkArgument(val.isPresent(), "%s has no value for %s", getName(), string);
|
||||
return val.get();
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.fabric.mixin;
|
||||
|
||||
import com.sk89q.worldedit.fabric.MutableBiomeArray;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeArray;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
@ -20,15 +20,15 @@
|
||||
package com.sk89q.worldedit.fabric.mixin;
|
||||
|
||||
import com.sk89q.worldedit.extension.platform.Watchdog;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.NonBlockingThreadExecutor;
|
||||
import net.minecraft.util.SystemUtil;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.thread.ReentrantThreadExecutor;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public abstract class MixinMinecraftServer extends NonBlockingThreadExecutor<ServerTask> implements Watchdog {
|
||||
public abstract class MixinMinecraftServer extends ReentrantThreadExecutor<ServerTask> implements Watchdog {
|
||||
|
||||
public MixinMinecraftServer(String name) {
|
||||
super(name);
|
||||
@ -39,7 +39,7 @@ public MixinMinecraftServer(String name) {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
timeReference = SystemUtil.getMeasuringTimeMs();
|
||||
timeReference = Util.getMeasuringTimeMs();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
"package": "com.sk89q.worldedit.fabric.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinBiomeArray",
|
||||
"MixinServerPlayerEntity",
|
||||
"MixinMinecraftServer",
|
||||
"AccessorServerPlayerEntity"
|
||||
|
Loading…
Reference in New Issue
Block a user