3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

Merge pull request #482 from EngineHub/forge-1.14

Update to Forge 1.14.
Dieser Commit ist enthalten in:
Kenzie Togami 2019-06-16 14:03:35 -07:00 committet von GitHub
Commit c97071c0f4
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
23 geänderte Dateien mit 533 neuen und 569 gelöschten Zeilen

Datei anzeigen

@ -58,8 +58,6 @@ public class SinglePickaxe implements BlockTool {
player.printError("Max blocks change limit reached."); player.printError("Max blocks change limit reached.");
} }
world.playEffect(clicked.toVector(), 2001, blockType.getLegacyId());
return true; return true;
} }

Datei anzeigen

@ -14,8 +14,8 @@ buildscript {
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'net.minecraftforge.gradle' apply plugin: 'net.minecraftforge.gradle'
def minecraftVersion = "1.13.2" def minecraftVersion = "1.14.2"
def forgeVersion = "25.0.146" def forgeVersion = "26.0.25"
configurations.all { Configuration it -> configurations.all { Configuration it ->
it.resolutionStrategy { ResolutionStrategy rs -> it.resolutionStrategy { ResolutionStrategy rs ->
@ -36,7 +36,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
minecraft { minecraft {
mappings channel: 'snapshot', version: '20190415-1.13.2' mappings channel: 'snapshot', version: "20190614-${minecraftVersion}"
runs { runs {
client = { client = {
@ -57,7 +57,6 @@ minecraft {
} }
} }
accessTransformer = file('worldedit_at.cfg')
} }
project.archivesBaseName = "${project.archivesBaseName}-mc${minecraftVersion}" project.archivesBaseName = "${project.archivesBaseName}-mc${minecraftVersion}"
@ -84,8 +83,7 @@ processResources {
jar { jar {
manifest { manifest {
attributes("Class-Path": "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar", attributes("Class-Path": "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar",
"WorldEdit-Version": version, "WorldEdit-Version": version)
"FMLAT": "worldedit_at.cfg")
} }
} }

Datei anzeigen

@ -36,7 +36,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.util.Substring; import com.sk89q.worldedit.internal.util.Substring;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import org.enginehub.piston.inject.InjectedValueStore; import org.enginehub.piston.inject.InjectedValueStore;
import org.enginehub.piston.inject.Key; import org.enginehub.piston.inject.Key;
import org.enginehub.piston.inject.MapBackedValueStore; import org.enginehub.piston.inject.MapBackedValueStore;
@ -78,8 +78,8 @@ public final class CommandWrapper {
private static Predicate<CommandSource> requirementsFor(org.enginehub.piston.Command mapping) { private static Predicate<CommandSource> requirementsFor(org.enginehub.piston.Command mapping) {
return ctx -> { return ctx -> {
final Entity entity = ctx.getEntity(); final Entity entity = ctx.getEntity();
if (!(entity instanceof EntityPlayerMP)) return true; if (!(entity instanceof ServerPlayerEntity)) return true;
final Actor actor = ForgeAdapter.adaptPlayer(((EntityPlayerMP) entity)); final Actor actor = ForgeAdapter.adaptPlayer(((ServerPlayerEntity) entity));
InjectedValueStore store = MapBackedValueStore.create(); InjectedValueStore store = MapBackedValueStore.create();
store.injectValue(Key.of(Actor.class), context -> Optional.of(actor)); store.injectValue(Key.of(Actor.class), context -> Optional.of(actor));
return mapping.getCondition().satisfied(store); return mapping.getCondition().satisfied(store);

Datei anzeigen

@ -40,15 +40,13 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.DirectionProperty; import net.minecraft.state.DirectionProperty;
import net.minecraft.state.IProperty; import net.minecraft.state.IProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -92,20 +90,20 @@ public final class ForgeAdapter {
return new Vec3d(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); return new Vec3d(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
} }
public static EnumFacing adapt(Direction face) { public static net.minecraft.util.Direction adapt(Direction face) {
switch (face) { switch (face) {
case NORTH: return EnumFacing.NORTH; case NORTH: return net.minecraft.util.Direction.NORTH;
case SOUTH: return EnumFacing.SOUTH; case SOUTH: return net.minecraft.util.Direction.SOUTH;
case WEST: return EnumFacing.WEST; case WEST: return net.minecraft.util.Direction.WEST;
case EAST: return EnumFacing.EAST; case EAST: return net.minecraft.util.Direction.EAST;
case DOWN: return EnumFacing.DOWN; case DOWN: return net.minecraft.util.Direction.DOWN;
case UP: case UP:
default: default:
return EnumFacing.UP; return net.minecraft.util.Direction.UP;
} }
} }
public static Direction adaptEnumFacing(EnumFacing face) { public static Direction adaptEnumFacing(net.minecraft.util.Direction face) {
switch (face) { switch (face) {
case NORTH: return Direction.NORTH; case NORTH: return Direction.NORTH;
case SOUTH: return Direction.SOUTH; case SOUTH: return Direction.SOUTH;
@ -149,7 +147,7 @@ public final class ForgeAdapter {
for (Map.Entry<IProperty<?>, Comparable<?>> prop : mcProps.entrySet()) { for (Map.Entry<IProperty<?>, Comparable<?>> prop : mcProps.entrySet()) {
Object value = prop.getValue(); Object value = prop.getValue();
if (prop.getKey() instanceof DirectionProperty) { if (prop.getKey() instanceof DirectionProperty) {
value = adaptEnumFacing((EnumFacing) value); value = adaptEnumFacing((net.minecraft.util.Direction) value);
} else if (prop.getKey() instanceof net.minecraft.state.EnumProperty) { } else if (prop.getKey() instanceof net.minecraft.state.EnumProperty) {
value = ((IStringSerializable) value).getName(); value = ((IStringSerializable) value).getName();
} }
@ -158,14 +156,14 @@ public final class ForgeAdapter {
return props; return props;
} }
private static IBlockState applyProperties(StateContainer<Block, IBlockState> stateContainer, IBlockState newState, Map<Property<?>, Object> states) { 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()) { for (Map.Entry<Property<?>, Object> state : states.entrySet()) {
IProperty property = stateContainer.getProperty(state.getKey().getName()); IProperty property = stateContainer.getProperty(state.getKey().getName());
Comparable value = (Comparable) state.getValue(); Comparable value = (Comparable) state.getValue();
// we may need to adapt this value, depending on the source prop // we may need to adapt this value, depending on the source prop
if (property instanceof DirectionProperty) { if (property instanceof DirectionProperty) {
Direction dir = (Direction) value; Direction dir = (Direction) value;
value = ForgeAdapter.adapt(dir); value = adapt(dir);
} else if (property instanceof net.minecraft.state.EnumProperty) { } else if (property instanceof net.minecraft.state.EnumProperty) {
String enumName = (String) value; String enumName = (String) value;
value = ((net.minecraft.state.EnumProperty<?>) property).parseValue((String) value).orElseGet(() -> { value = ((net.minecraft.state.EnumProperty<?>) property).parseValue((String) value).orElseGet(() -> {
@ -178,16 +176,16 @@ public final class ForgeAdapter {
return newState; return newState;
} }
public static IBlockState adapt(BlockState blockState) { public static net.minecraft.block.BlockState adapt(BlockState blockState) {
Block mcBlock = ForgeAdapter.adapt(blockState.getBlockType()); Block mcBlock = adapt(blockState.getBlockType());
IBlockState newState = mcBlock.getDefaultState(); net.minecraft.block.BlockState newState = mcBlock.getDefaultState();
Map<Property<?>, Object> states = blockState.getStates(); Map<Property<?>, Object> states = blockState.getStates();
return applyProperties(mcBlock.getStateContainer(), newState, states); return applyProperties(mcBlock.getStateContainer(), newState, states);
} }
public static BlockState adapt(IBlockState blockState) { public static BlockState adapt(net.minecraft.block.BlockState blockState) {
BlockType blockType = adapt(blockState.getBlock()); BlockType blockType = adapt(blockState.getBlock());
return blockType.getState(ForgeAdapter.adaptProperties(blockType, blockState.getValues())); return blockType.getState(adaptProperties(blockType, blockState.getValues()));
} }
public static Block adapt(BlockType blockType) { public static Block adapt(BlockType blockType) {
@ -207,7 +205,7 @@ public final class ForgeAdapter {
} }
public static ItemStack adapt(BaseItemStack baseItemStack) { public static ItemStack adapt(BaseItemStack baseItemStack) {
NBTTagCompound forgeCompound = null; CompoundNBT forgeCompound = null;
if (baseItemStack.getNbtData() != null) { if (baseItemStack.getNbtData() != null) {
forgeCompound = NBTConverter.toNative(baseItemStack.getNbtData()); forgeCompound = NBTConverter.toNative(baseItemStack.getNbtData());
} }
@ -237,7 +235,7 @@ public final class ForgeAdapter {
* @param player the player * @param player the player
* @return the WorldEdit player * @return the WorldEdit player
*/ */
public static ForgePlayer adaptPlayer(EntityPlayerMP player) { public static ForgePlayer adaptPlayer(ServerPlayerEntity player) {
checkNotNull(player); checkNotNull(player);
return new ForgePlayer(player); return new ForgePlayer(player);
} }

Datei anzeigen

@ -22,7 +22,7 @@ package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial; import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
import net.minecraft.block.material.EnumPushReaction; import net.minecraft.block.material.PushReaction;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -63,12 +63,12 @@ public class ForgeBlockMaterial extends PassthroughBlockMaterial {
@Override @Override
public boolean isFragileWhenPushed() { public boolean isFragileWhenPushed() {
return delegate.getPushReaction() == EnumPushReaction.DESTROY; return delegate.getPushReaction() == PushReaction.DESTROY;
} }
@Override @Override
public boolean isUnpushable() { public boolean isUnpushable() {
return delegate.getPushReaction() == EnumPushReaction.BLOCK; return delegate.getPushReaction() == PushReaction.BLOCK;
} }
@Override @Override

Datei anzeigen

@ -26,7 +26,6 @@ import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.BundledBlockRegistry; import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.state.IProperty; import net.minecraft.state.IProperty;
import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.fml.loading.FMLLoader;
@ -77,7 +76,7 @@ public class ForgeBlockRegistry extends BundledBlockRegistry {
@Override @Override
public OptionalInt getInternalBlockStateId(BlockState state) { public OptionalInt getInternalBlockStateId(BlockState state) {
IBlockState equivalent = ForgeAdapter.adapt(state); net.minecraft.block.BlockState equivalent = ForgeAdapter.adapt(state);
return OptionalInt.of(Block.getStateId(equivalent)); return OptionalInt.of(Block.getStateId(equivalent));
} }
} }

Datei anzeigen

@ -30,27 +30,26 @@ import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import com.mojang.datafixers.DSL.TypeReference; import com.mojang.datafixers.DSL.TypeReference;
import com.mojang.datafixers.DataFixTypes;
import com.mojang.datafixers.DataFixer; import com.mojang.datafixers.DataFixer;
import com.mojang.datafixers.DataFixerBuilder; import com.mojang.datafixers.DataFixerBuilder;
import com.mojang.datafixers.Dynamic; import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.schemas.Schema; import com.mojang.datafixers.schemas.Schema;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import net.minecraft.item.EnumDyeColor; import net.minecraft.item.DyeColor;
import net.minecraft.nbt.INBTBase; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.NBTDynamicOps; import net.minecraft.nbt.NBTDynamicOps;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.StringNBT;
import net.minecraft.nbt.NBTTagString; import net.minecraft.nbt.FloatNBT;
import net.minecraft.nbt.NBTTagFloat; import net.minecraft.util.Direction;
import net.minecraft.nbt.NBTTagList; import net.minecraft.util.JSONUtils;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.JsonUtils;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils; import net.minecraft.util.StringUtils;
import net.minecraft.util.datafix.DataFixesManager; import net.minecraft.util.datafix.DataFixesManager;
import net.minecraft.util.datafix.TypeReferences; import net.minecraft.util.datafix.TypeReferences;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.StringTextComponent;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -104,50 +103,50 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
} }
private CompoundTag fixChunk(CompoundTag originalChunk, int srcVer) { private CompoundTag fixChunk(CompoundTag originalChunk, int srcVer) {
NBTTagCompound tag = NBTConverter.toNative(originalChunk); CompoundNBT tag = NBTConverter.toNative(originalChunk);
NBTTagCompound fixed = convert(LegacyType.CHUNK, tag, srcVer); CompoundNBT fixed = convert(LegacyType.CHUNK, tag, srcVer);
return NBTConverter.fromNative(fixed); return NBTConverter.fromNative(fixed);
} }
private CompoundTag fixBlockEntity(CompoundTag origTileEnt, int srcVer) { private CompoundTag fixBlockEntity(CompoundTag origTileEnt, int srcVer) {
NBTTagCompound tag = NBTConverter.toNative(origTileEnt); CompoundNBT tag = NBTConverter.toNative(origTileEnt);
NBTTagCompound fixed = convert(LegacyType.BLOCK_ENTITY, tag, srcVer); CompoundNBT fixed = convert(LegacyType.BLOCK_ENTITY, tag, srcVer);
return NBTConverter.fromNative(fixed); return NBTConverter.fromNative(fixed);
} }
private CompoundTag fixEntity(CompoundTag origEnt, int srcVer) { private CompoundTag fixEntity(CompoundTag origEnt, int srcVer) {
NBTTagCompound tag = NBTConverter.toNative(origEnt); CompoundNBT tag = NBTConverter.toNative(origEnt);
NBTTagCompound fixed = convert(LegacyType.ENTITY, tag, srcVer); CompoundNBT fixed = convert(LegacyType.ENTITY, tag, srcVer);
return NBTConverter.fromNative(fixed); return NBTConverter.fromNative(fixed);
} }
private String fixBlockState(String blockState, int srcVer) { private String fixBlockState(String blockState, int srcVer) {
NBTTagCompound stateNBT = stateToNBT(blockState); CompoundNBT stateNBT = stateToNBT(blockState);
Dynamic<INBTBase> dynamic = new Dynamic<>(OPS_NBT, stateNBT); Dynamic<INBT> dynamic = new Dynamic<>(OPS_NBT, stateNBT);
NBTTagCompound fixed = (NBTTagCompound) INSTANCE.fixer.update(TypeReferences.BLOCK_STATE, dynamic, srcVer, DATA_VERSION).getValue(); CompoundNBT fixed = (CompoundNBT) INSTANCE.fixer.update(TypeReferences.BLOCK_STATE, dynamic, srcVer, DATA_VERSION).getValue();
return nbtToState(fixed); return nbtToState(fixed);
} }
private String nbtToState(NBTTagCompound tagCompound) { private String nbtToState(CompoundNBT tagCompound) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(tagCompound.getString("Name")); sb.append(tagCompound.getString("Name"));
if (tagCompound.contains("Properties", 10)) { if (tagCompound.contains("Properties", 10)) {
sb.append('['); sb.append('[');
NBTTagCompound props = tagCompound.getCompound("Properties"); CompoundNBT props = tagCompound.getCompound("Properties");
sb.append(props.keySet().stream().map(k -> k + "=" + props.getString(k).replace("\"", "")).collect(Collectors.joining(","))); sb.append(props.keySet().stream().map(k -> k + "=" + props.getString(k).replace("\"", "")).collect(Collectors.joining(",")));
sb.append(']'); sb.append(']');
} }
return sb.toString(); return sb.toString();
} }
private static NBTTagCompound stateToNBT(String blockState) { private static CompoundNBT stateToNBT(String blockState) {
int propIdx = blockState.indexOf('['); int propIdx = blockState.indexOf('[');
NBTTagCompound tag = new NBTTagCompound(); CompoundNBT tag = new CompoundNBT();
if (propIdx < 0) { if (propIdx < 0) {
tag.putString("Name", blockState); tag.putString("Name", blockState);
} else { } else {
tag.putString("Name", blockState.substring(0, propIdx)); tag.putString("Name", blockState.substring(0, propIdx));
NBTTagCompound propTag = new NBTTagCompound(); CompoundNBT propTag = new CompoundNBT();
String props = blockState.substring(propIdx + 1, blockState.length() - 1); String props = blockState.substring(propIdx + 1, blockState.length() - 1);
String[] propArr = props.split(","); String[] propArr = props.split(",");
for (String pair : propArr) { for (String pair : propArr) {
@ -168,8 +167,8 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
} }
private static String fixName(String key, int srcVer, TypeReference type) { private static String fixName(String key, int srcVer, TypeReference type) {
return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, new NBTTagString(key)), srcVer, DATA_VERSION) return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, new StringNBT(key)), srcVer, DATA_VERSION)
.getStringValue().orElse(key); .asString().orElse(key);
} }
private static final NBTDynamicOps OPS_NBT = NBTDynamicOps.INSTANCE; private static final NBTDynamicOps OPS_NBT = NBTDynamicOps.INSTANCE;
@ -185,14 +184,14 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
private static final Map<String, LegacyType> DFU_TO_LEGACY = new HashMap<>(); private static final Map<String, LegacyType> DFU_TO_LEGACY = new HashMap<>();
public enum LegacyType { public enum LegacyType {
LEVEL(DataFixTypes.LEVEL), LEVEL(TypeReferences.LEVEL),
PLAYER(DataFixTypes.PLAYER), PLAYER(TypeReferences.PLAYER),
CHUNK(DataFixTypes.CHUNK), CHUNK(TypeReferences.CHUNK),
BLOCK_ENTITY(TypeReferences.BLOCK_ENTITY), BLOCK_ENTITY(TypeReferences.BLOCK_ENTITY),
ENTITY(TypeReferences.ENTITY), ENTITY(TypeReferences.ENTITY),
ITEM_INSTANCE(TypeReferences.ITEM_STACK), ITEM_INSTANCE(TypeReferences.ITEM_STACK),
OPTIONS(DataFixTypes.OPTIONS), OPTIONS(TypeReferences.OPTIONS),
STRUCTURE(DataFixTypes.STRUCTURE); STRUCTURE(TypeReferences.STRUCTURE);
private final TypeReference type; private final TypeReference type;
@ -206,7 +205,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
} }
} }
public ForgeDataFixer(int dataVersion) { ForgeDataFixer(int dataVersion) {
super(dataVersion); super(dataVersion);
DATA_VERSION = dataVersion; DATA_VERSION = dataVersion;
INSTANCE = this; INSTANCE = this;
@ -215,8 +214,6 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
this.fixer = new WrappedDataFixer(DataFixesManager.getDataFixer()); this.fixer = new WrappedDataFixer(DataFixesManager.getDataFixer());
} }
// Called after fixers are built and ready for FIXING
@Override @Override
public DataFixer build(final Executor executor) { public DataFixer build(final Executor executor) {
return fixer; return fixer;
@ -233,7 +230,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
public <T> Dynamic<T> update(TypeReference type, Dynamic<T> dynamic, int sourceVer, int targetVer) { public <T> Dynamic<T> update(TypeReference type, Dynamic<T> dynamic, int sourceVer, int targetVer) {
LegacyType legacyType = DFU_TO_LEGACY.get(type.typeName()); LegacyType legacyType = DFU_TO_LEGACY.get(type.typeName());
if (sourceVer < LEGACY_VERSION && legacyType != null) { if (sourceVer < LEGACY_VERSION && legacyType != null) {
NBTTagCompound cmp = (NBTTagCompound) dynamic.getValue(); CompoundNBT cmp = (CompoundNBT) dynamic.getValue();
int desiredVersion = Math.min(targetVer, LEGACY_VERSION); int desiredVersion = Math.min(targetVer, LEGACY_VERSION);
cmp = convert(legacyType, cmp, sourceVer, desiredVersion); cmp = convert(legacyType, cmp, sourceVer, desiredVersion);
@ -243,7 +240,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return realFixer.update(type, dynamic, sourceVer, targetVer); return realFixer.update(type, dynamic, sourceVer, targetVer);
} }
private NBTTagCompound convert(LegacyType type, NBTTagCompound cmp, int sourceVer, int desiredVersion) { private CompoundNBT convert(LegacyType type, CompoundNBT cmp, int sourceVer, int desiredVersion) {
List<DataConverter> converters = ForgeDataFixer.this.converters.get(type); List<DataConverter> converters = ForgeDataFixer.this.converters.get(type);
if (converters != null && !converters.isEmpty()) { if (converters != null && !converters.isEmpty()) {
for (DataConverter converter : converters) { for (DataConverter converter : converters) {
@ -270,44 +267,44 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
} }
} }
public static NBTTagCompound convert(LegacyType type, NBTTagCompound cmp) { public static CompoundNBT convert(LegacyType type, CompoundNBT cmp) {
return convert(type.getDFUType(), cmp); return convert(type.getDFUType(), cmp);
} }
public static NBTTagCompound convert(LegacyType type, NBTTagCompound cmp, int sourceVer) { public static CompoundNBT convert(LegacyType type, CompoundNBT cmp, int sourceVer) {
return convert(type.getDFUType(), cmp, sourceVer); return convert(type.getDFUType(), cmp, sourceVer);
} }
public static NBTTagCompound convert(LegacyType type, NBTTagCompound cmp, int sourceVer, int targetVer) { public static CompoundNBT convert(LegacyType type, CompoundNBT cmp, int sourceVer, int targetVer) {
return convert(type.getDFUType(), cmp, sourceVer, targetVer); return convert(type.getDFUType(), cmp, sourceVer, targetVer);
} }
public static NBTTagCompound convert(TypeReference type, NBTTagCompound cmp) { public static CompoundNBT convert(TypeReference type, CompoundNBT cmp) {
int i = cmp.contains("DataVersion", 99) ? cmp.getInt("DataVersion") : -1; int i = cmp.contains("DataVersion", 99) ? cmp.getInt("DataVersion") : -1;
return convert(type, cmp, i); return convert(type, cmp, i);
} }
public static NBTTagCompound convert(TypeReference type, NBTTagCompound cmp, int sourceVer) { public static CompoundNBT convert(TypeReference type, CompoundNBT cmp, int sourceVer) {
return convert(type, cmp, sourceVer, DATA_VERSION); return convert(type, cmp, sourceVer, DATA_VERSION);
} }
public static NBTTagCompound convert(TypeReference type, NBTTagCompound cmp, int sourceVer, int targetVer) { public static CompoundNBT convert(TypeReference type, CompoundNBT cmp, int sourceVer, int targetVer) {
if (sourceVer >= targetVer) { if (sourceVer >= targetVer) {
return cmp; return cmp;
} }
return (NBTTagCompound) INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, cmp), sourceVer, targetVer).getValue(); return (CompoundNBT) INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, cmp), sourceVer, targetVer).getValue();
} }
public interface DataInspector { public interface DataInspector {
NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer); CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer);
} }
public interface DataConverter { public interface DataConverter {
int getDataVersion(); int getDataVersion();
NBTTagCompound convert(NBTTagCompound cmp); CompoundNBT convert(CompoundNBT cmp);
} }
@ -584,19 +581,19 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return key; return key;
} }
private static void convertCompound(LegacyType type, NBTTagCompound cmp, String key, int sourceVer, int targetVer) { private static void convertCompound(LegacyType type, CompoundNBT cmp, String key, int sourceVer, int targetVer) {
cmp.put(key, convert(type, cmp.getCompound(key), sourceVer, targetVer)); cmp.put(key, convert(type, cmp.getCompound(key), sourceVer, targetVer));
} }
private static void convertItem(NBTTagCompound nbttagcompound, String key, int sourceVer, int targetVer) { private static void convertItem(CompoundNBT nbttagcompound, String key, int sourceVer, int targetVer) {
if (nbttagcompound.contains(key, 10)) { if (nbttagcompound.contains(key, 10)) {
convertCompound(LegacyType.ITEM_INSTANCE, nbttagcompound, key, sourceVer, targetVer); convertCompound(LegacyType.ITEM_INSTANCE, nbttagcompound, key, sourceVer, targetVer);
} }
} }
private static void convertItems(NBTTagCompound nbttagcompound, String key, int sourceVer, int targetVer) { private static void convertItems(CompoundNBT nbttagcompound, String key, int sourceVer, int targetVer) {
if (nbttagcompound.contains(key, 9)) { if (nbttagcompound.contains(key, 9)) {
NBTTagList nbttaglist = nbttagcompound.getList(key, 10); ListNBT nbttaglist = nbttagcompound.getList(key, 10);
for (int j = 0; j < nbttaglist.size(); ++j) { for (int j = 0; j < nbttaglist.size(); ++j) {
nbttaglist.add(j, convert(LegacyType.ITEM_INSTANCE, nbttaglist.getCompound(j), sourceVer, targetVer)); nbttaglist.add(j, convert(LegacyType.ITEM_INSTANCE, nbttaglist.getCompound(j), sourceVer, targetVer));
@ -615,19 +612,19 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
} }
@Override @Override
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
NBTTagList nbttaglist = cmp.getList("Equipment", 10); ListNBT nbttaglist = cmp.getList("Equipment", 10);
NBTTagList nbttaglist1; ListNBT nbttaglist1;
if (!nbttaglist.isEmpty() && !cmp.contains("HandItems", 10)) { if (!nbttaglist.isEmpty() && !cmp.contains("HandItems", 10)) {
nbttaglist1 = new NBTTagList(); nbttaglist1 = new ListNBT();
nbttaglist1.add(nbttaglist.get(0)); nbttaglist1.add(nbttaglist.get(0));
nbttaglist1.add(new NBTTagCompound()); nbttaglist1.add(new CompoundNBT());
cmp.put("HandItems", nbttaglist1); cmp.put("HandItems", nbttaglist1);
} }
if (nbttaglist.size() > 1 && !cmp.contains("ArmorItem", 10)) { if (nbttaglist.size() > 1 && !cmp.contains("ArmorItem", 10)) {
nbttaglist1 = new NBTTagList(); nbttaglist1 = new ListNBT();
nbttaglist1.add(nbttaglist.get(1)); nbttaglist1.add(nbttaglist.get(1));
nbttaglist1.add(nbttaglist.get(2)); nbttaglist1.add(nbttaglist.get(2));
nbttaglist1.add(nbttaglist.get(3)); nbttaglist1.add(nbttaglist.get(3));
@ -638,21 +635,21 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
cmp.remove("Equipment"); cmp.remove("Equipment");
if (cmp.contains("DropChances", 9)) { if (cmp.contains("DropChances", 9)) {
nbttaglist1 = cmp.getList("DropChances", 5); nbttaglist1 = cmp.getList("DropChances", 5);
NBTTagList nbttaglist2; ListNBT nbttaglist2;
if (!cmp.contains("HandDropChances", 10)) { if (!cmp.contains("HandDropChances", 10)) {
nbttaglist2 = new NBTTagList(); nbttaglist2 = new ListNBT();
nbttaglist2.add(new NBTTagFloat(nbttaglist1.getFloat(0))); nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(0)));
nbttaglist2.add(new NBTTagFloat(0.0F)); nbttaglist2.add(new FloatNBT(0.0F));
cmp.put("HandDropChances", nbttaglist2); cmp.put("HandDropChances", nbttaglist2);
} }
if (!cmp.contains("ArmorDropChances", 10)) { if (!cmp.contains("ArmorDropChances", 10)) {
nbttaglist2 = new NBTTagList(); nbttaglist2 = new ListNBT();
nbttaglist2.add(new NBTTagFloat(nbttaglist1.getFloat(1))); nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(1)));
nbttaglist2.add(new NBTTagFloat(nbttaglist1.getFloat(2))); nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(2)));
nbttaglist2.add(new NBTTagFloat(nbttaglist1.getFloat(3))); nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(3)));
nbttaglist2.add(new NBTTagFloat(nbttaglist1.getFloat(4))); nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(4)));
cmp.put("ArmorDropChances", nbttaglist2); cmp.put("ArmorDropChances", nbttaglist2);
} }
@ -681,14 +678,14 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
} }
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (!cmp.contains("tag", 10)) { if (!cmp.contains("tag", 10)) {
return cmp; return cmp;
} else { } else {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag"); CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
if (nbttagcompound1.contains("BlockEntityTag", 10)) { if (nbttagcompound1.contains("BlockEntityTag", 10)) {
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag"); CompoundNBT nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
String s = cmp.getString("id"); String s = cmp.getString("id");
String s1 = convertEntityId(sourceVer, s); String s1 = convertEntityId(sourceVer, s);
boolean flag; boolean flag;
@ -812,11 +809,11 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
DataInspectorEntity() {} DataInspectorEntity() {}
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag"); CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
if (nbttagcompound1.contains("EntityTag", 10)) { if (nbttagcompound1.contains("EntityTag", 10)) {
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("EntityTag"); CompoundNBT nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
String s = cmp.getString("id"); String s = cmp.getString("id");
String s1; String s1;
@ -859,7 +856,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
this.key = getKey(type); this.key = getKey(type);
} }
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (this.key.equals(new ResourceLocation(cmp.getString("id")))) { if (this.key.equals(new ResourceLocation(cmp.getString("id")))) {
cmp = this.inspectChecked(cmp, sourceVer, targetVer); cmp = this.inspectChecked(cmp, sourceVer, targetVer);
} }
@ -867,7 +864,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return cmp; return cmp;
} }
abstract NBTTagCompound inspectChecked(NBTTagCompound nbttagcompound, int sourceVer, int targetVer); abstract CompoundNBT inspectChecked(CompoundNBT nbttagcompound, int sourceVer, int targetVer);
} }
private static class DataInspectorItemList extends DataInspectorTagged { private static class DataInspectorItemList extends DataInspectorTagged {
@ -879,7 +876,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
this.keys = astring; this.keys = astring;
} }
NBTTagCompound inspectChecked(NBTTagCompound nbttagcompound, int sourceVer, int targetVer) { CompoundNBT inspectChecked(CompoundNBT nbttagcompound, int sourceVer, int targetVer) {
for (String s : this.keys) { for (String s : this.keys) {
ForgeDataFixer.convertItems(nbttagcompound, s, sourceVer, targetVer); ForgeDataFixer.convertItems(nbttagcompound, s, sourceVer, targetVer);
} }
@ -896,7 +893,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
this.keys = astring; this.keys = astring;
} }
NBTTagCompound inspectChecked(NBTTagCompound nbttagcompound, int sourceVer, int targetVer) { CompoundNBT inspectChecked(CompoundNBT nbttagcompound, int sourceVer, int targetVer) {
for (String key : this.keys) { for (String key : this.keys) {
ForgeDataFixer.convertItem(nbttagcompound, key, sourceVer, targetVer); ForgeDataFixer.convertItem(nbttagcompound, key, sourceVer, targetVer);
} }
@ -915,7 +912,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 102; return 102;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if (cmp.contains("id", 99)) { if (cmp.contains("id", 99)) {
short short0 = cmp.getShort("id"); short short0 = cmp.getShort("id");
@ -1254,7 +1251,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 147; return 147;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("ArmorStand".equals(cmp.getString("id")) && cmp.getBoolean("Silent") && !cmp.getBoolean("Marker")) { if ("ArmorStand".equals(cmp.getString("id")) && cmp.getBoolean("Silent") && !cmp.getBoolean("Marker")) {
cmp.remove("Silent"); cmp.remove("Silent");
} }
@ -1271,20 +1268,20 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 804; return 804;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:banner".equals(cmp.getString("id")) && cmp.contains("tag", 10)) { if ("minecraft:banner".equals(cmp.getString("id")) && cmp.contains("tag", 10)) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag"); CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
if (nbttagcompound1.contains("BlockEntityTag", 10)) { if (nbttagcompound1.contains("BlockEntityTag", 10)) {
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag"); CompoundNBT nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
if (nbttagcompound2.contains("Base", 99)) { if (nbttagcompound2.contains("Base", 99)) {
cmp.putShort("Damage", (short) (nbttagcompound2.getShort("Base") & 15)); cmp.putShort("Damage", (short) (nbttagcompound2.getShort("Base") & 15));
if (nbttagcompound1.contains("display", 10)) { if (nbttagcompound1.contains("display", 10)) {
NBTTagCompound nbttagcompound3 = nbttagcompound1.getCompound("display"); CompoundNBT nbttagcompound3 = nbttagcompound1.getCompound("display");
if (nbttagcompound3.contains("Lore", 9)) { if (nbttagcompound3.contains("Lore", 9)) {
NBTTagList nbttaglist = nbttagcompound3.getList("Lore", 8); ListNBT nbttaglist = nbttagcompound3.getList("Lore", 8);
if (nbttaglist.size() == 1 && "(+NBT)".equals(nbttaglist.getString(0))) { if (nbttaglist.size() == 1 && "(+NBT)".equals(nbttaglist.getString(0))) {
return cmp; return cmp;
@ -1318,9 +1315,9 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 102; return 102;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:potion".equals(cmp.getString("id"))) { if ("minecraft:potion".equals(cmp.getString("id"))) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag"); CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
short short0 = cmp.getShort("Damage"); short short0 = cmp.getShort("Damage");
if (!nbttagcompound1.contains("Potion", 8)) { if (!nbttagcompound1.contains("Potion", 8)) {
@ -1483,10 +1480,10 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 105; return 105;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:spawn_egg".equals(cmp.getString("id"))) { if ("minecraft:spawn_egg".equals(cmp.getString("id"))) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag"); CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("EntityTag"); CompoundNBT nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
short short0 = cmp.getShort("Damage"); short short0 = cmp.getShort("Damage");
if (!nbttagcompound2.contains("id", 8)) { if (!nbttagcompound2.contains("id", 8)) {
@ -1589,7 +1586,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 106; return 106;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("Minecart".equals(cmp.getString("id"))) { if ("Minecart".equals(cmp.getString("id"))) {
String s = "MinecartRideable"; String s = "MinecartRideable";
int i = cmp.getInt("Type"); int i = cmp.getInt("Type");
@ -1614,13 +1611,13 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 107; return 107;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if (!"MobSpawner".equals(cmp.getString("id"))) { if (!"MobSpawner".equals(cmp.getString("id"))) {
return cmp; return cmp;
} else { } else {
if (cmp.contains("EntityId", 8)) { if (cmp.contains("EntityId", 8)) {
String s = cmp.getString("EntityId"); String s = cmp.getString("EntityId");
NBTTagCompound nbttagcompound1 = cmp.getCompound("SpawnData"); CompoundNBT nbttagcompound1 = cmp.getCompound("SpawnData");
nbttagcompound1.putString("id", s.isEmpty() ? "Pig" : s); nbttagcompound1.putString("id", s.isEmpty() ? "Pig" : s);
cmp.put("SpawnData", nbttagcompound1); cmp.put("SpawnData", nbttagcompound1);
@ -1628,13 +1625,13 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
} }
if (cmp.contains("SpawnPotentials", 9)) { if (cmp.contains("SpawnPotentials", 9)) {
NBTTagList nbttaglist = cmp.getList("SpawnPotentials", 10); ListNBT nbttaglist = cmp.getList("SpawnPotentials", 10);
for (int i = 0; i < nbttaglist.size(); ++i) { for (int i = 0; i < nbttaglist.size(); ++i) {
NBTTagCompound nbttagcompound2 = nbttaglist.getCompound(i); CompoundNBT nbttagcompound2 = nbttaglist.getCompound(i);
if (nbttagcompound2.contains("Type", 8)) { if (nbttagcompound2.contains("Type", 8)) {
NBTTagCompound nbttagcompound3 = nbttagcompound2.getCompound("Properties"); CompoundNBT nbttagcompound3 = nbttagcompound2.getCompound("Properties");
nbttagcompound3.putString("id", nbttagcompound2.getString("Type")); nbttagcompound3.putString("id", nbttagcompound2.getString("Type"));
nbttagcompound2.put("Entity", nbttagcompound3); nbttagcompound2.put("Entity", nbttagcompound3);
@ -1657,7 +1654,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 108; return 108;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if (cmp.contains("UUID", 8)) { if (cmp.contains("UUID", 8)) {
cmp.putUniqueId("UUID", UUID.fromString(cmp.getString("UUID"))); cmp.putUniqueId("UUID", UUID.fromString(cmp.getString("UUID")));
} }
@ -1676,7 +1673,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 109; return 109;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if (DataConverterHealth.a.contains(cmp.getString("id"))) { if (DataConverterHealth.a.contains(cmp.getString("id"))) {
float f; float f;
@ -1706,9 +1703,9 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 110; return 110;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("EntityHorse".equals(cmp.getString("id")) && !cmp.contains("SaddleItem", 10) && cmp.getBoolean("Saddle")) { if ("EntityHorse".equals(cmp.getString("id")) && !cmp.contains("SaddleItem", 10) && cmp.getBoolean("Saddle")) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); CompoundNBT nbttagcompound1 = new CompoundNBT();
nbttagcompound1.putString("id", "minecraft:saddle"); nbttagcompound1.putString("id", "minecraft:saddle");
nbttagcompound1.putByte("Count", (byte) 1); nbttagcompound1.putByte("Count", (byte) 1);
@ -1729,16 +1726,16 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 111; return 111;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
String s = cmp.getString("id"); String s = cmp.getString("id");
boolean flag = "Painting".equals(s); boolean flag = "Painting".equals(s);
boolean flag1 = "ItemFrame".equals(s); boolean flag1 = "ItemFrame".equals(s);
if ((flag || flag1) && !cmp.contains("Facing", 99)) { if ((flag || flag1) && !cmp.contains("Facing", 99)) {
EnumFacing enumdirection; Direction enumdirection;
if (cmp.contains("Direction", 99)) { if (cmp.contains("Direction", 99)) {
enumdirection = EnumFacing.byHorizontalIndex(cmp.getByte("Direction")); enumdirection = Direction.byHorizontalIndex(cmp.getByte("Direction"));
cmp.putInt("TileX", cmp.getInt("TileX") + enumdirection.getXOffset()); cmp.putInt("TileX", cmp.getInt("TileX") + enumdirection.getXOffset());
cmp.putInt("TileY", cmp.getInt("TileY") + enumdirection.getYOffset()); cmp.putInt("TileY", cmp.getInt("TileY") + enumdirection.getYOffset());
cmp.putInt("TileZ", cmp.getInt("TileZ") + enumdirection.getZOffset()); cmp.putInt("TileZ", cmp.getInt("TileZ") + enumdirection.getZOffset());
@ -1747,7 +1744,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
cmp.putByte("ItemRotation", (byte) (cmp.getByte("ItemRotation") * 2)); cmp.putByte("ItemRotation", (byte) (cmp.getByte("ItemRotation") * 2));
} }
} else { } else {
enumdirection = EnumFacing.byHorizontalIndex(cmp.getByte("Dir")); enumdirection = Direction.byHorizontalIndex(cmp.getByte("Dir"));
cmp.remove("Dir"); cmp.remove("Dir");
} }
@ -1766,8 +1763,8 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 113; return 113;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
NBTTagList nbttaglist; ListNBT nbttaglist;
if (cmp.contains("HandDropChances", 9)) { if (cmp.contains("HandDropChances", 9)) {
nbttaglist = cmp.getList("HandDropChances", 5); nbttaglist = cmp.getList("HandDropChances", 5);
@ -1795,9 +1792,9 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 135; return 135;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
while (cmp.contains("Riding", 10)) { while (cmp.contains("Riding", 10)) {
NBTTagCompound nbttagcompound1 = this.b(cmp); CompoundNBT nbttagcompound1 = this.b(cmp);
this.convert(cmp, nbttagcompound1); this.convert(cmp, nbttagcompound1);
cmp = nbttagcompound1; cmp = nbttagcompound1;
@ -1806,15 +1803,15 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return cmp; return cmp;
} }
protected void convert(NBTTagCompound nbttagcompound, NBTTagCompound nbttagcompound1) { protected void convert(CompoundNBT nbttagcompound, CompoundNBT nbttagcompound1) {
NBTTagList nbttaglist = new NBTTagList(); ListNBT nbttaglist = new ListNBT();
nbttaglist.add(nbttagcompound); nbttaglist.add(nbttagcompound);
nbttagcompound1.put("Passengers", nbttaglist); nbttagcompound1.put("Passengers", nbttaglist);
} }
protected NBTTagCompound b(NBTTagCompound nbttagcompound) { protected CompoundNBT b(CompoundNBT nbttagcompound) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Riding"); CompoundNBT nbttagcompound1 = nbttagcompound.getCompound("Riding");
nbttagcompound.remove("Riding"); nbttagcompound.remove("Riding");
return nbttagcompound1; return nbttagcompound1;
@ -1829,12 +1826,12 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 165; return 165;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:written_book".equals(cmp.getString("id"))) { if ("minecraft:written_book".equals(cmp.getString("id"))) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag"); CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
if (nbttagcompound1.contains("pages", 9)) { if (nbttagcompound1.contains("pages", 9)) {
NBTTagList nbttaglist = nbttagcompound1.getList("pages", 8); ListNBT nbttaglist = nbttagcompound1.getList("pages", 8);
for (int i = 0; i < nbttaglist.size(); ++i) { for (int i = 0; i < nbttaglist.size(); ++i) {
String s = nbttaglist.getString(i); String s = nbttaglist.getString(i);
@ -1842,12 +1839,12 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
if (!"null".equals(s) && !StringUtils.isNullOrEmpty(s)) { if (!"null".equals(s) && !StringUtils.isNullOrEmpty(s)) {
if ((s.charAt(0) != 34 || s.charAt(s.length() - 1) != 34) && (s.charAt(0) != 123 || s.charAt(s.length() - 1) != 125)) { if ((s.charAt(0) != 34 || s.charAt(s.length() - 1) != 34) && (s.charAt(0) != 123 || s.charAt(s.length() - 1) != 125)) {
object = new TextComponentString(s); object = new StringTextComponent(s);
} else { } else {
try { try {
object = JsonUtils.fromJson(DataConverterSignText.a, s, ITextComponent.class, true); object = JSONUtils.fromJson(DataConverterSignText.a, s, ITextComponent.class, true);
if (object == null) { if (object == null) {
object = new TextComponentString(""); object = new StringTextComponent("");
} }
} catch (JsonParseException jsonparseexception) { } catch (JsonParseException jsonparseexception) {
; ;
@ -1870,14 +1867,14 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
} }
if (object == null) { if (object == null) {
object = new TextComponentString(s); object = new StringTextComponent(s);
} }
} }
} else { } else {
object = new TextComponentString(""); object = new StringTextComponent("");
} }
nbttaglist.set(i, new NBTTagString(ITextComponent.Serializer.toJson((ITextComponent) object))); nbttaglist.set(i, new StringNBT(ITextComponent.Serializer.toJson((ITextComponent) object)));
} }
nbttagcompound1.put("pages", nbttaglist); nbttagcompound1.put("pages", nbttaglist);
@ -1898,7 +1895,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 502; return 502;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if (cmp.contains("id", 8) && DataConverterCookedFish.a.equals(new ResourceLocation(cmp.getString("id")))) { if (cmp.contains("id", 8) && DataConverterCookedFish.a.equals(new ResourceLocation(cmp.getString("id")))) {
cmp.putString("id", "minecraft:cooked_fish"); cmp.putString("id", "minecraft:cooked_fish");
} }
@ -1917,7 +1914,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 502; return 502;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("Zombie".equals(cmp.getString("id")) && cmp.getBoolean("IsVillager")) { if ("Zombie".equals(cmp.getString("id")) && cmp.getBoolean("IsVillager")) {
if (!cmp.contains("ZombieType", 99)) { if (!cmp.contains("ZombieType", 99)) {
int i = -1; int i = -1;
@ -1956,7 +1953,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 505; return 505;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
cmp.putString("useVbo", "true"); cmp.putString("useVbo", "true");
return cmp; return cmp;
} }
@ -1970,7 +1967,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 700; return 700;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("Guardian".equals(cmp.getString("id"))) { if ("Guardian".equals(cmp.getString("id"))) {
if (cmp.getBoolean("Elder")) { if (cmp.getBoolean("Elder")) {
cmp.putString("id", "ElderGuardian"); cmp.putString("id", "ElderGuardian");
@ -1991,7 +1988,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 701; return 701;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
String s = cmp.getString("id"); String s = cmp.getString("id");
if ("Skeleton".equals(s)) { if ("Skeleton".equals(s)) {
@ -2018,7 +2015,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 702; return 702;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("Zombie".equals(cmp.getString("id"))) { if ("Zombie".equals(cmp.getString("id"))) {
int i = cmp.getInt("ZombieType"); int i = cmp.getInt("ZombieType");
@ -2053,7 +2050,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 703; return 703;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("EntityHorse".equals(cmp.getString("id"))) { if ("EntityHorse".equals(cmp.getString("id"))) {
int i = cmp.getInt("Type"); int i = cmp.getInt("Type");
@ -2097,7 +2094,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 704; return 704;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
String s = DataConverterTileEntity.a.get(cmp.getString("id")); String s = DataConverterTileEntity.a.get(cmp.getString("id"));
if (s != null) { if (s != null) {
@ -2144,7 +2141,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 704; return 704;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
String s = DataConverterEntity.a.get(cmp.getString("id")); String s = DataConverterEntity.a.get(cmp.getString("id"));
if (s != null) { if (s != null) {
@ -2241,11 +2238,11 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 806; return 806;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
String s = cmp.getString("id"); String s = cmp.getString("id");
if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals(s)) { if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals(s)) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag"); CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
if (!nbttagcompound1.contains("Potion", 8)) { if (!nbttagcompound1.contains("Potion", 8)) {
nbttagcompound1.putString("Potion", "minecraft:water"); nbttagcompound1.putString("Potion", "minecraft:water");
@ -2268,7 +2265,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 808; return 808;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:shulker".equals(cmp.getString("id")) && !cmp.contains("Color", 99)) { if ("minecraft:shulker".equals(cmp.getString("id")) && !cmp.contains("Color", 99)) {
cmp.putByte("Color", (byte) 10); cmp.putByte("Color", (byte) 10);
} }
@ -2287,12 +2284,12 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 813; return 813;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:shulker_box".equals(cmp.getString("id")) && cmp.contains("tag", 10)) { if ("minecraft:shulker_box".equals(cmp.getString("id")) && cmp.contains("tag", 10)) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag"); CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
if (nbttagcompound1.contains("BlockEntityTag", 10)) { if (nbttagcompound1.contains("BlockEntityTag", 10)) {
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag"); CompoundNBT nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
if (nbttagcompound2.getList("Items", 10).isEmpty()) { if (nbttagcompound2.getList("Items", 10).isEmpty()) {
nbttagcompound2.remove("Items"); nbttagcompound2.remove("Items");
@ -2325,7 +2322,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 813; return 813;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:shulker".equals(cmp.getString("id"))) { if ("minecraft:shulker".equals(cmp.getString("id"))) {
cmp.remove("Color"); cmp.remove("Color");
} }
@ -2342,7 +2339,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 816; return 816;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if (cmp.contains("lang", 8)) { if (cmp.contains("lang", 8)) {
cmp.putString("lang", cmp.getString("lang").toLowerCase(Locale.ROOT)); cmp.putString("lang", cmp.getString("lang").toLowerCase(Locale.ROOT));
} }
@ -2359,7 +2356,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 820; return 820;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:totem".equals(cmp.getString("id"))) { if ("minecraft:totem".equals(cmp.getString("id"))) {
cmp.putString("id", "minecraft:totem_of_undying"); cmp.putString("id", "minecraft:totem_of_undying");
} }
@ -2378,18 +2375,18 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 1125; return 1125;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
boolean flag = true; boolean flag = true;
try { try {
NBTTagCompound nbttagcompound1 = cmp.getCompound("Level"); CompoundNBT nbttagcompound1 = cmp.getCompound("Level");
int i = nbttagcompound1.getInt("xPos"); int i = nbttagcompound1.getInt("xPos");
int j = nbttagcompound1.getInt("zPos"); int j = nbttagcompound1.getInt("zPos");
NBTTagList nbttaglist = nbttagcompound1.getList("TileEntities", 10); ListNBT nbttaglist = nbttagcompound1.getList("TileEntities", 10);
NBTTagList nbttaglist1 = nbttagcompound1.getList("Sections", 10); ListNBT nbttaglist1 = nbttagcompound1.getList("Sections", 10);
for (int k = 0; k < nbttaglist1.size(); ++k) { for (int k = 0; k < nbttaglist1.size(); ++k) {
NBTTagCompound nbttagcompound2 = nbttaglist1.getCompound(k); CompoundNBT nbttagcompound2 = nbttaglist1.getCompound(k);
byte b0 = nbttagcompound2.getByte("Y"); byte b0 = nbttagcompound2.getByte("Y");
byte[] abyte = nbttagcompound2.getByteArray("Blocks"); byte[] abyte = nbttagcompound2.getByteArray("Blocks");
@ -2398,7 +2395,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
int i1 = l & 15; int i1 = l & 15;
int j1 = l >> 8 & 15; int j1 = l >> 8 & 15;
int k1 = l >> 4 & 15; int k1 = l >> 4 & 15;
NBTTagCompound nbttagcompound3 = new NBTTagCompound(); CompoundNBT nbttagcompound3 = new CompoundNBT();
nbttagcompound3.putString("id", "bed"); nbttagcompound3.putString("id", "bed");
nbttagcompound3.putInt("x", i1 + (i << 4)); nbttagcompound3.putInt("x", i1 + (i << 4));
@ -2424,9 +2421,9 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 1125; return 1125;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:bed".equals(cmp.getString("id")) && cmp.getShort("Damage") == 0) { if ("minecraft:bed".equals(cmp.getString("id")) && cmp.getShort("Damage") == 0) {
cmp.putShort("Damage", (short) EnumDyeColor.RED.getId()); cmp.putShort("Damage", (short) DyeColor.RED.getId());
} }
return cmp; return cmp;
@ -2438,7 +2435,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
public static final Gson a = new GsonBuilder().registerTypeAdapter(ITextComponent.class, new JsonDeserializer() { public static final Gson a = new GsonBuilder().registerTypeAdapter(ITextComponent.class, new JsonDeserializer() {
ITextComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { ITextComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
if (jsonelement.isJsonPrimitive()) { if (jsonelement.isJsonPrimitive()) {
return new TextComponentString(jsonelement.getAsString()); return new StringTextComponent(jsonelement.getAsString());
} else if (jsonelement.isJsonArray()) { } else if (jsonelement.isJsonArray()) {
JsonArray jsonarray = jsonelement.getAsJsonArray(); JsonArray jsonarray = jsonelement.getAsJsonArray();
ITextComponent iTextComponent = null; ITextComponent iTextComponent = null;
@ -2472,7 +2469,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 101; return 101;
} }
public NBTTagCompound convert(NBTTagCompound cmp) { public CompoundNBT convert(CompoundNBT cmp) {
if ("Sign".equals(cmp.getString("id"))) { if ("Sign".equals(cmp.getString("id"))) {
this.convert(cmp, "Text1"); this.convert(cmp, "Text1");
this.convert(cmp, "Text2"); this.convert(cmp, "Text2");
@ -2483,18 +2480,18 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return cmp; return cmp;
} }
private void convert(NBTTagCompound nbttagcompound, String s) { private void convert(CompoundNBT nbttagcompound, String s) {
String s1 = nbttagcompound.getString(s); String s1 = nbttagcompound.getString(s);
Object object = null; Object object = null;
if (!"null".equals(s1) && !StringUtils.isNullOrEmpty(s1)) { if (!"null".equals(s1) && !StringUtils.isNullOrEmpty(s1)) {
if ((s1.charAt(0) != 34 || s1.charAt(s1.length() - 1) != 34) && (s1.charAt(0) != 123 || s1.charAt(s1.length() - 1) != 125)) { if ((s1.charAt(0) != 34 || s1.charAt(s1.length() - 1) != 34) && (s1.charAt(0) != 123 || s1.charAt(s1.length() - 1) != 125)) {
object = new TextComponentString(s1); object = new StringTextComponent(s1);
} else { } else {
try { try {
object = JsonUtils.fromJson(DataConverterSignText.a, s1, ITextComponent.class, true); object = JSONUtils.fromJson(DataConverterSignText.a, s1, ITextComponent.class, true);
if (object == null) { if (object == null) {
object = new TextComponentString(""); object = new StringTextComponent("");
} }
} catch (JsonParseException jsonparseexception) { } catch (JsonParseException jsonparseexception) {
; ;
@ -2517,11 +2514,11 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
} }
if (object == null) { if (object == null) {
object = new TextComponentString(s1); object = new StringTextComponent(s1);
} }
} }
} else { } else {
object = new TextComponentString(""); object = new StringTextComponent("");
} }
nbttagcompound.putString(s, ITextComponent.Serializer.toJson((ITextComponent) object)); nbttagcompound.putString(s, ITextComponent.Serializer.toJson((ITextComponent) object));
@ -2530,9 +2527,9 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
private static class DataInspectorPlayerVehicle implements DataInspector { private static class DataInspectorPlayerVehicle implements DataInspector {
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (cmp.contains("RootVehicle", 10)) { if (cmp.contains("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("RootVehicle"); CompoundNBT nbttagcompound1 = cmp.getCompound("RootVehicle");
if (nbttagcompound1.contains("Entity", 10)) { if (nbttagcompound1.contains("Entity", 10)) {
convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer); convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer);
@ -2545,7 +2542,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
private static class DataInspectorLevelPlayer implements DataInspector { private static class DataInspectorLevelPlayer implements DataInspector {
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (cmp.contains("Player", 10)) { if (cmp.contains("Player", 10)) {
convertCompound(LegacyType.PLAYER, cmp, "Player", sourceVer, targetVer); convertCompound(LegacyType.PLAYER, cmp, "Player", sourceVer, targetVer);
} }
@ -2556,16 +2553,16 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
private static class DataInspectorStructure implements DataInspector { private static class DataInspectorStructure implements DataInspector {
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
NBTTagList nbttaglist; ListNBT nbttaglist;
int j; int j;
NBTTagCompound nbttagcompound1; CompoundNBT nbttagcompound1;
if (cmp.contains("entities", 9)) { if (cmp.contains("entities", 9)) {
nbttaglist = cmp.getList("entities", 10); nbttaglist = cmp.getList("entities", 10);
for (j = 0; j < nbttaglist.size(); ++j) { for (j = 0; j < nbttaglist.size(); ++j) {
nbttagcompound1 = (NBTTagCompound) nbttaglist.get(j); nbttagcompound1 = (CompoundNBT) nbttaglist.get(j);
if (nbttagcompound1.contains("nbt", 10)) { if (nbttagcompound1.contains("nbt", 10)) {
convertCompound(LegacyType.ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer); convertCompound(LegacyType.ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer);
} }
@ -2576,7 +2573,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
nbttaglist = cmp.getList("blocks", 10); nbttaglist = cmp.getList("blocks", 10);
for (j = 0; j < nbttaglist.size(); ++j) { for (j = 0; j < nbttaglist.size(); ++j) {
nbttagcompound1 = (NBTTagCompound) nbttaglist.get(j); nbttagcompound1 = (CompoundNBT) nbttaglist.get(j);
if (nbttagcompound1.contains("nbt", 10)) { if (nbttagcompound1.contains("nbt", 10)) {
convertCompound(LegacyType.BLOCK_ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer); convertCompound(LegacyType.BLOCK_ENTITY, nbttagcompound1, "nbt", sourceVer, targetVer);
} }
@ -2589,17 +2586,17 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
private static class DataInspectorChunks implements DataInspector { private static class DataInspectorChunks implements DataInspector {
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (cmp.contains("Level", 10)) { if (cmp.contains("Level", 10)) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("Level"); CompoundNBT nbttagcompound1 = cmp.getCompound("Level");
NBTTagList nbttaglist; ListNBT nbttaglist;
int j; int j;
if (nbttagcompound1.contains("Entities", 9)) { if (nbttagcompound1.contains("Entities", 9)) {
nbttaglist = nbttagcompound1.getList("Entities", 10); nbttaglist = nbttagcompound1.getList("Entities", 10);
for (j = 0; j < nbttaglist.size(); ++j) { for (j = 0; j < nbttaglist.size(); ++j) {
nbttaglist.set(j, convert(LegacyType.ENTITY, (NBTTagCompound) nbttaglist.get(j), sourceVer, targetVer)); nbttaglist.set(j, convert(LegacyType.ENTITY, (CompoundNBT) nbttaglist.get(j), sourceVer, targetVer));
} }
} }
@ -2607,7 +2604,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
nbttaglist = nbttagcompound1.getList("TileEntities", 10); nbttaglist = nbttagcompound1.getList("TileEntities", 10);
for (j = 0; j < nbttaglist.size(); ++j) { for (j = 0; j < nbttaglist.size(); ++j) {
nbttaglist.set(j, convert(LegacyType.BLOCK_ENTITY, (NBTTagCompound) nbttaglist.get(j), sourceVer, targetVer)); nbttaglist.set(j, convert(LegacyType.BLOCK_ENTITY, (CompoundNBT) nbttaglist.get(j), sourceVer, targetVer));
} }
} }
} }
@ -2618,9 +2615,9 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
private static class DataInspectorEntityPassengers implements DataInspector { private static class DataInspectorEntityPassengers implements DataInspector {
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (cmp.contains("Passengers", 9)) { if (cmp.contains("Passengers", 9)) {
NBTTagList nbttaglist = cmp.getList("Passengers", 10); ListNBT nbttaglist = cmp.getList("Passengers", 10);
for (int j = 0; j < nbttaglist.size(); ++j) { for (int j = 0; j < nbttaglist.size(); ++j) {
nbttaglist.set(j, convert(LegacyType.ENTITY, nbttaglist.getCompound(j), sourceVer, targetVer)); nbttaglist.set(j, convert(LegacyType.ENTITY, nbttaglist.getCompound(j), sourceVer, targetVer));
@ -2633,7 +2630,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
private static class DataInspectorPlayer implements DataInspector { private static class DataInspectorPlayer implements DataInspector {
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
convertItems(cmp, "Inventory", sourceVer, targetVer); convertItems(cmp, "Inventory", sourceVer, targetVer);
convertItems(cmp, "EnderItems", sourceVer, targetVer); convertItems(cmp, "EnderItems", sourceVer, targetVer);
if (cmp.contains("ShoulderEntityLeft", 10)) { if (cmp.contains("ShoulderEntityLeft", 10)) {
@ -2652,15 +2649,15 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
ResourceLocation entityVillager = getKey("EntityVillager"); ResourceLocation entityVillager = getKey("EntityVillager");
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (entityVillager.equals(new ResourceLocation(cmp.getString("id"))) && cmp.contains("Offers", 10)) { if (entityVillager.equals(new ResourceLocation(cmp.getString("id"))) && cmp.contains("Offers", 10)) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("Offers"); CompoundNBT nbttagcompound1 = cmp.getCompound("Offers");
if (nbttagcompound1.contains("Recipes", 9)) { if (nbttagcompound1.contains("Recipes", 9)) {
NBTTagList nbttaglist = nbttagcompound1.getList("Recipes", 10); ListNBT nbttaglist = nbttagcompound1.getList("Recipes", 10);
for (int j = 0; j < nbttaglist.size(); ++j) { for (int j = 0; j < nbttaglist.size(); ++j) {
NBTTagCompound nbttagcompound2 = nbttaglist.getCompound(j); CompoundNBT nbttagcompound2 = nbttaglist.getCompound(j);
convertItem(nbttagcompound2, "buy", sourceVer, targetVer); convertItem(nbttagcompound2, "buy", sourceVer, targetVer);
convertItem(nbttagcompound2, "buyB", sourceVer, targetVer); convertItem(nbttagcompound2, "buyB", sourceVer, targetVer);
@ -2679,7 +2676,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner"); ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner");
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
String s = cmp.getString("id"); String s = cmp.getString("id");
if (entityMinecartMobSpawner.equals(new ResourceLocation(s))) { if (entityMinecartMobSpawner.equals(new ResourceLocation(s))) {
cmp.putString("id", tileEntityMobSpawner.toString()); cmp.putString("id", tileEntityMobSpawner.toString());
@ -2695,13 +2692,13 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner"); ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner");
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (tileEntityMobSpawner.equals(new ResourceLocation(cmp.getString("id")))) { if (tileEntityMobSpawner.equals(new ResourceLocation(cmp.getString("id")))) {
if (cmp.contains("SpawnPotentials", 9)) { if (cmp.contains("SpawnPotentials", 9)) {
NBTTagList nbttaglist = cmp.getList("SpawnPotentials", 10); ListNBT nbttaglist = cmp.getList("SpawnPotentials", 10);
for (int j = 0; j < nbttaglist.size(); ++j) { for (int j = 0; j < nbttaglist.size(); ++j) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompound(j); CompoundNBT nbttagcompound1 = nbttaglist.getCompound(j);
convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer); convertCompound(LegacyType.ENTITY, nbttagcompound1, "Entity", sourceVer, targetVer);
} }
@ -2718,7 +2715,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
ResourceLocation tileEntityCommand = getKey("TileEntityCommand"); ResourceLocation tileEntityCommand = getKey("TileEntityCommand");
@Override @Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) { public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (tileEntityCommand.equals(new ResourceLocation(cmp.getString("id")))) { if (tileEntityCommand.equals(new ResourceLocation(cmp.getString("id")))) {
cmp.putString("id", "Control"); cmp.putString("id", "Control");
convert(LegacyType.BLOCK_ENTITY, cmp, sourceVer, targetVer); convert(LegacyType.BLOCK_ENTITY, cmp, sourceVer, targetVer);

Datei anzeigen

@ -29,7 +29,7 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.NullWorld; import com.sk89q.worldedit.world.NullWorld;
import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.entity.EntityTypes;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
@ -51,7 +51,7 @@ class ForgeEntity implements Entity {
if (entity != null) { if (entity != null) {
ResourceLocation id = entity.getType().getRegistryName(); ResourceLocation id = entity.getType().getRegistryName();
if (id != null) { if (id != null) {
NBTTagCompound tag = new NBTTagCompound(); CompoundNBT tag = new CompoundNBT();
entity.writeWithoutTypeId(tag); entity.writeWithoutTypeId(tag);
return new BaseEntity(EntityTypes.get(id.toString()), NBTConverter.fromNative(tag)); return new BaseEntity(EntityTypes.get(id.toString()), NBTConverter.fromNative(tag));
} else { } else {
@ -78,7 +78,7 @@ class ForgeEntity implements Entity {
@Override @Override
public boolean setLocation(Location location) { public boolean setLocation(Location location) {
// TODO // TODO unused atm
return false; return false;
} }

Datei anzeigen

@ -23,27 +23,27 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.entity.metadata.EntityProperties; import com.sk89q.worldedit.entity.metadata.EntityProperties;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.boss.dragon.EnderDragonPartEntity;
import net.minecraft.entity.IMerchant; import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.INpc; import net.minecraft.entity.item.ExperienceOrbEntity;
import net.minecraft.entity.item.PaintingEntity;
import net.minecraft.entity.item.TNTEntity;
import net.minecraft.entity.merchant.IMerchant;
import net.minecraft.entity.INPC;
import net.minecraft.entity.IProjectile; import net.minecraft.entity.IProjectile;
import net.minecraft.entity.MultiPartEntityPart; import net.minecraft.entity.MobEntity;
import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.item.BoatEntity;
import net.minecraft.entity.item.EntityBoat; import net.minecraft.entity.item.EyeOfEnderEntity;
import net.minecraft.entity.item.EntityEnderEye; import net.minecraft.entity.item.FallingBlockEntity;
import net.minecraft.entity.item.EntityFallingBlock; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.ItemFrameEntity;
import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.passive.AmbientEntity;
import net.minecraft.entity.item.EntityPainting; import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.passive.GolemEntity;
import net.minecraft.entity.monster.EntityGolem; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.passive.EntityAmbientCreature; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
public class ForgeEntityProperties implements EntityProperties { public class ForgeEntityProperties implements EntityProperties {
@ -56,82 +56,82 @@ public class ForgeEntityProperties implements EntityProperties {
@Override @Override
public boolean isPlayerDerived() { public boolean isPlayerDerived() {
return entity instanceof EntityPlayer; return entity instanceof PlayerEntity;
} }
@Override @Override
public boolean isProjectile() { public boolean isProjectile() {
return entity instanceof EntityEnderEye || entity instanceof IProjectile; return entity instanceof EyeOfEnderEntity || entity instanceof IProjectile;
} }
@Override @Override
public boolean isItem() { public boolean isItem() {
return entity instanceof EntityItem; return entity instanceof ItemEntity;
} }
@Override @Override
public boolean isFallingBlock() { public boolean isFallingBlock() {
return entity instanceof EntityFallingBlock; return entity instanceof FallingBlockEntity;
} }
@Override @Override
public boolean isPainting() { public boolean isPainting() {
return entity instanceof EntityPainting; return entity instanceof PaintingEntity;
} }
@Override @Override
public boolean isItemFrame() { public boolean isItemFrame() {
return entity instanceof EntityItemFrame; return entity instanceof ItemFrameEntity;
} }
@Override @Override
public boolean isBoat() { public boolean isBoat() {
return entity instanceof EntityBoat; return entity instanceof BoatEntity;
} }
@Override @Override
public boolean isMinecart() { public boolean isMinecart() {
return entity instanceof EntityMinecart; return entity instanceof AbstractMinecartEntity;
} }
@Override @Override
public boolean isTNT() { public boolean isTNT() {
return entity instanceof EntityTNTPrimed; return entity instanceof TNTEntity;
} }
@Override @Override
public boolean isExperienceOrb() { public boolean isExperienceOrb() {
return entity instanceof EntityXPOrb; return entity instanceof ExperienceOrbEntity;
} }
@Override @Override
public boolean isLiving() { public boolean isLiving() {
return entity instanceof EntityLiving; return entity instanceof MobEntity;
} }
@Override @Override
public boolean isAnimal() { public boolean isAnimal() {
return entity instanceof EntityAnimal; return entity instanceof AnimalEntity;
} }
@Override @Override
public boolean isAmbient() { public boolean isAmbient() {
return entity instanceof EntityAmbientCreature; return entity instanceof AmbientEntity;
} }
@Override @Override
public boolean isNPC() { public boolean isNPC() {
return entity instanceof INpc || entity instanceof IMerchant; return entity instanceof INPC || entity instanceof IMerchant;
} }
@Override @Override
public boolean isGolem() { public boolean isGolem() {
return entity instanceof EntityGolem; return entity instanceof GolemEntity;
} }
@Override @Override
public boolean isTamed() { public boolean isTamed() {
return entity instanceof EntityTameable && ((EntityTameable) entity).isTamed(); return entity instanceof TameableEntity && ((TameableEntity) entity).isTamed();
} }
@Override @Override
@ -141,11 +141,11 @@ public class ForgeEntityProperties implements EntityProperties {
@Override @Override
public boolean isArmorStand() { public boolean isArmorStand() {
return entity instanceof EntityArmorStand; return entity instanceof ArmorStandEntity;
} }
@Override @Override
public boolean isPasteable() { public boolean isPasteable() {
return !(entity instanceof EntityPlayerMP || entity instanceof MultiPartEntityPart); return !(entity instanceof ServerPlayerEntity || entity instanceof EnderDragonPartEntity);
} }
} }

Datei anzeigen

@ -19,13 +19,13 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.world.GameType; import net.minecraft.world.GameType;
import net.minecraftforge.fml.server.ServerLifecycleHooks; import net.minecraftforge.fml.server.ServerLifecycleHooks;
public interface ForgePermissionsProvider { public interface ForgePermissionsProvider {
boolean hasPermission(EntityPlayerMP player, String permission); boolean hasPermission(ServerPlayerEntity player, String permission);
void registerPermission(String permission); void registerPermission(String permission);
@ -38,7 +38,7 @@ public interface ForgePermissionsProvider {
} }
@Override @Override
public boolean hasPermission(EntityPlayerMP player, String permission) { public boolean hasPermission(ServerPlayerEntity player, String permission) {
ForgeConfiguration configuration = platform.getConfiguration(); ForgeConfiguration configuration = platform.getConfiguration();
return configuration.cheatMode || return configuration.cheatMode ||
ServerLifecycleHooks.getCurrentServer().getPlayerList().canSendCommands(player.getGameProfile()) || ServerLifecycleHooks.getCurrentServer().getPlayerList().canSendCommands(player.getGameProfile()) ||
@ -49,7 +49,7 @@ public interface ForgePermissionsProvider {
public void registerPermission(String permission) {} public void registerPermission(String permission) {}
} }
// TODO Re-add when Sponge for 1.13 is out // TODO Re-add when Sponge for 1.14 is out
// class SpongePermissionsProvider implements ForgePermissionsProvider { // class SpongePermissionsProvider implements ForgePermissionsProvider {
// //
// @Override // @Override

Datei anzeigen

@ -30,11 +30,12 @@ import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.registry.Registries; import com.sk89q.worldedit.world.registry.Registries;
import net.minecraft.command.Commands; import net.minecraft.command.Commands;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.PlayerList; import net.minecraft.server.management.PlayerList;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.WorldServer; import net.minecraft.util.SharedConstants;
import net.minecraft.world.ServerWorld;
import net.minecraftforge.fml.server.ServerLifecycleHooks; import net.minecraftforge.fml.server.ServerLifecycleHooks;
import org.enginehub.piston.Command; import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
@ -74,8 +75,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
@Override @Override
public int getDataVersion() { public int getDataVersion() {
// TODO switch to SharedConstants in 1.14 return SharedConstants.getVersion().getWorldVersion();
return 1631;
} }
@Override @Override
@ -99,10 +99,10 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
} }
@Override @Override
public List<? extends com.sk89q.worldedit.world.World> getWorlds() { public List<? extends World> getWorlds() {
Iterable<WorldServer> worlds = server.getWorlds(); Iterable<ServerWorld> worlds = server.getWorlds();
List<com.sk89q.worldedit.world.World> ret = new ArrayList<>(); List<World> ret = new ArrayList<>();
for (WorldServer world : worlds) { for (ServerWorld world : worlds) {
ret.add(new ForgeWorld(world)); ret.add(new ForgeWorld(world));
} }
return ret; return ret;
@ -114,7 +114,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
if (player instanceof ForgePlayer) { if (player instanceof ForgePlayer) {
return player; return player;
} else { } else {
EntityPlayerMP entity = server.getPlayerList().getPlayerByUsername(player.getName()); ServerPlayerEntity entity = server.getPlayerList().getPlayerByUsername(player.getName());
return entity != null ? new ForgePlayer(entity) : null; return entity != null ? new ForgePlayer(entity) : null;
} }
} }
@ -125,7 +125,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
if (world instanceof ForgeWorld) { if (world instanceof ForgeWorld) {
return world; return world;
} else { } else {
for (WorldServer ws : server.getWorlds()) { for (ServerWorld ws : server.getWorlds()) {
if (ws.getWorldInfo().getWorldName().equals(world.getName())) { if (ws.getWorldInfo().getWorldName().equals(world.getName())) {
return new ForgeWorld(ws); return new ForgeWorld(ws);
} }
@ -145,7 +145,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
Set<String> perms = command.getCondition().as(PermissionCondition.class) Set<String> perms = command.getCondition().as(PermissionCondition.class)
.map(PermissionCondition::getPermissions) .map(PermissionCondition::getPermissions)
.orElseGet(Collections::emptySet); .orElseGet(Collections::emptySet);
if (perms.size() > 0) { if (!perms.isEmpty()) {
perms.forEach(ForgeWorldEdit.inst.getPermissionsProvider()::registerPermission); perms.forEach(ForgeWorldEdit.inst.getPermissionsProvider()::registerPermission);
} }
} }
@ -193,7 +193,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
public Collection<Actor> getConnectedUsers() { public Collection<Actor> getConnectedUsers() {
List<Actor> users = new ArrayList<>(); List<Actor> users = new ArrayList<>();
PlayerList scm = server.getPlayerList(); PlayerList scm = server.getPlayerList();
for (EntityPlayerMP entity : scm.getPlayers()) { for (ServerPlayerEntity entity : scm.getPlayers()) {
if (entity != null) { if (entity != null) {
users.add(new ForgePlayer(entity)); users.add(new ForgePlayer(entity));
} }

Datei anzeigen

@ -40,17 +40,17 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.SPacketBlockChange; import net.minecraft.network.play.server.SChangeBlockPacket;
import net.minecraft.network.play.server.SPacketCustomPayload; import net.minecraft.network.play.server.SCustomPayloadPlayPacket;
import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.util.EnumHand; import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import java.io.IOException; import java.io.IOException;
@ -60,10 +60,11 @@ import javax.annotation.Nullable;
public class ForgePlayer extends AbstractPlayerActor { public class ForgePlayer extends AbstractPlayerActor {
// see ClientPlayNetHandler: search for "invalid update packet", lots of hardcoded consts
private static final int STRUCTURE_BLOCK_PACKET_ID = 7; private static final int STRUCTURE_BLOCK_PACKET_ID = 7;
private final EntityPlayerMP player; private final ServerPlayerEntity player;
protected ForgePlayer(EntityPlayerMP player) { protected ForgePlayer(ServerPlayerEntity player) {
this.player = player; this.player = player;
ThreadSafeCache.getInstance().getOnlineIds().add(getUniqueId()); ThreadSafeCache.getInstance().getOnlineIds().add(getUniqueId());
} }
@ -75,7 +76,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override @Override
public BaseItemStack getItemInHand(HandSide handSide) { public BaseItemStack getItemInHand(HandSide handSide) {
ItemStack is = this.player.getHeldItem(handSide == HandSide.MAIN_HAND ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND); ItemStack is = this.player.getHeldItem(handSide == HandSide.MAIN_HAND ? Hand.MAIN_HAND : Hand.OFF_HAND);
return ForgeAdapter.adapt(is); return ForgeAdapter.adapt(is);
} }
@ -123,14 +124,14 @@ public class ForgePlayer extends AbstractPlayerActor {
send = send + "|" + StringUtil.joinString(params, "|"); send = send + "|" + StringUtil.joinString(params, "|");
} }
PacketBuffer buffer = new PacketBuffer(Unpooled.copiedBuffer(send.getBytes(WECUIPacketHandler.UTF_8_CHARSET))); PacketBuffer buffer = new PacketBuffer(Unpooled.copiedBuffer(send.getBytes(WECUIPacketHandler.UTF_8_CHARSET)));
SPacketCustomPayload packet = new SPacketCustomPayload(new ResourceLocation(ForgeWorldEdit.CUI_PLUGIN_CHANNEL), buffer); SCustomPayloadPlayPacket packet = new SCustomPayloadPlayPacket(new ResourceLocation(ForgeWorldEdit.CUI_PLUGIN_CHANNEL), buffer);
this.player.connection.sendPacket(packet); this.player.connection.sendPacket(packet);
} }
@Override @Override
public void printRaw(String msg) { public void printRaw(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
this.player.sendMessage(new TextComponentString(part)); this.player.sendMessage(new StringTextComponent(part));
} }
} }
@ -156,7 +157,7 @@ public class ForgePlayer extends AbstractPlayerActor {
private void sendColorized(String msg, TextFormatting formatting) { private void sendColorized(String msg, TextFormatting formatting) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
TextComponentString component = new TextComponentString(part); StringTextComponent component = new StringTextComponent(part);
component.getStyle().setColor(formatting); component.getStyle().setColor(formatting);
this.player.sendMessage(component); this.player.sendMessage(component);
} }
@ -196,10 +197,10 @@ public class ForgePlayer extends AbstractPlayerActor {
} }
BlockPos loc = ForgeAdapter.toBlockPos(pos); BlockPos loc = ForgeAdapter.toBlockPos(pos);
if (block == null) { if (block == null) {
final SPacketBlockChange packetOut = new SPacketBlockChange(((ForgeWorld) world).getWorld(), loc); final SChangeBlockPacket packetOut = new SChangeBlockPacket(((ForgeWorld) world).getWorld(), loc);
player.connection.sendPacket(packetOut); player.connection.sendPacket(packetOut);
} else { } else {
final SPacketBlockChange packetOut = new SPacketBlockChange(); final SChangeBlockPacket packetOut = new SChangeBlockPacket();
PacketBuffer buf = new PacketBuffer(Unpooled.buffer()); PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
buf.writeBlockPos(loc); buf.writeBlockPos(loc);
buf.writeVarInt(Block.getStateId(ForgeAdapter.adapt(block.toImmutableState()))); buf.writeVarInt(Block.getStateId(ForgeAdapter.adapt(block.toImmutableState())));
@ -213,7 +214,7 @@ public class ForgePlayer extends AbstractPlayerActor {
final BaseBlock baseBlock = (BaseBlock) block; final BaseBlock baseBlock = (BaseBlock) block;
final CompoundTag nbtData = baseBlock.getNbtData(); final CompoundTag nbtData = baseBlock.getNbtData();
if (nbtData != null) { if (nbtData != null) {
player.connection.sendPacket(new SPacketUpdateTileEntity( player.connection.sendPacket(new SUpdateTileEntityPacket(
new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()),
STRUCTURE_BLOCK_PACKET_ID, STRUCTURE_BLOCK_PACKET_ID,
NBTConverter.toNative(nbtData)) NBTConverter.toNative(nbtData))

Datei anzeigen

@ -50,34 +50,37 @@ import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes; import com.sk89q.worldedit.world.weather.WeatherTypes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves; import net.minecraft.block.Blocks;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.LeavesBlock;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext; import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.ActionResultType;
import net.minecraft.util.EnumFacing; import net.minecraft.util.Hand;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.ServerWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.chunk.AbstractChunkProvider;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.storage.AnvilSaveHandler; import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.ChunkProviderServer; import net.minecraft.world.chunk.ServerChunkProvider;
import net.minecraft.world.chunk.listener.IChunkStatusListener;
import net.minecraft.world.gen.feature.BigBrownMushroomFeature; 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.BigRedMushroomFeature;
import net.minecraft.world.gen.feature.BigTreeFeature; import net.minecraft.world.gen.feature.BigTreeFeature;
import net.minecraft.world.gen.feature.BirchTreeFeature; import net.minecraft.world.gen.feature.BirchTreeFeature;
import net.minecraft.world.gen.feature.CanopyTreeFeature; import net.minecraft.world.gen.feature.DarkOakTreeFeature;
import net.minecraft.world.gen.feature.Feature; 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.JungleTreeFeature;
import net.minecraft.world.gen.feature.MegaJungleFeature; import net.minecraft.world.gen.feature.MegaJungleFeature;
import net.minecraft.world.gen.feature.MegaPineTree; import net.minecraft.world.gen.feature.MegaPineTree;
@ -88,17 +91,20 @@ import net.minecraft.world.gen.feature.ShrubFeature;
import net.minecraft.world.gen.feature.SwampTreeFeature; import net.minecraft.world.gen.feature.SwampTreeFeature;
import net.minecraft.world.gen.feature.TallTaigaTreeFeature; import net.minecraft.world.gen.feature.TallTaigaTreeFeature;
import net.minecraft.world.gen.feature.TreeFeature; import net.minecraft.world.gen.feature.TreeFeature;
import net.minecraft.world.storage.SaveHandler;
import net.minecraft.world.storage.WorldInfo; import net.minecraft.world.storage.WorldInfo;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.OptionalInt; import java.util.OptionalInt;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -110,9 +116,9 @@ public class ForgeWorld extends AbstractWorld {
private static final Random random = new Random(); private static final Random random = new Random();
private static final int UPDATE = 1, NOTIFY = 2; private static final int UPDATE = 1, NOTIFY = 2;
private static final IBlockState JUNGLE_LOG = Blocks.JUNGLE_LOG.getDefaultState(); private static final net.minecraft.block.BlockState JUNGLE_LOG = Blocks.JUNGLE_LOG.getDefaultState();
private static final IBlockState JUNGLE_LEAF = Blocks.JUNGLE_LEAVES.getDefaultState().with(BlockLeaves.PERSISTENT, Boolean.TRUE); private static final net.minecraft.block.BlockState JUNGLE_LEAF = Blocks.JUNGLE_LEAVES.getDefaultState().with(LeavesBlock.PERSISTENT, Boolean.TRUE);
private static final IBlockState JUNGLE_SHRUB = Blocks.OAK_LEAVES.getDefaultState().with(BlockLeaves.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; private final WeakReference<World> worldRef;
@ -174,10 +180,10 @@ public class ForgeWorld extends AbstractWorld {
// First set the block // First set the block
Chunk chunk = world.getChunk(x >> 4, z >> 4); Chunk chunk = world.getChunk(x >> 4, z >> 4);
BlockPos pos = new BlockPos(x, y, z); BlockPos pos = new BlockPos(x, y, z);
IBlockState old = chunk.getBlockState(pos); net.minecraft.block.BlockState old = chunk.getBlockState(pos);
OptionalInt stateId = BlockStateIdAccess.getBlockStateId(block.toImmutableState()); OptionalInt stateId = BlockStateIdAccess.getBlockStateId(block.toImmutableState());
IBlockState newState = stateId.isPresent() ? Block.getStateById(stateId.getAsInt()) : ForgeAdapter.adapt(block.toImmutableState()); net.minecraft.block.BlockState newState = stateId.isPresent() ? Block.getStateById(stateId.getAsInt()) : ForgeAdapter.adapt(block.toImmutableState());
IBlockState successState = chunk.setBlockState(pos, newState, false); net.minecraft.block.BlockState successState = chunk.setBlockState(pos, newState, false);
boolean successful = successState != null; boolean successful = successState != null;
// Create the TileEntity // Create the TileEntity
@ -185,15 +191,16 @@ public class ForgeWorld extends AbstractWorld {
if (block instanceof BaseBlock) { if (block instanceof BaseBlock) {
CompoundTag tag = ((BaseBlock) block).getNbtData(); CompoundTag tag = ((BaseBlock) block).getNbtData();
if (tag != null) { if (tag != null) {
NBTTagCompound nativeTag = NBTConverter.toNative(tag); CompoundNBT nativeTag = NBTConverter.toNative(tag);
nativeTag.putString("id", ((BaseBlock) block).getNbtId()); nativeTag.putString("id", ((BaseBlock) block).getNbtId());
TileEntityUtils.setTileEntity(world, position, nativeTag); TileEntityUtils.setTileEntity(world, position, nativeTag);
successful = true; // update if TE changed as well
} }
} }
} }
if (successful && notifyAndLight) { if (successful && notifyAndLight) {
world.checkLight(pos); world.getChunkProvider().getLightManager().checkBlock(pos);
world.markAndNotifyBlock(pos, chunk, old, newState, UPDATE | NOTIFY); world.markAndNotifyBlock(pos, chunk, old, newState, UPDATE | NOTIFY);
} }
@ -239,45 +246,44 @@ public class ForgeWorld extends AbstractWorld {
checkNotNull(position); checkNotNull(position);
checkNotNull(biome); checkNotNull(biome);
Chunk chunk = getWorld().getChunk(new BlockPos(position.getBlockX(), 0, position.getBlockZ())); IChunk chunk = getWorld().getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4, ChunkStatus.FULL, false);
if (chunk.isLoaded()) { if (chunk == null) {
chunk.getBiomes()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = ForgeAdapter.adapt(biome); return false;
return true;
} }
chunk.getBiomes()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = ForgeAdapter.adapt(biome);
return false; return true;
} }
private static LoadingCache<WorldServer, WorldEditFakePlayer> fakePlayers private static LoadingCache<ServerWorld, WorldEditFakePlayer> fakePlayers
= CacheBuilder.newBuilder().weakKeys().softValues().build(CacheLoader.from(WorldEditFakePlayer::new)); = CacheBuilder.newBuilder().weakKeys().softValues().build(CacheLoader.from(WorldEditFakePlayer::new));
@Override @Override
public boolean useItem(BlockVector3 position, BaseItem item, Direction face) { public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
ItemStack stack = ForgeAdapter.adapt(new BaseItemStack(item.getType(), item.getNbtData(), 1)); ItemStack stack = ForgeAdapter.adapt(new BaseItemStack(item.getType(), item.getNbtData(), 1));
WorldServer world = (WorldServer) getWorld(); ServerWorld world = (ServerWorld) getWorld();
final WorldEditFakePlayer fakePlayer; final WorldEditFakePlayer fakePlayer;
try { try {
fakePlayer = fakePlayers.get(world); fakePlayer = fakePlayers.get(world);
} catch (ExecutionException ignored) { } catch (ExecutionException ignored) {
return false; return false;
} }
fakePlayer.setHeldItem(EnumHand.MAIN_HAND, stack); fakePlayer.setHeldItem(Hand.MAIN_HAND, stack);
fakePlayer.setLocationAndAngles(position.getBlockX(), position.getBlockY(), position.getBlockZ(), fakePlayer.setLocationAndAngles(position.getBlockX(), position.getBlockY(), position.getBlockZ(),
(float) face.toVector().toYaw(), (float) face.toVector().toPitch()); (float) face.toVector().toYaw(), (float) face.toVector().toPitch());
final BlockPos blockPos = ForgeAdapter.toBlockPos(position); final BlockPos blockPos = ForgeAdapter.toBlockPos(position);
final EnumFacing enumFacing = ForgeAdapter.adapt(face); final BlockRayTraceResult rayTraceResult = new BlockRayTraceResult(ForgeAdapter.toVec3(position),
ItemUseContext itemUseContext = new ItemUseContext(fakePlayer, stack, blockPos, enumFacing, blockPos.getX(), blockPos.getY(), blockPos.getZ()); ForgeAdapter.adapt(face), blockPos, false);
EnumActionResult used = stack.onItemUse(itemUseContext); ItemUseContext itemUseContext = new ItemUseContext(fakePlayer, Hand.MAIN_HAND, rayTraceResult);
if (used != EnumActionResult.SUCCESS) { ActionResultType used = stack.onItemUse(itemUseContext);
if (used != ActionResultType.SUCCESS) {
// try activating the block // try activating the block
if (getWorld().getBlockState(blockPos).onBlockActivated(world, blockPos, fakePlayer, EnumHand.MAIN_HAND, if (getWorld().getBlockState(blockPos).onBlockActivated(world, fakePlayer, Hand.MAIN_HAND, rayTraceResult)) {
enumFacing, blockPos.getX(), blockPos.getY(), blockPos.getZ())) { used = ActionResultType.SUCCESS;
used = EnumActionResult.SUCCESS;
} else { } else {
used = stack.getItem().onItemRightClick(world, fakePlayer, EnumHand.MAIN_HAND).getType(); used = stack.getItem().onItemRightClick(world, fakePlayer, Hand.MAIN_HAND).getType();
} }
} }
return used == EnumActionResult.SUCCESS; return used == ActionResultType.SUCCESS;
} }
@Override @Override
@ -289,24 +295,22 @@ public class ForgeWorld extends AbstractWorld {
return; return;
} }
EntityItem entity = new EntityItem(getWorld(), position.getX(), position.getY(), position.getZ(), ForgeAdapter.adapt(item)); ItemEntity entity = new ItemEntity(getWorld(), position.getX(), position.getY(), position.getZ(), ForgeAdapter.adapt(item));
entity.setPickupDelay(10); entity.setPickupDelay(10);
getWorld().spawnEntity(entity); getWorld().addEntity(entity);
} }
@Override @Override
public void simulateBlockMine(BlockVector3 position) { public void simulateBlockMine(BlockVector3 position) {
BlockPos pos = ForgeAdapter.toBlockPos(position); BlockPos pos = ForgeAdapter.toBlockPos(position);
IBlockState state = getWorld().getBlockState(pos); getWorld().destroyBlock(pos, true);
state.dropBlockAsItem(getWorld(), pos, 0);
getWorld().removeBlock(pos);
} }
@Override @Override
public boolean regenerate(Region region, EditSession editSession) { public boolean regenerate(Region region, EditSession editSession) {
// Don't even try to regen if it's going to fail. // Don't even try to regen if it's going to fail.
IChunkProvider provider = getWorld().getChunkProvider(); AbstractChunkProvider provider = getWorld().getChunkProvider();
if (!(provider instanceof ChunkProviderServer)) { if (!(provider instanceof ServerChunkProvider)) {
return false; return false;
} }
@ -315,11 +319,12 @@ public class ForgeWorld extends AbstractWorld {
// normally it should be deleted at the end of this method // normally it should be deleted at the end of this method
saveFolder.deleteOnExit(); saveFolder.deleteOnExit();
try { try {
WorldServer originalWorld = (WorldServer) getWorld(); ServerWorld originalWorld = (ServerWorld) getWorld();
MinecraftServer server = originalWorld.getServer(); MinecraftServer server = originalWorld.getServer();
AnvilSaveHandler saveHandler = new AnvilSaveHandler(saveFolder, originalWorld.getSaveHandler().getWorldDirectory().getName(), server, server.getDataFixer()); SaveHandler saveHandler = new SaveHandler(saveFolder, originalWorld.getSaveHandler().getWorldDirectory().getName(), server, server.getDataFixer());
World freshWorld = new WorldServer(server, saveHandler, originalWorld.getSavedDataStorage(), originalWorld.getWorldInfo(), originalWorld.dimension.getType(), originalWorld.profiler).init(); World freshWorld = new ServerWorld(server, server.getBackgroundExecutor(), saveHandler, originalWorld.getWorldInfo(),
originalWorld.dimension.getType(), originalWorld.getProfiler(), new NoOpChunkStatusListener());
// Pre-gen all the chunks // Pre-gen all the chunks
// We need to also pull one more chunk in every direction // We need to also pull one more chunk in every direction
@ -342,36 +347,45 @@ public class ForgeWorld extends AbstractWorld {
} }
@Nullable @Nullable
private static Feature<NoFeatureConfig> createTreeFeatureGenerator(TreeType type) { private static Feature<? extends IFeatureConfig> createTreeFeatureGenerator(TreeType type) {
switch (type) { switch (type) {
case TREE: return new TreeFeature(true); case TREE: return new TreeFeature(NoFeatureConfig::deserialize, true);
case BIG_TREE: return new BigTreeFeature(true); case BIG_TREE: return new BigTreeFeature(NoFeatureConfig::deserialize, true);
case PINE: case REDWOOD: return new PointyTaigaTreeFeature(NoFeatureConfig::deserialize);
case REDWOOD: return new PointyTaigaTreeFeature(); case TALL_REDWOOD: return new TallTaigaTreeFeature(NoFeatureConfig::deserialize, true);
case TALL_REDWOOD: return new TallTaigaTreeFeature(true); case BIRCH: return new BirchTreeFeature(NoFeatureConfig::deserialize, true, false);
case BIRCH: return new BirchTreeFeature(true, false); case JUNGLE: return new MegaJungleFeature(NoFeatureConfig::deserialize, true, 10, 20, JUNGLE_LOG, JUNGLE_LEAF);
case JUNGLE: return new MegaJungleFeature(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 SMALL_JUNGLE: return new JungleTreeFeature(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 SHORT_JUNGLE: return new JungleTreeFeature(true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, true); case JUNGLE_BUSH: return new ShrubFeature(NoFeatureConfig::deserialize, JUNGLE_LOG, JUNGLE_SHRUB);
case JUNGLE_BUSH: return new ShrubFeature(JUNGLE_LOG, JUNGLE_SHRUB); case SWAMP: return new SwampTreeFeature(NoFeatureConfig::deserialize);
case RED_MUSHROOM: return new BigBrownMushroomFeature(); case ACACIA: return new SavannaTreeFeature(NoFeatureConfig::deserialize, true);
case BROWN_MUSHROOM: return new BigRedMushroomFeature(); case DARK_OAK: return new DarkOakTreeFeature(NoFeatureConfig::deserialize, true);
case SWAMP: return new SwampTreeFeature(); case MEGA_REDWOOD: return new MegaPineTree(NoFeatureConfig::deserialize, true, random.nextBoolean());
case ACACIA: return new SavannaTreeFeature(true); case TALL_BIRCH: return new BirchTreeFeature(NoFeatureConfig::deserialize, true, true);
case DARK_OAK: return new CanopyTreeFeature(true); case RED_MUSHROOM: return new BigRedMushroomFeature(BigMushroomFeatureConfig::deserialize);
case MEGA_REDWOOD: return new MegaPineTree(false, random.nextBoolean()); case BROWN_MUSHROOM: return new BigBrownMushroomFeature(BigMushroomFeatureConfig::deserialize);
case TALL_BIRCH: return new BirchTreeFeature(true, true);
case RANDOM: return createTreeFeatureGenerator(TreeType.values()[ThreadLocalRandom.current().nextInt(TreeType.values().length)]); case RANDOM: return createTreeFeatureGenerator(TreeType.values()[ThreadLocalRandom.current().nextInt(TreeType.values().length)]);
case RANDOM_REDWOOD:
default: default:
return null; 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 @Override
public boolean generateTree(TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException { public boolean generateTree(TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
Feature<NoFeatureConfig> generator = createTreeFeatureGenerator(type); @SuppressWarnings("unchecked")
return generator != null && generator.place(getWorld(), getWorld().getChunkProvider().getChunkGenerator(), random, ForgeAdapter.toBlockPos(position), new NoFeatureConfig()); Feature<IFeatureConfig> generator = (Feature<IFeatureConfig>) createTreeFeatureGenerator(type);
return generator != null
&& generator.place(getWorld(), getWorld().getChunkProvider().getChunkGenerator(), random,
ForgeAdapter.toBlockPos(position), createFeatureConfig(type));
} }
@Override @Override
@ -388,7 +402,7 @@ public class ForgeWorld extends AbstractWorld {
public void fixLighting(Iterable<BlockVector2> chunks) { public void fixLighting(Iterable<BlockVector2> chunks) {
World world = getWorld(); World world = getWorld();
for (BlockVector2 chunk : chunks) { for (BlockVector2 chunk : chunks) {
world.getChunk(chunk.getBlockX(), chunk.getBlockZ()).resetRelightChecks(); world.getChunkProvider().getLightManager().func_215571_a(new ChunkPos(chunk.getBlockX(), chunk.getBlockZ()), true);
} }
} }
@ -447,7 +461,7 @@ public class ForgeWorld extends AbstractWorld {
@Override @Override
public int getMaxY() { public int getMaxY() {
return getWorld().getHeight() - 1; return getWorld().getMaxHeight() - 1;
} }
@Override @Override
@ -457,11 +471,9 @@ public class ForgeWorld extends AbstractWorld {
@Override @Override
public BlockState getBlock(BlockVector3 position) { public BlockState getBlock(BlockVector3 position) {
IBlockState mcState = getWorld().getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4).getBlockState( net.minecraft.block.BlockState mcState = getWorld()
position.getBlockX(), .getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4)
position.getBlockY(), .getBlockState(ForgeAdapter.toBlockPos(position));
position.getBlockZ()
);
BlockState matchingBlock = BlockStateIdAccess.getBlockStateById(Block.getStateId(mcState)); BlockState matchingBlock = BlockStateIdAccess.getBlockStateById(Block.getStateId(mcState));
if (matchingBlock != null) { if (matchingBlock != null) {
@ -475,7 +487,7 @@ public class ForgeWorld extends AbstractWorld {
public BaseBlock getFullBlock(BlockVector3 position) { public BaseBlock getFullBlock(BlockVector3 position) {
BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ());
// Avoid creation by using the CHECK mode -- if it's needed, it'll be re-created anyways // Avoid creation by using the CHECK mode -- if it's needed, it'll be re-created anyways
TileEntity tile = getWorld().getChunk(pos).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK); TileEntity tile = getWorld().getChunk(pos).getTileEntity(pos, Chunk.CreateEntityType.CHECK);
if (tile != null) { if (tile != null) {
return getBlock(position).toBaseBlock(NBTConverter.fromNative(TileEntityUtils.copyNbtData(tile))); return getBlock(position).toBaseBlock(NBTConverter.fromNative(TileEntityUtils.copyNbtData(tile)));
@ -507,33 +519,34 @@ public class ForgeWorld extends AbstractWorld {
@Override @Override
public List<? extends Entity> getEntities(Region region) { public List<? extends Entity> getEntities(Region region) {
List<Entity> entities = new ArrayList<>(); final World world = getWorld();
for (net.minecraft.entity.Entity entity : getWorld().loadedEntityList) { if (!(world instanceof ServerWorld)) {
if (region.contains(BlockVector3.at(entity.posX, entity.posY, entity.posZ))) { return Collections.emptyList();
entities.add(new ForgeEntity(entity));
}
} }
return entities; return ((ServerWorld) world).getEntities().filter(e -> region.contains(ForgeAdapter.adapt(e.getPosition())))
.map(ForgeEntity::new).collect(Collectors.toList());
} }
@Override @Override
public List<? extends Entity> getEntities() { public List<? extends Entity> getEntities() {
List<Entity> entities = new ArrayList<>(); final World world = getWorld();
for (net.minecraft.entity.Entity entity : getWorld().loadedEntityList) { if (!(world instanceof ServerWorld)) {
entities.add(new ForgeEntity(entity)); return Collections.emptyList();
} }
return entities; return ((ServerWorld) world).getEntities().map(ForgeEntity::new).collect(Collectors.toList());
} }
@Nullable @Nullable
@Override @Override
public Entity createEntity(Location location, BaseEntity entity) { public Entity createEntity(Location location, BaseEntity entity) {
World world = getWorld(); World world = getWorld();
net.minecraft.entity.Entity createdEntity = EntityType.create(world, new ResourceLocation(entity.getType().getId())); final Optional<EntityType<?>> entityType = EntityType.getTypeFromString(entity.getType().getId());
if (!entityType.isPresent()) return null;
net.minecraft.entity.Entity createdEntity = entityType.get().create(world);
if (createdEntity != null) { if (createdEntity != null) {
CompoundTag nativeTag = entity.getNbtData(); CompoundTag nativeTag = entity.getNbtData();
if (nativeTag != null) { if (nativeTag != null) {
NBTTagCompound tag = NBTConverter.toNative(entity.getNbtData()); CompoundNBT tag = NBTConverter.toNative(entity.getNbtData());
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name); tag.remove(name);
} }
@ -542,7 +555,7 @@ public class ForgeWorld extends AbstractWorld {
createdEntity.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); createdEntity.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
world.spawnEntity(createdEntity); world.addEntity(createdEntity);
return new ForgeEntity(createdEntity); return new ForgeEntity(createdEntity);
} else { } else {
return null; return null;
@ -553,10 +566,23 @@ public class ForgeWorld extends AbstractWorld {
* Thrown when the reference to the world is lost. * Thrown when the reference to the world is lost.
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
private static class WorldReferenceLostException extends WorldEditException { private static final class WorldReferenceLostException extends WorldEditException {
private WorldReferenceLostException(String message) { private WorldReferenceLostException(String message) {
super(message); super(message);
} }
} }
private static class NoOpChunkStatusListener implements IChunkStatusListener {
@Override
public void func_219509_a(ChunkPos chunkPos) {
}
@Override
public void func_219508_a(ChunkPos chunkPos, @Nullable ChunkStatus chunkStatus) {
}
@Override
public void func_219510_b() {
}
}
} }

Datei anzeigen

@ -19,9 +19,6 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer;
import com.mojang.brigadier.ParseResults; import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
@ -42,12 +39,13 @@ import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.item.ItemCategory; import com.sk89q.worldedit.world.item.ItemCategory;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.util.EnumHand; import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CommandEvent; import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent;
@ -60,9 +58,11 @@ import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent; import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent; import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@ -74,6 +74,9 @@ import java.io.UncheckedIOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer;
/** /**
* The Forge implementation of WorldEdit. * The Forge implementation of WorldEdit.
*/ */
@ -216,12 +219,12 @@ public class ForgeWorldEdit {
event instanceof PlayerInteractEvent.RightClickBlock event instanceof PlayerInteractEvent.RightClickBlock
&& ((PlayerInteractEvent.RightClickBlock) event) && ((PlayerInteractEvent.RightClickBlock) event)
.getUseItem() == Event.Result.DENY; .getUseItem() == Event.Result.DENY;
if (isLeftDeny || isRightDeny || event.getEntity().world.isRemote || event.getHand() == EnumHand.OFF_HAND) { if (isLeftDeny || isRightDeny || event.getEntity().world.isRemote || event.getHand() == Hand.OFF_HAND) {
return; return;
} }
WorldEdit we = WorldEdit.getInstance(); WorldEdit we = WorldEdit.getInstance();
ForgePlayer player = adaptPlayer((EntityPlayerMP) event.getEntityPlayer()); ForgePlayer player = adaptPlayer((ServerPlayerEntity) event.getEntityPlayer());
ForgeWorld world = getWorld(event.getEntityPlayer().world); ForgeWorld world = getWorld(event.getEntityPlayer().world);
if (event instanceof PlayerInteractEvent.LeftClickEmpty) { if (event instanceof PlayerInteractEvent.LeftClickEmpty) {
@ -256,10 +259,10 @@ public class ForgeWorldEdit {
@SubscribeEvent @SubscribeEvent
public void onCommandEvent(CommandEvent event) throws CommandSyntaxException { public void onCommandEvent(CommandEvent event) throws CommandSyntaxException {
ParseResults<CommandSource> parseResults = event.getParseResults(); ParseResults<CommandSource> parseResults = event.getParseResults();
if (!(parseResults.getContext().getSource().getEntity() instanceof EntityPlayerMP)) { if (!(parseResults.getContext().getSource().getEntity() instanceof ServerPlayerEntity)) {
return; return;
} }
EntityPlayerMP player = parseResults.getContext().getSource().asPlayer(); ServerPlayerEntity player = parseResults.getContext().getSource().asPlayer();
if (player.world.isRemote()) { if (player.world.isRemote()) {
return; return;
} }
@ -288,7 +291,7 @@ public class ForgeWorldEdit {
* @param player the player * @param player the player
* @return the session * @return the session
*/ */
public LocalSession getSession(EntityPlayerMP player) { public LocalSession getSession(ServerPlayerEntity player) {
checkNotNull(player); checkNotNull(player);
return WorldEdit.getInstance().getSessionManager().get(adaptPlayer(player)); return WorldEdit.getInstance().getSessionManager().get(adaptPlayer(player));
} }

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.forge.gui.GuiReferenceCard; import com.sk89q.worldedit.forge.gui.GuiReferenceCard;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
@ -39,7 +40,7 @@ public class KeyHandler {
@SubscribeEvent @SubscribeEvent
public void onKey(InputEvent.KeyInputEvent evt) { public void onKey(InputEvent.KeyInputEvent evt) {
if (mc.player != null && mc.world != null && mainKey.isPressed()) { if (mc.player != null && mc.world != null && mainKey.isPressed()) {
mc.displayGuiScreen(new GuiReferenceCard()); mc.displayGuiScreen(new GuiReferenceCard(new StringTextComponent("WorldEdit Reference")));
} }
} }

Datei anzeigen

@ -32,19 +32,19 @@ import com.sk89q.jnbt.LongTag;
import com.sk89q.jnbt.ShortTag; import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import net.minecraft.nbt.INBTBase; import net.minecraft.nbt.ByteArrayNBT;
import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTTagByteArray; import net.minecraft.nbt.DoubleNBT;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.INBT;
import net.minecraft.nbt.NBTTagDouble; import net.minecraft.nbt.ByteNBT;
import net.minecraft.nbt.NBTTagEnd; import net.minecraft.nbt.EndNBT;
import net.minecraft.nbt.NBTTagFloat; import net.minecraft.nbt.FloatNBT;
import net.minecraft.nbt.NBTTagInt; import net.minecraft.nbt.IntArrayNBT;
import net.minecraft.nbt.NBTTagIntArray; import net.minecraft.nbt.IntNBT;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.NBTTagLong; import net.minecraft.nbt.LongNBT;
import net.minecraft.nbt.NBTTagShort; import net.minecraft.nbt.StringNBT;
import net.minecraft.nbt.NBTTagString; import net.minecraft.nbt.ShortNBT;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -62,7 +62,7 @@ final class NBTConverter {
private NBTConverter() { private NBTConverter() {
} }
public static INBTBase toNative(Tag tag) { public static INBT toNative(Tag tag) {
if (tag instanceof IntArrayTag) { if (tag instanceof IntArrayTag) {
return toNative((IntArrayTag) tag); return toNative((IntArrayTag) tag);
@ -100,13 +100,13 @@ final class NBTConverter {
} }
} }
public static NBTTagIntArray toNative(IntArrayTag tag) { public static IntArrayNBT toNative(IntArrayTag tag) {
int[] value = tag.getValue(); int[] value = tag.getValue();
return new NBTTagIntArray(Arrays.copyOf(value, value.length)); return new IntArrayNBT(Arrays.copyOf(value, value.length));
} }
public static NBTTagList toNative(ListTag tag) { public static ListNBT toNative(ListTag tag) {
NBTTagList list = new NBTTagList(); ListNBT list = new ListNBT();
for (Tag child : tag.getValue()) { for (Tag child : tag.getValue()) {
if (child instanceof EndTag) { if (child instanceof EndTag) {
continue; continue;
@ -116,94 +116,94 @@ final class NBTConverter {
return list; return list;
} }
public static NBTTagLong toNative(LongTag tag) { public static LongNBT toNative(LongTag tag) {
return new NBTTagLong(tag.getValue()); return new LongNBT(tag.getValue());
} }
public static NBTTagString toNative(StringTag tag) { public static StringNBT toNative(StringTag tag) {
return new NBTTagString(tag.getValue()); return new StringNBT(tag.getValue());
} }
public static NBTTagInt toNative(IntTag tag) { public static IntNBT toNative(IntTag tag) {
return new NBTTagInt(tag.getValue()); return new IntNBT(tag.getValue());
} }
public static NBTTagByte toNative(ByteTag tag) { public static ByteNBT toNative(ByteTag tag) {
return new NBTTagByte(tag.getValue()); return new ByteNBT(tag.getValue());
} }
public static NBTTagByteArray toNative(ByteArrayTag tag) { public static ByteArrayNBT toNative(ByteArrayTag tag) {
byte[] value = tag.getValue(); byte[] value = tag.getValue();
return new NBTTagByteArray(Arrays.copyOf(value, value.length)); return new ByteArrayNBT(Arrays.copyOf(value, value.length));
} }
public static NBTTagCompound toNative(CompoundTag tag) { public static CompoundNBT toNative(CompoundTag tag) {
NBTTagCompound compound = new NBTTagCompound(); CompoundNBT compound = new CompoundNBT();
for (Entry<String, Tag> child : tag.getValue().entrySet()) { for (Entry<String, Tag> child : tag.getValue().entrySet()) {
compound.put(child.getKey(), toNative(child.getValue())); compound.put(child.getKey(), toNative(child.getValue()));
} }
return compound; return compound;
} }
public static NBTTagFloat toNative(FloatTag tag) { public static FloatNBT toNative(FloatTag tag) {
return new NBTTagFloat(tag.getValue()); return new FloatNBT(tag.getValue());
} }
public static NBTTagShort toNative(ShortTag tag) { public static ShortNBT toNative(ShortTag tag) {
return new NBTTagShort(tag.getValue()); return new ShortNBT(tag.getValue());
} }
public static NBTTagDouble toNative(DoubleTag tag) { public static DoubleNBT toNative(DoubleTag tag) {
return new NBTTagDouble(tag.getValue()); return new DoubleNBT(tag.getValue());
} }
public static Tag fromNative(INBTBase other) { public static Tag fromNative(INBT other) {
if (other instanceof NBTTagIntArray) { if (other instanceof IntArrayNBT) {
return fromNative((NBTTagIntArray) other); return fromNative((IntArrayNBT) other);
} else if (other instanceof NBTTagList) { } else if (other instanceof ListNBT) {
return fromNative((NBTTagList) other); return fromNative((ListNBT) other);
} else if (other instanceof NBTTagEnd) { } else if (other instanceof EndNBT) {
return fromNative((NBTTagEnd) other); return fromNative((EndNBT) other);
} else if (other instanceof NBTTagLong) { } else if (other instanceof LongNBT) {
return fromNative((NBTTagLong) other); return fromNative((LongNBT) other);
} else if (other instanceof NBTTagString) { } else if (other instanceof StringNBT) {
return fromNative((NBTTagString) other); return fromNative((StringNBT) other);
} else if (other instanceof NBTTagInt) { } else if (other instanceof IntNBT) {
return fromNative((NBTTagInt) other); return fromNative((IntNBT) other);
} else if (other instanceof NBTTagByte) { } else if (other instanceof ByteNBT) {
return fromNative((NBTTagByte) other); return fromNative((ByteNBT) other);
} else if (other instanceof NBTTagByteArray) { } else if (other instanceof ByteArrayNBT) {
return fromNative((NBTTagByteArray) other); return fromNative((ByteArrayNBT) other);
} else if (other instanceof NBTTagCompound) { } else if (other instanceof CompoundNBT) {
return fromNative((NBTTagCompound) other); return fromNative((CompoundNBT) other);
} else if (other instanceof NBTTagFloat) { } else if (other instanceof FloatNBT) {
return fromNative((NBTTagFloat) other); return fromNative((FloatNBT) other);
} else if (other instanceof NBTTagShort) { } else if (other instanceof ShortNBT) {
return fromNative((NBTTagShort) other); return fromNative((ShortNBT) other);
} else if (other instanceof NBTTagDouble) { } else if (other instanceof DoubleNBT) {
return fromNative((NBTTagDouble) other); return fromNative((DoubleNBT) other);
} else { } else {
throw new IllegalArgumentException("Can't convert other of type " + other.getClass().getCanonicalName()); throw new IllegalArgumentException("Can't convert other of type " + other.getClass().getCanonicalName());
} }
} }
public static IntArrayTag fromNative(NBTTagIntArray other) { public static IntArrayTag fromNative(IntArrayNBT other) {
int[] value = other.getIntArray(); int[] value = other.getIntArray();
return new IntArrayTag(Arrays.copyOf(value, value.length)); return new IntArrayTag(Arrays.copyOf(value, value.length));
} }
public static ListTag fromNative(NBTTagList other) { public static ListTag fromNative(ListNBT other) {
other = other.copy(); other = other.copy();
List<Tag> list = new ArrayList<>(); List<Tag> list = new ArrayList<>();
Class<? extends Tag> listClass = StringTag.class; Class<? extends Tag> listClass = StringTag.class;
@ -216,32 +216,32 @@ final class NBTConverter {
return new ListTag(listClass, list); return new ListTag(listClass, list);
} }
public static EndTag fromNative(NBTTagEnd other) { public static EndTag fromNative(EndNBT other) {
return new EndTag(); return new EndTag();
} }
public static LongTag fromNative(NBTTagLong other) { public static LongTag fromNative(LongNBT other) {
return new LongTag(other.getLong()); return new LongTag(other.getLong());
} }
public static StringTag fromNative(NBTTagString other) { public static StringTag fromNative(StringNBT other) {
return new StringTag(other.getString()); return new StringTag(other.getString());
} }
public static IntTag fromNative(NBTTagInt other) { public static IntTag fromNative(IntNBT other) {
return new IntTag(other.getInt()); return new IntTag(other.getInt());
} }
public static ByteTag fromNative(NBTTagByte other) { public static ByteTag fromNative(ByteNBT other) {
return new ByteTag(other.getByte()); return new ByteTag(other.getByte());
} }
public static ByteArrayTag fromNative(NBTTagByteArray other) { public static ByteArrayTag fromNative(ByteArrayNBT other) {
byte[] value = other.getByteArray(); byte[] value = other.getByteArray();
return new ByteArrayTag(Arrays.copyOf(value, value.length)); return new ByteArrayTag(Arrays.copyOf(value, value.length));
} }
public static CompoundTag fromNative(NBTTagCompound other) { public static CompoundTag fromNative(CompoundNBT other) {
Set<String> tags = other.keySet(); Set<String> tags = other.keySet();
Map<String, Tag> map = new HashMap<>(); Map<String, Tag> map = new HashMap<>();
for (String tagName : tags) { for (String tagName : tags) {
@ -250,15 +250,15 @@ final class NBTConverter {
return new CompoundTag(map); return new CompoundTag(map);
} }
public static FloatTag fromNative(NBTTagFloat other) { public static FloatTag fromNative(FloatNBT other) {
return new FloatTag(other.getFloat()); return new FloatTag(other.getFloat());
} }
public static ShortTag fromNative(NBTTagShort other) { public static ShortTag fromNative(ShortNBT other) {
return new ShortTag(other.getShort()); return new ShortTag(other.getShort());
} }
public static DoubleTag fromNative(NBTTagDouble other) { public static DoubleTag fromNative(DoubleNBT other) {
return new DoubleTag(other.getDouble()); return new DoubleTag(other.getDouble());
} }

Datei anzeigen

@ -19,7 +19,7 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent;
@ -58,10 +58,10 @@ public class ThreadSafeCache {
Set<UUID> onlineIds = new HashSet<>(); Set<UUID> onlineIds = new HashSet<>();
MinecraftServer server = ServerLifecycleHooks.getCurrentServer(); MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
if (server == null || server.getPlayerList() == null) { if (server == null) {
return; return;
} }
for (EntityPlayerMP player : server.getPlayerList().getPlayers()) { for (ServerPlayerEntity player : server.getPlayerList().getPlayers()) {
if (player != null) { if (player != null) {
onlineIds.add(player.getUniqueID()); onlineIds.add(player.getUniqueID());
} }

Datei anzeigen

@ -23,8 +23,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTTagInt; import net.minecraft.nbt.IntNBT;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -45,13 +45,13 @@ final class TileEntityUtils {
* @param tag the tag * @param tag the tag
* @param position the position * @param position the position
*/ */
private static void updateForSet(NBTTagCompound tag, BlockVector3 position) { private static void updateForSet(CompoundNBT tag, BlockVector3 position) {
checkNotNull(tag); checkNotNull(tag);
checkNotNull(position); checkNotNull(position);
tag.put("x", new NBTTagInt(position.getBlockX())); tag.put("x", new IntNBT(position.getBlockX()));
tag.put("y", new NBTTagInt(position.getBlockY())); tag.put("y", new IntNBT(position.getBlockY()));
tag.put("z", new NBTTagInt(position.getBlockZ())); tag.put("z", new IntNBT(position.getBlockZ()));
} }
/** /**
@ -62,7 +62,7 @@ final class TileEntityUtils {
* @param position the position * @param position the position
* @param tag the tag for the tile entity (may be null to do nothing) * @param tag the tag for the tile entity (may be null to do nothing)
*/ */
static void setTileEntity(World world, BlockVector3 position, @Nullable NBTTagCompound tag) { static void setTileEntity(World world, BlockVector3 position, @Nullable CompoundNBT tag) {
if (tag != null) { if (tag != null) {
updateForSet(tag, position); updateForSet(tag, position);
TileEntity tileEntity = TileEntity.create(tag); TileEntity tileEntity = TileEntity.create(tag);
@ -72,8 +72,8 @@ final class TileEntityUtils {
} }
} }
public static NBTTagCompound copyNbtData(TileEntity tile) { public static CompoundNBT copyNbtData(TileEntity tile) {
NBTTagCompound tag = new NBTTagCompound(); CompoundNBT tag = new CompoundNBT();
tile.write(tag); tile.write(tag);
return tag; return tag;
} }

Datei anzeigen

@ -20,21 +20,29 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.world.WorldServer; import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.world.ServerWorld;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import javax.annotation.Nullable;
import java.util.OptionalInt;
import java.util.UUID; import java.util.UUID;
public class WorldEditFakePlayer extends FakePlayer { public class WorldEditFakePlayer extends FakePlayer {
private static final GameProfile FAKE_GAME_PROFILE = new GameProfile(UUID.nameUUIDFromBytes("worldedit".getBytes()), "[WorldEdit]"); private static final GameProfile FAKE_GAME_PROFILE = new GameProfile(UUID.nameUUIDFromBytes("worldedit".getBytes()), "[WorldEdit]");
public WorldEditFakePlayer(WorldServer world) { public WorldEditFakePlayer(ServerWorld world) {
super(world, FAKE_GAME_PROFILE); super(world, FAKE_GAME_PROFILE);
} }
@Override @Override
public boolean canEat(boolean ignoreHunger) { public boolean canEat(boolean checkHunger) {
return true; return true;
} }
@Override
public OptionalInt openContainer(@Nullable INamedContainerProvider container) {
return OptionalInt.empty();
}
} }

Datei anzeigen

@ -20,46 +20,46 @@
package com.sk89q.worldedit.forge.gui; package com.sk89q.worldedit.forge.gui;
import com.sk89q.worldedit.forge.ForgeWorldEdit; import com.sk89q.worldedit.forge.ForgeWorldEdit;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class GuiReferenceCard extends GuiScreen { public class GuiReferenceCard extends Screen {
private GuiButton closeButton; private Button closeButton;
private int backgroundWidth = 256; private int backgroundWidth = 256;
private int backgroundHeight = 256; private int backgroundHeight = 256;
@Override public GuiReferenceCard(ITextComponent title) {
public void initGui() { super(title);
this.closeButton = new GuiButton(0, (this.width - this.backgroundWidth + 100) / 2, }
(this.height + this.backgroundHeight - 60) / 2, this.backgroundWidth - 100, 20, "Close") {
@Override
public void onClick(double mouseX, double mouseY) {
super.onClick(mouseX, mouseY);
mc.player.closeScreen(); @Override
} public void init() {
}; this.addButton(closeButton = new Button(
(this.width - this.backgroundWidth + 56) / 2, (this.height + this.backgroundHeight) / 2,
200, 20, "Close",
button -> this.minecraft.player.closeScreen()));
} }
@Override @Override
public void render(int mouseX, int mouseY, float par3) { public void render(int mouseX, int mouseY, float par3) {
int x = (this.width - this.backgroundWidth) / 2; int x = (this.width - this.backgroundWidth) / 2;
int y = (this.height - this.backgroundHeight) / 2 - this.closeButton.height; int y = (this.height - this.backgroundHeight) / 2 - this.closeButton.getHeight();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.textureManager.bindTexture(new ResourceLocation(ForgeWorldEdit.MOD_ID, "textures/gui/reference.png")); this.minecraft.textureManager.bindTexture(new ResourceLocation(ForgeWorldEdit.MOD_ID, "textures/gui/reference.png"));
this.drawTexturedModalRect(x, y, 0, 0, this.backgroundWidth, this.backgroundHeight); this.blit(x, y, 0, 0, this.backgroundWidth, this.backgroundHeight);
super.render(mouseX, mouseY, par3); super.render(mouseX, mouseY, par3);
} }
@Override @Override
public boolean doesGuiPauseGame() { public boolean isPauseScreen() {
return true; return true;
} }

Datei anzeigen

@ -1,65 +0,0 @@
/*
* 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.forge.gui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.IInteractionObject;
import javax.annotation.Nullable;
public class ResourceLocationInteractionObject implements IInteractionObject {
private ResourceLocation resourceLocation;
public ResourceLocationInteractionObject(ResourceLocation resourceLocation) {
this.resourceLocation = resourceLocation;
}
@Override
public Container createContainer(InventoryPlayer inventoryPlayer, EntityPlayer entityPlayer) {
throw new UnsupportedOperationException();
}
@Override
public String getGuiID() {
return resourceLocation.toString();
}
@Override
public ITextComponent getName() {
return new TextComponentString(resourceLocation.toString());
}
@Override
public boolean hasCustomName() {
return false;
}
@Nullable
@Override
public ITextComponent getCustomName() {
return null;
}
}

Datei anzeigen

@ -42,7 +42,7 @@ final class PacketHandlerUtil {
private static Predicate<String> validateLenient(String protocolVersion) { private static Predicate<String> validateLenient(String protocolVersion) {
return remoteVersion -> return remoteVersion ->
protocolVersion.equals(remoteVersion) protocolVersion.equals(remoteVersion)
|| NetworkRegistry.ABSENT.equals(remoteVersion) || NetworkRegistry.ABSENT.equals(remoteVersion)
|| NetworkRegistry.ACCEPTVANILLA.equals(remoteVersion); || NetworkRegistry.ACCEPTVANILLA.equals(remoteVersion);
} }
} }

Datei anzeigen

@ -23,9 +23,9 @@ import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.forge.ForgePlayer; import com.sk89q.worldedit.forge.ForgePlayer;
import com.sk89q.worldedit.forge.ForgeWorldEdit; import com.sk89q.worldedit.forge.ForgeWorldEdit;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.network.ThreadQuickExitException; import net.minecraft.network.ThreadQuickExitException;
import net.minecraft.network.play.server.SPacketCustomPayload; import net.minecraft.network.play.server.SCustomPayloadPlayPacket;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.network.NetworkEvent.ClientCustomPayloadEvent; import net.minecraftforge.fml.network.NetworkEvent.ClientCustomPayloadEvent;
import net.minecraftforge.fml.network.NetworkEvent.ServerCustomPayloadEvent; import net.minecraftforge.fml.network.NetworkEvent.ServerCustomPayloadEvent;
@ -45,14 +45,13 @@ public final class WECUIPacketHandler {
.buildLenientHandler(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, PROTOCOL_VERSION) .buildLenientHandler(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, PROTOCOL_VERSION)
.eventNetworkChannel(); .eventNetworkChannel();
public static void init() { public static void init() {
HANDLER.addListener(WECUIPacketHandler::onPacketData); HANDLER.addListener(WECUIPacketHandler::onPacketData);
HANDLER.addListener(WECUIPacketHandler::callProcessPacket); HANDLER.addListener(WECUIPacketHandler::callProcessPacket);
} }
public static void onPacketData(ServerCustomPayloadEvent event) { public static void onPacketData(ServerCustomPayloadEvent event) {
EntityPlayerMP player = event.getSource().get().getSender(); ServerPlayerEntity player = event.getSource().get().getSender();
LocalSession session = ForgeWorldEdit.inst.getSession(player); LocalSession session = ForgeWorldEdit.inst.getSession(player);
if (session.hasCUISupport()) { if (session.hasCUISupport()) {
@ -67,11 +66,12 @@ public final class WECUIPacketHandler {
public static void callProcessPacket(ClientCustomPayloadEvent event) { public static void callProcessPacket(ClientCustomPayloadEvent event) {
try { try {
new SPacketCustomPayload( new SCustomPayloadPlayPacket(
new ResourceLocation(ForgeWorldEdit.MOD_ID, ForgeWorldEdit.CUI_PLUGIN_CHANNEL), new ResourceLocation(ForgeWorldEdit.MOD_ID, ForgeWorldEdit.CUI_PLUGIN_CHANNEL),
event.getPayload() event.getPayload()
).processPacket(Minecraft.getInstance().player.connection); ).processPacket(Minecraft.getInstance().player.connection);
} catch (ThreadQuickExitException ignored) { } catch (ThreadQuickExitException ignored) {
} }
} }
} }