Pointless updates to the unused forge code in FAWE

Dieser Commit ist enthalten in:
MattBDev 2020-03-23 17:13:11 -04:00
Ursprung dabba81902
Commit 43dc1074b0
12 geänderte Dateien mit 97 neuen und 70 gelöschten Zeilen

Datei anzeigen

@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.forge.internal.NBTConverter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.registry.state.BooleanProperty;

Datei anzeigen

@ -26,17 +26,14 @@ 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.properties.IProperty;
import net.minecraft.util.ResourceLocation;
import net.minecraft.state.IProperty;
import net.minecraftforge.fml.loading.FMLLoader;
import javax.annotation.Nullable;
import net.minecraftforge.fml.loading.FMLLoader;
import java.util.OptionalInt;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.OptionalInt;
import java.util.TreeMap;
public class ForgeBlockRegistry extends BundledBlockRegistry {

Datei anzeigen

@ -35,6 +35,7 @@ import com.mojang.datafixers.DataFixerBuilder;
import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.schemas.Schema;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.forge.internal.NBTConverter;
import net.minecraft.item.DyeColor;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;

Datei anzeigen

@ -19,8 +19,8 @@
package com.sk89q.worldedit.forge;
import com.google.common.collect.Sets;
import com.sk89q.worldedit.command.util.PermissionCondition;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.AbstractPlatform;
import com.sk89q.worldedit.extension.platform.Actor;
@ -36,17 +36,17 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.management.PlayerList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import net.minecraft.util.SharedConstants;
import net.minecraft.world.server.ServerWorld;
import javax.annotation.Nullable;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -78,16 +78,6 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
return ForgeRegistries.getInstance();
}
@Override
public boolean isValidMobType(String type) {
return net.minecraftforge.registries.ForgeRegistries.ENTITIES.containsKey(new ResourceLocation(type));
}
@Override
public void reload() {
getConfiguration().load();
}
@Override
public int getDataVersion() {
return SharedConstants.getVersion().getWorldVersion();
@ -98,6 +88,16 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
return dataFixer;
}
@Override
public boolean isValidMobType(String type) {
return net.minecraftforge.registries.ForgeRegistries.ENTITIES.containsKey(new ResourceLocation(type));
}
@Override
public void reload() {
getConfiguration().load();
}
@Override
public int schedule(long delay, long period, Runnable task) {
return -1;

Datei anzeigen

@ -20,12 +20,12 @@
package com.sk89q.worldedit.forge;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.forge.internal.NBTConverter;
import com.sk89q.worldedit.forge.net.handler.WECUIPacketHandler;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.math.BlockVector3;
@ -36,22 +36,21 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.WorldEditText;
import com.sk89q.worldedit.util.formatting.component.TextUtils;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import net.minecraft.item.ItemStack;
import io.netty.buffer.Unpooled;
import net.minecraft.block.Block;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.SChangeBlockPacket;
import net.minecraft.network.play.server.SCustomPayloadPlayPacket;
import net.minecraft.util.ResourceLocation;
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.StringTextComponent;
@ -59,7 +58,6 @@ import net.minecraft.util.text.TextFormatting;
import java.io.IOException;
import java.util.Locale;
import java.util.UUID;
import javax.annotation.Nullable;
@ -98,7 +96,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override
public Location getLocation() {
Vector3 position = Vector3.at(this.player.posX, this.player.posY, this.player.posZ);
Vector3 position = Vector3.at(this.player.getPosX(), this.player.getPosY(), this.player.getPosZ());
return new Location(
ForgeWorldEdit.inst.getWorld(this.player.world),
position,

Datei anzeigen

@ -22,8 +22,8 @@ package com.sk89q.worldedit.forge;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Sets;
import com.google.common.io.Files;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
@ -34,6 +34,7 @@ import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.internal.util.BiomeMath;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
@ -41,6 +42,8 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.SideEffectSet;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.biome.BiomeType;
@ -50,23 +53,25 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes;
import net.minecraft.entity.EntityType;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityType;
import net.minecraft.block.Blocks;
import net.minecraft.block.LeavesBlock;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.inventory.IClearable;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeContainer;
import net.minecraft.world.biome.DefaultBiomeFeatures;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.AbstractChunkProvider;
import net.minecraft.world.gen.feature.BigBrownMushroomFeature;
@ -90,25 +95,26 @@ 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.WorldInfo;
import java.lang.ref.WeakReference;
import net.minecraft.world.server.ServerChunkProvider;
import net.minecraft.world.server.ServerWorld;
import net.minecraft.world.storage.SaveHandler;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.common.DimensionManager;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.lang.ref.WeakReference;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Random;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.OptionalInt;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkNotNull;
@ -253,7 +259,7 @@ public class ForgeWorld extends AbstractWorld {
@Override
public BiomeType getBiome(BlockVector2 position) {
checkNotNull(position);
return ForgeAdapter.adapt(getWorld().getBiomeBody(new BlockPos(position.getBlockX(), 0, position.getBlockZ())));
return ForgeAdapter.adapt(getWorld().getBiome(new BlockPos(position.getBlockX(), 0, position.getBlockZ())));
}
@Override
@ -262,10 +268,15 @@ public class ForgeWorld extends AbstractWorld {
checkNotNull(biome);
IChunk chunk = getWorld().getChunk(position.getBlockX() >> 4, position.getBlockZ() >> 4, ChunkStatus.FULL, false);
if (chunk == null) {
BiomeContainer container = chunk == null ? null : chunk.getBiomes();
if (chunk == null || container == null) {
return false;
}
chunk.getBiomes()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = ForgeAdapter.adapt(biome);
// Temporary, while biome setting is 2D only
for (int i = 0; i < BiomeMath.VERTICAL_BIT_MASK; i++) {
int idx = BiomeMath.computeBiomeIndex(position.getX(), i, position.getZ());
container.biomes[idx] = ForgeAdapter.adapt(biome);
}
chunk.setModified(true);
return true;
}
@ -293,8 +304,10 @@ public class ForgeWorld extends AbstractWorld {
ActionResultType used = stack.onItemUse(itemUseContext);
if (used != ActionResultType.SUCCESS) {
// try activating the block
if (getWorld().getBlockState(blockPos).onBlockActivated(world, fakePlayer, Hand.MAIN_HAND, rayTraceResult)) {
used = ActionResultType.SUCCESS;
ActionResultType resultType = getWorld().getBlockState(blockPos)
.onBlockActivated(world, fakePlayer, Hand.MAIN_HAND, rayTraceResult);
if (resultType.isSuccessOrConsume()) {
used = resultType;
} else {
used = stack.getItem().onItemRightClick(world, fakePlayer, Hand.MAIN_HAND).getType();
}
@ -372,6 +385,7 @@ public class ForgeWorld extends AbstractWorld {
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 MEGA_REDWOOD: return new MegaPineTree(NoFeatureConfig::deserialize, true, random.nextBoolean());
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);
@ -380,7 +394,6 @@ public class ForgeWorld extends AbstractWorld {
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);
@ -403,8 +416,8 @@ public class ForgeWorld extends AbstractWorld {
@SuppressWarnings("unchecked")
Feature<IFeatureConfig> generator = (Feature<IFeatureConfig>) createTreeFeatureGenerator(type);
return generator != null
&& generator.place(getWorld(), getWorld().getChunkProvider().getChunkGenerator(), random,
ForgeAdapter.toBlockPos(position), createFeatureConfig(type));
&& generator.place(getWorld(), getWorld().getChunkProvider().getChunkGenerator(), random,
ForgeAdapter.toBlockPos(position), createFeatureConfig(type));
}
@Override
@ -421,7 +434,7 @@ public class ForgeWorld extends AbstractWorld {
public void fixLighting(Iterable<BlockVector2> chunks) {
World world = getWorld();
for (BlockVector2 chunk : chunks) {
world.getChunkProvider().getLightManager().func_215571_a(new ChunkPos(chunk.getBlockX(), chunk.getBlockZ()), true);
world.getChunkProvider().getLightManager().retainData(new ChunkPos(chunk.getBlockX(), chunk.getBlockZ()), true);
}
}
@ -479,8 +492,9 @@ public class ForgeWorld extends AbstractWorld {
}
@Override
public BlockVector3 getSpawnPosition() {
return ForgeAdapter.adapt(getWorld().getSpawnPoint());
public int getMinY() {
// Note: This method exists to be re-written by mods that vary world height
return 0;
}
@Override
@ -489,15 +503,8 @@ public class ForgeWorld extends AbstractWorld {
}
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ());
TileEntity tile = getWorld().getChunk(pos).getTileEntity(pos);
if (tile != null) {
return getBlock(position).toBaseBlock(NBTConverter.fromNative(TileEntityUtils.copyNbtData(tile)));
} else {
return getBlock(position).toBaseBlock();
}
public BlockVector3 getSpawnPosition() {
return ForgeAdapter.adapt(getWorld().getSpawnPoint());
}
@Override
@ -514,6 +521,18 @@ public class ForgeWorld extends AbstractWorld {
return ForgeAdapter.adapt(mcState);
}
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ());
TileEntity tile = getWorld().getChunk(pos).getTileEntity(pos);
if (tile != null) {
return getBlock(position).toBaseBlock(NBTConverter.fromNative(TileEntityUtils.copyNbtData(tile)));
} else {
return getBlock(position).toBaseBlock();
}
}
@Override
public int hashCode() {
return getWorld().hashCode();

Datei anzeigen

@ -39,8 +39,8 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.item.ItemCategory;
import com.sk89q.worldedit.world.item.ItemType;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.util.Hand;
@ -72,10 +72,10 @@ import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer;
import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME;
/**
* The Forge implementation of WorldEdit.
@ -190,7 +190,9 @@ public class ForgeWorldEdit {
@SubscribeEvent
public void serverStopping(FMLServerStoppingEvent event) {
WorldEdit.getInstance().getPlatformManager().unregister(platform);
WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload();
worldEdit.getPlatformManager().unregister(platform);
}
@SubscribeEvent

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.forge.internal;
import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.ByteTag;
@ -57,7 +57,7 @@ import java.util.Set;
/**
* Converts between JNBT and Minecraft NBT classes.
*/
final class NBTConverter {
public final class NBTConverter {
private NBTConverter() {
}

Datei anzeigen

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.forge.internal;
import static com.google.common.base.Preconditions.checkNotNull;
@ -34,7 +34,7 @@ import javax.annotation.Nullable;
/**
* Utility methods for setting tile entities in the world.
*/
final class TileEntityUtils {
public final class TileEntityUtils {
private TileEntityUtils() {
}
@ -62,13 +62,15 @@ 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 CompoundNBT tag) {
static boolean setTileEntity(World world, BlockVector3 position, @Nullable CompoundNBT tag) {
if (tag != null) {
updateForSet(tag, position);
TileEntity tileEntity = TileEntity.create(tag);
if (tileEntity != null) {
world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
if (tileEntity == null) {
return false;
}
world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
return true;
}
}

Datei anzeigen

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

Datei anzeigen

@ -22,6 +22,12 @@ displayName="WorldEdit"
description='''
WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both single- and multi-player.
'''
[[dependencies.worldedit]]
modId="minecraft"
mandatory=true
versionRange="[${minecraftVersion},${nextMajorMinecraftVersion})"
ordering="NONE"
side="BOTH"
[[dependencies.worldedit]]
modId="forge"
mandatory=true
@ -33,4 +39,4 @@ WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both
mandatory=false
versionRange="[1.13]"
ordering="BEFORE"
side="SERVER"
side="SERVER"

Datei anzeigen

@ -11,7 +11,6 @@ disallowed-blocks=minecraft:oak_sapling,minecraft:jungle_sapling,minecraft:dark_
max-super-pickaxe-size=5
max-brush-radius=10
craftscript-dir=craftscripts
no-double-slash=false
wand-item=minecraft:wooden_axe
shell-save-type=
scripting-timeout=3000
@ -20,6 +19,7 @@ use-inventory-creative-override=false
log-file=worldedit.log
log-format=[%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$s]: %5$s%6$s%n
max-changed-blocks=-1
default-vertical-height=256
nav-wand-distance=50
butcher-default-radius=-1
default-max-changed-blocks=-1