-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6280d94
commit 4cdf0c9
Showing
6 changed files
with
109 additions
and
96 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
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
41 changes: 41 additions & 0 deletions
41
src/main/java/io/github/hhui64/pixelmoninfoplus/network/IMessageBase.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,41 @@ | ||
package io.github.hhui64.pixelmoninfoplus.network; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraftforge.fml.common.network.ByteBufUtils; | ||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage; | ||
|
||
public abstract class IMessageBase implements IMessage { | ||
public static int protocolVersion = 2; | ||
public NBTTagCompound compound; | ||
|
||
public IMessageBase() { | ||
super(); | ||
compound = new NBTTagCompound(); | ||
if (getProtocolVersion() <= 0) { | ||
compound.setInteger("protocolVersion", IMessageBase.protocolVersion); | ||
} | ||
} | ||
|
||
@Override | ||
public void fromBytes(ByteBuf buf) { | ||
compound = ByteBufUtils.readTag(buf); | ||
} | ||
|
||
@Override | ||
public void toBytes(ByteBuf buf) { | ||
ByteBufUtils.writeTag(buf, compound); | ||
} | ||
|
||
public int getLocalProtocolVersion() { | ||
return protocolVersion; | ||
} | ||
|
||
public int getProtocolVersion() { | ||
return this.compound.getInteger("protocolVersion"); | ||
} | ||
|
||
public boolean isProtocolVersionMatched() { | ||
return this.compound.getInteger("protocolVersion") == IMessageBase.protocolVersion; | ||
} | ||
} |
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