parent
6722e7a428
commit
00013865b0
6 changed files with 67 additions and 15 deletions
|
@ -1,6 +1,14 @@
|
|||
--- a/net/minecraft/command/Commands.java
|
||||
+++ b/net/minecraft/command/Commands.java
|
||||
@@ -202,6 +202,14 @@
|
||||
@@ -183,6 +183,7 @@
|
||||
if (p_i232148_1_.field_237219_d_) {
|
||||
PublishCommand.func_198581_a(this.field_197062_b);
|
||||
}
|
||||
+ net.minecraftforge.event.ForgeEventFactory.onCommandRegister(this.field_197062_b, p_i232148_1_);
|
||||
|
||||
this.field_197062_b.findAmbiguities((p_201302_1_, p_201302_2_, p_201302_3_, p_201302_4_) -> {
|
||||
field_197061_a.warn("Ambiguity between arguments {} and {} with inputs: {}", this.field_197062_b.getPath(p_201302_2_), this.field_197062_b.getPath(p_201302_3_), p_201302_4_);
|
||||
@@ -202,6 +203,14 @@
|
||||
|
||||
try {
|
||||
try {
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.world.server.ServerWorld;
|
|||
import net.minecraftforge.common.loot.LootModifierManager;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
|
@ -39,6 +40,8 @@ import net.minecraftforge.event.TickEvent;
|
|||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
||||
import net.minecraftforge.event.TickEvent.Phase;
|
||||
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
||||
import net.minecraftforge.server.command.ForgeCommand;
|
||||
import net.minecraftforge.server.command.ConfigCommand;
|
||||
|
||||
public class ForgeInternalHandler
|
||||
{
|
||||
|
@ -112,6 +115,13 @@ public class ForgeInternalHandler
|
|||
ForgeHooks.updateBurns();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCommandsRegister(RegisterCommandsEvent event)
|
||||
{
|
||||
new ForgeCommand(event.getDispatcher());
|
||||
ConfigCommand.register(event.getDispatcher());
|
||||
}
|
||||
|
||||
private static LootModifierManager INSTANCE;
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -114,7 +114,6 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
|||
modEventBus.addListener(this::gatherData);
|
||||
modEventBus.register(this);
|
||||
ATTRIBUTES.register(modEventBus);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStarting);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStopping);
|
||||
MinecraftForge.EVENT_BUS.addGenericListener(SoundEvent.class, this::missingSoundMapping);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ForgeConfig.clientSpec);
|
||||
|
@ -147,12 +146,6 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
|||
*/
|
||||
}
|
||||
|
||||
public void serverStarting(FMLServerStartingEvent evt)
|
||||
{
|
||||
new ForgeCommand(evt.getCommandDispatcher());
|
||||
ConfigCommand.register(evt.getCommandDispatcher());
|
||||
}
|
||||
|
||||
public void serverStopping(FMLServerStoppingEvent evt)
|
||||
{
|
||||
WorldWorkerManager.clear();
|
||||
|
|
|
@ -27,9 +27,12 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.block.NetherPortalBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.Commands;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
|
@ -724,4 +727,10 @@ public class ForgeEventFactory
|
|||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getListeners();
|
||||
}
|
||||
|
||||
public static void onCommandRegister(CommandDispatcher<CommandSource> dispatcher, Commands.EnvironmentType environment)
|
||||
{
|
||||
RegisterCommandsEvent event = new RegisterCommandsEvent(dispatcher, environment);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package net.minecraftforge.event;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.command.*;
|
||||
import net.minecraft.resources.*;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
|
||||
/**
|
||||
* Commands are rebuilt whenever {@link DataPackRegistries} is recreated.
|
||||
* You can use this event to register your commands whenever the {@link net.minecraft.command.Commands} class in constructed.
|
||||
*
|
||||
* The event is fired on the {@link MinecraftForge#EVENT_BUS}
|
||||
*/
|
||||
public class RegisterCommandsEvent extends Event
|
||||
{
|
||||
private final CommandDispatcher<CommandSource> dispatcher;
|
||||
private final Commands.EnvironmentType environment;
|
||||
|
||||
public RegisterCommandsEvent(CommandDispatcher<CommandSource> dispatcher, Commands.EnvironmentType environment)
|
||||
{
|
||||
this.dispatcher = dispatcher;
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
public CommandDispatcher<CommandSource> getDispatcher()
|
||||
{
|
||||
return dispatcher;
|
||||
}
|
||||
|
||||
public Commands.EnvironmentType getEnvironment()
|
||||
{
|
||||
return environment;
|
||||
}
|
||||
}
|
|
@ -19,14 +19,13 @@
|
|||
|
||||
package net.minecraftforge.fml.event.server;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
/**
|
||||
* Called after {@link FMLServerAboutToStartEvent} and before {@link FMLServerStartedEvent}.
|
||||
* This event allows for customizations of the server, such as loading custom commands, perhaps customizing recipes or
|
||||
* other activities.
|
||||
* This event allows for customizations of the server.
|
||||
*
|
||||
* If you need to add commands use {@link net.minecraftforge.event.RegisterCommandsEvent}.
|
||||
*
|
||||
* @author cpw
|
||||
*/
|
||||
|
@ -37,7 +36,4 @@ public class FMLServerStartingEvent extends ServerLifecycleEvent
|
|||
super(server);
|
||||
}
|
||||
|
||||
public CommandDispatcher<CommandSource> getCommandDispatcher() {
|
||||
return server.getCommandManager().getDispatcher();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue