Skip to content

Commit

Permalink
Fixed blocks getting voided when retracting after extending all the b…
Browse files Browse the repository at this point in the history
…locks in the inventory

- A few fixes to avoid using null itemstacks
  • Loading branch information
fuj1n committed Jun 12, 2018
1 parent 2d125f3 commit 0bd6285
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Expand Up @@ -23,7 +23,6 @@

public class DrawbridgeLogic extends DrawbridgeLogicBase
{

public DrawbridgeLogic ()
{
super(Util.prefix("inventory.drawbridge"), 2);
Expand All @@ -44,9 +43,9 @@ public DrawbridgeLogic ()

if (slot == 0)
{
if (item == null)
if (item.isEmpty())
{
setInventorySlotContents(1, null);
setInventorySlotContents(1, ItemStack.EMPTY);
}
else
{
Expand Down Expand Up @@ -80,7 +79,7 @@ public void subtractNextBlock ()

public void addLastBlock ()
{
if (getStackInSlot(0) != null)
if (!getStackInSlot(0).isEmpty())
{
decrStackSize(-1, -1);
}
Expand Down
Expand Up @@ -358,6 +358,11 @@ public String getName() {
return super.getName() + "." + getVariantName();
}

@Override
public boolean canEditDisguise(){
return !getExtended();
}

public abstract void setupStatistics(DrawbridgeStats ds);

public abstract boolean extendNext();
Expand Down
Expand Up @@ -45,7 +45,6 @@ public void setFire ()
world.playSound(null, loc.getX() + 0.5D, loc.getY() + 0.5D, loc.getZ() + 0.5D, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, Util.rand.nextFloat() * 0.4F + 0.8F);
world.setBlockState(position, Blocks.FIRE.getDefaultState(), 11);
}
//TODO registry for extinguishable blocks instead of hardcoded
} else if (shouldExtinguish && (state.getBlock() == Blocks.FIRE || state.getBlock() == Blocks.PORTAL))
{
world.playSound(null, loc.getX() + 0.5D, loc.getY() + 0.5D, loc.getZ() + 0.5D, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 1.0F, Util.rand.nextFloat() * 0.4F + 0.8F);
Expand Down
Expand Up @@ -26,7 +26,7 @@ public SlotDisguise (@Nonnull IDisguisable disguisable, int xPosition, int yPosi
*/
public boolean isItemValid (@Nullable ItemStack stack)
{
if (!disguise.canEditDisguise() || stack == null)
if (!disguise.canEditDisguise() || stack == null || stack.isEmpty())
{
return false;
}
Expand Down

0 comments on commit 0bd6285

Please sign in to comment.