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

Update to Forge 1.14.

Dieser Commit ist enthalten in:
wizjany 2019-06-09 01:02:24 -04:00
Ursprung 61fd44fa8c
Commit 078d6f6440
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.");
}
world.playEffect(clicked.toVector(), 2001, blockType.getLegacyId());
return true;
}

Datei anzeigen

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

Datei anzeigen

@ -36,7 +36,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.util.Substring;
import net.minecraft.command.CommandSource;
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.Key;
import org.enginehub.piston.inject.MapBackedValueStore;
@ -78,8 +78,8 @@ public final class CommandWrapper {
private static Predicate<CommandSource> requirementsFor(org.enginehub.piston.Command mapping) {
return ctx -> {
final Entity entity = ctx.getEntity();
if (!(entity instanceof EntityPlayerMP)) return true;
final Actor actor = ForgeAdapter.adaptPlayer(((EntityPlayerMP) entity));
if (!(entity instanceof ServerPlayerEntity)) return true;
final Actor actor = ForgeAdapter.adaptPlayer(((ServerPlayerEntity) entity));
InjectedValueStore store = MapBackedValueStore.create();
store.injectValue(Key.of(Actor.class), context -> Optional.of(actor));
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.ItemTypes;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.IProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
@ -92,20 +90,20 @@ public final class ForgeAdapter {
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) {
case NORTH: return EnumFacing.NORTH;
case SOUTH: return EnumFacing.SOUTH;
case WEST: return EnumFacing.WEST;
case EAST: return EnumFacing.EAST;
case DOWN: return EnumFacing.DOWN;
case NORTH: return net.minecraft.util.Direction.NORTH;
case SOUTH: return net.minecraft.util.Direction.SOUTH;
case WEST: return net.minecraft.util.Direction.WEST;
case EAST: return net.minecraft.util.Direction.EAST;
case DOWN: return net.minecraft.util.Direction.DOWN;
case UP:
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) {
case NORTH: return Direction.NORTH;
case SOUTH: return Direction.SOUTH;
@ -149,7 +147,7 @@ public final class ForgeAdapter {
for (Map.Entry<IProperty<?>, Comparable<?>> prop : mcProps.entrySet()) {
Object value = prop.getValue();
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) {
value = ((IStringSerializable) value).getName();
}
@ -158,14 +156,14 @@ public final class ForgeAdapter {
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()) {
IProperty property = stateContainer.getProperty(state.getKey().getName());
Comparable value = (Comparable) state.getValue();
// we may need to adapt this value, depending on the source prop
if (property instanceof DirectionProperty) {
Direction dir = (Direction) value;
value = ForgeAdapter.adapt(dir);
value = adapt(dir);
} else if (property instanceof net.minecraft.state.EnumProperty) {
String enumName = (String) value;
value = ((net.minecraft.state.EnumProperty<?>) property).parseValue((String) value).orElseGet(() -> {
@ -178,16 +176,16 @@ public final class ForgeAdapter {
return newState;
}
public static IBlockState adapt(BlockState blockState) {
Block mcBlock = ForgeAdapter.adapt(blockState.getBlockType());
IBlockState newState = mcBlock.getDefaultState();
public static net.minecraft.block.BlockState adapt(BlockState blockState) {
Block mcBlock = adapt(blockState.getBlockType());
net.minecraft.block.BlockState newState = mcBlock.getDefaultState();
Map<Property<?>, Object> states = blockState.getStates();
return applyProperties(mcBlock.getStateContainer(), newState, states);
}
public static BlockState adapt(IBlockState blockState) {
public static BlockState adapt(net.minecraft.block.BlockState blockState) {
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) {
@ -207,7 +205,7 @@ public final class ForgeAdapter {
}
public static ItemStack adapt(BaseItemStack baseItemStack) {
NBTTagCompound forgeCompound = null;
CompoundNBT forgeCompound = null;
if (baseItemStack.getNbtData() != null) {
forgeCompound = NBTConverter.toNative(baseItemStack.getNbtData());
}
@ -237,7 +235,7 @@ public final class ForgeAdapter {
* @param player the player
* @return the WorldEdit player
*/
public static ForgePlayer adaptPlayer(EntityPlayerMP player) {
public static ForgePlayer adaptPlayer(ServerPlayerEntity player) {
checkNotNull(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.PassthroughBlockMaterial;
import net.minecraft.block.material.EnumPushReaction;
import net.minecraft.block.material.PushReaction;
import net.minecraft.block.material.Material;
import javax.annotation.Nullable;
@ -63,12 +63,12 @@ public class ForgeBlockMaterial extends PassthroughBlockMaterial {
@Override
public boolean isFragileWhenPushed() {
return delegate.getPushReaction() == EnumPushReaction.DESTROY;
return delegate.getPushReaction() == PushReaction.DESTROY;
}
@Override
public boolean isUnpushable() {
return delegate.getPushReaction() == EnumPushReaction.BLOCK;
return delegate.getPushReaction() == PushReaction.BLOCK;
}
@Override

Datei anzeigen

@ -26,7 +26,6 @@ import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.state.IProperty;
import net.minecraftforge.fml.loading.FMLLoader;
@ -77,7 +76,7 @@ public class ForgeBlockRegistry extends BundledBlockRegistry {
@Override
public OptionalInt getInternalBlockStateId(BlockState state) {
IBlockState equivalent = ForgeAdapter.adapt(state);
net.minecraft.block.BlockState equivalent = ForgeAdapter.adapt(state);
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.JsonParseException;
import com.mojang.datafixers.DSL.TypeReference;
import com.mojang.datafixers.DataFixTypes;
import com.mojang.datafixers.DataFixer;
import com.mojang.datafixers.DataFixerBuilder;
import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.schemas.Schema;
import com.sk89q.jnbt.CompoundTag;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.nbt.INBTBase;
import net.minecraft.item.DyeColor;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.NBTDynamicOps;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.nbt.NBTTagFloat;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.JsonUtils;
import net.minecraft.nbt.StringNBT;
import net.minecraft.nbt.FloatNBT;
import net.minecraft.util.Direction;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
import net.minecraft.util.datafix.DataFixesManager;
import net.minecraft.util.datafix.TypeReferences;
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.Logger;
@ -104,50 +103,50 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
}
private CompoundTag fixChunk(CompoundTag originalChunk, int srcVer) {
NBTTagCompound tag = NBTConverter.toNative(originalChunk);
NBTTagCompound fixed = convert(LegacyType.CHUNK, tag, srcVer);
CompoundNBT tag = NBTConverter.toNative(originalChunk);
CompoundNBT fixed = convert(LegacyType.CHUNK, tag, srcVer);
return NBTConverter.fromNative(fixed);
}
private CompoundTag fixBlockEntity(CompoundTag origTileEnt, int srcVer) {
NBTTagCompound tag = NBTConverter.toNative(origTileEnt);
NBTTagCompound fixed = convert(LegacyType.BLOCK_ENTITY, tag, srcVer);
CompoundNBT tag = NBTConverter.toNative(origTileEnt);
CompoundNBT fixed = convert(LegacyType.BLOCK_ENTITY, tag, srcVer);
return NBTConverter.fromNative(fixed);
}
private CompoundTag fixEntity(CompoundTag origEnt, int srcVer) {
NBTTagCompound tag = NBTConverter.toNative(origEnt);
NBTTagCompound fixed = convert(LegacyType.ENTITY, tag, srcVer);
CompoundNBT tag = NBTConverter.toNative(origEnt);
CompoundNBT fixed = convert(LegacyType.ENTITY, tag, srcVer);
return NBTConverter.fromNative(fixed);
}
private String fixBlockState(String blockState, int srcVer) {
NBTTagCompound stateNBT = stateToNBT(blockState);
Dynamic<INBTBase> dynamic = new Dynamic<>(OPS_NBT, stateNBT);
NBTTagCompound fixed = (NBTTagCompound) INSTANCE.fixer.update(TypeReferences.BLOCK_STATE, dynamic, srcVer, DATA_VERSION).getValue();
CompoundNBT stateNBT = stateToNBT(blockState);
Dynamic<INBT> dynamic = new Dynamic<>(OPS_NBT, stateNBT);
CompoundNBT fixed = (CompoundNBT) INSTANCE.fixer.update(TypeReferences.BLOCK_STATE, dynamic, srcVer, DATA_VERSION).getValue();
return nbtToState(fixed);
}
private String nbtToState(NBTTagCompound tagCompound) {
private String nbtToState(CompoundNBT tagCompound) {
StringBuilder sb = new StringBuilder();
sb.append(tagCompound.getString("Name"));
if (tagCompound.contains("Properties", 10)) {
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(']');
}
return sb.toString();
}
private static NBTTagCompound stateToNBT(String blockState) {
private static CompoundNBT stateToNBT(String blockState) {
int propIdx = blockState.indexOf('[');
NBTTagCompound tag = new NBTTagCompound();
CompoundNBT tag = new CompoundNBT();
if (propIdx < 0) {
tag.putString("Name", blockState);
} else {
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[] propArr = props.split(",");
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) {
return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, new NBTTagString(key)), srcVer, DATA_VERSION)
.getStringValue().orElse(key);
return INSTANCE.fixer.update(type, new Dynamic<>(OPS_NBT, new StringNBT(key)), srcVer, DATA_VERSION)
.asString().orElse(key);
}
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<>();
public enum LegacyType {
LEVEL(DataFixTypes.LEVEL),
PLAYER(DataFixTypes.PLAYER),
CHUNK(DataFixTypes.CHUNK),
LEVEL(TypeReferences.LEVEL),
PLAYER(TypeReferences.PLAYER),
CHUNK(TypeReferences.CHUNK),
BLOCK_ENTITY(TypeReferences.BLOCK_ENTITY),
ENTITY(TypeReferences.ENTITY),
ITEM_INSTANCE(TypeReferences.ITEM_STACK),
OPTIONS(DataFixTypes.OPTIONS),
STRUCTURE(DataFixTypes.STRUCTURE);
OPTIONS(TypeReferences.OPTIONS),
STRUCTURE(TypeReferences.STRUCTURE);
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);
DATA_VERSION = dataVersion;
INSTANCE = this;
@ -215,8 +214,6 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
this.fixer = new WrappedDataFixer(DataFixesManager.getDataFixer());
}
// Called after fixers are built and ready for FIXING
@Override
public DataFixer build(final Executor executor) {
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) {
LegacyType legacyType = DFU_TO_LEGACY.get(type.typeName());
if (sourceVer < LEGACY_VERSION && legacyType != null) {
NBTTagCompound cmp = (NBTTagCompound) dynamic.getValue();
CompoundNBT cmp = (CompoundNBT) dynamic.getValue();
int desiredVersion = Math.min(targetVer, LEGACY_VERSION);
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);
}
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);
if (converters != null && !converters.isEmpty()) {
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);
}
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);
}
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);
}
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;
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);
}
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) {
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 {
NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer);
CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer);
}
public interface DataConverter {
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;
}
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));
}
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)) {
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)) {
NBTTagList nbttaglist = nbttagcompound.getList(key, 10);
ListNBT nbttaglist = nbttagcompound.getList(key, 10);
for (int j = 0; j < nbttaglist.size(); ++j) {
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
public NBTTagCompound convert(NBTTagCompound cmp) {
NBTTagList nbttaglist = cmp.getList("Equipment", 10);
NBTTagList nbttaglist1;
public CompoundNBT convert(CompoundNBT cmp) {
ListNBT nbttaglist = cmp.getList("Equipment", 10);
ListNBT nbttaglist1;
if (!nbttaglist.isEmpty() && !cmp.contains("HandItems", 10)) {
nbttaglist1 = new NBTTagList();
nbttaglist1 = new ListNBT();
nbttaglist1.add(nbttaglist.get(0));
nbttaglist1.add(new NBTTagCompound());
nbttaglist1.add(new CompoundNBT());
cmp.put("HandItems", nbttaglist1);
}
if (nbttaglist.size() > 1 && !cmp.contains("ArmorItem", 10)) {
nbttaglist1 = new NBTTagList();
nbttaglist1 = new ListNBT();
nbttaglist1.add(nbttaglist.get(1));
nbttaglist1.add(nbttaglist.get(2));
nbttaglist1.add(nbttaglist.get(3));
@ -638,21 +635,21 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
cmp.remove("Equipment");
if (cmp.contains("DropChances", 9)) {
nbttaglist1 = cmp.getList("DropChances", 5);
NBTTagList nbttaglist2;
ListNBT nbttaglist2;
if (!cmp.contains("HandDropChances", 10)) {
nbttaglist2 = new NBTTagList();
nbttaglist2.add(new NBTTagFloat(nbttaglist1.getFloat(0)));
nbttaglist2.add(new NBTTagFloat(0.0F));
nbttaglist2 = new ListNBT();
nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(0)));
nbttaglist2.add(new FloatNBT(0.0F));
cmp.put("HandDropChances", nbttaglist2);
}
if (!cmp.contains("ArmorDropChances", 10)) {
nbttaglist2 = new NBTTagList();
nbttaglist2.add(new NBTTagFloat(nbttaglist1.getFloat(1)));
nbttaglist2.add(new NBTTagFloat(nbttaglist1.getFloat(2)));
nbttaglist2.add(new NBTTagFloat(nbttaglist1.getFloat(3)));
nbttaglist2.add(new NBTTagFloat(nbttaglist1.getFloat(4)));
nbttaglist2 = new ListNBT();
nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(1)));
nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(2)));
nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(3)));
nbttaglist2.add(new FloatNBT(nbttaglist1.getFloat(4)));
cmp.put("ArmorDropChances", nbttaglist2);
}
@ -681,14 +678,14 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
}
@Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) {
public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (!cmp.contains("tag", 10)) {
return cmp;
} else {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag");
CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
if (nbttagcompound1.contains("BlockEntityTag", 10)) {
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
CompoundNBT nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
String s = cmp.getString("id");
String s1 = convertEntityId(sourceVer, s);
boolean flag;
@ -812,11 +809,11 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
DataInspectorEntity() {}
@Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag");
public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
if (nbttagcompound1.contains("EntityTag", 10)) {
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
CompoundNBT nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
String s = cmp.getString("id");
String s1;
@ -859,7 +856,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
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")))) {
cmp = this.inspectChecked(cmp, sourceVer, targetVer);
}
@ -867,7 +864,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
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 {
@ -879,7 +876,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
this.keys = astring;
}
NBTTagCompound inspectChecked(NBTTagCompound nbttagcompound, int sourceVer, int targetVer) {
CompoundNBT inspectChecked(CompoundNBT nbttagcompound, int sourceVer, int targetVer) {
for (String s : this.keys) {
ForgeDataFixer.convertItems(nbttagcompound, s, sourceVer, targetVer);
}
@ -896,7 +893,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
this.keys = astring;
}
NBTTagCompound inspectChecked(NBTTagCompound nbttagcompound, int sourceVer, int targetVer) {
CompoundNBT inspectChecked(CompoundNBT nbttagcompound, int sourceVer, int targetVer) {
for (String key : this.keys) {
ForgeDataFixer.convertItem(nbttagcompound, key, sourceVer, targetVer);
}
@ -915,7 +912,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 102;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if (cmp.contains("id", 99)) {
short short0 = cmp.getShort("id");
@ -1254,7 +1251,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 147;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("ArmorStand".equals(cmp.getString("id")) && cmp.getBoolean("Silent") && !cmp.getBoolean("Marker")) {
cmp.remove("Silent");
}
@ -1271,20 +1268,20 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 804;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
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)) {
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
CompoundNBT nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
if (nbttagcompound2.contains("Base", 99)) {
cmp.putShort("Damage", (short) (nbttagcompound2.getShort("Base") & 15));
if (nbttagcompound1.contains("display", 10)) {
NBTTagCompound nbttagcompound3 = nbttagcompound1.getCompound("display");
CompoundNBT nbttagcompound3 = nbttagcompound1.getCompound("display");
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))) {
return cmp;
@ -1318,9 +1315,9 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 102;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:potion".equals(cmp.getString("id"))) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag");
CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
short short0 = cmp.getShort("Damage");
if (!nbttagcompound1.contains("Potion", 8)) {
@ -1483,10 +1480,10 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 105;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:spawn_egg".equals(cmp.getString("id"))) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag");
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
CompoundNBT nbttagcompound2 = nbttagcompound1.getCompound("EntityTag");
short short0 = cmp.getShort("Damage");
if (!nbttagcompound2.contains("id", 8)) {
@ -1589,7 +1586,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 106;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("Minecart".equals(cmp.getString("id"))) {
String s = "MinecartRideable";
int i = cmp.getInt("Type");
@ -1614,13 +1611,13 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 107;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if (!"MobSpawner".equals(cmp.getString("id"))) {
return cmp;
} else {
if (cmp.contains("EntityId", 8)) {
String s = cmp.getString("EntityId");
NBTTagCompound nbttagcompound1 = cmp.getCompound("SpawnData");
CompoundNBT nbttagcompound1 = cmp.getCompound("SpawnData");
nbttagcompound1.putString("id", s.isEmpty() ? "Pig" : s);
cmp.put("SpawnData", nbttagcompound1);
@ -1628,13 +1625,13 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
}
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) {
NBTTagCompound nbttagcompound2 = nbttaglist.getCompound(i);
CompoundNBT nbttagcompound2 = nbttaglist.getCompound(i);
if (nbttagcompound2.contains("Type", 8)) {
NBTTagCompound nbttagcompound3 = nbttagcompound2.getCompound("Properties");
CompoundNBT nbttagcompound3 = nbttagcompound2.getCompound("Properties");
nbttagcompound3.putString("id", nbttagcompound2.getString("Type"));
nbttagcompound2.put("Entity", nbttagcompound3);
@ -1657,7 +1654,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 108;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if (cmp.contains("UUID", 8)) {
cmp.putUniqueId("UUID", UUID.fromString(cmp.getString("UUID")));
}
@ -1676,7 +1673,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 109;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if (DataConverterHealth.a.contains(cmp.getString("id"))) {
float f;
@ -1706,9 +1703,9 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
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")) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
CompoundNBT nbttagcompound1 = new CompoundNBT();
nbttagcompound1.putString("id", "minecraft:saddle");
nbttagcompound1.putByte("Count", (byte) 1);
@ -1729,16 +1726,16 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 111;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
String s = cmp.getString("id");
boolean flag = "Painting".equals(s);
boolean flag1 = "ItemFrame".equals(s);
if ((flag || flag1) && !cmp.contains("Facing", 99)) {
EnumFacing enumdirection;
Direction enumdirection;
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("TileY", cmp.getInt("TileY") + enumdirection.getYOffset());
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));
}
} else {
enumdirection = EnumFacing.byHorizontalIndex(cmp.getByte("Dir"));
enumdirection = Direction.byHorizontalIndex(cmp.getByte("Dir"));
cmp.remove("Dir");
}
@ -1766,8 +1763,8 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 113;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
NBTTagList nbttaglist;
public CompoundNBT convert(CompoundNBT cmp) {
ListNBT nbttaglist;
if (cmp.contains("HandDropChances", 9)) {
nbttaglist = cmp.getList("HandDropChances", 5);
@ -1795,9 +1792,9 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 135;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
while (cmp.contains("Riding", 10)) {
NBTTagCompound nbttagcompound1 = this.b(cmp);
CompoundNBT nbttagcompound1 = this.b(cmp);
this.convert(cmp, nbttagcompound1);
cmp = nbttagcompound1;
@ -1806,15 +1803,15 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return cmp;
}
protected void convert(NBTTagCompound nbttagcompound, NBTTagCompound nbttagcompound1) {
NBTTagList nbttaglist = new NBTTagList();
protected void convert(CompoundNBT nbttagcompound, CompoundNBT nbttagcompound1) {
ListNBT nbttaglist = new ListNBT();
nbttaglist.add(nbttagcompound);
nbttagcompound1.put("Passengers", nbttaglist);
}
protected NBTTagCompound b(NBTTagCompound nbttagcompound) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Riding");
protected CompoundNBT b(CompoundNBT nbttagcompound) {
CompoundNBT nbttagcompound1 = nbttagcompound.getCompound("Riding");
nbttagcompound.remove("Riding");
return nbttagcompound1;
@ -1829,12 +1826,12 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 165;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:written_book".equals(cmp.getString("id"))) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag");
CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
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) {
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 ((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 {
try {
object = JsonUtils.fromJson(DataConverterSignText.a, s, ITextComponent.class, true);
object = JSONUtils.fromJson(DataConverterSignText.a, s, ITextComponent.class, true);
if (object == null) {
object = new TextComponentString("");
object = new StringTextComponent("");
}
} catch (JsonParseException jsonparseexception) {
;
@ -1870,14 +1867,14 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
}
if (object == null) {
object = new TextComponentString(s);
object = new StringTextComponent(s);
}
}
} 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);
@ -1898,7 +1895,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
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")))) {
cmp.putString("id", "minecraft:cooked_fish");
}
@ -1917,7 +1914,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 502;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("Zombie".equals(cmp.getString("id")) && cmp.getBoolean("IsVillager")) {
if (!cmp.contains("ZombieType", 99)) {
int i = -1;
@ -1956,7 +1953,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 505;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
cmp.putString("useVbo", "true");
return cmp;
}
@ -1970,7 +1967,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 700;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("Guardian".equals(cmp.getString("id"))) {
if (cmp.getBoolean("Elder")) {
cmp.putString("id", "ElderGuardian");
@ -1991,7 +1988,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 701;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
String s = cmp.getString("id");
if ("Skeleton".equals(s)) {
@ -2018,7 +2015,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 702;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("Zombie".equals(cmp.getString("id"))) {
int i = cmp.getInt("ZombieType");
@ -2053,7 +2050,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 703;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("EntityHorse".equals(cmp.getString("id"))) {
int i = cmp.getInt("Type");
@ -2097,7 +2094,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 704;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
String s = DataConverterTileEntity.a.get(cmp.getString("id"));
if (s != null) {
@ -2144,7 +2141,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 704;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
String s = DataConverterEntity.a.get(cmp.getString("id"));
if (s != null) {
@ -2241,11 +2238,11 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 806;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
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)) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("tag");
CompoundNBT nbttagcompound1 = cmp.getCompound("tag");
if (!nbttagcompound1.contains("Potion", 8)) {
nbttagcompound1.putString("Potion", "minecraft:water");
@ -2268,7 +2265,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 808;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:shulker".equals(cmp.getString("id")) && !cmp.contains("Color", 99)) {
cmp.putByte("Color", (byte) 10);
}
@ -2287,12 +2284,12 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 813;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
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)) {
NBTTagCompound nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
CompoundNBT nbttagcompound2 = nbttagcompound1.getCompound("BlockEntityTag");
if (nbttagcompound2.getList("Items", 10).isEmpty()) {
nbttagcompound2.remove("Items");
@ -2325,7 +2322,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 813;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:shulker".equals(cmp.getString("id"))) {
cmp.remove("Color");
}
@ -2342,7 +2339,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 816;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if (cmp.contains("lang", 8)) {
cmp.putString("lang", cmp.getString("lang").toLowerCase(Locale.ROOT));
}
@ -2359,7 +2356,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 820;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("minecraft:totem".equals(cmp.getString("id"))) {
cmp.putString("id", "minecraft:totem_of_undying");
}
@ -2378,18 +2375,18 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 1125;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
boolean flag = true;
try {
NBTTagCompound nbttagcompound1 = cmp.getCompound("Level");
CompoundNBT nbttagcompound1 = cmp.getCompound("Level");
int i = nbttagcompound1.getInt("xPos");
int j = nbttagcompound1.getInt("zPos");
NBTTagList nbttaglist = nbttagcompound1.getList("TileEntities", 10);
NBTTagList nbttaglist1 = nbttagcompound1.getList("Sections", 10);
ListNBT nbttaglist = nbttagcompound1.getList("TileEntities", 10);
ListNBT nbttaglist1 = nbttagcompound1.getList("Sections", 10);
for (int k = 0; k < nbttaglist1.size(); ++k) {
NBTTagCompound nbttagcompound2 = nbttaglist1.getCompound(k);
CompoundNBT nbttagcompound2 = nbttaglist1.getCompound(k);
byte b0 = nbttagcompound2.getByte("Y");
byte[] abyte = nbttagcompound2.getByteArray("Blocks");
@ -2398,7 +2395,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
int i1 = l & 15;
int j1 = l >> 8 & 15;
int k1 = l >> 4 & 15;
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
CompoundNBT nbttagcompound3 = new CompoundNBT();
nbttagcompound3.putString("id", "bed");
nbttagcompound3.putInt("x", i1 + (i << 4));
@ -2424,9 +2421,9 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 1125;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
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;
@ -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() {
ITextComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
if (jsonelement.isJsonPrimitive()) {
return new TextComponentString(jsonelement.getAsString());
return new StringTextComponent(jsonelement.getAsString());
} else if (jsonelement.isJsonArray()) {
JsonArray jsonarray = jsonelement.getAsJsonArray();
ITextComponent iTextComponent = null;
@ -2472,7 +2469,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return 101;
}
public NBTTagCompound convert(NBTTagCompound cmp) {
public CompoundNBT convert(CompoundNBT cmp) {
if ("Sign".equals(cmp.getString("id"))) {
this.convert(cmp, "Text1");
this.convert(cmp, "Text2");
@ -2483,18 +2480,18 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
return cmp;
}
private void convert(NBTTagCompound nbttagcompound, String s) {
private void convert(CompoundNBT nbttagcompound, String s) {
String s1 = nbttagcompound.getString(s);
Object object = null;
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)) {
object = new TextComponentString(s1);
object = new StringTextComponent(s1);
} else {
try {
object = JsonUtils.fromJson(DataConverterSignText.a, s1, ITextComponent.class, true);
object = JSONUtils.fromJson(DataConverterSignText.a, s1, ITextComponent.class, true);
if (object == null) {
object = new TextComponentString("");
object = new StringTextComponent("");
}
} catch (JsonParseException jsonparseexception) {
;
@ -2517,11 +2514,11 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
}
if (object == null) {
object = new TextComponentString(s1);
object = new StringTextComponent(s1);
}
}
} else {
object = new TextComponentString("");
object = new StringTextComponent("");
}
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 {
@Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) {
public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (cmp.contains("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("RootVehicle");
CompoundNBT nbttagcompound1 = cmp.getCompound("RootVehicle");
if (nbttagcompound1.contains("Entity", 10)) {
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 {
@Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) {
public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (cmp.contains("Player", 10)) {
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 {
@Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) {
NBTTagList nbttaglist;
public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
ListNBT nbttaglist;
int j;
NBTTagCompound nbttagcompound1;
CompoundNBT nbttagcompound1;
if (cmp.contains("entities", 9)) {
nbttaglist = cmp.getList("entities", 10);
for (j = 0; j < nbttaglist.size(); ++j) {
nbttagcompound1 = (NBTTagCompound) nbttaglist.get(j);
nbttagcompound1 = (CompoundNBT) nbttaglist.get(j);
if (nbttagcompound1.contains("nbt", 10)) {
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);
for (j = 0; j < nbttaglist.size(); ++j) {
nbttagcompound1 = (NBTTagCompound) nbttaglist.get(j);
nbttagcompound1 = (CompoundNBT) nbttaglist.get(j);
if (nbttagcompound1.contains("nbt", 10)) {
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 {
@Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) {
public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
if (cmp.contains("Level", 10)) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("Level");
NBTTagList nbttaglist;
CompoundNBT nbttagcompound1 = cmp.getCompound("Level");
ListNBT nbttaglist;
int j;
if (nbttagcompound1.contains("Entities", 9)) {
nbttaglist = nbttagcompound1.getList("Entities", 10);
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);
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 {
@Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) {
public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
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) {
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 {
@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, "EnderItems", sourceVer, targetVer);
if (cmp.contains("ShoulderEntityLeft", 10)) {
@ -2652,15 +2649,15 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
ResourceLocation entityVillager = getKey("EntityVillager");
@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)) {
NBTTagCompound nbttagcompound1 = cmp.getCompound("Offers");
CompoundNBT nbttagcompound1 = cmp.getCompound("Offers");
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) {
NBTTagCompound nbttagcompound2 = nbttaglist.getCompound(j);
CompoundNBT nbttagcompound2 = nbttaglist.getCompound(j);
convertItem(nbttagcompound2, "buy", sourceVer, targetVer);
convertItem(nbttagcompound2, "buyB", sourceVer, targetVer);
@ -2679,7 +2676,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner");
@Override
public NBTTagCompound inspect(NBTTagCompound cmp, int sourceVer, int targetVer) {
public CompoundNBT inspect(CompoundNBT cmp, int sourceVer, int targetVer) {
String s = cmp.getString("id");
if (entityMinecartMobSpawner.equals(new ResourceLocation(s))) {
cmp.putString("id", tileEntityMobSpawner.toString());
@ -2695,13 +2692,13 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
ResourceLocation tileEntityMobSpawner = getKey("TileEntityMobSpawner");
@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 (cmp.contains("SpawnPotentials", 9)) {
NBTTagList nbttaglist = cmp.getList("SpawnPotentials", 10);
ListNBT nbttaglist = cmp.getList("SpawnPotentials", 10);
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);
}
@ -2718,7 +2715,7 @@ class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wor
ResourceLocation tileEntityCommand = getKey("TileEntityCommand");
@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")))) {
cmp.putString("id", "Control");
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.world.NullWorld;
import com.sk89q.worldedit.world.entity.EntityTypes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import java.lang.ref.WeakReference;
@ -51,7 +51,7 @@ class ForgeEntity implements Entity {
if (entity != null) {
ResourceLocation id = entity.getType().getRegistryName();
if (id != null) {
NBTTagCompound tag = new NBTTagCompound();
CompoundNBT tag = new CompoundNBT();
entity.writeWithoutTypeId(tag);
return new BaseEntity(EntityTypes.get(id.toString()), NBTConverter.fromNative(tag));
} else {
@ -78,7 +78,7 @@ class ForgeEntity implements Entity {
@Override
public boolean setLocation(Location location) {
// TODO
// TODO unused atm
return false;
}

Datei anzeigen

@ -23,27 +23,27 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.entity.metadata.EntityProperties;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.IMerchant;
import net.minecraft.entity.INpc;
import net.minecraft.entity.boss.dragon.EnderDragonPartEntity;
import net.minecraft.entity.item.ArmorStandEntity;
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.MultiPartEntityPart;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.item.EntityEnderEye;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.item.EntityPainting;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.monster.EntityGolem;
import net.minecraft.entity.passive.EntityAmbientCreature;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.item.BoatEntity;
import net.minecraft.entity.item.EyeOfEnderEntity;
import net.minecraft.entity.item.FallingBlockEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.item.ItemFrameEntity;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.entity.passive.AmbientEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.passive.GolemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
public class ForgeEntityProperties implements EntityProperties {
@ -56,82 +56,82 @@ public class ForgeEntityProperties implements EntityProperties {
@Override
public boolean isPlayerDerived() {
return entity instanceof EntityPlayer;
return entity instanceof PlayerEntity;
}
@Override
public boolean isProjectile() {
return entity instanceof EntityEnderEye || entity instanceof IProjectile;
return entity instanceof EyeOfEnderEntity || entity instanceof IProjectile;
}
@Override
public boolean isItem() {
return entity instanceof EntityItem;
return entity instanceof ItemEntity;
}
@Override
public boolean isFallingBlock() {
return entity instanceof EntityFallingBlock;
return entity instanceof FallingBlockEntity;
}
@Override
public boolean isPainting() {
return entity instanceof EntityPainting;
return entity instanceof PaintingEntity;
}
@Override
public boolean isItemFrame() {
return entity instanceof EntityItemFrame;
return entity instanceof ItemFrameEntity;
}
@Override
public boolean isBoat() {
return entity instanceof EntityBoat;
return entity instanceof BoatEntity;
}
@Override
public boolean isMinecart() {
return entity instanceof EntityMinecart;
return entity instanceof AbstractMinecartEntity;
}
@Override
public boolean isTNT() {
return entity instanceof EntityTNTPrimed;
return entity instanceof TNTEntity;
}
@Override
public boolean isExperienceOrb() {
return entity instanceof EntityXPOrb;
return entity instanceof ExperienceOrbEntity;
}
@Override
public boolean isLiving() {
return entity instanceof EntityLiving;
return entity instanceof MobEntity;
}
@Override
public boolean isAnimal() {
return entity instanceof EntityAnimal;
return entity instanceof AnimalEntity;
}
@Override
public boolean isAmbient() {
return entity instanceof EntityAmbientCreature;
return entity instanceof AmbientEntity;
}
@Override
public boolean isNPC() {
return entity instanceof INpc || entity instanceof IMerchant;
return entity instanceof INPC || entity instanceof IMerchant;
}
@Override
public boolean isGolem() {
return entity instanceof EntityGolem;
return entity instanceof GolemEntity;
}
@Override
public boolean isTamed() {
return entity instanceof EntityTameable && ((EntityTameable) entity).isTamed();
return entity instanceof TameableEntity && ((TameableEntity) entity).isTamed();
}
@Override
@ -141,11 +141,11 @@ public class ForgeEntityProperties implements EntityProperties {
@Override
public boolean isArmorStand() {
return entity instanceof EntityArmorStand;
return entity instanceof ArmorStandEntity;
}
@Override
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;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.world.GameType;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
public interface ForgePermissionsProvider {
boolean hasPermission(EntityPlayerMP player, String permission);
boolean hasPermission(ServerPlayerEntity player, String permission);
void registerPermission(String permission);
@ -38,7 +38,7 @@ public interface ForgePermissionsProvider {
}
@Override
public boolean hasPermission(EntityPlayerMP player, String permission) {
public boolean hasPermission(ServerPlayerEntity player, String permission) {
ForgeConfiguration configuration = platform.getConfiguration();
return configuration.cheatMode ||
ServerLifecycleHooks.getCurrentServer().getPlayerList().canSendCommands(player.getGameProfile()) ||
@ -49,7 +49,7 @@ public interface ForgePermissionsProvider {
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 {
//
// @Override

Datei anzeigen

@ -30,11 +30,12 @@ import com.sk89q.worldedit.world.DataFixer;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.registry.Registries;
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.management.PlayerList;
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 org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager;
@ -74,8 +75,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
@Override
public int getDataVersion() {
// TODO switch to SharedConstants in 1.14
return 1631;
return SharedConstants.getVersion().getWorldVersion();
}
@Override
@ -99,10 +99,10 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
}
@Override
public List<? extends com.sk89q.worldedit.world.World> getWorlds() {
Iterable<WorldServer> worlds = server.getWorlds();
List<com.sk89q.worldedit.world.World> ret = new ArrayList<>();
for (WorldServer world : worlds) {
public List<? extends World> getWorlds() {
Iterable<ServerWorld> worlds = server.getWorlds();
List<World> ret = new ArrayList<>();
for (ServerWorld world : worlds) {
ret.add(new ForgeWorld(world));
}
return ret;
@ -114,7 +114,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
if (player instanceof ForgePlayer) {
return player;
} else {
EntityPlayerMP entity = server.getPlayerList().getPlayerByUsername(player.getName());
ServerPlayerEntity entity = server.getPlayerList().getPlayerByUsername(player.getName());
return entity != null ? new ForgePlayer(entity) : null;
}
}
@ -125,7 +125,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
if (world instanceof ForgeWorld) {
return world;
} else {
for (WorldServer ws : server.getWorlds()) {
for (ServerWorld ws : server.getWorlds()) {
if (ws.getWorldInfo().getWorldName().equals(world.getName())) {
return new ForgeWorld(ws);
}
@ -145,7 +145,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
Set<String> perms = command.getCondition().as(PermissionCondition.class)
.map(PermissionCondition::getPermissions)
.orElseGet(Collections::emptySet);
if (perms.size() > 0) {
if (!perms.isEmpty()) {
perms.forEach(ForgeWorldEdit.inst.getPermissionsProvider()::registerPermission);
}
}
@ -193,7 +193,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
public Collection<Actor> getConnectedUsers() {
List<Actor> users = new ArrayList<>();
PlayerList scm = server.getPlayerList();
for (EntityPlayerMP entity : scm.getPlayers()) {
for (ServerPlayerEntity entity : scm.getPlayers()) {
if (entity != null) {
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 io.netty.buffer.Unpooled;
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.network.PacketBuffer;
import net.minecraft.network.play.server.SPacketBlockChange;
import net.minecraft.network.play.server.SPacketCustomPayload;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.network.play.server.SChangeBlockPacket;
import net.minecraft.network.play.server.SCustomPayloadPlayPacket;
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
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 java.io.IOException;
@ -60,10 +60,11 @@ import javax.annotation.Nullable;
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 final EntityPlayerMP player;
private final ServerPlayerEntity player;
protected ForgePlayer(EntityPlayerMP player) {
protected ForgePlayer(ServerPlayerEntity player) {
this.player = player;
ThreadSafeCache.getInstance().getOnlineIds().add(getUniqueId());
}
@ -75,7 +76,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override
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);
}
@ -123,14 +124,14 @@ public class ForgePlayer extends AbstractPlayerActor {
send = send + "|" + StringUtil.joinString(params, "|");
}
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);
}
@Override
public void printRaw(String msg) {
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) {
for (String part : msg.split("\n")) {
TextComponentString component = new TextComponentString(part);
StringTextComponent component = new StringTextComponent(part);
component.getStyle().setColor(formatting);
this.player.sendMessage(component);
}
@ -196,10 +197,10 @@ public class ForgePlayer extends AbstractPlayerActor {
}
BlockPos loc = ForgeAdapter.toBlockPos(pos);
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);
} else {
final SPacketBlockChange packetOut = new SPacketBlockChange();
final SChangeBlockPacket packetOut = new SChangeBlockPacket();
PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
buf.writeBlockPos(loc);
buf.writeVarInt(Block.getStateId(ForgeAdapter.adapt(block.toImmutableState())));
@ -213,7 +214,7 @@ public class ForgePlayer extends AbstractPlayerActor {
final BaseBlock baseBlock = (BaseBlock) block;
final CompoundTag nbtData = baseBlock.getNbtData();
if (nbtData != null) {
player.connection.sendPacket(new SPacketUpdateTileEntity(
player.connection.sendPacket(new SUpdateTileEntityPacket(
new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()),
STRUCTURE_BLOCK_PACKET_ID,
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.WeatherTypes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.LeavesBlock;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
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.WorldServer;
import net.minecraft.world.chunk.AbstractChunkProvider;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.storage.AnvilSaveHandler;
import net.minecraft.world.gen.ChunkProviderServer;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.chunk.IChunk;
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.BigMushroomFeatureConfig;
import net.minecraft.world.gen.feature.BigRedMushroomFeature;
import net.minecraft.world.gen.feature.BigTreeFeature;
import net.minecraft.world.gen.feature.BirchTreeFeature;
import net.minecraft.world.gen.feature.CanopyTreeFeature;
import net.minecraft.world.gen.feature.DarkOakTreeFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraft.world.gen.feature.JungleTreeFeature;
import net.minecraft.world.gen.feature.MegaJungleFeature;
import net.minecraft.world.gen.feature.MegaPineTree;
@ -88,17 +91,20 @@ import net.minecraft.world.gen.feature.ShrubFeature;
import net.minecraft.world.gen.feature.SwampTreeFeature;
import net.minecraft.world.gen.feature.TallTaigaTreeFeature;
import net.minecraft.world.gen.feature.TreeFeature;
import net.minecraft.world.storage.SaveHandler;
import net.minecraft.world.storage.WorldInfo;
import javax.annotation.Nullable;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Random;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
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 int UPDATE = 1, NOTIFY = 2;
private static final IBlockState JUNGLE_LOG = Blocks.JUNGLE_LOG.getDefaultState();
private static final IBlockState JUNGLE_LEAF = Blocks.JUNGLE_LEAVES.getDefaultState().with(BlockLeaves.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_LOG = Blocks.JUNGLE_LOG.getDefaultState();
private static final net.minecraft.block.BlockState JUNGLE_LEAF = Blocks.JUNGLE_LEAVES.getDefaultState().with(LeavesBlock.PERSISTENT, Boolean.TRUE);
private static final net.minecraft.block.BlockState JUNGLE_SHRUB = Blocks.OAK_LEAVES.getDefaultState().with(LeavesBlock.PERSISTENT, Boolean.TRUE);
private final WeakReference<World> worldRef;
@ -174,10 +180,10 @@ public class ForgeWorld extends AbstractWorld {
// First set the block
Chunk chunk = world.getChunk(x >> 4, z >> 4);
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());
IBlockState newState = stateId.isPresent() ? Block.getStateById(stateId.getAsInt()) : ForgeAdapter.adapt(block.toImmutableState());
IBlockState successState = chunk.setBlockState(pos, newState, false);
net.minecraft.block.BlockState newState = stateId.isPresent() ? Block.getStateById(stateId.getAsInt()) : ForgeAdapter.adapt(block.toImmutableState());
net.minecraft.block.BlockState successState = chunk.setBlockState(pos, newState, false);
boolean successful = successState != null;
// Create the TileEntity
@ -185,15 +191,16 @@ public class ForgeWorld extends AbstractWorld {
if (block instanceof BaseBlock) {
CompoundTag tag = ((BaseBlock) block).getNbtData();
if (tag != null) {
NBTTagCompound nativeTag = NBTConverter.toNative(tag);
CompoundNBT nativeTag = NBTConverter.toNative(tag);
nativeTag.putString("id", ((BaseBlock) block).getNbtId());
TileEntityUtils.setTileEntity(world, position, nativeTag);
successful = true; // update if TE changed as well
}
}
}
if (successful && notifyAndLight) {
world.checkLight(pos);
world.getChunkProvider().getLightManager().checkBlock(pos);
world.markAndNotifyBlock(pos, chunk, old, newState, UPDATE | NOTIFY);
}
@ -239,45 +246,44 @@ public class ForgeWorld extends AbstractWorld {
checkNotNull(position);
checkNotNull(biome);
Chunk chunk = getWorld().getChunk(new BlockPos(position.getBlockX(), 0, position.getBlockZ()));
if (chunk.isLoaded()) {
chunk.getBiomes()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = ForgeAdapter.adapt(biome);
return true;
IChunk chunk = getWorld().getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4, ChunkStatus.FULL, false);
if (chunk == null) {
return false;
}
return false;
chunk.getBiomes()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = ForgeAdapter.adapt(biome);
return true;
}
private static LoadingCache<WorldServer, WorldEditFakePlayer> fakePlayers
private static LoadingCache<ServerWorld, WorldEditFakePlayer> fakePlayers
= CacheBuilder.newBuilder().weakKeys().softValues().build(CacheLoader.from(WorldEditFakePlayer::new));
@Override
public boolean useItem(BlockVector3 position, BaseItem item, Direction face) {
ItemStack stack = ForgeAdapter.adapt(new BaseItemStack(item.getType(), item.getNbtData(), 1));
WorldServer world = (WorldServer) getWorld();
ServerWorld world = (ServerWorld) getWorld();
final WorldEditFakePlayer fakePlayer;
try {
fakePlayer = fakePlayers.get(world);
} catch (ExecutionException ignored) {
return false;
}
fakePlayer.setHeldItem(EnumHand.MAIN_HAND, stack);
fakePlayer.setHeldItem(Hand.MAIN_HAND, stack);
fakePlayer.setLocationAndAngles(position.getBlockX(), position.getBlockY(), position.getBlockZ(),
(float) face.toVector().toYaw(), (float) face.toVector().toPitch());
final BlockPos blockPos = ForgeAdapter.toBlockPos(position);
final EnumFacing enumFacing = ForgeAdapter.adapt(face);
ItemUseContext itemUseContext = new ItemUseContext(fakePlayer, stack, blockPos, enumFacing, blockPos.getX(), blockPos.getY(), blockPos.getZ());
EnumActionResult used = stack.onItemUse(itemUseContext);
if (used != EnumActionResult.SUCCESS) {
final BlockRayTraceResult rayTraceResult = new BlockRayTraceResult(ForgeAdapter.toVec3(position),
ForgeAdapter.adapt(face), blockPos, false);
ItemUseContext itemUseContext = new ItemUseContext(fakePlayer, Hand.MAIN_HAND, rayTraceResult);
ActionResultType used = stack.onItemUse(itemUseContext);
if (used != ActionResultType.SUCCESS) {
// try activating the block
if (getWorld().getBlockState(blockPos).onBlockActivated(world, blockPos, fakePlayer, EnumHand.MAIN_HAND,
enumFacing, blockPos.getX(), blockPos.getY(), blockPos.getZ())) {
used = EnumActionResult.SUCCESS;
if (getWorld().getBlockState(blockPos).onBlockActivated(world, fakePlayer, Hand.MAIN_HAND, rayTraceResult)) {
used = ActionResultType.SUCCESS;
} 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
@ -289,24 +295,22 @@ public class ForgeWorld extends AbstractWorld {
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);
getWorld().spawnEntity(entity);
getWorld().addEntity(entity);
}
@Override
public void simulateBlockMine(BlockVector3 position) {
BlockPos pos = ForgeAdapter.toBlockPos(position);
IBlockState state = getWorld().getBlockState(pos);
state.dropBlockAsItem(getWorld(), pos, 0);
getWorld().removeBlock(pos);
getWorld().destroyBlock(pos, true);
}
@Override
public boolean regenerate(Region region, EditSession editSession) {
// Don't even try to regen if it's going to fail.
IChunkProvider provider = getWorld().getChunkProvider();
if (!(provider instanceof ChunkProviderServer)) {
AbstractChunkProvider provider = getWorld().getChunkProvider();
if (!(provider instanceof ServerChunkProvider)) {
return false;
}
@ -315,11 +319,12 @@ public class ForgeWorld extends AbstractWorld {
// normally it should be deleted at the end of this method
saveFolder.deleteOnExit();
try {
WorldServer originalWorld = (WorldServer) getWorld();
ServerWorld originalWorld = (ServerWorld) getWorld();
MinecraftServer server = originalWorld.getServer();
AnvilSaveHandler saveHandler = new AnvilSaveHandler(saveFolder, originalWorld.getSaveHandler().getWorldDirectory().getName(), server, server.getDataFixer());
World freshWorld = new WorldServer(server, saveHandler, originalWorld.getSavedDataStorage(), originalWorld.getWorldInfo(), originalWorld.dimension.getType(), originalWorld.profiler).init();
SaveHandler saveHandler = new SaveHandler(saveFolder, originalWorld.getSaveHandler().getWorldDirectory().getName(), server, server.getDataFixer());
World freshWorld = new ServerWorld(server, server.getBackgroundExecutor(), saveHandler, originalWorld.getWorldInfo(),
originalWorld.dimension.getType(), originalWorld.getProfiler(), new NoOpChunkStatusListener());
// Pre-gen all the chunks
// We need to also pull one more chunk in every direction
@ -342,36 +347,45 @@ public class ForgeWorld extends AbstractWorld {
}
@Nullable
private static Feature<NoFeatureConfig> createTreeFeatureGenerator(TreeType type) {
private static Feature<? extends IFeatureConfig> createTreeFeatureGenerator(TreeType type) {
switch (type) {
case TREE: return new TreeFeature(true);
case BIG_TREE: return new BigTreeFeature(true);
case PINE:
case REDWOOD: return new PointyTaigaTreeFeature();
case TALL_REDWOOD: return new TallTaigaTreeFeature(true);
case BIRCH: return new BirchTreeFeature(true, false);
case JUNGLE: return new MegaJungleFeature(true, 10, 20, JUNGLE_LOG, JUNGLE_LEAF);
case SMALL_JUNGLE: return new JungleTreeFeature(true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, false);
case SHORT_JUNGLE: return new JungleTreeFeature(true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, true);
case JUNGLE_BUSH: return new ShrubFeature(JUNGLE_LOG, JUNGLE_SHRUB);
case RED_MUSHROOM: return new BigBrownMushroomFeature();
case BROWN_MUSHROOM: return new BigRedMushroomFeature();
case SWAMP: return new SwampTreeFeature();
case ACACIA: return new SavannaTreeFeature(true);
case DARK_OAK: return new CanopyTreeFeature(true);
case MEGA_REDWOOD: return new MegaPineTree(false, random.nextBoolean());
case TALL_BIRCH: return new BirchTreeFeature(true, true);
case TREE: return new TreeFeature(NoFeatureConfig::deserialize, true);
case BIG_TREE: return new BigTreeFeature(NoFeatureConfig::deserialize, true);
case REDWOOD: return new PointyTaigaTreeFeature(NoFeatureConfig::deserialize);
case TALL_REDWOOD: return new TallTaigaTreeFeature(NoFeatureConfig::deserialize, true);
case BIRCH: return new BirchTreeFeature(NoFeatureConfig::deserialize, true, false);
case JUNGLE: return new MegaJungleFeature(NoFeatureConfig::deserialize, true, 10, 20, JUNGLE_LOG, JUNGLE_LEAF);
case SMALL_JUNGLE: return new JungleTreeFeature(NoFeatureConfig::deserialize, true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, false);
case SHORT_JUNGLE: return new JungleTreeFeature(NoFeatureConfig::deserialize, true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, true);
case JUNGLE_BUSH: return new ShrubFeature(NoFeatureConfig::deserialize, JUNGLE_LOG, JUNGLE_SHRUB);
case SWAMP: return new SwampTreeFeature(NoFeatureConfig::deserialize);
case ACACIA: return new SavannaTreeFeature(NoFeatureConfig::deserialize, true);
case DARK_OAK: return new DarkOakTreeFeature(NoFeatureConfig::deserialize, true);
case MEGA_REDWOOD: return new MegaPineTree(NoFeatureConfig::deserialize, true, random.nextBoolean());
case TALL_BIRCH: return new BirchTreeFeature(NoFeatureConfig::deserialize, true, true);
case RED_MUSHROOM: return new BigRedMushroomFeature(BigMushroomFeatureConfig::deserialize);
case BROWN_MUSHROOM: return new BigBrownMushroomFeature(BigMushroomFeatureConfig::deserialize);
case RANDOM: return createTreeFeatureGenerator(TreeType.values()[ThreadLocalRandom.current().nextInt(TreeType.values().length)]);
case RANDOM_REDWOOD:
default:
return null;
}
}
private IFeatureConfig createFeatureConfig(TreeType type) {
if (type == TreeType.RED_MUSHROOM || type == TreeType.BROWN_MUSHROOM) {
return new BigMushroomFeatureConfig(true);
} else {
return new NoFeatureConfig();
}
}
@Override
public boolean generateTree(TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
Feature<NoFeatureConfig> generator = createTreeFeatureGenerator(type);
return generator != null && generator.place(getWorld(), getWorld().getChunkProvider().getChunkGenerator(), random, ForgeAdapter.toBlockPos(position), new NoFeatureConfig());
@SuppressWarnings("unchecked")
Feature<IFeatureConfig> generator = (Feature<IFeatureConfig>) createTreeFeatureGenerator(type);
return generator != null
&& generator.place(getWorld(), getWorld().getChunkProvider().getChunkGenerator(), random,
ForgeAdapter.toBlockPos(position), createFeatureConfig(type));
}
@Override
@ -388,7 +402,7 @@ public class ForgeWorld extends AbstractWorld {
public void fixLighting(Iterable<BlockVector2> chunks) {
World world = getWorld();
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
public int getMaxY() {
return getWorld().getHeight() - 1;
return getWorld().getMaxHeight() - 1;
}
@Override
@ -457,11 +471,9 @@ public class ForgeWorld extends AbstractWorld {
@Override
public BlockState getBlock(BlockVector3 position) {
IBlockState mcState = getWorld().getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4).getBlockState(
position.getBlockX(),
position.getBlockY(),
position.getBlockZ()
);
net.minecraft.block.BlockState mcState = getWorld()
.getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4)
.getBlockState(ForgeAdapter.toBlockPos(position));
BlockState matchingBlock = BlockStateIdAccess.getBlockStateById(Block.getStateId(mcState));
if (matchingBlock != null) {
@ -475,7 +487,7 @@ public class ForgeWorld extends AbstractWorld {
public BaseBlock getFullBlock(BlockVector3 position) {
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
TileEntity tile = getWorld().getChunk(pos).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK);
TileEntity tile = getWorld().getChunk(pos).getTileEntity(pos, Chunk.CreateEntityType.CHECK);
if (tile != null) {
return getBlock(position).toBaseBlock(NBTConverter.fromNative(TileEntityUtils.copyNbtData(tile)));
@ -507,33 +519,34 @@ public class ForgeWorld extends AbstractWorld {
@Override
public List<? extends Entity> getEntities(Region region) {
List<Entity> entities = new ArrayList<>();
for (net.minecraft.entity.Entity entity : getWorld().loadedEntityList) {
if (region.contains(BlockVector3.at(entity.posX, entity.posY, entity.posZ))) {
entities.add(new ForgeEntity(entity));
}
final World world = getWorld();
if (!(world instanceof ServerWorld)) {
return Collections.emptyList();
}
return entities;
return ((ServerWorld) world).getEntities().filter(e -> region.contains(ForgeAdapter.adapt(e.getPosition())))
.map(ForgeEntity::new).collect(Collectors.toList());
}
@Override
public List<? extends Entity> getEntities() {
List<Entity> entities = new ArrayList<>();
for (net.minecraft.entity.Entity entity : getWorld().loadedEntityList) {
entities.add(new ForgeEntity(entity));
final World world = getWorld();
if (!(world instanceof ServerWorld)) {
return Collections.emptyList();
}
return entities;
return ((ServerWorld) world).getEntities().map(ForgeEntity::new).collect(Collectors.toList());
}
@Nullable
@Override
public Entity createEntity(Location location, BaseEntity entity) {
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) {
CompoundTag nativeTag = entity.getNbtData();
if (nativeTag != null) {
NBTTagCompound tag = NBTConverter.toNative(entity.getNbtData());
CompoundNBT tag = NBTConverter.toNative(entity.getNbtData());
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name);
}
@ -542,7 +555,7 @@ public class ForgeWorld extends AbstractWorld {
createdEntity.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
world.spawnEntity(createdEntity);
world.addEntity(createdEntity);
return new ForgeEntity(createdEntity);
} else {
return null;
@ -553,10 +566,23 @@ public class ForgeWorld extends AbstractWorld {
* Thrown when the reference to the world is lost.
*/
@SuppressWarnings("serial")
private static class WorldReferenceLostException extends WorldEditException {
private static final class WorldReferenceLostException extends WorldEditException {
private WorldReferenceLostException(String 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;
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.exceptions.CommandSyntaxException;
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.ItemType;
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.ItemTags;
import net.minecraft.util.EnumHand;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CommandEvent;
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.common.Mod;
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.FMLServerStoppingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.logging.log4j.LogManager;
@ -74,6 +74,9 @@ import java.io.UncheckedIOException;
import java.nio.file.Files;
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.
*/
@ -216,12 +219,12 @@ public class ForgeWorldEdit {
event instanceof PlayerInteractEvent.RightClickBlock
&& ((PlayerInteractEvent.RightClickBlock) event)
.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;
}
WorldEdit we = WorldEdit.getInstance();
ForgePlayer player = adaptPlayer((EntityPlayerMP) event.getEntityPlayer());
ForgePlayer player = adaptPlayer((ServerPlayerEntity) event.getEntityPlayer());
ForgeWorld world = getWorld(event.getEntityPlayer().world);
if (event instanceof PlayerInteractEvent.LeftClickEmpty) {
@ -256,10 +259,10 @@ public class ForgeWorldEdit {
@SubscribeEvent
public void onCommandEvent(CommandEvent event) throws CommandSyntaxException {
ParseResults<CommandSource> parseResults = event.getParseResults();
if (!(parseResults.getContext().getSource().getEntity() instanceof EntityPlayerMP)) {
if (!(parseResults.getContext().getSource().getEntity() instanceof ServerPlayerEntity)) {
return;
}
EntityPlayerMP player = parseResults.getContext().getSource().asPlayer();
ServerPlayerEntity player = parseResults.getContext().getSource().asPlayer();
if (player.world.isRemote()) {
return;
}
@ -288,7 +291,7 @@ public class ForgeWorldEdit {
* @param player the player
* @return the session
*/
public LocalSession getSession(EntityPlayerMP player) {
public LocalSession getSession(ServerPlayerEntity player) {
checkNotNull(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 net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
@ -39,7 +40,7 @@ public class KeyHandler {
@SubscribeEvent
public void onKey(InputEvent.KeyInputEvent evt) {
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.StringTag;
import com.sk89q.jnbt.Tag;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagByteArray;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagEnd;
import net.minecraft.nbt.NBTTagFloat;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.nbt.NBTTagShort;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.nbt.ByteArrayNBT;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.DoubleNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ByteNBT;
import net.minecraft.nbt.EndNBT;
import net.minecraft.nbt.FloatNBT;
import net.minecraft.nbt.IntArrayNBT;
import net.minecraft.nbt.IntNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.LongNBT;
import net.minecraft.nbt.StringNBT;
import net.minecraft.nbt.ShortNBT;
import java.util.ArrayList;
import java.util.Arrays;
@ -62,7 +62,7 @@ final class NBTConverter {
private NBTConverter() {
}
public static INBTBase toNative(Tag tag) {
public static INBT toNative(Tag tag) {
if (tag instanceof IntArrayTag) {
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();
return new NBTTagIntArray(Arrays.copyOf(value, value.length));
return new IntArrayNBT(Arrays.copyOf(value, value.length));
}
public static NBTTagList toNative(ListTag tag) {
NBTTagList list = new NBTTagList();
public static ListNBT toNative(ListTag tag) {
ListNBT list = new ListNBT();
for (Tag child : tag.getValue()) {
if (child instanceof EndTag) {
continue;
@ -116,94 +116,94 @@ final class NBTConverter {
return list;
}
public static NBTTagLong toNative(LongTag tag) {
return new NBTTagLong(tag.getValue());
public static LongNBT toNative(LongTag tag) {
return new LongNBT(tag.getValue());
}
public static NBTTagString toNative(StringTag tag) {
return new NBTTagString(tag.getValue());
public static StringNBT toNative(StringTag tag) {
return new StringNBT(tag.getValue());
}
public static NBTTagInt toNative(IntTag tag) {
return new NBTTagInt(tag.getValue());
public static IntNBT toNative(IntTag tag) {
return new IntNBT(tag.getValue());
}
public static NBTTagByte toNative(ByteTag tag) {
return new NBTTagByte(tag.getValue());
public static ByteNBT toNative(ByteTag tag) {
return new ByteNBT(tag.getValue());
}
public static NBTTagByteArray toNative(ByteArrayTag tag) {
public static ByteArrayNBT toNative(ByteArrayTag tag) {
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) {
NBTTagCompound compound = new NBTTagCompound();
public static CompoundNBT toNative(CompoundTag tag) {
CompoundNBT compound = new CompoundNBT();
for (Entry<String, Tag> child : tag.getValue().entrySet()) {
compound.put(child.getKey(), toNative(child.getValue()));
}
return compound;
}
public static NBTTagFloat toNative(FloatTag tag) {
return new NBTTagFloat(tag.getValue());
public static FloatNBT toNative(FloatTag tag) {
return new FloatNBT(tag.getValue());
}
public static NBTTagShort toNative(ShortTag tag) {
return new NBTTagShort(tag.getValue());
public static ShortNBT toNative(ShortTag tag) {
return new ShortNBT(tag.getValue());
}
public static NBTTagDouble toNative(DoubleTag tag) {
return new NBTTagDouble(tag.getValue());
public static DoubleNBT toNative(DoubleTag tag) {
return new DoubleNBT(tag.getValue());
}
public static Tag fromNative(INBTBase other) {
if (other instanceof NBTTagIntArray) {
return fromNative((NBTTagIntArray) other);
public static Tag fromNative(INBT other) {
if (other instanceof IntArrayNBT) {
return fromNative((IntArrayNBT) other);
} else if (other instanceof NBTTagList) {
return fromNative((NBTTagList) other);
} else if (other instanceof ListNBT) {
return fromNative((ListNBT) other);
} else if (other instanceof NBTTagEnd) {
return fromNative((NBTTagEnd) other);
} else if (other instanceof EndNBT) {
return fromNative((EndNBT) other);
} else if (other instanceof NBTTagLong) {
return fromNative((NBTTagLong) other);
} else if (other instanceof LongNBT) {
return fromNative((LongNBT) other);
} else if (other instanceof NBTTagString) {
return fromNative((NBTTagString) other);
} else if (other instanceof StringNBT) {
return fromNative((StringNBT) other);
} else if (other instanceof NBTTagInt) {
return fromNative((NBTTagInt) other);
} else if (other instanceof IntNBT) {
return fromNative((IntNBT) other);
} else if (other instanceof NBTTagByte) {
return fromNative((NBTTagByte) other);
} else if (other instanceof ByteNBT) {
return fromNative((ByteNBT) other);
} else if (other instanceof NBTTagByteArray) {
return fromNative((NBTTagByteArray) other);
} else if (other instanceof ByteArrayNBT) {
return fromNative((ByteArrayNBT) other);
} else if (other instanceof NBTTagCompound) {
return fromNative((NBTTagCompound) other);
} else if (other instanceof CompoundNBT) {
return fromNative((CompoundNBT) other);
} else if (other instanceof NBTTagFloat) {
return fromNative((NBTTagFloat) other);
} else if (other instanceof FloatNBT) {
return fromNative((FloatNBT) other);
} else if (other instanceof NBTTagShort) {
return fromNative((NBTTagShort) other);
} else if (other instanceof ShortNBT) {
return fromNative((ShortNBT) other);
} else if (other instanceof NBTTagDouble) {
return fromNative((NBTTagDouble) other);
} else if (other instanceof DoubleNBT) {
return fromNative((DoubleNBT) other);
} else {
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();
return new IntArrayTag(Arrays.copyOf(value, value.length));
}
public static ListTag fromNative(NBTTagList other) {
public static ListTag fromNative(ListNBT other) {
other = other.copy();
List<Tag> list = new ArrayList<>();
Class<? extends Tag> listClass = StringTag.class;
@ -216,32 +216,32 @@ final class NBTConverter {
return new ListTag(listClass, list);
}
public static EndTag fromNative(NBTTagEnd other) {
public static EndTag fromNative(EndNBT other) {
return new EndTag();
}
public static LongTag fromNative(NBTTagLong other) {
public static LongTag fromNative(LongNBT other) {
return new LongTag(other.getLong());
}
public static StringTag fromNative(NBTTagString other) {
public static StringTag fromNative(StringNBT other) {
return new StringTag(other.getString());
}
public static IntTag fromNative(NBTTagInt other) {
public static IntTag fromNative(IntNBT other) {
return new IntTag(other.getInt());
}
public static ByteTag fromNative(NBTTagByte other) {
public static ByteTag fromNative(ByteNBT other) {
return new ByteTag(other.getByte());
}
public static ByteArrayTag fromNative(NBTTagByteArray other) {
public static ByteArrayTag fromNative(ByteArrayNBT other) {
byte[] value = other.getByteArray();
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();
Map<String, Tag> map = new HashMap<>();
for (String tagName : tags) {
@ -250,15 +250,15 @@ final class NBTConverter {
return new CompoundTag(map);
}
public static FloatTag fromNative(NBTTagFloat other) {
public static FloatTag fromNative(FloatNBT other) {
return new FloatTag(other.getFloat());
}
public static ShortTag fromNative(NBTTagShort other) {
public static ShortTag fromNative(ShortNBT other) {
return new ShortTag(other.getShort());
}
public static DoubleTag fromNative(NBTTagDouble other) {
public static DoubleTag fromNative(DoubleNBT other) {
return new DoubleTag(other.getDouble());
}

Datei anzeigen

@ -19,7 +19,7 @@
package com.sk89q.worldedit.forge;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
@ -58,10 +58,10 @@ public class ThreadSafeCache {
Set<UUID> onlineIds = new HashSet<>();
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
if (server == null || server.getPlayerList() == null) {
if (server == null) {
return;
}
for (EntityPlayerMP player : server.getPlayerList().getPlayers()) {
for (ServerPlayerEntity player : server.getPlayerList().getPlayers()) {
if (player != null) {
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 net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.IntNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -45,13 +45,13 @@ final class TileEntityUtils {
* @param tag the tag
* @param position the position
*/
private static void updateForSet(NBTTagCompound tag, BlockVector3 position) {
private static void updateForSet(CompoundNBT tag, BlockVector3 position) {
checkNotNull(tag);
checkNotNull(position);
tag.put("x", new NBTTagInt(position.getBlockX()));
tag.put("y", new NBTTagInt(position.getBlockY()));
tag.put("z", new NBTTagInt(position.getBlockZ()));
tag.put("x", new IntNBT(position.getBlockX()));
tag.put("y", new IntNBT(position.getBlockY()));
tag.put("z", new IntNBT(position.getBlockZ()));
}
/**
@ -62,7 +62,7 @@ final class TileEntityUtils {
* @param position the position
* @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) {
updateForSet(tag, position);
TileEntity tileEntity = TileEntity.create(tag);
@ -72,8 +72,8 @@ final class TileEntityUtils {
}
}
public static NBTTagCompound copyNbtData(TileEntity tile) {
NBTTagCompound tag = new NBTTagCompound();
public static CompoundNBT copyNbtData(TileEntity tile) {
CompoundNBT tag = new CompoundNBT();
tile.write(tag);
return tag;
}

Datei anzeigen

@ -20,21 +20,29 @@
package com.sk89q.worldedit.forge;
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 javax.annotation.Nullable;
import java.util.OptionalInt;
import java.util.UUID;
public class WorldEditFakePlayer extends FakePlayer {
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);
}
@Override
public boolean canEat(boolean ignoreHunger) {
public boolean canEat(boolean checkHunger) {
return true;
}
@Override
public OptionalInt openContainer(@Nullable INamedContainerProvider container) {
return OptionalInt.empty();
}
}

Datei anzeigen

@ -20,46 +20,46 @@
package com.sk89q.worldedit.forge.gui;
import com.sk89q.worldedit.forge.ForgeWorldEdit;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.lwjgl.opengl.GL11;
@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 backgroundHeight = 256;
@Override
public void initGui() {
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);
public GuiReferenceCard(ITextComponent title) {
super(title);
}
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
public void render(int mouseX, int mouseY, float par3) {
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);
this.mc.textureManager.bindTexture(new ResourceLocation(ForgeWorldEdit.MOD_ID, "textures/gui/reference.png"));
this.drawTexturedModalRect(x, y, 0, 0, this.backgroundWidth, this.backgroundHeight);
this.minecraft.textureManager.bindTexture(new ResourceLocation(ForgeWorldEdit.MOD_ID, "textures/gui/reference.png"));
this.blit(x, y, 0, 0, this.backgroundWidth, this.backgroundHeight);
super.render(mouseX, mouseY, par3);
}
@Override
public boolean doesGuiPauseGame() {
public boolean isPauseScreen() {
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) {
return remoteVersion ->
protocolVersion.equals(remoteVersion)
|| NetworkRegistry.ABSENT.equals(remoteVersion)
|| NetworkRegistry.ACCEPTVANILLA.equals(remoteVersion);
|| NetworkRegistry.ABSENT.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.ForgeWorldEdit;
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.play.server.SPacketCustomPayload;
import net.minecraft.network.play.server.SCustomPayloadPlayPacket;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.network.NetworkEvent.ClientCustomPayloadEvent;
import net.minecraftforge.fml.network.NetworkEvent.ServerCustomPayloadEvent;
@ -45,14 +45,13 @@ public final class WECUIPacketHandler {
.buildLenientHandler(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, PROTOCOL_VERSION)
.eventNetworkChannel();
public static void init() {
HANDLER.addListener(WECUIPacketHandler::onPacketData);
HANDLER.addListener(WECUIPacketHandler::callProcessPacket);
}
public static void onPacketData(ServerCustomPayloadEvent event) {
EntityPlayerMP player = event.getSource().get().getSender();
ServerPlayerEntity player = event.getSource().get().getSender();
LocalSession session = ForgeWorldEdit.inst.getSession(player);
if (session.hasCUISupport()) {
@ -67,11 +66,12 @@ public final class WECUIPacketHandler {
public static void callProcessPacket(ClientCustomPayloadEvent event) {
try {
new SPacketCustomPayload(
new SCustomPayloadPlayPacket(
new ResourceLocation(ForgeWorldEdit.MOD_ID, ForgeWorldEdit.CUI_PLUGIN_CHANNEL),
event.getPayload()
).processPacket(Minecraft.getInstance().player.connection);
} catch (ThreadQuickExitException ignored) {
}
}
}