Add RecipesUpdatedEvent, fired when recipes are downloaded from the server. (#5303)

This commit is contained in:
mezz 2019-01-25 13:36:42 -08:00 committed by LexManos
parent 69f8e57cea
commit c8c54113d0
3 changed files with 51 additions and 2 deletions

View file

@ -42,7 +42,15 @@
} }
if (flag && this.field_147299_f.field_71462_r instanceof GuiCommandBlock) { if (flag && this.field_147299_f.field_71462_r instanceof GuiCommandBlock) {
@@ -1272,7 +1280,7 @@ @@ -1182,6 +1190,7 @@
recipebookclient.func_199644_c();
recipebookclient.func_199642_d().forEach(searchtree::func_194043_a);
searchtree.func_194040_a();
+ net.minecraftforge.client.ForgeHooksClient.onRecipesUpdated();
}
public void func_200232_a(SPacketPlayerLook p_200232_1_) {
@@ -1272,7 +1281,7 @@
PacketThreadUtil.func_180031_a(p_147260_1_, this, this.field_147299_f); PacketThreadUtil.func_180031_a(p_147260_1_, this, this.field_147299_f);
Entity entity = this.field_147300_g.func_73045_a(p_147260_1_.func_149426_d()); Entity entity = this.field_147300_g.func_73045_a(p_147260_1_.func_149426_d());
if (entity instanceof EntityLivingBase) { if (entity instanceof EntityLivingBase) {
@ -51,7 +59,7 @@
if (potion != null) { if (potion != null) {
PotionEffect potioneffect = new PotionEffect(potion, p_147260_1_.func_180755_e(), p_147260_1_.func_149428_f(), p_147260_1_.func_186984_g(), p_147260_1_.func_179707_f(), p_147260_1_.func_205527_h()); PotionEffect potioneffect = new PotionEffect(potion, p_147260_1_.func_180755_e(), p_147260_1_.func_149428_f(), p_147260_1_.func_186984_g(), p_147260_1_.func_179707_f(), p_147260_1_.func_205527_h());
potioneffect.func_100012_b(p_147260_1_.func_149429_c()); potioneffect.func_100012_b(p_147260_1_.func_149429_c());
@@ -1598,10 +1606,12 @@ @@ -1598,10 +1607,12 @@
((DebugRendererWorldGenAttempts)this.field_147299_f.field_184132_p.field_201750_j).func_201734_a(packetbuffer.func_179259_c(), packetbuffer.readFloat(), packetbuffer.readFloat(), packetbuffer.readFloat(), packetbuffer.readFloat(), packetbuffer.readFloat()); ((DebugRendererWorldGenAttempts)this.field_147299_f.field_184132_p.field_201750_j).func_201734_a(packetbuffer.func_179259_c(), packetbuffer.readFloat(), packetbuffer.readFloat(), packetbuffer.readFloat(), packetbuffer.readFloat(), packetbuffer.readFloat());
field_147301_d.warn("Unknown custom packed identifier: {}", (Object)resourcelocation); field_147301_d.warn("Unknown custom packed identifier: {}", (Object)resourcelocation);
} else { } else {

View file

@ -38,6 +38,7 @@ import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f; import javax.vecmath.Vector4f;
import net.minecraft.client.MouseHelper; import net.minecraft.client.MouseHelper;
import net.minecraftforge.client.event.RecipesUpdatedEvent;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -810,4 +811,10 @@ public class ForgeHooksClient
Event event = new GuiScreenEvent.KeyboardCharTypedEvent.Post(guiScreen, codePoint, modifiers); Event event = new GuiScreenEvent.KeyboardCharTypedEvent.Post(guiScreen, codePoint, modifiers);
return MinecraftForge.EVENT_BUS.post(event); return MinecraftForge.EVENT_BUS.post(event);
} }
public static void onRecipesUpdated()
{
Event event = new RecipesUpdatedEvent();
MinecraftForge.EVENT_BUS.post(event);
}
} }

View file

@ -0,0 +1,34 @@
/*
* 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.client.event;
import net.minecraft.item.crafting.RecipeManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.Event;
/**
* Fired on {@link Dist#CLIENT} when {@link RecipeManager} has all of its recipes synced from the server to the client (just after a client has connected),
*/
public class RecipesUpdatedEvent extends Event
{
public RecipesUpdatedEvent()
{
}
}