Skip to content

Commit

Permalink
Merge remote-tracking branch 'Laiff/feature/level-maintainer-terminal…
Browse files Browse the repository at this point in the history
…' into dev

# Conflicts:
#	dependencies.gradle
  • Loading branch information
Dream-Master committed Oct 17, 2023
2 parents 7ae478a + 75a06d0 commit fa8d112
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.features.AEFeature;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketNEIDragClick;
import codechicken.nei.VisiblityData;
Expand Down Expand Up @@ -130,6 +133,12 @@ public void postUpdate(List<IAEItemStack> list) {
}
for (IAEItemStack is : list) {
NBTTagCompound data = is.getItemStack().getTagCompound();
if (data == null) {
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info("Received empty configuration: ", is);
}
continue;
}
long batch = data.getLong(TLMTags.Batch.tagName);
long quantity = data.getLong(TLMTags.Quantity.tagName);
int idx = data.getInteger(TLMTags.Index.tagName);
Expand Down Expand Up @@ -225,6 +234,7 @@ public boolean drawSlot0(Slot slot) {
fake.setStackSize(0);
}
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.setAeStack(fake);
aeRenderItem.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
Expand Down Expand Up @@ -344,9 +354,11 @@ private Rectangle getSlotArea(SlotFake slot) {

@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
for (SlotFluidConvertingFake slot : this.cont.getRequestSlots()) {
for (int i = 0; i < this.cont.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.cont.getRequestSlots()[i];
if (getSlotArea(slot).contains(mouseX, mouseY)) {
ItemStack itemStack = createLevelValues(draggedStack.copy());
itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putStack(itemStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(itemStack, slot.getSlotIndex()));
this.updateAmount(slot.getSlotIndex(), itemStack.stackSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ private int drawEntry(LevelTerminalEntry entry, int viewY, int titleBottom, int
&& relMouseY < Math.min(viewY + rowYBot, viewHeight);
if (stack != null) {

AEItemStack aeItemStack = AEItemStack.create(stack);
NBTTagCompound data = stack.getTagCompound();
ItemStack itemStack = data.hasKey(TLMTags.Stack.tagName)
? ItemStack.loadItemStackFromNBT(data.getCompoundTag(TLMTags.Stack.tagName))
Expand All @@ -581,15 +582,18 @@ private int drawEntry(LevelTerminalEntry entry, int viewY, int titleBottom, int
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
aeRenderItem.setAeStack(null);
aeItemStack.setStackSize(1);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem.zLevel = 3.0f - 50.0f;
aeRenderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
aeRenderItem.zLevel = 0.0f;
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
itemStack.stackSize = (int) quantity;
aeItemStack.setStackSize(quantity);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
if (batch > 0) {
itemStack.stackSize = (int) batch;
aeItemStack.setStackSize(batch);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem
.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, -11);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,13 @@ public ItemStack transferStackInSlot(EntityPlayer player, int idx) {
return null;
}

for (SlotFluidConvertingFake slot : this.getRequestSlots()) {
for (int i = 0; i < this.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.getRequestSlots()[i];
if (!slot.getHasStack()) {
ItemStack itemStack = ((Slot) this.inventorySlots.get(idx)).getStack();
slot.putConvertedStack(createLevelValues(itemStack.copy()));
ItemStack configuration = createLevelValues(itemStack.copy());
configuration.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putConvertedStack(configuration);
break;
}
}
Expand Down Expand Up @@ -140,6 +143,9 @@ public static ItemStack createLevelValues(ItemStack itemStack) {
if (!data.hasKey(TLMTags.Enable.tagName)) {
data.setBoolean(TLMTags.Enable.tagName, false);
}
if (data.hasKey(TLMTags.Index.tagName)) {
data.removeTag(TLMTags.Index.tagName);
}

data.setInteger(TLMTags.State.tagName, State.None.ordinal());
itemStack.setTagCompound(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,9 @@ public long getBatchSize(int idx) {
public IAEItemStack getCraftItem(int idx) {
IAEItemStack is = requestStacks.getStack(idx);
if (is == null) return null;
if (is.getItemStack() == null) return null;
ItemStack qis = loadItemStackFromTag(is.getItemStack());
if (qis == null) return null;
IAEItemStack qais = AEItemStack.create(qis);
qais.setStackSize(getBatchSize(idx));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import javax.annotation.Nullable;

Expand All @@ -16,7 +18,9 @@

import com.glodblock.github.client.gui.GuiLevelTerminal;

import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.features.AEFeature;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
Expand Down Expand Up @@ -45,6 +49,21 @@ public void fromBytes(ByteBuf buf) {
int numEntries = buf.readInt();

for (int i = 0; i < numEntries; ++i) {
if (buf.readableBytes() == 0) {
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info(
"Corrupted packet commands: (" + i
+ ") of ("
+ numEntries
+ ") -> "
+ this.commands.size()
+ " : "
+ this.commands.stream().map(packetEntry -> packetEntry.getClass().getSimpleName())
.collect(Collectors.groupingBy(String::new, Collectors.counting())));
AELog.info("Parsed content: -> " + this.commands);
}
return;
}
PacketType type = PacketType.values()[buf.readByte()];

try {
Expand Down Expand Up @@ -135,6 +154,14 @@ public IMessage onMessage(SPacketLevelTerminalUpdate message, MessageContext ctx
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;

if (gs instanceof GuiLevelTerminal levelTerminal) {
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info(
"Received commands -> " + message.commands.size()
+ " : "
+ message.commands.stream()
.map(packetEntry -> packetEntry.getClass().getSimpleName())
.collect(Collectors.groupingBy(String::new, Collectors.counting())));
}
levelTerminal.postUpdate(message.commands, message.statusFlags);
}

Expand Down Expand Up @@ -282,6 +309,38 @@ protected void read(ByteBuf buf) throws IOException {
this.items = payload.getTagList("data", NBT.TAG_COMPOUND);
}
}

@Override
public String toString() {
return "PacketAdd{" + "name='"
+ name
+ '\''
+ ", x="
+ x
+ ", y="
+ y
+ ", z="
+ z
+ ", dim="
+ dim
+ ", side="
+ side
+ ", rows="
+ rows
+ ", rowSize="
+ rowSize
+ ", online="
+ online
+ ", selfItemStack="
+ selfItemStack
+ ", displayItemStack="
+ displayItemStack
+ ", items="
+ items
+ ", entryId="
+ entryId
+ '}';
}
}

public static class PacketRemove extends PacketEntry {
Expand All @@ -302,6 +361,11 @@ protected void write(ByteBuf buf) {

@Override
protected void read(ByteBuf buf) {}

@Override
public String toString() {
return "PacketRemove{" + "entryId=" + entryId + '}';
}
}

/**
Expand Down Expand Up @@ -417,6 +481,25 @@ protected void read(ByteBuf buf) throws IOException {
}
}
}

@Override
public String toString() {
return "PacketOverwrite{" + "onlineValid="
+ onlineValid
+ ", online="
+ online
+ ", itemsValid="
+ itemsValid
+ ", allItemUpdate="
+ allItemUpdate
+ ", validIndices="
+ Arrays.toString(validIndices)
+ ", items="
+ items
+ ", entryId="
+ entryId
+ '}';
}
}

/**
Expand Down Expand Up @@ -446,5 +529,10 @@ protected void write(ByteBuf buf) {
protected void read(ByteBuf buf) {
newName = ByteBufUtils.readUTF8String(buf);
}

@Override
public String toString() {
return "PacketRename{" + "newName='" + newName + '\'' + ", entryId=" + entryId + '}';
}
}
}

0 comments on commit fa8d112

Please sign in to comment.