Files
MinecraftForge/src/test/java/net/minecraftforge/debug/ClientCommandTest.java
T
LexManos be80bc5e4c First pass of registry rewrite.
Tests do not run yet.
Things of note:
Removed the idea of substitutions, just register multiple items with the same name they will override each other like a normal map.
Decoupled Forge registries from vanilla classes. They now use bouncer classes. MODDERS SHOULD NEVER USE THESE
Introduced more stringent registry locking. As it sits things are only allowed to be registered during the RegistryEvent.Registry phases!
This is to force modders to split up their registrations, and pave the way for calling these functions multiple times during a single MC lifecycle.
ObjectHolder, Missing Mappings, etc... *should* now work for all registry types, nothing should be special cased to Blocks/Items anymore.
Added optional generic dummy factory to registries, to allow registry creators the ability to dummy more then just Blocks.
Re-worked the ItemStack transformer and applied it to ItemBlock and ItemBlockSpecial. Allowing us to cleanup reflective hacks in Block callbacks.
Registry onAdd callback is now only fired on the ACTIVE registry, fixing any issues of temp registries overriding active objects.
2017-06-23 11:04:13 -07:00

75 lines
2.3 KiB
Java

package net.minecraftforge.debug;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.registries.GameData;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@Mod(modid = "clientcommandtest", name = "Client Command Test", version = "0.0.0", clientSideOnly = true)
public class ClientCommandTest
{
@EventHandler
public void init(FMLInitializationEvent event)
{
ClientCommandHandler.instance.registerCommand(new TestCommand());
}
private class TestCommand extends CommandBase
{
@Override
public String getName()
{
return "clientCommandTest";
}
@Override
public String getUsage(ICommandSender sender)
{
return "clientCommandTest <block>";
}
@Override
public boolean checkPermission(MinecraftServer server, ICommandSender sender)
{
return true;
}
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
if (args.length > 0)
{
return getListOfStringsMatchingLastWord(args, ForgeRegistries.BLOCKS.getKeys());
}
return Collections.emptyList();
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length > 0)
{
sender.sendMessage(new TextComponentString("Input: " + Arrays.toString(args)));
}
else
{
sender.sendMessage(new TextComponentString("No arguments."));
}
}
}
}