提供: Minecraft Modding Wiki
この編集を取り消せます。
下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
87行目: | 87行目: | ||
<source lang = "java"> | <source lang = "java"> | ||
package yourpackage; | package yourpackage; | ||
+ | import cpw.mods.fml.client.FMLClientHandler; | ||
+ | import cpw.mods.fml.common.FMLCommonHandler; | ||
import cpw.mods.fml.common.network.simpleimpl.IMessage; | import cpw.mods.fml.common.network.simpleimpl.IMessage; | ||
+ | import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; | ||
+ | import cpw.mods.fml.common.network.simpleimpl.MessageContext; | ||
import io.netty.buffer.ByteBuf; | import io.netty.buffer.ByteBuf; | ||
+ | import net.minecraft.entity.player.EntityPlayer; | ||
− | public class MessageKeyPressed implements IMessage { | + | public class MessageKeyPressed implements IMessage, IMessageHandler<MessageKeyPressed, IMessage> { |
− | + | private byte key; | |
public MessageKeyPressed(){} | public MessageKeyPressed(){} | ||
109行目: | 114行目: | ||
buf.writeByte(this.key); | buf.writeByte(this.key); | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
@Override | @Override | ||
129行目: | 123行目: | ||
return null; | return null; | ||
} | } | ||
− | + | } | |
</source> | </source> | ||
169行目: | 163行目: | ||
<source lang = "java"> | <source lang = "java"> | ||
package yourpackage; | package yourpackage; | ||
+ | import cpw.mods.fml.client.FMLClientHandler; | ||
+ | import cpw.mods.fml.common.FMLCommonHandler; | ||
import cpw.mods.fml.common.network.simpleimpl.IMessage; | import cpw.mods.fml.common.network.simpleimpl.IMessage; | ||
+ | import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; | ||
+ | import cpw.mods.fml.common.network.simpleimpl.MessageContext; | ||
import io.netty.buffer.ByteBuf; | import io.netty.buffer.ByteBuf; | ||
+ | import net.minecraft.entity.player.EntityPlayer; | ||
− | public class MessageKeyPressed implements IMessage { | + | public class MessageKeyPressed implements IMessage, IMessageHandler<MessageKeyPressed, IMessage> { |
private byte key; | private byte key; | ||
191行目: | 190行目: | ||
buf.writeByte(this.key); | buf.writeByte(this.key); | ||
} | } | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
@Override | @Override | ||
216行目: | 201行目: | ||
} | } | ||
</source> | </source> | ||
− | + | キー判定を送るMessageクラス。 | |
− | + | ここでは、byte変数keyの内容をサーバーに送って、それをチャットに出力している。 | |
+ | |||
押しっぱなしかどうかを見たいのであれば、tick処理ループ内で、KeyBinding変数のgetIsKeyPressed()メソッドを監視し続ければよい。 | 押しっぱなしかどうかを見たいのであれば、tick処理ループ内で、KeyBinding変数のgetIsKeyPressed()メソッドを監視し続ければよい。 |