spotless apply

This commit is contained in:
asdflj committed 2022-12-05 14:41:36 +08:00
1 parent 6acf2bace1
commit 5e31096c7e
191 files changed
+5046 -5165

No files matched your search

@@ -17,23 +17,21 @@ 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 io.netty.buffer.ByteBuf;
import java.util.Objects;
import java.util.concurrent.Future;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import javax.annotation.Nullable;
import java.util.Objects;
import java.util.concurrent.Future;
public class CPacketCraftRequest implements IMessage {
private long amount;
private boolean heldShift;
public CPacketCraftRequest() {
}
public CPacketCraftRequest() {}
public CPacketCraftRequest( final int craftAmt, final boolean shift ) {
public CPacketCraftRequest(final int craftAmt, final boolean shift) {
amount = craftAmt;
heldShift = shift;
}
@@ -55,64 +53,60 @@ public class CPacketCraftRequest implements IMessage {
@Nullable
@Override
public IMessage onMessage(CPacketCraftRequest message, MessageContext ctx) {
if( ctx.getServerHandler().playerEntity.openContainer instanceof ContainerCraftAmount)
{
if (ctx.getServerHandler().playerEntity.openContainer instanceof ContainerCraftAmount) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
final ContainerCraftAmount cca = (ContainerCraftAmount) ctx.getServerHandler().playerEntity.openContainer;
final ContainerCraftAmount cca =
(ContainerCraftAmount) ctx.getServerHandler().playerEntity.openContainer;
final Object target = cca.getTarget();
if( target instanceof IGridHost)
{
if (target instanceof IGridHost) {
final IGridHost gh = (IGridHost) target;
final IGridNode gn = gh.getGridNode( ForgeDirection.UNKNOWN );
final IGridNode gn = gh.getGridNode(ForgeDirection.UNKNOWN);
if( gn == null )
{
if (gn == null) {
return null;
}
final IGrid g = gn.getGrid();
if( g == null || cca.getItemToCraft() == null )
{
if (g == null || cca.getItemToCraft() == null) {
return null;
}
cca.getItemToCraft().setStackSize( message.amount );
cca.getItemToCraft().setStackSize(message.amount);
Future<ICraftingJob> futureJob = null;
try
{
final ICraftingGrid cg = g.getCache( ICraftingGrid.class );
futureJob = cg.beginCraftingJob( cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.getItemToCraft(), null );
try {
final ICraftingGrid cg = g.getCache(ICraftingGrid.class);
futureJob = cg.beginCraftingJob(
cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.getItemToCraft(), null);
final ContainerOpenContext context = cca.getOpenContext();
if( context != null )
{
if (context != null) {
final TileEntity te = context.getTile();
InventoryHandler.openGui(player, player.worldObj, new BlockPos(te), Objects.requireNonNull(Util.from(context.getSide())), GuiType.FLUID_CRAFTING_CONFIRM);
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(te),
Objects.requireNonNull(Util.from(context.getSide())),
GuiType.FLUID_CRAFTING_CONFIRM);
if( player.openContainer instanceof ContainerFluidCraftConfirm)
{
final ContainerFluidCraftConfirm ccc = (ContainerFluidCraftConfirm) player.openContainer;
ccc.setAutoStart( message.heldShift );
ccc.setJob( futureJob );
if (player.openContainer instanceof ContainerFluidCraftConfirm) {
final ContainerFluidCraftConfirm ccc =
(ContainerFluidCraftConfirm) player.openContainer;
ccc.setAutoStart(message.heldShift);
ccc.setJob(futureJob);
cca.detectAndSendChanges();
}
}
}
catch( final Throwable e )
{
if( futureJob != null )
{
futureJob.cancel( true );
} catch (final Throwable e) {
if (futureJob != null) {
futureJob.cancel(true);
}
AELog.debug( e );
AELog.debug(e);
}
}
}
return null;
}
}
}
@@ -5,9 +5,8 @@ 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 io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP;
public class CPacketDumpTank implements IMessage {
@@ -38,11 +37,9 @@ public class CPacketDumpTank implements IMessage {
public IMessage onMessage(CPacketDumpTank message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
if (player.openContainer instanceof TankDumpable) {
((TankDumpable)player.openContainer).dumpTank(message.index);
((TankDumpable) player.openContainer).dumpTank(message.index);
}
return null;
}
}
}
@@ -5,9 +5,8 @@ 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 io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP;
public class CPacketEncodePattern implements IMessage {
@@ -28,11 +27,9 @@ public class CPacketEncodePattern implements IMessage {
public IMessage onMessage(CPacketEncodePattern message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
if (player.openContainer instanceof ContainerFluidPatternEncoder) {
((ContainerFluidPatternEncoder)player.openContainer).encodePattern();
((ContainerFluidPatternEncoder) player.openContainer).encodePattern();
}
return null;
}
}
}
@@ -14,12 +14,12 @@ public class CPacketFluidPatternTermBtns implements IMessage {
private String Name = "";
private String Value = "";
public CPacketFluidPatternTermBtns( final String name, final String value ) {
public CPacketFluidPatternTermBtns(final String name, final String value) {
Name = name;
Value = value;
}
public CPacketFluidPatternTermBtns( final String name, final Integer value ) {
public CPacketFluidPatternTermBtns(final String name, final Integer value) {
Name = name;
Value = value.toString();
}
@@ -33,12 +33,12 @@ public class CPacketFluidPatternTermBtns implements IMessage {
int leName = buf.readInt();
int leVal = buf.readInt();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < leName; i ++) {
for (int i = 0; i < leName; i++) {
sb.append(buf.readChar());
}
Name = sb.toString();
sb = new StringBuilder();
for (int i = 0; i < leVal; i ++) {
for (int i = 0; i < leVal; i++) {
sb.append(buf.readChar());
}
Value = sb.toString();
@@ -48,10 +48,10 @@ public class CPacketFluidPatternTermBtns implements IMessage {
public void toBytes(ByteBuf buf) {
buf.writeInt(Name.length());
buf.writeInt(Value.length());
for (int i = 0; i < Name.length(); i ++) {
for (int i = 0; i < Name.length(); i++) {
buf.writeChar(Name.charAt(i));
}
for (int i = 0; i < Value.length(); i ++) {
for (int i = 0; i < Value.length(); i++) {
buf.writeChar(Value.charAt(i));
}
}
@@ -63,8 +63,7 @@ public class CPacketFluidPatternTermBtns implements IMessage {
String Name = message.Name;
String Value = message.Value;
final Container c = ctx.getServerHandler().playerEntity.openContainer;
if( Name.startsWith( "PatternTerminal." ) && (c instanceof ContainerFluidPatternTerminal))
{
if (Name.startsWith("PatternTerminal.") && (c instanceof ContainerFluidPatternTerminal)) {
final ContainerFluidPatternTerminal cpt = (ContainerFluidPatternTerminal) c;
switch (Name) {
case "PatternTerminal.CraftMode":
@@ -99,8 +98,7 @@ public class CPacketFluidPatternTermBtns implements IMessage {
cpt.getPatternTerminal().setBeSubstitute(Value.equals("1"));
break;
}
} else if( Name.startsWith( "PatternTerminalEx." ) && (c instanceof ContainerFluidPatternTerminalEx))
{
} else if (Name.startsWith("PatternTerminalEx.") && (c instanceof ContainerFluidPatternTerminalEx)) {
final ContainerFluidPatternTerminalEx cpt = (ContainerFluidPatternTerminalEx) c;
switch (Name) {
case "PatternTerminalEx.Encode":
@@ -141,16 +139,14 @@ public class CPacketFluidPatternTermBtns implements IMessage {
cpt.getPatternTerminal().setBeSubstitute(Value.equals("1"));
break;
}
} else if(Name.equals( "Terminal.Cpu" ) && c instanceof ContainerFluidCraftConfirm) {
} else if (Name.equals("Terminal.Cpu") && c instanceof ContainerFluidCraftConfirm) {
final ContainerFluidCraftConfirm qk = (ContainerFluidCraftConfirm) c;
qk.cycleCpu( Value.equals( "Next" ) );
}
else if( Name.equals( "Terminal.Start" ) && c instanceof ContainerFluidCraftConfirm ) {
qk.cycleCpu(Value.equals("Next"));
} else if (Name.equals("Terminal.Start") && c instanceof ContainerFluidCraftConfirm) {
final ContainerFluidCraftConfirm qk = (ContainerFluidCraftConfirm) c;
qk.startJob();
}
return null;
}
}
}
@@ -8,14 +8,13 @@ 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 io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
public class CPacketFluidUpdate implements IMessage {
@@ -23,8 +22,7 @@ public class CPacketFluidUpdate implements IMessage {
private ItemStack itemStack;
private int slotIndex;
public CPacketFluidUpdate() {
}
public CPacketFluidUpdate() {}
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data, ItemStack itemStack) {
this.list = data;
@@ -50,8 +48,7 @@ public class CPacketFluidUpdate implements IMessage {
for (int i = 0; i < size; i++) {
int id = buf.readInt();
boolean isNull = buf.readBoolean();
if (!isNull)
list.put(id, null);
if (!isNull) list.put(id, null);
else {
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(buf);
list.put(id, fluid);
@@ -73,8 +70,7 @@ public class CPacketFluidUpdate implements IMessage {
try {
for (Map.Entry<Integer, IAEFluidStack> fs : list.entrySet()) {
buf.writeInt(fs.getKey());
if (fs.getValue() == null)
buf.writeBoolean(false);
if (fs.getValue() == null) buf.writeBoolean(false);
else {
buf.writeBoolean(true);
fs.getValue().writeToPacket(buf);
@@ -100,10 +96,14 @@ public class CPacketFluidUpdate implements IMessage {
EntityPlayer player = ctx.getServerHandler().playerEntity;
if (container instanceof FCBaseFluidMonitorContain) {
ItemStack item = player.inventory.getItemStack();
((FCBaseFluidMonitorContain) container).postChange(new ArrayList<IAEFluidStack>(message.list.values()), message.itemStack == null ? item : message.itemStack, player, message.slotIndex);
((FCBaseFluidMonitorContain) container)
.postChange(
new ArrayList<IAEFluidStack>(message.list.values()),
message.itemStack == null ? item : message.itemStack,
player,
message.slotIndex);
}
return null;
}
}
}
@@ -4,9 +4,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerOpenContext;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.core.sync.GuiBridge;
import appeng.helpers.InventoryAction;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
import com.glodblock.github.inventory.InventoryHandler;
@@ -17,12 +15,11 @@ 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 io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Objects;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
public class CPacketInventoryAction implements IMessage {
@@ -32,10 +29,9 @@ public class CPacketInventoryAction implements IMessage {
private IAEItemStack stack;
private boolean isEmpty;
public CPacketInventoryAction() {
}
public CPacketInventoryAction() {}
public CPacketInventoryAction( final InventoryAction action, final int slot, final int id ) {
public CPacketInventoryAction(final InventoryAction action, final int slot, final int id) {
this.action = action;
this.slot = slot;
this.id = id;
@@ -43,7 +39,7 @@ public class CPacketInventoryAction implements IMessage {
this.isEmpty = true;
}
public CPacketInventoryAction(final InventoryAction action, final int slot, final int id , IAEItemStack stack) {
public CPacketInventoryAction(final InventoryAction action, final int slot, final int id, IAEItemStack stack) {
this.action = action;
this.slot = slot;
this.id = id;
@@ -87,57 +83,58 @@ public class CPacketInventoryAction implements IMessage {
@Override
public IMessage onMessage(CPacketInventoryAction message, MessageContext ctx) {
final EntityPlayerMP sender = ctx.getServerHandler().playerEntity;
if( sender.openContainer instanceof AEBaseContainer )
{
if (sender.openContainer instanceof AEBaseContainer) {
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
if( message.action == InventoryAction.AUTO_CRAFT )
{
if (message.action == InventoryAction.AUTO_CRAFT) {
final ContainerOpenContext context = baseContainer.getOpenContext();
if( context != null )
{
if (context != null) {
final TileEntity te = context.getTile();
InventoryHandler.openGui( sender, te.getWorldObj(), new BlockPos(te), Objects.requireNonNull(Util.from(baseContainer.getOpenContext().getSide())), GuiType.FLUID_CRAFTING_AMOUNT );
InventoryHandler.openGui(
sender,
te.getWorldObj(),
new BlockPos(te),
Objects.requireNonNull(
Util.from(baseContainer.getOpenContext().getSide())),
GuiType.FLUID_CRAFTING_AMOUNT);
if( sender.openContainer instanceof ContainerCraftAmount )
{
if (sender.openContainer instanceof ContainerCraftAmount) {
final ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
if( baseContainer.getTargetStack() != null )
{
cca.getCraftingItem().putStack( baseContainer.getTargetStack().getItemStack() );
cca.setItemToCraft( baseContainer.getTargetStack() );
if (baseContainer.getTargetStack() != null) {
cca.getCraftingItem()
.putStack(baseContainer.getTargetStack().getItemStack());
cca.setItemToCraft(baseContainer.getTargetStack());
}
cca.detectAndSendChanges();
}
}
}else if (message.action == InventoryAction.valueOf("SET_PATTERN_VALUE"))
{
} else if (message.action == InventoryAction.valueOf("SET_PATTERN_VALUE")) {
final ContainerOpenContext context = baseContainer.getOpenContext();
if( context != null )
{
if (context != null) {
final TileEntity te = context.getTile();
InventoryHandler.openGui(sender, te.getWorldObj(), new BlockPos(te), Objects.requireNonNull(Util.from(baseContainer.getOpenContext().getSide())), GuiType.PATTERN_VALUE_SET );
if( sender.openContainer instanceof ContainerPatternValueAmount)
{
InventoryHandler.openGui(
sender,
te.getWorldObj(),
new BlockPos(te),
Objects.requireNonNull(
Util.from(baseContainer.getOpenContext().getSide())),
GuiType.PATTERN_VALUE_SET);
if (sender.openContainer instanceof ContainerPatternValueAmount) {
final ContainerPatternValueAmount cpv = (ContainerPatternValueAmount) sender.openContainer;
if( baseContainer.getTargetStack() != null )
{
cpv.setValueIndex( message.slot );
cpv.getPatternValue().putStack( baseContainer.getTargetStack().getItemStack() );
if (baseContainer.getTargetStack() != null) {
cpv.setValueIndex(message.slot);
cpv.getPatternValue()
.putStack(baseContainer.getTargetStack().getItemStack());
}
cpv.detectAndSendChanges();
}
}
}
else
{
baseContainer.doAction( sender, message.action, message.slot, message.id );
} else {
baseContainer.doAction(sender, message.action, message.slot, message.id);
}
}
return null;
}
}
}
@@ -9,20 +9,18 @@ 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 io.netty.buffer.ByteBuf;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nullable;
public class CPacketLevelMaintainer implements IMessage {
private String action;
private long size;
private int slotIndex;
public CPacketLevelMaintainer() {
}
public CPacketLevelMaintainer() {}
public CPacketLevelMaintainer(String action, int slotIndex) {
this.action = action;
@@ -104,9 +102,11 @@ public class CPacketLevelMaintainer implements IMessage {
@Nullable
@Override
public IMessage onMessage(CPacketLevelMaintainer message, MessageContext ctx) {
if (message.action.startsWith("TileLevelMaintainer.") && ctx.getServerHandler().playerEntity.openContainer instanceof ContainerLevelMaintainer) {
if (message.action.startsWith("TileLevelMaintainer.")
&& ctx.getServerHandler().playerEntity.openContainer instanceof ContainerLevelMaintainer) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
final ContainerLevelMaintainer cca = (ContainerLevelMaintainer) ctx.getServerHandler().playerEntity.openContainer;
final ContainerLevelMaintainer cca =
(ContainerLevelMaintainer) ctx.getServerHandler().playerEntity.openContainer;
switch (message.action) {
case "TileLevelMaintainer.Quantity":
cca.getTile().updateQuantity(message.slotIndex, message.size);
@@ -14,26 +14,22 @@ 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 io.netty.buffer.ByteBuf;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
import java.util.Objects;
public class CPacketPatternValueSet implements IMessage {
private GuiType originGui;
private int amount;
private int valueIndex;
public CPacketPatternValueSet() {
public CPacketPatternValueSet() {}
}
public CPacketPatternValueSet( int originalGui, int amount, int valueIndex ){
public CPacketPatternValueSet(int originalGui, int amount, int valueIndex) {
this.originGui = GuiType.getByOrdinal(originalGui);
this.amount = amount;
this.valueIndex = valueIndex;
@@ -65,15 +61,22 @@ public class CPacketPatternValueSet implements IMessage {
final ContainerOpenContext context = cpv.getOpenContext();
if (context != null) {
final TileEntity te = context.getTile();
InventoryHandler.openGui(player, player.worldObj, new BlockPos(te), Objects.requireNonNull(Util.from(context.getSide())), message.originGui);
if (player.openContainer instanceof ContainerFluidPatternTerminal || player.openContainer instanceof ContainerFluidPatternTerminalEx) {
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(te),
Objects.requireNonNull(Util.from(context.getSide())),
message.originGui);
if (player.openContainer instanceof ContainerFluidPatternTerminal
|| player.openContainer instanceof ContainerFluidPatternTerminalEx) {
Slot slot = player.openContainer.getSlot(message.valueIndex);
if (slot != null && slot.getHasStack()) {
ItemStack stack = slot.getStack().copy();
if (Util.isFluidPacket(stack)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(stack);
if (fluidStack != null) {
fluidStack = ItemFluidPacket.getFluidStack(stack).copy();
fluidStack = ItemFluidPacket.getFluidStack(stack)
.copy();
fluidStack.amount = message.amount;
}
slot.putStack(ItemFluidPacket.newStack(fluidStack));
@@ -82,13 +85,11 @@ public class CPacketPatternValueSet implements IMessage {
slot.putStack(stack);
}
}
}
}
}
}
return null;
}
}
}
@@ -7,16 +7,14 @@ 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 io.netty.buffer.ByteBuf;
import net.minecraft.inventory.Container;
import java.io.IOException;
import net.minecraft.inventory.Container;
public class CPacketSetTargetItem implements IMessage {
private IAEItemStack stack;
public CPacketSetTargetItem() {
}
public CPacketSetTargetItem() {}
public CPacketSetTargetItem(IAEItemStack stack) {
this.stack = stack;
@@ -50,7 +48,5 @@ public class CPacketSetTargetItem implements IMessage {
}
return null;
}
}
}
@@ -10,13 +10,12 @@ 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 io.netty.buffer.ByteBuf;
import java.util.Objects;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import javax.annotation.Nullable;
import java.util.Objects;
public class CPacketSwitchGuis implements IMessage {
private GuiType guiType;
@@ -51,7 +50,7 @@ public class CPacketSwitchGuis implements IMessage {
if (!(cont instanceof AEBaseContainer)) {
return null;
}
ContainerOpenContext context = ((AEBaseContainer)cont).getOpenContext();
ContainerOpenContext context = ((AEBaseContainer) cont).getOpenContext();
if (context == null) {
return null;
}
@@ -59,9 +58,13 @@ public class CPacketSwitchGuis implements IMessage {
if (te == null) {
return null;
}
InventoryHandler.openGui(player, player.worldObj, new BlockPos(te), Objects.requireNonNull(Util.from(context.getSide())), message.guiType);
InventoryHandler.openGui(
player,
player.worldObj,
new BlockPos(te),
Objects.requireNonNull(Util.from(context.getSide())),
message.guiType);
return null;
}
}
}
@@ -10,25 +10,23 @@ 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 io.netty.buffer.ByteBuf;
import java.util.LinkedList;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable;
import java.util.LinkedList;
import java.util.List;
public class CPacketTransferRecipe implements IMessage {
private List<OrderStack<?>> inputs;
private List<OrderStack<?>> outputs;
private boolean isCraft;
private final static int MAX_INDEX = 32;
private static final int MAX_INDEX = 32;
public CPacketTransferRecipe(){
}
public CPacketTransferRecipe() {}
public CPacketTransferRecipe(List<OrderStack<?>> IN, List<OrderStack<?>> OUT, boolean craft) {
this.inputs = IN;
@@ -36,8 +34,8 @@ public class CPacketTransferRecipe implements IMessage {
this.isCraft = craft;
}
//I should use GZIP to compress the message, but i'm too lazy.
//NBT to ByteBuf has a compress stream
// I should use GZIP to compress the message, but i'm too lazy.
// NBT to ByteBuf has a compress stream
@Override
public void toBytes(ByteBuf buf) {
buf.writeBoolean(isCraft);
@@ -63,11 +61,11 @@ public class CPacketTransferRecipe implements IMessage {
NBTTagCompound nbt_m = ByteBufUtils.readTag(buf);
NBTTagCompound nbt_i = nbt_m.getCompoundTag("i");
NBTTagCompound nbt_o = nbt_m.getCompoundTag("o");
for (int i = 0; i < MAX_INDEX; i ++) {
for (int i = 0; i < MAX_INDEX; i++) {
OrderStack<?> tmp = OrderStack.readFromNBT(nbt_i, null, i);
if (tmp != null) inputs.add(tmp);
}
for (int i = 0; i < MAX_INDEX; i ++) {
for (int i = 0; i < MAX_INDEX; i++) {
OrderStack<?> tmp = OrderStack.readFromNBT(nbt_o, null, i);
if (tmp != null) outputs.add(tmp);
}
@@ -85,10 +83,10 @@ public class CPacketTransferRecipe implements IMessage {
cf.getPatternTerminal().setCraftingRecipe(message.isCraft);
IInventory inputSlot = cf.getInventoryByName("crafting");
IInventory outputSlot = cf.getInventoryByName("output");
for (int i = 0; i < inputSlot.getSizeInventory(); i ++) {
for (int i = 0; i < inputSlot.getSizeInventory(); i++) {
inputSlot.setInventorySlotContents(i, null);
}
for (int i = 0; i < outputSlot.getSizeInventory(); i ++) {
for (int i = 0; i < outputSlot.getSizeInventory(); i++) {
outputSlot.setInventorySlotContents(i, null);
}
@@ -107,13 +105,10 @@ public class CPacketTransferRecipe implements IMessage {
ItemStack stack1;
if (stack.getStack() instanceof ItemStack) {
stack1 = ((ItemStack) stack.getStack()).copy();
}
else if (stack.getStack() instanceof FluidStack) {
} else if (stack.getStack() instanceof FluidStack) {
stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack());
}
else throw new UnsupportedOperationException("Trying to get an unsupported item!");
if (index < inputSlot.getSizeInventory())
inputSlot.setInventorySlotContents(index, stack1);
} else throw new UnsupportedOperationException("Trying to get an unsupported item!");
if (index < inputSlot.getSizeInventory()) inputSlot.setInventorySlotContents(index, stack1);
}
}
for (OrderStack<?> stack : message.outputs) {
@@ -122,13 +117,10 @@ public class CPacketTransferRecipe implements IMessage {
ItemStack stack1;
if (stack.getStack() instanceof ItemStack) {
stack1 = ((ItemStack) stack.getStack()).copy();
}
else if (stack.getStack() instanceof FluidStack) {
} else if (stack.getStack() instanceof FluidStack) {
stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack());
}
else throw new UnsupportedOperationException("Trying to get an unsupported item!");
if (index < outputSlot.getSizeInventory())
outputSlot.setInventorySlotContents(index, stack1);
} else throw new UnsupportedOperationException("Trying to get an unsupported item!");
if (index < outputSlot.getSizeInventory()) outputSlot.setInventorySlotContents(index, stack1);
}
}
c.onCraftMatrixChanged(inputSlot);
@@ -138,10 +130,10 @@ public class CPacketTransferRecipe implements IMessage {
boolean combine = cf.combine;
IInventory inputSlot = cf.getInventoryByName("crafting");
IInventory outputSlot = cf.getInventoryByName("output");
for (int i = 0; i < inputSlot.getSizeInventory(); i ++) {
for (int i = 0; i < inputSlot.getSizeInventory(); i++) {
inputSlot.setInventorySlotContents(i, null);
}
for (int i = 0; i < outputSlot.getSizeInventory(); i ++) {
for (int i = 0; i < outputSlot.getSizeInventory(); i++) {
outputSlot.setInventorySlotContents(i, null);
}
@@ -158,13 +150,10 @@ public class CPacketTransferRecipe implements IMessage {
ItemStack stack1;
if (stack.getStack() instanceof ItemStack) {
stack1 = ((ItemStack) stack.getStack()).copy();
}
else if (stack.getStack() instanceof FluidStack) {
} else if (stack.getStack() instanceof FluidStack) {
stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack());
}
else throw new UnsupportedOperationException("Trying to get an unsupported item!");
if (index < inputSlot.getSizeInventory())
inputSlot.setInventorySlotContents(index, stack1);
} else throw new UnsupportedOperationException("Trying to get an unsupported item!");
if (index < inputSlot.getSizeInventory()) inputSlot.setInventorySlotContents(index, stack1);
}
}
for (OrderStack<?> stack : message.outputs) {
@@ -173,13 +162,10 @@ public class CPacketTransferRecipe implements IMessage {
ItemStack stack1;
if (stack.getStack() instanceof ItemStack) {
stack1 = ((ItemStack) stack.getStack()).copy();
}
else if (stack.getStack() instanceof FluidStack) {
} else if (stack.getStack() instanceof FluidStack) {
stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack());
}
else throw new UnsupportedOperationException("Trying to get an unsupported item!");
if (index < outputSlot.getSizeInventory())
outputSlot.setInventorySlotContents(index, stack1);
} else throw new UnsupportedOperationException("Trying to get an unsupported item!");
if (index < outputSlot.getSizeInventory()) outputSlot.setInventorySlotContents(index, stack1);
}
}
c.onCraftMatrixChanged(inputSlot);
@@ -188,5 +174,4 @@ public class CPacketTransferRecipe implements IMessage {
return null;
}
}
}
@@ -9,21 +9,19 @@ 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 io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
public class SPacketFluidUpdate implements IMessage {
private Map<Integer, IAEFluidStack> list;
private IAEItemStack itemStack;
public SPacketFluidUpdate() {
}
public SPacketFluidUpdate() {}
public SPacketFluidUpdate(Map<Integer, IAEFluidStack> data) {
this.list = data;
@@ -48,8 +46,7 @@ public class SPacketFluidUpdate implements IMessage {
for (int i = 0; i < size; i++) {
int id = buf.readInt();
boolean isNull = buf.readBoolean();
if (!isNull)
list.put(id, null);
if (!isNull) list.put(id, null);
else {
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(buf);
list.put(id, fluid);
@@ -69,8 +66,7 @@ public class SPacketFluidUpdate implements IMessage {
try {
for (Map.Entry<Integer, IAEFluidStack> fs : list.entrySet()) {
buf.writeInt(fs.getKey());
if (fs.getValue() == null)
buf.writeBoolean(false);
if (fs.getValue() == null) buf.writeBoolean(false);
else {
buf.writeBoolean(true);
fs.getValue().writeToPacket(buf);
@@ -93,19 +89,17 @@ public class SPacketFluidUpdate implements IMessage {
@Override
public IMessage onMessage(SPacketFluidUpdate message, MessageContext ctx) {
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if( gs instanceof GuiIngredientBuffer)
{
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet() ) {
( (GuiIngredientBuffer) gs ).update(e.getKey(), e.getValue());
if (gs instanceof GuiIngredientBuffer) {
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet()) {
((GuiIngredientBuffer) gs).update(e.getKey(), e.getValue());
}
} else if (gs instanceof GuiLargeIngredientBuffer) {
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet() ) {
( (GuiLargeIngredientBuffer) gs ).update(e.getKey(), e.getValue());
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet()) {
((GuiLargeIngredientBuffer) gs).update(e.getKey(), e.getValue());
}
} else if( gs instanceof GuiFluidIO)
{
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet() ) {
( (GuiFluidIO) gs ).update(e.getKey(), e.getValue());
} else if (gs instanceof GuiFluidIO) {
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet()) {
((GuiFluidIO) gs).update(e.getKey(), e.getValue());
}
} else if (gs instanceof GuiFluidInterface) {
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet()) {
@@ -120,6 +114,5 @@ public class SPacketFluidUpdate implements IMessage {
}
return null;
}
}
}
@@ -12,13 +12,12 @@ 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 io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import java.io.IOException;
import java.nio.BufferOverflowException;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
public class SPacketMEInventoryUpdate implements IMessage {
@@ -49,7 +48,7 @@ public class SPacketMEInventoryUpdate implements IMessage {
ref = buf.readByte();
list = new LinkedList<>();
try {
for (int i = 0; i < amount; i ++) {
for (int i = 0; i < amount; i++) {
if (isFluid) {
list.add(AEFluidStack.loadFluidStackFromPacket(buf));
} else {