-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TCNEIPlugin support and ThaumicEnergistics support
- Loading branch information
Showing
27 changed files
with
266 additions
and
24 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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
77 changes: 77 additions & 0 deletions
77
src/main/java/com/github/vfyjxf/nee/network/packet/PacketArcaneRecipe.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,77 @@ | ||
package com.github.vfyjxf.nee.network.packet; | ||
|
||
import appeng.container.slot.SlotFakeCraftingMatrix; | ||
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 cpw.mods.fml.relauncher.ReflectionHelper; | ||
import io.netty.buffer.ByteBuf; | ||
import net.minecraft.entity.player.EntityPlayerMP; | ||
import net.minecraft.inventory.Container; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import thaumicenergistics.common.container.ContainerKnowledgeInscriber; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
/** | ||
* @author vfyjxf | ||
*/ | ||
public class PacketArcaneRecipe implements IMessage, IMessageHandler<PacketArcaneRecipe, IMessage> { | ||
|
||
NBTTagCompound input; | ||
|
||
public PacketArcaneRecipe() {} | ||
|
||
public PacketArcaneRecipe(NBTTagCompound input) { | ||
this.input = input; | ||
} | ||
|
||
@Override | ||
public void fromBytes(ByteBuf buf) { | ||
this.input = ByteBufUtils.readTag(buf); | ||
} | ||
|
||
@Override | ||
public void toBytes(ByteBuf buf) { | ||
ByteBufUtils.writeTag(buf, this.input); | ||
} | ||
|
||
@Override | ||
public IMessage onMessage(PacketArcaneRecipe message, MessageContext ctx) { | ||
EntityPlayerMP player = ctx.getServerHandler().playerEntity; | ||
Container container = player.openContainer; | ||
if (container instanceof ContainerKnowledgeInscriber) { | ||
ItemStack[] recipeInput = new ItemStack[9]; | ||
NBTTagCompound currentStack; | ||
for (int i = 0; i < recipeInput.length; i++) { | ||
currentStack = (NBTTagCompound) message.input.getTag("#" + i); | ||
recipeInput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack); | ||
} | ||
|
||
Field craftingSlots = ReflectionHelper.findField(ContainerKnowledgeInscriber.class, "craftingSlots"); | ||
SlotFakeCraftingMatrix[] craftMatrix = getCraftingSlots(craftingSlots, (ContainerKnowledgeInscriber) container); | ||
if (craftMatrix != null && message.input != null) { | ||
for (int i = 0; i < recipeInput.length; i++) { | ||
ItemStack currentItem = null; | ||
if (recipeInput[i] != null) { | ||
currentItem = recipeInput[i].copy(); | ||
} | ||
craftMatrix[i].putStack(currentItem); | ||
} | ||
((ContainerKnowledgeInscriber) container).func_75130_a(craftMatrix[0].inventory); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
private SlotFakeCraftingMatrix[] getCraftingSlots(Field field, ContainerKnowledgeInscriber container) { | ||
try { | ||
return (SlotFakeCraftingMatrix[]) field.get(container); | ||
} catch (IllegalAccessException e) { | ||
e.printStackTrace(); | ||
} | ||
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
Oops, something went wrong.