-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a notification event for handling game rule changes (#5152)
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
patches/minecraft/net/minecraft/command/CommandGameRule.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- ../src-base/minecraft/net/minecraft/command/CommandGameRule.java | ||
+++ ../src-work/minecraft/net/minecraft/command/CommandGameRule.java | ||
@@ -73,6 +73,7 @@ | ||
entityplayermp.field_71135_a.func_147359_a(new SPacketEntityStatus(entityplayermp, b0)); | ||
} | ||
} | ||
+ net.minecraftforge.event.ForgeEventFactory.onGameRuleChange(p_184898_0_, p_184898_1_, p_184898_2_); | ||
} | ||
|
||
public List<String> func_184883_a(MinecraftServer p_184883_1_, ICommandSender p_184883_2_, String[] p_184883_3_, @Nullable BlockPos p_184883_4_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/net/minecraftforge/event/GameRuleChangeEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Minecraft Forge | ||
* Copyright (c) 2016-2018. | ||
* | ||
* 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.event; | ||
|
||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.world.GameRules; | ||
import net.minecraftforge.fml.common.eventhandler.Event; | ||
|
||
/** | ||
* Fired when a game rule is changed, | ||
* via {@link net.minecraft.command.CommandGameRule#notifyGameRuleChange(GameRules, String, MinecraftServer)}. | ||
* | ||
* This allows updating clients with the effects of server rule changes. | ||
*/ | ||
public class GameRuleChangeEvent extends Event | ||
{ | ||
private final GameRules rules; | ||
private final String ruleName; | ||
private final MinecraftServer server; | ||
|
||
public GameRuleChangeEvent(GameRules rules, String ruleName, MinecraftServer server) | ||
{ | ||
this.rules = rules; | ||
this.ruleName = ruleName; | ||
this.server = server; | ||
} | ||
|
||
public GameRules getRules() | ||
{ | ||
return rules; | ||
} | ||
|
||
public String getRuleName() | ||
{ | ||
return ruleName; | ||
} | ||
|
||
public MinecraftServer getServer() | ||
{ | ||
return server; | ||
} | ||
} |