-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor some event handlers, to better separate the client-side ones
- Loading branch information
Showing
7 changed files
with
61 additions
and
80 deletions.
There are no files selected for viewing
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,42 @@ | ||
package baubles.client; | ||
|
||
import net.minecraft.client.renderer.block.model.ModelResourceLocation; | ||
import net.minecraft.util.text.TextFormatting; | ||
import net.minecraftforge.client.event.ModelRegistryEvent; | ||
import net.minecraftforge.client.model.ModelLoader; | ||
import net.minecraftforge.event.entity.player.ItemTooltipEvent; | ||
import net.minecraftforge.fml.client.FMLClientHandler; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; | ||
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import baubles.api.BaubleType; | ||
import baubles.api.IBauble; | ||
import baubles.common.items.ItemRing; | ||
import baubles.common.network.PacketHandler; | ||
import baubles.common.network.PacketOpenBaublesInventory; | ||
|
||
public class ClientEventHandler | ||
{ | ||
@SubscribeEvent | ||
public void registerItemModels(ModelRegistryEvent event) { | ||
ModelLoader.setCustomModelResourceLocation(ItemRing.RING, 0, new ModelResourceLocation("baubles:ring", "inventory")); | ||
} | ||
|
||
@SubscribeEvent | ||
public void playerTick(PlayerTickEvent event) { | ||
if (event.side == Side.CLIENT && event.phase == Phase.START ) { | ||
if (ClientProxy.KEY_BAUBLES.isPressed() && FMLClientHandler.instance().getClient().inGameHasFocus) { | ||
PacketHandler.INSTANCE.sendToServer(new PacketOpenBaublesInventory(event.player)); | ||
} | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void tooltipEvent(ItemTooltipEvent event) { | ||
if (!event.getItemStack().isEmpty() && event.getItemStack().getItem() instanceof IBauble) { | ||
BaubleType bt = ((IBauble)event.getItemStack().getItem()).getBaubleType(event.getItemStack()); | ||
event.getToolTip().add(TextFormatting.GOLD + net.minecraft.client.resources.I18n.format("name." + bt)); | ||
} | ||
} | ||
} |
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
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
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
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
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
This file was deleted.
Oops, something went wrong.