mirror of
https://github.com/GTNewHorizons/NotEnoughEnergistics.git
synced 2026-10-26 14:23:58 +00:00
Merge branch 'vfyjxf:main' into master
This commit is contained in:
15 files changed
+315
-262
No files matched your search
+1
-1
@@ -2,7 +2,7 @@ dependencies {
|
||||
compile("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-75-GTNH:dev")
|
||||
compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev")
|
||||
compile("com.github.GTNewHorizons:CodeChickenCore:1.1.3:dev")
|
||||
compile("com.github.GTNewHorizons:NotEnoughItems:2.1.22-GTNH:dev")
|
||||
compile("com.github.GTNewHorizons:NotEnoughItems:2.2.7-GTNH:dev")
|
||||
compile("com.github.GTNewHorizons:Baubles:1.0.1.14:dev")
|
||||
compile("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.8.3:dev")
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ modName = NotEnoughEnergistics
|
||||
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
|
||||
modId = neenergistics
|
||||
|
||||
modVersion=1.4.0
|
||||
modVersion=1.4.1
|
||||
|
||||
modGroup = com.github.vfyjxf.nee
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class NEECraftingHandler implements IOverlayHandler {
|
||||
private PacketNEIPatternRecipe packProcessRecipe(IRecipeHandler recipe, int recipeIndex) {
|
||||
final NBTTagCompound recipeInputs = new NBTTagCompound();
|
||||
NBTTagCompound recipeOutputs = new NBTTagCompound();
|
||||
String identifier = ((TemplateRecipeHandler) recipe).getOverlayIdentifier();
|
||||
String identifier = recipe.getOverlayIdentifier();
|
||||
int inputIndex = 0;
|
||||
int outputIndex = 0;
|
||||
//get all recipe inputs and other stacks,use first item
|
||||
@@ -76,7 +76,7 @@ public class NEECraftingHandler implements IOverlayHandler {
|
||||
List<PositionedStack> tInputs = new ArrayList<>();
|
||||
|
||||
if (!inputs.isEmpty() && !outputs.isEmpty()) {
|
||||
|
||||
NEECraftingHandler.ingredients.clear();
|
||||
for (PositionedStack positionedStack : inputs) {
|
||||
ItemStack currentStack = positionedStack.items[0];
|
||||
boolean find = false;
|
||||
@@ -152,6 +152,7 @@ public class NEECraftingHandler implements IOverlayHandler {
|
||||
private PacketNEIPatternRecipe packCraftingTableRecipe(IRecipeHandler recipe, int recipeIndex) {
|
||||
final NBTTagCompound recipeInputs = new NBTTagCompound();
|
||||
final List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
|
||||
NEECraftingHandler.ingredients.clear();
|
||||
for (final PositionedStack positionedStack : ingredients) {
|
||||
final int col = (positionedStack.relx - 25) / 18;
|
||||
final int row = (positionedStack.rely - 6) / 18;
|
||||
|
||||
@@ -19,17 +19,17 @@ public class NEENetworkHandler {
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
INSTANCE.registerMessage(PacketNEIPatternRecipe.class, PacketNEIPatternRecipe.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketArcaneRecipe.class, PacketArcaneRecipe.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketExtremeRecipe.class, PacketExtremeRecipe.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketStackCountChange.class, PacketStackCountChange.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketSlotStackChange.class, PacketSlotStackChange.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketCraftingRequest.class, PacketCraftingRequest.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketOpenCraftAmount.class, PacketOpenCraftAmount.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketOpenGui.class, PacketOpenGui.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketSetRecipe.class, PacketSetRecipe.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketValueConfigServer.class, PacketValueConfigServer.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketValueConfigClient.class, PacketValueConfigClient.class, nextId(), Side.CLIENT);
|
||||
INSTANCE.registerMessage(PacketNEIPatternRecipe.Handler.class, PacketNEIPatternRecipe.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketArcaneRecipe.Handler.class, PacketArcaneRecipe.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketExtremeRecipe.Handler.class, PacketExtremeRecipe.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketStackCountChange.Handler.class, PacketStackCountChange.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketSlotStackChange.Handler.class, PacketSlotStackChange.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketCraftingRequest.Handler.class, PacketCraftingRequest.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketOpenCraftAmount.Handler.class, PacketOpenCraftAmount.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketOpenGui.Handler.class, PacketOpenGui.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketSetRecipe.Handler.class, PacketSetRecipe.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketValueConfigServer.Handler.class, PacketValueConfigServer.class, nextId(), Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketValueConfigClient.Handler.class, PacketValueConfigClient.class, nextId(), Side.CLIENT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import java.lang.reflect.Field;
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class PacketArcaneRecipe implements IMessage, IMessageHandler<PacketArcaneRecipe, IMessage> {
|
||||
public class PacketArcaneRecipe implements IMessage {
|
||||
|
||||
NBTTagCompound input;
|
||||
|
||||
@@ -39,40 +39,44 @@ public class PacketArcaneRecipe implements IMessage, IMessageHandler<PacketArcan
|
||||
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) {
|
||||
public static final class Handler implements IMessageHandler<PacketArcaneRecipe, IMessage>{
|
||||
@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++) {
|
||||
ItemStack currentItem = null;
|
||||
if (recipeInput[i] != null) {
|
||||
currentItem = recipeInput[i].copy();
|
||||
}
|
||||
craftMatrix[i].putStack(currentItem);
|
||||
currentStack = (NBTTagCompound) message.input.getTag("#" + i);
|
||||
recipeInput[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
|
||||
Field craftingSlots = ReflectionHelper.findField(ContainerKnowledgeInscriber.class, "craftingSlots");
|
||||
SlotFakeCraftingMatrix[] craftMatrix = this.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);
|
||||
}
|
||||
container.onCraftMatrixChanged(craftMatrix[0].inventory);
|
||||
}
|
||||
container.onCraftMatrixChanged(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;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private SlotFakeCraftingMatrix[] getCraftingSlots(Field field, ContainerKnowledgeInscriber container) {
|
||||
try {
|
||||
return (SlotFakeCraftingMatrix[]) field.get(container);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,7 +57,7 @@ import static com.github.vfyjxf.nee.nei.NEECraftingHandler.INPUT_KEY;
|
||||
import static com.github.vfyjxf.nee.nei.NEECraftingHandler.OUTPUT_KEY;
|
||||
import static com.github.vfyjxf.nee.nei.NEECraftingHelper.RECIPE_LENGTH;
|
||||
|
||||
public class PacketCraftingRequest implements IMessage, IMessageHandler<PacketCraftingRequest, IMessage> {
|
||||
public class PacketCraftingRequest implements IMessage{
|
||||
|
||||
|
||||
private IAEItemStack requireToCraftStack;
|
||||
@@ -120,38 +120,40 @@ public class PacketCraftingRequest implements IMessage, IMessageHandler<PacketCr
|
||||
buf.writeInt(this.craftAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketCraftingRequest message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
public static final class Handler implements IMessageHandler<PacketCraftingRequest, IMessage>{
|
||||
@Override
|
||||
public IMessage onMessage(PacketCraftingRequest message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
|
||||
if (container instanceof AEBaseContainer) {
|
||||
AEBaseContainer baseContainer = (AEBaseContainer) container;
|
||||
Object target = baseContainer.getTarget();
|
||||
if (target instanceof IGridHost) {
|
||||
final IGridHost gh = (IGridHost) target;
|
||||
final IGridNode gn = gh.getGridNode(ForgeDirection.UNKNOWN);
|
||||
if (gn != null) {
|
||||
final IGrid grid = gn.getGrid();
|
||||
if (grid != null) {
|
||||
final ISecurityGrid security = grid.getCache(ISecurityGrid.class);
|
||||
if (security != null && security.hasPermission(player, SecurityPermissions.CRAFT)) {
|
||||
if (container instanceof ContainerCraftingTerm) {
|
||||
handlerCraftingTermRequest((ContainerCraftingTerm) container, message, grid, player);
|
||||
}
|
||||
if (container instanceof AEBaseContainer) {
|
||||
AEBaseContainer baseContainer = (AEBaseContainer) container;
|
||||
Object target = baseContainer.getTarget();
|
||||
if (target instanceof IGridHost) {
|
||||
final IGridHost gh = (IGridHost) target;
|
||||
final IGridNode gn = gh.getGridNode(ForgeDirection.UNKNOWN);
|
||||
if (gn != null) {
|
||||
final IGrid grid = gn.getGrid();
|
||||
if (grid != null) {
|
||||
final ISecurityGrid security = grid.getCache(ISecurityGrid.class);
|
||||
if (security != null && security.hasPermission(player, SecurityPermissions.CRAFT)) {
|
||||
if (container instanceof ContainerCraftingTerm) {
|
||||
message.handlerCraftingTermRequest((ContainerCraftingTerm) container, message, grid, player);
|
||||
}
|
||||
|
||||
if (container instanceof ContainerCraftingAmount) {
|
||||
handlerCraftingAmountRequest((ContainerCraftingAmount) container, message, grid, player);
|
||||
if (container instanceof ContainerCraftingAmount) {
|
||||
message.handlerCraftingAmountRequest((ContainerCraftingAmount) container, message, grid, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (GuiUtils.isWirelessCraftingTermContainer(container)) {
|
||||
message.handlerWirelessCraftingRequest((ContainerWirelessCraftingTerminal) container, message, player);
|
||||
}
|
||||
} else if (GuiUtils.isWirelessCraftingTermContainer(container)) {
|
||||
handlerWirelessCraftingRequest((ContainerWirelessCraftingTerminal) container, message, player);
|
||||
}
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void handlerCraftingTermRequest(ContainerCraftingTerm container, PacketCraftingRequest message, IGrid grid, EntityPlayerMP player) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class PacketExtremeRecipe implements IMessage, IMessageHandler<PacketExtremeRecipe, IMessage> {
|
||||
public class PacketExtremeRecipe implements IMessage {
|
||||
|
||||
private NBTTagCompound input;
|
||||
|
||||
@@ -46,52 +46,55 @@ public class PacketExtremeRecipe implements IMessage, IMessageHandler<PacketExtr
|
||||
ByteBufUtils.writeTag(buf, this.input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketExtremeRecipe message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof ContainerExtremeAutoCrafter) {
|
||||
ItemStack[] recipeInputs = new ItemStack[81];
|
||||
NBTTagCompound currentStack;
|
||||
for (int i = 0; i < recipeInputs.length; i++) {
|
||||
currentStack = (NBTTagCompound) message.input.getTag("#" + i);
|
||||
recipeInputs[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
int inputIndex = 0;
|
||||
for (int i = 81; i < 162; i++) {
|
||||
Slot fakeSlot = container.getSlot(i);
|
||||
ItemStack currentItem = recipeInputs[inputIndex];
|
||||
fakeSlot.putStack(currentItem);
|
||||
inputIndex++;
|
||||
}
|
||||
InventoryCrafting craftingMatrix = getCraftingMatrix((ContainerExtremeAutoCrafter) container);
|
||||
if (craftingMatrix != null) {
|
||||
container.onCraftMatrixChanged(craftingMatrix);
|
||||
public static final class Handler implements IMessageHandler<PacketExtremeRecipe, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(PacketExtremeRecipe message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof ContainerExtremeAutoCrafter) {
|
||||
ItemStack[] recipeInputs = new ItemStack[81];
|
||||
NBTTagCompound currentStack;
|
||||
for (int i = 0; i < recipeInputs.length; i++) {
|
||||
currentStack = (NBTTagCompound) message.input.getTag("#" + i);
|
||||
recipeInputs[i] = currentStack == null ? null : ItemStack.loadItemStackFromNBT(currentStack);
|
||||
}
|
||||
int inputIndex = 0;
|
||||
for (int i = 81; i < 162; i++) {
|
||||
Slot fakeSlot = container.getSlot(i);
|
||||
ItemStack currentItem = recipeInputs[inputIndex];
|
||||
fakeSlot.putStack(currentItem);
|
||||
inputIndex++;
|
||||
}
|
||||
InventoryCrafting craftingMatrix = getCraftingMatrix((ContainerExtremeAutoCrafter) container);
|
||||
if (craftingMatrix != null) {
|
||||
container.onCraftMatrixChanged(craftingMatrix);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private InventoryCrafting getCraftingMatrix(ContainerExtremeAutoCrafter container) {
|
||||
Field tileEntityExtremeAutoCrafterField = ReflectionHelper.findField(ContainerExtremeAutoCrafter.class, "tileEntityExtremeAutoCrafter");
|
||||
TileEntityExtremeAutoCrafter tileEntityExtremeAutoCrafter = null;
|
||||
private InventoryCrafting getCraftingMatrix(ContainerExtremeAutoCrafter container) {
|
||||
Field tileEntityExtremeAutoCrafterField = ReflectionHelper.findField(ContainerExtremeAutoCrafter.class, "tileEntityExtremeAutoCrafter");
|
||||
TileEntityExtremeAutoCrafter tileEntityExtremeAutoCrafter = null;
|
||||
|
||||
try {
|
||||
tileEntityExtremeAutoCrafter = (TileEntityExtremeAutoCrafter) tileEntityExtremeAutoCrafterField.get(container);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (tileEntityExtremeAutoCrafter != null) {
|
||||
Field craftingMatrixField = ReflectionHelper.findField(TileEntityExtremeAutoCrafter.class, "craftingMatrix");
|
||||
InventoryCrafting craftingMatrix = null;
|
||||
try {
|
||||
craftingMatrix = (InventoryCrafting) craftingMatrixField.get(tileEntityExtremeAutoCrafter);
|
||||
tileEntityExtremeAutoCrafter = (TileEntityExtremeAutoCrafter) tileEntityExtremeAutoCrafterField.get(container);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return craftingMatrix;
|
||||
if (tileEntityExtremeAutoCrafter != null) {
|
||||
Field craftingMatrixField = ReflectionHelper.findField(TileEntityExtremeAutoCrafter.class, "craftingMatrix");
|
||||
InventoryCrafting craftingMatrix = null;
|
||||
try {
|
||||
craftingMatrix = (InventoryCrafting) craftingMatrixField.get(tileEntityExtremeAutoCrafter);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return craftingMatrix;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import javax.annotation.Nonnull;
|
||||
import static com.github.vfyjxf.nee.nei.NEECraftingHandler.OUTPUT_KEY;
|
||||
|
||||
|
||||
public class PacketNEIPatternRecipe implements IMessage, IMessageHandler<PacketNEIPatternRecipe, IMessage> {
|
||||
public class PacketNEIPatternRecipe implements IMessage{
|
||||
|
||||
NBTTagCompound input;
|
||||
NBTTagCompound output;
|
||||
@@ -56,21 +56,24 @@ public class PacketNEIPatternRecipe implements IMessage, IMessageHandler<PacketN
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketNEIPatternRecipe message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof ContainerPatternTerm && message.output == null) {
|
||||
((ContainerPatternTerm) container).getPatternTerminal().setCraftingRecipe(true);
|
||||
message.craftingTableRecipeHandler((ContainerPatternTerm) container, message);
|
||||
} else if (container instanceof ContainerPatternTerm) {
|
||||
((ContainerPatternTerm) container).getPatternTerminal().setCraftingRecipe(false);
|
||||
message.processRecipeHandler((ContainerPatternTerm) container, message);
|
||||
} else if (container instanceof ContainerPatternTermEx && message.output != null) {
|
||||
((ContainerPatternTermEx) container).getPatternTerminal().setInverted(false);
|
||||
message.processRecipeHandler((ContainerPatternTermEx) container, message);
|
||||
public static final class Handler implements IMessageHandler<PacketNEIPatternRecipe, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(PacketNEIPatternRecipe message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof ContainerPatternTerm && message.output == null) {
|
||||
((ContainerPatternTerm) container).getPatternTerminal().setCraftingRecipe(true);
|
||||
message.craftingTableRecipeHandler((ContainerPatternTerm) container, message);
|
||||
} else if (container instanceof ContainerPatternTerm) {
|
||||
((ContainerPatternTerm) container).getPatternTerminal().setCraftingRecipe(false);
|
||||
message.processRecipeHandler((ContainerPatternTerm) container, message);
|
||||
} else if (container instanceof ContainerPatternTermEx && message.output != null) {
|
||||
((ContainerPatternTermEx) container).getPatternTerminal().setInverted(false);
|
||||
message.processRecipeHandler((ContainerPatternTermEx) container, message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private void craftingTableRecipeHandler(ContainerPatternTerm container, PacketNEIPatternRecipe message) {
|
||||
@@ -211,4 +214,5 @@ public class PacketNEIPatternRecipe implements IMessage, IMessageHandler<PacketN
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import static com.github.vfyjxf.nee.nei.NEECraftingHandler.OUTPUT_KEY;
|
||||
import static com.github.vfyjxf.nee.network.NEEGuiHandler.CRAFTING_AMOUNT_ID;
|
||||
import static com.github.vfyjxf.nee.network.NEEGuiHandler.CRAFTING_AMOUNT_WIRELESS_ID;
|
||||
|
||||
public class PacketOpenCraftAmount implements IMessage, IMessageHandler<PacketOpenCraftAmount, IMessage> {
|
||||
public class PacketOpenCraftAmount implements IMessage{
|
||||
|
||||
private NBTTagCompound recipe;
|
||||
|
||||
@@ -42,48 +42,51 @@ public class PacketOpenCraftAmount implements IMessage, IMessageHandler<PacketOp
|
||||
ByteBufUtils.writeTag(buf, this.recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketOpenCraftAmount message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof ContainerCraftingTerm) {
|
||||
final ContainerOpenContext context = ((ContainerCraftingTerm) container).getOpenContext();
|
||||
if (context != null) {
|
||||
final TileEntity tile = context.getTile();
|
||||
public static final class Handler implements IMessageHandler<PacketOpenCraftAmount, IMessage>{
|
||||
@Override
|
||||
public IMessage onMessage(PacketOpenCraftAmount message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof ContainerCraftingTerm) {
|
||||
final ContainerOpenContext context = ((ContainerCraftingTerm) container).getOpenContext();
|
||||
if (context != null) {
|
||||
final TileEntity tile = context.getTile();
|
||||
|
||||
NEEGuiHandler.openGui(player, CRAFTING_AMOUNT_ID, tile, context.getSide());
|
||||
NEEGuiHandler.openGui(player, CRAFTING_AMOUNT_ID, tile, context.getSide());
|
||||
|
||||
if (player.openContainer instanceof ContainerCraftingAmount) {
|
||||
ContainerCraftingAmount cca = (ContainerCraftingAmount) player.openContainer;
|
||||
if (message.recipe != null) {
|
||||
NBTTagCompound tag = message.recipe.getCompoundTag(OUTPUT_KEY);
|
||||
ItemStack result = tag == null ? null : ItemStack.loadItemStackFromNBT(tag);
|
||||
if (result != null) {
|
||||
cca.setResultStack(result);
|
||||
cca.getResultSlot().putStack(result);
|
||||
cca.setRecipe(message.recipe);
|
||||
}
|
||||
}
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
} else if (GuiUtils.isWirelessCraftingTermContainer(container)) {
|
||||
|
||||
NEEGuiHandler.openGui(player, CRAFTING_AMOUNT_WIRELESS_ID, player.worldObj);
|
||||
|
||||
if (player.openContainer instanceof ContainerCraftingAmount) {
|
||||
ContainerCraftingAmount cca = (ContainerCraftingAmount) player.openContainer;
|
||||
if (message.recipe != null) {
|
||||
NBTTagCompound tag = message.recipe.getCompoundTag(OUTPUT_KEY);
|
||||
ItemStack result = tag == null ? null : ItemStack.loadItemStackFromNBT(tag);
|
||||
if (result != null) {
|
||||
cca.setResultStack(result);
|
||||
cca.getResultSlot().putStack(result);
|
||||
cca.setRecipe(message.recipe);
|
||||
}
|
||||
cca.setResultStack(result);
|
||||
cca.getResultSlot().putStack(result);
|
||||
cca.setRecipe(message.recipe);
|
||||
}
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
} else if (GuiUtils.isWirelessCraftingTermContainer(container)) {
|
||||
|
||||
NEEGuiHandler.openGui(player, CRAFTING_AMOUNT_WIRELESS_ID, player.worldObj);
|
||||
|
||||
if (player.openContainer instanceof ContainerCraftingAmount) {
|
||||
ContainerCraftingAmount cca = (ContainerCraftingAmount) player.openContainer;
|
||||
if (message.recipe != null) {
|
||||
NBTTagCompound tag = message.recipe.getCompoundTag(OUTPUT_KEY);
|
||||
ItemStack result = tag == null ? null : ItemStack.loadItemStackFromNBT(tag);
|
||||
cca.setResultStack(result);
|
||||
cca.getResultSlot().putStack(result);
|
||||
cca.setRecipe(message.recipe);
|
||||
}
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
||||
public class PacketOpenGui implements IMessage, IMessageHandler<PacketOpenGui, IMessage> {
|
||||
public class PacketOpenGui implements IMessage{
|
||||
|
||||
private int guiId;
|
||||
|
||||
@@ -34,17 +34,22 @@ public class PacketOpenGui implements IMessage, IMessageHandler<PacketOpenGui, I
|
||||
buf.writeInt(this.guiId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketOpenGui message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof AEBaseContainer) {
|
||||
final ContainerOpenContext context = ((AEBaseContainer) container).getOpenContext();
|
||||
if (context != null) {
|
||||
final TileEntity tile = context.getTile();
|
||||
NEEGuiHandler.openGui(player, message.guiId, tile, context.getSide());
|
||||
public static final class Handler implements IMessageHandler<PacketOpenGui, IMessage>{
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketOpenGui message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof AEBaseContainer) {
|
||||
final ContainerOpenContext context = ((AEBaseContainer) container).getOpenContext();
|
||||
if (context != null) {
|
||||
final TileEntity tile = context.getTile();
|
||||
NEEGuiHandler.openGui(player, message.guiId, tile, context.getSide());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import static com.github.vfyjxf.nee.nei.NEECraftingHandler.INPUT_KEY;
|
||||
import static com.github.vfyjxf.nee.nei.NEECraftingHandler.OUTPUT_KEY;
|
||||
import static com.github.vfyjxf.nee.nei.NEECraftingHelper.RECIPE_LENGTH;
|
||||
|
||||
public class PacketSetRecipe implements IMessage, IMessageHandler<PacketSetRecipe, IMessage> {
|
||||
public class PacketSetRecipe implements IMessage{
|
||||
|
||||
private NBTTagCompound recipe;
|
||||
|
||||
@@ -48,42 +48,46 @@ public class PacketSetRecipe implements IMessage, IMessageHandler<PacketSetRecip
|
||||
ByteBufUtils.writeTag(buf, this.recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketSetRecipe message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
public static final class Handler implements IMessageHandler<PacketSetRecipe, IMessage>{
|
||||
|
||||
if (container instanceof AEBaseContainer) {
|
||||
AEBaseContainer aeContainer = (AEBaseContainer) container;
|
||||
IGrid grid = getNetwork(aeContainer);
|
||||
if (grid != null) {
|
||||
for (IGridNode gridNode : grid.getMachines(TilePatternInterface.class)) {
|
||||
@Override
|
||||
public IMessage onMessage(PacketSetRecipe message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
|
||||
if (gridNode.getMachine() instanceof TilePatternInterface) {
|
||||
if (container instanceof AEBaseContainer) {
|
||||
AEBaseContainer aeContainer = (AEBaseContainer) container;
|
||||
IGrid grid = message.getNetwork(aeContainer);
|
||||
if (grid != null) {
|
||||
for (IGridNode gridNode : grid.getMachines(TilePatternInterface.class)) {
|
||||
|
||||
TilePatternInterface tpi = (TilePatternInterface) gridNode.getMachine();
|
||||
NBTTagCompound currentTag = message.recipe.getCompoundTag(OUTPUT_KEY);
|
||||
ItemStack result = currentTag == null ? null : ItemStack.loadItemStackFromNBT(currentTag);
|
||||
if (gridNode.getMachine() instanceof TilePatternInterface) {
|
||||
|
||||
if (tpi.getProxy().isActive() && tpi.canPutPattern(result)) {
|
||||
TilePatternInterface tpi = (TilePatternInterface) gridNode.getMachine();
|
||||
NBTTagCompound currentTag = message.recipe.getCompoundTag(OUTPUT_KEY);
|
||||
ItemStack result = currentTag == null ? null : ItemStack.loadItemStackFromNBT(currentTag);
|
||||
|
||||
ItemStack patternStack = getPatternStack(player, message.recipe);
|
||||
if (tpi.getProxy().isActive() && tpi.canPutPattern(result)) {
|
||||
|
||||
if (patternStack != null) {
|
||||
ItemStack patternStack = message.getPatternStack(player, message.recipe);
|
||||
|
||||
if (patternStack != null) {
|
||||
|
||||
// if (tpi.putPattern(patternStack)) {
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IGrid getNetwork(AEBaseContainer container) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class PacketSlotStackChange implements IMessage, IMessageHandler<PacketSlotStackChange, IMessage> {
|
||||
public class PacketSlotStackChange implements IMessage{
|
||||
|
||||
private ItemStack stack;
|
||||
private List<Integer> craftingSlots;
|
||||
@@ -57,18 +57,21 @@ public class PacketSlotStackChange implements IMessage, IMessageHandler<PacketSl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketSlotStackChange message, MessageContext ctx) {
|
||||
Container container = ctx.getServerHandler().playerEntity.openContainer;
|
||||
ItemStack nextStack = message.getStack();
|
||||
if (nextStack != null) {
|
||||
for (Integer craftingSlot : message.getCraftingSlots()) {
|
||||
Slot currentSlot = container.getSlot(craftingSlot);
|
||||
if (currentSlot != null) {
|
||||
currentSlot.putStack(nextStack);
|
||||
public static final class Handler implements IMessageHandler<PacketSlotStackChange, IMessage>{
|
||||
@Override
|
||||
public IMessage onMessage(PacketSlotStackChange message, MessageContext ctx) {
|
||||
Container container = ctx.getServerHandler().playerEntity.openContainer;
|
||||
ItemStack nextStack = message.getStack();
|
||||
if (nextStack != null) {
|
||||
for (Integer craftingSlot : message.getCraftingSlots()) {
|
||||
Slot currentSlot = container.getSlot(craftingSlot);
|
||||
if (currentSlot != null) {
|
||||
currentSlot.putStack(nextStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.item.ItemStack;
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class PacketStackCountChange implements IMessage, IMessageHandler<PacketStackCountChange, IMessage> {
|
||||
public class PacketStackCountChange implements IMessage {
|
||||
|
||||
private int slotIndex;
|
||||
private int changeCount;
|
||||
@@ -48,32 +48,35 @@ public class PacketStackCountChange implements IMessage, IMessageHandler<PacketS
|
||||
buf.writeInt(this.changeCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketStackCountChange message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof AEBaseContainer) {
|
||||
handleMessage(message, container);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handleMessage(PacketStackCountChange message, Container container) {
|
||||
|
||||
if (container instanceof ContainerPatternTerm && ((ContainerPatternTerm) container).isCraftingMode()) {
|
||||
return;
|
||||
public static final class Handler implements IMessageHandler<PacketStackCountChange, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(PacketStackCountChange message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof AEBaseContainer) {
|
||||
handleMessage(message, container);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Slot currentSlot = container.getSlot(message.getSlotIndex());
|
||||
for (int i = 0; i < Math.abs(message.getChangeCount()); i++) {
|
||||
int currentStackSize = message.getChangeCount() > 0 ? currentSlot.getStack().stackSize + 1 : currentSlot.getStack().stackSize - 1;
|
||||
if (currentStackSize <= currentSlot.getStack().getMaxStackSize() && currentStackSize > 0) {
|
||||
ItemStack nextStack = currentSlot.getStack().copy();
|
||||
nextStack.stackSize = currentStackSize;
|
||||
currentSlot.putStack(nextStack);
|
||||
} else {
|
||||
break;
|
||||
private void handleMessage(PacketStackCountChange message, Container container) {
|
||||
|
||||
if (container instanceof ContainerPatternTerm && ((ContainerPatternTerm) container).isCraftingMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Slot currentSlot = container.getSlot(message.getSlotIndex());
|
||||
for (int i = 0; i < Math.abs(message.getChangeCount()); i++) {
|
||||
int currentStackSize = message.getChangeCount() > 0 ? currentSlot.getStack().stackSize + 1 : currentSlot.getStack().stackSize - 1;
|
||||
if (currentStackSize <= currentSlot.getStack().getMaxStackSize() && currentStackSize > 0) {
|
||||
ItemStack nextStack = currentSlot.getStack().copy();
|
||||
nextStack.stackSize = currentStackSize;
|
||||
currentSlot.putStack(nextStack);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,15 +3,21 @@ package com.github.vfyjxf.nee.network.packet;
|
||||
import codechicken.nei.recipe.GuiRecipe;
|
||||
import com.github.vfyjxf.nee.nei.NEECraftingHelper;
|
||||
import com.github.vfyjxf.nee.utils.GuiUtils;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
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.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class PacketValueConfigClient implements IMessage, IMessageHandler<PacketValueConfigClient, IMessage> {
|
||||
/**
|
||||
* @author vfyjxf
|
||||
*/
|
||||
public class PacketValueConfigClient implements IMessage {
|
||||
|
||||
|
||||
private String name;
|
||||
@@ -43,17 +49,28 @@ public class PacketValueConfigClient implements IMessage, IMessageHandler<Packet
|
||||
ByteBufUtils.writeUTF8String(buf, this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketValueConfigClient message, MessageContext ctx) {
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if ("PatternInterface.check".equals(message.name) && Boolean.parseBoolean(message.value)) {
|
||||
if (gui instanceof GuiRecipe) {
|
||||
GuiRecipe guiRecipe = (GuiRecipe) gui;
|
||||
if (GuiUtils.isGuiCraftingTerm(guiRecipe.firstGui)) {
|
||||
NEECraftingHelper.setIsPatternInterfaceExists(true);
|
||||
public static final class Handler implements IMessageHandler<PacketValueConfigClient, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(PacketValueConfigClient message, MessageContext ctx) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
handMessage(message, ctx);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void handMessage(PacketValueConfigClient message, MessageContext ctx) {
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if ("PatternInterface.check".equals(message.name)) {
|
||||
if (gui instanceof GuiRecipe) {
|
||||
GuiRecipe guiRecipe = (GuiRecipe) gui;
|
||||
if (GuiUtils.isGuiCraftingTerm(guiRecipe.firstGui)) {
|
||||
boolean value = Boolean.parseBoolean(message.value);
|
||||
NEECraftingHelper.setIsPatternInterfaceExists(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.inventory.Slot;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
|
||||
public class PacketValueConfigServer implements IMessage, IMessageHandler<PacketValueConfigServer, IMessage> {
|
||||
public class PacketValueConfigServer implements IMessage{
|
||||
|
||||
private String name;
|
||||
private String value;
|
||||
@@ -51,47 +51,51 @@ public class PacketValueConfigServer implements IMessage, IMessageHandler<Packet
|
||||
ByteBufUtils.writeUTF8String(buf, this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketValueConfigServer message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
public static final class Handler implements IMessageHandler<PacketValueConfigServer, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(PacketValueConfigServer message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
Container container = player.openContainer;
|
||||
|
||||
if ("Container.selectedSlot".equals(message.name)) {
|
||||
if (container instanceof ContainerPatternInterface) {
|
||||
ContainerPatternInterface cpc = (ContainerPatternInterface) container;
|
||||
int slotIndex = Integer.parseInt(message.value);
|
||||
Slot slot = container.getSlot(slotIndex);
|
||||
if (slot instanceof SlotRestrictedInput) {
|
||||
cpc.setSelectedSlotIndex(slot.slotNumber);
|
||||
if ("Container.selectedSlot".equals(message.name)) {
|
||||
if (container instanceof ContainerPatternInterface) {
|
||||
ContainerPatternInterface cpc = (ContainerPatternInterface) container;
|
||||
int slotIndex = Integer.parseInt(message.value);
|
||||
Slot slot = container.getSlot(slotIndex);
|
||||
if (slot instanceof SlotRestrictedInput) {
|
||||
cpc.setSelectedSlotIndex(slot.slotNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ("Gui.PatternInterface".equals(message.name)) {
|
||||
if (container instanceof ContainerPatternInterface) {
|
||||
ContainerPatternInterface cpc = (ContainerPatternInterface) container;
|
||||
TilePatternInterface tile = (TilePatternInterface) cpc.getTileEntity();
|
||||
tile.cancelWork(cpc.getSelectedSlotIndex());
|
||||
cpc.removeCurrentRecipe();
|
||||
tile.updateCraftingList();
|
||||
}
|
||||
} else if ("PatternInterface.check".equals(message.name)) {
|
||||
if (container instanceof AEBaseContainer || GuiUtils.isWirelessCraftingTermContainer(container)) {
|
||||
IGrid grid = container instanceof AEBaseContainer ? getNetwork((AEBaseContainer) container) : getNetwork((ContainerWirelessCraftingTerminal) container);
|
||||
if (grid != null) {
|
||||
} else if ("Gui.PatternInterface".equals(message.name)) {
|
||||
if (container instanceof ContainerPatternInterface) {
|
||||
ContainerPatternInterface cpc = (ContainerPatternInterface) container;
|
||||
TilePatternInterface tile = (TilePatternInterface) cpc.getTileEntity();
|
||||
tile.cancelWork(cpc.getSelectedSlotIndex());
|
||||
cpc.removeCurrentRecipe();
|
||||
tile.updateCraftingList();
|
||||
}
|
||||
} else if ("PatternInterface.check".equals(message.name)) {
|
||||
if (container instanceof AEBaseContainer || GuiUtils.isWirelessCraftingTermContainer(container)) {
|
||||
IGrid grid = container instanceof AEBaseContainer ? message.getNetwork((AEBaseContainer) container) : message.getNetwork((ContainerWirelessCraftingTerminal) container);
|
||||
if (grid != null) {
|
||||
|
||||
for (IGridNode gridNode : grid.getMachines(TilePatternInterface.class)) {
|
||||
for (IGridNode gridNode : grid.getMachines(TilePatternInterface.class)) {
|
||||
|
||||
if (gridNode.getMachine() instanceof TilePatternInterface) {
|
||||
NEENetworkHandler.getInstance().sendTo(new PacketValueConfigClient("PatternInterface.check", "true"), player);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (gridNode.getMachine() instanceof TilePatternInterface) {
|
||||
NEENetworkHandler.getInstance().sendTo(new PacketValueConfigClient("PatternInterface.check", "true"), player);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
NEENetworkHandler.getInstance().sendTo(new PacketValueConfigClient("PatternInterface.check", "false"), player);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IGrid getNetwork(AEBaseContainer container) {
|
||||
|
||||
Reference in new issue
Block a user