forked from GTNewHorizons/StructureLib
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
5 changed files
with
75 additions
and
1 deletion.
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
42 changes: 42 additions & 0 deletions
42
src/main/java/com/gtnewhorizon/structurelib/net/ScrollConstructablePacket.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,42 @@ | ||
package com.gtnewhorizon.structurelib.net; | ||
|
||
import com.gtnewhorizon.structurelib.item.ItemConstructableTrigger; | ||
import com.gtnewhorizon.structurelib.item.ItemDebugStructureWriter; | ||
import cpw.mods.fml.common.network.ByteBufUtils; | ||
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 net.minecraft.item.ItemStack; | ||
|
||
public class ScrollConstructablePacket implements IMessage, IMessageHandler<ScrollConstructablePacket, IMessage> { | ||
public ScrollConstructablePacket() {} | ||
|
||
byte metaData; | ||
|
||
public ScrollConstructablePacket(byte metaData) { | ||
this.metaData = metaData; | ||
} | ||
|
||
|
||
@Override | ||
public void fromBytes(ByteBuf buf) { | ||
metaData = buf.readByte(); | ||
} | ||
|
||
@Override | ||
public void toBytes(ByteBuf buf) { | ||
buf.writeByte(metaData); | ||
} | ||
|
||
@Override | ||
public IMessage onMessage(ScrollConstructablePacket message, MessageContext ctx) { | ||
ItemStack itemStack = ctx.getServerHandler().playerEntity.inventory.getCurrentItem(); | ||
if (itemStack == null || !(itemStack.getItem() instanceof ItemConstructableTrigger)) { | ||
return null; | ||
} | ||
if (message.metaData < 0 || message.metaData > 1) return null; | ||
itemStack.setItemDamage(message.metaData); | ||
return null; | ||
} | ||
} |
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