parent
52409e15cf
commit
671d462645
4 changed files with 118 additions and 8 deletions
|
@ -8,7 +8,7 @@
|
|||
|
||||
public void func_73863_a(int p_73863_1_, int p_73863_2_, float p_73863_3_)
|
||||
{
|
||||
@@ -147,7 +148,10 @@
|
||||
@@ -147,7 +145,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
|||
}
|
||||
|
||||
protected void func_146279_a(String p_146279_1_, int p_146279_2_, int p_146279_3_)
|
||||
@@ -157,7 +161,13 @@
|
||||
@@ -157,7 +158,13 @@
|
||||
|
||||
protected void func_146283_a(List<String> p_146283_1_, int p_146283_2_, int p_146283_3_)
|
||||
{
|
||||
|
@ -35,7 +35,13 @@
|
|||
{
|
||||
GlStateManager.func_179101_C();
|
||||
RenderHelper.func_74518_a();
|
||||
@@ -418,6 +428,7 @@
|
||||
@@ -414,10 +421,13 @@
|
||||
|
||||
public void func_175281_b(String p_175281_1_, boolean p_175281_2_)
|
||||
{
|
||||
+ p_175281_1_ = net.minecraftforge.event.ForgeEventFactory.onClientSendMessage(p_175281_1_);
|
||||
+ if (p_175281_1_.isEmpty()) return;
|
||||
if (p_175281_2_)
|
||||
{
|
||||
this.field_146297_k.field_71456_v.func_146158_b().func_146239_a(p_175281_1_);
|
||||
}
|
||||
|
@ -43,7 +49,7 @@
|
|||
|
||||
this.field_146297_k.field_71439_g.func_71165_d(p_175281_1_);
|
||||
}
|
||||
@@ -432,9 +443,15 @@
|
||||
@@ -432,9 +442,15 @@
|
||||
|
||||
if (guibutton.func_146116_c(this.field_146297_k, p_73864_1_, p_73864_2_))
|
||||
{
|
||||
|
@ -59,7 +65,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -464,8 +481,12 @@
|
||||
@@ -464,8 +480,12 @@
|
||||
this.field_146289_q = p_146280_1_.field_71466_p;
|
||||
this.field_146294_l = p_146280_2_;
|
||||
this.field_146295_m = p_146280_3_;
|
||||
|
@ -72,7 +78,7 @@
|
|||
}
|
||||
|
||||
public void func_183500_a(int p_183500_1_, int p_183500_2_)
|
||||
@@ -484,7 +505,10 @@
|
||||
@@ -484,7 +504,10 @@
|
||||
{
|
||||
while (Mouse.next())
|
||||
{
|
||||
|
@ -83,7 +89,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -492,7 +516,10 @@
|
||||
@@ -492,7 +515,10 @@
|
||||
{
|
||||
while (Keyboard.next())
|
||||
{
|
||||
|
@ -94,7 +100,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -554,6 +581,7 @@
|
||||
@@ -554,6 +580,7 @@
|
||||
public void func_146276_q_()
|
||||
{
|
||||
this.func_146270_b(0);
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016.
|
||||
*
|
||||
* This library 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 version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library 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 library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
/**
|
||||
* ClientChatEvent is fired whenever the client is about to send a chat message or command to the server. <br>
|
||||
* This event is fired via {@link ForgeEventFactory#onClientSendMessage(String)},
|
||||
* which is executed by {@link GuiScreen#sendChatMessage(String, boolean)}<br>
|
||||
* <br>
|
||||
* {@link #message} contains the message that will be sent to the server. This can be changed by mods.<br>
|
||||
* {@link #originalMessage} contains the original message that was going to be sent to the server. This cannot be changed by mods.<br>
|
||||
* <br>
|
||||
* This event is {@link Cancelable}. <br>
|
||||
* If this event is canceled, the chat message or command is never sent to the server.<br>
|
||||
* <br>
|
||||
* This event does not have a result. {@link HasResult}<br>
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
|
||||
**/
|
||||
@Cancelable
|
||||
public class ClientChatEvent extends Event
|
||||
{
|
||||
private String message;
|
||||
private final String originalMessage;
|
||||
public ClientChatEvent(String message)
|
||||
{
|
||||
this.setMessage(message);
|
||||
this.originalMessage = Strings.nullToEmpty(message);
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = Strings.nullToEmpty(message);
|
||||
}
|
||||
|
||||
public String getOriginalMessage()
|
||||
{
|
||||
return originalMessage;
|
||||
}
|
||||
}
|
|
@ -64,6 +64,7 @@ import net.minecraft.world.chunk.IChunkGenerator;
|
|||
import net.minecraft.world.storage.IPlayerFileData;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.loot.LootTable;
|
||||
import net.minecraftforge.client.event.ClientChatEvent;
|
||||
import net.minecraftforge.client.event.ClientChatReceivedEvent;
|
||||
import net.minecraftforge.client.event.RenderBlockOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderBlockOverlayEvent.OverlayType;
|
||||
|
@ -340,6 +341,13 @@ public class ForgeEventFactory
|
|||
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String onClientSendMessage(String message)
|
||||
{
|
||||
ClientChatEvent event = new ClientChatEvent(message);
|
||||
return MinecraftForge.EVENT_BUS.post(event) ? "" : event.getMessage();
|
||||
}
|
||||
|
||||
public static int onHoeUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos)
|
||||
{
|
||||
UseHoeEvent event = new UseHoeEvent(player, stack, worldIn, pos);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package net.minecraftforge.test;
|
||||
|
||||
import net.minecraftforge.client.event.ClientChatEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
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.eventhandler.SubscribeEvent;
|
||||
|
||||
@Mod(modid="clientchateventtest", name="Client Chat Event Test", version="0.0.0", acceptableRemoteVersions = "*")
|
||||
public class ClientChatEventTest {
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerAttemptChat(ClientChatEvent event)
|
||||
{
|
||||
if(event.getMessage().equals("Cancel"))
|
||||
event.setCanceled(true);
|
||||
else if(event.getMessage().equals("Replace this text"))
|
||||
event.setMessage("Text replaced.");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue