Implemented pushing upgrade
This commit is contained in:
parent
fd2258b690
commit
fd7bed0ebb
|
@ -136,6 +136,27 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (item.equals(FunctionalStorage.PUSHING_UPGRADE.get())){
|
||||||
|
Direction direction = Direction.byName(stack.getOrCreateTag().getString("Direction"));
|
||||||
|
TileUtil.getTileEntity(level, pos.relative(direction)).ifPresent(blockEntity1 -> {
|
||||||
|
blockEntity1.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite()).ifPresent(otherHandler -> {
|
||||||
|
for (int otherSlot = 0; otherSlot < getStorage().getSlots(); otherSlot++) {
|
||||||
|
ItemStack pulledStack = getStorage().extractItem(otherSlot, 2, true);
|
||||||
|
if (pulledStack.isEmpty()) continue;
|
||||||
|
boolean hasWorked = false;
|
||||||
|
for (int ourSlot = 0; ourSlot < otherHandler.getSlots(); ourSlot++) {
|
||||||
|
ItemStack simulated = otherHandler.insertItem(ourSlot, pulledStack, true);
|
||||||
|
if (simulated.getCount() != pulledStack.getCount()){
|
||||||
|
otherHandler.insertItem(ourSlot, getStorage().extractItem(otherSlot, pulledStack.getCount() - simulated.getCount(), false), false );
|
||||||
|
hasWorked = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasWorked) break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class DrawerRenderer implements BlockEntityRenderer<DrawerTile> {
|
||||||
|
|
||||||
public static void renderUpgrades(PoseStack matrixStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn, ControllableDrawerTile<?> tile){
|
public static void renderUpgrades(PoseStack matrixStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn, ControllableDrawerTile<?> tile){
|
||||||
matrixStack.pushPose();
|
matrixStack.pushPose();
|
||||||
matrixStack.translate(0.031,0.031f,0.469/16D);
|
matrixStack.translate(0.031,0.031f,0.472/16D);
|
||||||
float scale = 0.0625f;
|
float scale = 0.0625f;
|
||||||
for (int i = 0; i < tile.getStorageUpgrades().getSlots(); i++) {
|
for (int i = 0; i < tile.getStorageUpgrades().getSlots(); i++) {
|
||||||
ItemStack stack = tile.getStorageUpgrades().getStackInSlot(i);
|
ItemStack stack = tile.getStorageUpgrades().getStackInSlot(i);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user