Skip to content

Commit

Permalink
Readd rift structure breakBlock that went missing at some point (wtf?…
Browse files Browse the repository at this point in the history
…!?!). Fix interacting with the rift browser in complex situations such as with the Storage Drawers.
  • Loading branch information
gigaherz committed Apr 22, 2016
1 parent 19eb3cd commit 24d0bfa
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {

apply plugin: 'net.minecraftforge.gradle.forge'

version = "0.12.1"
version = "0.12.2"
group= "gigaherz.enderRift"
archivesBaseName = "EnderRift-1.8.9"

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/gigaherz/enderRift/blocks/BlockStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ public AxisAlignedBB getBB(int x, int y, int z, IBlockState state)
x + 16 / 16.0f, y + 16 / 16.0f, z + 16 / 16.0f);
}

@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
super.breakBlock(worldIn, pos, state);

RiftStructure.breakStructure(worldIn, pos);
}

@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
Expand Down
51 changes: 39 additions & 12 deletions src/main/java/gigaherz/enderRift/gui/ContainerBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.server.S2FPacketSetSlot;
import net.minecraft.util.IChatComponent;

import java.util.Comparator;
Expand All @@ -36,6 +37,7 @@ public class ContainerBrowser
public int scroll;
public SortMode sortMode = SortMode.StackSize;
private String filterText = "";
private ItemStack stackInCursor;

final static int Left = 8;
final static int Top = 18;
Expand Down Expand Up @@ -147,6 +149,23 @@ public void detectAndSendChanges()
}
}
}

for (ICrafting crafter : this.crafters)
{
if (!(crafter instanceof EntityPlayerMP))
continue;

EntityPlayerMP player = (EntityPlayerMP)crafter;
ItemStack newStack = player.inventory.getItemStack();

if (!ItemStack.areItemStacksEqual(stackInCursor, newStack))
{
stackInCursor = newStack == null ? null : newStack.copy();

player.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(-1, -1, newStack));
}
}

}

@Override
Expand Down Expand Up @@ -443,40 +462,48 @@ public ItemStack addToPlayer(ItemStack stack)
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)
{
Slot slot = this.inventorySlots.get(slotIndex);

if (slot == null || !slot.getHasStack())
{
return null;
}

if (slotIndex < FakeSlots)
{
// Shouldn't even happen, handled above.
return null;
}
else
{
Slot slot = this.inventorySlots.get(slotIndex);
if (slot == null || !slot.getHasStack())
{
return null;
}

IInventoryAutomation parent = tile.getAutomation();
if (parent == null)
return null;

ItemStack stack = slot.getStack();
ItemStack stackCopy = stack.copy();

ItemStack remaining = parent.pushItems(stack);

if (remaining != null)
{
if (remaining.stackSize != stack.stackSize)
tile.markDirty();
if (remaining.stackSize == stackCopy.stackSize)
{
return null;
}

tile.markDirty();
stack.stackSize = remaining.stackSize;
slot.onSlotChanged();
}
else
{
tile.markDirty();
stack.stackSize = 0;
slot.putStack(null);
}

slot.putStack(remaining);

return remaining;
slot.onPickupFromSlot(player, stack);
return stackCopy;
}
}

Expand Down

0 comments on commit 24d0bfa

Please sign in to comment.