Skip to content

Commit

Permalink
Rename Forge classes to NeoForge
Browse files Browse the repository at this point in the history
  • Loading branch information
Drullkus committed Dec 19, 2023
1 parent 7e5af45 commit f2cfe02
Show file tree
Hide file tree
Showing 36 changed files with 234 additions and 240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.neoforge;

import com.google.common.collect.ImmutableList;
import com.mojang.brigadier.Command;
Expand Down Expand Up @@ -75,7 +75,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher, or

private static Predicate<CommandSourceStack> requirementsFor(org.enginehub.piston.Command mapping) {
return ctx -> {
final Actor actor = ForgeAdapter.adaptCommandSource(ctx);
final Actor actor = NeoForgeAdapter.adaptCommandSource(ctx);
InjectedValueStore store = MapBackedValueStore.create();
store.injectValue(Key.of(Actor.class), context -> Optional.of(actor));
return mapping.getCondition().satisfied(store);
Expand All @@ -85,7 +85,7 @@ private static Predicate<CommandSourceStack> requirementsFor(org.enginehub.pisto
private static CompletableFuture<Suggestions> suggest(CommandContext<CommandSourceStack> context,
SuggestionsBuilder builder) throws CommandSyntaxException {
CommandSuggestionEvent event = new CommandSuggestionEvent(
ForgeAdapter.adaptCommandSource(context.getSource()),
NeoForgeAdapter.adaptCommandSource(context.getSource()),
builder.getInput()
);
WorldEdit.getInstance().getEventBus().post(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.neoforge;

import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.forge.internal.ForgeTransmogrifier;
import com.sk89q.worldedit.forge.internal.NBTConverter;
import com.sk89q.worldedit.neoforge.internal.NeoForgeTransmogrifier;
import com.sk89q.worldedit.neoforge.internal.NBTConverter;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
Expand Down Expand Up @@ -63,13 +63,13 @@

import static com.google.common.base.Preconditions.checkNotNull;

public final class ForgeAdapter {
public final class NeoForgeAdapter {

private ForgeAdapter() {
private NeoForgeAdapter() {
}

public static World adapt(ServerLevel world) {
return new ForgeWorld(world);
return new NeoForgeWorld(world);
}

/**
Expand All @@ -80,8 +80,8 @@ public static World adapt(ServerLevel world) {
*/
public static ServerLevel adapt(World world) {
checkNotNull(world);
if (world instanceof ForgeWorld) {
return ((ForgeWorld) world).getWorld();
if (world instanceof NeoForgeWorld) {
return ((NeoForgeWorld) world).getWorld();
} else {
// TODO introduce a better cross-platform world API to match more easily
throw new UnsupportedOperationException("Cannot adapt from a " + world.getClass());
Expand Down Expand Up @@ -156,7 +156,7 @@ public static BlockPos toBlockPos(BlockVector3 vector) {
*/
@Deprecated
public static Property<?> adaptProperty(net.minecraft.world.level.block.state.properties.Property<?> property) {
return ForgeTransmogrifier.transmogToWorldEditProperty(property);
return NeoForgeTransmogrifier.transmogToWorldEditProperty(property);
}

/**
Expand All @@ -181,7 +181,7 @@ public static Map<Property<?>, Object> adaptProperties(BlockType block, Map<net.
public static net.minecraft.world.level.block.state.BlockState adapt(BlockState blockState) {
int blockStateId = BlockStateIdAccess.getBlockStateId(blockState);
if (!BlockStateIdAccess.isValidInternalId(blockStateId)) {
return ForgeTransmogrifier.transmogToMinecraft(blockState);
return NeoForgeTransmogrifier.transmogToMinecraft(blockState);
}
return Block.stateById(blockStateId);
}
Expand All @@ -190,7 +190,7 @@ public static BlockState adapt(net.minecraft.world.level.block.state.BlockState
int blockStateId = Block.getId(blockState);
BlockState worldEdit = BlockStateIdAccess.getBlockStateById(blockStateId);
if (worldEdit == null) {
return ForgeTransmogrifier.transmogToWorldEdit(blockState);
return NeoForgeTransmogrifier.transmogToWorldEdit(blockState);
}
return worldEdit;
}
Expand Down Expand Up @@ -242,9 +242,9 @@ public static BaseItemStack adapt(ItemStack itemStack) {
* @param player the player
* @return the WorldEdit player
*/
public static ForgePlayer adaptPlayer(ServerPlayer player) {
public static NeoForgePlayer adaptPlayer(ServerPlayer player) {
checkNotNull(player);
return new ForgePlayer(player);
return new NeoForgePlayer(player);
}

/**
Expand All @@ -258,10 +258,10 @@ public static Actor adaptCommandSource(CommandSourceStack commandSourceStack) {
if (commandSourceStack.isPlayer()) {
return adaptPlayer(commandSourceStack.getPlayer());
}
if (ForgeWorldEdit.inst.getConfig().commandBlockSupport && commandSourceStack.source instanceof BaseCommandBlock commandBlock) {
return new ForgeBlockCommandSender(commandBlock);
if (NeoForgeWorldEdit.inst.getConfig().commandBlockSupport && commandSourceStack.source instanceof BaseCommandBlock commandBlock) {
return new NeoForgeBlockCommandSender(commandBlock);
}

return new ForgeCommandSender(commandSourceStack);
return new NeoForgeCommandSender(commandSourceStack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.neoforge;

import net.kyori.text.Component;
import net.kyori.text.TranslatableComponent;
Expand All @@ -30,7 +30,7 @@
/**
* Provides access to biome data in Forge.
*/
class ForgeBiomeRegistry implements BiomeRegistry {
class NeoForgeBiomeRegistry implements BiomeRegistry {

@Override
public Component getRichName(BiomeType biomeType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.neoforge;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Streams;
Expand All @@ -32,14 +32,14 @@

import java.util.Set;

public class ForgeBlockCategoryRegistry implements BlockCategoryRegistry {
public class NeoForgeBlockCategoryRegistry implements BlockCategoryRegistry {
@Override
public Set<BlockType> getCategorisedByName(String category) {
Iterable<Holder<Block>> tagged = BuiltInRegistries.BLOCK.getTagOrEmpty(TagKey.create(Registries.BLOCK, new ResourceLocation(category)));

return Streams.stream(tagged)
.map(Holder::value)
.map(ForgeAdapter::adapt)
.map(NeoForgeAdapter::adapt)
.collect(ImmutableSet.toImmutableSet());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.neoforge;

import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.AbstractCommandBlockActor;
Expand All @@ -42,12 +42,12 @@

import static com.google.common.base.Preconditions.checkNotNull;

public class ForgeBlockCommandSender extends AbstractCommandBlockActor {
public class NeoForgeBlockCommandSender extends AbstractCommandBlockActor {
private final BaseCommandBlock sender;
private final UUID uuid;

public ForgeBlockCommandSender(BaseCommandBlock sender) {
super(new Location(ForgeAdapter.adapt(checkNotNull(sender).getLevel()), ForgeAdapter.adapt(sender.getPosition())));
public NeoForgeBlockCommandSender(BaseCommandBlock sender) {
super(new Location(NeoForgeAdapter.adapt(checkNotNull(sender).getLevel()), NeoForgeAdapter.adapt(sender.getPosition())));

this.sender = sender;
this.uuid = UUID.nameUUIDFromBytes((UUID_PREFIX + sender.getName()).getBytes(StandardCharsets.UTF_8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.neoforge;

import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
Expand All @@ -31,11 +31,11 @@
* Material, and passes the rest to another implementation, typically the
* bundled block info.
*/
public class ForgeBlockMaterial extends PassthroughBlockMaterial {
public class NeoForgeBlockMaterial extends PassthroughBlockMaterial {

private final BlockState block;

public ForgeBlockMaterial(BlockState block, @Nullable BlockMaterial secondary) {
public NeoForgeBlockMaterial(BlockState block, @Nullable BlockMaterial secondary) {
super(secondary);
this.block = block;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.neoforge;

import com.sk89q.worldedit.forge.internal.ForgeTransmogrifier;
import com.sk89q.worldedit.neoforge.internal.NeoForgeTransmogrifier;
import com.sk89q.worldedit.registry.state.Property;
import net.kyori.text.Component;
import net.kyori.text.TranslatableComponent;
Expand All @@ -35,43 +35,43 @@
import java.util.OptionalInt;
import java.util.TreeMap;

public class ForgeBlockRegistry extends BundledBlockRegistry {
public class NeoForgeBlockRegistry extends BundledBlockRegistry {

private final Map<net.minecraft.world.level.block.state.BlockState, ForgeBlockMaterial> materialMap = new HashMap<>();
private final Map<net.minecraft.world.level.block.state.BlockState, NeoForgeBlockMaterial> materialMap = new HashMap<>();

@Override
public Component getRichName(BlockType blockType) {
return TranslatableComponent.of(ForgeAdapter.adapt(blockType).getDescriptionId());
return TranslatableComponent.of(NeoForgeAdapter.adapt(blockType).getDescriptionId());
}

@Override
public BlockMaterial getMaterial(BlockType blockType) {
Block block = ForgeAdapter.adapt(blockType);
Block block = NeoForgeAdapter.adapt(blockType);
if (block == null) {
return super.getMaterial(blockType);
}
return materialMap.computeIfAbsent(
block.defaultBlockState(),
s -> new ForgeBlockMaterial(s, super.getMaterial(blockType))
s -> new NeoForgeBlockMaterial(s, super.getMaterial(blockType))
);
}

@Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
Block block = ForgeAdapter.adapt(blockType);
Block block = NeoForgeAdapter.adapt(blockType);
Map<String, Property<?>> map = new TreeMap<>();
Collection<net.minecraft.world.level.block.state.properties.Property<?>> propertyKeys = block
.defaultBlockState()
.getProperties();
for (net.minecraft.world.level.block.state.properties.Property<?> key : propertyKeys) {
map.put(key.getName(), ForgeTransmogrifier.transmogToWorldEditProperty(key));
map.put(key.getName(), NeoForgeTransmogrifier.transmogToWorldEditProperty(key));
}
return map;
}

@Override
public OptionalInt getInternalBlockStateId(BlockState state) {
net.minecraft.world.level.block.state.BlockState equivalent = ForgeAdapter.adapt(state);
net.minecraft.world.level.block.state.BlockState equivalent = NeoForgeAdapter.adapt(state);
return OptionalInt.of(Block.getId(equivalent));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.neoforge;

import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor;
Expand All @@ -35,7 +35,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

public class ForgeCommandSender extends AbstractNonPlayerActor {
public class NeoForgeCommandSender extends AbstractNonPlayerActor {

/**
* One time generated ID.
Expand All @@ -44,7 +44,7 @@ public class ForgeCommandSender extends AbstractNonPlayerActor {

private final CommandSourceStack sender;

public ForgeCommandSender(CommandSourceStack sender) {
public NeoForgeCommandSender(CommandSourceStack sender) {
checkNotNull(sender);
checkArgument(!sender.isPlayer(), "Cannot wrap a player");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.neoforge;

import com.sk89q.worldedit.util.PropertiesConfiguration;

import java.io.File;
import java.nio.file.Path;

public class ForgeConfiguration extends PropertiesConfiguration {
public class NeoForgeConfiguration extends PropertiesConfiguration {

public boolean creativeEnable = false;
public boolean cheatMode = false;

public ForgeConfiguration(ForgeWorldEdit mod) {
public NeoForgeConfiguration(NeoForgeWorldEdit mod) {
super(mod.getWorkingDir().resolve("worldedit.properties"));
}

Expand All @@ -41,6 +40,6 @@ protected void loadExtra() {

@Override
public Path getWorkingDirectoryPath() {
return ForgeWorldEdit.inst.getWorkingDir();
return NeoForgeWorldEdit.inst.getWorkingDir();
}
}
Loading

0 comments on commit f2cfe02

Please sign in to comment.