Backstage Sigil of Holding (#785)
* Backstage Sigil of Holding All Sigil of Holding features work, just need to add the aesthetics -> TehNut Somebody might want to look at adding LP costs to the Sigil? Also recipes need to be added Added a keybinding system for future usage Standardized some NBT tags Compact classes Fix lang stuff? * Fancify Sigil of Holding GUI Displays the selected sigil in the GUI now Woops * Quick fix * Unused import * Final commit I promise
This commit is contained in:
parent
9aa2f86c88
commit
8d66575530
19 changed files with 922 additions and 6 deletions
61
src/main/java/WayofTime/bloodmagic/network/KeyProcessor.java
Normal file
61
src/main/java/WayofTime/bloodmagic/network/KeyProcessor.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
package WayofTime.bloodmagic.network;
|
||||
|
||||
import WayofTime.bloodmagic.util.handler.BMKeyBinding;
|
||||
import WayofTime.bloodmagic.util.handler.IKeybindable;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class KeyProcessor implements IMessage, IMessageHandler<KeyProcessor, IMessage>
|
||||
{
|
||||
public int keyId;
|
||||
public boolean showInChat;
|
||||
|
||||
public KeyProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
public KeyProcessor(BMKeyBinding.Key key, boolean showInChat)
|
||||
{
|
||||
this.keyId = key.ordinal();
|
||||
this.showInChat = showInChat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
this.keyId = buf.readInt();
|
||||
this.showInChat = buf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
buf.writeInt(this.keyId);
|
||||
buf.writeBoolean(this.showInChat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(KeyProcessor msg, MessageContext ctx)
|
||||
{
|
||||
EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity;
|
||||
|
||||
if (entityPlayer != null)
|
||||
{
|
||||
ItemStack heldStack = entityPlayer.getHeldItemMainhand();
|
||||
if (heldStack.getItem() instanceof IKeybindable)
|
||||
{
|
||||
if (msg.keyId < 0 || msg.keyId >= BMKeyBinding.Key.values().length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
BMKeyBinding.Key key = BMKeyBinding.Key.values()[msg.keyId];
|
||||
((IKeybindable) heldStack.getItem()).onKeyPressed(heldStack, entityPlayer, key, msg.showInChat);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue