Fixed not being able to start autocrafting in other dimensions with Network Transmitter / Network Receivers, fixes #406
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
- Added recipe transfer handler for Solderer (way2muchnoise)
|
- Added recipe transfer handler for Solderer (way2muchnoise)
|
||||||
- It is now possible to start a crafting task even if the crafting preview says you can't (raoulvdberge)
|
- It is now possible to start a crafting task even if the crafting preview says you can't (raoulvdberge)
|
||||||
- Fixed crash with JEI when changing screens in autocrafting (raoulvdberge)
|
- Fixed crash with JEI when changing screens in autocrafting (raoulvdberge)
|
||||||
|
- Fixed not being able to start autocrafting in other dimensions with Network Transmitter / Network Receivers (raoulvdberge)
|
||||||
- Fixed JEI overlay disappearing now and again (raoulvdberge)
|
- Fixed JEI overlay disappearing now and again (raoulvdberge)
|
||||||
- Fixed Detector hitbox (raoulvdberge)
|
- Fixed Detector hitbox (raoulvdberge)
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ public interface IItemGridHandler {
|
|||||||
*/
|
*/
|
||||||
void onInsertHeldItem(EntityPlayerMP player, boolean single);
|
void onInsertHeldItem(EntityPlayerMP player, boolean single);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player requests the crafting preview window to be opened.
|
||||||
|
*
|
||||||
|
* @param hash the hash of the item we want a preview for, see {@link refinedstorage.api.network.NetworkUtils#getItemStackHashCode(ItemStack)}
|
||||||
|
* @param quantity the amount of that item that we need a preview for
|
||||||
|
*/
|
||||||
|
void onCraftingPreviewRequested(EntityPlayerMP player, int hash, int quantity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a player requested crafting for an item.
|
* Called when a player requested crafting for an item.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import refinedstorage.api.network.INetworkMaster;
|
|||||||
import refinedstorage.api.network.NetworkUtils;
|
import refinedstorage.api.network.NetworkUtils;
|
||||||
import refinedstorage.api.network.grid.IItemGridHandler;
|
import refinedstorage.api.network.grid.IItemGridHandler;
|
||||||
import refinedstorage.api.storage.CompareUtils;
|
import refinedstorage.api.storage.CompareUtils;
|
||||||
|
import refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewData;
|
||||||
|
import refinedstorage.network.MessageGridCraftingPreviewResponse;
|
||||||
|
|
||||||
public class ItemGridHandler implements IItemGridHandler {
|
public class ItemGridHandler implements IItemGridHandler {
|
||||||
private INetworkMaster network;
|
private INetworkMaster network;
|
||||||
@@ -118,6 +120,19 @@ public class ItemGridHandler implements IItemGridHandler {
|
|||||||
network.getWirelessGridHandler().drainEnergy(player, RefinedStorage.INSTANCE.config.wirelessGridInsertUsage);
|
network.getWirelessGridHandler().drainEnergy(player, RefinedStorage.INSTANCE.config.wirelessGridInsertUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCraftingPreviewRequested(EntityPlayerMP player, int hash, int quantity) {
|
||||||
|
ItemStack stack = network.getItemStorage().get(hash);
|
||||||
|
|
||||||
|
if (stack != null) {
|
||||||
|
CraftingPreviewData previewData = new CraftingPreviewData(network);
|
||||||
|
|
||||||
|
previewData.calculate(stack, quantity);
|
||||||
|
|
||||||
|
RefinedStorage.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(previewData.values(), hash, quantity), player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCraftingRequested(int hash, int quantity) {
|
public void onCraftingRequested(int hash, int quantity) {
|
||||||
if (quantity <= 0) {
|
if (quantity <= 0) {
|
||||||
|
|||||||
@@ -3,12 +3,7 @@ package refinedstorage.network;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
import refinedstorage.RefinedStorage;
|
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
|
||||||
import refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewData;
|
|
||||||
import refinedstorage.container.ContainerGrid;
|
import refinedstorage.container.ContainerGrid;
|
||||||
|
|
||||||
public class MessageGridCraftingPreview extends MessageHandlerPlayerToServer<MessageGridCraftingPreview> implements IMessage {
|
public class MessageGridCraftingPreview extends MessageHandlerPlayerToServer<MessageGridCraftingPreview> implements IMessage {
|
||||||
@@ -40,21 +35,7 @@ public class MessageGridCraftingPreview extends MessageHandlerPlayerToServer<Mes
|
|||||||
Container container = player.openContainer;
|
Container container = player.openContainer;
|
||||||
|
|
||||||
if (container instanceof ContainerGrid) {
|
if (container instanceof ContainerGrid) {
|
||||||
TileEntity tile = player.getEntityWorld().getTileEntity(((ContainerGrid) container).getGrid().getNetworkPosition());
|
((ContainerGrid) container).getGrid().getItemHandler().onCraftingPreviewRequested(player, message.hash, message.quantity);
|
||||||
|
|
||||||
if (tile != null && tile instanceof INetworkMaster) {
|
|
||||||
INetworkMaster network = (INetworkMaster) tile;
|
|
||||||
|
|
||||||
ItemStack stack = network.getItemStorage().get(message.hash);
|
|
||||||
|
|
||||||
if (stack != null) {
|
|
||||||
CraftingPreviewData previewData = new CraftingPreviewData(network);
|
|
||||||
|
|
||||||
previewData.calculate(stack, message.quantity);
|
|
||||||
|
|
||||||
RefinedStorage.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(previewData.values(), message.hash, message.quantity), player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user