Large amount of work toward being able to place the recipe into the gui.
This commit is contained in:
parent
bee8d4aab0
commit
412d66593b
4 changed files with 102 additions and 13 deletions
|
@ -1,5 +1,6 @@
|
|||
package techreborn.packets;
|
||||
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -17,14 +18,21 @@ public class PacketSetRecipe implements INetworkPacket<PacketSetRecipe> {
|
|||
|
||||
BlockPos pos;
|
||||
ResourceLocation recipe;
|
||||
boolean custom;
|
||||
|
||||
public PacketSetRecipe(TileAutoCraftingTable tile, ResourceLocation recipe) {
|
||||
public PacketSetRecipe(TileAutoCraftingTable tile, IRecipe recipe, boolean custom) {
|
||||
this.pos = tile.getPos();
|
||||
this.recipe = recipe;
|
||||
if(recipe == null){
|
||||
this.recipe = new ResourceLocation("");
|
||||
} else {
|
||||
this.recipe = recipe.getRegistryName();
|
||||
}
|
||||
|
||||
if(this.recipe == null){
|
||||
//TODO fix vanilla recipes
|
||||
this.recipe = new ResourceLocation("");
|
||||
}
|
||||
this.custom = custom;
|
||||
}
|
||||
|
||||
public PacketSetRecipe() {
|
||||
|
@ -34,19 +42,21 @@ public class PacketSetRecipe implements INetworkPacket<PacketSetRecipe> {
|
|||
public void writeData(ExtendedPacketBuffer buffer) throws IOException {
|
||||
buffer.writeBlockPos(pos);
|
||||
buffer.writeResourceLocation(recipe);
|
||||
buffer.writeBoolean(custom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(ExtendedPacketBuffer buffer) throws IOException {
|
||||
pos = buffer.readBlockPos();
|
||||
recipe = buffer.readResourceLocation();
|
||||
custom = buffer.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(PacketSetRecipe message, MessageContext context) {
|
||||
TileEntity tileEntity = context.getServerHandler().player.world.getTileEntity(pos);;
|
||||
TileEntity tileEntity = context.getServerHandler().player.world.getTileEntity(message.pos);;
|
||||
if(tileEntity instanceof TileAutoCraftingTable){
|
||||
((TileAutoCraftingTable) tileEntity).setCurrentRecipe(recipe);
|
||||
((TileAutoCraftingTable) tileEntity).setCurrentRecipe(message.recipe, message.custom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue