Skip to content

Commit

Permalink
RC#2 - fixpack
Browse files Browse the repository at this point in the history
- Duplication glitch with Certus Tank
- Duplication glitch with overfilled Storage Component
- Duplication glitch with Conversion Monitor
- Duplication glitch with Fluid Export Bus
- Fixed client-side NPEs
- Fixed strange bug with Gas Conversion Monitor
- Additional containers validation to avoid some duplication glitches (not for all yet)
  • Loading branch information
aagrishankov committed Aug 5, 2020
1 parent 8439c51 commit 82ded33
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 64 deletions.
15 changes: 6 additions & 9 deletions src/main/scala/extracells/block/BlockCertusTank.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public TileEntity createNewTileEntity(World var1, int var2) {
public ItemStack getDropWithNBT(World world, int x, int y, int z) {
NBTTagCompound tileEntity = new NBTTagCompound();
TileEntity worldTE = world.getTileEntity(x, y, z);
if (worldTE != null && worldTE instanceof TileEntityCertusTank) {
if (worldTE instanceof TileEntityCertusTank) {
ItemStack dropStack = new ItemStack(
BlockEnum.CERTUSTANK.getBlock(), 1);

Expand Down Expand Up @@ -196,17 +196,14 @@ public boolean onBlockActivated(World worldObj, int x, int y, int z,

if (liquid != null) {
if (!entityplayer.capabilities.isCreativeMode) {
if (current.stackSize > 1) {
if (!entityplayer.inventory.addItemStackToInventory(filled)) {
return false;
} else {
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize -= 1;
}
} else {
if (current.stackSize == 1) {
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = filled;
} else {
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize--;
if (!entityplayer.inventory.addItemStackToInventory(filled))
entityplayer.entityDropItem(filled, 0);
}
}
tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true);
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {

@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return true;
return this.tileentity.isUseableByPlayer(entityplayer);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected void bindPlayerInventory(IInventory inventoryPlayer) {

@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return true;
return this.part.isValid();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package extracells.container;

import appeng.api.implementations.ICraftingPatternItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import extracells.api.IFluidInterface;
import extracells.container.slot.SlotRespective;
import extracells.gui.GuiFluidInterface;
Expand All @@ -19,6 +21,7 @@
public class ContainerFluidInterface extends Container implements
IContainerListener {
public IFluidInterface fluidInterface;
@SideOnly(Side.CLIENT)
public GuiFluidInterface gui;
EntityPlayer player;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {

@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return true;
return this.terminal != null && this.terminal.isValid();
}

public void forceFluidUpdate() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package extracells.container;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import extracells.gui.GuiFluidInterface;
import extracells.network.packet.part.PacketOreDictExport;
import extracells.part.PartOreDictExporter;
Expand All @@ -12,6 +13,7 @@

public class ContainerOreDictExport extends Container {
public PartOreDictExporter part;
@SideOnly(Side.CLIENT)
public GuiFluidInterface gui;
EntityPlayer player;

Expand Down Expand Up @@ -42,7 +44,7 @@ protected void bindPlayerInventory(IInventory inventoryPlayer) {

@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return true;
return this.part.isValid();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import appeng.api.implementations.guiobjects.IGuiItem;
import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.api.util.DimensionalCoord;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import extracells.container.slot.SlotNetworkTool;
import extracells.container.slot.SlotRespective;
import extracells.gui.GuiFluidPlaneFormation;
Expand All @@ -16,10 +18,14 @@

public class ContainerPlaneFormation extends Container {

private PartFluidPlaneFormation part;

@SideOnly(Side.CLIENT)
private GuiFluidPlaneFormation gui;

public ContainerPlaneFormation(PartFluidPlaneFormation part,
EntityPlayer player) {
this.part = part;
addSlotToContainer(new SlotRespective(part.getUpgradeInventory(), 0,
187, 8));
bindPlayerInventory(player.inventory);
Expand Down Expand Up @@ -58,7 +64,7 @@ protected void bindPlayerInventory(IInventory inventoryPlayer) {

@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return true;
return this.part.isValid();
}

public void setGui(GuiFluidPlaneFormation _gui) {
Expand Down
11 changes: 4 additions & 7 deletions src/main/scala/extracells/item/ItemFluidPattern.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,12 @@ public ItemFluidPattern() {

@Override
public IIcon getIcon(ItemStack itemStack, int pass) {
switch (pass) {
case 0:
if (pass == 0) {
Fluid fluid = getFluid(itemStack);
if (fluid == null)
return null;
return fluid.getIcon();
default:
return this.icon;
if (fluid != null)
return fluid.getIcon();
}
return this.icon;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/extracells/item/ItemStorageComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ItemStorageComponent() {

@Override
public int getBytes(ItemStack is) {
return this.size[is.getItemDamage()];
return this.size[MathHelper.clamp_int(is.getItemDamage(), 0, this.size.length)];
}

@Override
Expand Down
69 changes: 34 additions & 35 deletions src/main/scala/extracells/part/PartFluidConversionMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
Expand All @@ -26,9 +27,8 @@ public class PartFluidConversionMonitor extends PartFluidStorageMonitor {

@Override
public boolean onActivate(EntityPlayer player, Vec3 pos) {
boolean b = super.onActivate(player, pos);
if (b)
return b;
if (super.onActivate(player, pos))
return true;
if (player == null || player.worldObj == null)
return true;
if (player.worldObj.isRemote)
Expand All @@ -47,27 +47,27 @@ public boolean onActivate(EntityPlayer player, Vec3 pos) {
Actionable.SIMULATE, new MachineSource(this));
if (mon.canAccept(fl)
&& (not == null || not.getStackSize() == 0L)) {
mon.injectItems(fl, Actionable.MODULATE, new MachineSource(
this));

MutablePair<Integer, ItemStack> empty1 = FluidUtil
.drainStack(s2, f);
ItemStack empty = empty1.right;
if (empty != null) {
dropItems(getHost().getTile().getWorldObj(), getHost()
.getTile().xCoord + getSide().offsetX,
getHost().getTile().yCoord + getSide().offsetY,
getHost().getTile().zCoord + getSide().offsetZ,
empty);
}
ItemStack s3 = s.copy();
s3.stackSize = s3.stackSize - 1;
if (s3.stackSize == 0) {
player.inventory.setInventorySlotContents(
player.inventory.currentItem, null);
} else {
player.inventory.setInventorySlotContents(
player.inventory.currentItem, s3);
MutablePair<Integer, ItemStack> empty1 = FluidUtil.drainStack(s2, f);
int amount = empty1.getLeft();
if (amount > 0) {
f.amount = amount;
fl.setStackSize(amount);
not = mon.injectItems(fl.copy(), Actionable.SIMULATE, new MachineSource(this));
if (mon.canAccept(fl) && (not == null || not.getStackSize() == 0L)) {
mon.injectItems(fl, Actionable.MODULATE, new MachineSource(this));
ItemStack empty = empty1.right;
if (empty != null) {
TileEntity tile = this.getHost().getTile();
ForgeDirection side = this.getSide();
this.dropItems(tile.getWorldObj(), tile.xCoord + side.offsetX, tile.yCoord + side.offsetY, tile.zCoord + side.offsetZ, empty);
}
ItemStack s3 = s.copy();
s3.stackSize--;
if (s3.stackSize <= 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
else
player.inventory.setInventorySlotContents(player.inventory.currentItem, s3);
}
}
}
return true;
Expand All @@ -85,23 +85,22 @@ public boolean onActivate(EntityPlayer player, Vec3 pos) {
FluidUtil.createAEFluidStack(this.fluid),
Actionable.SIMULATE, new MachineSource(this));
if (extract != null) {
mon.extractItems(FluidUtil
.createAEFluidStack(new FluidStack(this.fluid,
(int) extract.getStackSize())),
Actionable.MODULATE, new MachineSource(this));
if (extract.getStackSize() <= 0)
return true;
extract = mon.extractItems(extract, Actionable.MODULATE, new MachineSource(this));
if (extract == null || extract.getStackSize() <= 0)
return true;

MutablePair<Integer, ItemStack> empty1 = FluidUtil
.fillStack(s2, extract.getFluidStack());
if (empty1.left == 0) {
mon.injectItems(FluidUtil
.createAEFluidStack(new FluidStack(this.fluid,
(int) extract.getStackSize())),
Actionable.MODULATE, new MachineSource(this));
mon.injectItems(extract, Actionable.MODULATE, new MachineSource(this));
return true;
}
ItemStack empty = empty1.right;
if (empty != null) {
dropItems(getHost().getTile().getWorldObj(), getHost()
.getTile().xCoord + getSide().offsetX,
.getTile().xCoord + getSide().offsetX,
getHost().getTile().yCoord + getSide().offsetY,
getHost().getTile().zCoord + getSide().offsetZ,
empty);
Expand Down Expand Up @@ -163,7 +162,7 @@ public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) {
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(int x, int y, int z, IPartRenderHelper rh,
RenderBlocks renderer) {
RenderBlocks renderer) {
Tessellator ts = Tessellator.instance;

IIcon side = TextureManager.TERMINAL_SIDE.getTexture();
Expand Down Expand Up @@ -201,4 +200,4 @@ public void renderStatic(int x, int y, int z, IPartRenderHelper rh,
renderStaticBusLights(x, y, z, rh, renderer);
}

}
}
12 changes: 8 additions & 4 deletions src/main/scala/extracells/part/PartFluidExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ public boolean doWork(int rate, int TicksSinceLastCall) {
if (fluid != null) {
IAEFluidStack stack = extractFluid(AEApi.instance().storage().createFluidStack(new FluidStack(fluid, rate * TicksSinceLastCall)), Actionable.SIMULATE);

if (stack == null)
if (stack == null || stack.getStackSize() <= 0)
continue;
int filled = facingTank.fill(getSide().getOpposite(), stack.getFluidStack(), true);
int filled = facingTank.fill(this.getSide().getOpposite(), stack.getFluidStack(), false);

if (filled > 0) {
extractFluid(AEApi.instance().storage().createFluidStack(new FluidStack(fluid, filled)), Actionable.MODULATE);
return true;
stack.setStackSize(filled);
stack = this.extractFluid(stack, Actionable.MODULATE);
if (stack != null && stack.getStackSize() > 0) {
facingTank.fill(this.getSide().getOpposite(), stack.getFluidStack(), true);
return true;
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/scala/extracells/part/PartFluidInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public boolean isItemValidForSlot(int slot, ItemStack stack) {

@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return true;
return PartFluidInterface.this.isValid();
}

@Override
Expand Down Expand Up @@ -538,6 +538,8 @@ currentPatternStack, getGridNode()
ICraftingPatternDetails p = ((ICraftingPatternItem) is
.getItem()).getPatternForItem(is, getGridNode()
.getWorld());
if (p == null)
continue;
this.patternConvert.put(p, pattern);
craftingTracker.addCraftingOption(this, p);
}
Expand Down Expand Up @@ -1033,7 +1035,7 @@ private NBTTagCompound writeOutputToNBT(NBTTagCompound tag) {
((IAEItemStack) s).getItemStack().writeToNBT(data);
} else {
((IAEFluidStack) s).getFluidStack().writeToNBT(data);
};
}
tag.setTag("add-" + i, data);
tag.setLong("add-" + i + "-amount", s.getStackSize());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ class PartGasConversionMonitor extends PartFluidConversionMonitor{
else
return true
if (extract != null) {
mon.extractItems(FluidUtil.createAEFluidStack(new FluidStack(this.fluid, extract.getStackSize.toInt)), Actionable.MODULATE, new MachineSource(this))
extract = mon.extractItems(extract, Actionable.MODULATE, new MachineSource(this))
if (extract == null || extract.getStackSize <= 0) {
return true
}
val empty1: MutablePair[Integer, ItemStack] = GasUtil.fillStack(s2, GasUtil.getGasStack(extract.getFluidStack))
if (empty1.left == 0) {
mon.injectItems(FluidUtil.createAEFluidStack(new FluidStack(this.fluid, extract.getStackSize.toInt)), Actionable.MODULATE, new MachineSource(this))
Expand Down

0 comments on commit 82ded33

Please sign in to comment.